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, 20:45 UTC
fix(mobile): the composer stays one row until the draft wraps (#20812)
Co-authored-by: Pixel Perfect <me@pixp.cc> Co-authored-by: Theo Browne <me@t3.gg> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Julius Marminge committed
Oct 20, 2026 at 13:08 UTC
dac3437d94129a7a072d19ffa482845624a25d14
22 files changed
+469
-201
apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz
Binary files a/apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz and /dev/null differ
apps/mobile/deps/react-native-screens-5.0.0-t3.30.tgz
Binary files /dev/null and b/apps/mobile/deps/react-native-screens-5.0.0-t3.30.tgz differ
apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ComposerEditorView.kt
+12
-4
@@ -57,6 +57,7 @@ class T3ComposerEditorView(context: Context, appContext: AppContext) : ExpoView(
57
private var applyingNativeValue = false
58
private var desiredLineHeightPx = 0
59
private var lastContentHeight = 0
60
+ private var lastContentWidth = 0
61
private var contentInsetVertical = 0
62
private var tokensJson = "[]"
63
private var tokens: List<ComposerToken> = emptyList()
@@ -424,12 +425,19 @@ class T3ComposerEditorView(context: Context, appContext: AppContext) : ExpoView(
425
}
426
427
private fun emitContentSizeIfNeeded() {
427
- val height = editor.layout?.height ?: editor.measuredHeight
428
- val contentHeight = height + contentInsetVertical * 2
429
- if (contentHeight == lastContentHeight) return
428
+ // The laid-out text without insets. A one-line draft reports its natural width, so
429
+ // JS can tell whether it fits a narrower row than the one it is laid out in; past
430
+ // one line only the height matters. Trailing whitespace hangs past a line without
431
+ // wrapping it, so getLineMax leaves it out.
432
+ val layout = editor.layout
433
+ val contentHeight = layout?.height ?: editor.measuredHeight
434
+ val contentWidth = if (layout?.lineCount == 1) layout.getLineMax(0).toInt() else 0
435
+ if (contentHeight == lastContentHeight && contentWidth == lastContentWidth) return
436
lastContentHeight = contentHeight
437
+ lastContentWidth = contentWidth
438
+ val density = resources.displayMetrics.density
439
onComposerContentSizeChange(
432
- mapOf("height" to contentHeight / resources.displayMetrics.density),
440
+ mapOf("width" to contentWidth / density, "height" to contentHeight / density),
441
)
442
}
443
apps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorView.swift
+22
-1
@@ -1230,7 +1230,28 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro
1230
}
1231
1232
private func emitContentSizeIfNeeded() {
1233
- let nextSize = textView.contentSize
1233
+ // The laid-out text without insets. A one-line draft reports its natural width, so
1234
+ // JS can tell whether it fits a narrower row than the one it is laid out in; past
1235
+ // one line only the height matters, so layout stops at the second line. The width
1236
+ // comes from the line fragment because usedRect spans the container once the view
1237
+ // scrolls. A trailing newline's empty line only exists as the extra fragment.
1238
+ let layout = textView.layoutManager
1239
+ let container = textView.textContainer
1240
+ var lines = 0
1241
+ var width: CGFloat = 0
1242
+ var height: CGFloat = 0
1243
+ let glyphs = NSRange(location: 0, length: layout.numberOfGlyphs)
1244
+ layout.enumerateLineFragments(forGlyphRange: glyphs) { _, used, _, _, stop in
1245
+ lines += 1
1246
+ width = used.width
1247
+ height = used.maxY
1248
+ if lines > 1 { stop.pointee = true }
1249
+ }
1250
+ if lines < 2, layout.extraLineFragmentTextContainer === container {
1251
+ lines += 1
1252
+ height = max(height, layout.extraLineFragmentUsedRect.maxY)
1253
+ }
1254
+ let nextSize = CGSize(width: lines == 1 ? ceil(width) : 0, height: ceil(height))
1255
guard abs(nextSize.width - lastContentSize.width) > 0.5 ||
1256
abs(nextSize.height - lastContentSize.height) > 0.5 else {
1257
return
apps/mobile/package.json
+1
-1
@@ -134,7 +134,7 @@
134
"react-native-pdf-jsi": "5.0.0",
135
"react-native-reanimated": "4.7.1",
136
"react-native-safe-area-context": "~5.10.1",
137
- "react-native-screens": "file:deps/react-native-screens-5.0.0-t3.29.tgz",
137
+ "react-native-screens": "file:deps/react-native-screens-5.0.0-t3.30.tgz",
138
"react-native-shiki-engine": "^0.3.12",
139
"react-native-svg": "15.16.0",
140
"react-native-webview": "14.0.1",
apps/mobile/src/components/ComposerToolbar.tsx
+76
-47
@@ -13,6 +13,8 @@ import {
13
type ViewStyle,
14
} from "react-native";
15
16
+import Animated, { FadeIn, LinearTransition } from "react-native-reanimated";
17
+
18
import { cn } from "../lib/cn";
19
import { AppText as Text } from "./ui/AppText";
20
import { SymbolView } from "./ui/AppSymbol";
@@ -21,6 +23,10 @@ import { useAndroidControlSizing } from "./ui/useAndroidControlSizing";
23
const COMPOSER_TOOLBAR_GAP = 8;
24
const COMPOSER_TOOLBAR_FADE_WIDTH = 18;
25
const COMPOSER_TOOLBAR_SCROLL_EPSILON = 4;
26
+const INLINE_CONTROL_LABEL_ENTERING = FadeIn.duration(160);
27
+// Android runs no composer layout transitions, so the toolbar never trails the dock.
28
+const INLINE_CONTROL_WIDTH_TRANSITION =
29
+ Platform.OS === "android" ? undefined : LinearTransition.duration(180);
30
31
export function ComposerInlineControl(props: {
32
readonly accessibilityHint?: string;
@@ -30,6 +36,8 @@ export function ComposerInlineControl(props: {
36
readonly icon?: ComponentProps<typeof SymbolView>["name"];
37
readonly renderIcon?: (size: number) => ReactNode;
38
readonly label: string;
39
+ /** Show only the icon and chevron; the label still names the control for accessibility. */
40
+ readonly iconOnly?: boolean;
41
readonly maxWidth?: ViewStyle["maxWidth"];
42
readonly onPress?: () => void;
43
readonly selected?: boolean;
@@ -38,56 +46,77 @@ export function ComposerInlineControl(props: {
46
readonly showChevron?: boolean;
47
}) {
48
const { scale, smallIconSize } = useAndroidControlSizing();
49
+ // The label fades in as the control widens, and leaves at once: an exiting view keeps
50
+ // drawing at its old place while the chevron moves into it. The clip keeps content laid out
51
+ // at the final width inside the frame while it eases there.
52
+ const animatesLabel = props.iconOnly !== undefined;
53
return (
42
- <Pressable
43
- accessibilityLabel={props.accessibilityLabel ?? props.label}
44
- accessibilityHint={props.accessibilityHint}
45
- accessibilityRole={props.static ? undefined : "button"}
46
- accessibilityState={
47
- props.static ? undefined : { disabled: props.disabled, selected: props.selected }
48
- }
49
- className="h-11 flex-row items-center gap-2 rounded-xl px-2 active:bg-subtle"
50
- disabled={props.disabled || props.static}
51
- onPress={props.onPress}
52
- style={{ maxWidth: props.maxWidth ?? 190, opacity: props.disabled ? 0.45 : 1 }}
54
+ <Animated.View
55
+ layout={animatesLabel ? INLINE_CONTROL_WIDTH_TRANSITION : undefined}
56
+ style={{
57
+ maxWidth: props.maxWidth ?? 190,
58
+ overflow: animatesLabel ? "hidden" : undefined,
59
+ }}
60
>
54
- {props.renderIcon ? (
55
- <View
56
- className="size-4 shrink-0 items-center justify-center"
57
- style={Platform.OS === "android" ? { width: 14 * scale, height: 14 * scale } : undefined}
58
- >
59
- {props.renderIcon(smallIconSize)}
60
- </View>
61
- ) : props.icon ? (
62
- <SymbolView
63
- name={props.icon}
64
- size={smallIconSize}
65
- tintColorClassName={
66
- props.emphasized || props.selected ? "accent-icon" : "accent-icon-muted"
67
- }
68
- type="monochrome"
69
- />
70
- ) : null}
71
- <Text
72
- className={cn(
73
- "shrink text-sm font-t3-medium",
74
- props.emphasized || props.selected ? "text-foreground" : "text-foreground-muted",
75
- )}
76
- numberOfLines={1}
61
+ <Pressable
62
+ accessibilityLabel={props.accessibilityLabel ?? props.label}
63
+ accessibilityHint={props.accessibilityHint}
64
+ accessibilityRole={props.static ? undefined : "button"}
65
+ accessibilityState={
66
+ props.static ? undefined : { disabled: props.disabled, selected: props.selected }
67
+ }
68
+ className="h-11 flex-row items-center gap-2 rounded-xl px-2 active:bg-subtle"
69
+ disabled={props.disabled || props.static}
70
+ onPress={props.onPress}
71
+ style={{ opacity: props.disabled ? 0.45 : 1 }}
72
>
78
- {props.label}
79
- </Text>
80
- {props.showChevron === false ? null : (
81
- <SymbolView
82
- name={props.chevronDirection === "right" ? "chevron.right" : "chevron.down"}
83
- size={Math.round(10 * scale)}
84
- tintColorClassName={
85
- props.emphasized || props.selected ? "accent-icon" : "accent-icon-muted"
86
- }
87
- type="monochrome"
88
- />
89
- )}
90
- </Pressable>
73
+ {props.renderIcon ? (
74
+ <View
75
+ className="size-4 shrink-0 items-center justify-center"
76
+ style={
77
+ Platform.OS === "android" ? { width: 14 * scale, height: 14 * scale } : undefined
78
+ }
79
+ >
80
+ {props.renderIcon(smallIconSize)}
81
+ </View>
82
+ ) : props.icon ? (
83
+ <SymbolView
84
+ name={props.icon}
85
+ size={smallIconSize}
86
+ tintColorClassName={
87
+ props.emphasized || props.selected ? "accent-icon" : "accent-icon-muted"
88
+ }
89
+ type="monochrome"
90
+ />
91
+ ) : null}
92
+ {props.iconOnly ? null : (
93
+ <Animated.View
94
+ className="shrink"
95
+ entering={animatesLabel ? INLINE_CONTROL_LABEL_ENTERING : undefined}
96
+ >
97
+ <Text
98
+ className={cn(
99
+ "text-sm font-t3-medium",
100
+ props.emphasized || props.selected ? "text-foreground" : "text-foreground-muted",
101
+ )}
102
+ numberOfLines={1}
103
+ >
104
+ {props.label}
105
+ </Text>
106
+ </Animated.View>
107
+ )}
108
+ {props.showChevron === false ? null : (
109
+ <SymbolView
110
+ name={props.chevronDirection === "right" ? "chevron.right" : "chevron.down"}
111
+ size={Math.round(10 * scale)}
112
+ tintColorClassName={
113
+ props.emphasized || props.selected ? "accent-icon" : "accent-icon-muted"
114
+ }
115
+ type="monochrome"
116
+ />
117
+ )}
118
+ </Pressable>
119
+ </Animated.View>
120
);
121
}
122
apps/mobile/src/components/ui/AndroidScreenHeader.tsx
+25
-1
@@ -1,5 +1,6 @@
1
import { AppActivityIndicator } from "./AppActivityIndicator";
2
-import { Column, Text as NativeText, RNHostView } from "@expo/ui/jetpack-compose";
2
+import { Column, Row, Text as NativeText, RNHostView } from "@expo/ui/jetpack-compose";
3
+import { weight } from "@expo/ui/jetpack-compose/modifiers";
4
import { useState, type ReactNode } from "react";
5
import { View } from "react-native";
6
@@ -43,6 +44,8 @@ export function AndroidScreenHeader(props: {
44
readonly onBack?: () => void;
45
readonly embedded?: boolean;
46
readonly hideBottomBorder?: boolean;
47
+ /** One row with the subtitle after the title, for screens short on height. */
48
+ readonly compact?: boolean;
49
}) {
50
const { colors } = useControlTheme();
51
const titleTypography = useScaledTextRole("title");
@@ -65,6 +68,7 @@ export function AndroidScreenHeader(props: {
68
}}
69
>
70
<NativeAppBar
71
+ singleLine={props.compact}
72
navigationIcon={
73
props.onBack || props.leading ? (
74
<View collapsable={false} className="flex-row items-center">
@@ -95,6 +99,26 @@ export function AndroidScreenHeader(props: {
99
>
100
{props.title}
101
</NativeText>
102
+ ) : props.compact ? (
103
+ <Row verticalAlignment="center" horizontalArrangement={{ spacedBy: 8 }}>
104
+ <NativeText
105
+ color={colors["--color-header-foreground"]}
106
+ maxLines={1}
107
+ overflow="ellipsis"
108
+ style={titleTypography}
109
+ >
110
+ {props.title}
111
+ </NativeText>
112
+ <NativeText
113
+ color={colors["--color-foreground-muted"]}
114
+ maxLines={1}
115
+ overflow="ellipsis"
116
+ style={subtitleTypography}
117
+ modifiers={[weight(1)]}
118
+ >
119
+ {props.subtitle}
120
+ </NativeText>
121
+ </Row>
122
) : (
123
<Column>
124
<NativeText
apps/mobile/src/components/ui/AppBar.android.tsx
+1
@@ -158,6 +158,7 @@ export function AppBar(props: AppBarProps) {
158
onBack={props.onBack}
159
leading={props.sidebar !== false ? <AndroidWorkspaceSidebarButton /> : undefined}
160
hideBottomBorder={props.hideBottomBorder}
161
+ compact={props.compact}
162
actions={
163
search
164
? [
apps/mobile/src/components/ui/AppBar.types.ts
+2
@@ -68,6 +68,8 @@ export interface AppBarProps {
68
readonly onPress?: () => void;
69
};
70
readonly hideBottomBorder?: boolean;
71
+ /** Android: one title row with the subtitle inline. iOS ignores it. */
72
+ readonly compact?: boolean;
73
readonly trailing?: ReactNode;
74
readonly matchSearchSurface?: boolean;
75
readonly options?: AppNativeStackNavigationOptions;
apps/mobile/src/components/ui/NativeAppBar.android.tsx
+3
-1
@@ -10,9 +10,11 @@ export function NativeAppBar(props: {
10
readonly title: ReactElement;
11
readonly navigationIcon?: ReactElement;
12
readonly actions?: ReactElement;
13
+ /** Shorter bar for a one-row title. */
14
+ readonly singleLine?: boolean;
15
}) {
16
const { colors } = useControlTheme();
15
- const layout = useToolbarLayout();
17
+ const layout = useToolbarLayout(false, props.singleLine);
18
return (
19
// The bar's height is fixed, so React Native lays out the screen below it from the first frame
20
// instead of at zero height until Compose has measured and reported the bar.
apps/mobile/src/components/ui/useToolbarLayout.ts
+8
-3
@@ -4,8 +4,11 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
4
import { useScaledTextRole } from "../../features/settings/appearance/useScaledTextRole";
5
import { useAndroidControlSizing } from "./useAndroidControlSizing";
6
7
-/** Shared Android header geometry; class-based spacing uses the app's 14dp rem. */
8
-export function useToolbarLayout(embedded = false) {
7
+/**
8
+ * Shared Android header geometry; class-based spacing uses the app's 14dp rem.
9
+ * `singleLine` sizes the toolbar for a title row with the subtitle inline.
10
+ */
11
+export function useToolbarLayout(embedded = false, singleLine = false) {
12
const insets = useSafeAreaInsets();
13
const title = useScaledTextRole("title");
14
const subtitle = useScaledTextRole("label");
@@ -13,7 +16,9 @@ export function useToolbarLayout(embedded = false) {
16
const { fontScale } = useWindowDimensions();
17
return {
18
height: Math.ceil(
16
- Math.max(48, 56 * scale, (title.lineHeight + subtitle.lineHeight) * fontScale + 1),
19
+ singleLine
20
+ ? Math.max(48, 48 * scale, title.lineHeight * fontScale + 1)
21
+ : Math.max(48, 56 * scale, (title.lineHeight + subtitle.lineHeight) * fontScale + 1),
22
),
23
paddingTop: embedded ? 8 * scale : Math.max(insets.top, 12 * scale),
24
paddingBottom: 7 * scale,
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+102
-49
@@ -15,6 +15,7 @@ import {
15
import {
16
createContext,
17
use,
18
+ useDeferredValue,
19
useEffect,
20
useEffectEvent,
21
useMemo,
@@ -23,6 +24,7 @@ import {
24
type ReactNode,
25
} from "react";
26
import { Platform, useWindowDimensions, View } from "react-native";
27
+import { KeyboardController, useKeyboardState } from "react-native-keyboard-controller";
28
import Animated, {
29
runOnJS,
30
useAnimatedStyle,
@@ -73,7 +75,10 @@ import { useOpenThreadPullRequests } from "../threads/use-open-thread-pull-reque
75
import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";
76
import { WORKSPACE_PANE_TIMING } from "./workspace-pane-animation";
77
import { WorkspaceInspectorPane } from "./workspace-inspector-pane";
76
-import { WorkspaceContentWidthContext } from "./workspace-content-width";
78
+import {
79
+ WorkspaceContentWidthContext,
80
+ WorkspaceSettledContentWidthContext,
81
+} from "./workspace-content-width";
82
import {
83
NativeWorkspaceModeContext,
84
NativeWorkspaceInspectorContext,
@@ -96,6 +101,13 @@ interface AdaptiveWorkspaceContextValue {
101
readonly toggleAuxiliaryPane: () => void;
102
readonly togglePrimarySidebar: () => void;
103
readonly setAuxiliaryPaneWidth: (width: number) => void;
104
+ /**
105
+ * Android split view while the thread composer has the soft keyboard: the
106
+ * sidebar and rail step aside and the thread header drops to one line.
107
+ */
108
+ readonly composerKeyboardActive: boolean;
109
+ /** The thread composer reports its focus so the layout can make room for typing. */
110
+ readonly setComposerEditing: (editing: boolean) => void;
111
}
112
113
const compactLayout = deriveLayout({ width: 0, height: 0 });
@@ -122,6 +134,8 @@ const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceContextValue>({
134
toggleAuxiliaryPane: () => undefined,
135
togglePrimarySidebar: () => undefined,
136
setAuxiliaryPaneWidth: () => undefined,
137
+ composerKeyboardActive: false,
138
+ setComposerEditing: () => undefined,
139
});
140
141
export function useAdaptiveWorkspaceLayout(): AdaptiveWorkspaceContextValue {
@@ -270,8 +284,19 @@ function AdaptiveWorkspaceLayoutContent(
284
nativeWorkspace,
285
usesSplitView: baseLayout.usesSplitView,
286
});
287
+ const [composerEditing, setComposerEditing] = useState(false);
288
+ const softKeyboardVisible = useKeyboardState((state) => state.isVisible);
289
+ // Keyed on the soft keyboard, not focus alone: a hardware keyboard leaves room
290
+ // for the sidebar, and Back closes the keyboard while the editor keeps focus.
291
+ // Deferred because the thread composer follows the keyboard only once its own render of this
292
+ // keyboard event commits; re-laying out the workspace in that commit held it behind the
293
+ // keyboard until the feed had reflowed.
294
+ const composerKeyboardActive = useDeferredValue(
295
+ Platform.OS === "android" && baseLayout.usesSplitView && composerEditing && softKeyboardVisible,
296
+ );
297
const showPrimarySidebar =
274
- !workspacePage && (primarySidebarPinned || primarySidebarPreferredVisible);
298
+ !workspacePage &&
299
+ (primarySidebarPinned || (primarySidebarPreferredVisible && !composerKeyboardActive));
300
const shouldRenderNavigationRail = Platform.OS === "android" && baseLayout.usesSplitView;
301
const navigationRailWidth =
302
shouldRenderNavigationRail && (showPrimarySidebar || workspacePage)
@@ -391,6 +416,12 @@ function AdaptiveWorkspaceLayoutContent(
416
if (primarySidebarPinned) {
417
return;
418
}
419
+ // A sidebar the keyboard set aside returns with the keyboard; the user's preference stays
420
+ // intact. One the user had hidden still opens.
421
+ if (composerKeyboardActive) {
422
+ void KeyboardController.dismiss();
423
+ if (primarySidebarPreferredVisible) return;
424
+ }
425
if (!panes.primarySidebarVisible && panes.primarySidebarSuppressedByAuxiliary) {
426
setFileInspectorPreferredVisible(false);
427
setPrimarySidebarPreferredVisible(true);
@@ -399,6 +430,7 @@ function AdaptiveWorkspaceLayoutContent(
430
setPrimarySidebarPreferredVisible((current) => !current);
431
};
432
const revealPrimarySidebar = () => {
433
+ if (composerKeyboardActive) void KeyboardController.dismiss();
434
if (panes.primarySidebarSuppressedByAuxiliary) {
435
setFileInspectorPreferredVisible(false);
436
}
@@ -499,12 +531,10 @@ function AdaptiveWorkspaceLayoutContent(
531
const contentTargetWidth = layout.usesSplitView
532
? Math.max(0, panes.contentPaneWidth - inspectorColumnTargetWidth)
533
: null;
502
- const [contentSizing, setContentSizing] = useState({
534
+ const [listPaneSizing, setListPaneSizing] = useState({
535
viewportWidth,
536
workspacePage,
505
- target: contentTargetWidth,
537
sidebarVisible: panes.primarySidebarVisible,
507
- width: contentTargetWidth,
538
listPaneTarget: layout.listPaneWidth,
539
listPaneFloor: layout.listPaneWidth,
540
listPaneCeiling: layout.listPaneWidth,
@@ -512,69 +542,80 @@ function AdaptiveWorkspaceLayoutContent(
542
});
543
if (
544
Platform.OS === "android" &&
515
- (contentSizing.viewportWidth !== viewportWidth ||
516
- contentSizing.workspacePage !== workspacePage ||
517
- contentSizing.target !== contentTargetWidth ||
518
- contentSizing.sidebarVisible !== panes.primarySidebarVisible ||
519
- contentSizing.listPaneTarget !== layout.listPaneWidth)
545
+ (listPaneSizing.viewportWidth !== viewportWidth ||
546
+ listPaneSizing.workspacePage !== workspacePage ||
547
+ listPaneSizing.sidebarVisible !== panes.primarySidebarVisible ||
548
+ listPaneSizing.listPaneTarget !== layout.listPaneWidth)
549
) {
521
- // A workspace page swaps the sidebar in the same frame, so nothing animates to wait for.
522
- const sameViewport =
523
- contentSizing.viewportWidth === viewportWidth &&
524
- contentSizing.workspacePage === workspacePage;
525
- const openingSidebar =
526
- sameViewport && !contentSizing.sidebarVisible && panes.primarySidebarVisible;
550
// A book-posture hinge resizes the visible list pane instead of revealing it.
551
const resizingSidebar =
529
- sameViewport &&
530
- contentSizing.sidebarVisible &&
552
+ listPaneSizing.viewportWidth === viewportWidth &&
553
+ listPaneSizing.workspacePage === workspacePage &&
554
+ listPaneSizing.sidebarVisible &&
555
panes.primarySidebarVisible &&
532
- contentSizing.listPaneTarget !== layout.listPaneWidth;
533
- const keepWide =
534
- (openingSidebar || resizingSidebar) &&
535
- contentSizing.width !== null &&
536
- contentTargetWidth !== null;
537
- setContentSizing({
556
+ listPaneSizing.listPaneTarget !== layout.listPaneWidth;
557
+ setListPaneSizing({
558
viewportWidth,
559
workspacePage,
540
- target: contentTargetWidth,
560
sidebarVisible: panes.primarySidebarVisible,
542
- // Clip the wide navigator while the sidebar opens or widens, then reflow once at the
543
- // end. Narrowing it first exposes an empty strip before the sidebar arrives.
544
- width: keepWide
545
- ? Math.max(contentSizing.width ?? 0, contentTargetWidth ?? 0)
546
- : contentTargetWidth,
561
listPaneTarget: layout.listPaneWidth,
562
// While a hinge resizes the list, its width follows the pane edge within this span. A
563
// retarget mid-animation widens the span, since the edge is still somewhere inside it.
564
listPaneFloor: resizingSidebar
551
- ? Math.min(contentSizing.listPaneFloor ?? 0, layout.listPaneWidth ?? 0)
565
+ ? Math.min(listPaneSizing.listPaneFloor ?? 0, layout.listPaneWidth ?? 0)
566
: layout.listPaneWidth,
567
listPaneCeiling: resizingSidebar
554
- ? Math.max(contentSizing.listPaneCeiling ?? 0, layout.listPaneWidth ?? 0)
568
+ ? Math.max(listPaneSizing.listPaneCeiling ?? 0, layout.listPaneWidth ?? 0)
569
: layout.listPaneWidth,
556
- revision: contentSizing.revision + 1,
570
+ revision: listPaneSizing.revision + 1,
571
});
572
}
559
- const settleContentWidth = (revision: number) => {
560
- setContentSizing((current) =>
573
+ const settleListPane = (revision: number) => {
574
+ setListPaneSizing((current) =>
575
current.revision !== revision ||
562
- (current.width === current.target &&
563
- current.listPaneFloor === current.listPaneTarget &&
576
+ (current.listPaneFloor === current.listPaneTarget &&
577
current.listPaneCeiling === current.listPaneTarget)
578
? current
579
: {
580
...current,
568
- width: current.target,
581
listPaneFloor: current.listPaneTarget,
582
listPaneCeiling: current.listPaneTarget,
583
},
584
);
585
};
574
- const listPaneFloor = contentSizing.listPaneFloor ?? 0;
575
- const listPaneCeiling = contentSizing.listPaneCeiling ?? 0;
576
- const contentSettledWidth = Platform.OS === "android" ? contentSizing.width : contentTargetWidth;
577
- const contentRevision = contentSizing.revision;
586
+ const listPaneFloor = listPaneSizing.listPaneFloor ?? 0;
587
+ const listPaneCeiling = listPaneSizing.listPaneCeiling ?? 0;
588
+ const listPaneRevision = listPaneSizing.revision;
589
+ // Android lays the content out at its new width as soon as a pane toggles, then holds it
590
+ // against the edge that stays put while the other one slides, so nothing reflows after the
591
+ // panes land. A sliding sidebar uncovers the strip it is about to fill, or covers the content
592
+ // until it is gone.
593
+ const contentLeftTarget =
594
+ navigationRailWidth +
595
+ (shouldRenderPrimarySidebar && !workspacePage && panes.primarySidebarVisible
596
+ ? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
597
+ : 0);
598
+ const [contentAnchor, setContentAnchor] = useState({
599
+ viewportWidth,
600
+ left: contentLeftTarget,
601
+ inspector: inspectorColumnTargetWidth,
602
+ end: false,
603
+ });
604
+ if (
605
+ Platform.OS === "android" &&
606
+ (contentAnchor.viewportWidth !== viewportWidth ||
607
+ contentAnchor.left !== contentLeftTarget ||
608
+ contentAnchor.inspector !== inspectorColumnTargetWidth)
609
+ ) {
610
+ setContentAnchor({
611
+ viewportWidth,
612
+ left: contentLeftTarget,
613
+ inspector: inspectorColumnTargetWidth,
614
+ end:
615
+ contentAnchor.viewportWidth === viewportWidth &&
616
+ contentAnchor.inspector === inspectorColumnTargetWidth,
617
+ });
618
+ }
619
620
const renderedSidebarWidth = useSharedValue(
621
panes.primarySidebarVisible ? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0) : 0,
@@ -598,7 +639,7 @@ function AdaptiveWorkspaceLayoutContent(
639
// The content beside it already took its final width when the page closed.
640
renderedSidebarWidth.set(
641
withTiming(targetWidth, snap ? { duration: 0 } : WORKSPACE_PANE_TIMING, (finished) => {
601
- if (finished && Platform.OS === "android") runOnJS(settleContentWidth)(contentRevision);
642
+ if (finished && Platform.OS === "android") runOnJS(settleListPane)(listPaneRevision);
643
}),
644
);
645
}, [
@@ -609,8 +650,8 @@ function AdaptiveWorkspaceLayoutContent(
650
panes.primarySidebarVisible,
651
renderedSidebarWidth,
652
renderedRailWidth,
612
- settleContentWidth,
613
- contentRevision,
653
+ settleListPane,
654
+ listPaneRevision,
655
workspacePage,
656
]);
657
const railAnimatedStyle = useAnimatedStyle(() => ({ width: renderedRailWidth.value }));
@@ -699,6 +740,8 @@ function AdaptiveWorkspaceLayoutContent(
740
toggleAuxiliaryPane,
741
togglePrimarySidebar,
742
setAuxiliaryPaneWidth,
743
+ composerKeyboardActive,
744
+ setComposerEditing,
745
};
746
747
if (nativeWorkspace) {
@@ -796,18 +839,28 @@ function AdaptiveWorkspaceLayoutContent(
839
<View
840
collapsable={false}
841
style={
799
- contentSettledWidth !== null
842
+ contentTargetWidth !== null
843
? {
844
flex: 1,
802
- width: contentSettledWidth,
845
+ width: contentTargetWidth,
846
+ alignSelf: contentAnchor.end ? "flex-end" : "flex-start",
847
}
848
: { flex: 1 }
849
}
850
>
851
+ {/* Android holds the content still, so its floating controls keep its width. */}
852
<WorkspaceContentWidthContext
808
- value={layout.usesSplitView ? renderedContentWidth : null}
853
+ value={
854
+ layout.usesSplitView && Platform.OS !== "android" ? renderedContentWidth : null
855
+ }
856
>
810
- {props.children}
857
+ <WorkspaceSettledContentWidthContext
858
+ value={
859
+ Platform.OS === "android" && layout.usesSplitView ? contentTargetWidth : null
860
+ }
861
+ >
862
+ {props.children}
863
+ </WorkspaceSettledContentWidthContext>
864
</WorkspaceContentWidthContext>
865
</View>
866
</View>
apps/mobile/src/features/layout/workspace-content-width.ts
+9
@@ -8,3 +8,12 @@ export const WorkspaceContentWidthContext = createContext<SharedValue<number> |
8
export function useWorkspaceContentWidth() {
9
return use(WorkspaceContentWidthContext);
10
}
11
+
12
+// The settled width itself. The feed lays its rows out at this width in the same commit that
13
+// resizes the pane; waiting for its own onLayout re-measured every row twice, once against the
14
+// old text widths, and the list jumped while it repositioned them.
15
+export const WorkspaceSettledContentWidthContext = createContext<number | null>(null);
16
+
17
+export function useWorkspaceSettledContentWidth() {
18
+ return use(WorkspaceSettledContentWidthContext);
19
+}
apps/mobile/src/features/threads/ThreadComposer.tsx
+154
-82
@@ -1,6 +1,7 @@
1
import { Button } from "../../components/ui/Button";
2
import * as Dialog from "../../components/ui/Dialog";
3
import type { ComposerTextPaste } from "../../native/T3ComposerEditor.types";
4
+import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
5
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
6
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
7
import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
@@ -187,6 +188,7 @@ export interface ThreadComposerProps {
188
readonly onUpdateModelSelection: (modelSelection: ModelSelection) => void;
189
readonly onUpdateRuntimeMode: (runtimeMode: RuntimeMode) => void;
190
readonly onUpdateInteractionMode: (interactionMode: ProviderInteractionMode) => void;
191
+ /** True while the draft is stacked above the controls rather than in the one-row capsule. */
192
readonly onExpandedChange?: (expanded: boolean) => void;
193
readonly onEditorFocusChange?: (focused: boolean) => void;
194
}
@@ -220,6 +222,11 @@ const composerHeightTransition: LayoutAnimationFunction = (values) => {
222
};
223
export const COMPOSER_LAYOUT_TRANSITION =
224
Platform.OS === "android" ? undefined : composerHeightTransition;
225
+// Share of the one-row composer the draft keeps; a long model name truncates first.
226
+const INLINE_EDITOR_MIN_WIDTH = "40%";
227
+// The one-row editor's horizontal padding plus room for the caret.
228
+const INLINE_EDITOR_TEXT_SLACK = 10;
229
+const INLINE_EDITOR_HEIGHT = 36;
230
231
const COMPOSER_ATTACHMENT_ENTERING =
232
Platform.OS === "android"
@@ -495,8 +502,39 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
502
);
503
const isVoiceInputPresented = voicePresentation.statusLabel !== null;
504
const isExpanded = isFocused || settingsSheetPresentation.keepsComposerExpanded;
498
- const showsCompactDictation = isVoiceInputPresented && !isExpanded;
499
- const isToolbarVisible = isExpanded || isVoiceInputPresented;
505
+ const { setComposerEditing } = useAdaptiveWorkspaceLayout();
506
+ // The composer stays one row, with the model picker in it, until the draft would
507
+ // wrap. Then the draft stacks above the controls and returns to the row once it
508
+ // fits again. The native editor reports its laid-out text size: more than one
509
+ // line means the draft wrapped where it is, and the widest line is a one-line
510
+ // draft's natural width, which is compared with the row's text area so a draft
511
+ // laid out in the wider card still returns to the row when it fits, including
512
+ // when the pane widens. The measurements live in refs and only the verdict is
513
+ // state, so a keystroke that keeps the verdict costs no extra render.
514
+ const draftSizeRef = useRef({ width: 0, height: 0 });
515
+ const rowGeometryRef = useRef({ surfaceWidth: 0, leadingWidth: 0, trailingWidth: 0 });
516
+ const [draftOverflowsRow, setDraftOverflowsRow] = useState(false);
517
+ const lineHeight = bodyText.lineHeight;
518
+ const updateDraftOverflow = () => {
519
+ const { width, height } = draftSizeRef.current;
520
+ const row = rowGeometryRef.current;
521
+ const rowTextWidth =
522
+ row.surfaceWidth - row.leadingWidth - row.trailingWidth - INLINE_EDITOR_TEXT_SLACK;
523
+ setDraftOverflowsRow(
524
+ height > lineHeight * 1.5 || (row.surfaceWidth > 0 && width > rowTextWidth),
525
+ );
526
+ };
527
+ const measureRow = (key: keyof typeof rowGeometryRef.current, value: number) => {
528
+ if (rowGeometryRef.current[key] === value) return;
529
+ rowGeometryRef.current = { ...rowGeometryRef.current, [key]: value };
530
+ updateDraftOverflow();
531
+ };
532
+ const usesCard = isExpanded && draftMessage.length > 0 && draftOverflowsRow;
533
+ const showsCompactDictation = isVoiceInputPresented && !usesCard;
534
+ const isToolbarVisible = usesCard || isVoiceInputPresented;
535
+ const hasEditingAttachments =
536
+ (queuedEdit !== null && queuedEdit.existingAttachments.length > 0) ||
537
+ stripAttachments.length > 0;
538
const attachmentBlockReason = composerAttachmentUploadBlockReason({
539
environmentId: props.environmentId,
540
attachments: draftAttachments,
@@ -519,8 +557,9 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
557
!modelUnavailable;
558
559
useEffect(() => {
522
- onExpandedChange?.(isExpanded);
523
- }, [isExpanded, onExpandedChange]);
560
+ onExpandedChange?.(usesCard);
561
+ }, [usesCard, onExpandedChange]);
562
+ useEffect(() => () => setComposerEditing(false), [setComposerEditing]);
563
564
const onPressPreview = (source: FilePreviewSource) => {
565
wasExpandedBeforePreviewRef.current = isFocused;
@@ -553,16 +592,14 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
592
const onEditorFocusChange = props.onEditorFocusChange;
593
const handleFocus = () => {
594
setIsFocused(true);
556
- onExpandedChange?.(true);
595
onEditorFocusChange?.(true);
596
+ setComposerEditing(true);
597
};
598
599
const handleBlur = () => {
600
setIsFocused(false);
562
- if (!settingsSheetPresentation.keepsComposerExpanded) {
563
- onExpandedChange?.(false);
564
- }
601
onEditorFocusChange?.(false);
602
+ setComposerEditing(false);
603
};
604
const handleSend = async (followUp?: ActiveTurnComposerAction) => {
605
if (voiceInput.blocksSubmission || pendingPastedTextAttachmentCountRef.current > 0) return;
@@ -676,12 +713,80 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
713
[navigation, settingsSheetPresentation.onStackTransitionsFinished],
714
);
715
716
+ // Removable attachments: inside the card, or above the focused one-row composer.
717
+ const editingAttachments = hasEditingAttachments ? (
718
+ <>
719
+ {queuedEdit !== null && queuedEdit.existingAttachments.length > 0 ? (
720
+ <Animated.View
721
+ className="px-[14px] pb-2.5"
722
+ entering={COMPOSER_ATTACHMENT_ENTERING}
723
+ exiting={FadeOut.duration(120)}
724
+ >
725
+ <ComposerQueuedEditAttachments
726
+ environmentId={props.environmentId}
727
+ attachments={queuedEdit.existingAttachments}
728
+ disabled={queuedEdit.saving || voiceInput.isBusy}
729
+ onRemove={queuedEdit.onRemoveExistingAttachment}
730
+ />
731
+ </Animated.View>
732
+ ) : null}
733
+ {stripAttachments.length > 0 ? (
734
+ <Animated.View
735
+ className="px-[14px] pb-2.5"
736
+ entering={COMPOSER_ATTACHMENT_ENTERING}
737
+ exiting={FadeOut.duration(120)}
738
+ >
739
+ <ComposerAttachmentStrip
740
+ environmentId={props.environmentId}
741
+ attachments={stripAttachments}
742
+ onRemove={voiceInput.isBusy ? () => undefined : props.onRemoveDraftImage}
743
+ onPressPreview={voiceInput.isBusy ? undefined : onPressPreview}
744
+ onPressVideo={voiceInput.isBusy ? undefined : onPressVideo}
745
+ onPressDocument={
746
+ voiceInput.isBusy
747
+ ? undefined
748
+ : (attachment) =>
749
+ openDraftDocument({
750
+ attachmentId: attachment.id,
751
+ name: attachment.name,
752
+ mimeType: attachment.mimeType,
753
+ sizeBytes: attachment.sizeBytes,
754
+ })
755
+ }
756
+ />
757
+ </Animated.View>
758
+ ) : null}
759
+ </>
760
+ ) : null;
761
+
762
+ // The row and the card's toolbar share this picker. It shrinks to the provider
763
+ // icon once the draft has text, so the draft keeps the width.
764
+ const modelControl = (
765
+ <View className="min-w-0 shrink">
766
+ <ComposerInlineControl
767
+ accessibilityLabel="Model and reasoning settings"
768
+ emphasized
769
+ renderIcon={(size) => (
770
+ <ProviderIcon
771
+ iconUrl={currentModelOption?.providerIconUrl}
772
+ provider={currentModelOption?.providerDriver}
773
+ size={size}
774
+ />
775
+ )}
776
+ label={currentModelOption?.label ?? currentModelSelection.model}
777
+ iconOnly={draftMessage.length > 0}
778
+ maxWidth="100%"
779
+ onPress={openSettings}
780
+ />
781
+ </View>
782
+ );
783
+
784
return (
785
<Animated.View
786
className="px-[12px]"
787
style={{
683
- paddingTop: isExpanded ? 8 : 6,
684
- paddingBottom: (props.bottomInset ?? 0) + (isExpanded ? 8 : 6),
788
+ paddingTop: usesCard ? 8 : 6,
789
+ paddingBottom: (props.bottomInset ?? 0) + (usesCard ? 8 : 6),
790
backgroundColor:
791
Platform.OS === "android" ? themeColorWithAlpha(composerPanel, 1) : undefined,
792
}}
@@ -700,6 +805,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
805
<Animated.View
806
className="relative w-full self-center"
807
style={{ maxWidth: props.contentMaxWidth }}
808
+ onLayout={(event) => measureRow("surfaceWidth", event.nativeEvent.layout.width)}
809
>
810
{!voiceInput.isBusy &&
811
composerMenu.trigger &&
@@ -746,10 +852,9 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
852
853
<ComposerSurface
854
style={
749
- isExpanded
855
+ usesCard
856
? {
857
borderRadius: 26,
752
- minHeight: 140,
858
overflow: "hidden" as const,
859
paddingBottom: 6,
860
paddingTop: 14,
@@ -761,12 +866,13 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
866
}
867
}
868
>
869
+ {isExpanded && !usesCard ? editingAttachments : null}
870
<ComposerDictationDraftContent
765
- className={isExpanded ? undefined : "flex-row items-center"}
766
- compact={!isExpanded}
871
+ className={usesCard ? undefined : "flex-row items-center"}
872
+ compact={!usesCard}
873
hidden={showsCompactDictation}
874
>
769
- {!isExpanded ? (
875
+ {!usesCard ? (
876
<ComposerAttachmentButton
877
supportsFiles={Boolean(
878
props.serverConfig?.environment.capabilities.fileAttachments,
@@ -775,49 +881,16 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
881
onPickFiles={props.onPickDraftFiles}
882
/>
883
) : null}
778
- {isExpanded && queuedEdit !== null && queuedEdit.existingAttachments.length > 0 ? (
779
- <Animated.View
780
- className="px-[14px] pb-2.5"
781
- entering={COMPOSER_ATTACHMENT_ENTERING}
782
- exiting={FadeOut.duration(120)}
783
- >
784
- <ComposerQueuedEditAttachments
785
- environmentId={props.environmentId}
786
- attachments={queuedEdit.existingAttachments}
787
- disabled={queuedEdit.saving || voiceInput.isBusy}
788
- onRemove={queuedEdit.onRemoveExistingAttachment}
789
- />
790
- </Animated.View>
791
- ) : null}
792
- {isExpanded && stripAttachments.length > 0 ? (
793
- <Animated.View
794
- className="px-[14px] pb-2.5"
795
- entering={COMPOSER_ATTACHMENT_ENTERING}
796
- exiting={FadeOut.duration(120)}
797
- >
798
- <ComposerAttachmentStrip
799
- environmentId={props.environmentId}
800
- attachments={stripAttachments}
801
- onRemove={voiceInput.isBusy ? () => undefined : props.onRemoveDraftImage}
802
- onPressPreview={voiceInput.isBusy ? undefined : onPressPreview}
803
- onPressVideo={voiceInput.isBusy ? undefined : onPressVideo}
804
- onPressDocument={
805
- voiceInput.isBusy
806
- ? undefined
807
- : (attachment) =>
808
- openDraftDocument({
809
- attachmentId: attachment.id,
810
- name: attachment.name,
811
- mimeType: attachment.mimeType,
812
- sizeBytes: attachment.sizeBytes,
813
- })
814
- }
815
- />
816
- </Animated.View>
817
- ) : null}
884
+ {usesCard ? editingAttachments : null}
885
<Animated.View
819
- className={isExpanded ? "px-[14px]" : "min-w-0 flex-1 px-[4px]"}
886
+ className={usesCard ? "px-[14px]" : "min-w-0 flex-1 px-[4px]"}
887
+ style={usesCard ? undefined : { minWidth: INLINE_EDITOR_MIN_WIDTH }}
888
layout={COMPOSER_LAYOUT_TRANSITION}
889
+ onLayout={
890
+ usesCard
891
+ ? undefined
892
+ : (event) => measureRow("leadingWidth", event.nativeEvent.layout.x)
893
+ }
894
>
895
<ComposerEditor
896
hidden={props.hidden}
@@ -931,19 +1004,29 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
1004
: FOLLOW_UP_ACTION_LABEL[sendPresentation.alternate]
1005
}
1006
scrollEnabled={isExpanded}
934
- singleLineCentered={!isExpanded}
1007
+ singleLineCentered={!usesCard}
1008
contentInsetVertical={
936
- isExpanded || Platform.OS === "android" ? 0 : collapsedEditorInset(bodyText)
1009
+ usesCard || Platform.OS === "android" ? 0 : collapsedEditorInset(bodyText)
1010
}
1011
+ onContentSizeChange={(size) => {
1012
+ draftSizeRef.current = size;
1013
+ updateDraftOverflow();
1014
+ }}
1015
style={
939
- isExpanded
1016
+ usesCard
1017
? {
941
- minHeight: 72,
942
- maxHeight: 160,
1018
+ // A stacked draft shows two to four lines, then scrolls.
1019
+ minHeight: lineHeight * 2 + 8,
1020
+ maxHeight: lineHeight * 4 + 8,
1021
paddingVertical: 4,
1022
}
1023
: {
946
- height: 36,
1024
+ // Large text sizes need room for one full line plus the iOS inset.
1025
+ height: Math.max(
1026
+ INLINE_EDITOR_HEIGHT,
1027
+ Math.ceil(lineHeight) +
1028
+ (Platform.OS === "android" ? 0 : 2 * collapsedEditorInset(bodyText)),
1029
+ ),
1030
}
1031
}
1032
textStyle={{
@@ -975,8 +1058,12 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
1058
) : null}
1059
</View>
1060
) : null}
978
- {!isExpanded ? (
979
- <View className="flex-row items-center">
1061
+ {!usesCard ? (
1062
+ <View
1063
+ className="min-w-0 shrink flex-row items-center"
1064
+ onLayout={(event) => measureRow("trailingWidth", event.nativeEvent.layout.width)}
1065
+ >
1066
+ {modelControl}
1067
<ComposerDictationStartAction
1068
state={voiceInput.state}
1069
isAvailable={voiceInput.isAvailable}
@@ -1008,7 +1095,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
1095
)}
1096
</View>
1097
) : null}
1011
- {isExpanded ? <View className="h-1" /> : null}
1098
+ {usesCard ? <View className="h-1" /> : null}
1099
</ComposerDictationDraftContent>
1100
<Animated.View
1101
accessibilityElementsHidden={!isToolbarVisible}
@@ -1017,7 +1104,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
1104
layout={COMPOSER_LAYOUT_TRANSITION}
1105
pointerEvents={isToolbarVisible ? "auto" : "none"}
1106
style={
1020
- isExpanded
1107
+ usesCard
1108
? undefined
1109
: {
1110
position: "absolute",
@@ -1058,22 +1145,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
1145
onPickMedia={props.onPickDraftMedia}
1146
onPickFiles={props.onPickDraftFiles}
1147
/>
1061
- <View className="min-w-0 shrink">
1062
- <ComposerInlineControl
1063
- accessibilityLabel="Model and reasoning settings"
1064
- emphasized
1065
- renderIcon={(size) => (
1066
- <ProviderIcon
1067
- iconUrl={currentModelOption?.providerIconUrl}
1068
- provider={currentModelOption?.providerDriver}
1069
- size={size}
1070
- />
1071
- )}
1072
- label={currentModelOption?.label ?? currentModelSelection.model}
1073
- maxWidth="100%"
1074
- onPress={openSettings}
1075
- />
1076
- </View>
1148
+ {modelControl}
1149
</View>
1150
)}
1151
<View className="shrink-0 flex-row items-center">
apps/mobile/src/features/threads/ThreadFeed.tsx
+13
-1
@@ -1,6 +1,7 @@
1
import { Button } from "../../components/ui/Button";
2
import * as Dialog from "../../components/ui/Dialog";
3
import { useOpenPullRequest } from "../../native/useOpenPullRequest";
4
+import { useWorkspaceSettledContentWidth } from "../layout/workspace-content-width";
5
import { ThreadMarkdownVideo, ThreadMediaVisibleContext } from "./ThreadMarkdownVideo";
6
import { useMarkdownImageSource } from "../../native/useMarkdownImageSource";
7
import { enrichedContextLinkCustomization } from "../../native/useEnrichedLinkVariants";
@@ -1696,9 +1697,12 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
1697
previousTextSize.current = workRowSizing.textSizeKey;
1698
listRef.current?.clearCaches({ mode: "sizes" });
1699
}, [workRowSizing.textSizeKey, listRef]);
1699
- const [viewportWidth, setViewportWidth] = useState(() =>
1700
+ const settledPaneWidth = useWorkspaceSettledContentWidth();
1701
+ const [measuredViewportWidth, setViewportWidth] = useState(() =>
1702
props.layoutVariant === "split" ? 0 : windowWidth,
1703
);
1704
+ const viewportWidth =
1705
+ settledPaneWidth !== null ? Math.round(settledPaneWidth) : measuredViewportWidth;
1706
const [viewportHeight, setViewportHeight] = useState(0);
1707
const [disclosureToggleSettling, setDisclosureToggleSettling] = useState(false);
1708
// LegendList's maintainScrollAtEnd alone re-pins the feed whenever the
@@ -2402,6 +2406,14 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2406
if (previousContentWidth.current === contentWidth) return;
2407
previousContentWidth.current = contentWidth;
2408
if (hasHtmlRenders) listRef.current?.clearCaches({ mode: "sizes" });
2409
+ // A reflow can grow the visible rows past LegendList's near-end threshold in one batch, and
2410
+ // maintainScrollAtEnd then stops following. Pin the end the feed was following once the new
2411
+ // sizes are in.
2412
+ if (!endFollowEnabledRef.current || !listRef.current?.getState().isAtEnd) return;
2413
+ const frame = requestAnimationFrame(() => {
2414
+ if (endFollowEnabledRef.current) void listRef.current?.scrollToEnd({ animated: false });
2415
+ });
2416
+ return () => cancelAnimationFrame(frame);
2417
}, [contentWidth, hasHtmlRenders, listRef]);
2418
2419
const renderItem = (info: { item: PendingThreadFeedEntry; index: number }) => (
apps/mobile/src/features/threads/ThreadHeader.tsx
+3
-1
@@ -20,7 +20,8 @@ export function ThreadHeader(
20
},
21
) {
22
const goBack = useWorkspaceBackNavigation("threads");
23
- const { layout, panes, toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();
23
+ const { layout, panes, toggleAuxiliaryPane, composerKeyboardActive } =
24
+ useAdaptiveWorkspaceLayout();
25
const { onOpenTerminal, onMergeBack } = props.gitControls;
26
const native = useThreadHeaderOptions(props);
27
const androidHeaderActions = useMemo<ReadonlyArray<AppBarAction>>(() => {
@@ -100,6 +101,7 @@ export function ThreadHeader(
101
onBack={layout.usesSplitView ? undefined : goBack}
102
actions={androidHeaderActions}
103
hideBottomBorder
104
+ compact={composerKeyboardActive}
105
/>
106
{native.fallback}
107
</>
apps/mobile/src/native/T3ComposerEditor.ios.tsx
+9
@@ -99,6 +99,9 @@ interface NativeComposerEditorProps extends ViewProps {
99
readonly onComposerFocus?: () => void;
100
readonly onComposerBlur?: () => void;
101
readonly onComposerSubmit?: (event: NativeSyntheticEvent<{ alternate: boolean }>) => void;
102
+ readonly onComposerContentSizeChange?: (
103
+ event: NativeSyntheticEvent<{ readonly width: number; readonly height: number }>,
104
+ ) => void;
105
}
106
107
const NativeView = requireNativeView<NativeComposerEditorProps>(NATIVE_MODULE_NAME);
@@ -125,6 +128,7 @@ export function ComposerEditor({
128
onFocus,
129
onBlur,
130
onSubmit,
131
+ onContentSizeChange,
132
contentInsetVertical = 0,
133
...props
134
}: ComposerEditorProps) {
@@ -349,6 +353,11 @@ export function ComposerEditor({
353
}}
354
onComposerFocus={onFocus}
355
onComposerBlur={onBlur}
356
+ onComposerContentSizeChange={
357
+ onContentSizeChange === undefined
358
+ ? undefined
359
+ : (event) => onContentSizeChange(event.nativeEvent)
360
+ }
361
onComposerSubmit={
362
onSubmit === undefined
363
? undefined
apps/mobile/src/native/T3ComposerEditor.native.tsx
+9
@@ -98,6 +98,9 @@ interface NativeComposerEditorProps extends ViewProps {
98
readonly onComposerPasteText?: (event: NativePasteTextEvent) => void;
99
readonly onComposerFocus?: () => void;
100
readonly onComposerBlur?: () => void;
101
+ readonly onComposerContentSizeChange?: (
102
+ event: NativeSyntheticEvent<{ readonly width: number; readonly height: number }>,
103
+ ) => void;
104
}
105
106
const NativeView = requireNativeView<NativeComposerEditorProps>(NATIVE_MODULE_NAME);
@@ -123,6 +126,7 @@ export function ComposerEditor({
126
onPasteText,
127
onFocus,
128
onBlur,
129
+ onContentSizeChange,
130
contentInsetVertical = 0,
131
...props
132
}: ComposerEditorProps) {
@@ -354,6 +358,11 @@ export function ComposerEditor({
358
}}
359
onComposerFocus={onFocus}
360
onComposerBlur={onBlur}
361
+ onComposerContentSizeChange={
362
+ onContentSizeChange === undefined
363
+ ? undefined
364
+ : (event) => onContentSizeChange(event.nativeEvent)
365
+ }
366
/>
367
</TextInputWrapper>
368
);
apps/mobile/src/native/T3ComposerEditor.tsx
+2
@@ -19,6 +19,7 @@ export function ComposerEditor({
19
singleLineCentered: _singleLineCentered,
20
enterBehavior: _enterBehavior,
21
readOnly = false,
22
+ onContentSizeChange,
23
...props
24
}: ComposerEditorProps) {
25
const inputRef = useRef<TextInputInstance>(null);
@@ -45,6 +46,7 @@ export function ComposerEditor({
46
editable={(props.editable ?? true) && !readOnly}
47
selection={selection}
48
onSelectionChange={(event) => props.onSelectionChange?.(event.nativeEvent.selection)}
49
+ onContentSizeChange={(event) => onContentSizeChange?.(event.nativeEvent.contentSize)}
50
multiline={props.multiline ?? true}
51
placeholderTextColorClassName={"accent-placeholder"}
52
className="text-foreground"
apps/mobile/src/native/T3ComposerEditor.types.ts
+8
@@ -68,6 +68,14 @@ export interface ComposerEditorProps {
68
readonly onPasteText?: (paste: ComposerTextPaste) => void;
69
readonly onFocus?: () => void;
70
readonly onBlur?: () => void;
71
+ /**
72
+ * Size of the laid-out text in dp, without insets. Width is the widest line, so a
73
+ * one-line draft reports its natural width; only fires when the size changes.
74
+ */
75
+ readonly onContentSizeChange?: (size: {
76
+ readonly width: number;
77
+ readonly height: number;
78
+ }) => void;
79
/**
80
* Hardware-keyboard Return behavior on iOS. No-op on Android, which has no
81
* hardware Return handling.
docs/operations/mobile-screens-fork.md
+1
-1
@@ -1,7 +1,7 @@
1
# Building the mobile Screens dependency
2
3
The mobile v5 stack uses a committed tarball from the
4
-[T3 Screens fork](https://github.com/pingdotgg/react-native-screens/tree/t3-v5.0.0-t3.29).
4
+[T3 Screens fork](https://github.com/pingdotgg/react-native-screens/tree/t3-v5.0.0-t3.30).
5
The fork owns the integration changes; the app does not patch this package.
6
Each archive includes compiled JavaScript, declarations, native source and
7
`t3-fork.json` recording its version, source commit and upstream base.
pnpm-lock.yaml
+9
-9
@@ -380,7 +380,7 @@ importers:
380
version: 7.5.1(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0)
381
'@react-navigation/native-stack':
382
specifier: 7.21.0
383
- version: 7.21.0(patch_hash=caae6552051bce91a85f567f3a08f9c8d25ce4c53f65a9391a67f016bb1d798e)(6f7595467acac269803072e24b2c2fee)
383
+ version: 7.21.0(patch_hash=caae6552051bce91a85f567f3a08f9c8d25ce4c53f65a9391a67f016bb1d798e)(16f893500fb9de13b2f16d636ddf6f9b)
384
'@shikijs/core':
385
specifier: 4.2.0
386
version: 4.2.0
@@ -592,8 +592,8 @@ importers:
592
specifier: ~5.10.1
593
version: 5.10.1(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0)
594
react-native-screens:
595
- specifier: file:deps/react-native-screens-5.0.0-t3.29.tgz
596
- version: file:apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0)
595
+ specifier: file:deps/react-native-screens-5.0.0-t3.30.tgz
596
+ version: file:apps/mobile/deps/react-native-screens-5.0.0-t3.30.tgz(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0)
597
react-native-shiki-engine:
598
specifier: ^0.3.12
599
version: 0.3.12(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0)
@@ -11271,9 +11271,9 @@ packages:
11271
react: '*'
11272
react-native: '*'
11273
11274
- react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz:
11275
- resolution: {integrity: sha512-Y5gaQmd/p1SOeCh7Esyaj1DEycDJ7XFNUdXS1ZDOsuwF5yK1h8yu4H4tCw6mKDrSVV8bNPBYhf4qs5/AaNe3zQ==, tarball: file:apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz}
11276
- version: 5.0.0-t3.29
11274
+ react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.30.tgz:
11275
+ resolution: {integrity: sha512-Szxvbp1mt4KwJ6cLoirkLQ2kz7Ebia3fTYPTjTifwqw3djskueHmML1np+wSZEs3Y0NtZf681SG/8xN5iW3T5Q==, tarball: file:apps/mobile/deps/react-native-screens-5.0.0-t3.30.tgz}
11276
+ version: 5.0.0-t3.30
11277
peerDependencies:
11278
react: '*'
11279
react-native: '*'
@@ -16475,7 +16475,7 @@ snapshots:
16475
optionalDependencies:
16476
'@react-native-masked-view/masked-view': 0.3.2(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0)
16477
16478
- '@react-navigation/native-stack@7.21.0(patch_hash=caae6552051bce91a85f567f3a08f9c8d25ce4c53f65a9391a67f016bb1d798e)(6f7595467acac269803072e24b2c2fee)':
16478
+ '@react-navigation/native-stack@7.21.0(patch_hash=caae6552051bce91a85f567f3a08f9c8d25ce4c53f65a9391a67f016bb1d798e)(16f893500fb9de13b2f16d636ddf6f9b)':
16479
dependencies:
16480
'@react-navigation/elements': 2.9.45(da16e244bd876bd7d4e1e8899c8eabfd)
16481
'@react-navigation/native': 7.5.1(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0)
@@ -16483,7 +16483,7 @@ snapshots:
16483
react: 19.3.0
16484
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6)
16485
react-native-safe-area-context: 5.10.1(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0)
16486
- react-native-screens: file:apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0)
16486
+ react-native-screens: file:apps/mobile/deps/react-native-screens-5.0.0-t3.30.tgz(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0)
16487
sf-symbols-typescript: 2.2.0
16488
warn-once: 0.1.1
16489
transitivePeerDependencies:
@@ -22649,7 +22649,7 @@ snapshots:
22649
react: 19.3.0
22650
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6)
22651
22652
- react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0):
22652
+ react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.30.tgz(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0):
22653
dependencies:
22654
react: 19.3.0
22655
react-freeze: 1.0.4(react@19.3.0)