Skip to content

Commit 92b74e5

Browse files
committed
fix(mobile): the status pill label no longer flickers when it is truncated
The label width subtracts the measured agents, queue and preview segment widths, and the label width in turn moves those segments. Pixel rounding flips a segment's width by one physical pixel per layout, so a truncated label re-ellipsized on every frame. Ignore sub-point changes in the measured segment widths.
1 parent 0912b24 commit 92b74e5

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎apps/mobile/src/features/threads/floating-working-control.tsx‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ const UniwindGlassContainer = withUniwind(GlassContainer, {
5858
});
5959
const AnimatedGlassView = Animated.createAnimatedComponent(UniwindGlassView);
6060

61+
// The segment widths feed labelWidth, and labelWidth moves the segments. Pixel
62+
// rounding then flips a segment's width by one physical pixel per layout, which
63+
// re-ellipsizes a truncated label every frame. Sub-point changes are ignored.
64+
function settleWidth(next: number) {
65+
return (current: number) => (Math.abs(current - next) < 1 ? current : next);
66+
}
67+
6168
const CONTROL_OVERLAY_OFFSET = CONTROL_HEIGHT + CONTROL_GAP - COMPOSER_CAPSULE_INSET;
6269
export const FLOATING_WORKING_CONTROL_COVERAGE = CONTROL_OVERLAY_OFFSET + CONTROL_GAP;
6370

@@ -182,7 +189,7 @@ export function FloatingWorkingControl(props: {
182189
{hasPreview ? (
183190
<View
184191
className="h-11 flex-row items-center"
185-
onLayout={(event) => setPreviewWidth(event.nativeEvent.layout.width)}
192+
onLayout={(event) => setPreviewWidth(settleWidth(event.nativeEvent.layout.width))}
186193
>
187194
{hasStatus ? <View className="h-4 w-px bg-border" /> : null}
188195
{props.devicePreview !== null ? (
@@ -199,7 +206,7 @@ export function FloatingWorkingControl(props: {
199206
accessibilityLabel={`Open agents, ${agents.accessibilityLabel}`}
200207
accessibilityHint="Opens this turn's subagents"
201208
onPress={props.onOpenAgents}
202-
onLayout={(event) => setAgentsWidth(event.nativeEvent.layout.width)}
209+
onLayout={(event) => setAgentsWidth(settleWidth(event.nativeEvent.layout.width))}
203210
className="h-11 flex-row items-center gap-1.5 px-3 active:opacity-70"
204211
>
205212
{hasStatus || hasPreview ? <View className="mr-1 h-4 w-px bg-border" /> : null}
@@ -215,7 +222,7 @@ export function FloatingWorkingControl(props: {
215222
accessibilityLabel={`Open queue, ${props.queuedCount} messages`}
216223
accessibilityHint="Opens queued messages for reordering, steering, or removal"
217224
onPress={props.onOpenQueue}
218-
onLayout={(event) => setQueueWidth(event.nativeEvent.layout.width)}
225+
onLayout={(event) => setQueueWidth(settleWidth(event.nativeEvent.layout.width))}
219226
style={{ maxWidth: Math.min(overlayWidth, windowWidth) * 0.45 }}
220227
className="h-11 flex-row items-center gap-2 px-3 active:opacity-70"
221228
>

0 commit comments

Comments
 (0)