diff --git a/packages/model-proxy/src/admin-control.mjs b/packages/model-proxy/src/admin-control.mjs index 8fd6d6f65..59d51fd9b 100644 --- a/packages/model-proxy/src/admin-control.mjs +++ b/packages/model-proxy/src/admin-control.mjs @@ -76,6 +76,7 @@ export function createProxyAdmin({ dataRoot, configDir, instance = null, unitDir try { fresh = (await riders()).find(r => r?.id === id); } catch { fresh = null; } if (!fresh) return { id, outcome: 'skipped', reason: 'unreadable' }; const again = decide(fresh, ridden()); + if (again === 'already') return { id, outcome: 'already' }; if (again !== 'ready') return { id, outcome: 'skipped', reason: again }; try { receipt({ op: 'ride-intent', org: id }); } catch { return { id, outcome: 'skipped', reason: 'not-recorded' }; } try { await rider.call('plugins.set', { revision: current.revision, plugins: { 'model-provider': [...providers, 'cliproxy'] } }); } @@ -89,7 +90,12 @@ export function createProxyAdmin({ dataRoot, configDir, instance = null, unitDir return { id, outcome: 'added' }; } async function rideSummary() { - try { const wasRidden = ridden(); return (await riders()).map(r => ({ id: r.id, state: decide(r, wasRidden) })); } catch { return null; } + // settings-p3 (review P3-3): a stand-in organization with no bus status (the single-business + // Console) can't be moved; running null says so before any Ride all run. + try { + const wasRidden = ridden(); + return (await riders()).map(r => { const state = decide(r, wasRidden); return state === 'fixture' && typeof r.status !== 'function' ? { id: r.id, state, running: null } : { id: r.id, state }; }); + } catch { return null; } } function nextSteps({ release, init, unitState, fence, lock }) { if (!release.fetched || release.problem) return ['fetch']; diff --git a/packages/model-proxy/tests/ride.test.mjs b/packages/model-proxy/tests/ride.test.mjs index 858848cdc..bff59095d 100644 --- a/packages/model-proxy/tests/ride.test.mjs +++ b/packages/model-proxy/tests/ride.test.mjs @@ -228,6 +228,16 @@ test('settings-p3 R1: the change log is read again before each add, and a read t } }); +test('settings-p3 review P3-1: an organization that took cliproxy during the run reads as already using it, with no add', async t => { + const b = bus({ providers: [] }); + let reads = 0; + const f = admin(t, { riders: async () => [{ id: 'o', fixture: false, cliproxy: reads++ > 0, changes: '', call: b.call }] }); + const r = await f.admin.rideAll(); + assert.deepEqual([r.added, r.already, r.skipped], [[], ['o'], []]); + assert.equal(b.calls.some(([v]) => v === 'plugins.set'), false); + assert.deepEqual(receipts(f.dataRoot).filter(x => x.op === 'ride-intent'), []); +}); + test('an intent receipt that cannot be written stops that add before plugins.set', async t => { const b = bus({ providers: [] }); const f = admin(t, { riders: async () => [{ id: 'w', fixture: false, cliproxy: false, changes: '', call: b.call }] }); @@ -422,6 +432,8 @@ test('a fixture organization moves only when stopped, with a proxy, a riding bus assert.deepEqual(await f.admin.rideMove({ org: 'no-status', principal }), { org: 'no-status', moved: false, reason: 'not-available' }); const listed = await f.admin.rideAll(); assert.deepEqual(listed.fixtures, [{ id: 'stand-in', running: false }, { id: 'live', running: true }, { id: 'busy', running: true }, { id: 'unproven', running: true }, { id: 'no-status', running: null }]); + // settings-p3 review P3-3: the status summary says so before any run, without asking any bus. + assert.deepEqual((await f.admin.status()).ride.filter(r => r.state === 'fixture'), [{ id: 'stand-in', state: 'fixture' }, { id: 'live', state: 'fixture' }, { id: 'busy', state: 'fixture' }, { id: 'unproven', state: 'fixture' }, { id: 'no-status', state: 'fixture', running: null }]); ownerNow = { ...owner, proxy: false }; assert.deepEqual(await f.admin.rideMove({ org: 'stand-in', principal }), { org: 'stand-in', moved: false, reason: 'no-proxy' }); ownerNow = { ...owner, riding: false }; diff --git a/packages/webui/src/public/display.js b/packages/webui/src/public/display.js index 1ef823fb6..7c9812507 100644 --- a/packages/webui/src/public/display.js +++ b/packages/webui/src/public/display.js @@ -946,9 +946,9 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo }; const rideReason = code => RIDE_REASONS[code] ?? `The change was refused (${code}).`; let rideResult = null; - // What the Ride all box lists (paintRide): skipped organizations and stand-in ones. + // What the Ride all box lists (paintRide): organizations that can ride, skipped ones and stand-in ones. const rideListed = () => { const ride = Array.isArray(state.ride) ? state.ride : []; - return (rideResult?.skipped ?? ride.filter(r => !['ready', 'already', 'fixture'].includes(r.state))).length + (rideResult?.fixtures ?? ride.filter(r => r.state === 'fixture')).length; }; + return ride.filter(r => r.state === 'ready').length + (rideResult?.skipped ?? ride.filter(r => !['ready', 'already', 'fixture'].includes(r.state))).length + (rideResult?.fixtures ?? ride.filter(r => r.state === 'fixture')).length; }; const li = text => { const el = document.createElement('li'); el.textContent = text; return el; }; function paintRide() { const box = $('proxy-ride'), ride = Array.isArray(state.ride) ? state.ride : null; @@ -961,8 +961,10 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo const go = $('proxy-ride-go'); go.disabled = !sendOk || Boolean(state.busy) || !ready; const skips = (rideResult?.skipped ?? ride.filter(r => !['ready', 'already', 'fixture'].includes(r.state)).map(r => ({ id: r.id, reason: r.state }))); $('proxy-ride-skips').replaceChildren(...skips.map(s => li(`Skipped ${s.id}: ${rideReason(s.reason)}`))); - const listed = rideResult?.fixtures ?? fixtures.map(f => ({ id: f.id })); + const listed = rideResult?.fixtures ?? fixtures.map(f => ({ id: f.id, running: f.running })); $('proxy-ride-fixtures').replaceChildren(...listed.map(f => { + // running null: no bus status here (the single-business Console), so moving is not available. + if (f.running === null) return li(`${f.id} uses stand-in models. Moving it is not available on this Console.`); const item = li(`${f.id} uses stand-in models, can be moved to the owner's models.${f.running === true ? ' Its bus is running: stop it first.' : ''} `); const move = document.createElement('button'); move.type = 'button'; move.className = 'btn'; move.textContent = `Move ${f.id}`; move.dataset.rideMove = f.id; move.disabled = !sendOk || Boolean(state.busy); diff --git a/packages/webui/tests/proxy-setup-browser.test.mjs b/packages/webui/tests/proxy-setup-browser.test.mjs index f078a7c39..3902e530a 100644 --- a/packages/webui/tests/proxy-setup-browser.test.mjs +++ b/packages/webui/tests/proxy-setup-browser.test.mjs @@ -372,6 +372,32 @@ test('settings-p3: the done line does not say every organization while the Ride assert.deepEqual(await b.evaluate('window.__unexpected'), []); }); +// settings-p3 review P2-1: an owner who can't send gets no Ride all step, so the done line shows while an +// organization can still ride; it must not say every organization can see the models. +test('settings-p3: the done line does not say every organization while one can still ride and the owner cannot send', { timeout: 90000 }, async t => { + const done = { ...running, organizations: [{ id: 'acme', proxy: 'shared', catalogue: { status: 'ready', models: 2 } }], ride: [{ id: 'acme', state: 'already' }, { id: 'north', state: 'ready' }] }; + const { f, b, wait } = await w15Fixture(t, { scenario: { ...scenario(done, { proxyAdminSend: false }), ...answering(1), '/api/triage/route': savedRoute } }); + await b.navigate(f.base + '/#/settings/model-proxy'); + await wait('document.querySelector("#proxy-setup-next [data-next]")?.dataset.next==="done"'); + assert.equal(await b.evaluate('document.querySelector("#proxy-setup-next").textContent'), 'The model service is set up. Some organizations still need a step under Use your models in every organization.'); + assert.match(await b.evaluate('document.querySelector("#proxy-ride-text").textContent'), /1 organization can ride now\./); + assert.deepEqual(await b.evaluate('window.__unexpected'), []); +}); + +// settings-p3 review P3-3: on a single-business Console a stand-in organization has no bus status +// (running null), so the page says moving is not available there and offers no Move button. +test('settings-p3: a stand-in organization with no bus status is not offered a Move', { timeout: 90000 }, async t => { + const state = { ...running, organizations: [{ id: 'acme', proxy: 'shared', catalogue: { status: 'ready', models: 2 } }], ride: [{ id: 'acme', state: 'already' }, { id: 'west', state: 'fixture', running: null }, { id: 'east', state: 'fixture' }] }; + const { f, b, wait } = await w15Fixture(t, { scenario: { ...scenario(state), ...answering(1), '/api/triage/route': savedRoute } }); + await b.navigate(f.base + '/#/settings/model-proxy'); + await wait('document.querySelector("#proxy-ride-fixtures li")'); + assert.deepEqual(await b.evaluate('[...document.querySelectorAll("#proxy-ride-fixtures li")].map(li => li.firstChild.textContent.trim())'), + ['west uses stand-in models. Moving it is not available on this Console.', "east uses stand-in models, can be moved to the owner's models."]); + assert.equal(await b.evaluate('document.querySelector("[data-ride-move=west]")'), null); + assert.equal(await b.evaluate('document.querySelector("[data-ride-move=east]").disabled'), false); + assert.deepEqual(await b.evaluate('window.__unexpected'), []); +}); + // settings-p3 (re-check 3 P3-5): a ready catalogue the bus picked up late (launchRestart) keeps the // organization listed with its Restart, holds the next step, and Model setup never says done. test('settings-p3: an organization whose agents start on the models only after a restart is listed and holds the next step', { timeout: 90000 }, async t => { diff --git a/packages/webui/tests/settings-s1-browser.test.mjs b/packages/webui/tests/settings-s1-browser.test.mjs index 7b6468cdc..37bbf5f28 100644 --- a/packages/webui/tests/settings-s1-browser.test.mjs +++ b/packages/webui/tests/settings-s1-browser.test.mjs @@ -217,8 +217,11 @@ test('settings-s1 B6: a stopped organization keeps its refused restart on screen assert.equal(await b.evaluate('(([a, w]) => w.getBoundingClientRect().top >= a.getBoundingClientRect().bottom)([...document.querySelectorAll("[data-org-down=gamma] .banner > p")])'), true, 'why line under the headline'); const primary = 'document.querySelector("[data-org-down=gamma] [data-org-restart=gamma]").classList.contains("primary")'; assert.equal(await b.evaluate(primary), true, 'Restart is primary before any refusal'); + // The refusal's own repaint (console-restart.js paintOrg) is read when it lands, before the page renders again. + await b.evaluate(`window.__firstPaint = null; new MutationObserver((_, o) => { const d = document.querySelector("[data-org-down=gamma] [data-org-restart-detail]"); if (d) { window.__firstPaint = d.closest("[data-org-restart-box]").querySelector("[data-org-restart]").classList.contains("primary"); o.disconnect(); } }).observe(document.body, { subtree: true, childList: true }); true`); await b.evaluate('document.querySelector("[data-org-down=gamma] [data-org-restart=gamma]").click(); true'); await wait('window.__writes.length === 1 && document.querySelector("[data-org-down=gamma] [data-org-restart-detail]")'); + assert.equal(await b.evaluate('window.__firstPaint'), false, 'the refusal repaint does not keep Restart primary'); // The page renders again after the restart; the refusal stays, with its plain line first. await new Promise(r => setTimeout(r, 500)); const receipt = await text('[data-org-down=gamma] [data-org-restart-receipt]');