fix(ui): strip ATX heading markers from quote chip display - #2214
Conversation
A quoted excerpt can carry markdown source verbatim (selection capture keeps
the raw text), so a heading line like `### Description` rendered in the chip
as cramped literal hashes. Strip a leading `#{1,6} ` marker at display time
only; the model still receives the excerpt verbatim via
formatTextWithInlineRefs. Mid-text `#` runs are treated as content and left
alone.
|
Clean minimal fix — the regex is correct against CommonMark (
P1 is a few lines (and pre-send, users see the very symptom #2213 describes); everything else can be follow-ups. Nice work otherwise! 🚢 |
) Maintainer review (P1): the pending-quotes Token in the composer drawer falls back to raw quote.text when no label is set, so '### Description' still rendered as cramped hashes one step before the chip. Route the fallback through stripQuoteHeadingMarkers too. Also add the '####### x' and '######x' boundary cases to the pure-function tests (P2) and soften the docstring claim about which markers survive selection normalization (P3).
Keep both sides of the composer.tsx import block: upstream's WorkspacePicker/ComposerDraftPersistence additions and our stripQuoteHeadingMarkers import.
|
Addressed all three review points on
Verification: |
|
Thanks for this — the fix is clean and I verified both display surfaces: the pre-send token in the composer (label-less selection quotes) and the sent chip's Three optional follow-ups, none blocking:
Happy to approve — these can be tracked as follow-ups. |
Fixes #2213
Problem
A quote chip can carry markdown source verbatim (selection capture keeps the
raw text), so a heading line like
### Descriptionrenders in the chip ascramped, overlapping literal hashes — it reads as a blob instead of three
distinct
#.The markdown renderer is not at fault:
###mid-line is not a heading markerper CommonMark (
/^(#{1,6}) +(.*)/anchors at line start), so it correctlyrenders as plain text. The issue is presentation of that literal text in the
chip.
Fix
Add
stripQuoteHeadingMarkers— display-only cleanup that removes a leadingATX heading marker (
#{1,6}) from the quote text shown in the chip:### Description→Description###Description(no space) → unchanged (not a heading)C# code,#hashtag, mid-text#runs → unchanged (treated as content)Presentation only:
formatTextWithInlineRefsstill sendsquote.textverbatim to the model, matching the chip's existing contract.
Tests
packages/ui/src/__tests__/quote-ref-chip.test.ts— 3 tests covering markerstripping (1–6 hashes, multi-space/tab), and non-heading preservation.
Run:
npm --workspace @maka/ui run build(tsc) — passesnode --test dist/__tests__/quote-ref-chip.test.js— 3/3 pass@maka/uisuite: 324/326 pass; the 2 failures(
astryx-form-controls-localization) are pre-existing and unrelated(Astryx TextInput "Optional" marker localization, not touched by this PR).