Repository navigation
fix(agent-manager): keep only the target tab on Close Others - #14127
Merged
Merged
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
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)
Previous review (commit 7bbba88)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Fix these issues in Kilo Cloud Files Reviewed (7 files)
Reviewed by deepseek-v4.1-flash · Input: 33.4K · Output: 7.7K · Cached: 212.6K Review guidance: REVIEW.md from base branch |
marius-kilocode
enabled auto-merge
September 14, 2026 15:58
eshurakov
approved these changes
Sep 15, 2026
This was referenced Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
handleCloseTabremoves the session fromlocalSessionIDsimmediately and postscloseSessionto the host. Each hostagentManager.statepush re-runsrestoreTrackedTabs, 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.closeOthersclosed 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 survivescloseTerminalwas 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.closeOthersmoved toclose-others.tsand 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
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 intests/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, andagent-manager-archpass.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.