The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): retain workspace-only sidebar refreshes
funky-xamarin7f674c3e7608
diff --git a/apps/desktop/src/app/session/hooks/use-session-list-actions.test.tsx b/apps/desktop/src/app/session/hooks/use-session-list-actions.test.tsxindex ed81b6bdf34..41d62b5e0c8 100644--- a/apps/desktop/src/app/session/hooks/use-session-list-actions.test.tsx+++ b/apps/desktop/src/app/session/hooks/use-session-list-actions.test.tsx@@ -148,6 +148,38 @@ afterEach(() => {setSessionsLoadError(false)})+describe('workspace-only sidebar refresh', () => {+ it.each(['cwd', 'git_repo_root', 'git_branch'] as const)(+ 'publishes %s changes to all slices without another message or a session click',+ async field => {+ const previous = row('moved', { cwd: '/old', git_repo_root: '/old', git_branch: 'old' })+ const incoming = { ...previous, [field]: '/new' }+ setSessions([previous])+ setCronSessions([{ ...previous, source: 'cron' }])+ setMessagingSessions([{ ...previous, source: 'telegram' }])+ listSidebarSessions.mockResolvedValue(+ sidebar({ sessions: [incoming] }, [{ ...incoming, source: 'cron' }], [{ ...incoming, source: 'telegram' }])+ )+ const { result } = renderHook(() => useSessionListActions({ profileScope: 'default' }))++ await act(async () => {+ await result.current.refreshSessions()+ })++ for (const store of [$sessions, $cronSessions, $messagingSessions]) {+ expect(store.get()[0]?.[field]).toBe('/new')+ }+ const snapshots = [$sessions.get(), $cronSessions.get(), $messagingSessions.get()]+ await act(async () => {+ await result.current.refreshSessions()+ })+ ;[$sessions, $cronSessions, $messagingSessions].forEach((store, i) => {+ expect(store.get()).toBe(snapshots[i])+ })+ }+ )+})+// #67600: a cold-start read that fails must not render as "No sessions yet".describe('refreshSessions cold-start load error', () => {const failedScan = (storage?: Record<string, 'corrupt'>): SidebarSessionsResponse => ({diff --git a/apps/desktop/src/lib/session-signatures.test.ts b/apps/desktop/src/lib/session-signatures.test.tsindex b712c873c70..cd5f39b0862 100644--- a/apps/desktop/src/lib/session-signatures.test.ts+++ b/apps/desktop/src/lib/session-signatures.test.ts@@ -12,6 +12,15 @@ describe('sameCronSignature', () => {expect(sameCronSignature([session('a', 't')], [])).toBe(false)})+ it.each(['cwd', 'git_repo_root', 'git_branch'] as const)('compares %s including cleared metadata', field => {+ const populated = [session('a', 't', { [field]: 'workspace' })]+ const cleared = [session('a', 't', { [field]: null })]+ expect(sameCronSignature(populated, cleared)).toBe(false)+ expect(sameCronSignature(cleared, populated)).toBe(false)+ expect(sameCronSignature(cleared, [session('a', 't', { [field]: null })])).toBe(true)+ expect(sameCronSignature(populated, [session('a', 't', { [field]: 'workspace' })])).toBe(true)+ })+it('is true when ids and titles match in order', () => {const a = [session('a', 'one'), session('b', 'two')]const b = [session('a', 'one'), session('b', 'two')]diff --git a/apps/desktop/src/lib/session-signatures.ts b/apps/desktop/src/lib/session-signatures.tsindex fac47254226..ba59c07f68b 100644--- a/apps/desktop/src/lib/session-signatures.ts+++ b/apps/desktop/src/lib/session-signatures.ts@@ -24,6 +24,11 @@ export function sameCronSignature(a: SessionInfo[], b: SessionInfo[]): boolean {session.message_count === other.message_count &&session.last_active === other.last_active &&session.ended_at === other.ended_at &&+ // A workspace move need not change activity or message counts. Let its+ // authoritative row reach the project overlays and move-target menu.+ session.cwd === other.cwd &&+ session.git_repo_root === other.git_repo_root &&+ session.git_branch === other.git_branch &&// Row STATE, not just row content: session-pin-sync reconciles the// sidebar's pins against `pinned` on the rows in this atom, so a page// whose only delta is a flag has to swap in or the reconciler reads a