Skip to content

fix(ui): show readable errors instead of programming errors - #191192

Merged
vyctorbrzezowski merged 2 commits into
mainfrom
brzezowski/readable-ui-errors
Nov 3, 2026
Merged

vyctorbrzezowski merged 2 commits into
mainfrom
brzezowski/readable-ui-errors

Conversation

@vyctorbrzezowski

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: pages show raw runtime text such as "Cannot read properties of undefined (reading 'map')" when the Control UI hits a code defect or an unexpected response shape.

User Impact

User impact: those failures now show the caller's fallback, or "Request failed" when there is none. Gateway errors and other messages users act on read exactly as before. Developers still get the original error and stack in the console.

Why This Change Was Made

The fix is in formatUiError, so every caller gets it.

Reaches the UI as Errors
Fallback or "Request failed", original in console TypeError, ReferenceError, RangeError, EvalError, URIError, InternalError, including ones from another realm
Unchanged GatewayRequestError, GatewayProtocolRequestError, GatewayProtocolRequestTimeoutError and the other Gateway client errors, UserFacingError, plain Error, DOMException, strings and plain objects
Unchanged, by exception TypeError from a failed fetch or module load (Failed to fetch, Load failed, NetworkError when...), since it describes the connection
Unchanged, by exception SyntaxError, since Debug's RPC params show JSON.parse errors that users fix

The check reads the error's class name, not its text, and Gateway errors have their own classes, so a Gateway message quoting a server exception still passes. A plain wrapper with a programming error as its cause keeps its own message and drops only that cause.

"Request failed" is untranslated, like the callers that already pass it as a fallback: the translated equivalents live in lazy catalogs and render as raw keys on pages that have not loaded them.

Evidence

gateway.node.test.ts now throws SyntaxError for a bad socket URL, which is what browsers throw; its fixture threw a TypeError browsers don't raise there.

Logs on pnpm dev:ui:mock. main now mocks logs.tail (#190380), so to reach this failure both captures ran locally with that one fixture line removed, restoring the mock's default empty response. The line removal is not in this PR. On the unmodified mock, Logs renders its entries with no banner.

Before

Logs banner showing the raw TypeError message

After

Logs banner showing Request failed

After, 390px

Logs banner at phone width showing Request failed

Console on After: [control-ui] programming error hidden from the UI: TypeError: Cannot read properties of undefined (reading 'map') at loadLogs.

Checks on the touched files: oxfmt, oxlint, tsgo:ui, ui:check-performance:base, mapper unit tests, gateway.node.test.ts, and 25 unit files covering Logs and error consumers, plus extensions/workboard/browser.

@vyctorbrzezowski vyctorbrzezowski self-assigned this Nov 2, 2026
@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 2, 2026
@clawsweeper

clawsweeper Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR replaces programming exceptions in Control UI error messages with a fallback while retaining diagnostics in the console.

Example: Logs receives a response without its expected lines array.

  • Before: The banner shows “Cannot read properties of undefined (reading 'map')”.
  • After: The banner shows “Request failed”.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Direct visual evidence supports the intended presentation change, but two focused correctness and usability repairs remain.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected desktop before/after and phone after screenshots exercise the real Logs page through pnpm dev:ui:mock with a disclosed malformed-response fixture; the banner changes to the fallback, and the body records the original console diagnostic.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Control UI failures expose programming exception text that users cannot act on.
Reason: The maintainer-authored direction improves a shared presentation boundary while preserving explicit user-facing and Gateway errors.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep this maintainer-authored PR open: the shared formatter change has useful visual proof, but cause filtering can corrupt retained messages and the new default gives no recovery guidance.

Priority: P2
Reviewed head: a7480f1977878e7602b5b2329843a34485bca916

Before merge

  • Filter causes before flattening their messages (P2) - Removing | ${cause.message} from the combined text can remove an unrelated retained message. For example, an AggregateError containing Error("x is not a function; reconnect and retry") followed by TypeError("x is not a function") formats the first cause, then skips the TypeError because its message is already a substring. This replacement subsequently strips the beginning of the retained Error and produces malformed text. An empty TypeError message also removes an unrelated separator. Exclude the classified nodes while assembling the error graph's text rather than deleting substrings afterward.
  • Give the new default failure message a next action (P2) - The demonstrated Logs failure reaches formatUiError without a fallback, so this branch now displays only “Request failed”. The new message identifies neither a useful recovery step nor how to proceed if retrying fails, contrary to the repository's error-message contract. Use default copy that directs the user to retry and report a persistent failure while keeping the programming detail in diagnostics.

Findings

  • [P2] Filter causes before flattening their messages — ui/src/lib/format-error.ts:63-65
  • [P2] Give the new default failure message a next action — ui/src/lib/format-error.ts:28

Tests

  • Missing end-to-end proof: The added formatter regressions are not accompanied by a recorded red-on-base test run.
Agent review details

How this fits together

Control UI pages pass caught failures through formatUiError, which combines error details, redacts sensitive text, and returns presentation text.

flowchart LR
  A[Page operation] --> B[Caught error]
  B --> C[UI error formatter]
  C --> D[Programming error classification]
  D --> E[Console diagnostics]
  D --> F[Fallback or retained message]
  F --> G[UI error banner]
Loading

Technical review

Best possible solution:

Keep the existing formatter as policy owner, filter programming-error nodes before assembling messages, and provide a default with a clear next action.

Do we have a high-confidence way to reproduce the issue?

Current-main source explains the exposed exception text, and the supplied browser captures demonstrate it with a malformed Logs response; no target code was executed during this review.

Is this the best way to solve the issue?

Centralizing presentation policy is appropriate, but filtering flattened strings loses error identity and the generic fallback needs recovery guidance.

Full review comments:

  • [P2] Filter causes before flattening their messages — ui/src/lib/format-error.ts:63-65
    Removing | ${cause.message} from the combined text can remove an unrelated retained message. For example, an AggregateError containing Error("x is not a function; reconnect and retry") followed by TypeError("x is not a function") formats the first cause, then skips the TypeError because its message is already a substring. This replacement subsequently strips the beginning of the retained Error and produces malformed text. An empty TypeError message also removes an unrelated separator. Exclude the classified nodes while assembling the error graph's text rather than deleting substrings afterward.
    Confidence: 0.98
  • [P2] Give the new default failure message a next action — ui/src/lib/format-error.ts:28
    The demonstrated Logs failure reaches formatUiError without a fallback, so this branch now displays only “Request failed”. The new message identifies neither a useful recovery step nor how to proceed if retrying fails, contrary to the repository's error-message contract. Use default copy that directs the user to retry and report a persistent failure while keeping the programming detail in diagnostics.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f33f9c1c53f9.

Provenance checked

  • Central UI error formatting and redaction changes intended behavior with a stated reason (8bf62e7: Consolidate drifting UI error helpers and bind browser-safe redaction once.)
  • Complete user-facing messages keeps the original intent (ce4b8d6: Keep localized guidance separate from retained native diagnostic causes.)
  • WebSocket constructor-error fixture changes intended behavior with a stated reason (4eb8b00: The table was consolidated while retaining connection diagnostic coverage; the earlier fixture modeled a generic constructor failure as TypeError.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test ui/src/lib/format-error.test.ts ui/src/api/gateway.node.test.ts --maxWorkers=1
  • pnpm test ui/src/components/panel-refresh-status.test.ts --maxWorkers=1
  • pnpm tsgo:ui
  • git diff --check

What I checked:

PR surface

Source +56, Tests +104. Total +160 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 58 2 +56
Tests 2 106 2 +104
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 164 4 +160

Labels

Label changes:

  • add P2: This improves error presentation across the Control UI, with focused repairs needed before merge.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This improves error presentation across the Control UI, with focused repairs needed before merge.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 2, 2026, 10:43 AM ET / 15:43 UTC.

@vyctorbrzezowski
vyctorbrzezowski merged commit 0cfd110 into main Nov 3, 2026
15 of 16 checks passed
@vyctorbrzezowski
vyctorbrzezowski deleted the brzezowski/readable-ui-errors branch November 3, 2026 15:58
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 4, 2026
…#191192)

Show readable failure messages while keeping programming errors in diagnostics. Read error fields through the existing typed helper and narrow diagnostic objects without casts.

Validated 77 formatter/Gateway client tests, UI types, assertion safety, and formatting. Safe UserFacingError messages and network/SyntaxError behavior are retained. Prior Cron layout failure is unrelated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant