Skip to content

fix(agent-manager): keep only the target tab on Close Others - #14127

Merged
marius-kilocode merged 3 commits into
mainfrom
sugary-satellite
Sep 15, 2026
Merged

marius-kilocode merged 3 commits into
mainfrom
sugary-satellite

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

In the Agent Manager tab bar, right-clicking a tab and choosing Close Others did not reliably leave only the target tab open. For local (non-worktree) sessions, closed tabs reappeared and stayed, so several tabs remained. In other cases the target tab was not the visible one because a surviving terminal stayed in front of it.

Why This Change Was Made

Two defects combined:

  1. Host pushes resurrected optimistically closed local tabs. handleCloseTab removes the session from localSessionIDs immediately and posts closeSession to the host. Each host agentManager.state push re-runs restoreTrackedTabs, which re-added every local id from the host inventory that was missing locally and never evicted ids that had left the inventory. With several closes in flight, the host still listed not-yet-removed sessions in an intermediate push, so they were restored, and later pushes kept them.
  2. closeOthers closed the others before revealing the target. Closing the previously active tab pulled selection onto a neighbor that was itself about to close, and a script terminal that survives closeTerminal was never deactivated, so it stayed in front of the session target.

The fix tracks local session ids the user just closed (closedLocals) and filters them out of the host inventory restore until the host drops them, and clears the entry when the session is opened again. closeOthers moved to close-others.ts and now reveals the target first (activate a terminal target, or deactivate the terminal and select a session target) before closing a snapshot of the other ids.

User Impact

Close Others now leaves only the chosen tab open and visible, for local sessions, worktree sessions, terminal tabs, and the review tab.

Evidence

  • New tests/unit/close-others.test.ts (7 cases: active and non-active target, terminal target, review among others, pending among others, neighbor steal, surviving script terminal) and 2 regression cases in tests/unit/local-tabs.test.ts. All 9 cases fail before the fix and pass after.
  • bun test tests/unit/close-others.test.ts tests/unit/local-tabs.test.ts: 47 pass, 0 fail.
  • bun run test:unit: 5667 pass, 2 skip, 0 fail. typecheck, lint, knip, and agent-manager-arch pass.
  • Isolated VS Code: Close Others on a worktree session with an active terminal left only the target and cleared the terminal; Close Others on a terminal target left only that terminal.

Limitation

The isolated harness could create only one real local session, so the 3+ real local session concurrent-close path is covered by unit tests and code analysis rather than an end-to-end UI run.

@kilo-code-bot

kilo-code-bot Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • packages/kilo-vscode/tests/unit/local-tabs.test.ts
Previous Review Summaries (2 snapshots, latest commit ff8b3e9)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit ff8b3e9)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • packages/kilo-vscode/tests/unit/close-others.test.ts
  • packages/kilo-vscode/tests/unit/local-tabs.test.ts
  • packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx
  • packages/kilo-vscode/webview-ui/agent-manager/close-others.ts
  • packages/kilo-vscode/webview-ui/src/utils/local-tabs.ts

Previous review (commit 7bbba88)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 2
Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx 1198 closedLocals is panel-global but pruned against the active project's sessions, so switching projects can drop suppression and a deferred stale push can resurrect a closed tab (multi-project flag only).

SUGGESTION

File Line Issue
packages/kilo-vscode/webview-ui/agent-manager/close-others.ts 30 A review-tab target falls through to selectSessionTab, marking the review id as a session. Unreachable today, but the exported utility is inconsistent.
packages/kilo-vscode/webview-ui/src/utils/local-tabs.ts 172 closed only filters inventory.local; current/evict can still carry a closed id, so the function does not enforce its own "never resurrect" comment.

Fix these issues in Kilo Cloud

Files Reviewed (7 files)
  • .changeset/close-others-local-tabs.md - 0 issues
  • packages/kilo-vscode/tests/unit/close-others.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/local-tabs.test.ts - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/agent-manager/close-others.ts - 1 issue
  • packages/kilo-vscode/webview-ui/agent-manager/tab-rendering.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/utils/local-tabs.ts - 1 issue

Reviewed by deepseek-v4.1-flash · Input: 33.4K · Output: 7.7K · Cached: 212.6K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit aa51594 into main Sep 15, 2026
25 checks passed
@marius-kilocode
marius-kilocode deleted the sugary-satellite branch September 15, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants