fix(webui): settings-s5: Model setup names each organization by its display name in the Move confirm, its result, the not-moved line and the skipped lines, and a stand-in organization's line says "your models" in step 3's words; before the first account step 3 names an organization the sidebar marks "can't start", with a Can't start badge, and stays closed; Technical details and Advanced show the timeouts init chose (firstOutputSeconds, rotateGraceMinutes, "the default" when proxy.json leaves them unset) from the status read; MosaicModelDots gains read() so another page can ask the marks to read the status again (#1873, lane settings-s5)
This commit is contained in:
1 parent
37c3854849
commit
81ca8399a2
3 files changed
+30
-13
No files matched your search
@@ -972,10 +972,13 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
|
||||
}
|
||||
function row(dl, term, text) { const dt = document.createElement('dt'), dd = document.createElement('dd'); dt.textContent = term; dd.textContent = text; dl.append(dt, dd); }
|
||||
function paintState() {
|
||||
// #1873 settings slice 5: the timeouts init chose, from the same read. Null is not set in
|
||||
// proxy.json, so the model service uses its default.
|
||||
const timeouts = s => !s || typeof s !== 'object' ? '' : `, wait for a first answer${s.firstOutputSeconds == null ? ': the default' : ` ${human(s.firstOutputSeconds)} seconds`}, old key kept${s.rotateGraceMinutes == null ? ' after a new one: the default' : ` ${human(s.rotateGraceMinutes)} minutes after a new one`}`;
|
||||
const { release, init, unit, fence, initLock } = state, dl = $('proxy-setup-state'); dl.replaceChildren();
|
||||
row(dl, 'Release', !release.fetched ? `Not fetched (pinned ${release.version}, panel ${release.panelVersion})` : release.verified ? `Fetched ${release.version}, panel ${release.panelVersion}, hashes verified` : `Fetched ${release.version}, hashes not verified (${release.problem})`);
|
||||
const files = init.files.filter(f => f.present).map(f => f.label).join(', ') || 'none';
|
||||
row(dl, 'Initialized', init.initialized ? `Yes, port ${init.settings?.port ?? '—'}` : init.partial ? `Partly (${init.problem ?? 'incomplete'}). Present: ${files}` : init.problem ? `No (${init.problem})` : 'No');
|
||||
row(dl, 'Initialized', init.initialized ? `Yes, port ${init.settings?.port ?? '—'}${timeouts(init.settings)}` : init.partial ? `Partly (${init.problem ?? 'incomplete'}). Present: ${files}` : init.problem ? `No (${init.problem})` : 'No');
|
||||
row(dl, 'Service', `${unit.unit}: ${unit.installed ? 'installed' : 'not installed'}, ${unit.active}${unit.pid ? `, pid ${unit.pid}` : ''}${unit.port ? `, port ${unit.port} ${unit.listening ? 'answering' : 'not answering'}` : ''}${unit.error ? ` (${unit.error})` : ''}`);
|
||||
row(dl, 'Fence', !fence.set ? 'Clear' : fence.invalid ? 'Set (unreadable fence file)' : `Set after ${fence.op ?? 'a key write'}${fence.org ? ` for ${fence.org}` : ''}${fence.time ? ` at ${window.MosaicLocalTime(fence.time)}` : ''}`);
|
||||
row(dl, 'Init lock', !initLock.present ? 'None' : initLock.clearable ? 'Stale: the bus is stopped and no model service files exist' : `Held: ${initLock.blockers.join('; ')}`);
|
||||
@@ -1118,7 +1121,16 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
|
||||
function paintOrgsCard() {
|
||||
const line = $('setup-step-organizations').querySelector('[data-step-summary]'), go = $('proxy-ride-go');
|
||||
go.className = 'btn'; delete line.dataset.next;
|
||||
if (!running() || !accountCount) { setCard('organizations', 'wait', 'Opens after your first account.'); return; }
|
||||
// settings-s5: before the first account, an organization the sidebar already marks "can't start" is
|
||||
// named here, so the card and the mark agree.
|
||||
if (!running() || !accountCount) {
|
||||
const blocked = running() ? cantStart().map(f => nameOf(f.id)) : [];
|
||||
if (!blocked.length) { setCard('organizations', 'wait', 'Opens after your first account.'); return; }
|
||||
const one = blocked.length === 1;
|
||||
// The card stays closed (Move needs a model from an account), with the mark's word on its badge.
|
||||
setCard('organizations', 'wait', `Opens after your first account. ${listNames(blocked)} can't start now: ${one ? 'it uses' : 'they use'} stand-in models and ${one ? 'its bus is' : 'their buses are'} stopped. After your first account, move ${one ? 'it' : 'them'} to your models under Use your models in every organization, then start ${one ? 'its bus' : 'their buses'}.`, { badge: ['badge-danger', "Can't start"] });
|
||||
return;
|
||||
}
|
||||
const step = orgStep(), names = needRestart().filter(restartHelps).map(o => nameOf(o.id));
|
||||
// settings-p3 (rebase re-check P3-1, settings-s4 P3): the Ride all box still lists an organization,
|
||||
// so not "every". One that turned the model service off is not waiting on anything: it is named.
|
||||
@@ -1200,7 +1212,11 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
|
||||
// After init, Advanced shows the settings init wrote, read-only.
|
||||
const dl = $('proxy-setup-settings'), s = init.initialized && init.settings && typeof init.settings === 'object' ? init.settings : null;
|
||||
dl.hidden = !s; $('proxy-setup-settings-note').hidden = !s; dl.replaceChildren();
|
||||
if (s) { row(dl, 'Port', human(s.port)); if (s.firstOutputSeconds !== undefined) row(dl, 'Wait for a first answer', `${human(s.firstOutputSeconds)} seconds`); }
|
||||
if (s) {
|
||||
row(dl, 'Port', human(s.port));
|
||||
if (s.firstOutputSeconds !== undefined) row(dl, 'Wait for a first answer', s.firstOutputSeconds === null ? 'The default' : `${human(s.firstOutputSeconds)} seconds`);
|
||||
if (s.rotateGraceMinutes !== undefined) row(dl, 'Old key kept after a new one', s.rotateGraceMinutes === null ? 'The default' : `${human(s.rotateGraceMinutes)} minutes`);
|
||||
}
|
||||
}
|
||||
// Programs that drive models: the harnesses this Console offers an organization, read on open.
|
||||
let programsRead = false;
|
||||
@@ -1255,15 +1271,15 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
|
||||
+ 'Admission gets stricter there: every launch route is checked, direct Anthropic routes too, and while the model service is down or fenced every launch in that organization is refused. '
|
||||
+ (ready ? `${ready} ${ready === 1 ? 'organization can' : 'organizations can'} ride now.` : 'No organization is waiting to ride.');
|
||||
const go = $('proxy-ride-go'); go.disabled = !sendOk || Boolean(state.busy) || !ready;
|
||||
$('proxy-ride-skips').replaceChildren(...rideSkips().map(s => li(`Skipped ${s.id}: ${rideReason(s.reason)}`)));
|
||||
$('proxy-ride-skips').replaceChildren(...rideSkips().map(s => li(`Skipped ${nameOf(s.id)}: ${rideReason(s.reason)}`)));
|
||||
const listedFixtures = rideResult?.fixtures ?? fixtures.map(f => ({ id: f.id, running: f.running }));
|
||||
$('proxy-ride-fixtures').replaceChildren(...listedFixtures.map(f => {
|
||||
// running null: no bus status here (the single-business Console), so moving is not available.
|
||||
const name = nameOf(f.id);
|
||||
if (f.running === null) return li(`${name} uses stand-in models. Moving it is not available on this Console.`);
|
||||
// settings-s4 review F2: running false is what the sidebar marks "can't start"; say so, and the fix.
|
||||
const item = li(f.running === false ? `${name} can't start: it uses stand-in models and its bus is stopped. Move it to the owner's models, then start its bus. `
|
||||
: `${name} uses stand-in models, can be moved to the owner's models.${f.running === true ? ' Its bus is running: stop it first.' : ''} `);
|
||||
const item = li(f.running === false ? `${name} can't start: it uses stand-in models and its bus is stopped. Move it to your models under Use your models in every organization, then start its bus. `
|
||||
: `${name} uses stand-in models, can be moved to your 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 ${name}`;
|
||||
move.dataset.rideMove = f.id; move.disabled = !sendOk || Boolean(state.busy);
|
||||
move.addEventListener('click', () => { if (!move.disabled) rideMove(f.id); });
|
||||
@@ -1281,13 +1297,13 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
|
||||
});
|
||||
};
|
||||
const rideMove = id => {
|
||||
if (!window.confirm(`Move ${id} to your models? Its stand-in models are replaced by a model your model service lists. After this, its agents spend real tokens on your account. Its bus stays stopped: start it when you are ready.`)) return;
|
||||
if (!window.confirm(`Move ${nameOf(id)} to your models? Its stand-in models are replaced by a model your model service lists. After this, its agents spend real tokens on your account. Its bus stays stopped: start it when you are ready.`)) return;
|
||||
return act('ride-move', async () => {
|
||||
const result = await admin('ride-move', { org: id });
|
||||
if (!result.moved) { rideSay(`${id} was not moved. ${rideReason(result.reason)}`, 'error'); return; }
|
||||
if (!result.moved) { rideSay(`${nameOf(id)} was not moved. ${rideReason(result.reason)}`, 'error'); return; }
|
||||
addReceipt(result.receipt);
|
||||
if (rideResult) rideResult = { ...rideResult, fixtures: rideResult.fixtures.filter(f => f.id !== id) };
|
||||
rideSay(`${id} now uses ${result.model}. Start its bus when you are ready. It spends real tokens from now on.`, 'success');
|
||||
rideSay(`${nameOf(id)} now uses ${result.model}. Start its bus when you are ready. It spends real tokens from now on.`, 'success');
|
||||
});
|
||||
};
|
||||
$('proxy-ride-go').addEventListener('click', () => { if (!$('proxy-ride-go').disabled) rideAll(); });
|
||||
@@ -1494,5 +1510,6 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
|
||||
document.addEventListener('mosaic-org-restarted', () => { read(); });
|
||||
const begin = () => { (window.MosaicOrg?.ready ?? Promise.resolve()).then(read, () => {}); };
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', begin, { once: true }); else begin();
|
||||
window.MosaicModelDots = { get: id => marks.get(id) ?? null };
|
||||
// settings-s5: a page that changes what the status says (an organization's Models choice) asks for a fresh read.
|
||||
window.MosaicModelDots = { get: id => marks.get(id) ?? null, read };
|
||||
})();
|
||||
@@ -177,7 +177,7 @@ test('Ride all confirms the stricter admission, paints skips and stand-in organi
|
||||
await wait(`document.querySelector("#proxy-ride")?.checkVisibility() && document.querySelector(${JSON.stringify(STEP3)})?.dataset.next==="ride-all"`);
|
||||
assert.equal(await b.evaluate('document.querySelector("#proxy-ride-go").className'), 'btn primary');
|
||||
assert.match(await b.evaluate('document.querySelector("#proxy-ride-text").textContent'), /every launch route is checked, direct Anthropic routes too.*2 organizations can ride now/);
|
||||
assert.match(await b.evaluate('document.querySelector("#proxy-ride-fixtures li").textContent'), /^west uses stand-in models, can be moved to the owner's models\./);
|
||||
assert.match(await b.evaluate('document.querySelector("#proxy-ride-fixtures li").textContent'), /^west uses stand-in models, can be moved to your models\./);
|
||||
// The first Ride all's own reload paints, then waits on the accounts read for good.
|
||||
await b.evaluate('document.querySelector("#proxy-ride-go").click()');
|
||||
await wait('window.__writes.some(w=>w.path==="/api/proxy/admin/ride-all")');
|
||||
@@ -399,7 +399,7 @@ test('settings-p3: a stand-in organization with no bus status is not offered a M
|
||||
await b.navigate(f.base + '/#/settings/model-setup');
|
||||
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."]);
|
||||
['west uses stand-in models. Moving it is not available on this Console.', "east uses stand-in models, can be moved to your 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'), []);
|
||||
|
||||
@@ -187,7 +187,7 @@ test('settings-s4 review F2: a stand-in organization with its bus stopped reads
|
||||
assert.equal(await text(STEP3), "The model service is set up. Gamma Home can't start: it uses stand-in models and its bus is stopped. Move it to your models under Use your models in every organization, then start its bus.");
|
||||
assert.equal(await b.evaluate('document.querySelector("#setup-step-organizations").dataset.state'), 'bad');
|
||||
const item = await b.evaluate('document.querySelector("#proxy-ride-fixtures li").firstChild.textContent.trim()');
|
||||
assert.equal(item, "Gamma Home can't start: it uses stand-in models and its bus is stopped. Move it to the owner's models, then start its bus.");
|
||||
assert.equal(item, "Gamma Home can't start: it uses stand-in models and its bus is stopped. Move it to your models under Use your models in every organization, then start its bus.");
|
||||
assert.equal(await b.evaluate('document.querySelector("[data-ride-move=gamma]").textContent'), 'Move Gamma Home');
|
||||
assert.equal(await b.evaluate('document.querySelector("[data-ride-move=gamma]").checkVisibility()'), true);
|
||||
// The organizations that need nothing get no mark.
|
||||
|
||||
Reference in new issue
Block a user