mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
fix(vscode): apply the selected agent instead of the stale session agent
This commit is contained in:
@@ -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.
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user