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