Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): stabilize landscape pane rendering and drawer rebound

DavidShen5cf96a0e9cc7
diff --git a/apps/mobile/src/__tests__/recentMessageHistories.test.tsx b/apps/mobile/src/__tests__/recentMessageHistories.test.tsx
index 314294ac1d..4042ff97a4 100644
--- a/apps/mobile/src/__tests__/recentMessageHistories.test.tsx
+++ b/apps/mobile/src/__tests__/recentMessageHistories.test.tsx
@@ -38,6 +38,7 @@ vi.mock('react-native-reanimated', () => ({
},
}));
vi.mock('react-native', () => ({
+ Platform: { OS: 'android', select: (values: Record<string, unknown>) => values.android ?? values.default },
StyleSheet: { create: (styles: unknown) => styles },
View: ({ children, pointerEvents, accessibilityElementsHidden, ref, style, onLayout }: {
children: ReactNode; pointerEvents?: string; accessibilityElementsHidden?: boolean; ref: Ref<unknown>; style?: unknown; onLayout?: () => void;
@@ -209,6 +210,12 @@ describe('resident five-task message lists outside route lifetimes', () => {
expect(container.querySelector('[data-drawer]')).toBeNull();
expect(container.querySelector('[data-task="a"]')).not.toBeNull();
});
+ it('keeps the detail history above a resident list while the list is dragged', async () => {
+ await show('a');
+ const history = container.querySelector('[data-task="a"]')!;
+ const clip = history.closest<HTMLElement>('[data-layout*="zIndex"]');
+ expect(clip?.dataset.layout).toContain('"zIndex":1');
+ });
it('hosts route drawers after the outer resident task list on persistent layouts', async () => {
remember('a');
await act(async () => root.render(
diff --git a/apps/mobile/src/__tests__/residentHomeList.test.tsx b/apps/mobile/src/__tests__/residentHomeList.test.tsx
index cdbf050813..a0fbea255b 100644
--- a/apps/mobile/src/__tests__/residentHomeList.test.tsx
+++ b/apps/mobile/src/__tests__/residentHomeList.test.tsx
@@ -28,6 +28,7 @@ vi.mock('react-native', async () => {
View: React.forwardRef(({ children, onLayout, ...props }: any, ref) => {
React.useImperativeHandle(ref, () => ({
measureLayout: (_: any, callback: any) => callback(0, 80, state.anchorWidth, 720),
+ measureInWindow: (callback: any) => callback(0, 80, state.anchorWidth, 720),
}));
React.useEffect(() => { onLayout?.(); }, [onLayout]);
return <div data-pointer={props.pointerEvents}>{children}</div>;
diff --git a/apps/mobile/src/__tests__/sessionListDrawer.test.ts b/apps/mobile/src/__tests__/sessionListDrawer.test.ts
index 9c1fa8d3b4..cfe8a0d8ad 100644
--- a/apps/mobile/src/__tests__/sessionListDrawer.test.ts
+++ b/apps/mobile/src/__tests__/sessionListDrawer.test.ts
@@ -51,6 +51,10 @@ describe('mobile session list drawer', () => {
expect(text).toContain('Math.max(1, width + insets.left)');
// 手势位移并回 progress:关闭动画从当前视觉位置继续,不跳帧。
expect(text).toContain('progress.value + dragX.value / panelWidth');
+ // A cancelled left swipe must animate the merged visual position back to
+ // the fully open state, even if a render/layout update interrupts dragX.
+ expect(text).toContain('const effective = Math.max(0, Math.min(1, progress.value + dragX.value / panelWidth));');
+ expect(text).toContain('progress.value = withTiming(1, {');
// 拖拽关闭只认「向左」意图:右拖 16pt 判失败,纵向 16pt 先到滚动优先(review #1328)。
expect(text).toContain('.activeOffsetX(-16)');
expect(text).toContain('.failOffsetX(16)');
diff --git a/apps/mobile/src/session/HomeSurface.tsx b/apps/mobile/src/session/HomeSurface.tsx
index a1e8558067..826ec51f05 100644
--- a/apps/mobile/src/session/HomeSurface.tsx
+++ b/apps/mobile/src/session/HomeSurface.tsx
@@ -3265,7 +3265,7 @@ function HomeScreenContent({ active = true, onModeChange, width, newSessionInSys
) : null}
</View>
- {residentList.enabled ? (
+ {residentList.enabled && !embedded ? (
<ResidentHomeList focused={screenFocused && active} top={chromeHeight}
left={embedded ? 0 : edgePadding.paddingLeft} right={embedded ? 0 : edgePadding.paddingRight}>
<ActiveHomeSession.Provider value={activeHomeSession}>
diff --git a/apps/mobile/src/session/RecentMessageHistories.tsx b/apps/mobile/src/session/RecentMessageHistories.tsx
index 6875579f40..6b7c3d2dec 100644
--- a/apps/mobile/src/session/RecentMessageHistories.tsx
+++ b/apps/mobile/src/session/RecentMessageHistories.tsx
@@ -3,6 +3,7 @@ import { StyleSheet, View } from 'react-native';
import { useSegments } from 'expo-router';
import { NavigationContext, NavigationRouteContext, useIsFocused } from 'expo-router/react-navigation';
import { PaneViewportProvider, usePaneViewport } from '@/platform/AdaptiveWindowContext';
+import { useTheme } from '@/theme';
import { getRecentTasks, recentTaskKey, subscribeRecentTasks } from './recentTasks';
import { NativeHistoryHost, NativeHistorySlot, needsResidentHistoryUpgrade } from './NativeResidentHistory';
import { useResidentHomeListContextBridge } from './ResidentHomeList';
@@ -25,6 +26,7 @@ const Context = createContext<{
* React children remain mounted until LRU eviction or sign-out. On iOS, a plain
* native content container docks into the route without moving React ownership. */
export function RecentMessageHistoriesProvider({ children }: { children: ReactNode }) {
+ const { colors } = useTheme();
const host = useRef<View>(null);
const namespace = useId();
const [overlays, setOverlays] = useState<Map<string, ReactNode>>(() => new Map());
@@ -98,11 +100,12 @@ export function RecentMessageHistoriesProvider({ children }: { children: ReactNo
// their route and must remain above/outside the resident scroll surface.
const top = Math.min(entry.frame.height, Math.max(0, entry.topInset));
const bottom = Math.min(entry.frame.height - top, Math.max(0, entry.bottomInset));
- return <View key={key} pointerEvents={active && entry.interactive ? 'auto' : 'none'}
+ return <View key={key} collapsable={false} pointerEvents={active && entry.interactive ? 'auto' : 'none'}
accessibilityElementsHidden={!active} importantForAccessibility={active ? 'auto' : 'no-hide-descendants'}
style={[styles.clip, { left: entry.frame.left, top: entry.frame.top + top,
- width: entry.frame.width, height: entry.frame.height - top - bottom, opacity: active ? 1 : 0 }]}>
- <View style={{ position: 'absolute', top: -top, width: entry.frame.width, height: entry.frame.height }}>
+ width: entry.frame.width, height: entry.frame.height - top - bottom,
+ backgroundColor: colors.surface, opacity: active ? 1 : 0 }]}>
+ <View collapsable={false} style={{ position: 'absolute', top: -top, width: entry.frame.width, height: entry.frame.height }}>
{content}
</View>
</View>;
@@ -161,7 +164,10 @@ export function RecentMessageHistories({ activeKey, children, topInset = 0, bott
}
const styles = StyleSheet.create({
container: { flex: 1 },
- clip: { position: 'absolute', overflow: 'hidden' },
+ // Keep the detail surface above the resident task ScrollView while Android
+ // promotes that native view during a drag. The explicit native boundary is
+ // also required for overflow clipping on flattened view trees.
+ clip: { position: 'absolute', overflow: 'hidden', zIndex: 1 },
// Android confines a child's zIndex to its parent stacking context. Route
// drawers therefore need their root host above resident histories/chrome too.
overlay: { ...StyleSheet.absoluteFill, zIndex: 40 },
diff --git a/apps/mobile/src/session/ResidentHomeList.tsx b/apps/mobile/src/session/ResidentHomeList.tsx
index c4152b359f..822d99792b 100644
--- a/apps/mobile/src/session/ResidentHomeList.tsx
+++ b/apps/mobile/src/session/ResidentHomeList.tsx
@@ -94,9 +94,11 @@ export function ResidentHomeList({ children, focused, top, left, right }: {
const measure = useCallback(() => {
const revision = ++measureRevision.current;
if (!context?.enabled || !latest.current.focused || !context.host.current) return;
- anchor.current?.measureLayout(context.host.current, (x, y, width, height) => {
- if (revision !== measureRevision.current || !latest.current.focused || width <= 0 || height <= 0) return;
- context.publish({ owner, frame: { left: x, top: y, width, height }, children: latest.current.children });
+ anchor.current?.measureInWindow((x, y, width, height) => {
+ context.host.current?.measureInWindow((hostX, hostY) => {
+ if (revision !== measureRevision.current || !latest.current.focused || width <= 0 || height <= 0) return;
+ context.publish({ owner, frame: { left: x - hostX, top: y - hostY, width, height }, children: latest.current.children });
+ });
});
}, [context, owner]);
useLayoutEffect(() => {
diff --git a/apps/mobile/src/session/SessionListDrawer.tsx b/apps/mobile/src/session/SessionListDrawer.tsx
index 52725dcd2e..0f9eb5408e 100644
--- a/apps/mobile/src/session/SessionListDrawer.tsx
+++ b/apps/mobile/src/session/SessionListDrawer.tsx
@@ -153,7 +153,12 @@ export function SessionListDrawer({ currentSessionId, persistent = false, newSes
runOnJS(closeFromGesture)();
} else {
// 未过阈回弹:位置插值档(fast + move 曲线)。
- dragX.value = withTiming(0, {
+ const effective = Math.max(0, Math.min(1, progress.value + dragX.value / panelWidth));
+ cancelAnimation(progress);
+ cancelAnimation(dragX);
+ progress.value = effective;
+ dragX.value = 0;
+ progress.value = withTiming(1, {
duration: motionDuration.fast,
easing: Easing.bezier(...motionEasing.move),
});