GeezerVison is showing github.com — fix(mobile): workspace tabs open from one place and never land on an … · pingdotgg/t3code@2a8b1ff
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/App.tsx +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -36,6 +36,7 @@ import { | 36 | 36 | hydrateWorkspaceSelections, | 37 | 37 | launchWorkspaceURL, | 38 | 38 | recordWorkspaceSelections, | | 39 | + settingsLinkPage, | 39 | 40 | } from "./features/workspace/workspace-selection-store"; | 40 | 41 | import { NativeLayoutMetricsProvider } from "./native/native-layout-metrics"; | 41 | 42 |
| @@ -54,7 +55,10 @@ const appLinking = { | 54 | 55 | filter: shouldHandleAppLink, | 55 | 56 | getInitialURL: async () => (await Linking.getInitialURL()) ?? (await launchWorkspaceURL()), | 56 | 57 | getStateFromPath: (path: string, options: Parameters<typeof getStateFromPath>[1]) => | 57 | | - restoreSettingsLinkState(restoreDraftLinkState(getStateFromPath(path, options), path)), | | 58 | + restoreSettingsLinkState( | | 59 | + restoreDraftLinkState(getStateFromPath(path, options), path), | | 60 | + settingsLinkPage(), | | 61 | + ), | 58 | 62 | }; | 59 | 63 |
| 60 | 64 | const Navigation = createStaticNavigation(RootStack); | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/Stack.tsx +3-37Lines changed: 3 additions & 37 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,7 +24,6 @@ import { androidWorkspaceDestinationAnimation } from "./lib/android-workspace-na | 24 | 24 | import { getCompactBrandHeaderOptions } from "./components/CompactBrandTitle"; | 25 | 25 | import { WorkspaceConnectionStatusProvider } from "./features/home/WorkspaceConnectionTitle"; | 26 | 26 | import { WorkspaceRootScreen } from "./features/workspace/WorkspaceRootScreen"; | 27 | | -import { AndroidWorkspaceSettings } from "./features/workspace/AndroidWorkspaceSettings"; | 28 | 27 | import { AndroidWorkspaceTabsProvider } from "./features/workspace/AndroidWorkspaceTabsProvider"; | 29 | 28 | import { | 30 | 29 | PullRequestRouteScreen, | @@ -125,6 +124,7 @@ import { SettingsRouteScreen } from "./features/settings/SettingsRouteScreen"; | 125 | 124 | import { SettingsThreadsRouteScreen } from "./features/settings/SettingsThreadsRouteScreen"; | 126 | 125 | import { SettingsEnvironmentFilterProvider } from "./features/settings/settings-environment-filter"; | 127 | 126 | import { settingsOpenIn } from "./features/settings/settings-navigation"; | | 127 | +import { WORKSPACE_OVERLAY_ROUTES } from "./features/layout/workspace-overlay-routes"; | 128 | 128 | import { ShowcaseCaptureCoordinator } from "./features/showcase/ShowcaseCaptureCoordinator"; | 129 | 129 | import { | 130 | 130 | SettingsLegalDocumentCloseHeaderButton, | @@ -229,7 +229,6 @@ const SETTINGS_SCREENS = { | 229 | 229 | Settings: createNativeStackScreen({ | 230 | 230 | screen: SettingsRouteScreen, | 231 | 231 | linking: "settings", | 232 | | - layout: ({ children }) => <AndroidWorkspaceSettings>{children}</AndroidWorkspaceSettings>, | 233 | 232 | options: { | 234 | 233 | ...SETTINGS_PAGE_OPTIONS, | 235 | 234 | title: "Settings", | @@ -453,12 +452,12 @@ const SETTINGS_SCREENS = { | 453 | 452 | SettingsAuth: createNativeStackScreen({ | 454 | 453 | screen: SettingsAuthRouteScreen, | 455 | 454 | linking: "settings/auth", | 456 | | - options: { headerShown: false }, | | 455 | + options: { headerShown: false, presentation: "modal" }, | 457 | 456 | }), | 458 | 457 | SettingsWaitlist: createNativeStackScreen({ | 459 | 458 | screen: SettingsAuthRouteScreen, | 460 | 459 | linking: "settings/waitlist", | 461 | | - options: { headerShown: false }, | | 460 | + options: { headerShown: false, presentation: "modal" }, | 462 | 461 | }), | 463 | 462 | }; | 464 | 463 |
| @@ -467,39 +466,6 @@ const SETTINGS_SCREENS = { | 467 | 466 | // across two bars the whole screen slides). | 468 | 467 | const THREAD_LINKING_PREFIX = "threads/:environmentId/:threadId"; | 469 | 468 |
| 470 | | -const WORKSPACE_OVERLAY_ROUTES = new Set([ | 471 | | - "PullRequestReview", | 472 | | - "PullRequestInlineComment", | 473 | | - "ConnectOnboarding", | 474 | | - "Connections", | 475 | | - "ConnectionsNew", | 476 | | - "GitBranches", | 477 | | - "GitCommit", | 478 | | - "GitConfirm", | 479 | | - "GitOverview", | 480 | | - "NewTaskProject", | 481 | | - "NewTaskFiles", | 482 | | - "NewTaskFile", | 483 | | - "NewTaskAttachment", | 484 | | - "NewTaskThreadSettings", | 485 | | - "AddProject", | 486 | | - "AddProjectRepository", | 487 | | - "AddProjectDestination", | 488 | | - "AddProjectLocal", | 489 | | - "AddProjectNew", | 490 | | - "NewTaskEnvironment", | 491 | | - "NewTaskBranch", | 492 | | - "SettingsLegal", | 493 | | - "ThreadAgents", | 494 | | - "ThreadBackgroundWork", | 495 | | - "ThreadPullRequests", | 496 | | - "ThreadQueue", | 497 | | - "ThreadReviewComment", | 498 | | - "ThreadDevicePreview", | 499 | | - "ThreadBrowserPreview", | 500 | | - "ThreadSettingsSheet", | 501 | | -]); | 502 | | - | 503 | 469 | function workspaceLocationFromState(state: NavigationState) { | 504 | 470 | const routes = state.routes.filter((route) => !WORKSPACE_OVERLAY_ROUTES.has(route.name)); | 505 | 471 | const effectiveState = | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/cloud/connectOnboardingNavigation.ts +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -6,8 +6,8 @@ import { appAtomRegistry } from "../../state/atom-registry"; | 6 | 6 | import { clearConnectOnboardingRequest, connectOnboardingRequestAtom } from "./connectOnboarding"; | 7 | 7 | import { isConnectOnboardingOptedOut } from "./connectOnboardingOptOut"; | 8 | 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 | 11 | const PRESENT_ONBOARDING_DELAY_MS = 600; | 12 | 12 |
| 13 | 13 | /** | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx +5-2Lines changed: 5 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -33,6 +33,8 @@ import { hasCloudPublicConfig } from "../cloud/publicConfig"; | 33 | 33 | import { CloudEnvironmentRows } from "./CloudEnvironmentRows"; | 34 | 34 | import { splitEnvironmentSections } from "./environmentSections"; | 35 | 35 | import { openSettings } from "../settings/settings-navigation"; | | 36 | +import { leaveSettingsPage } from "../settings/settings-navigation"; | | 37 | +import { workspaceHasColumns } from "../workspace/workspace-selection-store"; | 36 | 38 |
| 37 | 39 | type ConnectionsNewRouteParams = { | 38 | 40 | readonly mode?: string; | @@ -169,7 +171,8 @@ export function ConnectionsNewRouteScreen({ | 169 | 171 | if (!navigation.canGoBack()) { | 170 | 172 | navigation.dispatch(StackActions.replace("Home")); | 171 | 173 | } else { | 172 | | - navigation.goBack(); | | 174 | + // Added from the Settings list, the new environment shows on Environments. | | 175 | + leaveSettingsPage(navigation, workspaceHasColumns(), "SettingsEnvironments"); | 173 | 176 | } | 174 | 177 | } | 175 | 178 | }; | @@ -391,7 +394,7 @@ function T3ConnectSection() { | 391 | 394 | label="Sign in to T3 Connect" | 392 | 395 | description="Reach your machines from anywhere, no network setup." | 393 | 396 | disabled={!isLoaded} | 394 | | - onPress={() => openSettings(navigation, "SettingsAuth")} | | 397 | + onPress={() => navigation.navigate("SettingsAuth")} | 395 | 398 | /> | 396 | 399 | )} | 397 | 400 | </View> | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/keyboard/CommandPalette.tsx +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -402,6 +402,7 @@ export function CommandPalette(props: { | 402 | 402 | ); | 403 | 403 | return [...actions, ...projectItems, ...threadItems]; | 404 | 404 | }, [ | | 405 | + selectTab, | 405 | 406 | activeThread, | 406 | 407 | activeThreadRef, | 407 | 408 | environments.length, | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { StackActions, useNavigation } from "@react-navigation/native"; | | 2 | +import { Platform } from "react-native"; | 2 | 3 | import { resolveThreadReferenceCopyTarget } from "@t3tools/client-runtime/thread-reference"; | 3 | 4 | import { | 4 | 5 | createContext, | @@ -14,6 +15,10 @@ import { | 14 | 15 | } from "react"; | 15 | 16 |
| 16 | 17 | import { tryCopyTextWithHaptic } from "../../lib/copyTextWithHaptic"; | | 18 | +import { | | 19 | + firstWorkspaceDetailOpen, | | 20 | + workspaceHasColumns, | | 21 | +} from "../workspace/workspace-selection-store"; | 17 | 22 | import { T3KeyboardCommands } from "../../native/T3KeyboardCommands"; | 18 | 23 | import { useThreadShell } from "../../state/entities"; | 19 | 24 | import type { GitActionProgress } from "../../state/use-vcs-action-state"; | @@ -152,6 +157,9 @@ export function HardwareKeyboardCommandProvider({ | 152 | 157 | return; | 153 | 158 | } | 154 | 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; | 155 | 163 | if (navigation.canGoBack()) { | 156 | 164 | navigation.goBack(); | 157 | 165 | } else { | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx +59-13Lines changed: 59 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context"; | 1 | 2 | import { AdaptiveWorkspaceContext, useAdaptiveWorkspaceLayout } from "./adaptive-workspace-context"; | 2 | 3 | import { createDeferredNavigation } from "./deferred-navigation"; | 3 | 4 | import { uuidv4 } from "../../lib/uuid"; | @@ -94,9 +95,14 @@ import { AndroidHingeObserver } from "../../native/AndroidHingeObserver"; | 94 | 95 | import { WindowHingeContext } from "../../native/window-hinge-context"; | 95 | 96 | import { useAndroidWorkspaceRoot } from "../workspace/AndroidWorkspaceTabsProvider"; | 96 | 97 | import { openSettings } from "../settings/settings-navigation"; | 97 | | -import { resetRootStack } from "../../lib/root-stack-reset"; | 98 | | -import { currentWorkspaceSelections } from "../workspace/workspace-selection-store"; | | 98 | +import { dispatchRootStackReset, rootStackState } from "../../lib/root-stack-reset"; | | 99 | +import { | | 100 | + currentWorkspaceSelections, | | 101 | + workspaceSelectionCheck, | | 102 | +} from "../workspace/workspace-selection-store"; | 99 | 103 | import { workspaceTabNavigationState } from "../workspace/workspace-tab-navigation"; | | 104 | +import type { WorkspaceTab } from "../workspace/workspace-tabs-state"; | | 105 | +import { workspaceRoutesOf } from "./workspace-overlay-routes"; | 100 | 106 |
| 101 | 107 | export { useAdaptiveWorkspaceLayout }; | 102 | 108 |
| @@ -214,6 +220,7 @@ function AdaptiveWorkspaceLayoutContent( | 214 | 220 | const workspace = useWorkspaceTabs(); | 215 | 221 | // Settings and Usage occupy the workspace rather than a list/detail pair. | 216 | 222 | const androidSettingsOpen = useAndroidWorkspaceRoot()?.settingsOpen ?? false; | | 223 | + const safeAreaInsets = useSafeAreaInsets(); | 217 | 224 | const workspacePage = | 218 | 225 | Platform.OS === "android" && (androidSettingsOpen || workspace?.state.selectedTab === "usage"); | 219 | 226 | const navigation = useNavigation(); | @@ -239,10 +246,13 @@ function AdaptiveWorkspaceLayoutContent( | 239 | 246 | () => deriveLayout({ width: viewportWidth, height, nativeMetrics, nativeWorkspace }), | 240 | 247 | [height, viewportWidth, nativeMetrics, nativeWorkspace], | 241 | 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). | 242 | 251 | const [overlaySidebar, setOverlaySidebar] = useState({ | 243 | 252 | active: baseLayout.primarySidebarOverlaysContent, | 244 | 253 | pathname, | 245 | 254 | visible: isWorkspaceListPath(pathname), | | 255 | + keepOpenFor: null as string | null, | 246 | 256 | }); | 247 | 257 | if ( | 248 | 258 | overlaySidebar.active !== baseLayout.primarySidebarOverlaysContent || | @@ -251,7 +261,11 @@ function AdaptiveWorkspaceLayoutContent( | 251 | 261 | setOverlaySidebar({ | 252 | 262 | active: baseLayout.primarySidebarOverlaysContent, | 253 | 263 | pathname, | 254 | | - visible: isWorkspaceListPath(pathname), | | 264 | + visible: | | 265 | + isWorkspaceListPath(pathname) || | | 266 | + (overlaySidebar.keepOpenFor !== null && | | 267 | + overlaySidebar.keepOpenFor === props.workspaceRouteKey), | | 268 | + keepOpenFor: null, | 255 | 269 | }); | 256 | 270 | } | 257 | 271 | const preferredSidebarVisible = baseLayout.primarySidebarOverlaysContent | @@ -463,16 +477,35 @@ function AdaptiveWorkspaceLayoutContent( | 463 | 477 | } | 464 | 478 | setSupplementaryPanePreferredWidth(nextWidth); | 465 | 479 | }; | 466 | | - // This layout provides the context useSelectWorkspaceTab reads, so it builds the state itself. | 467 | | - const handleOpenSettings = () => | 468 | | - resetRootStack(navigation, (state) => | 469 | | - workspaceTabNavigationState( | 470 | | - state, | 471 | | - "settings", | 472 | | - currentWorkspaceSelections(), | 473 | | - Platform.OS === "ios" && layout.usesSplitView, | 474 | | - ), | | 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 | + }, | 475 | 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"); | 476 | 509 |
| 477 | 510 | const selectAndroidWorkspace = useAndroidWorkspaceSelection(); | 478 | 511 | const deferredThreadSelection = useMemo(() => createDeferredNavigation(), []); | @@ -531,6 +564,8 @@ function AdaptiveWorkspaceLayoutContent( | 531 | 564 | } | 532 | 565 |
| 533 | 566 | const projects = useProjects(); | | 567 | + const compactAndroidSettings = | | 568 | + Platform.OS === "android" && androidSettingsOpen && !layout.usesSplitView; | 534 | 569 | const handleStartNewTask = () => { | 535 | 570 | const thread = appAtomRegistry | 536 | 571 | .get(environmentThreadShells.navigationThreadShellsAtom) | @@ -778,6 +813,7 @@ function AdaptiveWorkspaceLayoutContent( | 778 | 813 | toggleAuxiliaryPane, | 779 | 814 | togglePrimarySidebar, | 780 | 815 | setPrimarySidebarVisible, | | 816 | + openWorkspaceTab, | 781 | 817 | setAuxiliaryPaneWidth, | 782 | 818 | composerKeyboardActive, | 783 | 819 | setComposerEditing, | @@ -898,7 +934,17 @@ function AdaptiveWorkspaceLayoutContent( | 898 | 934 | Platform.OS === "android" && layout.usesSplitView ? contentTargetWidth : null | 899 | 935 | } | 900 | 936 | > | 901 | | - {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} | 902 | 948 | </WorkspaceSettledContentWidthContext> | 903 | 949 | </WorkspaceContentWidthContext> | 904 | 950 | </View> | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/layout/adaptive-workspace-context.ts +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import type { WorkspaceTab } from "../workspace/workspace-tabs-state"; | 1 | 2 | import { createContext, use, type ReactNode } from "react"; | 2 | 3 | import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell"; | 3 | 4 | import { | @@ -26,6 +27,11 @@ interface AdaptiveWorkspaceContextValue { | 26 | 27 | readonly toggleAuxiliaryPane: () => void; | 27 | 28 | readonly togglePrimarySidebar: () => void; | 28 | 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; | 29 | 35 | readonly setAuxiliaryPaneWidth: (width: number) => void; | 30 | 36 | /** | 31 | 37 | * Android split view while the thread composer has the soft keyboard: the | @@ -63,6 +69,7 @@ export const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceContextVa | 63 | 69 | toggleAuxiliaryPane: () => undefined, | 64 | 70 | togglePrimarySidebar: () => undefined, | 65 | 71 | setPrimarySidebarVisible: () => undefined, | | 72 | + openWorkspaceTab: () => undefined, | 66 | 73 | setAuxiliaryPaneWidth: () => undefined, | 67 | 74 | composerKeyboardActive: false, | 68 | 75 | setComposerEditing: () => undefined, | |
|