@devries-cameron20 / t3code Mirror · read-only / commits / b248f5ad56
Fork 0

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 24, 07:45 UTC

fix(mobile): smooth composer status pill resizing (#10484)

Julius Marminge committed Sep 7, 2026 at 02:14 UTC b248f5ad566a8cd3ea2d7d678c1e8aa49c748879
1 file changed +35 -21
apps/mobile/src/features/threads/floating-working-control.tsx
+35 -21
@@ -6,6 +6,7 @@ import {
6 type LayoutChangeEvent,
7 Pressable,
8 Text as SystemText,
9 + useWindowDimensions,
10 View,
11 } from "react-native";
12 import Animated, {
@@ -65,6 +66,9 @@ export function FloatingWorkingControl(props: {
66 readonly showScrollToEnd: boolean;
67 readonly onScrollToEnd: () => void;
68 }) {
69 + const { width: windowWidth } = useWindowDimensions();
70 + const [overlayWidth, setOverlayWidth] = useState(windowWidth);
71 + const labelWidth = Math.max(0, Math.min(overlayWidth, windowWidth) - CONTROL_HEIGHT - 16);
72 const separationProgress = useSharedValue(props.showScrollToEnd ? 1 : 0);
73
74 useEffect(() => {
@@ -78,17 +82,10 @@ export function FloatingWorkingControl(props: {
82 opacity: separationProgress.value,
83 }));
84
81 - // The label swaps between connection, syncing, compacting, and working while
82 - // the capsule stays mounted. A layout transition on the capsule would move
83 - // its left edge, and labels laid out from that edge slide with it, so the pill
84 - // reads as shifting sideways. Instead an in-flow sizer animates to the
85 - // measured label width and the capsule takes its size from that, while the
86 - // labels sit centered on top. The row re-centers as the capsule grows, so its
87 - // midpoint never moves and the text underneath stays put.
88 - //
89 - // The sizer has to carry the width rather than the capsule itself: the native
90 - // glass view only picks up a size from a real layout pass, so an animated
91 - // width set straight on it leaves the glass stuck at its mounted size.
85 + // Animate an in-flow sizer so native glass receives real layout updates.
86 + // Measure labels in a separate, fixed-width host: measuring against the
87 + // animated capsule constrains the incoming text to each intermediate width
88 + // and repeatedly retargets the animation as it grows.
89 const capsuleWidth = useSharedValue<number | null>(null);
90 const measuredWidthRef = useRef<number | null>(null);
91 const handleLabelLayout = (event: LayoutChangeEvent) => {
@@ -123,15 +120,27 @@ export function FloatingWorkingControl(props: {
120 // Only the connection label is a button (tap to reconnect); the others
121 // pass touches through to the feed like before.
122 const statusInteractive = props.status?.kind === "connection";
126 - // Yoga centers an absolute child that has no insets on its parent's align and
127 - // justify, so each label row lands centered on the capsule without measuring
128 - // itself, and the capsule clips whatever a wider label overhangs while it
129 - // catches up.
123 + // The host stays centered on the capsule, but its measurement constraint
124 + // comes from the overlay, independent of the capsule's current width.
125 const statusContent =
126 props.status !== null ? (
127 <>
128 <Animated.View className="h-11" style={capsuleSizerStyle} />
134 - <FloatingStatusLabel status={props.status} onLayout={handleLabelLayout} />
129 + <View
130 + pointerEvents="box-none"
131 + className="absolute h-11 items-center justify-center"
132 + style={{ width: labelWidth }}
133 + >
134 + <FloatingStatusLabel
135 + key={
136 + props.status.kind === "working" || props.status.kind === "compacting"
137 + ? props.status.kind
138 + : `${props.status.kind}:${props.status.label}`
139 + }
140 + status={props.status}
141 + onLayout={handleLabelLayout}
142 + />
143 + </View>
144 </>
145 ) : null;
146
@@ -140,6 +149,7 @@ export function FloatingWorkingControl(props: {
149 pointerEvents="box-none"
150 className="absolute left-0 right-0 z-20 items-center"
151 style={{ top: -CONTROL_OVERLAY_OFFSET }}
152 + onLayout={(event) => setOverlayWidth(event.nativeEvent.layout.width)}
153 entering={NATIVE_LIQUID_GLASS_SUPPORTED ? undefined : CONTROL_ENTERING}
154 exiting={NATIVE_LIQUID_GLASS_SUPPORTED ? undefined : CONTROL_EXITING}
155 >
@@ -252,7 +262,9 @@ function FloatingStatusLabel(props: {
262 onLayout={props.onLayout}
263 >
264 <ActivityIndicator size="small" colorClassName="accent-icon-muted" />
255 - <Text className="font-t3-medium text-xs text-foreground">{props.status.label}</Text>
265 + <Text className="shrink font-t3-medium text-xs text-foreground" numberOfLines={1}>
266 + {props.status.label}
267 + </Text>
268 </StatusLabelRow>
269 );
270 }
@@ -274,7 +286,10 @@ function FloatingStatusLabel(props: {
286 ) : (
287 <View className="h-2 w-2 rounded-full bg-red-500" />
288 )}
277 - <Text className="max-w-[260px] font-t3-medium text-xs text-foreground" numberOfLines={1}>
289 + <Text
290 + className="max-w-[260px] shrink font-t3-medium text-xs text-foreground"
291 + numberOfLines={1}
292 + >
293 {props.status.label}
294 </Text>
295 </StatusLabelRow>
@@ -311,8 +326,7 @@ function FloatingStatusLabel(props: {
326 );
327 }
328
314 -// Rows are absolute with no insets, so the capsule centers them on itself and an
315 -// exiting row fading out never shifts the incoming one.
329 +// Absolute rows cross-fade around the same center without affecting each other.
330 function StatusLabelRow(props: {
331 readonly accessibilityLabel: string;
332 readonly accessibilityRole?: "button";
@@ -324,7 +338,7 @@ function StatusLabelRow(props: {
338 const rowClassName = `h-11 flex-row items-center px-4 ${props.className ?? ""}`;
339 return (
340 <Animated.View
327 - className="absolute"
341 + className="absolute max-w-full"
342 entering={LABEL_ENTERING}
343 exiting={LABEL_EXITING}
344 onLayout={props.onLayout}