fix(vscode): skip posting toggleChatSearch when target webview is not ready

This commit is contained in:
Sylwester Liljegren
2026-07-15 04:07:55 +02:00
parent b706b4d3b7
commit a4d15a58d5
2 changed files with 19 additions and 1 deletions
@@ -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" })
}),
)
@@ -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([])
})
})