From fc558df31ae6a1cab951534ad0a511a9450bc733 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Wed, 18 Nov 2026 10:58:04 -0600 Subject: [PATCH 1/4] fix(webui): drawer and page polish: at 390 the open agent sheet is the whole screen and the page under it no longer scrolls behind it, and Close puts the page back where it was; the drawer's Last activity is when the agent's current run took its role or conversation, from the claim time the workspace read already carries; the Dashboard's two columns line up with its tile row; the organization page's left column holds Autonomy and Starter packs; the workflows section() stub and its duplicate stopped panel are gone (#1873, lane sp18-drawer-polish) --- packages/webui/src/public/packs.css | 2 +- packages/webui/src/public/shell.css | 13 +++++ packages/webui/src/public/workflows.js | 4 +- packages/webui/src/public/workspace.js | 31 ++++++++---- .../webui/tests/agent-drawer-browser.test.mjs | 50 +++++++++++++++++-- .../webui/tests/kpi-tiles-browser.test.mjs | 21 ++++++++ .../webui/tests/org-page-fit-browser.test.mjs | 14 ++++++ .../tests/unified-workspace-browser.test.mjs | 5 +- .../webui/tests/workflows-browser.test.mjs | 3 ++ 9 files changed, 121 insertions(+), 22 deletions(-) diff --git a/packages/webui/src/public/packs.css b/packages/webui/src/public/packs.css index 92d57fbd2..f2a6a23ea 100644 --- a/packages/webui/src/public/packs.css +++ b/packages/webui/src/public/packs.css @@ -1,4 +1,4 @@ -[data-packs],[data-workflows]{margin-top:16px} +[data-packs]{margin-top:16px} .pack-list,.pack-hires{list-style:none;margin:8px 0;padding:0} .pack-row,.pack-hire{border-top:1px solid var(--border);padding:12px 0;overflow-wrap:anywhere} .pack-preview{border:1px solid var(--border);border-radius:var(--r);padding:12px;margin:12px 0;overflow-wrap:anywhere} diff --git a/packages/webui/src/public/shell.css b/packages/webui/src/public/shell.css index 16262b17a..16301a877 100644 --- a/packages/webui/src/public/shell.css +++ b/packages/webui/src/public/shell.css @@ -631,6 +631,14 @@ html[data-organizations] .ws-orgcard .at{grid-column:3;grid-row:1;font:500 11.5p html[data-organizations] .ws-orgcard .why{grid-column:1/-1;font-size:12px;color:var(--muted)} html[data-organizations] .ws-orgcard.off a{border-style:dashed} html[data-organizations] .ws-home-split{margin-top:4px} +/* SP18: the Dashboard's columns line up with its tile row. Three equal tracks with the tiles' gap, the left + column spanning two, end on a tile edge whether the row holds six tiles (after the fourth) or three + (after the second). Below 760 px the split is one column. */ +html[data-organizations] .ws-home>.ws-tiles{gap:var(--gap)} +@media (min-width:760px){ + html[data-organizations] .ws-home-split{grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--gap)} + html[data-organizations] .ws-home-split>:first-child{grid-column:span 2} +} html[data-organizations] .ws-trail{list-style:none;margin:0;padding:0;border:1px solid var(--line);border-radius:8px;background:var(--surface)} html[data-organizations] .ws-trail li{display:grid;grid-template-columns:48px 20px minmax(0,1fr);gap:10px;padding:7px 12px;border-bottom:1px solid color-mix(in srgb,var(--line) 60%,transparent);font-size:13px;align-items:center} html[data-organizations] .ws-trail li:last-child{border-bottom:0} @@ -770,6 +778,11 @@ html[data-organizations] .ws-drawer-acts .note{flex-basis:100%} @media (min-width:1200px){html[data-organizations] body:has(.ws-drawer) .content{padding-right:calc(420px + 22px)}} @media (max-width:700px){ html[data-organizations] .ws-drawer{top:0;left:0;right:0;width:auto;border-left:0;box-shadow:none} + /* SP18: the sheet covers the screen, so the page under it is held to one screen and does not scroll; it + kept its own height before, and the sheet showed over a long blank area. workspace.js puts the page's + place back on Close. */ + html[data-organizations]:has(#bus-view .ws-drawer){overflow:hidden} + html[data-organizations]:has(#bus-view .ws-drawer) body{height:100dvh;overflow:hidden} } @media (max-width:1100px){ html[data-organizations] .ws-tiles.six{grid-template-columns:repeat(3,minmax(0,1fr))} diff --git a/packages/webui/src/public/workflows.js b/packages/webui/src/public/workflows.js index f58f1e870..3272a1481 100644 --- a/packages/webui/src/public/workflows.js +++ b/packages/webui/src/public/workflows.js @@ -823,7 +823,5 @@ window.matchMedia(NARROW).addEventListener('change', () => { if (document.querySelector('[data-wfg-graph]')) document.dispatchEvent(new CustomEvent('mosaic-workspace-render')); }); - // section(): the organization page's old form editor is gone (SP17); workspace.js still asks for it. - const section = () => ''; - window.MosaicWorkflows = { load, section, page, card, hasDraft, forget, landed }; + window.MosaicWorkflows = { load, page, card, hasDraft, forget, landed }; })(); diff --git a/packages/webui/src/public/workspace.js b/packages/webui/src/public/workspace.js index 3f5df5519..503de5420 100644 --- a/packages/webui/src/public/workspace.js +++ b/packages/webui/src/public/workspace.js @@ -367,21 +367,20 @@ ${orgTiles} ${docrow}
-
+
${secH('Active agent sessions', live ? (noRuns ? 'running not read' : live.length ? `${live.length} running${tileAgents ? `, ${liveWorking} working` : ', working not read'}` : 'none running') : '', `This organization's agents`)} ${sessions} ${window.MosaicWorkflows?.card?.(id, { stopped, label: label(org) }) ?? ''} +
+ ${stopped ? stoppedPanel('data-autonomy', 'Autonomy') : window.MosaicAutonomy?.section(id) ?? ''} + ${stopped ? stoppedPanel('data-packs', 'Starter packs') : window.MosaicPacks?.section(id) ?? ''} +
${secH('Settings', 'every setting, with where its value comes from')} ${settingsList(org, { business, settings, instances, noRuns, orgCount: list ? list.length : null })}
-
- ${stopped ? stoppedPanel('data-autonomy', 'Autonomy') : window.MosaicAutonomy?.section(id) ?? ''} - ${stopped ? stoppedPanel('data-packs', 'Starter packs') : window.MosaicPacks?.section(id) ?? ''} - ${stopped ? stoppedPanel('data-workflows', 'Workflows') : window.MosaicWorkflows?.section(id) ?? ''} -
${await drawerRead} `; } @@ -1348,6 +1347,14 @@ const actions = chat || change ? `
${acts.join(' ')}

${esc(st?.text || '')}

` : `

This Console only reads ${esc(orgName)}. It can not message or stop its agents.

`; + // SP18: the agents read lists only roles a run holds now, and thread.claims only conversations a run + // holds now; each row's time is when that run took the role or the conversation. So the latest of + // them is when the agent's current run started. No read keeps when a run ended or when the agent last + // sent a message (a thread's messages read pages from the oldest message), so neither is shown. + const runAt = [a.s?.claimedAt, ...arr(body?.sessions).filter(x => x?.kind === 'thread' && x.org === org && x.instance === key).map(x => x.claimedAt)] + .filter(v => msOf(v) !== null).sort((x, y) => msOf(y) - msOf(x))[0] ?? null; + const activity = runAt ? `current run started ` + : `${(runWhy => runWhy ? `not read: ${esc(runWhy)}` : 'not recorded: no run holds it now, and no read keeps when its last run ended')(notRead(['agents', 'claims']))}`; const fields = [ field('org', 'Organization', orgChip(o, org)), // A pack hire's pack is named once, in Hired from; the Role row says only that it was hired. @@ -1358,11 +1365,7 @@ model ? field('model', 'Model', `${esc(model)}`) : '', project ? field('project', 'Project', `${esc(project.name || project.key || project.id)}${project.from ? ` ${project.from}` : ''}`) : '', task ? field('task', 'Task', `${esc(task.title || task.ref)}${task.title ? ` ${esc(task.ref)}` : ''}`) : '', - // SP16: no read the Console makes carries the time of a role agent's last message or run. The agents - // read's time is when it took the role and `since` is when its present state began, so neither is shown. - // An agent holding a conversation has its messages in that thread's messages read, but that read pages - // from the oldest message, so its last message is a walk of every page away; the drawer does not make it. - field('activity', 'Last activity', `${thread?.thread ? 'not shown: reading it means reading the whole conversation' : 'not recorded'}`), + field('activity', 'Last activity', activity), ].join(''); return shell(a.name, `
${fields}

Open tasks

${tasksBody}${tasksAll}
@@ -1377,6 +1380,11 @@ history.replaceState(unmarked(), '', sansAgent()); document.dispatchEvent(new CustomEvent('mosaic-workspace-render')); } + // SP18: below 701 px the open drawer is a sheet and shell.css holds the page under it to one screen, which + // scrolls the page to the top. The page's place is kept while no drawer is open and put back on Close. + const SHEET = window.matchMedia('(max-width:700px)'); + let pageY = 0; + window.addEventListener('scroll', () => { if (!document.querySelector('#bus-view [data-ws-drawer]')) pageY = window.scrollY; }, { passive: true }); // bus.js calls this after each paint: focus moves into a drawer a row opened, and back to the row // when the drawer has closed and focus was left nowhere. function afterPaint() { @@ -1386,6 +1394,7 @@ drawerShown = now; if (d && drawerFocus) { drawerFocus = false; d.querySelector('h2')?.focus({ preventScroll: true }); return; } drawerFocus = false; + if (!now && was && SHEET.matches && pageY) window.scrollTo(0, pageY); if (!now && was) { const a = document.activeElement; if (!a || a === document.body || !view?.contains(a)) view?.querySelector(`[data-focus-key="${CSS.escape(`agent:${was}`)}"]`)?.focus({ preventScroll: true }); diff --git a/packages/webui/tests/agent-drawer-browser.test.mjs b/packages/webui/tests/agent-drawer-browser.test.mjs index ea2564ef6..a7d0d636b 100644 --- a/packages/webui/tests/agent-drawer-browser.test.mjs +++ b/packages/webui/tests/agent-drawer-browser.test.mjs @@ -185,9 +185,12 @@ test('the drawer shows each field from its read: name, organization, role and so // Decisions waiting on a human that it raised, each into the Inbox. Chief's is not its own. const decisions = await b.evaluate(`[...document.querySelectorAll('${d} [data-drawer-decisions] li a')].map(a => [a.textContent.trim(), a.getAttribute("href")])`); assert.deepEqual(decisions, [['Ship the hero copy?', '#/inbox?d=acme%3Adec-1']]); - // SP16: no read gives the time of an agent's last activity. The agents read's time (when it took the - // role) and `since` (when its present state began) are not that, so the drawer says not recorded. - assert.equal(await text(`${d} [data-drawer-activity]`), 'not recorded'); + // SP18: the agents read lists only roles a run holds now, and its time is when that run took the role, + // so Last activity is when the current run started, 40 minutes before the read, with the time itself. + assert.match(await text(`${d} [data-drawer-activity]`), /^current run started 4[01] min ago$/); + const started = await attr(`${d} [data-drawer-activity] time`, 'datetime'); + assert.ok(Math.abs(Date.now() - Date.parse(started) - 40 * 60000) < 90000, started); + assert.match(await attr(`${d} [data-drawer-activity] time`, 'title'), /\d/); assert.equal(await b.evaluate(`document.querySelector('${d} [data-drawer-activity]').closest('.ws-drawer-f').querySelector('dt').textContent`), 'Last activity'); // Not a pack hire: no packs read, and no Hired from line. assert.equal(await has(`${d} [data-drawer-hired]`), false); @@ -209,6 +212,9 @@ test('a hired agent shows where its role came from; a not-running agent says not assert.match(await text(`${d} [data-drawer-source]`), new RegExp(`hire decision ${HIRE}`)); assert.match(await text(`${d} [data-drawer-state]`), /(^|\s)not running$/); assert.equal(await has(`${d} [data-drawer-model]`), false); + // SP18: no run holds it, and no read keeps the time of a run that ended: one plain line, no time. + assert.equal(await text(`${d} [data-drawer-activity]`), 'not recorded: no run holds it now, and no read keeps when its last run ended'); + assert.equal(await has(`${d} [data-drawer-activity] time`), false); }); test('SP16: a pack hire names its pack and the template the packs read gives; a refused read says so', async t => { @@ -501,8 +507,8 @@ test('Message opens the agent\'s thread in an Assistant pane; Stop asks first an assert.equal(await attr('[data-ws-drawer="acme:assistant"] [data-drawer-message]', 'href'), `#/assistant?add=acme%3A${THREAD}`); // SP16: Message is offered, so no line says why it is not. assert.equal(await has('[data-ws-drawer="acme:assistant"] [data-drawer-nomessage]'), false); - // It holds a conversation, whose messages read pages from the oldest message: the drawer says it does not read it. - assert.equal(await text('[data-ws-drawer="acme:assistant"] [data-drawer-activity]'), 'not shown: reading it means reading the whole conversation'); + // SP18: a conversation agent's run took its conversation 5 minutes before the read (thread.claims' time). + assert.match(await text('[data-ws-drawer="acme:assistant"] [data-drawer-activity]'), /^current run started [56] min ago$/); // A role agent holds no thread to open, so it has no Message; it can still be stopped. await b.evaluate('location.hash = "#/agents?agent=acme%3Acoder"'); await wait(`${open('acme:coder')} && document.querySelector('[data-ws-drawer="acme:coder"] [data-drawer-stop]')`); @@ -578,6 +584,40 @@ test('at 390 wide the drawer is a full-width sheet', async t => { assert.ok(box[3] <= box[2], `no horizontal page scroll: ${box[3]} > ${box[2]}`); }); +// SP18: the sheet is fixed to the screen, but the page under it kept its own height, so the page still +// scrolled behind the sheet and a full-page shot showed the sheet stretched down a long blank area. With the +// sheet open the page is one screen tall; Close puts the page back where the reader left it. +test('SP18: at 390 wide the open sheet is the whole screen, the page under it does not scroll, and Close keeps the place', async t => { + const { b, wait } = await setup(t, { viewport: [390, 844], hash: '#/orgs/acme/organization' }); + const link = JSON.stringify(sessionLink('acme:coder')); + await wait(`document.querySelector(${link}) && document.querySelectorAll("[data-org-settings] [data-org-setting]").length > 10`); + await b.evaluate(`document.querySelector(${link}).scrollIntoView({ block: 'center' })`); + const at = await b.evaluate('Math.round(scrollY)'); + assert.ok(at > 100, `the row is down the page: ${at}`); + await b.evaluate(`document.querySelector(${link}).click()`); + await wait(open('acme:coder')); + await b.evaluate('new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)))'); + const m = await b.evaluate(`(() => { const r = ${drawer('acme:coder')}.getBoundingClientRect(), e = document.documentElement; return { top: Math.round(r.top), bottom: Math.round(r.bottom), left: Math.round(r.left), width: Math.round(r.width), vh: innerHeight, vw: e.clientWidth, docH: e.scrollHeight, bodyH: Math.round(document.body.getBoundingClientRect().height), sw: e.scrollWidth }; })()`); + assert.equal(m.top, 0, JSON.stringify(m)); + assert.equal(m.bottom, m.vh, `the sheet ends at the screen's foot: ${JSON.stringify(m)}`); + assert.equal(m.left, 0); assert.equal(m.width, m.vw); + assert.ok(m.docH <= m.vh && m.bodyH <= m.vh, `the page under the sheet is one screen tall, nothing below to scroll to: ${JSON.stringify(m)}`); + assert.ok(m.sw <= m.vw, 'no sideways scroll'); + // A scroll on the page does nothing while the sheet is open. + await b.evaluate('window.scrollTo(0, 2000)'); + assert.equal(await b.evaluate('Math.round(scrollY)'), 0); + await b.evaluate(`${drawer('acme:coder')}.querySelector("[data-drawer-close]").click()`); + await wait(noDrawer); + await b.evaluate('new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)))'); + assert.ok(Math.abs(await b.evaluate('Math.round(scrollY)') - at) <= 1, `Close puts the page back at ${at}: ${await b.evaluate('Math.round(scrollY)')}`); + assert.ok(await b.evaluate('document.documentElement.scrollHeight') > 844, 'the page is its full height again'); + // At 1440 the drawer is a side panel: the page keeps its height and scrolls. + await b.viewport(1440, 900); + await b.evaluate(`document.querySelector(${link}).click()`); + await wait(open('acme:coder')); + assert.ok(await b.evaluate('document.documentElement.scrollHeight') > 900, 'at 1440 the page beside the drawer keeps its height'); +}); + // #1873 triage-followups: the page focuses its heading when its first render ends. On load the page // starts a second render that reads GET /api/workspace again, so when the first render's read is slow // the second draws the rows first and a reader can open a drawer before the first render ends. Its late diff --git a/packages/webui/tests/kpi-tiles-browser.test.mjs b/packages/webui/tests/kpi-tiles-browser.test.mjs index ef50aad0e..96d99b51a 100644 --- a/packages/webui/tests/kpi-tiles-browser.test.mjs +++ b/packages/webui/tests/kpi-tiles-browser.test.mjs @@ -279,3 +279,24 @@ test('At 390 wide the tiles sit two to a row with no sideways scroll, on the Das assert.equal(await cols('[data-org-tiles]'), 2); assert.equal(await b.evaluate('document.documentElement.scrollWidth <= document.documentElement.clientWidth'), true, 'organization page'); }); + +test('SP18: at 1440 and 1024 the Dashboard\'s two columns line up with the tile row above them', async t => { + const { b, wait } = await setup(t, { viewport: [1440, 1000] }); + await wait(homeReady); + // The left column ends where a tile ends and the right column starts where the next tile starts: the fourth + // and fifth of six at 1440, the second and third of three a row at 1024. + const edges = () => b.evaluate(`(() => { + const tiles = [...document.querySelectorAll('[data-ws-home] [data-ws-tile]')].map(e => e.getBoundingClientRect()); + const cols = [...document.querySelectorAll('[data-ws-home] .ws-home-split>*')].map(e => e.getBoundingClientRect()); + return { rights: tiles.map(r => Math.round(r.right)), lefts: tiles.map(r => Math.round(r.left)), left: cols[0] && [Math.round(cols[0].left), Math.round(cols[0].right)], right: cols[1] && [Math.round(cols[1].left), Math.round(cols[1].right)] }; + })()`); + for (const [w, nth] of [[1440, 4], [1024, 2]]) { + await b.viewport(w, 1000); + await b.evaluate('new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)))'); + const e = await edges(); + assert.ok(e.left && e.right && e.right[0] > e.left[1], `two columns side by side at ${w}: ${JSON.stringify(e)}`); + assert.ok(Math.abs(e.left[1] - e.rights[nth - 1]) <= 1, `at ${w} the left column ends with tile ${nth}: ${JSON.stringify(e)}`); + assert.ok(Math.abs(e.right[0] - e.lefts[nth]) <= 1, `at ${w} the right column starts with tile ${nth + 1}: ${JSON.stringify(e)}`); + assert.ok(Math.abs(e.right[1] - Math.max(...e.rights)) <= 1, `at ${w} the right column ends with the row`); + } +}); diff --git a/packages/webui/tests/org-page-fit-browser.test.mjs b/packages/webui/tests/org-page-fit-browser.test.mjs index c0756e952..2df340aab 100644 --- a/packages/webui/tests/org-page-fit-browser.test.mjs +++ b/packages/webui/tests/org-page-fit-browser.test.mjs @@ -180,6 +180,20 @@ test('the Settings card fits at 1440 with the drawer open, at 735 and 390 withou assert.deepEqual(cols[1].heads, ['Settings']); const gap = await b.evaluate(`(() => { const left = document.querySelector('#bus-view .ws-dash>.ws-split>section'), card = left.querySelector('[data-wfg-card]'), above = card.previousElementSibling; return Math.round(card.getBoundingClientRect().top - above.getBoundingClientRect().bottom); })()`); assert.ok(gap >= 0 && gap <= 40, `the Workflows card follows the sessions directly: ${gap}px`); + // SP18: Autonomy and Starter packs follow the Workflows card in the left column, so the left column is not + // empty beside the long Settings card and nothing runs full width below it. + const left = await b.evaluate(`(() => { const s = [...document.querySelectorAll('#bus-view .ws-dash>.ws-split>section')]; return { autonomy: !!s[0].querySelector('[data-autonomy]'), packs: !!s[0].querySelector('[data-packs]'), after: !!document.querySelector('#bus-view .ws-dash>.ws-split ~ :is(div,section):not([data-ws-drawer])'), ends: s.map(x => Math.round(x.getBoundingClientRect().bottom)) }; })()`); + assert.equal(left.autonomy && left.packs, true, `Autonomy and Starter packs are in the left column: ${JSON.stringify(left)}`); + assert.equal(left.after, false, 'no full-width block under the split'); + // How near level the two end depends on the data: in this fixture Autonomy is a one-line refusal and no pack + // is installed, so the Settings card is still the taller. The left column ends with Starter packs. + assert.ok(await b.evaluate(`Math.abs(document.querySelector('#bus-view .ws-dash>.ws-split>section [data-packs]').getBoundingClientRect().bottom - document.querySelector('#bus-view .ws-dash>.ws-split>section').getBoundingClientRect().bottom) <= 1`), `the left column ends with Starter packs: ${JSON.stringify(left.ends)}`); + // At 390 the page is one column: sessions, Workflows, Autonomy, Starter packs, then Settings. + await b.viewport(390, 844); + await b.evaluate('new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)))'); + const order = await b.evaluate(`[...document.querySelectorAll('#bus-view .ws-dash>.ws-split h2, #bus-view .ws-dash>.ws-split h3')].map(h => h.textContent.trim()).filter(x => ['Active agent sessions', 'Workflows', 'Autonomy', 'Starter packs', 'Settings'].includes(x))`); + assert.deepEqual(order, ['Active agent sessions', 'Workflows', 'Autonomy', 'Starter packs', 'Settings']); + assert.ok(await b.evaluate('document.documentElement.scrollWidth <= document.documentElement.clientWidth'), 'no sideways scroll at 390'); }); test('the bare organization address with a query is the organization page, query kept; ?agent= opens the drawer', async t => { diff --git a/packages/webui/tests/unified-workspace-browser.test.mjs b/packages/webui/tests/unified-workspace-browser.test.mjs index 29171de71..cab97d29e 100644 --- a/packages/webui/tests/unified-workspace-browser.test.mjs +++ b/packages/webui/tests/unified-workspace-browser.test.mjs @@ -302,8 +302,9 @@ test('keyboard focus follows visual order and survives a data refresh', async t await b.navigate(`http://127.0.0.1:${server.address().port}/#/orgs/ddigital/organization`); await wait('document.querySelectorAll("[data-org-dashboard] .ws-doc").length > 0 && document.querySelectorAll("#workspace-nav .ws-proj").length === 3'); const wide = await tabStops(b, 'document.querySelector("#sections a")'); - // The left column holds the sessions and, below them, the Workflows card (SP16); the right holds Settings. - const regions = ['nav', 'head', 'Sessions and workflows', 'Settings']; + // The left column holds the sessions and, below them, the Workflows card (SP16), then Autonomy and Starter + // packs (SP18); the right holds Settings. + const regions = ['nav', 'head', 'Sessions, workflows, autonomy and starter packs', 'Settings']; assert.deepEqual([...new Set(wide.map(s => s.region))].filter(r => r !== 'other'), regions); assertVisualOrder(wide.filter(s => s.region !== 'other'), regions, '1440'); const keys = wide.map(s => s.key); diff --git a/packages/webui/tests/workflows-browser.test.mjs b/packages/webui/tests/workflows-browser.test.mjs index 411001251..27fc4d533 100644 --- a/packages/webui/tests/workflows-browser.test.mjs +++ b/packages/webui/tests/workflows-browser.test.mjs @@ -312,6 +312,9 @@ test('a stopped organization is not read: the page and card say the bus is stopp await wait(`document.querySelector('[data-org-dashboard] [data-wfg-card][data-bus-stopped]')`, 'stopped card'); assert.match(await b.evaluate(`document.querySelector('[data-wfg-card]').textContent`), /Not read: the bus is stopped\./); assert.equal(await b.evaluate(`document.querySelector('[data-wfg-card] [data-wfg-none]')`), null); + // SP18: the card is the page's one Workflows block; the old stopped panel under it said the same thing twice. + assert.equal(await b.evaluate(`[...document.querySelectorAll('[data-org-dashboard] h2, [data-org-dashboard] h3')].filter(h => h.textContent.trim() === 'Workflows').length`), 1, 'one Workflows heading on a stopped organization page'); + assert.equal(await b.evaluate(`document.querySelector('[data-workflows]')`), null); assert.equal(reads.filter(id => id === 'gamma').length, 0, 'a stopped organization is not read'); }); -- 2.54.0 From 38ea639d70f3941ab27cde52430d77b7db62c3f2 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Wed, 18 Nov 2026 11:08:20 -0600 Subject: [PATCH 2/4] fix(webui): drawer polish review round: at 390 the page under the sheet goes back to its place only when the drawer closes onto that same page, so a link in the sheet opens its page at the top and a later page does not jump; Last activity counts a role or conversation claim only when the instances read lists its run as running, says when a running run holds nothing yet, and names the latest of several runs (#1873, lane sp18-drawer-polish) --- packages/webui/src/public/workspace.js | 31 ++++++--- .../webui/tests/agent-drawer-browser.test.mjs | 65 +++++++++++++++++-- 2 files changed, 80 insertions(+), 16 deletions(-) diff --git a/packages/webui/src/public/workspace.js b/packages/webui/src/public/workspace.js index 503de5420..5fc787ade 100644 --- a/packages/webui/src/public/workspace.js +++ b/packages/webui/src/public/workspace.js @@ -1348,13 +1348,18 @@ ? `
${acts.join(' ')}

${esc(st?.text || '')}

` : `

This Console only reads ${esc(orgName)}. It can not message or stop its agents.

`; // SP18: the agents read lists only roles a run holds now, and thread.claims only conversations a run - // holds now; each row's time is when that run took the role or the conversation. So the latest of - // them is when the agent's current run started. No read keeps when a run ended or when the agent last - // sent a message (a thread's messages read pages from the oldest message), so neither is shown. - const runAt = [a.s?.claimedAt, ...arr(body?.sessions).filter(x => x?.kind === 'thread' && x.org === org && x.instance === key).map(x => x.claimedAt)] - .filter(v => msOf(v) !== null).sort((x, y) => msOf(y) - msOf(x))[0] ?? null; - const activity = runAt ? `current run started ` - : `${(runWhy => runWhy ? `not read: ${esc(runWhy)}` : 'not recorded: no run holds it now, and no read keeps when its last run ended')(notRead(['agents', 'claims']))}`; + // holds now; each row carries that run and when it took the role or the conversation. A claim counts + // only when the instances read lists its run as running, so a claim left by a run that ended does not + // date a stopped agent. Last activity is the latest such time. No read keeps when a run ended or when + // the agent last sent a message (a thread's messages read pages from the oldest message), so neither is shown. + const runs = !unknown && runsRead(item) ? item.running : null; + const claims = [a.s ? { ...a.s, what: 'the role' } : null, ...arr(body?.sessions).filter(x => x?.kind === 'thread' && x.org === org && x.instance === key).map(x => ({ ...x, what: 'the conversation' }))] + .filter(c => c && msOf(c.claimedAt) !== null && (!runs || runs.includes(c.run))).sort((x, y) => msOf(y.claimedAt) - msOf(x.claimedAt)); + const last = claims[0], claimWhy = notRead(['agents', 'claims']); + const activity = last ? `${runs && runs.length > 1 ? `the latest of its ${runs.length} runs` : 'its run'} took ${last.what} ` + : `${claimWhy ? `not read: ${esc(claimWhy)}` + : runs?.length ? `not recorded: ${runs.length > 1 ? 'its runs hold' : 'its run holds'} no role or conversation yet` + : 'not recorded: no run holds it now, and no read keeps when its last run ended'}`; const fields = [ field('org', 'Organization', orgChip(o, org)), // A pack hire's pack is named once, in Hired from; the Role row says only that it was hired. @@ -1381,9 +1386,11 @@ document.dispatchEvent(new CustomEvent('mosaic-workspace-render')); } // SP18: below 701 px the open drawer is a sheet and shell.css holds the page under it to one screen, which - // scrolls the page to the top. The page's place is kept while no drawer is open and put back on Close. + // scrolls the page to the top. The page's place is kept while no drawer is open, with the page the sheet + // opened over. It is put back only when the drawer closes onto that same page (Close, Escape or Back); a + // link in the sheet goes to another page, which starts at its top, and the kept place is dropped. const SHEET = window.matchMedia('(max-width:700px)'); - let pageY = 0; + let pageY = 0, sheetOver = null; window.addEventListener('scroll', () => { if (!document.querySelector('#bus-view [data-ws-drawer]')) pageY = window.scrollY; }, { passive: true }); // bus.js calls this after each paint: focus moves into a drawer a row opened, and back to the row // when the drawer has closed and focus was left nowhere. @@ -1392,9 +1399,13 @@ const view = document.getElementById('bus-view'), d = view?.querySelector('[data-ws-drawer]'); const now = d?.dataset.wsDrawer || null, was = drawerShown; drawerShown = now; + if (now) sheetOver = sansAgent(); if (d && drawerFocus) { drawerFocus = false; d.querySelector('h2')?.focus({ preventScroll: true }); return; } drawerFocus = false; - if (!now && was && SHEET.matches && pageY) window.scrollTo(0, pageY); + if (!now && sheetOver !== null) { + if (SHEET.matches && pageY && sheetOver === sansAgent()) window.scrollTo(0, pageY); + sheetOver = null; pageY = window.scrollY; + } if (!now && was) { const a = document.activeElement; if (!a || a === document.body || !view?.contains(a)) view?.querySelector(`[data-focus-key="${CSS.escape(`agent:${was}`)}"]`)?.focus({ preventScroll: true }); diff --git a/packages/webui/tests/agent-drawer-browser.test.mjs b/packages/webui/tests/agent-drawer-browser.test.mjs index a7d0d636b..d63a4bfc0 100644 --- a/packages/webui/tests/agent-drawer-browser.test.mjs +++ b/packages/webui/tests/agent-drawer-browser.test.mjs @@ -18,7 +18,7 @@ const at = minutesAgo => new Date(Date.now() - minutesAgo * 60000).toISOString() const HIRE = '0f3c1a2b-4d5e-4f60-8a7b-9c0d1e2f3a4b'; const THREAD = '7b1e2c3d-4f50-4a61-8b72-9c83d4e5f6a7'; -function fixture() { +function fixture(tweak) { const LIST = [ { id: 'acme', label: 'Acme Studio', theme: 'cobalt' }, { id: 'beta', label: 'Beta Works', theme: 'grove' }, @@ -52,6 +52,7 @@ function fixture() { model: {}, }, }; + tweak?.(DATA); const value = (id, name) => Promise.resolve(DATA[id]?.[name] ?? (['usage', 'limits'].includes(name) ? {} : [])); const opts = id => ({ bus: { inbox: () => value(id, 'inbox'), agents: () => value(id, 'agents'), 'thread.claims': () => value(id, 'claims'), tasks: () => value(id, 'tasks'), usage: () => value(id, 'usage'), limits: () => value(id, 'limits'), decisions: () => value(id, 'decisions') }, @@ -115,8 +116,8 @@ const STUB = `(() => { }; })();`; -async function setup(t, { viewport = [1440, 900], hash = '#/agents', stub = true, scripts = [] } = {}) { - const server = await startServer({ port: 0, sso: createDevOwner(), organizations: fixture(), log: () => {} }); +async function setup(t, { viewport = [1440, 900], hash = '#/agents', stub = true, scripts = [], data } = {}) { + const server = await startServer({ port: 0, sso: createDevOwner(), organizations: fixture(data), log: () => {} }); t.after(() => close(server)); const b = await browser({ machine: false }); t.after(() => b.close()); await b.viewport(...viewport); @@ -186,8 +187,8 @@ test('the drawer shows each field from its read: name, organization, role and so const decisions = await b.evaluate(`[...document.querySelectorAll('${d} [data-drawer-decisions] li a')].map(a => [a.textContent.trim(), a.getAttribute("href")])`); assert.deepEqual(decisions, [['Ship the hero copy?', '#/inbox?d=acme%3Adec-1']]); // SP18: the agents read lists only roles a run holds now, and its time is when that run took the role, - // so Last activity is when the current run started, 40 minutes before the read, with the time itself. - assert.match(await text(`${d} [data-drawer-activity]`), /^current run started 4[01] min ago$/); + // so Last activity is when coder's running run took the role, 40 minutes before the read, with the time itself. + assert.match(await text(`${d} [data-drawer-activity]`), /^its run took the role 4[01] min ago$/); const started = await attr(`${d} [data-drawer-activity] time`, 'datetime'); assert.ok(Math.abs(Date.now() - Date.parse(started) - 40 * 60000) < 90000, started); assert.match(await attr(`${d} [data-drawer-activity] time`, 'title'), /\d/); @@ -217,6 +218,33 @@ test('a hired agent shows where its role came from; a not-running agent says not assert.equal(await has(`${d} [data-drawer-activity] time`), false); }); +// SP18 review: a claim dates the agent only when the instances read lists its run as running. +test('SP18 review: Last activity counts only a claim whose run is running', async t => { + // Coder runs run-2, but the role is still held by run-1, whose process ended: nothing dates run-2 yet. + { + const { wait, text, has } = await setup(t, { hash: '#/agents?agent=acme%3Acoder', data: d => { d.acme.instances.coder.running = ['run-2']; } }); + const d = '[data-ws-drawer="acme:coder"]'; + await wait(`${open('acme:coder')} && /running$/.test(document.querySelector('${d} [data-drawer-state]')?.textContent ?? '')`); + assert.equal(await text(`${d} [data-drawer-activity]`), 'not recorded: its run holds no role or conversation yet'); + assert.equal(await has(`${d} [data-drawer-activity] time`), false); + } + // Coder runs nothing, and a claim from three days ago is left: not running, and no time from that claim. + { + const { wait, text, has } = await setup(t, { hash: '#/agents?agent=acme%3Acoder', data: d => { d.acme.instances.coder.running = []; d.acme.agents[0].at = at(3 * 24 * 60); d.acme.agents[0].working = null; } }); + const d = '[data-ws-drawer="acme:coder"]'; + await wait(`${open('acme:coder')} && /not running$/.test(document.querySelector('${d} [data-drawer-state]')?.textContent ?? '')`); + assert.equal(await text(`${d} [data-drawer-activity]`), 'not recorded: no run holds it now, and no read keeps when its last run ended'); + assert.equal(await has(`${d} [data-drawer-activity] time`), false); + } + // Two runs, one holding the role: the line says it is the latest of them. + { + const { wait, text } = await setup(t, { hash: '#/agents?agent=acme%3Acoder', data: d => { d.acme.instances.coder.running = ['run-1', 'run-2']; } }); + const d = '[data-ws-drawer="acme:coder"]'; + await wait(`${open('acme:coder')} && !!document.querySelector('${d} [data-drawer-activity] time')`); + assert.match(await text(`${d} [data-drawer-activity]`), /^the latest of its 2 runs took the role 4[01] min ago$/); + } +}); + test('SP16: a pack hire names its pack and the template the packs read gives; a refused read says so', async t => { const { b, base, wait, text } = await setup(t, { hash: '#/agents?agent=beta%3Aresearch-2' }); const d = '[data-ws-drawer="beta:research-2"]'; @@ -508,7 +536,7 @@ test('Message opens the agent\'s thread in an Assistant pane; Stop asks first an // SP16: Message is offered, so no line says why it is not. assert.equal(await has('[data-ws-drawer="acme:assistant"] [data-drawer-nomessage]'), false); // SP18: a conversation agent's run took its conversation 5 minutes before the read (thread.claims' time). - assert.match(await text('[data-ws-drawer="acme:assistant"] [data-drawer-activity]'), /^current run started [56] min ago$/); + assert.match(await text('[data-ws-drawer="acme:assistant"] [data-drawer-activity]'), /^its run took the conversation [56] min ago$/); // A role agent holds no thread to open, so it has no Message; it can still be stopped. await b.evaluate('location.hash = "#/agents?agent=acme%3Acoder"'); await wait(`${open('acme:coder')} && document.querySelector('[data-ws-drawer="acme:coder"] [data-drawer-stop]')`); @@ -618,6 +646,31 @@ test('SP18: at 390 wide the open sheet is the whole screen, the page under it do assert.ok(await b.evaluate('document.documentElement.scrollHeight') > 900, 'at 1440 the page beside the drawer keeps its height'); }); +// SP18 review: only Close (or Back to the same page) puts the page back. A link in the sheet goes to a new +// page, which starts at its top, and the place kept for the page under the sheet is not used later either. +test('SP18 review: at 390 a link in the sheet opens its page at the top, and a later page does not jump', async t => { + const { b, wait } = await setup(t, { viewport: [390, 844], hash: '#/orgs/acme/organization' }); + const link = JSON.stringify(sessionLink('acme:coder')); + await wait(`document.querySelector(${link}) && document.querySelectorAll("[data-org-settings] [data-org-setting]").length > 10`); + await b.evaluate(`document.querySelector(${link}).scrollIntoView({ block: 'center' })`); + const at = await b.evaluate('Math.round(scrollY)'); + assert.ok(at > 100, `the row is down the page: ${at}`); + await b.evaluate(`document.querySelector(${link}).click()`); + await wait(open('acme:coder')); + await b.evaluate(`${drawer('acme:coder')}.querySelector("[data-drawer-task] a").click()`); + await wait(`${noDrawer} && location.hash.startsWith("#/orgs/acme/tasks?task=")`); + await b.evaluate('new Promise(r => setTimeout(r, 300))'); + // A long page, so a jump to the kept place would show. + await b.evaluate('document.body.style.minHeight = "4000px"; new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)))'); + const y = await b.evaluate('Math.round(scrollY)'); + assert.ok(y <= 1, `the Task page is at its top, not at ${at}: ${y}`); + // The next page with no drawer does not take the kept place either. + await b.evaluate('location.hash = "#/orgs/acme/organization"'); + await wait(`document.querySelectorAll("[data-org-settings] [data-org-setting]").length > 10`); + await b.evaluate('new Promise(r => setTimeout(r, 300))'); + assert.ok(await b.evaluate('Math.round(scrollY)') <= 1, `the organization page opens at its top: ${await b.evaluate('Math.round(scrollY)')}`); +}); + // #1873 triage-followups: the page focuses its heading when its first render ends. On load the page // starts a second render that reads GET /api/workspace again, so when the first render's read is slow // the second draws the rows first and a reader can open a drawer before the first render ends. Its late -- 2.54.0 From 9343baffff234a8596f106022e4d591b5f90ddbd Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Wed, 18 Nov 2026 11:18:10 -0600 Subject: [PATCH 3/4] fix(webui): drawer polish review round 2: the kept scroll place is dropped as soon as the address leaves the page under the sheet, so a project or Assistant page that bus.js draws without afterPaint no longer leaves it for a later page; the scroll tests make every page long first and wait for the linked page's own content; Last activity says one of its N runs, and a run when the runs were not read (#1873, lane sp18-drawer-polish) --- packages/webui/src/public/workspace.js | 9 +++-- .../webui/tests/agent-drawer-browser.test.mjs | 35 +++++++++++++------ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/packages/webui/src/public/workspace.js b/packages/webui/src/public/workspace.js index 5fc787ade..44a997ec9 100644 --- a/packages/webui/src/public/workspace.js +++ b/packages/webui/src/public/workspace.js @@ -1356,9 +1356,11 @@ const claims = [a.s ? { ...a.s, what: 'the role' } : null, ...arr(body?.sessions).filter(x => x?.kind === 'thread' && x.org === org && x.instance === key).map(x => ({ ...x, what: 'the conversation' }))] .filter(c => c && msOf(c.claimedAt) !== null && (!runs || runs.includes(c.run))).sort((x, y) => msOf(y.claimedAt) - msOf(x.claimedAt)); const last = claims[0], claimWhy = notRead(['agents', 'claims']); - const activity = last ? `${runs && runs.length > 1 ? `the latest of its ${runs.length} runs` : 'its run'} took ${last.what} ` + // With the runs not read, nothing checked the claim against a live run, so the line says "a run". + const activity = last ? `${!runs ? 'a run' : runs.length > 1 ? `one of its ${runs.length} runs` : 'its run'} took ${last.what} ` : `${claimWhy ? `not read: ${esc(claimWhy)}` : runs?.length ? `not recorded: ${runs.length > 1 ? 'its runs hold' : 'its run holds'} no role or conversation yet` + : !runs ? 'not recorded: no run holds its role or a conversation in the reads, and its runs were not read' : 'not recorded: no run holds it now, and no read keeps when its last run ended'}`; const fields = [ field('org', 'Organization', orgChip(o, org)), @@ -1388,10 +1390,13 @@ // SP18: below 701 px the open drawer is a sheet and shell.css holds the page under it to one screen, which // scrolls the page to the top. The page's place is kept while no drawer is open, with the page the sheet // opened over. It is put back only when the drawer closes onto that same page (Close, Escape or Back); a - // link in the sheet goes to another page, which starts at its top, and the kept place is dropped. + // link in the sheet goes to another page, which starts at its top, and the kept place is dropped. Some + // pages a link opens (a project, the Assistant) are drawn without afterPaint, so the place is dropped as + // soon as the address leaves the page under the sheet. const SHEET = window.matchMedia('(max-width:700px)'); let pageY = 0, sheetOver = null; window.addEventListener('scroll', () => { if (!document.querySelector('#bus-view [data-ws-drawer]')) pageY = window.scrollY; }, { passive: true }); + window.addEventListener('hashchange', () => { if (sheetOver !== null && sansAgent() !== sheetOver) { sheetOver = null; pageY = 0; } }); // bus.js calls this after each paint: focus moves into a drawer a row opened, and back to the row // when the drawer has closed and focus was left nowhere. function afterPaint() { diff --git a/packages/webui/tests/agent-drawer-browser.test.mjs b/packages/webui/tests/agent-drawer-browser.test.mjs index d63a4bfc0..040e1995b 100644 --- a/packages/webui/tests/agent-drawer-browser.test.mjs +++ b/packages/webui/tests/agent-drawer-browser.test.mjs @@ -241,7 +241,15 @@ test('SP18 review: Last activity counts only a claim whose run is running', asyn const { wait, text } = await setup(t, { hash: '#/agents?agent=acme%3Acoder', data: d => { d.acme.instances.coder.running = ['run-1', 'run-2']; } }); const d = '[data-ws-drawer="acme:coder"]'; await wait(`${open('acme:coder')} && !!document.querySelector('${d} [data-drawer-activity] time')`); - assert.match(await text(`${d} [data-drawer-activity]`), /^the latest of its 2 runs took the role 4[01] min ago$/); + assert.match(await text(`${d} [data-drawer-activity]`), /^one of its 2 runs took the role 4[01] min ago$/); + } + // The instances read fails: nothing checked the claim against a live run, so the line says "a run". + { + const fail = `(() => { const f = window.fetch; window.fetch = (u, i) => /\\/api\\/orgs\\/acme\\/bus\\/instances$/.test(String(u)) ? Promise.resolve(new Response('{}', { status: 503 })) : f(u, i); })();`; + const { wait, text } = await setup(t, { hash: '#/agents?agent=acme%3Acoder', scripts: [fail] }); + const d = '[data-ws-drawer="acme:coder"]'; + await wait(`${open('acme:coder')} && /^State not read/.test(document.querySelector('${d} [data-drawer-state]')?.textContent ?? '')`); + assert.match(await text(`${d} [data-drawer-activity]`), /^a run took the role 4[01] min ago$/); } }); @@ -648,27 +656,32 @@ test('SP18: at 390 wide the open sheet is the whole screen, the page under it do // SP18 review: only Close (or Back to the same page) puts the page back. A link in the sheet goes to a new // page, which starts at its top, and the place kept for the page under the sheet is not used later either. -test('SP18 review: at 390 a link in the sheet opens its page at the top, and a later page does not jump', async t => { +// The Task page is drawn through afterPaint; a project page is drawn by bus.js without it. +for (const [label, sel, hashStart, ready] of [ + ['Task', '[data-drawer-task] a', '#/orgs/acme/tasks?task=', 'document.querySelector("[data-tasks-board]")'], + ['Project', '[data-drawer-project] a', '#/orgs/acme/projects/p-site', 'document.querySelector("#bus-view h1")'], +]) test(`SP18 review: at 390 the sheet's ${label} link opens its page at the top, and a later page does not jump`, async t => { const { b, wait } = await setup(t, { viewport: [390, 844], hash: '#/orgs/acme/organization' }); const link = JSON.stringify(sessionLink('acme:coder')); await wait(`document.querySelector(${link}) && document.querySelectorAll("[data-org-settings] [data-org-setting]").length > 10`); + // Every page is long, so a jump to the kept place would show wherever it lands. + await b.evaluate('document.head.insertAdjacentHTML("beforeend", "")'); await b.evaluate(`document.querySelector(${link}).scrollIntoView({ block: 'center' })`); const at = await b.evaluate('Math.round(scrollY)'); assert.ok(at > 100, `the row is down the page: ${at}`); await b.evaluate(`document.querySelector(${link}).click()`); await wait(open('acme:coder')); - await b.evaluate(`${drawer('acme:coder')}.querySelector("[data-drawer-task] a").click()`); - await wait(`${noDrawer} && location.hash.startsWith("#/orgs/acme/tasks?task=")`); - await b.evaluate('new Promise(r => setTimeout(r, 300))'); - // A long page, so a jump to the kept place would show. - await b.evaluate('document.body.style.minHeight = "4000px"; new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)))'); + await b.evaluate(`${drawer('acme:coder')}.querySelector(${JSON.stringify(sel)}).click()`); + await wait(`${noDrawer} && location.hash.startsWith(${JSON.stringify(hashStart)}) && ${ready}`); + await b.evaluate('new Promise(r => setTimeout(r, 500))'); const y = await b.evaluate('Math.round(scrollY)'); - assert.ok(y <= 1, `the Task page is at its top, not at ${at}: ${y}`); + assert.ok(y <= 1, `the ${label} page is at its top, not at ${at}: ${y}`); // The next page with no drawer does not take the kept place either. await b.evaluate('location.hash = "#/orgs/acme/organization"'); - await wait(`document.querySelectorAll("[data-org-settings] [data-org-setting]").length > 10`); - await b.evaluate('new Promise(r => setTimeout(r, 300))'); - assert.ok(await b.evaluate('Math.round(scrollY)') <= 1, `the organization page opens at its top: ${await b.evaluate('Math.round(scrollY)')}`); + await wait('document.querySelectorAll("[data-org-settings] [data-org-setting]").length > 10'); + await b.evaluate('new Promise(r => setTimeout(r, 500))'); + const later = await b.evaluate('Math.round(scrollY)'); + assert.ok(later <= 1, `the organization page opens at its top: ${later}`); }); // #1873 triage-followups: the page focuses its heading when its first render ends. On load the page -- 2.54.0 From 2d44750b96a5618212ee48ffdd9133ec9c9d6e23 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Wed, 18 Nov 2026 11:26:45 -0600 Subject: [PATCH 4/4] fix(webui): drawer polish review round 3 notes: with the runs not read and no claim, Last activity names the agents and claims reads, with a test for chief; the Project scroll test waits for the Projects page heading; a test comment matches the one of its runs wording (#1873, lane sp18-drawer-polish) --- packages/webui/src/public/workspace.js | 2 +- .../webui/tests/agent-drawer-browser.test.mjs | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/webui/src/public/workspace.js b/packages/webui/src/public/workspace.js index 44a997ec9..32e993088 100644 --- a/packages/webui/src/public/workspace.js +++ b/packages/webui/src/public/workspace.js @@ -1360,7 +1360,7 @@ const activity = last ? `${!runs ? 'a run' : runs.length > 1 ? `one of its ${runs.length} runs` : 'its run'} took ${last.what} ` : `${claimWhy ? `not read: ${esc(claimWhy)}` : runs?.length ? `not recorded: ${runs.length > 1 ? 'its runs hold' : 'its run holds'} no role or conversation yet` - : !runs ? 'not recorded: no run holds its role or a conversation in the reads, and its runs were not read' + : !runs ? 'not recorded: the agents and claims reads show no run holding its role or a conversation, and its runs were not read' : 'not recorded: no run holds it now, and no read keeps when its last run ended'}`; const fields = [ field('org', 'Organization', orgChip(o, org)), diff --git a/packages/webui/tests/agent-drawer-browser.test.mjs b/packages/webui/tests/agent-drawer-browser.test.mjs index 040e1995b..62773fce1 100644 --- a/packages/webui/tests/agent-drawer-browser.test.mjs +++ b/packages/webui/tests/agent-drawer-browser.test.mjs @@ -236,7 +236,7 @@ test('SP18 review: Last activity counts only a claim whose run is running', asyn assert.equal(await text(`${d} [data-drawer-activity]`), 'not recorded: no run holds it now, and no read keeps when its last run ended'); assert.equal(await has(`${d} [data-drawer-activity] time`), false); } - // Two runs, one holding the role: the line says it is the latest of them. + // Two runs, one holding the role: no read says which run is newer, so the line says one of them. { const { wait, text } = await setup(t, { hash: '#/agents?agent=acme%3Acoder', data: d => { d.acme.instances.coder.running = ['run-1', 'run-2']; } }); const d = '[data-ws-drawer="acme:coder"]'; @@ -251,6 +251,15 @@ test('SP18 review: Last activity counts only a claim whose run is running', asyn await wait(`${open('acme:coder')} && /^State not read/.test(document.querySelector('${d} [data-drawer-state]')?.textContent ?? '')`); assert.match(await text(`${d} [data-drawer-activity]`), /^a run took the role 4[01] min ago$/); } + // The same failed read for chief, which holds no role and no conversation: the line names both gaps. + { + const fail = `(() => { const f = window.fetch; window.fetch = (u, i) => /\\/api\\/orgs\\/acme\\/bus\\/instances$/.test(String(u)) ? Promise.resolve(new Response('{}', { status: 503 })) : f(u, i); })();`; + const { wait, text, has } = await setup(t, { hash: '#/agents?agent=acme%3Achief', scripts: [fail] }); + const d = '[data-ws-drawer="acme:chief"]'; + await wait(`${open('acme:chief')} && /^State not read/.test(document.querySelector('${d} [data-drawer-state]')?.textContent ?? '')`); + assert.equal(await text(`${d} [data-drawer-activity]`), 'not recorded: the agents and claims reads show no run holding its role or a conversation, and its runs were not read'); + assert.equal(await has(`${d} [data-drawer-activity] time`), false); + } }); test('SP16: a pack hire names its pack and the template the packs read gives; a refused read says so', async t => { @@ -656,10 +665,11 @@ test('SP18: at 390 wide the open sheet is the whole screen, the page under it do // SP18 review: only Close (or Back to the same page) puts the page back. A link in the sheet goes to a new // page, which starts at its top, and the place kept for the page under the sheet is not used later either. -// The Task page is drawn through afterPaint; a project page is drawn by bus.js without it. +// The Task page is drawn through afterPaint; a project address is drawn by bus.js's chat branch without it +// (this fixture has no chat backend, so that page is the Projects list saying the route is invalid). for (const [label, sel, hashStart, ready] of [ ['Task', '[data-drawer-task] a', '#/orgs/acme/tasks?task=', 'document.querySelector("[data-tasks-board]")'], - ['Project', '[data-drawer-project] a', '#/orgs/acme/projects/p-site', 'document.querySelector("#bus-view h1")'], + ['Project', '[data-drawer-project] a', '#/orgs/acme/projects/p-site', 'document.querySelector("#bus-view h1")?.textContent.trim() === "Projects"'], ]) test(`SP18 review: at 390 the sheet's ${label} link opens its page at the top, and a later page does not jump`, async t => { const { b, wait } = await setup(t, { viewport: [390, 844], hash: '#/orgs/acme/organization' }); const link = JSON.stringify(sessionLink('acme:coder')); -- 2.54.0