Avoid system identity reads and remove config opener

This commit is contained in:
murashit 2026-05-13 08:57:16 +09:00
parent 34a3f9ffcb
commit 5a9484f989
6 changed files with 3 additions and 47 deletions

View file

@ -6,7 +6,7 @@ const watch = process.argv.includes("--watch");
const context = await esbuild.context({
entryPoints: ["src/main.ts"],
bundle: true,
external: ["obsidian", "electron"],
external: ["obsidian"],
format: "cjs",
platform: "node",
target: "es2022",

View file

@ -36,7 +36,6 @@ export class StdioAppServerTransport implements AppServerTransport {
this.process = spawn(this.codexPath, ["app-server"], {
cwd: this.cwd,
stdio: ["pipe", "pipe", "pipe"],
env: process.env,
});
this.process.once("error", (error) => {

5
src/electron.d.ts vendored
View file

@ -1,5 +0,0 @@
declare module "electron" {
export const shell: {
openPath(path: string): Promise<string>;
};
}

View file

@ -1,6 +1,4 @@
import { ItemView, MarkdownRenderer, Notice, Platform, Plugin, TFile, type WorkspaceLeaf } from "obsidian";
import { existsSync } from "fs";
import { join } from "path";
import { ItemView, MarkdownRenderer, Notice, Plugin, TFile, type WorkspaceLeaf } from "obsidian";
import type { AppServerClient } from "./app-server/client";
import { ConnectionManager, StaleConnectionError } from "./app-server/connection-manager";
@ -57,7 +55,6 @@ import { CodexPanelSettingTab } from "./settings-tab";
import { clearActiveThreadState, clearConnectionScopedState, createPanelState, type PanelState } from "./state/panel-state";
import { userInputDraftKey, userInputOtherDraftKey } from "./panel/request-state";
import { getThreadTitle } from "./threads";
import { errorMessage } from "./utils";
import { questionDefaultAnswer, type PendingUserInput } from "./user-input/model";
import {
renderComposerShell,
@ -661,7 +658,6 @@ class CodexPanelView extends ItemView {
toggleFast: () => this.toggleFastMode(),
toggleRuntime: () => this.toggleRuntimePicker("model"),
connect: () => void this.reconnectFromToolbar(),
openCodexConfigFolder: () => void this.openCodexConfigFolder(),
refreshThreads: () => {
this.state.openDetails.delete("status-panel");
void this.refreshThreads();
@ -680,30 +676,6 @@ class CodexPanelView extends ItemView {
});
}
private async openCodexConfigFolder(): Promise<void> {
if (!Platform.isDesktopApp) {
new Notice("Opening .codex requires Obsidian desktop.");
return;
}
try {
const { shell } = await import("electron");
if (!shell) throw new Error("Electron shell is not available.");
const vaultCodexPath = join(this.plugin.vaultPath, ".codex");
const targetPath = existsSync(vaultCodexPath)
? vaultCodexPath
: (this.state.initializeResponse?.codexHome ?? join(process.env.HOME ?? "", ".codex"));
const message = await shell.openPath(targetPath);
if (message) throw new Error(message);
if (targetPath !== vaultCodexPath) {
new Notice("Vault .codex folder not found. Opened Codex home instead.");
}
} catch (error) {
new Notice(`Could not open Codex config folder: ${errorMessage(error)}`);
}
}
private toolbarViewModel(): ToolbarViewModel {
const snapshot = this.runtimeSnapshot();
const config = configRecord(this.state.effectiveConfig);

View file

@ -65,7 +65,6 @@ export interface ToolbarActions {
toggleFast: () => void;
toggleRuntime: () => void;
connect: () => void;
openCodexConfigFolder: () => void;
refreshThreads: () => void;
resumeThread: (threadId: string) => void;
archiveThread: (threadId: string) => void;
@ -220,10 +219,6 @@ function renderStatusPanel(parent: HTMLElement, model: ToolbarViewModel, actions
onClick: actions.refreshThreads,
className: "codex-panel__status-panel-item",
});
createToolbarPanelItem(statusItems, "Open Codex config folder", {
onClick: actions.openCodexConfigFolder,
className: "codex-panel__status-panel-item",
});
renderRateLimitPanel(parent, model.rateLimit);
renderConnectionDiagnostics(parent, model.diagnostics);
renderEffectiveConfig(parent, model.configSections);

View file

@ -781,7 +781,6 @@ describe("view renderers", () => {
it("renders connection diagnostics in the status menu", () => {
const parent = document.createElement("div");
const openCodexConfigFolder = vi.fn();
renderToolbar(
parent,
@ -793,12 +792,9 @@ describe("view renderers", () => {
{ label: "compatibility", value: "model/list failed", level: "error" },
],
}),
toolbarActions({ openCodexConfigFolder }),
toolbarActions(),
);
parent.querySelectorAll<HTMLButtonElement>(".codex-panel__status-panel-item")[2]?.click();
expect(openCodexConfigFolder).toHaveBeenCalled();
expect(parent.textContent).toContain("Open Codex config folder");
expect(parent.querySelector(".codex-panel__connection-diagnostics-title")?.textContent).toBe("Connection diagnostics");
expect(parent.textContent).toContain("Effective Codex config");
expect(parent.textContent).toContain("codex-cli/1.2.3");
@ -1139,7 +1135,6 @@ function toolbarActions(overrides: Partial<Parameters<typeof renderToolbar>[2]>
toggleFast: vi.fn(),
toggleRuntime: vi.fn(),
connect: vi.fn(),
openCodexConfigFolder: vi.fn(),
refreshThreads: vi.fn(),
resumeThread: vi.fn(),
archiveThread: vi.fn(),