Repository navigation
refactor(tui): stop sanitizing each streamed markdown chunk twice - #127838
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 22, 2026, 9:17 AM ET / 13:17 UTC. ClawSweeper reviewWhat this changesThe PR stops the streamed-assistant assembler from sanitizing text that the TUI markdown renderer already sanitizes immediately before terminal rendering. Merge readinessKeep open for maintainer landing review: the focused refactor leaves terminal sanitization at the existing markdown boundary, and no actionable patch defect was found. The maintainer label prevents automated cleanup; the current head’s merge-result checks are still incomplete. Priority: P3 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherGateway assistant snapshots flow through the TUI stream assembler into the chat log, then through the markdown renderer before terminal output. The markdown renderer owns source sanitization, URL extraction, and rendered-line isolation. flowchart LR
A[Assistant stream snapshots] --> B[Stream assembler]
B --> C[Chat log updates]
C --> D[Markdown source sanitization]
D --> E[Markdown renderer]
E --> F[Terminal output]
Decision needed
Why: The PR is maintainer-labeled and its remaining gate is a human landing decision over the current merge result, not a mechanical defect. Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +9. Total +9 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep raw assistant stream snapshots until HyperlinkMarkdown’s existing markdown-source sanitizer, then land after the current merge result and exact-head checks are verified. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main sanitizes each streamed assistant snapshot before the markdown renderer sanitizes it again; the new regression encodes that exact boundary change. No test was executed because this is a read-only review. Is this the best way to solve the issue? Yes. HyperlinkMarkdown already sanitizes raw markdown before rendering, while non-stream/history extraction retains explicit sanitization, so moving this stream-only duplicate pass to its existing owner is the narrowest solution. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4f5905373d17. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
e08e508 to
46e4a40
Compare
|
Merged via squash.
|
What Problem This Solves
Streaming assistant snapshots crossed the TUI terminal-safety sanitizer in the stream assembler and then crossed the same sanitizer again at the markdown rendering boundary. A 400-delta cumulative stream therefore scanned 5,535,190 bytes while producing a final 13,890-byte response.
Why This Change Was Made
The stream-only extractors now preserve assistant text until
HyperlinkMarkdown, the terminal rendering boundary that already owns markdown sanitization, URL extraction, and rendered-line isolation. Generic message extraction, history rendering, command output, attachment labels, errors, and non-assistant fallback paths retain their existing explicit sanitization.Production LOC: +17/-17 (net 0). Tests: +9/-0.
User Impact
Streaming output is unchanged. Each cumulative assistant snapshot now crosses markdown source sanitization once instead of twice, reducing duplicate sanitizer work without adding a cache, trusted-text bypass, fallback, or compatibility path.
Evidence
Blacksmith Testbox proof: https://github.com/openclaw/openclaw/actions/runs/32565865725
sanitizeMarkdownSourceThe timing change is incidental; this change removes the duplicate sanitization pass.
Regression proof:
Validation:
node scripts/run-vitest.mjs src/tui/tui-formatters.test.ts src/tui/tui-stream-assembler.test.ts src/tui/components/hyperlink-markdown.test.ts(120 passed)node scripts/run-vitest.mjs run --config test/vitest/vitest.tui-pty.config.ts -t "authenticates a streamed prefix before the complete ordered final frame"(passed)node scripts/check-changed.mjs -- src/tui/tui-formatters.ts src/tui/tui-stream-assembler.test.ts(passed)git diff --check origin/main...HEAD(passed)The full PTY suite encountered an unrelated timeout in
reconciles active and terminal runs after reconnect history; the focused streaming PTY proof passed before and after the final rebase. Autoreview was attempted three times, including against the final branch, but its Codex subprocess exited before returning structured findings each time.