Skip to content

Commit d61499f

Browse files
t3dotggclaude
andcommitted
fix(mobile): reconnects no longer shift the thread list
The environment connection status rendered as a row above the thread list, so every reconnect pushed the rows down and popped them back. The brand/title slot in the header now doubles as the status surface: while an environment is unavailable the lockup ("Threads" on the iPad sidebar) fades to a spinner plus status label in place, and fades back on reconnect. Nothing is inserted into the list, so its geometry never moves. An 800ms debounce keeps sub-second blips invisible entirely. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent 94696b0 commit d61499f

9 files changed

Lines changed: 326 additions & 152 deletions

‎apps/mobile/src/components/CompactBrandTitle.tsx‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../native/native-glass";
1616
const IOS_NATIVE_LEADING_TITLE_OFFSET = -6;
1717
const IPAD_NATIVE_LEADING_TITLE_OFFSET = 7;
1818

19+
/**
20+
* Horizontal correction applied to content rendered in the brand title slot,
21+
* shared with the connection-status swap so both align identically.
22+
*/
23+
export function brandTitleOffset(nativeLeadingItem: boolean): number {
24+
if (Platform.OS !== "ios") return 0;
25+
if (nativeLeadingItem) {
26+
return Platform.isPad ? IPAD_NATIVE_LEADING_TITLE_OFFSET : IOS_NATIVE_LEADING_TITLE_OFFSET;
27+
}
28+
return Platform.isPad ? IPAD_HOME_TITLE_OFFSET : 0;
29+
}
30+
1931
/**
2032
* Compact brand lockup sized for native navigation bars.
2133
*/
@@ -28,16 +40,7 @@ export function CompactBrandTitle(
2840
const mutedColor = useThemeColor("--color-foreground-muted");
2941
const subtleColor = useThemeColor("--color-subtle");
3042
const stageLabel = resolveMobileStageLabel(Constants.expoConfig?.extra?.appVariant);
31-
const titleOffset =
32-
Platform.OS !== "ios"
33-
? 0
34-
: props.nativeLeadingItem
35-
? Platform.isPad
36-
? IPAD_NATIVE_LEADING_TITLE_OFFSET
37-
: IOS_NATIVE_LEADING_TITLE_OFFSET
38-
: Platform.isPad
39-
? IPAD_HOME_TITLE_OFFSET
40-
: 0;
43+
const titleOffset = brandTitleOffset(props.nativeLeadingItem === true);
4144

4245
return (
4346
<View

‎apps/mobile/src/features/home/HomeHeader.tsx‎

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,
2222
} from "../layout/native-mail-search-toolbar";
2323
import type { HomeProjectSortOrder } from "./homeThreadList";
24+
import { WorkspaceConnectionTitle } from "./WorkspaceConnectionTitle";
2425
import {
2526
buildHomeListFilterMenu,
2627
type HomeListFilterMenuEnvironment,
@@ -47,6 +48,7 @@ export function HomeHeader(props: {
4748
readonly onProjectChange: (projectKey: string | null) => void;
4849
readonly onProjectSortOrderChange: (sortOrder: HomeProjectSortOrder) => void;
4950
readonly onThreadSortOrderChange: (sortOrder: SidebarThreadSortOrder) => void;
51+
readonly onOpenEnvironments: () => void;
5052
readonly onOpenSettings: () => void;
5153
readonly onStartNewTask: () => void;
5254
}) {
@@ -207,18 +209,27 @@ function AndroidHomeHeader(props: HomeHeaderProps) {
207209
>
208210
<View className="w-full max-w-[720px] self-center gap-3">
209211
<View className="flex-row items-center gap-2.5">
210-
<View className="flex-1 flex-row items-center gap-2">
211-
{/* Mirrors the desktop SidebarBrand: T3 mark + muted "Code". */}
212-
<T3Wordmark color={iconColor} height={15} />
213-
<RNText className="-ml-0.5 text-[21px] font-t3-medium tracking-[-0.5px] text-foreground-muted">
214-
Code
215-
</RNText>
216-
<View className="rounded-full bg-subtle px-2 py-0.75">
217-
<RNText className="text-[11px] font-t3-bold tracking-[1.1px] text-foreground-muted uppercase">
218-
{stageLabel}
219-
</RNText>
220-
</View>
221-
</View>
212+
{/* Brand slot doubles as the connection status surface: while an
213+
environment reconnects, the lockup fades to a status label in
214+
place (no layout shift in the list below). */}
215+
<WorkspaceConnectionTitle
216+
grow
217+
onPress={props.onOpenEnvironments}
218+
brand={
219+
<View className="flex-row items-center gap-2">
220+
{/* Mirrors the desktop SidebarBrand: T3 mark + muted "Code". */}
221+
<T3Wordmark color={iconColor} height={15} />
222+
<RNText className="-ml-0.5 text-[21px] font-t3-medium tracking-[-0.5px] text-foreground-muted">
223+
Code
224+
</RNText>
225+
<View className="rounded-full bg-subtle px-2 py-0.75">
226+
<RNText className="text-[11px] font-t3-bold tracking-[1.1px] text-foreground-muted uppercase">
227+
{stageLabel}
228+
</RNText>
229+
</View>
230+
</View>
231+
}
232+
/>
222233

223234
<ControlPillMenu
224235
actions={menuActions}

‎apps/mobile/src/features/home/HomeRouteScreen.tsx‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as Order from "effect/Order";
33
import { useNavigation } from "@react-navigation/native";
44
import { useEffect, useMemo, useState } from "react";
55

6-
import { getCompactBrandHeaderOptions } from "../../components/CompactBrandTitle";
76
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
87
import { useProjects, useThreadShells } from "../../state/entities";
98
import { usePendingNewTasks } from "../../state/use-pending-new-tasks";
@@ -20,6 +19,7 @@ import { useHomeListOptions } from "./home-list-options";
2019
import { buildHomeProjectScopes } from "./homeThreadList";
2120
import { usePendingTaskListActions } from "./usePendingTaskListActions";
2221
import { useThreadListActions } from "./useThreadListActions";
22+
import { getConnectionAwareBrandHeaderOptions } from "./WorkspaceConnectionTitle";
2323

2424
/* ─── Route screen ───────────────────────────────────────────────────── */
2525

@@ -126,8 +126,16 @@ export function HomeRouteScreen() {
126126
onStartNewTask={() => navigation.navigate("NewTaskSheet", { screen: "NewTask" })}
127127
>
128128
<>
129-
{/* Restore the compact title after the split branch blanks the detail header. */}
130-
<NativeStackScreenOptions options={getCompactBrandHeaderOptions()} />
129+
{/* Restore the compact title after the split branch blanks the detail
130+
header. The brand slot doubles as the connection status surface:
131+
while an environment reconnects, the lockup fades to a status label
132+
in place (no layout shift in the list below). */}
133+
<NativeStackScreenOptions
134+
options={getConnectionAwareBrandHeaderOptions({
135+
onOpenEnvironments: () =>
136+
navigation.navigate("SettingsSheet", { screen: "SettingsEnvironments" }),
137+
})}
138+
/>
131139
<HomeHeader
132140
environments={environments}
133141
projects={projectFilterOptions}
@@ -138,6 +146,9 @@ export function HomeRouteScreen() {
138146
threadSortOrder={listOptions.threadSortOrder}
139147
onEnvironmentChange={setSelectedEnvironmentId}
140148
onProjectChange={setSelectedProjectKey}
149+
onOpenEnvironments={() =>
150+
navigation.navigate("SettingsSheet", { screen: "SettingsEnvironments" })
151+
}
141152
onOpenSettings={() => navigation.navigate("SettingsSheet", { screen: "Settings" })}
142153
onProjectSortOrderChange={setProjectSortOrder}
143154
onSearchQueryChange={setSearchQuery}
@@ -161,9 +172,6 @@ export function HomeRouteScreen() {
161172
onUnpinThread={unpinThread}
162173
onEnvironmentChange={setSelectedEnvironmentId}
163174
onProjectChange={setSelectedProjectKey}
164-
onOpenEnvironments={() =>
165-
navigation.navigate("SettingsSheet", { screen: "SettingsEnvironments" })
166-
}
167175
onOpenSettings={() => navigation.navigate("SettingsSheet", { screen: "Settings" })}
168176
onProjectSortOrderChange={setProjectSortOrder}
169177
onSearchQueryChange={setSearchQuery}

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ import {
7171
type HomeProjectSortOrder,
7272
} from "./homeThreadList";
7373
import { SwipeableScrollGateProvider, useSwipeableScrollGate } from "./thread-swipe-actions";
74-
import { WorkspaceConnectionStatus } from "./WorkspaceConnectionStatus";
75-
import { shouldShowWorkspaceConnectionStatus } from "./workspace-connection-status";
7674

7775
/* ─── Types ──────────────────────────────────────────────────────────── */
7876

@@ -97,7 +95,6 @@ interface HomeScreenProps {
9795
readonly onProjectSortOrderChange: (sortOrder: HomeProjectSortOrder) => void;
9896
readonly onThreadSortOrderChange: (sortOrder: SidebarThreadSortOrder) => void;
9997
readonly onAddConnection: () => void;
100-
readonly onOpenEnvironments: () => void;
10198
readonly onOpenSettings: () => void;
10299
readonly onStartNewTask: () => void;
103100
readonly onSelectThread: (thread: EnvironmentThreadShell) => void;
@@ -969,20 +966,13 @@ export function HomeScreen(props: HomeScreenProps) {
969966
? null
970967
: (props.savedConnectionsById[props.selectedEnvironmentId]?.environmentLabel ??
971968
"this environment");
972-
const shouldShowConnectionStatus = shouldShowWorkspaceConnectionStatus(props.catalogState);
969+
// Connection state surfaces in the header title slot
970+
// (WorkspaceConnectionTitle) — nothing renders inside the list, so
971+
// reconnects never shift the rows.
973972
const emptyState = deriveEmptyState({
974973
catalogState: props.catalogState,
975974
projectCount: props.projects.length,
976975
});
977-
const connectionStatus =
978-
shouldShowConnectionStatus && Platform.OS !== "ios" ? (
979-
<View
980-
className="absolute left-0 right-0 items-center"
981-
style={{ bottom: Math.max(insets.bottom, 18) + 76 }}
982-
>
983-
<WorkspaceConnectionStatus state={props.catalogState} onPress={props.onOpenEnvironments} />
984-
</View>
985-
) : null;
986976

987977
if (!hasAnyThreads) {
988978
return (
@@ -1001,41 +991,17 @@ export function HomeScreen(props: HomeScreenProps) {
1001991
onAction={!props.catalogState.hasReadyEnvironment ? props.onAddConnection : undefined}
1002992
variant="plain"
1003993
/>
1004-
{emptyState.loading && !shouldShowConnectionStatus ? (
994+
{emptyState.loading ? (
1005995
<View className="mt-4 items-center">
1006996
<ActivityIndicator color={accentColor} />
1007997
</View>
1008998
) : null}
1009-
{shouldShowConnectionStatus && Platform.OS === "ios" ? (
1010-
<View className="mt-4">
1011-
<WorkspaceConnectionStatus
1012-
state={props.catalogState}
1013-
onPress={props.onOpenEnvironments}
1014-
variant="sidebar"
1015-
/>
1016-
</View>
1017-
) : null}
1018999
</View>
1019-
{connectionStatus}
10201000
</View>
10211001
);
10221002
}
10231003

1024-
const listHeader = (
1025-
<>
1026-
{Platform.OS === "ios" ? null : <HomeTopContentSpacer />}
1027-
1028-
{shouldShowConnectionStatus && Platform.OS === "ios" ? (
1029-
<View className="pb-4">
1030-
<WorkspaceConnectionStatus
1031-
state={props.catalogState}
1032-
onPress={props.onOpenEnvironments}
1033-
variant="sidebar"
1034-
/>
1035-
</View>
1036-
) : null}
1037-
</>
1038-
);
1004+
const listHeader = Platform.OS === "ios" ? null : <HomeTopContentSpacer />;
10391005

10401006
// Project scoping lives in the header filter menu (no inline chip row on
10411007
// mobile — the menu is the one filter surface).
@@ -1116,7 +1082,6 @@ export function HomeScreen(props: HomeScreenProps) {
11161082
}}
11171083
/>
11181084
</SwipeableScrollGateProvider>
1119-
{connectionStatus}
11201085
</View>
11211086
);
11221087
}
@@ -1171,7 +1136,6 @@ export function HomeScreen(props: HomeScreenProps) {
11711136
}
11721137
/>
11731138
</SwipeableScrollGateProvider>
1174-
{connectionStatus}
11751139
</View>
11761140
);
11771141
}

‎apps/mobile/src/features/home/WorkspaceConnectionStatus.tsx‎

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)