Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 避免重新挂载时提前回退到新任务
DavidShenf4fa296b8e00
diff --git a/apps/desktop/src/renderer/__tests__/remoteProjectsStartup.test.tsx b/apps/desktop/src/renderer/__tests__/remoteProjectsStartup.test.tsxindex 0be5290573..15393acbfb 100644--- a/apps/desktop/src/renderer/__tests__/remoteProjectsStartup.test.tsx+++ b/apps/desktop/src/renderer/__tests__/remoteProjectsStartup.test.tsx@@ -61,6 +61,7 @@ afterEach(() => {state.refresh.mockReset().mockResolvedValue('ok');state.readCache.mockReset().mockResolvedValue([]);state.navigate.mockReset();+ state.localSessions = [{ id: 'local-B', status: 'active', source: 'desktop' }] as import('@/lib/ccAgent.types').Session[];clearLastView();vi.mocked(clearCachedDevice).mockClear();setDataOwnerGeneration(null, 0);@@ -71,7 +72,7 @@ afterEach(() => {// #7437 / unit: real startup hook + redirect + mirror. Earlier tests seeded// bootstrap before mount, missing local-B arriving before cache/device discovery.// Deferred IPC replies verify the visible route without network or real waits.-// Standalone on Windows: 3.38s Vitest / 57ms tests (17 cases, one worker).+// Standalone on Windows: 5.51s wall / 3.74s Vitest / 61ms tests (18 cases, one worker).function deferred<T>() {let resolve!: (value: T) => void;let reject!: (reason: Error) => void;@@ -213,6 +214,35 @@ it('restores a known local task while remote initialization is still pending', aexpect(state.navigate).toHaveBeenCalledExactlyOnceWith('/cc-agent/local-B', { replace: true });});+// PR #7453: clear() leaves discovery settled after unmount/logout. With no local+// rows, the child used to navigate synchronously before the parent's effect reset+// discovery; local-B in earlier cases accidentally added an await to the fallback.+it('waits for remote discovery after remount when the local task list is empty', async () => {+ const previous = setupStartup();+ state.localSessions = [];+ let view!: ReturnType<typeof render>;+ await act(async () => { view = render(<StartupRoute />); });+ view.unmount();+ state.navigate.mockClear();+ const current = setupStartup();+ await act(async () => { render(<StartupRoute />); });+ expect(state.navigate).not.toHaveBeenCalled();+ await act(async () => {+ previous.cache.resolve([]);+ previous.link.resolve({ linkStatus: 'connecting' });+ previous.directory.resolve({ devices: [] });+ });+ expect(state.navigate).not.toHaveBeenCalled();+ await act(async () => {+ current.link.resolve({ linkStatus: 'connecting' });+ current.directory.resolve({ devices: [{ deviceId: 'peer', name: 'Peer', online: false, remoteControlEnabled: false, isSelf: false }] });+ current.cache.resolve([{ deviceId: 'peer', deviceName: 'Peer', sessions: [+ { id: 'remote-A', status: 'active', source: 'desktop' } as import('@/lib/ccAgent.types').Session,+ ] }]);+ });+ expect(state.navigate).toHaveBeenCalledExactlyOnceWith('/cc-agent/remote-A', { replace: true });+});+it.each(['deleted', 'refused'] as const)('handles confirmed deletion before the old cold cache returns: %s', async (outcome) => {vi.useFakeTimers();let finishCache!: (devices: Awaited<ReturnType<typeof state.readCache>>) => void;diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentIndexRedirect.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentIndexRedirect.tsxindex 0254a1d51f..3a53c1094f 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentIndexRedirect.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentIndexRedirect.tsx@@ -23,6 +23,7 @@ import { CINDY_MAKE_ENABLED, isCindyMakeSource } from '@cindy/maker-shared/cindyimport { useCCSessions } from '@/hooks/useCCSessions';import {getSessionDeviceId,+ remoteProjectsStore,useRemoteBootstrapLoadingDeviceIds,useRemoteInitialDiscoverySettled,useRemoteProjectSessions,@@ -100,7 +101,12 @@ export function CCAgentIndexRedirect() {// Known archived/hidden rows may fall back immediately. Existing mirrors// remain usable offline; no network request or reconnect is started here.if (!lastSession && !allSessions.some((s) => s.id === last.sessionId)) {- if (!remoteInitialDiscoverySettled) return;+ // Descendant passive effects run before the synchronizer's mount+ // effect. Let that commit finish resetting discovery after a previous+ // unmount/logout, then read live state instead of the render snapshot.+ // In particular, an empty fallback has no other await before navigation.+ await Promise.resolve();+ if (cancelled || !remoteProjectsStore.getInitialDiscoverySettled()) return;const deviceId = getSessionDeviceId(last.sessionId);if (deviceId ? remoteLoadingDeviceIds.has(deviceId) : remoteLoadingDeviceIds.size > 0)return;