← Back to PRs

#13862: ui(chat): surface TUI-style formatted errors in WebChat

by yeaso-ai open 2026-02-11 03:59 View on GitHub →
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