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): the decline dialog never moves under the pointer [B26,N26]

Corey Olson980100c9dcb8
diff --git a/src/cockpit.js b/src/cockpit.js
index 41a29fb8..4d5317d8 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -31,6 +31,8 @@ import {
roadmapSummary,
} from './view/roadmap-summary.js';
import { roadmapBlock } from './view/roadmap-block.js';
+import { openPageDialog } from './view/page-dialog.js';
+import { closePageDialog } from './view/page-dialog.js';
import { applyStateDelta } from './api-http.js';
/** The CLI's default phrases, ordered by depth for the existing prose inventory guard. */
@@ -323,7 +325,7 @@ let data = null;
let seen = '';
let addressReady = false;
let heldClickPointer = null;
-let deferredClickRender = false;
+let deferredClickRender = false; const pageDialogs = new Set(); // open page dialogs; the page holds its redraws while one is open
// Detail replies stay with an unchanged summary, while search results are keyed by board and words.
const itemDetails = new Map();
const itemSearches = new Map();
@@ -613,6 +615,7 @@ const chip = (s) => '<span class="chip ' + STATES[s][1] + '">' + STATES[s][0] +
const staleChip = (${staleChip.toString()});
// A roadmap item's blocker dot and unfolded reason from src/view/roadmap-block.js (#605), read from the summaries held.
const roadmapBlock = (${roadmapBlock.toString()});
+const openPageDialog = (${openPageDialog.toString()}), closePageDialog = (${closePageDialog.toString()});
/** Parse the bounded reference syntax before requesting additional committed line windows. */
function codeReferenceParts(ref) {
const match = /^(.+):(\\d+)(?:-(\\d+))?@([0-9a-f]{7,40})$/.exec(String(ref));
@@ -2477,7 +2480,7 @@ function renderReleaseNotes(project) {
function render() {
// A refresh that moved the page to another board closes a confirmation opened on the last one.
closeIfLeft();
- if (heldClickPointer !== null) { deferredClickRender = true; return; }
+ if (heldClickPointer !== null || pageDialogs.size) { deferredClickRender = true; return; }
deferredClickRender = false;
const statsFocus = document.activeElement?.id === 'proof-stats-summary' ? document.activeElement.id : null;
const p = data.project;
@@ -3401,15 +3404,12 @@ function leaveDialogs() {
* cannot act on the page, or switch the board, under a question the page is asking.
*/
function openModal(dialog, focus) {
- dialog.hidden = false;
- for (const element of document.body.children || []) if (element !== dialog && element.tagName !== 'SCRIPT') element.inert = true;
- focus.focus();
+ openPageDialog(dialog, focus, pageDialogs);
}
/** Hide a page dialog and give the page back its clicks and focus. */
function closeModal(dialog) {
- dialog.hidden = true;
- for (const element of document.body.children || []) element.inert = false;
+ if (closePageDialog(dialog, pageDialogs) && deferredClickRender) requestAnimationFrame(() => { if (!pageDialogs.size && heldClickPointer === null && deferredClickRender) { deferredClickRender = false; render(); } });
}
/** Keep Tab and Shift+Tab cycling through an open page dialog's own controls. */
diff --git a/src/view/page-dialog.js b/src/view/page-dialog.js
new file mode 100644
index 00000000..93818077
--- /dev/null
+++ b/src/view/page-dialog.js
@@ -0,0 +1,35 @@
+/**
+ * A page dialog shows over an inert page: nothing behind it takes a click or focus while it is open. The page
+ * also does not redraw while one is open (#668): a redraw can shorten the page and clamp its scroll under the
+ * dialog, which moves the control the person is aiming at. The functions are copied into the page as text, so
+ * they stay self-contained and take their state as arguments.
+ */
+
+/**
+ * Show a page dialog and mark it open, so the page holds its redraws until it closes.
+ *
+ * @param {HTMLElement} dialog the dialog to show
+ * @param {HTMLElement} focus the control that takes focus first
+ * @param {Set<HTMLElement>} open the page's open dialogs
+ */
+export function openPageDialog(dialog, focus, open) {
+ dialog.hidden = false;
+ open.add(dialog);
+ for (const element of document.body.children || []) if (element !== dialog && element.tagName !== 'SCRIPT') element.inert = true;
+ focus.focus();
+}
+
+/**
+ * Hide a page dialog, give the page back its clicks and focus, and report whether any dialog is still open.
+ * The caller draws the held page only when none is, so a closing dialog never draws over another one.
+ *
+ * @param {HTMLElement} dialog the dialog to hide
+ * @param {Set<HTMLElement>} open the page's open dialogs
+ * @returns {boolean} true when no page dialog is open any more
+ */
+export function closePageDialog(dialog, open) {
+ dialog.hidden = true;
+ open.delete(dialog);
+ for (const element of document.body.children || []) element.inert = false;
+ return open.size === 0;
+}
diff --git a/test/cockpit/spec.test.js b/test/cockpit/spec.test.js
index e50c19e0..f7fae9d9 100644
--- a/test/cockpit/spec.test.js
+++ b/test/cockpit/spec.test.js
@@ -1167,3 +1167,59 @@ test('doctrine and spec rows share the items row [N26]', { timeout: 300_000 }, a
}
}
});
+
+/** The decline dialog's submit button keeps its place while the dialog is open, even when an approval note times out under it. */
+test('the decline dialog never moves under the pointer [B26,N26]', { timeout: 120_000 }, async (t) => {
+ const executable = chromeExecutable();
+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME to check the decline dialog.');
+
+ // A long list at a phone width: the page ends below the detail, so removing a note above it clamps the page's scroll.
+ const rows = Array.from({ length: 24 }, (_, index) => `- G${index + 1} [draft, must] Row ${index + 1} keeps its wording. | gate: review`);
+ const spec = '# Decline stability\n\n## G · Goals\n' + rows.join('\n') + '\n';
+ const box = machine();
+ project(box, 'decline-stable', spec);
+ const view = await startView(box);
+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-decline-stable-chrome-'));
+ let chrome;
+ /** One key press, as the keyboard sends it to the focused list. */
+ const pressKey = async (key, code, keyCode) => {
+ for (const type of ['keyDown', 'keyUp']) await chrome.send('Input.dispatchKeyEvent', { type, key, code, windowsVirtualKeyCode: keyCode, ...(type === 'keyDown' && key.length === 1 ? { text: key, unmodifiedText: key } : {}) });
+ };
+ /** The page's scroll and the decline dialog's submit button's box, read in one step. */
+ const measure = async () => JSON.parse(await chrome.stable(`JSON.stringify((() => {
+ const r = document.querySelector('#spec-decline-submit').getBoundingClientRect();
+ return { y: scrollY, box: [r.x, r.y, r.width, r.height] };
+ })())`));
+ 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');
+ await chrome.waitFor('data?.project?.spec?.length === 24');
+ await chrome.click("document.querySelector('[data-tab=spec]')");
+ await chrome.click("document.querySelector('#spec-chips [data-rows=\"spec:all\"]')");
+ await chrome.waitFor("!!document.querySelector('#spec-list [data-row=\"spec:G2\"]')");
+ // Approving G1 from the list leaves a note in the list for six seconds; the decline for the next row opens inside that window.
+ await chrome.click("document.querySelector('#spec-list [data-row=\"spec:G1\"]')");
+ await chrome.stable("document.querySelector('#spec-list').focus();true");
+ await pressKey('a', 'KeyA', 65);
+ await chrome.waitFor("!!document.querySelector('#spec-list .spec-feedback.ok')");
+ await chrome.stable('window.scrollTo(0, document.documentElement.scrollHeight);true');
+ await pressKey('d', 'KeyD', 68);
+ await chrome.waitFor("!document.querySelector('#spec-decline-dialog').hidden && document.querySelector('#spec-decline-title').textContent === 'Decline G2'");
+ assert.equal(await chrome.stable("!!document.querySelector('#spec-list .spec-feedback.ok')"), true, 'the approval note is still in the list when the dialog opens');
+ await chrome.send('Input.insertText', { text: 'a reason' });
+ const opened = await measure();
+
+ // The note's six-second timer fires while the dialog is open. Its own state clears; the page must not redraw.
+ await new Promise((resolve) => setTimeout(resolve, 7000)); // budget: the note's six-second timer, plus a second of slack
+ assert.equal(await chrome.stable('view.specFeedback === null'), true, 'the approval note timed out while the dialog was open');
+ assert.deepEqual(await measure(), opened, 'nothing moves while the dialog waits for its press');
+
+ // The press itself: record the page and the button at pointer down, then press with the real mouse.
+ await chrome.stable("window.__pressAt = null; document.addEventListener('pointerdown', (event) => { if (event.target.closest('#spec-decline-submit')) window.__pressAt = JSON.stringify({ y: scrollY, box: (() => { const r = document.querySelector('#spec-decline-submit').getBoundingClientRect(); return [r.x, r.y, r.width, r.height]; })() }); }, { capture: true });true");
+ await press(chrome, "document.querySelector('#spec-decline-submit')");
+ const pressed = JSON.parse(await chrome.stable('window.__pressAt'));
+ assert.deepEqual(pressed, opened, 'the page and the submit button are where the person aimed when the press lands');
+ assert.deepEqual(chrome.exceptions, []);
+ } finally { if (chrome) await closeSnapshotChrome(chrome); rmSync(profile, { recursive: true, force: true }); await view.stop(); }
+});