Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/selected-agent-over-stale-session.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---

Fix agent mode switch getting stuck on draft/cloud-import sessions: apply the explicitly selected agent instead of reverting to the stale session agent.
8 changes: 8 additions & 0 deletions packages/kilo-vscode/tests/unit/session-agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ describe("resolvePromptAgent", () => {
expect(resolvePromptAgent({ selections: {}, pending: "code" })).toBe("code")
})

it("honors an explicit pending selection for a draft scope with no per-session entry", () => {
expect(resolvePromptAgent({ sessionID: "draft-1", selections: {}, pending: "ask" })).toBe("ask")
})

it("does not fall back to pending for a real server session with no per-session entry", () => {
expect(resolvePromptAgent({ sessionID: "ses_1", selections: {}, pending: "ask" })).toBeUndefined()
})

it("omits the agent when there is no explicit selection", () => {
expect(resolvePromptAgent({ sessionID: "ses_1", selections: {}, pending: null })).toBeUndefined()
expect(resolvePromptAgent({ selections: {}, pending: null })).toBeUndefined()
Expand Down
12 changes: 11 additions & 1 deletion packages/kilo-vscode/webview-ui/src/context/session-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,17 @@ export function resolvePromptAgent(input: {
selections: Record<string, string>
pending: string | null
}) {
if (input.sessionID) return input.selections[input.sessionID]
if (input.sessionID) {
const sel = input.selections[input.sessionID]
if (sel) return sel
// Only fall back to the pending selection for draft scopes, not real server
// sessions. A server session with no stored selection must keep its own agent
// rather than be flipped to the stale/default pending agent.
if (!input.sessionID.startsWith("ses_")) {
return input.pending ?? undefined
}
return undefined
}
return input.pending ?? undefined
Comment thread
hdcodedev marked this conversation as resolved.
}

Expand Down
Loading