Skip to content

feat(agent-manager): attach focused terminal context - #13230

Merged
marius-kilocode merged 3 commits into
mainfrom
marvelous-albatross
Aug 19, 2026
Merged

feat(agent-manager): attach focused terminal context#13230
marius-kilocode merged 3 commits into
mainfrom
marvelous-albatross

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

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.

@terminal now 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.

@marius-kilocode
marius-kilocode merged commit e7124b1 into main Aug 19, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the marvelous-albatross branch August 19, 2026 10:58
: context === "local"
? SessionTerminalManager.LOCAL_KEY
: SessionTerminalManager.worktreeKey(context)
if (sessionId && this.showExisting(sessionId, false)) return true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Suggested change
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.

@kilo-code-bot

kilo-code-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
packages/kilo-vscode/src/agent-manager/SessionTerminalManager.ts 221 Session-keyed reveal runs first and steals prompt focus

SUGGESTION

File Line Issue
packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx 384 Hidden side terminals outrank the visible tab terminal
Files Reviewed (17 files)
  • .changeset/agent-manager-terminal-context.md - 0 issues
  • packages/kilo-vscode/src/KiloProvider.ts - 0 issues
  • packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts - 0 issues
  • packages/kilo-vscode/src/agent-manager/SessionTerminalManager.ts - 1 issue
  • packages/kilo-vscode/src/agent-manager/types.ts - 0 issues
  • packages/kilo-vscode/tests/unit/agent-manager-arch.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/agent-manager-terminal-output.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/prompt-send-contract.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/session-terminal-manager.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/terminal-architecture.test.ts - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/agent-manager/terminal/TerminalTab.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/terminal/output.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/chat/ChatView.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/hooks/useTerminalContext.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/types/messages/webview-messages.ts - 0 issues

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 main

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