diff --git a/packages/kilo-vscode/src/services/code-actions/register-code-actions.ts b/packages/kilo-vscode/src/services/code-actions/register-code-actions.ts index e7417e1116..e0b9a77a89 100644 --- a/packages/kilo-vscode/src/services/code-actions/register-code-actions.ts +++ b/packages/kilo-vscode/src/services/code-actions/register-code-actions.ts @@ -111,7 +111,7 @@ export function registerCodeActions( // webview closes the search bar itself if it's already open. vscode.commands.registerCommand("kilo-code.new.toggleChatSearch", async () => { const view = target() - await revealTarget(view) + if (!(await revealTarget(view))) return view.postMessage({ type: "action", action: "focusSearch" }) }), ) diff --git a/packages/kilo-vscode/tests/unit/register-code-actions.test.ts b/packages/kilo-vscode/tests/unit/register-code-actions.test.ts index cc5c812daa..8ae2765256 100644 --- a/packages/kilo-vscode/tests/unit/register-code-actions.test.ts +++ b/packages/kilo-vscode/tests/unit/register-code-actions.test.ts @@ -127,4 +127,22 @@ describe("registerCodeActions", () => { expect(state.events).toEqual(["wait"]) expect(state.posts).toEqual([]) }) + + it("toggles chat search on the active Agent Manager once it is ready", async () => { + const state = setup(true) + + await state.commands.get("kilo-code.new.toggleChatSearch")?.() + + expect(state.events).toEqual(["wait", "post"]) + expect(state.posts).toEqual([{ type: "action", action: "focusSearch" }]) + }) + + it("does not toggle chat search when Agent Manager readiness is cancelled", async () => { + const state = setup(true, false) + + await state.commands.get("kilo-code.new.toggleChatSearch")?.() + + expect(state.events).toEqual(["wait"]) + expect(state.posts).toEqual([]) + }) })