Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 立即复用文件预览并保留返回任务内容
Dashb41bf2c03fd1
diff --git a/apps/mobile/app/files/preview/[sessionId].tsx b/apps/mobile/app/files/preview/[sessionId].tsxindex b5b67c02c9..5aa4a0c1ab 100644--- a/apps/mobile/app/files/preview/[sessionId].tsx+++ b/apps/mobile/app/files/preview/[sessionId].tsx@@ -213,7 +213,12 @@ function RemoteFilePreviewContent() {const [session, setSession] = useState<RemoteSession | null>(knownSession);const workdir = session?.workingDir ?? '';- const [siblings, setSiblings] = useState<FileBrowserGridItem[] | null>(null);+ // The requested file is already known. Mount it (and its cached body) before+ // listing neighbours; a slow directory read must not hold every reopen blank.+ const [siblings, setSiblings] = useState<FileBrowserGridItem[] | null>(() => (+ initialRelPath && workdir ? [fallbackItem(initialRelPath)]+ : singleAbsPath ? [absPathItem(singleAbsPath)] : null+ ));const [siblingListing, setSiblingListing] = useState<SiblingListing | null>(null);const [pageIndex, setPageIndex] = useState(0);// 屏级焦点(HTML 可执行 WebView 的挂载门之一,见 renderItem 的 visible)。@@ -318,6 +323,7 @@ function RemoteFilePreviewContent() {// 只消费下面缓存的原始目录项重建展示模型,不能为翻译重新请求设备。useEffect(() => {if (!deviceId || !workdir || !initialRelPath) return undefined;+ setSiblings((previous) => previous ?? [fallbackItem(initialRelPath)]);let cancelled = false;const dirRel = parentRelPath(initialRelPath) ?? '';const listingKey = `${deviceId}\u0000${workdir}\u0000${dirRel}`;diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsxindex 7651fad2f1..cfe40af99c 100644--- a/apps/mobile/app/sessions/[sessionId].tsx+++ b/apps/mobile/app/sessions/[sessionId].tsx@@ -4901,16 +4901,19 @@ function SessionScreenContent() {prefix: renderWindow.prefix,};}, [renderWindow.items, renderWindow.prefix, sessionId]);- // Known stale entry content bypasses the quiet delay; routine sync stays subtle.- const showSyncingIndicator = !showConnectionBanner && !showCachedHistoryNotice- && (loading || historyView.snapshot.loading || status === 'connecting' || contentRecoveryState === 'syncing');- const showSyncingImmediately = showSyncingIndicator && hasSessionEntryPreviewMismatch(+ const entryPreviewMismatch = hasSessionEntryPreviewMismatch(sessionId,remoteSessionStore.getSessionMessagePreview(sessionId),currentSession?.preview,messages,historyView.snapshot,);+ // Reopening a cached task performs background validation. Do not make that+ // look like the finished task is running again; show actual recovery/missing content.+ const showSyncingIndicator = !showConnectionBanner && !showCachedHistoryNotice+ && (!hasRenderedMessages || entryPreviewMismatch || outboxRecoverySyncHeld || status === 'connecting')+ && (loading || historyView.snapshot.loading || status === 'connecting' || contentRecoveryState === 'syncing');+ const showSyncingImmediately = showSyncingIndicator && entryPreviewMismatch;const diffCount = renderWindow.diffCount;const searchHits = useMemo(() => searchOpen && searchQuery.trim()diff --git a/apps/mobile/src/__tests__/recentMessageHistories.test.tsx b/apps/mobile/src/__tests__/recentMessageHistories.test.tsxindex d26c29aa4d..c0e47e2676 100644--- a/apps/mobile/src/__tests__/recentMessageHistories.test.tsx+++ b/apps/mobile/src/__tests__/recentMessageHistories.test.tsx@@ -155,6 +155,26 @@ describe('resident five-task message lists outside route lifetimes', () => {expect(container.querySelector('button')).toBeNull();expect(unmounts).toEqual(['a']);});+ // Regression: preview -> interactive back exposes the native slot before JS+ // focus returns. The slot must accept its retained surface while subscriptions+ // and positioning remain paused. Existing reentry tests only used focused slots.+ it('keeps the native docking slot ready while a file preview covers the task', async () => {+ state.native = true;+ await show('a', 'cached');+ const original = container.querySelector<HTMLButtonElement>('[data-task="a"]')!;+ await act(async () => original.click());+ state.focused = false;+ await show('a', 'cached');+ expect(container.querySelector('[data-slot]')?.getAttribute('data-selected')).toBe('true');+ expect(original.dataset.active).toBe('false');+ expect(original.dataset.positioning).toBe('false');+ expect(original.closest('[data-store-gate]')?.getAttribute('data-store-gate')).toBe('false');+ state.focused = true;+ await show('a', 'cached');+ expect(container.querySelector('[data-task="a"]')).toBe(original);+ expect(original.textContent).toBe('cached:420');+ expect(unmounts).toEqual([]);+ });it('shows cached native content before new route data and chrome are ready', async () => {state.native = true;await show('a', 'cached');diff --git a/apps/mobile/src/session/RecentMessageHistories.tsx b/apps/mobile/src/session/RecentMessageHistories.tsxindex 6875579f40..e2b9663541 100644--- a/apps/mobile/src/session/RecentMessageHistories.tsx+++ b/apps/mobile/src/session/RecentMessageHistories.tsx@@ -155,7 +155,10 @@ export function RecentMessageHistories({ activeKey, children, topInset = 0, bottreturn <View ref={anchor} collapsable={false} pointerEvents={NativeHistorySlot ? 'auto' : 'none'} onLayout={measure} style={styles.container}>{/* Dock retained content immediately. `ready` gates new props and positioning,not visibility: a new route starts with unmeasured chrome even on a cache hit. */}- {NativeHistorySlot ? <NativeHistorySlot surfaceId={context.namespace + activeKey} selected={focused}+ {/* A mounted route keeps its docking slot eligible even while covered.+ UIKit restores it during interactive back, before JS focus changes.+ The stack's getId keeps one route per task; focus still gates activity. */}+ {NativeHistorySlot ? <NativeHistorySlot surfaceId={context.namespace + activeKey} selectedpointerEvents={interactive && ready ? 'auto' : 'none'} style={StyleSheet.absoluteFill} /> : null}</View>;}