Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(view): retain geometry before zero-height boxes grow [N26,C7]

Corey Olson6ff2671dfab3
diff --git a/test/cockpit/demo.test.js b/test/cockpit/demo.test.js
index 3a48ef4a..b7c37fe5 100644
--- a/test/cockpit/demo.test.js
+++ b/test/cockpit/demo.test.js
@@ -353,7 +353,7 @@ async function armLaneReleaseCapture(chrome, selector, stableRoot = "document.qu
if (node === target) return true;
if (node.contains(target)) return false;
const rect = node.getBoundingClientRect();
- return prior.has(name(node).node) || (rect.width > 0 && rect.height > 0 && rect.top < targetTop);
+ return retained.has(name(node).node) || (rect.width > 0 && rect.height > 0 && rect.top < targetTop);
});
};
/** Compare boxes above the target, including hidden panels that could become visible in a refresh. */
@@ -380,7 +380,10 @@ async function armLaneReleaseCapture(chrome, selector, stableRoot = "document.qu
append(events, { type, at: performance.now(), scrollX, scrollY, target: targetBox,
point, activeElement: name(document.activeElement) }, 160, 'eventLimit');
};
- const initial = observedNodes(target).slice(0, 2000).map(box);
+ // Retain pre-aim geometry even for zero-area boxes; eligibility for changes stays separate.
+ const initialNodes = [...document.body.querySelectorAll('*')].filter(node => node === target || !node.contains(target));
+ if (initialNodes.length > 2000) dropped.nodeLimit += initialNodes.length - 2000;
+ const initial = initialNodes.slice(0, 2000).map(box);
for (const entry of initial) prior.set(entry.node, entry);
/** Observe native pointer boundaries before the shared press rechecks its aimed point. */
const listener = event => sample(event.type, Number.isFinite(event.clientX)
@@ -1270,3 +1273,121 @@ test('a moved press target names a rendered-above box later in DOM order [N26,C7
rmSync(profile, { recursive: true, force: true });
}
});
+
+test('a zero-height box above a moved target keeps its old geometry [N26,C7]', {
+ timeout: 120_000, // budget: hang-only ceiling for real Chrome startup and one deterministic pointer-movement capture.
+}, async (t) => {
+ const executable = chromeExecutable();
+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for the moved-press capture.');
+
+ const box = machine();
+ project(box, 'moved-press-capture');
+ const view = await startView(box);
+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-moved-press-'));
+ let chrome;
+ try {
+ chrome = await openSnapshotChrome(executable, view.link.href, profile);
+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 375, height: 900, deviceScaleFactor: 1, mobile: false });
+ await chrome.waitFor("innerWidth === 375 && document.readyState === 'complete' && !!document.querySelector('#lanes')");
+ await chrome.stable(`(() => {
+ const standIn = document.createElement('div');
+ standIn.id = 'press-move-stand-in';
+ standIn.style.cssText = 'height:0px;background:#ddd;overflow-anchor:none';
+ const target = document.createElement('button');
+ target.id = 'press-move-target';
+ target.type = 'button';
+ target.textContent = 'Press target';
+ target.style.cssText = 'display:block;height:44px;overflow-anchor:auto';
+ const spacer = document.createElement('div');
+ spacer.style.cssText = 'height:1100px;overflow-anchor:none';
+ const group = document.createElement('div');
+ group.style.cssText = 'display:flex;flex-direction:column;overflow-anchor:auto';
+ standIn.style.order = '-1';
+ target.style.order = '0';
+ const below = Array.from({ length: 12 }, (_, index) => {
+ const node = document.createElement('div');
+ node.id = 'press-below-' + index;
+ node.style.cssText = 'height:0px;order:1;overflow-anchor:none';
+ return node;
+ });
+ group.append(target, standIn, ...below);
+ document.body.prepend(spacer, group);
+ let grew = false;
+ const growAboveTarget = event => {
+ if (!grew && event.target === target) {
+ grew = true;
+ standIn.style.height = '98px';
+ below.forEach(node => { node.style.height = '12px'; });
+ }
+ };
+ document.addEventListener('pointermove', growAboveTarget, true);
+ window.__pressMoveFixture = { grew: () => grew, cleanup() {
+ document.removeEventListener('pointermove', growAboveTarget, true);
+ spacer.remove(); group.remove(); delete window.__pressMoveFixture;
+ } };
+ return { standIn: standIn.id, target: target.id };
+ })()`);
+ const order = JSON.parse(await chrome.stable(`JSON.stringify((() => {
+ const above = document.querySelector('#press-move-stand-in');
+ const target = document.querySelector('#press-move-target');
+ const before = above.getBoundingClientRect();
+ return { above: before.bottom <= target.getBoundingClientRect().top,
+ later: Boolean(target.compareDocumentPosition(above) & Node.DOCUMENT_POSITION_FOLLOWING),
+ before: { top: before.top, documentTop: before.top + scrollY, height: before.height } };
+ })())`));
+ assert.deepEqual({ above: order.above, later: order.later, height: order.before.height }, { above: true, later: true, height: 0 },
+ 'the initially zero-height box is physically above the target but later in DOM order');
+ const captureSetup = await armLaneReleaseCapture(chrome, '#press-move-target', 'document.documentElement');
+ assert.equal(captureSetup.armed, true, `the named stand-in target is present before the shared press: ${JSON.stringify({ armed: captureSetup.armed, error: captureSetup.error ?? null })}`);
+ let pressError = null;
+ try { await press(chrome, "document.querySelector('#press-move-target')"); }
+ catch (error) { pressError = error; }
+ const capture = await finishLaneReleaseCapture(chrome, captureSetup);
+ const fixture = JSON.parse(await chrome.stable(`JSON.stringify({ grew: window.__pressMoveFixture?.grew() ?? false,
+ targetTop: document.querySelector('#press-move-target').getBoundingClientRect().top,
+ below: [...document.querySelectorAll('[id^="press-below-"]')].map(node => ({
+ top: node.getBoundingClientRect().top, height: node.getBoundingClientRect().height })) })`));
+ const changed = capture.page?.changedNodes ?? [];
+ const moved = changed.find(node => node.node?.id === 'press-move-stand-in');
+ const captureDetail = { capture, captureError: null };
+ if (pressError) includeLaneReleaseCapture(pressError, captureDetail);
+ const failureText = `${pressError?.message ?? 'shared press unexpectedly completed without an error'}; lane-release capture: ${JSON.stringify(captureDetail)}`;
+ assert.ok(fixture.grew, 'the stand-in box grows during the shared press pointer movement');
+ assert.ok(pressError, 'the unchanged shared press refuses the moved target instead of clicking it');
+ assert.equal(pressError.code, 'ERR_ASSERTION', `the shared press keeps its native assertion failure: ${pressError.message}`);
+ assert.match(pressError.message, /shared press: target stays under the pointer/,
+ `the refusal comes from the shared press geometry guard: ${pressError.message}`);
+ assert.equal(capture.pageError, null, `the page capture finishes without a probe error: ${failureText}`);
+ assert.equal(capture.page?.armed, true, `the capture returns its completed page observations: ${failureText}`);
+ assert.ok(moved, `the failure capture names the changed box and its old/new geometry: ${failureText}`);
+ assert.ok(moved.first, 'a box growing from zero above target retains old top/height: ' + failureText);
+ assert.deepEqual({ top: moved.first.top, documentTop: moved.first.documentTop, height: moved.first.height }, order.before,
+ 'old top and height are the actual measurements before aim');
+ assert.equal(moved.last.height, 98, 'the new height is the actual grown box');
+ assert.equal(fixture.below.length, 12);
+ assert.ok(fixture.below.every(box => box.height === 12 && box.top > fixture.targetTop),
+ 'twelve other zero-height boxes really grew below the target');
+ assert.ok(changed.every(entry => !entry.node.id.startsWith('press-below-')),
+ 'below-target changes cannot crowd the rendered-above diagnostic');
+ assert.equal(capture.page.truncated.remainingChangedNodes, 0, 'below-target growth does not consume the ten-detail allowance');
+ assert.equal(moved.first.id, 'press-move-stand-in', `the captured old box is the named stand-in: ${failureText}`);
+ assert.ok([moved.first.top, moved.first.height, moved.last.top, moved.last.height].every(Number.isFinite),
+ `the named box has finite old/new top and height measurements: ${failureText}`);
+ assert.notEqual(moved.first.height, moved.last.height, `the captured stand-in height changed: ${failureText}`);
+ assert.ok(capture.page.changedNodes.length <= 10 && Number.isInteger(capture.page.truncated.remainingChangedNodes),
+ `the failure capture caps box details at ten and counts the remainder: ${failureText}`);
+ assert.ok(Number.isFinite(capture.page.scrollY.before) && Number.isFinite(capture.page.scrollY.after),
+ `the failure capture records scroll positions even when flex layout moves the target without scrolling: ${failureText}`);
+ assert.match(pressError.message, /lane-release capture: .*press-move-stand-in.*scrollY.*before.*after/s,
+ `the failed press message carries the changed box and scroll positions: ${failureText}`);
+ assert.match(pressError.message, /remainingChangedNodes/, `the failure message reports the count of other changed boxes: ${failureText}`);
+ assert.ok(Object.hasOwn(capture.page, 'scrollAnchoring'), `the capture records whether Chromium reported an anchor: ${failureText}`);
+ } finally {
+ if (chrome) {
+ await chrome.stable('window.__pressMoveFixture?.cleanup()').catch(() => undefined);
+ await closeSnapshotChrome(chrome);
+ }
+ await view.stop();
+ rmSync(profile, { recursive: true, force: true });
+ }
+});