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'); });