The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): add session-history fallback to $focusedWorkspaceCwd for primary sessions
Mohammadb90aa6565199
diff --git a/apps/desktop/src/store/session-states.test.ts b/apps/desktop/src/store/session-states.test.tsindex b3d457edc72..53fa072b59c 100644--- a/apps/desktop/src/store/session-states.test.ts+++ b/apps/desktop/src/store/session-states.test.ts@@ -17,6 +17,8 @@ import {$activeSessionId,$connection,$selectedStoredSessionId,+ $workspaceCwdOwner,+ setCurrentCwd,setSessionOwnerHint,setSessions} from '@/store/session'@@ -1259,6 +1261,24 @@ describe('$focusedStoredSessionId in Bot Mode (#96062)', () => {expect($focusedStoredSessionId.get()).toBe('stacked')expect($focusedWorkspaceCwd.get()).toBe('/repo-stacked')})++ it('falls back to sessions list cwd for primary session when workspaceCwdOwner is mismatched', () => {+ $selectedStoredSessionId.set('primary-1')+ $workspaceCwdOwner.set('other-session-from-different-project')+ setCurrentCwd('/repo-other')+ setSessions([{ cwd: '/repo-primary-project', id: 'primary-1' } as any])+ $sessionTiles.set([])+ $sessionStates.set({})+ $layoutTree.set(+ split('row', [+ group(['workspace'], { active: 'workspace', id: 'grp-main' })+ ])+ )+ noteActiveTreeGroup('grp-main')++ expect($focusedStoredSessionId.get()).toBe('primary-1')+ expect($focusedWorkspaceCwd.get()).toBe('/repo-primary-project')+ })})describe('focusedSessionNeedsRoute', () => {diff --git a/apps/desktop/src/store/session-states.ts b/apps/desktop/src/store/session-states.tsindex 754da6a7bf9..cdf1e9deced 100644--- a/apps/desktop/src/store/session-states.ts+++ b/apps/desktop/src/store/session-states.ts@@ -3076,7 +3076,7 @@ export const $focusedSessionState = computed([$focusedRuntimeId, $sessionStates])/** The workspace CWD of the currently focused session (the focused tile's cwd,- * else the primary session's confirmed workspace cwd). */+ * else the primary session's confirmed workspace cwd, with fallback to historical session cwd). */export const $focusedWorkspaceCwd = computed([$focusedStoredSessionId,@@ -3101,7 +3101,23 @@ export const $focusedWorkspaceCwd = computed(const hasPrimaryWorkspace = Boolean(currentCwd) && (workspaceCwdOwner ?? null) === (selectedStoredId ?? null)- return hasPrimaryWorkspace ? currentCwd.trim() : ''+ if (hasPrimaryWorkspace) {+ return currentCwd.trim()+ }++ if (selectedStoredId) {+ const fallbackCwd = (+ focusedSessionState?.cwd ||+ sessions.find(s => sessionMatchesStoredId(s, selectedStoredId))?.cwd ||+ ''+ ).trim()++ if (fallbackCwd) {+ return fallbackCwd+ }+ }++ return ''})