The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): gateway switch no longer keeps the previous gateway's workspace folder (#114306)
teknium16f6ab904f205
diff --git a/apps/desktop/src/store/gateway-switch.test.ts b/apps/desktop/src/store/gateway-switch.test.tsindex e9b67ebb281..7d5d4797422 100644--- a/apps/desktop/src/store/gateway-switch.test.ts+++ b/apps/desktop/src/store/gateway-switch.test.ts@@ -4,6 +4,8 @@ import { $sessionsLimit, resetSessionsLimit, SIDEBAR_SESSIONS_PAGE_SIZE } from 'import {$activeSessionId,$cronSessions,+ $currentBranch,+ $currentCwd,$freshDraftReady,$messagingSessions,$sessionProfilesTruncated,@@ -11,6 +13,8 @@ import {$sessionsLoading,setActiveSessionId,setCronSessions,+ setCurrentBranch,+ setCurrentCwdTransient,setFreshDraftReady,setMessagingSessions,setSessionProfilesTruncated,@@ -86,6 +90,16 @@ describe('wipeSessionListsForGatewaySwitch', () => {expect($freshDraftReady.get()).toBe(true)})+ it("drops the outgoing gateway's draft workspace so the next gateway seeds its own (#114306)", () => {+ setCurrentCwdTransient('/opt/data/profiles/tenant-a')+ setCurrentBranch('main')++ wipeSessionListsForGatewaySwitch()++ expect($currentCwd.get()).toBe('')+ expect($currentBranch.get()).toBe('')+ })+it("forgets the previous backend's in-memory paging state", () => {const page = {messages: Array.from({ length: 120 }, (_, index) => ({diff --git a/apps/desktop/src/store/gateway-switch.ts b/apps/desktop/src/store/gateway-switch.tsindex c9288ee7aa2..86b76549020 100644--- a/apps/desktop/src/store/gateway-switch.ts+++ b/apps/desktop/src/store/gateway-switch.ts@@ -12,6 +12,8 @@ import {$unreadFinishedSessionIds,setActiveSessionId,setCronSessions,+ setCurrentBranch,+ setCurrentCwdTransient,setFreshDraftReady,setMessages,setMessagingPlatformTotals,@@ -222,6 +224,15 @@ export function wipeSessionListsForGatewaySwitch(): void {setMessages([])setFreshDraftReady(true)+ // The draft workspace belongs to the outgoing backend. Nothing downstream+ // clears it: ensureDefaultWorkspaceCwd only seeds a NON-empty remembered+ // path and seedDefaultCwd only applies the new gateway's default when the+ // cwd is EMPTY, so a gateway with nothing remembered kept painting (and+ // sending on session.create) the previous gateway's folder (#114306).+ // Transient on purpose: the per-backend memory of the old gateway stays.+ setCurrentCwdTransient('')+ setCurrentBranch('')+// Artifacts are keyed by sessions on the previous backend, so both the// registry and any rail tab pointing into it go with them.clearArtifactRegistry()