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 loading switch marks no shouts for the next project [N26]

Corey Olsonfaf4234ee8a3
diff --git a/src/cockpit.js b/src/cockpit.js
index a00bee0e..5b00ca18 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -531,6 +531,8 @@ async function refresh() {
keep('pb.project', view.root);
return refresh();
}
+ // The project this board is, so a switch still loading never reads it as the next one's.
+ next.root = root;
// Rebuild only when the board changed: a list rebuilt under the pointer can swallow a click.
const text = JSON.stringify(next);
if (text !== seen) {
@@ -705,7 +707,8 @@ function showTab() {
*/
function countUnseen() {
const p = data && data.project;
- if (!p) return;
+ // While a switch loads, the board on hand is the last project's: it marks nothing for this one.
+ if (!p || data.root !== view.root) return;
const key = 'pb.seen.' + view.root;
const kept = view.seen[key] ?? keep(key);
const newest = p.shouts.length ? p.shouts[0].shout_id : 0;
diff --git a/test/cockpit.test.js b/test/cockpit.test.js
index 530e6678..d9ecb106 100644
--- a/test/cockpit.test.js
+++ b/test/cockpit.test.js
@@ -905,6 +905,20 @@ test('the shouts tab counts shouts you have not seen [N26]', async () => {
assert.equal(count(again), '');
await again.click({ root: alpha.repo, classes: 'proj side' });
assert.equal(count(again), '41');
+
+ // A switch to beta that is slow to arrive: tabs clicked meanwhile must not mark alpha's shouts as
+ // beta's, or beta's next shout would never count.
+ const racing = await openPage(view, { store });
+ racing.run(`const plain = fetch; globalThis.fetch = (path, init) => path.includes(${JSON.stringify(encodeURIComponent(beta.repo))}) ? new Promise((done) => setTimeout(done, 300)).then(() => plain(path, init)) : plain(path, init);`);
+ racing.run(`switchTo(${JSON.stringify(beta.repo)})`);
+ await racing.click({ tab: 'shouts' });
+ await racing.click({ tab: 'items' });
+ await new Promise((done) => setTimeout(done, 600));
+ await racing.run('refresh()');
+ assert.equal(racing.element('proj-name').textContent, 'beta');
+ box.run(beta.repo, 'shout', 'web', 'beta moves on');
+ await racing.run('refresh()');
+ assert.equal(count(racing), '1', 'the shout that came after counts');
} finally {
await view.stop();
}