The best way to control Claude Code, Codex and more from any computer or phone
refactor(android): every header goes through AppBar, so the filter stays put (#26741)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 3, 2026 at 16:53 UTC
5e6c4d92d182d7d15250fd65f9dbabc18683aecf
63 files changed
+1065
-670
apps/mobile/assets/icons/filter-filled.xml
new
+7
@@ -0,0 +1,7 @@
1
+<!-- Tabler Icons filter, filled (MIT), matching AppSymbol's line.3.horizontal.decrease.circle.fill. -->
2
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
3
+ android:width="24dp" android:height="24dp"
4
+ android:viewportWidth="24" android:viewportHeight="24">
5
+ <path android:fillColor="#000000"
6
+ android:pathData="M20,3 h-16 a1,1 0 0,0 -1,1 v2.227 l0.008,0.223 a3,3 0 0,0 0.772,1.795 l4.22,4.641 v8.114 a1,1 0 0,0 1.316,0.949 l6,-2 l0.108,-0.043 a1,1 0 0,0 0.576,-0.906 v-6.586 l4.121,-4.12 a3,3 0 0,0 0.879,-2.123 v-2.171 a1,1 0 0,0 -1,-1 z" />
7
+</vector>
apps/mobile/assets/icons/filter.xml
new
+8
@@ -0,0 +1,8 @@
1
+<!-- Tabler Icons filter (MIT), matching AppSymbol's line.3.horizontal.decrease.circle.
2
+ Strokes expanded to fills: Expo UI's vector parser does not support strokes. -->
3
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
4
+ android:width="24dp" android:height="24dp"
5
+ android:viewportWidth="24" android:viewportHeight="24">
6
+ <path android:fillColor="#000000"
7
+ android:pathData="M3,4 A1,1 0 0,1 4,3 L20,3 A1,1 0 0,1 21,4 L21,6.172 A1,1 0 0,1 20.9969,6.2505 L20.9723,6.5633 A1,1 0 0,1 20.9477,6.7183 L20.8745,7.0235 A1,1 0 0,1 20.826,7.1727 L20.7059,7.4627 A1,1 0 0,1 20.6347,7.6025 L20.4707,7.8701 A1,1 0 0,1 20.3778,7.9977 L20.1738,8.2362 A1,1 0 0,1 20.1211,8.2931 L16,12.4142 L16,19 A1,1 0 0,1 15.3162,19.9487 L9.3162,21.9487 A1,1 0 0,1 8,21 L8,12.8866 L3.7801,8.2447 A1,1 0 0,1 3.7328,8.1888 L3.5517,7.9575 A1,1 0 0,1 3.4694,7.8348 L3.3236,7.5783 A1,1 0 0,1 3.2604,7.4451 L3.1539,7.1699 A1,1 0 0,1 3.111,7.0287 L3.0462,6.7409 A1,1 0 0,1 3.0245,6.595 L3.0027,6.3008 A1,1 0 0,1 3,6.227 Z M5,6.1901 L5.0136,6.3737 L5.0459,6.5172 L5.099,6.6544 L5.1716,6.7823 L5.2846,6.9264 L9.7399,11.8273 A1,1 0 0,1 10,12.5 L10,19.6126 L14,18.2792 L14,12 A1,1 0 0,1 14.2929,11.2929 L18.6795,6.9063 L18.8068,6.7576 L18.8883,6.6246 L18.9481,6.4801 L18.9846,6.328 L19,6.1327 L19,5 L5,5 Z" />
8
+</vector>
apps/mobile/assets/icons/search.xml
new
+10
@@ -0,0 +1,10 @@
1
+<!-- Tabler Icons search (MIT), matching AppSymbol's magnifyingglass.
2
+ Strokes expanded to fills: Expo UI's vector parser does not support strokes. -->
3
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
4
+ android:width="24dp" android:height="24dp"
5
+ android:viewportWidth="24" android:viewportHeight="24">
6
+ <path android:fillColor="#000000"
7
+ android:pathData="M2,10 A8,8 0 1,1 18,10 A8,8 0 1,1 2,10 Z M4,10 A6,6 0 1,0 16,10 A6,6 0 1,0 4,10 Z" />
8
+ <path android:fillColor="#000000"
9
+ android:pathData="M14.2929,15.7071 A1,1 0 0,1 15.7071,14.2929 L21.7071,20.2929 A1,1 0 0,1 20.2929,21.7071 Z" />
10
+</vector>
apps/mobile/src/Stack.tsx
+1
-1
@@ -973,7 +973,7 @@ const RootStackConfig = createWorkspaceStackNavigator({
973
screen: ConnectOnboardingRouteScreen,
974
linking: "connect-onboarding",
975
options: {
976
- // Android root formSheets lack a native stack bar; the route provides AndroidSheetHeader.
976
+ // Android root formSheets lack a native stack bar; the route provides its own sheet AppBar.
977
...(Platform.OS === "android" ? { headerShown: false } : SHEET_SOLID_HEADER_OPTIONS),
978
title: "Set up T3 Connect",
979
gestureEnabled: true,
apps/mobile/src/components/ui/AndroidScreenHeader.tsx
-6
@@ -208,9 +208,3 @@ export function AndroidScreenHeader(props: {
208
</View>
209
);
210
}
211
-
212
-export function AndroidSheetHeader(
213
- props: Omit<Parameters<typeof AndroidScreenHeader>[0], "embedded">,
214
-) {
215
- return <AndroidScreenHeader {...props} embedded />;
216
-}
apps/mobile/src/components/ui/AppBar.android.test.tsx
new
+56
@@ -0,0 +1,56 @@
1
+import { act, type ReactNode } from "react";
2
+import { createRoot, type Root } from "react-dom/client";
3
+import { afterEach, expect, it, vi } from "vite-plus/test";
4
+
5
+vi.mock("react-native", () => ({
6
+ View: (props: { readonly children?: ReactNode }) => <div>{props.children}</div>,
7
+ Keyboard: { dismiss: () => {} },
8
+ BackHandler: { addEventListener: () => ({ remove: () => {} }) },
9
+}));
10
+// React Navigation throws this outside a navigator, as for the Arrange threads sheet.
11
+vi.mock("@react-navigation/native", () => ({
12
+ useIsFocused: () => {
13
+ throw new Error("Couldn't find a navigation object.");
14
+ },
15
+}));
16
+vi.mock("./AndroidScreenHeader", () => ({
17
+ AndroidScreenHeader: (props: { readonly title: string }) => <h1>{props.title}</h1>,
18
+}));
19
+vi.mock("./WorkspaceAppBar.android", () => ({
20
+ useHasWorkspaceAppBar: () => false,
21
+ WorkspaceAppBar: () => null,
22
+}));
23
+vi.mock("./Menu", () => ({ Menu: (props: { readonly children?: ReactNode }) => props.children }));
24
+vi.mock("./ScreenHeaderButton.android", () => ({ ScreenHeaderButton: () => null }));
25
+vi.mock("./SearchField", () => ({ SearchField: () => null }));
26
+vi.mock("./useToolbarLayout", () => ({
27
+ useToolbarLayout: () => ({ height: 48, paddingTop: 0, paddingBottom: 0 }),
28
+}));
29
+vi.mock("../../native/StackHeader", () => ({ NativeStackScreenOptions: () => null }));
30
+vi.mock("../../features/layout/workspace-sidebar-toolbar", () => ({
31
+ AndroidWorkspaceSidebarButton: () => null,
32
+}));
33
+vi.mock("../../features/settings/appearance/AppearancePreferencesProvider", () => ({
34
+ useAppearancePreferences: () => ({ themeVariables: {} }),
35
+}));
36
+
37
+import { AppBar } from "./AppBar.android";
38
+
39
+const roots: Root[] = [];
40
+
41
+afterEach(() => {
42
+ for (const root of roots.splice(0)) act(() => root.unmount());
43
+ document.body.innerHTML = "";
44
+});
45
+
46
+it("renders a sheet bar without search outside a navigation container", () => {
47
+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
48
+ const container = document.createElement("div");
49
+ document.body.append(container);
50
+ const root = createRoot(container);
51
+ roots.push(root);
52
+
53
+ act(() => root.render(<AppBar sheet sidebar={false} title="Arrange threads" />));
54
+
55
+ expect(container.textContent).toBe("Arrange threads");
56
+});
apps/mobile/src/components/ui/AppBar.android.tsx
+168
-149
@@ -1,5 +1,5 @@
1
-import { useRef, useState } from "react";
2
-import { Keyboard, Pressable, TextInput, type TextInputInstance, View } from "react-native";
1
+import { type RefObject, useRef, useState } from "react";
2
+import { Keyboard, type TextInputInstance, View } from "react-native";
3
import { useHardwareBack } from "../../lib/backHandler";
4
import { useToolbarLayout } from "./useToolbarLayout";
5
import { NativeStackScreenOptions } from "../../native/StackHeader";
@@ -7,155 +7,166 @@ import { AndroidWorkspaceSidebarButton } from "../../features/layout/workspace-s
7
import { useAppearancePreferences } from "../../features/settings/appearance/AppearancePreferencesProvider";
8
import { AndroidScreenHeader } from "./AndroidScreenHeader";
9
import { ScreenHeaderButton } from "./ScreenHeaderButton.android";
10
-import { SymbolView } from "./AppSymbol";
10
import { Menu } from "./Menu";
11
import { SearchField } from "./SearchField";
12
import { androidHeaderMenuActions, findHeaderMenuAction } from "./headerMenu.android";
14
-import type { AppBarProps } from "./AppBar.types";
15
-import { useAndroidControlSizing } from "./useAndroidControlSizing";
13
+import type { AppBarMenuItem, AppBarProps, AppBarSearch } from "./AppBar.types";
14
+import { useHasWorkspaceAppBar, WorkspaceAppBar } from "./WorkspaceAppBar.android";
15
+
16
+function selectMenuItem(items: ReadonlyArray<AppBarMenuItem>, id: string) {
17
+ const action = findHeaderMenuAction(items, id);
18
+ if (action && !action.disabled) action.onPress();
19
+}
20
+
21
+interface SearchState {
22
+ readonly searching: boolean;
23
+ readonly open: () => void;
24
+ readonly close: () => void;
25
+ readonly inputRef: RefObject<TextInputInstance | null>;
26
+}
27
28
export function AppBar(props: AppBarProps) {
29
+ return props.search ? (
30
+ <SearchableAppBar {...props} search={props.search} />
31
+ ) : (
32
+ <AppBarView {...props} />
33
+ );
34
+}
35
+
36
+// Only a bar with search registers for hardware back: its focus check needs a navigation
37
+// context, and sheet headers such as Arrange threads render outside one.
38
+function SearchableAppBar(props: AppBarProps & { readonly search: AppBarSearch }) {
39
const { search } = props;
19
- const { paddingTop, paddingBottom } = useToolbarLayout();
20
- const { scale, buttonSize, iconSize, smallIconSize } = useAndroidControlSizing();
21
- const { themeVariables } = useAppearancePreferences();
22
- const inputRef = useRef<TextInputInstance>(null);
40
const [searchOpen, setSearchOpen] = useState(false);
24
- const searching = search !== undefined && (searchOpen || search.value.length > 0);
25
- const onSearchChange = search?.onChangeText;
26
- const closeSearch = () => {
27
- onSearchChange?.("");
28
- setSearchOpen(false);
29
- Keyboard.dismiss();
41
+ const inputRef = useRef<TextInputInstance>(null);
42
+ const inline = search.mode === "inline";
43
+ const controlled = search.active !== undefined;
44
+ const searching =
45
+ inline || (controlled ? search.active === true : searchOpen || search.value.length > 0);
46
+ const open = () => {
47
+ if (!controlled) setSearchOpen(true);
48
+ search.onOpen?.();
49
+ inputRef.current?.focus();
50
};
31
- useHardwareBack(searching && search?.mode !== "inline", () => {
32
- closeSearch();
51
+ const close = () => {
52
+ if (!controlled) {
53
+ search.onChangeText("");
54
+ setSearchOpen(false);
55
+ Keyboard.dismiss();
56
+ }
57
+ search.onClose?.();
58
+ };
59
+ useHardwareBack(searching && !inline && !controlled, () => {
60
+ close();
61
return true;
62
});
63
+ return <AppBarView {...props} searchState={{ searching, open, close, inputRef }} />;
64
+}
65
+
66
+function AppBarView(props: AppBarProps & { readonly searchState?: SearchState }) {
67
+ const { search, searchState } = props;
68
+ const { paddingTop, paddingBottom } = useToolbarLayout(props.sheet);
69
+ const { themeVariables } = useAppearancePreferences();
70
+ const inWorkspace = useHasWorkspaceAppBar();
71
+ const inline = search?.mode === "inline";
72
+ const searching = searchState?.searching === true;
73
+ const openSearch = () => searchState?.open();
74
+ const closeSearch = () => searchState?.close();
75
+
76
+ const searchLabel = search?.accessibilityLabel ?? search?.placeholder ?? "";
77
+ const searchField =
78
+ search && searchState ? (
79
+ <SearchField
80
+ inputRef={searchState.inputRef}
81
+ accessibilityLabel={searchLabel}
82
+ clearAccessibilityLabel={search.clearAccessibilityLabel ?? "Clear search"}
83
+ placeholder={
84
+ search.compactToolbar
85
+ ? (search.compactPlaceholder ?? search.placeholder)
86
+ : search.placeholder
87
+ }
88
+ value={search.value}
89
+ onChangeText={search.onChangeText}
90
+ autoFocus={!inline}
91
+ />
92
+ ) : null;
93
+
94
+ if (inWorkspace) {
95
+ const menu = props.menus?.[0];
96
+ const icon = typeof menu?.icon === "string" ? menu.icon : menu?.icon.android;
97
+ return (
98
+ <WorkspaceAppBar
99
+ title={props.title}
100
+ titleContent={props.titleContent}
101
+ search={
102
+ search
103
+ ? {
104
+ accessibilityLabel: searchLabel,
105
+ active: searching,
106
+ field: searchField,
107
+ onOpen: openSearch,
108
+ onClose: closeSearch,
109
+ }
110
+ : undefined
111
+ }
112
+ filter={
113
+ menu
114
+ ? {
115
+ accessibilityLabel: menu.title,
116
+ customized: icon?.endsWith(".fill") === true,
117
+ actions: androidHeaderMenuActions(menu.items),
118
+ onSelect: (id) => selectMenuItem(menu.items, id),
119
+ }
120
+ : undefined
121
+ }
122
+ />
123
+ );
124
+ }
125
+
126
const menuView = props.menus?.map((menu) => (
127
<Menu
128
key={menu.title}
129
actions={androidHeaderMenuActions(menu.items)}
130
isAnchoredToRight
131
title={menu.status ?? menu.title}
41
- onPressAction={({ nativeEvent }) => {
42
- const action = findHeaderMenuAction(menu.items, nativeEvent.event);
43
- if (action && !action.disabled) action.onPress();
44
- }}
132
+ onPressAction={({ nativeEvent }) => selectMenuItem(menu.items, nativeEvent.event)}
133
>
46
- {search?.mode === "inline" ? (
47
- <Pressable
48
- accessibilityLabel={menu.title}
49
- accessibilityRole="button"
50
- className="items-center justify-center rounded-full bg-subtle"
51
- style={{ width: buttonSize, height: buttonSize }}
52
- >
53
- <SymbolView
54
- name={menu.icon}
55
- size={smallIconSize}
56
- tintColorClassName="accent-header-foreground"
57
- type="monochrome"
58
- />
59
- </Pressable>
60
- ) : (
61
- <ScreenHeaderButton accessibilityLabel={menu.title} icon={menu.icon} />
62
- )}
134
+ <ScreenHeaderButton accessibilityLabel={menu.title} icon={menu.icon} />
135
</Menu>
136
));
65
- const options = (
66
- <NativeStackScreenOptions
67
- options={{
68
- ...props.options,
69
- ...(props.matchSearchSurface
70
- ? { contentStyle: { backgroundColor: themeVariables["--color-header"] } }
71
- : undefined),
72
- headerShown: false,
73
- title: props.title,
74
- }}
75
- optionsVersion={props.optionsVersion}
76
- />
77
- );
78
- if (search?.mode === "inline") {
79
- return (
80
- <>
81
- {options}
82
- <View
83
- className="border-b border-header-border bg-header px-3"
84
- style={{
85
- paddingTop,
86
- paddingBottom: 8.75 * scale,
87
- borderBottomWidth: 0,
88
- }}
89
- >
90
- <View className="flex-row items-center gap-2" style={{ minHeight: buttonSize }}>
91
- {props.onBack ? (
92
- <Pressable
93
- accessibilityLabel="Navigate up"
94
- accessibilityRole="button"
95
- hitSlop={8}
96
- onPress={props.onBack}
97
- className="items-center justify-center"
98
- style={{ width: buttonSize, height: buttonSize }}
99
- >
100
- <SymbolView
101
- name="chevron.left"
102
- size={iconSize}
103
- tintColorClassName="accent-header-foreground"
104
- type="monochrome"
105
- />
106
- </Pressable>
107
- ) : null}
108
- <View
109
- className="flex-1 flex-row items-center bg-input"
110
- style={{
111
- minHeight: Math.max(48, 38.5 * scale),
112
- gap: 8.75 * scale,
113
- borderRadius: 14 * scale,
114
- paddingHorizontal: 12.25 * scale,
115
- }}
116
- >
117
- <SymbolView
118
- name="magnifyingglass"
119
- size={Math.round(17 * scale)}
120
- tintColorClassName="accent-header-foreground"
121
- type="monochrome"
122
- />
123
- <TextInput
124
- accessibilityLabel={search.placeholder}
125
- autoCapitalize="none"
126
- onChangeText={search.onChangeText}
127
- value={search.value}
128
- placeholder={
129
- search.compactToolbar
130
- ? (search.compactPlaceholder ?? search.placeholder)
131
- : search.placeholder
132
- }
133
- placeholderTextColorClassName="accent-placeholder"
134
- className="flex-1 text-base font-sans text-header-foreground"
135
- style={{ paddingVertical: 7 * scale }}
136
- />
137
- </View>
138
- {menuView}
139
- </View>
140
- </View>
141
- </>
137
+ const options =
138
+ props.embedded || props.sheet ? null : (
139
+ <NativeStackScreenOptions
140
+ options={{
141
+ ...props.options,
142
+ ...(props.matchSearchSurface
143
+ ? { contentStyle: { backgroundColor: themeVariables["--color-header"] } }
144
+ : undefined),
145
+ headerShown: false,
146
+ title: props.title,
147
+ }}
148
+ optionsVersion={props.optionsVersion}
149
+ />
150
);
143
- }
151
const header = (
152
<AndroidScreenHeader
153
title={props.title}
154
+ titleContent={props.titleContent}
155
subtitle={props.subtitle}
156
onBack={props.onBack}
149
- leading={props.sidebar !== false ? <AndroidWorkspaceSidebarButton /> : undefined}
157
+ leading={
158
+ props.leading ?? (props.sidebar !== false ? <AndroidWorkspaceSidebarButton /> : undefined)
159
+ }
160
+ embedded={props.sheet}
161
hideBottomBorder={props.hideBottomBorder}
162
compact={props.compact}
163
actions={
153
- search
164
+ search && !inline
165
? [
166
{
156
- accessibilityLabel: search.placeholder,
167
+ accessibilityLabel: searchLabel,
168
icon: "magnifyingglass",
158
- onPress: () => setSearchOpen(true),
169
+ onPress: openSearch,
170
},
171
...(search.refreshInToolbar && search.onRefresh
172
? [
@@ -180,46 +191,54 @@ export function AppBar(props: AppBarProps) {
191
}
192
/>
193
);
194
+ if (!search) {
195
+ return (
196
+ <>
197
+ {options}
198
+ {header}
199
+ </>
200
+ );
201
+ }
202
return (
203
<>
204
{options}
186
- {search ? (
187
- <View>
205
+ <View>
206
+ <View
207
+ pointerEvents={searching ? "none" : "auto"}
208
+ accessibilityElementsHidden={searching}
209
+ importantForAccessibility={searching ? "no-hide-descendants" : "auto"}
210
+ style={{ opacity: searching ? 0 : 1 }}
211
+ >
212
+ {header}
213
+ </View>
214
+ {searching ? (
215
<View
189
- pointerEvents={searching ? "none" : "auto"}
190
- accessibilityElementsHidden={searching}
191
- importantForAccessibility={searching ? "no-hide-descendants" : "auto"}
192
- style={{ opacity: searching ? 0 : 1 }}
216
+ className="absolute inset-0 bg-header"
217
+ // Match Material TopAppBar's 4dp icon inset so buttons stay where the bar drew them.
218
+ style={{ paddingTop, paddingBottom, paddingHorizontal: 4 }}
219
>
194
- {header}
195
- </View>
196
- {searching ? (
197
- <View
198
- className="absolute inset-0 bg-header"
199
- // Match Material TopAppBar's navigation inset so the back button stays put.
200
- style={{ paddingTop, paddingBottom, paddingHorizontal: 4 }}
201
- >
202
- <View className="flex-1 flex-row items-center gap-1">
220
+ <View className="flex-1 flex-row items-center gap-1">
221
+ {inline ? (
222
+ props.onBack ? (
223
+ <ScreenHeaderButton
224
+ accessibilityLabel="Navigate up"
225
+ icon="arrow.left"
226
+ onPress={props.onBack}
227
+ />
228
+ ) : null
229
+ ) : (
230
<ScreenHeaderButton
231
accessibilityLabel={search.closeAccessibilityLabel ?? "Close search"}
232
icon="arrow.left"
233
onPress={closeSearch}
234
/>
208
- <SearchField
209
- inputRef={inputRef}
210
- accessibilityLabel={search.placeholder}
211
- clearAccessibilityLabel={search.clearAccessibilityLabel ?? "Clear search"}
212
- placeholder={search.placeholder}
213
- value={search.value}
214
- onChangeText={search.onChangeText}
215
- />
216
- </View>
235
+ )}
236
+ {searchField}
237
+ {inline ? menuView : null}
238
</View>
218
- ) : null}
219
- </View>
220
- ) : (
221
- header
222
- )}
239
+ </View>
240
+ ) : null}
241
+ </View>
242
</>
243
);
244
}
apps/mobile/src/components/ui/AppBar.tsx
+1
@@ -52,6 +52,7 @@ export function AppBar(props: AppBarProps) {
52
usesNativeMailSearchToolbar;
53
const visibleMenus = compactSearch ? (menus?.slice(1) ?? []) : (menus ?? []);
54
const refresh = search?.refreshInToolbar ? search.onRefresh : undefined;
55
+ if (props.embedded || props.sheet) return null;
56
return (
57
<>
58
<NativeStackScreenOptions
apps/mobile/src/components/ui/AppBar.types.ts
+22
-1
@@ -11,6 +11,11 @@ export interface AppBarAction {
11
readonly loading?: boolean;
12
readonly selected?: boolean;
13
readonly tintColor?: ColorValue;
14
+ /** Android overflow menu: the row's second line. */
15
+ readonly subtitle?: string;
16
+ readonly destructive?: boolean;
17
+ /** Android: always in the overflow menu, never a toolbar button. */
18
+ readonly overflowOnly?: boolean;
19
}
20
21
export type AppBarMenuItem =
@@ -18,6 +23,8 @@ export type AppBarMenuItem =
23
readonly id: string;
24
readonly title: string;
25
readonly icon?: string;
26
+ /** Android: tints the icon, such as a label's color dot. */
27
+ readonly iconColor?: ColorValue;
28
readonly subtitle?: string;
29
readonly disabled?: boolean;
30
readonly selected?: boolean;
@@ -43,6 +50,8 @@ export interface AppBarSearch {
50
readonly value: string;
51
readonly onChangeText: (value: string) => void;
52
readonly placeholder: string;
53
+ /** Defaults to the placeholder. */
54
+ readonly accessibilityLabel?: string;
55
readonly mode?: "inline" | "collapsible";
56
readonly compactToolbar?: boolean;
57
readonly compactPlaceholder?: string;
@@ -51,16 +60,28 @@ export interface AppBarSearch {
60
readonly onRefresh?: () => void;
61
readonly refreshAccessibilityLabel?: string;
62
readonly refreshInToolbar?: boolean;
63
+ /** Controlled open state. The owner then also handles back and the keyboard shortcut. */
64
+ readonly active?: boolean;
65
+ readonly onOpen?: () => void;
66
+ readonly onClose?: () => void;
67
}
68
69
export interface AppBarProps {
70
readonly title: string;
58
- readonly subtitle?: string;
71
+ /** Android: replaces the title text, such as the brand title. iOS ignores it. */
72
+ readonly titleContent?: ReactNode;
73
+ readonly subtitle?: string | null;
74
readonly actions?: ReadonlyArray<AppBarAction>;
75
readonly menus?: ReadonlyArray<AppBarMenu>;
76
readonly search?: AppBarSearch;
77
readonly onBack?: () => void;
78
readonly sidebar?: boolean;
79
+ /** Android: replaces the sidebar button at the start of the bar. */
80
+ readonly leading?: ReactNode;
81
+ /** Leaves route options to the screen: in-screen bars, and screens that set their own. iOS draws nothing. */
82
+ readonly embedded?: boolean;
83
+ /** An embedded bar at the top of a sheet. */
84
+ readonly sheet?: boolean;
85
readonly backInSplitView?: {
86
readonly accessibilityLabel: string;
87
readonly icon: string;
apps/mobile/src/components/ui/NativeAppBar.android.tsx
+5
-2
@@ -10,6 +10,8 @@ export function NativeAppBar(props: {
10
readonly title: ReactElement;
11
readonly navigationIcon?: ReactElement;
12
readonly actions?: ReactElement;
13
+ /** Compose nodes laid out by the bar itself, so they never wait on a React Native measure. */
14
+ readonly nativeActions?: ReactElement;
15
/** Shorter bar for a one-row title. */
16
readonly singleLine?: boolean;
17
}) {
@@ -36,9 +38,10 @@ export function NativeAppBar(props: {
38
<RNHostView matchContents>{props.navigationIcon}</RNHostView>
39
</TopAppBar.NavigationIcon>
40
) : null}
39
- {props.actions ? (
41
+ {props.actions || props.nativeActions ? (
42
<TopAppBar.Actions>
41
- <RNHostView matchContents>{props.actions}</RNHostView>
43
+ {props.nativeActions}
44
+ {props.actions ? <RNHostView matchContents>{props.actions}</RNHostView> : null}
45
</TopAppBar.Actions>
46
) : null}
47
</TopAppBar>
apps/mobile/src/components/ui/Sheet.android.tsx
+4
-2
@@ -2,7 +2,7 @@ import { useState } from "react";
2
import { View } from "react-native";
3
import { FormSheet } from "react-native-screens";
4
import { useResolveClassNames } from "uniwind";
5
-import { AndroidSheetHeader } from "./AndroidScreenHeader";
5
+import { AppBar } from "./AppBar";
6
import { RoutedFormSheetContext } from "./RoutedFormSheetContext";
7
import { ScreenContent } from "./ScreenContent";
8
import type { SheetProps } from "./Sheet.types";
@@ -24,7 +24,9 @@ export function Sheet(props: SheetProps) {
24
{/* Android FormSheet does not bound flex children. Material drags target the first scroll view, so place content before the header. */}
25
<View collapsable={false} className="absolute inset-0 flex-col-reverse bg-header">
26
<ScreenContent>{props.children}</ScreenContent>
27
- <AndroidSheetHeader
27
+ <AppBar
28
+ sheet
29
+ sidebar={false}
30
title={props.title}
31
onBack={() => setIsOpen(false)}
32
hideBottomBorder
apps/mobile/src/components/ui/SheetHeader.android.tsx
+5
-3
@@ -1,6 +1,6 @@
1
import { View } from "react-native";
2
3
-import { AndroidScreenHeader } from "./AndroidScreenHeader";
3
+import { AppBar } from "./AppBar";
4
import { Button } from "./Button";
5
import { IconButton } from "./IconButton";
6
import type { SheetCloseButtonProps, SheetHeaderProps } from "./SheetHeader.types";
@@ -36,8 +36,10 @@ export function SheetHeader(props: SheetHeaderProps) {
36
) : undefined;
37
38
return (
39
- <AndroidScreenHeader
40
- embedded={props.presentation === "inline"}
39
+ <AppBar
40
+ embedded
41
+ sheet={props.presentation === "inline"}
42
+ sidebar={false}
43
title={props.title}
44
subtitle={props.subtitle}
45
leading={
apps/mobile/src/components/ui/WorkspaceAppBar.android.tsx
new
+233
@@ -0,0 +1,233 @@
1
+import { Box, Icon, IconButton, RNHostView } from "@expo/ui/jetpack-compose";
2
+import { size } from "@expo/ui/jetpack-compose/modifiers";
3
+import type { MenuAction } from "@react-native-menu/menu";
4
+import {
5
+ createContext,
6
+ use,
7
+ useLayoutEffect,
8
+ useState,
9
+ useSyncExternalStore,
10
+ type ReactNode,
11
+} from "react";
12
+import { Pressable, View } from "react-native";
13
+
14
+import { AndroidAnchoredMenu } from "./AndroidAnchoredMenu";
15
+import { AndroidHeaderIconButton } from "./AndroidScreenHeader";
16
+import { AppText } from "./AppText";
17
+import { NativeAppBar } from "./NativeAppBar.android";
18
+import { useControlTheme } from "./useControlTheme";
19
+import { useToolbarLayout } from "./useToolbarLayout";
20
+
21
+const SEARCH_ICON = require("../../../assets/icons/search.xml");
22
+const FILTER_ICON = require("../../../assets/icons/filter.xml");
23
+const FILTER_FILLED_ICON = require("../../../assets/icons/filter-filled.xml");
24
+// Material TopAppBar: 48dp icon buttons, the last one 4dp from the end.
25
+const ACTION_SIZE = 48;
26
+const ACTION_END_INSET = 4;
27
+
28
+export interface WorkspaceAppBarProps {
29
+ readonly title: string;
30
+ readonly titleContent?: ReactNode;
31
+ readonly search?: {
32
+ readonly accessibilityLabel: string;
33
+ readonly active: boolean;
34
+ readonly field: ReactNode;
35
+ readonly onOpen: () => void;
36
+ readonly onClose: () => void;
37
+ };
38
+ /** Stays trailing while searching, so it never moves and still narrows the results. */
39
+ readonly filter?: {
40
+ readonly accessibilityLabel: string;
41
+ readonly customized: boolean;
42
+ readonly actions: MenuAction[];
43
+ readonly onSelect: (id: string) => void;
44
+ };
45
+}
46
+
47
+function createWorkspaceAppBarStore() {
48
+ let owner: object | null = null;
49
+ let content: WorkspaceAppBarProps | null = null;
50
+ const listeners = new Set<() => void>();
51
+ const emit = () => {
52
+ for (const listener of listeners) listener();
53
+ };
54
+ return {
55
+ subscribe: (listener: () => void) => {
56
+ listeners.add(listener);
57
+ return () => {
58
+ listeners.delete(listener);
59
+ };
60
+ },
61
+ get: () => content,
62
+ set: (nextOwner: object, next: WorkspaceAppBarProps) => {
63
+ owner = nextOwner;
64
+ content = next;
65
+ emit();
66
+ },
67
+ clear: (previousOwner: object) => {
68
+ if (owner !== previousOwner) return;
69
+ owner = null;
70
+ content = null;
71
+ emit();
72
+ },
73
+ };
74
+}
75
+
76
+const WorkspaceAppBarStoreContext = createContext<ReturnType<
77
+ typeof createWorkspaceAppBarStore
78
+> | null>(null);
79
+
80
+/**
81
+ * Hosts one app bar above a set of workspace tab panes. Hidden panes lay out at zero size, and a
82
+ * Compose bar inside one takes frames to measure again when it returns, so the bar lives here and
83
+ * the visible tab projects its contents into it.
84
+ */
85
+export function WorkspaceAppBarScope(props: {
86
+ readonly children: ReactNode;
87
+ /** Off, panes draw their own bars; the children keep their place so toggling keeps their state. */
88
+ readonly enabled?: boolean;
89
+}) {
90
+ const [store] = useState(createWorkspaceAppBarStore);
91
+ const enabled = props.enabled ?? true;
92
+ return (
93
+ <WorkspaceAppBarStoreContext value={enabled ? store : null}>
94
+ {enabled ? <WorkspaceAppBarHost /> : null}
95
+ {props.children}
96
+ </WorkspaceAppBarStoreContext>
97
+ );
98
+}
99
+
100
+function WorkspaceAppBarHost() {
101
+ const store = use(WorkspaceAppBarStoreContext)!;
102
+ const content = useSyncExternalStore(store.subscribe, store.get, store.get);
103
+ return <WorkspaceAppBarView {...(content ?? { title: "" })} />;
104
+}
105
+
106
+export function useHasWorkspaceAppBar() {
107
+ return use(WorkspaceAppBarStoreContext) !== null;
108
+}
109
+
110
+/** Shows a tab's header in the enclosing scope's bar, or inline outside one. */
111
+export function WorkspaceAppBar(props: WorkspaceAppBarProps) {
112
+ const store = use(WorkspaceAppBarStoreContext);
113
+ const [owner] = useState(() => ({}));
114
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- projects this tab's header into the out-of-tree workspace bar after every commit
115
+ useLayoutEffect(() => {
116
+ store?.set(owner, props);
117
+ });
118
+ // Hidden panes destroy their effects, so the tab leaving the screen releases the bar.
119
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- releases the workspace bar when this tab hides or unmounts
120
+ useLayoutEffect(() => (store ? () => store.clear(owner) : undefined), [store, owner]);
121
+ return store ? null : <WorkspaceAppBarView {...props} />;
122
+}
123
+
124
+/**
125
+ * Every tab draws the same bar, so a switch only changes its contents. The actions are Compose nodes
126
+ * and the title host keeps one height: React Native content hosted in Compose lags Compose's layout
127
+ * by a frame whenever its size changes, which showed as the filter jumping between tabs.
128
+ */
129
+function WorkspaceAppBarView(props: WorkspaceAppBarProps) {
130
+ const { search, filter } = props;
131
+ const searching = search?.active === true;
132
+ const { colors } = useControlTheme();
133
+ const tint = colors["--color-header-foreground"];
134
+ const { height, paddingTop, paddingBottom } = useToolbarLayout();
135
+ const filterMenu = filter ? (
136
+ <AndroidAnchoredMenu
137
+ actions={filter.actions}
138
+ onPressAction={({ nativeEvent }) => filter.onSelect(nativeEvent.event)}
139
+ >
140
+ {(open) =>
141
+ searching ? (
142
+ <AndroidHeaderIconButton
143
+ accessibilityLabel={filter.accessibilityLabel}
144
+ icon={
145
+ filter.customized
146
+ ? "line.3.horizontal.decrease.circle.fill"
147
+ : "line.3.horizontal.decrease.circle"
148
+ }
149
+ onPress={open}
150
+ />
151
+ ) : (
152
+ // The bar draws the icon; this takes the touch so the menu can anchor to the slot.
153
+ <Pressable
154
+ accessibilityLabel={filter.accessibilityLabel}
155
+ accessibilityRole="button"
156
+ android_ripple={{ borderless: true, radius: 20 }}
157
+ onPress={open}
158
+ style={{ width: ACTION_SIZE, height: ACTION_SIZE }}
159
+ />
160
+ )
161
+ }
162
+ </AndroidAnchoredMenu>
163
+ ) : null;
164
+ return (
165
+ <View className="bg-header" style={{ paddingTop, paddingBottom }}>
166
+ <View
167
+ pointerEvents={searching ? "none" : "auto"}
168
+ accessibilityElementsHidden={searching}
169
+ importantForAccessibility={searching ? "no-hide-descendants" : "auto"}
170
+ style={{ opacity: searching ? 0 : 1 }}
171
+ >
172
+ <NativeAppBar
173
+ title={
174
+ <RNHostView matchContents={{ vertical: true }}>
175
+ <View collapsable={false} className="justify-center" style={{ height: ACTION_SIZE }}>
176
+ {props.titleContent ?? (
177
+ <AppText textRole="title" numberOfLines={1} className="text-header-foreground">
178
+ {props.title}
179
+ </AppText>
180
+ )}
181
+ </View>
182
+ </RNHostView>
183
+ }
184
+ // Both slots always exist: Expo UI applies a child insert or removal a frame before the
185
+ // other children's new props, so changing the slot count drew the wrong glyph mid-switch.
186
+ nativeActions={
187
+ <>
188
+ <IconButton enabled={search !== undefined} onClick={search?.onOpen}>
189
+ <Icon
190
+ source={SEARCH_ICON}
191
+ size={24}
192
+ tint={search ? tint : "transparent"}
193
+ contentDescription={search?.accessibilityLabel}
194
+ />
195
+ </IconButton>
196
+ <Box contentAlignment="center" modifiers={[size(ACTION_SIZE, ACTION_SIZE)]}>
197
+ <Icon
198
+ source={filter?.customized ? FILTER_FILLED_ICON : FILTER_ICON}
199
+ size={24}
200
+ tint={filter ? tint : "transparent"}
201
+ />
202
+ </Box>
203
+ </>
204
+ }
205
+ />
206
+ {filter && !searching ? (
207
+ <View
208
+ className="absolute"
209
+ style={{ right: ACTION_END_INSET, top: (height - ACTION_SIZE) / 2 }}
210
+ >
211
+ {filterMenu}
212
+ </View>
213
+ ) : null}
214
+ </View>
215
+ {searching ? (
216
+ <View
217
+ className="absolute inset-0 bg-header"
218
+ style={{ paddingTop, paddingBottom, paddingHorizontal: ACTION_END_INSET }}
219
+ >
220
+ <View className="flex-1 flex-row items-center gap-1">
221
+ <AndroidHeaderIconButton
222
+ accessibilityLabel="Close search"
223
+ icon="arrow.left"
224
+ onPress={search.onClose}
225
+ />
226
+ {search.field}
227
+ {filterMenu}
228
+ </View>
229
+ </View>
230
+ ) : null}
231
+ </View>
232
+ );
233
+}
apps/mobile/src/components/ui/headerMenu.android.ts
+1
@@ -20,6 +20,7 @@ export function androidHeaderMenuActions(items: ReadonlyArray<AppBarMenuItem>):
20
title: item.title,
21
subtitle: item.subtitle,
22
image: item.icon,
23
+ imageColor: item.iconColor,
24
state: item.selected ? "on" : undefined,
25
attributes: item.disabled ? { disabled: true } : undefined,
26
},
apps/mobile/src/components/ui/menuActionItems.test.ts
new
+59
@@ -0,0 +1,59 @@
1
+import type { MenuAction } from "@react-native-menu/menu";
2
+import { describe, expect, it, vi } from "vite-plus/test";
3
+
4
+import { androidHeaderMenuActions, findHeaderMenuAction } from "./headerMenu.android";
5
+import { appBarMenuItemsFromActions } from "./menuActionItems";
6
+
7
+describe("appBarMenuItemsFromActions", () => {
8
+ it("round-trips a filter menu through AppBar items back to Android actions", () => {
9
+ const actions: MenuAction[] = [
10
+ {
11
+ id: "labels",
12
+ title: "Labels",
13
+ subactions: [
14
+ {
15
+ id: "label:bug",
16
+ title: "bug",
17
+ image: "circle.fill",
18
+ imageColor: "#d73a4a",
19
+ state: "on",
20
+ },
21
+ { id: "label:docs", title: "docs", subtitle: "3 open", state: "off" },
22
+ ],
23
+ },
24
+ ];
25
+ const onSelect = vi.fn();
26
+
27
+ const items = appBarMenuItemsFromActions(actions, onSelect);
28
+
29
+ expect(androidHeaderMenuActions(items)).toEqual([
30
+ {
31
+ id: "labels",
32
+ title: "Labels",
33
+ image: undefined,
34
+ subactions: [
35
+ {
36
+ id: "label:bug",
37
+ title: "bug",
38
+ subtitle: undefined,
39
+ image: "circle.fill",
40
+ imageColor: "#d73a4a",
41
+ state: "on",
42
+ attributes: undefined,
43
+ },
44
+ {
45
+ id: "label:docs",
46
+ title: "docs",
47
+ subtitle: "3 open",
48
+ image: undefined,
49
+ imageColor: undefined,
50
+ state: undefined,
51
+ attributes: undefined,
52
+ },
53
+ ],
54
+ },
55
+ ]);
56
+ findHeaderMenuAction(items, "label:docs")?.onPress();
57
+ expect(onSelect).toHaveBeenCalledWith("label:docs");
58
+ });
59
+});
apps/mobile/src/components/ui/menuActionItems.ts
new
+29
@@ -0,0 +1,29 @@
1
+import type { MenuAction } from "@react-native-menu/menu";
2
+import type { AppBarMenuItem } from "./AppBar.types";
3
+
4
+/** Adapts a `MenuAction` tree and its selection handler to `AppBar` menu items. */
5
+export function appBarMenuItemsFromActions(
6
+ actions: ReadonlyArray<MenuAction>,
7
+ onSelect: (id: string) => void,
8
+): AppBarMenuItem[] {
9
+ return actions.map((action, index) => {
10
+ const id = action.id ?? String(index);
11
+ return action.subactions?.length
12
+ ? {
13
+ id,
14
+ title: action.title,
15
+ icon: action.image,
16
+ items: appBarMenuItemsFromActions(action.subactions, onSelect),
17
+ }
18
+ : {
19
+ id,
20
+ title: action.title,
21
+ subtitle: action.subtitle,
22
+ icon: action.image,
23
+ iconColor: action.imageColor,
24
+ selected: action.state === "on",
25
+ disabled: action.attributes?.disabled,
26
+ onPress: () => onSelect(id),
27
+ };
28
+ });
29
+}
apps/mobile/src/features/connection/ConnectionsRouteScreen.tsx
+4
-2
@@ -7,7 +7,7 @@ import { useState } from "react";
7
import { Platform, View } from "react-native";
8
import { useSafeAreaInsets } from "react-native-safe-area-context";
9
10
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
10
+import { AppBar } from "../../components/ui/AppBar";
11
import { useRemoteConnections } from "../../state/use-remote-environment-registry";
12
import { LocalEnvironmentList } from "./LocalEnvironmentList";
13
import { PullRequestRoutingSettings } from "./PullRequestRoutingSettings";
@@ -31,7 +31,9 @@ export function ConnectionsRouteScreen() {
31
return (
32
<View collapsable={false} className="flex-1 bg-sheet">
33
{Platform.OS === "android" ? (
34
- <AndroidScreenHeader
34
+ <AppBar
35
+ embedded
36
+ sidebar={false}
37
title="Environments"
38
onBack={() => navigation.goBack()}
39
actions={[
apps/mobile/src/features/files/AttachmentFileScreen.tsx
+5
-5
@@ -11,10 +11,8 @@ import {
11
import { useRef, useState } from "react";
12
import { Platform, View } from "react-native";
13
14
-import {
15
- AndroidHeaderIconButton,
16
- AndroidScreenHeader,
17
-} from "../../components/ui/AndroidScreenHeader";
14
+import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
15
+import { AppBar } from "../../components/ui/AppBar";
16
import { Menu } from "../../components/ui/Menu";
17
import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
18
import { useAttachmentDocument } from "../../lib/attachmentDocument";
@@ -241,7 +239,9 @@ export function AttachmentFileScreen(props: AttachmentFileScreenProps) {
239
}}
240
/>
241
{isAndroid ? (
244
- <AndroidScreenHeader
242
+ <AppBar
243
+ embedded
244
+ sidebar={false}
245
title={params.name}
246
subtitle={subtitle}
247
onBack={handleBack}
apps/mobile/src/features/files/FilesHeader.tsx
+5
-5
@@ -1,10 +1,8 @@
1
import { useRef, useState, type ReactNode } from "react";
2
import { Keyboard, type TextInputInstance, View } from "react-native";
3
4
-import {
5
- AndroidHeaderIconButton,
6
- AndroidScreenHeader,
7
-} from "../../components/ui/AndroidScreenHeader";
4
+import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
5
+import { AppBar } from "../../components/ui/AppBar";
6
import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
7
import { SearchField } from "../../components/ui/SearchField";
8
import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
@@ -43,7 +41,9 @@ export function FilesHeader(props: {
41
importantForAccessibility={searching ? "no-hide-descendants" : "auto"}
42
style={{ opacity: searching ? 0 : 1 }}
43
>
46
- <AndroidScreenHeader
44
+ <AppBar
45
+ embedded
46
+ sidebar={false}
47
title="Files"
48
subtitle={props.projectName}
49
hideBottomBorder
apps/mobile/src/features/files/ZipArchiveView.test.tsx
+2
-1
@@ -125,7 +125,8 @@ vi.mock("../../components/ui/Toolbar", () => {
125
}),
126
};
127
});
128
-vi.mock("../../components/ui/AndroidScreenHeader", () => ({ AndroidScreenHeader: () => null }));
128
+vi.mock("../../components/ui/AppBar", () => ({ AppBar: () => null }));
129
+vi.mock("../../components/ui/AndroidScreenHeader", () => ({ AndroidHeaderIconButton: () => null }));
130
vi.mock("../../components/ui/Menu", () => ({ Menu: () => null }));
131
vi.mock("../../components/ui/AppSymbol", () => ({ SymbolView: () => null }));
132
vi.mock("../../components/ui/Progress", () => ({ Progress: () => null }));
apps/mobile/src/features/files/ZipArchiveView.tsx
+7
-3
@@ -20,7 +20,7 @@ import { Keyboard, Platform, Pressable, ScrollView, TextInput, View } from "reac
20
import { useSafeAreaInsets } from "react-native-safe-area-context";
21
22
import { PierreEntryIcon } from "../../components/PierreEntryIcon";
23
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
23
+import { AppBar } from "../../components/ui/AppBar";
24
import { SymbolView } from "../../components/ui/AppSymbol";
25
import { AppText as Text } from "../../components/ui/AppText";
26
import { Button } from "../../components/ui/Button";
@@ -306,7 +306,9 @@ function ZipArchiveHeader(props: {
306
}}
307
/>
308
{isAndroid ? (
309
- <AndroidScreenHeader
309
+ <AppBar
310
+ embedded
311
+ sidebar={false}
312
title={props.name}
313
subtitle={props.subtitle}
314
onBack={() => {
@@ -756,7 +758,9 @@ function ZipEntryView(props: {
758
}}
759
/>
760
{isAndroid ? (
759
- <AndroidScreenHeader
761
+ <AppBar
762
+ embedded
763
+ sidebar={false}
764
title={entry.name}
765
subtitle={subtitle}
766
onBack={props.onBack}
apps/mobile/src/features/home/HomeHeader.android.tsx
+1
-1
@@ -90,7 +90,7 @@ export function HomeHeader(props: HomeHeaderProps) {
90
onSearchQueryChange={props.onSearchQueryChange}
91
filterActions={menuActions}
92
filterCustomized={hasCustomListOptions}
93
- onFilterAction={handleMenuAction}
93
+ onFilterSelect={(event) => handleMenuAction({ nativeEvent: { event } })}
94
onOpenEnvironments={props.onOpenEnvironments}
95
/>
96
</>
apps/mobile/src/features/home/HomeRouteScreen.tsx
+2
-2
@@ -24,7 +24,7 @@ import { useSavedRemoteConnections } from "../../state/use-remote-environment-re
24
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
25
import { useDeviceType, useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
26
import { WorkspaceEmptyDetail } from "../layout/WorkspaceEmptyDetail";
27
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
27
+import { AppBar } from "../../components/ui/AppBar";
28
import { AndroidHomeFabLayout } from "./AndroidHomeFab";
29
import { HomeScreen } from "./HomeScreen";
30
import { HomeHeader } from "./HomeHeader";
@@ -185,7 +185,7 @@ export function HomeRouteScreen() {
185
/>
186
</Toolbar>
187
) : null}
188
- {Platform.OS === "android" ? <AndroidScreenHeader title="Threads" /> : null}
188
+ {Platform.OS === "android" ? <AppBar embedded sidebar={false} title="Threads" /> : null}
189
<WorkspaceEmptyDetail
190
onAddConnection={
191
Platform.OS === "android" && !catalogState.hasConnections
apps/mobile/src/features/home/ThreadListToolbar.android.tsx
new
+90
@@ -0,0 +1,90 @@
1
+import { useEffect, useState } from "react";
2
+import { useNavigation, useNavigationState } from "@react-navigation/native";
3
+import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
4
+import { BackHandler, Keyboard } from "react-native";
5
+
6
+import { AppBar } from "../../components/ui/AppBar";
7
+import { appBarMenuItemsFromActions } from "../../components/ui/menuActionItems";
8
+import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
9
+import { WorkspaceBrandTitle } from "../workspace/WorkspaceBrandTitle";
10
+import { useWorkspaceConnectionState } from "../../state/workspace";
11
+import type { ThreadListToolbarProps } from "./ThreadListToolbar.types";
12
+
13
+export function ThreadListToolbar(props: ThreadListToolbarProps) {
14
+ const navigation = useNavigation();
15
+ const workspace = useWorkspaceTabs();
16
+ const isTabActive = workspace?.isTabActive;
17
+ const homeFocused = useNavigationState((state) => state.routes[state.index]?.name === "Home");
18
+ const listFocused =
19
+ homeFocused && (workspace === null || workspace.state.selectedTab === "threads");
20
+ const connectionState = useWorkspaceConnectionState();
21
+ const { onRequestVisibility, onSearchQueryChange } = props;
22
+ const [searchOpen, setSearchOpen] = useState(false);
23
+ const searching = searchOpen || props.searchQuery.length > 0;
24
+ const openSearch = () => {
25
+ onRequestVisibility?.();
26
+ setSearchOpen(true);
27
+ return true;
28
+ };
29
+ useHardwareKeyboardCommand("focusSearch", openSearch);
30
+
31
+ const closeSearch = () => {
32
+ onSearchQueryChange("");
33
+ setSearchOpen(false);
34
+ Keyboard.dismiss();
35
+ };
36
+
37
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes to BackHandler while searching to close search on Android back
38
+ useEffect(() => {
39
+ if (!searching || !listFocused) return;
40
+ const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
41
+ // Frozen Home screens can keep effects alive after a detail route opens.
42
+ const state = navigation.getState();
43
+ if (
44
+ !state ||
45
+ state.routes[state.index]?.name !== "Home" ||
46
+ isTabActive?.("threads") === false
47
+ )
48
+ return false;
49
+ if (Keyboard.isVisible()) Keyboard.dismiss();
50
+ else closeSearch();
51
+ return true;
52
+ });
53
+ return () => subscription.remove();
54
+ }, [closeSearch, searching, listFocused, navigation, isTabActive]);
55
+
56
+ return (
57
+ <AppBar
58
+ title="T3 Code"
59
+ titleContent={
60
+ <WorkspaceBrandTitle
61
+ accessibilityLabel="T3 Code, Threads"
62
+ onOpenEnvironments={props.onOpenEnvironments}
63
+ />
64
+ }
65
+ sidebar={false}
66
+ search={{
67
+ value: props.searchQuery,
68
+ onChangeText: onSearchQueryChange,
69
+ placeholder: "Search",
70
+ accessibilityLabel: "Search threads",
71
+ active: searching,
72
+ onOpen: openSearch,
73
+ onClose: closeSearch,
74
+ }}
75
+ menus={
76
+ connectionState.hasConnections
77
+ ? [
78
+ {
79
+ title: "Filter threads",
80
+ icon: props.filterCustomized
81
+ ? "line.3.horizontal.decrease.circle.fill"
82
+ : "line.3.horizontal.decrease.circle",
83
+ items: appBarMenuItemsFromActions(props.filterActions, props.onFilterSelect),
84
+ },
85
+ ]
86
+ : undefined
87
+ }
88
+ />
89
+ );
90
+}
apps/mobile/src/features/home/ThreadListToolbar.tsx
+4
-119
@@ -1,121 +1,6 @@
1
-import { useEffect, useRef, useState, type ComponentProps } from "react";
2
-import { useNavigation, useNavigationState } from "@react-navigation/native";
3
-import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
4
-import {
5
- BackHandler,
6
- Keyboard,
7
- type TextInputInstance,
8
- View,
9
- type LayoutChangeEvent,
10
-} from "react-native";
11
-import type { MenuAction } from "@react-native-menu/menu";
1
+import type { ThreadListToolbarProps } from "./ThreadListToolbar.types";
2
13
-import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
14
-import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
15
-import { Menu } from "../../components/ui/Menu";
16
-import { SearchField } from "../../components/ui/SearchField";
17
-import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
18
-import { WorkspaceListToolbarRow } from "../workspace/WorkspaceListToolbarRow";
19
-import { useWorkspaceConnectionState } from "../../state/workspace";
20
-import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
21
-
22
-export function ThreadListToolbar(props: {
23
- readonly searchQuery: string;
24
- readonly onSearchQueryChange: (query: string) => void;
25
- readonly filterActions: MenuAction[];
26
- readonly filterCustomized: boolean;
27
- readonly onFilterAction: NonNullable<ComponentProps<typeof Menu>["onPressAction"]>;
28
- readonly onOpenEnvironments: () => void;
29
- readonly sidebar?: boolean;
30
- readonly onLayout?: (event: LayoutChangeEvent) => void;
31
- readonly onRequestVisibility?: () => void;
32
-}) {
33
- const navigation = useNavigation();
34
- const workspace = useWorkspaceTabs();
35
- const isTabActive = workspace?.isTabActive;
36
- const homeFocused = useNavigationState((state) => state.routes[state.index]?.name === "Home");
37
- const listFocused =
38
- homeFocused && (workspace === null || workspace.state.selectedTab === "threads");
39
- const { paddingTop, paddingBottom } = useToolbarLayout();
40
- const connectionState = useWorkspaceConnectionState();
41
- const { onRequestVisibility, onSearchQueryChange } = props;
42
- const searchRef = useRef<TextInputInstance>(null);
43
- const [searchOpen, setSearchOpen] = useState(false);
44
- const searching = searchOpen || props.searchQuery.length > 0;
45
- const openSearch = () => {
46
- onRequestVisibility?.();
47
- setSearchOpen(true);
48
- searchRef.current?.focus();
49
- return true;
50
- };
51
- useHardwareKeyboardCommand("focusSearch", openSearch);
52
-
53
- const closeSearch = () => {
54
- onSearchQueryChange("");
55
- setSearchOpen(false);
56
- Keyboard.dismiss();
57
- };
58
-
59
- // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes to BackHandler while searching to close search on Android back
60
- useEffect(() => {
61
- if (!searching || !listFocused) return;
62
- const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
63
- // Frozen Home screens can keep effects alive after a detail route opens.
64
- const state = navigation.getState();
65
- if (
66
- !state ||
67
- state.routes[state.index]?.name !== "Home" ||
68
- isTabActive?.("threads") === false
69
- )
70
- return false;
71
- if (Keyboard.isVisible()) Keyboard.dismiss();
72
- else closeSearch();
73
- return true;
74
- });
75
- return () => subscription.remove();
76
- }, [closeSearch, searching, listFocused, navigation, isTabActive]);
77
-
78
- const filterIcon = props.filterCustomized
79
- ? "line.3.horizontal.decrease.circle.fill"
80
- : "line.3.horizontal.decrease.circle";
81
- const searchField = (
82
- <SearchField
83
- inputRef={searchRef}
84
- accessibilityLabel="Search threads"
85
- clearAccessibilityLabel="Clear search"
86
- placeholder="Search"
87
- value={props.searchQuery}
88
- onChangeText={onSearchQueryChange}
89
- />
90
- );
91
- const filterButton = connectionState.hasConnections ? (
92
- <AndroidAnchoredMenu actions={props.filterActions} onPressAction={props.onFilterAction}>
93
- {(open) => (
94
- <AndroidHeaderIconButton
95
- accessibilityLabel="Filter threads"
96
- icon={filterIcon}
97
- onPress={open}
98
- />
99
- )}
100
- </AndroidAnchoredMenu>
101
- ) : null;
102
-
103
- return (
104
- <View
105
- onLayout={props.onLayout}
106
- className={props.sidebar ? "absolute inset-x-0 top-0 z-[4] bg-header px-2" : "bg-header px-2"}
107
- style={{ paddingTop, paddingBottom }}
108
- >
109
- <WorkspaceListToolbarRow
110
- searching={searching}
111
- searchField={searchField}
112
- onCloseSearch={closeSearch}
113
- onOpenSearch={openSearch}
114
- searchAccessibilityLabel="Search threads"
115
- titleAccessibilityLabel="T3 Code, Threads"
116
- onOpenEnvironments={props.onOpenEnvironments}
117
- filter={filterButton}
118
- />
119
- </View>
120
- );
3
+/** iOS lists use native header items; only Android draws this toolbar. */
4
+export function ThreadListToolbar(_props: ThreadListToolbarProps) {
5
+ return null;
6
}
apps/mobile/src/features/home/ThreadListToolbar.types.ts
new
+11
@@ -0,0 +1,11 @@
1
+import type { MenuAction } from "@react-native-menu/menu";
2
+
3
+export interface ThreadListToolbarProps {
4
+ readonly searchQuery: string;
5
+ readonly onSearchQueryChange: (query: string) => void;
6
+ readonly filterActions: MenuAction[];
7
+ readonly filterCustomized: boolean;
8
+ readonly onFilterSelect: (id: string) => void;
9
+ readonly onOpenEnvironments: () => void;
10
+ readonly onRequestVisibility?: () => void;
11
+}
apps/mobile/src/features/pull-requests/PullRequestDiscussionScreen.tsx
+4
-2
@@ -14,7 +14,7 @@ import { KeyboardAvoidingView, useKeyboardState } from "react-native-keyboard-co
14
import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
15
import { useSafeAreaInsets } from "react-native-safe-area-context";
16
import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";
17
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
17
+import { AppBar } from "../../components/ui/AppBar";
18
import { Button } from "../../components/ui/Button";
19
import { GlassSurface } from "../../components/ui/GlassSurface";
20
import { NativeStackScreenOptions } from "../../native/StackHeader";
@@ -140,7 +140,9 @@ function Discussion({ params }: { params: PullRequestParams & { readonly discuss
140
options={{ title: "Discussion", unstable_headerSubtitle: `#${params.number}` }}
141
/>
142
{Platform.OS === "android" ? (
143
- <AndroidScreenHeader
143
+ <AppBar
144
+ embedded
145
+ sidebar={false}
146
title="Discussion"
147
subtitle={`#${params.number}`}
148
onBack={() => navigation.goBack()}
apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
+8
-4
@@ -65,7 +65,7 @@ import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeS
65
import { useSafeAreaInsets } from "react-native-safe-area-context";
66
67
import { AppText as Text } from "../../components/ui/AppText";
68
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
68
+import { AppBar } from "../../components/ui/AppBar";
69
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
70
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
71
import { AndroidWorkspaceSidebarButton } from "../layout/workspace-sidebar-toolbar";
@@ -486,7 +486,9 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
486
optionsVersion={[layout.usesSplitView, sidebarHeaderItem]}
487
/>
488
{Platform.OS === "android" ? (
489
- <AndroidScreenHeader
489
+ <AppBar
490
+ embedded
491
+ sidebar={false}
492
title={`#${params.number}${connected ? "" : " · Offline"}`}
493
subtitle={params.repository}
494
onBack={layout.usesSplitView ? undefined : returnToList}
@@ -957,7 +959,7 @@ export function PullRequestFileRouteScreen(props: PullRequestFileRouteProps) {
959
<View className="flex-1 bg-screen">
960
<NativeStackScreenOptions options={{ title, headerTitle: title }} />
961
{Platform.OS === "android" ? (
960
- <AndroidScreenHeader title={title} onBack={() => navigation.goBack()} />
962
+ <AppBar embedded sidebar={false} title={title} onBack={() => navigation.goBack()} />
963
) : null}
964
<View className="flex-1 items-center justify-center">
965
<AppActivityIndicator accessibilityLabel="Loading changes" />
@@ -1154,7 +1156,9 @@ function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
1156
}}
1157
/>
1158
{Platform.OS === "android" ? (
1157
- <AndroidScreenHeader
1159
+ <AppBar
1160
+ embedded
1161
+ sidebar={false}
1162
title={title}
1163
onBack={() => navigation.goBack()}
1164
trailing={
apps/mobile/src/features/pull-requests/PullRequestSearchSheet.tsx
+4
-2
@@ -2,7 +2,7 @@ import { useNavigation } from "@react-navigation/native";
2
import { useRef, type ReactNode } from "react";
3
import { Platform, View, type TextInputInstance } from "react-native";
4
5
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
5
+import { AppBar } from "../../components/ui/AppBar";
6
import { SearchField } from "../../components/ui/SearchField";
7
import { SheetHeader } from "../../components/ui/SheetHeader";
8
import { Toolbar } from "../../components/ui/Toolbar";
@@ -37,7 +37,9 @@ export function PullRequestSearchSheet(props: {
37
if (Platform.OS === "android") {
38
return (
39
<View className="flex-1 bg-sheet" collapsable={false}>
40
- <AndroidScreenHeader
40
+ <AppBar
41
+ embedded
42
+ sidebar={false}
43
title={props.title}
44
hideBottomBorder
45
onBack={() => navigation.goBack()}
apps/mobile/src/features/pull-requests/PullRequestToolbar.android.tsx
+37
-51
@@ -1,17 +1,15 @@
1
import { useNavigation } from "@react-navigation/native";
2
-import { useEffect, useRef } from "react";
3
-import { BackHandler, Keyboard, View, type TextInputInstance } from "react-native";
4
-import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
5
-import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
6
-import { SearchField } from "../../components/ui/SearchField";
7
-import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
2
+import { useEffect } from "react";
3
+import { BackHandler, Keyboard } from "react-native";
4
+import { AppBar } from "../../components/ui/AppBar";
5
+import { appBarMenuItemsFromActions } from "../../components/ui/menuActionItems";
6
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
9
-import { WorkspaceListToolbarRow } from "../workspace/WorkspaceListToolbarRow";
7
+import { WorkspaceBrandTitle } from "../workspace/WorkspaceBrandTitle";
8
import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
9
import type { PullRequestFilterMenu } from "./PullRequestListFilters";
10
import { openSettings } from "../settings/settings-navigation";
11
14
-/** PR search shares the thread list's Android header row. */
12
+/** PR search shares the thread list's Android header. */
13
export function PullRequestToolbar(props: {
14
readonly filters: PullRequestFilterMenu | null;
15
readonly onRequestVisibility?: () => void;
@@ -22,7 +20,6 @@ export function PullRequestToolbar(props: {
20
const { dispatch, getScrollOffset, recordScrollOffset, isTabActive } = workspace;
21
const { onRequestVisibility } = props;
22
const tab = workspace.state.tabs.pullRequests;
25
- const input = useRef<TextInputInstance>(null);
23
const searching = tab.searchMode !== "resting";
24
const openSearch = () => {
25
onRequestVisibility?.();
@@ -32,7 +29,6 @@ export function PullRequestToolbar(props: {
29
offset: getScrollOffset("pullRequests"),
30
});
31
dispatch({ type: "search", tab: "pullRequests" });
35
- input.current?.focus();
32
return true;
33
};
34
useHardwareKeyboardCommand("focusSearch", openSearch);
@@ -56,47 +52,37 @@ export function PullRequestToolbar(props: {
52
});
53
return () => subscription.remove();
54
}, [searching, closeSearch, navigation, isTabActive]);
59
- const { paddingTop, paddingBottom } = useToolbarLayout();
55
return (
61
- <View className="bg-header px-2" style={{ paddingTop, paddingBottom }}>
62
- <WorkspaceListToolbarRow
63
- searching={searching}
64
- searchField={
65
- <SearchField
66
- inputRef={input}
67
- accessibilityLabel="Search pull requests"
68
- clearAccessibilityLabel="Clear search"
69
- placeholder="Search pull requests"
70
- value={tab.query}
71
- onChangeText={(query) => dispatch({ type: "query", tab: "pullRequests", query })}
72
- />
73
- }
74
- onCloseSearch={closeSearch}
75
- onOpenSearch={openSearch}
76
- searchAccessibilityLabel="Search pull requests"
77
- titleAccessibilityLabel="T3 Code, Pull requests"
78
- onOpenEnvironments={() => openSettings(navigation, "SettingsEnvironments")}
79
- filter={
80
- filters ? (
81
- <AndroidAnchoredMenu
82
- actions={filters.actions}
83
- onPressAction={({ nativeEvent }) => filters.onSelect(nativeEvent.event)}
84
- >
85
- {(open) => (
86
- <AndroidHeaderIconButton
87
- accessibilityLabel="Filter pull requests"
88
- icon={
89
- filters.customized
90
- ? "line.3.horizontal.decrease.circle.fill"
91
- : "line.3.horizontal.decrease.circle"
92
- }
93
- onPress={open}
94
- />
95
- )}
96
- </AndroidAnchoredMenu>
97
- ) : null
98
- }
99
- />
100
- </View>
56
+ <AppBar
57
+ title="T3 Code"
58
+ titleContent={
59
+ <WorkspaceBrandTitle
60
+ accessibilityLabel="T3 Code, Pull requests"
61
+ onOpenEnvironments={() => openSettings(navigation, "SettingsEnvironments")}
62
+ />
63
+ }
64
+ sidebar={false}
65
+ search={{
66
+ value: tab.query,
67
+ onChangeText: (query) => dispatch({ type: "query", tab: "pullRequests", query }),
68
+ placeholder: "Search pull requests",
69
+ active: searching,
70
+ onOpen: openSearch,
71
+ onClose: closeSearch,
72
+ }}
73
+ menus={
74
+ filters
75
+ ? [
76
+ {
77
+ title: "Filter pull requests",
78
+ icon: filters.customized
79
+ ? "line.3.horizontal.decrease.circle.fill"
80
+ : "line.3.horizontal.decrease.circle",
81
+ items: appBarMenuItemsFromActions(filters.actions, filters.onSelect),
82
+ },
83
+ ]
84
+ : undefined
85
+ }
86
+ />
87
);
88
}
apps/mobile/src/features/pull-requests/guide/PullRequestGuideScreen.tsx
+4
-2
@@ -5,7 +5,7 @@ import type { FileDiffMetadata } from "@pierre/diffs";
5
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
6
import { useEffect } from "react";
7
import { Platform, Pressable, View } from "react-native";
8
-import { AndroidScreenHeader } from "../../../components/ui/AndroidScreenHeader";
8
+import { AppBar } from "../../../components/ui/AppBar";
9
import { useSafeAreaInsets } from "react-native-safe-area-context";
10
import {
11
letterStopNotes,
@@ -139,7 +139,9 @@ export function PullRequestGuideStopScreen({ route }: StaticScreenProps<GuideSto
139
}}
140
/>
141
{Platform.OS === "android" ? (
142
- <AndroidScreenHeader
142
+ <AppBar
143
+ embedded
144
+ sidebar={false}
145
title={`Stop ${route.params.position + 1}`}
146
onBack={() => navigation.goBack()}
147
trailing={
apps/mobile/src/features/review/ReviewSheet.tsx
+3
-2
@@ -28,7 +28,6 @@ import { NativeInspectorContent } from "../../native/NativeInspectorContent";
28
29
import { AppText as Text } from "../../components/ui/AppText";
30
import { SymbolView } from "../../components/ui/AppSymbol";
31
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
31
import { ScreenContent } from "../../components/ui/ScreenContent";
32
import { cn } from "../../lib/cn";
33
import { environmentCatalog } from "../../connection/catalog";
@@ -398,7 +397,9 @@ function ReviewFileNavigator({
397
}
398
>
399
{Platform.OS === "android" ? (
401
- <AndroidScreenHeader
400
+ <AppBar
401
+ embedded
402
+ sidebar={false}
403
title="Changed files"
404
subtitle={`${files.length} ${files.length === 1 ? "file" : "files"}`}
405
hideBottomBorder
apps/mobile/src/features/settings/SettingsKeyboardRouteScreen.tsx
+2
-2
@@ -5,7 +5,7 @@ import { AsyncResult } from "effect/reactivity";
5
import { Platform, View } from "react-native";
6
import { useSafeAreaInsets } from "react-native-safe-area-context";
7
8
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
8
+import { AppBar } from "../../components/ui/AppBar";
9
import { AppText as Text } from "../../components/ui/AppText";
10
import { NativeStackScreenOptions } from "../../native/StackHeader";
11
import {
@@ -48,7 +48,7 @@ export function SettingsKeyboardRouteScreen() {
48
{Platform.OS === "android" ? (
49
<>
50
<NativeStackScreenOptions options={{ headerShown: false }} />
51
- <AndroidScreenHeader title="Keyboard" onBack={() => navigation.goBack()} />
51
+ <AppBar embedded sidebar={false} title="Keyboard" onBack={() => navigation.goBack()} />
52
</>
53
) : null}
54
<ScrollView
apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx
+3
-2
@@ -39,7 +39,7 @@ import { SettingsSection } from "./components/SettingsSection";
39
import { ListActionRow as SettingsActionRow } from "../../components/ui/ListActionRow";
40
import { SettingsSwitchRow } from "./components/SettingsSwitchRow";
41
import {
42
- AndroidSettingsEnvironmentFilter,
42
+ useSettingsEnvironmentMenu,
43
SettingsEnvironmentFilterHeader,
44
} from "./components/SettingsEnvironmentFilterHeader";
45
import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-environment-filter";
@@ -49,6 +49,7 @@ import { DEFAULT_SETTINGS_PAGE } from "../workspace/workspace-tab-navigation";
49
import { readUnloadedThreadCount } from "../../state/olderSettledShelf";
50
51
export function SettingsProjectOverviewRouteScreen() {
52
+ const environmentMenu = useSettingsEnvironmentMenu();
53
const insets = useSafeAreaInsets();
54
const [isRemoving, setIsRemoving] = useState(false);
55
const removalPending = useRef(false);
@@ -88,7 +89,7 @@ export function SettingsProjectOverviewRouteScreen() {
89
return (
90
<>
91
<SettingsEnvironmentFilterHeader />
91
- <SettingsScreen title="Projects" trailing={<AndroidSettingsEnvironmentFilter />}>
92
+ <SettingsScreen title="Projects" menus={[environmentMenu]}>
93
<ScrollView
94
contentInsetAdjustmentBehavior="automatic"
95
showsVerticalScrollIndicator={false}
apps/mobile/src/features/settings/SettingsProviderAccountsRouteScreen.tsx
+3
-2
@@ -29,7 +29,7 @@ import { useEnvironmentsWithScope } from "../../state/session";
29
import { useAtomCommand } from "../../state/use-atom-command";
30
import { ListActionRow as SettingsActionRow } from "../../components/ui/ListActionRow";
31
import {
32
- AndroidSettingsEnvironmentFilter,
32
+ useSettingsEnvironmentMenu,
33
SettingsEnvironmentFilterHeader,
34
} from "./components/SettingsEnvironmentFilterHeader";
35
import { SettingsScreen } from "./components/SettingsScreen";
@@ -37,6 +37,7 @@ import { SettingsSection } from "./components/SettingsSection";
37
import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-environment-filter";
38
39
export function SettingsProviderAccountsRouteScreen() {
40
+ const environmentMenu = useSettingsEnvironmentMenu();
41
const { selectedTargets } = useSettingsEnvironmentFilter();
42
const permittedEnvironments = useEnvironmentsWithScope(selectedTargets, AuthProvidersManageScope);
43
const providersByEnvironment = useAtomValue(environmentPresentations.providersByEnvironmentAtom);
@@ -44,7 +45,7 @@ export function SettingsProviderAccountsRouteScreen() {
45
return (
46
<>
47
<SettingsEnvironmentFilterHeader />
47
- <SettingsScreen title="Providers" trailing={<AndroidSettingsEnvironmentFilter />}>
48
+ <SettingsScreen title="Providers" menus={[environmentMenu]}>
49
<ScreenScrollView
50
className="flex-1"
51
contentInsetAdjustmentBehavior="automatic"
apps/mobile/src/features/settings/SettingsRouteScreen.tsx
+3
-2
@@ -31,7 +31,7 @@ import { SettingsSection, SettingsSidebarContext } from "./components/SettingsSe
31
import { SettingsScreen } from "./components/SettingsScreen";
32
import type { SettingsPageTarget } from "./components/settings-page-targets";
33
import {
34
- AndroidSettingsEnvironmentFilter,
34
+ useSettingsEnvironmentMenu,
35
SettingsEnvironmentFilterHeader,
36
} from "./components/SettingsEnvironmentFilterHeader";
37
import { useSettingsEnvironmentFilter } from "./settings-environment-filter";
@@ -59,6 +59,7 @@ export function SettingsListScreen(props: {
59
}) {
60
const surface = useWorkspaceSurface();
61
const workspace = useWorkspaceTabs();
62
+ const environmentMenu = useSettingsEnvironmentMenu();
63
const inSidebar = props.sidebar;
64
const selected = props.selected;
65
const sidebar = inSidebar ? { selected } : null;
@@ -76,7 +77,7 @@ export function SettingsListScreen(props: {
77
<SettingsScreen
78
title="Settings"
79
workspaceRoot={inSidebar}
79
- trailing={<AndroidSettingsEnvironmentFilter />}
80
+ menus={[environmentMenu]}
81
search={
82
workspace
83
? {
apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx
+14
-15
@@ -67,7 +67,7 @@ import { resolveNewTaskBranchLabel } from "../threads/new-task-context-presentat
67
import { useVoiceInputController } from "../voice-input/useVoiceInputController";
68
import { ScheduledTaskPromptField } from "./components/ScheduledTaskPromptField";
69
import {
70
- AndroidSettingsEnvironmentFilter,
70
+ useSettingsEnvironmentMenu,
71
SettingsEnvironmentFilterHeader,
72
} from "./components/SettingsEnvironmentFilterHeader";
73
import { SettingsScreen } from "./components/SettingsScreen";
@@ -400,6 +400,7 @@ export function SettingsScheduledTasksRouteScreen() {
400
const { startEditor, resetEditor } = useScheduledTaskEditor();
401
const navigation = useNavigation<NativeStackNavigationProp<ScheduledTaskRoutes>>();
402
const insets = useSafeAreaInsets();
403
+ const environmentMenu = useSettingsEnvironmentMenu();
404
const newTask = () => {
405
if (visibleEnvironments.length === 0) return;
406
resetEditor();
@@ -422,21 +423,19 @@ export function SettingsScheduledTasksRouteScreen() {
423
/>
424
<SettingsScreen
425
title="Scheduled tasks"
425
- trailing={
426
- <View className="flex-row items-center">
427
- <AndroidSettingsEnvironmentFilter />
428
- <Pressable
429
- accessibilityRole="button"
430
- accessibilityLabel="New task"
431
- accessibilityState={{ disabled: visibleEnvironments.length === 0 }}
432
- disabled={visibleEnvironments.length === 0}
433
- onPress={newTask}
434
- className="size-11 items-center justify-center rounded-full disabled:opacity-50"
435
- >
436
- <SymbolView name="plus" size={22} tintColorClassName="accent-icon" />
437
- </Pressable>
438
- </View>
426
+ actions={
427
+ Platform.OS === "android"
428
+ ? [
429
+ {
430
+ accessibilityLabel: "New task",
431
+ icon: "plus",
432
+ disabled: visibleEnvironments.length === 0,
433
+ onPress: newTask,
434
+ },
435
+ ]
436
+ : undefined
437
}
438
+ menus={[environmentMenu]}
439
>
440
<ScrollView
441
keyboardShouldPersistTaps="handled"
apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx
+5
-1
@@ -87,7 +87,11 @@ vi.mock("../../components/ui/Button", () => ({
87
}));
88
vi.mock("./components/SettingsScreen", () => ({ SettingsScreen: Children }));
89
vi.mock("./components/SettingsEnvironmentFilterHeader", () => ({
90
- AndroidSettingsEnvironmentFilter: () => null,
90
+ useSettingsEnvironmentMenu: () => ({
91
+ title: "Filter",
92
+ icon: "line.3.horizontal.decrease.circle",
93
+ items: [],
94
+ }),
95
SettingsEnvironmentFilterHeader: () => null,
96
}));
97
vi.mock("./components/DatabaseStorageNotice", () => ({ DatabaseStorageNotice: () => null }));
apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx
+3
-5
@@ -23,7 +23,7 @@ import {
23
} from "../threads/thread-settings-options";
24
import { SettingsScreen } from "./components/SettingsScreen";
25
import {
26
- AndroidSettingsEnvironmentFilter,
26
+ useSettingsEnvironmentMenu,
27
SettingsEnvironmentFilterHeader,
28
} from "./components/SettingsEnvironmentFilterHeader";
29
import { BranchNamingSettings } from "./components/BranchNamingSettings";
@@ -177,6 +177,7 @@ export function SettingsEnvironmentMaintenanceRouteScreen() {
177
}
178
179
function ServerSettingsDetail(props: { readonly page: SettingsPage }) {
180
+ const environmentMenu = useSettingsEnvironmentMenu();
181
const insets = useSafeAreaInsets();
182
const navigation = useNavigation();
183
const { selectedTargets, projectGroups, selectedProjectKey } = useSettingsEnvironmentFilter();
@@ -285,10 +286,7 @@ function ServerSettingsDetail(props: { readonly page: SettingsPage }) {
286
return (
287
<>
288
<SettingsEnvironmentFilterHeader />
288
- <SettingsScreen
289
- title={PAGE_TITLES[props.page]}
290
- trailing={<AndroidSettingsEnvironmentFilter />}
291
- >
289
+ <SettingsScreen title={PAGE_TITLES[props.page]} menus={[environmentMenu]}>
290
<ScrollView
291
contentInsetAdjustmentBehavior="automatic"
292
showsVerticalScrollIndicator={false}
apps/mobile/src/features/settings/components/SettingsEnvironmentFilterHeader.tsx
+39
-67
@@ -1,9 +1,8 @@
1
import type { NativeStackHeaderItem } from "@react-navigation/native-stack";
2
import { resolveEnvironmentMachineKind } from "@t3tools/contracts";
3
-import { Platform, Pressable } from "react-native";
3
+import { Platform } from "react-native";
4
5
-import { Menu } from "../../../components/ui/Menu";
6
-import { SymbolView } from "../../../components/ui/AppSymbol";
5
+import type { AppBarMenu } from "../../../components/ui/AppBar.types";
6
import { ENVIRONMENT_MACHINE_SYMBOLS } from "../../../components/EnvironmentMachineSymbol";
7
import { NativeStackScreenOptions } from "../../../native/StackHeader";
8
import { withNativeGlassHeaderItem } from "../../layout/native-glass-header-items";
@@ -116,7 +115,8 @@ export function SettingsEnvironmentFilterHeader(props: {
115
);
116
}
117
119
-export function AndroidSettingsEnvironmentFilter() {
118
+/** Android's settings scope filter, as an `AppBar` menu. */
119
+export function useSettingsEnvironmentMenu(): AppBarMenu {
120
const {
121
availableTargets,
122
selectedIds,
@@ -126,69 +126,41 @@ export function AndroidSettingsEnvironmentFilter() {
126
selectedProjectKey,
127
selectProject,
128
} = useSettingsEnvironmentFilter();
129
- const filterIcon =
130
- selectedIds === null && selectedProjectKey === null
131
- ? "line.3.horizontal.decrease"
132
- : "line.3.horizontal.decrease.circle.fill";
133
-
134
- return (
135
- <Menu
136
- accessible
137
- accessibilityRole="button"
138
- accessibilityLabel="Filter settings environments and projects"
139
- title="Settings scope"
140
- actions={[
141
- {
142
- id: "all",
143
- title: "All connected environments",
144
- state: selectedIds === null ? ("on" as const) : ("off" as const),
145
- },
146
- ...availableTargets.map((entry) => ({
147
- id: `environment:${entry.environmentId}`,
148
- title: `Environment · ${entry.label}`,
149
- image: ENVIRONMENT_MACHINE_SYMBOLS[resolveEnvironmentMachineKind(entry.serverConfig)],
150
- subtitle: entry.displayUrl ?? undefined,
151
- state:
152
- selectedIds === null || selectedIds.has(entry.environmentId)
153
- ? ("on" as const)
154
- : ("off" as const),
155
- })),
156
- {
157
- id: "project:all",
158
- title: "All projects",
159
- state: selectedProjectKey === null ? ("on" as const) : ("off" as const),
160
- },
161
- ...selectableProjectGroups.map((group) => ({
162
- id: `project:${group.key}`,
163
- title: `Project · ${projectMenuLabel(group)}`,
164
- state: selectedProjectKey === group.key ? ("on" as const) : ("off" as const),
165
- })),
166
- ]}
167
- onPressAction={({ nativeEvent }) => {
168
- if (nativeEvent.event === "all") selectAll();
169
- else if (nativeEvent.event === "project:all") selectProject(null);
170
- else if (nativeEvent.event.startsWith("project:")) {
171
- const group = selectableProjectGroups.find(
172
- (entry) => `project:${entry.key}` === nativeEvent.event,
173
- );
174
- if (group) selectProject(group.key);
175
- } else {
176
- const target = availableTargets.find(
177
- (entry) => `environment:${entry.environmentId}` === nativeEvent.event,
178
- );
179
- if (target) toggleEnvironment(target.environmentId);
180
- }
181
- }}
182
- >
183
- <Pressable
184
- accessibilityRole="button"
185
- accessibilityLabel="Filter settings environments and projects"
186
- className="size-11 items-center justify-center rounded-full"
187
- >
188
- <SymbolView name={filterIcon} size={22} tintColorClassName="accent-icon" />
189
- </Pressable>
190
- </Menu>
191
- );
129
+ return {
130
+ title: "Filter settings environments and projects",
131
+ icon:
132
+ selectedIds === null && selectedProjectKey === null
133
+ ? "line.3.horizontal.decrease.circle"
134
+ : "line.3.horizontal.decrease.circle.fill",
135
+ items: [
136
+ {
137
+ id: "all",
138
+ title: "All connected environments",
139
+ selected: selectedIds === null,
140
+ onPress: selectAll,
141
+ },
142
+ ...availableTargets.map((entry) => ({
143
+ id: `environment:${entry.environmentId}`,
144
+ title: `Environment · ${entry.label}`,
145
+ icon: ENVIRONMENT_MACHINE_SYMBOLS[resolveEnvironmentMachineKind(entry.serverConfig)],
146
+ subtitle: entry.displayUrl ?? undefined,
147
+ selected: selectedIds === null || selectedIds.has(entry.environmentId),
148
+ onPress: () => toggleEnvironment(entry.environmentId),
149
+ })),
150
+ {
151
+ id: "project:all",
152
+ title: "All projects",
153
+ selected: selectedProjectKey === null,
154
+ onPress: () => selectProject(null),
155
+ },
156
+ ...selectableProjectGroups.map((group) => ({
157
+ id: `project:${group.key}`,
158
+ title: `Project · ${projectMenuLabel(group)}`,
159
+ selected: selectedProjectKey === group.key,
160
+ onPress: () => selectProject(group.key),
161
+ })),
162
+ ],
163
+ };
164
}
165
166
const projectMenuLabel = (group: { readonly label: string; readonly archived: boolean }) =>
apps/mobile/src/features/settings/components/SettingsScreen.tsx
+13
-21
@@ -2,7 +2,6 @@ import { useNavigation, useRoute } from "@react-navigation/native";
2
import type { ReactNode } from "react";
3
import { Platform, View } from "react-native";
4
5
-import { AndroidSheetHeader } from "../../../components/ui/AndroidScreenHeader";
5
import type { AppBarProps } from "../../../components/ui/AppBar.types";
6
import { AppBar } from "../../../components/ui/AppBar";
7
import { ScreenContent as SettingsScreenContent } from "../../../components/ui/ScreenContent";
@@ -19,7 +18,7 @@ import {
18
export { SettingsScreenContent };
19
20
export function SettingsScreen(
22
- props: Pick<AppBarProps, "title" | "actions" | "trailing" | "search"> & {
21
+ props: Pick<AppBarProps, "title" | "actions" | "trailing" | "search" | "menus"> & {
22
readonly children: ReactNode;
23
readonly formSheet?: boolean;
24
readonly workspaceRoot?: boolean;
@@ -44,25 +43,18 @@ export function SettingsScreen(
43
44
return (
45
<View collapsable={false} className={`flex-1 ${surfaceClassName}`}>
47
- {Platform.OS === "android" && props.formSheet ? (
48
- <AndroidSheetHeader
49
- title={props.title}
50
- actions={props.actions}
51
- trailing={props.trailing}
52
- onBack={() => navigation.goBack()}
53
- hideBottomBorder
54
- />
55
- ) : (
56
- <AppBar
57
- title={props.title}
58
- actions={props.actions}
59
- search={props.search}
60
- trailing={Platform.OS === "android" ? props.trailing : undefined}
61
- sidebar={false}
62
- onBack={workspaceRoot ? undefined : () => navigation.goBack()}
63
- hideBottomBorder={!props.formSheet}
64
- />
65
- )}
46
+ <AppBar
47
+ title={props.title}
48
+ actions={props.actions}
49
+ search={props.search}
50
+ trailing={Platform.OS === "android" ? props.trailing : undefined}
51
+ // iOS screens put their filter menus in native header items themselves.
52
+ menus={Platform.OS === "android" ? props.menus : undefined}
53
+ sheet={Platform.OS === "android" && props.formSheet}
54
+ sidebar={false}
55
+ onBack={workspaceRoot ? undefined : () => navigation.goBack()}
56
+ hideBottomBorder={!props.formSheet || Platform.OS === "android"}
57
+ />
58
<ScreenScrollViewBottomInset value={deviceType === "pad" || compactTabs ? 80 : 0}>
59
<ScreenScrollViewSurface value={surfaceClassName}>
60
{props.formSheet && Platform.OS !== "android" ? (
apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx
+7
-3
@@ -25,7 +25,7 @@ import { sanitizeNewRefName } from "@t3tools/shared/git";
25
import { Platform, Pressable, ScrollView, View } from "react-native";
26
import { useSafeAreaInsets } from "react-native-safe-area-context";
27
28
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
28
+import { AppBar } from "../../components/ui/AppBar";
29
import { ScreenContent } from "../../components/ui/ScreenContent";
30
import { SymbolView } from "../../components/ui/AppSymbol";
31
import { AppText as Text } from "../../components/ui/AppText";
@@ -195,7 +195,9 @@ export function NewTaskEnvironmentPickerRouteScreen() {
195
}}
196
/>
197
{Platform.OS === "android" ? (
198
- <AndroidScreenHeader
198
+ <AppBar
199
+ embedded
200
+ sidebar={false}
201
title="Environment"
202
hideBottomBorder
203
onBack={() => navigation.goBack()}
@@ -485,7 +487,9 @@ export function BranchPickerScreen(props: {
487
return (
488
<View className="flex-1 bg-sheet" collapsable={false}>
489
<NativeStackScreenOptions options={{ headerShown: false }} />
488
- <AndroidScreenHeader
490
+ <AppBar
491
+ embedded
492
+ sidebar={false}
493
title={props.title}
494
hideBottomBorder
495
onBack={() => navigation.goBack()}
apps/mobile/src/features/threads/ThreadAgentsSheet.tsx
+2
-2
@@ -20,7 +20,7 @@ import { Platform, Pressable, ScrollView, View } from "react-native";
20
import { ScreenStack } from "react-native-screens";
21
import { useSafeAreaInsets } from "react-native-safe-area-context";
22
23
-import { AndroidSheetHeader } from "../../components/ui/AndroidScreenHeader";
23
+import { AppBar } from "../../components/ui/AppBar";
24
import { AppText as Text } from "../../components/ui/AppText";
25
import { environmentThreadDetails } from "../../state/threads";
26
import { NativeStackScreenOptions, nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
@@ -166,7 +166,7 @@ export function ThreadAgentsSheet({ route }: StaticScreenProps<AgentsTarget>) {
166
return (
167
<View collapsable={false} className="flex-1 bg-sheet">
168
<NativeStackScreenOptions options={{ sheetCornerRadius: 28 }} />
169
- <AndroidSheetHeader title="Agents" onBack={() => navigation.goBack()} />
169
+ <AppBar sheet sidebar={false} title="Agents" onBack={() => navigation.goBack()} />
170
<ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
171
</View>
172
);
apps/mobile/src/features/threads/ThreadBackgroundWorkSheet.tsx
+2
-2
@@ -11,7 +11,7 @@ import { Platform, Pressable, ScrollView, View } from "react-native";
11
import { ScreenStack } from "react-native-screens";
12
import { useSafeAreaInsets } from "react-native-safe-area-context";
13
14
-import { AndroidSheetHeader } from "../../components/ui/AndroidScreenHeader";
14
+import { AppBar } from "../../components/ui/AppBar";
15
import { SymbolView } from "../../components/ui/AppSymbol";
16
import { AppText as Text } from "../../components/ui/AppText";
17
import { ScreenContent } from "../../components/ui/ScreenContent";
@@ -97,7 +97,7 @@ export function ThreadBackgroundWorkSheet({ route }: StaticScreenProps<Backgroun
97
return (
98
<View collapsable={false} className="flex-1 bg-sheet">
99
<NativeStackScreenOptions options={{ sheetCornerRadius: 28 }} />
100
- <AndroidSheetHeader title="Background work" onBack={() => navigation.goBack()} />
100
+ <AppBar sheet sidebar={false} title="Background work" onBack={() => navigation.goBack()} />
101
<ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
102
</View>
103
);
apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+2
-11
@@ -61,7 +61,6 @@ import {
61
} from "../home/WorkspaceConnectionTitle";
62
import { SidebarHeaderActions } from "./sidebar-header-actions";
63
import { ThreadListToolbar } from "../home/ThreadListToolbar";
64
-import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
64
import { useFabScroll } from "../home/FabScrollContext";
65
import { SidebarFilterButton } from "./sidebar-filter-button";
66
import { createSidebarHeaderItems } from "./sidebar-native-header-items";
@@ -414,12 +413,7 @@ function ThreadNavigationSidebarPane(
413
};
414
415
const [measuredHeaderHeight, setMeasuredHeaderHeight] = useState<number | null>(null);
417
- const { height, paddingTop, paddingBottom } = useToolbarLayout();
418
- const stickyHeaderHeight =
419
- measuredHeaderHeight ??
420
- (Platform.OS === "android"
421
- ? paddingTop + height + paddingBottom
422
- : insets.top + SIDEBAR_STICKY_HEADER_HEIGHT);
416
+ const stickyHeaderHeight = measuredHeaderHeight ?? insets.top + SIDEBAR_STICKY_HEADER_HEIGHT;
417
const topListInset = stickyHeaderHeight + 6;
418
const handleStickyHeaderLayout = (event: LayoutChangeEvent) => {
419
const nextHeight = event.nativeEvent.layout.height;
@@ -789,7 +783,6 @@ function ThreadNavigationSidebarPane(
783
style={
784
Platform.OS === "android"
785
? {
792
- marginTop: stickyHeaderHeight,
786
marginHorizontal: 4,
787
paddingBottom: insets.bottom,
788
backgroundColor: drawerColor,
@@ -845,13 +838,11 @@ function ThreadNavigationSidebarPane(
838
839
{Platform.OS === "android" ? (
840
<ThreadListToolbar
848
- sidebar
849
- onLayout={handleStickyHeaderLayout}
841
searchQuery={props.searchQuery}
842
onSearchQueryChange={props.onSearchQueryChange}
843
filterActions={listMenuActions}
844
filterCustomized={filterCustomized}
854
- onFilterAction={handleListMenuAction}
845
+ onFilterSelect={(event) => handleListMenuAction({ nativeEvent: { event } })}
846
onOpenEnvironments={props.onOpenEnvironmentSettings}
847
onRequestVisibility={props.onRequestVisibility}
848
/>
apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsx
+4
-2
@@ -4,7 +4,7 @@ import { useMemo } from "react";
4
import { Platform, View } from "react-native";
5
import { useSafeAreaInsets } from "react-native-safe-area-context";
6
7
-import { AndroidSheetHeader } from "../../components/ui/AndroidScreenHeader";
7
+import { AppBar } from "../../components/ui/AppBar";
8
import { AppText as Text } from "../../components/ui/AppText";
9
import { ScreenContent } from "../../components/ui/ScreenContent";
10
import { SheetHeader } from "../../components/ui/SheetHeader";
@@ -111,7 +111,9 @@ export function ThreadPullRequestsSheet(
111
return (
112
<View collapsable={false} className="flex-1 bg-header">
113
<NativeStackScreenOptions options={{ sheetCornerRadius: 28 }} />
114
- <AndroidSheetHeader
114
+ <AppBar
115
+ sheet
116
+ sidebar={false}
117
title={title}
118
hideBottomBorder
119
onBack={() => navigation.goBack()}
apps/mobile/src/features/threads/ThreadQueueControl.tsx
+2
-2
@@ -20,7 +20,7 @@ import { Screen, ScreenStack, ScreenStackHeaderConfig } from "react-native-scree
20
import { useSafeAreaInsets } from "react-native-safe-area-context";
21
22
import { Button } from "../../components/ui/Button";
23
-import { AndroidSheetHeader } from "../../components/ui/AndroidScreenHeader";
23
+import { AppBar } from "../../components/ui/AppBar";
24
import { AppText as Text } from "../../components/ui/AppText";
25
import { SymbolView } from "../../components/ui/AppSymbol";
26
import { Menu } from "../../components/ui/Menu";
@@ -395,7 +395,7 @@ export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
395
<GestureHandlerRootView style={{ flex: 1 }}>
396
<View collapsable={false} className="flex-1 bg-sheet">
397
<NativeStackScreenOptions options={{ sheetCornerRadius: 28 }} />
398
- <AndroidSheetHeader title="Queued" onBack={() => navigation.goBack()} />
398
+ <AppBar sheet sidebar={false} title="Queued" onBack={() => navigation.goBack()} />
399
<ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
400
</View>
401
</GestureHandlerRootView>
apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
+4
-2
@@ -59,7 +59,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
59
60
import { SymbolView } from "../../components/ui/AppSymbol";
61
import { AppText as Text } from "../../components/ui/AppText";
62
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
62
+import { AppBar } from "../../components/ui/AppBar";
63
import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
64
import { IconButton } from "../../components/ui/IconButton";
65
import { ProviderIcon } from "../../components/ProviderIcon";
@@ -1433,7 +1433,9 @@ function ThreadSettingsChoiceScreen() {
1433
<>
1434
<NativeStackScreenOptions options={{ headerShown: Platform.OS !== "android" }} />
1435
{Platform.OS === "android" ? (
1436
- <AndroidScreenHeader
1436
+ <AppBar
1437
+ embedded
1438
+ sidebar={false}
1439
title={route.params.title}
1440
onBack={() => navigation.goBack()}
1441
hideBottomBorder
apps/mobile/src/features/threads/git/GitBranchesSheet.occupancy.test.tsx
+1
-1
@@ -19,7 +19,7 @@ vi.mock("react-native", () => ({
19
}));
20
vi.mock("@react-navigation/native", () => ({ useNavigation: () => ({}) }));
21
vi.mock("react-native-safe-area-context", () => ({ useSafeAreaInsets: () => ({ bottom: 0 }) }));
22
-vi.mock("../../../components/ui/AndroidScreenHeader", () => ({ AndroidSheetHeader: () => null }));
22
+vi.mock("../../../components/ui/AppBar", () => ({ AppBar: () => null }));
23
vi.mock("../../../components/ui/SheetHeader", () => ({ SheetHeader: () => null }));
24
vi.mock("../../../components/ui/ScreenContent", () => ({
25
ScreenContent: ({ children }: { children: ReactNode }) => <div>{children}</div>,
apps/mobile/src/features/threads/git/GitBranchesSheet.test.tsx
+1
-1
@@ -27,7 +27,7 @@ vi.mock("react-native", () => ({
27
vi.mock("react-native-safe-area-context", () => ({
28
useSafeAreaInsets: () => ({ bottom: 0 }),
29
}));
30
-vi.mock("../../../components/ui/AndroidScreenHeader", () => ({ AndroidSheetHeader: () => null }));
30
+vi.mock("../../../components/ui/AppBar", () => ({ AppBar: () => null }));
31
vi.mock("../../../components/ui/SheetHeader", () => ({ SheetHeader: () => null }));
32
vi.mock("../../../components/ui/ScreenContent", () => ({
33
ScreenContent: ({ children }: { children: ReactNode }) => children,
apps/mobile/src/features/threads/git/GitBranchesSheet.tsx
+4
-2
@@ -4,7 +4,7 @@ import { useState } from "react";
4
import { Platform, Pressable, ScrollView, useWindowDimensions, View } from "react-native";
5
import { useSafeAreaInsets } from "react-native-safe-area-context";
6
7
-import { AndroidSheetHeader } from "../../../components/ui/AndroidScreenHeader";
7
+import { AppBar } from "../../../components/ui/AppBar";
8
import { SheetHeader } from "../../../components/ui/SheetHeader";
9
import { ScreenContent } from "../../../components/ui/ScreenContent";
10
import { NativeStackScreenOptions } from "../../../native/StackHeader";
@@ -78,7 +78,9 @@ export function GitBranchesSheet(_props: GitBranchesSheetProps) {
78
/>
79
) : null}
80
{Platform.OS === "android" ? (
81
- <AndroidSheetHeader
81
+ <AppBar
82
+ sheet
83
+ sidebar={false}
84
title="Branches & worktrees"
85
onBack={() => navigation.goBack()}
86
hideBottomBorder
apps/mobile/src/features/threads/git/GitConfirmSheet.tsx
+4
-2
@@ -9,7 +9,7 @@ import { Platform, ScrollView, useWindowDimensions, View } from "react-native";
9
10
import { useSafeAreaInsets } from "react-native-safe-area-context";
11
12
-import { AndroidSheetHeader } from "../../../components/ui/AndroidScreenHeader";
12
+import { AppBar } from "../../../components/ui/AppBar";
13
import { ScreenContent } from "../../../components/ui/ScreenContent";
14
import { NativeStackScreenOptions } from "../../../native/StackHeader";
15
import { AppText as Text } from "../../../components/ui/AppText";
@@ -130,7 +130,9 @@ export function GitConfirmSheet(props: GitConfirmSheetProps) {
130
/>
131
) : null}
132
{Platform.OS === "android" ? (
133
- <AndroidSheetHeader
133
+ <AppBar
134
+ sheet
135
+ sidebar={false}
136
title="Confirm action"
137
onBack={() => navigation.goBack()}
138
hideBottomBorder
apps/mobile/src/features/threads/git/GitOverviewSheet.tsx
+5
-5
@@ -23,10 +23,8 @@ import { ScreenStack } from "react-native-screens";
23
import { useSafeAreaInsets } from "react-native-safe-area-context";
24
import { NativeInspectorContent } from "../../../native/NativeInspectorContent";
25
import { NativeHeader, NativeScreen } from "../../../native/ThemedScreenStack";
26
-import {
27
- AndroidHeaderIconButton,
28
- AndroidSheetHeader,
29
-} from "../../../components/ui/AndroidScreenHeader";
26
+import { AndroidHeaderIconButton } from "../../../components/ui/AndroidScreenHeader";
27
+import { AppBar } from "../../../components/ui/AppBar";
28
import { AndroidAnchoredMenu } from "../../../components/ui/AndroidAnchoredMenu";
29
import { ListRow } from "../../../components/ui/ListRow";
30
import { ListSection } from "../../../components/ui/ListSection";
@@ -467,7 +465,9 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
465
</Text>
466
</View>
467
) : (
470
- <AndroidSheetHeader
468
+ <AppBar
469
+ sheet
470
+ sidebar={false}
471
title={currentBranchLabel}
472
hideBottomBorder={Platform.OS === "android"}
473
subtitle={currentStatusSummary}
apps/mobile/src/features/threads/worktree-setup-sheet.android.tsx
+4
-2
@@ -1,7 +1,7 @@
1
import { Host, ModalBottomSheet, RNHostView } from "@expo/ui/jetpack-compose";
2
import { View, useWindowDimensions } from "react-native";
3
import { withUniwind } from "uniwind";
4
-import { AndroidSheetHeader } from "../../components/ui/AndroidScreenHeader";
4
+import { AppBar } from "../../components/ui/AppBar";
5
import type { WorktreeSetupSheetProps } from "./worktree-setup-sheet";
6
7
const NativeBottomSheet = withUniwind(ModalBottomSheet, {
@@ -24,7 +24,9 @@ export function WorktreeSetupSheet({ children, height, onClose }: WorktreeSetupS
24
height: Math.min((height || 360) + 64, window.height * 0.85),
25
}}
26
>
27
- <AndroidSheetHeader
27
+ <AppBar
28
+ sheet
29
+ sidebar={false}
30
title="Worktree setup"
31
actions={[
32
{ accessibilityLabel: "Close setup details", icon: "xmark", onPress: onClose },
apps/mobile/src/features/usage/UsageRouteScreen.tsx
+20
-25
@@ -30,7 +30,7 @@ import {
30
usageSourceMessages,
31
} from "@t3tools/shared/usageFormat";
32
import { useRef, useState, type ReactNode } from "react";
33
-import { Platform, Pressable, RefreshControl, View } from "react-native";
33
+import { Platform, RefreshControl, View } from "react-native";
34
import Animated, { FadeIn, ReduceMotion } from "react-native-reanimated";
35
import { useSafeAreaInsets } from "react-native-safe-area-context";
36
@@ -48,8 +48,6 @@ import { UsageDailyChart } from "./UsageDailyChart";
48
import { toggleUsageEnvironment } from "./usageEnvironmentSelection";
49
import { useRefreshLimits } from "./UsageLimitsSection";
50
import { UsageLimitsSection } from "./UsageLimitsPooled";
51
-import { Menu } from "../../components/ui/Menu";
52
-import { SymbolView } from "../../components/ui/AppSymbol";
51
import { NativeStackScreenOptions } from "../../native/StackHeader";
52
import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
53
import type { UsageChartMetric } from "./usageChartData";
@@ -225,30 +223,27 @@ function UsageScreen(props: {
223
const id = EnvironmentId.make(value);
224
setSelectedEnvironmentIds((selected) => toggleUsageEnvironment(selected, environments, id));
225
};
228
- const environmentFilter = showEnvironmentFilter ? (
229
- <Menu
230
- accessible
231
- accessibilityRole="button"
232
- accessibilityLabel="Filter usage environments"
233
- title="Environments"
234
- actions={environmentActions}
235
- onPressAction={({ nativeEvent }) => selectEnvironment(nativeEvent.event)}
236
- >
237
- <Pressable
238
- accessibilityRole="button"
239
- accessibilityLabel="Filter usage environments"
240
- className={cn(
241
- "items-center justify-center rounded-full",
242
- Platform.OS === "ios" ? "size-[28px]" : "size-[44px]",
243
- )}
244
- >
245
- <SymbolView name={filterIcon} size={22} tintColorClassName="accent-icon" />
246
- </Pressable>
247
- </Menu>
248
- ) : null;
226
+ const environmentMenu = {
227
+ title: "Filter usage environments",
228
+ icon:
229
+ selectedEnvironmentIds === null
230
+ ? ("line.3.horizontal.decrease.circle" as const)
231
+ : ("line.3.horizontal.decrease.circle.fill" as const),
232
+ items: environmentActions.map((action) => ({
233
+ id: action.id,
234
+ title: action.title,
235
+ subtitle: action.subtitle,
236
+ selected: action.state === "on",
237
+ onPress: () => selectEnvironment(action.id),
238
+ })),
239
+ };
240
241
return (
251
- <SettingsScreen title="Usage" trailing={environmentFilter} workspaceRoot={props.workspace}>
242
+ <SettingsScreen
243
+ title="Usage"
244
+ menus={showEnvironmentFilter ? [environmentMenu] : undefined}
245
+ workspaceRoot={props.workspace}
246
+ >
247
{Platform.OS === "ios" ? (
248
<NativeStackScreenOptions
249
optionsVersion={JSON.stringify({ showEnvironmentFilter, filterIcon, environmentActions })}
apps/mobile/src/features/workspace/AndroidWorkspaceSidebar.android.tsx
+30
-27
@@ -12,6 +12,7 @@ import { PullRequestsScreen } from "../pull-requests/PullRequestsScreen";
12
import { PullRequestToolbar } from "../pull-requests/PullRequestToolbar.android";
13
import { WorkspaceTabsContext, useWorkspaceTabs } from "./WorkspaceTabsContext";
14
import { WorkspaceTabPanes } from "./WorkspaceTabPanes";
15
+import { WorkspaceAppBarScope } from "../../components/ui/WorkspaceAppBar.android";
16
17
export function AndroidWorkspaceSidebar(props: {
18
readonly children: ReactNode;
@@ -29,32 +30,34 @@ export function AndroidWorkspaceSidebar(props: {
30
const context = { ...workspace, bottomClearance };
31
if (enabled.length === 0) return <WorkspaceNoTabs />;
32
return (
32
- <WorkspaceTabPanes
33
- tabs={NAVIGATION_TAB_ORDER}
34
- selected={workspace.state.selectedTab}
35
- renderTab={(tab) =>
36
- tab === "threads" ? (
37
- props.children
38
- ) : tab !== "pullRequests" ? (
39
- <View className="flex-1 bg-screen" />
40
- ) : (
41
- <WorkspaceTabsContext value={context}>
42
- <PullRequestsScreen
43
- sidebar
44
- selectedPullRequestKey={props.selectedPullRequestKey}
45
- renderFrame={(filters, list) => (
46
- <View className="flex-1 bg-header">
47
- <PullRequestToolbar
48
- filters={filters}
49
- onRequestVisibility={props.onRequestVisibility}
50
- />
51
- <ScreenContent insetHorizontal>{list}</ScreenContent>
52
- </View>
53
- )}
54
- />
55
- </WorkspaceTabsContext>
56
- )
57
- }
58
- />
33
+ <WorkspaceAppBarScope>
34
+ <WorkspaceTabPanes
35
+ tabs={NAVIGATION_TAB_ORDER}
36
+ selected={workspace.state.selectedTab}
37
+ renderTab={(tab) =>
38
+ tab === "threads" ? (
39
+ props.children
40
+ ) : tab !== "pullRequests" ? (
41
+ <View className="flex-1 bg-screen" />
42
+ ) : (
43
+ <WorkspaceTabsContext value={context}>
44
+ <PullRequestsScreen
45
+ sidebar
46
+ selectedPullRequestKey={props.selectedPullRequestKey}
47
+ renderFrame={(filters, list) => (
48
+ <View className="flex-1 bg-header">
49
+ <PullRequestToolbar
50
+ filters={filters}
51
+ onRequestVisibility={props.onRequestVisibility}
52
+ />
53
+ <ScreenContent insetHorizontal>{list}</ScreenContent>
54
+ </View>
55
+ )}
56
+ />
57
+ </WorkspaceTabsContext>
58
+ )
59
+ }
60
+ />
61
+ </WorkspaceAppBarScope>
62
);
63
}
apps/mobile/src/features/workspace/WorkspaceBrandTitle.tsx
new
+22
@@ -0,0 +1,22 @@
1
+import { CompactBrandTitle } from "../../components/CompactBrandTitle";
2
+import { WorkspaceConnectionTitle } from "../home/WorkspaceConnectionTitle";
3
+
4
+/** The title of a workspace list tab: the brand and the connection status. */
5
+export function WorkspaceBrandTitle(props: {
6
+ readonly accessibilityLabel: string;
7
+ readonly onOpenEnvironments: () => void;
8
+}) {
9
+ return (
10
+ <WorkspaceConnectionTitle
11
+ grow
12
+ onPress={props.onOpenEnvironments}
13
+ brand={
14
+ <CompactBrandTitle
15
+ allowFontScaling={false}
16
+ accessibilityLabel={props.accessibilityLabel}
17
+ fit
18
+ />
19
+ }
20
+ />
21
+ );
22
+}
apps/mobile/src/features/workspace/WorkspaceListToolbarRow.tsx
deleted
-63
@@ -1,63 +0,0 @@
1
-import type { ReactNode } from "react";
2
-import { View } from "react-native";
3
-import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
4
-import { CompactBrandTitle } from "../../components/CompactBrandTitle";
5
-import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
6
-import { WorkspaceConnectionTitle } from "../home/WorkspaceConnectionTitle";
7
-
8
-/**
9
- * The Android header row above each workspace tab's list. Both tabs draw this same row, so
10
- * switching tabs leaves the title and buttons where they were. It is plain React Native rather
11
- * than the Compose app bar: a hidden tab lays out at zero size, and Compose-hosted content takes
12
- * several frames to measure again when the tab comes back.
13
- */
14
-export function WorkspaceListToolbarRow(props: {
15
- readonly searching: boolean;
16
- readonly searchField: ReactNode;
17
- readonly onCloseSearch: () => void;
18
- readonly onOpenSearch: () => void;
19
- readonly searchAccessibilityLabel: string;
20
- readonly titleAccessibilityLabel: string;
21
- readonly onOpenEnvironments: () => void;
22
- /** Stays trailing while searching, so it never moves and still narrows the results. */
23
- readonly filter: ReactNode;
24
-}) {
25
- const { height } = useToolbarLayout();
26
- return (
27
- <View className="flex-row items-center gap-1" style={{ minHeight: height }}>
28
- {props.searching ? (
29
- <>
30
- <AndroidHeaderIconButton
31
- accessibilityLabel="Close search"
32
- icon="arrow.left"
33
- onPress={props.onCloseSearch}
34
- />
35
- {props.searchField}
36
- {props.filter}
37
- </>
38
- ) : (
39
- <>
40
- <View className="min-w-0 flex-1 pl-4">
41
- <WorkspaceConnectionTitle
42
- grow
43
- onPress={props.onOpenEnvironments}
44
- brand={
45
- <CompactBrandTitle
46
- allowFontScaling={false}
47
- accessibilityLabel={props.titleAccessibilityLabel}
48
- fit
49
- />
50
- }
51
- />
52
- </View>
53
- <AndroidHeaderIconButton
54
- accessibilityLabel={props.searchAccessibilityLabel}
55
- icon="magnifyingglass"
56
- onPress={props.onOpenSearch}
57
- />
58
- {props.filter}
59
- </>
60
- )}
61
- </View>
62
- );
63
-}
apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx
+36
-33
@@ -6,7 +6,7 @@ import { WorkspaceExtraTab } from "./WorkspaceExtraTab";
6
import { View } from "react-native";
7
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
8
import { NativeStackScreenOptions } from "../../native/StackHeader";
9
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
9
+import { AppBar } from "../../components/ui/AppBar";
10
import { EmptyState } from "../../components/ui/EmptyState";
11
import { ScreenContent } from "../../components/ui/ScreenContent";
12
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
@@ -18,6 +18,7 @@ import { AndroidWorkspaceNavigation, FloatingWorkspaceTabs } from "./AndroidWork
18
import { FLOATING_TABS } from "./floating-workspace-tabs";
19
import { WorkspaceTabsContext, useWorkspaceTabs } from "./WorkspaceTabsContext";
20
import { WorkspaceTabPanes } from "./WorkspaceTabPanes";
21
+import { WorkspaceAppBarScope } from "../../components/ui/WorkspaceAppBar.android";
22
import type { WorkspaceTab } from "./workspace-tabs-state";
23
24
const TABS: readonly WorkspaceTab[] = NAVIGATION_TAB_ORDER;
@@ -65,38 +66,40 @@ export function WorkspaceRootScreen() {
66
<WorkspaceNoTabs />
67
)
68
) : (
68
- <WorkspaceTabPanes
69
- tabs={TABS}
70
- selected={tab}
71
- renderTab={(tab) =>
72
- tab === "threads" ? (
73
- <HomeRouteScreen />
74
- ) : tab !== "pullRequests" ? (
75
- <WorkspaceExtraTab tab={tab} />
76
- ) : layout.usesSplitView ? (
77
- <>
78
- <NativeStackScreenOptions options={{ headerShown: false }} />
79
- <AndroidScreenHeader title="Pull requests" />
80
- <View className="flex-1 items-center justify-center px-10">
81
- <EmptyState
82
- title="Select a pull request"
83
- detail="Choose a pull request from the sidebar to review it."
84
- variant="plain"
85
- />
86
- </View>
87
- </>
88
- ) : (
89
- <PullRequestsScreen
90
- renderFrame={(filters, list) => (
91
- <>
92
- <PullRequestToolbar filters={filters} />
93
- <ScreenContent>{list}</ScreenContent>
94
- </>
95
- )}
96
- />
97
- )
98
- }
99
- />
69
+ <WorkspaceAppBarScope enabled={!layout.usesSplitView}>
70
+ <WorkspaceTabPanes
71
+ tabs={TABS}
72
+ selected={tab}
73
+ renderTab={(tab) =>
74
+ tab === "threads" ? (
75
+ <HomeRouteScreen />
76
+ ) : tab !== "pullRequests" ? (
77
+ <WorkspaceExtraTab tab={tab} />
78
+ ) : layout.usesSplitView ? (
79
+ <>
80
+ <NativeStackScreenOptions options={{ headerShown: false }} />
81
+ <AppBar embedded sidebar={false} title="Pull requests" />
82
+ <View className="flex-1 items-center justify-center px-10">
83
+ <EmptyState
84
+ title="Select a pull request"
85
+ detail="Choose a pull request from the sidebar to review it."
86
+ variant="plain"
87
+ />
88
+ </View>
89
+ </>
90
+ ) : (
91
+ <PullRequestsScreen
92
+ renderFrame={(filters, list) => (
93
+ <>
94
+ <PullRequestToolbar filters={filters} />
95
+ <ScreenContent>{list}</ScreenContent>
96
+ </>
97
+ )}
98
+ />
99
+ )
100
+ }
101
+ />
102
+ </WorkspaceAppBarScope>
103
)}
104
</SafeAreaInsetsContext>
105
{layout.usesSplitView ? null : floatingTabsEnabled ? (
apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
+4
-2
@@ -10,7 +10,7 @@ import { useKeyboardState } from "react-native-keyboard-controller";
10
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
11
12
import { CompactBrandTitle } from "../../components/CompactBrandTitle";
13
-import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
13
+import { AppBar } from "../../components/ui/AppBar";
14
import { HeaderItemsWidthContext } from "../../native/header-items-width";
15
import { NativeStackScreenOptions } from "../../native/StackHeader";
16
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
@@ -164,7 +164,9 @@ function WorkspaceRootContent() {
164
}}
165
/>
166
) : (
167
- <AndroidScreenHeader
167
+ <AppBar
168
+ embedded
169
+ sidebar={false}
170
title="T3 Code"
171
titleContent={renderHeaderTitle()}
172
actions={[
apps/mobile/src/features/workspace/workspace-tabs-state.test.ts
+4
-1
@@ -212,7 +212,7 @@ vi.mock("./WorkspaceExtraTab", () => ({
212
},
213
}));
214
vi.mock("../../native/StackHeader", () => ({ NativeStackScreenOptions: () => null }));
215
-vi.mock("../../components/ui/AndroidScreenHeader", () => ({ AndroidScreenHeader: () => null }));
215
+vi.mock("../../components/ui/AppBar", () => ({ AppBar: () => null }));
216
vi.mock("../../components/ui/EmptyState", () => ({ EmptyState: () => null }));
217
vi.mock("../../components/ui/ScreenContent", () => ({
218
ScreenContent: ({ children }: { children: ReactNode }) => createElement("div", null, children),
@@ -232,6 +232,9 @@ vi.mock("./AndroidWorkspaceNavigation", () => ({
232
FloatingWorkspaceTabs: () => null,
233
}));
234
vi.mock("./WorkspaceNoTabs", () => ({ WorkspaceNoTabs: () => null }));
235
+vi.mock("../../components/ui/WorkspaceAppBar.android", () => ({
236
+ WorkspaceAppBarScope: ({ children }: { children: ReactNode }) => children,
237
+}));
238
239
function setup(split: boolean, floating: boolean) {
240
mocks.split = split;
apps/mobile/vite.config.ts
+1
@@ -20,6 +20,7 @@ const reactTests = [
20
"src/components/ProjectFavicon.test.tsx",
21
"src/components/ui/Dialog.android.test.tsx",
22
"src/features/pull-requests/usePullRequestList.test.tsx",
23
+ "src/components/ui/AppBar.android.test.tsx",
24
"src/features/files/ZipArchiveView.test.tsx",
25
"src/features/pull-requests/guide/useReviewGuide.test.tsx",
26
"src/features/settings/SettingsServerControlsRouteScreen.test.tsx",
vite.config.ts
+21
@@ -386,6 +386,27 @@ export default defineConfig({
386
],
387
},
388
},
389
+ {
390
+ files: ["apps/mobile/src/features/**"],
391
+ rules: {
392
+ "eslint/no-restricted-imports": [
393
+ "error",
394
+ {
395
+ paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS],
396
+ patterns: [
397
+ {
398
+ group: [
399
+ "**/components/ui/AndroidScreenHeader",
400
+ "**/components/ui/WorkspaceAppBar*",
401
+ ],
402
+ importNames: ["AndroidScreenHeader", "WorkspaceAppBar"],
403
+ message: "Use AppBar, so every screen gets the same header and button metrics.",
404
+ },
405
+ ],
406
+ },
407
+ ],
408
+ },
409
+ },
410
{
411
files: ["apps/web/src/components/pullRequest/pullRequestIcons.tsx"],
412
rules: { "eslint/no-restricted-imports": ["error", { paths: RESTRICTED_IMPORT_PATHS }] },