From d392866cca1e1774b6d91bcdb3c9a50f1865d060 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Date: Sat, 21 Nov 2026 06:38:55 +0100 Subject: [PATCH 1/2] test(e2e): measure the E4 header layout in one snapshot and retry until it settles The five boxes were read in separate calls while the shell could still replace the synthetic PTY title; the journey now reads them together and retries a bounded number of times, keeping the 24 px limit. --- .ai/contexts/tool-bar.md | 8 ++++++++ e2e/tool-bar.spec.js | 44 +++++++++++++++++++++++----------------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/.ai/contexts/tool-bar.md b/.ai/contexts/tool-bar.md index 7afa4cd4e..9d26780f2 100644 --- a/.ai/contexts/tool-bar.md +++ b/.ai/contexts/tool-bar.md @@ -113,3 +113,11 @@ the shell sizing and tool state regressions. `e2e/tool-bar.spec.js`: E1-E8, including the 32-case overflow matrix and width restoration. These Electron journeys run only in CI; local jsdom tests do not prove rendered geometry or native Tab traversal. + +E4 reapplies each short/long title pair and reads all header rectangles in one +synchronous renderer evaluation. Separate bounding-box calls can straddle a +PTY title update and combine the id's old position with Refresh's new one +(#1163). A bounded `toPass` retries the complete geometry assertions while +layout settles, retaining the nonnegative gap strictly below 24 CSS px and +the id/control containment checks. Each retry measures the requested titles, +even if shell output updated the PTY title since the preceding attempt. diff --git a/e2e/tool-bar.spec.js b/e2e/tool-bar.spec.js index d8986a3fe..323190556 100644 --- a/e2e/tool-bar.spec.js +++ b/e2e/tool-bar.spec.js @@ -114,25 +114,31 @@ test('E4: Refresh stays beside the id with short and long session and PTY titles await viewport(app, page, width); for (const name of ['Session', 'Session '.repeat(30)]) { for (const title of ['Shell', 'Program title '.repeat(30)]) { - await page.evaluate(({ name, title }) => { - document.getElementById('terminal-header-name').textContent = name; - const el = document.getElementById('terminal-header-pty-title'); - el.textContent = title; - el.style.display = ''; - }, { name, title }); - const id = await box(page.locator('#terminal-header-id')); - const info = await box(page.locator('#terminal-header-info')); - const refresh = await box(page.locator('#terminal-refresh-btn')); - const stop = await box(page.locator('#terminal-stop-btn')); - const header = await box(page.locator('#terminal-header')); - expect(id.x).toBeGreaterThanOrEqual(info.x); - expect(id.x + id.width).toBeLessThanOrEqual(info.x + info.width + 1); - expect(refresh.x - id.x - id.width).toBeGreaterThanOrEqual(0); - expect(refresh.x - id.x - id.width).toBeLessThan(24); - for (const control of [refresh, stop]) { - expect(control.x).toBeGreaterThanOrEqual(header.x); - expect(control.x + control.width).toBeLessThanOrEqual(header.x + header.width); - } + await expect(async () => { + const [id, info, refresh, stop, header] = await page.evaluate(({ name, title }) => { + document.getElementById('terminal-header-name').textContent = name; + const el = document.getElementById('terminal-header-pty-title'); + el.textContent = title; + el.style.display = ''; + return ['terminal-header-id', 'terminal-header-info', 'terminal-refresh-btn', 'terminal-stop-btn', 'terminal-header'] + .map(id => { + const { x, width, height } = document.getElementById(id).getBoundingClientRect(); + return { x, width, height }; + }); + }, { name, title }); + for (const rect of [id, info, refresh, stop, header]) { + expect(rect.width).toBeGreaterThan(0); + expect(rect.height).toBeGreaterThan(0); + } + expect(id.x).toBeGreaterThanOrEqual(info.x); + expect(id.x + id.width).toBeLessThanOrEqual(info.x + info.width + 1); + expect(refresh.x - id.x - id.width).toBeGreaterThanOrEqual(0); + expect(refresh.x - id.x - id.width).toBeLessThan(24); + for (const control of [refresh, stop]) { + expect(control.x).toBeGreaterThanOrEqual(header.x); + expect(control.x + control.width).toBeLessThanOrEqual(header.x + header.width); + } + }).toPass({ timeout: 5000 }); await expect(page.locator('#terminal-header [data-header-kind="toggle"]')).toHaveCount(0); } } From 9557a51f81f78ae55aa87208ebf2dce9b2d4f5b7 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Date: Sat, 21 Nov 2026 07:01:15 +0100 Subject: [PATCH 2/2] docs(tool-bar): describe the E4 measurement race as the trace shows it --- .ai/contexts/tool-bar.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.ai/contexts/tool-bar.md b/.ai/contexts/tool-bar.md index 9d26780f2..5ec126bef 100644 --- a/.ai/contexts/tool-bar.md +++ b/.ai/contexts/tool-bar.md @@ -115,9 +115,12 @@ width restoration. These Electron journeys run only in CI; local jsdom tests do not prove rendered geometry or native Tab traversal. E4 reapplies each short/long title pair and reads all header rectangles in one -synchronous renderer evaluation. Separate bounding-box calls can straddle a -PTY title update and combine the id's old position with Refresh's new one -(#1163). A bounded `toPass` retries the complete geometry assertions while -layout settles, retaining the nonnegative gap strictly below 24 CSS px and -the id/control containment checks. Each retry measures the requested titles, -even if shell output updated the PTY title since the preceding attempt. +synchronous renderer evaluation. Separate `boundingBox()` calls (CDP +`DOM.getBoxModel`) do not come from one layout: in #1163, right after the +800→1400 resize, the id came from a layout without E4's labels and Refresh from +one with them (~95 px apart), while `getBoundingClientRect` in one synchronous +pass forces a single coherent layout. A bounded `toPass` retries the complete +geometry assertions, retaining the nonnegative gap strictly below 24 CSS px +and the id/control containment checks; each retry reapplies the requested +titles. Other journeys still read boxes in separate calls after a resize +(`geometry()` in E1/E5/E5b/E6).