The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 14:30 UTC
fix(mobile): sidebar connection status uses the header's free width (#26266)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 27, 2026 at 22:03 UTC
28da8c84ff46f4beae9e2febed0fb8a75b77f224
3 files changed
+86
-56
apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
+6
-5
@@ -11,6 +11,7 @@ import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area
11
12
import { CompactBrandTitle } from "../../components/CompactBrandTitle";
13
import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
14
+import { HeaderItemsWidthContext } from "../../native/header-items-width";
15
import { NativeStackScreenOptions } from "../../native/StackHeader";
16
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
17
import { isDuoDevice } from "../../lib/device-type";
@@ -49,10 +50,11 @@ import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
50
const TAB_TITLES = WORKSPACE_TAB_LABELS;
51
52
function WorkspaceRootTitle(props: {
52
- readonly maxWidth: number;
53
+ readonly columnWidth: number;
54
readonly onOpenEnvironments: () => void;
55
}) {
56
const { state, settingsOpen } = useWorkspaceTabs()!;
57
+ const maxWidth = Math.max(0, props.columnWidth - (use(HeaderItemsWidthContext) ?? 160));
58
const enabled = useEnabledNavigationTabs();
59
const tabTitle = settingsOpen
60
? "Settings"
@@ -60,10 +62,10 @@ function WorkspaceRootTitle(props: {
62
? TAB_TITLES[state.selectedTab]
63
: "Navigation";
64
return (
63
- <View style={{ width: props.maxWidth, minHeight: 32, justifyContent: "center" }}>
65
+ <View style={{ width: maxWidth, minHeight: 32, justifyContent: "center" }}>
66
<WorkspaceConnectionTitle
67
brand={<CompactBrandTitle accessibilityLabel={`T3 Code, ${tabTitle}`} fit />}
66
- maxWidth={props.maxWidth}
68
+ maxWidth={maxWidth}
69
onPress={props.onOpenEnvironments}
70
/>
71
</View>
@@ -99,8 +101,7 @@ function WorkspaceRootContent() {
101
const settingsOpen = workspace.settingsOpen;
102
const renderHeaderTitle = () => (
103
<WorkspaceRootTitle
102
- // Settings adds its scope filter beside search.
103
- maxWidth={Math.max(0, width - 160 - (settingsOpen ? 44 : 0))}
104
+ columnWidth={width}
105
onOpenEnvironments={() => openSettings(navigation, "SettingsEnvironments")}
106
/>
107
);
apps/mobile/src/native/V5StackHeader.ios.tsx
+76
-51
@@ -9,6 +9,7 @@ import { KeyboardController, useKeyboardState } from "react-native-keyboard-cont
9
import { isDuoDevice } from "../lib/device-type";
10
import { useMobileNavigationTheme } from "../lib/useMobileNavigationTheme";
11
import { useDeviceType, useNativeLayoutMetrics } from "../native/native-layout-metrics";
12
+import { HeaderItemsWidthContext } from "./header-items-width";
13
import {
14
SearchBar,
15
Stack,
@@ -22,6 +23,10 @@ import {
23
type HeaderBarButtonSearchBarPlacementItem,
24
} from "react-native-screens";
25
26
+// UIKit's bar margins, and the width of a glass bar button.
27
+const BAR_MARGINS = 32;
28
+const BAR_BUTTON_WIDTH = 44;
29
+
30
type HeaderItem = NonNullable<NonNullable<StackHeaderConfigProps["ios"]>["leadingItems"]>[number];
31
type ToolbarItem =
32
| NativeStackHeaderItem
@@ -276,6 +281,24 @@ export function V5StackHeader(props: {
281
const frame = requestAnimationFrame(() => autofocusRef.current?.focus());
282
return () => cancelAnimationFrame(frame);
283
}, [searchOptions?.autoFocus, autofocusRef]);
284
+ const searchButton = !bottomSearch && searchOptions?.placement === "integratedButton";
285
+ const itemsWidth =
286
+ BAR_MARGINS +
287
+ (props.canGoBack && options.headerBackVisible !== false ? BAR_BUTTON_WIDTH : 0) +
288
+ (searchButton ? BAR_BUTTON_WIDTH : 0) +
289
+ [...leading, ...trailing].reduce(
290
+ (width, item) =>
291
+ width +
292
+ (item.type === "spacer"
293
+ ? item.sizing === "fixed"
294
+ ? item.width
295
+ : 0
296
+ : // The keyboard dismiss rides the vertical bar, not beside the title.
297
+ item.id === "dismiss-keyboard"
298
+ ? 0
299
+ : BAR_BUTTON_WIDTH),
300
+ 0,
301
+ );
302
const titleStyle = StyleSheet.flatten(options.headerTitleStyle);
303
const headerStyle = StyleSheet.flatten(options.headerStyle);
304
const appearance = {
@@ -292,56 +315,58 @@ export function V5StackHeader(props: {
315
subtitleFontColor: options.headerSubtitleStyle?.color,
316
};
317
return (
295
- <Stack.HeaderConfig
296
- hidden={options.headerShown === false}
297
- transparent={options.headerTransparent}
298
- title={title}
299
- subtitle={options.unstable_headerSubtitle ?? options.headerSubtitle}
300
- backButtonHidden={options.headerBackVisible === false}
301
- ios={{
302
- navigationItemStyle: options.unstable_navigationItemStyle,
303
- // Opt-ins apply only where the Duo is short: folded, or held landscape. The Duo
304
- // resolves `automatic` to minimize on scroll, so the tall unfolded display opts out.
305
- minimizationBehavior: !isDuoDevice(deviceType)
306
- ? undefined
307
- : deviceType === "duo-unfolded" &&
308
- nativeMetrics &&
309
- nativeMetrics.height > nativeMetrics.width
310
- ? "never"
311
- : options.unstable_headerMinimizationBehavior,
312
- tintColor: options.headerTintColor,
313
- searchBar:
314
- mailSearch || searchOptions ? (
315
- <SearchBar
316
- {...searchOptions}
317
- ref={searchOptions?.ref ?? searchRef}
318
- hideNavigationBar={false}
319
- hideWhenScrolling={false}
320
- allowToolbarIntegration={searchOptions?.allowToolbarIntegration ?? true}
321
- placement={bottomSearch ? "integrated" : (searchOptions?.placement ?? "automatic")}
322
- placeholder={mailSearch?.placeholder ?? searchOptions?.placeholder ?? "Search"}
323
- onFocus={(event) => {
324
- searchOptions?.onFocus?.(event);
325
- }}
326
- onChangeText={(event) => {
327
- mailSearch?.onSearchTextChange?.(event.nativeEvent.text);
328
- searchOptions?.onChangeText?.(event);
329
- }}
330
- />
331
- ) : undefined,
332
- toolbarItems: bottom,
333
- leadingItems: leading,
334
- trailingItems: trailing,
335
- titleItem: isValidElement(titleElement)
336
- ? { id: "title", render: () => titleElement }
337
- : undefined,
338
- largeTitleEnabled: options.headerLargeTitle,
339
- backButtonDisplayMode: options.headerBackButtonDisplayMode ?? "minimal",
340
- backButtonMenuEnabled: options.headerBackButtonMenuEnabled ?? true,
341
- backButtonTitle: options.headerBackTitle,
342
- standardAppearance: appearance,
343
- scrollEdgeAppearance: appearance,
344
- }}
345
- />
318
+ <HeaderItemsWidthContext value={itemsWidth}>
319
+ <Stack.HeaderConfig
320
+ hidden={options.headerShown === false}
321
+ transparent={options.headerTransparent}
322
+ title={title}
323
+ subtitle={options.unstable_headerSubtitle ?? options.headerSubtitle}
324
+ backButtonHidden={options.headerBackVisible === false}
325
+ ios={{
326
+ navigationItemStyle: options.unstable_navigationItemStyle,
327
+ // Opt-ins apply only where the Duo is short: folded, or held landscape. The Duo
328
+ // resolves `automatic` to minimize on scroll, so the tall unfolded display opts out.
329
+ minimizationBehavior: !isDuoDevice(deviceType)
330
+ ? undefined
331
+ : deviceType === "duo-unfolded" &&
332
+ nativeMetrics &&
333
+ nativeMetrics.height > nativeMetrics.width
334
+ ? "never"
335
+ : options.unstable_headerMinimizationBehavior,
336
+ tintColor: options.headerTintColor,
337
+ searchBar:
338
+ mailSearch || searchOptions ? (
339
+ <SearchBar
340
+ {...searchOptions}
341
+ ref={searchOptions?.ref ?? searchRef}
342
+ hideNavigationBar={false}
343
+ hideWhenScrolling={false}
344
+ allowToolbarIntegration={searchOptions?.allowToolbarIntegration ?? true}
345
+ placement={bottomSearch ? "integrated" : (searchOptions?.placement ?? "automatic")}
346
+ placeholder={mailSearch?.placeholder ?? searchOptions?.placeholder ?? "Search"}
347
+ onFocus={(event) => {
348
+ searchOptions?.onFocus?.(event);
349
+ }}
350
+ onChangeText={(event) => {
351
+ mailSearch?.onSearchTextChange?.(event.nativeEvent.text);
352
+ searchOptions?.onChangeText?.(event);
353
+ }}
354
+ />
355
+ ) : undefined,
356
+ toolbarItems: bottom,
357
+ leadingItems: leading,
358
+ trailingItems: trailing,
359
+ titleItem: isValidElement(titleElement)
360
+ ? { id: "title", render: () => titleElement }
361
+ : undefined,
362
+ largeTitleEnabled: options.headerLargeTitle,
363
+ backButtonDisplayMode: options.headerBackButtonDisplayMode ?? "minimal",
364
+ backButtonMenuEnabled: options.headerBackButtonMenuEnabled ?? true,
365
+ backButtonTitle: options.headerBackTitle,
366
+ standardAppearance: appearance,
367
+ scrollEdgeAppearance: appearance,
368
+ }}
369
+ />
370
+ </HeaderItemsWidthContext>
371
);
372
}
apps/mobile/src/native/header-items-width.ts
new
+4
@@ -0,0 +1,4 @@
1
+import { createContext } from "react";
2
+
3
+/** Width a header's own buttons and margins take beside a custom title, which RN sizes itself. */
4
+export const HeaderItemsWidthContext = createContext<number | null>(null);