mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 09:20:03 +01:00
fix(home): cancel and error proposal chips render cleanly (no 'proposed' prefix, no 0% confidence)
When the user clicked Cancel and it succeeded, the chip rendered as: proposed cancelled — Ctrl+C sent... · 0% confidence because renderProposal had only two branches: dispatched (the post-/api/dispatch happy chip) and the catch-all 'proposed' shape for real decide() outputs. Cancel and error results fell into the latter, inheriting both the 'proposed' label and the meaningless 0% confidence pill that came from the synthetic confidence:0 we set when stuffing those non-decision events into the proposals Map. Split renderProposal into three explicit branches: • kind === 'cancelled' → 'cancelled · <reason>' (no confidence) • kind === 'error' → red 'error · <reason>' (no confidence) • everything else → the existing 'proposed' chip with confidence Side note: a non-obvious bash trap during this commit — the comment above the new branches initially used backticks around the word 'reason' for stylistic emphasis. The whole HTML body lives inside a template literal, so those backticks closed the literal mid-comment and tsc reported syntax errors on the comment line. Reworded the comment to avoid backticks. Worth flagging for future home/server.ts edits inside the INDEX_HTML body. tsc clean, eslint clean, smoke confirmed the new template lands in the served HTML.
This commit is contained in:
1 file changed
+13
@@ -172,6 +172,19 @@ function renderProposal(p) {
|
||||
}
|
||||
const a = prop.decision.action;
|
||||
const reason = a.reason ?? '';
|
||||
// Cancel and error chips carry their full message in the reason field —
|
||||
// don't tack on the meaningless 0% confidence pill or the "proposed"
|
||||
// prefix (Cancel isn't a proposal, Error wasn't a brain decision). Only
|
||||
// real decide()-produced proposals (wait/dispatch/recovery) get the
|
||||
// confidence footer.
|
||||
if (a.kind === 'cancelled') {
|
||||
return '<div class="proposal"><span class="label">cancelled</span>' +
|
||||
(reason ? escapeHtml(reason) : 'Ctrl+C sent') + '</div>';
|
||||
}
|
||||
if (a.kind === 'error') {
|
||||
return '<div class="proposal" style="border-left-color:#dc2626;color:#f87171"><span class="label">error</span>' +
|
||||
escapeHtml(reason || 'unknown') + '</div>';
|
||||
}
|
||||
return '<div class="proposal"><span class="label">proposed</span>' +
|
||||
escapeHtml(a.kind) + (a.intent ? ' · ' + escapeHtml(a.intent) : '') +
|
||||
(reason ? ' — ' + escapeHtml(reason) : '') +
|
||||
|
||||
Reference in new issue
Block a user