fix(webui): U3 review fixes, figures from failed reads say not read (#1873)
A project row's sessions, open tasks and needs-you figures come from reads beyond the project list; when those failed in the row's organization the cells now say not read instead of none or 0, and a note names the organization. Dashboard per-organization figures and Done this week count only organizations that made the tile's reads, a dashboard with no answering organization shows no totals, and empty lists say not read when no organization could make the read. Sessions now names each session's organization for screen readers. The org-archive test waits for the setup steps, which render after the editor title.
This commit is contained in:
1 parent
68fd66903b
commit
aa087e7380
3 files changed
+102
-29
No files matched your search
@@ -427,7 +427,12 @@
|
|||||||
const READ_WHY = { 'channel-disabled': 'the chat channel is off', 'outcome-unknown': 'no answer', timeout: 'no answer in time' };
|
const READ_WHY = { 'channel-disabled': 'the chat channel is off', 'outcome-unknown': 'no answer', timeout: 'no answer in time' };
|
||||||
const missOf = (r, names) => { const n = r?.state === 'ok' && r.errors ? names.find(x => r.errors[x]) : null; return n ? READ_WHY[r.errors[n]] || String(r.errors[n]) : null; };
|
const missOf = (r, names) => { const n = r?.state === 'ok' && r.errors ? names.find(x => r.errors[x]) : null; return n ? READ_WHY[r.errors[n]] || String(r.errors[n]) : null; };
|
||||||
const missed = (o, names) => o.rows.filter(r => missOf(r, names)).map(r => `${esc(o.name(r.org))} (${esc(missOf(r, names))})`);
|
const missed = (o, names) => o.rows.filter(r => missOf(r, names)).map(r => `${esc(o.name(r.org))} (${esc(missOf(r, names))})`);
|
||||||
const missLine = (o, names, key) => { const m = missed(o, names); return m.length ? `<p class="note ws-miss" data-ws-miss="${key}">Not read in ${andList(m)}.</p>` : ''; };
|
const missLine = (o, names, key, lead = 'Not read in') => { const m = missed(o, names); return m.length ? `<p class="note ws-miss" data-ws-miss="${key}">${lead} ${andList(m)}.</p>` : ''; };
|
||||||
|
// 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) {
|
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.';
|
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 `<section class="ws ${cls}" ${attr} data-ws-failed><div class="ws-vh"><h1 tabindex="-1">${title}</h1><p class="sub">${why}</p></div></section>`;
|
return `<section class="ws ${cls}" ${attr} data-ws-failed><div class="ws-vh"><h1 tabindex="-1">${title}</h1><p class="sub">${why}</p></div></section>`;
|
||||||
@@ -450,21 +455,23 @@
|
|||||||
catch (err) { return failedPage('ws-home', 'data-ws-home', 'Dashboard', err); }
|
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 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);
|
const inbox = arr(body.inbox), sessions = arr(body.sessions), projectRows = arr(body.projects), tasks = arr(body.tasks);
|
||||||
tellInbox(body.inbox);
|
if (!noneRead(o, ['inbox'])) tellInbox(body.inbox);
|
||||||
const parts = f => per.map(x => ({ id: x.org, n: num(f(x)) }));
|
|
||||||
const sessN = s => num(s?.working) + num(s?.waiting) + num(s?.idle) + num(s?.live);
|
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 answered = o.rows.filter(r => r.state === 'ok').length;
|
||||||
const tile = (key, name, big, small, ps, delta) => {
|
const tile = (key, name, big, small, ps, delta) => {
|
||||||
const m = missed(o, SRC[key]);
|
const m = missed(o, SRC[key]);
|
||||||
if (m.length && m.length === answered) return `<div class="ws-tile quiet" data-ws-tile="${key}" data-ws-miss="${key}"><span class="ws-label">${name}</span><span class="ws-empty-t">Not read</span><span class="ws-delta">${andList(m)}</span></div>`;
|
if (!readers(o, SRC[key]).size) return `<div class="ws-tile quiet" data-ws-tile="${key}" data-ws-miss="${key}"><span class="ws-label">${name}</span><span class="ws-empty-t">Not read</span><span class="ws-delta">${andList(m)}</span></div>`;
|
||||||
return `<div class="ws-tile" data-ws-tile="${key}"><span class="ws-label">${name}</span><span class="ws-big">${big}${small ? `<small>${small}</small>` : ''}</span>${ps ? bar(o, ps) + by(o, ps) : ''}<span class="ws-delta">${delta}</span>${m.length ? `<span class="ws-delta ws-miss" data-ws-miss="${key}">Not read in ${andList(m)}</span>` : ''}</div>`;
|
return `<div class="ws-tile" data-ws-tile="${key}"><span class="ws-label">${name}</span><span class="ws-big">${big}${small ? `<small>${small}</small>` : ''}</span>${ps ? bar(o, ps) + by(o, ps) : ''}<span class="ws-delta">${delta}</span>${m.length ? `<span class="ws-delta ws-miss" data-ws-miss="${key}">Not read in ${andList(m)}</span>` : ''}</div>`;
|
||||||
};
|
};
|
||||||
const tiles = t ? `<div class="ws-g5 keep2" data-ws-tiles>
|
const tiles = t && answered ? `<div class="ws-g5 keep2" data-ws-tiles>
|
||||||
${tile('needs', 'Needs you', num(t.needsYou), t.needsYou === 1 ? 'item' : 'items', parts(x => x.needsYou), t.oldestNeedsYouAt ? `oldest ${span(t.oldestNeedsYouAt)}` : 'nothing waiting')}
|
${tile('needs', 'Needs you', num(t.needsYou), t.needsYou === 1 ? 'item' : 'items', parts('needs', x => x.needsYou), t.oldestNeedsYouAt ? `oldest ${span(t.oldestNeedsYouAt)}` : 'nothing waiting')}
|
||||||
${tile('sessions', 'Sessions', sessN(t.sessions), `${num(t.sessions?.working)} working`, parts(x => sessN(x.sessions)), `${num(t.sessions?.waiting)} waiting on you · ${num(t.sessions?.idle)} idle${num(t.sessions?.live) ? ` · ${num(t.sessions.live)} live ${t.sessions.live === 1 ? 'thread' : 'threads'}` : ''}`)}
|
${tile('sessions', 'Sessions', sessN(t.sessions), `${num(t.sessions?.working)} working`, parts('sessions', x => sessN(x.sessions)), `${num(t.sessions?.waiting)} waiting on you · ${num(t.sessions?.idle)} idle${num(t.sessions?.live) ? ` · ${num(t.sessions.live)} live ${t.sessions.live === 1 ? 'thread' : 'threads'}` : ''}`)}
|
||||||
${tile('tasks', 'Open tasks', num(t.openTasks), '', parts(x => x.openTasks), `<b>${num(t.doneThisWeek)}</b> done this week`)}
|
${tile('tasks', 'Open tasks', num(t.openTasks), '', parts('tasks', x => x.openTasks), `<b>${num(t.doneThisWeek)}</b> done this week`)}
|
||||||
${tile('projects', 'Projects', num(t.projects?.active) + num(t.projects?.archived), `${num(t.projects?.active)} active`, parts(x => num(x.projects?.active) + num(x.projects?.archived)), `${num(t.projects?.archived)} archived`)}
|
${tile('projects', 'Projects', num(t.projects?.active) + num(t.projects?.archived), `${num(t.projects?.active)} active`, parts('projects', x => num(x.projects?.active) + num(x.projects?.archived)), `${num(t.projects?.archived)} archived`)}
|
||||||
<div class="ws-tile quiet" data-ws-tile="spend"><span class="ws-label">Model spend</span><span class="ws-empty-t">No spend figures yet</span><span class="ws-delta">No read prices model use today.</span></div>
|
<div class="ws-tile quiet" data-ws-tile="spend"><span class="ws-label">Model spend</span><span class="ws-empty-t">No spend figures yet</span><span class="ws-delta">No read prices model use today.</span></div>
|
||||||
</div>` : '<p class="ws-panel tight note" data-ws-tiles>No organization answered, so there are no totals yet.</p>';
|
</div>` : '<p class="ws-panel tight note" data-ws-tiles>No organization answered, so there are no totals yet.</p>';
|
||||||
|
|
||||||
@@ -476,25 +483,26 @@
|
|||||||
|
|
||||||
const recent = projectRows.filter(p => p.lastActivity).slice(0, 6);
|
const recent = projectRows.filter(p => p.lastActivity).slice(0, 6);
|
||||||
const STATE_WORD = { working: 'has a session working', waiting: 'is waiting on you', idle: 'has an idle session', none: 'no live session' };
|
const STATE_WORD = { working: 'has a session working', waiting: 'is waiting on you', idle: 'has an idle session', none: 'no live session' };
|
||||||
const trail = recent.length ? `<ol class="ws-trail" data-ws-recent>${recent.map(p => `<li class="ws-o" style="${o.style(p.org)}"><time datetime="${esc(p.lastActivity)}">${esc(when(p.lastActivity))}</time>${av(o.meta(p.org))}<span class="what"><a href="${esc(orgHref(p.org))}/projects/${enc(p.id)}" data-focus-key="${esc(`recent:${p.org}:${p.id}`)}"><b>${esc(p.name || p.key || p.id)}</b></a> ${STATE_WORD[p.state] || ''}${p.needsYou ? `, ${plural(p.needsYou, 'item')} for you` : ''} <span class="src">· ${esc(o.name(p.org))}</span></span></li>`).join('')}</ol>` : '<p class="ws-panel tight note" data-ws-recent>No project activity yet</p>';
|
const trail = recent.length ? `<ol class="ws-trail" data-ws-recent>${recent.map(p => `<li class="ws-o" style="${o.style(p.org)}"><time datetime="${esc(p.lastActivity)}">${esc(when(p.lastActivity))}</time>${av(o.meta(p.org))}<span class="what"><a href="${esc(orgHref(p.org))}/projects/${enc(p.id)}" data-focus-key="${esc(`recent:${p.org}:${p.id}`)}"><b>${esc(p.name || p.key || p.id)}</b></a> ${STATE_WORD[p.state] || ''}${p.needsYou ? `, ${plural(p.needsYou, 'item')} for you` : ''} <span class="src">· ${esc(o.name(p.org))}</span></span></li>`).join('')}</ol>` : `<p class="ws-panel tight note" data-ws-recent>${noneRead(o, ['projects']) ? 'Projects not read' : 'No project activity yet'}</p>`;
|
||||||
|
|
||||||
const open = tasks.filter(x => !x.done);
|
const open = tasks.filter(x => !x.done);
|
||||||
const buckets = new Map();
|
const buckets = new Map();
|
||||||
for (const x of open) { const b = typeof x.bucket === 'string' && x.bucket ? x.bucket : ''; if (!buckets.has(b)) buckets.set(b, new Map()); const g = buckets.get(b); g.set(x.org, (g.get(x.org) || 0) + 1); }
|
for (const x of open) { const b = typeof x.bucket === 'string' && x.bucket ? x.bucket : ''; if (!buckets.has(b)) buckets.set(b, new Map()); const g = buckets.get(b); g.set(x.org, (g.get(x.org) || 0) + 1); }
|
||||||
const srows = [...buckets.entries()].map(([b, g]) => ({ name: b ? titleCase(b) : 'No bucket', g, n: [...g.values()].reduce((a, c) => a + c, 0) })).sort((a, b) => b.n - a.n);
|
const srows = [...buckets.entries()].map(([b, g]) => ({ name: b ? titleCase(b) : 'No bucket', g, n: [...g.values()].reduce((a, c) => a + c, 0) })).sort((a, b) => b.n - a.n);
|
||||||
if (t) srows.push({ name: 'Done this week', g: new Map(per.map(x => [x.org, num(x.doneThisWeek)])), n: num(t.doneThisWeek) });
|
const taskOrgs = readers(o, ['tasks']);
|
||||||
|
if (t && taskOrgs.size) srows.push({ name: 'Done this week', g: new Map(per.filter(x => taskOrgs.has(x.org)).map(x => [x.org, num(x.doneThisWeek)])), n: num(t.doneThisWeek) });
|
||||||
const max = Math.max(1, ...srows.map(s => s.n));
|
const max = Math.max(1, ...srows.map(s => s.n));
|
||||||
const states = srows.length ? `<div class="ws-panel tight ws-states" data-ws-states>${srows.map(s => { const ps = [...s.g.entries()].filter(([, n]) => n > 0).map(([id, n]) => ({ id, n })); return `<div class="ws-srow"><span class="sl">${esc(s.name)}</span><span class="sn">${s.n}</span>${bar(o, ps, `width:${Math.max(4, Math.round((s.n / max) * 90))}%`)}${by(o, ps)}</div>`; }).join('')}</div>` : '<p class="ws-panel tight note" data-ws-states>No open tasks</p>';
|
const states = srows.length ? `<div class="ws-panel tight ws-states" data-ws-states>${srows.map(s => { const ps = [...s.g.entries()].filter(([, n]) => n > 0).map(([id, n]) => ({ id, n })); return `<div class="ws-srow"><span class="sl">${esc(s.name)}</span><span class="sn">${s.n}</span>${bar(o, ps, `width:${Math.max(4, Math.round((s.n / max) * 90))}%`)}${by(o, ps)}</div>`; }).join('')}</div>` : `<p class="ws-panel tight note" data-ws-states>${noneRead(o, ['tasks']) ? 'Tasks not read' : 'No open tasks'}</p>`;
|
||||||
|
|
||||||
const needs = inbox.slice(0, 5);
|
const needs = inbox.slice(0, 5);
|
||||||
const needsList = needs.length ? `<ul class="ws-needs" data-ws-needs>${needs.map(d => `<li class="ws-edge ws-o" style="${o.style(d.org)}">${av(o.meta(d.org), 'md')}<a class="q" href="${esc(selHref(`/inbox?d=${enc(itemKey(d))}`))}" data-focus-key="${esc(`need:${itemKey(d)}`)}">${esc(d.question || `Decision ${d.id}`)}</a><span class="src">${fromWords(o, d)}</span>${classChip(d.class)}</li>`).join('')}</ul>${inbox.length > needs.length ? `<p class="note ws-more-line">${inbox.length - needs.length} more in the inbox</p>` : ''}` : '<p class="ws-panel tight note" data-ws-needs>Nothing needs you</p>';
|
const needsList = needs.length ? `<ul class="ws-needs" data-ws-needs>${needs.map(d => `<li class="ws-edge ws-o" style="${o.style(d.org)}">${av(o.meta(d.org), 'md')}<a class="q" href="${esc(selHref(`/inbox?d=${enc(itemKey(d))}`))}" data-focus-key="${esc(`need:${itemKey(d)}`)}">${esc(d.question || `Decision ${d.id}`)}</a><span class="src">${fromWords(o, d)}</span>${classChip(d.class)}</li>`).join('')}</ul>${inbox.length > needs.length ? `<p class="note ws-more-line">${inbox.length - needs.length} more in the inbox</p>` : ''}` : `<p class="ws-panel tight note" data-ws-needs>${noneRead(o, ['inbox']) ? 'Decisions not read' : 'Nothing needs you'}</p>`;
|
||||||
|
|
||||||
const now = sessions.filter(s => s.kind === 'thread' || s.state === 'working' || s.state === 'waiting');
|
const now = sessions.filter(s => s.kind === 'thread' || s.state === 'working' || s.state === 'waiting');
|
||||||
const idle = sessions.length - now.length;
|
const idle = sessions.length - now.length;
|
||||||
const who = s => (s.kind === 'thread' ? s.instance || s.thread || 'thread' : s.role || 'agent');
|
const who = s => (s.kind === 'thread' ? s.instance || s.thread || 'thread' : s.role || 'agent');
|
||||||
const what = s => s.project?.name || s.task?.title || '';
|
const what = s => s.project?.name || s.task?.title || '';
|
||||||
const st = s => { const [cls, glyph, word] = s.kind === 'thread' ? ['s-working', '●', 'live'] : ACTIVITY[s.state] || ['s-unknown', '?', s.state || 'not reported']; return `${dot(cls, glyph, word === 'waiting on you' ? 'waiting' : word, true)}${s.state === 'waiting' ? ' <span class="muted">on you</span>' : s.since ? ` <span class="muted">${esc(span(s.since))}</span>` : ''}`; };
|
const st = s => { const [cls, glyph, word] = s.kind === 'thread' ? ['s-working', '●', 'live'] : ACTIVITY[s.state] || ['s-unknown', '?', s.state || 'not reported']; return `${dot(cls, glyph, word === 'waiting on you' ? 'waiting' : word, true)}${s.state === 'waiting' ? ' <span class="muted">on you</span>' : s.since ? ` <span class="muted">${esc(span(s.since))}</span>` : ''}`; };
|
||||||
const sessTable = now.length ? `<div class="ws-tbl"><table class="ws-sess" data-ws-sessions><thead><tr><th scope="col">Agent and project</th><th scope="col">Status</th></tr></thead><tbody>${now.slice(0, 8).map(s => `<tr><td class="who"><span class="ws-orgref">${av(o.meta(s.org), 'xs')}${esc(who(s))}</span>${what(s) ? `<span class="muted"> · ${esc(what(s))}</span>` : ''}</td><td class="st">${st(s)}</td></tr>`).join('')}</tbody></table></div>${now.length > 8 ? `<p class="note ws-more-line">${now.length - 8} more on Agents</p>` : ''}` : `<p class="ws-panel tight note" data-ws-sessions>No session working right now${idle ? `; ${plural(idle, 'idle session')}` : ''}</p>`;
|
const sessTable = now.length ? `<div class="ws-tbl"><table class="ws-sess" data-ws-sessions><thead><tr><th scope="col">Agent and project</th><th scope="col">Status</th></tr></thead><tbody>${now.slice(0, 8).map(s => `<tr><td class="who"><span class="ws-orgref">${av(o.meta(s.org), 'xs')}<span class="ws-sr">${esc(o.name(s.org))}: </span>${esc(who(s))}</span>${what(s) ? `<span class="muted"> · ${esc(what(s))}</span>` : ''}</td><td class="st">${st(s)}</td></tr>`).join('')}</tbody></table></div>${now.length > 8 ? `<p class="note ws-more-line">${now.length - 8} more on Agents</p>` : ''}` : `<p class="ws-panel tight note" data-ws-sessions>${noneRead(o, ['agents', 'claims']) ? 'Sessions not read' : `No session working right now${idle ? `; ${plural(idle, 'idle session')}` : ''}`}</p>`;
|
||||||
|
|
||||||
const total = t ? num(t.projects?.active) + num(t.projects?.archived) : null;
|
const total = t ? num(t.projects?.active) + num(t.projects?.archived) : null;
|
||||||
const allRead = !o.unread.length;
|
const allRead = !o.unread.length;
|
||||||
@@ -517,7 +525,7 @@
|
|||||||
${secH('Needs you', '', `<a href="${esc(selHref('/inbox'))}" data-focus-key="home-inbox">Inbox</a>`)}
|
${secH('Needs you', '', `<a href="${esc(selHref('/inbox'))}" data-focus-key="home-inbox">Inbox</a>`)}
|
||||||
${needsList}${missLine(o, ['inbox'], 'needs')}
|
${needsList}${missLine(o, ['inbox'], 'needs')}
|
||||||
${secH('Sessions now', '', `<a href="${esc(selHref('/agents'))}" data-focus-key="home-agents">Agents</a>`)}
|
${secH('Sessions now', '', `<a href="${esc(selHref('/agents'))}" data-focus-key="home-agents">Agents</a>`)}
|
||||||
${sessTable}${missLine(o, ['agents', 'claims', 'threads'], 'sessions')}
|
${sessTable}${missLine(o, ['agents', 'claims'], 'sessions')}
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</article>`;
|
</article>`;
|
||||||
@@ -561,6 +569,11 @@
|
|||||||
const ar = key => (f.sort === key ? `<span class="ar" aria-hidden="true">${f.order === 'desc' ? '↓' : '↑'}</span>` : '');
|
const ar = key => (f.sort === key ? `<span class="ar" aria-hidden="true">${f.order === 'desc' ? '↓' : '↑'}</span>` : '');
|
||||||
const head = `<tr>${flat ? `<th scope="col"${aria('org')} hide-m">Organization${ar('org')}</th>` : ''}<th scope="col"${aria('name')}">Project${ar('name')}</th><th scope="col"${aria('status')}">Status${ar('status')}</th><th scope="col" class="hide-m">Sessions</th><th scope="col" class="num hide-m">Open tasks</th><th scope="col" class="num">Needs you</th><th scope="col"${aria('activity')} hide-m">Last activity${ar('activity')}</th><th scope="col" class="hide-m">Git</th></tr>`;
|
const head = `<tr>${flat ? `<th scope="col"${aria('org')} hide-m">Organization${ar('org')}</th>` : ''}<th scope="col"${aria('name')}">Project${ar('name')}</th><th scope="col"${aria('status')}">Status${ar('status')}</th><th scope="col" class="hide-m">Sessions</th><th scope="col" class="num hide-m">Open tasks</th><th scope="col" class="num">Needs you</th><th scope="col"${aria('activity')} hide-m">Last activity${ar('activity')}</th><th scope="col" class="hide-m">Git</th></tr>`;
|
||||||
const SESS = [['working', 's-working', '●', 'working'], ['waiting', 's-waiting', '◐', 'waiting'], ['idle', 's-idle', '–', 'idle']];
|
const SESS = [['working', 's-working', '●', 'working'], ['waiting', 's-waiting', '◐', 'waiting'], ['idle', 's-idle', '–', 'idle']];
|
||||||
|
// A row's figures come from more reads than its project list (workspace-read.mjs orgRows). A
|
||||||
|
// figure whose reads failed in the row's organization says "not read", never 0 or none.
|
||||||
|
const DEP = { sessions: ['agents', 'claims', 'threads', 'tasks'], tasks: ['tasks'], needs: ['inbox', 'tasks'], activity: ['tasks', 'inbox', 'agents', 'claims', 'threads'] };
|
||||||
|
const notRead = (p, key) => missOf(o.rows.find(r => r.org === p.org), DEP[key]);
|
||||||
|
const nr = why => `<span class="muted" title="${esc(why)}">not read</span>`;
|
||||||
const sessCell = p => { const s = p.sessions || {}, have = SESS.filter(([k]) => num(s[k]) > 0); if (!have.length) return '<span class="muted">none</span>'; const [k, cls, glyph, word] = have[0]; return `${dot(cls, glyph, `${num(s[k])} ${word}`, true)}${have.length > 1 ? `<span class="t2">${have.slice(1).map(([k2, , , w2]) => `${num(s[k2])} ${w2}`).join(' · ')}</span>` : ''}`; };
|
const sessCell = p => { const s = p.sessions || {}, have = SESS.filter(([k]) => num(s[k]) > 0); if (!have.length) return '<span class="muted">none</span>'; const [k, cls, glyph, word] = have[0]; return `${dot(cls, glyph, `${num(s[k])} ${word}`, true)}${have.length > 1 ? `<span class="t2">${have.slice(1).map(([k2, , , w2]) => `${num(s[k2])} ${w2}`).join(' · ')}</span>` : ''}`; };
|
||||||
const row = p => {
|
const row = p => {
|
||||||
const href = `${orgHref(p.org)}/projects/${enc(p.id)}`, active = p.status === 'active';
|
const href = `${orgHref(p.org)}/projects/${enc(p.id)}`, active = p.status === 'active';
|
||||||
@@ -568,16 +581,16 @@
|
|||||||
${flat ? `<td class="hide-m">${o.ref(p.org)}</td>` : ''}
|
${flat ? `<td class="hide-m">${o.ref(p.org)}</td>` : ''}
|
||||||
<td><a class="t1 nm" href="${esc(href)}" data-focus-key="${esc(`prow:${p.org}:${p.id}`)}">${av(o.meta(p.org), 'xs mob')}${esc(p.name || p.key || p.id)}<span class="ws-sr"> in ${esc(o.name(p.org))}</span></a>${p.key ? `<span class="t2 mono hide-m">${esc(p.key)}</span>` : ''}<span class="t2 show-m">${p.lastActivity ? esc(ago(p.lastActivity)) : 'No activity yet'}</span></td>
|
<td><a class="t1 nm" href="${esc(href)}" data-focus-key="${esc(`prow:${p.org}:${p.id}`)}">${av(o.meta(p.org), 'xs mob')}${esc(p.name || p.key || p.id)}<span class="ws-sr"> in ${esc(o.name(p.org))}</span></a>${p.key ? `<span class="t2 mono hide-m">${esc(p.key)}</span>` : ''}<span class="t2 show-m">${p.lastActivity ? esc(ago(p.lastActivity)) : 'No activity yet'}</span></td>
|
||||||
<td>${active ? dot('s-ok', '●', 'active', true) : dot('s-idle', '–', 'archived', true)}</td>
|
<td>${active ? dot('s-ok', '●', 'active', true) : dot('s-idle', '–', 'archived', true)}</td>
|
||||||
<td class="hide-m">${sessCell(p)}</td>
|
<td class="hide-m">${notRead(p, 'sessions') ? nr(notRead(p, 'sessions')) : sessCell(p)}</td>
|
||||||
<td class="num hide-m">${num(p.openTasks)}</td>
|
<td class="num hide-m">${notRead(p, 'tasks') ? nr(notRead(p, 'tasks')) : num(p.openTasks)}</td>
|
||||||
<td class="num">${p.needsYou ? `<span class="ws-n hot">${num(p.needsYou)}</span>` : '<span class="muted">0</span>'}</td>
|
<td class="num">${notRead(p, 'needs') ? nr(notRead(p, 'needs')) : p.needsYou ? `<span class="ws-n hot">${num(p.needsYou)}</span>` : '<span class="muted">0</span>'}</td>
|
||||||
<td class="hide-m">${p.lastActivity ? `<time datetime="${esc(p.lastActivity)}">${esc(ago(p.lastActivity))}</time>` : '<span class="muted">none yet</span>'}</td>
|
<td class="hide-m">${p.lastActivity ? `<time datetime="${esc(p.lastActivity)}">${esc(ago(p.lastActivity))}</time>${notRead(p, 'activity') ? '<span class="t2">some reads missing</span>' : ''}` : notRead(p, 'activity') ? nr(notRead(p, 'activity')) : '<span class="muted">none yet</span>'}</td>
|
||||||
<td class="hide-m">${p.git ? `<span class="ws-chip outline">${esc(p.git)}</span>` : '<span class="muted">none</span>'}</td>
|
<td class="hide-m">${p.git ? `<span class="ws-chip outline">${esc(p.git)}</span>` : '<span class="muted">none</span>'}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
};
|
};
|
||||||
const unreadRow = r => `<tr class="ws-unread"><td colspan="${cols}">${dot(...orgState(r), true)} <span class="muted">Not read${r.at ? ` at ${esc(hm(r.at))}` : ''}${r.reason ? `: ${esc(r.reason)}` : ''}</span></td></tr>`;
|
const unreadRow = r => `<tr class="ws-unread"><td colspan="${cols}">${dot(...orgState(r), true)} <span class="muted">Not read${r.at ? ` at ${esc(hm(r.at))}` : ''}${r.reason ? `: ${esc(r.reason)}` : ''}</span></td></tr>`;
|
||||||
let tbody;
|
let tbody;
|
||||||
if (flat) tbody = rows.length ? rows.map(row).join('') : `<tr><td colspan="${cols}" class="muted">${f.org || f.state || f.name || f.status.join() !== 'active' ? 'No projects match these filters' : 'No projects yet'}</td></tr>`;
|
if (flat) tbody = rows.length ? rows.map(row).join('') : `<tr><td colspan="${cols}" class="muted">${noneRead(o, ['projects']) ? 'Projects not read' : f.org || f.state || f.name || f.status.join() !== 'active' ? 'No projects match these filters' : 'No projects yet'}</td></tr>`;
|
||||||
else {
|
else {
|
||||||
const groups = (f.sort === 'org' && f.order === 'desc' ? [...o.rows].reverse() : o.rows);
|
const groups = (f.sort === 'org' && f.order === 'desc' ? [...o.rows].reverse() : o.rows);
|
||||||
tbody = groups.map(r => {
|
tbody = groups.map(r => {
|
||||||
@@ -588,7 +601,8 @@
|
|||||||
}).join('') || `<tr><td colspan="${cols}" class="muted">No organizations yet</td></tr>`;
|
}).join('') || `<tr><td colspan="${cols}" class="muted">No organizations yet</td></tr>`;
|
||||||
}
|
}
|
||||||
const unreadNote = flat && o.unread.length ? `<p class="note ws-unread-note" data-ws-unread>Not in this list: ${andList(o.unread.map(stateWords))}.</p>` : '';
|
const unreadNote = flat && o.unread.length ? `<p class="note ws-unread-note" data-ws-unread>Not in this list: ${andList(o.unread.map(stateWords))}.</p>` : '';
|
||||||
const missNote = flat ? missLine(o, ['projects'], 'projects') : '';
|
// Projects that were read can still lack figures from the other reads; the cells say "not read".
|
||||||
|
const missNote = (flat ? missLine(o, ['projects'], 'projects') : '') + missLine({ ...o, rows: o.rows.filter(r => !missOf(r, ['projects'])) }, DEP.activity, 'figures', 'Some figures not read in');
|
||||||
const shown = new Set(rows.map(p => p.org)).size;
|
const shown = new Set(rows.map(p => p.org)).size;
|
||||||
const sub = `${plural(rows.length, 'project')} in ${plural(shown, 'organization')}, sorted by ${SORT_WORD[f.sort]}${f.sort === 'activity' ? (f.order === 'desc' ? ', newest first' : ', oldest first') : f.order === 'desc' ? ', descending' : ''}. Each row names its organization by mark and colour edge.`;
|
const sub = `${plural(rows.length, 'project')} in ${plural(shown, 'organization')}, sorted by ${SORT_WORD[f.sort]}${f.sort === 'activity' ? (f.order === 'desc' ? ', newest first' : ', oldest first') : f.order === 'desc' ? ', descending' : ''}. Each row names its organization by mark and colour edge.`;
|
||||||
const statusVal = f.status.join(',');
|
const statusVal = f.status.join(',');
|
||||||
@@ -619,7 +633,7 @@
|
|||||||
} catch (err) { return failedPage('ws-inbox', 'data-ws-inbox', 'Inbox', err); }
|
} catch (err) { return failedPage('ws-inbox', 'data-ws-inbox', 'Inbox', err); }
|
||||||
const every = orgsOf(all || body), o = orgsOf(body);
|
const every = orgsOf(all || body), o = orgsOf(body);
|
||||||
const everyRows = arr((all || body).inbox);
|
const everyRows = arr((all || body).inbox);
|
||||||
tellInbox(everyRows);
|
if (!noneRead(every, ['inbox'])) tellInbox(everyRows);
|
||||||
const counts = new Map();
|
const counts = new Map();
|
||||||
for (const d of everyRows) counts.set(d.org, (counts.get(d.org) || 0) + 1);
|
for (const d of everyRows) counts.set(d.org, (counts.get(d.org) || 0) + 1);
|
||||||
const rows = arr(body.inbox);
|
const rows = arr(body.inbox);
|
||||||
@@ -635,7 +649,7 @@
|
|||||||
</tr>`;
|
</tr>`;
|
||||||
};
|
};
|
||||||
const unread = (o.unread.length ? `<p class="note ws-unread-note" data-ws-unread>Not in this list: ${andList(o.unread.map(stateWords))}.</p>` : '') + missLine(o, ['inbox'], 'inbox');
|
const unread = (o.unread.length ? `<p class="note ws-unread-note" data-ws-unread>Not in this list: ${andList(o.unread.map(stateWords))}.</p>` : '') + missLine(o, ['inbox'], 'inbox');
|
||||||
const table = rows.length ? `<div class="ws-tbl"><table class="ws-ibx" data-ws-items><caption class="ws-sr">Items that need you</caption><thead><tr><th scope="col" class="hide-m">Source</th><th scope="col">Needs</th><th scope="col" class="hide-m">Class</th><th scope="col" class="num">Waiting</th></tr></thead><tbody>${rows.map(row).join('')}</tbody></table></div>` : `<p class="ws-panel tight note" data-ws-items>${org ? 'Nothing needs you in these organizations' : 'Nothing needs you'}</p>`;
|
const table = rows.length ? `<div class="ws-tbl"><table class="ws-ibx" data-ws-items><caption class="ws-sr">Items that need you</caption><thead><tr><th scope="col" class="hide-m">Source</th><th scope="col">Needs</th><th scope="col" class="hide-m">Class</th><th scope="col" class="num">Waiting</th></tr></thead><tbody>${rows.map(row).join('')}</tbody></table></div>` : `<p class="ws-panel tight note" data-ws-items>${noneRead(o, ['inbox']) ? 'Decisions not read' : org ? 'Nothing needs you in these organizations' : 'Nothing needs you'}</p>`;
|
||||||
let insp = '';
|
let insp = '';
|
||||||
if (picked) {
|
if (picked) {
|
||||||
const d = picked, id = esc(d.id);
|
const d = picked, id = esc(d.id);
|
||||||
@@ -658,7 +672,7 @@
|
|||||||
</aside>`;
|
</aside>`;
|
||||||
}
|
}
|
||||||
const orgsWith = new Set(rows.map(d => d.org)).size;
|
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 `<section class="ws ws-inbox" data-ws-inbox>
|
return `<section class="ws ws-inbox" data-ws-inbox>
|
||||||
<div class="ws-vh"><h1 tabindex="-1">Inbox</h1><p class="sub">${sub}</p></div>
|
<div class="ws-vh"><h1 tabindex="-1">Inbox</h1><p class="sub">${sub}</p></div>
|
||||||
<div class="ws-toolbar">
|
<div class="ws-toolbar">
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ test('owner can start a down bus after setup recorded done and sees recovery gui
|
|||||||
const f = await fixture(t);
|
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.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');
|
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.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.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')`);
|
await f.wait(`document.querySelector('[data-step="bus"]').innerText.includes('stale bus host lock')`);
|
||||||
|
|||||||
@@ -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.
|
// 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 ACME_DECISION = 'dec-acme-7f3c9a21-5b8e-4d1f-9c2a-0e6b7d8f9a10';
|
||||||
const BETA_DECISION = 'dec-beta-1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d';
|
const BETA_DECISION = 'dec-beta-1a2b3c4d-5e6f-4a1b-8c9d-0e1f2a3b4c5d';
|
||||||
function fixture({ pollMs, fail = {} } = {}) {
|
function fixture({ pollMs, fail = {}, down = [] } = {}) {
|
||||||
const LIST = [
|
const LIST = [
|
||||||
{ id: 'acme', label: 'Acme Studio', theme: 'cobalt', busHealthy: true },
|
{ id: 'acme', label: 'Acme Studio', theme: 'cobalt', busHealthy: true },
|
||||||
{ id: 'beta', label: 'Beta Works', theme: 'grove', busHealthy: true },
|
{ id: 'beta', label: 'Beta Works', theme: 'grove', busHealthy: true },
|
||||||
@@ -48,7 +48,8 @@ function fixture({ pollMs, fail = {} } = {}) {
|
|||||||
});
|
});
|
||||||
const member = org => ({
|
const member = org => ({
|
||||||
id: org.id, doc: { appearance: { theme: org.theme } },
|
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),
|
options: () => opts(org.id),
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
@@ -68,8 +69,8 @@ function fixture({ pollMs, fail = {} } = {}) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setup(t, { viewport = [1440, 900], hash = '/', workspaceTimeoutMs, fail } = {}) {
|
async function setup(t, { viewport = [1440, 900], hash = '/', workspaceTimeoutMs, fail, down } = {}) {
|
||||||
const server = await startServer({ port: 0, sso: createDevOwner(), organizations: fixture({ fail }), log: () => {}, ...(workspaceTimeoutMs ? { workspaceTimeoutMs } : {}) });
|
const server = await startServer({ port: 0, sso: createDevOwner(), organizations: fixture({ fail, down }), log: () => {}, ...(workspaceTimeoutMs ? { workspaceTimeoutMs } : {}) });
|
||||||
t.after(() => close(server));
|
t.after(() => close(server));
|
||||||
const b = await browser({ machine: false }); t.after(() => b.close());
|
const b = await browser({ machine: false }); t.after(() => b.close());
|
||||||
await b.viewport(...viewport);
|
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.match(await text('[data-ws-tile=projects]'), /Not read/i);
|
||||||
assert.equal(await text('[data-ws-tile=projects] .ws-big'), null);
|
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('|'));
|
||||||
|
});
|
||||||
Reference in new issue
Block a user