Skip to content

fix(ui): decode artifact previews as UTF-8 - #117657

Merged
steipete merged 1 commit into
mainfrom
codex/qa400-ui-artifact-utf8-8d7
Aug 2, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa400-ui-artifact-utf8-8d7

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Control UI workspace previews corrupt UTF-8 text and JSON artifacts. Accented characters, CJK text, and emoji appear as mojibake, and the sidebar's copied raw text is corrupted too.

Why This Change Was Made

The Gateway delivers inline artifacts as Base64-encoded bytes, but the workspace preview treated the binary string returned by atob() as decoded text. One canonical text-artifact path now converts those bytes through TextDecoder, matching the existing attachment decoder in ui/src/pages/chat/components/chat-attachments.ts and removing duplicated JSON/plain-text branches.

User Impact

Downloaded text/plain and application/json artifacts display and copy their original Unicode content correctly. Existing Markdown/JSON code fences, image data URLs, and visible malformed-Base64 errors are preserved. Production code decreases by two lines.

Evidence

  • Focused owner suite: node scripts/run-vitest.mjs ui/src/pages/chat/components/chat-session-workspace.test.ts.
  • Before the fix: both real Unicode regressions failed; the other 15 tests passed.
  • After the fix: all 17 tests passed, including accented/CJK/emoji JSON and plain text, unchanged image previews, and malformed-Base64 visible errors.
  • Four independent blind hostile source reviews returned no P0–P3 findings.
  • Official Codex autoreview returned findings: [], patch is correct, and confidence 0.98; TruffleHog secret scanning also passed.
  • Frozen reviewed commit: a2893fba094c2aa541613b0013ceacd308d50495.
  • Real served Control UI browser proof on the exact frozen head a2893fba094c2aa541613b0013ceacd308d50495: 2/2 passed using actual Google Chrome 150.0.7871.187, the real Vite-served Control UI, and a mocked Gateway WebSocket; artifacts.list and artifacts.download were exercised through the actual workspace artifact rows.
  • Focused browser command: PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/qa400-artifact-utf8-proof.e2e.test.ts (the isolated temporary proof spec was removed after the run; the reviewed Git tree stayed unchanged).
  • The actual browser visibly rendered and displayed raw Résumé 東京 🦀 for both text/plain and application/json, expanded the JSON preview, clicked each real code-copy button, and confirmed the browser clipboard received the exact original Unicode string; no Gateway or unknown-agent error appeared.
  • Redacted real-browser screenshots: text-plain-rendered.png, text-plain-raw.png, application-json-rendered.png, and application-json-raw.png under /private/tmp/openclaw-qa400-ui-artifact-utf8-a289-browser-proof/. Structured request/clipboard evidence is in text-plain.json and application-json.json in the same directory.
  • Authoritative clean browser-test terminal log: /private/tmp/openclaw-qa400-ui-artifact-utf8-a289-browser-proof-final.log (Test Files 1 passed; Tests 2 passed; duration 10.45s).

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 21:58
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 9:48 PM ET / August 2, 2026, 01:48 UTC.

ClawSweeper review

What this changes

The PR decodes Base64 text/* and JSON workspace artifacts as UTF-8 before the Control UI renders or copies their preview content.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Current main still corrupts Base64 UTF-8 artifact text by using the binary string returned from atob() directly. The PR repairs that owner boundary with byte decoding plus TextDecoder, matches the existing Control UI attachment pattern, and remains a valid focused fix; the protected maintainer label requires a human merge decision.

Priority: P2
Reviewed head: a2893fba094c2aa541613b0013ceacd308d50495
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary fix with matching regression coverage, a pre-existing sibling decoder pattern, successful checks, and concrete served-browser proof.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body now records an exact-head served-browser run that exercised actual artifact rows, rendered and copied Unicode text for plain text and JSON, and reports redacted screenshots plus a passing two-test terminal result.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body now records an exact-head served-browser run that exercised actual artifact rows, rendered and copied Unicode text for plain text and JSON, and reports redacted screenshots plus a passing two-test terminal result.
Evidence reviewed 6 items Current-main defect: Current main assigns globalThis.atob(data) directly to both markdown content and copied raw text for Base64 JSON and text/* artifacts. That value is a binary string, not decoded UTF-8 text.
Gateway-to-UI path: Opening an artifact calls Gateway artifacts.download and passes its data, encoding, MIME type, title, and URL directly into the affected sidebar-content function.
Existing sibling conversion: The existing attachment text path converts Base64 binary-string characters to bytes and applies TextDecoder before treating the result as text, matching this PR’s conversion contract.
Findings None None.
Security None None.

How this fits together

The Control UI requests workspace artifacts from the Gateway, selects a preview based on MIME type, and forwards rendered and raw text to the sidebar. This patch changes the Base64 text conversion boundary before that content is displayed or copied.

flowchart LR
  A[Gateway artifact response] --> B[Workspace artifact request]
  B --> C[MIME preview selection]
  C --> D[Base64 bytes decoded as UTF-8]
  D --> E[Rendered sidebar preview]
  D --> F[Copyable raw text]
Loading

Decision needed

Question Recommendation
Should this maintainer-labeled Control UI bug fix be refreshed against current main and landed with its supplied browser proof? Refresh and land: Rebase or refresh the clean merge result, then merge the focused UTF-8 decoding repair.

Why: The implementation is source-proven and the supplied exact-head browser evidence is strong, but the protected maintainer label requires an explicit human merge decision.

Before merge

  • Resolve merge risk (P1) - The branch is behind current main, so a maintainer should refresh the clean merge result before landing; this alone does not show that the patch removes current-main behavior.
Agent review details

Security

None.

PR surface

Source -2, Tests +89. Total +87 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 9 11 -2
Tests 1 89 0 +89
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 98 11 +87

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: ui/src/pages/chat/components/chat-session-workspace.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused UTF-8 byte-decoding repair after a maintainer confirms the refreshed merge result, retaining the existing image data-URL and visible malformed-Base64 error paths.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the focused UTF-8 byte-decoding repair after a maintainer confirms the refreshed merge result, retaining the existing image data-URL and visible malformed-Base64 error paths.

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

Yes. Current main routes Base64 text/* and JSON artifact data through direct atob() output, which deterministically mishandles UTF-8 bytes before rendering and copying.

Is this the best way to solve the issue?

Yes. Converting the Base64 binary string into bytes and applying the existing TextDecoder pattern fixes the conversion at its owner boundary without changing image or error behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6a527b6e5531.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body now records an exact-head served-browser run that exercised actual artifact rows, rendered and copied Unicode text for plain text and JSON, and reports redacted screenshots plus a passing two-test terminal result.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body now records an exact-head served-browser run that exercised actual artifact rows, rendered and copied Unicode text for plain text and JSON, and reports redacted screenshots plus a passing two-test terminal result.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The defect corrupts Control UI artifact preview and copied text but has a narrow UI-only blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body now records an exact-head served-browser run that exercised actual artifact rows, rendered and copied Unicode text for plain text and JSON, and reports redacted screenshots plus a passing two-test terminal result.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body now records an exact-head served-browser run that exercised actual artifact rows, rendered and copied Unicode text for plain text and JSON, and reports redacted screenshots plus a passing two-test terminal result.

Evidence

What I checked:

Likely related people:

  • steipete: Git blame attributes the current artifact-preview owner function to Peter Steinberger, and the supplied PR by steipete repairs that same function and its regression coverage. (role: current behavior author and recent area contributor; confidence: high; commits: 2fcb1f728028, a2893fba094c; files: ui/src/pages/chat/components/chat-session-workspace.ts, ui/src/pages/chat/components/chat-session-workspace.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-01T22:03:58.269Z sha a2893fb :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 2, 2026
@steipete
steipete merged commit 12a8d80 into main Aug 2, 2026
158 of 174 checks passed
@steipete
steipete deleted the codex/qa400-ui-artifact-utf8-8d7 branch August 2, 2026 02:05
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
llwijvbw123 pushed a commit to llwijvbw123/openclaw that referenced this pull request Aug 28, 2026
…elf-release

* commit '10a390ed7fa88d09da0d4523c3ed1e3550ece5c6': (4646 commits)
  fix(release): allow larger npm plugin artifacts (openclaw#117745)
  refactor(macos): consolidate gateway process fixtures (openclaw#117740)
  fix(ui): preserve complete persisted log messages (openclaw#117666)
  fix(ui): decode artifact previews as UTF-8 (openclaw#117657)
  fix(control-ui): restore sandbox media previews (openclaw#117689)
  fix(plugins): link host declared as direct dependency (openclaw#117738)
  fix(macos): avoid self-named defaults suite (openclaw#117690)
  fix(inference): preserve run ownership and completion delivery (openclaw#117731)
  test(talk): align browser E2E tool completion
  test: consolidate OpenClaw E2E fixtures (openclaw#117701)
  fix(release): ignore bundle fields in npm locks (openclaw#117730)
  fix(meeting-bot): keep configured host options internal
  refactor(line): remove dead card helpers (openclaw#117729)
  perf(cli): attribute command startup stages (openclaw#117720)
  refactor(whatsapp): deduplicate reply delivery test fixtures (openclaw#117710)
  docs(changelog): note bounded WebRTC tool calls
  docs(changelog): note meeting audio bounds
  fix(meeting-bot): preserve node host SDK surface
  test(talk): split WebRTC tool lifecycle coverage
  fix(meeting-bot): break node host import cycle
  ...

# Conflicts:
#	package.json
#	src/agents/model-auth.ts
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant