Skip to content

fix(agent-manager): route mode shortcuts through modal - #12796

Merged
marius-kilocode merged 2 commits into
mainfrom
plan-cmd-dot-agent-manager-mode-switching
Aug 3, 2026
Merged

fix(agent-manager): route mode shortcuts through modal#12796
marius-kilocode merged 2 commits into
mainfrom
plan-cmd-dot-agent-manager-mode-switching

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

The Agent Manager New Worktree prompt has independent mode and model controls, but Cmd+. was always handled by the underlying chat session. This meant the visible modal selection could stay stale, and creating a worktree could use a different mode or model than the one shown in the form.

This change gives the New Worktree modal first ownership of the forward and reverse mode-cycle shortcuts while its New tab is active. Manual mode selection and keyboard cycling now share the same local transition, which resolves the selected mode's effective model and compatible reasoning variant without mutating the hidden chat session. Closing the modal or switching to Import restores the existing Agent Manager shortcut behavior.

A patch changeset records the user-visible fix.

Comment thread packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx Outdated
Comment thread packages/kilo-vscode/tests/unit/session-model-store.test.ts Outdated
Comment thread packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx
@kilo-code-bot

kilo-code-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Optional cleanup before merge

Overview

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

SUGGESTION

File Line Issue
packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx 83 mode prop name collides with the local mode() creation-mode accessor and with "agent mode" used elsewhere in the file (existing comment, still open)
Files Reviewed (6 files in incremental diff)
  • packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx - initial model now resolves through modelForAgent, matching mode switching and resetModel; 1 open naming suggestion
  • packages/kilo-vscode/webview-ui/src/context/session.tsx - modelForAgent / variantForAgent delegate to the pure helpers; gating (getModeModel + userSetAgents) and variant fallback are behavior-equivalent to the previous inline logic
  • packages/kilo-vscode/webview-ui/src/context/session-model-store.ts - getAgentModel matches the old shouldClearModeModelSelection precedence
  • packages/kilo-vscode/webview-ui/src/context/session-variant-store.ts - getAgentVariant is an exact extraction of the prior two-line body
  • packages/kilo-vscode/tests/unit/session-model-store.test.ts - new cases exercise getAgentModel for both the remembered-selection and configured-mode-model paths
  • packages/kilo-vscode/tests/unit/session-variant-store.test.ts - new case covers getAgentVariant

Resolved since the previous review

  • NewWorktreeDialog.tsx:110 - initial model now uses session.modelForAgent(initialAgent), so the created worktree's model no longer depends on whether the user touched the mode control.
  • session-model-store.test.ts - the store module now has a production consumer (session.tsx imports getAgentModel) and the new tests cover the added resolvers instead of duplicating an existing case.

Notes / assumptions

  • No new issues found in this increment. getAgentModel(store, env, agent, userSet) reproduces getModeModel(agent) !== null && userSetAgents()[agent] === true exactly, and getAgentVariant preserves the !model?.variants -> undefined early return.
  • Minor, not commented inline: modelForAgent builds a full ModelStore object per call even though getAgentModel only reads modelSelections and recentModels; getAgentVariant's untested undefined model branch.
  • Lint/typecheck/test/knip/marker concerns were left to CI per repo review guidance.

Fix these issues in Kilo Cloud

Previous Review Summary (commit 20d1648)

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

Previous review (commit 20d1648)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

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

SUGGESTION

File Line Issue
packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx 110 Initial model uses configModelForAgent while mode cycling uses modelForAgent, so the created worktree's model depends on whether the user touched the mode control; also makes overridden() report an override the user never made
packages/kilo-vscode/tests/unit/session-model-store.test.ts 152 New case exercises session-model-store.ts (test-only module) and duplicates the existing line-93 test; the new modelForAgent gating and variantForAgent remain untested
packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx 83 mode prop name collides with the local mode() creation-mode accessor (line 321) and with "agent mode" used elsewhere
Files Reviewed (10 files)
  • .changeset/agent-manager-modal-mode-shortcut.md - user-facing patch changeset present and reads correctly
  • packages/kilo-vscode/tests/unit/agent-manager-mode-router.test.ts - covers dispatch, unregister, and stale-cleanup identity guard against the real implementation
  • packages/kilo-vscode/tests/unit/session-model-store.test.ts - 1 issue
  • packages/kilo-vscode/webview-ui/agent-manager/AgentManagerApp.tsx - router creation and shortcut fallback verified; document.hasFocus() guard preserved
  • packages/kilo-vscode/webview-ui/agent-manager/NewWorktreeDialog.tsx - 2 issues
  • packages/kilo-vscode/webview-ui/agent-manager/ProjectList.tsx - prop threading only
  • packages/kilo-vscode/webview-ui/agent-manager/mode-router.ts - single-slot handler with identity-guarded cleanup; no leak (dialog createRoot dispose runs onCleanup)
  • packages/kilo-vscode/webview-ui/src/context/session.tsx - new agent-scoped resolvers mirror existing precedence rules
  • packages/kilo-vscode/webview-ui/src/stories/StoryProviders.tsx - mock kept in sync with the context interface
  • packages/kilo-vscode/webview-ui/src/stories/agent-manager.stories.tsx - story updated for the required prop

Notes / assumptions

  • Registration lifecycle checked against packages/ui/src/context/dialog.tsx: close() defers dispose() by 100ms, so the modal keeps the shortcut for ~100ms after closing. Judged too minor to comment on inline.
  • No inline comments were raised for lint/typecheck/test/kilocode_change/knip concerns, which CI already covers.

Fix these issues in Kilo Cloud


Reviewed by claude-opus-5 · Input: 44 · Output: 10.6K · Cached: 1.6M

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit 7b07eb8 into main Aug 3, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the plan-cmd-dot-agent-manager-mode-switching branch August 3, 2026 10:25
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…nager-mode-switching

fix(agent-manager): route mode shortcuts through modal
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