@devries-cameron20 / t3code Mirror · read-only / commits / 9db3cb1091
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 13:30 UTC

fix(mobile): a link during video playback no longer rebuilds the open thread (#34990)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Chirag Agggarwal committed Nov 15, 2026 at 00:42 UTC 9db3cb10916c81830efa0d0d7be6601d2fe51158
6 files changed +152 -12
apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
+9 -5
@@ -107,7 +107,10 @@ function ColumnScreen(props: {
107 readonly selectedThreadKey?: string | null;
108 readonly selectedPullRequestKey?: string | null;
109 readonly onDismiss: (routeKey: string, native: boolean) => void;
110 - readonly onAppearance: (type: "willAppear" | "didAppear" | "willDisappear", key: string) => void;
110 + readonly onAppearance: (
111 + type: "willAppear" | "didAppear" | "willDisappear" | "didDisappear",
112 + key: string,
113 + ) => void;
114 readonly onCompose?: () => void;
115 readonly navigation: ViewProps["navigation"];
116 readonly footer?: ReactNode;
@@ -152,9 +155,10 @@ function ColumnScreen(props: {
155 props.onAppearance("willDisappear", key);
156 props.navigation.emit({ type: "transitionStart", target: key, data: { closing: true } });
157 }}
155 - onDidDisappear={() =>
156 - props.navigation.emit({ type: "transitionEnd", target: key, data: { closing: true } })
157 - }
158 + onDidDisappear={() => {
159 + props.onAppearance("didDisappear", key);
160 + props.navigation.emit({ type: "transitionEnd", target: key, data: { closing: true } });
161 + }}
162 >
163 <PaneContext value={sidebar ? "sidebar" : "content"}>
164 <NavigationContext value={descriptor.navigation}>
@@ -307,7 +311,7 @@ function WorkspaceColumns(
311 }
312 };
313 const followCollapsedSplit = (
310 - type: "willAppear" | "didAppear" | "willDisappear",
314 + type: "willAppear" | "didAppear" | "willDisappear" | "didDisappear",
315 key: string,
316 ) => {
317 if (!collapsed.current || layout.usesSplitView) return;
apps/mobile/src/native/createV5StackNavigator.ios.test.tsx new
+95
@@ -0,0 +1,95 @@
1 +import type { ParamListBase, StackNavigationState } from "@react-navigation/native";
2 +import { act, createContext, type ComponentProps, type ReactNode } from "react";
3 +import { createRoot } from "react-dom/client";
4 +import type { Stack as NativeStack } from "react-native-screens";
5 +import { expect, it, vi } from "vite-plus/test";
6 +
7 +type ScreenProps = ComponentProps<typeof NativeStack.Screen>;
8 +const screens = vi.hoisted(() => new Map<string, ScreenProps>());
9 +
10 +vi.mock("react-native", () => ({
11 + StyleSheet: { flatten: (style: unknown) => style },
12 + View: ({ children }: { children?: ReactNode }) => children,
13 +}));
14 +vi.mock("react-native-screens", () => ({
15 + Stack: {
16 + Host: ({ children }: { children?: ReactNode }) => children,
17 + Screen: (props: ScreenProps) => {
18 + screens.set(props.screenKey, props);
19 + return null;
20 + },
21 + },
22 +}));
23 +vi.mock("@react-navigation/native", () => ({
24 + NavigationContext: createContext(undefined),
25 + NavigationRouteContext: createContext(undefined),
26 + usePreventRemoveContext: () => ({ preventedRoutes: {} }),
27 +}));
28 +vi.mock("@react-navigation/native-stack", () => ({ NativeStackView: () => null }));
29 +vi.mock("./V5StackHeader.ios", () => ({ V5StackHeader: () => null }));
30 +vi.mock("./NativeColumnContent.ios", () => ({ NativeColumnContent: () => null }));
31 +vi.mock("./NativeScrollViewMarker", () => ({
32 + NativeScrollEdgeEffectsContext: createContext(undefined),
33 +}));
34 +
35 +import { V5CardStackView, type V5StackViewProps } from "./createV5StackNavigator.ios";
36 +
37 +const home = { key: "home", name: "Home" };
38 +const thread = { key: "thread", name: "Thread" };
39 +
40 +function fire(key: string, event: "onWillAppear" | "onWillDisappear" | "onDidDisappear") {
41 + const handler = screens.get(key)?.[event] as (() => void) | undefined;
42 + if (!handler) throw new Error(`No ${event} for ${key}`);
43 + act(() => handler());
44 +}
45 +
46 +it("forgets native Back when a full-screen presentation covers the top card", () => {
47 + vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
48 + const state: StackNavigationState<ParamListBase> = {
49 + key: "stack",
50 + type: "stack",
51 + stale: false,
52 + index: 1,
53 + routeNames: ["Home", "Thread"],
54 + routes: [home, thread],
55 + preloadedRoutes: [],
56 + };
57 + const navigation = { getState: () => state, emit: vi.fn(), dispatch: vi.fn() };
58 + const descriptor = (route: typeof home) => ({
59 + route,
60 + navigation,
61 + options: {},
62 + render: () => null,
63 + });
64 + const onNativePopChange = vi.fn();
65 + const root = createRoot(document.createElement("div"));
66 + try {
67 + act(() =>
68 + root.render(
69 + <V5CardStackView
70 + {...({
71 + state,
72 + navigation,
73 + descriptors: { home: descriptor(home), thread: descriptor(thread) },
74 + describe: () => descriptor(home),
75 + } as unknown as V5StackViewProps)}
76 + onNativePopChange={onNativePopChange}
77 + />,
78 + ),
79 + );
80 +
81 + // A presentation covers the thread: nothing in the stack appears beneath it.
82 + fire("thread", "onWillDisappear");
83 + fire("thread", "onDidDisappear");
84 + expect(onNativePopChange).toHaveBeenLastCalledWith(null);
85 +
86 + // Native Back reveals Home, so the thread stays the card being popped.
87 + fire("thread", "onWillDisappear");
88 + fire("home", "onWillAppear");
89 + fire("thread", "onDidDisappear");
90 + expect(onNativePopChange).toHaveBeenLastCalledWith("thread");
91 + } finally {
92 + act(() => root.unmount());
93 + vi.unstubAllGlobals();
94 + }
95 +});
apps/mobile/src/native/createV5StackNavigator.ios.tsx
+10 -3
@@ -63,6 +63,8 @@ export function V5CardStackView(
63 // Options a screen set inside this workspace tab slot, over its route's.
64 const slot = use(WorkspaceSlotOptionsContext);
65 const nativePopSource = useRef<string | null>(null);
66 + // Back reveals the card beneath; a full-screen presentation covers the card without revealing one.
67 + const cardRevealed = useRef(false);
68 const { onNativePopChange } = props;
69 const setNativePopSource = useCallback(
70 (key: string | null) => {
@@ -175,6 +177,7 @@ export function V5CardStackView(
177 if (preventedRoutes[route.key]?.preventRemove) descriptor.navigation.goBack();
178 }}
179 onWillAppear={() => {
180 + cardRevealed.current = true;
181 if (index === 0) props.onRootVisibilityChange?.(true);
182 props.navigation.emit({
183 type: "transitionStart",
@@ -217,6 +220,7 @@ export function V5CardStackView(
220 const state = props.navigation.getState();
221 // Only native Back leaves the disappearing card active; JS navigation already changed history.
222 if (state.index > 0 && state.routes[state.index]?.key === route.key) {
223 + cardRevealed.current = false;
224 setNativePopSource(route.key);
225 }
226 props.navigation.emit({
@@ -225,13 +229,16 @@ export function V5CardStackView(
229 data: { closing: true },
230 });
231 }}
228 - onDidDisappear={() =>
232 + onDidDisappear={() => {
233 + if (nativePopSource.current === route.key && !cardRevealed.current) {
234 + setNativePopSource(null);
235 + }
236 props.navigation.emit({
237 type: "transitionEnd",
238 target: route.key,
239 data: { closing: true },
233 - })
234 - }
240 + });
241 + }}
242 >
243 <NavigationContext value={descriptor.navigation}>
244 <NavigationRouteContext value={descriptor.route}>
apps/mobile/src/native/workspace-stack-projection.test.ts
+25 -1
@@ -246,7 +246,7 @@ describe("collapsed split Back", () => {
246 routeParamList: {},
247 routeGetIdList: {},
248 };
249 - type Appearance = "willAppear" | "didAppear" | "willDisappear";
249 + type Appearance = "willAppear" | "didAppear" | "willDisappear" | "didDisappear";
250 // UIKit's appearance callbacks for one collapsed transition, against the router at each step.
251 function replay(
252 steps: ReadonlyArray<readonly [Appearance, string, StackNavigationState<ParamListBase>]>,
@@ -315,6 +315,30 @@ describe("collapsed split Back", () => {
315 ).toBeNull();
316 });
317
318 + it("forgets the leaving detail when a full-screen presentation covers it", () => {
319 + const state = history([home, thread]);
320 + const leavingAfter = (steps: ReadonlyArray<readonly [Appearance, string]>) =>
321 + steps.reduce<CollapsedSplitColumn>(
322 + (column, [type, key]) =>
323 + collapsedSplitTransition(column, { type, key }, state, home.key).column,
324 + { visible: "secondary", leaving: null },
325 + ).leaving;
326 + expect(
327 + leavingAfter([
328 + ["willDisappear", thread.key],
329 + ["didDisappear", thread.key],
330 + ]),
331 + ).toBeNull();
332 + // Native Back reveals the list before the detail finishes disappearing.
333 + expect(
334 + leavingAfter([
335 + ["willDisappear", thread.key],
336 + ["willAppear", home.key],
337 + ["didDisappear", thread.key],
338 + ]),
339 + ).toBe(thread.key);
340 + });
341 +
342 it("does not mistake JS navigation or a cold link for native Back", () => {
343 const pushed = history([home, thread, files]);
344 expect(
apps/mobile/src/native/workspace-stack-projection.ts
+12 -3
@@ -91,6 +91,8 @@ export function nativeStackPopAction(
91 export interface CollapsedSplitColumn {
92 readonly visible: "primary" | "secondary";
93 readonly leaving: string | null;
94 + /** Back reveals another screen; a full-screen presentation covers the detail without one. */
95 + readonly revealed?: boolean;
96 }
97
98 /**
@@ -100,7 +102,10 @@ export interface CollapsedSplitColumn {
102 */
103 export function collapsedSplitTransition(
104 column: CollapsedSplitColumn,
103 - event: { readonly type: "willAppear" | "didAppear" | "willDisappear"; readonly key: string },
105 + event: {
106 + readonly type: "willAppear" | "didAppear" | "willDisappear" | "didDisappear";
107 + readonly key: string;
108 + },
109 state: Pick<NavigationState, "key" | "index" | "routes">,
110 primaryKey: string,
111 ): {
@@ -113,14 +118,18 @@ export function collapsedSplitTransition(
118 return {
119 column:
120 state.index > 0 && state.routes[state.index]?.key === event.key
116 - ? { ...column, leaving: event.key }
121 + ? { ...column, leaving: event.key, revealed: false }
122 : column,
123 pop: null,
124 };
125 case "willAppear":
126 // A cancelled swipe, or an expansion that keeps the detail on screen.
127 + if (column.leaving === event.key) return { column: { ...column, leaving: null }, pop: null };
128 + return { column: column.leaving ? { ...column, revealed: true } : column, pop: null };
129 + case "didDisappear":
130 return {
123 - column: column.leaving === event.key ? { ...column, leaving: null } : column,
131 + column:
132 + column.leaving === event.key && !column.revealed ? { ...column, leaving: null } : column,
133 pop: null,
134 };
135 case "didAppear":
apps/mobile/vite.config.ts
+1
@@ -37,6 +37,7 @@ const reactTests = [
37 "src/native/NativeHeaderToolbar.test.tsx",
38 "src/components/ComposerEditor.ios.test.tsx",
39 "src/native/V5StackHeader.ios.test.tsx",
40 + "src/native/createV5StackNavigator.ios.test.tsx",
41 "src/native/useRetryingImageSource.test.tsx",
42 "src/state/queries.debounce.test.tsx",
43 "src/state/use-selected-thread-git-state.test.tsx",