Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 撤销已卸载的 iOS 侧栏内容
Dash95e85b75ef33
diff --git a/apps/mobile/docs/navigation-and-composer.md b/apps/mobile/docs/navigation-and-composer.mdindex 7b1e4c4783..43ab169abb 100644--- a/apps/mobile/docs/navigation-and-composer.md+++ b/apps/mobile/docs/navigation-and-composer.md@@ -19,7 +19,7 @@- 减弱动态效果:不播形变与拉开,直接到位。- 伙伴对话:左上角为返回(回到伙伴列表);Duo 系统栏已有返回时保留侧栏按钮,不出现两个返回。- Duo 等宽屏任务页可拖动中间把手调整两栏:列表宽度限制在 240–420pt,并为正文保留至少 400pt;真实折痕划分的两栏不允许移动。宽度在当前窗口内跨任务和旋转保留,不写入持久设置。-- iOS 首页列表留在自己的原生路由内,进入任务后仍可供返回动画显示;常驻侧栏独立保留列表内容,拖动分栏时不叠加尺寸动画。系统顶栏已计入安全区时,磨砂高度直接采用原生测量值。+- iOS 首页列表留在自己的原生路由内,进入任务后仍可供返回动画显示;常驻侧栏独立保留列表内容,拖动分栏时不叠加尺寸动画。抽屉页面卸载时只撤销自己发布的内容,旧页面的清理不影响新页面,下一任务测量前不显示失效内容。系统顶栏已计入安全区时,磨砂高度直接采用原生测量值。- 设置等整页滚动的二级页:顶栏透明、系统柔和边缘,内容滚到顶栏和底部指示条下面,无硬分界(设置、语音词典、账号注销、伙伴私聊、共享任务管理、资源列表);设备详情只去掉底部色带。## 已知未完成diff --git a/apps/mobile/src/__tests__/residentHomeList.test.tsx b/apps/mobile/src/__tests__/residentHomeList.test.tsxindex ee27fc75da..1486345cba 100644--- a/apps/mobile/src/__tests__/residentHomeList.test.tsx+++ b/apps/mobile/src/__tests__/residentHomeList.test.tsx@@ -287,3 +287,47 @@ it('does not draw the retained iOS sidebar over home during return', () => {expect(state.slide().opacity).toBe(0);expect(host.querySelector('[data-host]')?.getAttribute('data-pointer')).toBe('none');});++// Unit regression #6902: earlier return coverage kept the drawer owner mounted.+// Real iOS back unmounts it; entering another task must not expose its old actions+// while the next drawer waits for measurement, or resurrect it from a late one.+it('revokes an unmounted iOS drawer while the next task waits for measurement', () => {+ state.platform = 'ios'; state.segments = ['sessions', '[sessionId]'];+ const host = document.createElement('div'), root = createRoot(host); roots.push(root);+ const oldSelect = vi.fn(), nextSelect = vi.fn();+ const render = (task: string | null) => act(() => root.render(<ResidentHomeListProvider>+ {task ? <ResidentHomeList key={task} focused top={80} left={0} right={0}>+ <ListProbe onSelect={task === 'old' ? oldSelect : nextSelect} />+ </ResidentHomeList> : null}+ </ResidentHomeListProvider>));+ render('old');+ expect(host.querySelector('[data-select]')).not.toBeNull();+ state.deferMeasure = true; render('old');+ state.segments = []; render(null);+ act(() => { while (state.measurements.length) state.measurements.shift()!(); });+ state.segments = ['sessions', '[sessionId]']; render('next');+ expect(host.querySelector('[data-select]')).toBeNull();+ act(() => { while (state.measurements.length) state.measurements.shift()!(); });+ act(() => (host.querySelector('[data-select]') as HTMLButtonElement).click());+ expect(nextSelect).toHaveBeenCalledOnce(); expect(oldSelect).not.toHaveBeenCalled();+});++it('keeps the new drawer entry when an older retained owner unmounts later', () => {+ state.platform = 'ios'; state.segments = ['sessions', '[sessionId]'];+ const host = document.createElement('div'), root = createRoot(host); roots.push(root);+ const oldSelect = vi.fn(), nextSelect = vi.fn();+ const render = (old: boolean, next: boolean) => act(() => root.render(<ResidentHomeListProvider>+ {old ? <ResidentHomeList key="old" focused={!next} top={80} left={0} right={0}>+ <ListProbe onSelect={oldSelect} />+ </ResidentHomeList> : null}+ {next ? <ResidentHomeList key="next" focused top={80} left={0} right={0}>+ <ListProbe onSelect={nextSelect} />+ </ResidentHomeList> : null}+ </ResidentHomeListProvider>));+ render(true, false); render(true, true);+ const list = host.querySelector('[data-select]');+ render(false, true);+ expect(host.querySelector('[data-select]')).toBe(list);+ act(() => (list as HTMLButtonElement).click());+ expect(nextSelect).toHaveBeenCalledOnce(); expect(oldSelect).not.toHaveBeenCalled();+});diff --git a/apps/mobile/src/session/ResidentHomeList.tsx b/apps/mobile/src/session/ResidentHomeList.tsxindex d621340c48..c062a8b848 100644--- a/apps/mobile/src/session/ResidentHomeList.tsx+++ b/apps/mobile/src/session/ResidentHomeList.tsx@@ -24,6 +24,7 @@ const Context = createContext<{persistent: boolean;mounted: { current: boolean };publish(entry: Entry): void;+ unpublish(owner: string): void;host: React.RefObject<View | null>;} | null>(null);@@ -75,7 +76,10 @@ export function ResidentHomeListProvider({ children }: { children: ReactNode })const [entry, setEntry] = useState<Entry | null>(null);const reduceMotion = useReduceMotionEnabled();const publish = useCallback((next: Entry) => { setEntry(next); }, []);- const context = useMemo(() => ({ persistent, mounted, publish, host }), [persistent, publish]);+ const unpublish = useCallback((owner: string) => {+ setEntry(current => current?.owner === owner ? null : current);+ }, []);+ const context = useMemo(() => ({ persistent, mounted, publish, unpublish, host }), [persistent, publish, unpublish]);useLayoutEffect(() => {mounted.current = !!entry;}, [entry]);@@ -109,6 +113,7 @@ export function ResidentHomeList({ children, focused, top, left, right }: {children: ReactNode; focused: boolean; top: number; left: number; right: number;}) {const context = useContext(Context);+ const unpublish = context?.unpublish;const owner = useId();const anchor = useRef<View>(null);const latest = useRef({ children, focused });@@ -128,6 +133,12 @@ export function ResidentHomeList({ children, focused, top, left, right }: {measure();return () => { ++measureRevision.current; };}, [measure, children, focused, top, left, right]);+ // iOS Home lives in its native route, so an unmounted drawer has no successor+ // in this host. Android retains the root list through route-owner handoffs.+ // Layout/prop updates keep the live list; an old owner cannot clear a new one.+ useLayoutEffect(() => {+ if (Platform.OS === 'ios') return () => { unpublish?.(owner); };+ }, [unpublish, owner]);return <View ref={anchor} collapsable={false} pointerEvents="none" onLayout={measure}style={{ flex: 1, marginTop: top, marginLeft: -left, marginRight: -right }} />;}