From a2e2f1c43eaa205e162512d6c65327254213027b Mon Sep 17 00:00:00 2001 From: kate bonner Date: Thu, 9 Jul 2026 06:32:51 +0000 Subject: [PATCH 1/2] fix(inspector): default amicode.inspector.autoOpen to false MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Run Inspector auto-launches on every solve today because the contributed setting default is `true`, while the code (autoOpenEnabled(), run_inspector.ts) and its comments assume `false`. VS Code returns the contributed package.json default, not the code fallback, so the panel steals focus whenever a solve starts. Flip the contributed default to false so the inspector no longer auto-launches; it stays reachable on demand via the status-bar item and the "Amicode: Open Run Inspector" command (and, once the opencode-side button lands, the in-chat "Inspect Run" button). No src changes — every auto-reveal path is already gated on autoOpenEnabled(). Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/extension/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/extension/package.json b/packages/extension/package.json index 49650edf4..f19fef68e 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -114,8 +114,8 @@ "properties": { "amicode.inspector.autoOpen": { "type": "boolean", - "default": true, - "description": "Automatically reveal the Run Inspector panel when a solve starts (default on). Turn off if a starting solve stealing focus bothers you." + "default": false, + "description": "Automatically reveal the Run Inspector panel when a solve starts (default off, so a starting solve never steals focus). Leave off to open it on demand — the status-bar item or the \"Amicode: Open Run Inspector\" command. Turn on to have a starting solve reveal the panel automatically." }, "amicode.opencodeBinary": { "type": "string", From 0a7e9cec14a658019d7b14c7a98a66350d4e8be7 Mon Sep 17 00:00:00 2001 From: kate bonner Date: Thu, 9 Jul 2026 14:39:58 +0000 Subject: [PATCH 2/2] fix(inspector): gate the Run Inspector view so it only ever opens on button press MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The autoOpen default flip stops the extension from auto-revealing on solve start, but VS Code independently restores webview panels that were open in a prior session — so the Run Inspector still reappeared on window load, regardless of the setting. Gate the `amicode.runInspector` view behind a `when: amicode.inspectorRevealed` context key. That key starts false on every window load and is never persisted, so VS Code has no visible view to restore — the panel can't come back on its own. Route every reveal path (open command, run picker, demo replay, and the opted-in autoOpen auto-reveal) through a single revealInspector() that flips the key on, then focuses. The inspector now materializes only on a deliberate open and never via VS Code's view-state restoration. Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/extension/package.json | 3 ++- packages/extension/src/extension.ts | 8 ++++---- packages/extension/src/run_inspector.ts | 20 ++++++++++++++++++-- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/packages/extension/package.json b/packages/extension/package.json index f19fef68e..9a0349a3c 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -63,7 +63,8 @@ { "id": "amicode.runInspector", "name": "Run Inspector", - "type": "webview" + "type": "webview", + "when": "amicode.inspectorRevealed" } ] }, diff --git a/packages/extension/src/extension.ts b/packages/extension/src/extension.ts index f95e2a2a4..41fbf2be1 100644 --- a/packages/extension/src/extension.ts +++ b/packages/extension/src/extension.ts @@ -5,7 +5,7 @@ import { ServerManager } from "./server_manager"; import { fetchProviderSignal } from "./llm_creds.mjs"; import { resolveOpencodeBinary, OpencodeMissingError } from "./opencode_binary"; import { ChatPanel } from "./chat_panel"; -import { registerRunInspector } from "./run_inspector"; +import { registerRunInspector, revealInspector } from "./run_inspector"; import { registerCatalogCard } from "./catalog_card_shell"; import { registerTrees } from "./trees"; import { StatusBarManager } from "./status_bar"; @@ -316,7 +316,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise { ChatPanel.openOrReveal(ctx, readyUrl); }), vscode.commands.registerCommand("amicode.openInspector", async () => { - await vscode.commands.executeCommand("amicode.runInspector.focus"); + await revealInspector(); }), // Run picker (pre-UX4 utility): switch the inspector between tracked runs. // Picking pins the selection (a background solve won't steal the view); @@ -358,7 +358,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise { if (!pick) return; if (pick.follow) runsManager?.resumeAutoFollow(); else if (pick.runId) runsManager?.selectRun(pick.runId); - await vscode.commands.executeCommand("amicode.runInspector.focus"); + await revealInspector(); }), vscode.commands.registerCommand("amicode.stopRun", async () => { const dir = runsManager?.getActiveRunDir(); @@ -503,7 +503,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise { runsManager?.pokeDiscovery(); runsManager?.selectRun(path.basename(runDir)); runsChannel.appendLine(`[demo] replayed → ${runDir}`); - await vscode.commands.executeCommand("amicode.runInspector.focus"); + await revealInspector(); // Save-to-catalog prompt (#47): the watcher suppresses the promote // prompt for runs already finished at switch (anti-re-pop), so the // explicit replay owns its own prompt → the catalog card. diff --git a/packages/extension/src/run_inspector.ts b/packages/extension/src/run_inspector.ts index 91495f5b5..84418d1c0 100644 --- a/packages/extension/src/run_inspector.ts +++ b/packages/extension/src/run_inspector.ts @@ -159,7 +159,7 @@ class InspectorView implements vscode.WebviewViewProvider { // Buffered in the pane regardless (shows when the user opens the panel); // only steal focus when the auto-open setting is enabled (his UX gate). if (autoOpenEnabled()) { - vscode.commands.executeCommand("amicode.runInspector.focus").then(undefined, () => undefined); + void revealInspector(); } return; } @@ -226,7 +226,7 @@ class InspectorView implements vscode.WebviewViewProvider { // default so a starting solve never steals focus; the status-bar item and // the explicit open command (which bypasses reveal) remain available. if (!autoOpenEnabled()) return; - vscode.commands.executeCommand("amicode.runInspector.focus").then(undefined, () => undefined); + void revealInspector(); } // -------- internal -------- @@ -279,6 +279,22 @@ export function autoOpenEnabled(): boolean { return vscode.workspace.getConfiguration("amicode").get("inspector.autoOpen", false); } +/** Context key gating the Run Inspector view (package.json `when`). It starts + * false on every window load and is NOT persisted, so VS Code never restores + * the panel on its own — the view only materializes once a reveal path flips + * it. That is what makes the inspector strictly button-press-only. */ +export const INSPECTOR_CONTEXT_KEY = "amicode.inspectorRevealed"; + +/** The one way the Run Inspector is ever shown: flip the gate context key on + * (so the gated view is allowed to appear), then focus it. Every reveal path — + * the open command, the run picker, demo replay, and the opted-in auto-reveal — + * funnels through here, so the panel is only ever shown deliberately and never + * by VS Code's own view-state restoration. */ +export async function revealInspector(): Promise { + await vscode.commands.executeCommand("setContext", INSPECTOR_CONTEXT_KEY, true); + await vscode.commands.executeCommand("amicode.runInspector.focus"); +} + function newNonce(): string { let s = ""; const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";