fix(webui): settings slice 1: no harness names written into the page: Settings > Triage shows each harness by the id its module is installed under, from the route read, and its help line says the list holds only the programs the model runs with; the drawer's harness refusal reads the route and names its harness by that id, or keeps a plain line without a name when the route can't be read (#1873, lane settings-s1)

This commit was merged in pull request #2000.
This commit is contained in:
jason.woltje committed 2026-11-19 14:38:04 -06:00
1 parent c9d64a341e
commit fbaae25d06
4 files changed
+45 -14

No files matched your search

+15 -1
View File
@@ -288,6 +288,18 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
entry.focus(); entry.focus();
} }
const harnessRefused = h => h
? `Not sent. The model Triage uses doesn't run with ${h}, the program its route says runs it. Choose a model that runs with ${h}, or another program, in Triage settings.`
: 'Not sent. The model Triage uses doesn\'t run with the program its route says runs it. Choose a model and a program that run together in Triage settings.';
// The route read (Settings > Triage's own read) names the harness; any failure keeps the line without it.
async function routeHarness() {
try {
const r = await systemFetch('/api/triage/route', { cache: 'no-store', redirect: 'manual' });
const h = r.ok ? (await r.json())?.route?.harness : null;
return typeof h === 'string' && h ? clean(h, 64) : null;
} catch { return null; }
}
// Plain words for each answer. A refused send keeps the draft; an unknown outcome is never resent. // Plain words for each answer. A refused send keeps the draft; an unknown outcome is never resent.
function answer(status, body) { function answer(status, body) {
const code = body && typeof body.error === 'string' ? body.error : ''; const code = body && typeof body.error === 'string' ? body.error : '';
@@ -300,7 +312,8 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
// Slice 1 has no way to issue a Triage key, so that line ends at what is missing. // 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-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-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, and the chosen model doesn\'t run with it. Choose a model that runs with Claude Code in Triage settings.', link: TRIAGE_FIX }; // The harness is named as its module declares it, from the route read in send(); no list of names lives here.
if (status === 409 && code === 'triage-harness-incompatible') return { text: harnessRefused(null), harnessRefused: true, 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-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 }; 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. // Any other route refusal (an unsafe key file, ...) carries its own plain line.
@@ -331,6 +344,7 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date(
try { try {
const r = await systemFetch('/api/triage/message', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ text }), cache: 'no-store', redirect: 'manual' }); const r = await systemFetch('/api/triage/message', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ text }), cache: 'no-store', redirect: 'manual' });
result = answer(r.status, await r.json().catch(() => null)); result = answer(r.status, await r.json().catch(() => null));
if (result.harnessRefused) { const h = await routeHarness(); if (h) result.text = harnessRefused(h); }
} catch { } catch {
result = { unknown: true, text: 'The Console did not answer. The message may or may not have arrived. It was not sent again: check the conversation before you send it again.' }; result = { unknown: true, text: 'The Console did not answer. The message may or may not have arrived. It was not sent again: check the conversation before you send it again.' };
} }
+4 -7
View File
@@ -33,15 +33,12 @@
const models = () => (Array.isArray(data?.choices?.models) ? data.choices.models : []); const models = () => (Array.isArray(data?.choices?.models) ? data.choices.models : []);
const harnessesOf = key => models().find(m => m.key === key)?.harnesses ?? []; const harnessesOf = key => models().find(m => m.key === key)?.harnesses ?? [];
// #1873 settings slice 1 (section 9): the owner reads a harness by its product name; the id stays the value.
const HARNESS_NAMES = { 'claude-code': 'Claude Code', codex: 'Codex', opencode: 'OpenCode' };
const harnessName = h => HARNESS_NAMES[h] ?? h;
const savedAt = v => (Number.isFinite(Date.parse(v)) ? window.MosaicLocalTime(v) : 'at an unknown time'); const savedAt = v => (Number.isFinite(Date.parse(v)) ? window.MosaicLocalTime(v) : 'at an unknown time');
function stored() { function stored() {
const r = data?.route; const r = data?.route;
if (!r) return `<p id="triage-route-stored" data-revision="0"><strong>Not set.</strong> Triage has no model chosen yet, so it will not start.</p>`; if (!r) return `<p id="triage-route-stored" data-revision="0"><strong>Not set.</strong> Triage has no model chosen yet, so it will not start.</p>`;
return `<p id="triage-route-stored" data-revision="${esc(r.revision)}">Saved route: <strong>${esc(r.model)}</strong>, runs with <strong>${esc(harnessName(r.harness))}</strong>. Daily token limit ${esc(Number(r.cap).toLocaleString('en-US'))}, resets at ${esc(r.reset)} ${esc(r.timeZone)}. Saved ${esc(savedAt(r.updatedAt))}.</p>`; return `<p id="triage-route-stored" data-revision="${esc(r.revision)}">Saved route: <strong>${esc(r.model)}</strong>, runs with <strong>${esc(r.harness)}</strong>. Daily token limit ${esc(Number(r.cap).toLocaleString('en-US'))}, resets at ${esc(r.reset)} ${esc(r.timeZone)}. Saved ${esc(savedAt(r.updatedAt))}.</p>`;
} }
function form() { function form() {
@@ -55,14 +52,14 @@
+ list.map(m => `<option value="${esc(m.key)}"${m.key === d.model ? ' selected' : ''}${m.available ? '' : ' disabled'}>${esc(m.label && m.label !== m.key ? `${m.label} (${m.key})` : m.key)}${m.available ? '' : ' (unavailable)'}</option>`).join(''); + list.map(m => `<option value="${esc(m.key)}"${m.key === d.model ? ' selected' : ''}${m.available ? '' : ' disabled'}>${esc(m.label && m.label !== m.key ? `${m.label} (${m.key})` : m.key)}${m.available ? '' : ' (unavailable)'}</option>`).join('');
const hs = harnessesOf(d.model); const hs = harnessesOf(d.model);
const harnessOptions = `<option value=""${d.harness === '' ? ' selected' : ''}>${d.model ? 'Choose what runs it' : 'Choose a model first'}</option>` const harnessOptions = `<option value=""${d.harness === '' ? ' selected' : ''}>${d.model ? 'Choose what runs it' : 'Choose a model first'}</option>`
+ (d.harness && !hs.includes(d.harness) ? `<option value="${esc(d.harness)}" selected>${esc(harnessName(d.harness))} (not offered for this model)</option>` : '') + (d.harness && !hs.includes(d.harness) ? `<option value="${esc(d.harness)}" selected>${esc(d.harness)} (not offered for this model)</option>` : '')
+ hs.map(h => `<option value="${esc(h)}"${h === d.harness ? ' selected' : ''}>${esc(harnessName(h))}</option>`).join(''); + hs.map(h => `<option value="${esc(h)}"${h === d.harness ? ' selected' : ''}>${esc(h)}</option>`).join('');
const status = data?.choices?.status; const status = data?.choices?.status;
const catalogue = status === 'ready' ? '' : `<p class="small warn" id="triage-route-catalogue" data-status="${esc(status ?? 'unknown')}">No organization can show your models right now, so no route can be saved. <a href="#/settings/model-proxy">Open Model setup</a> to see why each organization can't see your models.</p>`; const catalogue = status === 'ready' ? '' : `<p class="small warn" id="triage-route-catalogue" data-status="${esc(status ?? 'unknown')}">No organization can show your models right now, so no route can be saved. <a href="#/settings/model-proxy">Open Model setup</a> to see why each organization can't see your models.</p>`;
const conflictButton = conflict ? ' <button type="button" class="btn" id="triage-route-reload">Reload route</button>' : ''; const conflictButton = conflict ? ' <button type="button" class="btn" id="triage-route-reload">Reload route</button>' : '';
return `${catalogue}<form id="triage-route-form" novalidate><div class="filters">` return `${catalogue}<form id="triage-route-form" novalidate><div class="filters">`
+ `<label>Model <select id="triage-route-model"${off}>${modelOptions}</select></label>` + `<label>Model <select id="triage-route-model"${off}>${modelOptions}</select></label>`
+ `<label>Runs with <select id="triage-route-harness" aria-describedby="triage-route-harness-help"${off}>${harnessOptions}</select><span class="small muted" id="triage-route-harness-help">The program that runs the model. Triage runs only with Claude Code.</span></label>` + `<label>Runs with <select id="triage-route-harness" aria-describedby="triage-route-harness-help"${off}>${harnessOptions}</select><span class="small muted" id="triage-route-harness-help">The program that runs the model, named as its module is installed. The list shows only the programs this model runs with.</span></label>`
+ `<label>Daily token limit <input id="triage-route-cap" type="number" min="1" step="1" inputmode="numeric" value="${esc(d.cap)}"${off}></label>` + `<label>Daily token limit <input id="triage-route-cap" type="number" min="1" step="1" inputmode="numeric" value="${esc(d.cap)}"${off}></label>`
+ `<label>Reset <input id="triage-route-reset" value="00:00" readonly aria-readonly="true"></label>` + `<label>Reset <input id="triage-route-reset" value="00:00" readonly aria-readonly="true"></label>`
+ `<label>Time zone <input id="triage-route-zone" list="triage-route-zones" autocomplete="off" spellcheck="false" placeholder="Region/City" value="${esc(d.timeZone)}"${off}></label>` + `<label>Time zone <input id="triage-route-zone" list="triage-route-zones" autocomplete="off" spellcheck="false" placeholder="Region/City" value="${esc(d.timeZone)}"${off}></label>`
@@ -472,17 +472,21 @@ test('triage-cap: a read without the usage fields shows no usage line', async t
assert.equal(await f.b.evaluate('document.querySelector("#triage-usage").hidden'), true); assert.equal(await f.b.evaluate('document.querySelector("#triage-usage").hidden'), true);
}); });
// The Triage route read this test server does not mount: the route names its harness as the module is installed.
const ROUTE_READ = `(()=>{const prev=window.fetch;window.fetch=(i,init)=>{if(new URL(typeof i==="string"?i:i.url,location.href).pathname==="/api/triage/route")return Promise.resolve(new Response(JSON.stringify({route:{model:"sonnet",harness:"claude-code",cap:150000,reset:"00:00",timeZone:"UTC",revision:1,updatedAt:"2026-11-18T12:00:00.000Z"},revision:1,choices:{status:"ready",models:[]},send:true,note:""}),{status:200,headers:{"content-type":"application/json"}}));return prev(i,init);};})()`;
// #1873 settings slice 1, bullet 5 (DESIGN.md section 5): a route refusal is a plain line that says what is // #1873 settings slice 1, bullet 5 (DESIGN.md section 5): a route refusal is a plain line that says what is
// missing, with a link to the Settings page that fixes it. The harness refusal names Claude Code. The key // missing, with a link to the Settings page that fixes it. The harness refusal names the route's harness as
// refusal has no fix page in slice 1, so it ends at what is missing and offers no link. // its module declares it, read from the route; no harness name is written into the page. The key refusal has
test('settings-s1 B5: route refusals read as plain lines with the fix link; the harness line names Claude Code', async t => { // no fix page in slice 1, so it ends at what is missing and offers no link.
test('settings-s1 B5: route refusals read as plain lines with the fix link; the harness line names the route\'s harness', async t => {
const host = fakeHost({ running: false }); const host = fakeHost({ running: false });
const f = await setup(t, { host, proxyAdmin: {} }); const f = await setup(t, { host, proxyAdmin: {}, init: ROUTE_READ });
await open(f); await open(f);
await type(f, 'is acme healthy?'); await type(f, 'is acme healthy?');
const { ROUTE_REFUSALS } = await import('../src/triage-host.mjs'); const { ROUTE_REFUSALS } = await import('../src/triage-host.mjs');
const cases = [ const cases = [
['triage-harness-incompatible', /^Not sent\. Triage runs only with Claude Code, and the chosen model doesn't run with it\. Choose a model that runs with Claude Code in Triage settings\. Open Triage settings$/, '#/settings/triage'], ['triage-harness-incompatible', /^Not sent\. The model Triage uses doesn't run with claude-code, the program its route says runs it\. Choose a model that runs with claude-code, or another program, in Triage settings\. Open Triage settings$/, '#/settings/triage'],
['triage-proxy-down', /^Not sent\. The model service isn't running, so Triage can't start\. Open Model setup$/, '#/settings/model-proxy'], ['triage-proxy-down', /^Not sent\. The model service isn't running, so Triage can't start\. Open Model setup$/, '#/settings/model-proxy'],
['triage-model-not-offered', /^Not sent\. The model Triage uses is no longer offered\./, '#/settings/triage'], ['triage-model-not-offered', /^Not sent\. The model Triage uses is no longer offered\./, '#/settings/triage'],
['triage-key-missing', /^Not sent\. Triage isn't turned on yet: it needs a Triage key, and none is issued on this instance\.$/, null], ['triage-key-missing', /^Not sent\. Triage isn't turned on yet: it needs a Triage key, and none is issued on this instance\.$/, null],
@@ -508,6 +512,20 @@ test('settings-s1 B5: route refusals read as plain lines with the fix link; the
assert.notEqual(await f.text('h1'), 'Not found'); assert.notEqual(await f.text('h1'), 'Not found');
}); });
// When the route read gives no harness (here the server does not mount it), the line stays plain without a name.
test('settings-s1 B5: the harness refusal without a readable route keeps a plain line and its fix link', async t => {
const host = fakeHost({ running: false });
const f = await setup(t, { host, proxyAdmin: {} });
await open(f);
await type(f, 'is acme healthy?');
const { ROUTE_REFUSALS } = await import('../src/triage-host.mjs');
host.h.next = new TriageError('triage-harness-incompatible', ROUTE_REFUSALS['triage-harness-incompatible']);
const status = await sendAndWait(f, '');
assert.equal(status, "Not sent. The model Triage uses doesn't run with the program its route says runs it. Choose a model and a program that run together in Triage settings. Open Triage settings");
assert.equal(await f.b.evaluate('document.querySelector("#triage-send-status a")?.getAttribute("href") ?? null'), '#/settings/triage');
assert.equal(await f.b.evaluate('document.querySelector("#triage-text").value'), 'is acme healthy?', 'the draft stays');
});
// Settings > Triage exists only where /api/config says proxyAdmin, so without it no line links there. // Settings > Triage exists only where /api/config says proxyAdmin, so without it no line links there.
test('settings-s1 B5: without the Triage settings page the refusal keeps its line and offers no link to it', async t => { test('settings-s1 B5: without the Triage settings page the refusal keeps its line and offers no link to it', async t => {
const host = fakeHost({ route: 'not set' }); const host = fakeHost({ route: 'not set' });
@@ -46,6 +46,8 @@ test('the owner sees Triage in Settings, "not set" before a first save, the cata
assert.equal(await text(b, 'settings-page-title'), 'Triage'); assert.equal(await text(b, 'settings-page-title'), 'Triage');
assert.deepEqual(await options(b, 'triage-route-model'), [['', 'Choose a model', false], ['down', 'Down (down) (unavailable)', true], ['glm-flash', 'GLM Flash (glm-flash)', false], ['sonnet', 'Sonnet (sonnet)', false]]); assert.deepEqual(await options(b, 'triage-route-model'), [['', 'Choose a model', false], ['down', 'Down (down) (unavailable)', true], ['glm-flash', 'GLM Flash (glm-flash)', false], ['sonnet', 'Sonnet (sonnet)', false]]);
assert.deepEqual(await options(b, 'triage-route-harness'), [['', 'Choose a model first', false]]); assert.deepEqual(await options(b, 'triage-route-harness'), [['', 'Choose a model first', false]]);
// The help line names no harness: the list carries each harness's id as its module is installed.
assert.equal(await text(b, 'triage-route-harness-help'), 'The program that runs the model, named as its module is installed. The list shows only the programs this model runs with.');
assert.equal(await value(b, 'triage-route-cap'), '', 'no default cap'); assert.equal(await value(b, 'triage-route-cap'), '', 'no default cap');
assert.equal(await value(b, 'triage-route-zone'), '', 'no default time zone'); assert.equal(await value(b, 'triage-route-zone'), '', 'no default time zone');
assert.equal(await value(b, 'triage-route-reset'), '00:00'); assert.equal(await value(b, 'triage-route-reset'), '00:00');
@@ -76,7 +78,7 @@ test('Save posts the fields and the read revision once, then shows the stored ro
await wait('/^Saved .+\\.$/.test(document.getElementById("triage-route-line")?.textContent) && document.getElementById("triage-route-stored")?.dataset.revision==="1"'); await wait('/^Saved .+\\.$/.test(document.getElementById("triage-route-line")?.textContent) && document.getElementById("triage-route-stored")?.dataset.revision==="1"');
assert.equal(await b.evaluate('document.activeElement?.id'), 'triage-route-line', 'focus lands on the saved line, not the page body'); assert.equal(await b.evaluate('document.activeElement?.id'), 'triage-route-line', 'focus lands on the saved line, not the page body');
assert.deepEqual(await writes(b), [{ method: 'POST', body: { model: 'sonnet', harness: 'claude-code', cap: 150000, timeZone: 'America/Chicago', revision: 0 } }]); assert.deepEqual(await writes(b), [{ method: 'POST', body: { model: 'sonnet', harness: 'claude-code', cap: 150000, timeZone: 'America/Chicago', revision: 0 } }]);
assert.match(await text(b, 'triage-route-stored'), /^Saved route: sonnet, runs with Claude Code\. Daily token limit 150,000, resets at 00:00 America\/Chicago\. Saved .+\.$/); assert.match(await text(b, 'triage-route-stored'), /^Saved route: sonnet, runs with claude-code\. Daily token limit 150,000, resets at 00:00 America\/Chicago\. Saved .+\.$/);
assert.equal(await value(b, 'triage-route-cap'), '150000'); assert.equal(await value(b, 'triage-route-cap'), '150000');
// The next save carries the new revision. // The next save carries the new revision.
await type(b, 'triage-route-cap', '9000'); await type(b, 'triage-route-cap', '9000');