Skip to content

Commit d26280c

Browse files
bitmvkclaude
andcommitted
fix(mobile): cold-start PR links start on the Pulls list on Android
The tab is no longer selected when a page gains focus, so a cold-start link straight into a PR left the list on Chats. Seed the starting tab from the first page in the launch stack, reusing the page-to-tab mapping list selection already uses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 16f73fc commit d26280c

4 files changed

Lines changed: 20 additions & 11 deletions

File tree

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ import {
100100
workspaceTabColumns,
101101
workspaceTabNavigationState,
102102
} from "../workspace/workspace-tab-navigation";
103-
import type { WorkspaceTab } from "../workspace/workspace-tabs-state";
103+
import { workspaceTabOf, type WorkspaceTab } from "../workspace/workspace-tabs-state";
104104
import { workspaceRoutesOf } from "./workspace-overlay-routes";
105105
import { SettingsWorkspaceLayout } from "../settings/SettingsWorkspaceLayout";
106106

@@ -535,10 +535,7 @@ function AdaptiveWorkspaceLayoutContent(
535535
if (Platform.OS === "android") Keyboard.dismiss();
536536
setFileInspectorPreferredVisible(false);
537537
if (layout.primarySidebarOverlaysContent) setPrimarySidebarVisible(false);
538-
workspace?.dispatch({
539-
type: "select",
540-
tab: detail.name === "Thread" ? "threads" : "pullRequests",
541-
});
538+
workspace?.dispatch({ type: "select", tab: workspaceTabOf(detail.name) });
542539
startOpeningDetail(detail);
543540
navigation.dispatch(selectWorkspaceDetail(detail, sheet));
544541
});

‎apps/mobile/src/features/workspace/AndroidWorkspaceTabsProvider.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createContext, use, type ReactNode } from "react";
33
import { Platform } from "react-native";
44
import { androidWorkspaceSettingsOpen } from "./android-workspace-tabs";
55
import { WorkspaceTabsProvider } from "./WorkspaceTabsContext";
6+
import { workspaceTabOf } from "./workspace-tabs-state";
67

78
interface AndroidWorkspaceRoot {
89
/**
@@ -35,7 +36,10 @@ export function AndroidWorkspaceTabsProvider(props: {
3536
settingsIndex < 0 ? null : (props.state.routes[settingsIndex + 1]?.name ?? null);
3637
const root = { key, settingsOpen, settingsRoute, settingsPage };
3738
return Platform.OS === "android" ? (
38-
<WorkspaceTabsProvider>
39+
// A cold-start link lands on a page with no list selection; start on that page's list.
40+
<WorkspaceTabsProvider
41+
initialTab={workspaceTabOf(props.state.routes.find((route) => route.name !== "Home")?.name)}
42+
>
3943
<AndroidWorkspaceRootContext value={root}>{props.children}</AndroidWorkspaceRootContext>
4044
</WorkspaceTabsProvider>
4145
) : (

‎apps/mobile/src/features/workspace/WorkspaceTabsContext.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ function resolveWorkspaceTabsSelection(
5252

5353
// One model per provider. Handlers on frozen screens keep stale closures, so
5454
// they read the current selection from the registry at call time.
55-
function createWorkspaceTabsModel() {
56-
const stored = Atom.make(initialWorkspaceTabsState());
55+
function createWorkspaceTabsModel(selectedTab?: WorkspaceTab) {
56+
const stored = Atom.make(initialWorkspaceTabsState(selectedTab));
5757
const scrollOffsets: Record<WorkspaceSearchTab, number> = {
5858
threads: 0,
5959
pullRequests: 0,
@@ -75,9 +75,10 @@ function createWorkspaceTabsModel() {
7575
export function WorkspaceTabsProvider(props: {
7676
readonly children: ReactNode;
7777
readonly settingsOpen?: boolean;
78+
readonly initialTab?: WorkspaceTab;
7879
}) {
7980
const registry = use(RegistryContext);
80-
const [model] = useState(createWorkspaceTabsModel);
81+
const [model] = useState(() => createWorkspaceTabsModel(props.initialTab));
8182
const state = useAtomValue(model.resolved);
8283
const context = {
8384
state,

‎apps/mobile/src/features/workspace/workspace-tabs-state.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,16 @@ function emptyTab(): WorkspaceTabState {
3838
return { query: "", searchMode: "resting", scrollOffset: 0, searchEntryOffset: 0 };
3939
}
4040

41-
export function initialWorkspaceTabsState(): WorkspaceTabsState {
41+
/** The list a workspace page belongs to. */
42+
export function workspaceTabOf(routeName: string | undefined): WorkspaceTab {
43+
return routeName === "PullRequest" ? "pullRequests" : "threads";
44+
}
45+
46+
export function initialWorkspaceTabsState(
47+
selectedTab: WorkspaceTab = "threads",
48+
): WorkspaceTabsState {
4249
return {
43-
selectedTab: "threads",
50+
selectedTab,
4451
selectionRevision: 0,
4552
tabs: {
4653
threads: emptyTab(),

0 commit comments

Comments
 (0)