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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(view): guard stale reveal [H5,N26,N27]
Corey Olsonf1fe785cfea2
diff --git a/src/cockpit.js b/src/cockpit.jsindex 4c55d546..7d2a81d3 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -165,6 +165,7 @@ function homeTab() {return kept && kept !== 'roadmap' ? kept : 'items';}const view = { root: keep('pb.project'), tab: addressTab() || homeTab(), seen: {}, code: {}, item: null, adding: false, state: 'active', rows: { spec: 'decide', doctrine: 'all' }, row: { spec: null, doctrine: null } };+let switchGeneration = 0;if (snapshot) view.state = 'all';let data = null;let seen = '';@@ -1258,10 +1259,12 @@ function fold(open) {/** Show another project and its item; history restores keep the tab their entry named. */function switchTo(root, target = null, record = true) {+ const generation = ++switchGeneration;answer(null);view.root = root;const item = typeof target === 'number' ? target : /^item:(\\d+)$/.exec(target || '');- view.item = typeof item === 'number' ? item : item ? Number(item[1]) : null;+ const requestedItem = typeof item === 'number' ? item : item ? Number(item[1]) : null;+ view.item = requestedItem;view.adding = false;if (record && view.item !== null) { view.tab = 'items'; keep('pb.tab', view.tab); }keep('pb.project', root);@@ -1272,8 +1275,8 @@ function switchTo(root, target = null, record = true) {if (data) renderSide();document.body.classList.add('switching');refresh().catch(() => { $('live').textContent = 'offline: is pullboard view still running?'; }).finally(() => {- document.body.classList.remove('switching');- if (view.item !== null && view.root === root && view.tab === 'items') reveal();+ if (generation === switchGeneration) document.body.classList.remove('switching');+ if (generation === switchGeneration && requestedItem !== null && view.item === requestedItem && view.root === root && view.tab === 'items') reveal();});}diff --git a/test/cockpit.test.js b/test/cockpit.test.jsindex 9f99f85c..c4491537 100644--- a/test/cockpit.test.js+++ b/test/cockpit.test.js@@ -2901,6 +2901,11 @@ test('real Chrome keeps the demo board usable at phone and desktop widths [H5,N2const demo = project(box, 'phone-demo');const other = project(box, 'other-demo');box.run(demo.repo, 'add', 'web', 'Starter item', '--specs', 'G1', '--criterion', 'visible in the detail pane');+ box.run(other.repo, 'add', 'web', 'Other starter item', '--specs', 'G1', '--criterion', 'visible after a project switch');+ for (let n = 1; n <= 10; n += 1) {+ box.run(demo.repo, 'add', 'web', `Switch race filler ${n}`, '--specs', 'G1', '--criterion', 'keeps the narrow list below the viewport');+ box.run(other.repo, 'add', 'web', `Other switch race filler ${n}`, '--specs', 'G1', '--criterion', 'keeps the narrow list below the viewport');+ }const wrapTitle = 'word boundary test ' + 'abcdef0123456789'.repeat(12);box.run(demo.repo, 'add', 'web', wrapTitle, '--specs', 'G1', '--criterion', 'the activity title wraps without splitting words');box.run(demo.repo, 'shout', 'person', 'Should the phone demo ship?', '--decision');@@ -3121,6 +3126,71 @@ test('real Chrome keeps the demo board usable at phone and desktop widths [H5,N2await chrome.waitFor("!document.querySelector('#lanes [data-release=web]')");}+ await setViewport(375);+ await click('[data-tab="items"]');+ await chrome.waitFor("!!document.querySelector('#chain .row') && !document.body.classList.contains('switching')");+ await chrome.evaluate('window.scrollTo(0, 0)');+ await waitForStableBoxes(chrome, ['[data-pane="items"] aside.detail', '#new-item']);+ const detailTop = Number(await chrome.evaluate("document.querySelector('[data-pane=items] aside.detail').getBoundingClientRect().top"));+ assert.ok(detailTop > 900, `the real mobile detail starts below the viewport before selecting a row (${detailTop}px)`);+ const otherId = await boardId(view, other.repo);+ await chrome.evaluate(`(() => {+ const plain = fetch;+ let release;+ const hold = new Promise((resolve) => { release = resolve; });+ window.__releaseOtherState = release;+ window.__otherStateStarted = false;+ window.__otherStateFinished = false;+ window.__detailRevealCalls = [];+ const scrollIntoView = HTMLElement.prototype.scrollIntoView;+ /** Record actual detail reveals so the delayed-switch seam proves the callback occurred. */+ HTMLElement.prototype.scrollIntoView = function(...args) {+ const tracked = this.id === 'detail';+ const entry = tracked ? { at: performance.now(), root: view.root === ${JSON.stringify(other.repo)}, tab: view.tab, item: view.item, adding: view.adding, narrow: matchMedia('(max-width: 900px)').matches, before: { scrollY, rect: (() => { const r=this.getBoundingClientRect(); return {x:r.x,y:r.y,bottom:r.bottom}; })() }, args } : null;+ const result = scrollIntoView.apply(this, args);+ if (tracked) { entry.after = { scrollY, rect: (() => { const r=this.getBoundingClientRect(); return {x:r.x,y:r.y,bottom:r.bottom}; })() }; window.__detailRevealCalls.push(entry); }+ return result;+ };+ globalThis.fetch = (path, init) => {+ if (String(path).includes(${JSON.stringify('/api/v1/boards/' + otherId + '/state')})) {+ window.__otherStateStarted = true;+ return hold.then(() => plain(path, init)).then((response) => {+ window.__otherStateFinished = true;+ return response;+ });+ }+ return plain(path, init);+ };+ })()`);+ await chrome.evaluate(`switchTo(${JSON.stringify(other.repo)}, null)`);+ await chrome.waitFor(`window.__otherStateStarted && view.root === ${JSON.stringify(other.repo)}`);+ await click('#chain .row');+ await chrome.waitFor('view.item !== null');+ const send = chrome.send;+ let releaseOnMouseMove = true;+ const switchPointer = {};+ /** Release the delayed response after the helper samples the target but before its pointer move. */+ chrome.send = async (method, params) => {+ if (releaseOnMouseMove && method === 'Input.dispatchMouseEvent' && params.type === 'mouseMoved') {+ releaseOnMouseMove = false;+ switchPointer.before = JSON.parse(await chrome.evaluate(`JSON.stringify({root:view.root === ${JSON.stringify(other.repo)},tab:view.tab,scrollY,detailRevealCount:window.__detailRevealCalls.length,rect:(()=>{const r=document.querySelector('#new-item').getBoundingClientRect();return{x:r.x,y:r.y,bottom:r.bottom}})()})`));+ await chrome.evaluate('window.__releaseOtherState()');+ await chrome.waitFor('window.__otherStateFinished && !document.body.classList.contains("switching")');+ switchPointer.after = JSON.parse(await chrome.evaluate(`JSON.stringify({root:view.root === ${JSON.stringify(other.repo)},tab:view.tab,scrollY,detailRevealCount:window.__detailRevealCalls.length,rect:(()=>{const r=document.querySelector('#new-item').getBoundingClientRect();return{x:r.x,y:r.y,bottom:r.bottom}})()})`));+ }+ return send(method, params);+ };+ try {+ await click('#new-item');+ } finally {+ chrome.send = send;+ }+ await chrome.waitFor("document.querySelector('#proj-name').textContent === 'other-demo' && !document.body.classList.contains('switching')");+ assert.deepEqual(switchPointer.after, switchPointer.before,+ 'completing a null-target switch after pointer targeting cannot scroll the New item button');+ assert.equal(await chrome.evaluate("document.querySelector('#add-form').hidden"), false,+ 'a null-target project switch cannot scroll away a later New item click when its delayed response arrives');+await chrome.evaluate(`(() => {const probe = document.createElement('div');probe.dataset.scrollbarProof = '';