The best way to control Claude Code, Codex and more from any computer or phone
feat(mobile): add Usage and Settings to workspace navigation (#23841)
Alex committed
Oct 23, 2026 at 22:13 UTC
91455de0f2220a63b3778042dda0e3e797cbbef1
44 files changed
+1487
-410
apps/mobile/modules/t3-native-controls/android/src/main/java/expo/modules/t3nativecontrols/T3WorkspaceNavigationModule.kt
+12
-8
@@ -63,12 +63,11 @@ import expo.modules.kotlin.modules.ModuleDefinition
63
import expo.modules.kotlin.viewevent.EventDispatcher
64
import expo.modules.kotlin.views.ExpoView
65
66
-private val TABS = listOf("threads", "pullRequests", "settings")
67
-
66
class T3WorkspaceNavigationModule : Module() {
67
override fun definition() = ModuleDefinition {
68
Name("T3WorkspaceNavigation")
69
View(T3WorkspaceNavigationView::class) {
70
+ Prop("tabs") { view: T3WorkspaceNavigationView, value: List<String> -> view.tabs = value }
71
Prop("selectedTab") { view: T3WorkspaceNavigationView, value: String ->
72
view.selectedTab = value
73
}
@@ -121,6 +120,7 @@ class T3WorkspaceNavigationView(
120
private val onTabSelected by EventDispatcher()
121
private val onNewThread by EventDispatcher()
122
private val onOverlayChange by EventDispatcher()
123
+ var tabs by mutableStateOf(listOf("threads", "pullRequests", "usage", "settings"))
124
var selectedTab by mutableStateOf("threads")
125
var rail by mutableStateOf(false)
126
var dark by mutableStateOf(false)
@@ -175,7 +175,7 @@ class T3WorkspaceNavigationView(
175
tonalElevation = androidx.compose.ui.unit.Dp(0f),
176
windowInsets = WindowInsets(0),
177
) {
178
- TABS.forEach { tab ->
178
+ tabs.forEach { tab ->
179
NavigationBarItem(
180
selected = selectedTab == tab,
181
onClick = { onTabSelected(mapOf("tab" to tab)) },
@@ -267,12 +267,14 @@ class T3WorkspaceNavigationView(
267
)
268
}
269
}
270
- newThreadButton(fraction) {
271
- expanded = false
272
- onNewThread(emptyMap<String, Any>())
270
+ if (selectedTab == "threads") {
271
+ newThreadButton(fraction) {
272
+ expanded = false
273
+ onNewThread(emptyMap<String, Any>())
274
+ }
275
}
276
Spacer(Modifier.weight(1f))
275
- TABS.forEach { tab ->
277
+ tabs.forEach { tab ->
278
railItem(tab, fraction) {
279
expanded = false
280
onTabSelected(mapOf("tab" to tab))
@@ -356,7 +358,8 @@ class T3WorkspaceNavigationView(
358
359
private fun tabTitle(tab: String) = when (tab) {
360
"threads" -> "Chats"
359
- "pullRequests" -> "PRs"
361
+ "pullRequests" -> "Pulls"
362
+ "usage" -> "Usage"
363
else -> "Settings"
364
}
365
@@ -368,6 +371,7 @@ class T3WorkspaceNavigationView(
371
when (tab) {
372
"threads" -> R.drawable.t3_chats
373
"pullRequests" -> R.drawable.t3_pull_requests
374
+ "usage" -> R.drawable.t3_usage
375
else -> R.drawable.t3_settings
376
}
377
)
apps/mobile/modules/t3-native-controls/android/src/main/res/drawable/t3_usage.xml
new
+3
@@ -0,0 +1,3 @@
1
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
2
+ <path android:fillColor="#000000" android:fillType="evenOdd" android:pathData="M4,20V10H8V20ZM10,20V4H14V20ZM16,20V7H20V20Z" />
3
+</vector>
apps/mobile/modules/t3-native-controls/ios/T3NativeControlsModule.swift
+5
-2
@@ -34,9 +34,12 @@ public final class T3NativeControlsModule: Module {
34
35
View(T3SidebarTabBarView.self) {
36
ViewName("SidebarTabBar")
37
- Events("onSelectionChange")
38
- Prop("selectedIndex") { (view: T3SidebarTabBarView, value: Int) in view.selectedIndex = value }
37
+ Events("onSelectionChange", "onCompose")
38
+ Prop("tabs") { (view: T3SidebarTabBarView, value: [String]) in view.tabs = value }
39
+ Prop("selectedTab") { (view: T3SidebarTabBarView, value: String) in view.selectedTab = value }
40
Prop("selectedColor") { (view: T3SidebarTabBarView, value: UIColor) in view.selectedColor = value }
41
+ Prop("showsCompose") { (view: T3SidebarTabBarView, value: Bool) in view.showsCompose = value }
42
+ Prop("compact") { (view: T3SidebarTabBarView, value: Bool) in view.compact = value }
43
Prop("appearance") { (view: T3SidebarTabBarView, value: String) in view.appearance = value }
44
}
45
apps/mobile/modules/t3-native-controls/ios/T3SidebarTabBarView.swift
+121
-18
@@ -1,37 +1,139 @@
1
import ExpoModulesCore
2
import UIKit
3
4
+private final class WorkspaceTabBar: UITabBar {
5
+ var onContentLayout: ((CGRect) -> Void)?
6
+
7
+ override func layoutSubviews() {
8
+ super.layoutSubviews()
9
+ let row = tabButtons(in: self).reduce(CGRect.null) { $0.union(convert($1.bounds, from: $1)) }
10
+ if !row.isNull { onContentLayout?(row) }
11
+ }
12
+
13
+ override func safeAreaInsetsDidChange() {
14
+ super.safeAreaInsetsDidChange()
15
+ invalidateIntrinsicContentSize()
16
+ }
17
+
18
+ private func tabButtons(in view: UIView) -> [UIView] {
19
+ view.subviews.filter { !$0.isHidden }.flatMap { subview in
20
+ if subview is UIControl, subview.accessibilityIdentifier?.hasPrefix("workspace-tab-") == true {
21
+ return [subview]
22
+ }
23
+ return tabButtons(in: subview)
24
+ }
25
+ }
26
+}
27
+
28
final class T3SidebarTabBarView: ExpoView, UITabBarDelegate {
29
let onSelectionChange = EventDispatcher()
6
- private let tabBar = UITabBar()
7
- var selectedIndex = 0 { didSet { updateSelection() } }
30
+ let onCompose = EventDispatcher()
31
+ private let tabBar = WorkspaceTabBar()
32
+ private let composeButton = UIButton(type: .system)
33
+ private lazy var tabBarTrailing = tabBar.trailingAnchor.constraint(equalTo: trailingAnchor)
34
+ private var itemsByTab: [String: UITabBarItem] = [:]
35
+ var tabs = ["threads", "pullRequests", "usage", "settings"] {
36
+ didSet { if tabs != oldValue { updateItems() } }
37
+ }
38
+ var selectedTab = "threads" { didSet { updateSelection() } }
39
var selectedColor: UIColor = .systemBlue { didSet { tabBar.tintColor = selectedColor } }
40
+ var compact = false {
41
+ didSet {
42
+ tabBarTrailing.constant = showsCompose ? (compact ? -64 : -76) : 0
43
+ tabBar.setNeedsLayout()
44
+ }
45
+ }
46
+ var showsCompose = false {
47
+ didSet {
48
+ composeButton.isHidden = !showsCompose
49
+ tabBarTrailing.constant = showsCompose ? (compact ? -64 : -76) : 0
50
+ setNeedsLayout()
51
+ }
52
+ }
53
var appearance = "light" {
54
didSet { overrideUserInterfaceStyle = appearance == "dark" ? .dark : .light }
55
}
56
57
required init(appContext: AppContext? = nil) {
58
super.init(appContext: appContext)
15
- let iconBundle = Bundle(for: Self.self).url(forResource: "T3NativeControlIcons", withExtension: "bundle").flatMap(Bundle.init(url:))
16
- let pullRequestIcon = UIImage(named: "pull-request", in: iconBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
17
- tabBar.items = [
18
- UITabBarItem(title: "Threads", image: tabIcon(UIImage(systemName: "text.bubble")), tag: 0),
19
- UITabBarItem(title: "Pulls", image: tabIcon(pullRequestIcon), tag: 1),
20
- ]
21
- tabBar.items?.last?.accessibilityLabel = "Pull requests"
22
- tabBar.items?.first?.selectedImage = tabIcon(UIImage(systemName: "text.bubble.fill"))
59
tabBar.itemPositioning = .fill
60
+ // iPad's regular bar uses a compressed inline row even with fill positioning.
61
+ // This floating sidebar control needs the same full-size items as a phone bar.
62
+ if #available(iOS 17.0, *) {
63
+ tabBar.traitOverrides.horizontalSizeClass = .compact
64
+ }
65
tabBar.delegate = self
66
+ tabBar.translatesAutoresizingMaskIntoConstraints = false
67
addSubview(tabBar)
26
- updateSelection()
68
+ NSLayoutConstraint.activate([
69
+ tabBar.leadingAnchor.constraint(equalTo: leadingAnchor),
70
+ tabBarTrailing,
71
+ tabBar.bottomAnchor.constraint(equalTo: bottomAnchor),
72
+ ])
73
+ // UIKit's floating row changes with window geometry. Follow its laid-out items
74
+ // instead of estimating their position from a second set of safe-area updates.
75
+ tabBar.onContentLayout = { [weak self] frame in self?.layoutCompose(alongside: frame) }
76
+ composeButton.accessibilityLabel = "New chat"
77
+ composeButton.addAction(UIAction { [weak self] _ in self?.onCompose() }, for: .touchUpInside)
78
+ composeButton.isHidden = true
79
+ addSubview(composeButton)
80
+ configureCompose()
81
+ prepareItems()
82
+ updateItems()
83
}
84
29
- override func layoutSubviews() {
30
- super.layoutSubviews()
31
- tabBar.frame = bounds
85
+ private func configureCompose() {
86
+ var configuration: UIButton.Configuration
87
+ if #available(iOS 26.0, *) {
88
+ configuration = .glass()
89
+ } else {
90
+ configuration = .gray()
91
+ }
92
+ configuration.cornerStyle = .capsule
93
+ configuration.baseForegroundColor = .label
94
+ configuration.image = UIImage(systemName: "square.and.pencil")
95
+ configuration.preferredSymbolConfigurationForImage = UIImage.SymbolConfiguration(pointSize: 24)
96
+ composeButton.configuration = configuration
97
+ }
98
+
99
+ private func prepareItems() {
100
+ let iconBundle = Bundle(for: Self.self).url(forResource: "T3NativeControlIcons", withExtension: "bundle").flatMap(Bundle.init(url:))
101
+ let pullRequestIcon = UIImage(named: "pull-request", in: iconBundle, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate)
102
+ let labels = ["threads": "Chats", "pullRequests": "PRs", "usage": "Usage", "settings": "Settings"]
103
+ let symbols = ["threads": "text.bubble", "usage": "chart.bar.xaxis", "settings": "gearshape"]
104
+ for (tab, label) in labels {
105
+ let icon = tab == "pullRequests" ? pullRequestIcon : UIImage(systemName: symbols[tab] ?? "circle")
106
+ let item = UITabBarItem(title: nil, image: tabIcon(icon), tag: 0)
107
+ item.accessibilityLabel = label
108
+ item.accessibilityIdentifier = "workspace-tab-\(tab)"
109
+ if tab == "threads" { item.selectedImage = tabIcon(UIImage(systemName: "text.bubble.fill")) }
110
+ itemsByTab[tab] = item
111
+ }
112
+ }
113
+
114
+ private func updateItems() {
115
+ tabBar.items = tabs.enumerated().compactMap { index, tab in
116
+ guard let item = itemsByTab[tab] else { return nil }
117
+ item.tag = index
118
+ return item
119
+ }
120
updateSelection()
121
}
122
123
+ private func layoutCompose(alongside frame: CGRect) {
124
+ guard showsCompose, frame.height > 0 else { return }
125
+ let row = convert(frame, from: tabBar)
126
+ let size = row.height + 8
127
+ composeButton.frame = CGRect(x: row.maxX + 16, y: row.midY - size / 2, width: size, height: size)
128
+ }
129
+
130
+ override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
131
+ if showsCompose, let target = composeButton.hitTest(convert(point, to: composeButton), with: event) {
132
+ return target
133
+ }
134
+ return tabBar.hitTest(convert(point, to: tabBar), with: event)
135
+ }
136
+
137
override func didMoveToWindow() {
138
super.didMoveToWindow()
139
updateSelection()
@@ -49,12 +151,13 @@ final class T3SidebarTabBarView: ExpoView, UITabBarDelegate {
151
}
152
153
private func updateSelection() {
52
- guard let items = tabBar.items, items.indices.contains(selectedIndex) else { return }
53
- guard tabBar.selectedItem !== items[selectedIndex] else { return }
54
- tabBar.selectedItem = items[selectedIndex]
154
+ guard let item = itemsByTab[selectedTab], tabBar.items?.contains(item) == true else { return }
155
+ guard tabBar.selectedItem !== item else { return }
156
+ tabBar.selectedItem = item
157
}
158
159
func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
58
- onSelectionChange(["index": item.tag])
160
+ guard tabs.indices.contains(item.tag) else { return }
161
+ onSelectionChange(["tab": tabs[item.tag]])
162
}
163
}
apps/mobile/src/Stack.tsx
+14
-34
@@ -85,6 +85,7 @@ import {
85
} from "./features/threads/ThreadSettingsSheet";
86
import { NewTaskFlowProvider } from "./features/threads/new-task-flow-provider";
87
import { NewTaskRouteScreen } from "./features/threads/NewTaskRouteScreen";
88
+import { SettingsNavigationRouteScreen } from "./features/settings/SettingsNavigationRouteScreen";
89
import { SettingsAppearanceRouteScreen } from "./features/settings/SettingsAppearanceRouteScreen";
90
import { SettingsClientStorageRouteScreen } from "./features/settings/SettingsClientStorageRouteScreen";
91
import { SettingsDiagnosticsRouteScreen } from "./features/diagnostics/SettingsDiagnosticsRouteScreen";
@@ -237,6 +238,7 @@ const SettingsContentStack = createV5SheetStackNavigator({
238
// Android draws its own app bar here. Hidden only from inside the screen, the native one
239
// showed for the first frame of the Settings tab and pushed the page down.
240
headerShown: Platform.OS !== "android",
241
+ headerBackVisible: false,
242
},
243
}),
244
SettingsEnvironments: createNativeStackScreen({
@@ -305,6 +307,11 @@ const SettingsContentStack = createV5SheetStackNavigator({
307
title: "Archived Threads",
308
},
309
}),
310
+ SettingsNavigation: createNativeStackScreen({
311
+ screen: SettingsNavigationRouteScreen,
312
+ linking: "navigation-tabs",
313
+ options: { title: "Navigation tabs" },
314
+ }),
315
SettingsAppearance: createNativeStackScreen({
316
screen: SettingsAppearanceRouteScreen,
317
linking: "appearance",
@@ -975,8 +982,8 @@ const RootStackConfig = createWorkspaceStackNavigator({
982
...NESTED_NAVIGATOR_OPTIONS,
983
gestureEnabled: true,
984
headerShown: false,
978
- // Android opens Settings as a top-level tab, so it swaps like the other tabs.
979
- ...(Platform.OS === "android" ? { animation: "none" as const } : null),
985
+ presentation: "card",
986
+ animation: "none",
987
},
988
}),
989
SettingsLegal: createNativeStackScreen({
@@ -1066,42 +1073,15 @@ export const RootStack = RootStackConfig.with(function AdaptiveRootStack({ Navig
1073
const { width, height } = useWindowDimensions();
1074
const nativeMetrics = useNativeLayoutMetrics();
1075
const usesSplitView = deriveLayout({ width, height, nativeMetrics }).usesSplitView;
1069
- const usesWorkspaceFlowScreens = Platform.OS === "android" || usesSplitView;
1070
- const flowPresentations = useRef(new Map<string, boolean>());
1076
1077
return (
1078
<Navigator
1079
screenLayout={(props) => <GuardedScreenLayout {...props} />}
1075
- screenListeners={{
1076
- state: ({ data }) => {
1077
- const keys = new Set(data.state.routes.map((route) => route.key));
1078
- for (const key of flowPresentations.current.keys()) {
1079
- if (!keys.has(key)) flowPresentations.current.delete(key);
1080
- }
1081
- },
1082
- }}
1083
- screenOptions={({ route }) => {
1084
- if (route.name !== "SettingsSheet") {
1085
- return Platform.OS === "android"
1086
- ? { animation: androidWorkspaceDestinationAnimation(route.name, usesSplitView) }
1087
- : {};
1088
- }
1089
-
1090
- // Moving an open flow between a sheet and a split column remounts its nested
1091
- // navigator. Keep its presentation until dismissal so folding preserves the settings flow.
1092
- let usesCard = flowPresentations.current.get(route.key);
1093
- if (usesCard === undefined) {
1094
- usesCard = usesWorkspaceFlowScreens;
1095
- flowPresentations.current.set(route.key, usesCard);
1096
- }
1097
- return usesCard
1098
- ? { presentation: "card" }
1099
- : {
1100
- presentation: "formSheet",
1101
- sheetAllowedDetents: [1],
1102
- sheetGrabberVisible: true,
1103
- };
1104
- }}
1080
+ screenOptions={({ route }) =>
1081
+ Platform.OS === "android" && route.name !== "SettingsSheet"
1082
+ ? { animation: androidWorkspaceDestinationAnimation(route.name, usesSplitView) }
1083
+ : {}
1084
+ }
1085
/>
1086
);
1087
});
apps/mobile/src/components/ui/ScreenScrollView.tsx
+9
-1
@@ -1,11 +1,19 @@
1
-import type { ComponentProps } from "react";
1
+import { createContext, use, type ComponentProps } from "react";
2
import { Platform } from "react-native";
3
import { NativeScrollView as ScrollView } from "../../native/NativeScrollViewMarker";
4
5
+export const ScreenScrollViewBottomInset = createContext(0);
6
+
7
export function ScreenScrollView(props: ComponentProps<typeof ScrollView>) {
8
+ const bottomInset = use(ScreenScrollViewBottomInset);
9
return (
10
<ScrollView
11
{...props}
12
+ contentInset={
13
+ Platform.OS === "ios" && bottomInset > 0
14
+ ? { ...props.contentInset, bottom: (props.contentInset?.bottom ?? 0) + bottomInset }
15
+ : props.contentInset
16
+ }
17
contentContainerStyle={[
18
props.contentContainerStyle,
19
Platform.OS === "android" && {
apps/mobile/src/features/home/home-thread-navigation.test.ts
+4
@@ -21,6 +21,10 @@ function loadRouters() {
21
22
vi.mock("react-native", () => ({ Platform: { OS: "ios" }, Keyboard: { dismiss: vi.fn() } }));
23
24
+vi.mock("../workspace/useAndroidWorkspaceSelection", () => ({
25
+ useAndroidWorkspaceSelection: vi.fn(),
26
+}));
27
+
28
vi.mock("@react-navigation/native", () => {
29
const { CommonActions, StackActions } = loadRouters();
30
return { CommonActions, StackActions };
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+8
-66
@@ -1,3 +1,4 @@
1
+import { AdaptiveWorkspaceContext, useAdaptiveWorkspaceLayout } from "./adaptive-workspace-context";
2
import { createDeferredNavigation } from "./deferred-navigation";
3
import { uuidv4 } from "../../lib/uuid";
4
import type {
@@ -15,7 +16,6 @@ import {
16
useNavigation,
17
} from "@react-navigation/native";
18
import {
18
- createContext,
19
use,
20
useDeferredValue,
21
useEffect,
@@ -43,10 +43,7 @@ import {
43
type VerticalHinge,
44
deriveWorkspacePaneLayout,
45
isPrimarySidebarPinned,
46
- type FileInspectorPaneLayout,
47
- type Layout,
46
type WorkspaceAuxiliaryPaneRole,
49
- type WorkspacePaneLayout,
47
} from "../../lib/layout";
48
import {
49
resolveThreadSelectionNavigationAction,
@@ -73,6 +70,7 @@ import {
70
} from "../workspace/AndroidWorkspaceNavigation";
71
import { AndroidWorkspaceSidebar } from "../workspace/AndroidWorkspaceSidebar";
72
import { useAndroidWorkspaceSelection } from "../workspace/useAndroidWorkspaceSelection";
73
+import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
74
import { HomeListOptionsProvider } from "../home/home-list-options";
75
import { newTaskDestination } from "../threads/new-task-project-selection";
76
import { usePendingTaskListActions } from "../home/usePendingTaskListActions";
@@ -94,65 +92,7 @@ import { useNativeLayoutMetrics } from "../../native/native-layout-metrics";
92
import { AndroidHingeObserver } from "../../native/AndroidHingeObserver";
93
import { WindowHingeContext } from "../../native/window-hinge-context";
94
97
-interface AdaptiveWorkspaceContextValue {
98
- readonly layout: Layout;
99
- readonly panes: WorkspacePaneLayout;
100
- readonly fileInspector: FileInspectorPaneLayout;
101
- readonly primarySidebarSearchQuery: string;
102
- readonly startNewTask: () => void;
103
- readonly deferThreadSelectionUntil: (operation: Promise<unknown>) => void;
104
- readonly selectThread: (thread: EnvironmentThreadShell) => void;
105
- readonly selectThreadRoute: (params: ReactNavigation.RootParamList["Thread"]) => void;
106
- readonly activateAuxiliaryPaneRole: (role: WorkspaceAuxiliaryPaneRole) => () => void;
107
- readonly registerWorkspaceInspector: (render: () => ReactNode) => () => void;
108
- readonly setPrimarySidebarSearchQuery: (query: string) => void;
109
- readonly showAuxiliaryPane: (role: WorkspaceAuxiliaryPaneRole) => void;
110
- readonly toggleAuxiliaryPane: () => void;
111
- readonly togglePrimarySidebar: () => void;
112
- readonly setAuxiliaryPaneWidth: (width: number) => void;
113
- /**
114
- * Android split view while the thread composer has the soft keyboard: the
115
- * sidebar and rail step aside and the thread header drops to one line.
116
- */
117
- readonly composerKeyboardActive: boolean;
118
- /** The thread composer reports its focus so the layout can make room for typing. */
119
- readonly setComposerEditing: (editing: boolean) => void;
120
-}
121
-
122
-const compactLayout = deriveLayout({ width: 0, height: 0 });
123
-const compactPanes = deriveWorkspacePaneLayout({
124
- layout: compactLayout,
125
- viewportWidth: 0,
126
- primarySidebarPreferredVisible: true,
127
- auxiliaryPanePreferredVisible: true,
128
-});
129
-const compactFileInspector = deriveFileInspectorPaneLayout({
130
- layout: compactLayout,
131
- viewportWidth: 0,
132
-});
133
-const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceContextValue>({
134
- layout: compactLayout,
135
- panes: compactPanes,
136
- fileInspector: compactFileInspector,
137
- primarySidebarSearchQuery: "",
138
- startNewTask: () => undefined,
139
- deferThreadSelectionUntil: () => undefined,
140
- selectThread: () => undefined,
141
- selectThreadRoute: () => undefined,
142
- activateAuxiliaryPaneRole: () => () => undefined,
143
- registerWorkspaceInspector: () => () => undefined,
144
- setPrimarySidebarSearchQuery: () => undefined,
145
- showAuxiliaryPane: () => undefined,
146
- toggleAuxiliaryPane: () => undefined,
147
- togglePrimarySidebar: () => undefined,
148
- setAuxiliaryPaneWidth: () => undefined,
149
- composerKeyboardActive: false,
150
- setComposerEditing: () => undefined,
151
-});
152
-
153
-export function useAdaptiveWorkspaceLayout(): AdaptiveWorkspaceContextValue {
154
- return use(AdaptiveWorkspaceContext);
155
-}
95
+export { useAdaptiveWorkspaceLayout };
96
97
export function useAdaptiveWorkspacePaneRole(role: WorkspaceAuxiliaryPaneRole) {
98
const { activateAuxiliaryPaneRole } = useAdaptiveWorkspaceLayout();
@@ -265,9 +205,11 @@ function AdaptiveWorkspaceLayoutContent(
205
const nativeMetrics = useNativeLayoutMetrics();
206
const { width: viewportWidth, height } = nativeMetrics ?? windowDimensions;
207
const pathname = props.pathname;
268
- // Android's Settings tab is a full workspace page: the rail stays, the sidebar and
269
- // auxiliary panes hide.
270
- const workspacePage = Platform.OS === "android" && pathname.startsWith("/settings");
208
+ const workspace = useWorkspaceTabs();
209
+ // Settings and Usage occupy the workspace rather than a list/detail pair.
210
+ const workspacePage =
211
+ Platform.OS === "android" &&
212
+ (pathname.startsWith("/settings") || workspace?.state.selectedTab === "usage");
213
const navigation = useNavigation();
214
const activeRoleOwner = useRef<symbol | null>(null);
215
const [primarySidebarPreferredVisible, setPrimarySidebarPreferredVisible] = useState(true);
apps/mobile/src/features/layout/WorkspaceEmptyDetail.tsx
+2
@@ -13,6 +13,8 @@ export function WorkspaceEmptyDetail(props: {
13
readonly onAddConnection?: () => void;
14
}) {
15
const pullRequests = props.tab === "pullRequests";
16
+ if (props.tab && props.tab !== "threads" && props.tab !== "pullRequests")
17
+ return <View className="flex-1 bg-screen" />;
18
return (
19
<View
20
className={
apps/mobile/src/features/layout/adaptive-workspace-context.ts
new
+71
@@ -0,0 +1,71 @@
1
+import { createContext, use, type ReactNode } from "react";
2
+import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
3
+import {
4
+ deriveFileInspectorPaneLayout,
5
+ deriveLayout,
6
+ deriveWorkspacePaneLayout,
7
+ type FileInspectorPaneLayout,
8
+ type Layout,
9
+ type WorkspaceAuxiliaryPaneRole,
10
+ type WorkspacePaneLayout,
11
+} from "../../lib/layout";
12
+
13
+interface AdaptiveWorkspaceContextValue {
14
+ readonly layout: Layout;
15
+ readonly panes: WorkspacePaneLayout;
16
+ readonly fileInspector: FileInspectorPaneLayout;
17
+ readonly primarySidebarSearchQuery: string;
18
+ readonly startNewTask: () => void;
19
+ readonly deferThreadSelectionUntil: (operation: Promise<unknown>) => void;
20
+ readonly selectThread: (thread: EnvironmentThreadShell) => void;
21
+ readonly selectThreadRoute: (params: ReactNavigation.RootParamList["Thread"]) => void;
22
+ readonly activateAuxiliaryPaneRole: (role: WorkspaceAuxiliaryPaneRole) => () => void;
23
+ readonly registerWorkspaceInspector: (render: () => ReactNode) => () => void;
24
+ readonly setPrimarySidebarSearchQuery: (query: string) => void;
25
+ readonly showAuxiliaryPane: (role: WorkspaceAuxiliaryPaneRole) => void;
26
+ readonly toggleAuxiliaryPane: () => void;
27
+ readonly togglePrimarySidebar: () => void;
28
+ readonly setAuxiliaryPaneWidth: (width: number) => void;
29
+ /**
30
+ * Android split view while the thread composer has the soft keyboard: the
31
+ * sidebar and rail step aside and the thread header drops to one line.
32
+ */
33
+ readonly composerKeyboardActive: boolean;
34
+ /** The thread composer reports its focus so the layout can make room for typing. */
35
+ readonly setComposerEditing: (editing: boolean) => void;
36
+}
37
+
38
+const compactLayout = deriveLayout({ width: 0, height: 0 });
39
+const compactPanes = deriveWorkspacePaneLayout({
40
+ layout: compactLayout,
41
+ viewportWidth: 0,
42
+ primarySidebarPreferredVisible: true,
43
+ auxiliaryPanePreferredVisible: true,
44
+});
45
+const compactFileInspector = deriveFileInspectorPaneLayout({
46
+ layout: compactLayout,
47
+ viewportWidth: 0,
48
+});
49
+export const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceContextValue>({
50
+ layout: compactLayout,
51
+ panes: compactPanes,
52
+ fileInspector: compactFileInspector,
53
+ primarySidebarSearchQuery: "",
54
+ startNewTask: () => undefined,
55
+ deferThreadSelectionUntil: () => undefined,
56
+ selectThread: () => undefined,
57
+ selectThreadRoute: () => undefined,
58
+ activateAuxiliaryPaneRole: () => () => undefined,
59
+ registerWorkspaceInspector: () => () => undefined,
60
+ setPrimarySidebarSearchQuery: () => undefined,
61
+ showAuxiliaryPane: () => undefined,
62
+ toggleAuxiliaryPane: () => undefined,
63
+ togglePrimarySidebar: () => undefined,
64
+ setAuxiliaryPaneWidth: () => undefined,
65
+ composerKeyboardActive: false,
66
+ setComposerEditing: () => undefined,
67
+});
68
+
69
+export function useAdaptiveWorkspaceLayout(): AdaptiveWorkspaceContextValue {
70
+ return use(AdaptiveWorkspaceContext);
71
+}
apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
+10
-10
@@ -26,7 +26,7 @@ import { EnvironmentId, ThreadId } from "@t3tools/contracts";
26
import { scopedThreadKey } from "../../lib/scopedEntities";
27
import { WorkspaceTabsProvider, useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
28
import { WorkspaceNativeTabs } from "../workspace/WorkspaceNativeTabs.ios";
29
-import { isDuoDevice } from "../../lib/device-type";
29
+import { workspaceUsesColumns } from "../workspace/workspace-tabs-state";
30
import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
31
32
import { useAdaptiveWorkspaceLayout } from "./AdaptiveWorkspaceLayout";
@@ -178,12 +178,10 @@ function WorkspaceColumns(
178
179
const selectedTab = useWorkspaceTabs()?.state.selectedTab;
180
const openNewTask = startNewTask;
181
- // The Duo keeps compose in the detail column's bar, which is its vertical bar in landscape
182
- // and folded, so it sits with the column's other actions whichever screen is shown. Pull
183
- // requests leave it out, including one opened from a thread; their bar is already full of
184
- // review actions.
181
+ // The cover detail rail needs room for thread tools above the fixed tabs.
182
+ // The unfolded Duo keeps compose beside its sidebar control.
183
const detailCompose =
186
- isDuoDevice(deviceType) && selectedTab !== "pullRequests" ? openNewTask : undefined;
184
+ deviceType === "duo-unfolded" && selectedTab !== "pullRequests" ? openNewTask : undefined;
185
const inspector = use(NativeWorkspaceInspectorContext);
186
const hostRef = useRef<SplitHostCommands>(null);
187
const activeDetailKey = props.detail.at(-1)?.key;
@@ -362,7 +360,8 @@ function WorkspaceColumns(
360
}
361
362
function WorkspaceStackView(props: ViewProps & { readonly nativeColumns: boolean }) {
365
- const { layout, startNewTask } = useAdaptiveWorkspaceLayout();
363
+ const { layout } = useAdaptiveWorkspaceLayout();
364
+ const workspace = useWorkspaceTabs()!;
365
// Native dismiss commits the route pop after the transition. Restore the dock
366
// when the primary screen starts appearing, including interactive back gestures.
367
const [primaryVisible, setPrimaryVisible] = useState(false);
@@ -380,6 +379,7 @@ function WorkspaceStackView(props: ViewProps & { readonly nativeColumns: boolean
379
const descriptors = props.descriptors;
380
const baseRoute = { key: `${props.state.key}:workspace`, name: "Workspace" };
381
const visibleRoute = projection.detail.at(-1) ?? primaryRoute;
382
+ const workspacePage = !workspaceUsesColumns(workspace.state.selectedTab, visibleRoute.name);
383
const baseDescriptor: Descriptor = {
384
...primaryDescriptor,
385
navigation: props.descriptors[visibleRoute.key]!.navigation,
@@ -389,8 +389,8 @@ function WorkspaceStackView(props: ViewProps & { readonly nativeColumns: boolean
389
options: { headerShown: false },
390
render: () => (
391
<WorkspaceNativeTabs
392
- onNewTask={startNewTask}
392
hidden={
393
+ !workspacePage &&
394
projection.detail.length > 0 &&
395
!primaryVisible &&
396
!layout.usesSplitView &&
@@ -401,7 +401,7 @@ function WorkspaceStackView(props: ViewProps & { readonly nativeColumns: boolean
401
props.navigation.dispatch({ type: "POP_TO_TOP", target: props.state.key });
402
}}
403
>
404
- {props.nativeColumns ? (
404
+ {props.nativeColumns && !workspacePage ? (
405
<WorkspaceColumns
406
{...props}
407
descriptors={descriptors}
@@ -503,7 +503,7 @@ function WorkspaceStackNavigator({
503
return (
504
<NativeWorkspaceModeContext value={usesNativeWorkspaceColumns}>
505
<NavigationContent>
506
- <WorkspaceTabsProvider>
506
+ <WorkspaceTabsProvider settingsOpen={state.routes[state.index]?.name === "SettingsSheet"}>
507
<WorkspaceStackView
508
nativeColumns={usesNativeWorkspaceColumns}
509
{...rest}
apps/mobile/src/features/layout/workspace-sidebar-toolbar.tsx
+1
-1
@@ -2,7 +2,7 @@ import { Platform } from "react-native";
2
3
import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
4
5
-import { useAdaptiveWorkspaceLayout } from "./AdaptiveWorkspaceLayout";
5
+import { useAdaptiveWorkspaceLayout } from "./adaptive-workspace-context";
6
7
export function AndroidWorkspaceSidebarButton() {
8
const { layout, panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
apps/mobile/src/features/settings/SettingsNavigationRouteScreen.tsx
new
+128
@@ -0,0 +1,128 @@
1
+import { useAtomSet, useAtomValue } from "@effect/atom-react";
2
+import { AsyncResult } from "effect/reactivity";
3
+import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
4
+import { Platform, View } from "react-native";
5
+import { useSafeAreaInsets } from "react-native-safe-area-context";
6
+import {
7
+ moveNavigationTab,
8
+ navigationCustomizationAvailable,
9
+ toggleNavigationTabVisibility,
10
+} from "../workspace/navigation-tab-order";
11
+import { AppText as Text } from "../../components/ui/AppText";
12
+import { IconButton } from "../../components/ui/IconButton";
13
+import { Button } from "../../components/ui/Button";
14
+import { ScreenScrollView } from "../../components/ui/ScreenScrollView";
15
+import { SymbolView } from "../../components/ui/AppSymbol";
16
+import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
17
+import {
18
+ NAVIGATION_TAB_ICONS,
19
+ WORKSPACE_TAB_LABELS,
20
+ useNavigationTabOrder,
21
+ useHiddenNavigationTabs,
22
+ useEnabledNavigationTabs,
23
+} from "../workspace/navigation-tabs";
24
+import { SettingsScreen } from "./components/SettingsScreen";
25
+import { SettingsSection } from "./components/SettingsSection";
26
+import { resolveWorkspaceTabOrder } from "../workspace/workspace-tabs-state";
27
+
28
+export function SettingsNavigationRouteScreen() {
29
+ const insets = useSafeAreaInsets();
30
+ const order = useNavigationTabOrder();
31
+ const { layout } = useAdaptiveWorkspaceLayout();
32
+ const capacity = Platform.OS === "android" && layout.usesSplitView ? 5 : 4;
33
+ const hidden = useHiddenNavigationTabs();
34
+ const enabled = useEnabledNavigationTabs();
35
+ const preferences = useAtomValue(mobilePreferencesAtom);
36
+ const customizable = navigationCustomizationAvailable();
37
+ const ready = customizable && AsyncResult.isSuccess(preferences) && !preferences.waiting;
38
+ const save = useAtomSet(updateMobilePreferencesAtom);
39
+ return (
40
+ <SettingsScreen title="Navigation tabs">
41
+ <ScreenScrollView
42
+ contentInsetAdjustmentBehavior="automatic"
43
+ contentContainerClassName="gap-4 px-5 pt-4"
44
+ contentContainerStyle={{ paddingBottom: insets.bottom + 24 }}
45
+ >
46
+ <Text className="px-2 text-sm text-foreground-muted">
47
+ {customizable
48
+ ? "Phones show the first four enabled sections; Android tablet rails show all enabled sections. Remaining sections appear at the top of Settings. Hidden sections appear only here. Settings always stays last. Saved on this device."
49
+ : "Tab customization becomes available when there are six sections, including Settings."}
50
+ </Text>
51
+ <SettingsSection title="Tab order">
52
+ {order.map((tab, index) => (
53
+ <View key={tab} className="flex-row items-center gap-3 px-4 py-3">
54
+ <SymbolView
55
+ name={NAVIGATION_TAB_ICONS[tab]}
56
+ size={22}
57
+ tintColorClassName="accent-icon"
58
+ />
59
+ <View className="flex-1">
60
+ <Text>{WORKSPACE_TAB_LABELS[tab]}</Text>
61
+ <Text className="text-xs text-foreground-muted">
62
+ {hidden.includes(tab)
63
+ ? "Hidden"
64
+ : enabled.indexOf(tab) < capacity
65
+ ? `Tab ${enabled.indexOf(tab) + 1}`
66
+ : "In Settings"}
67
+ </Text>
68
+ </View>
69
+ <IconButton
70
+ icon={hidden.includes(tab) ? "eye.slash" : "eye"}
71
+ accessibilityLabel={`${hidden.includes(tab) ? "Show" : "Hide"} ${WORKSPACE_TAB_LABELS[tab]}`}
72
+ disabled={!ready}
73
+ onPress={() =>
74
+ save({
75
+ transform: (current) => ({
76
+ hiddenNavigationTabs: toggleNavigationTabVisibility(
77
+ current.hiddenNavigationTabs,
78
+ tab,
79
+ ),
80
+ }),
81
+ })
82
+ }
83
+ />
84
+ <IconButton
85
+ icon="arrow.up"
86
+ accessibilityLabel={`Move ${WORKSPACE_TAB_LABELS[tab]} up`}
87
+ disabled={!ready || index === 0}
88
+ onPress={() =>
89
+ save({
90
+ transform: (current) => ({
91
+ navigationTabOrder: moveNavigationTab(
92
+ resolveWorkspaceTabOrder(current.navigationTabOrder),
93
+ tab,
94
+ index - 1,
95
+ ),
96
+ }),
97
+ })
98
+ }
99
+ />
100
+ <IconButton
101
+ icon="arrow.down"
102
+ accessibilityLabel={`Move ${WORKSPACE_TAB_LABELS[tab]} down`}
103
+ disabled={!ready || index === order.length - 1}
104
+ onPress={() =>
105
+ save({
106
+ transform: (current) => ({
107
+ navigationTabOrder: moveNavigationTab(
108
+ resolveWorkspaceTabOrder(current.navigationTabOrder),
109
+ tab,
110
+ index + 1,
111
+ ),
112
+ }),
113
+ })
114
+ }
115
+ />
116
+ </View>
117
+ ))}
118
+ </SettingsSection>
119
+ <Button
120
+ label="Reset tabs"
121
+ tone="text"
122
+ disabled={!ready}
123
+ onPress={() => save({ navigationTabOrder: [], hiddenNavigationTabs: [] })}
124
+ />
125
+ </ScreenScrollView>
126
+ </SettingsScreen>
127
+ );
128
+}
apps/mobile/src/features/settings/SettingsRouteScreen.tsx
+73
-30
@@ -1,14 +1,30 @@
1
-import { Toolbar } from "../../components/ui/Toolbar";
2
-import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
1
+import {
2
+ navigationCustomizationAvailable,
3
+ overflowNavigationTabs,
4
+} from "../workspace/navigation-tab-order";
5
+import {
6
+ NAVIGATION_TAB_ICONS,
7
+ WORKSPACE_TAB_LABELS,
8
+ useNavigationTabOrder,
9
+ useHiddenNavigationTabs,
10
+} from "../workspace/navigation-tabs";
11
+import { useSelectWorkspaceTab } from "../workspace/useSelectWorkspaceTab";
12
+import {
13
+ ScreenScrollView as ScrollView,
14
+ ScreenScrollViewBottomInset,
15
+} from "../../components/ui/ScreenScrollView";
16
import { useAuth, useUser } from "@clerk/expo";
17
import { useNavigation } from "@react-navigation/native";
18
import { Platform, View } from "react-native";
19
+import { useWorkspaceSurface } from "../workspace/useWorkspaceSurface";
20
+import { useDeviceType } from "../../native/native-layout-metrics";
21
+import { useCompactWorkspaceTabs } from "../workspace/useSystemWorkspaceTabBar";
22
+import { NativeStackScreenOptions } from "../../native/StackHeader";
23
import { deriveProjectGroupLabel } from "@t3tools/client-runtime/state/project-grouping";
24
import { useSafeAreaInsets } from "react-native-safe-area-context";
25
26
import { hasCloudPublicConfig } from "../cloud/publicConfig";
27
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
11
-import { NativeStackScreenOptions } from "../../native/StackHeader";
28
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
29
import { SettingsRow } from "./components/SettingsRow";
30
import { SettingsSection } from "./components/SettingsSection";
@@ -20,8 +36,9 @@ import {
36
import { useSettingsEnvironmentFilter } from "./settings-environment-filter";
37
38
export function SettingsRouteScreen() {
23
- const navigation = useNavigation();
24
- const { layout } = useAdaptiveWorkspaceLayout();
39
+ const surface = useWorkspaceSurface();
40
+ const deviceType = useDeviceType();
41
+ const compactTabs = useCompactWorkspaceTabs();
42
const content = hasCloudPublicConfig() ? (
43
<ConfiguredSettingsRouteScreen />
44
) : (
@@ -29,30 +46,27 @@ export function SettingsRouteScreen() {
46
);
47
48
return (
32
- <>
49
+ <View className={`flex-1 ${surface.className}`}>
50
{Platform.OS === "ios" ? (
34
- <NativeStackScreenOptions options={{ headerBackVisible: !layout.usesSplitView }} />
35
- ) : null}
36
- {Platform.OS === "ios" && layout.usesSplitView ? (
37
- <>
38
- <Toolbar placement="left">
39
- <Toolbar.Button
40
- accessibilityLabel="Go back"
41
- icon="chevron.left"
42
- onPress={() => navigation.goBack()}
43
- />
44
- </Toolbar>
45
- </>
51
+ <NativeStackScreenOptions
52
+ options={{
53
+ headerTransparent: false,
54
+ headerStyle: { backgroundColor: surface.backgroundColor },
55
+ contentStyle: { backgroundColor: surface.backgroundColor },
56
+ }}
57
+ />
58
) : null}
47
- <SettingsEnvironmentFilterHeader closeSettings />
48
- {Platform.OS === "android" ? (
49
- <SettingsScreen title="Settings" trailing={<AndroidSettingsEnvironmentFilter />}>
50
- {content}
51
- </SettingsScreen>
52
- ) : (
53
- content
54
- )}
55
- </>
59
+ <SettingsEnvironmentFilterHeader />
60
+ <ScreenScrollViewBottomInset value={deviceType === "pad" || compactTabs ? 80 : 0}>
61
+ {Platform.OS === "android" ? (
62
+ <SettingsScreen title="Settings" trailing={<AndroidSettingsEnvironmentFilter />}>
63
+ {content}
64
+ </SettingsScreen>
65
+ ) : (
66
+ content
67
+ )}
68
+ </ScreenScrollViewBottomInset>
69
+ </View>
70
);
71
}
72
@@ -69,7 +83,7 @@ function ConfiguredSettingsRouteScreen() {
83
: (user?.primaryEmailAddress?.emailAddress ?? "Signed in");
84
85
return (
72
- <View collapsable={false} className="flex-1 bg-sheet">
86
+ <View collapsable={false} className="flex-1">
87
<ScrollView
88
contentInsetAdjustmentBehavior="automatic"
89
showsVerticalScrollIndicator={false}
@@ -77,6 +91,7 @@ function ConfiguredSettingsRouteScreen() {
91
contentContainerClassName="gap-4 px-5 pt-4"
92
contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
93
>
94
+ <OverflowSection />
95
<SettingsSection title="Connections">
96
<SettingsRow
97
icon="person.crop.circle"
@@ -107,7 +122,7 @@ function LocalSettingsRouteScreen() {
122
const environmentCount = Object.keys(savedConnectionsById).length;
123
124
return (
110
- <View collapsable={false} className="flex-1 bg-sheet">
125
+ <View collapsable={false} className="flex-1">
126
<ScrollView
127
contentInsetAdjustmentBehavior="automatic"
128
showsVerticalScrollIndicator={false}
@@ -117,6 +132,7 @@ function LocalSettingsRouteScreen() {
132
paddingBottom: Math.max(insets.bottom, 18) + 18,
133
}}
134
>
135
+ <OverflowSection />
136
<SettingsSection title="Connections">
137
<SettingsRow
138
icon="desktopcomputer"
@@ -154,6 +170,13 @@ function SettingsIndexSections() {
170
<>
171
<SettingsSection title="Interface">
172
<SettingsRow icon="paintbrush" label="Appearance" target="SettingsAppearance" />
173
+ {navigationCustomizationAvailable() ? (
174
+ <SettingsRow
175
+ icon="line.3.horizontal"
176
+ label="Navigation tabs"
177
+ target="SettingsNavigation"
178
+ />
179
+ ) : null}
180
{Platform.OS === "ios" ? (
181
<>
182
<SettingsRow icon="keyboard" label="Keyboard" target="SettingsKeyboard" />
@@ -215,9 +238,29 @@ function SettingsIndexSections() {
238
</SettingsSection>
239
240
<SettingsSection title="App">
218
- <SettingsRow icon="chart.bar.xaxis" label="Usage" target="SettingsUsage" />
241
<SettingsRow icon="info.circle" label="About T3 Code" target="SettingsAbout" />
242
</SettingsSection>
243
</>
244
);
245
}
246
+
247
+function OverflowSection() {
248
+ const order = useNavigationTabOrder();
249
+ const hidden = useHiddenNavigationTabs();
250
+ const { layout } = useAdaptiveWorkspaceLayout();
251
+ const tabs =
252
+ Platform.OS === "android" && layout.usesSplitView ? [] : overflowNavigationTabs(order, hidden);
253
+ const selectTab = useSelectWorkspaceTab();
254
+ return tabs.length ? (
255
+ <SettingsSection>
256
+ {tabs.map((tab) => (
257
+ <SettingsRow
258
+ key={tab}
259
+ icon={NAVIGATION_TAB_ICONS[tab]}
260
+ label={WORKSPACE_TAB_LABELS[tab]}
261
+ onPress={() => selectTab(tab)}
262
+ />
263
+ ))}
264
+ </SettingsSection>
265
+ ) : null;
266
+}
apps/mobile/src/features/settings/components/SettingsEnvironmentFilterHeader.tsx
-19
@@ -1,4 +1,3 @@
1
-import { useNavigation } from "@react-navigation/native";
1
import type { NativeStackHeaderItem } from "@react-navigation/native-stack";
2
import { resolveEnvironmentMachineKind } from "@t3tools/contracts";
3
import { Platform, Pressable } from "react-native";
@@ -8,16 +7,11 @@ import { SymbolView } from "../../../components/ui/AppSymbol";
7
import { ENVIRONMENT_MACHINE_SYMBOLS } from "../../../components/EnvironmentMachineSymbol";
8
import { NativeStackScreenOptions } from "../../../native/StackHeader";
9
import { withNativeGlassHeaderItem } from "../../layout/native-glass-header-items";
11
-import { useAdaptiveWorkspaceLayout } from "../../layout/AdaptiveWorkspaceLayout";
10
import { useSettingsEnvironmentFilter } from "../settings-environment-filter";
11
12
export function SettingsEnvironmentFilterHeader(props: {
15
- readonly closeSettings?: boolean;
13
readonly trailingItems?: readonly NativeStackHeaderItem[];
14
}) {
18
- const navigation = useNavigation();
19
- const { layout } = useAdaptiveWorkspaceLayout();
20
- const closeSettings = props.closeSettings === true && !layout.usesSplitView;
15
const {
16
availableTargets,
17
selectedTargets,
@@ -35,7 +29,6 @@ export function SettingsEnvironmentFilterHeader(props: {
29
? "line.3.horizontal.decrease"
30
: "line.3.horizontal.decrease.circle.fill";
31
const filterVersion = JSON.stringify({
38
- closeSettings,
32
selection: selectedIds === null ? null : [...selectedIds].sort(),
33
targets: availableTargets.map((entry) => [
34
entry.environmentId,
@@ -117,18 +110,6 @@ export function SettingsEnvironmentFilterHeader(props: {
110
},
111
}),
112
...(props.trailingItems ?? []),
120
- ...(closeSettings
121
- ? [
122
- withNativeGlassHeaderItem({
123
- accessibilityLabel: "Close settings",
124
- icon: { name: "xmark", type: "sfSymbol" },
125
- identifier: "settings-close",
126
- label: "",
127
- onPress: () => navigation.goBack(),
128
- type: "button",
129
- }),
130
- ]
131
- : []),
113
],
114
}}
115
/>
apps/mobile/src/features/settings/components/SettingsScreen.tsx
+32
-7
@@ -6,6 +6,11 @@ import type { AppBarProps } from "../../../components/ui/AppBar.types";
6
import { AppBar } from "../../../components/ui/AppBar";
7
import { ScreenContent as SettingsScreenContent } from "../../../components/ui/ScreenContent";
8
import { useWorkspaceTabs } from "../../workspace/WorkspaceTabsContext";
9
+import { useWorkspaceSurface } from "../../workspace/useWorkspaceSurface";
10
+import { useDeviceType } from "../../../native/native-layout-metrics";
11
+import { NativeStackScreenOptions } from "../../../native/StackHeader";
12
+import { useCompactWorkspaceTabs } from "../../workspace/useSystemWorkspaceTabBar";
13
+import { ScreenScrollViewBottomInset } from "../../../components/ui/ScreenScrollView";
14
15
export { SettingsScreenContent };
16
@@ -13,18 +18,27 @@ export function SettingsScreen(
18
props: Pick<AppBarProps, "title" | "actions" | "trailing"> & {
19
readonly children: ReactNode;
20
readonly formSheet?: boolean;
21
+ readonly workspaceRoot?: boolean;
22
},
23
) {
24
const navigation = useNavigation();
25
const route = useRoute();
26
const index = useNavigationState((state) => state.index);
27
const workspace = useWorkspaceTabs();
28
+ const surface = useWorkspaceSurface();
29
+ const deviceType = useDeviceType();
30
+ const compactTabs = useCompactWorkspaceTabs();
31
+ const cover = deviceType === "duo-folded";
32
// Android opens Settings as a workspace tab; its root page has nothing to go back to.
33
const workspaceRoot =
24
- Platform.OS === "android" && workspace !== null && index === 0 && route.name === "Settings";
34
+ props.workspaceRoot ||
35
+ (Platform.OS === "android" && workspace !== null && index === 0 && route.name === "Settings");
36
37
return (
27
- <View collapsable={false} className="flex-1 bg-sheet">
38
+ <View
39
+ collapsable={false}
40
+ className={`flex-1 ${workspaceRoot || cover ? surface.className : "bg-sheet"}`}
41
+ >
42
<AppBar
43
title={props.title}
44
actions={props.actions}
@@ -33,11 +47,22 @@ export function SettingsScreen(
47
onBack={workspaceRoot ? undefined : () => navigation.goBack()}
48
hideBottomBorder={!props.formSheet}
49
/>
36
- {props.formSheet ? (
37
- props.children
38
- ) : (
39
- <SettingsScreenContent>{props.children}</SettingsScreenContent>
40
- )}
50
+ {Platform.OS === "ios" && (workspaceRoot || cover) ? (
51
+ <NativeStackScreenOptions
52
+ options={{
53
+ headerTransparent: false,
54
+ headerStyle: { backgroundColor: surface.backgroundColor },
55
+ contentStyle: { backgroundColor: surface.backgroundColor },
56
+ }}
57
+ />
58
+ ) : null}
59
+ <ScreenScrollViewBottomInset value={deviceType === "pad" || compactTabs ? 80 : 0}>
60
+ {props.formSheet ? (
61
+ props.children
62
+ ) : (
63
+ <SettingsScreenContent>{props.children}</SettingsScreenContent>
64
+ )}
65
+ </ScreenScrollViewBottomInset>
66
</View>
67
);
68
}
apps/mobile/src/features/settings/components/settings-sheet-targets.ts
+1
@@ -5,6 +5,7 @@ export type SettingsSheetTarget =
5
| "SettingsAbout"
6
| "SettingsArchive"
7
| "SettingsAppearance"
8
+ | "SettingsNavigation"
9
| "SettingsOrganization"
10
| "SettingsProjectOverview"
11
| "SettingsEnvironmentNewThreads"
apps/mobile/src/features/usage/UsageRouteScreen.tsx
+23
-16
@@ -3,7 +3,7 @@ import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
3
import { ChatGptUsageSummary } from "./ChatGptUsageSummary";
4
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
5
import { EnvironmentId, USAGE_CONTRACT_VERSION, type UsageProviderKind } from "@t3tools/contracts";
6
-import { type RouteProp, useIsFocused, useNavigation, useRoute } from "@react-navigation/native";
6
+import { type RouteProp, useIsFocused, useRoute } from "@react-navigation/native";
7
import { cursorKeychainAccessEnvironments } from "@t3tools/client-runtime/state/usage";
8
import {
9
updatingProvidersLabel,
@@ -55,6 +55,7 @@ import { useRefreshLimits } from "./UsageLimitsSection";
55
import { UsageLimitsSection } from "./UsageLimitsPooled";
56
import { Menu } from "../../components/ui/Menu";
57
import { SymbolView } from "../../components/ui/AppSymbol";
58
+import { NativeStackScreenOptions } from "../../native/StackHeader";
59
import type { UsageChartMetric } from "./usageChartData";
60
import { PROVIDER_LABEL, useProviderColors, useUsageMixColors } from "./usageProviders";
61
@@ -80,22 +81,28 @@ const CHART_HEIGHT = 180;
81
const providerLabel = (provider: UsageProviderKind) => PROVIDER_LABEL[provider];
82
const CURSOR_KEYCHAIN_COPY = "Requires access to your Cursor login in macOS Keychain.";
83
83
-export function UsageRouteScreen() {
84
+export function UsageRouteScreen(props: { readonly workspace?: boolean }) {
85
const route = useRoute<RouteProp<{ Usage: { tab?: string } | undefined }, "Usage">>();
85
- const navigation = useNavigation();
86
+ return <UsageScreen workspace={props.workspace} tabParam={route.params?.tab} />;
87
+}
88
+
89
+function UsageScreen(props: {
90
+ readonly workspace?: boolean;
91
+ readonly tabParam: string | undefined;
92
+}) {
93
const insets = useSafeAreaInsets();
94
const [selection, setSelection] = useState(() => ({
88
- params: route.params,
89
- tab: (route.params?.tab === "usage" ? "usage" : "limits") as UsageTab,
95
+ params: props.tabParam,
96
+ tab: (props.tabParam === "usage" ? "usage" : "limits") as UsageTab,
97
}));
91
- if (selection.params !== route.params) {
98
+ if (selection.params !== props.tabParam) {
99
setSelection({
93
- params: route.params,
94
- tab: route.params?.tab === "usage" ? "usage" : "limits",
100
+ params: props.tabParam,
101
+ tab: props.tabParam === "usage" ? "usage" : "limits",
102
});
103
}
104
const { tab } = selection;
98
- const setTab = (tab: UsageTab) => setSelection({ params: route.params, tab });
105
+ const setTab = (tab: UsageTab) => setSelection({ params: props.tabParam, tab });
106
const [windowSelection, setWindowSelection] = useState(() => ({
107
days: 30,
108
window: makeWindow(30),
@@ -234,14 +241,14 @@ export function UsageRouteScreen() {
241
</Menu>
242
) : null;
243
237
- useLayoutEffect(() => {
238
- if (Platform.OS === "ios") {
239
- navigation.setOptions({ headerRight: () => environmentFilter });
240
- }
241
- }, [navigation, environmentFilter]);
242
-
244
return (
244
- <SettingsScreen title="Usage" trailing={environmentFilter}>
245
+ <SettingsScreen title="Usage" trailing={environmentFilter} workspaceRoot={props.workspace}>
246
+ {Platform.OS === "ios" ? (
247
+ <NativeStackScreenOptions
248
+ optionsVersion={environmentFilter}
249
+ options={{ headerRight: () => environmentFilter }}
250
+ />
251
+ ) : null}
252
<ScrollView
253
contentInsetAdjustmentBehavior="automatic"
254
showsVerticalScrollIndicator={false}
apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.android.tsx
+20
-12
@@ -1,3 +1,4 @@
1
+import { selectedNavigationTab, visibleNavigationTabs } from "./navigation-tab-order";
2
import { requireNativeView } from "expo";
3
import { CommonActions, useNavigation } from "@react-navigation/native";
4
import {
@@ -20,6 +21,7 @@ import {
21
} from "./android-workspace-tabs";
22
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
23
import { useAndroidWorkspaceRoot } from "./AndroidWorkspaceTabsProvider";
24
+import { useNavigationTabOrder, useHiddenNavigationTabs } from "./navigation-tabs";
25
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
26
27
// Matches RAIL_WIDTH in the native rail.
@@ -27,6 +29,7 @@ export const ANDROID_WORKSPACE_RAIL_WIDTH = 72;
29
30
interface NativeNavigationProps extends ViewProps {
31
readonly rail: boolean;
32
+ readonly tabs: readonly string[];
33
readonly selectedTab: AndroidWorkspaceNavigationTab;
34
readonly dark: boolean;
35
readonly textScale: number;
@@ -62,6 +65,8 @@ export function AndroidWorkspaceNavigation(props: {
65
readonly onOverlayChange?: (overlay: boolean) => void;
66
}) {
67
const workspace = useWorkspaceTabs()!;
68
+ const order = useNavigationTabOrder();
69
+ const hidden = useHiddenNavigationTabs();
70
const root = useAndroidWorkspaceRoot();
71
const navigation = useNavigation();
72
const insets = useSafeAreaInsets();
@@ -73,9 +78,13 @@ export function AndroidWorkspaceNavigation(props: {
78
const rail = Boolean(props.rail);
79
const { containerColor, indicatorColor, selectedColor, unselectedColor } =
80
androidWorkspaceNavigationColors(colors, rail);
76
- const selectedTab: AndroidWorkspaceNavigationTab = root?.settingsOpen
77
- ? "settings"
78
- : workspace.state.selectedTab;
81
+ const selectedTab = selectedNavigationTab(
82
+ order,
83
+ workspace.state.selectedTab,
84
+ root?.settingsOpen ?? false,
85
+ hidden,
86
+ rail ? 5 : 4,
87
+ );
88
if (!rail && keyboardVisible) return null;
89
90
return (
@@ -88,6 +97,7 @@ export function AndroidWorkspaceNavigation(props: {
97
>
98
<NativeNavigation
99
rail={rail}
100
+ tabs={[...visibleNavigationTabs(order, hidden, rail ? 5 : 4), "settings"]}
101
selectedTab={selectedTab}
102
dark={themeAppearance === "dark"}
103
textScale={scale}
@@ -104,15 +114,13 @@ export function AndroidWorkspaceNavigation(props: {
114
onTabSelected={(event) => {
115
Keyboard.dismiss();
116
const tab = event.nativeEvent.tab;
107
- if (tab !== selectedTab) {
108
- if (tab !== "settings") workspace.dispatch({ type: "select", tab });
109
- // Reset the root stack even when a nested settings navigator has focus.
110
- if (root) {
111
- navigation.dispatch({
112
- ...CommonActions.reset(androidWorkspaceTabNavigationState(root.getState(), tab)),
113
- target: root.key,
114
- });
115
- }
117
+ if (tab !== "settings") workspace.dispatch({ type: "select", tab });
118
+ // Reset the root stack even when a nested settings navigator has focus.
119
+ if (root) {
120
+ navigation.dispatch({
121
+ ...CommonActions.reset(androidWorkspaceTabNavigationState(root.getState(), tab)),
122
+ target: root.key,
123
+ });
124
}
125
props.onSelect?.();
126
}}
apps/mobile/src/features/workspace/AndroidWorkspaceSidebar.android.tsx
+8
-1
@@ -1,3 +1,6 @@
1
+import { WorkspaceNoTabs } from "./WorkspaceNoTabs";
2
+import { useEnabledNavigationTabs } from "./navigation-tabs";
3
+import { NAVIGATION_TAB_ORDER } from "./navigation-tab-order";
4
import { useMemo, type ReactNode } from "react";
5
import { View } from "react-native";
6
import { ScreenContent } from "../../components/ui/ScreenContent";
@@ -13,14 +16,18 @@ export function AndroidWorkspaceSidebar(props: {
16
readonly selectedPullRequestKey: string | null;
17
}) {
18
const workspace = useWorkspaceTabs()!;
19
+ const enabled = useEnabledNavigationTabs();
20
const context = useMemo(() => ({ ...workspace, bottomClearance: 16 }), [workspace]);
21
+ if (enabled.length === 0) return <WorkspaceNoTabs />;
22
return (
23
<WorkspaceTabPanes
19
- tabs={["threads", "pullRequests"]}
24
+ tabs={NAVIGATION_TAB_ORDER}
25
selected={workspace.state.selectedTab}
26
renderTab={(tab) =>
27
tab === "threads" ? (
28
props.children
29
+ ) : tab !== "pullRequests" ? (
30
+ <View className="flex-1 bg-screen" />
31
) : (
32
<WorkspaceTabsContext value={context}>
33
<PullRequestFilterMenuProvider>
apps/mobile/src/features/workspace/WorkspaceExtraTab.tsx
new
+16
@@ -0,0 +1,16 @@
1
+import { type NavigationTab } from "./navigation-tab-order";
2
+import { NativeStackScreenOptions } from "../../native/StackHeader";
3
+import { UsageRouteScreen } from "../usage/UsageRouteScreen";
4
+
5
+export function WorkspaceExtraTab(_props: {
6
+ tab: Exclude<NavigationTab, "threads" | "pullRequests">;
7
+}) {
8
+ return (
9
+ <>
10
+ <NativeStackScreenOptions
11
+ options={{ headerSearchBarOptions: undefined, unstable_headerRightItems: undefined }}
12
+ />
13
+ <UsageRouteScreen workspace />
14
+ </>
15
+ );
16
+}
apps/mobile/src/features/workspace/WorkspaceNativeTabs.ios.tsx
+115
-59
@@ -1,6 +1,11 @@
1
-import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
1
+import { useNavigation } from "@react-navigation/native";
2
+import {
3
+ WORKSPACE_TAB_LABELS,
4
+ NAVIGATION_TAB_ICONS,
5
+ useEnabledNavigationTabs,
6
+} from "./navigation-tabs";
7
import { useCallback, useMemo, useState, type ReactNode } from "react";
3
-import { Keyboard, Platform, View, type NativeSyntheticEvent } from "react-native";
8
+import { Keyboard, View, useWindowDimensions, type NativeSyntheticEvent } from "react-native";
9
import {
10
Tabs,
11
type TabSelectedEvent,
@@ -9,12 +14,19 @@ import {
14
} from "react-native-screens";
15
16
import { WorkspaceTabsContext, useWorkspaceTabs } from "./WorkspaceTabsContext";
12
-import type { WorkspaceTab } from "./workspace-tabs-state";
17
+import {
18
+ NATIVE_WORKSPACE_TAB_SLOTS,
19
+ workspaceTabForNativeSlot,
20
+ type WorkspaceTab,
21
+} from "./workspace-tabs-state";
22
import { NativeWorkspaceTabActivityContext } from "../../native/v5-workspace-context";
14
-import { useSystemWorkspaceTabBar } from "./useSystemWorkspaceTabBar";
23
+import { useCompactWorkspaceTabs, useSystemWorkspaceTabBar } from "./useSystemWorkspaceTabBar";
24
+import { useControlTheme } from "../../components/ui/useControlTheme";
25
+import { useDeviceType } from "../../native/native-layout-metrics";
26
+import { WorkspaceSidebarTabs } from "./WorkspaceSidebarTabs";
27
+import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
28
29
const PULL_REQUEST_ICON = require("../../../assets/icons/pull-request.png");
17
-const COMPOSE_TAB = "compose";
30
31
/** Retain each native controller tree; removing its root can leave RNS's stack empty. */
32
function RetainedWorkspaceTab(props: {
@@ -48,86 +60,130 @@ export function WorkspaceNativeTabs(props: {
60
readonly children: ReactNode;
61
readonly hidden: boolean;
62
readonly onSelect: () => void;
51
- readonly onNewTask: () => void;
63
}) {
64
const workspace = useWorkspaceTabs()!;
54
- const metrics = useNativeLayoutMetrics();
55
- const deviceType = useDeviceType();
56
- const phoneBar =
57
- Platform.OS === "ios" &&
58
- deviceType !== "pad" &&
59
- (metrics?.verticalBarEdge ?? "none") === "none";
65
+ const order = useEnabledNavigationTabs();
66
+ const primaryTabs = order.slice(0, 4);
67
+ const overflow = order[4];
68
+ const navigation = useNavigation();
69
const [provenance, setProvenance] = useState(0);
70
const systemTabBar = useSystemWorkspaceTabBar();
71
+ const deviceType = useDeviceType();
72
+ const compactTabs = useCompactWorkspaceTabs();
73
+ const { layout, startNewTask } = useAdaptiveWorkspaceLayout();
74
+ const compactSidebarTabs = deviceType === "phone" || !layout.usesSplitView;
75
+ const { width } = useWindowDimensions();
76
+ const { colors } = useControlTheme();
77
const selectedTab = workspace.state.selectedTab;
78
+ const selectedSlot = workspace.settingsOpen ? -1 : primaryTabs.indexOf(selectedTab);
79
const request = useMemo(
64
- () => ({ selectedScreenKey: selectedTab, baseProvenance: provenance }),
65
- [selectedTab, provenance],
80
+ () => ({
81
+ selectedScreenKey:
82
+ selectedSlot === -1 ? "settings" : NATIVE_WORKSPACE_TAB_SLOTS[selectedSlot]!,
83
+ baseProvenance: provenance,
84
+ }),
85
+ [selectedSlot, provenance],
86
);
87
return (
88
<View style={{ flex: 1 }}>
89
<Tabs.Host
90
navStateRequest={request}
91
tabBarHidden={props.hidden || !systemTabBar}
72
- ios={{ tabBarControllerMode: "tabBar", tabBarMinimizeBehavior: "never" }}
92
+ ios={{
93
+ tabBarControllerMode: "tabBar",
94
+ tabBarMinimizeBehavior: "never",
95
+ tabBarTintColor: colors["--color-primary"],
96
+ }}
97
onTabSelectionPrevented={({
98
nativeEvent,
99
}: NativeSyntheticEvent<TabSelectionPreventedEvent>) => {
76
- if (nativeEvent.preventedScreenKey === COMPOSE_TAB) props.onNewTask();
100
+ if (nativeEvent.preventedScreenKey === "settings") {
101
+ navigation.navigate("SettingsSheet", {
102
+ screen: "SettingsContent",
103
+ params: { screen: "Settings" },
104
+ });
105
+ }
106
}}
107
onTabSelectionRejected={({
108
nativeEvent,
80
- }: NativeSyntheticEvent<TabSelectionRejectedEvent>) => {
81
- setProvenance(nativeEvent.provenance);
82
- }}
109
+ }: NativeSyntheticEvent<TabSelectionRejectedEvent>) =>
110
+ setProvenance(nativeEvent.provenance)
111
+ }
112
onTabSelected={({ nativeEvent }: NativeSyntheticEvent<TabSelectedEvent>) => {
84
- const tab = nativeEvent.selectedScreenKey;
85
- if (tab !== "threads" && tab !== "pullRequests") return;
113
setProvenance(nativeEvent.provenance);
87
- if (nativeEvent.actionOrigin === "programmatic-js" || tab === selectedTab) return;
114
+ if (nativeEvent.actionOrigin === "programmatic-js") return;
115
+ const tab = workspaceTabForNativeSlot(primaryTabs, nativeEvent.selectedScreenKey);
116
+ // UIKit sends reselects here even when preventNativeSelection is enabled.
117
+ if (tab === "settings") {
118
+ navigation.navigate("SettingsSheet", {
119
+ screen: "SettingsContent",
120
+ params: { screen: "Settings" },
121
+ });
122
+ return;
123
+ }
124
+ if (!tab) return;
125
Keyboard.dismiss();
126
props.onSelect();
127
workspace.dispatch({ type: "select", tab });
128
}}
129
>
93
- {(["threads", "pullRequests"] as const).map((tab: WorkspaceTab) => (
94
- <Tabs.Screen
95
- key={tab}
96
- screenKey={tab}
97
- title={tab === "threads" ? "Threads" : "Pulls"}
98
- tabBarItemAccessibilityLabel={tab === "threads" ? "Threads" : "Pull requests"}
99
- ios={{
100
- icon:
101
- tab === "threads"
102
- ? { type: "sfSymbol", name: "text.bubble" }
103
- : { type: "templateSource", templateSource: PULL_REQUEST_ICON },
104
- selectedIcon:
105
- tab === "threads" ? { type: "sfSymbol", name: "text.bubble.fill" } : undefined,
106
- overrideScrollViewContentInsetAdjustmentBehavior: false,
107
- }}
108
- >
109
- <RetainedWorkspaceTab tab={tab} active={selectedTab === tab}>
110
- {props.children}
111
- </RetainedWorkspaceTab>
112
- </Tabs.Screen>
113
- ))}
114
- {phoneBar ? (
115
- <Tabs.Screen
116
- key={COMPOSE_TAB}
117
- screenKey={COMPOSE_TAB}
118
- title="New chat"
119
- preventNativeSelection
120
- ios={{
121
- role: "search",
122
- // iOS 27 detaches a search tab only while it may activate search.
123
- automaticallyActivatesSearch: true,
124
- icon: { type: "sfSymbol", name: "square.and.pencil" },
125
- }}
126
- >
127
- <View />
128
- </Tabs.Screen>
129
- ) : null}
130
+ {NATIVE_WORKSPACE_TAB_SLOTS.map((slot, index) => {
131
+ const settings = slot === "settings";
132
+ const tab = settings ? (overflow ?? selectedTab) : primaryTabs[index];
133
+ if (!tab) return null;
134
+ return (
135
+ <Tabs.Screen
136
+ // Stable slot controllers keep UIKit's stacks attached when a section moves into Settings.
137
+ key={slot}
138
+ screenKey={slot}
139
+ title=""
140
+ tabBarItemAccessibilityLabel={settings ? "Settings" : WORKSPACE_TAB_LABELS[tab]}
141
+ preventNativeSelection={settings}
142
+ ios={{
143
+ icon: settings
144
+ ? { type: "sfSymbol", name: "gearshape" }
145
+ : tab === "pullRequests"
146
+ ? { type: "templateSource", templateSource: PULL_REQUEST_ICON }
147
+ : { type: "sfSymbol", name: NAVIGATION_TAB_ICONS[tab] },
148
+ selectedIcon:
149
+ !settings && tab === "threads"
150
+ ? { type: "sfSymbol", name: "text.bubble.fill" }
151
+ : undefined,
152
+ overrideScrollViewContentInsetAdjustmentBehavior: false,
153
+ }}
154
+ >
155
+ <RetainedWorkspaceTab
156
+ tab={tab}
157
+ active={settings ? selectedSlot === -1 : selectedSlot === index}
158
+ >
159
+ {props.children}
160
+ </RetainedWorkspaceTab>
161
+ </Tabs.Screen>
162
+ );
163
+ })}
164
</Tabs.Host>
165
+ {(deviceType === "pad" || compactTabs) && !props.hidden ? (
166
+ <View
167
+ pointerEvents="box-none"
168
+ style={{
169
+ position: "absolute",
170
+ left: 0,
171
+ bottom: 0,
172
+ width: layout.listPaneWidth ?? width,
173
+ height: 128,
174
+ }}
175
+ >
176
+ <WorkspaceSidebarTabs
177
+ compact={compactSidebarTabs}
178
+ reserveComposeSpace={compactSidebarTabs}
179
+ onNewTask={
180
+ compactSidebarTabs && !workspace.settingsOpen && selectedTab === "threads"
181
+ ? startNewTask
182
+ : undefined
183
+ }
184
+ />
185
+ </View>
186
+ ) : null}
187
</View>
188
);
189
}
apps/mobile/src/features/workspace/WorkspaceNoTabs.tsx
new
+23
@@ -0,0 +1,23 @@
1
+import { useNavigation } from "@react-navigation/native";
2
+import { View } from "react-native";
3
+import { EmptyState } from "../../components/ui/EmptyState";
4
+
5
+export function WorkspaceNoTabs() {
6
+ const navigation = useNavigation();
7
+ return (
8
+ <View className="flex-1 items-center justify-center bg-screen">
9
+ <EmptyState
10
+ title="All sections are hidden"
11
+ detail="Show a section to add it back to navigation."
12
+ actionLabel="Edit navigation tabs"
13
+ variant="plain"
14
+ onAction={() =>
15
+ navigation.navigate("SettingsSheet", {
16
+ screen: "SettingsContent",
17
+ params: { screen: "SettingsNavigation", initial: false },
18
+ })
19
+ }
20
+ />
21
+ </View>
22
+ );
23
+}
apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx
+31
-17
@@ -1,3 +1,7 @@
1
+import { WorkspaceNoTabs } from "./WorkspaceNoTabs";
2
+import { useEnabledNavigationTabs } from "./navigation-tabs";
3
+import { NAVIGATION_TAB_ORDER } from "./navigation-tab-order";
4
+import { WorkspaceExtraTab } from "./WorkspaceExtraTab";
5
import { useMemo } from "react";
6
import { View } from "react-native";
7
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
@@ -16,11 +20,12 @@ import { WorkspaceTabsContext, useWorkspaceTabs } from "./WorkspaceTabsContext";
20
import { WorkspaceTabPanes } from "./WorkspaceTabPanes";
21
import type { WorkspaceTab } from "./workspace-tabs-state";
22
19
-const TABS: readonly WorkspaceTab[] = ["threads", "pullRequests"];
23
+const TABS: readonly WorkspaceTab[] = NAVIGATION_TAB_ORDER;
24
25
export function WorkspaceRootScreen() {
26
const { layout, startNewTask } = useAdaptiveWorkspaceLayout();
27
const workspace = useWorkspaceTabs()!;
28
+ const enabled = useEnabledNavigationTabs();
29
const insets = useSafeAreaInsets();
30
const { fabClearance } = useAndroidControlSizing();
31
const context = useMemo(
@@ -33,6 +38,7 @@ export function WorkspaceRootScreen() {
38
const tab = workspace.state.selectedTab;
39
40
if (layout.usesSplitView) {
41
+ if (enabled.length === 0) return <View className="flex-1 bg-screen" />;
42
return (
43
<WorkspaceTabPanes
44
tabs={TABS}
@@ -40,6 +46,8 @@ export function WorkspaceRootScreen() {
46
renderTab={(tab) =>
47
tab === "threads" ? (
48
<HomeRouteScreen />
49
+ ) : tab !== "pullRequests" ? (
50
+ <WorkspaceExtraTab tab={tab} />
51
) : (
52
<>
53
<NativeStackScreenOptions options={{ headerShown: false }} />
@@ -63,22 +71,28 @@ export function WorkspaceRootScreen() {
71
<View className="flex-1 bg-header">
72
<NativeStackScreenOptions options={{ headerShown: false }} />
73
<SafeAreaInsetsContext value={{ ...insets, bottom: 0 }}>
66
- <WorkspaceTabPanes
67
- tabs={TABS}
68
- selected={tab}
69
- renderTab={(tab) =>
70
- tab === "threads" ? (
71
- <HomeRouteScreen />
72
- ) : (
73
- <PullRequestFilterMenuProvider>
74
- <PullRequestToolbar />
75
- <ScreenContent>
76
- <PullRequestsScreen />
77
- </ScreenContent>
78
- </PullRequestFilterMenuProvider>
79
- )
80
- }
81
- />
74
+ {enabled.length === 0 ? (
75
+ <WorkspaceNoTabs />
76
+ ) : (
77
+ <WorkspaceTabPanes
78
+ tabs={TABS}
79
+ selected={tab}
80
+ renderTab={(tab) =>
81
+ tab === "threads" ? (
82
+ <HomeRouteScreen />
83
+ ) : tab !== "pullRequests" ? (
84
+ <WorkspaceExtraTab tab={tab} />
85
+ ) : (
86
+ <PullRequestFilterMenuProvider>
87
+ <PullRequestToolbar />
88
+ <ScreenContent>
89
+ <PullRequestsScreen />
90
+ </ScreenContent>
91
+ </PullRequestFilterMenuProvider>
92
+ )
93
+ }
94
+ />
95
+ )}
96
</SafeAreaInsetsContext>
97
<AndroidWorkspaceNavigation onNewThread={startNewTask} />
98
</View>
apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
+106
-38
@@ -1,3 +1,7 @@
1
+import { WorkspaceNoTabs } from "./WorkspaceNoTabs";
2
+import { WORKSPACE_TAB_LABELS, useEnabledNavigationTabs } from "./navigation-tabs";
3
+import { WorkspaceExtraTab } from "./WorkspaceExtraTab";
4
+import { WorkspaceSectionToolbar } from "./WorkspaceSectionToolbar";
5
import { useNavigation } from "@react-navigation/native";
6
import { use, useCallback, useMemo } from "react";
7
import { Platform, View, useWindowDimensions } from "react-native";
@@ -5,10 +9,12 @@ import { useKeyboardState } from "react-native-keyboard-controller";
9
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
10
11
import { CompactBrandTitle } from "../../components/CompactBrandTitle";
8
-import { isDuoDevice } from "../../lib/device-type";
12
import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
13
import { NativeStackScreenOptions } from "../../native/StackHeader";
14
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
15
+import { isDuoDevice } from "../../lib/device-type";
16
+import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
17
+import { useWorkspaceSurface } from "./useWorkspaceSurface";
18
import {
19
useDeviceType,
20
useDuoBottomBarInset,
@@ -26,25 +32,34 @@ import {
32
useWorkspaceTabs,
33
} from "./WorkspaceTabsContext";
34
import { WorkspaceToolbar } from "./WorkspaceToolbar";
29
-import { WORKSPACE_DOCK, WORKSPACE_TOOLBAR, workspaceToolbarHeight } from "./workspace-tabs-state";
35
+import {
36
+ WORKSPACE_DOCK,
37
+ workspaceSearchBottomClearance,
38
+ workspaceDockBottomClearance,
39
+ workspaceToolbarHeight,
40
+} from "./workspace-tabs-state";
41
import { WorkspaceSidebarTabs } from "./WorkspaceSidebarTabs";
31
-import { useSidebarWorkspaceTabs, useSystemWorkspaceTabBar } from "./useSystemWorkspaceTabBar";
42
+import {
43
+ useCompactWorkspaceTabs,
44
+ useSidebarWorkspaceTabs,
45
+ useSystemWorkspaceTabBar,
46
+} from "./useSystemWorkspaceTabBar";
47
33
-const TAB_TITLES = {
34
- threads: "Threads",
35
- pullRequests: "Pull requests",
36
-};
48
+const TAB_TITLES = WORKSPACE_TAB_LABELS;
49
50
function WorkspaceRootTitle(props: {
51
readonly maxWidth: number;
52
readonly onOpenEnvironments: () => void;
53
}) {
54
const { state } = useWorkspaceTabs()!;
55
+ const enabled = useEnabledNavigationTabs();
56
return (
57
<View style={{ width: props.maxWidth, minHeight: 32, justifyContent: "center" }}>
58
<WorkspaceConnectionTitle
59
brand={
47
- <CompactBrandTitle accessibilityLabel={`T3 Code, ${TAB_TITLES[state.selectedTab]}`} />
60
+ <CompactBrandTitle
61
+ accessibilityLabel={`T3 Code, ${enabled.length ? TAB_TITLES[state.selectedTab] : "Navigation"}`}
62
+ />
63
}
64
maxWidth={props.maxWidth}
65
onPress={props.onOpenEnvironments}
@@ -61,9 +76,12 @@ function WorkspaceRootContent() {
76
const columnMetrics = useNativeColumnLayoutMetrics();
77
const nativeMetrics = useNativeLayoutMetrics();
78
const deviceType = useDeviceType();
79
+ const surface = useWorkspaceSurface();
80
const systemTabBar = useSystemWorkspaceTabBar();
81
+ const compactTabs = useCompactWorkspaceTabs();
82
+ const enabled = useEnabledNavigationTabs();
83
const sidebarTabs = useSidebarWorkspaceTabs();
66
- const sidebarPicker = sidebarTabs === "picker";
84
+ const sidebarPicker = sidebarTabs === "picker" || (deviceType === "pad" && layout.usesSplitView);
85
const sidebarNavigation =
86
primaryColumn !== null &&
87
(layout.usesSplitView ||
@@ -75,6 +93,7 @@ function WorkspaceRootContent() {
93
const keyboardHeight = useKeyboardState((keyboard) => keyboard.height);
94
const workspace = useWorkspaceTabs()!;
95
const { state } = workspace;
96
+ const solidHeader = deviceType === "duo-folded" || state.selectedTab === "usage";
97
const renderHeaderTitle = useCallback(
98
() => (
99
<WorkspaceRootTitle
@@ -92,35 +111,58 @@ function WorkspaceRootContent() {
111
const tab = state.tabs[state.selectedTab];
112
const bottomClearance =
113
Platform.OS === "ios" && isDuoDevice(deviceType)
95
- ? Math.max(bottomBarInset ?? Math.max(insets.bottom, 12), keyboardHeight + 8) +
96
- WORKSPACE_TOOLBAR.height +
97
- 16
98
- : Platform.OS === "ios"
99
- ? Math.max(insets.bottom, keyboardHeight) +
100
- (systemTabBar || sidebarTabs || tab.searchMode !== "resting"
101
- ? sidebarPicker
102
- ? 80
103
- : 16
104
- : WORKSPACE_DOCK.height + WORKSPACE_DOCK.bottomGap + 16)
105
- : keyboardHeight > 0 && tab.searchMode !== "resting"
106
- ? keyboardHeight + 64
107
- : Math.max(insets.bottom, 12) + workspaceToolbarHeight(tab.searchMode) + 16;
114
+ ? workspaceSearchBottomClearance({
115
+ bottomInset: insets.bottom,
116
+ bottomBarInset,
117
+ keyboardHeight,
118
+ })
119
+ : compactTabs || deviceType === "pad"
120
+ ? workspaceDockBottomClearance({ bottomInset: insets.bottom, keyboardHeight })
121
+ : Platform.OS === "ios"
122
+ ? Math.max(insets.bottom, keyboardHeight) +
123
+ (systemTabBar || sidebarTabs || tab.searchMode !== "resting"
124
+ ? sidebarPicker
125
+ ? 80
126
+ : 16
127
+ : WORKSPACE_DOCK.height + WORKSPACE_DOCK.bottomGap + 16)
128
+ : keyboardHeight > 0 && tab.searchMode !== "resting"
129
+ ? keyboardHeight + 64
130
+ : Math.max(insets.bottom, 12) + workspaceToolbarHeight(tab.searchMode) + 16;
131
const context = useMemo(() => ({ ...workspace, bottomClearance }), [workspace, bottomClearance]);
132
133
return (
134
<WorkspaceTabsContext value={context}>
135
<View
113
- className={sidebarPicker ? "flex-1 bg-drawer" : "flex-1 bg-screen"}
136
+ className={`flex-1 ${sidebarPicker ? "bg-drawer" : surface.className}`}
137
style={sidebarPicker ? { paddingTop: insets.top } : undefined}
138
>
139
{Platform.OS === "ios" ? (
140
<NativeStackScreenOptions
118
- optionsVersion={[state.selectedTab, state.selectionRevision, width, sidebarNavigation]}
141
+ optionsVersion={[
142
+ state.selectedTab,
143
+ state.selectionRevision,
144
+ width,
145
+ sidebarNavigation,
146
+ enabled.length,
147
+ ]}
148
options={{
120
- title: TAB_TITLES[state.selectedTab],
149
+ title: enabled.length ? TAB_TITLES[state.selectedTab] : "Navigation",
150
headerShown: true,
151
+ headerTransparent: solidHeader ? false : NATIVE_LIQUID_GLASS_SUPPORTED,
152
+ headerStyle: solidHeader
153
+ ? { backgroundColor: surface.backgroundColor }
154
+ : NATIVE_LIQUID_GLASS_SUPPORTED
155
+ ? { backgroundColor: "transparent" }
156
+ : undefined,
157
+ contentStyle: solidHeader ? { backgroundColor: surface.backgroundColor } : undefined,
158
+ ...(state.selectedTab !== "usage" || enabled.length === 0
159
+ ? { headerRight: undefined }
160
+ : {}),
161
+ ...(enabled.length === 0
162
+ ? { headerSearchBarOptions: undefined, unstable_headerRightItems: () => [] }
163
+ : {}),
164
unstable_headerLeftItems: () => [],
123
- headerTitle: renderHeaderTitle,
165
+ headerTitle: state.selectedTab === "usage" ? undefined : renderHeaderTitle,
166
}}
167
/>
168
) : (
@@ -128,14 +170,18 @@ function WorkspaceRootContent() {
170
title="T3 Code"
171
titleContent={renderHeaderTitle()}
172
actions={[
131
- {
132
- accessibilityLabel:
133
- state.selectedTab === "threads" ? "Search threads" : "Search pull requests",
134
- icon: "magnifyingglass",
135
- onPress: () => {
136
- dispatchHardwareKeyboardCommand("focusSearch");
137
- },
138
- },
173
+ ...(state.selectedTab === "threads" || state.selectedTab === "pullRequests"
174
+ ? [
175
+ {
176
+ accessibilityLabel:
177
+ state.selectedTab === "threads" ? "Search threads" : "Search pull requests",
178
+ icon: "magnifyingglass" as const,
179
+ onPress: () => {
180
+ dispatchHardwareKeyboardCommand("focusSearch");
181
+ },
182
+ },
183
+ ]
184
+ : []),
185
{
186
accessibilityLabel: "Settings",
187
icon: "gearshape",
@@ -148,11 +194,33 @@ function WorkspaceRootContent() {
194
]}
195
/>
196
)}
151
- <SafeAreaInsetsContext value={sidebarPicker ? { ...insets, top: 0 } : insets}>
152
- {state.selectedTab === "threads" ? <HomeRouteScreen /> : <PullRequestsScreen />}
197
+ <SafeAreaInsetsContext
198
+ value={
199
+ sidebarPicker ? { ...insets, top: 0 } : compactTabs ? { ...insets, bottom: 0 } : insets
200
+ }
201
+ >
202
+ {enabled.length === 0 ? (
203
+ <WorkspaceNoTabs />
204
+ ) : state.selectedTab === "threads" ? (
205
+ <HomeRouteScreen />
206
+ ) : state.selectedTab === "pullRequests" ? (
207
+ <PullRequestsScreen />
208
+ ) : (
209
+ <WorkspaceExtraTab tab={state.selectedTab} />
210
+ )}
211
</SafeAreaInsetsContext>
154
- {sidebarPicker ? <WorkspaceSidebarTabs /> : null}
155
- <WorkspaceToolbar sidebar={sidebarNavigation} onNewTask={startNewTask} />
212
+ {deviceType !== "pad" && deviceType !== "phone" && sidebarPicker ? (
213
+ <WorkspaceSidebarTabs />
214
+ ) : null}
215
+ {enabled.length === 0 ? null : state.selectedTab === "threads" ||
216
+ state.selectedTab === "pullRequests" ? (
217
+ <WorkspaceToolbar sidebar={sidebarNavigation} onNewTask={startNewTask} />
218
+ ) : (
219
+ <WorkspaceSectionToolbar
220
+ onNewTask={startNewTask}
221
+ showCompose={state.selectedTab !== "usage"}
222
+ />
223
+ )}
224
</View>
225
</WorkspaceTabsContext>
226
);
apps/mobile/src/features/workspace/WorkspaceSectionToolbar.tsx
new
+91
@@ -0,0 +1,91 @@
1
+import { useNavigation } from "@react-navigation/native";
2
+import { selectedNavigationTab, visibleNavigationTabs } from "./navigation-tab-order";
3
+import { Toolbar } from "../../components/ui/Toolbar";
4
+import { useControlTheme } from "../../components/ui/useControlTheme";
5
+import { useDeviceType } from "../../native/native-layout-metrics";
6
+import {
7
+ NAVIGATION_TAB_ICONS,
8
+ WORKSPACE_TAB_LABELS,
9
+ useNavigationTabOrder,
10
+ useHiddenNavigationTabs,
11
+} from "./navigation-tabs";
12
+import { useWorkspaceTabs } from "./WorkspaceTabsContext";
13
+import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
14
+import { useCompactWorkspaceTabs, useSidebarWorkspaceTabs } from "./useSystemWorkspaceTabBar";
15
+
16
+const PULL_REQUEST_ICON = require("../../../assets/icons/pull-request.png");
17
+
18
+export function WorkspaceTabToolbarButtons() {
19
+ const order = useNavigationTabOrder();
20
+ const hidden = useHiddenNavigationTabs();
21
+ const workspace = useWorkspaceTabs()!;
22
+ const selectTab = useSelectWorkspaceTab();
23
+ const navigation = useNavigation();
24
+ const selected = selectedNavigationTab(
25
+ order,
26
+ workspace.state.selectedTab,
27
+ workspace.settingsOpen,
28
+ hidden,
29
+ );
30
+ const selectedTint = useControlTheme().colors["--color-primary"];
31
+ return (
32
+ <>
33
+ {visibleNavigationTabs(order, hidden).map((tab) => (
34
+ <Toolbar.Button
35
+ key={tab}
36
+ identifier={`workspace-tab-${tab}`}
37
+ accessibilityLabel={WORKSPACE_TAB_LABELS[tab]}
38
+ icon={
39
+ tab === "pullRequests"
40
+ ? { type: "image", source: PULL_REQUEST_ICON, tinted: true }
41
+ : NAVIGATION_TAB_ICONS[tab]
42
+ }
43
+ tintColor={selected === tab ? selectedTint : undefined}
44
+ onPress={() => selectTab(tab)}
45
+ />
46
+ ))}
47
+ <Toolbar.Button
48
+ identifier="workspace-tab-settings"
49
+ accessibilityLabel="Settings"
50
+ icon="gearshape"
51
+ tintColor={selected === "settings" ? selectedTint : undefined}
52
+ onPress={() =>
53
+ navigation.navigate("SettingsSheet", {
54
+ screen: "SettingsContent",
55
+ params: { screen: "Settings" },
56
+ })
57
+ }
58
+ />
59
+ </>
60
+ );
61
+}
62
+
63
+export function WorkspaceSectionToolbar({
64
+ onNewTask,
65
+ showCompose = true,
66
+}: {
67
+ readonly onNewTask: () => void;
68
+ readonly showCompose?: boolean;
69
+}) {
70
+ const sidebarTabs = useSidebarWorkspaceTabs();
71
+ const compactTabs = useCompactWorkspaceTabs();
72
+ const deviceType = useDeviceType();
73
+ return (
74
+ <>
75
+ {showCompose && sidebarTabs !== "picker" && deviceType !== "duo-unfolded" && !compactTabs ? (
76
+ <Toolbar placement="right">
77
+ <Toolbar.Button
78
+ accessibilityLabel="New chat"
79
+ icon="square.and.pencil"
80
+ onPress={onNewTask}
81
+ />
82
+ </Toolbar>
83
+ ) : null}
84
+ {sidebarTabs === "toolbar" ? (
85
+ <Toolbar placement="bottom">
86
+ <WorkspaceTabToolbarButtons />
87
+ </Toolbar>
88
+ ) : null}
89
+ </>
90
+ );
91
+}
apps/mobile/src/features/workspace/WorkspaceSidebarTabs.ios.tsx
+55
-10
@@ -1,33 +1,78 @@
1
+import { useNavigation } from "@react-navigation/native";
2
+import { selectedNavigationTab, visibleNavigationTabs } from "./navigation-tab-order";
3
import { requireNativeView } from "expo";
4
import type { NativeSyntheticEvent, ViewProps } from "react-native";
3
-import { useSafeAreaInsets } from "react-native-safe-area-context";
5
import { useControlTheme } from "../../components/ui/useControlTheme";
6
+import { useNavigationTabOrder, useHiddenNavigationTabs } from "./navigation-tabs";
7
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
8
import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
9
10
const NativeSidebarTabBar = requireNativeView<
11
ViewProps & {
10
- selectedIndex: number;
12
+ tabs: readonly string[];
13
+ selectedTab: string;
14
selectedColor: string;
15
appearance: string;
13
- onSelectionChange: (event: NativeSyntheticEvent<{ index: number }>) => void;
16
+ showsCompose: boolean;
17
+ compact?: boolean;
18
+ onSelectionChange: (event: NativeSyntheticEvent<{ tab: string }>) => void;
19
+ onCompose: () => void;
20
}
21
>("T3NativeControls", "SidebarTabBar");
22
17
-export function WorkspaceSidebarTabs() {
23
+export function WorkspaceSidebarTabs(props: {
24
+ readonly onNewTask?: () => void;
25
+ readonly compact?: boolean;
26
+ readonly reserveComposeSpace?: boolean;
27
+}) {
28
const workspace = useWorkspaceTabs()!;
29
+ const order = useNavigationTabOrder();
30
+ const hidden = useHiddenNavigationTabs();
31
+ const tabs = [...visibleNavigationTabs(order, hidden), "settings" as const];
32
+ const navigation = useNavigation();
33
const selectTab = useSelectWorkspaceTab();
20
- const insets = useSafeAreaInsets();
34
const { colors, colorScheme } = useControlTheme();
35
+ // UIKit loses accessible names when updating nil-titled items in place.
36
+ const tabBarKey = tabs.join(":");
37
return (
38
<NativeSidebarTabBar
24
- selectedIndex={workspace.state.selectedTab === "threads" ? 0 : 1}
39
+ key={tabBarKey}
40
+ tabs={tabs}
41
+ selectedTab={selectedNavigationTab(
42
+ order,
43
+ workspace.state.selectedTab,
44
+ workspace.settingsOpen,
45
+ hidden,
46
+ )}
47
selectedColor={colors["--color-primary"]}
48
appearance={colorScheme}
27
- onSelectionChange={({ nativeEvent }) =>
28
- selectTab(nativeEvent.index === 0 ? "threads" : "pullRequests")
29
- }
30
- style={{ position: "absolute", bottom: 0, left: 0, right: 0, height: 64 + insets.bottom }}
49
+ showsCompose={Boolean(props.onNewTask)}
50
+ compact={props.compact}
51
+ onCompose={() => props.onNewTask?.()}
52
+ onSelectionChange={({ nativeEvent }) => {
53
+ const tab = tabs.find((candidate) => candidate === nativeEvent.tab);
54
+ if (tab === "settings")
55
+ navigation.navigate("SettingsSheet", {
56
+ screen: "SettingsContent",
57
+ params: { screen: "Settings" },
58
+ });
59
+ else if (tab) selectTab(tab);
60
+ }}
61
+ // Keep the host stable while UIKit updates the bars' intrinsic size and safe area together.
62
+ style={{
63
+ position: "absolute",
64
+ bottom: 0,
65
+ left: props.compact ? 8 : 0,
66
+ // Keep the tab icons in place when Compose disappears on other destinations.
67
+ right:
68
+ (props.compact ? 12 : 0) +
69
+ ((props.reserveComposeSpace ?? props.compact) && !props.onNewTask
70
+ ? props.compact
71
+ ? 64
72
+ : 76
73
+ : 0),
74
+ height: 128,
75
+ }}
76
/>
77
);
78
}
apps/mobile/src/features/workspace/WorkspaceSidebarTabs.tsx
+5
-1
@@ -1,3 +1,7 @@
1
-export function WorkspaceSidebarTabs() {
1
+export function WorkspaceSidebarTabs(_props: {
2
+ readonly onNewTask?: () => void;
3
+ readonly compact?: boolean;
4
+ readonly reserveComposeSpace?: boolean;
5
+}) {
6
return null;
7
}
apps/mobile/src/features/workspace/WorkspaceTabsContext.tsx
+14
-3
@@ -1,3 +1,5 @@
1
+import { resolveSelectedNavigationTab } from "./navigation-tab-order";
2
+import { useNavigationTabOrder, useHiddenNavigationTabs } from "./navigation-tabs";
3
import {
4
createContext,
5
use,
@@ -22,6 +24,7 @@ export const WorkspaceTabsContext = createContext<{
24
readonly dispatch: Dispatch<WorkspaceTabsAction>;
25
readonly isTabActive: (tab: WorkspaceTab) => boolean;
26
readonly bottomClearance: number;
27
+ readonly settingsOpen: boolean;
28
readonly getScrollOffset: (tab: WorkspaceTab) => number;
29
readonly recordScrollOffset: (tab: WorkspaceTab, offset: number) => void;
30
} | null>(null);
@@ -30,14 +33,21 @@ export function useWorkspaceTabs() {
33
return use(WorkspaceTabsContext);
34
}
35
33
-export function WorkspaceTabsProvider(props: { readonly children: ReactNode }) {
36
+export function WorkspaceTabsProvider(props: {
37
+ readonly children: ReactNode;
38
+ readonly settingsOpen?: boolean;
39
+}) {
40
const [state, dispatch] = useReducer(workspaceTabsReducer, undefined, initialWorkspaceTabsState);
41
+ const order = useNavigationTabOrder();
42
+ const hidden = useHiddenNavigationTabs();
43
+ const selected = resolveSelectedNavigationTab(order, hidden, state.selectedTab);
44
+ if (selected && selected !== state.selectedTab) dispatch({ type: "select", tab: selected });
45
const activeTab = useRef(state.selectedTab);
46
useLayoutEffect(() => {
47
activeTab.current = state.selectedTab;
48
}, [state.selectedTab]);
49
const isTabActive = useCallback((tab: WorkspaceTab) => activeTab.current === tab, []);
40
- const scrollOffsets = useRef({ threads: 0, pullRequests: 0 });
50
+ const scrollOffsets = useRef({ threads: 0, pullRequests: 0, usage: 0 });
51
const getScrollOffset = useCallback((tab: WorkspaceTab) => scrollOffsets.current[tab], []);
52
const recordScrollOffset = useCallback((tab: WorkspaceTab, offset: number) => {
53
scrollOffsets.current[tab] = offset;
@@ -48,10 +58,11 @@ export function WorkspaceTabsProvider(props: { readonly children: ReactNode }) {
58
dispatch,
59
isTabActive,
60
bottomClearance: 0,
61
+ settingsOpen: props.settingsOpen ?? false,
62
getScrollOffset,
63
recordScrollOffset,
64
}),
54
- [state, isTabActive, getScrollOffset, recordScrollOffset],
65
+ [state, isTabActive, getScrollOffset, recordScrollOffset, props.settingsOpen],
66
);
67
return <WorkspaceTabsContext value={context}>{props.children}</WorkspaceTabsContext>;
68
}
apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx
+16
-38
@@ -1,6 +1,6 @@
1
import { useActiveNewTask } from "../../state/active-new-task";
2
import { Toolbar } from "../../components/ui/Toolbar";
3
-import { useFocusEffect, useNavigation } from "@react-navigation/native";
3
+import { useFocusEffect } from "@react-navigation/native";
4
import { use, useCallback, useEffect, useRef, type ReactNode } from "react";
5
import { Platform, Pressable, type TextInputInstance } from "react-native";
6
import { useReanimatedKeyboardAnimation } from "react-native-keyboard-controller";
@@ -20,12 +20,8 @@ import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
20
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
21
import { WorkspaceSearchField } from "./WorkspaceSearchField";
22
import { WORKSPACE_TOOLBAR } from "./workspace-tabs-state";
23
-import { useSidebarWorkspaceTabs } from "./useSystemWorkspaceTabBar";
24
-import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
25
-import { useMobileNavigationTheme } from "../../lib/useMobileNavigationTheme";
26
-
27
-// Tabler's git-pull-request geometry, shared with the UIKit tab bar.
28
-const PULL_REQUEST_ICON = require("../../../assets/icons/pull-request.png");
23
+import { useCompactWorkspaceTabs, useSidebarWorkspaceTabs } from "./useSystemWorkspaceTabBar";
24
+import { WorkspaceTabToolbarButtons } from "./WorkspaceSectionToolbar";
25
26
/**
27
* Rises once the keyboard reaches its content. UIKit also reports keyboards without height, with a
@@ -61,11 +57,9 @@ export function WorkspaceToolbar(props: {
57
}) {
58
const workspace = useWorkspaceTabs()!;
59
const activeNewTask = useActiveNewTask();
64
- const navigation = useNavigation();
60
const deviceType = useDeviceType();
61
const sidebarTabs = useSidebarWorkspaceTabs();
67
- const selectTab = useSelectWorkspaceTab();
68
- const selectedTint = useMobileNavigationTheme().colors.primary;
62
+ const compactTabs = useCompactWorkspaceTabs();
63
// On the Duo, compose belongs to the threads tab, in the detail column's bar when unfolded.
64
const nativeToolbarCompose =
65
Platform.OS === "ios" &&
@@ -168,16 +162,17 @@ export function WorkspaceToolbar(props: {
162
/>
163
{/* UIKit lays trailing items out from the edge inward. */}
164
<Toolbar placement="right">
171
- <Toolbar.Button
172
- accessibilityLabel="Settings"
173
- icon="gearshape"
174
- onPress={() =>
175
- navigation.navigate("SettingsSheet", {
176
- screen: "SettingsContent",
177
- params: { screen: "Settings" },
178
- })
179
- }
180
- />
165
+ {selectedTab !== "threads" ||
166
+ isDuoDevice(deviceType) ||
167
+ deviceType === "pad" ||
168
+ sidebarTabs === "picker" ||
169
+ compactTabs ? null : (
170
+ <Toolbar.Button
171
+ accessibilityLabel="New chat"
172
+ icon="square.and.pencil"
173
+ onPress={props.onNewTask}
174
+ />
175
+ )}
176
{NATIVE_LIQUID_GLASS_SUPPORTED ? null : (
177
<Toolbar.Button
178
accessibilityLabel={
@@ -189,24 +184,7 @@ export function WorkspaceToolbar(props: {
184
)}
185
</Toolbar>
186
<Toolbar placement="bottom">
192
- {sidebarTabs === "toolbar" ? (
193
- <Toolbar.Button
194
- identifier="workspace-tab-threads"
195
- accessibilityLabel="Threads"
196
- icon={selectedTab === "threads" ? "text.bubble.fill" : "text.bubble"}
197
- tintColor={selectedTab === "threads" ? selectedTint : undefined}
198
- onPress={() => selectTab("threads")}
199
- />
200
- ) : null}
201
- {sidebarTabs === "toolbar" ? (
202
- <Toolbar.Button
203
- identifier="workspace-tab-pull-requests"
204
- accessibilityLabel="Pull requests"
205
- icon={{ type: "image", source: PULL_REQUEST_ICON, tinted: true }}
206
- tintColor={selectedTab === "pullRequests" ? selectedTint : undefined}
207
- onPress={() => selectTab("pullRequests")}
208
- />
209
- ) : null}
187
+ {sidebarTabs === "toolbar" ? <WorkspaceTabToolbarButtons /> : null}
188
{nativeToolbarCompose ? <Toolbar.Spacer flexible /> : null}
189
{nativeToolbarCompose ? (
190
<Toolbar.Button
apps/mobile/src/features/workspace/navigation-tab-order.test.ts
new
+69
@@ -0,0 +1,69 @@
1
+import { describe, expect, it } from "vite-plus/test";
2
+import {
3
+ NAVIGATION_TAB_ORDER,
4
+ navigationCustomizationAvailable,
5
+ moveNavigationTab,
6
+ overflowNavigationTabs,
7
+ enabledNavigationTabs,
8
+ toggleNavigationTabVisibility,
9
+ resolveSelectedNavigationTab,
10
+ resolveNavigationTabOrder,
11
+ selectedNavigationTab,
12
+ visibleNavigationTabs,
13
+} from "./navigation-tab-order";
14
+
15
+describe("navigation tab order", () => {
16
+ it("enables customization only above four registered sections, excluding Settings", () => {
17
+ expect(navigationCustomizationAvailable()).toBe(false);
18
+ expect(navigationCustomizationAvailable(3)).toBe(false);
19
+ expect(navigationCustomizationAvailable(4)).toBe(false);
20
+ expect(navigationCustomizationAvailable(5)).toBe(true);
21
+ expect(navigationCustomizationAvailable(6)).toBe(true);
22
+ });
23
+
24
+ it("fills missing sections and drops removed placeholders, duplicates, and Settings", () => {
25
+ expect(
26
+ resolveNavigationTabOrder(["usage", "home", "issues", "settings", "usage", null]),
27
+ ).toEqual(["usage", "threads", "pullRequests"]);
28
+ expect(resolveNavigationTabOrder()).toEqual(NAVIGATION_TAB_ORDER);
29
+ });
30
+
31
+ it("moves a section without changing the relative order of the others", () => {
32
+ for (const tab of NAVIGATION_TAB_ORDER) {
33
+ for (let position = 0; position < NAVIGATION_TAB_ORDER.length; position++) {
34
+ const order = moveNavigationTab(NAVIGATION_TAB_ORDER, tab, position);
35
+ expect(order[position]).toBe(tab);
36
+ expect(order.filter((other) => other !== tab)).toEqual(
37
+ NAVIGATION_TAB_ORDER.filter((other) => other !== tab),
38
+ );
39
+ }
40
+ }
41
+ });
42
+
43
+ it("shows every real section without overflow and keeps Settings selected during editing", () => {
44
+ expect(visibleNavigationTabs()).toEqual(NAVIGATION_TAB_ORDER);
45
+ expect(overflowNavigationTabs()).toEqual([]);
46
+ expect(selectedNavigationTab(undefined, "threads", true)).toBe("settings");
47
+ expect(selectedNavigationTab(undefined, "usage", false)).toBe("usage");
48
+ expect(selectedNavigationTab(undefined, "usage", false, [], 2)).toBe("settings");
49
+ });
50
+
51
+ it("removes hidden sections from navigation and restores their saved positions", () => {
52
+ const order = moveNavigationTab(undefined, "usage", 0);
53
+ const hidden = toggleNavigationTabVisibility([], "usage");
54
+ expect(enabledNavigationTabs(order, hidden)).toEqual(["threads", "pullRequests"]);
55
+ expect(toggleNavigationTabVisibility(hidden, "usage")).toEqual([]);
56
+ expect(visibleNavigationTabs(order, [], 5)).toEqual(order);
57
+ expect(enabledNavigationTabs(undefined, ["home", "issues", "settings"])).toEqual(
58
+ NAVIGATION_TAB_ORDER,
59
+ );
60
+ });
61
+
62
+ it("falls back when the selected section is hidden, including when all are hidden", () => {
63
+ expect(resolveSelectedNavigationTab(undefined, ["threads"], "threads")).toBe("pullRequests");
64
+ expect(resolveSelectedNavigationTab(undefined, ["threads"], "usage")).toBe("usage");
65
+ expect(
66
+ resolveSelectedNavigationTab(undefined, NAVIGATION_TAB_ORDER, "threads"),
67
+ ).toBeUndefined();
68
+ });
69
+});
apps/mobile/src/features/workspace/navigation-tab-order.ts
new
+87
@@ -0,0 +1,87 @@
1
+export const NAVIGATION_TAB_ORDER = ["threads", "pullRequests", "usage"] as const;
2
+export type NavigationTab = (typeof NAVIGATION_TAB_ORDER)[number];
3
+
4
+export function navigationCustomizationAvailable(
5
+ registeredSections: number = NAVIGATION_TAB_ORDER.length,
6
+) {
7
+ return registeredSections > 4;
8
+}
9
+
10
+export const NAVIGATION_TAB_LABELS: Readonly<Record<NavigationTab, string>> = {
11
+ threads: "Threads",
12
+ pullRequests: "Pulls",
13
+ usage: "Usage",
14
+};
15
+
16
+function isNavigationTab(value: unknown): value is NavigationTab {
17
+ return NAVIGATION_TAB_ORDER.some((tab) => tab === value);
18
+}
19
+
20
+/** Complete older preferences without losing their order or retaining removed sections. */
21
+export function resolveNavigationTabOrder(saved?: readonly unknown[]): readonly NavigationTab[] {
22
+ if (!saved?.length) return NAVIGATION_TAB_ORDER;
23
+ return [...new Set([...saved.filter(isNavigationTab), ...NAVIGATION_TAB_ORDER])];
24
+}
25
+
26
+export function moveNavigationTab(
27
+ saved: readonly unknown[] | undefined,
28
+ tab: NavigationTab,
29
+ position: number,
30
+): readonly NavigationTab[] {
31
+ const order = [...resolveNavigationTabOrder(saved)];
32
+ const from = order.indexOf(tab);
33
+ const to = Math.max(0, Math.min(order.length - 1, position));
34
+ order.splice(from, 1);
35
+ order.splice(to, 0, tab);
36
+ return order;
37
+}
38
+
39
+export function resolveHiddenNavigationTabs(saved?: readonly unknown[]): readonly NavigationTab[] {
40
+ return [...new Set(saved?.filter(isNavigationTab) ?? [])];
41
+}
42
+
43
+export function toggleNavigationTabVisibility(
44
+ saved: readonly unknown[] | undefined,
45
+ tab: NavigationTab,
46
+) {
47
+ const hidden = resolveHiddenNavigationTabs(saved);
48
+ return hidden.includes(tab) ? hidden.filter((candidate) => candidate !== tab) : [...hidden, tab];
49
+}
50
+
51
+export function enabledNavigationTabs(saved?: readonly unknown[], hidden?: readonly unknown[]) {
52
+ const excluded = resolveHiddenNavigationTabs(hidden);
53
+ return resolveNavigationTabOrder(saved).filter((tab) => !excluded.includes(tab));
54
+}
55
+
56
+export function visibleNavigationTabs(
57
+ saved?: readonly unknown[],
58
+ hidden?: readonly unknown[],
59
+ capacity = 4,
60
+) {
61
+ return enabledNavigationTabs(saved, hidden).slice(0, capacity);
62
+}
63
+
64
+export function overflowNavigationTabs(saved?: readonly unknown[], hidden?: readonly unknown[]) {
65
+ return enabledNavigationTabs(saved, hidden).slice(4);
66
+}
67
+
68
+export function selectedNavigationTab(
69
+ saved: readonly unknown[] | undefined,
70
+ selected: NavigationTab,
71
+ settingsOpen: boolean,
72
+ hidden?: readonly unknown[],
73
+ capacity = 4,
74
+): NavigationTab | "settings" {
75
+ return settingsOpen || !visibleNavigationTabs(saved, hidden, capacity).includes(selected)
76
+ ? "settings"
77
+ : selected;
78
+}
79
+
80
+export function resolveSelectedNavigationTab(
81
+ saved: readonly unknown[] | undefined,
82
+ hidden: readonly unknown[] | undefined,
83
+ selected: NavigationTab,
84
+) {
85
+ const enabled = enabledNavigationTabs(saved, hidden);
86
+ return enabled.includes(selected) ? selected : enabled[0];
87
+}
apps/mobile/src/features/workspace/navigation-tabs.ts
new
+51
@@ -0,0 +1,51 @@
1
+import { useAtomValue } from "@effect/atom-react";
2
+import { AsyncResult } from "effect/reactivity";
3
+import { useMemo } from "react";
4
+import { Platform } from "react-native";
5
+import {
6
+ NAVIGATION_TAB_LABELS,
7
+ navigationCustomizationAvailable,
8
+ resolveHiddenNavigationTabs,
9
+ enabledNavigationTabs,
10
+ type NavigationTab,
11
+} from "./navigation-tab-order";
12
+import type { AppSymbolName } from "../../components/ui/AppSymbol";
13
+import { mobilePreferencesAtom } from "../../state/preferences";
14
+import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
15
+import { resolveWorkspaceTabOrder } from "./workspace-tabs-state";
16
+
17
+export const WORKSPACE_TAB_LABELS = {
18
+ ...NAVIGATION_TAB_LABELS,
19
+ ...(Platform.OS === "ios" ? { threads: "Chats", pullRequests: "PRs" } : {}),
20
+};
21
+
22
+export const NAVIGATION_TAB_ICONS = {
23
+ threads: "text.bubble",
24
+ pullRequests: PullRequestGlyph.pullRequest,
25
+ usage: "chart.bar.xaxis",
26
+} as const satisfies Readonly<Record<NavigationTab, AppSymbolName>>;
27
+
28
+export function useNavigationTabOrder() {
29
+ const preferences = useAtomValue(mobilePreferencesAtom);
30
+ const saved = AsyncResult.isSuccess(preferences)
31
+ ? preferences.value.navigationTabOrder
32
+ : undefined;
33
+ return useMemo(() => resolveWorkspaceTabOrder(saved), [saved]);
34
+}
35
+
36
+export function useHiddenNavigationTabs() {
37
+ const preferences = useAtomValue(mobilePreferencesAtom);
38
+ const saved = AsyncResult.isSuccess(preferences)
39
+ ? preferences.value.hiddenNavigationTabs
40
+ : undefined;
41
+ return useMemo(
42
+ () => (navigationCustomizationAvailable() ? resolveHiddenNavigationTabs(saved) : []),
43
+ [saved],
44
+ );
45
+}
46
+
47
+export function useEnabledNavigationTabs() {
48
+ const order = useNavigationTabOrder();
49
+ const hidden = useHiddenNavigationTabs();
50
+ return useMemo(() => enabledNavigationTabs(order, hidden), [order, hidden]);
51
+}
apps/mobile/src/features/workspace/useSelectWorkspaceTab.ts
+5
-5
@@ -1,6 +1,7 @@
1
import { StackActions, useNavigation } from "@react-navigation/native";
2
import { useCallback } from "react";
3
-import { Keyboard } from "react-native";
3
+import { Keyboard, Platform } from "react-native";
4
+import { resetAndroidWorkspace } from "../../lib/android-workspace-navigation";
5
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
6
import type { WorkspaceTab } from "./workspace-tabs-state";
7
@@ -8,15 +9,14 @@ import type { WorkspaceTab } from "./workspace-tabs-state";
9
export function useSelectWorkspaceTab() {
10
const workspace = useWorkspaceTabs()!;
11
const navigation = useNavigation();
11
- const selectedTab = workspace.state.selectedTab;
12
const { dispatch } = workspace;
13
return useCallback(
14
(tab: WorkspaceTab) => {
15
- if (tab === selectedTab) return;
15
Keyboard.dismiss();
17
- if (navigation.getState()?.index) navigation.dispatch(StackActions.popToTop());
16
+ if (Platform.OS === "android") resetAndroidWorkspace(navigation);
17
+ else navigation.dispatch(StackActions.popTo("Home"));
18
dispatch({ type: "select", tab });
19
},
20
- [dispatch, navigation, selectedTab],
20
+ [dispatch, navigation],
21
);
22
}
apps/mobile/src/features/workspace/useSystemWorkspaceTabBar.ts
+32
-5
@@ -1,20 +1,47 @@
1
+import { isDuoDevice } from "../../lib/device-type";
2
import { Platform } from "react-native";
3
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
4
import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
5
+import { useWorkspaceTabs } from "./WorkspaceTabsContext";
6
+import { workspaceUsesColumns } from "./workspace-tabs-state";
7
+
8
+function useWorkspacePage() {
9
+ const workspace = useWorkspaceTabs();
10
+ return (
11
+ workspace !== null &&
12
+ (workspace.settingsOpen || !workspaceUsesColumns(workspace.state.selectedTab))
13
+ );
14
+}
15
16
/** Where an iOS split window shows the workspace tabs instead of UIKit's tab bar. */
17
export function useSidebarWorkspaceTabs(): "picker" | "toolbar" | null {
18
const { layout } = useAdaptiveWorkspaceLayout();
19
const deviceType = useDeviceType();
20
const metrics = useNativeLayoutMetrics();
10
- if (Platform.OS !== "ios" || !layout.usesSplitView) return null;
11
- if (deviceType === "pad") return "picker";
12
- // The Duo's side rail carries UIKit's tabs. Unfolded in portrait it has no
13
- // rail, so the tabs sit in the thread list's own toolbar.
21
+ const page = useWorkspacePage();
22
+ if (Platform.OS !== "ios" || !layout.usesSplitView || page) return null;
23
+ if (deviceType === "pad") return null;
24
+ // Portrait Duo has no system rail; keep its tabs in the sidebar like iPad.
25
+ if (deviceType === "duo-unfolded" && (metrics?.verticalBarEdge ?? "none") === "none")
26
+ return "picker";
27
return (metrics?.verticalBarEdge ?? "none") === "none" ? "toolbar" : null;
28
}
29
30
+export function useCompactWorkspaceTabs() {
31
+ const { layout } = useAdaptiveWorkspaceLayout();
32
+ const deviceType = useDeviceType();
33
+ // The compact glass picker reserves the trailing edge for a separate compose button.
34
+ return (
35
+ Platform.OS === "ios" &&
36
+ deviceType !== "pad" &&
37
+ !layout.usesSplitView &&
38
+ !isDuoDevice(deviceType)
39
+ );
40
+}
41
+
42
export function useSystemWorkspaceTabBar() {
43
+ const deviceType = useDeviceType();
44
const sidebarTabs = useSidebarWorkspaceTabs();
19
- return Platform.OS === "ios" && sidebarTabs === null;
45
+ const compactTabs = useCompactWorkspaceTabs();
46
+ return Platform.OS === "ios" && deviceType !== "pad" && sidebarTabs === null && !compactTabs;
47
}
apps/mobile/src/features/workspace/useWorkspaceSurface.ts
new
+11
@@ -0,0 +1,11 @@
1
+import { useControlTheme } from "../../components/ui/useControlTheme";
2
+import { useDeviceType } from "../../native/native-layout-metrics";
3
+
4
+export function useWorkspaceSurface() {
5
+ const cover = useDeviceType() === "duo-folded";
6
+ const { colors } = useControlTheme();
7
+ return {
8
+ className: cover ? "bg-drawer" : "bg-screen",
9
+ backgroundColor: colors[cover ? "--color-drawer" : "--color-screen"],
10
+ };
11
+}
apps/mobile/src/features/workspace/workspace-tabs-state.test.ts
+88
-1
@@ -1,7 +1,73 @@
1
import { describe, expect, it } from "vite-plus/test";
2
-import { initialWorkspaceTabsState, workspaceTabsReducer } from "./workspace-tabs-state";
2
+import {
3
+ initialWorkspaceTabsState,
4
+ workspaceTabsReducer,
5
+ workspaceTabForNativeSlot,
6
+ resolveWorkspaceTabOrder,
7
+ workspaceSearchBottomClearance,
8
+ workspaceDockBottomClearance,
9
+ workspaceUsesColumns,
10
+} from "./workspace-tabs-state";
11
+
12
+describe("compact list clearance", () => {
13
+ it.each([
14
+ { bottomInset: 34, keyboardHeight: 300, clearance: 380 },
15
+ { bottomInset: 34, keyboardHeight: 0, clearance: 114 },
16
+ { bottomInset: 34, keyboardHeight: 20, clearance: 114 },
17
+ ])("keeps the last result above the keyboard and dock: %j", ({ clearance, ...input }) => {
18
+ expect(workspaceDockBottomClearance(input)).toBe(clearance);
19
+ });
20
+});
21
+
22
+describe("Duo list clearance", () => {
23
+ it.each([18, 60])(
24
+ "scrolls the last row above search with a %s-point native bar inset",
25
+ (bottomBarInset) => {
26
+ const clearance = workspaceSearchBottomClearance({
27
+ bottomInset: 34,
28
+ bottomBarInset,
29
+ keyboardHeight: 0,
30
+ });
31
+ expect(clearance).toBe(bottomBarInset + 48 + 16);
32
+ },
33
+ );
34
+
35
+ it("keeps the last row above search when the keyboard lifts the field", () => {
36
+ expect(
37
+ workspaceSearchBottomClearance({ bottomInset: 34, bottomBarInset: 18, keyboardHeight: 300 }),
38
+ ).toBe(300 + 8 + 48 + 16);
39
+ });
40
+
41
+ it("falls back to the field's safe-area spacing before native bar metrics arrive", () => {
42
+ expect(workspaceSearchBottomClearance({ bottomInset: 34, keyboardHeight: 0 })).toBe(
43
+ 34 + 48 + 16,
44
+ );
45
+ expect(workspaceSearchBottomClearance({ bottomInset: 0, keyboardHeight: 0 })).toBe(
46
+ 12 + 48 + 16,
47
+ );
48
+ });
49
+});
50
51
describe("workspace root navigation", () => {
52
+ it("keeps Usage and Settings out of the list/detail layout", () => {
53
+ expect(workspaceUsesColumns("usage")).toBe(false);
54
+ expect(workspaceUsesColumns("threads", "SettingsSheet")).toBe(false);
55
+ expect(workspaceUsesColumns("pullRequests", "SettingsSheet")).toBe(false);
56
+ });
57
+
58
+ it("restores columns for chat and pull request lists and their details", () => {
59
+ expect(workspaceUsesColumns("threads")).toBe(true);
60
+ expect(workspaceUsesColumns("threads", "Thread")).toBe(true);
61
+ expect(workspaceUsesColumns("pullRequests", "PullRequest")).toBe(true);
62
+ });
63
+
64
+ it("keeps the registered defaults while customization is unavailable", () => {
65
+ expect(resolveWorkspaceTabOrder(undefined)).toEqual(["threads", "pullRequests", "usage"]);
66
+ expect(resolveWorkspaceTabOrder(["home", "usage", "issues", "threads"])).toEqual(
67
+ resolveWorkspaceTabOrder(undefined),
68
+ );
69
+ });
70
+
71
it("retains separate queries and positions across tabs, and cancels only the current search", () => {
72
let state = initialWorkspaceTabsState();
73
state = workspaceTabsReducer(state, { type: "scroll", tab: "threads", offset: 640 });
@@ -64,4 +130,25 @@ describe("workspace root navigation", () => {
130
expect(state.tabs.pullRequests.searchMode).toBe("resting");
131
expect(workspaceTabsReducer(state, { type: "select", tab: "pullRequests" })).toBe(state);
132
});
133
+ it("returns from Usage without losing list state", () => {
134
+ let state = workspaceTabsReducer(initialWorkspaceTabsState(), {
135
+ type: "query",
136
+ query: "retained",
137
+ tab: "threads",
138
+ });
139
+ for (const tab of ["usage"] as const) {
140
+ state = workspaceTabsReducer(state, { type: "select", tab });
141
+ expect(state.selectedTab).toBe(tab);
142
+ expect(workspaceTabsReducer(state, { type: "search" })).toBe(state);
143
+ }
144
+ state = workspaceTabsReducer(state, { type: "select", tab: "threads" });
145
+ expect(state.tabs.threads.query).toBe("retained");
146
+ });
147
+ it("opens Settings on native reselection instead of selecting its overflow section", () => {
148
+ const order = ["threads", "pullRequests", "usage"] as const;
149
+ expect(workspaceTabForNativeSlot(order, "settings")).toBe("settings");
150
+ expect(workspaceTabForNativeSlot(order, "first")).toBe("threads");
151
+ expect(workspaceTabForNativeSlot(order, "third")).toBe("usage");
152
+ expect(workspaceTabForNativeSlot(order, "removed")).toBeNull();
153
+ });
154
});
apps/mobile/src/features/workspace/workspace-tabs-state.ts
+59
-2
@@ -1,6 +1,23 @@
1
-export type WorkspaceTab = "threads" | "pullRequests";
1
+import {
2
+ NAVIGATION_TAB_ORDER,
3
+ navigationCustomizationAvailable,
4
+ resolveNavigationTabOrder,
5
+ type NavigationTab,
6
+} from "./navigation-tab-order";
7
+
8
+export function resolveWorkspaceTabOrder(saved: readonly unknown[] | undefined) {
9
+ return navigationCustomizationAvailable()
10
+ ? resolveNavigationTabOrder(saved)
11
+ : NAVIGATION_TAB_ORDER;
12
+}
13
+
14
+export type WorkspaceTab = NavigationTab;
15
export type WorkspaceSearchMode = "resting" | "active" | "expanded";
16
17
+export function workspaceUsesColumns(tab: WorkspaceTab, detailRoute?: string) {
18
+ return (tab === "threads" || tab === "pullRequests") && detailRoute !== "SettingsSheet";
19
+}
20
+
21
export interface WorkspaceTabState {
22
readonly query: string;
23
readonly searchMode: WorkspaceSearchMode;
@@ -22,7 +39,11 @@ export function initialWorkspaceTabsState(): WorkspaceTabsState {
39
return {
40
selectedTab: "threads",
41
selectionRevision: 0,
25
- tabs: { threads: emptyTab(), pullRequests: emptyTab() },
42
+ tabs: {
43
+ threads: emptyTab(),
44
+ pullRequests: emptyTab(),
45
+ usage: emptyTab(),
46
+ },
47
};
48
}
49
@@ -47,6 +68,7 @@ export function workspaceTabsReducer(
68
selectionRevision: state.selectionRevision + 1,
69
};
70
const tab = action.tab ?? state.selectedTab;
71
+ if (tab !== "threads" && tab !== "pullRequests") return state;
72
const current = state.tabs[tab];
73
let next: WorkspaceTabState;
74
switch (action.type) {
@@ -84,8 +106,43 @@ export function workspaceTabsReducer(
106
export const WORKSPACE_TOOLBAR = { height: 48, expandedGap: 10, edge: 16, gap: 8 };
107
export const WORKSPACE_DOCK = { height: 48, tabsWidth: 176, gap: 12, bottomGap: 6 };
108
109
+export function workspaceDockBottomClearance(input: {
110
+ readonly bottomInset: number;
111
+ readonly keyboardHeight: number;
112
+}) {
113
+ return 64 + Math.max(input.bottomInset, input.keyboardHeight) + 16;
114
+}
115
+
116
+export function workspaceSearchBottomClearance(input: {
117
+ readonly bottomInset: number;
118
+ readonly bottomBarInset?: number;
119
+ readonly keyboardHeight: number;
120
+}) {
121
+ const bottom = input.bottomBarInset ?? Math.max(input.bottomInset, 12);
122
+ // AboveKeyboard lifts the field to an 8-point gap above the keyboard.
123
+ return (
124
+ Math.max(bottom, input.keyboardHeight > 0 ? input.keyboardHeight + 8 : 0) +
125
+ WORKSPACE_TOOLBAR.height +
126
+ 16
127
+ );
128
+}
129
+
130
export function workspaceToolbarHeight(mode: WorkspaceSearchMode): number {
131
return mode === "expanded"
132
? WORKSPACE_TOOLBAR.height * 2 + WORKSPACE_TOOLBAR.expandedGap
133
: WORKSPACE_TOOLBAR.height;
134
}
135
+
136
+export const NATIVE_WORKSPACE_TAB_SLOTS = [
137
+ "first",
138
+ "second",
139
+ "third",
140
+ "fourth",
141
+ "settings",
142
+] as const;
143
+
144
+export function workspaceTabForNativeSlot(order: readonly WorkspaceTab[], slot: string) {
145
+ if (slot === "settings") return "settings";
146
+ const index = NATIVE_WORKSPACE_TAB_SLOTS.findIndex((candidate) => candidate === slot);
147
+ return order[index] ?? null;
148
+}
apps/mobile/src/lib/storage.test.ts
+28
@@ -131,6 +131,34 @@ describe("mobile connection storage", () => {
131
});
132
});
133
134
+ it("persists tab order locally and retains it when another preference changes", async () => {
135
+ const navigationTabOrder = ["usage", "threads", "pullRequests"];
136
+ const hiddenNavigationTabs = ["issues", "home"];
137
+ await savePreferencesPatch({ navigationTabOrder, hiddenNavigationTabs });
138
+ await savePreferencesPatch({ baseFontSize: 19 });
139
+ await expect(loadPreferences()).resolves.toEqual({
140
+ navigationTabOrder,
141
+ hiddenNavigationTabs,
142
+ baseFontSize: 19,
143
+ });
144
+ });
145
+
146
+ it("ignores invalid tab-order entries without dropping other saved preferences", async () => {
147
+ mocks.setPreferencesJson(
148
+ JSON.stringify({
149
+ navigationTabOrder: ["usage", null, 4, "threads"],
150
+ hiddenNavigationTabs: ["home", null],
151
+ baseFontSize: 18,
152
+ }),
153
+ 1,
154
+ );
155
+ await expect(loadPreferences()).resolves.toEqual({
156
+ navigationTabOrder: ["usage", "threads"],
157
+ hiddenNavigationTabs: ["home"],
158
+ baseFontSize: 18,
159
+ });
160
+ });
161
+
162
it("loads legacy preferences when SQLite is unavailable", async () => {
163
mocks.setDatabaseFailures(true, true);
164
await mocks.setItemAsync("t3code.preferences", JSON.stringify({ baseFontSize: 17 }));
apps/mobile/src/native/NativeColumnContent.ios.tsx
+8
-2
@@ -1,6 +1,6 @@
1
import { HeaderHeightContext } from "@react-navigation/elements";
2
import { useState, type ReactNode } from "react";
3
-import { View } from "react-native";
3
+import { View, type ColorValue } from "react-native";
4
import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";
5
import { NativeColumnLayoutMetricsContext } from "./native-layout-metrics";
6
import type { NativeLayoutMetrics } from "../lib/reserved-regions";
@@ -10,10 +10,16 @@ export function NativeColumnContent(props: {
10
readonly children: ReactNode;
11
readonly primary?: boolean;
12
readonly insetHorizontally?: boolean;
13
+ readonly backgroundColor?: ColorValue;
14
}) {
15
const [metrics, setMetrics] = useState<NativeLayoutMetrics | null>(null);
16
return (
16
- <View className={props.primary ? "flex-1 bg-drawer" : "flex-1 bg-screen"}>
17
+ <View
18
+ className={props.primary ? "flex-1 bg-drawer" : "flex-1 bg-screen"}
19
+ style={
20
+ props.backgroundColor === undefined ? undefined : { backgroundColor: props.backgroundColor }
21
+ }
22
+ >
23
<SafeAreaProvider style={{ flex: 1 }}>
24
<SafeAreaView
25
edges={props.insetHorizontally === false ? [] : ["left", "right"]}
apps/mobile/src/native/V5StackHeader.ios.tsx
+11
-4
@@ -218,15 +218,22 @@ export function V5StackHeader(props: {
218
bottom.length = 0;
219
}
220
if (props.onCompose) {
221
- if (trailing.length)
222
- trailing.push({ type: "spacer", id: "compose-group", sizing: "fixed", width: 8 });
223
- trailing.push({
221
+ const compose: HeaderItem = {
222
type: "item",
223
id: "workspace-compose",
224
title: "New task",
225
icon: { type: "sfSymbol", name: "square.and.pencil" },
226
onPress: props.onCompose,
229
- });
227
+ };
228
+ if (deviceType === "duo-unfolded") {
229
+ if (leading.length)
230
+ leading.unshift({ type: "spacer", id: "compose-group", sizing: "fixed", width: 8 });
231
+ leading.unshift(compose);
232
+ } else {
233
+ if (trailing.length)
234
+ trailing.push({ type: "spacer", id: "compose-group", sizing: "fixed", width: 8 });
235
+ trailing.push(compose);
236
+ }
237
}
238
const left = options.headerLeft?.(itemProps);
239
const right = options.headerRight?.(itemProps);
apps/mobile/src/native/createV5StackNavigator.ios.tsx
+3
@@ -237,6 +237,9 @@ export function V5CardStackView(
237
}
238
/>
239
<NativeColumnContent
240
+ backgroundColor={
241
+ StyleSheet.flatten(descriptor.options.contentStyle)?.backgroundColor
242
+ }
243
insetHorizontally={
244
(descriptor.options as AppNativeStackNavigationOptions)
245
.nativeContentInsetHorizontally
apps/mobile/src/persistence/mobile-preferences.ts
+16
@@ -51,6 +51,8 @@ const isThreadListFilters = Schema.is(ThreadListFilters);
51
const isPullRequestListPreferences = Schema.is(PullRequestListPreferences);
52
53
export interface Preferences {
54
+ readonly navigationTabOrder?: readonly string[];
55
+ readonly hiddenNavigationTabs?: readonly string[];
56
readonly pullRequestHideTestFiles?: boolean;
57
readonly pullRequestMergeMethod?: PullRequestMergeMethod;
58
readonly liveActivitiesEnabled?: boolean;
@@ -126,6 +128,8 @@ export class MobilePreferencesStore extends Context.Service<
128
129
function sanitizePreferences(parsed: Preferences): Preferences {
130
const preferences: {
131
+ navigationTabOrder?: readonly string[];
132
+ hiddenNavigationTabs?: readonly string[];
133
pullRequestHideTestFiles?: boolean;
134
pullRequestMergeMethod?: PullRequestMergeMethod;
135
liveActivitiesEnabled?: boolean;
@@ -157,6 +161,18 @@ function sanitizePreferences(parsed: Preferences): Preferences {
161
pullRequestListFilters?: PullRequestListPreferences;
162
} = {};
163
164
+ if (Array.isArray(parsed.hiddenNavigationTabs)) {
165
+ preferences.hiddenNavigationTabs = parsed.hiddenNavigationTabs.filter(
166
+ (tab): tab is string => typeof tab === "string",
167
+ );
168
+ }
169
+
170
+ if (Array.isArray(parsed.navigationTabOrder)) {
171
+ preferences.navigationTabOrder = parsed.navigationTabOrder.filter(
172
+ (tab): tab is string => typeof tab === "string",
173
+ );
174
+ }
175
+
176
if (typeof parsed.pullRequestHideTestFiles === "boolean") {
177
preferences.pullRequestHideTestFiles = parsed.pullRequestHideTestFiles;
178
}
docs/user/usage.md
+2
@@ -4,6 +4,8 @@ Open **Usage** from the sidebar or the command palette, or press `mod+u` on web
4
desktop when the terminal is not focused. Customize `usage.open` in
5
**Settings → Keybindings**.
6
7
+On mobile, choose **Usage** in the workspace navigation.
8
+
9
## Understand your usage
10
11
**Usage** combines Codex, Claude Code, Grok Build, OpenCode, Antigravity, Pi, Muse Code, and Cursor history