The best way to control Claude Code, Codex and more from any computer or phone
fix(web): keep inward mini browser resizes from growing (#26027)
diddletime committed
Nov 1, 2026 at 15:59 UTC
b5d9f85b9adc08a45a77a715c2a7a9684ce4d15a
2 files changed
+56
-6
apps/web/src/components/chat/chatCanvasLayout.test.ts
+41
@@ -23,6 +23,47 @@ const expectClear = (result: ReturnType<typeof resolve>) => {
23
};
24
25
describe("chat canvas layout", () => {
26
+ it("does not enlarge the preview when its right edge is dragged inward", () => {
27
+ for (const height of [300, 400, 600, 900]) {
28
+ for (const x of [12, 200, 500, 700]) {
29
+ const start = resolve(1000, { ...preview, position: { x, y: 500 } }, height).frame!;
30
+ const resized = resizePreviewMiniPlayer({
31
+ start,
32
+ direction: "east",
33
+ delta: { x: -30, y: 0 },
34
+ source: preview.source,
35
+ container: { width: 1000, height },
36
+ });
37
+ expect(resized.width, JSON.stringify({ height, x, start, resized })).toBeLessThanOrEqual(
38
+ start.width,
39
+ );
40
+ const rendered = resolve(
41
+ 1000,
42
+ {
43
+ ...preview,
44
+ width: resized.width,
45
+ position: resized,
46
+ lastInteraction: "resize",
47
+ },
48
+ height,
49
+ ).frame!;
50
+ expect(
51
+ rendered.width,
52
+ JSON.stringify({ height, x, start, resized, rendered }),
53
+ ).toBeLessThanOrEqual(start.width);
54
+ expect(rendered.x).toBe(start.x);
55
+ expect(rendered.y, JSON.stringify({ height, x, start, resized, rendered })).toBe(start.y);
56
+ expect(
57
+ resolve(1000, {
58
+ ...preview,
59
+ width: resized.width,
60
+ position: resized,
61
+ lastInteraction: "resize",
62
+ }).frame!.width,
63
+ ).toBe(resized.width);
64
+ }
65
+ }
66
+ });
67
it("lifts a growing preview above the composer without snapping at the chat boundary", () => {
68
let previous: ReturnType<typeof resolve> | undefined;
69
for (let width = 480; width <= 1100; width++) {
apps/web/src/components/preview/previewMiniPlayerLayout.ts
+15
-6
@@ -107,18 +107,21 @@ const availableArea = (
107
PREVIEW_MINI_PLAYER_EDGE_GAP * 2,
108
});
109
110
+const minimumPreviewMiniPlayerWidth = (source: PreviewMiniPlayerSize) =>
111
+ Math.max(
112
+ PREVIEW_MINI_PLAYER_MIN_SIZE.width,
113
+ (PREVIEW_MINI_PLAYER_MIN_SIZE.height * source.width) / source.height,
114
+ );
115
+
116
function fitPreviewMiniPlayerWidth(
117
desiredWidth: number,
118
source: PreviewMiniPlayerSize,
119
max: PreviewMiniPlayerSize,
120
+ minimumWidth = minimumPreviewMiniPlayerWidth(source),
121
): PreviewMiniPlayerSize {
122
const aspectRatio = source.width / source.height;
123
const width = Math.min(
117
- Math.max(
118
- desiredWidth,
119
- PREVIEW_MINI_PLAYER_MIN_SIZE.width,
120
- PREVIEW_MINI_PLAYER_MIN_SIZE.height * aspectRatio,
121
- ),
124
+ Math.max(desiredWidth, minimumWidth),
125
Math.max(1, max.width),
126
Math.max(1, max.height * aspectRatio),
127
);
@@ -244,6 +247,7 @@ export function resolvePreviewMiniPlayerFrame(input: {
247
position && width ? { composer: obstacles.composer, detailsCard: null } : obstacles,
248
position && width ? spanOf(position.x, width) : null,
249
),
250
+ width ?? undefined,
251
);
252
const { detailsCard } = obstacles;
253
const anchored =
@@ -307,7 +311,12 @@ export function resizePreviewMiniPlayer(input: {
311
: horizontal
312
? desiredWidth
313
: desiredHeight * aspectRatio;
310
- const size = fitPreviewMiniPlayerWidth(desired, source, max);
314
+ const size = fitPreviewMiniPlayerWidth(
315
+ desired,
316
+ source,
317
+ max,
318
+ Math.min(start.width, minimumPreviewMiniPlayerWidth(source)),
319
+ );
320
const position = clampPreviewMiniPlayerPosition(
321
{ x: west ? right - size.width : start.x, y: north ? bottom - size.height : start.y },
322
container,