Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): release the raw pagination lock on history fallback
Leng Jingxu5d5bb13ef592
diff --git a/apps/desktop/src/renderer/__tests__/deviceLinkControllerScenarios.test.ts b/apps/desktop/src/renderer/__tests__/deviceLinkControllerScenarios.test.tsindex 71ed0a84f6..2a0f9da08a 100644--- a/apps/desktop/src/renderer/__tests__/deviceLinkControllerScenarios.test.ts+++ b/apps/desktop/src/renderer/__tests__/deviceLinkControllerScenarios.test.ts@@ -347,6 +347,35 @@ describe('device-link controller mirror — end-to-end scenarios', () => {}});+ it('releases the raw pagination lock when the history view falls back', async () => {+ const s = sid();+ host.enableHistoryView();+ const rows = Array.from({ length: 30 }, (_, index) => dbMessage(s, String(index), 'visible',+ new Date(1_750_000_000_000 + index * 1000).toISOString(), 'user'));+ host.seedSession(s, {}, rows);+ remoteProjectsStore.setDeviceSessions(DEVICE_ID, 'Mac A', [{ id: s } as Session]);+ makerChatStore.ensureInitialMessages(s);+ await flush(); await flush();+ const view = getRemoteHistoryView(s)!;+ expect(view.getSnapshot().hasMore).toBe(true);+ const invoke = host.invoke.getMockImplementation()!;+ host.invoke.mockImplementation(async (device, channel, args) => {+ if (channel === 'local-db:messages:view' && (args[1] as { before?: string })?.before) {+ throw new Error('[UNSUPPORTED_CAPABILITY] History view scan budget exceeded');+ }+ return invoke(device, channel, args);+ });+ try {+ await makerChatStore.loadOlderMessages(s).catch(() => false);+ await flush();+ expect(getRemoteHistoryView(s)).not.toBe(view);+ expect(makerChatStore.getSnapshot(s).isLoadingMore).toBe(false);+ } finally {+ host.invoke.mockImplementation(invoke);+ makerChatStore.purgeSession(s);+ }+ });+// A durable push both invalidates the view (page read at +500 ms) and arms the// lost-push repair (+1.5 s). The repair must only read when nothing read the// latest page after the push: a running turn used to cost two page reads plus andiff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.tsindex e32fd73757..6e9f5c1bff 100644--- a/apps/desktop/src/renderer/lib/makerChatStore.ts+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts@@ -11919,12 +11919,13 @@ function createRemoteHistoryView(sessionId: string) {if (!snapshot.ready && view.isActive() && isHistoryViewUnavailable(snapshot.error)) {void reconcileRemoteMessages(sessionId, { force: true }).catch(() => undefined);}- if (snapshot.ready) {- const isLoadingMore = view.isLoadingOlder();+ const historyUnavailable = isHistoryViewUnavailable(snapshot.error);+ if (snapshot.ready || historyUnavailable) {+ const isLoadingMore = historyUnavailable ? false : view.isLoadingOlder();setState(sessionId, (state) => state.isLoadingMore === isLoadingMore? state : { ...state, isLoadingMore });}- if (isHistoryViewUnavailable(snapshot.error)) writeCache = undefined;+ if (historyUnavailable) writeCache = undefined;else if (snapshot.ready && !snapshot.loading && !snapshot.error && writeCache) {const writer = writeCache;persistTimer = setTimeout(() => { if (isCurrent()) writer(snapshot); }, 1200);