@devries-cameron20 / t3code-1 / commits / ad2d22c809
Fork 0

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

fix(mobile): opening a search result clears Home's search on iPhone (#28324)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Victor committed Nov 12, 2026 at 16:52 UTC ad2d22c809d373a51c6594ff715d428f4ab8cc1e
5 files changed +76 -15
apps/mobile/src/features/home/HomeRouteScreen.tsx
+14 -7
@@ -26,7 +26,11 @@ import {
26 import { AndroidHomeFabLayout } from "./AndroidHomeFab";
27 import { HomeScreen } from "./HomeScreen";
28 import { useHomeListOptions } from "./home-list-options";
29 -import { useAtomValueWhileVisible, useHomeRouteVisible } from "./home-route-visibility";
29 +import {
30 + runWhenHomeCovered,
31 + useAtomValueWhileVisible,
32 + useHomeRouteVisible,
33 +} from "./home-route-visibility";
34 import { buildHomeProjectScopes } from "./homeThreadList";
35 import { usePendingTaskListActions } from "./usePendingTaskListActions";
36 import { useThreadListActions } from "./useThreadListActions";
@@ -64,13 +68,16 @@ export function HomeRouteScreen() {
68 else if (workspace) workspace.dispatch({ type: "query", query, tab: "threads" });
69 else setLocalSearchQuery(query);
70 };
67 - const handleSelectThread = (thread: EnvironmentThreadShell) =>
68 - selectDetail({
69 - name: "Thread",
70 - params: { environmentId: String(thread.environmentId), threadId: String(thread.id) },
71 - });
72 - const selectThreadRoute = (params: ReactNavigation.RootParamList["Thread"]) =>
71 + // Split layouts keep the query; only the stacked layout opens the thread over the list.
72 + // Android's search field keeps its own open state, which a cleared query would leave open.
73 + const clearsSearchOnOpen = Platform.OS !== "android" && !layout.usesSplitView;
74 + const selectThreadRoute = (params: ReactNavigation.RootParamList["Thread"]) => {
75 + if (searchQuery !== "" && clearsSearchOnOpen && workspace)
76 + runWhenHomeCovered(() => workspace.cancelSearch("threads"));
77 selectDetail({ name: "Thread", params });
78 + };
79 + const handleSelectThread = (thread: EnvironmentThreadShell) =>
80 + selectThreadRoute({ environmentId: String(thread.environmentId), threadId: String(thread.id) });
81 const handleNewThreadOnBranch = (thread: EnvironmentThreadShell) => {
82 selectThreadRoute({
83 draft: {
apps/mobile/src/features/home/home-route-visibility.test.ts new
+35
@@ -0,0 +1,35 @@
1 +import { describe, expect, it, vi } from "vite-plus/test";
2 +
3 +import {
4 + recordHomeTransitionEnd,
5 + recordHomeTransitionStart,
6 + runWhenHomeCovered,
7 +} from "./home-route-visibility";
8 +
9 +vi.mock("@react-navigation/native", () => ({ useNavigation: vi.fn() }));
10 +
11 +describe("runWhenHomeCovered", () => {
12 + it("waits for the page opening over Home to finish covering it, then runs once", () => {
13 + const clearSearch = vi.fn();
14 + runWhenHomeCovered(clearSearch);
15 + recordHomeTransitionStart(true);
16 + expect(clearSearch).not.toHaveBeenCalled();
17 + recordHomeTransitionEnd(true, true);
18 + expect(clearSearch).not.toHaveBeenCalled();
19 + recordHomeTransitionEnd(true, false);
20 + expect(clearSearch).toHaveBeenCalledTimes(1);
21 + recordHomeTransitionStart(false);
22 + recordHomeTransitionEnd(true, false);
23 + expect(clearSearch).toHaveBeenCalledTimes(1);
24 + });
25 +
26 + it("drops the action when Home reappears before it is covered", () => {
27 + const clearSearch = vi.fn();
28 + runWhenHomeCovered(clearSearch);
29 + recordHomeTransitionStart(true);
30 + recordHomeTransitionStart(false);
31 + recordHomeTransitionEnd(false, false);
32 + recordHomeTransitionEnd(true, false);
33 + expect(clearSearch).not.toHaveBeenCalled();
34 + });
35 +});
apps/mobile/src/features/home/home-route-visibility.ts
+15 -2
@@ -33,8 +33,17 @@ function subscribeHomeVisibility(onChange: () => void) {
33 };
34 }
35
36 +let onHomeCovered: (() => void) | null = null;
37 +
38 +/** Runs `action` once the page opening over Home covers it; Home starting to reappear first drops it. */
39 +export function runWhenHomeCovered(action: () => void): void {
40 + onHomeCovered = action;
41 +}
42 +
43 export function recordHomeTransitionStart(closing: boolean): void {
37 - if (!closing) setHomeVisible(true);
44 + if (closing) return;
45 + onHomeCovered = null;
46 + setHomeVisible(true);
47 }
48
49 /**
@@ -42,7 +51,11 @@ export function recordHomeTransitionStart(closing: boolean): void {
51 * disappears last. So a disappear hides Home only when another route has the focus.
52 */
53 export function recordHomeTransitionEnd(closing: boolean, homeFocused: boolean): void {
45 - if (closing && !homeFocused) setHomeVisible(false);
54 + if (!closing || homeFocused) return;
55 + setHomeVisible(false);
56 + const action = onHomeCovered;
57 + onHomeCovered = null;
58 + action?.();
59 }
60
61 /** Popping a sheet or a deep-linked route above Home has no appear event. */
apps/mobile/src/features/layout/workspace/WorkspaceTabsContext.tsx
+9 -2
@@ -26,6 +26,8 @@ export const WorkspaceTabsContext = createContext<{
26 readonly settingsOpen: boolean;
27 readonly getScrollOffset: (tab: WorkspaceSearchTab) => number;
28 readonly recordScrollOffset: (tab: WorkspaceSearchTab, offset: number) => void;
29 + /** Leaves search and returns the list to where it was when search began. */
30 + readonly cancelSearch: (tab: WorkspaceSearchTab) => void;
31 } | null>(null);
32
33 export function useWorkspaceTabs() {
@@ -79,15 +81,20 @@ export function WorkspaceTabsProvider(props: {
81 const registry = use(RegistryContext);
82 const [model] = useState(createWorkspaceTabsModel);
83 const state = useAtomValue(model.resolved);
84 + const dispatch = (action: WorkspaceTabsAction) =>
85 + registry.set(model.stored, workspaceTabsReducer(registry.get(model.resolved), action));
86 const context = {
87 state,
84 - dispatch: (action: WorkspaceTabsAction) =>
85 - registry.set(model.stored, workspaceTabsReducer(registry.get(model.resolved), action)),
88 + dispatch,
89 isTabActive: (tab: WorkspaceTab) => registry.get(model.resolved).selectedTab === tab,
90 bottomClearance: 0,
91 settingsOpen: props.settingsOpen ?? false,
92 getScrollOffset: model.getScrollOffset,
93 recordScrollOffset: model.recordScrollOffset,
94 + cancelSearch: (tab: WorkspaceSearchTab) => {
95 + model.recordScrollOffset(tab, registry.get(model.resolved).tabs[tab].searchEntryOffset);
96 + dispatch({ type: "cancel", tab });
97 + },
98 };
99 return <WorkspaceTabsContext value={context}>{props.children}</WorkspaceTabsContext>;
100 }
apps/mobile/src/features/layout/workspace/WorkspaceToolbar.tsx
+3 -4
@@ -80,10 +80,7 @@ export function WorkspaceToolbar(props: {
80 searchRef.current?.focus();
81 return true;
82 };
83 - const cancelSearch = () => {
84 - workspace.recordScrollOffset(selectedTab, tab.searchEntryOffset);
85 - workspace.dispatch({ type: "cancel", tab: selectedTab });
86 - };
83 + const cancelSearch = () => workspace.cancelSearch(selectedTab);
84 const searchFocused = () =>
85 tab.searchMode === "resting"
86 ? enterSearch()
@@ -96,6 +93,8 @@ export function WorkspaceToolbar(props: {
93 // The sidebar remains visible while its detail owns navigation focus.
94 const searchHostVisible = focused || settingsListOnTop || primaryColumn?.presented === true;
95 const restoreSearch = () => {
96 + // A search cancelled while its screen was covered leaves its text in the native field.
97 + if (tab.searchMode === "resting") searchRef.current?.setText("");
98 if (
99 searchHostVisible &&
100 searchVisible &&