Repository navigation
fix(chat): preserve Markdown image examples in native chat - #113904
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 25, 2026, 6:51 PM ET / 22:51 UTC. ClawSweeper reviewWhat this changesThe PR replaces regex-based Markdown image preprocessing in native iOS/macOS chat with structural CommonMark image parsing so code examples, escaped syntax, and persisted chat text are not mistaken for images. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 5 items remain Keep this PR open for human maintainer review. The Priority: P2 Review scores
Verification
How this fits togetherNative iOS/macOS chat preprocesses Markdown before the text reaches rendering and persisted history. It extracts embedded data images while converting actual remote-image syntax to safe non-fetching text. flowchart LR
A[Chat Markdown input] --> B[Native Markdown preprocessor]
B --> C[CommonMark image parsing]
C --> D[Data image extraction]
C --> E[Safe remote image text]
D --> F[Chat rendering and history]
E --> F
Decision needed
Why: The protected Before merge
Agent review detailsSecurityNone. PR surfaceOther +184. Total +184 across 2 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the structural CommonMark approach if native review confirms its source-range contract, then add redacted after-fix native runtime evidence showing literal Markdown examples remain text while genuine data and remote images retain their intended handling. Do we have a high-confidence way to reproduce the issue? No high-confidence live reproduction was independently established. The supplied PR description and focused test diff identify a plausible current native preprocessing path, but no executable source inspection or after-fix runtime artifact was available in this review environment. Is this the best way to solve the issue? Unclear. Structural CommonMark parsing is a plausible maintainable replacement for a document-wide image regex, but its exact source-range and newline behavior needs native owner and dependency-contract verification before it can be called the best fix. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against bfc8c89c3573. LabelsLabel changes:
Label 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
|
7034bc2 to
d141b3e
Compare
|
Merged via squash.
|
…etwork-none * origin/main: (74 commits) fix(ui): make Control UI ownership and permissions reliable (#115364) feat(system-agent): host memory import in Ask OpenClaw (#115376) fix(chat): preserve literal Markdown image examples (#113904) refactor(chat): keep web and terminal sessions synchronized (#115377) fix(ui): order model picker by provider strength (#115380) feat(ui): make Memory settings a destination page with live overview and dreams (#115383) docs(security): fix warning line wrap (#115388) fix(memory-core): avoid cubic MMR similarity rescans (#113359) fix(discord): preserve code-leading reasoning chunks (#103166) fix(slack): protect outbound hooks from previews fix(ui): keep explicit navigation ahead of chat canonicalization (#115366) fix(exec): safely cancel pending node approvals (#115373) fix: make Code Mode reliable across gateway and provider lifecycles (#115379) perf(ui): debounce event-driven session list refreshes and right-size child paging (#115374) feat(talk): support GPT-Live realtime voice over ChatGPT OAuth (#115226) feat(system-agent): guide gateway configuration in Ask OpenClaw (#115363) fix(agents): make overflow recovery append-only via branch-and-reappend (#115271) (#115310) fix(macos): bound websocket ping so a dropped pong cannot orphan its continuation (#115362) fix(codex): isolate native hook relay startup (#115078) fix(ci): stop reviving superseded pull request workflows (#115378) ... # Conflicts: # CHANGELOG.md
What Problem This Solves
Native iOS/macOS chat already supports inline data-image rendering and safely flattens remote Markdown images into alt text. The remaining implementation used a document-wide regular expression, so image examples inside fenced code, inline code, indented code, and escaped Markdown were still mistaken for real images. That changed rendered text and the sanitized user-history copy.
Why This Change Was Made
This rewrite keeps the landed image feature and the current provenance-marker metadata sanitizer intact. It replaces only image recognition with the repository-pinned
swift-markdown0.8.0 CommonMark AST, then maps structural image source ranges back to the original UTF-8 text.The mapping follows the dependency contract directly:
SourceLocation.columnis 1-based UTF-8 bytes.nil, so they are still collected and safely flattened.Unsupported/remote image alt text is emitted as escaped literal Markdown. Decoded entities therefore cannot synthesize a second image or link when native chat parses the cleaned text again.
User Impact
Evidence
Exact rewritten head:
d141b3e16281e14af56da734619f537ea3dcf840.swift-markdown0.8.0 revision3c6f9523da3a1ec2fd829673e472d95b8097a3b8and transitiveswift-cmark0.8.0 revision924936d0427cb25a61169739a7660230bffa6ea6.scripts/format-swift.sh macos: 0 files require formatting.git diff --check: passed.gpt-5.6-sol, high): clean, no accepted/actionable findings.macos-swift: Swift lint, release build, OpenClawKit tests, and macOS app tests passed.ChatMarkdownPreprocessorpassed; OpenClawKit finished with 1,239 tests in 95 suites, and the macOS app/shared run finished with 1,522 tests in 166 suites.ios-build, native i18n, macOS Node, Android builds/tests/lint, security, and the aggregateopenclaw/ci-gatepassed.The first CI attempt had one unrelated Android coroutine test timeout after 5 seconds; all other 1,939 Play tests passed. The permitted single retry passed without code changes.
Provenance
The over-broad regex came from #38895 (
4bf902de5851304cae53c57889b5ae90fa7367a8, follow-upd25b493c7f79d13e7dca0278f66aeeb6c05f4d72), authored and merged by @obviyus on 2026-03-07. That PR correctly established remote-image flattening; this change preserves that security behavior while moving recognition to the CommonMark owner boundary.