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, 21:00 UTC
fix(mobile): iPad sidebar shows new threads after switching tabs (#27894)
Julius Marminge committed
Nov 11, 2026 at 15:46 UTC
52f0988cd6939d674fe108b0a4cb829892d6cc30
3 files changed
+88
apps/mobile/src/features/home/home-route-visibility.test.tsx
new
+81
@@ -0,0 +1,81 @@
1
+import { RegistryContext } from "@effect/atom-react";
2
+import { Atom, AtomRegistry } from "effect/reactivity";
3
+import { act, useLayoutEffect } from "react";
4
+import { createRoot } from "react-dom/client";
5
+import { expect, it, vi } from "vite-plus/test";
6
+
7
+import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
8
+
9
+// The Thread in the detail column is the focused route on iPad split view.
10
+vi.mock("@react-navigation/native", () => ({
11
+ useNavigation: () => ({ isFocused: () => false }),
12
+}));
13
+
14
+import {
15
+ recordHomeTransitionEnd,
16
+ recordHomeTransitionStart,
17
+ useAtomValueWhileVisible,
18
+ useHomeRouteVisible,
19
+} from "./home-route-visibility";
20
+
21
+const shellsAtom = Atom.make(0).pipe(Atom.keepAlive);
22
+
23
+function setup() {
24
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
25
+ const registry = AtomRegistry.make();
26
+ let latest: number | undefined;
27
+ function Probe() {
28
+ const visible = useHomeRouteVisible();
29
+ const value = useAtomValueWhileVisible(shellsAtom, visible);
30
+ useLayoutEffect(() => {
31
+ latest = value;
32
+ });
33
+ return null;
34
+ }
35
+ const root = createRoot(document.createElement("div"));
36
+ const sidebar = {
37
+ presented: true,
38
+ selectedThreadKey: "env-1:thread-1",
39
+ selectedPullRequestKey: null,
40
+ };
41
+ return {
42
+ registry,
43
+ get latest() {
44
+ return latest;
45
+ },
46
+ showHome() {
47
+ act(() =>
48
+ root.render(
49
+ <RegistryContext.Provider value={registry}>
50
+ <NativePrimaryColumnContext value={sidebar}>
51
+ <Probe />
52
+ </NativePrimaryColumnContext>
53
+ </RegistryContext.Provider>,
54
+ ),
55
+ );
56
+ },
57
+ [Symbol.dispose]() {
58
+ act(() => root.unmount());
59
+ registry.dispose();
60
+ },
61
+ };
62
+}
63
+
64
+it("keeps the sidebar thread list live after switching tabs beside a focused Thread", () => {
65
+ using home = setup();
66
+ // The primary column appearing is the only navigation event Home gets on iPad.
67
+ recordHomeTransitionStart(false);
68
+ home.showHome();
69
+ act(() => home.registry.set(shellsAtom, 1));
70
+ expect(home.latest).toBe(1);
71
+
72
+ // Chats → PRs → Chats: Chats' column will-appear, then the PRs column's did-disappear.
73
+ act(() => {
74
+ recordHomeTransitionEnd(true);
75
+ recordHomeTransitionStart(false);
76
+ recordHomeTransitionEnd(true);
77
+ });
78
+ act(() => home.registry.set(shellsAtom, 2));
79
+
80
+ expect(home.latest, "new thread shells reach the sidebar list").toBe(2);
81
+});
apps/mobile/src/features/home/home-route-visibility.ts
+6
@@ -3,6 +3,8 @@ import { useNavigation } from "@react-navigation/native";
3
import { useContext, useRef, useSyncExternalStore } from "react";
4
import type { Atom } from "effect/reactivity";
5
6
+import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
7
+
8
/**
9
* Home stays mounted under a pushed Thread, and native-stack never freezes the
10
* route directly below the focused one on Fabric, so Home has to stop its own
@@ -43,7 +45,11 @@ export function recordHomeFocus(): void {
45
46
export function useHomeRouteVisible(): boolean {
47
const navigation = useNavigation();
48
+ const primaryColumn = useContext(NativePrimaryColumnContext);
49
const visible = useSyncExternalStore(subscribeHomeVisibility, () => homeVisible);
50
+ // Every tab slot's primary column reports to the one Home route, so a tab
51
+ // switch can end on the leaving slot's disappear. Trust this column instead.
52
+ if (primaryColumn) return primaryColumn.presented;
53
// Before Home's first navigation event: a cold deep link mounts Home under
54
// its Thread without ever showing it.
55
return visible ?? navigation.isFocused();
apps/mobile/vite.config.ts
+1
@@ -42,6 +42,7 @@ const reactTests = [
42
"src/features/threads/use-thread-list-now.test.tsx",
43
"src/features/threads/useThreadListV2.test.tsx",
44
"src/features/home/home-list-options.test.tsx",
45
+ "src/features/home/home-route-visibility.test.tsx",
46
"src/features/layout/workspace/useSearchScrollRestoration.test.tsx",
47
"src/features/connection/ConnectionsNewRouteScreen.test.tsx",
48
"src/features/devices/device-stream.browser.test.ts",