diff --git a/packages/webui/src/public/display.js b/packages/webui/src/public/display.js index e7fc6606e..b94ddf27c 100644 --- a/packages/webui/src/public/display.js +++ b/packages/webui/src/public/display.js @@ -288,6 +288,18 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date( 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. function answer(status, body) { 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. 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, 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-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. @@ -331,6 +344,7 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date( try { 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)); + if (result.harnessRefused) { const h = await routeHarness(); if (h) result.text = harnessRefused(h); } } 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.' }; } diff --git a/packages/webui/src/public/triage-settings.js b/packages/webui/src/public/triage-settings.js index c64de1507..6af4d58ce 100644 --- a/packages/webui/src/public/triage-settings.js +++ b/packages/webui/src/public/triage-settings.js @@ -33,15 +33,12 @@ const models = () => (Array.isArray(data?.choices?.models) ? data.choices.models : []); 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'); function stored() { const r = data?.route; if (!r) return `
Not set. Triage has no model chosen yet, so it will not start.
`; - return `Saved route: ${esc(r.model)}, runs with ${esc(harnessName(r.harness))}. Daily token limit ${esc(Number(r.cap).toLocaleString('en-US'))}, resets at ${esc(r.reset)} ${esc(r.timeZone)}. Saved ${esc(savedAt(r.updatedAt))}.
`; + return `Saved route: ${esc(r.model)}, runs with ${esc(r.harness)}. Daily token limit ${esc(Number(r.cap).toLocaleString('en-US'))}, resets at ${esc(r.reset)} ${esc(r.timeZone)}. Saved ${esc(savedAt(r.updatedAt))}.
`; } function form() { @@ -55,14 +52,14 @@ + list.map(m => ``).join(''); const hs = harnessesOf(d.model); const harnessOptions = `` - + (d.harness && !hs.includes(d.harness) ? `` : '') - + hs.map(h => ``).join(''); + + (d.harness && !hs.includes(d.harness) ? `` : '') + + hs.map(h => ``).join(''); const status = data?.choices?.status; const catalogue = status === 'ready' ? '' : `No organization can show your models right now, so no route can be saved. Open Model setup to see why each organization can't see your models.
`; const conflictButton = conflict ? ' ' : ''; return `${catalogue}