Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 同步删除历史投影并规范详情重试
Dash4696246dd5b2
diff --git a/apps/mobile/src/__tests__/remoteHistoryReentry.test.ts b/apps/mobile/src/__tests__/remoteHistoryReentry.test.tsindex aef7bd67fc..a6fcd223a1 100644--- a/apps/mobile/src/__tests__/remoteHistoryReentry.test.ts+++ b/apps/mobile/src/__tests__/remoteHistoryReentry.test.ts@@ -23,6 +23,32 @@ function mount(entry: ReturnType<typeof getRemoteHistoryView>, source = reader()afterEach(() => { releases.splice(0).forEach(release => release()); clearRemoteHistoryViews(); });describe('history reentry', () => {+ it.each(['invoke', 'push', 'initial-invoke', 'initial-push'])('retires deleted history through %s without another notification', async (operation) => {+ const source = reader();+ let settle!: (value: HistoryViewPage<RemoteMessage>) => void;+ const delayed = new Promise<HistoryViewPage<RemoteMessage>>(resolve => { settle = resolve; });+ source.readHistoryView.mockImplementationOnce(() => delayed);+ const entry = getRemoteHistoryView('delete-device', 'delete-session', source);+ mount(entry, source);+ const pending = entry.view.refresh();+ if (!operation.startsWith('initial')) { settle(page('deleted')); await pending; }+ const other = getRemoteHistoryView('other-device', 'delete-session', reader());+ mount(other); await other.view.refresh();+ source.readHistoryView.mockResolvedValue({ ...page(), items: [] });+ if (operation.endsWith('push')) {+ remoteSessionStore.applyRemotePush('delete-device', 'local-db:messages:deleted', {+ sessionId: 'delete-session', clientIds: ['a'],+ });+ } else remoteSessionStore.removeMessages('delete-session', ['a'], 'delete-device');+ expect(entry.view.getSnapshot()).toMatchObject({ ready: false, items: [] });+ expect(other.view.getSnapshot().ready).toBe(true);+ settle(page('deleted')); await pending;+ expect(entry.view.getSnapshot().items).toEqual([]);+ expect(entry.view.isActive()).toBe(true);+ await entry.view.refresh();+ expect(entry.view.getSnapshot()).toMatchObject({ ready: true, items: [] });+ });+it('does not register abandoned renders', () => {getRemoteHistoryView('d', 's', reader());expect(findRemoteHistoryView('d', 's')).toBeUndefined();diff --git a/apps/mobile/src/__tests__/sessionSyncProductionCallbacks.test.ts b/apps/mobile/src/__tests__/sessionSyncProductionCallbacks.test.tsindex bc30bc5814..1f138f1752 100644--- a/apps/mobile/src/__tests__/sessionSyncProductionCallbacks.test.ts+++ b/apps/mobile/src/__tests__/sessionSyncProductionCallbacks.test.ts@@ -309,37 +309,34 @@ describe('production session recovery callbacks', () => {// Run the production push routing tail with real projection generations.describe('destructive remote history pushes', () => {- it.each(['delete', 'clear', 'archive', 'initial-delete'])('retires old pages on %s without an unrelated activity event', async (operation) => {+ // Delete (including initial-page races) is exercised through the real store in remoteHistoryReentry.test.ts.+ it.each(['clear', 'archive'])('retires old pages on %s without an unrelated activity event', async (operation) => {const context = readFileSync(resolve(process.cwd(), 'src/device-link/DeviceLinkContext.tsx'), 'utf8');const body = context.slice(context.indexOf(' const historySessionId ='), context.indexOf('/** provider revision')).trim().slice(0, -1);const stale = { id: 'old', clientId: 'old', role: 'user', content: 'old', createdAt: '2026-09-08T00:00:00Z' };const oldPage = { version: 1 as const, items: projectHistoryView([stale], false), hasMore: false, nextCursor: null };- const delayed = deferred<typeof oldPage>();let reads = 0;const view = new HistoryViewController({- page: async () => ++reads === 1 ? (operation === 'initial-delete' ? delayed.promise : oldPage)+ page: async () => ++reads === 1 ? oldPage: { ...oldPage, items: [] },details: async () => ({ version: 1, messages: [], hasMore: false, nextCursor: null }),expanded: async () => undefined,});const first = view.refresh();- if (operation !== 'initial-delete') await first;+ await first;let raw = [stale];const store = {applyRemotePush: vi.fn(() => { if (operation !== 'clear') raw = []; }),invalidateSessionMessageWindow: vi.fn(() => { raw = []; }),};- const push = operation === 'clear' || operation === 'archive'- ? { channel: 'local-db:sessions:patched', payload: { sessionId: 's', patch: operation === 'clear'- ? { clearedAt: '2026-09-08T01:00:00Z' } : { status: 'archived' } } }- : { channel: 'local-db:messages:deleted', payload: { sessionId: 's', clientIds: ['old'] } };+ const push = { channel: 'local-db:sessions:patched', payload: { sessionId: 's', patch: operation === 'clear'+ ? { clearedAt: '2026-09-08T01:00:00Z' } : { status: 'archived' } } };const compiled = ts.transpileModule(body, { compilerOptions: { target: ts.ScriptTarget.ES2022 } }).outputText;const route = new Function('push', 'env', 'findRemoteHistoryView', 'remoteSessionStore', compiled);route(push, { src: 'device-a' }, (device: string, session: string) => device === 'device-a' && session === 's' ? view : undefined, store);expect(raw).toEqual([]);expect(view.getSnapshot().items).toEqual([]);expect(view.getSnapshot().details.size).toBe(0);- if (operation === 'initial-delete') delayed.resolve(oldPage);await first; await tick();expect(view.getSnapshot().items).toEqual([]);expect(view.isActive()).toBe(operation !== 'archive');diff --git a/apps/mobile/src/device-link/DeviceLinkContext.tsx b/apps/mobile/src/device-link/DeviceLinkContext.tsxindex 01fe4c8bc0..5119d94bee 100644--- a/apps/mobile/src/device-link/DeviceLinkContext.tsx+++ b/apps/mobile/src/device-link/DeviceLinkContext.tsx@@ -1402,8 +1402,6 @@ export function routeFrame(env: Envelope, handlers: {// Retire that mirror too so a failed refresh cannot reveal pre-clear messages.remoteSessionStore.invalidateSessionMessageWindow(historySessionId as string, env.src);historyView.reset();- } else if (historyView && push.channel === 'local-db:messages:deleted') {- historyView.reset();} else if (historyView?.getSnapshot().ready && (push.channel === 'local-db:messages:created' || push.channel === 'maker:status-changed')) historyView.invalidate();}diff --git a/apps/mobile/src/session/MessageRenderer.tsx b/apps/mobile/src/session/MessageRenderer.tsxindex 283e045dc9..6d762af511 100644--- a/apps/mobile/src/session/MessageRenderer.tsx+++ b/apps/mobile/src/session/MessageRenderer.tsx@@ -4178,9 +4178,15 @@ function WorkGroupCard({<View style={styles.workGroupStack}>{item.deferred?.loading && <CompactActivityIndicator color={colors.textTertiary} size={header.iconSize} />}{item.deferred?.failed && (- <Pressable onPress={item.deferred.retry} accessibilityRole="button">- <Text style={{ color: colors.textSecondary }}>{t('message.renderer.retryPreview')}</Text>- </Pressable>+ <MessageListActionButton+ accessibilityLabel={t('message.renderer.retryPreview')}+ disabled={item.deferred.loading}+ onPress={item.deferred.retry}+ style={[styles.payloadOpenButton, { minHeight: MESSAGE_CONTROL_TOUCH_SIZE, minWidth: MESSAGE_CONTROL_TOUCH_SIZE }]}+ testID="message.workDetailsRetry"+ >+ <Text style={styles.payloadOpenButtonText}>{t('message.renderer.retryPreview')}</Text>+ </MessageListActionButton>)}{item.children.map((child) => {if (child.type === 'thinking') {diff --git a/apps/mobile/src/session/remoteSessionStore.ts b/apps/mobile/src/session/remoteSessionStore.tsindex 4b797a13fc..4b7f2a7667 100644--- a/apps/mobile/src/session/remoteSessionStore.ts+++ b/apps/mobile/src/session/remoteSessionStore.ts@@ -3765,6 +3765,7 @@ export const remoteSessionStore = {if (messagesChanged) {applyMessageWriteRetention(sessionId);}+ resetRemoteHistoryViews(deviceId, sessionId);if (!messagesChanged && !tasksChanged && !projectionSettled) return;bumpMessageVersion(sessionId);emit();