@devries-cameron20 / t3code-1 / commits / 5848bc263b
Fork 0

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

feat(mobile): Settings is a workspace tab, and tabs never open on an empty detail (#24524)

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

Julius Marminge committed Oct 24, 2026 at 17:29 UTC 5848bc263bf4fe905e6e3f2eccabfc700d14d58e
65 files changed +1805 -1015
apps/mobile/src/App.tsx
+18 -2
@@ -31,6 +31,13 @@ import { useUiRuntimeMemoryWarningGc } from "./lib/useUiRuntimeMemoryWarningGc";
31 import { SubscriptionUsageCoordinator } from "./widgets/SubscriptionUsageCoordinator";
32 import { VoiceInputProvider } from "./features/voice-input/VoiceInputProvider";
33 import { GlobalVoiceInputControl } from "./features/voice-input/GlobalVoiceInputControl";
34 +import { restoreSettingsLinkState } from "./features/settings/settings-navigation";
35 +import {
36 + hydrateWorkspaceSelections,
37 + launchWorkspaceURL,
38 + recordWorkspaceSelections,
39 + settingsLinkPage,
40 +} from "./features/workspace/workspace-selection-store";
41 import { NativeLayoutMetricsProvider } from "./native/native-layout-metrics";
42
43 import "../global.css";
@@ -40,13 +47,18 @@ if (process.env.EXPO_PUBLIC_SHOWCASE === "1") {
47 }
48
49 void SplashScreen.preventAutoHideAsync().catch(() => {});
50 +void hydrateWorkspaceSelections();
51
52 const appLinking = {
53 prefixes: [Linking.createURL("/"), "t3code://", "t3code-dev://", "t3code-preview://"],
54 config: { initialRouteName: "Home" },
55 filter: shouldHandleAppLink,
56 + getInitialURL: async () => (await Linking.getInitialURL()) ?? (await launchWorkspaceURL()),
57 getStateFromPath: (path: string, options: Parameters<typeof getStateFromPath>[1]) =>
49 - restoreDraftLinkState(getStateFromPath(path, options), path),
58 + restoreSettingsLinkState(
59 + restoreDraftLinkState(getStateFromPath(path, options), path),
60 + settingsLinkPage(),
61 + ),
62 };
63
64 const Navigation = createStaticNavigation(RootStack);
@@ -107,7 +119,11 @@ function AppContent() {
119 <GlobalVoiceInputControl>
120 <NativeLayoutMetricsProvider>
121 <IncomingShareProvider>
110 - <Navigation linking={appLinking} theme={navigationTheme} />
122 + <Navigation
123 + linking={appLinking}
124 + theme={navigationTheme}
125 + onStateChange={recordWorkspaceSelections}
126 + />
127 </IncomingShareProvider>
128 <Dialog.Host />
129 <ThreadArrangementHost />
apps/mobile/src/Stack.tsx
+284 -314
@@ -3,7 +3,6 @@ import { ComponentCatalogScreen } from "./features/development/ComponentCatalogS
3 import { PullRequestGuideStopScreen } from "./features/pull-requests/guide/PullRequestGuideScreen";
4 import { PullRequestInlineCommentScreen } from "./features/pull-requests/PullRequestInlineCommentScreen";
5 import { PullRequestDiscussionScreen } from "./features/pull-requests/PullRequestDiscussionScreen";
6 -import { createV5SheetStackNavigator } from "./native/createV5StackNavigator";
6 import { createWorkspaceStackNavigator } from "./features/layout/createWorkspaceStackNavigator";
7 import {
8 createPathConfigForStaticNavigation,
@@ -25,7 +24,6 @@ import { androidWorkspaceDestinationAnimation } from "./lib/android-workspace-na
24 import { getCompactBrandHeaderOptions } from "./components/CompactBrandTitle";
25 import { WorkspaceConnectionStatusProvider } from "./features/home/WorkspaceConnectionTitle";
26 import { WorkspaceRootScreen } from "./features/workspace/WorkspaceRootScreen";
28 -import { AndroidWorkspaceSettings } from "./features/workspace/AndroidWorkspaceSettings";
27 import { AndroidWorkspaceTabsProvider } from "./features/workspace/AndroidWorkspaceTabsProvider";
28 import {
29 PullRequestRouteScreen,
@@ -109,7 +107,6 @@ import {
107 ScheduledTaskModelPickerRouteScreen,
108 ScheduledTaskBranchPickerRouteScreen,
109 } from "./features/settings/ScheduledTaskPickerScreens";
112 -import { ScheduledTaskEditorProvider } from "./features/settings/scheduled-task-editor";
110 import { SettingsKeyboardRouteScreen } from "./features/settings/SettingsKeyboardRouteScreen";
111 import { SettingsLegalRouteScreen } from "./features/settings/SettingsLegalRouteScreen";
112 import { SettingsMicrophoneRouteScreen } from "./features/settings/SettingsMicrophoneRouteScreen";
@@ -126,6 +123,12 @@ import { SettingsNotificationsRouteScreen } from "./features/settings/SettingsNo
123 import { SettingsRouteScreen } from "./features/settings/SettingsRouteScreen";
124 import { SettingsThreadsRouteScreen } from "./features/settings/SettingsThreadsRouteScreen";
125 import { SettingsEnvironmentFilterProvider } from "./features/settings/settings-environment-filter";
126 +import { openSettings, settingsOpenIn } from "./features/settings/settings-navigation";
127 +import { DEFAULT_SETTINGS_PAGE } from "./features/workspace/workspace-tab-navigation";
128 +import {
129 + isWorkspaceOverlayRoute,
130 + registerPresentedRoutes,
131 +} from "./features/layout/workspace-overlay-routes";
132 import { ShowcaseCaptureCoordinator } from "./features/showcase/ShowcaseCaptureCoordinator";
133 import {
134 SettingsLegalDocumentCloseHeaderButton,
@@ -212,8 +215,6 @@ const LEGAL_DOCUMENT_HEADER_OPTIONS: AppScreenOptions = {
215 presentation: "fullScreenModal",
216 };
217
215 -const NESTED_NAVIGATOR_OPTIONS = { nativeContentInsetHorizontally: false, headerShown: false };
216 -
218 // Thread settings keep the Duo's vertical bar so cancel, search, filter and confirm sit in the
219 // rail. The picker stack spans the sheet so its header reaches the rail, and insets its content.
220 const THREAD_SETTINGS_SHEET_OPTIONS = {
@@ -223,295 +224,253 @@ const THREAD_SETTINGS_SHEET_OPTIONS = {
224 nativeContentInsetHorizontally: false,
225 };
226
226 -const SettingsContentStack = createV5SheetStackNavigator({
227 - initialRouteName: "Settings",
228 - screenOptions: {
229 - ...GLASS_HEADER_OPTIONS,
230 - unstable_navigationItemStyle: undefined,
231 - },
232 - screens: {
233 - Settings: createNativeStackScreen({
234 - screen: SettingsRouteScreen,
235 - linking: "",
236 - options: {
237 - title: "Settings",
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({
245 - screen: SettingsEnvironmentsRouteScreen,
246 - linking: "environments",
247 - options: {
248 - title: "Environments",
249 - },
250 - }),
251 - SettingsEnvironmentDetail: createNativeStackScreen({
252 - screen: SettingsEnvironmentDetailRouteScreen,
253 - linking: "environments/:environmentId",
254 - options: { title: "Environment" },
255 - }),
256 - SettingsEnvironmentNewThreads: createNativeStackScreen({
257 - screen: SettingsEnvironmentNewThreadsRouteScreen,
258 - linking: "new-threads",
259 - options: { title: "New threads" },
260 - }),
261 - SettingsEnvironmentSourceControl: createNativeStackScreen({
262 - screen: SettingsEnvironmentSourceControlRouteScreen,
263 - linking: "source-control",
264 - options: { title: "Source control" },
265 - }),
266 - SettingsEnvironmentAgentBehavior: createNativeStackScreen({
267 - screen: SettingsEnvironmentAgentBehaviorRouteScreen,
268 - linking: "agent-behavior",
269 - options: { title: "Agent behavior" },
270 - }),
271 - SettingsProviderAccounts: createNativeStackScreen({
272 - screen: SettingsProviderAccountsRouteScreen,
273 - linking: "provider-accounts",
274 - options: { title: "Provider accounts" },
275 - }),
276 - SettingsEnvironmentMaintenance: createNativeStackScreen({
277 - screen: SettingsEnvironmentMaintenanceRouteScreen,
278 - linking: "maintenance",
279 - options: { title: "Maintenance" },
280 - }),
281 - SettingsNotifications: createNativeStackScreen({
282 - screen: SettingsNotificationsRouteScreen,
283 - linking: "notifications",
284 - options: { title: "Notifications" },
285 - }),
286 - SettingsThreads: createNativeStackScreen({
287 - screen: SettingsThreadsRouteScreen,
288 - linking: "thread-preferences",
289 - options: { title: "Thread behavior" },
290 - }),
291 - SettingsAbout: createNativeStackScreen({
292 - screen: SettingsAboutRouteScreen,
293 - linking: "about",
294 - options: { title: "About T3 Code" },
295 - }),
296 - SettingsEnvironmentNew: createNativeStackScreen({
297 - screen: ConnectionsNewRouteScreen,
298 - linking: "environment-new",
299 - options: {
300 - title: "Add Environment",
301 - },
302 - }),
303 - SettingsArchive: createNativeStackScreen({
304 - screen: ArchivedThreadsRouteScreen,
305 - linking: "archive",
306 - options: {
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",
318 - options: {
319 - title: "Appearance",
320 - },
321 - }),
322 - SettingsProjectGrouping: createNativeStackScreen({
323 - screen: SettingsProjectGroupingRouteScreen,
324 - linking: "project-grouping",
325 - options: {
326 - title: "Organization",
327 - },
328 - }),
329 - SettingsOrganization: createNativeStackScreen({
330 - screen: SettingsProjectGroupingRouteScreen,
331 - linking: "organization",
332 - options: {
333 - title: "Organization",
334 - },
335 - }),
336 - SettingsProjectOverview: createNativeStackScreen({
337 - screen: SettingsProjectOverviewRouteScreen,
338 - linking: "project",
339 - options: { title: "Project overview" },
340 - }),
341 - SettingsKeyboard: createNativeStackScreen({
342 - screen: SettingsKeyboardRouteScreen,
343 - linking: "keyboard",
344 - options: {
345 - title: "Keyboard",
346 - },
347 - }),
348 - SettingsMicrophone: createNativeStackScreen({
349 - screen: SettingsMicrophoneRouteScreen,
350 - linking: "microphone",
351 - options: {
352 - title: "Microphone",
353 - },
354 - }),
355 - SettingsFollowUp: createNativeStackScreen({
356 - screen: SettingsFollowUpRouteScreen,
357 - linking: "follow-ups",
358 - options: {
359 - title: "Follow-ups",
360 - },
361 - }),
362 - SettingsScheduledTasks: createNativeStackScreen({
363 - screen: SettingsScheduledTasksRouteScreen,
364 - linking: "scheduled-tasks",
365 - options: {
366 - title: "Scheduled Tasks",
367 - headerTitleStyle: { fontSize: 16, fontWeight: "800" },
368 - },
369 - }),
370 - SettingsScheduledTaskNew: createNativeStackScreen({
371 - screen: SettingsScheduledTaskNewRouteScreen,
372 - linking: "scheduled-tasks/new",
373 - options: { title: "New scheduled task" },
374 - }),
375 - SettingsScheduledTaskEdit: createNativeStackScreen({
376 - screen: SettingsScheduledTaskEditRouteScreen,
377 - options: { title: "Edit scheduled task" },
378 - }),
379 - SettingsScheduledTaskBranch: createNativeStackScreen({
380 - screen: ScheduledTaskBranchPickerRouteScreen,
381 - options: { title: "Base branch" },
382 - }),
383 - SettingsScheduledTaskModel: createNativeStackScreen({
384 - screen: ScheduledTaskModelPickerRouteScreen,
385 - options: {
386 - headerShown: false,
387 - ...(Platform.OS === "android"
388 - ? { presentation: "card" as const }
389 - : {
390 - ...THREAD_SETTINGS_SHEET_OPTIONS,
391 - }),
392 - },
393 - }),
394 - SettingsClientStorage: createNativeStackScreen({
395 - screen: SettingsClientStorageRouteScreen,
396 - linking: "client-storage",
397 - options: {
398 - title: "Client Storage",
399 - },
400 - }),
401 - SettingsDiagnostics: createNativeStackScreen({
402 - screen: SettingsDiagnosticsRouteScreen,
403 - linking: "diagnostics",
404 - options: {
405 - title: "Diagnostics",
406 - },
407 - }),
408 - // Its params are a tap-time snapshot, not a stable resource address: `now` is the wall-clock
409 - // of the tap, `environmentIds` is the usage screen's local filter selection, and the window
410 - // id/kind identify freshly aggregated pools. React Navigation round-trips non-path params
411 - // through the URL as query strings, so a path here would bake in a permanently stale
412 - // timestamp and filter.
413 - SettingsUsageAccount: createNativeStackScreen({
414 - screen: UsageLimitAccountScreen,
415 - options: { title: "Account" },
416 - }),
417 - SettingsOpenSourceLicenses: createNativeStackScreen({
418 - screen: SettingsOpenSourceLicensesRouteScreen,
419 - linking: "open-source-licenses",
420 - options: {
421 - title: "Open source licenses",
422 - },
423 - }),
424 - SettingsOpenSourceLicense: createNativeStackScreen({
425 - screen: SettingsOpenSourceLicenseRouteScreen,
426 - linking: "open-source-licenses/:entryKey",
427 - options: {
428 - title: "License notice",
429 - },
430 - }),
431 - SettingsUsage: createNativeStackScreen({
432 - screen: UsageRouteScreen,
433 - linking: "usage",
434 - options: {
435 - title: "Usage",
436 - },
437 - }),
438 - },
439 -});
227 +// Settings pages are root routes so they share the workspace's columns and header. The
228 +// `Settings` route marks the Settings tab as open (see settings-navigation.ts).
229 +const SETTINGS_PAGE_OPTIONS = SHEET_GLASS_HEADER_OPTIONS;
230
441 -// Keeping bar visibility invariant avoids iOS 26's headerless-to-headered jump.
442 -const SettingsSheetStack = createV5SheetStackNavigator({
443 - initialRouteName: "SettingsContent",
444 - screenOptions: {
445 - headerShown: false,
446 - },
447 - screens: {
448 - SettingsContent: createNativeStackScreen({
449 - screen: SettingsContentStack,
450 - options: NESTED_NAVIGATOR_OPTIONS,
451 - linking: "",
452 - layout: ({ children }) => (
453 - <SettingsEnvironmentFilterProvider>
454 - <ScheduledTaskEditorProvider>{children}</ScheduledTaskEditorProvider>
455 - </SettingsEnvironmentFilterProvider>
456 - ),
457 - }),
458 - SettingsAuth: createNativeStackScreen({
459 - screen: SettingsAuthRouteScreen,
460 - linking: "auth",
461 - }),
462 - SettingsWaitlist: createNativeStackScreen({
463 - screen: SettingsAuthRouteScreen,
464 - linking: "waitlist",
465 - }),
466 - },
467 -});
231 +const SETTINGS_SCREENS = {
232 + Settings: createNativeStackScreen({
233 + screen: SettingsRouteScreen,
234 + linking: "settings",
235 + options: {
236 + ...SETTINGS_PAGE_OPTIONS,
237 + title: "Settings",
238 + ...(Platform.OS === "android" ? { animation: "none" as const } : {}),
239 + // Android draws its own app bar here. Hidden only from inside the screen, the native one
240 + // showed for the first frame of the Settings tab and pushed the page down.
241 + headerShown: Platform.OS !== "android",
242 + headerBackVisible: false,
243 + },
244 + }),
245 + SettingsEnvironments: createNativeStackScreen({
246 + screen: SettingsEnvironmentsRouteScreen,
247 + linking: "settings/environments",
248 + options: {
249 + ...SETTINGS_PAGE_OPTIONS,
250 + title: "Environments",
251 + },
252 + }),
253 + SettingsEnvironmentDetail: createNativeStackScreen({
254 + screen: SettingsEnvironmentDetailRouteScreen,
255 + linking: "settings/environments/:environmentId",
256 + options: { ...SETTINGS_PAGE_OPTIONS, title: "Environment" },
257 + }),
258 + SettingsEnvironmentNewThreads: createNativeStackScreen({
259 + screen: SettingsEnvironmentNewThreadsRouteScreen,
260 + linking: "settings/new-threads",
261 + options: { ...SETTINGS_PAGE_OPTIONS, title: "New threads" },
262 + }),
263 + SettingsEnvironmentSourceControl: createNativeStackScreen({
264 + screen: SettingsEnvironmentSourceControlRouteScreen,
265 + linking: "settings/source-control",
266 + options: { ...SETTINGS_PAGE_OPTIONS, title: "Source control" },
267 + }),
268 + SettingsEnvironmentAgentBehavior: createNativeStackScreen({
269 + screen: SettingsEnvironmentAgentBehaviorRouteScreen,
270 + linking: "settings/agent-behavior",
271 + options: { ...SETTINGS_PAGE_OPTIONS, title: "Agent behavior" },
272 + }),
273 + SettingsProviderAccounts: createNativeStackScreen({
274 + screen: SettingsProviderAccountsRouteScreen,
275 + linking: "settings/provider-accounts",
276 + options: { ...SETTINGS_PAGE_OPTIONS, title: "Provider accounts" },
277 + }),
278 + SettingsEnvironmentMaintenance: createNativeStackScreen({
279 + screen: SettingsEnvironmentMaintenanceRouteScreen,
280 + linking: "settings/maintenance",
281 + options: { ...SETTINGS_PAGE_OPTIONS, title: "Maintenance" },
282 + }),
283 + SettingsNotifications: createNativeStackScreen({
284 + screen: SettingsNotificationsRouteScreen,
285 + linking: "settings/notifications",
286 + options: { ...SETTINGS_PAGE_OPTIONS, title: "Notifications" },
287 + }),
288 + SettingsThreads: createNativeStackScreen({
289 + screen: SettingsThreadsRouteScreen,
290 + linking: "settings/thread-preferences",
291 + options: { ...SETTINGS_PAGE_OPTIONS, title: "Thread behavior" },
292 + }),
293 + SettingsAbout: createNativeStackScreen({
294 + screen: SettingsAboutRouteScreen,
295 + linking: "settings/about",
296 + options: { ...SETTINGS_PAGE_OPTIONS, title: "About T3 Code" },
297 + }),
298 + SettingsEnvironmentNew: createNativeStackScreen({
299 + screen: ConnectionsNewRouteScreen,
300 + linking: "settings/environment-new",
301 + options: {
302 + ...SETTINGS_PAGE_OPTIONS,
303 + title: "Add Environment",
304 + },
305 + }),
306 + SettingsArchive: createNativeStackScreen({
307 + screen: ArchivedThreadsRouteScreen,
308 + linking: "settings/archive",
309 + options: {
310 + ...SETTINGS_PAGE_OPTIONS,
311 + title: "Archived Threads",
312 + },
313 + }),
314 + SettingsNavigation: createNativeStackScreen({
315 + screen: SettingsNavigationRouteScreen,
316 + linking: "settings/navigation-tabs",
317 + options: { ...SETTINGS_PAGE_OPTIONS, title: "Navigation tabs" },
318 + }),
319 + SettingsAppearance: createNativeStackScreen({
320 + screen: SettingsAppearanceRouteScreen,
321 + linking: "settings/appearance",
322 + options: {
323 + ...SETTINGS_PAGE_OPTIONS,
324 + title: "Appearance",
325 + },
326 + }),
327 + SettingsProjectGrouping: createNativeStackScreen({
328 + screen: SettingsProjectGroupingRouteScreen,
329 + linking: "settings/project-grouping",
330 + options: {
331 + ...SETTINGS_PAGE_OPTIONS,
332 + title: "Organization",
333 + },
334 + }),
335 + SettingsOrganization: createNativeStackScreen({
336 + screen: SettingsProjectGroupingRouteScreen,
337 + linking: "settings/organization",
338 + options: {
339 + ...SETTINGS_PAGE_OPTIONS,
340 + title: "Organization",
341 + },
342 + }),
343 + SettingsProjectOverview: createNativeStackScreen({
344 + screen: SettingsProjectOverviewRouteScreen,
345 + linking: "settings/project",
346 + options: { ...SETTINGS_PAGE_OPTIONS, title: "Project overview" },
347 + }),
348 + SettingsKeyboard: createNativeStackScreen({
349 + screen: SettingsKeyboardRouteScreen,
350 + linking: "settings/keyboard",
351 + options: {
352 + ...SETTINGS_PAGE_OPTIONS,
353 + title: "Keyboard",
354 + },
355 + }),
356 + SettingsMicrophone: createNativeStackScreen({
357 + screen: SettingsMicrophoneRouteScreen,
358 + linking: "settings/microphone",
359 + options: {
360 + ...SETTINGS_PAGE_OPTIONS,
361 + title: "Microphone",
362 + },
363 + }),
364 + SettingsFollowUp: createNativeStackScreen({
365 + screen: SettingsFollowUpRouteScreen,
366 + linking: "settings/follow-ups",
367 + options: {
368 + ...SETTINGS_PAGE_OPTIONS,
369 + title: "Follow-ups",
370 + },
371 + }),
372 + SettingsScheduledTasks: createNativeStackScreen({
373 + screen: SettingsScheduledTasksRouteScreen,
374 + linking: "settings/scheduled-tasks",
375 + options: {
376 + ...SETTINGS_PAGE_OPTIONS,
377 + title: "Scheduled Tasks",
378 + headerTitleStyle: { fontSize: 16, fontWeight: "800" },
379 + },
380 + }),
381 + SettingsScheduledTaskNew: createNativeStackScreen({
382 + screen: SettingsScheduledTaskNewRouteScreen,
383 + linking: "settings/scheduled-tasks/new",
384 + options: { ...SETTINGS_PAGE_OPTIONS, title: "New scheduled task" },
385 + }),
386 + SettingsScheduledTaskEdit: createNativeStackScreen({
387 + screen: SettingsScheduledTaskEditRouteScreen,
388 + options: { ...SETTINGS_PAGE_OPTIONS, title: "Edit scheduled task" },
389 + }),
390 + SettingsScheduledTaskBranch: createNativeStackScreen({
391 + screen: ScheduledTaskBranchPickerRouteScreen,
392 + options: { ...SETTINGS_PAGE_OPTIONS, title: "Base branch" },
393 + }),
394 + SettingsScheduledTaskModel: createNativeStackScreen({
395 + screen: ScheduledTaskModelPickerRouteScreen,
396 + options: {
397 + ...SETTINGS_PAGE_OPTIONS,
398 + headerShown: false,
399 + ...(Platform.OS === "android"
400 + ? { presentation: "card" as const }
401 + : {
402 + ...THREAD_SETTINGS_SHEET_OPTIONS,
403 + }),
404 + },
405 + }),
406 + SettingsClientStorage: createNativeStackScreen({
407 + screen: SettingsClientStorageRouteScreen,
408 + linking: "settings/client-storage",
409 + options: {
410 + ...SETTINGS_PAGE_OPTIONS,
411 + title: "Client Storage",
412 + },
413 + }),
414 + SettingsDiagnostics: createNativeStackScreen({
415 + screen: SettingsDiagnosticsRouteScreen,
416 + linking: "settings/diagnostics",
417 + options: {
418 + ...SETTINGS_PAGE_OPTIONS,
419 + title: "Diagnostics",
420 + },
421 + }),
422 + // Its params are a tap-time snapshot, not a stable resource address: `now` is the wall-clock
423 + // of the tap, `environmentIds` is the usage screen's local filter selection, and the window
424 + // id/kind identify freshly aggregated pools. React Navigation round-trips non-path params
425 + // through the URL as query strings, so a path here would bake in a permanently stale
426 + // timestamp and filter.
427 + SettingsUsageAccount: createNativeStackScreen({
428 + screen: UsageLimitAccountScreen,
429 + options: { ...SETTINGS_PAGE_OPTIONS, title: "Account" },
430 + }),
431 + SettingsOpenSourceLicenses: createNativeStackScreen({
432 + screen: SettingsOpenSourceLicensesRouteScreen,
433 + linking: "settings/open-source-licenses",
434 + options: {
435 + ...SETTINGS_PAGE_OPTIONS,
436 + title: "Open source licenses",
437 + },
438 + }),
439 + SettingsOpenSourceLicense: createNativeStackScreen({
440 + screen: SettingsOpenSourceLicenseRouteScreen,
441 + linking: "settings/open-source-licenses/:entryKey",
442 + options: {
443 + ...SETTINGS_PAGE_OPTIONS,
444 + title: "License notice",
445 + },
446 + }),
447 + SettingsUsage: createNativeStackScreen({
448 + screen: UsageRouteScreen,
449 + linking: "settings/usage",
450 + options: {
451 + ...SETTINGS_PAGE_OPTIONS,
452 + title: "Usage",
453 + },
454 + }),
455 + SettingsAuth: createNativeStackScreen({
456 + screen: SettingsAuthRouteScreen,
457 + linking: "settings/auth",
458 + options: { headerShown: false, presentation: "modal" },
459 + }),
460 + SettingsWaitlist: createNativeStackScreen({
461 + screen: SettingsAuthRouteScreen,
462 + linking: "settings/waitlist",
463 + options: { headerShown: false, presentation: "modal" },
464 + }),
465 +};
466
467 // A nested stack means a second UINavigationController with its own UINavigationBar, which breaks
468 // iOS 26's shared-header morphing between Home and Thread (each pair inside one bar morphs;
469 // across two bars the whole screen slides).
470 const THREAD_LINKING_PREFIX = "threads/:environmentId/:threadId";
471
474 -const WORKSPACE_OVERLAY_ROUTES = new Set([
475 - "PullRequestReview",
476 - "PullRequestInlineComment",
477 - "ConnectOnboarding",
478 - "Connections",
479 - "ConnectionsNew",
480 - "GitBranches",
481 - "GitCommit",
482 - "GitConfirm",
483 - "GitOverview",
484 - "NewTaskProject",
485 - "NewTaskFiles",
486 - "NewTaskFile",
487 - "NewTaskAttachment",
488 - "NewTaskThreadSettings",
489 - "AddProject",
490 - "AddProjectRepository",
491 - "AddProjectDestination",
492 - "AddProjectLocal",
493 - "AddProjectNew",
494 - "NewTaskEnvironment",
495 - "NewTaskBranch",
496 - "SettingsLegal",
497 - "SettingsSheet",
498 - "ThreadAgents",
499 - "ThreadBackgroundWork",
500 - "ThreadPullRequests",
501 - "ThreadQueue",
502 - "ThreadReviewComment",
503 - "ThreadDevicePreview",
504 - "ThreadBrowserPreview",
505 - "ThreadSettingsSheet",
506 -]);
507 -
472 function workspaceLocationFromState(state: NavigationState) {
509 - // Android opens Settings as a workspace page rather than an overlay, so the layout sees it.
510 - const routes = state.routes.filter(
511 - (route) =>
512 - !WORKSPACE_OVERLAY_ROUTES.has(route.name) ||
513 - (Platform.OS === "android" && route.name === "SettingsSheet"),
514 - );
473 + const routes = state.routes.filter((route) => !isWorkspaceOverlayRoute(route.name));
474 const effectiveState =
475 routes.length > 0 && routes.length !== state.routes.length
476 ? ({ ...state, routes, index: routes.length - 1 } as NavigationState)
@@ -543,6 +502,11 @@ function RootStackLayout(props: {
502 const path = getPathFromState(props.state, navigationPathConfig);
503 const pathname = path.startsWith("/") ? path : `/${path}`;
504 const workspaceLocation = workspaceLocationFromState(props.state);
505 + const settingsOpen = settingsOpenIn(
506 + props.state.routes
507 + .slice(0, props.state.index + 1)
508 + .filter((route) => !isWorkspaceOverlayRoute(route.name)),
509 + );
510 const draftRoute = props.state.routes.findLast((route) => route.name === "Thread");
511 const draftParams = (
512 draftRoute?.params as
@@ -579,20 +543,22 @@ function RootStackLayout(props: {
543 <HardwareKeyboardCommandProvider pathname={pathname}>
544 <ThreadOutboxDrainWorker />
545 <ShowcaseCaptureCoordinator pathname={pathname} />
582 - <ExistingThreadSettingsRouteProvider>
583 - <WorkspaceConnectionStatusProvider>
584 - <AndroidWorkspaceTabsProvider state={props.state}>
585 - <AdaptiveWorkspaceLayout
586 - pathname={workspaceLocation.pathname}
587 - workspaceRouteKey={workspaceLocation.routeKey}
588 - selectedPullRequestKey={selectedPullRequestKey(props.state)}
589 - >
590 - {props.children}
591 - <HardwareKeyboardCommandOverlay />
592 - </AdaptiveWorkspaceLayout>
593 - </AndroidWorkspaceTabsProvider>
594 - </WorkspaceConnectionStatusProvider>
595 - </ExistingThreadSettingsRouteProvider>
546 + <SettingsEnvironmentFilterProvider open={settingsOpen}>
547 + <ExistingThreadSettingsRouteProvider>
548 + <WorkspaceConnectionStatusProvider>
549 + <AndroidWorkspaceTabsProvider state={props.state}>
550 + <AdaptiveWorkspaceLayout
551 + pathname={workspaceLocation.pathname}
552 + workspaceRouteKey={workspaceLocation.routeKey}
553 + selectedPullRequestKey={selectedPullRequestKey(props.state)}
554 + >
555 + {props.children}
556 + <HardwareKeyboardCommandOverlay />
557 + </AdaptiveWorkspaceLayout>
558 + </AndroidWorkspaceTabsProvider>
559 + </WorkspaceConnectionStatusProvider>
560 + </ExistingThreadSettingsRouteProvider>
561 + </SettingsEnvironmentFilterProvider>
562 </HardwareKeyboardCommandProvider>
563 </NewTaskFlowProvider>
564 );
@@ -974,18 +940,7 @@ const RootStackConfig = createWorkspaceStackNavigator({
940 sheetGrabberVisible: true,
941 },
942 }),
977 - SettingsSheet: createNativeStackScreen({
978 - screen: SettingsSheetStack,
979 - layout: ({ children }) => <AndroidWorkspaceSettings>{children}</AndroidWorkspaceSettings>,
980 - linking: "settings",
981 - options: {
982 - ...NESTED_NAVIGATOR_OPTIONS,
983 - gestureEnabled: true,
984 - headerShown: false,
985 - presentation: "card",
986 - animation: "none",
987 - },
988 - }),
943 + ...SETTINGS_SCREENS,
944 SettingsLegal: createNativeStackScreen({
945 screen: SettingsLegalRouteScreen,
946 linking: "settings/legal",
@@ -1063,12 +1018,27 @@ function ScreenRenderFallback(props: RenderFailureProps & { readonly routeName:
1018 const exit = navigation.canGoBack()
1019 ? { label: "Go back", onPress: () => navigation.goBack() }
1020 : props.routeName === "Home"
1066 - ? { label: "Open settings", onPress: () => navigation.navigate("SettingsSheet") }
1021 + ? // Home itself failed, and the Settings list renders inside it; open a Settings page.
1022 + {
1023 + label: "Open settings",
1024 + onPress: () => openSettings(navigation, DEFAULT_SETTINGS_PAGE),
1025 + }
1026 : { label: "Return home", onPress: () => navigation.dispatch(StackActions.replace("Home")) };
1027
1028 return <RenderFailureView {...props} exit={exit} />;
1029 }
1030
1031 +registerPresentedRoutes(
1032 + Object.entries(RootStackConfig.config.screens ?? {}).flatMap(([name, screen]) => {
1033 + const options = (screen as { readonly options?: unknown }).options;
1034 + const presentation =
1035 + options && typeof options === "object"
1036 + ? (options as { readonly presentation?: string }).presentation
1037 + : undefined;
1038 + return presentation !== undefined && presentation !== "card" ? [name] : [];
1039 + }),
1040 +);
1041 +
1042 export const RootStack = RootStackConfig.with(function AdaptiveRootStack({ Navigator }) {
1043 const { width, height } = useWindowDimensions();
1044 const nativeMetrics = useNativeLayoutMetrics();
@@ -1078,7 +1048,7 @@ export const RootStack = RootStackConfig.with(function AdaptiveRootStack({ Navig
1048 <Navigator
1049 screenLayout={(props) => <GuardedScreenLayout {...props} />}
1050 screenOptions={({ route }) =>
1081 - Platform.OS === "android" && route.name !== "SettingsSheet"
1051 + Platform.OS === "android"
1052 ? { animation: androidWorkspaceDestinationAnimation(route.name, usesSplitView) }
1053 : {}
1054 }
apps/mobile/src/features/cloud/connectOnboardingNavigation.ts
+2 -2
@@ -6,8 +6,8 @@ import { appAtomRegistry } from "../../state/atom-registry";
6 import { clearConnectOnboardingRequest, connectOnboardingRequestAtom } from "./connectOnboarding";
7 import { isConnectOnboardingOptedOut } from "./connectOnboardingOptOut";
8
9 -// Sign-in happens inside the Settings sheet; give its session-state transition
10 -// a beat to settle before presenting another formSheet on top.
9 +// Sign-in happens in its own modal; give its session-state transition a beat to
10 +// settle before presenting another formSheet on top.
11 const PRESENT_ONBOARDING_DELAY_MS = 600;
12
13 /**
apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx
+6 -2
@@ -32,6 +32,9 @@ import { SymbolView } from "../../components/ui/AppSymbol";
32 import { hasCloudPublicConfig } from "../cloud/publicConfig";
33 import { CloudEnvironmentRows } from "./CloudEnvironmentRows";
34 import { splitEnvironmentSections } from "./environmentSections";
35 +import { openSettings } from "../settings/settings-navigation";
36 +import { leaveSettingsPage } from "../settings/settings-navigation";
37 +import { workspaceHasColumns } from "../workspace/workspace-selection-store";
38
39 type ConnectionsNewRouteParams = {
40 readonly mode?: string;
@@ -168,7 +171,8 @@ export function ConnectionsNewRouteScreen({
171 if (!navigation.canGoBack()) {
172 navigation.dispatch(StackActions.replace("Home"));
173 } else {
171 - navigation.goBack();
174 + // Added from the Settings list, the new environment shows on Environments.
175 + leaveSettingsPage(navigation, workspaceHasColumns(), "SettingsEnvironments");
176 }
177 }
178 };
@@ -390,7 +394,7 @@ function T3ConnectSection() {
394 label="Sign in to T3 Connect"
395 description="Reach your machines from anywhere, no network setup."
396 disabled={!isLoaded}
393 - onPress={() => navigation.navigate("SettingsSheet", { screen: "SettingsAuth" })}
397 + onPress={() => navigation.navigate("SettingsAuth")}
398 />
399 )}
400 </View>
apps/mobile/src/features/home/HomeRouteScreen.tsx
+9 -34
@@ -34,6 +34,8 @@ import { usePendingTaskListActions } from "./usePendingTaskListActions";
34 import { useThreadListActions } from "./useThreadListActions";
35 import { getConnectionAwareBrandHeaderOptions } from "./WorkspaceConnectionTitle";
36 import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
37 +import { openSettings } from "../settings/settings-navigation";
38 +import { useSelectWorkspaceTab } from "../workspace/useSelectWorkspaceTab";
39
40 export function HomeRouteScreen() {
41 const { width: windowWidth } = useWindowDimensions();
@@ -54,6 +56,7 @@ export function HomeRouteScreen() {
56 const { environments: workspaceEnvironments, state: catalogState } = useWorkspaceState();
57 const { savedConnectionsById } = useSavedRemoteConnections();
58 const navigation = useNavigation();
59 + const selectTab = useSelectWorkspaceTab();
60 const workspace = useWorkspaceTabs();
61 const [localSearchQuery, setLocalSearchQuery] = useState("");
62 const searchQuery =
@@ -187,11 +190,7 @@ export function HomeRouteScreen() {
190 <WorkspaceEmptyDetail
191 onAddConnection={
192 Platform.OS === "android" && !catalogState.hasConnections
190 - ? () =>
191 - navigation.navigate("SettingsSheet", {
192 - screen: "SettingsContent",
193 - params: { screen: "SettingsEnvironmentNew" },
194 - })
193 + ? () => openSettings(navigation, "SettingsEnvironmentNew")
194 : undefined
195 }
196 onStartNewTask={
@@ -217,11 +216,7 @@ export function HomeRouteScreen() {
216 ...getConnectionAwareBrandHeaderOptions({
217 headerWidth,
218 trailingItemCount: nativePrimaryColumn && deviceType === "pad" ? 2 : 1,
220 - onOpenEnvironments: () =>
221 - navigation.navigate("SettingsSheet", {
222 - screen: "SettingsContent",
223 - params: { screen: "SettingsEnvironments" },
224 - }),
219 + onOpenEnvironments: () => openSettings(navigation, "SettingsEnvironments"),
220 }),
221 headerShown: Platform.OS !== "android",
222 }}
@@ -235,18 +230,8 @@ export function HomeRouteScreen() {
230 selectedProjectKey={selectedProjectKey}
231 onEnvironmentChange={setSelectedEnvironmentId}
232 onProjectChange={setSelectedProjectKey}
238 - onOpenEnvironments={() =>
239 - navigation.navigate("SettingsSheet", {
240 - screen: "SettingsContent",
241 - params: { screen: "SettingsEnvironments" },
242 - })
243 - }
244 - onOpenSettings={() =>
245 - navigation.navigate("SettingsSheet", {
246 - screen: "SettingsContent",
247 - params: { screen: "Settings" },
248 - })
249 - }
233 + onOpenEnvironments={() => openSettings(navigation, "SettingsEnvironments")}
234 + onOpenSettings={() => selectTab("settings")}
235 onSearchQueryChange={setSearchQuery}
236 onStartNewTask={startNewTask}
237 />
@@ -254,12 +239,7 @@ export function HomeRouteScreen() {
239 <HomeScreen
240 catalogState={catalogState}
241 environments={environments}
257 - onAddConnection={() =>
258 - navigation.navigate("SettingsSheet", {
259 - screen: "SettingsContent",
260 - params: { screen: "SettingsEnvironmentNew" },
261 - })
262 - }
242 + onAddConnection={() => openSettings(navigation, "SettingsEnvironmentNew")}
243 onArchiveThread={archiveThread}
244 onDeleteThread={confirmDeleteThread}
245 onSettleThread={settleThread}
@@ -274,12 +254,7 @@ export function HomeRouteScreen() {
254 onRegenerateThreadTitle={regenerateThreadTitle}
255 onEnvironmentChange={setSelectedEnvironmentId}
256 onProjectChange={setSelectedProjectKey}
277 - onOpenSettings={() =>
278 - navigation.navigate("SettingsSheet", {
279 - screen: "SettingsContent",
280 - params: { screen: "Settings" },
281 - })
282 - }
257 + onOpenSettings={() => selectTab("settings")}
258 onSearchQueryChange={setSearchQuery}
259 onSelectThread={handleSelectThread}
260 onSelectPendingTask={openPendingTask}
apps/mobile/src/features/keyboard/CommandPalette.tsx
+10 -30
@@ -60,6 +60,8 @@ import {
60 import { parseActiveThreadPath, type HardwareKeyboardCommand } from "./hardwareKeyboardCommands";
61 import { threadJumpIndex } from "./threadKeyboardShortcuts";
62 import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
63 +import { openSettings } from "../settings/settings-navigation";
64 +import { useSelectWorkspaceTab } from "../workspace/useSelectWorkspaceTab";
65
66 const PALETTE_COMMANDS: ReadonlyArray<HardwareKeyboardCommand> = [
67 "commandPalette",
@@ -208,6 +210,7 @@ export function CommandPalette(props: {
210 readonly onCommand: (command: HardwareKeyboardCommand) => void;
211 }) {
212 const navigation = useNavigation();
213 + const selectTab = useSelectWorkspaceTab();
214 const { themeVariables } = useAppearancePreferences();
215 const { selectThread, selectThreadRoute } = useAdaptiveWorkspaceLayout();
216 const runCommand = props.onCommand;
@@ -269,66 +272,42 @@ export function CommandPalette(props: {
272 kind: "action",
273 title: "Open settings",
274 searchTerms: ["preferences", "configuration"],
272 - run: () =>
273 - navigation.navigate("SettingsSheet", {
274 - screen: "SettingsContent",
275 - params: { screen: "Settings" },
276 - }),
275 + run: () => selectTab("settings"),
276 },
277 {
278 key: "appearance",
279 kind: "action",
280 title: "Appearance",
281 searchTerms: ["theme", "colors", "dark", "light"],
283 - run: () =>
284 - navigation.navigate("SettingsSheet", {
285 - screen: "SettingsContent",
286 - params: { screen: "SettingsAppearance" },
287 - }),
282 + run: () => openSettings(navigation, "SettingsAppearance"),
283 },
284 {
285 key: "environments",
286 kind: "action",
287 title: "Manage environments",
288 searchTerms: ["connections", "server", "remote"],
294 - run: () =>
295 - navigation.navigate("SettingsSheet", {
296 - screen: "SettingsContent",
297 - params: { screen: "SettingsEnvironments" },
298 - }),
289 + run: () => openSettings(navigation, "SettingsEnvironments"),
290 },
291 {
292 key: "scheduledTasks",
293 kind: "action",
294 title: "Scheduled tasks",
295 searchTerms: ["schedule", "automations", "recurring"],
305 - run: () =>
306 - navigation.navigate("SettingsSheet", {
307 - screen: "SettingsContent",
308 - params: { screen: "SettingsScheduledTasks" },
309 - }),
296 + run: () => openSettings(navigation, "SettingsScheduledTasks"),
297 },
298 {
299 key: "usage",
300 kind: "action",
301 title: "Usage",
302 searchTerms: ["limits", "accounts", "quota"],
316 - run: () =>
317 - navigation.navigate("SettingsSheet", {
318 - screen: "SettingsContent",
319 - params: { screen: "SettingsUsage" },
320 - }),
303 + run: () => openSettings(navigation, "SettingsUsage"),
304 },
305 {
306 key: "archive",
307 kind: "action",
308 title: "Archived threads",
309 searchTerms: ["restore", "history"],
327 - run: () =>
328 - navigation.navigate("SettingsSheet", {
329 - screen: "SettingsContent",
330 - params: { screen: "SettingsArchive" },
331 - }),
310 + run: () => openSettings(navigation, "SettingsArchive"),
311 },
312 ];
313 const projectByKey = new Map(
@@ -423,6 +402,7 @@ export function CommandPalette(props: {
402 );
403 return [...actions, ...projectItems, ...threadItems];
404 }, [
405 + selectTab,
406 activeThread,
407 activeThreadRef,
408 environments.length,
apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx
+8
@@ -1,4 +1,5 @@
1 import { StackActions, useNavigation } from "@react-navigation/native";
2 +import { Platform } from "react-native";
3 import { resolveThreadReferenceCopyTarget } from "@t3tools/client-runtime/thread-reference";
4 import {
5 createContext,
@@ -14,6 +15,10 @@ import {
15 } from "react";
16
17 import { tryCopyTextWithHaptic } from "../../lib/copyTextWithHaptic";
18 +import {
19 + firstWorkspaceDetailOpen,
20 + workspaceHasColumns,
21 +} from "../workspace/workspace-selection-store";
22 import { T3KeyboardCommands } from "../../native/T3KeyboardCommands";
23 import { useThreadShell } from "../../state/entities";
24 import type { GitActionProgress } from "../../state/use-vcs-action-state";
@@ -152,6 +157,9 @@ export function HardwareKeyboardCommandProvider({
157 return;
158 }
159 if (command === "back") {
160 + // Beside a visible list, the first detail page has nothing to go back to.
161 + if (Platform.OS === "ios" && workspaceHasColumns() && firstWorkspaceDetailOpen(navigation))
162 + return;
163 if (navigation.canGoBack()) {
164 navigation.goBack();
165 } else {
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+67 -14
@@ -1,3 +1,4 @@
1 +import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
2 import { AdaptiveWorkspaceContext, useAdaptiveWorkspaceLayout } from "./adaptive-workspace-context";
3 import { createDeferredNavigation } from "./deferred-navigation";
4 import { uuidv4 } from "../../lib/uuid";
@@ -43,6 +44,7 @@ import {
44 type VerticalHinge,
45 deriveWorkspacePaneLayout,
46 isPrimarySidebarPinned,
47 + isWorkspaceListPath,
48 type WorkspaceAuxiliaryPaneRole,
49 } from "../../lib/layout";
50 import {
@@ -91,6 +93,16 @@ import {
93 import { useNativeLayoutMetrics } from "../../native/native-layout-metrics";
94 import { AndroidHingeObserver } from "../../native/AndroidHingeObserver";
95 import { WindowHingeContext } from "../../native/window-hinge-context";
96 +import { useAndroidWorkspaceRoot } from "../workspace/AndroidWorkspaceTabsProvider";
97 +import { openSettings } from "../settings/settings-navigation";
98 +import { dispatchRootStackReset, rootStackState } from "../../lib/root-stack-reset";
99 +import {
100 + currentWorkspaceSelections,
101 + workspaceSelectionCheck,
102 +} from "../workspace/workspace-selection-store";
103 +import { workspaceTabNavigationState } from "../workspace/workspace-tab-navigation";
104 +import type { WorkspaceTab } from "../workspace/workspace-tabs-state";
105 +import { workspaceRoutesOf } from "./workspace-overlay-routes";
106
107 export { useAdaptiveWorkspaceLayout };
108
@@ -207,9 +219,10 @@ function AdaptiveWorkspaceLayoutContent(
219 const pathname = props.pathname;
220 const workspace = useWorkspaceTabs();
221 // Settings and Usage occupy the workspace rather than a list/detail pair.
222 + const androidSettingsOpen = useAndroidWorkspaceRoot()?.settingsOpen ?? false;
223 + const safeAreaInsets = useSafeAreaInsets();
224 const workspacePage =
211 - Platform.OS === "android" &&
212 - (pathname.startsWith("/settings") || workspace?.state.selectedTab === "usage");
225 + Platform.OS === "android" && (androidSettingsOpen || workspace?.state.selectedTab === "usage");
226 const navigation = useNavigation();
227 const activeRoleOwner = useRef<symbol | null>(null);
228 const [primarySidebarPreferredVisible, setPrimarySidebarPreferredVisible] = useState(true);
@@ -233,10 +246,13 @@ function AdaptiveWorkspaceLayoutContent(
246 () => deriveLayout({ width: viewportWidth, height, nativeMetrics, nativeWorkspace }),
247 [height, viewportWidth, nativeMetrics, nativeWorkspace],
248 );
249 + // The overlay sidebar closes when a page opens from it, and stays open on a list or on the
250 + // page a tab switch opened (`keepOpenFor`, set by that switch).
251 const [overlaySidebar, setOverlaySidebar] = useState({
252 active: baseLayout.primarySidebarOverlaysContent,
253 pathname,
239 - visible: pathname === "/",
254 + visible: isWorkspaceListPath(pathname),
255 + keepOpenFor: null as string | null,
256 });
257 if (
258 overlaySidebar.active !== baseLayout.primarySidebarOverlaysContent ||
@@ -245,7 +261,11 @@ function AdaptiveWorkspaceLayoutContent(
261 setOverlaySidebar({
262 active: baseLayout.primarySidebarOverlaysContent,
263 pathname,
248 - visible: pathname === "/",
264 + visible:
265 + isWorkspaceListPath(pathname) ||
266 + (overlaySidebar.keepOpenFor !== null &&
267 + overlaySidebar.keepOpenFor === props.workspaceRouteKey),
268 + keepOpenFor: null,
269 });
270 }
271 const preferredSidebarVisible = baseLayout.primarySidebarOverlaysContent
@@ -457,12 +477,35 @@ function AdaptiveWorkspaceLayoutContent(
477 }
478 setSupplementaryPanePreferredWidth(nextWidth);
479 };
460 - const handleOpenSettings = () => {
461 - navigation.navigate("SettingsSheet", {
462 - screen: "SettingsContent",
463 - params: { screen: "Settings" },
464 - });
480 + /**
481 + * The one way to open a workspace tab: replaces the workspace with the tab's list and, when the
482 + * window has columns, the page it last showed, keeping any sheet on top. An overlay sidebar
483 + * stays open over that page.
484 + */
485 + const openWorkspaceTab = (
486 + tab: WorkspaceTab | "settings",
487 + options?: { readonly columns?: boolean },
488 + ) => {
489 + const state = rootStackState(navigation);
490 + if (!state) return;
491 + const { workspace, overlays } = workspaceRoutesOf(state.routes.slice(0, state.index + 1));
492 + const next = workspaceTabNavigationState(
493 + { ...state, routes: workspace },
494 + tab,
495 + currentWorkspaceSelections(),
496 + {
497 + columns: Platform.OS === "ios" && (options?.columns ?? layout.usesSplitView),
498 + check: workspaceSelectionCheck,
499 + overlays,
500 + },
501 + );
502 + if (layout.primarySidebarOverlaysContent) {
503 + const opened = next.routes.at(-1 - overlays.length)?.key ?? null;
504 + setOverlaySidebar((current) => ({ ...current, visible: true, keepOpenFor: opened }));
505 + }
506 + dispatchRootStackReset(navigation, state, next);
507 };
508 + const handleOpenSettings = () => openWorkspaceTab("settings");
509
510 const selectAndroidWorkspace = useAndroidWorkspaceSelection();
511 const deferredThreadSelection = useMemo(() => createDeferredNavigation(), []);
@@ -521,6 +564,8 @@ function AdaptiveWorkspaceLayoutContent(
564 }
565
566 const projects = useProjects();
567 + const compactAndroidSettings =
568 + Platform.OS === "android" && androidSettingsOpen && !layout.usesSplitView;
569 const handleStartNewTask = () => {
570 const thread = appAtomRegistry
571 .get(environmentThreadShells.navigationThreadShellsAtom)
@@ -555,10 +600,7 @@ function AdaptiveWorkspaceLayoutContent(
600 // Minted here (root stack navigation) so the sidebar pane stays free of
601 // navigation hooks — on iOS it renders inside an independent nav tree.
602 const handleOpenEnvironmentSettings = () => {
558 - navigation.navigate("SettingsSheet", {
559 - screen: "SettingsContent",
560 - params: { screen: "SettingsEnvironments" },
561 - });
603 + openSettings(navigation, "SettingsEnvironments");
604 };
605
606 const handleOpenThreadPullRequests = useOpenThreadPullRequests();
@@ -771,6 +813,7 @@ function AdaptiveWorkspaceLayoutContent(
813 toggleAuxiliaryPane,
814 togglePrimarySidebar,
815 setPrimarySidebarVisible,
816 + openWorkspaceTab,
817 setAuxiliaryPaneWidth,
818 composerKeyboardActive,
819 setComposerEditing,
@@ -891,7 +934,17 @@ function AdaptiveWorkspaceLayoutContent(
934 Platform.OS === "android" && layout.usesSplitView ? contentTargetWidth : null
935 }
936 >
894 - {props.children}
937 + {/* Compact Settings keeps the bottom navigation under all of its pages. */}
938 + <SafeAreaInsetsContext
939 + value={
940 + compactAndroidSettings ? { ...safeAreaInsets, bottom: 0 } : safeAreaInsets
941 + }
942 + >
943 + <View className="flex-1">{props.children}</View>
944 + </SafeAreaInsetsContext>
945 + {compactAndroidSettings ? (
946 + <AndroidWorkspaceNavigation onNewThread={handleStartNewTask} />
947 + ) : null}
948 </WorkspaceSettledContentWidthContext>
949 </WorkspaceContentWidthContext>
950 </View>
apps/mobile/src/features/layout/WorkspaceEmptyDetail.tsx
+16 -10
@@ -8,13 +8,13 @@ import { EmptyState } from "../../components/ui/EmptyState";
8 import type { WorkspaceTab } from "../workspace/workspace-tabs-state";
9
10 export function WorkspaceEmptyDetail(props: {
11 - readonly tab?: WorkspaceTab;
11 + readonly tab?: WorkspaceTab | "settings";
12 readonly onStartNewTask?: () => void;
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" />;
16 + const settings = props.tab === "settings";
17 + if (props.tab === "usage") return <View className="flex-1 bg-screen" />;
18 return (
19 <View
20 className={
@@ -49,16 +49,22 @@ export function WorkspaceEmptyDetail(props: {
49 type="hierarchical"
50 />
51 <Text className="text-center text-xl font-t3-bold">
52 - {pullRequests ? "Select a pull request" : "Select a thread"}
52 + {settings
53 + ? "Select a setting"
54 + : pullRequests
55 + ? "Select a pull request"
56 + : "Select a thread"}
57 </Text>
58 <Text className="text-center text-base text-foreground-muted">
55 - {pullRequests
56 - ? "Choose a pull request from the sidebar to review it."
57 - : Platform.OS === "android"
58 - ? "Choose a thread from the sidebar or start a new thread."
59 - : "Choose a thread from the sidebar or start a new task."}
59 + {settings
60 + ? "Choose a page from the sidebar."
61 + : pullRequests
62 + ? "Choose a pull request from the sidebar to review it."
63 + : Platform.OS === "android"
64 + ? "Choose a thread from the sidebar or start a new thread."
65 + : "Choose a thread from the sidebar or start a new task."}
66 </Text>
61 - {props.onStartNewTask && !pullRequests ? (
67 + {props.onStartNewTask && !pullRequests && !settings ? (
68 Platform.OS === "android" ? (
69 <NewThreadButton extended className="mt-2" onPress={props.onStartNewTask} />
70 ) : (
apps/mobile/src/features/layout/adaptive-workspace-context.ts
+7
@@ -1,3 +1,4 @@
1 +import type { WorkspaceTab } from "../workspace/workspace-tabs-state";
2 import { createContext, use, type ReactNode } from "react";
3 import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
4 import {
@@ -26,6 +27,11 @@ interface AdaptiveWorkspaceContextValue {
27 readonly toggleAuxiliaryPane: () => void;
28 readonly togglePrimarySidebar: () => void;
29 readonly setPrimarySidebarVisible: (visible: boolean) => void;
30 + /** Opens a workspace tab with its list and, with columns, the page it last showed. */
31 + readonly openWorkspaceTab: (
32 + tab: WorkspaceTab | "settings",
33 + options?: { readonly columns?: boolean },
34 + ) => void;
35 readonly setAuxiliaryPaneWidth: (width: number) => void;
36 /**
37 * Android split view while the thread composer has the soft keyboard: the
@@ -63,6 +69,7 @@ export const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceContextVa
69 toggleAuxiliaryPane: () => undefined,
70 togglePrimarySidebar: () => undefined,
71 setPrimarySidebarVisible: () => undefined,
72 + openWorkspaceTab: () => undefined,
73 setAuxiliaryPaneWidth: () => undefined,
74 composerKeyboardActive: false,
75 setComposerEditing: () => undefined,
apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
+60 -12
@@ -27,6 +27,9 @@ import { scopedThreadKey } from "../../lib/scopedEntities";
27 import { WorkspaceTabsProvider, useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
28 import { WorkspaceNativeTabs } from "../workspace/WorkspaceNativeTabs.ios";
29 import { workspaceUsesColumns } from "../workspace/workspace-tabs-state";
30 +import { isSettingsRoute, settingsOpenIn } from "../settings/settings-navigation";
31 +import { workspaceRoutesOf } from "./workspace-overlay-routes";
32 +import { useWorkspaceSidebarHeaderItem } from "./useWorkspaceSidebarHeaderItem";
33 import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
34
35 import { useAdaptiveWorkspaceLayout } from "./AdaptiveWorkspaceLayout";
@@ -55,6 +58,8 @@ import {
58 NativePrimaryColumnContext,
59 NativeWorkspaceInspectorContext,
60 NativeWorkspaceModeContext,
61 + WorkspaceSlotOptionsContext,
62 + slotScreenOptions,
63 } from "../../native/v5-workspace-context";
64
65 type ViewProps = ComponentProps<typeof NativeStackView>;
@@ -66,6 +71,16 @@ const isPullRequestRoute = (route: Route) =>
71 route.name === "PullRequestFile" ||
72 route.name === "PullRequestFiles";
73
74 +/** Only these screens follow the sidebar's state; a thread's header draws its own toggle. */
75 +function SidebarToggleHeader(props: ComponentProps<typeof V5StackHeader>) {
76 + const sidebarItem = useWorkspaceSidebarHeaderItem();
77 + const options = {
78 + ...props.options,
79 + unstable_headerLeftItems: () => [sidebarItem],
80 + } as AppNativeStackNavigationOptions as typeof props.options;
81 + return <V5StackHeader {...props} options={options} />;
82 +}
83 +
84 function ColumnScreen(props: {
85 readonly descriptor: Descriptor;
86 readonly primary?: boolean;
@@ -75,9 +90,19 @@ function ColumnScreen(props: {
90 readonly onDismiss: (routeKey: string, native: boolean) => void;
91 readonly onAppearance: (type: "willAppear" | "didAppear" | "willDisappear", key: string) => void;
92 readonly onCompose?: () => void;
93 + /** Settings pages don't draw their own sidebar toggle, unlike threads and pull requests. */
94 + readonly sidebarToggle?: boolean;
95 readonly navigation: ViewProps["navigation"];
96 }) {
97 const { descriptor } = props;
98 + // Options a screen set inside this workspace tab slot, over its route's.
99 + const options = slotScreenOptions(
100 + use(WorkspaceSlotOptionsContext),
101 + descriptor.route.key,
102 + descriptor.options,
103 + );
104 + const Header =
105 + props.sidebarToggle && !options.unstable_headerLeftItems ? SidebarToggleHeader : V5StackHeader;
106 const [presented, setPresented] = useState(false);
107 const primaryColumn = useMemo(
108 () =>
@@ -118,8 +143,8 @@ function ColumnScreen(props: {
143 >
144 <NavigationContext value={descriptor.navigation}>
145 <NavigationRouteContext value={descriptor.route}>
121 - <V5StackHeader
122 - options={descriptor.options}
146 + <Header
147 + options={options}
148 canGoBack={!props.primary}
149 column={props.primary ? "primary" : "detail"}
150 onCompose={
@@ -133,7 +158,7 @@ function ColumnScreen(props: {
158 <ColumnContent
159 primary={props.primary}
160 insetHorizontally={
136 - (descriptor.options as AppNativeStackNavigationOptions).nativeContentInsetHorizontally
161 + (options as AppNativeStackNavigationOptions).nativeContentInsetHorizontally
162 }
163 >
164 <NativePrimaryColumnContext value={primaryColumn}>
@@ -156,6 +181,7 @@ function WorkspaceColumns(
181 setPrimarySidebarVisible,
182 toggleAuxiliaryPane,
183 startNewTask,
184 + openWorkspaceTab,
185 } = useAdaptiveWorkspaceLayout();
186 const deviceType = useDeviceType();
187 // Split screens must remain mounted while UIKit animates a detached route away.
@@ -186,12 +212,16 @@ function WorkspaceColumns(
212 });
213 }
214
189 - const selectedTab = useWorkspaceTabs()?.state.selectedTab;
215 + const workspaceTabs = useWorkspaceTabs();
216 + const selectedTab = workspaceTabs?.state.selectedTab;
217 + const settingsOpen = workspaceTabs?.settingsOpen ?? false;
218 const openNewTask = startNewTask;
219 // The cover detail rail needs room for thread tools above the fixed tabs.
220 // The unfolded Duo keeps compose in its detail bar.
221 const detailCompose =
194 - deviceType === "duo-unfolded" && selectedTab !== "pullRequests" ? openNewTask : undefined;
222 + deviceType === "duo-unfolded" && selectedTab !== "pullRequests" && !settingsOpen
223 + ? openNewTask
224 + : undefined;
225 const inspector = use(NativeWorkspaceInspectorContext);
226 const hostRef = useRef<SplitHostCommands>(null);
227 const activeDetailKey = props.detail.at(-1)?.key;
@@ -274,6 +304,17 @@ function WorkspaceColumns(
304 }}
305 onExpand={() => {
306 collapsed.current = false;
307 + // Native callbacks can outlive the render that created them, so decide from the live
308 + // router state. An expanded split has columns, so its tab gets a page beside the list.
309 + const live = props.navigation.getState();
310 + const { workspace } = workspaceRoutesOf(live.routes.slice(0, live.index + 1));
311 + if (workspace.some((route) => route.name !== "Home" && route.name !== "Settings")) return;
312 + const tab = workspace.some((route) => route.name === "Settings")
313 + ? "settings"
314 + : (["threads", "pullRequests", "usage"] as const).find((candidate) =>
315 + workspaceTabs?.isTabActive(candidate),
316 + );
317 + openWorkspaceTab(tab ?? "threads", { columns: true });
318 }}
319 preferredDisplayMode={
320 // UIKit applies the mode as a collapsed split expands, before the new width reaches JS, so a
@@ -341,7 +382,7 @@ function WorkspaceColumns(
382 />
383 <ColumnContent>
384 <WorkspaceEmptyDetail
344 - tab={selectedTab}
385 + tab={settingsOpen ? "settings" : selectedTab}
386 onStartNewTask={
387 // Duo provides compose in the detail bar; iPad uses the empty-state action.
388 detailCompose ? undefined : openNewTask
@@ -355,6 +396,11 @@ function WorkspaceColumns(
396 <ColumnScreen
397 key={route.key}
398 descriptor={descriptor}
399 + sidebarToggle={
400 + layout.usesSplitView &&
401 + props.detail[0]?.key === route.key &&
402 + isSettingsRoute(route.name)
403 + }
404 attached={props.detail.some((current) => current.key === route.key)}
405 onDismiss={handleNativeDismiss}
406 onAppearance={followCollapsedSplit}
@@ -397,7 +443,7 @@ function WorkspaceStackView(props: ViewProps & { readonly nativeColumns: boolean
443 const descriptors = props.descriptors;
444 const baseRoute = { key: `${props.state.key}:workspace`, name: "Workspace" };
445 const visibleRoute = projection.detail.at(-1) ?? primaryRoute;
400 - const workspacePage = !workspaceUsesColumns(workspace.state.selectedTab, visibleRoute.name);
446 + const workspacePage = !workspaceUsesColumns(workspace.state.selectedTab, workspace.settingsOpen);
447 const baseDescriptor: Descriptor = {
448 ...primaryDescriptor,
449 navigation: props.descriptors[visibleRoute.key]!.navigation,
@@ -414,10 +460,6 @@ function WorkspaceStackView(props: ViewProps & { readonly nativeColumns: boolean
460 !layout.usesSplitView &&
461 (metrics?.verticalBarEdge ?? "none") === "none"
462 }
417 - onSelect={() => {
418 - if (props.state.index > 0)
419 - props.navigation.dispatch({ type: "POP_TO_TOP", target: props.state.key });
420 - }}
463 >
464 {props.nativeColumns && !workspacePage ? (
465 <WorkspaceColumns
@@ -518,10 +560,16 @@ function WorkspaceStackNavigator({
560 UNSTABLE_router,
561 });
562 if (!nativeWorkspaceColumnsReady) return null;
563 + const settingsOpen = settingsOpenIn(
564 + state.routes.slice(0, state.index + 1).filter((route) => {
565 + const presentation = descriptors[route.key]?.options.presentation;
566 + return presentation === undefined || presentation === "card";
567 + }),
568 + );
569 return (
570 <NativeWorkspaceModeContext value={usesNativeWorkspaceColumns}>
571 <NavigationContent>
524 - <WorkspaceTabsProvider settingsOpen={state.routes[state.index]?.name === "SettingsSheet"}>
572 + <WorkspaceTabsProvider settingsOpen={settingsOpen}>
573 <WorkspaceStackView
574 nativeColumns={usesNativeWorkspaceColumns}
575 {...rest}
apps/mobile/src/features/layout/workspace-overlay-routes.ts new
+61
@@ -0,0 +1,61 @@
1 +/**
2 + * Root routes listed as presented over the workspace, including ones that are plain cards on
3 + * Android but still sit above the workspace there.
4 + */
5 +const LISTED_OVERLAY_ROUTES: ReadonlySet<string> = new Set([
6 + "PullRequestReview",
7 + "PullRequestInlineComment",
8 + "ConnectOnboarding",
9 + "Connections",
10 + "ConnectionsNew",
11 + "GitBranches",
12 + "GitCommit",
13 + "GitConfirm",
14 + "GitOverview",
15 + "NewTaskProject",
16 + "NewTaskFiles",
17 + "NewTaskFile",
18 + "NewTaskAttachment",
19 + "NewTaskThreadSettings",
20 + "AddProject",
21 + "AddProjectRepository",
22 + "AddProjectDestination",
23 + "AddProjectLocal",
24 + "AddProjectNew",
25 + "NewTaskEnvironment",
26 + "NewTaskBranch",
27 + "SettingsLegal",
28 + "SettingsAuth",
29 + "SettingsWaitlist",
30 + "ThreadAgents",
31 + "ThreadBackgroundWork",
32 + "ThreadPullRequests",
33 + "ThreadQueue",
34 + "ThreadReviewComment",
35 + "ThreadDevicePreview",
36 + "ThreadBrowserPreview",
37 + "ThreadSettingsSheet",
38 +]);
39 +
40 +// Every route whose `presentation` is a sheet or modal, read from the root stack's config once.
41 +let presentedRoutes: ReadonlySet<string> = new Set();
42 +
43 +export function registerPresentedRoutes(names: Iterable<string>) {
44 + presentedRoutes = new Set(names);
45 +}
46 +
47 +/** Whether a root route is presented over the workspace (a sheet or modal). */
48 +export function isWorkspaceOverlayRoute(name: string) {
49 + return LISTED_OVERLAY_ROUTES.has(name) || presentedRoutes.has(name);
50 +}
51 +
52 +/** The routes that make up the workspace, up to the first sheet or modal above it. */
53 +export function workspaceRoutesOf<Route extends { readonly name: string }>(
54 + routes: readonly Route[],
55 +) {
56 + const firstOverlay = routes.findIndex((route) => isWorkspaceOverlayRoute(route.name));
57 + return {
58 + workspace: firstOverlay < 0 ? routes : routes.slice(0, firstOverlay),
59 + overlays: firstOverlay < 0 ? [] : routes.slice(firstOverlay),
60 + };
61 +}
apps/mobile/src/features/pull-requests/PullRequestToolbar.android.tsx
+2 -6
@@ -9,6 +9,7 @@ import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands
9 import { WorkspaceListToolbarRow } from "../workspace/WorkspaceListToolbarRow";
10 import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
11 import { usePullRequestFilterMenu } from "./PullRequestFilterMenuContext";
12 +import { openSettings } from "../settings/settings-navigation";
13
14 /** PR search shares the thread list's Android header row. */
15 export function PullRequestToolbar(props: { readonly onRequestVisibility?: () => void }) {
@@ -71,12 +72,7 @@ export function PullRequestToolbar(props: { readonly onRequestVisibility?: () =>
72 onOpenSearch={openSearch}
73 searchAccessibilityLabel="Search pull requests"
74 titleAccessibilityLabel="T3 Code, Pull requests"
74 - onOpenEnvironments={() =>
75 - navigation.navigate("SettingsSheet", {
76 - screen: "SettingsContent",
77 - params: { screen: "SettingsEnvironments" },
78 - })
79 - }
75 + onOpenEnvironments={() => openSettings(navigation, "SettingsEnvironments")}
76 filter={
77 filters ? (
78 <AndroidAnchoredMenu
apps/mobile/src/features/settings/SettingsAuthRouteScreen.tsx
+4 -4
@@ -4,7 +4,7 @@ import {
4 type UserProfileCustomPage,
5 UserProfileView,
6 } from "@clerk/expo/native-components";
7 -import { StackActions, useNavigation } from "@react-navigation/native";
7 +import { useNavigation } from "@react-navigation/native";
8 import { useEffect, useLayoutEffect, useState } from "react";
9 import { View } from "react-native";
10
@@ -25,7 +25,7 @@ export function SettingsAuthRouteScreen() {
25
26 useLayoutEffect(() => {
27 if (!hasCloudPublicConfig()) {
28 - navigation.dispatch(StackActions.replace("SettingsContent"));
28 + navigation.goBack();
29 }
30 }, [navigation]);
31
@@ -35,7 +35,7 @@ export function SettingsAuthRouteScreen() {
35 function ConfiguredSettingsAuthRouteScreen() {
36 const { isLoaded, isSignedIn } = useAuth({ treatPendingAsSignedOut: false });
37 const navigation = useNavigation();
38 - const handleHostBack = () => navigation.dispatch(StackActions.popTo("SettingsContent"));
38 + const handleHostBack = () => navigation.goBack();
39 // Once signed in, stay on the profile view so signing out pops back instead of
40 // flashing the sign-in form.
41 const [hasBeenSignedIn, setHasBeenSignedIn] = useState(isSignedIn === true);
@@ -43,7 +43,7 @@ function ConfiguredSettingsAuthRouteScreen() {
43
44 useEffect(() => {
45 if (hasBeenSignedIn && isLoaded && isSignedIn === false) {
46 - navigation.dispatch(StackActions.popTo("SettingsContent"));
46 + navigation.goBack();
47 }
48 }, [hasBeenSignedIn, isLoaded, isSignedIn, navigation]);
49
apps/mobile/src/features/settings/SettingsEnvironmentDetailRouteScreen.tsx
+1 -7
@@ -202,13 +202,7 @@ function EnvironmentDetail({ environmentId }: { readonly environmentId: Environm
202 environmentId={environmentId}
203 connected={connected}
204 onAddRoute={() =>
205 - navigation.navigate("SettingsSheet", {
206 - screen: "SettingsContent",
207 - params: {
208 - screen: "SettingsEnvironmentNew",
209 - params: { routeFor: environmentId },
210 - },
211 - })
205 + navigation.navigate("SettingsEnvironmentNew", { routeFor: environmentId })
206 }
207 />
208 {outdated ? (
apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx
+2 -9
@@ -65,10 +65,7 @@ export function SettingsEnvironmentsRouteScreen() {
65 }
66
67 const openEnvironment = (environmentId: EnvironmentId) => {
68 - navigation.navigate("SettingsSheet", {
69 - screen: "SettingsContent",
70 - params: { screen: "SettingsEnvironmentDetail", params: { environmentId } },
71 - });
68 + navigation.navigate("SettingsEnvironmentDetail", { environmentId });
69 };
70 const handleUpdateEnvironment = (
71 environmentId: EnvironmentId,
@@ -127,11 +124,7 @@ export function SettingsEnvironmentsRouteScreen() {
124 accessibilityLabel: "Add environment",
125 icon: "plus",
126 tintColor: headerIconColor,
130 - onPress: () =>
131 - navigation.navigate("SettingsSheet", {
132 - screen: "SettingsContent",
133 - params: { screen: "SettingsEnvironmentNew" },
134 - }),
127 + onPress: () => navigation.navigate("SettingsEnvironmentNew"),
128 },
129 ]}
130 >
apps/mobile/src/features/settings/SettingsNotificationsRouteScreen.tsx
+1 -1
@@ -209,7 +209,7 @@ function ConfiguredSettingsNotificationsRouteScreen() {
209 { text: "Cancel", style: "cancel" },
210 {
211 text: "Continue",
212 - onPress: () => navigation.navigate("SettingsSheet", { screen: "SettingsAuth" }),
212 + onPress: () => navigation.navigate("SettingsAuth"),
213 },
214 ],
215 );
apps/mobile/src/features/settings/SettingsOpenSourceLicensesRouteScreen.tsx
+2 -6
@@ -69,12 +69,8 @@ export function SettingsOpenSourceLicensesRouteScreen() {
69 <LicenseRow
70 entry={item}
71 onPress={() =>
72 - navigation.navigate("SettingsSheet", {
73 - screen: "SettingsContent",
74 - params: {
75 - screen: "SettingsOpenSourceLicense",
76 - params: { entryKey: thirdPartyLicenseEntryKey(item) },
77 - },
72 + navigation.navigate("SettingsOpenSourceLicense", {
73 + entryKey: thirdPartyLicenseEntryKey(item),
74 })
75 }
76 />
apps/mobile/src/features/settings/SettingsProjectOverviewRouteScreen.tsx
+5 -1
@@ -39,6 +39,9 @@ import {
39 SettingsEnvironmentFilterHeader,
40 } from "./components/SettingsEnvironmentFilterHeader";
41 import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-environment-filter";
42 +import { leaveSettingsPage } from "./settings-navigation";
43 +import { workspaceHasColumns } from "../workspace/workspace-selection-store";
44 +import { DEFAULT_SETTINGS_PAGE } from "../workspace/workspace-tab-navigation";
45
46 export function SettingsProjectOverviewRouteScreen() {
47 const insets = useSafeAreaInsets();
@@ -63,7 +66,8 @@ export function SettingsProjectOverviewRouteScreen() {
66 // The filter can move to another project while a removal is still running.
67 const finishProjectRemoval = (projectKey: string | null) => {
68 if (latestProjectKey.current !== projectKey) return;
66 - if (navigation.isFocused()) navigation.goBack();
69 + if (navigation.isFocused())
70 + leaveSettingsPage(navigation, workspaceHasColumns(), DEFAULT_SETTINGS_PAGE);
71 // Otherwise the filter keeps pointing at the removed project as an unavailable one.
72 selectProject(null);
73 };
apps/mobile/src/features/settings/SettingsRouteScreen.tsx
+35 -17
@@ -14,7 +14,8 @@ import {
14 ScreenScrollViewBottomInset,
15 } from "../../components/ui/ScreenScrollView";
16 import { useAuth, useUser } from "@clerk/expo";
17 -import { useNavigation } from "@react-navigation/native";
17 +import { useNavigation, useNavigationState } from "@react-navigation/native";
18 +import { use, useMemo } from "react";
19 import { Platform, View } from "react-native";
20 import { useWorkspaceSurface } from "../workspace/useWorkspaceSurface";
21 import { useDeviceType } from "../../native/native-layout-metrics";
@@ -26,18 +27,27 @@ import { hasCloudPublicConfig } from "../cloud/publicConfig";
27 import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
28 import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
29 import { SettingsRow } from "./components/SettingsRow";
29 -import { SettingsSection } from "./components/SettingsSection";
30 +import { SettingsSection, SettingsSidebarContext } from "./components/SettingsSection";
31 import { SettingsScreen } from "./components/SettingsScreen";
32 import {
33 AndroidSettingsEnvironmentFilter,
34 SettingsEnvironmentFilterHeader,
35 } from "./components/SettingsEnvironmentFilterHeader";
36 import { useSettingsEnvironmentFilter } from "./settings-environment-filter";
37 +import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
38
39 export function SettingsRouteScreen() {
40 const surface = useWorkspaceSurface();
41 const deviceType = useDeviceType();
42 const compactTabs = useCompactWorkspaceTabs();
43 + const { layout } = useAdaptiveWorkspaceLayout();
44 + const inSidebar = use(NativePrimaryColumnContext) !== null && layout.usesSplitView;
45 + // The page open beside the list: the route right above the Settings tab's route.
46 + const selected = useNavigationState((state) => {
47 + const list = state.routes.findIndex((route) => route.name === "Settings");
48 + return list < 0 ? null : (state.routes[list + 1]?.name ?? null);
49 + });
50 + const sidebar = useMemo(() => (inSidebar ? { selected } : null), [inSidebar, selected]);
51 const content = hasCloudPublicConfig() ? (
52 <ConfiguredSettingsRouteScreen />
53 ) : (
@@ -45,22 +55,27 @@ export function SettingsRouteScreen() {
55 );
56
57 return (
48 - <View className={`flex-1 ${surface.className}`}>
49 - <SettingsEnvironmentFilterHeader />
50 - <ScreenScrollViewBottomInset value={deviceType === "pad" || compactTabs ? 80 : 0}>
51 - {Platform.OS === "android" ? (
52 - <SettingsScreen title="Settings" trailing={<AndroidSettingsEnvironmentFilter />}>
53 - {content}
54 - </SettingsScreen>
55 - ) : (
56 - content
57 - )}
58 - </ScreenScrollViewBottomInset>
59 - </View>
58 + <SettingsSidebarContext value={sidebar}>
59 + <View className={`flex-1 ${surface.className}`}>
60 + <SettingsEnvironmentFilterHeader />
61 + <ScreenScrollViewBottomInset value={deviceType === "pad" || compactTabs ? 80 : 0}>
62 + {Platform.OS === "android" ? (
63 + <SettingsScreen title="Settings" trailing={<AndroidSettingsEnvironmentFilter />}>
64 + {content}
65 + </SettingsScreen>
66 + ) : (
67 + content
68 + )}
69 + </ScreenScrollViewBottomInset>
70 + </View>
71 + </SettingsSidebarContext>
72 );
73 }
74
75 function ConfiguredSettingsRouteScreen() {
76 + // UIKit's scroll-edge material takes the scroll view's own color; like the chat list, match
77 + // the sidebar's surface so the bar doesn't darken over content at rest.
78 + const listSurface = use(NativePrimaryColumnContext) ? "bg-drawer" : "bg-screen";
79 const insets = useSafeAreaInsets();
80 const navigation = useNavigation();
81 const { isLoaded, isSignedIn } = useAuth({ treatPendingAsSignedOut: false });
@@ -77,7 +92,7 @@ function ConfiguredSettingsRouteScreen() {
92 <ScrollView
93 contentInsetAdjustmentBehavior="automatic"
94 showsVerticalScrollIndicator={false}
80 - className="flex-1"
95 + className={`flex-1 ${listSurface}`}
96 contentContainerClassName="gap-4 px-5 pt-4"
97 contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
98 >
@@ -88,7 +103,7 @@ function ConfiguredSettingsRouteScreen() {
103 label="T3 Account"
104 value={accountLabel}
105 disabled={!isLoaded}
91 - onPress={() => navigation.navigate("SettingsSheet", { screen: "SettingsAuth" })}
106 + onPress={() => navigation.navigate("SettingsAuth")}
107 />
108 <SettingsRow
109 icon="desktopcomputer"
@@ -107,6 +122,9 @@ function ConfiguredSettingsRouteScreen() {
122 }
123
124 function LocalSettingsRouteScreen() {
125 + // UIKit's scroll-edge material takes the scroll view's own color; like the chat list, match
126 + // the sidebar's surface so the bar doesn't darken over content at rest.
127 + const listSurface = use(NativePrimaryColumnContext) ? "bg-drawer" : "bg-screen";
128 const insets = useSafeAreaInsets();
129 const { savedConnectionsById } = useSavedRemoteConnections();
130 const environmentCount = Object.keys(savedConnectionsById).length;
@@ -116,7 +134,7 @@ function LocalSettingsRouteScreen() {
134 <ScrollView
135 contentInsetAdjustmentBehavior="automatic"
136 showsVerticalScrollIndicator={false}
119 - className="flex-1"
137 + className={`flex-1 ${listSurface}`}
138 contentContainerClassName="gap-4 px-5 pt-4"
139 contentContainerStyle={{
140 paddingBottom: Math.max(insets.bottom, 18) + 18,
apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx
+2 -6
@@ -451,12 +451,8 @@ function ServerSettingsDetail(props: { readonly page: SettingsPage }) {
451 label={target.label}
452 value="Server and provider updates"
453 onPress={() =>
454 - navigation.navigate("SettingsSheet", {
455 - screen: "SettingsContent",
456 - params: {
457 - screen: "SettingsEnvironmentDetail",
458 - params: { environmentId: target.environmentId },
459 - },
454 + navigation.navigate("SettingsEnvironmentDetail", {
455 + environmentId: target.environmentId,
456 })
457 }
458 />
apps/mobile/src/features/settings/components/SettingsRow.tsx
+45 -25
@@ -1,9 +1,14 @@
1 -import { useNavigation } from "@react-navigation/native";
2 -import type { ComponentProps } from "react";
1 +import { useNavigation, useRoute } from "@react-navigation/native";
2 +import { use, type ComponentProps } from "react";
3 import { Platform } from "react-native";
4
5 import { ListRow } from "../../../components/ui/ListRow";
6 -import type { SettingsLegalDocumentTarget, SettingsSheetTarget } from "./settings-sheet-targets";
6 +import { ListRowLayout } from "../../../components/ui/ListRowLayout";
7 +import { RowPressable } from "../../../components/ui/RowPressable";
8 +import { cn } from "../../../lib/cn";
9 +import type { SettingsLegalDocumentTarget, SettingsPageTarget } from "./settings-page-targets";
10 +import { SettingsSidebarContext } from "./SettingsSection";
11 +import { openSettings } from "../settings-navigation";
12
13 export function SettingsRow(props: {
14 readonly disabled?: boolean;
@@ -11,33 +16,48 @@ export function SettingsRow(props: {
16 readonly label: string;
17 readonly value?: string;
18 readonly valuePosition?: "below" | "trailing";
14 - readonly target?: SettingsSheetTarget;
19 + readonly target?: SettingsPageTarget;
20 readonly fullScreenTarget?: SettingsLegalDocumentTarget;
21 readonly onPress?: () => void;
22 }) {
23 const navigation = useNavigation();
24 + const sidebar = use(SettingsSidebarContext);
25 + // The Settings list opens pages in place of the detail column; a page's own rows push below.
26 + const inList = ["Home", "Settings"].includes(useRoute().name);
27 const valueBelow =
28 props.valuePosition === "below" ||
29 (props.valuePosition === undefined && Platform.OS === "android");
22 - return (
23 - <ListRow
24 - icon={props.icon}
25 - label={props.label}
26 - description={valueBelow ? props.value : undefined}
27 - detail={valueBelow ? undefined : props.value}
28 - disabled={props.disabled}
29 - onPress={() => {
30 - if (props.target) {
31 - navigation.navigate("SettingsSheet", {
32 - screen: "SettingsContent",
33 - params: { screen: props.target },
34 - });
35 - } else if (props.fullScreenTarget) {
36 - navigation.navigate(props.fullScreenTarget);
37 - } else {
38 - props.onPress?.();
39 - }
40 - }}
41 - />
42 - );
30 + const content = {
31 + icon: props.icon,
32 + label: props.label,
33 + description: valueBelow ? props.value : undefined,
34 + detail: valueBelow ? undefined : props.value,
35 + disabled: props.disabled,
36 + };
37 + const onPress = () => {
38 + if (props.target) {
39 + if (inList) openSettings(navigation, props.target);
40 + else navigation.navigate(props.target);
41 + } else if (props.fullScreenTarget) {
42 + navigation.navigate(props.fullScreenTarget);
43 + } else {
44 + props.onPress?.();
45 + }
46 + };
47 + if (sidebar) {
48 + const selected = props.target !== undefined && props.target === sidebar.selected;
49 + return (
50 + <RowPressable
51 + accessibilityRole="button"
52 + accessibilityLabel={[props.label, props.value].filter(Boolean).join(", ")}
53 + accessibilityState={{ disabled: Boolean(props.disabled), selected }}
54 + disabled={props.disabled}
55 + onPress={onPress}
56 + className={cn("rounded-2xl", selected && "bg-subtle-strong")}
57 + >
58 + <ListRowLayout {...content} />
59 + </RowPressable>
60 + );
61 + }
62 + return <ListRow {...content} onPress={onPress} />;
63 }
apps/mobile/src/features/settings/components/SettingsScreen.tsx
+2 -3
@@ -1,4 +1,4 @@
1 -import { useNavigation, useNavigationState, useRoute } from "@react-navigation/native";
1 +import { useNavigation, useRoute } from "@react-navigation/native";
2 import type { ReactNode } from "react";
3 import { Platform, View } from "react-native";
4
@@ -22,7 +22,6 @@ export function SettingsScreen(
22 ) {
23 const navigation = useNavigation();
24 const route = useRoute();
25 - const index = useNavigationState((state) => state.index);
25 const workspace = useWorkspaceTabs();
26 const surface = useWorkspaceSurface();
27 const deviceType = useDeviceType();
@@ -31,7 +30,7 @@ export function SettingsScreen(
30 // Android opens Settings as a workspace tab; its root page has nothing to go back to.
31 const workspaceRoot =
32 props.workspaceRoot ||
34 - (Platform.OS === "android" && workspace !== null && index === 0 && route.name === "Settings");
33 + (Platform.OS === "android" && workspace !== null && route.name === "Settings");
34
35 return (
36 <View
apps/mobile/src/features/settings/components/SettingsSection.tsx
+38 -1
@@ -1 +1,38 @@
1 -export { ListSection as SettingsSection } from "../../../components/ui/ListSection";
1 +import { createContext, use, type ComponentProps } from "react";
2 +import { View } from "react-native";
3 +
4 +import { AppText as Text } from "../../../components/ui/AppText";
5 +import { ListSection } from "../../../components/ui/ListSection";
6 +
7 +/**
8 + * Set while the Settings list is a split view's sidebar, naming the page open beside it. Like the
9 + * system Settings app, the sidebar lists plain rows and highlights that page instead of cards.
10 + */
11 +export const SettingsSidebarContext = createContext<{ readonly selected: string | null } | null>(
12 + null,
13 +);
14 +
15 +export function SettingsSection(props: ComponentProps<typeof ListSection>) {
16 + if (!use(SettingsSidebarContext)) return <ListSection {...props} />;
17 + return (
18 + <View className="gap-1">
19 + {props.title ? (
20 + <View className="flex-row items-center justify-between gap-3 px-2">
21 + <View className="min-w-0 flex-1 flex-row items-center gap-2">
22 + {props.titleIcon}
23 + <Text textRole="footnote" className="shrink font-t3-medium text-foreground-muted">
24 + {props.title}
25 + </Text>
26 + </View>
27 + {props.trailing}
28 + </View>
29 + ) : null}
30 + <View>{props.children}</View>
31 + {props.footer ? (
32 + <Text textRole="footnote" className="px-2 text-foreground-muted">
33 + {props.footer}
34 + </Text>
35 + ) : null}
36 + </View>
37 + );
38 +}
apps/mobile/src/features/settings/components/settings-page-targets.ts new
+30
@@ -0,0 +1,30 @@
1 +/** Settings pages a Settings row opens. */
2 +export const SETTINGS_PAGE_TARGETS = [
3 + "SettingsEnvironments",
4 + "SettingsNotifications",
5 + "SettingsThreads",
6 + "SettingsAbout",
7 + "SettingsArchive",
8 + "SettingsAppearance",
9 + "SettingsNavigation",
10 + "SettingsOrganization",
11 + "SettingsProjectOverview",
12 + "SettingsEnvironmentNewThreads",
13 + "SettingsEnvironmentSourceControl",
14 + "SettingsEnvironmentAgentBehavior",
15 + "SettingsEnvironmentMaintenance",
16 + "SettingsProviderAccounts",
17 + "SettingsKeyboard",
18 + "SettingsMicrophone",
19 + "SettingsFollowUp",
20 + "SettingsScheduledTasks",
21 + "SettingsProjectGrouping",
22 + "SettingsClientStorage",
23 + "SettingsDiagnostics",
24 + "SettingsOpenSourceLicenses",
25 + "SettingsUsage",
26 +] as const;
27 +
28 +export type SettingsPageTarget = (typeof SETTINGS_PAGE_TARGETS)[number];
29 +
30 +export type SettingsLegalDocumentTarget = "SettingsLegal";
apps/mobile/src/features/settings/components/settings-sheet-targets.ts deleted
-26
@@ -1,26 +0,0 @@
1 -export type SettingsSheetTarget =
2 - | "SettingsEnvironments"
3 - | "SettingsNotifications"
4 - | "SettingsThreads"
5 - | "SettingsAbout"
6 - | "SettingsArchive"
7 - | "SettingsAppearance"
8 - | "SettingsNavigation"
9 - | "SettingsOrganization"
10 - | "SettingsProjectOverview"
11 - | "SettingsEnvironmentNewThreads"
12 - | "SettingsEnvironmentSourceControl"
13 - | "SettingsEnvironmentAgentBehavior"
14 - | "SettingsEnvironmentMaintenance"
15 - | "SettingsProviderAccounts"
16 - | "SettingsKeyboard"
17 - | "SettingsMicrophone"
18 - | "SettingsFollowUp"
19 - | "SettingsScheduledTasks"
20 - | "SettingsProjectGrouping"
21 - | "SettingsClientStorage"
22 - | "SettingsDiagnostics"
23 - | "SettingsOpenSourceLicenses"
24 - | "SettingsUsage";
25 -
26 -export type SettingsLegalDocumentTarget = "SettingsLegal";
apps/mobile/src/features/settings/scheduled-task-editor.tsx
+4 -30
@@ -1,14 +1,6 @@
1 import { useAtomValue } from "@effect/atom-react";
2 import type { EnvironmentId } from "@t3tools/contracts";
3 -import {
4 - createContext,
5 - use,
6 - useMemo,
7 - useCallback,
8 - type Dispatch,
9 - type ReactNode,
10 - type SetStateAction,
11 -} from "react";
3 +import { useMemo, useCallback, type Dispatch, type SetStateAction } from "react";
4
5 import { useProjects, useServerConfigs } from "../../state/entities";
6 import {
@@ -28,19 +20,8 @@ import {
20 type ScheduledTaskEditor,
21 } from "./scheduled-task-editor-state";
22
31 -const ScheduledTaskEditorContext = createContext<{
32 - readonly editor: ScheduledTaskEditor | null;
33 - readonly voiceOwnerKey: string;
34 - readonly readEditor: () => ScheduledTaskEditor | null;
35 - readonly setEditor: Dispatch<SetStateAction<ScheduledTaskEditor | null>>;
36 - readonly startEditor: (editor: ScheduledTaskEditor | null) => void;
37 - readonly hasChanges: boolean;
38 - readonly resetEditor: () => void;
39 - readonly draftForEnvironment: (environmentId: EnvironmentId) => ScheduledTaskDraft;
40 -} | null>(null);
41 -
42 -/** Keeps the form draft alive while its native picker routes are on top. */
43 -export function ScheduledTaskEditorProvider({ children }: { readonly children: ReactNode }) {
23 +/** The form draft lives in an atom, so it survives while its native picker routes are on top. */
24 +export function useScheduledTaskEditor() {
25 const { selectedTargets, selectedProjectKey, projectGroups } = useSettingsEnvironmentFilter();
26 const selectedGroup = projectGroups.find((group) => group.key === selectedProjectKey);
27 const configs = useServerConfigs();
@@ -102,7 +83,7 @@ export function ScheduledTaskEditorProvider({ children }: { readonly children: R
83 () => readScheduledTaskEditor(voiceOwnerKey, defaultEditor),
84 [defaultEditor, voiceOwnerKey],
85 );
105 - const value = useMemo(
86 + return useMemo(
87 () => ({
88 editor,
89 voiceOwnerKey,
@@ -124,11 +105,4 @@ export function ScheduledTaskEditorProvider({ children }: { readonly children: R
105 draftForEnvironment,
106 ],
107 );
127 - return <ScheduledTaskEditorContext value={value}>{children}</ScheduledTaskEditorContext>;
128 -}
129 -
130 -export function useScheduledTaskEditor() {
131 - const context = use(ScheduledTaskEditorContext);
132 - if (!context) throw new Error("Scheduled task editor provider is missing.");
133 - return context;
108 }
apps/mobile/src/features/settings/settings-environment-filter.tsx
+84 -38
@@ -1,6 +1,14 @@
1 import type { EnvironmentId } from "@t3tools/contracts";
2 import { buildProjectGroups } from "@t3tools/client-runtime/state/project-grouping";
3 -import { createContext, useContext, useMemo, useState, type ReactNode } from "react";
3 +import {
4 + createContext,
5 + useContext,
6 + useMemo,
7 + useState,
8 + type Dispatch,
9 + type ReactNode,
10 + type SetStateAction,
11 +} from "react";
12
13 import { useEnvironments, type EnvironmentPresentation } from "../../state/environments";
14 import { useProjects } from "../../state/entities";
@@ -11,41 +19,88 @@ export type SettingsTarget = EnvironmentPresentation & {
19 readonly serverConfig: NonNullable<EnvironmentPresentation["serverConfig"]>;
20 };
21
22 +// Several mounted Settings components read the scope at once (the list, its header, a page and
23 +// its editor), so share the derived lists across them for the same inputs.
24 +const targetsCache = new WeakMap<readonly EnvironmentPresentation[], readonly SettingsTarget[]>();
25 +const groupsCache = new WeakMap<object, Map<string, ReturnType<typeof buildProjectGroups>>>();
26 +
27 function connectedSettingsTargets(environments: readonly EnvironmentPresentation[]) {
15 - return environments.filter(
16 - (entry): entry is SettingsTarget =>
17 - entry.connection.phase === "connected" && entry.serverConfig !== null,
18 - );
28 + let targets = targetsCache.get(environments);
29 + if (!targets) {
30 + targets = environments.filter(
31 + (entry): entry is SettingsTarget =>
32 + entry.connection.phase === "connected" && entry.serverConfig !== null,
33 + );
34 + targetsCache.set(environments, targets);
35 + }
36 + return targets;
37 +}
38 +
39 +function settingsProjectGroups(
40 + projects: Parameters<typeof buildProjectGroups>[0]["projects"],
41 + groupingMode: Parameters<typeof buildProjectGroups>[0]["settings"]["sidebarProjectGroupingMode"],
42 +) {
43 + let byMode = groupsCache.get(projects);
44 + if (!byMode) groupsCache.set(projects, (byMode = new Map()));
45 + let groups = byMode.get(groupingMode);
46 + if (!groups) {
47 + groups = buildProjectGroups({
48 + projects,
49 + settings: { sidebarProjectGroupingMode: groupingMode, sidebarProjectGroupingOverrides: {} },
50 + });
51 + byMode.set(groupingMode, groups);
52 + }
53 + return groups;
54 }
55
21 -const SettingsEnvironmentFilterContext = createContext<{
22 - readonly availableTargets: readonly SettingsTarget[];
23 - readonly selectedTargets: readonly SettingsTarget[];
56 +interface SettingsEnvironmentSelection {
57 readonly selectedIds: ReadonlySet<EnvironmentId> | null;
25 - readonly projectGroups: ReturnType<typeof buildProjectGroups>;
26 - readonly selectableProjectGroups: ReturnType<typeof buildProjectGroups>;
58 readonly selectedProjectKey: string | null;
28 - readonly selectProject: (projectKey: string | null) => void;
29 - readonly selectAll: () => void;
30 - readonly toggleEnvironment: (environmentId: EnvironmentId) => void;
31 -} | null>(null);
59 + readonly setSelectedIds: Dispatch<SetStateAction<ReadonlySet<EnvironmentId> | null>>;
60 + readonly setSelectedProjectKey: Dispatch<SetStateAction<string | null>>;
61 +}
62 +
63 +const SettingsEnvironmentSelectionContext = createContext<SettingsEnvironmentSelection | null>(
64 + null,
65 +);
66
33 -export function SettingsEnvironmentFilterProvider(props: { readonly children: ReactNode }) {
67 +/**
68 + * Holds the Settings scope selection across Settings pages, which are separate root routes.
69 + * It stays mounted for the whole app, so it keeps only the selection; the environment and
70 + * project data is derived in the hook, by the Settings pages that are mounted. The selection
71 + * resets when Settings closes.
72 + */
73 +export function SettingsEnvironmentFilterProvider(props: {
74 + readonly open: boolean;
75 + readonly children: ReactNode;
76 +}) {
77 + const [selectedIds, setSelectedIds] = useState<ReadonlySet<EnvironmentId> | null>(null);
78 + const [selectedProjectKey, setSelectedProjectKey] = useState<string | null>(null);
79 + if (!props.open && (selectedIds !== null || selectedProjectKey !== null)) {
80 + setSelectedIds(null);
81 + setSelectedProjectKey(null);
82 + }
83 + const value = useMemo(
84 + () => ({ selectedIds, selectedProjectKey, setSelectedIds, setSelectedProjectKey }),
85 + [selectedIds, selectedProjectKey],
86 + );
87 + return (
88 + <SettingsEnvironmentSelectionContext value={value}>
89 + {props.children}
90 + </SettingsEnvironmentSelectionContext>
91 + );
92 +}
93 +
94 +export function useSettingsEnvironmentFilter() {
95 + const selection = useContext(SettingsEnvironmentSelectionContext);
96 + if (selection === null) throw new Error("Settings environment filter provider is missing.");
97 + const { selectedIds, selectedProjectKey, setSelectedIds, setSelectedProjectKey } = selection;
98 const { environments } = useEnvironments();
99 const projects = useProjects();
100 const groupingSettings = useMobileProjectGroupingSettings();
101 const groupingMode = groupingSettings.sidebarProjectGroupingMode;
38 - const [selectedIds, setSelectedIds] = useState<ReadonlySet<EnvironmentId> | null>(null);
39 - const [selectedProjectKey, setSelectedProjectKey] = useState<string | null>(null);
40 - const projectGroups = useMemo(
41 - () =>
42 - buildProjectGroups({
43 - projects,
44 - settings: { sidebarProjectGroupingMode: groupingMode, sidebarProjectGroupingOverrides: {} },
45 - }),
46 - [projects, groupingMode],
47 - );
48 - const availableTargets = useMemo(() => connectedSettingsTargets(environments), [environments]);
102 + const projectGroups = settingsProjectGroups(projects, groupingMode);
103 + const availableTargets = connectedSettingsTargets(environments);
104 const selectedTargets = useMemo(
105 () =>
106 availableTargets.filter(
@@ -62,7 +117,7 @@ export function SettingsEnvironmentFilterProvider(props: { readonly children: Re
117 ),
118 [projectGroups, selectedTargets],
119 );
65 - const value = useMemo(
120 + return useMemo(
121 () => ({
122 availableTargets,
123 selectedTargets,
@@ -84,17 +139,8 @@ export function SettingsEnvironmentFilterProvider(props: { readonly children: Re
139 projectGroups,
140 selectableProjectGroups,
141 selectedProjectKey,
142 + setSelectedIds,
143 + setSelectedProjectKey,
144 ],
145 );
89 - return (
90 - <SettingsEnvironmentFilterContext value={value}>
91 - {props.children}
92 - </SettingsEnvironmentFilterContext>
93 - );
94 -}
95 -
96 -export function useSettingsEnvironmentFilter() {
97 - const filter = useContext(SettingsEnvironmentFilterContext);
98 - if (filter === null) throw new Error("Settings environment filter provider is missing.");
99 - return filter;
146 }
apps/mobile/src/features/settings/settings-navigation.ts new
+119
@@ -0,0 +1,119 @@
1 +import type { NavigationState, PartialState } from "@react-navigation/native";
2 +
3 +import {
4 + dispatchRootStackReset,
5 + resetRootStack,
6 + rootStackState,
7 + type RootStackNavigation,
8 +} from "../../lib/root-stack-reset";
9 +
10 +type RootParams = ReactNavigation.RootParamList;
11 +
12 +/** Settings routes that open as modals over whatever is on screen, not as Settings pages. */
13 +const SETTINGS_MODAL_ROUTES = new Set(["SettingsLegal", "SettingsAuth", "SettingsWaitlist"]);
14 +
15 +/** Root routes that make up the Settings tab: its list and the pages it opens. */
16 +export type SettingsRouteName = Exclude<
17 + Extract<keyof RootParams, `Settings${string}`>,
18 + "SettingsLegal" | "SettingsAuth" | "SettingsWaitlist"
19 +>;
20 +
21 +/** A page in the Settings tab's detail column. */
22 +export type SettingsPageName = Exclude<SettingsRouteName, "Settings">;
23 +
24 +export function isSettingsRoute(name: string): boolean {
25 + return name.startsWith("Settings") && !SETTINGS_MODAL_ROUTES.has(name);
26 +}
27 +
28 +/**
29 + * Settings is open while its `Settings` route is under the topmost workspace page and that
30 + * page is a Settings page. A Settings page pushed without it, such as a usage account opened
31 + * from the Usage tab, stays a detail of the current tab.
32 + */
33 +export function settingsOpenIn(workspaceRoutes: readonly { readonly name: string }[]): boolean {
34 + return (
35 + workspaceRoutes.some((route) => route.name === "Settings") &&
36 + isSettingsRoute(workspaceRoutes.at(-1)?.name ?? "")
37 + );
38 +}
39 +
40 +/**
41 + * A `settings/...` link names only its page, so put the Settings tab's route under it. A bare
42 + * `settings` link opens `page` beside the list when the window has columns.
43 + */
44 +export function restoreSettingsLinkState(
45 + state: PartialState<NavigationState> | undefined,
46 + page: SettingsPageName | undefined,
47 +) {
48 + if (!state) return state;
49 + const routes = [...state.routes];
50 + const list = routes.findIndex((route) => route.name === "Settings");
51 + const first = routes.findIndex((route) => isSettingsRoute(route.name));
52 + if (first < 0) return state;
53 + if (list < 0) routes.splice(first, 0, { name: "Settings" });
54 + const top = routes.at(-1);
55 + if (page && top?.name === "Settings") routes.push({ name: page });
56 + return routes.length === state.routes.length
57 + ? state
58 + : { ...state, index: routes.length - 1, routes };
59 +}
60 +
61 +type SettingsPageArgs<Name extends SettingsPageName> = undefined extends RootParams[Name]
62 + ? [params?: RootParams[Name]]
63 + : [params: RootParams[Name]];
64 +
65 +type RouteLike = { readonly name: string; readonly key?: string; readonly params?: object };
66 +
67 +/**
68 + * Settings pages sit on the root stack above Home, under a `Settings` route that keeps the
69 + * Settings list as the workspace's primary content. Opening a page replaces whatever was above
70 + * Home, so the tab always starts from its list and Back returns there. Routes already on screen
71 + * keep their keys, so reopening the open page doesn't rebuild it.
72 + */
73 +export function settingsNavigationState<State extends { readonly routes: readonly RouteLike[] }>(
74 + state: State,
75 + page: SettingsPageName | undefined,
76 + params?: object,
77 + key?: string,
78 +) {
79 + const home = state.routes.find((route) => route.name === "Home") ?? { name: "Home" };
80 + const list = state.routes.find((route) => route.name === "Settings") ?? { name: "Settings" };
81 + const current = page
82 + ? state.routes.find(
83 + (route) => route.name === page && JSON.stringify(route.params) === JSON.stringify(params),
84 + )
85 + : undefined;
86 + const routes = [
87 + home,
88 + list,
89 + ...(page ? [current ?? (key ? { key, name: page, params } : { name: page, params })] : []),
90 + ];
91 + return { ...state, index: routes.length - 1, routes };
92 +}
93 +
94 +/** Opens one Settings page in the Settings tab, from anywhere outside it. */
95 +export function openSettings<Name extends SettingsPageName>(
96 + navigation: RootStackNavigation,
97 + page: Name,
98 + ...[params]: SettingsPageArgs<Name>
99 +) {
100 + resetRootStack(navigation, (state) => settingsNavigationState(state, page, params));
101 +}
102 +
103 +/**
104 + * Closes a Settings page that finished its job. The first page beside the list is replaced with
105 + * `fallback` when the window has columns, since going back would leave the detail column empty.
106 + */
107 +export function leaveSettingsPage(
108 + navigation: RootStackNavigation & { readonly goBack: () => void },
109 + columns: boolean,
110 + fallback: SettingsPageName,
111 +) {
112 + const state = rootStackState(navigation);
113 + const below = state?.routes[state.index - 1];
114 + if (state && columns && below?.name === "Settings") {
115 + dispatchRootStackReset(navigation, state, settingsNavigationState(state, fallback));
116 + } else {
117 + navigation.goBack();
118 + }
119 +}
apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx
+2 -6
@@ -33,6 +33,7 @@ import {
33 subscribeToShowcaseRenderSignal,
34 } from "./showcaseRenderSignal";
35 import { stageShowcaseAgentActivity } from "./stageShowcaseAgentActivity";
36 +import { openSettings } from "../settings/settings-navigation";
37
38 const SHOWCASE_ENABLED = process.env.EXPO_PUBLIC_SHOWCASE === "1";
39 const SHOWCASE_THREAD_ID = "remote-command-center";
@@ -243,12 +244,7 @@ function EnabledShowcaseCaptureCoordinator(props: { readonly pathname: string })
244 return;
245 }
246 if (requestedScene === "environments") {
246 - navigation.dispatch(
247 - CommonActions.navigate("SettingsSheet", {
248 - screen: "SettingsContent",
249 - params: { screen: "SettingsEnvironments" },
250 - }),
251 - );
247 + openSettings(navigation, "SettingsEnvironments");
248 } else if (requestedScene === "terminal") {
249 navigation.dispatch(
250 CommonActions.navigate("ThreadTerminal", { ...params, terminalId: "term-1" }),
apps/mobile/src/features/threads/ThreadFeed.tsx
+2 -6
@@ -284,6 +284,7 @@ import {
284 ThreadMarkdownImageUnavailable,
285 ThreadMarkdownImageView,
286 } from "./ThreadMarkdownImage";
287 +import { openSettings } from "../settings/settings-navigation";
288
289 const WIDE_MARKDOWN_BLOCK_OPTIONS = {
290 // Native iOS blockquotes and adjacent selectable text are separate layout
@@ -1173,12 +1174,7 @@ function ThreadAutomationMessageRow(props: {
1174 <Pressable
1175 accessibilityRole="link"
1176 hitSlop={6}
1176 - onPress={() =>
1177 - navigation.navigate("SettingsSheet", {
1178 - screen: "SettingsContent",
1179 - params: { screen: "SettingsScheduledTasks" },
1180 - })
1181 - }
1177 + onPress={() => openSettings(navigation, "SettingsScheduledTasks")}
1178 >
1179 <Text className="font-t3-medium text-xs text-foreground-secondary">
1180 Open automation
apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+2 -4
@@ -97,6 +97,7 @@ import {
97 useAndroidWorkspaceBack,
98 useWorkspaceBackNavigation,
99 } from "../workspace/useAndroidWorkspaceNavigation";
100 +import { openSettings } from "../settings/settings-navigation";
101
102 interface ThreadInspectorSelection {
103 readonly routeThreadIdentity: string | null;
@@ -256,10 +257,7 @@ function LiveThreadRouteController(props: ThreadRouteScreenProps) {
257 onReconnectEnvironment(environmentId);
258 return;
259 }
259 - navigation.navigate("SettingsSheet", {
260 - screen: "SettingsContent",
261 - params: { screen: "SettingsEnvironments" },
262 - });
260 + openSettings(navigation, "SettingsEnvironments");
261 }}
262 />
263 );
apps/mobile/src/features/usage/UsageLimitsPooled.tsx
+6 -12
@@ -151,18 +151,12 @@ function PoolWindowCard({
151 const navigation = useNavigation();
152 const nextRefill = pool.resets.find((reset) => reset.restoresPercent > 0);
153 const openAccount = (account: LimitAccount) =>
154 - navigation.navigate("SettingsSheet", {
155 - screen: "SettingsContent",
156 - params: {
157 - screen: "SettingsUsageAccount",
158 - params: {
159 - accountKey: account.key,
160 - windowId: pool.id,
161 - windowKind: pool.kind,
162 - environmentIds,
163 - now,
164 - },
165 - },
154 + navigation.navigate("SettingsUsageAccount", {
155 + accountKey: account.key,
156 + windowId: pool.id,
157 + windowKind: pool.kind,
158 + environmentIds,
159 + now,
160 });
161 return (
162 <View className="gap-3 rounded-[24px] border-continuous bg-grouped-card p-4">
apps/mobile/src/features/workspace/AndroidWorkspaceSettings.tsx deleted
-20
@@ -1,20 +0,0 @@
1 -import type { ReactNode } from "react";
2 -import { Platform, View } from "react-native";
3 -import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
4 -import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
5 -import { AndroidWorkspaceNavigation } from "./AndroidWorkspaceNavigation";
6 -
7 -/** Settings keeps its existing stack inside the full workspace, above compact navigation. */
8 -export function AndroidWorkspaceSettings(props: { readonly children: ReactNode }) {
9 - const { layout, startNewTask } = useAdaptiveWorkspaceLayout();
10 - const insets = useSafeAreaInsets();
11 - if (Platform.OS !== "android") return props.children;
12 - return (
13 - <View className="flex-1 bg-header">
14 - <SafeAreaInsetsContext value={layout.usesSplitView ? insets : { ...insets, bottom: 0 }}>
15 - <View className="flex-1">{props.children}</View>
16 - </SafeAreaInsetsContext>
17 - {layout.usesSplitView ? null : <AndroidWorkspaceNavigation onNewThread={startNewTask} />}
18 - </View>
19 - );
20 -}
apps/mobile/src/features/workspace/WorkspaceNativeTabs.ios.tsx
+33 -39
@@ -1,17 +1,11 @@
1 -import { useNavigation } from "@react-navigation/native";
1 import {
2 WORKSPACE_TAB_LABELS,
3 NAVIGATION_TAB_ICONS,
4 useEnabledNavigationTabs,
5 } from "./navigation-tabs";
7 -import { useCallback, useMemo, useState, type ReactNode } from "react";
8 -import { Keyboard, View, useWindowDimensions, type NativeSyntheticEvent } from "react-native";
9 -import {
10 - Tabs,
11 - type TabSelectedEvent,
12 - type TabSelectionPreventedEvent,
13 - type TabSelectionRejectedEvent,
14 -} from "react-native-screens";
6 +import { useCallback, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
7 +import { View, useWindowDimensions, type NativeSyntheticEvent } from "react-native";
8 +import { Tabs, type TabSelectedEvent, type TabSelectionRejectedEvent } from "react-native-screens";
9
10 import { WorkspaceTabsContext, useWorkspaceTabs } from "./WorkspaceTabsContext";
11 import {
@@ -20,12 +14,16 @@ import {
14 workspaceUsesColumns,
15 type WorkspaceTab,
16 } from "./workspace-tabs-state";
23 -import { NativeWorkspaceTabActivityContext } from "../../native/v5-workspace-context";
17 +import {
18 + NativeWorkspaceTabActivityContext,
19 + WorkspaceSlotOptionsContext,
20 +} from "../../native/v5-workspace-context";
21 import { useCompactWorkspaceTabs, useSystemWorkspaceTabBar } from "./useSystemWorkspaceTabBar";
22 import { useControlTheme } from "../../components/ui/useControlTheme";
23 import { useDeviceType } from "../../native/native-layout-metrics";
24 import { WorkspaceSidebarTabs } from "./WorkspaceSidebarTabs";
25 import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
26 +import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
27
28 const PULL_REQUEST_ICON = require("../../../assets/icons/pull-request.png");
29
@@ -36,8 +34,12 @@ function RetainedWorkspaceTab(props: {
34 readonly children: ReactNode;
35 }) {
36 const workspace = useWorkspaceTabs()!;
39 - const { isTabActive } = workspace;
40 - const isActive = useCallback(() => isTabActive(props.tab), [isTabActive, props.tab]);
37 + // Whether this slot is the visible one, read by cleanups after the switch has committed.
38 + const activeRef = useRef(props.active);
39 + useLayoutEffect(() => {
40 + activeRef.current = props.active;
41 + }, [props.active]);
42 + const isActive = useCallback(() => activeRef.current, []);
43 const activity = useMemo(
44 () => ({
45 active: props.active,
@@ -45,6 +47,19 @@ function RetainedWorkspaceTab(props: {
47 }),
48 [props.active, isActive],
49 );
50 + const [optionsByRoute, setOptionsByRoute] = useState<ReadonlyMap<string, object>>(new Map());
51 + // Stable, so writers and the cleanups that depend on them don't re-run on every write.
52 + const setRouteOptions = useCallback(
53 + (routeKey: string, options: object) =>
54 + setOptionsByRoute((current) =>
55 + new Map(current).set(routeKey, { ...current.get(routeKey), ...options }),
56 + ),
57 + [],
58 + );
59 + const slotOptions = useMemo(
60 + () => ({ byRoute: optionsByRoute, set: setRouteOptions }),
61 + [optionsByRoute, setRouteOptions],
62 + );
63 const [content, setContent] = useState(
64 props.active ? { workspace, children: props.children } : null,
65 );
@@ -52,7 +67,9 @@ function RetainedWorkspaceTab(props: {
67 setContent({ workspace, children: props.children });
68 return content ? (
69 <NativeWorkspaceTabActivityContext value={activity}>
55 - <WorkspaceTabsContext value={content.workspace}>{content.children}</WorkspaceTabsContext>
70 + <WorkspaceSlotOptionsContext value={slotOptions}>
71 + <WorkspaceTabsContext value={content.workspace}>{content.children}</WorkspaceTabsContext>
72 + </WorkspaceSlotOptionsContext>
73 </NativeWorkspaceTabActivityContext>
74 ) : null;
75 }
@@ -60,13 +77,12 @@ function RetainedWorkspaceTab(props: {
77 export function WorkspaceNativeTabs(props: {
78 readonly children: ReactNode;
79 readonly hidden: boolean;
63 - readonly onSelect: () => void;
80 }) {
81 const workspace = useWorkspaceTabs()!;
82 const order = useEnabledNavigationTabs();
83 const primaryTabs = order.slice(0, 4);
84 const overflow = order[4];
69 - const navigation = useNavigation();
85 + const selectTab = useSelectWorkspaceTab();
86 const [provenance, setProvenance] = useState(0);
87 const systemTabBar = useSystemWorkspaceTabBar();
88 const deviceType = useDeviceType();
@@ -95,16 +111,6 @@ export function WorkspaceNativeTabs(props: {
111 tabBarMinimizeBehavior: "never",
112 tabBarTintColor: colors["--color-primary"],
113 }}
98 - onTabSelectionPrevented={({
99 - nativeEvent,
100 - }: NativeSyntheticEvent<TabSelectionPreventedEvent>) => {
101 - if (nativeEvent.preventedScreenKey === "settings") {
102 - navigation.navigate("SettingsSheet", {
103 - screen: "SettingsContent",
104 - params: { screen: "Settings" },
105 - });
106 - }
107 - }}
114 onTabSelectionRejected={({
115 nativeEvent,
116 }: NativeSyntheticEvent<TabSelectionRejectedEvent>) =>
@@ -114,18 +120,7 @@ export function WorkspaceNativeTabs(props: {
120 setProvenance(nativeEvent.provenance);
121 if (nativeEvent.actionOrigin === "programmatic-js") return;
122 const tab = workspaceTabForNativeSlot(primaryTabs, nativeEvent.selectedScreenKey);
117 - // UIKit sends reselects here even when preventNativeSelection is enabled.
118 - if (tab === "settings") {
119 - navigation.navigate("SettingsSheet", {
120 - screen: "SettingsContent",
121 - params: { screen: "Settings" },
122 - });
123 - return;
124 - }
125 - if (!tab) return;
126 - Keyboard.dismiss();
127 - props.onSelect();
128 - workspace.dispatch({ type: "select", tab });
123 + if (tab) selectTab(tab);
124 }}
125 >
126 {NATIVE_WORKSPACE_TAB_SLOTS.map((slot, index) => {
@@ -139,7 +134,6 @@ export function WorkspaceNativeTabs(props: {
134 screenKey={slot}
135 title=""
136 tabBarItemAccessibilityLabel={settings ? "Settings" : WORKSPACE_TAB_LABELS[tab]}
142 - preventNativeSelection={settings}
137 ios={{
138 icon: settings
139 ? { type: "sfSymbol", name: "gearshape" }
@@ -166,7 +160,7 @@ export function WorkspaceNativeTabs(props: {
160 {(deviceType === "pad" ||
161 compactTabs ||
162 (layout.primarySidebarOverlaysContent &&
169 - (workspace.settingsOpen || !workspaceUsesColumns(selectedTab)))) &&
163 + !workspaceUsesColumns(selectedTab, workspace.settingsOpen))) &&
164 !props.hidden ? (
165 <View
166 pointerEvents="box-none"
apps/mobile/src/features/workspace/WorkspaceNoTabs.tsx
+2 -6
@@ -1,6 +1,7 @@
1 import { useNavigation } from "@react-navigation/native";
2 import { View } from "react-native";
3 import { EmptyState } from "../../components/ui/EmptyState";
4 +import { openSettings } from "../settings/settings-navigation";
5
6 export function WorkspaceNoTabs() {
7 const navigation = useNavigation();
@@ -11,12 +12,7 @@ export function WorkspaceNoTabs() {
12 detail="Show a section to add it back to navigation."
13 actionLabel="Edit navigation tabs"
14 variant="plain"
14 - onAction={() =>
15 - navigation.navigate("SettingsSheet", {
16 - screen: "SettingsContent",
17 - params: { screen: "SettingsNavigation", initial: false },
18 - })
19 - }
15 + onAction={() => openSettings(navigation, "SettingsNavigation")}
16 />
17 </View>
18 );
apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
+25 -17
@@ -1,6 +1,7 @@
1 import { WorkspaceNoTabs } from "./WorkspaceNoTabs";
2 import { WORKSPACE_TAB_LABELS, useEnabledNavigationTabs } from "./navigation-tabs";
3 import { WorkspaceExtraTab } from "./WorkspaceExtraTab";
4 +import { SettingsRouteScreen } from "../settings/SettingsRouteScreen";
5 import { WorkspaceSectionToolbar } from "./WorkspaceSectionToolbar";
6 import { useNavigation } from "@react-navigation/native";
7 import { use, useCallback, useMemo } from "react";
@@ -44,6 +45,8 @@ import {
45 useSidebarWorkspaceTabs,
46 useSystemWorkspaceTabBar,
47 } from "./useSystemWorkspaceTabBar";
48 +import { openSettings } from "../settings/settings-navigation";
49 +import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
50
51 const TAB_TITLES = WORKSPACE_TAB_LABELS;
52
@@ -70,6 +73,7 @@ function WorkspaceRootTitle(props: {
73
74 function WorkspaceRootContent() {
75 const navigation = useNavigation();
76 + const selectTab = useSelectWorkspaceTab();
77 const { width: windowWidth } = useWindowDimensions();
78 const { layout, startNewTask } = useAdaptiveWorkspaceLayout();
79 const primaryColumn = use(NativePrimaryColumnContext);
@@ -97,17 +101,14 @@ function WorkspaceRootContent() {
101 () => (
102 <WorkspaceRootTitle
103 maxWidth={Math.max(0, width - 160)}
100 - onOpenEnvironments={() =>
101 - navigation.navigate("SettingsSheet", {
102 - screen: "SettingsContent",
103 - params: { screen: "SettingsEnvironments" },
104 - })
105 - }
104 + onOpenEnvironments={() => openSettings(navigation, "SettingsEnvironments")}
105 />
106 ),
107 [width, navigation],
108 );
109 const tab = state.tabs[state.selectedTab];
110 + // Settings is a workspace tab too; its list takes the place of the selected tab's.
111 + const settingsOpen = workspace.settingsOpen;
112 const bottomClearance =
113 layout.primarySidebarOverlaysContent && state.selectedTab === "usage"
114 ? workspaceDockBottomClearance({ bottomInset: insets.bottom, keyboardHeight })
@@ -140,6 +141,7 @@ function WorkspaceRootContent() {
141 {Platform.OS === "ios" ? (
142 <NativeStackScreenOptions
143 optionsVersion={[
144 + settingsOpen,
145 state.selectedTab,
146 state.selectionRevision,
147 width,
@@ -147,7 +149,11 @@ function WorkspaceRootContent() {
149 enabled.length,
150 ]}
151 options={{
150 - title: enabled.length ? TAB_TITLES[state.selectedTab] : "Navigation",
152 + title: settingsOpen
153 + ? "Settings"
154 + : enabled.length
155 + ? TAB_TITLES[state.selectedTab]
156 + : "Navigation",
157 headerShown: true,
158 headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,
159 headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED
@@ -158,7 +164,8 @@ function WorkspaceRootContent() {
164 ? { headerSearchBarOptions: undefined, unstable_headerRightItems: () => [] }
165 : {}),
166 unstable_headerLeftItems: () => [],
161 - headerTitle: state.selectedTab === "usage" ? undefined : renderHeaderTitle,
167 + headerTitle:
168 + settingsOpen || state.selectedTab === "usage" ? undefined : renderHeaderTitle,
169 }}
170 />
171 ) : (
@@ -181,11 +188,7 @@ function WorkspaceRootContent() {
188 {
189 accessibilityLabel: "Settings",
190 icon: "gearshape",
184 - onPress: () =>
185 - navigation.navigate("SettingsSheet", {
186 - screen: "SettingsContent",
187 - params: { screen: "Settings" },
188 - }),
191 + onPress: () => selectTab("settings"),
192 },
193 ]}
194 />
@@ -195,7 +198,12 @@ function WorkspaceRootContent() {
198 sidebarPicker ? { ...insets, top: 0 } : compactTabs ? { ...insets, bottom: 0 } : insets
199 }
200 >
198 - {enabled.length === 0 ? (
201 + {settingsOpen ? (
202 + <>
203 + <NativeStackScreenOptions options={{ headerSearchBarOptions: undefined }} />
204 + <SettingsRouteScreen />
205 + </>
206 + ) : enabled.length === 0 ? (
207 <WorkspaceNoTabs />
208 ) : state.selectedTab === "threads" ? (
209 <HomeRouteScreen />
@@ -208,13 +216,13 @@ function WorkspaceRootContent() {
216 {deviceType !== "pad" && deviceType !== "phone" && sidebarPicker ? (
217 <WorkspaceSidebarTabs />
218 ) : null}
211 - {enabled.length === 0 ? null : state.selectedTab === "threads" ||
212 - state.selectedTab === "pullRequests" ? (
219 + {enabled.length === 0 && !settingsOpen ? null : !settingsOpen &&
220 + (state.selectedTab === "threads" || state.selectedTab === "pullRequests") ? (
221 <WorkspaceToolbar sidebar={sidebarNavigation} onNewTask={startNewTask} />
222 ) : (
223 <WorkspaceSectionToolbar
224 onNewTask={startNewTask}
217 - showCompose={state.selectedTab !== "usage"}
225 + showCompose={!settingsOpen && state.selectedTab !== "usage"}
226 />
227 )}
228 </View>
apps/mobile/src/features/workspace/WorkspaceSectionToolbar.tsx
+1 -6
@@ -49,12 +49,7 @@ export function WorkspaceTabToolbarButtons() {
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 - }
52 + onPress={() => selectTab("settings")}
53 />
54 </>
55 );
apps/mobile/src/features/workspace/WorkspaceSidebarTabs.ios.tsx
+1 -5
@@ -51,11 +51,7 @@ export function WorkspaceSidebarTabs(props: {
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 - });
54 + if (tab === "settings") selectTab("settings");
55 else if (tab) selectTab(tab);
56 }}
57 // Keep the host stable while UIKit updates the bars' intrinsic size and safe area together.
apps/mobile/src/features/workspace/android-workspace-tabs.ts
+14 -22
@@ -1,41 +1,33 @@
1 import type { NavigationState } from "@react-navigation/native";
2 import { androidWorkspaceNavigationState } from "../../lib/android-workspace-navigation";
3 +import {
4 + isSettingsRoute,
5 + settingsNavigationState,
6 + settingsOpenIn,
7 +} from "../settings/settings-navigation";
8 import type { WorkspaceTab } from "./workspace-tabs-state";
9
10 /** Settings joins the two list tabs as a top-level Android destination. */
11 export type AndroidWorkspaceNavigationTab = WorkspaceTab | "settings";
12
8 -const WORKSPACE_ROUTES = new Set(["Home", "Thread", "PullRequest", "SettingsSheet"]);
13 +const WORKSPACE_ROUTES = new Set(["Home", "Thread", "PullRequest"]);
14
10 -/**
11 - * The Settings tab reuses the settings navigator, reset over Home alone so stale chat and
12 - * PR history is dropped while nested settings pages keep an ordinary Back.
13 - */
15 +/** The Settings tab resets over Home alone so stale chat and PR history is dropped. */
16 export function androidWorkspaceTabNavigationState(
17 state: NavigationState,
18 tab: AndroidWorkspaceNavigationTab,
19 ) {
20 const home = androidWorkspaceNavigationState(state);
19 - if (tab !== "settings") return home;
20 - return {
21 - ...home,
22 - index: 1,
23 - routes: [
24 - ...home.routes,
25 - {
26 - name: "SettingsSheet",
27 - params: { screen: "SettingsContent", params: { screen: "Settings" } },
28 - },
29 - ],
30 - };
21 + return tab === "settings" ? settingsNavigationState(home, undefined) : home;
22 }
23
33 -/** Settings stays selected while its navigator is the topmost workspace route. */
24 +/** Settings stays selected while one of its pages is the topmost workspace route. */
25 export function androidWorkspaceSettingsOpen(state: NavigationState): boolean {
35 - const top = state.routes
36 - .slice(0, state.index + 1)
37 - .findLast((route) => WORKSPACE_ROUTES.has(route.name));
38 - return top?.name === "SettingsSheet";
26 + return settingsOpenIn(
27 + state.routes
28 + .slice(0, state.index + 1)
29 + .filter((route) => WORKSPACE_ROUTES.has(route.name) || isSettingsRoute(route.name)),
30 + );
31 }
32
33 export function androidWorkspaceTabFromNavigationState(
apps/mobile/src/features/workspace/useSelectWorkspaceTab.ts
+10 -12
@@ -1,22 +1,20 @@
1 -import { StackActions, useNavigation } from "@react-navigation/native";
1 import { useCallback } from "react";
3 -import { Keyboard, Platform } from "react-native";
4 -import { resetAndroidWorkspace } from "../../lib/android-workspace-navigation";
2 +import { Keyboard } from "react-native";
3 +
4 +import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
5 import { useWorkspaceTabs } from "./WorkspaceTabsContext";
6 import type { WorkspaceTab } from "./workspace-tabs-state";
7
8 -/** Switch workspace tabs from inside the sidebar, closing any open detail first. */
8 +/** Opens a workspace tab, Settings included, from a tab bar, rail, toolbar or command. */
9 export function useSelectWorkspaceTab() {
10 - const workspace = useWorkspaceTabs()!;
11 - const navigation = useNavigation();
12 - const { dispatch } = workspace;
10 + const dispatch = useWorkspaceTabs()?.dispatch;
11 + const { openWorkspaceTab } = useAdaptiveWorkspaceLayout();
12 return useCallback(
14 - (tab: WorkspaceTab) => {
13 + (tab: WorkspaceTab | "settings") => {
14 Keyboard.dismiss();
16 - if (Platform.OS === "android") resetAndroidWorkspace(navigation);
17 - else navigation.dispatch(StackActions.popTo("Home"));
18 - dispatch({ type: "select", tab });
15 + openWorkspaceTab(tab);
16 + if (tab !== "settings") dispatch?.({ type: "select", tab });
17 },
20 - [dispatch, navigation],
18 + [dispatch, openWorkspaceTab],
19 );
20 }
apps/mobile/src/features/workspace/useSystemWorkspaceTabBar.ts
+1 -2
@@ -8,8 +8,7 @@ import { workspaceUsesColumns } from "./workspace-tabs-state";
8 function useWorkspacePage() {
9 const workspace = useWorkspaceTabs();
10 return (
11 - workspace !== null &&
12 - (workspace.settingsOpen || !workspaceUsesColumns(workspace.state.selectedTab))
11 + workspace !== null && !workspaceUsesColumns(workspace.state.selectedTab, workspace.settingsOpen)
12 );
13 }
14
apps/mobile/src/features/workspace/workspace-selection-store.ts new
+142
@@ -0,0 +1,142 @@
1 +import type { NavigationState } from "@react-navigation/native";
2 +import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
3 +import * as Linking from "expo-linking";
4 +import { AppState, Dimensions, Platform } from "react-native";
5 +
6 +import { environmentCatalog } from "../../connection/catalog";
7 +import { deriveLayout } from "../../lib/layout";
8 +import {
9 + NATIVE_METRICS_TIMEOUT_MS,
10 + nativeWorkspaceColumnsSupportedFor,
11 +} from "../../native/NativeWorkspaceColumns";
12 +import {
13 + currentNativeLayoutMetrics,
14 + firstNativeLayoutMetrics,
15 +} from "../../native/native-layout-metrics";
16 +import { loadPreferences, savePreferencesPatch } from "../../persistence/imperative";
17 +import { rootStackState, type RootStackNavigation } from "../../lib/root-stack-reset";
18 +import { workspaceRoutesOf } from "../layout/workspace-overlay-routes";
19 +import type { WorkspaceSelections } from "../../persistence/mobile-preferences";
20 +import { appAtomRegistry } from "../../state/atom-registry";
21 +import { environmentPresentations } from "../../state/presentation";
22 +import { environmentThreadShells, threadEnvironment } from "../../state/threads";
23 +import {
24 + rememberedSettingsPage,
25 + workspaceSelectionsIn,
26 + type WorkspaceSelectionCheck,
27 +} from "./workspace-tab-navigation";
28 +
29 +// Only iOS columns reopen a remembered page; Android always opens a tab on its list.
30 +const REMEMBERS = Platform.OS === "ios";
31 +
32 +// Read synchronously when a tab opens, so it lives in memory and is saved when the app leaves
33 +// the foreground rather than on every chat switch.
34 +let selections: WorkspaceSelections = {};
35 +let saved = selections;
36 +let hydration: Promise<void> | null = null;
37 +
38 +function save() {
39 + const writing = selections;
40 + if (saved === writing) return;
41 + // Marked saved only once written, so a failed write is retried on the next background.
42 + void savePreferencesPatch({ workspaceSelections: writing })
43 + .then(() => {
44 + saved = writing;
45 + })
46 + .catch(() => undefined);
47 +}
48 +
49 +/** Loads the saved selections once; pages visited before it resolves win over saved ones. */
50 +export function hydrateWorkspaceSelections() {
51 + if (!REMEMBERS) return Promise.resolve();
52 + hydration ??= loadPreferences()
53 + .then((preferences) => {
54 + selections = { ...preferences.workspaceSelections, ...selections };
55 + saved = selections;
56 + AppState.addEventListener("change", (status) => {
57 + if (status !== "active") save();
58 + });
59 + })
60 + .catch(() => undefined);
61 + return hydration;
62 +}
63 +
64 +export function currentWorkspaceSelections() {
65 + return selections;
66 +}
67 +
68 +/** The navigation container's `onStateChange`: remembers the page each tab is showing. */
69 +export function recordWorkspaceSelections(state: NavigationState | undefined) {
70 + if (!REMEMBERS || !state) return;
71 + selections = workspaceSelectionsIn(state.routes.slice(0, state.index + 1), selections);
72 +}
73 +
74 +function environmentRemoved(environmentId: string) {
75 + const catalog = appAtomRegistry.get(environmentCatalog.catalogValueAtom);
76 + return (
77 + catalog.isReady &&
78 + !appAtomRegistry
79 + .get(environmentPresentations.presentationsAtom)
80 + .has(environmentId as EnvironmentId)
81 + );
82 +}
83 +
84 +/**
85 + * A remembered chat is gone once its environment was removed, or once that environment's
86 + * snapshot has loaded without it. Before it loads there is nothing to contradict it.
87 + */
88 +export const workspaceSelectionCheck: WorkspaceSelectionCheck = {
89 + thread: (selection) => {
90 + if (environmentRemoved(selection.environmentId)) return false;
91 + const environmentId = selection.environmentId as EnvironmentId;
92 + if (!appAtomRegistry.get(threadEnvironment.snapshotAtom(environmentId))) return true;
93 + return appAtomRegistry
94 + .get(environmentThreadShells.environmentThreadIndexAtom(environmentId))
95 + .has(selection.threadId as ThreadId);
96 + },
97 + pullRequest: (selection) => !environmentRemoved(selection.environmentId),
98 +};
99 +
100 +/** Whether the window lays the workspace out in columns, by the rule the layout itself uses. */
101 +export function workspaceHasColumns() {
102 + const metrics = currentNativeLayoutMetrics();
103 + const { width, height } = metrics ?? Dimensions.get("window");
104 + return deriveLayout({
105 + width,
106 + height,
107 + nativeMetrics: metrics,
108 + nativeWorkspace: nativeWorkspaceColumnsSupportedFor(metrics),
109 + }).usesSplitView;
110 +}
111 +
112 +/** The Settings page a bare `settings` link opens beside the list when there are columns. */
113 +export function settingsLinkPage() {
114 + return REMEMBERS && workspaceHasColumns() ? rememberedSettingsPage(selections) : undefined;
115 +}
116 +
117 +/**
118 + * Where a cold start without a link opens. A window that starts with columns reopens the last
119 + * chat beside the list instead of an empty detail column; a compact window opens on the list.
120 + * It waits for the first layout metrics as long as the workspace itself does.
121 + */
122 +export async function launchWorkspaceURL(): Promise<string | null> {
123 + if (!REMEMBERS) return null;
124 + await Promise.all([
125 + hydrateWorkspaceSelections(),
126 + firstNativeLayoutMetrics(NATIVE_METRICS_TIMEOUT_MS),
127 + ]);
128 + const thread = selections.threads;
129 + if (!thread || !workspaceHasColumns() || !workspaceSelectionCheck.thread(thread)) return null;
130 + return Linking.createURL(
131 + `threads/${encodeURIComponent(thread.environmentId)}/${encodeURIComponent(thread.threadId)}`,
132 + );
133 +}
134 +
135 +/** Whether the workspace shows its first detail page, directly above its list. */
136 +export function firstWorkspaceDetailOpen(navigation: RootStackNavigation) {
137 + const state = rootStackState(navigation);
138 + if (!state) return false;
139 + const { workspace, overlays } = workspaceRoutesOf(state.routes.slice(0, state.index + 1));
140 + const list = (name: string | undefined) => name === "Home" || name === "Settings";
141 + return overlays.length === 0 && !list(workspace.at(-1)?.name) && list(workspace.at(-2)?.name);
142 +}
apps/mobile/src/features/workspace/workspace-tab-navigation.test.ts new
+162
@@ -0,0 +1,162 @@
1 +import { describe, expect, it } from "vite-plus/test";
2 +
3 +import { restoreSettingsLinkState } from "../settings/settings-navigation";
4 +import { workspaceSelectionsIn, workspaceTabNavigationState } from "./workspace-tab-navigation";
5 +
6 +const home = { key: "home", name: "Home" };
7 +const thread = {
8 + key: "thread",
9 + name: "Thread",
10 + params: { environmentId: "env", threadId: "thread-a" },
11 +};
12 +const pullRequest = {
13 + key: "pr",
14 + name: "PullRequest",
15 + params: { environmentId: "env", projectId: "project", repository: "o/r", number: 7 },
16 +};
17 +const settings = { key: "settings", name: "Settings" };
18 +const available = { thread: () => true, pullRequest: () => true };
19 +const names = (state: { routes: readonly { name: string }[] }) =>
20 + state.routes.map((route) => route.name);
21 +
22 +describe("workspace tab selections", () => {
23 + it("remembers the chat, pull request and Settings page each tab showed", () => {
24 + const afterThread = workspaceSelectionsIn([home, thread], {});
25 + const afterPullRequest = workspaceSelectionsIn([home, pullRequest], afterThread);
26 + expect(afterPullRequest).toMatchObject({
27 + threads: thread.params,
28 + pullRequests: pullRequest.params,
29 + });
30 + const afterSettings = workspaceSelectionsIn(
31 + [home, settings, { key: "appearance", name: "SettingsAppearance" }],
32 + afterPullRequest,
33 + );
34 + expect(afterSettings.settings).toBe("SettingsAppearance");
35 + expect(workspaceSelectionsIn([home, thread], afterSettings)).toBe(afterSettings);
36 + });
37 +
38 + it("doesn't remember pages a Settings row doesn't open", () => {
39 + for (const name of ["SettingsEnvironmentNew", "SettingsProjectOverview", "SettingsAuth"]) {
40 + expect(workspaceSelectionsIn([home, settings, { key: name, name }], {}).settings).toBe(
41 + undefined,
42 + );
43 + }
44 + });
45 +});
46 +
47 +describe("opening a workspace tab", () => {
48 + const columns = { columns: true, check: available };
49 +
50 + it("opens the remembered page beside the list with columns, and the list without", () => {
51 + const state = { routes: [home, thread] };
52 + const selections = { threads: thread.params, pullRequests: pullRequest.params };
53 + expect(names(workspaceTabNavigationState(state, "pullRequests", selections, columns))).toEqual([
54 + "Home",
55 + "PullRequest",
56 + ]);
57 + expect(
58 + names(
59 + workspaceTabNavigationState(state, "pullRequests", selections, {
60 + columns: false,
61 + check: available,
62 + }),
63 + ),
64 + ).toEqual(["Home"]);
65 + expect(names(workspaceTabNavigationState(state, "settings", {}, columns))).toEqual([
66 + "Home",
67 + "Settings",
68 + "SettingsEnvironments",
69 + ]);
70 + });
71 +
72 + it("keeps the route that is already open, so re-selecting a tab doesn't rebuild it", () => {
73 + const next = workspaceTabNavigationState(
74 + { routes: [home, thread] },
75 + "threads",
76 + { threads: thread.params },
77 + columns,
78 + );
79 + expect(next.routes.map((route) => route.key)).toEqual(["home", "thread"]);
80 + });
81 +
82 + it("reopens a tab's page under the key it had, so its kept screen is reused", () => {
83 + const columnsAvailable = { columns: true, check: available };
84 + let selections = workspaceSelectionsIn([home, thread], {});
85 + const away = workspaceTabNavigationState(
86 + { routes: [home, thread] },
87 + "pullRequests",
88 + selections,
89 + {
90 + columns: false,
91 + check: available,
92 + },
93 + );
94 + selections = workspaceSelectionsIn(away.routes, selections);
95 + const back = workspaceTabNavigationState(away, "threads", selections, columnsAvailable);
96 + expect(back.routes.at(-1)).toMatchObject({ key: "thread", params: thread.params });
97 + });
98 +
99 + it("falls back to the list for a chat that no longer exists, or an unknown Settings page", () => {
100 + const missing = { thread: () => false, pullRequest: () => true };
101 + expect(
102 + names(
103 + workspaceTabNavigationState(
104 + { routes: [home] },
105 + "threads",
106 + { threads: thread.params },
107 + {
108 + columns: true,
109 + check: missing,
110 + },
111 + ),
112 + ),
113 + ).toEqual(["Home"]);
114 + expect(
115 + names(
116 + workspaceTabNavigationState(
117 + { routes: [home] },
118 + "settings",
119 + { settings: "SettingsGone" },
120 + columns,
121 + ),
122 + ),
123 + ).toEqual(["Home", "Settings", "SettingsEnvironments"]);
124 + });
125 +
126 + it("keeps an open sheet on top", () => {
127 + const sheet = { key: "sheet", name: "ConnectOnboarding" };
128 + const next = workspaceTabNavigationState(
129 + { routes: [home] },
130 + "threads",
131 + { threads: thread.params },
132 + {
133 + ...columns,
134 + overlays: [sheet],
135 + },
136 + );
137 + expect(names(next)).toEqual(["Home", "Thread", "ConnectOnboarding"]);
138 + expect(next.index).toBe(2);
139 + });
140 +});
141 +
142 +describe("Settings links", () => {
143 + it("puts the Settings list under a linked page, and a page beside a bare link with columns", () => {
144 + const linked = restoreSettingsLinkState(
145 + { routes: [{ name: "Home" }, { name: "SettingsKeyboard" }] },
146 + undefined,
147 + );
148 + expect(names(linked!)).toEqual(["Home", "Settings", "SettingsKeyboard"]);
149 + const bare = { routes: [{ name: "Home" }, { name: "Settings" }] };
150 + expect(names(restoreSettingsLinkState(bare, "SettingsAppearance")!)).toEqual([
151 + "Home",
152 + "Settings",
153 + "SettingsAppearance",
154 + ]);
155 + expect(restoreSettingsLinkState(bare, undefined)).toBe(bare);
156 + });
157 +
158 + it("opens the sign-in link as a modal over the workspace", () => {
159 + const state = { routes: [{ name: "Home" }, { name: "SettingsAuth" }] };
160 + expect(restoreSettingsLinkState(state, "SettingsAppearance")).toBe(state);
161 + });
162 +});
apps/mobile/src/features/workspace/workspace-tab-navigation.ts new
+202
@@ -0,0 +1,202 @@
1 +import type { WorkspaceSelections } from "../../persistence/mobile-preferences";
2 +import {
3 + SETTINGS_PAGE_TARGETS,
4 + type SettingsPageTarget,
5 +} from "../settings/components/settings-page-targets";
6 +import { settingsNavigationState } from "../settings/settings-navigation";
7 +import type { WorkspaceTab } from "./workspace-tabs-state";
8 +
9 +type RouteLike = {
10 + readonly name: string;
11 + readonly key?: string;
12 + readonly params?: object | undefined;
13 +};
14 +type ThreadSelection = NonNullable<WorkspaceSelections["threads"]>;
15 +type PullRequestSelection = NonNullable<WorkspaceSelections["pullRequests"]>;
16 +
17 +/** Opened when Settings has columns and none of its pages has been opened yet. */
18 +export const DEFAULT_SETTINGS_PAGE = "SettingsEnvironments" satisfies SettingsPageTarget;
19 +
20 +// Pages a Settings row opens, minus Project overview: it shows the project chosen in the
21 +// Settings scope, which resets whenever Settings closes.
22 +const REMEMBERED_SETTINGS_PAGES: ReadonlySet<string> = new Set(
23 + SETTINGS_PAGE_TARGETS.filter((page) => page !== "SettingsProjectOverview"),
24 +);
25 +
26 +export function rememberedSettingsPage(selections: WorkspaceSelections): SettingsPageTarget {
27 + return selections.settings && REMEMBERED_SETTINGS_PAGES.has(selections.settings)
28 + ? (selections.settings as SettingsPageTarget)
29 + : DEFAULT_SETTINGS_PAGE;
30 +}
31 +
32 +/** Whether a remembered chat or pull request can still be opened. */
33 +export interface WorkspaceSelectionCheck {
34 + readonly thread: (selection: ThreadSelection) => boolean;
35 + readonly pullRequest: (selection: PullRequestSelection) => boolean;
36 +}
37 +
38 +function stringParam(params: object | undefined, key: string) {
39 + const value = (params as Record<string, unknown> | undefined)?.[key];
40 + return typeof value === "string" ? value : undefined;
41 +}
42 +
43 +function pullRequestSelection(
44 + params: object | undefined,
45 +): Omit<PullRequestSelection, "key"> | undefined {
46 + const value = params as Record<string, unknown> | undefined;
47 + if (
48 + typeof value?.environmentId !== "string" ||
49 + typeof value.projectId !== "string" ||
50 + typeof value.repository !== "string" ||
51 + typeof value.number !== "number"
52 + ) {
53 + return undefined;
54 + }
55 + return {
56 + environmentId: value.environmentId,
57 + projectId: value.projectId,
58 + repository: value.repository,
59 + number: value.number,
60 + ...(typeof value.host === "string" ? { host: value.host } : {}),
61 + };
62 +}
63 +
64 +function samePullRequest(
65 + left: PullRequestSelection | undefined,
66 + right: Omit<PullRequestSelection, "key">,
67 +) {
68 + return (
69 + left?.environmentId === right.environmentId &&
70 + left.projectId === right.projectId &&
71 + left.repository === right.repository &&
72 + left.number === right.number &&
73 + left.host === right.host
74 + );
75 +}
76 +
77 +/**
78 + * The page each tab shows in a root route chain: the newest chat, the newest pull request, and
79 + * the Settings page directly above the Settings route. Returns `previous` when nothing changed.
80 + */
81 +export function workspaceSelectionsIn(
82 + routes: readonly RouteLike[],
83 + previous: WorkspaceSelections,
84 +): WorkspaceSelections {
85 + let next = previous;
86 + const thread = routes.findLast((route) => route.name === "Thread");
87 + const environmentId = stringParam(thread?.params, "environmentId");
88 + const threadId = stringParam(thread?.params, "threadId");
89 + if (
90 + environmentId &&
91 + threadId &&
92 + (next.threads?.environmentId !== environmentId ||
93 + next.threads.threadId !== threadId ||
94 + next.threads.key !== thread?.key)
95 + ) {
96 + next = { ...next, threads: { environmentId, threadId, key: thread?.key } };
97 + }
98 + const pullRequestRoute = routes.findLast((route) => route.name === "PullRequest");
99 + const pullRequest = pullRequestSelection(pullRequestRoute?.params);
100 + if (
101 + pullRequest &&
102 + (!samePullRequest(next.pullRequests, pullRequest) ||
103 + next.pullRequests?.key !== pullRequestRoute?.key)
104 + ) {
105 + next = { ...next, pullRequests: { ...pullRequest, key: pullRequestRoute?.key } };
106 + }
107 + const list = routes.findIndex((route) => route.name === "Settings");
108 + const page = list < 0 ? undefined : routes[list + 1];
109 + if (
110 + page &&
111 + REMEMBERED_SETTINGS_PAGES.has(page.name) &&
112 + (page.name !== next.settings || page.key !== next.settingsKey)
113 + ) {
114 + next = { ...next, settings: page.name, settingsKey: page.key };
115 + }
116 + return next;
117 +}
118 +
119 +function identityOf({ key: _key, ...identity }: PullRequestSelection) {
120 + return identity;
121 +}
122 +
123 +let routeKeys = 0;
124 +
125 +/** New routes get their key here, so the caller knows which route it is about to show. */
126 +function keyed<Route extends RouteLike>(route: Route): Route & { readonly key: string } {
127 + if (route.key !== undefined) return route as Route & { readonly key: string };
128 + routeKeys += 1;
129 + return { ...route, key: `${route.name}-workspace-${routeKeys}` };
130 +}
131 +
132 +function detailRoute(
133 + state: { readonly routes: readonly RouteLike[] },
134 + tab: "threads" | "pullRequests",
135 + selections: WorkspaceSelections,
136 + check: WorkspaceSelectionCheck,
137 +): RouteLike | undefined {
138 + if (tab === "threads") {
139 + const thread = selections.threads;
140 + if (!thread || !check.thread(thread)) return undefined;
141 + return (
142 + state.routes.find(
143 + (route) =>
144 + route.name === "Thread" &&
145 + stringParam(route.params, "environmentId") === thread.environmentId &&
146 + stringParam(route.params, "threadId") === thread.threadId,
147 + ) ?? {
148 + key: thread.key,
149 + name: "Thread",
150 + params: { environmentId: thread.environmentId, threadId: thread.threadId },
151 + }
152 + );
153 + }
154 + const pullRequest = selections.pullRequests;
155 + if (!pullRequest || !check.pullRequest(pullRequest)) return undefined;
156 + return (
157 + state.routes.find(
158 + (route) =>
159 + route.name === "PullRequest" &&
160 + samePullRequest(pullRequestSelection(route.params), pullRequest),
161 + ) ?? { key: pullRequest.key, name: "PullRequest", params: identityOf(pullRequest) }
162 + );
163 +}
164 +
165 +/**
166 + * The root stack for opening a workspace tab. With columns the detail column must show
167 + * something, so the tab reopens the page it last showed (Settings falls back to its default);
168 + * without columns the tab opens on its list. Routes already on screen keep their keys, and
169 + * `overlays` (open sheets) stay on top.
170 + */
171 +export function workspaceTabNavigationState<
172 + State extends { readonly routes: readonly RouteLike[] },
173 +>(
174 + state: State,
175 + tab: WorkspaceTab | "settings",
176 + selections: WorkspaceSelections,
177 + options: {
178 + readonly columns: boolean;
179 + readonly check: WorkspaceSelectionCheck;
180 + readonly overlays?: readonly RouteLike[];
181 + },
182 +) {
183 + const overlays = options.overlays ?? [];
184 + if (tab === "settings") {
185 + const page = options.columns ? rememberedSettingsPage(selections) : undefined;
186 + const settings = settingsNavigationState(
187 + state,
188 + page,
189 + undefined,
190 + page === selections.settings ? selections.settingsKey : undefined,
191 + );
192 + const routes = [...settings.routes.map(keyed), ...overlays];
193 + return { ...settings, index: routes.length - 1, routes };
194 + }
195 + const home = state.routes.find((route) => route.name === "Home") ?? { name: "Home" };
196 + const detail =
197 + options.columns && tab !== "usage"
198 + ? detailRoute(state, tab, selections, options.check)
199 + : undefined;
200 + const routes = [...[home, ...(detail ? [detail] : [])].map(keyed), ...overlays];
201 + return { ...state, index: routes.length - 1, routes };
202 +}
apps/mobile/src/features/workspace/workspace-tabs-state.test.ts
+3 -8
@@ -49,16 +49,11 @@ describe("Duo list clearance", () => {
49 });
50
51 describe("workspace root navigation", () => {
52 - it("keeps Usage and Settings out of the list/detail layout", () => {
52 + it("pairs Settings, chats and pull requests with a detail column, and keeps Usage one page", () => {
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", () => {
54 + expect(workspaceUsesColumns("usage", true)).toBe(true);
55 expect(workspaceUsesColumns("threads")).toBe(true);
60 - expect(workspaceUsesColumns("threads", "Thread")).toBe(true);
61 - expect(workspaceUsesColumns("pullRequests", "PullRequest")).toBe(true);
56 + expect(workspaceUsesColumns("pullRequests")).toBe(true);
57 });
58
59 it("keeps the registered defaults while customization is unavailable", () => {
apps/mobile/src/features/workspace/workspace-tabs-state.ts
+3 -2
@@ -14,8 +14,9 @@ export function resolveWorkspaceTabOrder(saved: readonly unknown[] | undefined)
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";
17 +/** Settings, Chats and pull requests pair a list with a detail column; Usage is one page. */
18 +export function workspaceUsesColumns(tab: WorkspaceTab, settingsOpen = false) {
19 + return settingsOpen || tab === "threads" || tab === "pullRequests";
20 }
21
22 export interface WorkspaceTabState {
apps/mobile/src/lib/adaptive-navigation.test.ts
+4 -4
@@ -39,7 +39,7 @@ describe("resolveThreadSelectionOverlayState", () => {
39 key: "workspace",
40 type: "stack",
41 stale: false as const,
42 - routeNames: ["Home", "Thread", "ThreadFiles", "SettingsSheet", "SettingsLegal"],
42 + routeNames: ["Home", "Thread", "ThreadFiles", "Connections", "SettingsLegal"],
43 };
44 const home = { key: "home", name: "Home" };
45 const thread = {
@@ -48,7 +48,7 @@ describe("resolveThreadSelectionOverlayState", () => {
48 params: { environmentId: "environment", threadId: "old-thread" },
49 };
50 const files = { key: "files", name: "ThreadFiles", params: thread.params };
51 - const settings = { key: "settings", name: "SettingsSheet" };
51 + const settings = { key: "settings", name: "Connections" };
52 const params = { environmentId: "environment", threadId: "new-thread" };
53
54 it("replaces the underlying file route and dismisses every overlay above it", () => {
@@ -98,11 +98,11 @@ it("replacing a draft underneath an overlay removes its draft identity", () => {
98 key: "root",
99 type: "stack",
100 stale: false,
101 - routeNames: ["Thread", "SettingsSheet"],
101 + routeNames: ["Thread", "Connections"],
102 index: 1,
103 routes: [
104 { key: "draft", name: "Thread", params: { draft: { draftId: "old" } } },
105 - { key: "settings", name: "SettingsSheet" },
105 + { key: "settings", name: "Connections" },
106 ],
107 },
108 workspaceRouteKey: "draft",
apps/mobile/src/lib/android-workspace-navigation.test.ts
+22 -34
@@ -12,8 +12,8 @@ import {
12 resetAndroidWorkspace,
13 returnToAndroidWorkspaceList,
14 type AndroidWorkspaceDestination,
15 - type AndroidWorkspaceResetAction,
15 } from "./android-workspace-navigation";
16 +import type { RootStackResetAction } from "./root-stack-reset";
17
18 const require = NodeModule.createRequire(import.meta.url);
19 const nativePackage = require.resolve("@react-navigation/native/package.json");
@@ -38,7 +38,9 @@ const options = {
38 "PullRequest",
39 "PullRequestFile",
40 "PullRequestReviewers",
41 - "SettingsSheet",
41 + "Settings",
42 + "SettingsUsage",
43 + "SettingsUsageAccount",
44 ],
45 routeParamList: {},
46 routeGetIdList: {},
@@ -159,7 +161,7 @@ describe("Android workspace navigation", () => {
161 );
162 let listSelected = false;
163 const navigation = {
162 - dispatch: (action: AndroidWorkspaceResetAction) => {
164 + dispatch: (action: RootStackResetAction) => {
165 state = apply(state, action);
166 },
167 getParent: () => undefined,
@@ -248,13 +250,10 @@ describe("Android workspace navigation", () => {
250 ).toBe(false);
251 });
252
251 - it("resets the root stack when a nested Settings stack has focus", () => {
252 - const root = apply(router.getInitialState(options), StackActions.push("SettingsSheet"));
253 - const settings = router.getInitialState({
254 - ...options,
255 - routeNames: ["SettingsContent", "SettingsEnvironments"],
256 - });
257 - const actions: AndroidWorkspaceResetAction[] = [];
253 + it("resets the root stack when a nested stack has focus", () => {
254 + const root = apply(router.getInitialState(options), StackActions.push("Thread", thread.params));
255 + const nested = router.getInitialState({ ...options, routeNames: ["Nested", "NestedChild"] });
256 + const actions: RootStackResetAction[] = [];
257 const rootNavigation = {
258 dispatch: () => undefined,
259 getParent: () => undefined,
@@ -264,7 +263,7 @@ describe("Android workspace navigation", () => {
263 {
264 dispatch: (action) => actions.push(action),
265 getParent: () => rootNavigation,
267 - getState: () => settings,
266 + getState: () => nested,
267 },
268 thread,
269 );
@@ -275,7 +274,7 @@ describe("Android workspace navigation", () => {
274
275 it("resets from the navigation container before any navigation action", () => {
276 const root = router.getInitialState(options);
278 - const actions: AndroidWorkspaceResetAction[] = [];
277 + const actions: RootStackResetAction[] = [];
278 // The container only learns the root state after the first action.
279 resetAndroidWorkspace(
280 {
@@ -303,7 +302,7 @@ describe("Android Settings tab", () => {
302 it("opens over Home alone, dropping chat and PR history, and Back returns to Home", () => {
303 const previous = legacyHistory();
304 const settings = openTab(previous, "settings");
306 - expect(names(settings)).toEqual(["Home", "SettingsSheet"]);
305 + expect(names(settings)).toEqual(["Home", "Settings"]);
306 expect(settings.routes[0]?.key).toBe(previous.routes[0]?.key);
307 expect(selectedTab(settings, "threads")).toBe("settings");
308 const back = apply(settings, StackActions.pop());
@@ -312,32 +311,21 @@ describe("Android Settings tab", () => {
311 expect(selectedTab(back, "settings")).not.toBe("settings");
312 });
313
315 - it("stays selected under a nested settings page until a list tab returns to Home", () => {
314 + it("stays selected under a settings page until a list tab returns to Home", () => {
315 const previous = legacyHistory();
317 - const settings = openTab(previous, "settings");
318 - // Usage pushes inside the nested settings navigator, which the root router never sees.
319 - const usage: State = {
320 - ...settings,
321 - routes: settings.routes.map((route) =>
322 - route.name === "SettingsSheet"
323 - ? {
324 - ...route,
325 - state: {
326 - routes: [
327 - {
328 - name: "SettingsContent",
329 - state: { index: 1, routes: [{ name: "Settings" }, { name: "SettingsUsage" }] },
330 - },
331 - ],
332 - },
333 - }
334 - : route,
335 - ),
336 - };
316 + const usage = apply(openTab(previous, "settings"), StackActions.push("SettingsUsage"));
317 expect(selectedTab(usage, "threads")).toBe("settings");
318 const list = openTab(usage, "pullRequests");
319 expect(names(list)).toEqual(["Home"]);
320 expect(list.routes[0]?.key).toBe(previous.routes[0]?.key);
321 expect(selectedTab(list, "pullRequests")).toBe("pullRequests");
322 });
323 +
324 + it("leaves a settings page opened from the Usage tab in that tab", () => {
325 + const account = apply(
326 + router.getInitialState(options),
327 + StackActions.push("SettingsUsageAccount"),
328 + );
329 + expect(selectedTab(account, "usage")).toBe("usage");
330 + });
331 });
apps/mobile/src/lib/android-workspace-navigation.ts
+8 -31
@@ -1,21 +1,10 @@
1 -import type { CommonActions, NavigationState } from "@react-navigation/native";
1 +import type { NavigationState } from "@react-navigation/native";
2 +import { resetRootStack, type RootStackNavigation } from "./root-stack-reset";
3
4 export type AndroidWorkspaceDestination =
5 | { readonly name: "Thread"; readonly params: ReactNavigation.RootParamList["Thread"] }
6 | { readonly name: "PullRequest"; readonly params: ReactNavigation.RootParamList["PullRequest"] };
7
7 -export type AndroidWorkspaceResetAction = ReturnType<typeof CommonActions.reset> & {
8 - readonly target: string;
9 -};
10 -
11 -interface WorkspaceNavigation {
12 - readonly dispatch: (action: AndroidWorkspaceResetAction) => void;
13 - readonly getParent: () => WorkspaceNavigation | undefined;
14 - readonly getState: () => NavigationState | undefined;
15 - /** Only on the navigation container, whose `getState` stays empty until the first action. */
16 - readonly getRootState?: () => NavigationState | undefined;
17 -}
18 -
8 function androidWorkspaceBackReturnsToThread(state: NavigationState) {
9 const current = state.routes[state.index];
10 const params = current?.params as ReactNavigation.RootParamList["Thread"] | undefined;
@@ -55,27 +44,15 @@ export function androidWorkspaceNavigationState(
44 };
45 }
46
58 -/**
59 - * Resets the root stack to a workspace list or detail. Always reads and targets the root
60 - * navigator: the sidebar and rail render in the root layout, where `useNavigation()` is the
61 - * container, and a container dispatch runs on the deepest focused navigator. With Settings
62 - * or New task open, that is their nested stack, which rejects the reset.
63 - */
47 +/** Resets the root stack to a workspace list or detail. */
48 export function resetAndroidWorkspace(
65 - navigation: WorkspaceNavigation,
49 + navigation: RootStackNavigation,
50 destination?: AndroidWorkspaceDestination,
51 reviewers?: ReactNavigation.RootParamList["PullRequestReviewers"],
52 ) {
69 - let root = navigation;
70 - for (let parent = root.getParent(); parent; parent = root.getParent()) root = parent;
71 - const state = root.getRootState?.() ?? root.getState();
72 - if (!state) return;
73 - // Same shape as `CommonActions.reset`, which would pull React Native into node tests.
74 - navigation.dispatch({
75 - type: "RESET",
76 - payload: androidWorkspaceNavigationState(state, destination, reviewers),
77 - target: state.key,
78 - });
53 + resetRootStack(navigation, (state) =>
54 + androidWorkspaceNavigationState(state, destination, reviewers),
55 + );
56 }
57
58 export function parentThreadIsBelow(
@@ -114,7 +91,7 @@ export function linkedThreadStep(
91 }
92
93 export function returnToAndroidWorkspaceList(
117 - navigation: WorkspaceNavigation & { readonly goBack: () => void },
94 + navigation: RootStackNavigation & { readonly goBack: () => void },
95 selectTab: () => void,
96 ) {
97 const state = navigation.getState();
apps/mobile/src/lib/layout.ts
+6 -1
@@ -175,12 +175,17 @@ export function alignListPaneToHinge(input: {
175 * collapse it there. Compact layouts stay pinned so a reveal request (such as
176 * focusing search) cannot flip the saved preference for a later split view.
177 */
178 +/** Home's list, or the Settings list in its place, with no detail selected. */
179 +export function isWorkspaceListPath(pathname: string): boolean {
180 + return pathname === "/" || pathname === "/settings";
181 +}
182 +
183 export function isPrimarySidebarPinned(input: {
184 readonly pathname: string;
185 readonly nativeWorkspace: boolean;
186 readonly usesSplitView: boolean;
187 }): boolean {
183 - return input.pathname === "/" && !(input.nativeWorkspace && input.usesSplitView);
188 + return isWorkspaceListPath(input.pathname) && !(input.nativeWorkspace && input.usesSplitView);
189 }
190
191 export function deriveWorkspacePaneLayout(input: {
apps/mobile/src/lib/root-stack-reset.ts new
+44
@@ -0,0 +1,44 @@
1 +import type { CommonActions, NavigationState } from "@react-navigation/native";
2 +
3 +export type RootStackResetAction = ReturnType<typeof CommonActions.reset> & {
4 + readonly target: string;
5 +};
6 +
7 +export interface RootStackNavigation {
8 + readonly dispatch: (action: RootStackResetAction) => void;
9 + readonly getParent: () => RootStackNavigation | undefined;
10 + readonly getState: () => NavigationState | undefined;
11 + /** Only on the navigation container, whose `getState` stays empty until the first action. */
12 + readonly getRootState?: () => NavigationState | undefined;
13 +}
14 +
15 +/**
16 + * The root stack's state, read from anywhere. The sidebar and rail render in the root layout,
17 + * where `useNavigation()` is the container, so walk up to the root navigator.
18 + */
19 +export function rootStackState(navigation: RootStackNavigation) {
20 + let root = navigation;
21 + for (let parent = root.getParent(); parent; parent = root.getParent()) root = parent;
22 + return root.getRootState?.() ?? root.getState();
23 +}
24 +
25 +/**
26 + * Replaces the root stack. Targets the root explicitly: a container dispatch runs on the deepest
27 + * focused navigator, which can be a nested stack that rejects the reset.
28 + */
29 +export function dispatchRootStackReset(
30 + navigation: RootStackNavigation,
31 + state: NavigationState,
32 + payload: RootStackResetAction["payload"],
33 +) {
34 + // Same shape as `CommonActions.reset`, which would pull React Native into node tests.
35 + navigation.dispatch({ type: "RESET", payload, target: state.key });
36 +}
37 +
38 +export function resetRootStack(
39 + navigation: RootStackNavigation,
40 + nextState: (state: NavigationState) => RootStackResetAction["payload"],
41 +) {
42 + const state = rootStackState(navigation);
43 + if (state) dispatchRootStackReset(navigation, state, nextState(state));
44 +}
apps/mobile/src/native/NativeHeaderToolbar.test.tsx
+5 -1
@@ -19,7 +19,9 @@ const harness = vi.hoisted(() => ({
19
20 // Native headers retain the actions materialized when navigation applies options. Like React
21 // Navigation, the header renders again only when the options are no longer shallowly equal.
22 -vi.mock("@react-navigation/native", () => {
22 +vi.mock("@react-navigation/native", async () => {
23 + // vi.mock factories run before the file's imports.
24 + const { createContext } = await vi.importActual<typeof import("react")>("react");
25 const navigation = {
26 setOptions(options: HeaderOptions) {
27 harness.setOptionsCalls += 1;
@@ -39,6 +41,8 @@ vi.mock("@react-navigation/native", () => {
41 },
42 };
43 return {
44 + // Outside a workspace tab slot the header writes to the route's navigation.
45 + NavigationRouteContext: createContext(undefined),
46 useNavigation: () => navigation,
47 useRoute: () => ({ key: "file", name: "ThreadFile", params: harness.params }),
48 };
apps/mobile/src/native/NativeHeaderToolbar.tsx
+8 -13
@@ -1,9 +1,8 @@
1 -import { useNavigation, useRoute, type ParamListBase } from "@react-navigation/native";
1 +import { useRoute } from "@react-navigation/native";
2 import type {
3 NativeStackHeaderItem,
4 NativeStackHeaderItemMenu,
5 NativeStackNavigationOptions,
6 - NativeStackNavigationProp,
6 } from "@react-navigation/native-stack";
7 import {
8 Children,
@@ -17,11 +16,7 @@ import {
16 import type { ColorValue } from "react-native";
17 import type { HeaderBarButtonSearchBarPlacementItem } from "react-native-screens";
18 import { NativeWorkspaceTabActivityContext } from "./v5-workspace-context";
20 -import { NativeStackScreenOptions } from "./StackHeader";
21 -
22 -function useNativeStackNavigation(): NativeStackNavigationProp<ParamListBase> | null {
23 - return useNavigation<NativeStackNavigationProp<ParamListBase>>();
24 -}
19 +import { NativeStackScreenOptions, useScreenOptionsWriter } from "./StackHeader";
20
21 function labelFromChildren(children: ReactNode): string {
22 const parts: string[] = [];
@@ -230,7 +225,7 @@ function NativeHeaderToolbarRoot(props: {
225 readonly placement?: "left" | "right" | "bottom";
226 readonly children?: ReactNode;
227 }) {
233 - const navigation = useNativeStackNavigation();
228 + const setOptions = useScreenOptionsWriter();
229 const route = useRoute();
230 const tabActivity = use(NativeWorkspaceTabActivityContext);
231 const isTabActive = tabActivity?.isActive;
@@ -242,20 +237,20 @@ function NativeHeaderToolbarRoot(props: {
237 );
238
239 useLayoutEffect(() => {
245 - if (!navigation) return;
240 + if (!setOptions) return;
241 return () => {
242 if (isTabActive && !isTabActive()) return;
243 if (props.placement === "bottom") {
249 - navigation.setOptions({
244 + setOptions({
245 unstable_headerToolbarItems: () => [],
246 } as NativeStackOptionsWithToolbar);
247 } else if (props.placement === "left") {
253 - navigation.setOptions({ unstable_headerLeftItems: () => [] });
248 + setOptions({ unstable_headerLeftItems: () => [] });
249 } else {
255 - navigation.setOptions({ unstable_headerRightItems: () => [] });
250 + setOptions({ unstable_headerRightItems: () => [] });
251 }
252 };
258 - }, [navigation, props.placement, isTabActive]);
253 + }, [setOptions, props.placement, isTabActive]);
254
255 return (
256 <NativeStackScreenOptions
apps/mobile/src/native/NativeWorkspaceColumns.ios.tsx
+11 -6
@@ -1,6 +1,7 @@
1 import { requireOptionalNativeModule } from "expo";
2 import { useEffect, useState } from "react";
3 import { Platform } from "react-native";
4 +import type { NativeLayoutMetrics } from "../lib/reserved-regions";
5 import { useNativeLayoutMetrics } from "./native-layout-metrics";
6
7 const nativeControls = requireOptionalNativeModule<{
@@ -10,9 +11,17 @@ const nativeControls = requireOptionalNativeModule<{
11 export const NATIVE_WORKSPACE_COLUMNS_SUPPORTED =
12 Platform.OS === "ios" && Platform.isPad && nativeControls?.supportsWorkspaceColumns === true;
13
14 +/** Whether a window with these metrics lays the workspace out in UIKit columns. */
15 +export function nativeWorkspaceColumnsSupportedFor(metrics: NativeLayoutMetrics | null) {
16 + return (
17 + NATIVE_WORKSPACE_COLUMNS_SUPPORTED ||
18 + (nativeControls?.supportsWorkspaceColumns === true && metrics?.hasHinge === true)
19 + );
20 +}
21 +
22 // Binaries without the native no-hinge fallback never report metrics on ordinary
23 // iPhones running iOS 27.1 or later. Use the compact navigator rather than staying blank.
15 -const NATIVE_METRICS_TIMEOUT_MS = 1000;
24 +export const NATIVE_METRICS_TIMEOUT_MS = 1000;
25
26 export function useNativeWorkspaceColumnsReady() {
27 const metrics = useNativeLayoutMetrics();
@@ -32,9 +41,5 @@ export function useNativeWorkspaceColumnsReady() {
41 }
42
43 export function useNativeWorkspaceColumnsSupported() {
35 - const metrics = useNativeLayoutMetrics();
36 - return (
37 - NATIVE_WORKSPACE_COLUMNS_SUPPORTED ||
38 - (nativeControls?.supportsWorkspaceColumns === true && metrics?.hasHinge === true)
39 - );
44 + return nativeWorkspaceColumnsSupportedFor(useNativeLayoutMetrics());
45 }
apps/mobile/src/native/NativeWorkspaceColumns.tsx
+5
@@ -1,5 +1,10 @@
1 import { Platform } from "react-native";
2 export const NATIVE_WORKSPACE_COLUMNS_SUPPORTED = Platform.OS === "ios" && Platform.isPad;
3 +export const NATIVE_METRICS_TIMEOUT_MS = 0;
4 +
5 +export function nativeWorkspaceColumnsSupportedFor(_metrics: unknown) {
6 + return NATIVE_WORKSPACE_COLUMNS_SUPPORTED;
7 +}
8
9 // oxlint-disable-next-line t3code/no-hookless-use-function -- Non-iOS stub of a hook; the .ios.tsx file calls hooks.
10 export function useNativeWorkspaceColumnsReady() {
apps/mobile/src/native/StackHeader.tsx
+30 -5
@@ -1,10 +1,17 @@
1 -import { useNavigation, type ParamListBase } from "@react-navigation/native";
1 +import {
2 + NavigationRouteContext,
3 + useNavigation,
4 + type ParamListBase,
5 +} from "@react-navigation/native";
6 import type {
7 NativeStackNavigationOptions,
8 NativeStackNavigationProp,
9 } from "@react-navigation/native-stack";
10 import { isValidElement, use, useEffect, useLayoutEffect, useMemo, useRef } from "react";
7 -import { NativeWorkspaceTabActivityContext } from "./v5-workspace-context";
11 +import {
12 + NativeWorkspaceTabActivityContext,
13 + WorkspaceSlotOptionsContext,
14 +} from "./v5-workspace-context";
15 import type { ColorValue } from "react-native";
16
17 export {
@@ -160,6 +167,23 @@ function stabilizeOptionFunctions(
167 return value;
168 }
169
170 +/**
171 + * Sets the current screen's options. Inside a workspace tab slot they're kept for that slot, so
172 + * slots rendering the same route never overwrite each other's header.
173 + */
174 +export function useScreenOptionsWriter() {
175 + const navigation = useNativeStackNavigation();
176 + const setSlotOptions = use(WorkspaceSlotOptionsContext)?.set;
177 + const routeKey = use(NavigationRouteContext)?.key;
178 + return useMemo(() => {
179 + if (setSlotOptions && routeKey !== undefined)
180 + return (options: NativeStackNavigationOptions) => setSlotOptions(routeKey, options);
181 + return navigation
182 + ? (options: NativeStackNavigationOptions) => navigation.setOptions(options)
183 + : null;
184 + }, [navigation, routeKey, setSlotOptions]);
185 +}
186 +
187 export function NativeStackScreenOptions(props: {
188 readonly options?: AppNativeStackNavigationOptions;
189 /**
@@ -173,6 +197,7 @@ export function NativeStackScreenOptions(props: {
197 readonly name?: string;
198 }) {
199 const navigation = useNativeStackNavigation();
200 + const setOptions = useScreenOptionsWriter();
201 const tabActive = use(NativeWorkspaceTabActivityContext)?.active ?? true;
202 const lastAppliedOptionsSignatureRef = useRef<string | undefined>(undefined);
203 const latestOptionFunctionsRef = useRef(new Map<string, (...args: unknown[]) => unknown>());
@@ -192,7 +217,7 @@ export function NativeStackScreenOptions(props: {
217 lastAppliedOptionsSignatureRef.current = undefined;
218 return;
219 }
195 - if (!navigation || !stableOptions) {
220 + if (!setOptions || !stableOptions) {
221 return;
222 }
223 const signature = optionsSignature([stableOptions, props.optionsVersion]);
@@ -204,7 +229,7 @@ export function NativeStackScreenOptions(props: {
229 // stabilized factories keep their identity, so one whose output changed needs a new wrapper
230 // to reach the header.
231 optionFunctionWrappersRef.current = new Map();
207 - navigation.setOptions(
232 + setOptions(
233 stabilizeOptionFunctions(
234 normalizedOptions,
235 "options",
@@ -212,7 +237,7 @@ export function NativeStackScreenOptions(props: {
237 optionFunctionWrappersRef.current,
238 ) as NativeStackNavigationOptions,
239 );
215 - }, [navigation, normalizedOptions, props.optionsVersion, stableOptions, tabActive]);
240 + }, [setOptions, normalizedOptions, props.optionsVersion, stableOptions, tabActive]);
241
242 useEffect(() => {
243 if (!navigation || !props.listeners) {
apps/mobile/src/native/createV5StackNavigator.ios.tsx
+13 -139
@@ -20,7 +20,8 @@ import {
20 type NativeStackNavigatorProps,
21 type NativeStackTypeBag,
22 } from "@react-navigation/native-stack";
23 -import { useCallback, useRef, useState, type ComponentProps } from "react";
23 +import { use, useCallback, useRef, useState, type ComponentProps } from "react";
24 +import { WorkspaceSlotOptionsContext, slotScreenOptions } from "./v5-workspace-context";
25 import { StyleSheet, View } from "react-native";
26 import { FormSheet, Stack } from "react-native-screens";
27 import { NativeScrollEdgeEffectsContext } from "./NativeScrollViewMarker";
@@ -56,6 +57,8 @@ export function V5CardStackView(
57 props: V5StackViewProps & { readonly onRootVisibilityChange?: (visible: boolean) => void },
58 ) {
59 const { preventedRoutes } = usePreventRemoveContext();
60 + // Options a screen set inside this workspace tab slot, over its route's.
61 + const slot = use(WorkspaceSlotOptionsContext);
62 const nativePopSource = useRef<string | null>(null);
63 const [screens, setScreens] = useState({
64 completedNativeDismissals: new Set<string>(),
@@ -148,6 +151,7 @@ export function V5CardStackView(
151 {screens.routes.map((route, index) => {
152 const descriptor = props.descriptors[route.key] ?? screens.descriptors[route.key];
153 if (!descriptor) return null;
154 + const options = slotScreenOptions(slot, route.key, descriptor.options);
155 const attached = props.state.routes.some((current) => current.key === route.key);
156 return (
157 <Stack.Screen
@@ -157,8 +161,7 @@ export function V5CardStackView(
161 attached || screens.nativeCompletingPops.has(route.key) ? "attached" : "detached"
162 }
163 preventNativeDismiss={
160 - preventedRoutes[route.key]?.preventRemove ||
161 - descriptor.options.gestureEnabled === false
164 + preventedRoutes[route.key]?.preventRemove || options.gestureEnabled === false
165 }
166 onDismiss={removeDismissed}
167 onNativeDismiss={nativeDismiss}
@@ -229,7 +232,7 @@ export function V5CardStackView(
232 <NavigationContext value={descriptor.navigation}>
233 <NavigationRouteContext value={descriptor.route}>
234 <V5StackHeader
232 - options={descriptor.options}
235 + options={options}
236 canGoBack={
237 attached
238 ? props.state.routes.findIndex((current) => current.key === route.key) > 0
@@ -237,15 +240,12 @@ export function V5CardStackView(
240 }
241 />
242 <NativeColumnContent
240 - backgroundColor={
241 - StyleSheet.flatten(descriptor.options.contentStyle)?.backgroundColor
242 - }
243 + backgroundColor={StyleSheet.flatten(options.contentStyle)?.backgroundColor}
244 insetHorizontally={
244 - (descriptor.options as AppNativeStackNavigationOptions)
245 - .nativeContentInsetHorizontally
245 + (options as AppNativeStackNavigationOptions).nativeContentInsetHorizontally
246 }
247 >
248 - <NativeScrollEdgeEffectsContext value={descriptor.options.scrollEdgeEffects}>
248 + <NativeScrollEdgeEffectsContext value={options.scrollEdgeEffects}>
249 {descriptor.render()}
250 </NativeScrollEdgeEffectsContext>
251 </NativeColumnContent>
@@ -262,9 +262,7 @@ export function V5CardStackView(
262 export function V5StackView(props: V5StackViewProps) {
263 const groups = partitionStackPresentations(props.state.routes, (route) => {
264 const presentation = props.descriptors[route.key]?.options.presentation;
265 - return (
266 - route.name === "SettingsSheet" || (presentation !== undefined && presentation !== "card")
267 - );
265 + return presentation !== undefined && presentation !== "card";
266 });
267 const routes = groups.map((group) => group[0]!);
268 const descriptors = Object.fromEntries(
@@ -304,118 +302,7 @@ export function V5StackView(props: V5StackViewProps) {
302 );
303 }
304
307 -export function V5SheetStackView(props: V5StackViewProps) {
308 - const { preventedRoutes } = usePreventRemoveContext();
309 - const groups = partitionStackPresentations(
310 - props.state.routes,
311 - (route) => props.descriptors[route.key]?.options.presentation === "formSheet",
312 - );
313 - const [retained, setRetained] = useState({
314 - groups: groups.slice(1),
315 - descriptors: props.descriptors,
316 - observedRoutes: props.state.routes,
317 - observedDescriptors: props.descriptors,
318 - });
319 - if (
320 - retained.observedRoutes !== props.state.routes ||
321 - retained.observedDescriptors !== props.descriptors
322 - ) {
323 - const active = new Set(groups.slice(1).map((group) => group[0]!.key));
324 - const sheets = [
325 - ...groups.slice(1),
326 - ...retained.groups.filter((group) => !active.has(group[0]!.key)),
327 - ];
328 - const sheetKeys = new Set(sheets.flatMap((group) => group.map((route) => route.key)));
329 - setRetained({
330 - groups: sheets,
331 - descriptors: Object.fromEntries(
332 - Object.entries({ ...retained.descriptors, ...props.descriptors }).filter(([key]) =>
333 - sheetKeys.has(key),
334 - ),
335 - ),
336 - observedRoutes: props.state.routes,
337 - observedDescriptors: props.descriptors,
338 - });
339 - }
340 - const removeSheet = (key: string) => {
341 - setRetained((current) => {
342 - const sheets = current.groups.filter((group) => group[0]!.key !== key);
343 - const sheetKeys = new Set(sheets.flatMap((group) => group.map((route) => route.key)));
344 - return {
345 - ...current,
346 - groups: sheets,
347 - descriptors: Object.fromEntries(
348 - Object.entries(current.descriptors).filter(([routeKey]) => sheetKeys.has(routeKey)),
349 - ),
350 - };
351 - });
352 - };
353 - const base = groups[0] ?? [];
354 - return (
355 - <View className="flex-1 bg-screen">
356 - <V5CardStackView
357 - {...props}
358 - state={{ ...props.state, routes: base, index: base.length - 1, preloadedRoutes: [] }}
359 - />
360 - {retained.groups.map((group) => {
361 - const first = group[0]!;
362 - const descriptor = props.descriptors[first.key] ?? retained.descriptors[first.key];
363 - if (!descriptor) return null;
364 - const options = descriptor.options;
365 - const attached = nativeWorkspacePopCount(props.state, first.key) > 0;
366 - return (
367 - <FormSheet
368 - key={first.key}
369 - isOpen={attached}
370 - detents={options.sheetAllowedDetents}
371 - initialDetentIndex={options.sheetInitialDetentIndex}
372 - largestUndimmedDetentIndex={options.sheetLargestUndimmedDetentIndex}
373 - prefersGrabberVisible={options.sheetGrabberVisible}
374 - prefersHorizontalBars={options.sheetPrefersHorizontalBars}
375 - preferredCornerRadius={options.sheetCornerRadius}
376 - prefersScrollingExpandsWhenScrolledToEdge={options.sheetExpandsWhenScrolledToEdge}
377 - nativeContainerStyle={{
378 - backgroundColor: StyleSheet.flatten(options.contentStyle)?.backgroundColor,
379 - }}
380 - preventNativeDismiss={
381 - group.some((route) => preventedRoutes[route.key]?.preventRemove) ||
382 - options.gestureEnabled === false
383 - }
384 - onNativeDismissPrevented={() => {
385 - const guarded = group.findLast((route) => preventedRoutes[route.key]?.preventRemove);
386 - if (guarded) {
387 - const state = props.navigation.getState();
388 - const action = nativeWorkspacePopAction(state, first.key);
389 - if (action) props.navigation.dispatch(action);
390 - }
391 - }}
392 - onDismiss={() => removeSheet(first.key)}
393 - onNativeDismiss={() => {
394 - const state = props.navigation.getState();
395 - const action = nativeWorkspacePopAction(state, first.key);
396 - if (action) props.navigation.dispatch(action);
397 - removeSheet(first.key);
398 - }}
399 - >
400 - <V5CardStackView
401 - {...props}
402 - descriptors={{ ...retained.descriptors, ...props.descriptors }}
403 - state={{
404 - ...props.state,
405 - routes: group,
406 - index: group.length - 1,
407 - preloadedRoutes: [],
408 - }}
409 - />
410 - </FormSheet>
411 - );
412 - })}
413 - </View>
414 - );
415 -}
416 -
305 function V5Navigator({
418 - nativeSheets,
306 id,
307 initialRouteName,
308 UNSTABLE_routeNamesChangeBehavior,
@@ -426,7 +313,7 @@ function V5Navigator({
313 screenLayout,
314 UNSTABLE_router,
315 ...rest
429 -}: NativeStackNavigatorProps & { readonly nativeSheets?: boolean }) {
316 +}: NativeStackNavigatorProps) {
317 const { state, describe, descriptors, navigation, NavigationContent } = useNavigationBuilder<
318 StackNavigationState<ParamListBase>,
319 StackRouterOptions,
@@ -444,7 +331,7 @@ function V5Navigator({
331 screenLayout,
332 UNSTABLE_router,
333 });
447 - const StackView = nativeSheets ? V5SheetStackView : V5StackView;
334 + const StackView = V5StackView;
335 return (
336 <NavigationContent>
337 <StackView
@@ -462,10 +349,6 @@ function V5StackNavigator(props: NativeStackNavigatorProps) {
349 return <V5Navigator {...props} />;
350 }
351
465 -function V5SheetStackNavigator(props: NativeStackNavigatorProps) {
466 - return <V5Navigator {...props} nativeSheets />;
467 -}
468 -
352 type V5TypeBag<ParamList extends ParamListBase, NavigatorID extends string | undefined> = Omit<
353 NativeStackTypeBag<ParamList, NavigatorID>,
354 "Navigator"
@@ -478,12 +361,3 @@ export function createV5StackNavigator<
361 >(config?: Config): TypedNavigator<TypeBag, Config> {
362 return createNavigatorFactory(V5StackNavigator)(config);
363 }
481 -
482 -export function createV5SheetStackNavigator<
483 - const ParamList extends ParamListBase,
484 - const NavigatorID extends string | undefined = string | undefined,
485 - const TypeBag extends NavigatorTypeBagBase = V5TypeBag<ParamList, NavigatorID>,
486 - const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,
487 ->(config?: Config): TypedNavigator<TypeBag, Config> {
488 - return createNavigatorFactory(V5SheetStackNavigator)(config);
489 -}
apps/mobile/src/native/createV5StackNavigator.tsx
+1 -4
@@ -1,4 +1 @@
1 -export {
2 - createNativeStackNavigator as createV5StackNavigator,
3 - createNativeStackNavigator as createV5SheetStackNavigator,
4 -} from "@react-navigation/native-stack";
1 +export { createNativeStackNavigator as createV5StackNavigator } from "@react-navigation/native-stack";
apps/mobile/src/native/native-layout-metrics.tsx
+28 -1
@@ -14,13 +14,40 @@ const DeviceTypeContext = createContext<DeviceType>(
14 // Column reservations come from UIKit's layout, outside the resizing navigator.
15 export const NativeColumnLayoutMetricsContext = createContext<NativeLayoutMetrics | null>(null);
16
17 +// The latest metrics outside React, for decisions made before the first screen renders.
18 +let latestMetrics: NativeLayoutMetrics | null = null;
19 +const metricsWaiters = new Set<(metrics: NativeLayoutMetrics) => void>();
20 +
21 +/** Resolves with the first native layout metrics, or null after `timeoutMs` without any. */
22 +export function firstNativeLayoutMetrics(timeoutMs: number) {
23 + if (latestMetrics) return Promise.resolve(latestMetrics);
24 + return new Promise<NativeLayoutMetrics | null>((resolve) => {
25 + const settle = (metrics: NativeLayoutMetrics | null) => {
26 + metricsWaiters.delete(settle);
27 + clearTimeout(timeout);
28 + resolve(metrics);
29 + };
30 + const timeout = setTimeout(() => settle(null), timeoutMs);
31 + metricsWaiters.add(settle);
32 + });
33 +}
34 +
35 +export function currentNativeLayoutMetrics() {
36 + return latestMetrics;
37 +}
38 +
39 export function NativeLayoutMetricsProvider(props: { readonly children: ReactNode }) {
40 const [metrics, setMetrics] = useState<NativeLayoutMetrics | null>(null);
41 + const publish = (next: NativeLayoutMetrics) => {
42 + latestMetrics = next;
43 + for (const settle of [...metricsWaiters]) settle(next);
44 + setMetrics(next);
45 + };
46 const deviceType = deriveDeviceType({ isPad: IS_PAD, metrics });
47 return (
48 <NativeLayoutContext value={metrics}>
49 <DeviceTypeContext value={deviceType}>
23 - <NativeLayoutObserver onChange={setMetrics} />
50 + <NativeLayoutObserver onChange={publish} />
51 {props.children}
52 </DeviceTypeContext>
53 </NativeLayoutContext>
apps/mobile/src/native/v5-workspace-context.tsx
+21
@@ -1,6 +1,27 @@
1 import { createContext, type ReactNode } from "react";
2
3 export const NativeWorkspaceModeContext = createContext(false);
4 +/**
5 + * Each workspace tab slot renders the same routes, so header options a screen sets are kept per
6 + * slot (by route key) instead of on the shared route: a slot's header then never shows options
7 + * another slot set, and switching tabs has nothing left to update.
8 + */
9 +export interface WorkspaceSlotOptions {
10 + readonly byRoute: ReadonlyMap<string, object>;
11 + readonly set: (routeKey: string, options: object) => void;
12 +}
13 +export const WorkspaceSlotOptionsContext = createContext<WorkspaceSlotOptions | null>(null);
14 +
15 +/** A route's options with whatever its screens set within this slot on top. */
16 +export function slotScreenOptions<Options extends object>(
17 + slot: WorkspaceSlotOptions | null,
18 + routeKey: string | undefined,
19 + options: Options,
20 +): Options {
21 + const own = routeKey === undefined ? undefined : slot?.byRoute.get(routeKey);
22 + return own ? { ...options, ...own } : options;
23 +}
24 +
25 /** Retained tabs must not update another tab's navigation options. */
26 export const NativeWorkspaceTabActivityContext = createContext<{
27 readonly active: boolean;
apps/mobile/src/native/workspace-stack-projection.test.ts
+22 -6
@@ -23,7 +23,7 @@ const { StackRouter } = requireNavigation("@react-navigation/routers") as {
23 const home = { key: "home", name: "Home" };
24 const thread = { key: "thread", name: "Thread", params: { threadId: "draft-thread" } };
25 const files = { key: "files", name: "ThreadFiles", params: thread.params };
26 -const settings = { key: "settings", name: "SettingsSheet" };
26 +const settings = { key: "settings", name: "Settings" };
27 const legal = { key: "legal", name: "SettingsLegal" };
28
29 function history(
@@ -34,7 +34,7 @@ function history(
34 type: "stack",
35 stale: false,
36 index: routes.length - 1,
37 - routeNames: ["Home", "Thread", "ThreadFiles", "SettingsSheet", "SettingsLegal"],
37 + routeNames: ["Home", "Thread", "ThreadFiles", "Settings", "SettingsLegal"],
38 routes,
39 preloadedRoutes: [],
40 };
@@ -44,20 +44,36 @@ describe("workspace router projection", () => {
44 it("keeps workspace flows beside Home and restores them after a modal closes", () => {
45 const draft = { key: "draft", name: "Thread", params: { draft: {} } };
46 const modal = { key: "connect", name: "ConnectOnboarding" };
47 - const routes = [home, thread, draft, settings, legal];
47 + const routes = [home, thread, draft, legal];
48 const isOverlay = (route: { name: string }) => route.name === "ConnectOnboarding";
49 expect(projectWorkspaceStack(history([...routes, modal]), isOverlay)).toEqual({
50 primary: home,
51 - detail: [thread, draft, settings, legal],
51 + detail: [thread, draft, legal],
52 overlays: [modal],
53 });
54 expect(projectWorkspaceStack(history(routes), isOverlay)).toEqual({
55 primary: home,
56 - detail: [thread, draft, settings, legal],
56 + detail: [thread, draft, legal],
57 overlays: [],
58 });
59 });
60
61 + it("shows the Settings list as the primary content and its pages as the detail", () => {
62 + const environments = { key: "environments", name: "SettingsEnvironments" };
63 + expect(projectWorkspaceStack(history([home, settings, environments]), () => false)).toEqual({
64 + primary: home,
65 + detail: [environments],
66 + overlays: [],
67 + });
68 + });
69 +
70 + it("returns from a Settings page to the Settings list that Home is showing", () => {
71 + const environments = { key: "environments", name: "SettingsEnvironments" };
72 + expect(
73 + nativeStackPopAction(history([home, settings, environments]), environments.key, home.key),
74 + ).toMatchObject({ payload: { count: 1 } });
75 + });
76 +
77 it("retains a cold-linked detail route without changing the router history", () => {
78 const state = history([thread, files]);
79 expect(projectWorkspaceStack(state, () => false)).toEqual({
@@ -330,7 +346,7 @@ describe("v5 stack handoff", () => {
346 expect(
347 partitionStackPresentations(
348 [home, thread, settings, legal, secondModal],
333 - (route) => route.name === "SettingsSheet",
349 + (route) => route.name === "Settings",
350 ),
351 ).toEqual([[home, thread], [settings, legal], [secondModal]]);
352 });
apps/mobile/src/native/workspace-stack-projection.ts
+8 -2
@@ -13,7 +13,10 @@ export function projectWorkspaceStack(
13 const firstOverlay = state.routes.findIndex(isOverlay);
14 const workspaceRoutes = state.routes.slice(0, firstOverlay < 0 ? undefined : firstOverlay);
15 const primary = workspaceRoutes.find((route) => route.name === "Home");
16 - const detail = workspaceRoutes.filter((route) => route.name !== "Home");
16 + // The Settings tab's route only selects what Home shows; its pages are the detail.
17 + const detail = workspaceRoutes.filter(
18 + (route) => route.name !== "Home" && route.name !== "Settings",
19 + );
20 const overlays = firstOverlay < 0 ? [] : state.routes.slice(firstOverlay);
21 return { primary, detail, overlays };
22 }
@@ -50,10 +53,13 @@ export function nativeStackPopAction(
53 destinationKey?: string,
54 ) {
55 const sourceIndex = state.routes.findIndex((route) => route.key === dismissedKey);
53 - const destinationIndex =
56 + let destinationIndex =
57 destinationKey === undefined
58 ? sourceIndex - 1
59 : state.routes.findIndex((route) => route.key === destinationKey);
60 + // Home's screen draws the Settings list, so going back to it from a Settings page stops there.
61 + if (destinationIndex >= 0 && state.routes[destinationIndex + 1]?.name === "Settings")
62 + destinationIndex += 1;
63 if (
64 sourceIndex <= 0 ||
65 sourceIndex > state.index ||
apps/mobile/src/persistence/mobile-preferences.ts
+33
@@ -47,7 +47,35 @@ const PullRequestListPreferences = Schema.Struct({
47 });
48 export type PullRequestListPreferences = typeof PullRequestListPreferences.Type;
49
50 +/**
51 + * The page each workspace tab last showed, reopened when the tab returns with columns. `key` is
52 + * that page's route key: reopening under the same key reuses the screen a tab kept mounted.
53 + */
54 +const WorkspaceSelections = Schema.Struct({
55 + threads: Schema.optional(
56 + Schema.Struct({
57 + environmentId: Schema.String,
58 + threadId: Schema.String,
59 + key: Schema.optional(Schema.String),
60 + }),
61 + ),
62 + pullRequests: Schema.optional(
63 + Schema.Struct({
64 + environmentId: Schema.String,
65 + projectId: Schema.String,
66 + repository: Schema.String,
67 + number: Schema.Number,
68 + host: Schema.optional(Schema.String),
69 + key: Schema.optional(Schema.String),
70 + }),
71 + ),
72 + settings: Schema.optional(Schema.String),
73 + settingsKey: Schema.optional(Schema.String),
74 +});
75 +export type WorkspaceSelections = typeof WorkspaceSelections.Type;
76 +
77 const isThreadListFilters = Schema.is(ThreadListFilters);
78 +const isWorkspaceSelections = Schema.is(WorkspaceSelections);
79 const isPullRequestListPreferences = Schema.is(PullRequestListPreferences);
80
81 export interface Preferences {
@@ -87,6 +115,7 @@ export interface Preferences {
115 readonly threadListWorkingShelfExpanded?: boolean;
116 readonly threadListFilters?: ThreadListFilters;
117 readonly pullRequestListFilters?: PullRequestListPreferences;
118 + readonly workspaceSelections?: WorkspaceSelections;
119 }
120
121 export class MobilePreferencesLoadError extends Schema.TaggedError<MobilePreferencesLoadError>()(
@@ -159,6 +188,7 @@ function sanitizePreferences(parsed: Preferences): Preferences {
188 threadListWorkingShelfExpanded?: boolean;
189 threadListFilters?: ThreadListFilters;
190 pullRequestListFilters?: PullRequestListPreferences;
191 + workspaceSelections?: WorkspaceSelections;
192 } = {};
193
194 if (Array.isArray(parsed.hiddenNavigationTabs)) {
@@ -298,6 +328,9 @@ function sanitizePreferences(parsed: Preferences): Preferences {
328 if (isPullRequestListPreferences(parsed.pullRequestListFilters)) {
329 preferences.pullRequestListFilters = parsed.pullRequestListFilters;
330 }
331 + if (isWorkspaceSelections(parsed.workspaceSelections)) {
332 + preferences.workspaceSelections = parsed.workspaceSelections;
333 + }
334 return preferences;
335 }
336
apps/mobile/src/state/use-remote-environment-registry.ts
+1 -1
@@ -176,7 +176,7 @@ export function useRemoteConnections() {
176 { text: "Cancel", style: "cancel" },
177 {
178 text: "Open T3 Account",
179 - onPress: () => navigation.navigate("SettingsSheet", { screen: "SettingsAuth" }),
179 + onPress: () => navigation.navigate("SettingsAuth"),
180 },
181 remove,
182 ],