feat(agent-manager): attach focused terminal context - #13230
Conversation
| : context === "local" | ||
| ? SessionTerminalManager.LOCAL_KEY | ||
| : SessionTerminalManager.worktreeKey(context) | ||
| if (sessionId && this.showExisting(sessionId, false)) return true |
There was a problem hiding this comment.
[WARNING]: Session-keyed reveal runs first and steals prompt focus
showExisting(sessionId, false) returns as soon as this session has any live mapped VS Code terminal, so agentManagerContext is never consulted. A focused worktree, local, or Run terminal is ignored and getTerminalContents copies the session terminal instead.
preserveFocus=false also calls Terminal.show(false), which moves keyboard focus into the terminal panel. The previous default (true) still selected the terminal for selectAll/copySelection without leaving the Agent Manager prompt, and nothing restores focus after capture.
Consider revealing with preserveFocus=true, and only after the focused or context-keyed terminal, so @terminal matches what the user is looking at.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| const focusedTerm = side.find((term) => term.id === focused) ?? tabs.find((term) => term.id === focused) | ||
| const sideTerm = side.find((term) => term.id === terms.sideActiveFor(key)) | ||
| const tab = tabs.find((term) => term.id === terms.activeId()) | ||
| const id = focusedTerm?.id ?? sideTerm?.id |
There was a problem hiding this comment.
[SUGGESTION]: Hidden side terminals outrank the visible tab terminal
When nothing is focused, sideTerm wins over tab even if the side panel is closed. terminalVisible() already exists in this file and the cycle helper treats a visible unfocused side terminal as the target. Without that check, @terminal from the prompt can attach a background Run/Setup buffer instead of the tab the user is viewing.
| const id = focusedTerm?.id ?? sideTerm?.id | |
| const id = focusedTerm?.id ?? (terminalVisible() ? sideTerm?.id : undefined) |
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (17 files)
Fix these issues in Kilo Cloud Reviewed by grok-4.6 · Input: 324.2K · Output: 42.4K · Cached: 890.8K Review guidance: REVIEW.md from base branch |
Agent Manager terminal output was not available to
@terminal, even though embedded terminals, Run terminals, and Setup terminals are visible in the panel. This caused terminal questions from Agent Manager sessions to fall back to unrelated VS Code terminal state or fail to include the relevant output.@terminalnow captures the focused terminal within the active Agent Manager context, including embedded Run and Setup terminals, while preserving the existing standard VS Code terminal path for the sidebar. Terminal context routing is explicit, output limits use the shared truncation helper, and the focused-terminal behavior is covered by unit and end-to-end validation.