The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): project tree follows sessions.changed so external session create/delete/rename/cwd changes show up (#100354)
Teknium1bf2cf57ef37
diff --git a/apps/desktop/src/app/contrib/hooks/use-background-sync.test.ts b/apps/desktop/src/app/contrib/hooks/use-background-sync.test.tsindex 509ff19cbee..346f47e280a 100644--- a/apps/desktop/src/app/contrib/hooks/use-background-sync.test.ts+++ b/apps/desktop/src/app/contrib/hooks/use-background-sync.test.ts@@ -41,7 +41,13 @@ vi.mock('@/hermes', async importOriginal => ({getLatestSessionMessages: vi.fn()}))+vi.mock('@/store/projects', async importOriginal => ({+ ...(await importOriginal()),+ refreshProjectTree: vi.fn(async () => undefined)+}))+const { getLatestSessionMessages } = await import('@/hermes')+const { refreshProjectTree } = await import('@/store/projects')const ACTIVE_RUNTIME_ID = 'runtime-active'const ACTIVE_STORED_ID = 'stored-active'@@ -564,6 +570,16 @@ describe('active transcript refresh', () => {expect(refresh).toHaveBeenCalledTimes(1)})++ it('refreshes the project tree on a sessions.changed tick, alongside the sessions list (#100354)', async () => {+ $changeEventsAvailable.set(true)++ renderSync(vi.fn(async () => undefined))++ act(() => notifySessionsChanged())++ await waitFor(() => expect(refreshProjectTree).toHaveBeenCalledTimes(1))+ })})describe('reconcileActiveTranscript', () => {diff --git a/apps/desktop/src/app/contrib/hooks/use-background-sync.ts b/apps/desktop/src/app/contrib/hooks/use-background-sync.tsindex 573e3b7d32e..785f4f20275 100644--- a/apps/desktop/src/app/contrib/hooks/use-background-sync.ts+++ b/apps/desktop/src/app/contrib/hooks/use-background-sync.ts@@ -9,6 +9,7 @@ import { sessionMessagesSignature } from '@/lib/session-signatures'import { $changeEventsAvailable, $cronChangeTick, $sessionsChangeTick } from '@/store/live-sync'import { $onBattery, batteryPollInterval } from '@/store/power'import { refreshActiveProfile } from '@/store/profile'+import { refreshProjectTree } from '@/store/projects'import {$activeSessionId,$busy,@@ -729,6 +730,11 @@ export function useBackgroundSync({lastRunAt = Date.now()void refreshSessions()void refreshMessagingSessions()+ // The project tree is a grouping of the same stored rows, so a session+ // created/deleted/renamed/re-homed outside this window goes stale in the+ // Projects sidebar without this (#100354). refreshProjectTree() keeps the+ // cached tree on failure, so a not-yet-ready backend costs nothing.+ void refreshProjectTree()requestActiveTranscriptRefresh(true)// Bot canonical chats live in workspace tiles, never in the main-pane// selection — without this they never see background deliveries