diff --git a/packages/webui/src/public/bus.js b/packages/webui/src/public/bus.js
index 862fada7f..2d40fe5b1 100644
--- a/packages/webui/src/public/bus.js
+++ b/packages/webui/src/public/bus.js
@@ -1306,6 +1306,42 @@
const ROUTE_CELLS=[['harness','Harness'],['model','Model'],['thinking','Thinking'],['fallback.harness','Fallback harness'],['fallback.model','Fallback model'],['fallback.thinking','Fallback thinking']];
const routeCells=r=>({harness:r.harness??'',model:r.model??'',thinking:r.thinking??'','fallback.harness':r.fallback?.harness??'','fallback.model':r.fallback?.model??'','fallback.thinking':r.fallback?.thinking??''});
const sameCells=(a,b)=>ROUTE_CELLS.every(([k])=>a[k]===b[k]);
+ // #1873 settings slice 1 (D2): an organization that lists the model service but cannot see its
+ // models. For the instance owner the page reads the model service's state once per visit, so the
+ // line says which is true: the service is not set up or not running (a link to its page), or it
+ // runs and this organization still cannot read it. A running bus picks the service up at its next
+ // catalogue read (proxy-pickup), so when the bus names a cause the line shows that cause and a
+ // Check again that rereads; a Restart would not help there, and with the dev fixture it would stop
+ // the organization. Only a running service with no cause from the bus offers Restart. The Restart
+ // follows that state; it is never offered on a guess.
+ let serviceState=null, serviceLoading=false;
+ function readService(){
+ if(serviceLoading||serviceState!==null||isTester||!triageOwner||!window.MosaicOrg)return; serviceLoading=true;const epoch=orgEpoch;
+ fetch('/api/proxy/admin/status',{cache:'no-store',redirect:'manual'}).then(async r=>{const v=await r.json();if(epoch!==orgEpoch)return;if(!r.ok||!v||typeof v!=='object')throw Error();
+ serviceState=v.init?.initialized!==true?'not-set-up':v.unit?.active==='active'&&v.unit?.healthy===true&&v.fence?.set!==true?'running':'not-running';})
+ .catch(()=>{if(epoch!==orgEpoch)return;serviceState=false;}).finally(()=>{if(epoch!==orgEpoch)return;serviceLoading=false;if(routeOf().split('?')[0]==='/settings/routing')render(false);});
+ }
+ function catalogueLine(proxyOn,catalogue){
+ const org=txt(window.MosaicOrg?.label||'This organization'), id=window.MosaicOrg?.id, owner=canSend&&!isTester;
+ const lead=`${org} can't see your models yet.`, thinking='A change to thinking alone still saves.';
+ // The bus's own cause lines (proxy-pickup), shown as it wrote them.
+ const causes=(Array.isArray(catalogue?.notices)?catalogue.notices:[]).filter(n=>typeof n==='string'&&n).map(n=>`
${txt(n)}
`).join('');
+ if(!proxyOn)return `
${lead} ${thinking}
${causes}`;
+ if(owner)readService();
+ const recheck='';
+ // Only the lock cause asks for a restart; with the dev fixture or a key that does not load the
+ // start is refused too, and a restart would stop the organization.
+ const lockCause=(catalogue?.notices??[]).some(n=>typeof n==='string'&&n.includes('(proxy-lock-invalid)'));
+ if(owner&&serviceState==='running'&&causes)return `
${lead} Your model service is running, but ${org} can't use it. ${org} says why:
${lead} Your model service is running, but ${org} can't read your models from it. Restart ${org} to connect it again. It stops for a moment and starts again. ${thinking}
${lead} ${thinking}${owner?' A new model needs the model service: ask the instance owner to set it up, or press Stop using the model service when this organization does not need it.':''}
${causes}`;
+ }
+ // Check again rereads Routing; the bus looks for the model service at that read. A draft is kept.
+ document.addEventListener('click',e=>{if(e.target.id!=='routes-recheck')return;e.target.disabled=true;serviceState=null;routesView=null;last.delete('routes');render(true);});
+ document.addEventListener('mosaic-org-restarted',e=>{if(e.detail?.id!==window.MosaicOrg?.id)return;serviceState=null;routesView=null;last.delete('routes');const path=routeOf().split('?')[0];if(path==='/settings/routing'||document.querySelector('[data-org-down]'))render(true);});
function routesSection(view,instanceInfo){
const title='
Routing
';
readHarnesses();
@@ -1334,8 +1370,8 @@
// fixture-only catalogue is ready with no model proxy). Before the setting is read it falls
// back to the catalogue status, as before.
const proxyOn=harnessSettings?(Array.isArray(harnessSettings.plugins?.['model-provider'])?harnessSettings.plugins['model-provider']:[]).includes('cliproxy'):v.catalogue?.status!=='disabled';
- const catalogueInfo=v.catalogue?.status==='ready'?`
Model catalogue, observed ${txt(window.MosaicLocalTime(v.catalogue.observedAt))}.
Model catalogue unavailable. A change to thinking alone still saves.${proxyOn&&canSend&&!isTester?' A new model needs the catalogue: set up the model proxy, or, when this organization has none, press Disable model proxy catalogue.':''}
No harness is switched on in the business file\'s plugins.harness, so every launch refuses harness-off and a save that changes a harness refuses too. Switch one on under Harnesses.
';
return `${title}${catalogueInfo}${providerControl}${harnessControl}${off}`;
@@ -1357,13 +1393,13 @@
// A viewer without the switch is sent to the owner.
function catalogueStep(code,routes){
if(!['model-catalogue-unavailable','model-provider-unavailable'].includes(code))return '';
- if(!canSend||isTester)return ' Ask the organization\'s owner to set up the model proxy, or to disable the model proxy catalogue when the change needs no proxy.';
+ if(!canSend||isTester)return ' Ask the organization\'s owner to set up the model service, or to stop using it when the change does not need it.';
const names=Array.isArray(harnessSettings?.plugins?.['model-provider'])?harnessSettings.plugins['model-provider']:[];
if(!names.includes('cliproxy'))return '';
const moved=Object.entries(routes).flatMap(([name,r])=>{const was=routesView?.instances?.[name]??{};
return [[r.harness,r.model,was.harness,was.model],[r.fallback?.harness,r.fallback?.model,was.fallback?.harness,was.fallback?.model]].filter(([h,m,wh,wm])=>m&&(h!==wh||m!==wm)).map(([,m])=>m);});
const module=key=>routesView?.providerModels?.[key]?.module;
- return moved.length&&moved.every(key=>module(key)&&module(key)!=='cliproxy'&&names.includes(module(key)))?' This change needs no model proxy: press Disable model proxy catalogue, then save again.':'';
+ return moved.length&&moved.every(key=>module(key)&&module(key)!=='cliproxy'&&names.includes(module(key)))?' This change does not need the model service: press Stop using the model service, then save again.':'';
}
const routesAnswer=r=>/^[a-f0-9]{64}$/.test(r?.revision??'')&&Array.isArray(r.harnesses)&&Array.isArray(r.models)&&[r.levels,r.instances].every(o=>o&&typeof o==='object'&&!Array.isArray(o));
for(const kind of ['input','change'])document.addEventListener(kind,e=>{const form=e.target?.closest?.('#routes-form');if(!form||!routesView)return;routesDraft=routesFields(form);routesEditVersion++;markSettingsDraft('routing',true);form.querySelector('.settings-actions')?.classList.add('has-draft');const discard=$('routes-reload');if(discard){discard.hidden=false;discard.disabled=false;}
@@ -1388,7 +1424,7 @@
try {const read=await fetch('/api/proxy/plugins',{cache:'no-store'});const settings=await read.json();if(epoch!==orgEpoch)return;if(!read.ok||!/^[a-f0-9]{64}$/.test(settings.revision??''))throw Error('Could not read provider settings.');
const names=Array.isArray(settings.plugins?.['model-provider'])?settings.plugins['model-provider']:[];
// The fresh read decides: a stale label never turns the proxy module on when it meant off.
- const on=names.includes('cliproxy');if(String(on)!==button.dataset.enabled){button.dataset.enabled=String(on);button.textContent=`${on?'Disable':'Enable'} model proxy catalogue`;button.disabled=false;status.textContent='The switch now shows the current setting. Press it again to change it.';return;}
+ const on=names.includes('cliproxy');if(String(on)!==button.dataset.enabled){button.dataset.enabled=String(on);button.textContent=on?'Stop using the model service':'Use your models';button.disabled=false;status.textContent='The switch now shows the current setting. Press it again to change it.';return;}
const next=on?names.filter(n=>n!=='cliproxy'):[...names,'cliproxy'];
const response=await fetch('/api/proxy/plugins/set',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({revision:settings.revision,plugins:{'model-provider':next}}),cache:'no-store',redirect:'manual'});
if(epoch!==orgEpoch)return;if(!response.ok)throw Error('Provider setting was refused.');harnessSettings=null;routesView=null;last.delete('routes');render(true);
@@ -1459,10 +1495,10 @@
// #1873 A2: the root and project agent levels (agents.js MosaicAgentLevels), the owner's only.
let agentLevels='';
if (page==='agents' && window.MosaicOrg && window.MosaicAgentLevels && !isTester) agentLevels = await window.MosaicAgentLevels.section().catch(()=>'');
- if (page==='routing') { try { [routes] = await get('routes'); } catch (err) { if (err.status === 403 || err.code === 'signed-out') throw err; } }
+ if (page==='routing') { await window.MosaicConsole?.ready; try { [routes] = await get('routes'); } catch (err) { if (err.status === 403 || err.code === 'signed-out') throw err; } }
if (page==='tokens' && s.launch && !s.launch.refused) takeSnapshot(s.launch);
const notify = typeof n.binding==='string' ? `${txt(n.binding)}` : n.refused ? `Could not be read: ${txt(n.refused)}` : 'None set';
- const contents={limits:()=>launchForm(s.launch),routing:()=>routesSection(routes,instances),agents:()=>agentsSection(instances)+agentLevels,assistant:()=>assistantSection(s.launch,names),tokens:()=>tokenLimits(limitRows,limitsRefused)+tokenUsage(usage),names:()=>testerNames(names,instances),about:()=>`
Address
${txt(s.address)||'unknown'}
Release
${txt(s.release)||'unknown'}
Business
${txt(s.business)||none}
Board
${txt(s.board)||'unknown'}
Notifier binding
${notify}
`, 'model-proxy':()=>'Open model proxy settings'};
+ const contents={limits:()=>launchForm(s.launch),routing:()=>routesSection(routes,instances),agents:()=>agentsSection(instances)+agentLevels,assistant:()=>assistantSection(s.launch,names),tokens:()=>tokenLimits(limitRows,limitsRefused)+tokenUsage(usage),names:()=>testerNames(names,instances),about:()=>`
Address
${txt(s.address)||'unknown'}
Release
${txt(s.release)||'unknown'}
Business
${txt(s.business)||none}
Board
${txt(s.board)||'unknown'}
Notifier binding
${notify}
`, 'model-proxy':()=>'Open model service settings'};
const helpers={limits:'Leave a limit blank for no limit. Zero stops new launches. Running sessions keep running when limits or models change.',routing:"Each agent’s harness, model and thinking, and the fallback a launch takes when the primary harness fails its preflight. A fallback sets all three or none. Running sessions keep their route. The next launch reads the change.",agents:'Each agent with its definition, launch membership and runs. A launch refuses until the agent has a route in Routing.',assistant:'The definition stays an assistant one. Holder and credentials stay hand edits.',tokens:'Token limits the bus checks, and token use read from session transcripts.'};
return settingsShell(page,contents[page](),`${get.oldest()?`Read ${when(get.oldest())}.`: 'Reading…'} ${helpers[page]||''}`);
}
@@ -1675,6 +1711,21 @@
// After a refusal nothing read before is shown anywhere: not in a view, the palette or the Inbox count.
function forget() { window.MosaicChat?.forget(); last.clear(); inboxCount = null; messageCount = null; }
const failedView = (err, path) => `${head(path === '/queue' ? 'Queue' : failTitle(err))}
${refusal(err) ? `refused: ${txt(err.code)}. ` : ''}${why(err, err.code === 'queue-refused')} Console shows nothing rather than a guess. Nothing was written.
${retry}
${empty('Nothing to show.', refusal(err) ? 'The view stays empty until the problem above is fixed.' : err.module ? 'Read again.' : 'Read again, or come back when the bus answers.')}`;
+ // #1873 settings slice 1 (D7): an organization page under Settings that cannot be read keeps the
+ // Settings nav, so the instance pages (Appearance, Model service, Triage, Console) stay one link
+ // away. When the organization's bus is down the page says so in plain words and offers Restart,
+ // whose refusal stays on screen (console-restart.js keeps it per organization); the header's own
+ // "Bus unavailable" banner steps aside on this page so there is one Restart, not two.
+ function settingsFailed(err, path) {
+ const page = path.split('/')[2] || 'appearance', id = window.MosaicOrg?.id, row = id ? window.MosaicOrg.row?.(id) : null;
+ const org = txt(window.MosaicOrg?.label || id || ''), name = settingsPages.find(([p]) => p === page)?.[1] || 'this page';
+ if (id && row?.busHealthy === false && !refusal(err)) {
+ const restart = window.MosaicConsole?.orgRestartButton?.(id, { name: window.MosaicOrg.label || id, primary: true }) || '';
+ const state = row.busStopped ? `${org} is stopped` : `${org} isn't running`;
+ return settingsShell(page, `
${state}, so ${txt(name)} can't be read. Start it again to see and change this page. Nothing was written.
${txt(failTitle(err))}. ${refusal(err) ? `${txt(err.code)}. ` : ''}${why(err, err.code === 'queue-refused')} Console shows nothing rather than a guess. Nothing was written.
${retry}
`);
+ }
const staleBanner = err => `
The last read failed. ${why(err)} This is what was read before, ${when(readAt)}. Nothing was changed.
${retry}
`;
// Freshness line in the command bar for bus pages.
const stamp = iso => { const t = Date.parse(iso); return Number.isFinite(t) ? `${new Date(t).toISOString().slice(11, 19)} UTC` : 'unknown'; };
@@ -1928,7 +1979,7 @@
if (err.code === 'signed-out') return;
const kept = reader(false);
try { if (refusal(err)) throw err; html = await view(kept, path, new URLSearchParams(query), opts, current); readAt = kept.oldest(); html = staleBanner(err) + html; state = 'stale'; }
- catch { html = failedView(err, path) + (path === '/settings' ? appearance() : ''); state = refusal(err) ? 'refused' : 'failed'; }
+ catch { if (window.MosaicOrg && path.startsWith('/settings/')) { await window.MosaicConsole?.ready; html = settingsFailed(err, path); } else html = failedView(err, path) + (path === '/settings' ? appearance() : ''); state = refusal(err) ? 'refused' : 'failed'; }
if (refusal(err)) forget();
}
if (!current()) return;
@@ -1944,6 +1995,7 @@
syncAppearance(true);
if (path.startsWith('/docs/')) paintDoc();
if (path === '/organization') window.MosaicConsole?.attachBus(document.querySelector('[data-dashboard-bus]'));
+ if ($('bus-view').querySelector('[data-org-down]')) { const down = $('bus-down'); if (down) down.hidden = true; }
if (path === '/settings/model-proxy') proxyCleanup=window.MosaicProxy.mount();
if (path === '/settings/organizations') orgCleanup=window.MosaicOrgCreate.mount();
sections(path);
@@ -2164,6 +2216,7 @@
instanceView = null; instanceDrafts = { add: null, change: null }; instanceReceipt = ''; instanceReceiptOp = null; instanceReceipts = Object.create(null);
routesView = null; routesDraft = null; routesReceipt = ''; routesEditVersion++;
harnessSettings = null; harnessDraft = null; harnessReceipt = '';
+ serviceState = null; serviceLoading = false;
// A file draft is keyed by project and path only; the page reload that used to drop it is gone.
docKey = null; docStates.clear(); pkAll = []; pkShown = []; pkAt = 0;
configRead = switchRead = fetch('/api/config', { cache: 'no-store', redirect: 'manual' }).then(r => { if (r.type === 'opaqueredirect') { signOut(); return null; } return r.json(); }).then(c => applyConfig(c, { quiet: true })).catch(() => {});
diff --git a/packages/webui/src/public/console-restart.js b/packages/webui/src/public/console-restart.js
index 5ab4a989c..895d52e71 100644
--- a/packages/webui/src/public/console-restart.js
+++ b/packages/webui/src/public/console-restart.js
@@ -175,6 +175,8 @@
}
} catch (error) {
busReceipt = error instanceof SyntaxError || error?.name === 'TypeError' ? 'Outcome unknown. Check the bus with mosaic bus status before retrying.' : error.message;
+ // #1873 D7: the refusal follows the organization onto its Settings pages.
+ if (!(error instanceof SyntaxError || error?.name === 'TypeError')) orgReceipts.set(id, { ok: false, ...refusalLine(window.MosaicOrg?.label || id, error.message) });
} finally { busBusy = false; paintBus(); }
});
@@ -196,5 +198,54 @@
} finally { busBusy = false; paintBus(); }
}
- window.MosaicConsole = Object.freeze({ ready, settingsMarkup, busButton, attachBus, get busRestart() { return busAllowed(); }, get config() { return config; } });
+ // #1873 settings slice 1 (D2, D3, D7): a Restart button for one named organization, for pages that
+ // list organizations by id (Routing, Model proxy, a stopped organization's Settings). Each
+ // organization keeps its own receipt, so a refusal stays on screen across repaints until the next
+ // press. It calls the same POST /api/orgs//restart/bus as the header's Restart bus.
+ const orgReceipts = new Map(), orgBusy = new Set();
+ const orgAllowed = () => config?.orgSetup === true && config?.tester !== true && config?.user !== true;
+ // The refusal the bus host wrote, with one plain line in front when its code is known.
+ function refusalLine(name, message) {
+ const text = String(message || 'The restart was refused. Nothing was retried.');
+ if (/\bfixture-proxy-configured\b/.test(text)) return { plain: `${name} runs on test models, which can't share this machine with your model service. It did not start.`, detail: text };
+ return { plain: `${name} did not start.`, detail: text };
+ }
+ function orgRestartButton(id, { name = id, label = `Restart ${name}`, primary = false } = {}) {
+ if (!orgAllowed() || typeof id !== 'string' || !id) return '';
+ const busy = orgBusy.has(id), r = orgReceipts.get(id);
+ const receipt = !r ? '' : r.ok ? esc(r.text) : `${esc(r.plain)}${esc(r.detail)}`;
+ return `${receipt}`;
+ }
+ const paintOrg = id => document.querySelectorAll(`[data-org-restart-box="${CSS.escape(id)}"]`).forEach(el => {
+ const b = el.querySelector('[data-org-restart]');
+ el.outerHTML = orgRestartButton(id, { name: b?.dataset.orgName || id, label: b?.dataset.label, primary: b?.hasAttribute('data-primary') });
+ });
+ async function restartOrg(id, name) {
+ if (orgBusy.has(id) || !orgAllowed()) return null;
+ orgBusy.add(id); orgReceipts.delete(id); paintOrg(id);
+ let result;
+ try {
+ const response = await nativeFetch(`/api/orgs/${encodeURIComponent(id)}/restart/bus`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}', cache: 'no-store', redirect: 'manual' });
+ if (response.type === 'opaqueredirect') throw new Error('Sign in again, then retry.');
+ const body = await response.json();
+ if (!response.ok || body.outcome !== 'done' || body.step !== 'bus-restart') throw new Error(body.message || 'The restart was refused. Nothing was retried.');
+ result = { ok: true, healthy: body.healthy === true, text: `${name} ${body.restarted ? 'restarted' : 'started'} at ${clock()}. ${body.healthy ? 'It answers.' : `It has not answered yet. Check it with mosaic bus status ${id}.`}` };
+ } catch (error) {
+ result = error instanceof SyntaxError || error?.name === 'TypeError'
+ ? { ok: false, plain: 'Outcome unknown.', detail: `Check it with mosaic bus status ${id} before you press Restart again.` }
+ : { ok: false, ...refusalLine(name, error.message) };
+ }
+ orgBusy.delete(id); orgReceipts.set(id, result); paintOrg(id);
+ if (id === window.MosaicOrg?.id) { busReceipt = result.ok ? result.text : `${result.plain} ${result.detail}`; paintBus(); }
+ await Promise.resolve(window.MosaicOrg?.refreshList?.()).catch(() => {});
+ document.dispatchEvent(new CustomEvent('mosaic-org-restarted', { detail: { id, ok: result.ok, healthy: result.healthy === true } }));
+ return result;
+ }
+ document.addEventListener('click', e => {
+ const button = e.target.closest?.('[data-org-restart]');
+ if (!button || button.disabled) return;
+ restartOrg(button.dataset.orgRestart, button.dataset.orgName || button.dataset.orgRestart);
+ });
+
+ window.MosaicConsole = Object.freeze({ ready, settingsMarkup, busButton, attachBus, orgRestartButton, restartOrg, orgRefusal: id => orgReceipts.get(id) ?? null, get busRestart() { return busAllowed(); }, get config() { return config; } });
})();
diff --git a/packages/webui/src/public/display.js b/packages/webui/src/public/display.js
index 98fdc12c1..96a5efeb8 100644
--- a/packages/webui/src/public/display.js
+++ b/packages/webui/src/public/display.js
@@ -13,7 +13,15 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
const clean = (value, max = 8000) => (typeof value === 'string' ? value : value === null || value === undefined ? '' : String(value)).replace(/\r\n?/g, '\n').replace(HIDDEN, '').slice(0, max);
const when = value => window.MosaicLocalTime(clean(value, 64));
const el = (tag, cls, text) => { const n = document.createElement(tag); if (cls) n.className = cls; if (text !== undefined) n.textContent = clean(text); return n; };
- const NO_ROUTE = 'No model route is set for Triage, so Triage will not start. The instance owner sets the route first.';
+ const NO_ROUTE = 'Triage has no model chosen yet, so it will not start.';
+ // #1873 settings slice 1 (section 5): a fix link goes only to a Settings page that exists for this viewer.
+ // Settings > Triage exists only where /api/config says proxyAdmin (bus.js triageOwner); Model proxy always does.
+ const TRIAGE_FIX = { href: '#/settings/triage', label: 'Open Triage settings' };
+ const SERVICE_FIX = { href: '#/settings/model-proxy', label: 'Open model service settings' };
+ const pageExists = fix => fix !== TRIAGE_FIX || config?.proxyAdmin === true;
+ const fixLink = fix => { const a = el('a', 'triage-fix', fix.label); a.href = fix.href; a.addEventListener('click', () => close()); return a; };
+ // An organization's name from the Console's own list, or its id when the list does not hold it.
+ const orgName = id => { const name = window.MosaicOrg?.row?.(id)?.label; return typeof name === 'string' && name ? clean(name, 200) : clean(id) || 'unnamed'; };
let config = null, entry = null, drawer = null, parts = null, timer = null, gen = 0, sending = false, lastTranscript = '', lastHealth = '', shown = [];
const read = () => systemFetch('/api/config', { cache: 'no-store', redirect: 'manual' }).then(r => (r.ok ? r.json() : null)).catch(() => null);
@@ -43,6 +51,7 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
x.addEventListener('click', close);
hd.append(title, x);
const state = el('p', 'triage-state'); state.id = 'triage-state'; state.setAttribute('role', 'status');
+ const stateFix = el('p', 'triage-state-fix'); stateFix.id = 'triage-state-fix'; stateFix.hidden = true;
const usage = el('p', 'note triage-usage'); usage.id = 'triage-usage'; usage.hidden = true;
const healthSec = el('details', 'triage-health-sec'); healthSec.open = true;
const healthSum = el('summary', '', 'Health');
@@ -52,10 +61,10 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
const transcript = el('ol', 'triage-transcript'); transcript.id = 'triage-transcript'; transcript.tabIndex = 0;
transcript.setAttribute('aria-label', 'Triage conversation');
const compose = el('div', 'triage-compose');
- drawer.append(hd, state, usage, healthSec, convo, transcript, compose);
+ drawer.append(hd, state, stateFix, usage, healthSec, convo, transcript, compose);
drawer.addEventListener('keydown', e => { if (e.key === 'Escape') { e.preventDefault(); close(); } });
document.body.append(drawer);
- parts = { title, state, usage, health, transcript, compose, box: null, send: null, status: null, off: null };
+ parts = { title, state, stateFix, usage, health, transcript, compose, box: null, send: null, status: null, off: null };
}
// The message box is built once and never rewritten or removed by a read, so a draft survives every
@@ -90,16 +99,17 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
if (!canSend) { parts.off.textContent = READ_ONLY; parts.box.disabled = parts.send.disabled = true; return; }
// A route that is not set, or a session over its cap, turns the box off and says why.
const until = typeof view.overCapUntil === 'string' && view.overCapUntil ? view.overCapUntil : null;
- const reason = view.route !== 'set' ? 'Sending is off: no model route is set for Triage.'
- : until ? `Sending is off: Triage is over its daily token cap until ${when(until)}.` : '';
+ const reason = view.route !== 'set' ? 'Sending is off: Triage has no model chosen yet.'
+ : until ? `Sending is off: Triage used its daily token limit. It takes messages again at ${when(until)}.` : '';
parts.off.textContent = reason;
parts.box.disabled = !!reason;
parts.send.disabled = !!reason || sending;
}
const stateLine = view => {
- if (view.route !== 'set') return clean(view.routeMessage) || NO_ROUTE;
- if (view.overCapUntil) return clean(view.capMessage) ? `${clean(view.capMessage)} Local time: ${when(view.overCapUntil)}.` : `Triage is over its daily token cap. It takes messages again at ${when(view.overCapUntil)}.`;
+ // The page's own plain line (section 5), with the fix link under it; the read's routeMessage is the older wording.
+ if (view.route !== 'set') return NO_ROUTE;
+ if (view.overCapUntil) return `Triage used its daily token limit. It takes messages again at ${when(view.overCapUntil)}.`;
if (view.running === true) return 'Running.';
const x = view.lastExit;
if (x && typeof x === 'object') {
@@ -115,7 +125,7 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
const usageLine = view => {
if (!Object.hasOwn(view, 'usageToday')) return '';
const u = view.usageToday, c = view.cap;
- if (u === 'not set' || c === 'not set') return 'Daily token cap: not set.';
+ if (u === 'not set' || c === 'not set') return 'Daily token limit: not set.';
if (notRead(u) || notRead(c)) return "Today's token usage: not read.";
const n = v => (Number.isSafeInteger(v) ? v.toLocaleString() : 'not read');
const reset = typeof view.resetsAt === 'string' && Number.isFinite(Date.parse(view.resetsAt)) ? ` Resets at ${when(view.resetsAt)}.` : '';
@@ -128,7 +138,7 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
if (notRead(s)) return ['Health: not read'];
const lines = [];
lines.push(notRead(s.console) ? 'Console: not read' : `Console: ${clean(s.console.state) || 'not read'}, ${when(s.console.at)}`);
- if (notRead(s.proxy)) lines.push('Proxy: not read');
+ if (notRead(s.proxy)) lines.push('Model service: not read');
else {
const p = s.proxy;
const words = [p.healthy === true ? 'healthy' : p.healthy === false ? 'not healthy' : 'health not read'];
@@ -136,7 +146,7 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
if (p.installed === false) words.push('not installed');
if (typeof p.active === 'string' && p.active) words.push(`unit ${clean(p.active)}`);
if (p.fence === true) words.push('fence set');
- lines.push(`Proxy: ${words.join(', ')}`);
+ lines.push(`Model service: ${words.join(', ')}`);
}
lines.push(`System config: ${configWords(s.systemConfig)}`);
const orgs = s.organizations;
@@ -144,9 +154,12 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
else if (!orgs.list.length) lines.push('Organizations: none');
else for (const o of orgs.list) {
if (!o || typeof o !== 'object') continue;
- const bus = notRead(o.bus) ? 'bus not read' : `bus ${clean(o.bus.state) || 'not read'}${o.bus.lastStart && o.bus.lastStart.ok === false ? `, last start failed ${when(o.bus.lastStart.at)}` : ''}`;
+ // #1873 settings slice 1 (D7): a refused last start reads as not running, never as running. The
+ // read carries the time only, not the reason, so the line says where the reason is shown.
+ const refused = !notRead(o.bus) && o.bus.lastStart && o.bus.lastStart.ok === false;
+ const bus = notRead(o.bus) ? 'bus not read' : refused ? `not running: its last start failed at ${when(o.bus.lastStart.at)} (bus ${clean(o.bus.state) || 'not read'}). Restart it on the dashboard to see why` : `bus ${clean(o.bus.state) || 'not read'}`;
const proc = notRead(o.processing) ? 'processing not read' : o.processing.invalid === true ? 'processing state not valid' : o.processing.halted === true ? 'processing stopped' : 'processing on';
- lines.push(`${clean(o.id) || 'unnamed'}: ${bus}, ${proc}, config ${configWords(o.config)}`);
+ lines.push(`${orgName(o.id)}: ${bus}, ${proc}, config ${configWords(o.config)}`);
}
return lines;
}
@@ -187,6 +200,11 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
const t = parts.transcript, atBottom = t.scrollHeight - t.scrollTop - t.clientHeight < 24, top = t.scrollTop;
parts.state.textContent = stateLine(view);
parts.state.dataset.kind = view.route !== 'set' ? 'off' : view.overCapUntil ? 'cap' : view.running === true ? 'running' : 'stopped';
+ // The fix link exists only while the route is not set and its page exists, so no link sits hidden in the drawer.
+ const fixable = view.route !== 'set' && pageExists(TRIAGE_FIX);
+ parts.stateFix.hidden = !fixable;
+ if (!fixable) parts.stateFix.replaceChildren();
+ else if (!parts.stateFix.firstChild) parts.stateFix.append(fixLink(TRIAGE_FIX));
const usage = usageLine(view);
parts.usage.textContent = usage;
parts.usage.hidden = !usage;
@@ -268,13 +286,21 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
if (code === 'triage-route-invalid' || code === 'triage-start-failed') return { text: `Not delivered: ${code === 'triage-start-failed' ? 'the Triage session did not start' : 'Triage did not start because the model route\'s answer is not usable'}. The message is in the conversation with the Console's note; it was not sent again.` };
// This one can come before or after the message is written.
if (code === 'triage-dir-unsafe') return { text: 'Not delivered: a Triage directory is not safe to use. It was not sent again: check the conversation before you send it again.' };
- // A route refusal (no key, the proxy down, the model no longer offered, ...) carries its own plain line.
+ // #1873 settings slice 1 (section 5): a route refusal reads as what is missing, with the page that fixes it.
+ // Slice 1 has no way to issue a Triage key, so that line ends at what is missing.
+ if (status === 409 && code === 'triage-key-missing') return { text: 'Not sent. Triage isn\'t turned on yet: it needs a Triage key, and none is issued on this instance.' };
+ if (status === 409 && code === 'triage-proxy-down') return { text: 'Not sent. The model service isn\'t running, so Triage can\'t start.', link: SERVICE_FIX };
+ if (status === 409 && code === 'triage-harness-incompatible') return { text: 'Not sent. Triage runs only with Claude Code. Choose Claude Code under "Runs with" in Triage settings.', link: TRIAGE_FIX };
+ if (status === 409 && code === 'triage-model-not-offered') return { text: 'Not sent. The model Triage uses is no longer offered. Choose another model in Triage settings.', link: TRIAGE_FIX };
+ if (status === 409 && code === 'triage-catalogue-unavailable') return { text: 'Not sent. The model service can\'t confirm Triage\'s model right now, so Triage can\'t start.', link: SERVICE_FIX };
+ // Any other route refusal (an unsafe key file, ...) carries its own plain line.
if (status === 409 && /^triage-(key|proxy|model|catalogue|harness)-/.test(code) && typeof body.message === 'string') return { text: `Not sent. ${clean(body.message)}` };
- if (status === 409) return { text: code === 'triage-no-route' ? 'Not sent: no model route is set for Triage. The instance owner sets the route first.' : code === 'triage-route-refused' ? 'Not sent: the model route refused to start Triage.' : 'Not sent: the model route\'s answer is not usable.' };
+ if (status === 409 && code === 'triage-no-route') return { text: 'Not sent. Triage has no model chosen yet.', link: TRIAGE_FIX };
+ if (status === 409) return { text: code === 'triage-route-refused' ? 'Not sent: the model route refused to start Triage.' : 'Not sent: the model route\'s answer is not usable.' };
if (status === 429) {
if (code === 'triage-over-cap') {
const until = typeof body.until === 'string' ? clean(body.until) : '';
- return { text: until ? `Not sent: Triage is over its daily token cap. It takes messages again at ${when(until)} (${until}).` : 'Not sent: Triage is over its daily token cap.' };
+ return { text: until ? `Not sent: Triage used its daily token limit. It takes messages again at ${when(until)} (${until}).` : 'Not sent: Triage used its daily token limit.', link: TRIAGE_FIX };
}
return { text: 'Not sent: Triage has too many messages waiting. Try again in a moment.' };
}
@@ -303,6 +329,7 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
// The status line can grow the composer; a reader at the bottom of the transcript stays there.
const t = parts.transcript, atBottom = t.scrollHeight - t.scrollTop - t.clientHeight < 24;
parts.status.textContent = result.text;
+ if (result.link && pageExists(result.link)) parts.status.append(' ', fixLink(result.link));
parts.status.dataset.kind = result.sent ? 'ok' : result.unknown ? 'unknown' : 'refused';
// Only a 202 clears the box, and only when the reader has not typed more since.
if (result.sent && parts.box.value === text) parts.box.value = '';
@@ -374,7 +401,7 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
const banner = document.getElementById('bus-down');
if (!banner) return;
const org = rowsSeen.find(row => current && row.id === decodeURIComponent(current) && !row.invalid), path = route().split('?')[0];
- if (system(location.hash) || (path === '/organization' && org?.busHealthy === false) || (banner.dataset.orgBus && org?.busHealthy !== false)) { banner.hidden = true; delete banner.dataset.orgBus; return; }
+ if (system(location.hash) || ((path === '/organization' || document.querySelector('#bus-view [data-org-down]')) && org?.busHealthy === false) || (banner.dataset.orgBus && org?.busHealthy !== false)) { banner.hidden = true; delete banner.dataset.orgBus; return; }
if (org?.busHealthy === false) { banner.textContent = 'Bus unavailable'; banner.hidden = false; banner.dataset.orgBus = '1'; window.MosaicConsole?.attachBus(banner, 'Restart the bus'); }
};
// Idempotent: each read replaces the banner, and removes it on recovery.
@@ -480,6 +507,9 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
// The open organization's name as the last list read gave it, for the breadcrumb.
get label() { const id = current ? decodeURIComponent(current) : null, row = id && rowsSeen.find(r => r.id === id); return id ? (typeof row?.label === 'string' && row.label ? row.label : id) : null; },
ready, route, get list() { return list; }, readList, refreshList,
+ // #1873 settings slice 1: an organization's row as the last list read gave it (name and bus state), or null.
+ row: id => { const r = rowsSeen.find(x => x.id === id && !x.invalid); return r ? Object.freeze({ id: r.id, label: typeof r.label === 'string' && r.label ? r.label : r.id, busHealthy: r.busHealthy, busStopped: r.busStopped === true }) : null; },
+ rows: () => rowsSeen.filter(x => !x.invalid).map(r => Object.freeze({ id: r.id, label: typeof r.label === 'string' && r.label ? r.label : r.id, busHealthy: r.busHealthy, busStopped: r.busStopped === true })),
// SP3: whether this address is a system page (no organization's), for the shell's theme scope.
system: () => system(location.hash),
switchTo: next => { const path = route().split('?')[0]; location.hash = `#/orgs/${encodeURIComponent(next)}${path === '/dashboard' || path === '/' ? '/organization' : route()}`; },
@@ -507,13 +537,20 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
(() => {
'use strict';
// #1873: setup from nothing to a working proxy. Shown only to the instance owner (config.proxyAdmin).
- const setupMarkup = '
Proxy setup
'
- + '
Each step is checked on the host. Files are named by label; keys are never shown.
'
- + '
'
+ // #1873 settings slice 1 (D3, D4): the next step and its one button come first, then the kept list
+ // of organizations that need a restart and the Ride all box (ride-default). Done steps, the service controls, the fence, the init lock,
+ // the organization table and the receipts sit under Technical details.
+ const setupMarkup = '
Set up the model service
'
+ + '
The model service lets your organizations use your own model accounts. Each step is checked on this machine. Keys are never shown.