Skip to content

fix(agent-manager): make terminal shortcuts focus-aware - #13229

Merged
marius-kilocode merged 4 commits into
mainfrom
refactor-terminal-shortcut-logic
Aug 19, 2026
Merged

fix(agent-manager): make terminal shortcuts focus-aware#13229
marius-kilocode merged 4 commits into
mainfrom
refactor-terminal-shortcut-logic

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

Problem

Agent Manager has two terminal locations with different navigation semantics. A central terminal is part of the main session tab strip, while right-sidebar terminals are an independent terminal area. A global terminal shortcut caused Cmd/Ctrl+T and Cmd/Ctrl+Shift+T to open content in the wrong location, and returning from a terminal could show a prompt without a selected session tab.

Behavior

Focus location Cmd/Ctrl+T Cmd/Ctrl+Shift+T
Center prompt Create a new session tab Create a central terminal tab
Center terminal tab Create a new session tab Create another central terminal tab
Right-sidebar terminal Create another right-sidebar terminal tab No action

Why the behavior differs

  • The center is the session workspace. Cmd/Ctrl+T therefore creates a session when focus is anywhere in the center, including a central terminal, because the user is still working in the central session area.
  • Cmd/Ctrl+Shift+T is the explicit central-terminal action. It creates a central terminal from the prompt or another central terminal.
  • Right-sidebar terminals are a separate terminal workspace. Cmd/Ctrl+T creates another terminal in that same sidebar so the new tab stays with the focused terminal area.
  • Cmd/Ctrl+Shift+T is disabled in the right sidebar to avoid accidentally creating a central terminal while the user is working in the sidebar.

Focus and restoration

  • The extension tracks prompt, central-terminal, and sidebar-terminal focus with separate context keys.
  • Terminal focus is resolved from the current DOM owner after focus transitions, so a delayed blur event from another mounted terminal cannot overwrite the active focus target.
  • When Cmd/Ctrl+Shift+M returns from a central terminal, Agent Manager restores the session tab that was selected before the terminal opened and focuses its prompt.
  • If that session is no longer available, the first available session tab is selected. If no session tab exists, Agent Manager creates and selects a real New Session tab instead of showing an untracked prompt template.
  • Sidebar terminal selection remains local to the sidebar and does not replace the selected center session.

Supporting changes

  • Split central-terminal and sidebar-terminal commands and keybinding conditions.
  • Update shortcut dialog entries, terminal menu hints, fallback bindings, translations, and release notes.
  • Add coverage for focus resolution, session restoration, command routing, manifest conditions, and the terminal shortcut matrix.

Comment thread packages/kilo-vscode/webview-ui/agent-manager/terminal/state.ts Outdated
Comment thread packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx Outdated
Comment thread packages/kilo-vscode/src/KiloProvider.ts
Comment thread packages/kilo-vscode/package.json Outdated
Comment thread packages/kilo-vscode/webview-ui/agent-manager/focus.ts Outdated
Comment thread packages/kilo-vscode/CHANGELOG.md Outdated
@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 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/webview-ui/agent-manager/focus.ts 40 Empty-worktree restore stays pending and never hides the central terminal after sessionAdded
packages/kilo-vscode/webview-ui/agent-manager/terminal/state.ts 965 Second central terminal can overwrite session restore memory when no session is current
Files Reviewed (12 files)
  • packages/kilo-vscode/CHANGELOG.md
  • packages/kilo-vscode/package.json
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/src/agent-manager/format-keybinding.ts
  • packages/kilo-vscode/tests/unit/agent-manager-session-restore.test.ts
  • packages/kilo-vscode/tests/unit/extension-arch.test.ts
  • packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx
  • packages/kilo-vscode/webview-ui/agent-manager/focus.ts - 1 issue
  • packages/kilo-vscode/webview-ui/agent-manager/project/store.ts
  • packages/kilo-vscode/webview-ui/agent-manager/selection-actions.ts
  • packages/kilo-vscode/webview-ui/agent-manager/terminal/state.ts - 1 issue
  • packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts

Fix these issues in Kilo Cloud

Previous Review Summary (commit 76d6ce3)

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

Previous review (commit 76d6ce3)

Status: 6 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
packages/kilo-vscode/webview-ui/agent-manager/terminal/state.ts 661 activate always remembers the current session, including context switches that already have a remembered terminal
packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx 2044 Session restore reuses tabMemory, so a second central terminal overwrites the stored session id
packages/kilo-vscode/src/KiloProvider.ts 1572 Webview blur clears focus context keys and they are not restored on return
packages/kilo-vscode/package.json 743 Center shortcuts require prompt/main-terminal focus, so tab/chat/review focus is a no-op or leaks VS Code defaults
packages/kilo-vscode/webview-ui/agent-manager/focus.ts 37 Empty-worktree restore creates a session then immediately focuses an untracked prompt

SUGGESTION

File Line Issue
packages/kilo-vscode/CHANGELOG.md 7 Patch-level note is under Minor Changes, and the shipped 7.4.21 notes were rewritten
Files Reviewed (47 files)
  • .changeset/terminal-shortcut-focus.md - 0 issues
  • packages/kilo-vscode/CHANGELOG.md - 1 issue
  • packages/kilo-vscode/package.json - 1 issue
  • packages/kilo-vscode/src/KiloProvider.ts - 1 issue
  • packages/kilo-vscode/src/agent-manager/format-keybinding.ts - 0 issues
  • packages/kilo-vscode/src/agent-manager/host.ts - 0 issues
  • packages/kilo-vscode/src/agent-manager/vscode-host.ts - 0 issues
  • packages/kilo-vscode/src/extension.ts - 0 issues
  • packages/kilo-vscode/src/kilo-provider/options.ts - 0 issues
  • packages/kilo-vscode/tests/unit/agent-manager-arch.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/agent-manager-focus.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/agent-manager-session-restore.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/extension-arch.test.ts - 0 issues
  • packages/kilo-vscode/tests/unit/format-keybinding.test.ts - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/agent-manager/TabBar.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/focus.ts - 1 issue
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/* - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/keybind-defaults.ts - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/selection-actions.ts - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/shortcuts.ts - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/tab-rendering.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/terminal/SideTerminalPanel.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/terminal/TerminalTab.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/terminal/render.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/agent-manager/terminal/state.ts - 1 issue
  • 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: 328.6K · Output: 70.3K · Cached: 3.2M

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit d88a7fa into main Aug 19, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the refactor-terminal-shortcut-logic branch August 19, 2026 11:46
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