From 614bde2cc53ba42bbeffd680f509fc477e420ba5 Mon Sep 17 00:00:00 2001 From: g-but <41178744+g-but@users.noreply.github.com> Date: Wed, 20 May 2026 07:37:30 +0200 Subject: [PATCH] fix(home): cancel and error proposal chips render cleanly (no 'proposed' prefix, no 0% confidence) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 · ' (no confidence) • kind === 'error' → red 'error · ' (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. --- home/server.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/home/server.ts b/home/server.ts index 044ef3513..456db509d 100644 --- a/home/server.ts +++ b/home/server.ts @@ -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 '
cancelled' + + (reason ? escapeHtml(reason) : 'Ctrl+C sent') + '
'; + } + if (a.kind === 'error') { + return '
error' + + escapeHtml(reason || 'unknown') + '
'; + } return '
proposed' + escapeHtml(a.kind) + (a.intent ? ' · ' + escapeHtml(a.intent) : '') + (reason ? ' — ' + escapeHtml(reason) : '') +