fix(webui): settings-s5 recheck: coming back to an organization's Models page reads the model service again, so the not set up line goes once the owner has set it up (N1); a switch left while it writes no longer moves focus to its outcome line on the next visit, and a render that paints no outcome line drops the focus request (N2); tests red on da123f6dd (#1873, lane settings-s5)

This commit was merged in pull request #2007.
This commit is contained in:
jason.woltje committed 2026-11-19 21:48:50 -06:00
1 parent 55f9652f6a
commit e6f6f5445b
2 files changed
+35 -2

No files matched your search

+7 -2
View File
@@ -1497,7 +1497,8 @@
// P3-2: a failed read before the write changed nothing and says so, with Read again.
}catch{if(epoch!==orgEpoch)return;if(sent){modelsReceipt='Outcome unknown. Read the page again before trying.';modelsReceiptKind='banner ref';harnessSettings=null;}else{modelsReceipt='Not changed. Nothing was written.';modelsReceiptKind='banner err';harnessSettings=false;}}
// P2-4: the render that shows the outcome moves focus to it (render() below).
finally{if(epoch===orgEpoch){modelsBusy=false;modelsFocus=!!modelsReceipt;if(!out())render(harnessSettings===null);}}
// Recheck N2: only while the page is still shown; a switch left mid-write does not take focus later.
finally{if(epoch===orgEpoch){modelsBusy=false;modelsFocus=!!modelsReceipt&&routeOf().split('?')[0]==='/settings/routing';if(!out())render(harnessSettings===null);}}
}
document.addEventListener('change',e=>{if(e.target.id==='models-yours'&&e.target.checked)setModels(true);});
document.addEventListener('click',e=>{if(e.target.closest?.('#models-stop'))setModels(false);else if(e.target.id==='models-read'){harnessSettings=null;harnessReceipt='';modelsReceipt='';modelsReceiptKind='';render(false);}});
@@ -1975,6 +1976,8 @@
if ((navigated || path !== '/settings/organizations') && orgCleanup) {orgCleanup();orgCleanup=null;}
// Leaving a decision discards its confirmation immediately, including a preview in flight.
if (answer && (navigated || path !== (answer.org ? '/inbox' : `/inbox/${answer.id}`))) answer = null;
// Recheck N1: arriving at Models reads the model service again; a status read on an earlier visit may be out of date.
if (navigated && path === '/settings/routing' && (typeof shown === 'string' ? shown.split('?')[0] : shown) !== path && !serviceLoading) serviceState = null;
const g = ++gen, routeVersion = routesEditVersion;
const current = () => g === gen && route === routeOf() && !out();
// In organization mode #/ is the cross-organization dashboard; the processing controls stay on the board.
@@ -2113,7 +2116,9 @@
const h1 = $('bus-view').querySelector('h1');
document.title = path === '/settings/business' && $('settings-page-title') ? `Settings · ${window.MosaicOrg ? 'Organization' : 'Business'} · Mosaic Console` : `${h1 ? h1.textContent : 'Console'} · Mosaic Console`;
// settings-s5 review P2-4: after a switch on Organization > Models, focus goes to its outcome line.
if (modelsFocus && $('models-receipt')) { modelsFocus = false; if (k) restore(k); $('models-receipt').focus({ preventScroll: true }); }
// Recheck N2: a render that paints no outcome line drops the request instead of keeping it.
const focusModels = modelsFocus && $('models-receipt'); modelsFocus = false;
if (focusModels) { if (k) restore(k); focusModels.focus({ preventScroll: true }); }
else if (k) restore(k);
// Message on the Board (row 95) lands in the form it opened, addressed to the role.
else if (focusSend && $('send-body')) { $('send-body').focus(); announce(`Message to ${draft.to}`); }
@@ -233,6 +233,34 @@ test('settings-s5: Use your models shows Saving while its write is out', { timeo
await wait('/^Saved\./.test(document.querySelector("#models-receipt")?.textContent ?? "")');
});
// Recheck N1: the not set up line goes once the owner sets the service up and comes back to Models.
test('settings-s5: coming back to Models after setting the service up reads it again, and the not set up line goes', { timeout: 90000 }, async t => {
const { b, wait } = await setup(t, { path: '/#/settings/routing?org=acme', stub: { service: { ...SERVICE_UP, init: { initialized: false, partial: false, problem: null, files: [] } } } });
await wait('document.querySelector("#models-service") && document.querySelector("#models-in-force")?.textContent.includes("does not use")');
await b.evaluate(`window.__s5.service = ${JSON.stringify(SERVICE_UP)}; location.hash = '#/settings/agents?org=acme'; true`);
await wait('location.hash.startsWith("#/settings/agents") && !document.querySelector("#models-in-force") && document.querySelector("#settings-page-title")');
await b.evaluate(`location.hash = '#/settings/routing?org=acme'; true`);
await wait('document.querySelector("#models-in-force")?.textContent.includes("does not use") && !document.querySelector("#models-service")');
});
// Recheck N2: a switch left while it writes does not move focus on the next visit to Models.
test('settings-s5: leaving Models while a switch writes, the next visit focuses the page title, not the outcome line', { timeout: 90000 }, async t => {
const { b, wait, click } = await setup(t, { path: '/#/settings/routing?org=acme' });
await wait('document.querySelector("#models-in-force")?.textContent.includes("does not use")');
await b.evaluate(`(() => { const f = window.fetch; window.fetch = async (input, init = {}) => { if ((init.method || 'GET') !== 'GET' && String(input).endsWith('/proxy/plugins/set')) await new Promise(r => { window.__release = r; }); return f(input, init); }; return true; })()`);
await click('#models-yours');
await wait('typeof window.__release === "function"');
await b.evaluate(`location.hash = '#/settings/agents?org=acme'; true`);
await wait('location.hash.startsWith("#/settings/agents") && !document.querySelector("#models-in-force") && document.querySelector("#settings-page-title")');
await b.evaluate('window.__release(); true');
await wait('window.__sets.length === 1');
await new Promise(r => setTimeout(r, 400));
await b.evaluate(`location.hash = '#/settings/routing?org=acme'; true`);
await wait('document.querySelector("#models-in-force")?.textContent.includes("uses your models") && /^Saved\./.test(document.querySelector("#models-receipt")?.textContent ?? "")');
await new Promise(r => setTimeout(r, 300));
assert.equal(await b.evaluate('document.activeElement?.id'), 'settings-page-title');
});
// Review P3-2: a failed read before the write says nothing was written, and offers Read again.
test('settings-s5: a switch whose first read fails says Not changed, not Outcome unknown', { timeout: 90000 }, async t => {
const { b, wait, text, click } = await setup(t, { path: '/#/settings/routing?org=acme' });