` : ''; };
+ // The organizations that answered and made every read a figure is built from. Only these count
+ // toward it: a failed read reaches the merge as an empty list, so its zero is not a figure.
+ const readers = (o, names) => new Set(o.rows.filter(r => r.state === 'ok' && !missOf(r, names)).map(r => r.org));
+ // Some organizations exist, and none of them could make these reads.
+ const noneRead = (o, names) => o.rows.length > 0 && !readers(o, names).size;
function failedPage(cls, attr, title, err) {
const why = err?.status === 403 ? 'This Console refused the read across organizations.' : err?.status === 0 ? 'You are signed out. Reload the page to sign in again.' : err?.status === 400 ? 'The read refused these filters. Clear them and try again.' : 'The read across organizations did not answer. The page tries again on its next refresh.';
return `
${title}
${why}
`;
@@ -450,21 +455,23 @@
catch (err) { return failedPage('ws-home', 'data-ws-home', 'Dashboard', err); }
const o = orgsOf(body), m = body.metrics, t = m?.totals, per = arr(m?.orgs);
const inbox = arr(body.inbox), sessions = arr(body.sessions), projectRows = arr(body.projects), tasks = arr(body.tasks);
- tellInbox(body.inbox);
- const parts = f => per.map(x => ({ id: x.org, n: num(f(x)) }));
+ if (!noneRead(o, ['inbox'])) tellInbox(body.inbox);
const sessN = s => num(s?.working) + num(s?.waiting) + num(s?.idle) + num(s?.live);
- const SRC = { needs: ['inbox'], sessions: ['agents', 'claims', 'threads'], tasks: ['tasks'], projects: ['projects'] };
+ // The reads each tile's figures come from (workspace-read.mjs orgRows).
+ const SRC = { needs: ['inbox'], sessions: ['agents', 'claims'], tasks: ['tasks'], projects: ['projects'] };
+ // Per-organization figures name only the organizations that made the tile's reads.
+ const parts = (key, f) => { const ok = readers(o, SRC[key]); return per.filter(x => ok.has(x.org)).map(x => ({ id: x.org, n: num(f(x)) })); };
const answered = o.rows.filter(r => r.state === 'ok').length;
const tile = (key, name, big, small, ps, delta) => {
const m = missed(o, SRC[key]);
- if (m.length && m.length === answered) return `
${org ? 'Nothing needs you in these organizations' : 'Nothing needs you'}
`;
+ const table = rows.length ? `
Items that need you
Source
Needs
Class
Waiting
${rows.map(row).join('')}
` : `
${noneRead(o, ['inbox']) ? 'Decisions not read' : org ? 'Nothing needs you in these organizations' : 'Nothing needs you'}
`;
let insp = '';
if (picked) {
const d = picked, id = esc(d.id);
@@ -658,7 +672,7 @@
`;
}
const orgsWith = new Set(rows.map(d => d.org)).size;
- const sub = rows.length ? `${plural(rows.length, 'item')} need${rows.length === 1 ? 's' : ''} you, from ${plural(orgsWith, 'organization')}. Each row names where it came from. An item leaves only when it is answered.` : `${missed(o, ['inbox']).length || o.unread.length ? 'Nothing needs you in the organizations that were read.' : 'Nothing needs you right now.'} An item leaves only when it is answered.`;
+ const sub = rows.length ? `${plural(rows.length, 'item')} need${rows.length === 1 ? 's' : ''} you, from ${plural(orgsWith, 'organization')}. Each row names where it came from. An item leaves only when it is answered.` : `${noneRead(o, ['inbox']) ? 'No organization\'s inbox could be read.' : missed(o, ['inbox']).length || o.unread.length ? 'Nothing needs you in the organizations that were read.' : 'Nothing needs you right now.'} An item leaves only when it is answered.`;
return `
Inbox
${sub}
diff --git a/packages/webui/tests/org-archive-browser.test.mjs b/packages/webui/tests/org-archive-browser.test.mjs
index 9f4960d10..6e51cf453 100644
--- a/packages/webui/tests/org-archive-browser.test.mjs
+++ b/packages/webui/tests/org-archive-browser.test.mjs
@@ -131,6 +131,7 @@ test('owner can start a down bus after setup recorded done and sees recovery gui
const f = await fixture(t);
await f.b.evaluate(`(()=>{const old=window.fetch;window.fetch=async (input,init={})=>{const u=String(input);if(u.endsWith('/setup') && (!init.method || init.method==='GET'))return new Response(JSON.stringify({notifications:{state:'done'},queue:{state:'done'},projects:[],bus:{state:'done',verb:'mosaic bus start alpha'}}),{status:200});if(u.endsWith('/setup/bus') && init.method==='POST')return new Response(JSON.stringify({error:'stale-lock',message:'stale bus host lock'}),{status:409});return old(input,init)}})()`);
await f.open('alpha');
+ // The setup steps render after the editor title, once the setup and organization list reads answer.
await f.wait(`!!document.querySelector('[data-step="bus"] [data-run="bus"]:not(:disabled)')`);
await f.b.evaluate(`document.querySelector('[data-step="bus"] [data-run="bus"]').click()`);
await f.wait(`document.querySelector('[data-step="bus"]').innerText.includes('stale bus host lock')`);
diff --git a/packages/webui/tests/workspace-pages-browser.test.mjs b/packages/webui/tests/workspace-pages-browser.test.mjs
index 28cf3f143..7073bde2d 100644
--- a/packages/webui/tests/workspace-pages-browser.test.mjs
+++ b/packages/webui/tests/workspace-pages-browser.test.mjs
@@ -14,7 +14,7 @@ const at = minutesAgo => new Date(Date.now() - minutesAgo * 60000).toISOString()
// acme and beta answer; gamma's bus is stopped. Decision ids are long so a shortened id would show.
const ACME_DECISION = 'dec-acme-7f3c9a21-5b8e-4d1f-9c2a-0e6b7d8f9a10';
const BETA_DECISION = 'dec-beta-1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d';
-function fixture({ pollMs, fail = {} } = {}) {
+function fixture({ pollMs, fail = {}, down = [] } = {}) {
const LIST = [
{ id: 'acme', label: 'Acme Studio', theme: 'cobalt', busHealthy: true },
{ id: 'beta', label: 'Beta Works', theme: 'grove', busHealthy: true },
@@ -48,7 +48,8 @@ function fixture({ pollMs, fail = {} } = {}) {
});
const member = org => ({
id: org.id, doc: { appearance: { theme: org.theme } },
- status: async () => (org.busHealthy ? { healthy: true, pid: 4242, boot: null } : { healthy: false, boot: { ok: false, at: at(90), lastGood: null, reason: 'stopped by the owner' } }),
+ // down: the cross-organization read finds these buses stopped; the page's own reads still answer.
+ status: async () => (org.busHealthy && !down.includes(org.id) ? { healthy: true, pid: 4242, boot: null } : { healthy: false, boot: { ok: false, at: at(90), lastGood: null, reason: 'stopped by the owner' } }),
options: () => opts(org.id),
});
return {
@@ -68,8 +69,8 @@ function fixture({ pollMs, fail = {} } = {}) {
};
}
-async function setup(t, { viewport = [1440, 900], hash = '/', workspaceTimeoutMs, fail } = {}) {
- const server = await startServer({ port: 0, sso: createDevOwner(), organizations: fixture({ fail }), log: () => {}, ...(workspaceTimeoutMs ? { workspaceTimeoutMs } : {}) });
+async function setup(t, { viewport = [1440, 900], hash = '/', workspaceTimeoutMs, fail, down } = {}) {
+ const server = await startServer({ port: 0, sso: createDevOwner(), organizations: fixture({ fail, down }), log: () => {}, ...(workspaceTimeoutMs ? { workspaceTimeoutMs } : {}) });
t.after(() => close(server));
const b = await browser({ machine: false }); t.after(() => b.close());
await b.viewport(...viewport);
@@ -308,3 +309,60 @@ test('When every answering organization failed a read, its tile says Not read in
assert.match(await text('[data-ws-tile=projects]'), /Not read/i);
assert.equal(await text('[data-ws-tile=projects] .ws-big'), null);
});
+
+// Review P2 (org-u3): a project row's figures come from reads beyond the project list.
+test('Project rows and per-organization figures say not read when the reads behind them failed', async t => {
+ const { b, wait, text } = await setup(t, { fail: { beta: ['inbox', 'tasks', 'agents', 'claims', 'threads'] }, hash: '/projects' });
+ await wait('document.querySelector("[data-ws-project=\'beta:p-shop\']")');
+ const cells = await b.evaluate(`[...document.querySelector("[data-ws-project='beta:p-shop']").cells].map(c => c.innerText.trim())`);
+ // Grouped columns: Project, Status, Sessions, Open tasks, Needs you, Last activity, Git.
+ assert.deepEqual(cells.slice(2, 5), ['not read', 'not read', 'not read'], 'sessions, open tasks and needs you');
+ assert.match(cells[5], /some reads missing/);
+ const acme = await b.evaluate(`[...document.querySelector("[data-ws-project='acme:p-site']").cells].map(c => c.innerText.trim())`);
+ assert.equal(acme[3], '1'); assert.equal(acme[4], '1');
+ assert.match(await text('[data-ws-miss=figures]'), /Some figures not read in Beta Works/);
+ // Dashboard: the per-organization figures leave Beta out instead of showing its 0.
+ await b.evaluate('location.hash = "#/orgs/acme/"');
+ await wait('document.querySelector("[data-ws-tiles]")');
+ for (const tile of ['needs', 'sessions', 'tasks']) {
+ const by = await b.evaluate(`document.querySelector('[data-ws-tile=${tile}] .ws-by')?.textContent ?? ''`);
+ assert.doesNotMatch(by, /Beta Works/, tile);
+ assert.match(await text(`[data-ws-tile=${tile}] [data-ws-miss=${tile}]`), /Not read in Beta Works/, tile);
+ }
+ assert.doesNotMatch(await b.evaluate(`[...document.querySelectorAll('[data-ws-states] .ws-srow')].find(r => /Done this week/.test(r.textContent))?.querySelector('.ws-by')?.textContent ?? ''`), /Beta Works/);
+});
+
+test('With every organization down the dashboard and inbox show no totals and no empty-list claims', async t => {
+ const { b, wait, text } = await setup(t, { down: ['acme', 'beta'] });
+ await wait('document.querySelector("[data-ws-tiles]")');
+ assert.equal(await b.evaluate('document.querySelectorAll("[data-ws-home] .ws-big").length'), 0);
+ assert.match(await text('[data-ws-tiles]'), /No organization answered/);
+ assert.equal(await text('[data-ws-needs]'), 'Decisions not read');
+ assert.equal(await text('[data-ws-states]'), 'Tasks not read');
+ assert.equal(await text('[data-ws-recent]'), 'Projects not read');
+ assert.equal(await text('[data-ws-sessions]'), 'Sessions not read');
+ await b.evaluate('location.hash = "#/orgs/acme/inbox"');
+ await wait('document.querySelector("[data-ws-items]")');
+ assert.equal(await text('[data-ws-items]'), 'Decisions not read');
+ await b.evaluate('location.hash = "#/orgs/acme/projects?grouping=flat"');
+ await wait('document.querySelector("[data-ws-table]")');
+ await b.evaluate('document.querySelector("[data-ws-group=flat]").click()');
+ await wait('document.querySelector("[data-ws-table][data-grouping=flat]")');
+ assert.match(await text('[data-ws-table] tbody'), /Projects not read/);
+});
+
+test('When no organization could read its tasks, Tasks by state shows no Done this week figure', async t => {
+ const { wait, text } = await setup(t, { fail: { acme: ['tasks'], beta: ['tasks'] } });
+ await wait('document.querySelector("[data-ws-states]")');
+ assert.equal(await text('[data-ws-states]'), 'Tasks not read');
+ assert.match(await text('[data-ws-tile=tasks]'), /Not read/);
+});
+
+// Review P3: the session's organization is in the accessible text, not only in the hidden avatar.
+test('Sessions now names each session\'s organization for a screen reader', async t => {
+ const { b, wait } = await setup(t);
+ await wait('document.querySelector("[data-ws-sessions] td.who")');
+ const who = await b.evaluate('[...document.querySelectorAll("[data-ws-sessions] td.who")].map(c => c.textContent)');
+ assert.ok(who.some(w => /Acme Studio: coder/.test(w)), who.join('|'));
+ assert.ok(who.some(w => /Beta Works: pm/.test(w)), who.join('|'));
+});