Skip to content

Commit 52ad83f

Browse files
fix(mobile): a wider model label no longer bounces an open wide-row card
A label that grows while the card is open, such as the summary switching to Ultrathink as the prompt mentions it, only narrows the compact slot, so the card stays correct. Forget the slot only when the label shrinks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 267b0dd commit 52ad83f

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎apps/mobile/src/features/threads/compactComposerLayout.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ describe("compact composer layout", () => {
108108
slot = compactSlotAfterLabelLayout(slot, { ...label, width: 200 });
109109
expect(composer({ ...line, compactWidth: slot.compactWidth }).isExpanded).toBe(true);
110110

111-
// Opening and closing the card resizes a truncated label without resetting the slot.
111+
// Opening and closing the card resizes a truncated label without resetting the slot,
112+
// and a label that grows with the card open only narrows a slot the draft already fills.
112113
slot = compactSlotAfterLabelLayout(slot, { ...label, width: 240, isExpanded: false });
113114
slot = compactSlotAfterLabelLayout(slot, { ...label, width: 200 });
115+
slot = compactSlotAfterLabelLayout(slot, { ...label, width: 220 });
114116
expect(slot.compactWidth).toBe(320);
115117

116118
slot = compactSlotAfterLabelLayout(slot, { ...label, width: 160 });

‎apps/mobile/src/features/threads/compactComposerLayout.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,22 @@ export function compactSlotAfterRowLayout(
2727

2828
/**
2929
* A label shown at rest shares the row with the compact slot, which is only measured while
30-
* collapsed, so a label that resizes while the card stays open forgets it. Layouts that
31-
* open or close the card only record the width: resetting on them would loop.
30+
* collapsed, so a label that shrinks while the card stays open forgets it; a wider label only
31+
* narrows the slot, which keeps an open card correct. Layouts that open or close the card
32+
* only record the width: resetting on them would loop.
3233
*/
3334
export function compactSlotAfterLabelLayout(
3435
slot: CompactComposerSlot,
3536
label: { readonly width: number; readonly isExpanded: boolean; readonly shownAtRest: boolean },
3637
): CompactComposerSlot {
3738
const previous = slot.label;
3839
if (previous.width === label.width && previous.isExpanded === label.isExpanded) return slot;
39-
const resizedWhileOpen = label.shownAtRest && label.isExpanded && previous.isExpanded;
40+
const shrankWhileOpen =
41+
label.shownAtRest && label.isExpanded && previous.isExpanded && label.width < previous.width;
4042
return {
4143
...slot,
4244
label: { width: label.width, isExpanded: label.isExpanded },
43-
compactWidth: resizedWhileOpen ? 0 : slot.compactWidth,
45+
compactWidth: shrankWhileOpen ? 0 : slot.compactWidth,
4446
};
4547
}
4648

0 commit comments

Comments
 (0)