From 54534bd64162172322ba3785a6970ac3d94ccbf3 Mon Sep 17 00:00:00 2001 From: Josh Lambert Date: Fri, 5 Jun 2026 10:24:18 -0400 Subject: [PATCH 1/2] fix(vscode): preserve sidebar on window reload --- .changeset/steady-sidebar-reload.md | 5 ++++ packages/kilo-vscode/src/KiloProvider.ts | 1 - packages/kilo-vscode/src/extension.ts | 8 +------ .../kilo-vscode/src/kilo-provider/options.ts | 1 - .../tests/unit/extension-arch.test.ts | 23 +++++++++++++++++++ 5 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 .changeset/steady-sidebar-reload.md diff --git a/.changeset/steady-sidebar-reload.md b/.changeset/steady-sidebar-reload.md new file mode 100644 index 00000000000..5617e44ee8a --- /dev/null +++ b/.changeset/steady-sidebar-reload.md @@ -0,0 +1,5 @@ +--- +"kilo-code": patch +--- + +Keep the Explorer and other primary sidebar views open when VS Code reloads while Kilo Code is hidden. diff --git a/packages/kilo-vscode/src/KiloProvider.ts b/packages/kilo-vscode/src/KiloProvider.ts index 58b3d11b3ee..353724d1103 100644 --- a/packages/kilo-vscode/src/KiloProvider.ts +++ b/packages/kilo-vscode/src/KiloProvider.ts @@ -500,7 +500,6 @@ export class KiloProvider implements vscode.WebviewViewProvider, TelemetryProper private setSidebarVisible(visible: boolean): void { this.setStreamVisibility(visible) vscode.commands.executeCommand("setContext", "kilo-code.new.sidebarVisible", visible) - this.opts.onSidebarVisibilityChange?.(visible) } /** Resolve a WebviewPanel for displaying Kilo in an editor tab. */ diff --git a/packages/kilo-vscode/src/extension.ts b/packages/kilo-vscode/src/extension.ts index 63e75d9e3d0..2d956ed825e 100644 --- a/packages/kilo-vscode/src/extension.ts +++ b/packages/kilo-vscode/src/extension.ts @@ -29,7 +29,6 @@ let shuttingDown = false const RESTORE_KEY = "kilo.workbench.restore" type RestoreState = { - sidebar?: boolean agentManager?: boolean } @@ -50,10 +49,8 @@ export function activate(context: vscode.ExtensionContext) { // Create shared connection service (one server for all webviews) const connectionService = new KiloConnectionService(context) let restore = context.workspaceState.get(RESTORE_KEY) ?? {} - const closeSidebar = restore.sidebar === false const remember = (patch: RestoreState) => { const next = { ...restore, ...patch } - if (shuttingDown && patch.sidebar === false) next.sidebar = restore.sidebar if (shuttingDown && patch.agentManager === false) next.agentManager = restore.agentManager restore = next void context.workspaceState.update(RESTORE_KEY, restore) @@ -124,9 +121,7 @@ export function activate(context: vscode.ExtensionContext) { } // Create the provider with shared service - const provider = new KiloProvider(context.extensionUri, connectionService, context, { - onSidebarVisibilityChange: (visible) => remember({ sidebar: visible }), - }) + const provider = new KiloProvider(context.extensionUri, connectionService, context) provider.setRemoteService(remoteService) // Register the webview view provider for the sidebar. @@ -136,7 +131,6 @@ export function activate(context: vscode.ExtensionContext) { webviewOptions: { retainContextWhenHidden: true }, }), ) - if (closeSidebar) void vscode.commands.executeCommand("workbench.action.closeSidebar") // Ensure Agent Manager navigation keybindings work when a VS Code terminal has focus. // The terminal intercepts all keystrokes unless the command is listed in diff --git a/packages/kilo-vscode/src/kilo-provider/options.ts b/packages/kilo-vscode/src/kilo-provider/options.ts index e8f747ff8f2..32f5d3793ce 100644 --- a/packages/kilo-vscode/src/kilo-provider/options.ts +++ b/packages/kilo-vscode/src/kilo-provider/options.ts @@ -4,6 +4,5 @@ export type KiloProviderOptions = { snapshotInitialization?: "wait" slimEditMetadata?: boolean tabTitle?: (title: string) => void - onSidebarVisibilityChange?: (visible: boolean) => void worktreeDirectories?: () => string[] } diff --git a/packages/kilo-vscode/tests/unit/extension-arch.test.ts b/packages/kilo-vscode/tests/unit/extension-arch.test.ts index 174989a2611..7cd7fc75888 100644 --- a/packages/kilo-vscode/tests/unit/extension-arch.test.ts +++ b/packages/kilo-vscode/tests/unit/extension-arch.test.ts @@ -16,6 +16,7 @@ const PKG_JSON_FILE = path.join(ROOT, "package.json") const SRC_DIR = path.join(ROOT, "src") const EXTENSION_FILE = path.join(ROOT, "src/extension.ts") const KILO_PROVIDER_FILE = path.join(ROOT, "src/KiloProvider.ts") +const KILO_PROVIDER_OPTIONS_FILE = path.join(ROOT, "src/kilo-provider/options.ts") function sliceBlock(source: string, start: number): string { const open = source.indexOf("{", start) @@ -105,6 +106,28 @@ describe("Extension — package.json command sync", () => { }) }) +describe("Extension — sidebar visibility", () => { + const ext = fs.readFileSync(EXTENSION_FILE, "utf-8") + const provider = fs.readFileSync(KILO_PROVIDER_FILE, "utf-8") + const options = fs.readFileSync(KILO_PROVIDER_OPTIONS_FILE, "utf-8") + + it("does not close or track the primary sidebar during workbench restore", () => { + const restore = ext.indexOf("type RestoreState") + expect(restore, "RestoreState must exist for Agent Manager restoration").toBeGreaterThan(-1) + + expect(ext).not.toContain("workbench.action.closeSidebar") + expect(ext).not.toContain("onSidebarVisibilityChange") + expect(sliceBlock(ext, restore)).not.toContain("sidebar") + expect(provider).not.toContain("onSidebarVisibilityChange") + expect(options).not.toContain("onSidebarVisibilityChange") + }) + + it("keeps live Kilo sidebar visibility handling", () => { + expect(provider).toContain("this.setStreamVisibility(visible)") + expect(provider).toContain('vscode.commands.executeCommand("setContext", "kilo-code.new.sidebarVisible", visible)') + }) +}) + // --------------------------------------------------------------------------- // KiloProvider handler wiring — every new KiloProvider() must get // setContinueInWorktreeHandler() called before resolving its webview. From ca5c4d9a9121216c103fe501c3110683895a90ad Mon Sep 17 00:00:00 2001 From: Josh Lambert Date: Fri, 5 Jun 2026 10:27:45 -0400 Subject: [PATCH 2/2] test(vscode): remove sidebar reload regression guard --- .../tests/unit/extension-arch.test.ts | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/packages/kilo-vscode/tests/unit/extension-arch.test.ts b/packages/kilo-vscode/tests/unit/extension-arch.test.ts index 7cd7fc75888..174989a2611 100644 --- a/packages/kilo-vscode/tests/unit/extension-arch.test.ts +++ b/packages/kilo-vscode/tests/unit/extension-arch.test.ts @@ -16,7 +16,6 @@ const PKG_JSON_FILE = path.join(ROOT, "package.json") const SRC_DIR = path.join(ROOT, "src") const EXTENSION_FILE = path.join(ROOT, "src/extension.ts") const KILO_PROVIDER_FILE = path.join(ROOT, "src/KiloProvider.ts") -const KILO_PROVIDER_OPTIONS_FILE = path.join(ROOT, "src/kilo-provider/options.ts") function sliceBlock(source: string, start: number): string { const open = source.indexOf("{", start) @@ -106,28 +105,6 @@ describe("Extension — package.json command sync", () => { }) }) -describe("Extension — sidebar visibility", () => { - const ext = fs.readFileSync(EXTENSION_FILE, "utf-8") - const provider = fs.readFileSync(KILO_PROVIDER_FILE, "utf-8") - const options = fs.readFileSync(KILO_PROVIDER_OPTIONS_FILE, "utf-8") - - it("does not close or track the primary sidebar during workbench restore", () => { - const restore = ext.indexOf("type RestoreState") - expect(restore, "RestoreState must exist for Agent Manager restoration").toBeGreaterThan(-1) - - expect(ext).not.toContain("workbench.action.closeSidebar") - expect(ext).not.toContain("onSidebarVisibilityChange") - expect(sliceBlock(ext, restore)).not.toContain("sidebar") - expect(provider).not.toContain("onSidebarVisibilityChange") - expect(options).not.toContain("onSidebarVisibilityChange") - }) - - it("keeps live Kilo sidebar visibility handling", () => { - expect(provider).toContain("this.setStreamVisibility(visible)") - expect(provider).toContain('vscode.commands.executeCommand("setContext", "kilo-code.new.sidebarVisible", visible)') - }) -}) - // --------------------------------------------------------------------------- // KiloProvider handler wiring — every new KiloProvider() must get // setContinueInWorktreeHandler() called before resolving its webview.