Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): release passive gestures for inline video controls
Chrise41aa7677ee8
diff --git a/apps/mobile/src/__tests__/composerPullThroughGateWiring.test.tsx b/apps/mobile/src/__tests__/composerPullThroughGateWiring.test.tsxindex dddad0482c..1660042c98 100644--- a/apps/mobile/src/__tests__/composerPullThroughGateWiring.test.tsx+++ b/apps/mobile/src/__tests__/composerPullThroughGateWiring.test.tsx@@ -9,13 +9,23 @@ import type { ComposerPullThroughBridge } from '@/session/composerPullThrough';// 否则 tracker 的 end() 不跑,被 setFrozen(true) 冻住的列表滚动无法恢复。const runtime = vi.hoisted(() => ({reactions: new Set<() => void>(),+ platform: 'android',enabledLog: new Array<{ gesture: string; enabled: boolean }>(),+ handlers: new Map<string, (...args: unknown[]) => void>(),+ measure: vi.fn(() => ({ pageY: 800 })),+ setNativeProps: vi.fn(),}));-vi.mock('react-native', () => ({- Animated: { ScrollView: function AnimatedScrollView() { return null; } },- Platform: { OS: 'android' },-}));+vi.mock('react-native', async () => {+ const { useEffect } = await import('react');+ return {+ Animated: { ScrollView: function AnimatedScrollView({ ref }: { ref: (node: unknown) => void }) {+ useEffect(() => { ref({ setNativeProps: runtime.setNativeProps }); }, [ref]);+ return null;+ } },+ Platform: { get OS() { return runtime.platform; } },+ };+});// 真 reanimated 的 reaction 在输入 shared value 每次被写时都跑 react worklet// (不比较 mapper 返回值,见 lib/module/mappers.js),previous 靠第二参传入。@@ -23,7 +33,7 @@ vi.mock('react-native', () => ({vi.mock('react-native-reanimated', async () => {const { useRef } = await import('react');return {- measure: () => null,+ measure: runtime.measure,runOnJS: (fn: unknown) => fn,useAnimatedReaction: (prepare: () => unknown, react: (value: unknown, previous: unknown) => void) => {const latest = useRef({ prepare, react, previous: undefined as unknown, started: false, job: null as (() => void) | null });@@ -55,7 +65,10 @@ vi.mock('@/platform/gestureHandler', () => {},};for (const method of ['onTouchesDown', 'onTouchesMove', 'onTouchesUp', 'onTouchesCancelled', 'onFinalize']) {- gesture[method] = () => gesture;+ gesture[method] = (callback: (...args: unknown[]) => void) => {+ if (name === 'manual') runtime.handlers.set(method, callback);+ return gesture;+ };}return gesture;};@@ -79,7 +92,11 @@ const enabledSequence = () => runtime.enabledLog.map(({ gesture, enabled }) => `beforeEach(() => {runtime.reactions.clear();+ runtime.platform = 'android';runtime.enabledLog.length = 0;+ runtime.handlers.clear();+ runtime.measure.mockReturnValue({ pageY: 800 });+ runtime.setNativeProps.mockClear();root = createRoot(document.createElement('div'));});afterEach(() => act(() => root.unmount()));@@ -119,4 +136,41 @@ describe('composer pull-through gesture gate wiring', () => {flushFrame();expect(enabledSequence()).toEqual(['manual:0', 'native:0', 'manual:1', 'native:1', 'manual:0', 'native:0']);});++ // Regression: a pending passive recognizer blocked AVPlayer resume/seek on iOS.+ // Exercise production callbacks, not a copy of the gesture-state decisions.+ it('releases native touches immediately when no composer handoff can start', () => {+ runtime.platform = 'ios';+ act(() => root.render(<Harness />));+ const fail = vi.fn(() => runtime.handlers.get('onFinalize')!());+ const touch = (y: number) => ({ numberOfTouches: 1, allTouches: [{ absoluteY: y }] });+ act(() => runtime.handlers.get('onTouchesDown')!(touch(300), { fail }));+ expect(fail).toHaveBeenCalledTimes(1);+ bridgeRef.current!.armed.value = true;+ act(() => runtime.handlers.get('onTouchesDown')!(touch(850), { fail }));+ expect(fail).toHaveBeenCalledTimes(2);+ expect(runtime.setNativeProps).not.toHaveBeenCalled();+ expect(bridgeRef.current!.event.value.id).toBe(0);+ });++ it('settles armed taps and preserves a completed pull-through handoff', () => {+ runtime.platform = 'ios';+ act(() => root.render(<Harness />));+ bridgeRef.current!.armed.value = true;+ const fail = vi.fn(() => runtime.handlers.get('onFinalize')!());+ const down = () => runtime.handlers.get('onTouchesDown')!(+ { numberOfTouches: 1, allTouches: [{ absoluteY: 300 }] }, { fail });+ act(down);+ expect(fail).not.toHaveBeenCalled();+ act(() => runtime.handlers.get('onTouchesUp')!({ changedTouches: [{ absoluteY: 300 }] }, { fail }));+ expect(fail).toHaveBeenCalledTimes(1);+ expect(runtime.setNativeProps).not.toHaveBeenCalled();+ act(down);+ act(() => runtime.handlers.get('onTouchesMove')!({ numberOfTouches: 1, allTouches: [{ absoluteY: 850 }] }));+ expect(runtime.setNativeProps).toHaveBeenLastCalledWith({ scrollEnabled: false });+ act(() => runtime.handlers.get('onTouchesUp')!({ changedTouches: [{ absoluteY: 900 }] }, { fail }));+ expect(fail).toHaveBeenCalledTimes(2);+ expect(runtime.setNativeProps).toHaveBeenLastCalledWith({ scrollEnabled: true });+ expect(bridgeRef.current!.event.value).toEqual({ id: 1, active: false, startY: 800, y: 900, successful: true });+ });});diff --git a/apps/mobile/src/session/composerPullThrough.tsx b/apps/mobile/src/session/composerPullThrough.tsxindex b2e9c2be24..f2277445c7 100644--- a/apps/mobile/src/session/composerPullThrough.tsx+++ b/apps/mobile/src/session/composerPullThrough.tsx@@ -135,14 +135,22 @@ export function ComposerPullThroughScrollView({ bridge, ref, ...props }: PullThr// composer blocks edge-back. Manual observes touches without a competing pan.const tracker = Gesture.Manual().enabled(attach)- .onTouchesDown((touches) => {+ .onTouchesDown((touches, manager) => {'worklet';phase.value = PHASE_IDLE;- if (touches.numberOfTouches !== 1 || !armed.value) return;+ // A passive Manual recognizer must still leave BEGAN. Keeping it pending+ // makes AVPlayer's native play/seek controls wait indefinitely on iOS.+ if (touches.numberOfTouches !== 1 || !armed.value) {+ manager.fail();+ return;+ }const frame = measure(grabberRef);const y = touches.allTouches[0]?.absoluteY;// 只从输入框上方的聊天记录起手;按在输入框上的触摸本就归输入框。- if (!frame || y === undefined || y >= frame.pageY) return;+ if (!frame || y === undefined || y >= frame.pageY) {+ manager.fail();+ return;+ }composerTop.value = frame.pageY;previousY.value = y;phase.value = PHASE_TRACKING;@@ -167,9 +175,10 @@ export function ComposerPullThroughScrollView({ bridge, ref, ...props }: PullThrconst current = event.value;event.value = { id: current.id, active: true, startY: current.startY, y, successful: false };})- .onTouchesUp((touches) => {+ .onTouchesUp((touches, manager) => {'worklet';end(touches.changedTouches[0]?.absoluteY ?? NaN, true);+ manager.fail();}).onTouchesCancelled(() => {'worklet';