#13862: ui(chat): surface TUI-style formatted errors in WebChat
app: web-ui
size: S
# Prompt Request: WebChat error-surface parity with TUI
Use this prompt to implement and validate the change.
---
You are working in OpenClaw.
Goal:
Make Dashboard WebChat surface run failures with the same class of user-facing error detail as TUI, so
quota/rate-limit/context failures do not look like “streaming with no output”.
Context:
In WebChat, when chat events end with `state === "error"`, the stream/run state is cleared, but failure detail is
not always visible as assistant text in-thread.
TUI currently formats raw assistant/API errors into readable output (HTTP code/type/message/request_id where
available).
Requirements:
1) Add/ensure a UI-side formatter that matches TUI-style raw error formatting behavior:
- If input is empty: `LLM request failed with an unknown error.`
- If input starts with plain `NNN <text>` and `<text>` is not JSON: `HTTP NNN: <text>`
- If input contains structured JSON API error payloads:
- include HTTP code when present
- include error type when present
- include message
- include request_id when present
- example shape: `HTTP 429 rate_limit_error: ... (request_id: req_123)`
- Truncate very long raw fallbacks safely.
2) Wire formatter into WebChat chat controller in both paths:
- immediate send failure (`sendChatMessage` catch path)
- streamed chat event failure (`handleChatEvent` when `payload.state === "error"`)
3) On `state === "error"`:
- clear stream/run state as today
- set `lastError` to formatted value
- append an assistant message bubble containing formatted error text to `chatMessages`
- do not break existing behavior for delta/final/aborted or unrelated run IDs
4) Tests:
- Add/adjust tests to cover:
- structured JSON error formatting
- plain HTTP-prefixed error formatting
- unknown/empty fallback
- error event appends assistant message and clears run/stream state
5) Keep scope tight:
- no unrelated refactors
- no API contract changes unless strictly required
Acceptance criteria:
- Repro a provider error in Dashboard WebChat (quota/rate-limit/context overflow): user sees explicit assistant
error text in-thread.
- Error text quality matches TUI class of detail.
- Tests for formatter + chat error handling pass.
Most Similar PRs
#5693: fix(chat): display error messages when LLM requests fail
by niemesrw · 2026-01-31
67.4%
#18942: fix(tui): trigger render after finalizing chat assistant message
by BinHPdev · 2026-02-17
62.6%
#3721: fix(ui): webchat not displaying chat responses
by maxmaxrouge-rgb · 2026-01-29
62.6%
#21141: fix- Auto-reply: improve user-facing error messages
by sahilsatralkar · 2026-02-19
61.0%
#18824: fix(ui): avoid chat bubble flicker after streaming completes
by cccat6 · 2026-02-17
60.3%
#9218: Fix Control UI chat resync on gaps and terminal events
by figitaki · 2026-02-05
60.1%
#8353: fix(ui): display tool calls during webchat streaming
by MarvinDontPanic · 2026-02-03
59.8%
#12974: fix: intermittent (no output) reported by users
by vincentkoc · 2026-02-10
59.7%
#7522: fix(webchat): auto-scroll when message queue changes
by alsoknownasfoo · 2026-02-02
59.4%
#20610: fix: reduce chat history render limit to improve performance Fixes #…
by anandsuraj · 2026-02-19
59.4%