Repository navigation
fix(preview): keep markdown markers inside inline code and ~~~ fences - #27260
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns: this fixes a real preview bug with a proportionate change inside the module that owns it, and nothing is taken away. Notes
[DESIGN-REVIEWED] 64c1d6b Description read[DESCRIPTION-READ] d117638ceb3c32c4971fd78f35b75764c8fb28bfb0b4aed57908d63387f6488b That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Every item serves the frozen Goal and fixes the cause: the emphasis and link passes no longer see inline code as plain text. Notes
What this change shipsInventory (5 items) — 4 justifiedIntent: one-line chat previews (sidebar, archived sessions, roster) show inline code exactly as typed, and treat
[FIRST-PRINCIPLES-REVIEWED] 64c1d6b Description read[DESCRIPTION-READ] a215d8b5d106866d8073f70b4352547a86ad445a16b33b59744f93e2be6cab70 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
4d000e5 to
388a5e0
Compare
388a5e0 to
64c1d6b
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: bug fix: the preview stripper keeps markdown markers inside inline code spans and treats ~~~ fences as fences, with a new test file.
Problem / Motivation
Goal: One-line chat previews show inline code exactly as typed, and treat a
~~~fence as code.The sidebar, archived-session and roster previews come from
strip_markdown_preview. It ran the emphasis, strike and link passes over inline code too. So`__init__`showed asinit,`**kwargs`as*kwargs, and`~~x~~`asx. A~~~pyfence showed as~py x=1 ~.Why it matters
Previews of coding chats are full of identifiers. Dropping their underscores and stars shows the wrong name. The module docstring promises inline code keeps its literal text, and the dashboard's own
stripMdalready does.Not a goal
What changed (motivation → approach → change)
Inline code lost its markers because every later pass saw the code as plain text.
preview_text.pynow sets each inline code span aside as a token before the link, header and emphasis passes, then puts it back. A span opens on a run of backticks and closes on the next run of the same length on the same line, so``a`b``works too. The scan is one pass, so cost stays linear.A line that starts with
~~~(or more tildes) now opens a fence, closed by a run at least as long. It becomes(code)or(diff), like a backtick fence.The
[OPTIONS: ...]line is dropped before code is set aside, so a backtick-wrapped one still never shows. NUL characters are dropped up front; they render as nothing and cannot fake a token.Backwards compatibility
Compatible: previews only gain characters that were wrongly removed; every caller still gets a plain-text string.
Removes nothing: no key, path, record or function is taken away.
Tests
test/test_preview_text_inline_code.py(new file, so it does not touch the lines #12829 edits intest/test_preview_text.py) covers markers inside inline code, link labels holding code, multi-backtick spans,~~~fences of every length, the[OPTIONS:]line, and strike outside code. 17 of its 21 cases fail onorigin/main.Proof: PROVEN test/test_preview_text_inline_code.py::test_inline_code_keeps_markdown_markers[call
__init__now-call init now], test/test_preview_text_inline_code.py::test_inline_code_keeps_markdown_markers[pass**kwargsand*args-pass **kwargs and *args], test/test_preview_text_inline_code.py::test_inline_code_keeps_markdown_markers[use~~x~~here-usexhere], test/test_preview_text_inline_code.py::test_inline_code_keeps_markdown_markers[see[a](b)there-see a there], test/test_preview_text_inline_code.py::test_link_label_with_inline_code_keeps_code (head 388a5e0)Determinism: the file passed 5 repeat runs, and a seeded shuffle of it with
test/test_preview_text.py(60 passed). Related backend set: 1461 passed. isort, flake8, mypy and the flake-pattern ratchet pass.Manual verification
N/A — the function is pure text in, text out; the unit cases are the full behavior.
Related Issues
Fixes #27247
Sibling sweep
Swept: git grep -nE "_STRIKE_RE|_BOLD_RE|def strip_markdown" -- src/
Sibling: src/kiro_crew/preview_text.py -- changed here
Sibling: src/kiro_crew/whatsapp/renderer.py:154 -- not affected -- its _sub_outside_code skips inline code spans
Sibling: src/kiro_crew/voice_reply.py:334 -- not affected -- speech output drops markdown markers on purpose
Pattern harvest
Rule candidate: review-prompt
Pattern: a markdown text pass that rewrites emphasis without first setting code spans aside
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)