Repository navigation
fix(tts): preserve literal directives in Markdown code - #138319
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review The initial completed review has not published yet. Exact-head CI is green for |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Consolidating on the canonical Markdown code-region owner is the right correctness move; the duplicate regex scanner was exactly the kind of parser drift that creates fence and inline-code edge cases. I am less comfortable treating the measured ~48 ms median / ~96 ms max at 65 KiB as incidental, though. Since final-text processing runs multiple directive passes, it would be worth seeing whether the code-region map can be computed once and reused without creating a second parser. I would track that as a bounded performance follow-up rather than weakening this correctness fix.
|
Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 10:42 AM ET / 14:42 UTC. ClawSweeper reviewWhat this changesThe PR replaces final-text TTS directive extraction’s local Markdown code scanner with the shared Markdown-aware helper and adds coverage for complex literal-code examples. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep open. Current main still uses the narrow local scanner, while this focused PR routes final-text TTS extraction through the existing Markdown-aware helper; no blocking correctness or security findings were found. Priority: P2 Review scores
Verification
How this fits togetherAssistant final text is normalized into cleaned transcript text plus TTS delivery facts before gateway delivery and UI history rendering. The shared directive helper uses Markdown code regions so literal examples remain text while directives outside code remain active. flowchart LR
A[Assistant final text] --> B[Delivery directive processing]
B --> C[TTS fact extraction]
C --> D[Markdown code-region helper]
D --> E[Cleaned text and TTS facts]
E --> F[Gateway final event]
E --> G[Transcript and Control UI]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -46, Tests +20. Total -26 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Land the owner-boundary refactor so all final-text TTS passes share the established Markdown code-region contract; keep the separate incremental stream cleaner as follow-up work rather than adding another scanner here. Do we have a high-confidence way to reproduce the issue? Yes—source establishes the gap: current main’s local patterns cannot model unclosed, quoted, longer, false-closing, or multiline CommonMark code regions, while the shared Markdown parser does and the added parser-level cases exercise them. Is this the best way to solve the issue? Yes—the final-text extraction owner is the correct boundary, and reuse of the existing Markdown-aware directive helper removes duplicated parsing policy without changing TTS facts, configuration, or provider routing. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 523221e3767f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…9-prep * commit '407a8f453c0f0306af1ddc0aafa8697c1d49a9e7': (312 commits) perf(ui): coalesce automation event refreshes (#138065) fix: reject incomplete Skill Workshop directory reads (#138082) test(ui): decouple rendering checks from generated wording (#138283) perf: avoid temporary entries in bounded JSON traversal (#138017) fix(irc): render complete messages before splitting (#138328) perf: prepare worker trajectory payloads only for recorded events (#138086) fix(mcp): paginated listings no longer time out after a forward clock step (#137206) fix(codex): page native transcripts and bound UI previews (#136282) feat(gateway): apply more settings without restarting (#138112) fix(docs): preserve mirrored ClawHub maturity links (#138241) fix(test): own UI animation and legacy database setup (#138296) fix(tts): preserve literal directives in Markdown code (#138319) fix: load chat widgets behind authenticated gateways (#138074) chore(ui): cover native approval finalization (#137259) fix(cron): cancel conditions before main-session handoff (#138313) fix(backup): preserve text after embedded NUL characters (#138327) fix(android): align composer control sheets (#137442) fix(ci): wait for replacement PR runs instead of stale failures (#138307) fix(sessions): keep Gateway responsive with long transcripts (#138094) fix(computer): map window inputs to delivered image coordinates (#138271) ... # Conflicts: # scripts/release-check.ts # test/release-check.test.ts
Additional instructions
Maintainers can update this branch through normal repository access.
What Problem This Solves
Fixes an issue where assistant replies containing literal TTS syntax inside Markdown code lost part of the example and recorded unintended speech directives. Unclosed fences, false closing fences, longer enclosing fences and multiline inline code all reproduced the corruption, even with automatic speech disabled.
Why This Change Was Made
The final-text TTS owner had a separate regex-based Markdown scanner. It now uses the existing canonical code-region replacement helper while preserving its five-pass order, capture coercion and first-text/provider precedence. The duplicate range type, four-pattern scanner, membership check and replacement adapter are deleted: production +9/−55, net −46; tests +30/−10, net +20.
The affected owner is also present in stable v2026.9.1. This changes neither configuration nor stored fact shape. The canonical parser follows the existing Markdown code-preservation contract.
User Impact
Literal examples remain intact in the saved assistant transcript and Control UI, and do not become speech instructions. Active directives outside code retain their existing behavior.
Evidence
sessions.create → chat.inject → final event → chat.historybefore and after. All four corruptions are repaired; simple code, active-TTS and ordinary-text controls retain their behavior. Final events match saved history in every case. Two separate escaped-custom-tag hypotheses remain unchanged and unqualified.[[tts:text]]example disappears; after, it remains visible. Each phase needed one ordinary reload after the initial browser-handoff connection failure. Owned tabs, Gateways and listeners were closed. This is Gateway/transcript/UI proof, without external model-service or synthesized-audio claims.4a4b39734084529d59584fe9e7f184db3b1c3d09.Before:
After:
Correctness has a measured parsing cost: five canonical Markdown passes retain the existing directive ordering. Warm ten-call medians for 4/16/65 KiB TTS-containing code were 0.034/0.099/0.374 ms before and 3.382/11.484/48.386 ms after (65 KiB maximum 95.61 ms). Ordinary text without TTS retains its early return. This PR makes no performance improvement claim and adds no cache or alternate parser.
Connected follow-up: the optional incremental TTS stream cleaner has the same code-preservation gap when model overrides/automatic TTS enable it. An actual ACP dispatcher-to-delivery probe preserves that evidence. This final-text repair does not fix incremental stream delivery; that path needs shared stable-span ownership for incomplete Markdown and hidden directive blocks, rather than another regex scanner. It is tracked as part of the same invariant, not a separate bug count.
Release-note context: preserve literal TTS syntax in Markdown code examples in assistant final messages and avoid extracting unintended speech facts.