Repository navigation
Conversation
|
🦞👀 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. What this changesPair inline-code delimiters by equal backtick-run length so plain-text previews preserve embedded backticks. Example: A session message contains Rename to
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current preview defect with a focused regex change, sufficient Gateway proof, and the previously requested regression; no actionable findings remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe shared Markdown normalizer converts message text into plain-text projections consumed by Gateway session previews and sidebar narration. flowchart LR
A[Message text] --> B[Fence and link stripping]
B --> C[Code span protection]
C --> D[Formatting removal]
D --> E[Literal restoration]
E --> F[Session previews and narration]
Technical reviewBest possible solution: Land the focused matcher replacement and retained regression once the existing required checks pass. Do we have a high-confidence way to reproduce the issue? Main's matcher splits double-backtick spans, and the supplied paired Gateway output demonstrates the resulting preview corruption; no target code was executed during this review. Is this the best way to solve the issue? The patch is the smallest complete fix for the embedded-backtick defect: it reuses the existing placeholder owner and extends an existing independent regression without new machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 88a0f3baca8a. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests 0. Total +1 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (12 earlier review cycles; latest 8 shown)
Reviewed November 11, 2026, 12:22 PM ET / 17:22 UTC (Revision 13). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
Proof for head a51322a (main merged in, plus one commit on top of the contributor commits). What changed on top of the contributor commits:
Setup:
Controls, from the same previews:
On this version Run output (4 runs) |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Added the regression the review asked for by extending the existing In a Out of scope here: a Markdown link written inside a double-backtick span ( @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in f19f6c0. Thanks @wangmiao0668000666. |
Precedent: #196547 (same owner,
flattenMarkdownToPlainTextinline-code handling); #187853 (same function, earlier shape).What Problem This Solves
Session previews and sidebar narration still drop code contents when the code itself contains a backtick. A message like
Rename to ``abnow` showed as `Rename to ab now` instead of `Rename to a`b now`, and a common glob pattern like**/*.ts`` came back as**/.ts.This is the multi-backtick twin of #196547 (merged this morning): that PR replaced a lossy
[^\]*capture with NUL placeholders, but it pairs spans by a single backtick, so a span opened with two backticks (`` ````) still truncates at the first inner backtick. CommonMark pairs inline code by backtick runs of equal length, so `` ``abis a single valid span whose content isa`b.Why This Change Was Made
flattenMarkdownToPlainTextnow holds inline code spans with a run-length scanner instead of a single-backtick regex. A span opened by an N-backtick run is closed only by a run of exactly N backticks; the content between them — including inner backticks — is preserved whole through block-marker and emphasis stripping and restored after whitespace collapsing. NULs outside code are still doubled so they cannot look like a placeholder, and the scanner runs after link stripping so backticks inside link destinations stay visible to link parsing. An unmatched opening run is consumed whole (not one backtick at a time), so its tail backticks cannot reopen as a narrower span and steal delimiters from a later valid code span. A single-line backtick run (three or more) is a code span, not a fenced block — only a run that spans a line break is left for fence stripping.Behavior for 1-backtick spans, link destinations holding backticks, fences, and the existing inline-code row is unchanged: all pre-existing
flattenMarkdownToPlainTextcases and theprojectSessionDisplayMessagecases produce identical output, with the addition of embedded-backtick, triple-backtick, single-line-run, and unmatched-run cases.Production LOC is
+57/-10, net +47(shrunken from the first review's+79/-10by the UI-asset-budget repairs below).Classification:
behavior-completing(recovers content that a documented Markdown form previously lost in previews).User Impact
Code names, globs, and Markdown examples that themselves contain a backtick now read back exactly as written in session-list previews, sidebar narration, and title/template excerpts. The stored transcript was never affected; this only changes the flattened plain-text projection.
Evidence
Review-finding repairs (RED base -> GREEN exact head)
Four review findings were repaired and are covered by committed regression cases
(
markdown-plain-text.test.ts, suite now 46 passed on head):Multiline inline code — CommonMark lets a code span span lines, so a
newline cannot mark a fence. The scanner now skips only line-start runs of
three or more backticks; multiline spans of any run length are held whole.
Useinit\nnextnow→Use `init next` now07b79ad91a4):Useinit\nnextnow→Use __init__ next now;Use ``a\nb`` now→Use a b nowIndented fenced blocks — CommonMark lets a fence start with up to three
spaces of indentation, so the line-start check must allow them.
Before\n ```ts\nx\n ```\nAfter→Before ts x After07b79ad91a4):Before\n ```ts\nx\n ```\nAfter→Before AfterCompleted triple fences — the fence fast-path skipped inputs that carried
only triple-backtick runs, and the pairing pass only removed four-plus-backtick
or tilde fences, so a completed triple-backtick block could have an inner
backtick paired by the inline-code scanner (hiding the closing fence in a NUL
placeholder the trailing fence regex then could not remove). Fences now strip
completed triple runs through the existing fence owner before inline-code
protection; single-line triple runs are still inline code.
a5a3ff81):Before\n```text\n\n\nAfter `ok`.` → `Before textAfter ok.87182cfd):Before\n```text\n\n```\nAfterok.` → `Before After ok.`UI asset budget — the run-length scanner ships in the Control UI bundle
via sidebar narration, and the exact-head
control-ui-performancecheckreported the largest JS chunk ~0.4 KiB gzip over base. The nested run-scanning
loop was replaced with a single lookaround regex that finds the next backtick
run of exactly the opener's length, and the unmatched-run and line-start fence
skip were merged into one check. The scanner's minified size drops from 559 B
to ~440 B, and line-start inspection is bounded to the current line (a
lastIndexOf("\n")+ one regex on the leading run, per ClawSweeper'sbounded line-start inspectionrequest) rather than re-slicing the wholeprefix. Behavior is unchanged: all 43 committed cases and 72 adversarial
fence/inline-code inputs produce identical output to the prior head.
Budget overage: the exact-head
control-ui-performancecheck measures+199 B gzip for both chat-boot and new-session boot JS versus base; the
largest-JS budget allows only the inherited base overage plus 64 B build
variance. This is the equal-length-run pairing's necessary cost — CommonMark
pairs inline code by backtick runs of equal length, which a single-backtick
regex cannot express — already reduced from ~0.4 KiB to +199 B. The scanner
was shrunk through 8 implementation variants (equal-length regex pairing,
bounded line-start inspection, single-pass line tracking) with identical
output across all 43 committed cases and 74 adversarial inputs; the remaining
delta is the semantic floor for run-length pairing plus fence/unmatched
handling, and cannot be lowered without dropping the fix's core behavior.
ClawSweeper's review (needs-human, reviewed head
dc6ca75e) recommendsexplicitly approving a narrowly measured budget exception for this delta:
"Approve narrow exceptions: Accept the useful preview fix, quantify the
current-head asset deltas, and explicitly approve only those deltas plus the
seven inherited test-debt lines." This PR requests that owner approval rather
than expanding the enforced cap unilaterally.
Shipped Gateway proof (RED base -> GREEN exact head)
Built Gateway (
node dist/index.js) per side in secretless local Docker, anOpenAI-Responses stand-in (HTTP fixture at
OPENAI_BASE_URL) replying with fixedtext, real Gateway
gateway run --allow-unconfiguredon loopback with a token,an agent turn driven by
chat.send, and the preview read viasessions.list(
includeLastMessage: true).Stand-in reply:
Rename to ``aband match**/*.ts. Keepxy`` whole.0fd8c138f5b, without this fix):chat.historyassistant message (original preserved):Rename to ``aband match**/*.ts. Keepxy`` whole.sessions.listlastMessagePreview:Rename to ab and match **/*.ts. Keep xy whole.— embedded backticks dropped (ab→ab,xy→xy) and a stray backtick remains after**/*.ts.07b79ad91a4, with this fix):chat.historyassistant message (original preserved):Rename to ``aband match**/*.ts. Keepxy`` whole.sessions.listlastMessagePreview:Rename to ab and match /*.ts. Keep xy whole.— embedded backticks preserved (ab,/*.ts,xyall whole).Direct dist-call controls (same built dist as the Gateway run):
Exact-head proof receipt
07b79ad91a40fd8c138f5bflattenMarkdownToPlainTextinpackages/normalization-core/src/markdown-plain-text.ts, andprojectSessionDisplayMessageinsrc/gateway/session-display-projection.ts(producer chain).flattenMarkdown: trueprojection used by session-list previews.{ role, text }projection, and the shippedsessions.listlastMessagePreviewreadback above.flattenMarkdownToPlainText("Rename to ``aband match**/*.ts``.")returnedRename to ab and match **/.ts.` and the shipped preview dropped the embedded backticks.Rename to ab and match **/*.ts.` and the shipped preview preserves them.markdown-plain-text.test.tscases and thesession-display-projection.test.tscases are byte-identical between base and head (zero regression), verified by running both suites on both trees.Verification
node_modules/.bin/vitest run packages/normalization-core/src/markdown-plain-text.test.ts— 46 passed on headnode_modules/.bin/vitest run src/gateway/session-display-projection.test.ts— 16 passed on headnode scripts/check-test-lines-ratchet.mts --base refs/remotes/origin/ci-ratchet-base --no-merge-base— OK (allocation sized to net regression growth)oxlint— 0 errors on changed filesgit diff --check upstream/main...HEAD— cleanScope and risk
+57/-10, net +47config/test-lines-allocations/markdown-multi-backtick-code-span.txt, leaving the shared scalar unchanged.