Skip to content

Fix Agent Manager session selector state#9922

Open
marius-kilocode wants to merge 3 commits intomainfrom
apple-snarl
Open

Fix Agent Manager session selector state#9922
marius-kilocode wants to merge 3 commits intomainfrom
apple-snarl

Conversation

@marius-kilocode
Copy link
Copy Markdown
Collaborator

Summary

  • Keep Agent Manager model, mode, and reasoning effort selections scoped to the active pending tab or real session.
  • Recover real-session selector state from the latest user message history instead of duplicating preferences into Agent Manager topology state.
  • Document the selector state architecture and edge cases in packages/kilo-vscode/docs/agent-manager-session-preferences.md.

Architecture Decisions

  • agent-manager.json remains topology-only: worktrees, sessions, tab order, and layout state. It does not store model, mode, or reasoning preferences.
  • Pending and unsent selector changes live only in webview memory, keyed by pending tab ID before session creation and by real session ID after creation.
  • When a pending local tab creates a real session, its in-memory model, mode, and reasoning selections are transferred to the new session ID so the UI does not jump.
  • Once a prompt is sent, the CLI stores the actual agent, model.providerID, model.modelID, and model.variant on the user message. On reload, the webview scans message history and restores the selectors from the latest user message.
  • Session placement does not affect preference scope. Local tabs, multiple tabs in the same worktree, and sessions in different worktrees all use the same session ID based mapping.

Validation

  • Added regression coverage for scoped pending tab variants, model isolation, initial Agent Manager prompt forwarding, message-history preference recovery, and topology-only state loading.

const pendingAgent = draftID ? store.agentSelections[draftID] : pendingAgentSelection()
const pendingModel = draftID ? store.sessionOverrides[draftID] : undefined
if (draftID) {
const entries = transferVariants(store.variantSelections, draftID, session.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.

WARNING: Pending session preferences are copied but never cleared

transferVariants copies the pending tab's variant keys into the real session, but the original session/<draftID>/... entries remain in variantSelections; the same block also leaves agentSelections[draftID] and sessionOverrides[draftID] behind after copying them. Creating/sending many pending tabs will accumulate stale per-tab state for the lifetime of the webview. Clear the draft-scoped agent, model, and variant entries after transferring them to the real session.

@@ -1744,7 +1767,7 @@ export const SessionProvider: ParentComponent = (props) => {
providerID,
modelID,
agent,
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: Pending-tab mode selection is not used when sending

The mode selector now stores pending-tab choices under store.agentSelections[draftID], but sendMessage still builds agent from selectedAgentName(), which only reflects the current real session or global pending selection. For a pending Agent Manager tab with a non-default mode, the request can be sent with the default/old agent even though the UI shows the scoped mode. Use the same draft-aware scope as model/variant selection (for example agentForScope(draftID ?? sid)) when constructing this payload.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented May 5, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Resolved Previous Findings
File Previous Line Resolution
packages/kilo-vscode/webview-ui/src/context/session.tsx 929 Fixed by clearing draft-scoped agent, model, and variant entries after transfer.
packages/kilo-vscode/webview-ui/src/context/session.tsx 1794 Fixed by deriving prompt agent and variant from the draft-aware scope.
Files Reviewed (5 files)
  • packages/kilo-vscode/tests/unit/session-variant-store.test.ts
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx
  • packages/kilo-vscode/webview-ui/src/context/session-model-store.ts
  • packages/kilo-vscode/webview-ui/src/context/session-variant-store.ts
  • packages/kilo-vscode/webview-ui/src/context/session.tsx

Reviewed by gpt-5.5-20260423 · 799,379 tokens

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.

1 participant