Skip to content

fix(preview): keep markdown markers inside inline code and ~~~ fences - #27260

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/preview-text-inline-code
Nov 1, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/preview-text-inline-code

Conversation

@RohanK6

@RohanK6 RohanK6 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

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 as init, `**kwargs` as *kwargs, and `~~x~~` as x. A ~~~py fence 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 stripMd already does.

Not a goal

  • Changing how Slack, WhatsApp or voice replies render markdown.
  • Rendering markdown in previews; they stay plain text.

What changed (motivation → approach → change)

Inline code lost its markers because every later pass saw the code as plain text.

preview_text.py now 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 in test/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 on origin/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 **kwargs and *args-pass **kwargs and *args], test/test_preview_text_inline_code.py::test_inline_code_keeps_markdown_markers[use ~~x~~ here-use x here], 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

src/kiro_crew/slack/format.py:982 rewrites ** and ~~ inside inline code on its own path; it is a channel renderer outside this Goal and gets its own issue.

Pattern harvest

Rule candidate: review-prompt
Pattern: a markdown text pass that rewrites emphasis without first setting code spans aside

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@RohanK6
RohanK6 requested review from a team and KiroCrewCaptain as code owners November 1, 2026 18:29
@RohanK6
RohanK6 requested a review from CrysisDeu November 1, 2026 18:29
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 64c1d6b8842af8c84184dd6d0cfe479db596c937 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 64c1d6b8842af8c84184dd6d0cfe479db596c937 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Previews already saved by the history projection keep their old wrongly stripped text until they are rebuilt. The effect is cosmetic and goes away as new turns arrive, so no backfill is needed.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 64c1d6b8842af8c84184dd6d0cfe479db596c937 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 1 — second spelling: _protect_inline_code is a second matcher for "a run of N backticks closes on the next run of exactly N" next to src/kiro_crew/widget_parse.py:142 mask_inline_code. That makes 2 copies (grep: def .*inline_code in src/kiro_crew). This is a note, not a block: the existing helper masks one line at a time and does not hand back span contents. Subtraction: find the spans by comparing mask_inline_code(line) with the original line, and drop the custom run and closer scanner.

What this change ships

Inventory (5 items) — 4 justified

Intent: one-line chat previews (sidebar, archived sessions, roster) show inline code exactly as typed, and treat ~~~ blocks as code. This is a FIX (#27247).

  1. Inline code in previews keeps its __, **, ~~, []() and # as typed — second spelling of widget_parse.mask_inline_code
  2. Multi-backtick spans (``a`b``) render as their code, with padding trimmed — justified
  3. A ~~~ fence becomes (code) / (diff), and only a run at least as long as the opener closes it — justified
  4. A backtick-wrapped [OPTIONS: …] line is still hidden, because it is now dropped before code is set aside — justified
  5. NUL characters in the input are dropped from previews — justified

[FIRST-PRINCIPLES-REVIEWED] 64c1d6b

Description read

[DESCRIPTION-READ] a215d8b5d106866d8073f70b4352547a86ad445a16b33b59744f93e2be6cab70

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 64c1d6b8842af8c84184dd6d0cfe479db596c937 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 64c1d6b

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 64c1d6b8842af8c84184dd6d0cfe479db596c937 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 64c1d6b8842af8c84184dd6d0cfe479db596c937 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 64c1d6b

Verdict parsed from the review's SHA-scoped output markers for commit 64c1d6b8842af8c84184dd6d0cfe479db596c937.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 64c1d6b8842af8c84184dd6d0cfe479db596c937 false-positive: <reason, 20 to 500 characters>

@RohanK6
RohanK6 force-pushed the fix/preview-text-inline-code branch from 4d000e5 to 388a5e0 Compare November 1, 2026 18:47
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 1, 2026
@RohanK6
RohanK6 force-pushed the fix/preview-text-inline-code branch from 388a5e0 to 64c1d6b Compare November 1, 2026 19:29
@RohanK6

RohanK6 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/init.py, src/kiro_crew/autonudge.py, src/kiro_crew/cron_history.py since this head went green (1b06e8e -> 9617133); CI re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Nov 1, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 1, 2026 21:07

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@KiroCrewCaptain
KiroCrewCaptain merged commit 48d719d into main Nov 1, 2026
96 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/preview-text-inline-code branch November 1, 2026 21:23
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sidebar preview strips markdown markers inside inline code and misreads ~~~ fences

2 participants