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): a dropped item read loads again on its own [N26]

Corey Olsonbe7fefeac733
diff --git a/src/cockpit.js b/src/cockpit.js
index 41a29fb8..5f2b8138 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -1576,14 +1576,15 @@ function detailOf(project, item, ask, root = view.root) {
/** Keep the prior detail visible during a refresh, or return the short initial loading state. */
const waiting = (entry) => (entry?.shown ? { item: { ...item, ...entry.shown } } : { loading: true });
if (kept?.loading) return waiting(kept);
- if (kept && kept.summary === summary && !movedSince(project, item.id, kept.cursor)) {
+ if (kept && kept.summary === summary && !movedSince(project, item.id, kept.cursor) && !(ask && kept.error && Date.now() - kept.failedAt >= 2_500)) {
return kept.error ? { error: kept.error } : { item: { ...item, ...kept.detail } };
}
if (!ask) return waiting(kept && { shown: kept.detail });
const entry = { loading: true, summary, cursor: project.events?.[0]?.event_id ?? 0, detail: null, error: null, shown: kept?.detail ?? null };
itemDetails.set(key, entry);
detailRead = api(boardPath(root) + '/items/' + encodeURIComponent(String(item.id))).then((reply) => { entry.detail = reply.item; },
- (error) => { entry.error = String(error.message || error); }).finally(() => {
+ // A failed read is not the answer: while this item stays open it reads again in 3 s, so a dropped request recovers (#908).
+ (error) => { entry.error = String(error.message || error); entry.failedAt = Date.now(); setTimeout(() => { if (view.root === drawnRoot && view.item === item.id) render(); }, 3_000); }).finally(() => {
entry.loading = false;
if (view.root === drawnRoot && ((root === view.root && view.item === item.id) || view.tab === 'roadmap')) render();
});
diff --git a/test/cockpit/local-origin.test.js b/test/cockpit/local-origin.test.js
index 5383157e..9c0e4ffa 100644
--- a/test/cockpit/local-origin.test.js
+++ b/test/cockpit/local-origin.test.js
@@ -1051,3 +1051,40 @@ test('the page tells its transport when the board drew, and today\'s transport n
finally { rmSync(profile, { recursive: true, force: true }); }
}
});
+
+test('an item whose detail read is dropped once loads on its own [N26]', { timeout: 90_000 }, async () => { // budget: hang ceiling for one view, one Chrome and a retried read.
+ const executable = chromeExecutable();
+ assert.ok(executable, 'the detail retry check needs real Chrome');
+ const box = machine();
+ const board = project(box, 'detail-retry');
+ box.run(board.repo, 'add', 'web', 'An item whose first read is dropped', '--specs', 'G1');
+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-detail-retry-'));
+ let view, chrome, listener;
+ const reads = [];
+ try {
+ view = await startView(box);
+ chrome = await openSnapshotChrome(executable, 'about:blank', profile);
+ // The first read of the item's detail fails at the network, as CI's 'Failed to fetch' did (#908); later ones go through.
+ listener = ({ data }) => {
+ const message = JSON.parse(String(data));
+ if (message.method !== 'Fetch.requestPaused') return;
+ const { requestId, request } = message.params;
+ reads.push(request.url);
+ const send = reads.length === 1 ? chrome.send('Fetch.failRequest', { requestId, errorReason: 'Failed' }) : chrome.send('Fetch.continueRequest', { requestId });
+ send.catch(() => { /* the page may have moved on */ });
+ };
+ chrome.socket.addEventListener('message', listener);
+ await chrome.send('Fetch.enable', { patterns: [{ urlPattern: view.base + '/api/v1/boards/*/items/1*', requestStage: 'Request' }] });
+ await chrome.send('Page.navigate', { url: view.link.href + '#/items/1' });
+ await chrome.waitFor("document.querySelector('#detail')?.textContent.includes('Could not load #1')", 30_000); // budget: hang ceiling for the first, dropped read.
+ await chrome.waitFor("document.querySelectorAll('#detail button[data-shout], #detail button[data-new]').length === 2", 30_000); // budget: hang ceiling for the page's own retry 3 s later.
+ assert.ok(reads.length >= 2, 'the page read the item again after the dropped read');
+ assert.doesNotMatch(await chrome.stable("document.querySelector('#detail').textContent"), /Could not load/u, 'the failure no longer shows');
+ } finally {
+ try { if (chrome) { if (listener) chrome.socket.removeEventListener('message', listener); await closeSnapshotChrome(chrome); } }
+ finally {
+ try { if (view) await view.stop(); }
+ finally { rmSync(profile, { recursive: true, force: true }); }
+ }
+ }
+});