Repository navigation
fix(ui): preserve literal source previews and copied whitespace - #140306
Conversation
Use the shared variable-length fence formatter for raw text and decoded text artifacts. Encode all code-copy payloads with the existing marked JSON transport so attribute sanitation cannot trim indentation or a final newline. Keep decoder, marker values, parser and inline-code behavior unchanged. Validation: original nested-fence and independent whitespace regressions fail before their repairs; 125 selected cases, 20 source checks and 10 docs checks pass. Synthetic browser component captures verify raw-view and artifact actions. Final eight-file P2 review is clean.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 1:14 PM ET / 17:14 UTC. ClawSweeper reviewWhat this changesThe PR preserves nested Markdown in source previews and whitespace in copied code by reusing existing fence formatting and encoded clipboard payloads. Merge readiness✅ Ready for maintainer review The repair remains useful: current main still contains the reported defects. No actionable correctness or security findings were identified, and this maintainer-authored PR is protected from automatic closure. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI renders chat source text and downloaded text artifacts in a sidebar. Its Markdown renderer produces sanitized previews and supplies code text to the shared clipboard handler. flowchart LR
A[Chat source text] --> C[Literal preview formatting]
B[Decoded text artifact] --> C
C --> D[Sanitized Markdown renderer]
D --> E[Sidebar preview]
D --> F[Encoded copy payload]
F --> G[Clipboard handler]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -10, Tests +136, Docs +6. Total +132 across 8 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep literal preview formatting and whitespace-safe copying on the existing shared paths while preserving sanitization and Markdown line-ending normalization. Do we have a high-confidence way to reproduce the issue? Yes, from source: embedded triple-backtick fences terminate current-main raw previews early, and ordinary copy payloads lack the whitespace-preserving encoding already used for block art. No runtime reproduction was executed here. Is this the best way to solve the issue? Yes. Reusing the existing variable-length formatter and encoded copy transport repairs the producers without adding a competing renderer, changing the decoder, or weakening sanitization. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 489647702cd2. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
* origin/main: (25 commits) docs(releases): keep the release-notes nav group to version routes (#140353) fix(ui): hide trust wrappers in imported chat history fix(subagents): subagent list building decodes unrelated saved prompts in large session stores (#139540) test(process): share relay startup fixtures (#140345) refactor(doctor): inline GitHub skill discovery inputs (#140343) refactor(ui): share channel status type definitions (#140331) refactor: simplify queue state and infrastructure dispatch (#140311) fix: require saved agent turns before update verification succeeds (#140274) fix(update): keep the service profile when switching to Git (#140263) fix(ui): prevent image avatars overlapping mobile chat (#140341) fix(test): accept release subpages in docs route shape (#140337) refactor(plugins): share uninstall mutation ownership (#140322) refactor(agents): use canonical tool execution arguments (#140280) perf(cli): keep inference metadata and domain help lazy (#140327) refactor(plugins): simplify self-hosted setup results (#140332) refactor(config): reuse parent lookup for unset operations (#140326) fix(plugins): preserve exact installed-index mutation receipts (#140328) test(agents): simplify MCP and LSP boundary fixtures (#140312) fix(ui): preserve literal source previews and copied whitespace (#140306) fix: OpenCode Go/Zen requests are missing the required x-opencode-session header (#137464) ...
…claw#140306) Use the shared variable-length fence formatter for raw text and decoded text artifacts. Encode all code-copy payloads with the existing marked JSON transport so attribute sanitation cannot trim indentation or a final newline. Keep decoder, marker values, parser and inline-code behavior unchanged. Validation: original nested-fence and independent whitespace regressions fail before their repairs; 125 selected cases, 20 source checks and 10 docs checks pass. Synthetic browser component captures verify raw-view and artifact actions. Final eight-file P2 review is clean.
|
Follow-up to the marked JSON copy payload introduced here: #141574 merged into main on September 7, 2026. It fixes another sanitization boundary: HTML-comment terminators and closing tags could cause the entire copy payload attribute to be removed even though the code remained visible. The follow-up escapes angle brackets inside the existing JSON encoding and preserves the decoder, whitespace behavior, and source-preview work from this PR. It complements this merged change rather than replacing it. |
What Problem This Solves
Fixes an issue where View Raw Text and decoded text-artifact previews stopped showing literal source at an embedded code fence. Following text could render as Markdown, and Copy code returned only part of the source. Ordinary code copying could also strip leading whitespace and the final newline.
Why This Change Was Made
Both preview producers now use the existing variable-length fence formatter. All code-copy buttons use the existing marked JSON transport, which preserves whitespace through attribute sanitization. The decoder, marker values, sanitizer policy, shared formatter and separate inline-span behavior are preserved.
User Impact
Source previews retain nested Markdown notation, and copies retain the complete code text and intentional whitespace within the existing Markdown line-ending normalization. Production code decreases by 10 lines. The Control UI guide documents the behavior.
Evidence
The original preview regressions failed before the fence repair; separate ordinary whitespace-copy cases confirmed the attribute-transport defect. All 125 distinct selected cases pass, along with 20 source checks and 10 documentation-only checks. The final eight-file managed P2 review is clean.
Before/after browser captures use actual production components, synthetic text/artifact data and real Raw/Copy actions with a mocked clipboard. They verify component behavior, not an installed-app or operating-system clipboard workflow. Both full captures were inspected before upload.