Skip to content

Commit 4268800

Browse files
fix(web): restore composer controls as space becomes available
Restore each control that clears the one-pixel slack margin instead of retaining the entire previous overflow layout. Implemented with Codex through T3 Code.
1 parent 0ba06a1 commit 4268800

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

‎apps/web/src/components/composerFooterLayout.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,33 @@ describe("resolveRestingComposerControlsLayout hysteresis", () => {
333333
).toEqual({ hiddenCount: 0, visible: true });
334334
});
335335

336+
it("restores the blocks that fit when the full cluster has no slack", () => {
337+
const partlyRestored = resolveRestingComposerControlsLayout({
338+
...base,
339+
hostWidth: 357,
340+
previous: { hiddenCount: 2, visible: true },
341+
});
342+
expect(partlyRestored).toEqual({ hiddenCount: 1, visible: true });
343+
expect(
344+
resolveRestingComposerControlsLayout({ ...base, hostWidth: 357, previous: partlyRestored }),
345+
).toEqual(partlyRestored);
346+
expect(
347+
resolveRestingComposerControlsLayout({ ...base, hostWidth: 358, previous: partlyRestored }),
348+
).toEqual({ hiddenCount: 0, visible: true });
349+
});
350+
351+
it("requires slack before partially restoring a cluster", () => {
352+
// One inline block, the picker, and overflow need 149 + 60 + 24 + 8 = 241px.
353+
const previous = { hiddenCount: 2, visible: true };
354+
expect(resolveRestingComposerControlsLayout({ ...base, hostWidth: 241, previous })).toEqual(
355+
previous,
356+
);
357+
expect(resolveRestingComposerControlsLayout({ ...base, hostWidth: 242, previous })).toEqual({
358+
hiddenCount: 1,
359+
visible: true,
360+
});
361+
});
362+
336363
it("still resolves from scratch when there is no previous layout", () => {
337364
expect(resolveRestingComposerControlsLayout({ ...base, hostWidth: 357 })).toEqual({
338365
hiddenCount: 0,

‎apps/web/src/components/composerFooterLayout.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,13 @@ export function resolveRestingComposerControlsLayout(
134134
// composer re-measures on every render, so without that margin a host
135135
// sitting exactly on a threshold flips a block in and out until React
136136
// gives up with "Maximum update depth exceeded".
137-
if (previous && hiddenCount < previous.hiddenCount) {
138-
if (restingComposerControlsWidth(input, hiddenCount) > hostWidth - RESTING_CONTROLS_SLACK_PX) {
139-
hiddenCount = Math.min(previous.hiddenCount, blockWidths.length);
137+
if (previous) {
138+
const previousHiddenCount = Math.min(previous.hiddenCount, blockWidths.length);
139+
while (
140+
hiddenCount < previousHiddenCount &&
141+
restingComposerControlsWidth(input, hiddenCount) > hostWidth - RESTING_CONTROLS_SLACK_PX
142+
) {
143+
hiddenCount += 1;
140144
}
141145
}
142146
const minimumWidth = restingComposerControlsWidth(input, hiddenCount, input.minimumFixedWidth);

0 commit comments

Comments
 (0)