GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(mobile): workspace tabs open from one place and never land on an … · pingdotgg/t3code@2a8b1ff

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/mobile/src
    • App.tsx
    • Stack.tsx
    • features
      • cloud
        • connectOnboardingNavigation.ts
      • connection
        • ConnectionsNewRouteScreen.tsx
      • keyboard
        • CommandPalette.tsx
        • HardwareKeyboardCommandProvider.tsx
      • layout
        • AdaptiveWorkspaceLayout.tsx
        • adaptive-workspace-context.ts
        • createWorkspaceStackNavigator.ios.tsx
        • workspace-overlay-routes.ts
      • settings
        • SettingsProjectOverviewRouteScreen.tsx
        • SettingsRouteScreen.tsx
        • components
          • SettingsRow.tsx
          • settings-page-targets.ts
          • settings-sheet-targets.ts
        • settings-navigation.ts
      • workspace
        • AndroidWorkspaceSettings.tsx
        • android-workspace-tabs.ts
        • useSelectWorkspaceTab.ts
        • workspace-selection-store.ts
        • workspace-tab-navigation.test.ts
        • workspace-tab-navigation.ts
    • lib
      • root-stack-reset.ts
    • native
      • NativeWorkspaceColumns.ios.tsx
      • NativeWorkspaceColumns.tsx
      • createV5StackNavigator.ios.tsx
      • createV5StackNavigator.tsx
      • native-layout-metrics.tsx
    • state
      • use-remote-environment-registry.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/mobile/src/App.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/App.tsx
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
hydrateWorkspaceSelections,
3737
launchWorkspaceURL,
3838
recordWorkspaceSelections,
39+
settingsLinkPage,
3940
} from "./features/workspace/workspace-selection-store";
4041
import { NativeLayoutMetricsProvider } from "./native/native-layout-metrics";
4142

@@ -54,7 +55,10 @@ const appLinking = {
5455
filter: shouldHandleAppLink,
5556
getInitialURL: async () => (await Linking.getInitialURL()) ?? (await launchWorkspaceURL()),
5657
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+
),
5862
};
5963

6064
const Navigation = createStaticNavigation(RootStack);
Collapse file

‎apps/mobile/src/Stack.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/Stack.tsx
+3-37Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { androidWorkspaceDestinationAnimation } from "./lib/android-workspace-na
2424
import { getCompactBrandHeaderOptions } from "./components/CompactBrandTitle";
2525
import { WorkspaceConnectionStatusProvider } from "./features/home/WorkspaceConnectionTitle";
2626
import { WorkspaceRootScreen } from "./features/workspace/WorkspaceRootScreen";
27-
import { AndroidWorkspaceSettings } from "./features/workspace/AndroidWorkspaceSettings";
2827
import { AndroidWorkspaceTabsProvider } from "./features/workspace/AndroidWorkspaceTabsProvider";
2928
import {
3029
PullRequestRouteScreen,
@@ -125,6 +124,7 @@ import { SettingsRouteScreen } from "./features/settings/SettingsRouteScreen";
125124
import { SettingsThreadsRouteScreen } from "./features/settings/SettingsThreadsRouteScreen";
126125
import { SettingsEnvironmentFilterProvider } from "./features/settings/settings-environment-filter";
127126
import { settingsOpenIn } from "./features/settings/settings-navigation";
127+
import { WORKSPACE_OVERLAY_ROUTES } from "./features/layout/workspace-overlay-routes";
128128
import { ShowcaseCaptureCoordinator } from "./features/showcase/ShowcaseCaptureCoordinator";
129129
import {
130130
SettingsLegalDocumentCloseHeaderButton,
@@ -229,7 +229,6 @@ const SETTINGS_SCREENS = {
229229
Settings: createNativeStackScreen({
230230
screen: SettingsRouteScreen,
231231
linking: "settings",
232-
layout: ({ children }) => <AndroidWorkspaceSettings>{children}</AndroidWorkspaceSettings>,
233232
options: {
234233
...SETTINGS_PAGE_OPTIONS,
235234
title: "Settings",
@@ -453,12 +452,12 @@ const SETTINGS_SCREENS = {
453452
SettingsAuth: createNativeStackScreen({
454453
screen: SettingsAuthRouteScreen,
455454
linking: "settings/auth",
456-
options: { headerShown: false },
455+
options: { headerShown: false, presentation: "modal" },
457456
}),
458457
SettingsWaitlist: createNativeStackScreen({
459458
screen: SettingsAuthRouteScreen,
460459
linking: "settings/waitlist",
461-
options: { headerShown: false },
460+
options: { headerShown: false, presentation: "modal" },
462461
}),
463462
};
464463

@@ -467,39 +466,6 @@ const SETTINGS_SCREENS = {
467466
// across two bars the whole screen slides).
468467
const THREAD_LINKING_PREFIX = "threads/:environmentId/:threadId";
469468

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-
503469
function workspaceLocationFromState(state: NavigationState) {
504470
const routes = state.routes.filter((route) => !WORKSPACE_OVERLAY_ROUTES.has(route.name));
505471
const effectiveState =
Collapse file

‎apps/mobile/src/features/cloud/connectOnboardingNavigation.ts‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/cloud/connectOnboardingNavigation.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { appAtomRegistry } from "../../state/atom-registry";
66
import { clearConnectOnboardingRequest, connectOnboardingRequestAtom } from "./connectOnboarding";
77
import { isConnectOnboardingOptedOut } from "./connectOnboardingOptOut";
88

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.
1111
const PRESENT_ONBOARDING_DELAY_MS = 600;
1212

1313
/**
Collapse file

‎apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import { hasCloudPublicConfig } from "../cloud/publicConfig";
3333
import { CloudEnvironmentRows } from "./CloudEnvironmentRows";
3434
import { splitEnvironmentSections } from "./environmentSections";
3535
import { openSettings } from "../settings/settings-navigation";
36+
import { leaveSettingsPage } from "../settings/settings-navigation";
37+
import { workspaceHasColumns } from "../workspace/workspace-selection-store";
3638

3739
type ConnectionsNewRouteParams = {
3840
readonly mode?: string;
@@ -169,7 +171,8 @@ export function ConnectionsNewRouteScreen({
169171
if (!navigation.canGoBack()) {
170172
navigation.dispatch(StackActions.replace("Home"));
171173
} else {
172-
navigation.goBack();
174+
// Added from the Settings list, the new environment shows on Environments.
175+
leaveSettingsPage(navigation, workspaceHasColumns(), "SettingsEnvironments");
173176
}
174177
}
175178
};
@@ -391,7 +394,7 @@ function T3ConnectSection() {
391394
label="Sign in to T3 Connect"
392395
description="Reach your machines from anywhere, no network setup."
393396
disabled={!isLoaded}
394-
onPress={() => openSettings(navigation, "SettingsAuth")}
397+
onPress={() => navigation.navigate("SettingsAuth")}
395398
/>
396399
)}
397400
</View>
Collapse file

‎apps/mobile/src/features/keyboard/CommandPalette.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/keyboard/CommandPalette.tsx
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ export function CommandPalette(props: {
402402
);
403403
return [...actions, ...projectItems, ...threadItems];
404404
}, [
405+
selectTab,
405406
activeThread,
406407
activeThreadRef,
407408
environments.length,
Collapse file

‎apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { StackActions, useNavigation } from "@react-navigation/native";
2+
import { Platform } from "react-native";
23
import { resolveThreadReferenceCopyTarget } from "@t3tools/client-runtime/thread-reference";
34
import {
45
createContext,
@@ -14,6 +15,10 @@ import {
1415
} from "react";
1516

1617
import { tryCopyTextWithHaptic } from "../../lib/copyTextWithHaptic";
18+
import {
19+
firstWorkspaceDetailOpen,
20+
workspaceHasColumns,
21+
} from "../workspace/workspace-selection-store";
1722
import { T3KeyboardCommands } from "../../native/T3KeyboardCommands";
1823
import { useThreadShell } from "../../state/entities";
1924
import type { GitActionProgress } from "../../state/use-vcs-action-state";
@@ -152,6 +157,9 @@ export function HardwareKeyboardCommandProvider({
152157
return;
153158
}
154159
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;
155163
if (navigation.canGoBack()) {
156164
navigation.goBack();
157165
} else {
Collapse file

‎apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+59-13Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
12
import { AdaptiveWorkspaceContext, useAdaptiveWorkspaceLayout } from "./adaptive-workspace-context";
23
import { createDeferredNavigation } from "./deferred-navigation";
34
import { uuidv4 } from "../../lib/uuid";
@@ -94,9 +95,14 @@ import { AndroidHingeObserver } from "../../native/AndroidHingeObserver";
9495
import { WindowHingeContext } from "../../native/window-hinge-context";
9596
import { useAndroidWorkspaceRoot } from "../workspace/AndroidWorkspaceTabsProvider";
9697
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";
99103
import { workspaceTabNavigationState } from "../workspace/workspace-tab-navigation";
104+
import type { WorkspaceTab } from "../workspace/workspace-tabs-state";
105+
import { workspaceRoutesOf } from "./workspace-overlay-routes";
100106

101107
export { useAdaptiveWorkspaceLayout };
102108

@@ -214,6 +220,7 @@ function AdaptiveWorkspaceLayoutContent(
214220
const workspace = useWorkspaceTabs();
215221
// Settings and Usage occupy the workspace rather than a list/detail pair.
216222
const androidSettingsOpen = useAndroidWorkspaceRoot()?.settingsOpen ?? false;
223+
const safeAreaInsets = useSafeAreaInsets();
217224
const workspacePage =
218225
Platform.OS === "android" && (androidSettingsOpen || workspace?.state.selectedTab === "usage");
219226
const navigation = useNavigation();
@@ -239,10 +246,13 @@ function AdaptiveWorkspaceLayoutContent(
239246
() => deriveLayout({ width: viewportWidth, height, nativeMetrics, nativeWorkspace }),
240247
[height, viewportWidth, nativeMetrics, nativeWorkspace],
241248
);
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).
242251
const [overlaySidebar, setOverlaySidebar] = useState({
243252
active: baseLayout.primarySidebarOverlaysContent,
244253
pathname,
245254
visible: isWorkspaceListPath(pathname),
255+
keepOpenFor: null as string | null,
246256
});
247257
if (
248258
overlaySidebar.active !== baseLayout.primarySidebarOverlaysContent ||
@@ -251,7 +261,11 @@ function AdaptiveWorkspaceLayoutContent(
251261
setOverlaySidebar({
252262
active: baseLayout.primarySidebarOverlaysContent,
253263
pathname,
254-
visible: isWorkspaceListPath(pathname),
264+
visible:
265+
isWorkspaceListPath(pathname) ||
266+
(overlaySidebar.keepOpenFor !== null &&
267+
overlaySidebar.keepOpenFor === props.workspaceRouteKey),
268+
keepOpenFor: null,
255269
});
256270
}
257271
const preferredSidebarVisible = baseLayout.primarySidebarOverlaysContent
@@ -463,16 +477,35 @@ function AdaptiveWorkspaceLayoutContent(
463477
}
464478
setSupplementaryPanePreferredWidth(nextWidth);
465479
};
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+
},
475501
);
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");
476509

477510
const selectAndroidWorkspace = useAndroidWorkspaceSelection();
478511
const deferredThreadSelection = useMemo(() => createDeferredNavigation(), []);
@@ -531,6 +564,8 @@ function AdaptiveWorkspaceLayoutContent(
531564
}
532565

533566
const projects = useProjects();
567+
const compactAndroidSettings =
568+
Platform.OS === "android" && androidSettingsOpen && !layout.usesSplitView;
534569
const handleStartNewTask = () => {
535570
const thread = appAtomRegistry
536571
.get(environmentThreadShells.navigationThreadShellsAtom)
@@ -778,6 +813,7 @@ function AdaptiveWorkspaceLayoutContent(
778813
toggleAuxiliaryPane,
779814
togglePrimarySidebar,
780815
setPrimarySidebarVisible,
816+
openWorkspaceTab,
781817
setAuxiliaryPaneWidth,
782818
composerKeyboardActive,
783819
setComposerEditing,
@@ -898,7 +934,17 @@ function AdaptiveWorkspaceLayoutContent(
898934
Platform.OS === "android" && layout.usesSplitView ? contentTargetWidth : null
899935
}
900936
>
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}
902948
</WorkspaceSettledContentWidthContext>
903949
</WorkspaceContentWidthContext>
904950
</View>
Collapse file

‎apps/mobile/src/features/layout/adaptive-workspace-context.ts‎

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 numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { WorkspaceTab } from "../workspace/workspace-tabs-state";
12
import { createContext, use, type ReactNode } from "react";
23
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
34
import {
@@ -26,6 +27,11 @@ interface AdaptiveWorkspaceContextValue {
2627
readonly toggleAuxiliaryPane: () => void;
2728
readonly togglePrimarySidebar: () => void;
2829
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;
2935
readonly setAuxiliaryPaneWidth: (width: number) => void;
3036
/**
3137
* Android split view while the thread composer has the soft keyboard: the
@@ -63,6 +69,7 @@ export const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceContextVa
6369
toggleAuxiliaryPane: () => undefined,
6470
togglePrimarySidebar: () => undefined,
6571
setPrimarySidebarVisible: () => undefined,
72+
openWorkspaceTab: () => undefined,
6673
setAuxiliaryPaneWidth: () => undefined,
6774
composerKeyboardActive: false,
6875
setComposerEditing: () => undefined,

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.