From 3bca0a35c0126876a3cf9a009b52f2d55c939d3f Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 4 Oct 2026 16:02:58 -0700 Subject: [PATCH 01/11] test(load3d): pin the viewer's docked-panel geometry above the sm breakpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Load3D/HDR viewer is the one dialog that stays inset-aware after #20002: its own `max-w-[min(80vw,calc(100vw-var(--workspace-inset-right,0px)-1rem))]` is what holds it on the centring branch of the new translate-x clamp instead of the viewport gutter floor, so it still clears the docked Agent panel while every other dialog keeps its size and covers the panel. That cap is declared twice — unprefixed and `sm:`-prefixed — because tailwind-merge treats prefixed and unprefixed `max-w-*` as separate groups, and above `sm:` only the prefixed one is live. The existing guard in this test runs at 500px and 400px, both under `sm:`, so it cannot see the prefixed cap at all: dropping it leaves this spec green while the viewer covers the panel by 180px at 1280px. Add a step at 1280px and 1920px asserting the real docked panel is flush with the right edge, the viewer sits at the 8px gutter, and its right edge stops 8px short of the panel. Measured against the real 420px docked panel at main 94ddfcc78d: | viewport | viewer x | viewer right | panel left | | --- | --- | --- | --- | | 1280 | 8 | 852 | 860 | | 1440 | 8 | 1012 | 1020 | | 1920 | 8 | 1492 | 1500 | Co-Authored-By: Claude Opus 5 (1M context) --- .../tests/load3d/load3dAgentUpdate.spec.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts index 1e116466039..ffcb43523c7 100644 --- a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts +++ b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts @@ -4,6 +4,10 @@ import { AgentPanel } from '@e2e/fixtures/components/AgentPanel' import { load3dAgentTest as test } from '@e2e/fixtures/load3dAgentFixture' import { Load3DViewerHelper } from '@e2e/tests/load3d/Load3DViewerHelper' +// The 0.5rem gutter the dialog clamp leaves at the viewport edge, and half of +// the 1rem the viewer's own width cap reserves inside the visible workspace. +const VIEWPORT_GUTTER = 8 + test.describe('Load3D agent updates', { tag: '@cloud' }, () => { test.describe.configure({ timeout: 60_000 }) @@ -69,6 +73,36 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { await viewer.waitForOpen() }) + await test.step('centre the viewer beside the panel above the sm breakpoint', async () => { + // The viewer keeps its own inset-aware width cap while every other dialog + // now resolves against the raw viewport, and that cap is what holds it on + // the centring branch of the dialog clamp instead of the gutter floor. + // The cap is declared twice — unprefixed and `sm:`-prefixed — because + // tailwind-merge treats those as separate groups, so only the prefixed one + // is live here. The narrow-viewport steps below run under `sm:` and cannot + // see it: drop it and they still pass while the viewer covers the panel. + for (const width of [1280, 1920]) { + await page.setViewportSize({ width, height: 800 }) + + await expect(async () => { + const dialogBox = await viewer.dialog.boundingBox() + const panelBox = await panel.boundingBox() + expect(dialogBox).not.toBeNull() + expect(panelBox).not.toBeNull() + if (!dialogBox || !panelBox) return + + // The panel is docked against the right edge, so its left edge is the + // boundary of the visible workspace. + expect(panelBox.x + panelBox.width).toBeCloseTo(width, 1) + expect(dialogBox.x).toBeCloseTo(VIEWPORT_GUTTER, 1) + expect(dialogBox.x + dialogBox.width).toBeCloseTo( + panelBox.x - VIEWPORT_GUTTER, + 1 + ) + }).toPass({ timeout: 5000 }) + } + }) + await test.step('keep the viewer outside the docked Agent panel', async () => { await page.setViewportSize({ width: 500, height: 800 }) From 63fd8bd4c6c05216012706c4ae24b3fc72c5ec10 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 4 Oct 2026 17:12:47 -0700 Subject: [PATCH 02/11] test(load3d): assert the viewer geometry both clamp branches share MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses the three findings on #20136, all three reproduced locally first against the real 420px docked panel. `toBeCloseTo`'s second argument is a digit count, not pixels, so the `1` these assertions passed demanded a delta under 0.05px — effectively exact equality, where every other geometry check in this file deliberately allows a full pixel. Replace it with explicit ±1px bounds carrying a label, so a fractional panel width or transform rounding cannot fail a correct layout and a real failure names which edge moved. The pinned coordinates also hid a premise. The viewer's width is `min(80vw, 100vw - inset - 1rem)`, so the inset-aware term only binds while the panel is wider than `20vw - 1rem` — above roughly 2180px at the default 420px panel the 80vw term is smaller and the viewer centres in the workspace instead of sitting at the gutter. Measured: adding 2560px to the loop failed the old step at `expected 8, received 46` on unmodified production code. Derive the expectation from the measured panel box instead and assert the geometry both clamp branches share — equal gutters either side of the viewer, never tighter than the floor, and the width the live cap produces — then add 2560px as coverage of the branch the previous step could not express. Drop the bare `x === 8` assertion, which could not distinguish the branches the comment named: wherever the cap binds the width is exactly `100vw - inset - 1rem`, so centring resolves to the same 8px the gutter floor gives. It passed under both mutations below. The comment is corrected to say so, and to name why only the `sm:`-prefixed declaration is live — the `full` dialog size ships `sm:max-w-[calc(100vw-1rem)]`, which outranks an unprefixed cap above the breakpoint. The mutation proof is unchanged and re-measured on this commit: - delete only the `sm:`-prefixed inset-aware cap: fails here on `the viewer fills the workspace up to its own 80vw width`, expected <= 845, received 1024 — and still passes 3/3 on the parent spec, which is the gap this test closes. - restore the pre-#19729 `left-1/2 w-[80vw] sm:max-w-[80vw]` contentClass: fails identically. Measured geometry, `--project=cloud` against the real docked panel: | viewport | viewer x | viewer width | viewer right | panel left | | --- | --- | --- | --- | --- | | 1280 | 8 | 844 | 852 | 860 | | 1440 | 8 | 1004 | 1012 | 1020 | | 1920 | 8 | 1484 | 1492 | 1500 | | 2560 | 46 | 2048 | 2094 | 2140 | `load3dAgentUpdate.spec.ts` 3 passed; `dialogAgentPanelInset.spec.ts` 3 passed, unaffected; `oxfmt --check`, `oxlint --type-aware` and `pnpm typecheck:browser` clean. Still no production code changes. Co-Authored-By: Claude Opus 5 (1M context) --- .../tests/load3d/load3dAgentUpdate.spec.ts | 70 +++++++++++++++---- 1 file changed, 57 insertions(+), 13 deletions(-) diff --git a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts index ffcb43523c7..af922e39f8c 100644 --- a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts +++ b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts @@ -8,6 +8,17 @@ import { Load3DViewerHelper } from '@e2e/tests/load3d/Load3DViewerHelper' // the 1rem the viewer's own width cap reserves inside the visible workspace. const VIEWPORT_GUTTER = 8 +// The slack the rest of this file already allows on bounding boxes, so a +// fractional panel width or transform rounding cannot turn a correct layout +// into a failure. Note `toBeCloseTo`'s second argument is a digit count, not +// pixels, so it cannot express this. +const PIXEL_SLACK = 1 + +function expectPixels(actual: number, expected: number, label: string): void { + expect(actual, label).toBeGreaterThanOrEqual(expected - PIXEL_SLACK) + expect(actual, label).toBeLessThanOrEqual(expected + PIXEL_SLACK) +} + test.describe('Load3D agent updates', { tag: '@cloud' }, () => { test.describe.configure({ timeout: 60_000 }) @@ -75,13 +86,23 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { await test.step('centre the viewer beside the panel above the sm breakpoint', async () => { // The viewer keeps its own inset-aware width cap while every other dialog - // now resolves against the raw viewport, and that cap is what holds it on - // the centring branch of the dialog clamp instead of the gutter floor. - // The cap is declared twice — unprefixed and `sm:`-prefixed — because - // tailwind-merge treats those as separate groups, so only the prefixed one - // is live here. The narrow-viewport steps below run under `sm:` and cannot - // see it: drop it and they still pass while the viewer covers the panel. - for (const width of [1280, 1920]) { + // now resolves against the raw viewport. The cap is declared twice — + // unprefixed and `sm:`-prefixed — because the `full` dialog size already + // ships `sm:max-w-[calc(100vw-1rem)]`, which outranks an unprefixed cap + // above the breakpoint, so only the prefixed declaration is live here. + // The narrow-viewport steps below run under `sm:` and cannot see it: drop + // it and they still pass while the viewer covers the panel. + // + // Both branches of the dialog's `translate-x` clamp — the 0.5rem gutter + // floor and centring inside the visible workspace — are exercised, and + // they are not distinguishable from the viewer's x alone: wherever the + // inset-aware cap binds, the width is exactly `100vw - inset - 1rem`, so + // centring resolves to the same 8px the gutter floor gives. What is + // asserted instead is the geometry both branches share — equal gutters + // either side of the viewer, never tighter than the floor — plus the + // width the live cap produces, which is what the dropped declaration + // changes. + for (const width of [1280, 1920, 2560]) { await page.setViewportSize({ width, height: 800 }) await expect(async () => { @@ -92,13 +113,36 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { if (!dialogBox || !panelBox) return // The panel is docked against the right edge, so its left edge is the - // boundary of the visible workspace. - expect(panelBox.x + panelBox.width).toBeCloseTo(width, 1) - expect(dialogBox.x).toBeCloseTo(VIEWPORT_GUTTER, 1) - expect(dialogBox.x + dialogBox.width).toBeCloseTo( - panelBox.x - VIEWPORT_GUTTER, - 1 + // boundary of the visible workspace. Its width is the resizable + // `draggedWidth`, so derive everything from the measured box rather + // than pinning coordinates that only hold at its default width. + expectPixels( + panelBox.x + panelBox.width, + width, + 'the panel is flush with the right edge' + ) + + // `min(80vw, 100vw - inset - 1rem)`: the viewer's own width against + // its inset-aware cap. Above ~2180px at the default panel width the + // 80vw term is the smaller one and the cap stops binding, which is + // correct and must not fail the step. + expectPixels( + dialogBox.width, + Math.min(width * 0.8, panelBox.x - 2 * VIEWPORT_GUTTER), + 'the viewer fills the workspace up to its own 80vw width' + ) + + const leftGutter = dialogBox.x + const rightGutter = panelBox.x - (dialogBox.x + dialogBox.width) + expectPixels( + rightGutter, + leftGutter, + 'the viewer sits centred between the viewport and panel edges' ) + expect( + leftGutter, + 'the viewer keeps at least the clamp gutter at the viewport edge' + ).toBeGreaterThanOrEqual(VIEWPORT_GUTTER - PIXEL_SLACK) }).toPass({ timeout: 5000 }) } }) From b9bcf4e197a07376d09f97db38c38cb3533d5aa0 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 4 Oct 2026 17:53:56 -0700 Subject: [PATCH 03/11] test(load3d): pin the inset mode and drop the vacuous clamp-floor check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Round 2 of the Cursor panel. All three findings reproduced before repair. The step substituted `panelBox.x` for `100vw - inset`, which only holds while the panel is docked and not overlaying: `DockedAgentPanel` publishes the inset as `docked && !isOverlay ? width : 0`, so in overlay mode the inset is 0 while the panel still covers the right edge, and the viewer is then correctly wider than the workspace. Read `--workspace-inset-right` and assert it equals the measured panel width, then express the cap as `100vw - inset - 1rem` the way production does. A panel that drops into overlay now fails on its own assertion instead of looking like a viewer regression. Dropped the `leftGutter >= 8` check. The clamp is `max(gutter floor, centre in the visible workspace)`, and the viewer's cap holds its width at or under `100vw - inset - 1rem`, which leaves the centring term at least 8px — so the floor can at best tie and never binds for this dialog. Measured: delete the `max(...)` floor from `dialog.variants.ts` entirely and the previous commit's step still passes 3/3. The same mutation does fail `dialogAgentPanelInset.spec.ts` at 1440px (`expected 8, received -138`) and at the sm breakpoint, which is where that floor is actually covered. The comment is corrected: it had claimed both clamp branches were exercised here. Renamed the shared `VIEWPORT_GUTTER = 8`. It stood in for two independent production values at once — the clamp's `0.5rem` floor and the `1rem` the viewer's cap reserves — which are only coincidentally in a 1:2 ratio, so updating it to track one would have silently corrupted the other. With the floor check gone there is one value left, named for what it is. Re-measured on this commit, `--project=cloud` against the real docked panel: - `load3dAgentUpdate.spec.ts` 3 passed, including the 2560px case. - deleting only the `sm:`-prefixed inset-aware cap: fails, `the viewer fills the workspace up to its own 80vw width`, expected <= 845, received 1024. - restoring the pre-#19729 `left-1/2 w-[80vw] sm:max-w-[80vw]` contentClass: fails identically. - `dialogAgentPanelInset.spec.ts` 3 passed, unaffected. Still test-only. Co-Authored-By: Claude Opus 5 (1M context) --- .../tests/load3d/load3dAgentUpdate.spec.ts | 63 +++++++++++-------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts index af922e39f8c..018973e067f 100644 --- a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts +++ b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts @@ -4,9 +4,11 @@ import { AgentPanel } from '@e2e/fixtures/components/AgentPanel' import { load3dAgentTest as test } from '@e2e/fixtures/load3dAgentFixture' import { Load3DViewerHelper } from '@e2e/tests/load3d/Load3DViewerHelper' -// The 0.5rem gutter the dialog clamp leaves at the viewport edge, and half of -// the 1rem the viewer's own width cap reserves inside the visible workspace. -const VIEWPORT_GUTTER = 8 +// The `1rem` the viewer's own width cap reserves inside the visible workspace: +// `max-w-[min(80vw,calc(100vw-var(--workspace-inset-right,0px)-1rem))]`. Not +// shared with the dialog clamp's own `0.5rem` gutter floor, which is a separate +// production value that only happens to be half of this one. +const VIEWER_CAP_RESERVE = 16 // The slack the rest of this file already allows on bounding boxes, so a // fractional panel width or transform rounding cannot turn a correct layout @@ -93,21 +95,28 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { // The narrow-viewport steps below run under `sm:` and cannot see it: drop // it and they still pass while the viewer covers the panel. // - // Both branches of the dialog's `translate-x` clamp — the 0.5rem gutter - // floor and centring inside the visible workspace — are exercised, and - // they are not distinguishable from the viewer's x alone: wherever the - // inset-aware cap binds, the width is exactly `100vw - inset - 1rem`, so - // centring resolves to the same 8px the gutter floor gives. What is - // asserted instead is the geometry both branches share — equal gutters - // either side of the viewer, never tighter than the floor — plus the - // width the live cap produces, which is what the dropped declaration - // changes. + // This dialog is always on the centring term of the clamp's `max()`, + // never its 0.5rem gutter floor: the cap holds the width at or under + // `100vw - inset - 1rem`, which leaves centring at least 8px, so the + // floor can at best tie. That makes the viewer's x unusable as evidence + // on its own, and a floor assertion here vacuous. What is asserted is + // the width the live cap produces, which is what dropping the prefixed + // declaration changes, and equal gutters either side of the viewer. The + // floor itself is covered by `dialogAgentPanelInset.spec.ts`, where a + // dialog without an inset-aware cap does sit on it. for (const width of [1280, 1920, 2560]) { await page.setViewportSize({ width, height: 800 }) await expect(async () => { const dialogBox = await viewer.dialog.boundingBox() const panelBox = await panel.boundingBox() + const inset = await page.evaluate( + (property) => + parseFloat( + document.documentElement.style.getPropertyValue(property) + ) || 0, + '--workspace-inset-right' + ) expect(dialogBox).not.toBeNull() expect(panelBox).not.toBeNull() if (!dialogBox || !panelBox) return @@ -122,27 +131,31 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { 'the panel is flush with the right edge' ) - // `min(80vw, 100vw - inset - 1rem)`: the viewer's own width against - // its inset-aware cap. Above ~2180px at the default panel width the - // 80vw term is the smaller one and the cap stops binding, which is - // correct and must not fail the step. + // The panel publishes its width as the inset only while it is docked + // and not overlaying; in overlay mode it covers the right edge with + // an inset of 0, and the viewer is then correctly wider than the + // workspace. Pin the mode so a failure below is attributable to the + // viewer rather than to the panel having gone into overlay. + expectPixels( + inset, + panelBox.width, + 'the docked panel publishes its width as the workspace inset' + ) + + // `min(80vw, 100vw - inset - 1rem)`. Above ~2180px at the default + // panel width the 80vw term is the smaller one and the cap stops + // binding, which is correct and must not fail the step. expectPixels( dialogBox.width, - Math.min(width * 0.8, panelBox.x - 2 * VIEWPORT_GUTTER), + Math.min(width * 0.8, width - inset - VIEWER_CAP_RESERVE), 'the viewer fills the workspace up to its own 80vw width' ) - const leftGutter = dialogBox.x - const rightGutter = panelBox.x - (dialogBox.x + dialogBox.width) expectPixels( - rightGutter, - leftGutter, + panelBox.x - (dialogBox.x + dialogBox.width), + dialogBox.x, 'the viewer sits centred between the viewport and panel edges' ) - expect( - leftGutter, - 'the viewer keeps at least the clamp gutter at the viewport edge' - ).toBeGreaterThanOrEqual(VIEWPORT_GUTTER - PIXEL_SLACK) }).toPass({ timeout: 5000 }) } }) From 0e9fa11271e1f41009bae031b409bea80aa8b656 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 4 Oct 2026 18:18:28 -0700 Subject: [PATCH 04/11] test(load3d): size the viewer either side of the sm breakpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Round 3 of the Cursor panel. Four findings, all reproduced before repair. Read the inset through `getComputedStyle` and require a px length before parsing. `parseFloat(element.style.getPropertyValue(...)) || 0` collapsed "absent", "renamed" and "not a px length" into the same 0 that overlay mode legitimately publishes, which is the one distinction the inset assertion exists to draw. Measured: with no publishers mounted the property is removed outright, so `getPropertyValue` returns `''`, while overlay mode returns `'0px'` — the old read could not tell those apart, and the width expectation would quietly become `min(80vw, 100vw - 16)`. Express the right gutter as `100vw - inset - (x + width)` rather than `panelBox.x - (x + width)`. Production centres on `100vw - inset`, so the old form silently asserted that `panelBox.x` and `100vw - inset` agree to within 1px, while the two assertions above each allow a pixel of their own. All three now resolve against the same boundary. Add a 500px viewport, which ties the unprefixed cap to a check. Only the `sm:`-prefixed twin was width-checked, so deleting the unprefixed one was caught but drifting its value was invisible everywhere. Measured: change the unprefixed `1rem` to `3rem` and the previous commit passes 3/3, while this one fails at 500px with `expected >= 63, received 32`. Below `sm` the unprefixed declaration is the live one and the viewer is 64px wide against a 420px panel, so one extra iteration covers it. The step is renamed, since it no longer runs only above the breakpoint. Wait for the open transition before the first measurement. `waitForOpen` asserts visibility only, so the first iteration could sample the dialog mid `data-[state=open]:zoom-in-95` and put a scaled box in the trace as the apparent failure. `toPass` retried that away, so this buys a readable trace rather than stability. `expectDialogBoundsWithDockedPanel` already polls `getAnimations().length` for the same reason. Re-measured on this commit, `--project=cloud` against the real docked panel: - `load3dAgentUpdate.spec.ts` 3 passed, now covering 1280, 1920, 2560 and 500. - deleting only the `sm:`-prefixed cap: fails, expected <= 845, received 1024. - restoring the pre-#19729 `left-1/2 w-[80vw] sm:max-w-[80vw]` contentClass: fails identically. - drifting the unprefixed cap to `3rem`: fails at 500px, expected >= 63, received 32. Still test-only. Co-Authored-By: Claude Opus 5 (1M context) --- .../tests/load3d/load3dAgentUpdate.spec.ts | 51 ++++++++++++++----- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts index 018973e067f..6491f777cb9 100644 --- a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts +++ b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts @@ -86,41 +86,61 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { await viewer.waitForOpen() }) - await test.step('centre the viewer beside the panel above the sm breakpoint', async () => { + await test.step('size the viewer against the docked panel either side of the sm breakpoint', async () => { // The viewer keeps its own inset-aware width cap while every other dialog // now resolves against the raw viewport. The cap is declared twice — // unprefixed and `sm:`-prefixed — because the `full` dialog size already // ships `sm:max-w-[calc(100vw-1rem)]`, which outranks an unprefixed cap - // above the breakpoint, so only the prefixed declaration is live here. - // The narrow-viewport steps below run under `sm:` and cannot see it: drop - // it and they still pass while the viewer covers the panel. + // above the breakpoint. So the prefixed declaration is the live one above + // `sm` and the unprefixed one below it, and the loop runs a viewport each + // side so neither can drift unobserved. The pre-existing steps below only + // bound the viewer rather than sizing it, which is why dropping the + // prefixed declaration left them green while the viewer covered the panel. // // This dialog is always on the centring term of the clamp's `max()`, // never its 0.5rem gutter floor: the cap holds the width at or under // `100vw - inset - 1rem`, which leaves centring at least 8px, so the // floor can at best tie. That makes the viewer's x unusable as evidence // on its own, and a floor assertion here vacuous. What is asserted is - // the width the live cap produces, which is what dropping the prefixed - // declaration changes, and equal gutters either side of the viewer. The - // floor itself is covered by `dialogAgentPanelInset.spec.ts`, where a - // dialog without an inset-aware cap does sit on it. - for (const width of [1280, 1920, 2560]) { + // the width the live cap produces and equal gutters either side of the + // viewer. The floor itself is covered by `dialogAgentPanelInset.spec.ts`, + // where a dialog without an inset-aware cap does sit on it. + // + // Measure only once the open transition has finished: `waitForOpen` only + // asserts visibility, and `data-[state=open]:zoom-in-95` would otherwise + // put a scaled box in the trace as the first thing that failed. + await expect + .poll(() => viewer.dialog.evaluate((el) => el.getAnimations().length)) + .toBe(0) + + for (const width of [1280, 1920, 2560, 500]) { await page.setViewportSize({ width, height: 800 }) await expect(async () => { const dialogBox = await viewer.dialog.boundingBox() const panelBox = await panel.boundingBox() - const inset = await page.evaluate( + // Read the resolved value, not the inline style the panel happens to + // write today, and require a px length. `parseFloat(...) || 0` would + // turn a renamed or unparseable property into the same 0 that overlay + // mode legitimately publishes, which is the distinction the next + // assertion exists to draw. + const publishedInset = await page.evaluate( (property) => - parseFloat( - document.documentElement.style.getPropertyValue(property) - ) || 0, + getComputedStyle(document.documentElement) + .getPropertyValue(property) + .trim(), '--workspace-inset-right' ) expect(dialogBox).not.toBeNull() expect(panelBox).not.toBeNull() if (!dialogBox || !panelBox) return + expect( + publishedInset, + 'the workspace inset is published as a px length' + ).toMatch(/^-?\d+(\.\d+)?px$/) + const inset = Number.parseFloat(publishedInset) + // The panel is docked against the right edge, so its left edge is the // boundary of the visible workspace. Its width is the resizable // `draggedWidth`, so derive everything from the measured box rather @@ -151,8 +171,11 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { 'the viewer fills the workspace up to its own 80vw width' ) + // Both gutters resolve against `100vw - inset`, the same boundary + // production centres on, so the slack stays in the assertions above + // rather than compounding into this one. expectPixels( - panelBox.x - (dialogBox.x + dialogBox.width), + width - inset - (dialogBox.x + dialogBox.width), dialogBox.x, 'the viewer sits centred between the viewport and panel edges' ) From 87bd01b6c2a4c2f371e318c25e235e5641777f88 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 4 Oct 2026 18:45:49 -0700 Subject: [PATCH 05/11] test(load3d): certify painted chrome and move the sub-sm case clear of overlay Round 4 of the Cursor panel. Move the sub-`sm` iteration from 500px to 560px. `isOverlay` flips at `PANEL_MIN_WIDTH + SIDE_TOOLBAR_WIDTH`, which is 476 with no sidebar panel visible, so 500px left 24px of margin: a modest change to either constant would have turned the case into an overlay-mode one and failed `the docked panel publishes its width as the workspace inset` against correct behaviour, losing the sub-`sm` coverage the last round added. 560px is still under the 640px breakpoint, so the unprefixed cap is still the live one, and it no longer duplicates the 500px step below, whose horizontal bounds the loop had made redundant. Assert the viewer paints its chrome inside its own box. The four geometric assertions only measure the border box, and nothing in `dialogContentVariants` or `DialogHeader` clips, so a viewer narrower than its own fixed-width header controls paints past its right edge with every one of them green. Measured, and it is not hypothetical: at 500px the viewer is 64px wide while its content is 92px, and the close button's right edge lands at 101px against a dialog right edge of 72px and a panel left edge of 80px, so the control paints 21px onto the docked panel. The pre-existing 500px step passes through that, because it measures the box. **That 500px overflow is a real rendering defect and this commit does not fix it.** It predates this branch, it is in production code, and this PR is test-only, so it is reported rather than patched here. At 560px and above the content fits (122px in a 122px box), which is what the new assertion pins. Re-measured on this commit, `--project=cloud` against the real docked panel: | viewport | inset | viewer width | content width | | --- | --- | --- | --- | | 2560 | 420px | 2048 | 2046 | | 1920 | 420px | 1484 | 1482 | | 1280 | 420px | 844 | 842 | | 560 | 420px | 124 | 122 | | 500 | 420px | 64 | **92** | - `load3dAgentUpdate.spec.ts` 3 passed. - deleting only the `sm:`-prefixed cap: fails, expected <= 845, received 1024. - restoring the pre-#19729 contentClass: fails identically. - drifting the unprefixed cap to `3rem`: fails at 560px, expected >= 123, received 92. Declined the suggestion to split the loop into one table-driven case per width. Every step in this test walks the same opened viewer through viewports, and resizing is part of what is under test: a fresh fixture per width would quadruple an already 60s spec and would never exercise a resize. Co-Authored-By: Claude Opus 5 (1M context) --- .../tests/load3d/load3dAgentUpdate.spec.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts index 6491f777cb9..8dc337021d2 100644 --- a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts +++ b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts @@ -113,7 +113,12 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { .poll(() => viewer.dialog.evaluate((el) => el.getAnimations().length)) .toBe(0) - for (const width of [1280, 1920, 2560, 500]) { + // 560px is the sub-`sm` case: under the 640px breakpoint, so the + // unprefixed cap is live, and well clear of the docked/overlay threshold + // at `PANEL_MIN_WIDTH + SIDE_TOOLBAR_WIDTH` (476), which a narrower + // viewport would sit close enough to that a modest change to either + // constant would silently turn this case into an overlay-mode one. + for (const width of [1280, 1920, 2560, 560]) { await page.setViewportSize({ width, height: 800 }) await expect(async () => { @@ -179,6 +184,19 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { dialogBox.x, 'the viewer sits centred between the viewport and panel edges' ) + + // The box being inside the workspace is not the same as what is + // painted being inside it: the header's controls are a fixed width + // and nothing in the dialog clips them, so a viewer narrower than + // its own chrome paints past its right edge and onto the panel with + // every assertion above still green. + const overflow = await viewer.dialog.evaluate( + (element) => element.scrollWidth - element.clientWidth + ) + expect( + overflow, + 'the viewer paints its chrome inside its own box' + ).toBeLessThanOrEqual(0) }).toPass({ timeout: 5000 }) } }) From a8e239a0d030c5c1b30aaad95b913fdcffd3a08d Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 4 Oct 2026 19:11:40 -0700 Subject: [PATCH 06/11] test(load3d): drop the overflow check that could not fire, and name the overlay precondition Round 5 of the Cursor panel, and the High finding is about round 4's own fix. Remove the `scrollWidth <= clientWidth` assertion. It was added citing the 500px overlap and then landed in the same commit that moved the loop off 500px, so it could not fail at any width it ran at. Two measurements confirm it, both against unmodified production code: - the header chrome fits from about 546px upward, and the loop's narrowest viewport is 560, where the content is 122px in a 122px box; - the dialog root could not see body overflow in any case. `GlobalDialog.vue` wraps the body in `flex-1 overflow-auto`, so descendant overflow terminates there. At 560px the body reports `scrollWidth` 254 against `clientWidth` 122 while the dialog root reports 122 against 122. Keeping it would have been the same defect round 2 removed from this step: an assertion that reads as coverage and cannot go red. Its `PIXEL_SLACK` bypass goes with it. Name the precondition behind the 476px overlay threshold. It is the sidebar-closed value. `reservedWorkspaceWidth` initializes to `SIDE_TOOLBAR_WIDTH + SIDEBAR_MIN_WIDTH` and resolves there whenever a sidebar tab is visible, which puts the threshold at 788 and would overlay the panel at every width in this loop. The fixture opens no sidebar tab, and the inset assertion is what actually holds that, so the comment now says so instead of stating 476 as the threshold. **Two production findings measured here, neither fixed by this test-only PR.** At every sub-`sm` viewport with the panel docked, the Load3D viewer's 3D canvas collapses to **zero width**: `Load3dViewerContent.vue`'s `w-72` sidebar has an auto flex basis and absorbs all the shrink, so the canvas pane (`flex-1`, basis 0) gets nothing. Measured canvas width 0 at 630, 600, 560 and 500px, against 522px at 1280px. And below about 546px the header controls paint past the dialog onto the panel: at 500px the content is 92px in a 64px box with the close button's right edge at 101px against a panel left edge of 80px. Asserting either here would pin a defect or go red on one, so both are reported rather than encoded. Re-measured on this commit, `--project=cloud`: - `load3dAgentUpdate.spec.ts` 3 passed. - deleting only the `sm:`-prefixed cap: fails, expected <= 845, received 1024. - drifting the unprefixed cap to `3rem`: fails at 560px, expected >= 123, received 92. Co-Authored-By: Claude Opus 5 (1M context) --- .../tests/load3d/load3dAgentUpdate.spec.ts | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts index 8dc337021d2..720103b6cd4 100644 --- a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts +++ b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts @@ -114,10 +114,12 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { .toBe(0) // 560px is the sub-`sm` case: under the 640px breakpoint, so the - // unprefixed cap is live, and well clear of the docked/overlay threshold - // at `PANEL_MIN_WIDTH + SIDE_TOOLBAR_WIDTH` (476), which a narrower - // viewport would sit close enough to that a modest change to either - // constant would silently turn this case into an overlay-mode one. + // unprefixed cap is live. `isOverlay` flips at + // `PANEL_MIN_WIDTH + reservedWorkspaceWidth`, which is 476 for this + // fixture because it opens no sidebar tab — with one visible the + // reservation is `SIDE_TOOLBAR_WIDTH + SIDEBAR_MIN_WIDTH` and the + // threshold is 788, above every width here. The inset assertion below is + // what holds that precondition, rather than this comment. for (const width of [1280, 1920, 2560, 560]) { await page.setViewportSize({ width, height: 800 }) @@ -184,19 +186,6 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { dialogBox.x, 'the viewer sits centred between the viewport and panel edges' ) - - // The box being inside the workspace is not the same as what is - // painted being inside it: the header's controls are a fixed width - // and nothing in the dialog clips them, so a viewer narrower than - // its own chrome paints past its right edge and onto the panel with - // every assertion above still green. - const overflow = await viewer.dialog.evaluate( - (element) => element.scrollWidth - element.clientWidth - ) - expect( - overflow, - 'the viewer paints its chrome inside its own box' - ).toBeLessThanOrEqual(0) }).toPass({ timeout: 5000 }) } }) From 99441e509bd97553a2ab3b580415230fc07197e5 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 4 Oct 2026 19:37:04 -0700 Subject: [PATCH 07/11] test(load3d): pin where the prefixed cap becomes live, and gate each resize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Round 6 of the Cursor panel. Add a 640px sample, the breakpoint itself. The lowest above-`sm` sample was 1280, so the loop pinned that the prefixed declaration is live without pinning *where* it becomes live. Measured: retarget the duplicate from `sm:` to `md:` and the previous commit passes 3/3, because every sample it takes is either above `md` or below `sm`. With 640 in the loop it fails there, `expected <= 205, received 512`, as the viewport falls back to the generic `sm:max-w-[calc(100vw-1rem)]` and the viewer covers the panel. Gate each iteration on `window.innerWidth` reaching the requested size. `setViewportSize` resolves before the page has re-laid out and the inset publish is a separate async flush, so an iteration's first attempt could pair a pre-resize box with a post-resize inset — the same misleading first trace entry round 3 fixed for the open transition, recurring once per iteration. It also makes `width` legitimate ground truth for `100vw`: a headed run on a display narrower than a sample gets a window-clamped viewport, and that now fails naming the viewport instead of naming the viewer three assertions later. Correct the overlay comment, which was wrong in two ways. `isOverlay` compares `requestedWidth + reservedWorkspaceWidth`, and neither term is a constant: the first is the dragged or maximized panel width, so 476 is the default-width value rather than a threshold. And 788 is not "above every width here" — only 560 and 640 are below it, so a visible sidebar tab flips the two narrow samples and leaves the three wider ones docked. Relabel the width assertion `the viewer box is the width its cap resolves to`. It was claiming the viewer fills the workspace, which is not true at the narrow samples: the box is 124px and 204px there, narrower than the viewer's own body content, and the canvas pane collapses to zero width. The comment now says that, and says why the pin is two-sided anyway — it is the cap's contract, so a production change giving the viewer a sub-`sm` floor is a change to that contract and should surface here rather than pass silently. Not adding the overflow check to the pre-existing 500px step. It fires there, which is the point being made and is also the reason: the 21px of header control painted onto the panel at 500px is a production defect that predates this branch, and a test-only PR should not go red on it. Reported instead. Re-measured on this commit, `--project=cloud`: - `load3dAgentUpdate.spec.ts` 3 passed, covering 1280, 1920, 2560, 640, 560. - retargeting the duplicate to `md:`: fails at 640, expected <= 205, received 512. - deleting only the `sm:`-prefixed cap: fails, expected <= 845, received 1024. - drifting the unprefixed cap to `3rem`: fails at 560, expected >= 123, received 92. Co-Authored-By: Claude Opus 5 (1M context) --- .../tests/load3d/load3dAgentUpdate.spec.ts | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts index 720103b6cd4..44f04692b8f 100644 --- a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts +++ b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts @@ -113,15 +113,33 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { .poll(() => viewer.dialog.evaluate((el) => el.getAnimations().length)) .toBe(0) - // 560px is the sub-`sm` case: under the 640px breakpoint, so the - // unprefixed cap is live. `isOverlay` flips at - // `PANEL_MIN_WIDTH + reservedWorkspaceWidth`, which is 476 for this - // fixture because it opens no sidebar tab — with one visible the - // reservation is `SIDE_TOOLBAR_WIDTH + SIDEBAR_MIN_WIDTH` and the - // threshold is 788, above every width here. The inset assertion below is + // 640 is the breakpoint itself, the narrowest viewport at which the + // prefixed declaration is live, so it is what pins *where* that happens: + // retarget the duplicate from `sm:` to `md:` and every wider sample + // stays green while 640 falls back to the generic + // `sm:max-w-[calc(100vw-1rem)]` and fails. 560 is the sub-`sm` case, + // where the unprefixed declaration is the live one. + // + // Both narrow samples depend on the panel staying docked. `isOverlay` + // compares `requestedWidth + reservedWorkspaceWidth`, so neither term is + // a constant: the first is the dragged or maximized panel width, and the + // second is `SIDE_TOOLBAR_WIDTH` alone here only because this fixture + // opens no sidebar tab — with one visible it is + // `SIDE_TOOLBAR_WIDTH + SIDEBAR_MIN_WIDTH` and 560 and 640 would overlay + // while the three wider samples would not. The inset assertion below is // what holds that precondition, rather than this comment. - for (const width of [1280, 1920, 2560, 560]) { + for (const width of [1280, 1920, 2560, 640, 560]) { await page.setViewportSize({ width, height: 800 }) + // `setViewportSize` resolves before the page has re-laid out, and the + // inset publish is a separate async flush, so without this an + // iteration's first attempt can pair a pre-resize box with a + // post-resize inset. It also makes `width` legitimate ground truth for + // `100vw`: a headed run on a narrower display gets a window-clamped + // viewport, and that then fails here, naming the viewport, instead of + // further down naming the viewer. + await expect + .poll(() => page.evaluate(() => window.innerWidth)) + .toBe(width) await expect(async () => { const dialogBox = await viewer.dialog.boundingBox() @@ -172,10 +190,19 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { // `min(80vw, 100vw - inset - 1rem)`. Above ~2180px at the default // panel width the 80vw term is the smaller one and the cap stops // binding, which is correct and must not fail the step. + // + // This is a claim about the dialog's box and nothing else. At the + // two narrow samples the box is 124px and 204px, which is narrower + // than the viewer's own body content, so what it contains is not + // laid out usefully there — the canvas pane in particular collapses + // to zero width. Pinning the box two-sided is deliberate: it is the + // cap's contract, so a production change that gives the viewer a + // sub-`sm` floor is a change to that contract and should surface + // here rather than pass silently. expectPixels( dialogBox.width, Math.min(width * 0.8, width - inset - VIEWER_CAP_RESERVE), - 'the viewer fills the workspace up to its own 80vw width' + 'the viewer box is the width its cap resolves to' ) // Both gutters resolve against `100vw - inset`, the same boundary From 9c681c1e829bcd80e7471a8e3c4ec2e6d5cf61b3 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 4 Oct 2026 20:07:09 -0700 Subject: [PATCH 08/11] test(load3d): vary the panel width, so the inset term is actually load-bearing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Round 7 of the Cursor panel. Every sample left the docked panel at its default 420px, which made the inset term in the viewer's cap and a hard-coded `420px` indistinguishable — and made `the docked panel publishes its width as the workspace inset` tautological, since nothing varied. Measured: replace `var(--workspace-inset-right,0px)` with `420px` in both declarations and the previous commit passes 3/3. Added a case that drags the panel to 620px at a 1920px viewport and re-measures. That mutation now fails there, `expected <= 1285, received 1484`, which is the viewer overlapping the widened panel by 200px. The viewer has to be closed to do it, and that is not a harness workaround: it is modal and its overlay is `fixed inset-0 z-1700`, so `elementFromPoint` at the handle's centre returns the overlay, not the handle. The case closes the viewer, drags, reopens, asserts, then drags back to 420 and reopens, because the narrow steps below are written against a 420px panel and a 620px one overlays at their viewports. Import `WORKSPACE_INSET_RIGHT` from the composable instead of repeating the property name, matching `browser_tests/fixtures/utils/workspaceInset.ts`, so a rename does not turn this step red while the sibling spec stays green. Correct what the `window.innerWidth` gate claims. It cannot order against the inset publish — `innerWidth` reflects the new metrics before the `resize` event dispatches, so `useWindowSize` and the publishing `watchEffect` can still be pending. What it does guarantee is that the box is not measured before the viewport width changed; `toPass` covers the rest. The comment says that now. Keeping the width bound two-sided at 640. An upper bound would cover the retarget regression that sample is for, but the symmetric form is the cap's contract at every sample, and a one-off asymmetry at one viewport costs more in readability than the pin costs a future sub-`sm` floor, which is one expectation to update in a step that names the cap. Re-measured on this commit, `--project=cloud`, all four mutations caught: | mutation | fails at | expected | received | | --- | --- | --- | --- | | inset term replaced by `420px` | 1920 / 620px panel | <= 1285 | 1484 | | duplicate retargeted `sm:` → `md:` | 640 | <= 205 | 512 | | `sm:`-prefixed cap deleted | 1280 | <= 845 | 1024 | | unprefixed cap drifted to `3rem` | 560 | >= 123 | 92 | `load3dAgentUpdate.spec.ts` 3 passed. Co-Authored-By: Claude Opus 5 (1M context) --- .../tests/load3d/load3dAgentUpdate.spec.ts | 90 +++++++++++++++---- 1 file changed, 75 insertions(+), 15 deletions(-) diff --git a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts index 44f04692b8f..479e6f08dfb 100644 --- a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts +++ b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts @@ -1,5 +1,7 @@ import { expect } from '@playwright/test' +import { WORKSPACE_INSET_RIGHT } from '@/composables/useWorkspaceInset' + import { AgentPanel } from '@e2e/fixtures/components/AgentPanel' import { load3dAgentTest as test } from '@e2e/fixtures/load3dAgentFixture' import { Load3DViewerHelper } from '@e2e/tests/load3d/Load3DViewerHelper' @@ -128,20 +130,8 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { // `SIDE_TOOLBAR_WIDTH + SIDEBAR_MIN_WIDTH` and 560 and 640 would overlay // while the three wider samples would not. The inset assertion below is // what holds that precondition, rather than this comment. - for (const width of [1280, 1920, 2560, 640, 560]) { - await page.setViewportSize({ width, height: 800 }) - // `setViewportSize` resolves before the page has re-laid out, and the - // inset publish is a separate async flush, so without this an - // iteration's first attempt can pair a pre-resize box with a - // post-resize inset. It also makes `width` legitimate ground truth for - // `100vw`: a headed run on a narrower display gets a window-clamped - // viewport, and that then fails here, naming the viewport, instead of - // further down naming the viewer. - await expect - .poll(() => page.evaluate(() => window.innerWidth)) - .toBe(width) - - await expect(async () => { + const expectViewerBesidePanel = async (width: number) => + expect(async () => { const dialogBox = await viewer.dialog.boundingBox() const panelBox = await panel.boundingBox() // Read the resolved value, not the inline style the panel happens to @@ -154,7 +144,7 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { getComputedStyle(document.documentElement) .getPropertyValue(property) .trim(), - '--workspace-inset-right' + WORKSPACE_INSET_RIGHT ) expect(dialogBox).not.toBeNull() expect(panelBox).not.toBeNull() @@ -214,7 +204,77 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { 'the viewer sits centred between the viewport and panel edges' ) }).toPass({ timeout: 5000 }) + + const resizeViewportTo = async (width: number) => { + await page.setViewportSize({ width, height: 800 }) + // Only guarantees the box is not measured before the viewport width + // changed — `window.innerWidth` reflects the new metrics before the + // `resize` event dispatches, so it says nothing about whether the + // inset publish has flushed; `toPass` is what covers that. It also + // makes `width` legitimate ground truth for `100vw`: a headed run on a + // narrower display gets a window-clamped viewport, which then fails + // here naming the viewport instead of three assertions later naming + // the viewer. + await expect + .poll(() => page.evaluate(() => window.innerWidth)) + .toBe(width) } + + // Closes the viewer first, because its modal overlay covers the handle. + const dragPanelEdgeBy = async (dx: number) => { + await viewer.cancelButton.click() + await viewer.waitForClosed() + const handleBox = await page + .getByTestId('agent-panel-resize-handle') + .boundingBox() + expect(handleBox).not.toBeNull() + if (!handleBox) throw new Error('Panel resize handle is not laid out') + const x = handleBox.x + handleBox.width / 2 + const y = handleBox.y + handleBox.height / 2 + await page.mouse.move(x, y) + await page.mouse.down() + await page.mouse.move(x + dx, y, { steps: 10 }) + await page.mouse.up() + } + + const reopenViewer = async () => { + await load3dAgent.viewer.openViewerButton.click() + await viewer.waitForOpen() + await expect + .poll(() => viewer.dialog.evaluate((el) => el.getAnimations().length)) + .toBe(0) + } + + for (const width of [1280, 1920, 2560, 640, 560]) { + await resizeViewportTo(width) + await expectViewerBesidePanel(width) + } + + // Every iteration above leaves the panel at its default 420px, so the + // inset term in the viewer's cap and a hard-coded `420px` would be + // indistinguishable — including to the inset assertion itself, which is + // tautological while the width never varies. Drag the panel wider and + // re-measure: at a 1920px viewport that regression would render the + // viewer at 1484px instead of 1284px and overlap the panel by 200px. + // + // The viewer has to be closed to do it. It is modal, and its overlay is + // `fixed inset-0`, so the panel's resize handle is genuinely unreachable + // by a pointer while the viewer is open. + await resizeViewportTo(1920) + await dragPanelEdgeBy(-200) + await expect + .poll(async () => Math.round((await panel.boundingBox())?.width ?? 0)) + .toBe(620) + await reopenViewer() + await expectViewerBesidePanel(1920) + + // Restore the default width: the narrow steps below are written against + // a 420px panel, and a 620px one overlays at their viewports. + await dragPanelEdgeBy(200) + await expect + .poll(async () => Math.round((await panel.boundingBox())?.width ?? 0)) + .toBe(420) + await reopenViewer() }) await test.step('keep the viewer outside the docked Agent panel', async () => { From d444f800c73d4c99461567149fe63917b82ac531 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Fri, 23 Oct 2026 09:27:23 -0700 Subject: [PATCH 09/11] test(load3d): pin the cap against production's 90vw term, not a stale 80vw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `keeps the full-screen viewer inside the visible workspace inset` step failed at the 2560px sample with `expect(2124).toBeLessThanOrEqual(2049)`. That is arithmetic, not flake: 2124 is exactly `2560 - 420 - 16`, the inset term of the cap, and 2048 is exactly `0.8 * 2560`. The spec carried `80vw` while the one declaration that produces this width — the `full` size's compound variant in `src/components/ui/dialog/dialog.variants.ts` — ships `max-w-[min(90vw,calc(100vw-var(--workspace-inset-right,0px)-1rem))]`. Correct the fraction and name it, so the next drift names the constant. Only the 2560px sample moves (2048 -> 2124); 1280, 1920, 640, 560 and the dragged-panel 1920/620 case all resolve on the inset term and are byte-identical, so this is not an assertion loosened until it passed. Also retire two comments that describe a declaration the tree no longer has. The cap was once declared twice, unprefixed and `sm:`-prefixed, because `size: 'full'` shipped `sm:max-w-[calc(100vw-1rem)]`. It does not: `full` now contributes no classes and the cap is a single unprefixed declaration, so nothing breakpoint-prefixed competes with it. The 640/560 samples are kept and their rationale restated — a future prefixed cap on `full` would regress above `sm` only, which is what they catch. The `min()`'s viewport term binds only above `(inset + 1rem) * 10`, i.e. 4360px at the default panel, so it is inert at every sample here. Kept anyway: it is the cap's real shape, and a wider panel moves the crossover. --- .../tests/load3d/load3dAgentUpdate.spec.ts | 51 ++++++++++++------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts index 479e6f08dfb..ce1afa6f305 100644 --- a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts +++ b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts @@ -7,11 +7,16 @@ import { load3dAgentTest as test } from '@e2e/fixtures/load3dAgentFixture' import { Load3DViewerHelper } from '@e2e/tests/load3d/Load3DViewerHelper' // The `1rem` the viewer's own width cap reserves inside the visible workspace: -// `max-w-[min(80vw,calc(100vw-var(--workspace-inset-right,0px)-1rem))]`. Not +// `max-w-[min(90vw,calc(100vw-var(--workspace-inset-right,0px)-1rem))]`. Not // shared with the dialog clamp's own `0.5rem` gutter floor, which is a separate // production value that only happens to be half of this one. const VIEWER_CAP_RESERVE = 16 +// The viewport fraction in the same cap's other term. Read off the `full` +// size's compound variant in `src/components/ui/dialog/dialog.variants.ts`, +// which is the one declaration that produces this width. +const VIEWER_CAP_VIEWPORT_FRACTION = 0.9 + // The slack the rest of this file already allows on bounding boxes, so a // fractional panel width or transform rounding cannot turn a correct layout // into a failure. Note `toBeCloseTo`'s second argument is a digit count, not @@ -90,14 +95,16 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { await test.step('size the viewer against the docked panel either side of the sm breakpoint', async () => { // The viewer keeps its own inset-aware width cap while every other dialog - // now resolves against the raw viewport. The cap is declared twice — - // unprefixed and `sm:`-prefixed — because the `full` dialog size already - // ships `sm:max-w-[calc(100vw-1rem)]`, which outranks an unprefixed cap - // above the breakpoint. So the prefixed declaration is the live one above - // `sm` and the unprefixed one below it, and the loop runs a viewport each - // side so neither can drift unobserved. The pre-existing steps below only - // bound the viewer rather than sizing it, which is why dropping the - // prefixed declaration left them green while the viewer covered the panel. + // now resolves against the raw viewport. That cap is a single unprefixed + // declaration on the `full` size's compound variant, and the `full` size + // itself contributes no classes, so nothing breakpoint-prefixed competes + // with it at any viewport. The loop still samples either side of `sm` + // because the sized siblings (`sm:max-w-*`) are prefixed, so a future + // change that gives `full` a prefixed cap would outrank this one above + // the breakpoint only — exactly the drift the two narrow samples catch. + // The pre-existing steps below only bound the viewer rather than sizing + // it, which is why losing the cap above `sm` would leave them green + // while the viewer covered the panel. // // This dialog is always on the centring term of the clamp's `max()`, // never its 0.5rem gutter floor: the cap holds the width at or under @@ -115,12 +122,10 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { .poll(() => viewer.dialog.evaluate((el) => el.getAnimations().length)) .toBe(0) - // 640 is the breakpoint itself, the narrowest viewport at which the - // prefixed declaration is live, so it is what pins *where* that happens: - // retarget the duplicate from `sm:` to `md:` and every wider sample - // stays green while 640 falls back to the generic - // `sm:max-w-[calc(100vw-1rem)]` and fails. 560 is the sub-`sm` case, - // where the unprefixed declaration is the live one. + // 640 is the `sm` breakpoint itself, the narrowest viewport at which a + // prefixed cap would be live, so it is what pins *where* a regression + // takes effect: prefix this cap at `sm:` and 640 and every wider sample + // fail while 560 alone stays green. 560 is the sub-`sm` case. // // Both narrow samples depend on the panel staying docked. `isOverlay` // compares `requestedWidth + reservedWorkspaceWidth`, so neither term is @@ -177,9 +182,14 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { 'the docked panel publishes its width as the workspace inset' ) - // `min(80vw, 100vw - inset - 1rem)`. Above ~2180px at the default - // panel width the 80vw term is the smaller one and the cap stops - // binding, which is correct and must not fail the step. + // `min(90vw, 100vw - inset - 1rem)`, mirroring the production + // declaration rather than only the term that happens to bind. The + // viewport term is the smaller one only above `(inset + 1rem) * 10` + // — 4360px at the default 420px panel — so it binds at none of the + // samples below. It is kept because it is the cap's actual shape: a + // wider panel or a wider viewport moves the crossover, and pinning + // only the inset term would then assert a width production no + // longer produces. // // This is a claim about the dialog's box and nothing else. At the // two narrow samples the box is 124px and 204px, which is narrower @@ -191,7 +201,10 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { // here rather than pass silently. expectPixels( dialogBox.width, - Math.min(width * 0.8, width - inset - VIEWER_CAP_RESERVE), + Math.min( + width * VIEWER_CAP_VIEWPORT_FRACTION, + width - inset - VIEWER_CAP_RESERVE + ), 'the viewer box is the width its cap resolves to' ) From 59ead65fe08665044635d1db7e90e43756cb214f Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Fri, 23 Oct 2026 17:22:32 -0700 Subject: [PATCH 10/11] test(load3d): pin docked viewer bounds --- .../tests/load3d/load3dAgentUpdate.spec.ts | 296 ++++++------------ 1 file changed, 89 insertions(+), 207 deletions(-) diff --git a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts index ce1afa6f305..37316af8a5c 100644 --- a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts +++ b/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts @@ -6,21 +6,6 @@ import { AgentPanel } from '@e2e/fixtures/components/AgentPanel' import { load3dAgentTest as test } from '@e2e/fixtures/load3dAgentFixture' import { Load3DViewerHelper } from '@e2e/tests/load3d/Load3DViewerHelper' -// The `1rem` the viewer's own width cap reserves inside the visible workspace: -// `max-w-[min(90vw,calc(100vw-var(--workspace-inset-right,0px)-1rem))]`. Not -// shared with the dialog clamp's own `0.5rem` gutter floor, which is a separate -// production value that only happens to be half of this one. -const VIEWER_CAP_RESERVE = 16 - -// The viewport fraction in the same cap's other term. Read off the `full` -// size's compound variant in `src/components/ui/dialog/dialog.variants.ts`, -// which is the one declaration that produces this width. -const VIEWER_CAP_VIEWPORT_FRACTION = 0.9 - -// The slack the rest of this file already allows on bounding boxes, so a -// fractional panel width or transform rounding cannot turn a correct layout -// into a failure. Note `toBeCloseTo`'s second argument is a digit count, not -// pixels, so it cannot express this. const PIXEL_SLACK = 1 function expectPixels(actual: number, expected: number, label: string): void { @@ -28,7 +13,7 @@ function expectPixels(actual: number, expected: number, label: string): void { expect(actual, label).toBeLessThanOrEqual(expected + PIXEL_SLACK) } -test.describe('Load3D agent updates', { tag: '@cloud' }, () => { +test.describe('Load3D agent updates', { tag: ['@cloud', '@agent'] }, () => { test.describe.configure({ timeout: 60_000 }) test('retires an incompatible replacement link without blocking the next agent edit', async ({ @@ -85,209 +70,106 @@ test.describe('Load3D agent updates', { tag: '@cloud' }, () => { const viewer = new Load3DViewerHelper(page) const panel = page.getByTestId('docked-agent-panel') - await test.step('open the viewer from an agent-updated node', async () => { - load3dAgent.setModelFromAgent('cube.obj') - await load3dAgent.expectModel('cube.obj') - await load3dAgent.viewer.waitForModelLoaded() + const openViewer = async () => { await load3dAgent.viewer.openViewerButton.click() await viewer.waitForOpen() - }) - - await test.step('size the viewer against the docked panel either side of the sm breakpoint', async () => { - // The viewer keeps its own inset-aware width cap while every other dialog - // now resolves against the raw viewport. That cap is a single unprefixed - // declaration on the `full` size's compound variant, and the `full` size - // itself contributes no classes, so nothing breakpoint-prefixed competes - // with it at any viewport. The loop still samples either side of `sm` - // because the sized siblings (`sm:max-w-*`) are prefixed, so a future - // change that gives `full` a prefixed cap would outrank this one above - // the breakpoint only — exactly the drift the two narrow samples catch. - // The pre-existing steps below only bound the viewer rather than sizing - // it, which is why losing the cap above `sm` would leave them green - // while the viewer covered the panel. - // - // This dialog is always on the centring term of the clamp's `max()`, - // never its 0.5rem gutter floor: the cap holds the width at or under - // `100vw - inset - 1rem`, which leaves centring at least 8px, so the - // floor can at best tie. That makes the viewer's x unusable as evidence - // on its own, and a floor assertion here vacuous. What is asserted is - // the width the live cap produces and equal gutters either side of the - // viewer. The floor itself is covered by `dialogAgentPanelInset.spec.ts`, - // where a dialog without an inset-aware cap does sit on it. - // - // Measure only once the open transition has finished: `waitForOpen` only - // asserts visibility, and `data-[state=open]:zoom-in-95` would otherwise - // put a scaled box in the trace as the first thing that failed. await expect .poll(() => viewer.dialog.evaluate((el) => el.getAnimations().length)) .toBe(0) + } - // 640 is the `sm` breakpoint itself, the narrowest viewport at which a - // prefixed cap would be live, so it is what pins *where* a regression - // takes effect: prefix this cap at `sm:` and 640 and every wider sample - // fail while 560 alone stays green. 560 is the sub-`sm` case. - // - // Both narrow samples depend on the panel staying docked. `isOverlay` - // compares `requestedWidth + reservedWorkspaceWidth`, so neither term is - // a constant: the first is the dragged or maximized panel width, and the - // second is `SIDE_TOOLBAR_WIDTH` alone here only because this fixture - // opens no sidebar tab — with one visible it is - // `SIDE_TOOLBAR_WIDTH + SIDEBAR_MIN_WIDTH` and 560 and 640 would overlay - // while the three wider samples would not. The inset assertion below is - // what holds that precondition, rather than this comment. - const expectViewerBesidePanel = async (width: number) => - expect(async () => { - const dialogBox = await viewer.dialog.boundingBox() - const panelBox = await panel.boundingBox() - // Read the resolved value, not the inline style the panel happens to - // write today, and require a px length. `parseFloat(...) || 0` would - // turn a renamed or unparseable property into the same 0 that overlay - // mode legitimately publishes, which is the distinction the next - // assertion exists to draw. - const publishedInset = await page.evaluate( - (property) => - getComputedStyle(document.documentElement) - .getPropertyValue(property) - .trim(), - WORKSPACE_INSET_RIGHT - ) - expect(dialogBox).not.toBeNull() - expect(panelBox).not.toBeNull() - if (!dialogBox || !panelBox) return - - expect( - publishedInset, - 'the workspace inset is published as a px length' - ).toMatch(/^-?\d+(\.\d+)?px$/) - const inset = Number.parseFloat(publishedInset) - - // The panel is docked against the right edge, so its left edge is the - // boundary of the visible workspace. Its width is the resizable - // `draggedWidth`, so derive everything from the measured box rather - // than pinning coordinates that only hold at its default width. - expectPixels( - panelBox.x + panelBox.width, - width, - 'the panel is flush with the right edge' - ) + const expectViewerBesidePanel = async (width: number) => { + await page.setViewportSize({ width, height: 800 }) + await expect + .poll(() => page.evaluate(() => window.innerWidth)) + .toBe(width) - // The panel publishes its width as the inset only while it is docked - // and not overlaying; in overlay mode it covers the right edge with - // an inset of 0, and the viewer is then correctly wider than the - // workspace. Pin the mode so a failure below is attributable to the - // viewer rather than to the panel having gone into overlay. - expectPixels( - inset, - panelBox.width, - 'the docked panel publishes its width as the workspace inset' - ) + await expect(async () => { + const dialogBox = await viewer.dialog.boundingBox() + const panelBox = await panel.boundingBox() + if (!dialogBox) throw new Error('Load3D viewer is not laid out') + if (!panelBox) throw new Error('Agent panel is not laid out') + + const publishedInset = await page.evaluate( + (property) => + getComputedStyle(document.documentElement) + .getPropertyValue(property) + .trim(), + WORKSPACE_INSET_RIGHT + ) + expect(publishedInset).toMatch(/^\d+(\.\d+)?px$/) + const inset = Number.parseFloat(publishedInset) - // `min(90vw, 100vw - inset - 1rem)`, mirroring the production - // declaration rather than only the term that happens to bind. The - // viewport term is the smaller one only above `(inset + 1rem) * 10` - // — 4360px at the default 420px panel — so it binds at none of the - // samples below. It is kept because it is the cap's actual shape: a - // wider panel or a wider viewport moves the crossover, and pinning - // only the inset term would then assert a width production no - // longer produces. - // - // This is a claim about the dialog's box and nothing else. At the - // two narrow samples the box is 124px and 204px, which is narrower - // than the viewer's own body content, so what it contains is not - // laid out usefully there — the canvas pane in particular collapses - // to zero width. Pinning the box two-sided is deliberate: it is the - // cap's contract, so a production change that gives the viewer a - // sub-`sm` floor is a change to that contract and should surface - // here rather than pass silently. - expectPixels( - dialogBox.width, - Math.min( - width * VIEWER_CAP_VIEWPORT_FRACTION, - width - inset - VIEWER_CAP_RESERVE - ), - 'the viewer box is the width its cap resolves to' - ) + expectPixels( + panelBox.x + panelBox.width, + width, + 'the panel is flush with the viewport edge' + ) + expectPixels( + inset, + panelBox.width, + 'the panel publishes its width as the workspace inset' + ) + expect(dialogBox.width).toBeGreaterThan(0) + expect(dialogBox.x).toBeGreaterThanOrEqual(0) + expect(dialogBox.x + dialogBox.width).toBeLessThanOrEqual( + panelBox.x + PIXEL_SLACK + ) + expectPixels( + panelBox.x - (dialogBox.x + dialogBox.width), + dialogBox.x, + 'the viewer is centered in the visible workspace' + ) + }).toPass({ timeout: 5000 }) + } - // Both gutters resolve against `100vw - inset`, the same boundary - // production centres on, so the slack stays in the assertions above - // rather than compounding into this one. - expectPixels( - width - inset - (dialogBox.x + dialogBox.width), - dialogBox.x, - 'the viewer sits centred between the viewport and panel edges' - ) - }).toPass({ timeout: 5000 }) - - const resizeViewportTo = async (width: number) => { - await page.setViewportSize({ width, height: 800 }) - // Only guarantees the box is not measured before the viewport width - // changed — `window.innerWidth` reflects the new metrics before the - // `resize` event dispatches, so it says nothing about whether the - // inset publish has flushed; `toPass` is what covers that. It also - // makes `width` legitimate ground truth for `100vw`: a headed run on a - // narrower display gets a window-clamped viewport, which then fails - // here naming the viewport instead of three assertions later naming - // the viewer. - await expect - .poll(() => page.evaluate(() => window.innerWidth)) - .toBe(width) - } - - // Closes the viewer first, because its modal overlay covers the handle. - const dragPanelEdgeBy = async (dx: number) => { - await viewer.cancelButton.click() - await viewer.waitForClosed() - const handleBox = await page - .getByTestId('agent-panel-resize-handle') - .boundingBox() - expect(handleBox).not.toBeNull() - if (!handleBox) throw new Error('Panel resize handle is not laid out') - const x = handleBox.x + handleBox.width / 2 - const y = handleBox.y + handleBox.height / 2 - await page.mouse.move(x, y) - await page.mouse.down() - await page.mouse.move(x + dx, y, { steps: 10 }) - await page.mouse.up() - } - - const reopenViewer = async () => { - await load3dAgent.viewer.openViewerButton.click() - await viewer.waitForOpen() - await expect - .poll(() => viewer.dialog.evaluate((el) => el.getAnimations().length)) - .toBe(0) - } - - for (const width of [1280, 1920, 2560, 640, 560]) { - await resizeViewportTo(width) - await expectViewerBesidePanel(width) - } - - // Every iteration above leaves the panel at its default 420px, so the - // inset term in the viewer's cap and a hard-coded `420px` would be - // indistinguishable — including to the inset assertion itself, which is - // tautological while the width never varies. Drag the panel wider and - // re-measure: at a 1920px viewport that regression would render the - // viewer at 1484px instead of 1284px and overlap the panel by 200px. - // - // The viewer has to be closed to do it. It is modal, and its overlay is - // `fixed inset-0`, so the panel's resize handle is genuinely unreachable - // by a pointer while the viewer is open. - await resizeViewportTo(1920) - await dragPanelEdgeBy(-200) + const resizePanelTo = async (width: number) => { + await viewer.cancelButton.click() + await viewer.waitForClosed() + const handleBox = await page + .getByTestId('agent-panel-resize-handle') + .boundingBox() + const panelBox = await panel.boundingBox() + if (!handleBox) + throw new Error('Agent panel resize handle is not laid out') + if (!panelBox) throw new Error('Agent panel is not laid out') + + const x = handleBox.x + handleBox.width / 2 + const y = handleBox.y + handleBox.height / 2 + await page.mouse.move(x, y) + await page.mouse.down() + await page.mouse.move(x + panelBox.width - width, y, { steps: 10 }) + await page.mouse.up() await expect .poll(async () => Math.round((await panel.boundingBox())?.width ?? 0)) - .toBe(620) - await reopenViewer() - await expectViewerBesidePanel(1920) + .toBe(width) + await openViewer() + } - // Restore the default width: the narrow steps below are written against - // a 420px panel, and a 620px one overlays at their viewports. - await dragPanelEdgeBy(200) - await expect - .poll(async () => Math.round((await panel.boundingBox())?.width ?? 0)) - .toBe(420) - await reopenViewer() + await test.step('open the viewer from an agent-updated node', async () => { + load3dAgent.setModelFromAgent('cube.obj') + await load3dAgent.expectModel('cube.obj') + await load3dAgent.viewer.waitForModelLoaded() + await openViewer() + }) + + await test.step('keep the viewer beside the panel on a desktop viewport', () => + expectViewerBesidePanel(1280)) + + await test.step('keep the viewer beside the panel at the sm breakpoint', () => + expectViewerBesidePanel(640)) + + await test.step('keep the viewer beside the panel below the sm breakpoint', () => + expectViewerBesidePanel(560)) + + await test.step('keep the viewer beside the panel on a wide viewport', () => + expectViewerBesidePanel(2560)) + + await test.step('follow a wider panel without overlapping it', async () => { + await page.setViewportSize({ width: 1920, height: 800 }) + await resizePanelTo(620) + await expectViewerBesidePanel(1920) + await resizePanelTo(420) }) await test.step('keep the viewer outside the docked Agent panel', async () => { From be1e0a650b3466d2dc6249e0b4aba620891733fa Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Fri, 23 Oct 2026 17:27:47 -0700 Subject: [PATCH 11/11] test(agent): move Load3D coverage into Agent suite --- browser_tests/tests/{load3d => agent}/load3dAgentUpdate.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename browser_tests/tests/{load3d => agent}/load3dAgentUpdate.spec.ts (99%) diff --git a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts b/browser_tests/tests/agent/load3dAgentUpdate.spec.ts similarity index 99% rename from browser_tests/tests/load3d/load3dAgentUpdate.spec.ts rename to browser_tests/tests/agent/load3dAgentUpdate.spec.ts index 37316af8a5c..6ada6f17dd5 100644 --- a/browser_tests/tests/load3d/load3dAgentUpdate.spec.ts +++ b/browser_tests/tests/agent/load3dAgentUpdate.spec.ts @@ -13,7 +13,7 @@ function expectPixels(actual: number, expected: number, label: string): void { expect(actual, label).toBeLessThanOrEqual(expected + PIXEL_SLACK) } -test.describe('Load3D agent updates', { tag: ['@cloud', '@agent'] }, () => { +test.describe('Load3D Agent updates', { tag: ['@cloud', '@agent'] }, () => { test.describe.configure({ timeout: 60_000 }) test('retires an incompatible replacement link without blocking the next agent edit', async ({