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 22, 14:30 UTC
feat(mobile): split wide Android Settings into two panes (#24298)
Alex committed
Oct 27, 2026 at 00:38 UTC
6f0f1a9851318ad7cf573ebb06bd368022c7a039
15 files changed
+206
-19
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+9
-3
@@ -95,9 +95,13 @@ import {
95
currentWorkspaceSelections,
96
workspaceSelectionCheck,
97
} from "../workspace/workspace-selection-store";
98
-import { workspaceTabNavigationState } from "../workspace/workspace-tab-navigation";
98
+import {
99
+ workspaceTabColumns,
100
+ workspaceTabNavigationState,
101
+} from "../workspace/workspace-tab-navigation";
102
import type { WorkspaceTab } from "../workspace/workspace-tabs-state";
103
import { workspaceRoutesOf } from "./workspace-overlay-routes";
104
+import { SettingsWorkspaceLayout } from "../settings/SettingsWorkspaceLayout";
105
106
export { useAdaptiveWorkspaceLayout };
107
@@ -478,7 +482,7 @@ function AdaptiveWorkspaceLayoutContent(
482
tab,
483
currentWorkspaceSelections(),
484
{
481
- columns: Platform.OS === "ios" && (options?.columns ?? layout.usesSplitView),
485
+ columns: workspaceTabColumns(Platform.OS, tab, options?.columns ?? layout.usesSplitView),
486
check: workspaceSelectionCheck,
487
overlays,
488
},
@@ -908,7 +912,9 @@ function AdaptiveWorkspaceLayoutContent(
912
compactAndroidSettings ? { ...safeAreaInsets, bottom: 0 } : safeAreaInsets
913
}
914
>
911
- <View className="flex-1">{props.children}</View>
915
+ <View className="flex-1">
916
+ <SettingsWorkspaceLayout>{props.children}</SettingsWorkspaceLayout>
917
+ </View>
918
</SafeAreaInsetsContext>
919
{compactAndroidSettings ? (
920
<AndroidWorkspaceNavigation onNewThread={handleStartNewTask} />
apps/mobile/src/features/settings/SettingsRouteScreen.tsx
+13
-3
@@ -24,7 +24,7 @@ import { deriveProjectGroupLabel } from "@t3tools/client-runtime/state/project-g
24
import { useSafeAreaInsets } from "react-native-safe-area-context";
25
26
import { hasCloudPublicConfig } from "../cloud/publicConfig";
27
-import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
27
+import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
28
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
29
import { SettingsRow } from "./components/SettingsRow";
30
import { SettingsSection, SettingsSidebarContext } from "./components/SettingsSection";
@@ -39,8 +39,6 @@ import { filterSettingsSections } from "./settings-search";
39
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
40
41
export function SettingsRouteScreen() {
42
- const surface = useWorkspaceSurface();
43
- const workspace = useWorkspaceTabs();
42
const { layout } = useAdaptiveWorkspaceLayout();
43
const inSidebar = use(NativePrimaryColumnContext) !== null && layout.usesSplitView;
44
// The page open beside the list: the route right above the Settings tab's route. While
@@ -52,6 +50,17 @@ export function SettingsRouteScreen() {
50
? rememberedSettingsPage(currentWorkspaceSelections())
51
: (state.routes[list + 1]?.name ?? null);
52
});
53
+ return <SettingsListScreen sidebar={inSidebar} selected={selected} />;
54
+}
55
+
56
+export function SettingsListScreen(props: {
57
+ readonly sidebar: boolean;
58
+ readonly selected: string | null;
59
+}) {
60
+ const surface = useWorkspaceSurface();
61
+ const workspace = useWorkspaceTabs();
62
+ const inSidebar = props.sidebar;
63
+ const selected = props.selected;
64
const sidebar = useMemo(() => (inSidebar ? { selected } : null), [inSidebar, selected]);
65
const content = hasCloudPublicConfig() ? (
66
<ConfiguredSettingsRouteScreen />
@@ -66,6 +75,7 @@ export function SettingsRouteScreen() {
75
{Platform.OS === "android" ? (
76
<SettingsScreen
77
title="Settings"
78
+ workspaceRoot={inSidebar}
79
trailing={<AndroidSettingsEnvironmentFilter />}
80
search={
81
workspace
apps/mobile/src/features/settings/SettingsWorkspaceLayout.android.tsx
new
+57
@@ -0,0 +1,57 @@
1
+import { NavigationRouteContext } from "@react-navigation/native";
2
+import { Activity, useState, type ReactNode } from "react";
3
+import { View } from "react-native";
4
+
5
+import { AppText } from "../../components/ui/AppText";
6
+import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
7
+import { useAndroidWorkspaceRoot } from "../workspace/AndroidWorkspaceTabsProvider";
8
+import { SettingsListScreen } from "./SettingsRouteScreen";
9
+import { SettingsScreen } from "./components/SettingsScreen";
10
+
11
+const SETTINGS_LIST_ROUTE = { key: "settings-sidebar", name: "Settings" };
12
+
13
+export function SettingsWorkspaceLayout(props: { readonly children: ReactNode }) {
14
+ const root = useAndroidWorkspaceRoot();
15
+ const { layout } = useAdaptiveWorkspaceLayout();
16
+ const split = root?.settingsOpen === true && layout.usesSplitView;
17
+ const [visited, setVisited] = useState(split);
18
+ if (split && !visited) setVisited(true);
19
+ const emptyDetail = split && root.settingsPage === null;
20
+ const route = root?.settingsRoute ?? SETTINGS_LIST_ROUTE;
21
+
22
+ return (
23
+ <View className="flex-1 flex-row">
24
+ {visited ? (
25
+ <Activity mode={split ? "visible" : "hidden"}>
26
+ <View style={{ width: layout.listPaneWidth ?? 0, marginRight: layout.listPaneGap ?? 0 }}>
27
+ <NavigationRouteContext value={route}>
28
+ <SettingsListScreen sidebar selected={root?.settingsPage ?? null} />
29
+ </NavigationRouteContext>
30
+ </View>
31
+ </Activity>
32
+ ) : null}
33
+ <View className="flex-1">
34
+ <View
35
+ className="flex-1"
36
+ pointerEvents={emptyDetail ? "none" : "auto"}
37
+ accessibilityElementsHidden={emptyDetail}
38
+ importantForAccessibility={emptyDetail ? "no-hide-descendants" : "auto"}
39
+ style={emptyDetail ? { opacity: 0 } : undefined}
40
+ >
41
+ {props.children}
42
+ </View>
43
+ {emptyDetail ? (
44
+ <View className="absolute inset-0">
45
+ <NavigationRouteContext value={route}>
46
+ <SettingsScreen title="Settings" workspaceRoot>
47
+ <View className="flex-1 items-center justify-center p-6">
48
+ <AppText className="text-foreground-muted">Select a setting</AppText>
49
+ </View>
50
+ </SettingsScreen>
51
+ </NavigationRouteContext>
52
+ </View>
53
+ ) : null}
54
+ </View>
55
+ </View>
56
+ );
57
+}
apps/mobile/src/features/settings/SettingsWorkspaceLayout.tsx
new
+5
@@ -0,0 +1,5 @@
1
+import type { ReactNode } from "react";
2
+
3
+export function SettingsWorkspaceLayout(props: { readonly children: ReactNode }) {
4
+ return props.children;
5
+}
apps/mobile/src/features/settings/components/SettingsScreen.tsx
+7
-1
@@ -9,6 +9,7 @@ import { useWorkspaceTabs } from "../../workspace/WorkspaceTabsContext";
9
import { useWorkspaceSurface } from "../../workspace/useWorkspaceSurface";
10
import { useDeviceType } from "../../../native/native-layout-metrics";
11
import { useCompactWorkspaceTabs } from "../../workspace/useSystemWorkspaceTabBar";
12
+import { useAdaptiveWorkspaceLayout } from "../../layout/adaptive-workspace-context";
13
import {
14
ScreenScrollViewBottomInset,
15
ScreenScrollViewSurface,
@@ -29,6 +30,7 @@ export function SettingsScreen(
30
const surface = useWorkspaceSurface();
31
const deviceType = useDeviceType();
32
const compactTabs = useCompactWorkspaceTabs();
33
+ const { layout } = useAdaptiveWorkspaceLayout();
34
const cover = deviceType === "duo-folded";
35
// Android opens Settings as a workspace tab; its root page has nothing to go back to.
36
const workspaceRoot =
@@ -55,7 +57,11 @@ export function SettingsScreen(
57
{props.formSheet ? (
58
props.children
59
) : (
58
- <SettingsScreenContent>{props.children}</SettingsScreenContent>
60
+ <SettingsScreenContent
61
+ insetHorizontal={Platform.OS === "android" && layout.usesSplitView}
62
+ >
63
+ {props.children}
64
+ </SettingsScreenContent>
65
)}
66
</ScreenScrollViewSurface>
67
</ScreenScrollViewBottomInset>
apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.android.tsx
+3
-1
@@ -118,7 +118,9 @@ export function AndroidWorkspaceNavigation(props: {
118
// Reset the root stack even when a nested settings navigator has focus.
119
if (root) {
120
navigation.dispatch({
121
- ...CommonActions.reset(androidWorkspaceTabNavigationState(root.getState(), tab)),
121
+ ...CommonActions.reset(
122
+ androidWorkspaceTabNavigationState(root.getState(), tab, rail),
123
+ ),
124
target: root.key,
125
});
126
}
apps/mobile/src/features/workspace/AndroidWorkspaceTabsProvider.tsx
+10
-1
@@ -21,6 +21,8 @@ interface AndroidWorkspaceRoot {
21
readonly getState: () => NavigationState;
22
/** Settings is derived from navigation rather than kept in the tab reducer. */
23
readonly settingsOpen: boolean;
24
+ readonly settingsRoute: NavigationState["routes"][number] | undefined;
25
+ readonly settingsPage: string | null;
26
}
27
28
const AndroidWorkspaceRootContext = createContext<AndroidWorkspaceRoot | null>(null);
@@ -41,7 +43,14 @@ export function AndroidWorkspaceTabsProvider(props: {
43
const getState = useCallback(() => stateRef.current, []);
44
const key = props.state.key;
45
const settingsOpen = Platform.OS === "android" && androidWorkspaceSettingsOpen(props.state);
44
- const root = useMemo(() => ({ key, getState, settingsOpen }), [key, getState, settingsOpen]);
46
+ const settingsIndex = props.state.routes.findIndex((route) => route.name === "Settings");
47
+ const settingsRoute = settingsIndex < 0 ? undefined : props.state.routes[settingsIndex];
48
+ const settingsPage =
49
+ settingsIndex < 0 ? null : (props.state.routes[settingsIndex + 1]?.name ?? null);
50
+ const root = useMemo(
51
+ () => ({ key, getState, settingsOpen, settingsRoute, settingsPage }),
52
+ [key, getState, settingsOpen, settingsRoute, settingsPage],
53
+ );
54
return Platform.OS === "android" ? (
55
<WorkspaceTabsProvider>
56
<AndroidWorkspaceRootContext value={root}>{props.children}</AndroidWorkspaceRootContext>
apps/mobile/src/features/workspace/android-workspace-tabs.ts
+8
-1
@@ -6,6 +6,7 @@ import {
6
settingsOpenIn,
7
} from "../settings/settings-navigation";
8
import type { WorkspaceTab } from "./workspace-tabs-state";
9
+import { rememberedSettingsPage, workspaceSelectionsIn } from "./workspace-tab-navigation";
10
11
/** Settings joins the two list tabs as a top-level Android destination. */
12
export type AndroidWorkspaceNavigationTab = WorkspaceTab | "settings";
@@ -16,9 +17,15 @@ const WORKSPACE_ROUTES = new Set(["Home", "Thread", "PullRequest"]);
17
export function androidWorkspaceTabNavigationState(
18
state: NavigationState,
19
tab: AndroidWorkspaceNavigationTab,
20
+ columns = false,
21
) {
22
const home = androidWorkspaceNavigationState(state);
21
- return tab === "settings" ? settingsNavigationState(home, undefined) : home;
23
+ if (tab !== "settings") return home;
24
+ const page = columns
25
+ ? rememberedSettingsPage(workspaceSelectionsIn(state.routes, {}))
26
+ : undefined;
27
+ const current = state.routes.find((route) => route.name === page);
28
+ return settingsNavigationState(state, page, current?.params);
29
}
30
31
/** Settings stays selected while one of its pages is the topmost workspace route. */
apps/mobile/src/features/workspace/useSelectWorkspaceTab.ts
+1
-1
@@ -1,7 +1,7 @@
1
import { useCallback } from "react";
2
import { Keyboard } from "react-native";
3
4
-import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
4
+import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
5
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
6
import type { WorkspaceTab } from "./workspace-tabs-state";
7
apps/mobile/src/features/workspace/useSystemWorkspaceTabBar.ts
+1
-1
@@ -1,6 +1,6 @@
1
import { isDuoDevice } from "../../lib/device-type";
2
import { Platform } from "react-native";
3
-import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
3
+import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
4
import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
5
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
6
import { workspaceUsesColumns } from "./workspace-tabs-state";
apps/mobile/src/features/workspace/workspace-tab-navigation.test.ts
+35
-1
@@ -1,7 +1,11 @@
1
import { describe, expect, it } from "vite-plus/test";
2
3
import { restoreSettingsLinkState } from "../settings/settings-navigation";
4
-import { workspaceSelectionsIn, workspaceTabNavigationState } from "./workspace-tab-navigation";
4
+import {
5
+ workspaceSelectionsIn,
6
+ workspaceTabColumns,
7
+ workspaceTabNavigationState,
8
+} from "./workspace-tab-navigation";
9
10
const home = { key: "home", name: "Home" };
11
const thread = {
@@ -47,6 +51,36 @@ describe("workspace tab selections", () => {
51
describe("opening a workspace tab", () => {
52
const columns = { columns: true, check: available };
53
54
+ it("opens Android Settings beside its default page only in a wide window", () => {
55
+ const open = (wide: boolean) =>
56
+ workspaceTabNavigationState(
57
+ { routes: [home, thread] },
58
+ "settings",
59
+ {},
60
+ {
61
+ columns: workspaceTabColumns("android", "settings", wide),
62
+ check: available,
63
+ },
64
+ );
65
+ expect(names(open(false))).toEqual(["Home", "Settings"]);
66
+ expect(names(open(true))).toEqual(["Home", "Settings", "SettingsEnvironments"]);
67
+ });
68
+
69
+ it("keeps Android list tabs and iOS remembered-detail navigation unchanged", () => {
70
+ const open = (platform: string) =>
71
+ workspaceTabNavigationState(
72
+ { routes: [home, thread] },
73
+ "threads",
74
+ { threads: thread.params },
75
+ {
76
+ columns: workspaceTabColumns(platform, "threads", true),
77
+ check: available,
78
+ },
79
+ );
80
+ expect(names(open("android"))).toEqual(["Home"]);
81
+ expect(names(open("ios"))).toEqual(["Home", "Thread"]);
82
+ });
83
+
84
it("opens the remembered page beside the list with columns, and the list without", () => {
85
const state = { routes: [home, thread] };
86
const selections = { threads: thread.params, pullRequests: pullRequest.params };
apps/mobile/src/features/workspace/workspace-tab-navigation.ts
+8
@@ -17,6 +17,14 @@ type PullRequestSelection = NonNullable<WorkspaceSelections["pullRequests"]>;
17
/** Opened when Settings has columns and none of its pages has been opened yet. */
18
export const DEFAULT_SETTINGS_PAGE = "SettingsEnvironments" satisfies SettingsPageTarget;
19
20
+export function workspaceTabColumns(
21
+ platform: string,
22
+ tab: WorkspaceTab | "settings",
23
+ columns: boolean,
24
+) {
25
+ return columns && (platform === "ios" || (platform === "android" && tab === "settings"));
26
+}
27
+
28
// Pages a Settings row opens, minus Project overview: it shows the project chosen in the
29
// Settings scope, which resets whenever Settings closes.
30
const REMEMBERED_SETTINGS_PAGES: ReadonlySet<string> = new Set(
apps/mobile/src/lib/android-workspace-navigation.test.ts
+22
-2
@@ -37,6 +37,9 @@ const options = {
37
"PullRequestFile",
38
"PullRequestReviewers",
39
"Settings",
40
+ "SettingsEnvironments",
41
+ "SettingsAppearance",
42
+ "SettingsOpenSourceLicenses",
43
"SettingsUsage",
44
"SettingsUsageAccount",
45
],
@@ -218,11 +221,28 @@ describe("Android workspace navigation", () => {
221
describe("Android Settings tab", () => {
222
type State = ReturnType<typeof router.getInitialState>;
223
type Tab = AndroidWorkspaceNavigationTab;
221
- const openTab = (state: State, tab: Tab) =>
222
- apply(state, CommonActions.reset(androidWorkspaceTabNavigationState(state, tab)));
224
+ const openTab = (state: State, tab: Tab, columns = false) =>
225
+ apply(state, CommonActions.reset(androidWorkspaceTabNavigationState(state, tab, columns)));
226
const selectedTab = (state: State, previous: Tab) =>
227
androidWorkspaceTabFromNavigationState(state, previous);
228
229
+ it("opens a default Settings page beside the category list in wide layouts", () => {
230
+ const settings = openTab(legacyHistory(), "settings", true);
231
+ expect(names(settings)).toEqual(["Home", "Settings", "SettingsEnvironments"]);
232
+ expect(selectedTab(settings, "threads")).toBe("settings");
233
+ expect(names(apply(settings, StackActions.pop()))).toEqual(["Home", "Settings"]);
234
+ });
235
+
236
+ it("keeps the selected category mounted when reselecting wide Settings", () => {
237
+ let settings = openTab(legacyHistory(), "settings");
238
+ settings = apply(settings, StackActions.push("SettingsAppearance"));
239
+ const category = settings.routes.at(-1);
240
+ settings = apply(settings, StackActions.push("SettingsOpenSourceLicenses"));
241
+ const reselected = openTab(settings, "settings", true);
242
+ expect(names(reselected)).toEqual(["Home", "Settings", "SettingsAppearance"]);
243
+ expect(reselected.routes.at(-1)?.key).toBe(category?.key);
244
+ });
245
+
246
it("opens over Home alone, dropping chat and PR history, and Back returns to Home", () => {
247
const previous = legacyHistory();
248
const settings = openTab(previous, "settings");
apps/mobile/src/native/NativeHeaderToolbar.test.tsx
+24
-2
@@ -1,4 +1,5 @@
1
import type { NativeStackHeaderItem } from "@react-navigation/native-stack";
2
+import { NavigationContext } from "@react-navigation/native";
3
import { act, createContext, startTransition, Suspense, type ReactElement } from "react";
4
import { createRoot, type Root } from "react-dom/client";
5
import { afterEach, expect, it, vi } from "vite-plus/test";
@@ -20,7 +21,7 @@ const harness = vi.hoisted(() => ({
21
// Navigation, the header renders again only when the options are no longer shallowly equal.
22
vi.mock("@react-navigation/native", async () => {
23
// vi.mock factories run before the file's imports.
23
- const { createContext } = await vi.importActual<typeof import("react")>("react");
24
+ const { createContext, use } = await vi.importActual<typeof import("react")>("react");
25
const navigation = {
26
setOptions(options: HeaderOptions) {
27
harness.setOptionsCalls += 1;
@@ -39,15 +40,23 @@ vi.mock("@react-navigation/native", async () => {
40
[];
41
},
42
};
43
+ const navigationContext = createContext<typeof navigation | undefined>(navigation);
44
return {
45
// Outside a workspace tab slot the header writes to the route's navigation.
46
NavigationRouteContext: createContext(undefined),
45
- useNavigation: () => navigation,
47
+ NavigationContext: navigationContext,
48
+ useNavigation: () =>
49
+ use(navigationContext) ?? {
50
+ setOptions() {
51
+ throw new Error("Cannot call setOptions outside a screen");
52
+ },
53
+ },
54
useRoute: () => ({ key: "file", name: "ThreadFile", params: harness.params }),
55
};
56
});
57
58
import { NativeHeaderToolbar } from "./NativeHeaderToolbar";
59
+import { NativeStackScreenOptions } from "./StackHeader";
60
61
let root: Root | null = null;
62
@@ -97,6 +106,19 @@ afterEach(() => {
106
vi.unstubAllGlobals();
107
});
108
109
+it("does not configure a native screen from an embedded pane", () => {
110
+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
111
+ root = createRoot(document.createElement("div"));
112
+ act(() =>
113
+ root!.render(
114
+ <NavigationContext value={undefined}>
115
+ <NativeStackScreenOptions options={{ headerShown: false }} />
116
+ </NavigationContext>,
117
+ ),
118
+ );
119
+ expect(harness.setOptionsCalls).toBe(0);
120
+});
121
+
122
it.each(["left", "right", "bottom"] as const)(
123
"dispatches retained %s actions to the latest committed handlers without registering again",
124
(placement) => {
apps/mobile/src/native/StackHeader.tsx
+3
-2
@@ -1,6 +1,6 @@
1
import {
2
+ NavigationContext,
3
NavigationRouteContext,
3
- useNavigation,
4
type ParamListBase,
5
} from "@react-navigation/native";
6
import type {
@@ -37,7 +37,8 @@ export type AppNativeStackNavigationOptions = Omit<
37
};
38
39
function useNativeStackNavigation(): NativeStackNavigationProp<ParamListBase> | null {
40
- return useNavigation<NativeStackNavigationProp<ParamListBase>>();
40
+ const navigation = use(NavigationContext);
41
+ return navigation ? (navigation as NativeStackNavigationProp<ParamListBase>) : null;
42
}
43
44
function normalizeScreenOptions(