@devries-cameron20 / t3code-1 / commits / 9cdd05926b
Fork 0

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

fix(mobile): keep Duo toolbar actions clear of workspace tabs (#22976)

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

Julius Marminge committed Oct 21, 2026 at 17:58 UTC 9cdd05926b28631fc201e5a3ba80648943834b44
10 files changed +121 -340
apps/mobile/src/features/home/HomeHeader.tsx
+3 -238
@@ -1,243 +1,8 @@
1 -import { Toolbar } from "../../components/ui/Toolbar";
2 -import { NativeStackScreenOptions } from "../../native/StackHeader";
3 -import { use, useCallback, useEffect, useRef } from "react";
4 -import { useNavigation, type ParamListBase } from "@react-navigation/native";
5 -import type { NativeStackNavigationProp } from "@react-navigation/native-stack";
6 -import { Platform } from "react-native";
7 -import type { SearchBarCommands } from "react-native-screens";
8 -import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
9 -import { useUniwindTheme } from "../../lib/useUniwindTheme";
10 -import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
11 -import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
12 -import { createNativeMailSearchToolbarItem } from "../layout/native-mail-search-toolbar";
13 -import { useNativeMailSearchToolbar } from "../../native/use-native-mail-search-toolbar";
14 -import { useDeviceType } from "../../native/native-layout-metrics";
15 -import { buildHomeListFilterMenu } from "./home-list-filter-menu";
16 -import {
17 - createSidebarFilterHeaderItem,
18 - createSidebarHeaderItems,
19 -} from "../threads/sidebar-native-header-items";
1 import type { HomeHeaderProps } from "./HomeHeader.types";
21 -import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
2
3 export type { HomeHeaderEnvironment } from "./HomeHeader.types";
4
25 -export function HomeHeader(props: HomeHeaderProps) {
26 - const navigation = useNavigation<NativeStackNavigationProp<ParamListBase>>();
27 - const { layout, panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
28 - const usesNativeMailSearchToolbar = useNativeMailSearchToolbar();
29 - const deviceType = useDeviceType();
30 - const primaryColumn = use(NativePrimaryColumnContext);
31 - const sidebarHeader =
32 - Platform.OS === "ios" &&
33 - primaryColumn !== null &&
34 - (deviceType === "pad" || !usesNativeMailSearchToolbar);
35 - const showsCompactCompose = deviceType === "pad" && !layout.usesSplitView;
36 - const searchBarRef = useRef<SearchBarCommands>(null);
37 - const focusAfterReveal = useRef(false);
38 - useEffect(
39 - () =>
40 - navigation.addListener("transitionEnd", (event) => {
41 - if (focusAfterReveal.current && !event.data.closing) {
42 - focusAfterReveal.current = false;
43 - searchBarRef.current?.focus();
44 - }
45 - }),
46 - [navigation],
47 - );
48 - const iconColor = useUniwindTheme()["--color-icon"];
49 - const hasCustomListOptions =
50 - props.selectedEnvironmentId !== null || props.selectedProjectKey !== null;
51 - const focusSearch = useCallback(() => {
52 - if (primaryColumn && !panes.primarySidebarVisible) {
53 - focusAfterReveal.current = true;
54 - togglePrimarySidebar();
55 - return true;
56 - }
57 - searchBarRef.current?.focus();
58 - return searchBarRef.current !== null;
59 - }, [primaryColumn, panes.primarySidebarVisible, togglePrimarySidebar]);
60 - useHardwareKeyboardCommand("focusSearch", focusSearch);
61 - const filterMenu = buildHomeListFilterMenu(props);
62 -
63 - if (props.usesWorkspaceToolbar) {
64 - return deviceType === "duo-unfolded" ? (
65 - <NativeStackScreenOptions
66 - optionsVersion={filterMenu.items}
67 - options={{
68 - nativeSidebarFilter: createSidebarFilterHeaderItem({
69 - filterIcon: hasCustomListOptions
70 - ? "line.3.horizontal.decrease.circle.fill"
71 - : "line.3.horizontal.decrease.circle",
72 - filterMenu,
73 - }),
74 - }}
75 - />
76 - ) : null;
77 - }
78 -
79 - return (
80 - <>
81 - <NativeStackScreenOptions
82 - optionsVersion={[filterMenu.items, showsCompactCompose]}
83 - options={{
84 - headerTintColor: iconColor,
85 - unstable_headerRightItems: () =>
86 - sidebarHeader
87 - ? [
88 - ...createSidebarHeaderItems({
89 - filterIcon: hasCustomListOptions
90 - ? "line.3.horizontal.decrease.circle.fill"
91 - : "line.3.horizontal.decrease.circle",
92 - filterMenu,
93 - onOpenSettings: props.onOpenSettings,
94 - }),
95 - ...(showsCompactCompose
96 - ? [
97 - withNativeGlassHeaderItem({
98 - accessibilityLabel: "New task",
99 - axisBehavior: "horizontalOnly",
100 - icon: { name: "square.and.pencil", type: "sfSymbol" } as const,
101 - identifier: "home-new-task",
102 - label: "",
103 - onPress: props.onStartNewTask,
104 - type: "button",
105 - }),
106 - ]
107 - : []),
108 - ]
109 - : [
110 - withNativeGlassHeaderItem({
111 - accessibilityLabel: "Open settings",
112 - icon: { name: "ellipsis", type: "sfSymbol" } as const,
113 - identifier: "home-settings",
114 - label: "",
115 - onPress: props.onOpenSettings,
116 - type: "button",
117 - }),
118 - ],
119 - // The keys below are set per-branch (not `undefined`) so a later
120 - // reapply cannot clobber options owned by Toolbar.
121 - ...(sidebarHeader
122 - ? {
123 - headerSearchBarOptions: {
124 - ref: searchBarRef,
125 - autoCapitalize: "none" as const,
126 - hideNavigationBar: false,
127 - hideWhenScrolling: false,
128 - obscureBackground: false,
129 - placement: "stacked" as const,
130 - allowToolbarIntegration: false,
131 - placeholder: "Search",
132 - onCancelButtonPress: () => props.onSearchQueryChange(""),
133 - onChangeText: (event) => props.onSearchQueryChange(event.nativeEvent.text),
134 - },
135 - unstable_headerToolbarItems: () => [],
136 - }
137 - : usesNativeMailSearchToolbar
138 - ? {
139 - headerSearchBarOptions: {
140 - ref: searchBarRef,
141 - autoCapitalize: "none" as const,
142 - onCancelButtonPress: () => props.onSearchQueryChange(""),
143 - },
144 - unstable_headerToolbarItems: () => [
145 - createNativeMailSearchToolbarItem({
146 - composeButtonId: "home-new-task",
147 - composeSystemImageName: "square.and.pencil",
148 - filterMenu,
149 - filterButtonId: "home-filter",
150 - filterSystemImageName: hasCustomListOptions
151 - ? "line.3.horizontal.decrease.circle.fill"
152 - : "line.3.horizontal.decrease",
153 - onComposePress: props.onStartNewTask,
154 - onSearchTextChange: props.onSearchQueryChange,
155 - placeholder: "Search",
156 - searchTextChangeId: "home-search-text",
157 - showsSearchDismissButton: true,
158 - }),
159 - ],
160 - }
161 - : {
162 - headerSearchBarOptions: {
163 - ref: searchBarRef,
164 - autoCapitalize: "none" as const,
165 - hideNavigationBar: false,
166 - placeholder: "Search",
167 - onCancelButtonPress: () => {
168 - props.onSearchQueryChange("");
169 - },
170 - onChangeText: (event) => {
171 - props.onSearchQueryChange(event.nativeEvent.text);
172 - },
173 - },
174 - }),
175 - }}
176 - />
177 -
178 - {sidebarHeader || usesNativeMailSearchToolbar ? null : (
179 - <Toolbar placement="bottom">
180 - <Toolbar.Menu
181 - accessibilityLabel="Filter threads"
182 - icon={
183 - hasCustomListOptions
184 - ? "line.3.horizontal.decrease.circle.fill"
185 - : "line.3.horizontal.decrease.circle"
186 - }
187 - title="Thread list options"
188 - separateBackground
189 - >
190 - <Toolbar.Menu title="Environment">
191 - <Toolbar.Label>Environment</Toolbar.Label>
192 - <Toolbar.MenuAction
193 - isOn={props.selectedEnvironmentId === null}
194 - onPress={() => props.onEnvironmentChange(null)}
195 - subtitle="Show threads from every environment"
196 - >
197 - <Toolbar.Label>All environments</Toolbar.Label>
198 - </Toolbar.MenuAction>
199 - {props.environments.map((environment) => (
200 - <Toolbar.MenuAction
201 - key={environment.environmentId}
202 - isOn={props.selectedEnvironmentId === environment.environmentId}
203 - onPress={() => props.onEnvironmentChange(environment.environmentId)}
204 - >
205 - <Toolbar.Label>{environment.label}</Toolbar.Label>
206 - </Toolbar.MenuAction>
207 - ))}
208 - </Toolbar.Menu>
209 -
210 - {props.projects.length > 0 ? (
211 - <Toolbar.Menu title="Project">
212 - <Toolbar.Label>Project</Toolbar.Label>
213 - <Toolbar.MenuAction
214 - isOn={props.selectedProjectKey === null}
215 - onPress={() => props.onProjectChange(null)}
216 - subtitle="Show threads from every project"
217 - >
218 - <Toolbar.Label>All projects</Toolbar.Label>
219 - </Toolbar.MenuAction>
220 - {props.projects.map((project) => (
221 - <Toolbar.MenuAction
222 - key={project.key}
223 - isOn={props.selectedProjectKey === project.key}
224 - onPress={() => props.onProjectChange(project.key)}
225 - >
226 - <Toolbar.Label>{project.label}</Toolbar.Label>
227 - </Toolbar.MenuAction>
228 - ))}
229 - </Toolbar.Menu>
230 - ) : null}
231 - </Toolbar.Menu>
232 - <Toolbar.Spacer flexible />
233 - <Toolbar.Button
234 - accessibilityLabel="New task"
235 - icon="square.and.pencil"
236 - onPress={props.onStartNewTask}
237 - separateBackground
238 - />
239 - </Toolbar>
240 - )}
241 - </>
242 - );
5 +/** The iOS thread list lives in the workspace, whose WorkspaceToolbar owns its header and search. */
6 +export function HomeHeader(_props: HomeHeaderProps) {
7 + return null;
8 }
apps/mobile/src/features/home/HomeHeader.types.ts
-1
@@ -7,7 +7,6 @@ import type {
7 export type HomeHeaderEnvironment = HomeListFilterMenuEnvironment;
8
9 export interface HomeHeaderProps {
10 - readonly usesWorkspaceToolbar?: boolean;
10 readonly environments: ReadonlyArray<HomeHeaderEnvironment>;
11 readonly projects: ReadonlyArray<HomeListFilterMenuProject>;
12 readonly searchQuery: string;
apps/mobile/src/features/home/HomeRouteScreen.tsx
-1
@@ -228,7 +228,6 @@ export function HomeRouteScreen() {
228 />
229 )}
230 <HomeHeader
231 - usesWorkspaceToolbar={workspace !== null}
231 environments={environments}
232 projects={projectFilterOptions}
233 searchQuery={searchQuery}
apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
+30 -17
@@ -14,7 +14,6 @@ import {
14 } from "@react-navigation/native";
15 import {
16 NativeStackView,
17 - type NativeStackHeaderItemMenu,
17 type NativeStackNavigationEventMap,
18 type NativeStackNavigationOptions,
19 type NativeStackNavigatorProps,
@@ -25,9 +24,10 @@ import { View } from "react-native";
24 import { Split, type SplitHostCommands } from "react-native-screens";
25 import { EnvironmentId, ThreadId } from "@t3tools/contracts";
26 import { scopedThreadKey } from "../../lib/scopedEntities";
28 -import { WorkspaceTabsProvider } from "../workspace/WorkspaceTabsContext";
27 +import { WorkspaceTabsProvider, useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
28 import { WorkspaceNativeTabs } from "../workspace/WorkspaceNativeTabs.ios";
30 -import { useNativeLayoutMetrics } from "../../native/native-layout-metrics";
29 +import { isDuoDevice } from "../../lib/device-type";
30 +import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
31
32 import { useAdaptiveWorkspaceLayout } from "./AdaptiveWorkspaceLayout";
33 import { WorkspaceEmptyDetail } from "./WorkspaceEmptyDetail";
@@ -60,14 +60,20 @@ type ViewProps = ComponentProps<typeof NativeStackView>;
60 type Descriptor = ViewProps["descriptors"][string];
61 type Route = ViewProps["state"]["routes"][number];
62
63 +const isPullRequestRoute = (route: Route) =>
64 + route.name === "PullRequest" ||
65 + route.name === "PullRequestFile" ||
66 + route.name === "PullRequestFiles";
67 +
68 function ColumnScreen(props: {
69 readonly descriptor: Descriptor;
70 readonly primary?: boolean;
71 readonly selectedThreadKey?: string | null;
72 readonly selectedPullRequestKey?: string | null;
68 - readonly sidebarFilter?: NativeStackHeaderItemMenu;
73 readonly onDismiss: (routeKey: string) => void;
74 readonly onAppearance: (type: "willAppear" | "didAppear" | "willDisappear", key: string) => void;
75 + readonly onCompose?: () => void;
76 + readonly covered?: boolean;
77 readonly navigation: ViewProps["navigation"];
78 }) {
79 const { descriptor } = props;
@@ -109,8 +115,9 @@ function ColumnScreen(props: {
115 <V5StackHeader
116 options={descriptor.options}
117 canGoBack={!props.primary}
112 - primary={props.primary}
113 - sidebarFilter={props.sidebarFilter}
118 + column={props.primary ? "primary" : "detail"}
119 + onCompose={props.onCompose}
120 + covered={props.covered}
121 />
122 <ColumnContent
123 primary={props.primary}
@@ -132,6 +139,15 @@ function WorkspaceColumns(
139 props: ViewProps & { readonly primary: Route; readonly detail: Route[] },
140 ) {
141 const { layout, panes, togglePrimarySidebar, toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();
142 + const deviceType = useDeviceType();
143 + const selectedTab = useWorkspaceTabs()?.state.selectedTab;
144 + const openNewTask = () => props.navigation.navigate("NewTaskSheet", { screen: "NewTask" });
145 + // The Duo keeps compose in the detail column's bar, which is its vertical bar in landscape
146 + // and folded, so it sits with the column's other actions whichever screen is shown. Pull
147 + // requests leave it out, including one opened from a thread; their bar is already full of
148 + // review actions.
149 + const detailCompose =
150 + isDuoDevice(deviceType) && selectedTab !== "pullRequests" ? openNewTask : undefined;
151 const inspector = use(NativeWorkspaceInspectorContext);
152 const hostRef = useRef<SplitHostCommands>(null);
153 const activeDetailKey = props.detail.at(-1)?.key;
@@ -139,12 +155,7 @@ function WorkspaceColumns(
155 const collapsed = useRef(!layout.usesSplitView);
156 const collapsedColumn = useRef<CollapsedSplitColumn>({ visible: compactColumn, leaving: null });
157 const threadParams = props.detail.findLast((route) => route.name === "Thread")?.params;
142 - const pullRequestParams = props.detail.findLast(
143 - (route) =>
144 - route.name === "PullRequest" ||
145 - route.name === "PullRequestFile" ||
146 - route.name === "PullRequestFiles",
147 - )?.params;
158 + const pullRequestParams = props.detail.findLast(isPullRequestRoute)?.params;
159 const selectedPullRequestKey =
160 pullRequestParams &&
161 "environmentId" in pullRequestParams &&
@@ -199,7 +210,6 @@ function WorkspaceColumns(
210
211 const primary = props.descriptors[props.primary.key];
212 if (!primary) return null;
202 - const sidebarFilter = (primary.options as AppNativeStackNavigationOptions).nativeSidebarFilter;
213 return (
214 <Split.Host
215 ref={hostRef}
@@ -240,6 +250,7 @@ function WorkspaceColumns(
250 selectedPullRequestKey={selectedPullRequestKey}
251 onDismiss={handleNativeDismiss}
252 onAppearance={followCollapsedSplit}
253 + covered={!layout.usesSplitView && activeDetailKey !== undefined}
254 navigation={props.navigation}
255 />
256 </Split.Stack>
@@ -264,12 +275,14 @@ function WorkspaceColumns(
275 ],
276 }}
277 canGoBack={false}
267 - sidebarFilter={sidebarFilter}
278 + column="detail"
279 + onCompose={detailCompose}
280 />
281 <ColumnContent>
282 <WorkspaceEmptyDetail
271 - onStartNewTask={() =>
272 - props.navigation.navigate("NewTaskSheet", { screen: "NewTask" })
283 + onStartNewTask={
284 + // The detail bar or a visible sidebar already carries compose.
285 + detailCompose || panes.primarySidebarVisible ? undefined : openNewTask
286 }
287 />
288 </ColumnContent>
@@ -282,8 +295,8 @@ function WorkspaceColumns(
295 descriptor={descriptor}
296 onDismiss={handleNativeDismiss}
297 onAppearance={followCollapsedSplit}
298 + onCompose={isPullRequestRoute(route) ? undefined : detailCompose}
299 navigation={props.navigation}
286 - sidebarFilter={sidebarFilter}
300 />
301 ) : null;
302 })}
apps/mobile/src/features/threads/sidebar-native-header-items.ts
+11 -18
@@ -31,30 +31,23 @@ function toNativeHeaderMenuItems(items: HomeListFilterMenu["items"]): NativeHead
31 );
32 }
33
34 -export function createSidebarFilterHeaderItem(input: {
35 - readonly filterIcon: string;
36 - readonly filterMenu: HomeListFilterMenu;
37 -}): NativeStackHeaderItemMenu {
38 - return withNativeGlassHeaderItem({
39 - type: "menu",
40 - axisBehavior: "horizontalOnly",
41 - label: "",
42 - accessibilityLabel: "Filter threads",
43 - icon: sfSymbolIcon(input.filterIcon),
44 - menu: {
45 - title: input.filterMenu.title,
46 - items: toNativeHeaderMenuItems(input.filterMenu.items),
47 - },
48 - });
49 -}
50 -
34 export function createSidebarHeaderItems(input: {
35 readonly filterIcon: string;
36 readonly filterMenu: HomeListFilterMenu;
37 readonly onOpenSettings: () => void;
38 }): NativeStackHeaderItem[] {
39 return [
57 - createSidebarFilterHeaderItem(input),
40 + withNativeGlassHeaderItem({
41 + type: "menu",
42 + axisBehavior: "horizontalOnly",
43 + label: "",
44 + accessibilityLabel: "Filter threads",
45 + icon: sfSymbolIcon(input.filterIcon),
46 + menu: {
47 + title: input.filterMenu.title,
48 + items: toNativeHeaderMenuItems(input.filterMenu.items),
49 + },
50 + }),
51 withNativeGlassHeaderItem({
52 type: "button",
53 axisBehavior: "horizontalOnly",
apps/mobile/src/features/threads/useThreadHeaderOptions.tsx
+2 -23
@@ -100,23 +100,6 @@ export function useThreadHeaderOptions(props: {
100 [navigation],
101 );
102
103 - const duoRightHeaderItems = useMemo<NativeHeaderItems>(
104 - () => [
105 - ...threadCenterHeaderItems,
106 - { type: "spacing", spacing: 8 },
107 - withNativeGlassHeaderItem({
108 - type: "button" as const,
109 - axisBehavior: "verticalPreferred",
110 - identifier: "thread-right-new-task",
111 - label: "New task",
112 - accessibilityLabel: "New task",
113 - icon: { name: "square.and.pencil", type: "sfSymbol" as const },
114 - onPress: () => navigation.navigate("NewTaskSheet", { screen: "NewTask" }),
115 - }),
116 - ],
117 - [navigation, threadCenterHeaderItems],
118 - );
119 -
103 const options: AppNativeStackNavigationOptions = {
104 headerShown: true,
105 headerTitle: props.title,
@@ -133,12 +116,9 @@ export function useThreadHeaderOptions(props: {
116 : canGoBack
117 ? undefined
118 : () => compactHomeHeaderItems,
119 + // The workspace navigator adds compose to the Duo detail column's bar.
120 unstable_headerRightItems: () =>
137 - usesDuoHeader
138 - ? duoRightHeaderItems
139 - : layout.usesSplitView
140 - ? threadCenterHeaderItems
141 - : compactRightHeaderItems,
121 + usesDuoHeader || layout.usesSplitView ? threadCenterHeaderItems : compactRightHeaderItems,
122 unstable_headerToolbarItems: () => [],
123 unstable_headerSubtitle: props.usesNativeHeaderGlass ? props.subtitle : undefined,
124 contentStyle: undefined,
@@ -154,7 +134,6 @@ export function useThreadHeaderOptions(props: {
134 splitLeftHeaderItems,
135 threadCenterHeaderItems,
136 compactRightHeaderItems,
157 - duoRightHeaderItems,
137 usesDuoHeader,
138 environmentId,
139 threadId,
apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
-1
@@ -112,7 +112,6 @@ function WorkspaceRootContent() {
112 headerShown: true,
113 unstable_headerLeftItems: () => [],
114 headerTitle: renderHeaderTitle,
115 - ...(state.selectedTab === "threads" ? {} : { nativeSidebarFilter: undefined }),
115 }}
116 />
117 ) : (
apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx
+22 -7
@@ -2,7 +2,8 @@ import { Toolbar } from "../../components/ui/Toolbar";
2 import { useFocusEffect, useNavigation } from "@react-navigation/native";
3 import { use, useCallback, useEffect, useRef } from "react";
4 import { Platform } from "react-native";
5 -import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
5 +import { isDuoDevice } from "../../lib/device-type";
6 +import { useDeviceType } from "../../native/native-layout-metrics";
7 import type { SearchBarCommands } from "react-native-screens";
8
9 import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
@@ -24,16 +25,22 @@ export function WorkspaceToolbar(props: {
25 }) {
26 const workspace = useWorkspaceTabs()!;
27 const navigation = useNavigation();
27 - const metrics = useNativeLayoutMetrics();
28 const deviceType = useDeviceType();
29 const sidebarTabs = useSidebarWorkspaceTabs();
30 const selectTab = useSelectWorkspaceTab();
31 const selectedTint = useMobileNavigationTheme().colors.primary;
32 + // On the Duo, compose belongs to the threads tab, in the detail column's bar when unfolded.
33 const nativeToolbarCompose =
34 Platform.OS === "ios" &&
34 - (deviceType === "pad" ||
35 - sidebarTabs !== null ||
36 - (metrics?.verticalBarEdge ?? "none") !== "none");
35 + (isDuoDevice(deviceType)
36 + ? deviceType === "duo-folded" && workspace.state.selectedTab === "threads"
37 + : deviceType === "pad");
38 + // The expanded Duo sidebar keeps a full search field in its bottom toolbar. UIKit holds the
39 + // integrated field there, but moves the button form into the detail column's vertical bar.
40 + // Folded, the workspace tab bar owns the bottom of the vertical bar, so search keeps UIKit's
41 + // own placement.
42 + const toolbarSearch =
43 + NATIVE_LIQUID_GLASS_SUPPORTED && deviceType === "duo-unfolded" && props.sidebar === true;
44 const { isTabActive } = workspace;
45 const tabActive = use(NativeWorkspaceTabActivityContext)?.active ?? true;
46 const { panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
@@ -87,8 +94,15 @@ export function WorkspaceToolbar(props: {
94 hideNavigationBar: false,
95 hideWhenScrolling: false,
96 obscureBackground: false,
90 - placement: NATIVE_LIQUID_GLASS_SUPPORTED ? "integratedButton" : "stacked",
91 - allowToolbarIntegration: NATIVE_LIQUID_GLASS_SUPPORTED,
97 + placement: toolbarSearch
98 + ? "integrated"
99 + : NATIVE_LIQUID_GLASS_SUPPORTED
100 + ? "integratedButton"
101 + : "stacked",
102 + // Folded, the tab bar owns the bottom of the vertical bar; refusing toolbar
103 + // integration also makes UIKit re-place a visible search in the navigation bar.
104 + allowToolbarIntegration:
105 + NATIVE_LIQUID_GLASS_SUPPORTED && deviceType !== "duo-folded",
106 placeholder:
107 selectedTab === "pullRequests" ? "Search pull requests" : "Search threads",
108 cancelButtonText: "✕",
@@ -154,6 +168,7 @@ export function WorkspaceToolbar(props: {
168 />
169 ) : null}
170 {nativeToolbarCompose ? <Toolbar.Spacer flexible /> : null}
171 + {toolbarSearch ? <Toolbar.SearchBarSlot /> : null}
172 {nativeToolbarCompose ? (
173 <Toolbar.Button
174 identifier="workspace-compose"
apps/mobile/src/native/StackHeader.tsx
-2
@@ -1,6 +1,5 @@
1 import { useNavigation, type ParamListBase } from "@react-navigation/native";
2 import type {
3 - NativeStackHeaderItemMenu,
3 NativeStackNavigationOptions,
4 NativeStackNavigationProp,
5 } from "@react-navigation/native-stack";
@@ -20,7 +19,6 @@ export type AppNativeStackNavigationOptions = Omit<
19 "headerTintColor" | "unstable_headerLeftItems" | "unstable_headerRightItems"
20 > & {
21 readonly nativeContentInsetHorizontally?: boolean;
23 - readonly nativeSidebarFilter?: NativeStackHeaderItemMenu;
22 readonly headerTintColor?: string | ColorValue;
23 readonly unstable_headerCenterItems?: unknown;
24 readonly unstable_headerLeftItems?: unknown;
apps/mobile/src/native/V5StackHeader.ios.tsx
+53 -32
@@ -3,7 +3,7 @@ import type {
3 NativeStackHeaderItemMenu,
4 NativeStackNavigationOptions,
5 } from "@react-navigation/native-stack";
6 -import { isValidElement, useEffect, useRef } from "react";
6 +import { isValidElement, useEffect, useRef, useState } from "react";
7 import { StyleSheet } from "react-native";
8 import { useMobileNavigationTheme } from "../lib/useMobileNavigationTheme";
9 import { useDeviceType, useNativeLayoutMetrics } from "../native/native-layout-metrics";
@@ -139,36 +139,34 @@ function convertItems(items: NativeStackHeaderItem[], prefix: string): HeaderIte
139 export function V5StackHeader(props: {
140 readonly options: Options;
141 readonly canGoBack: boolean;
142 - readonly primary?: boolean;
143 - readonly sidebarFilter?: NativeStackHeaderItemMenu;
142 + /** Workspace split columns share the vertical bar with the workspace tab bar. */
143 + readonly column?: "primary" | "detail";
144 + /** The workspace's compose action, shown as its own group in this column's bar. */
145 + readonly onCompose?: () => void;
146 + /** Whether another column covers this one in a collapsed split. */
147 + readonly covered?: boolean;
148 }) {
149 const { options } = props;
150 const theme = useMobileNavigationTheme();
151 const nativeMetrics = useNativeLayoutMetrics();
152 const deviceType = useDeviceType();
153 const searchRef = useRef<SearchBarCommands>(null);
150 - const usesDuoToolbarRail =
151 - deviceType === "duo-unfolded" && (nativeMetrics?.verticalBarEdge ?? "none") !== "none";
154 const itemProps = { tintColor: options.headerTintColor, canGoBack: props.canGoBack };
155 const leading = convertItems(options.unstable_headerLeftItems?.(itemProps) ?? [], "leading");
154 - const trailingItems = [
155 - ...(options.unstable_headerCenterItems?.() ?? []),
156 - ...(options.unstable_headerRightItems?.(itemProps) ?? []),
157 - ];
158 - // Keep the sidebar's filter actions when UIKit moves the menu to the detail rail.
159 - if (usesDuoToolbarRail && !props.primary && props.sidebarFilter) {
160 - trailingItems.push({
161 - ...props.sidebarFilter,
162 - identifier: "home-filter",
163 - axisBehavior: "verticalPreferred",
164 - });
165 - }
166 - const trailing = convertItems(trailingItems, "trailing");
156 + const trailing = convertItems(
157 + [
158 + ...(options.unstable_headerCenterItems?.() ?? []),
159 + ...(options.unstable_headerRightItems?.(itemProps) ?? []),
160 + ],
161 + "trailing",
162 + );
163 const toolbar = options.unstable_headerToolbarItems?.() ?? [];
164 const mailSearch = toolbar.find(
165 (item): item is HeaderBarButtonMailSearchToolbarItem => item.type === "mailSearchToolbar",
166 );
167 const bottomSearch = Boolean(mailSearch) && deviceType !== "pad";
168 + // A vertical bar keeps fixed spaces at full length and separates items itself.
169 + const spacesSearch = bottomSearch && (nativeMetrics?.verticalBarEdge ?? "none") === "none";
170 const bottom = toolbar.flatMap<HeaderItem>((item, index) => {
171 if (item.type === "mailSearchToolbar") return [];
172 if (item.type === "searchBarPlacement")
@@ -180,7 +178,6 @@ export function V5StackHeader(props: {
178 bottom.push({
179 type: "item",
180 id: mailSearch.filterButtonId ?? "filter",
183 - axisBehavior: bottomSearch ? "horizontalOnly" : undefined,
181 icon: {
182 type: "sfSymbol",
183 name: mailSearch.filterSystemImageName ?? "line.3.horizontal.decrease",
@@ -188,37 +185,46 @@ export function V5StackHeader(props: {
185 menu: convertMenu(mailSearch.filterMenu, "filter-menu"),
186 });
187 if (bottomSearch) {
191 - if (bottom.length)
188 + if (spacesSearch && bottom.length)
189 bottom.push({ type: "spacer", id: "before-search", sizing: "fixed", width: 8 });
193 - bottom.push({
194 - type: "item",
195 - id: "home-search",
196 - axisBehavior: "horizontalOnly",
197 - searchBarPlacement: true,
198 - });
199 - if (mailSearch.onComposePress)
190 + bottom.push({ type: "item", id: "home-search", searchBarPlacement: true });
191 + if (spacesSearch && mailSearch.onComposePress)
192 bottom.push({ type: "spacer", id: "after-search", sizing: "fixed", width: 8 });
193 }
194 if (mailSearch.onComposePress)
195 bottom.push({
196 type: "item",
197 id: mailSearch.composeButtonId ?? "compose",
206 - axisBehavior: bottomSearch ? "horizontalOnly" : undefined,
198 identifier: "workspace-trailing-action",
199 icon: { type: "sfSymbol", name: mailSearch.composeSystemImageName ?? "square.and.pencil" },
200 onPress: mailSearch.onComposePress,
201 });
202 }
212 - // Duo keeps compose at the bottom of a visible sidebar. On a single panel,
213 - // the primary column owns the rail too; its separate UIToolbar is inaccessible.
203 + // UIKit doesn't stack a column's toolbar against the workspace tab bar, which owns the
204 + // bottom of the vertical bar and draws over it. Those columns keep the group in their
205 + // navigation items. An expanded sidebar's toolbar stays horizontal, outside the bar.
206 if (
207 + props.column &&
208 nativeMetrics &&
209 nativeMetrics.verticalBarEdge !== "none" &&
217 - (!props.primary || nativeMetrics.horizontalSizeClass === "compact")
210 + (props.column === "detail" || nativeMetrics.horizontalSizeClass === "compact")
211 ) {
212 + if (trailing.length && bottom.length)
213 + trailing.push({ type: "spacer", id: "toolbar-group", sizing: "fixed", width: 8 });
214 trailing.push(...bottom);
215 bottom.length = 0;
216 }
217 + if (props.onCompose) {
218 + if (trailing.length)
219 + trailing.push({ type: "spacer", id: "compose-group", sizing: "fixed", width: 8 });
220 + trailing.push({
221 + type: "item",
222 + id: "workspace-compose",
223 + title: "New task",
224 + icon: { type: "sfSymbol", name: "square.and.pencil" },
225 + onPress: props.onCompose,
226 + });
227 + }
228 const left = options.headerLeft?.(itemProps);
229 const right = options.headerRight?.(itemProps);
230 if (!options.unstable_headerLeftItems && isValidElement(left))
@@ -231,6 +237,20 @@ export function V5StackHeader(props: {
237 ? options.headerTitle({ children: title ?? "", tintColor: options.headerTintColor })
238 : undefined;
239 const searchOptions = options.headerSearchBarOptions;
240 + const searchPlacement = bottomSearch ? "integrated" : (searchOptions?.placement ?? "automatic");
241 + // UIKit re-places a visible search controller when its placement changes, but not one whose
242 + // column is covered; that one needs a new controller to place once the column shows again.
243 + // A hidden tab only sees the new placement as it returns, after its detail uncovered the list.
244 + const covered = props.covered === true;
245 + const [search, setSearch] = useState({ placement: searchPlacement, covered, epoch: 0 });
246 + if (search.placement !== searchPlacement || search.covered !== covered)
247 + setSearch({
248 + placement: searchPlacement,
249 + covered,
250 + epoch:
251 + search.epoch +
252 + (search.placement !== searchPlacement && (search.covered || covered) ? 1 : 0),
253 + });
254 const autofocusRef = searchOptions?.ref ?? searchRef;
255 const searchHasFocus = useRef(false);
256 useEffect(() => {
@@ -277,12 +297,13 @@ export function V5StackHeader(props: {
297 searchBar:
298 mailSearch || searchOptions ? (
299 <SearchBar
300 + key={search.epoch}
301 {...searchOptions}
302 ref={searchOptions?.ref ?? searchRef}
303 hideNavigationBar={false}
304 hideWhenScrolling={false}
305 allowToolbarIntegration={searchOptions?.allowToolbarIntegration ?? true}
285 - placement={bottomSearch ? "integrated" : (searchOptions?.placement ?? "automatic")}
306 + placement={searchPlacement}
307 placeholder={mailSearch?.placeholder ?? searchOptions?.placeholder ?? "Search"}
308 onFocus={(event) => {
309 searchHasFocus.current = true;