From e0aeb847135bf7b3286a342e845832af9ecefd43 Mon Sep 17 00:00:00 2001 From: marius-kilocode Date: Tue, 25 Aug 2026 16:51:48 +0200 Subject: [PATCH] fix(agent-manager): avoid stale history switch entries --- .changeset/agent-manager-history-switch-queue.md | 5 +++++ .../webview-ui/agent-manager/AgentManagerApp.tsx | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/agent-manager-history-switch-queue.md diff --git a/.changeset/agent-manager-history-switch-queue.md b/.changeset/agent-manager-history-switch-queue.md new file mode 100644 index 00000000000..9cfd32747aa --- /dev/null +++ b/.changeset/agent-manager-history-switch-queue.md @@ -0,0 +1,5 @@ +--- +"kilo-code": patch +--- + +Prevent overlapping Agent Manager history activations from leaving stale project-switch state. diff --git a/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx b/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx index e61dcee4c45..f5a772c667d 100644 --- a/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx +++ b/packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx @@ -307,12 +307,12 @@ const AgentManagerContent: Component = () => { } const openHistory = (pid?: string) => { const scoped = pid !== undefined && multiProject() - if (scoped) setHistorySwitches((prev) => (prev.includes(pid) ? prev : [...prev, pid])) + if (scoped && (currentProjectId() !== pid || historySwitches().length > 0)) + setHistorySwitches((prev) => (prev.includes(pid) ? prev : [...prev, pid])) setHistoryProject(scoped ? pid : undefined) setHistory(true) if (scoped) { - // Activating the target project first lets the shared session store and - // the pick routing operate in that project only. + // Activate the target so the session store and pick routing use that project. vscode.postMessage({ type: "agentManager.activateSelection", target: { projectId: pid, kind: "local" },