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

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

feat(mobile): search Settings, and keep its sidebar header clean (#24766)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 25, 2026 at 00:07 UTC b3d382e1009d5430de8c528aef99a39854a7cbc4
10 files changed +449 -227
apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
+1 -14
@@ -39,7 +39,6 @@ import { workspaceUsesColumns } from "../workspace/workspace-tabs-state";
39 import { isSettingsRoute, settingsOpenIn } from "../settings/settings-navigation";
40 import { workspaceRoutesOf } from "./workspace-overlay-routes";
41 import { setNativelyPoppingWorkspaceRoute } from "../workspace/workspace-detail-selection";
42 -import { useWorkspaceSidebarHeaderItem } from "./useWorkspaceSidebarHeaderItem";
42 import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
43
44 import { useAdaptiveWorkspaceLayout } from "./AdaptiveWorkspaceLayout";
@@ -94,26 +93,15 @@ function ColumnScreen(props: {
93 readonly onDismiss: (routeKey: string, native: boolean) => void;
94 readonly onAppearance: (type: "willAppear" | "didAppear" | "willDisappear", key: string) => void;
95 readonly onCompose?: () => void;
97 - /** Settings pages don't draw their own sidebar toggle, unlike threads and pull requests. */
98 - readonly sidebarToggle?: boolean;
96 readonly navigation: ViewProps["navigation"];
97 }) {
98 const { descriptor } = props;
99 // Options a screen set inside this workspace tab slot, over its route's.
103 - const slotOptions = slotScreenOptions(
100 + const options = slotScreenOptions(
101 use(WorkspaceSlotOptionsContext),
102 descriptor.route.key,
103 descriptor.options,
104 );
108 - const sidebarItem = useWorkspaceSidebarHeaderItem();
109 - // Swapping header components would unmount the native header config, which hides the bar.
110 - const options =
111 - props.sidebarToggle && !slotOptions.unstable_headerLeftItems
112 - ? ({
113 - ...slotOptions,
114 - unstable_headerLeftItems: () => [sidebarItem],
115 - } as AppNativeStackNavigationOptions as typeof slotOptions)
116 - : slotOptions;
105 const [presented, setPresented] = useState(false);
106 const primaryColumn = useMemo(
107 () =>
@@ -420,7 +408,6 @@ function WorkspaceColumns(
408 key={screenKey}
409 screenKey={screenKey}
410 descriptor={descriptor}
423 - sidebarToggle={inSettingsSlot}
411 attached={props.detail.some((current) => current.key === route.key)}
412 onDismiss={handleNativeDismiss}
413 onAppearance={followCollapsedSplit}
apps/mobile/src/features/settings/SettingsRouteScreen.tsx
+153 -141
@@ -11,13 +11,15 @@ import {
11 import { currentWorkspaceSelections } from "../workspace/workspace-selection-store";
12 import { rememberedSettingsPage } from "../workspace/workspace-tab-navigation";
13 import { useSelectWorkspaceTab } from "../workspace/useSelectWorkspaceTab";
14 +import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
15 import {
16 ScreenScrollView as ScrollView,
17 ScreenScrollViewBottomInset,
18 } from "../../components/ui/ScreenScrollView";
19 +import { EmptyState } from "../../components/ui/EmptyState";
20 import { useAuth, useUser } from "@clerk/expo";
21 import { useNavigation, useNavigationState } from "@react-navigation/native";
20 -import { use, useMemo } from "react";
22 +import { use, useMemo, type ComponentProps } from "react";
23 import { Platform, View } from "react-native";
24 import { useWorkspaceSurface } from "../workspace/useWorkspaceSurface";
25 import { useDeviceType } from "../../native/native-layout-metrics";
@@ -31,17 +33,20 @@ import { useSavedRemoteConnections } from "../../state/use-remote-environment-re
33 import { SettingsRow } from "./components/SettingsRow";
34 import { SettingsSection, SettingsSidebarContext } from "./components/SettingsSection";
35 import { SettingsScreen } from "./components/SettingsScreen";
36 +import type { SettingsPageTarget } from "./components/settings-page-targets";
37 import {
38 AndroidSettingsEnvironmentFilter,
39 SettingsEnvironmentFilterHeader,
40 } from "./components/SettingsEnvironmentFilterHeader";
41 import { useSettingsEnvironmentFilter } from "./settings-environment-filter";
42 +import { filterSettingsSections } from "./settings-search";
43 import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
44
45 export function SettingsRouteScreen() {
46 const surface = useWorkspaceSurface();
47 const deviceType = useDeviceType();
48 const compactTabs = useCompactWorkspaceTabs();
49 + const workspace = useWorkspaceTabs();
50 const { layout } = useAdaptiveWorkspaceLayout();
51 const inSidebar = use(NativePrimaryColumnContext) !== null && layout.usesSplitView;
52 // The page open beside the list: the route right above the Settings tab's route. While
@@ -66,7 +71,20 @@ export function SettingsRouteScreen() {
71 <SettingsEnvironmentFilterHeader />
72 <ScreenScrollViewBottomInset value={deviceType === "pad" || compactTabs ? 80 : 0}>
73 {Platform.OS === "android" ? (
69 - <SettingsScreen title="Settings" trailing={<AndroidSettingsEnvironmentFilter />}>
74 + <SettingsScreen
75 + title="Settings"
76 + trailing={<AndroidSettingsEnvironmentFilter />}
77 + search={
78 + workspace
79 + ? {
80 + value: workspace.state.tabs.settings.query,
81 + onChangeText: (query) =>
82 + workspace.dispatch({ type: "query", tab: "settings", query }),
83 + placeholder: "Search settings",
84 + }
85 + : undefined
86 + }
87 + >
88 {content}
89 </SettingsScreen>
90 ) : (
@@ -78,12 +96,14 @@ export function SettingsRouteScreen() {
96 );
97 }
98
99 +type SettingsListRow = ComponentProps<typeof SettingsRow> & { readonly id: string };
100 +
101 +interface SettingsListSection {
102 + readonly title?: string;
103 + readonly rows: readonly SettingsListRow[];
104 +}
105 +
106 function ConfiguredSettingsRouteScreen() {
82 - // UIKit's scroll-edge material takes the scroll view's own color; like the chat list, match
83 - // the sidebar's surface so the bar doesn't darken over content at rest.
84 - // Grouped cards only lift off the screen surface; the drawer is as dark as they are.
85 - const listSurface = use(SettingsSidebarContext) ? "bg-drawer" : "bg-screen";
86 - const insets = useSafeAreaInsets();
107 const navigation = useNavigation();
108 const { isLoaded, isSignedIn } = useAuth({ treatPendingAsSignedOut: false });
109 const { user } = useUser();
@@ -95,77 +115,96 @@ function ConfiguredSettingsRouteScreen() {
115 : (user?.primaryEmailAddress?.emailAddress ?? "Signed in");
116
117 return (
98 - <View collapsable={false} className="flex-1">
99 - <ScrollView
100 - contentInsetAdjustmentBehavior="automatic"
101 - showsVerticalScrollIndicator={false}
102 - className={`flex-1 ${listSurface}`}
103 - contentContainerClassName="gap-4 px-5 pt-4"
104 - contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
105 - >
106 - <OverflowSection />
107 - <SettingsSection title="Connections">
108 - <SettingsRow
109 - icon="person.crop.circle"
110 - label="T3 Account"
111 - value={accountLabel}
112 - disabled={!isLoaded}
113 - onPress={() => navigation.navigate("SettingsAuth")}
114 - />
115 - <SettingsRow
116 - icon="desktopcomputer"
117 - label="Environments"
118 - value={`${Object.keys(savedConnectionsById).length}`}
119 - valuePosition="trailing"
120 - target="SettingsEnvironments"
121 - />
122 - <SettingsRow icon="bell.badge" label="Notifications" target="SettingsNotifications" />
123 - </SettingsSection>
124 -
125 - <SettingsIndexSections />
126 - </ScrollView>
127 - </View>
118 + <SettingsList
119 + connections={[
120 + {
121 + id: "account",
122 + icon: "person.crop.circle",
123 + label: "T3 Account",
124 + value: accountLabel,
125 + disabled: !isLoaded,
126 + onPress: () => navigation.navigate("SettingsAuth"),
127 + },
128 + environmentsRow(Object.keys(savedConnectionsById).length),
129 + {
130 + id: "SettingsNotifications",
131 + icon: "bell.badge",
132 + label: "Notifications",
133 + target: "SettingsNotifications",
134 + },
135 + ]}
136 + />
137 );
138 }
139
140 function LocalSettingsRouteScreen() {
141 + const { savedConnectionsById } = useSavedRemoteConnections();
142 + return <SettingsList connections={[environmentsRow(Object.keys(savedConnectionsById).length)]} />;
143 +}
144 +
145 +function environmentsRow(count: number): SettingsListRow {
146 + return {
147 + id: "SettingsEnvironments",
148 + icon: "desktopcomputer",
149 + label: "Environments",
150 + value: `${count}`,
151 + valuePosition: "trailing",
152 + target: "SettingsEnvironments",
153 + };
154 +}
155 +
156 +function SettingsList(props: { readonly connections: readonly SettingsListRow[] }) {
157 // UIKit's scroll-edge material takes the scroll view's own color; like the chat list, match
158 // the sidebar's surface so the bar doesn't darken over content at rest.
159 // Grouped cards only lift off the screen surface; the drawer is as dark as they are.
160 const listSurface = use(SettingsSidebarContext) ? "bg-drawer" : "bg-screen";
161 const insets = useSafeAreaInsets();
137 - const { savedConnectionsById } = useSavedRemoteConnections();
138 - const environmentCount = Object.keys(savedConnectionsById).length;
162 + const workspace = useWorkspaceTabs();
163 + const query = workspace?.state.tabs.settings.query ?? "";
164 + const overflowRows = useOverflowRows();
165 + const indexSections = useSettingsIndexSections();
166 + const sections = filterSettingsSections(
167 + [{ rows: overflowRows }, { title: "Connections", rows: props.connections }, ...indexSections],
168 + query,
169 + );
170
171 return (
172 <View collapsable={false} className="flex-1">
173 <ScrollView
174 contentInsetAdjustmentBehavior="automatic"
175 + keyboardShouldPersistTaps="handled"
176 showsVerticalScrollIndicator={false}
177 className={`flex-1 ${listSurface}`}
178 contentContainerClassName="gap-4 px-5 pt-4"
179 contentContainerStyle={{
148 - paddingBottom: Math.max(insets.bottom, 18) + 18,
180 + // The workspace's clearance keeps the last row above its search field and keyboard.
181 + paddingBottom: Math.max(
182 + Math.max(insets.bottom, 18) + 18,
183 + workspace?.bottomClearance ?? 0,
184 + ),
185 }}
186 >
151 - <OverflowSection />
152 - <SettingsSection title="Connections">
153 - <SettingsRow
154 - icon="desktopcomputer"
155 - label="Environments"
156 - value={`${environmentCount}`}
157 - valuePosition="trailing"
158 - target="SettingsEnvironments"
187 + {sections.length ? (
188 + sections.map((section) => (
189 + <SettingsSection key={section.title ?? "tabs"} title={section.title}>
190 + {section.rows.map(({ id, ...row }) => (
191 + <SettingsRow key={id} {...row} />
192 + ))}
193 + </SettingsSection>
194 + ))
195 + ) : (
196 + <EmptyState
197 + variant="plain"
198 + title="No results"
199 + detail={`No settings match “${query.trim()}”.`}
200 />
160 - </SettingsSection>
161 -
162 - <SettingsIndexSections />
201 + )}
202 </ScrollView>
203 </View>
204 );
205 }
206
168 -function SettingsIndexSections() {
207 +function useSettingsIndexSections(): SettingsListSection[] {
208 const { selectedTargets, projectGroups, selectedProjectKey } = useSettingsEnvironmentFilter();
209 const noServerTargets = selectedTargets.length === 0;
210 const selectedProject = projectGroups.find((group) => group.key === selectedProjectKey);
@@ -182,101 +221,74 @@ function SettingsIndexSections() {
221 members: scopedProjectMembers,
222 })
223 : (selectedProject?.label ?? "Unavailable project");
185 - return (
186 - <>
187 - <SettingsSection title="Interface">
188 - <SettingsRow icon="paintbrush" label="Appearance" target="SettingsAppearance" />
189 - {navigationCustomizationAvailable() ? (
190 - <SettingsRow
191 - icon="line.3.horizontal"
192 - label="Navigation tabs"
193 - target="SettingsNavigation"
194 - />
195 - ) : null}
196 - {Platform.OS === "ios" ? (
197 - <>
198 - <SettingsRow icon="keyboard" label="Keyboard" target="SettingsKeyboard" />
199 - <SettingsRow icon="mic" label="Microphone" target="SettingsMicrophone" />
200 - </>
201 - ) : null}
202 - </SettingsSection>
203 -
204 - <SettingsSection title="Automations">
205 - <SettingsRow icon="clock" label="Scheduled tasks" target="SettingsScheduledTasks" />
206 - </SettingsSection>
207 -
208 - <SettingsSection title="Projects & threads">
209 - {selectedProjectKey !== null ? (
210 - <SettingsRow
211 - icon="folder"
212 - label="Overview"
213 - value={projectLabel}
214 - target="SettingsProjectOverview"
215 - />
216 - ) : null}
217 - <SettingsRow icon="folder" label="Organization" target="SettingsOrganization" />
218 - <SettingsRow icon="text.bubble" label="Thread behavior" target="SettingsThreads" />
219 - <SettingsRow icon="arrow.turn.left.up" label="Follow-ups" target="SettingsFollowUp" />
220 - <SettingsRow icon="archivebox" label="Archived Threads" target="SettingsArchive" />
221 - </SettingsSection>
222 -
223 - <SettingsSection title="Server settings">
224 - <SettingsRow
225 - icon="person.crop.circle"
226 - label="Provider accounts"
227 - target="SettingsProviderAccounts"
228 - disabled={noServerTargets}
229 - />
230 - <SettingsRow
231 - icon="text.bubble"
232 - label="New threads"
233 - target="SettingsEnvironmentNewThreads"
234 - disabled={noServerTargets}
235 - />
236 - <SettingsRow
237 - icon="arrow.triangle.branch"
238 - label="Source control"
239 - target="SettingsEnvironmentSourceControl"
240 - disabled={noServerTargets}
241 - />
242 - <SettingsRow
243 - icon="text.alignleft"
244 - label="Agent behavior"
245 - target="SettingsEnvironmentAgentBehavior"
246 - disabled={noServerTargets}
247 - />
248 - <SettingsRow
249 - icon="arrow.clockwise"
250 - label="Maintenance"
251 - target="SettingsEnvironmentMaintenance"
252 - disabled={noServerTargets}
253 - />
254 - </SettingsSection>
255 -
256 - <SettingsSection title="App">
257 - <SettingsRow icon="info.circle" label="About T3 Code" target="SettingsAbout" />
258 - </SettingsSection>
259 - </>
260 - );
224 + const page = (
225 + target: SettingsPageTarget,
226 + icon: SettingsListRow["icon"],
227 + label: string,
228 + extra?: Pick<SettingsListRow, "disabled" | "value">,
229 + ): SettingsListRow => ({ id: target, icon, label, target, ...extra });
230 + const serverPage = (target: SettingsPageTarget, icon: SettingsListRow["icon"], label: string) =>
231 + page(target, icon, label, { disabled: noServerTargets });
232 + return [
233 + {
234 + title: "Interface",
235 + rows: [
236 + page("SettingsAppearance", "paintbrush", "Appearance"),
237 + ...(navigationCustomizationAvailable()
238 + ? [page("SettingsNavigation", "line.3.horizontal", "Navigation tabs")]
239 + : []),
240 + ...(Platform.OS === "ios"
241 + ? [
242 + page("SettingsKeyboard", "keyboard", "Keyboard"),
243 + page("SettingsMicrophone", "mic", "Microphone"),
244 + ]
245 + : []),
246 + ],
247 + },
248 + {
249 + title: "Automations",
250 + rows: [page("SettingsScheduledTasks", "clock", "Scheduled tasks")],
251 + },
252 + {
253 + title: "Projects & threads",
254 + rows: [
255 + ...(selectedProjectKey !== null
256 + ? [page("SettingsProjectOverview", "folder", "Overview", { value: projectLabel })]
257 + : []),
258 + page("SettingsOrganization", "folder", "Organization"),
259 + page("SettingsThreads", "text.bubble", "Thread behavior"),
260 + page("SettingsFollowUp", "arrow.turn.left.up", "Follow-ups"),
261 + page("SettingsArchive", "archivebox", "Archived Threads"),
262 + ],
263 + },
264 + {
265 + title: "Server settings",
266 + rows: [
267 + serverPage("SettingsProviderAccounts", "person.crop.circle", "Provider accounts"),
268 + serverPage("SettingsEnvironmentNewThreads", "text.bubble", "New threads"),
269 + serverPage("SettingsEnvironmentSourceControl", "arrow.triangle.branch", "Source control"),
270 + serverPage("SettingsEnvironmentAgentBehavior", "text.alignleft", "Agent behavior"),
271 + serverPage("SettingsEnvironmentMaintenance", "arrow.clockwise", "Maintenance"),
272 + ],
273 + },
274 + {
275 + title: "App",
276 + rows: [page("SettingsAbout", "info.circle", "About T3 Code")],
277 + },
278 + ];
279 }
280
263 -function OverflowSection() {
281 +function useOverflowRows(): SettingsListRow[] {
282 const order = useNavigationTabOrder();
283 const hidden = useHiddenNavigationTabs();
284 const { layout } = useAdaptiveWorkspaceLayout();
285 const tabs =
286 Platform.OS === "android" && layout.usesSplitView ? [] : overflowNavigationTabs(order, hidden);
287 const selectTab = useSelectWorkspaceTab();
270 - return tabs.length ? (
271 - <SettingsSection>
272 - {tabs.map((tab) => (
273 - <SettingsRow
274 - key={tab}
275 - icon={NAVIGATION_TAB_ICONS[tab]}
276 - label={WORKSPACE_TAB_LABELS[tab]}
277 - onPress={() => selectTab(tab)}
278 - />
279 - ))}
280 - </SettingsSection>
281 - ) : null;
288 + return tabs.map((tab) => ({
289 + id: tab,
290 + icon: NAVIGATION_TAB_ICONS[tab],
291 + label: WORKSPACE_TAB_LABELS[tab],
292 + onPress: () => selectTab(tab),
293 + }));
294 }
apps/mobile/src/features/settings/components/SettingsScreen.tsx
+2 -1
@@ -17,7 +17,7 @@ import {
17 export { SettingsScreenContent };
18
19 export function SettingsScreen(
20 - props: Pick<AppBarProps, "title" | "actions" | "trailing"> & {
20 + props: Pick<AppBarProps, "title" | "actions" | "trailing" | "search"> & {
21 readonly children: ReactNode;
22 readonly formSheet?: boolean;
23 readonly workspaceRoot?: boolean;
@@ -44,6 +44,7 @@ export function SettingsScreen(
44 <AppBar
45 title={props.title}
46 actions={props.actions}
47 + search={props.search}
48 trailing={Platform.OS === "android" ? props.trailing : undefined}
49 sidebar={false}
50 onBack={workspaceRoot ? undefined : () => navigation.goBack()}
apps/mobile/src/features/settings/settings-search.test.ts new
+68
@@ -0,0 +1,68 @@
1 +import { describe, expect, it } from "vite-plus/test";
2 +
3 +import { filterSettingsSections } from "./settings-search";
4 +
5 +const SECTIONS = [
6 + { rows: [{ id: "usage", label: "Usage" }] },
7 + {
8 + title: "Connections",
9 + rows: [
10 + { id: "account", label: "T3 Account" },
11 + { id: "SettingsEnvironments", label: "Environments" },
12 + ],
13 + },
14 + {
15 + title: "Interface",
16 + rows: [
17 + { id: "SettingsAppearance", label: "Appearance" },
18 + { id: "SettingsKeyboard", label: "Keyboard" },
19 + ],
20 + },
21 + {
22 + title: "Server settings",
23 + rows: [
24 + { id: "SettingsProviderAccounts", label: "Provider accounts" },
25 + { id: "SettingsEnvironmentSourceControl", label: "Source control" },
26 + ],
27 + },
28 +];
29 +
30 +function visible(query: string) {
31 + return filterSettingsSections(SECTIONS, query).map((section) => [
32 + section.title ?? null,
33 + section.rows.map((row) => row.label),
34 + ]);
35 +}
36 +
37 +describe("filterSettingsSections", () => {
38 + it.each([
39 + {
40 + query: "",
41 + expected: SECTIONS.map((section) => [
42 + section.title ?? null,
43 + section.rows.map((row) => row.label),
44 + ]),
45 + },
46 + { query: " ", expected: visible("") },
47 + { query: "appear", expected: [["Interface", ["Appearance"]]] },
48 + { query: "KEYBOARD", expected: [["Interface", ["Keyboard"]]] },
49 + { query: "dark mode", expected: [["Interface", ["Appearance"]]] },
50 + { query: "branch naming", expected: [["Server settings", ["Source control"]]] },
51 + {
52 + query: "server settings",
53 + expected: [["Server settings", ["Provider accounts", "Source control"]]],
54 + },
55 + {
56 + query: "accounts",
57 + expected: [["Server settings", ["Provider accounts"]]],
58 + },
59 + { query: "usage", expected: [[null, ["Usage"]]] },
60 + { query: "zzzz", expected: [] },
61 + ])("$query", ({ query, expected }) => {
62 + expect(visible(query)).toEqual(expected);
63 + });
64 +
65 + it("drops sections that start empty", () => {
66 + expect(filterSettingsSections([{ rows: [] }, ...SECTIONS], "").length).toBe(SECTIONS.length);
67 + });
68 +});
apps/mobile/src/features/settings/settings-search.ts new
+120
@@ -0,0 +1,120 @@
1 +import { foldSearchQuery, rankSearchItems, scoreSearchTerms } from "@t3tools/shared/paletteSearch";
2 +
3 +import type { SettingsPageTarget } from "./components/settings-page-targets";
4 +
5 +/** What each page holds besides its row's label, so search finds a setting by its own name. */
6 +const SETTINGS_SEARCH_TERMS = {
7 + account: ["sign in", "sign out", "login", "clerk", "connect"],
8 + SettingsEnvironments: [
9 + "servers",
10 + "connections",
11 + "pair",
12 + "add environment",
13 + "remote",
14 + "tailscale",
15 + ],
16 + SettingsNotifications: ["push", "alerts", "live activity", "agent activity"],
17 + SettingsAppearance: [
18 + "theme",
19 + "dark mode",
20 + "light mode",
21 + "colors",
22 + "font size",
23 + "text size",
24 + "code",
25 + "diffs",
26 + "terminal",
27 + "word break",
28 + "math",
29 + ],
30 + SettingsNavigation: ["tabs", "tab order", "reorder", "hide tabs"],
31 + SettingsKeyboard: ["return key", "send message", "new line", "hardware keyboard"],
32 + SettingsMicrophone: ["voice", "dictation", "audio input", "bluetooth"],
33 + SettingsScheduledTasks: ["automations", "schedule", "cron", "recurring", "webhook"],
34 + SettingsProjectOverview: ["project", "checkouts", "worktrees", "delete project"],
35 + SettingsOrganization: ["project grouping", "group projects", "sidebar"],
36 + SettingsThreads: [
37 + "auto-settle",
38 + "settle",
39 + "snooze",
40 + "usage limits",
41 + "auto-resume",
42 + "plan mode",
43 + "working section",
44 + ],
45 + SettingsFollowUp: ["queue", "steer", "while the agent is running"],
46 + SettingsArchive: ["archive", "archived", "restore", "unarchive"],
47 + SettingsProviderAccounts: ["codex", "claude", "cursor", "opencode", "sign in", "login", "auth"],
48 + SettingsEnvironmentNewThreads: [
49 + "default workspace",
50 + "worktree",
51 + "submodules",
52 + "default permissions",
53 + "access",
54 + ],
55 + SettingsEnvironmentSourceControl: [
56 + "git",
57 + "branch naming",
58 + "pull requests",
59 + "co-authors",
60 + "agent credits",
61 + "default branch",
62 + "automatically pull",
63 + "worktrees",
64 + "start from remote",
65 + ],
66 + SettingsEnvironmentAgentBehavior: ["response streaming", "preview browser", "browser access"],
67 + SettingsEnvironmentMaintenance: ["updates", "provider updates", "restart", "manage environments"],
68 + SettingsAbout: [
69 + "version",
70 + "diagnostics",
71 + "client storage",
72 + "cache",
73 + "legal",
74 + "privacy",
75 + "terms",
76 + "open source licenses",
77 + ],
78 +} satisfies Partial<Record<SettingsPageTarget | "account", readonly string[]>>;
79 +const termsById: ReadonlyMap<string, readonly string[]> = new Map(
80 + Object.entries(SETTINGS_SEARCH_TERMS),
81 +);
82 +
83 +export interface SettingsSearchRow {
84 + readonly id: string;
85 + readonly label: string;
86 +}
87 +
88 +export interface SettingsSearchSection<Row extends SettingsSearchRow> {
89 + readonly title?: string;
90 + readonly rows: readonly Row[];
91 +}
92 +
93 +/**
94 + * Keeps the rows whose label, section, or page contents match `query`, in list order, and drops
95 + * sections left empty. Matching is the command palette's, so both searches agree.
96 + */
97 +export function filterSettingsSections<
98 + Row extends SettingsSearchRow,
99 + Section extends SettingsSearchSection<Row>,
100 +>(sections: readonly Section[], query: string): Section[] {
101 + const normalizedQuery = foldSearchQuery(query);
102 + const rows = sections.flatMap((section) =>
103 + section.rows.map((row) => ({ row, section: section.title })),
104 + );
105 + const matched = normalizedQuery
106 + ? new Set(
107 + rankSearchItems(rows, ({ row, section }, options) =>
108 + scoreSearchTerms(
109 + normalizedQuery,
110 + [row.label, ...(section ? [section] : []), ...(termsById.get(row.id) ?? [])],
111 + options,
112 + ),
113 + ).map(({ item }) => item.row),
114 + )
115 + : null;
116 + return sections.flatMap((section) => {
117 + const kept = matched ? section.rows.filter((row) => matched.has(row)) : section.rows;
118 + return kept.length ? [{ ...section, rows: kept }] : [];
119 + });
120 +}
apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
+21 -18
@@ -54,16 +54,17 @@ function WorkspaceRootTitle(props: {
54 readonly maxWidth: number;
55 readonly onOpenEnvironments: () => void;
56 }) {
57 - const { state } = useWorkspaceTabs()!;
57 + const { state, settingsOpen } = useWorkspaceTabs()!;
58 const enabled = useEnabledNavigationTabs();
59 + const tabTitle = settingsOpen
60 + ? "Settings"
61 + : enabled.length
62 + ? TAB_TITLES[state.selectedTab]
63 + : "Navigation";
64 return (
65 <View style={{ width: props.maxWidth, minHeight: 32, justifyContent: "center" }}>
66 <WorkspaceConnectionTitle
62 - brand={
63 - <CompactBrandTitle
64 - accessibilityLabel={`T3 Code, ${enabled.length ? TAB_TITLES[state.selectedTab] : "Navigation"}`}
65 - />
66 - }
67 + brand={<CompactBrandTitle accessibilityLabel={`T3 Code, ${tabTitle}`} />}
68 maxWidth={props.maxWidth}
69 onPress={props.onOpenEnvironments}
70 />
@@ -106,9 +107,9 @@ function WorkspaceRootContent() {
107 ),
108 [width, navigation],
109 );
109 - const tab = state.tabs[state.selectedTab];
110 // Settings is a workspace tab too; its list takes the place of the selected tab's.
111 const settingsOpen = workspace.settingsOpen;
112 + const tab = state.tabs[settingsOpen ? "settings" : state.selectedTab];
113 const bottomClearance =
114 layout.primarySidebarOverlaysContent && state.selectedTab === "usage"
115 ? workspaceDockBottomClearance({ bottomInset: insets.bottom, keyboardHeight })
@@ -164,8 +165,12 @@ function WorkspaceRootContent() {
165 ? { headerSearchBarOptions: undefined, unstable_headerRightItems: () => [] }
166 : {}),
167 unstable_headerLeftItems: () => [],
168 + // Beside a detail column the tab bar names the tab and the detail header the page,
169 + // so the sidebar keeps the brand.
170 headerTitle:
168 - settingsOpen || state.selectedTab === "usage" ? undefined : renderHeaderTitle,
171 + sidebarNavigation || (!settingsOpen && state.selectedTab !== "usage")
172 + ? renderHeaderTitle
173 + : undefined,
174 }}
175 />
176 ) : (
@@ -199,10 +204,7 @@ function WorkspaceRootContent() {
204 }
205 >
206 {settingsOpen ? (
202 - <>
203 - <NativeStackScreenOptions options={{ headerSearchBarOptions: undefined }} />
204 - <SettingsRouteScreen />
205 - </>
207 + <SettingsRouteScreen />
208 ) : enabled.length === 0 ? (
209 <WorkspaceNoTabs />
210 ) : state.selectedTab === "threads" ? (
@@ -216,14 +218,15 @@ function WorkspaceRootContent() {
218 {deviceType !== "pad" && deviceType !== "phone" && sidebarPicker ? (
219 <WorkspaceSidebarTabs />
220 ) : null}
219 - {enabled.length === 0 && !settingsOpen ? null : !settingsOpen &&
220 - (state.selectedTab === "threads" || state.selectedTab === "pullRequests") ? (
221 + {/* Android's Settings list carries its own search in its app bar. */}
222 + {enabled.length === 0 && !settingsOpen ? null : (
223 + settingsOpen
224 + ? Platform.OS === "ios"
225 + : state.selectedTab === "threads" || state.selectedTab === "pullRequests"
226 + ) ? (
227 <WorkspaceToolbar sidebar={sidebarNavigation} onNewTask={startNewTask} />
228 ) : (
223 - <WorkspaceSectionToolbar
224 - onNewTask={startNewTask}
225 - showCompose={!settingsOpen && state.selectedTab !== "usage"}
226 - />
229 + <WorkspaceSectionToolbar onNewTask={startNewTask} showCompose={false} />
230 )}
231 </View>
232 </WorkspaceTabsContext>
apps/mobile/src/features/workspace/WorkspaceTabsContext.tsx
+6 -5
@@ -14,6 +14,7 @@ import {
14 import {
15 initialWorkspaceTabsState,
16 workspaceTabsReducer,
17 + type WorkspaceSearchTab,
18 type WorkspaceTab,
19 type WorkspaceTabsAction,
20 type WorkspaceTabsState,
@@ -25,8 +26,8 @@ export const WorkspaceTabsContext = createContext<{
26 readonly isTabActive: (tab: WorkspaceTab) => boolean;
27 readonly bottomClearance: number;
28 readonly settingsOpen: boolean;
28 - readonly getScrollOffset: (tab: WorkspaceTab) => number;
29 - readonly recordScrollOffset: (tab: WorkspaceTab, offset: number) => void;
29 + readonly getScrollOffset: (tab: WorkspaceSearchTab) => number;
30 + readonly recordScrollOffset: (tab: WorkspaceSearchTab, offset: number) => void;
31 } | null>(null);
32
33 export function useWorkspaceTabs() {
@@ -47,9 +48,9 @@ export function WorkspaceTabsProvider(props: {
48 activeTab.current = state.selectedTab;
49 }, [state.selectedTab]);
50 const isTabActive = useCallback((tab: WorkspaceTab) => activeTab.current === tab, []);
50 - const scrollOffsets = useRef({ threads: 0, pullRequests: 0, usage: 0 });
51 - const getScrollOffset = useCallback((tab: WorkspaceTab) => scrollOffsets.current[tab], []);
52 - const recordScrollOffset = useCallback((tab: WorkspaceTab, offset: number) => {
51 + const scrollOffsets = useRef({ threads: 0, pullRequests: 0, usage: 0, settings: 0 });
52 + const getScrollOffset = useCallback((tab: WorkspaceSearchTab) => scrollOffsets.current[tab], []);
53 + const recordScrollOffset = useCallback((tab: WorkspaceSearchTab, offset: number) => {
54 scrollOffsets.current[tab] = offset;
55 }, []);
56 const context = useMemo(
apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx
+54 -41
@@ -19,6 +19,12 @@ import { useWorkspaceTabs } from "./WorkspaceTabsContext";
19 import { useCompactWorkspaceTabs, useSidebarWorkspaceTabs } from "./useSystemWorkspaceTabBar";
20 import { WorkspaceTabToolbarButtons } from "./WorkspaceSectionToolbar";
21
22 +const SEARCH_LABELS = {
23 + threads: "Search threads",
24 + pullRequests: "Search pull requests",
25 + settings: "Search settings",
26 +} as const;
27 +
28 export function WorkspaceToolbar(props: {
29 readonly onNewTask: () => void;
30 readonly sidebar?: boolean;
@@ -34,15 +40,23 @@ export function WorkspaceToolbar(props: {
40 const nativeToolbarCompose =
41 Platform.OS === "ios" &&
42 deviceType === "duo-folded" &&
43 + !workspace.settingsOpen &&
44 workspace.state.selectedTab === "threads" &&
45 activeNewTask === null;
39 - const { isTabActive } = workspace;
46 const tabActive = use(NativeWorkspaceTabActivityContext)?.active ?? true;
47 const focused = useIsFocused();
48 const { panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
49 const searchRef = useRef<SearchBarCommands>(null);
44 - const tab = workspace.state.tabs[workspace.state.selectedTab];
45 - const selectedTab = workspace.state.selectedTab;
50 + // The Settings list takes the selected tab's place, so search follows it.
51 + const selectedTab = workspace.settingsOpen ? "settings" : workspace.state.selectedTab;
52 + const tab = workspace.state.tabs[selectedTab];
53 + const searchLabel = SEARCH_LABELS[selectedTab === "usage" ? "threads" : selectedTab];
54 + const { isTabActive: isListTabActive } = workspace;
55 + const isTabActive = useCallback(
56 + // A retained tab slot stays mounted while another is shown.
57 + (tab: typeof selectedTab) => (tab === "settings" ? tabActive : isListTabActive(tab)),
58 + [tabActive, isListTabActive],
59 + );
60 const foldedSearch = deviceType === "duo-folded";
61 const primaryColumn = use(NativePrimaryColumnContext);
62 // UIKit hosts integrated search outside the sidebar's sliding content.
@@ -60,11 +74,11 @@ export function WorkspaceToolbar(props: {
74 if (props.sidebar && !panes.primarySidebarVisible) togglePrimarySidebar();
75 }, [workspace, selectedTab, props.sidebar, panes.primarySidebarVisible, togglePrimarySidebar]);
76 const focusSearch = useCallback(() => {
63 - if (!workspace.isTabActive(selectedTab)) return false;
77 + if (!isTabActive(selectedTab)) return false;
78 if (duoSearch || !NATIVE_LIQUID_GLASS_SUPPORTED) enterSearch();
79 searchRef.current?.focus();
80 return true;
67 - }, [workspace, selectedTab, enterSearch, duoSearch]);
81 + }, [isTabActive, selectedTab, enterSearch, duoSearch]);
82 const cancelSearch = useCallback(() => {
83 workspace.recordScrollOffset(selectedTab, tab.searchEntryOffset);
84 workspace.dispatch({ type: "cancel", tab: selectedTab });
@@ -124,13 +138,7 @@ export function WorkspaceToolbar(props: {
138 const searchButton = foldedSearch ? (
139 <Toolbar.Button
140 identifier="workspace-search"
127 - accessibilityLabel={
128 - searchVisible
129 - ? "Close search"
130 - : selectedTab === "pullRequests"
131 - ? "Search pull requests"
132 - : "Search threads"
133 - }
141 + accessibilityLabel={searchVisible ? "Close search" : searchLabel}
142 icon={searchVisible ? "xmark" : "magnifyingglass"}
143 onPress={searchVisible ? () => searchRef.current?.cancelSearch() : focusSearch}
144 separateBackground
@@ -142,8 +150,13 @@ export function WorkspaceToolbar(props: {
150 optionsVersion={[selectedTab, tab.searchMode]}
151 listeners={{ transitionEnd: restoreSearch }}
152 options={{
153 + // Without Liquid Glass, Settings keeps its search field out instead of a search button,
154 + // which would take the header's trailing items from the scope filter.
155 headerSearchBarOptions:
146 - (NATIVE_LIQUID_GLASS_SUPPORTED || tab.searchMode !== "resting") && searchVisible
156 + (NATIVE_LIQUID_GLASS_SUPPORTED ||
157 + tab.searchMode !== "resting" ||
158 + workspace.settingsOpen) &&
159 + searchVisible
160 ? {
161 ref: searchRef,
162 autoFocus: tab.searchMode === "active",
@@ -160,8 +173,7 @@ export function WorkspaceToolbar(props: {
173 NATIVE_LIQUID_GLASS_SUPPORTED &&
174 deviceType !== "phone" &&
175 sidebarTabs !== "picker",
163 - placeholder:
164 - selectedTab === "pullRequests" ? "Search pull requests" : "Search threads",
176 + placeholder: searchLabel,
177 cancelButtonHidden: foldedSearch,
178 onFocus: searchFocused,
179 onBlur: () => workspace.dispatch({ type: "expand", tab: selectedTab }),
@@ -177,32 +189,33 @@ export function WorkspaceToolbar(props: {
189 : undefined,
190 }}
191 />
180 - {/* UIKit lays trailing items out from the edge inward. */}
181 - <Toolbar placement="right">
182 - {searchButton}
183 - {nativeToolbarCompose && foldedSearch ? <Toolbar.Spacer width={8} /> : null}
184 - {composeButton}
185 - {selectedTab !== "threads" ||
186 - isDuoDevice(deviceType) ||
187 - deviceType === "pad" ||
188 - sidebarTabs === "picker" ||
189 - compactTabs ? null : (
190 - <Toolbar.Button
191 - accessibilityLabel="New chat"
192 - icon="square.and.pencil"
193 - onPress={props.onNewTask}
194 - />
195 - )}
196 - {NATIVE_LIQUID_GLASS_SUPPORTED ? null : (
197 - <Toolbar.Button
198 - accessibilityLabel={
199 - selectedTab === "pullRequests" ? "Search pull requests" : "Search threads"
200 - }
201 - icon="magnifyingglass"
202 - onPress={focusSearch}
203 - />
204 - )}
205 - </Toolbar>
192 + {/* UIKit lays trailing items out from the edge inward. A trailing toolbar replaces the
193 + header's own items, so an empty one would hide the Settings scope filter. */}
194 + {workspace.settingsOpen && !foldedSearch ? null : (
195 + <Toolbar placement="right">
196 + {searchButton}
197 + {nativeToolbarCompose && foldedSearch ? <Toolbar.Spacer width={8} /> : null}
198 + {composeButton}
199 + {selectedTab !== "threads" ||
200 + isDuoDevice(deviceType) ||
201 + deviceType === "pad" ||
202 + sidebarTabs === "picker" ||
203 + compactTabs ? null : (
204 + <Toolbar.Button
205 + accessibilityLabel="New chat"
206 + icon="square.and.pencil"
207 + onPress={props.onNewTask}
208 + />
209 + )}
210 + {NATIVE_LIQUID_GLASS_SUPPORTED ? null : (
211 + <Toolbar.Button
212 + accessibilityLabel={searchLabel}
213 + icon="magnifyingglass"
214 + onPress={focusSearch}
215 + />
216 + )}
217 + </Toolbar>
218 + )}
219 <Toolbar placement="bottom">
220 {sidebarTabs === "toolbar" ? <WorkspaceTabToolbarButtons /> : null}
221 {bottomSearch && searchVisible ? <Toolbar.SearchBarSlot /> : null}
apps/mobile/src/features/workspace/workspace-tabs-state.test.ts
+14
@@ -110,6 +110,20 @@ describe("workspace root navigation", () => {
110 expect(workspaceTabsReducer(state, { type: "cancel" }).tabs.threads.scrollOffset).toBe(500);
111 });
112
113 + it("keeps the Settings search apart from the tab Settings opened over", () => {
114 + let state = workspaceTabsReducer(initialWorkspaceTabsState(), {
115 + type: "query",
116 + query: "diff",
117 + tab: "threads",
118 + });
119 + state = workspaceTabsReducer(state, { type: "search", tab: "settings" });
120 + state = workspaceTabsReducer(state, { type: "query", query: "theme", tab: "settings" });
121 + expect(state.tabs.settings).toMatchObject({ query: "theme", searchMode: "active" });
122 + state = workspaceTabsReducer(state, { type: "cancel", tab: "settings" });
123 + expect(state.tabs.settings).toMatchObject({ query: "", searchMode: "resting" });
124 + expect(state.tabs.threads.query).toBe("diff");
125 + });
126 +
127 it("a late native blur cannot reopen a cancelled search", () => {
128 let state = workspaceTabsReducer(initialWorkspaceTabsState(), { type: "search" });
129 state = workspaceTabsReducer(state, { type: "cancel" });
apps/mobile/src/features/workspace/workspace-tabs-state.ts
+10 -7
@@ -12,6 +12,8 @@ export function resolveWorkspaceTabOrder(saved: readonly unknown[] | undefined)
12 }
13
14 export type WorkspaceTab = NavigationTab;
15 +/** Lists with their own search: the searchable tabs and the Settings list. */
16 +export type WorkspaceSearchTab = WorkspaceTab | "settings";
17 export type WorkspaceSearchMode = "resting" | "active" | "expanded";
18
19 /** Settings, Chats and pull requests pair a list with a detail column; Usage is one page. */
@@ -29,7 +31,7 @@ export interface WorkspaceTabState {
31 export interface WorkspaceTabsState {
32 readonly selectedTab: WorkspaceTab;
33 readonly selectionRevision: number;
32 - readonly tabs: Readonly<Record<WorkspaceTab, WorkspaceTabState>>;
34 + readonly tabs: Readonly<Record<WorkspaceSearchTab, WorkspaceTabState>>;
35 }
36
37 function emptyTab(): WorkspaceTabState {
@@ -44,17 +46,18 @@ export function initialWorkspaceTabsState(): WorkspaceTabsState {
46 threads: emptyTab(),
47 pullRequests: emptyTab(),
48 usage: emptyTab(),
49 + settings: emptyTab(),
50 },
51 };
52 }
53
54 export type WorkspaceTabsAction =
55 | { readonly type: "select"; readonly tab: WorkspaceTab }
53 - | { readonly type: "search"; readonly tab?: WorkspaceTab }
54 - | { readonly type: "query"; readonly query: string; readonly tab?: WorkspaceTab }
55 - | { readonly type: "expand"; readonly tab?: WorkspaceTab }
56 - | { readonly type: "cancel"; readonly tab?: WorkspaceTab }
57 - | { readonly type: "scroll"; readonly tab: WorkspaceTab; readonly offset: number };
56 + | { readonly type: "search"; readonly tab?: WorkspaceSearchTab }
57 + | { readonly type: "query"; readonly query: string; readonly tab?: WorkspaceSearchTab }
58 + | { readonly type: "expand"; readonly tab?: WorkspaceSearchTab }
59 + | { readonly type: "cancel"; readonly tab?: WorkspaceSearchTab }
60 + | { readonly type: "scroll"; readonly tab: WorkspaceSearchTab; readonly offset: number };
61
62 export function workspaceTabsReducer(
63 state: WorkspaceTabsState,
@@ -69,7 +72,7 @@ export function workspaceTabsReducer(
72 selectionRevision: state.selectionRevision + 1,
73 };
74 const tab = action.tab ?? state.selectedTab;
72 - if (tab !== "threads" && tab !== "pullRequests") return state;
75 + if (tab !== "threads" && tab !== "pullRequests" && tab !== "settings") return state;
76 const current = state.tabs[tab];
77 let next: WorkspaceTabState;
78 switch (action.type) {