Repository navigation
fix: render Slack-formatted send_message bodies legibly in the bell - #29906
Conversation
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed at 7b1c03d15a (T1: the bell shows a Slack-bound send_message body as broken Markdown, so links are unclickable; no linked issue, so I tiered it from the description).
The fix only converts the bell's copy, gated on send_to_slack, so every delivery leg still sends the caller's own bytes. mrkdwn_to_markdown is conservative where it has to be: code spans and fences stay verbatim (an unterminated fence too), only a URI angle form becomes a link (mentions and <!here> stay literal), emphasis converts only at Slack's word boundaries so **bold** and snake_case pass through, and label brackets and destinations with spaces or parens are escaped. The tests cover each of these, and both module specs move with the code. One commit, no merge commits.
Approved on this head. It merges once fork CI runs and is green.
AI-assisted, sent by CommunityCrew
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. The bell's copy is converted at the one point where Slack-bound text enters it, every delivery leg still sends the caller's own bytes, and the result is re-scanned for secrets before it is stored. Notes
[DESIGN-REVIEWED] ed27d2d Description read[DESCRIPTION-READ] 37d1992c21f742a166aa02d81797b89bdf7aabcd04303a93806f228dc8c51aca 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, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The fix converts only the bell's copy, at the one point where Slack-bound text enters it. It adds a regression test that fails on base, and no converter in the opposite direction exists in-tree. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: make a Slack-formatted
[FIRST-PRINCIPLES-REVIEWED] ed27d2d Description read[DESCRIPTION-READ] 4abee28d51ec99fd62a7e2764d57ab41887f176ce70f29c8c7b76e79f2d5f1a9 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
7b1c03d to
1000c5a
Compare
|
Pushed GPT 6.1 blocking finding (emphasis conversion corrupts Markdown link destinations) — fixed. The finding names a class: the emphasis pass reaching inside URL-shaped spans. All sites of the class are now atoms in Design Review / Opus note ( One note for maintainers: the branch sits on its previous base rather than current main — the latest upstream commits touch |
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed at 1000c5a3db. The new push makes every URL-shaped span an atom for the emphasis pass: Slack angle links still convert, while existing Markdown links and images (via md_link_destination, so balanced parens stay one atom) and bare URLs pass through verbatim. So a _ or * inside a destination is never read as emphasis. The new tests cover each of these, and the spec and comment now say plainly that a Markdown body on a no-Slack install only changes single-delimiter weight. Still one commit.
Approved on this head. It merges once fork CI runs and is green.
AI-assisted, sent by CommunityCrew
bolichen97
left a comment
There was a problem hiding this comment.
Thanks @brandonjsmith. I'm changing my approval on 1000c5a3db to a change request. The fork GPT 6.1 review found one real problem, and its adjudication upheld it.
Blocker: a bare non-web Slack link stops being clickable. _markdown_link turns <url> (no label) into a bare url. That is fine for https://, but the bell's Markdown renderer only autolinks bare http/www (MarkdownRenderer.tsx, the GFM plugin). So <vscode://file/project/app.py:42>, which reached the bell as a clickable autolink before this PR, now arrives as plain text. Fix: when there is no label, emit an explicit link, [url](url), using the same (<url>) form your labelled branch already uses when the destination holds a space or parens. Please add one test for a vscode: (or mailto:) bare link.
The other finding (bold around a Slack link reads as italic) was downgraded as low-impact, so it doesn't block. Fix it only if it's easy.
Everything else in my earlier reviews still stands. I'll re-review once you push.
AI-assisted, sent by CommunityCrew
1000c5a to
d3515df
Compare
|
Pushed Upheld finding (bare Finding not upheld (emphasis pairing across a link: |
d3515df to
9fad516
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed at 9fad5167a0. This fixes my change request: a label-less <url> now becomes a self-labelled link, [url](url), so a vscode:// or slack:// link stays clickable in the bell. Destinations with a space or parens still take the (<url>) form. The new vscode: test covers it, and the old bare-URL test now checks the self-labelled form. Still one commit.
Approved on this head. It merges once fork CI runs and is green.
AI-assisted, sent by CommunityCrew
bolichen97
left a comment
There was a problem hiding this comment.
Requesting changes on c006f70. GPT 6.1's adjudication stage failed to run on this head (a GitHub rate limit, fix in #33613), so I checked its three blocking findings by calling mrkdwn_to_markdown at this head. All three reproduce:
src/kiro_crew/slack/mrkdwn_markdown.py:103: emphasis is converted per segment between protected atoms, so bold that encloses a link never converts.*Review <https://example.com/reviews/123|REVIEW-123> now*becomes*Review [REVIEW-123](https://example.com/reviews/123) now*, which the bell shows as italic, not bold.src/kiro_crew/slack/mrkdwn_markdown.py:125: inline-code splitting runs before link matching, so a link label containing backticks is left as raw angle-form text.<https://example.com/file|View `main.py` file>comes back unchanged.src/kiro_crew/slack/mrkdwn_markdown.py:57:_INLINE_CODEmatches single backticks only, so text inside a double-backtick span is rewritten.``echo `pwd` && curl <https://example.com/api>``gets its link converted inside the code span.proactive_send.py:943runs this path wheneversend_to_slackis true.
Each needs a small test with the trigger above.
The other reds on this head are not from your change: Backend Tests (3.12, 7) is a facade-guard timeout seen on three other branches today, and Real Adapter now passes.
AI-assisted, sent by CommunityCrew
c006f70 to
04102a0
Compare
|
Pushed The converter now runs ONE left-to-right token scan per fence-free region, where inline code spans (any backtick-run length) and URL-shaped spans compete by start position, earliest wins. That single rule settles both nestings the way Slack reads them, and emphasis then converts over the whole region with tokens reduced to inert sentinels:
Each trigger from your review is a test verbatim, plus bold-spanning-inline-code; specs updated in the same commit. 33 converter tests green, mypy/flake8/black/flake-ratchet clean. |
bolichen97
left a comment
There was a problem hiding this comment.
Thanks for 04102a0. I re-ran the three triggers from my last review against mrkdwn_to_markdown at this head, and all three are fixed:
- bold around a link now gives
**Review [REVIEW-123](https://example.com/reviews/123) now** - a link label with backticks now converts to
[View \main.py` file](https://example.com/file)` - the double-backtick span is left unchanged
One blocker is left. It is GPT 6.1's upheld finding, and it reproduces:
src/kiro_crew/slack/mrkdwn_markdown.py:152 escapes the bang whenever out.endswith("!"), even when that bang is already escaped. The input \!<https://example.com/review/123|Review> becomes \\. Markdown reads \\ as a literal backslash and then ![...] as an image, so the bell shows an image chip instead of the link.
Fix: count the backslashes directly before the !, and add the escape only when that count is even. Please add a test with this input. Then I can approve once CI is green.
AI-assisted, sent by CommunityCrew
04102a0 to
d8913b9
Compare
|
Pushed Already-escaped bang before a converted link — fixed with backslash parity. The bang-escape now counts the trailing backslash run first: an odd run means the |
bolichen97
left a comment
There was a problem hiding this comment.
Approving d8913b9. The bang escape now checks backslash parity:
\!<https://example.com/review/123|Review>gives\\\!<https://x.y|L>still gets the escape- the three cases from my earlier review stay fixed
test/test_mrkdwn_to_markdown.py passes locally: 35 passed.
The fork CI runs on this head are approved and running. I'll merge once CI and the AI review lanes are green on this head.
AI-assisted, sent by CommunityCrew
bolichen97
left a comment
There was a problem hiding this comment.
Changing my approval to request changes on d8913b9. GPT 6.1 found a security-class issue on this head, and I reproduced it:
redact_for_display("key AKIA\x00*IOSFODNN7EXAMPLE* end", _redact_all)returns the text unchanged, because the U+0000 splits the key.mrkdwn_to_markdownthen strips the U+0000 and returnskey AKIA*IOSFODNN7EXAMPLE* end.proactive_send.py:943passes that tostate.notifywith no further redaction. In the bell, the Markdown renderer drops the asterisks and shows the whole key.
The fix works too: redact_for_display(mrkdwn_to_markdown(...), _redact_all) returns key [REDACTED: credential] end.
Fix: run bell_text, _ = redact_for_display(bell_text, _redact_all) after the conversion and before state.notify. Add one test with the split-key input above, asserting the bell body holds [REDACTED: credential].
Everything else on this head is still fine. I'll approve again once this lands.
AI-assisted, sent by CommunityCrew
One send_message call reaches two renderers with two grammars: Slack renders mrkdwn, while the notification center renders Markdown. A Slack-style link (<url|label>) therefore rendered as raw unclickable text in the bell, and the emphasis sigils mapped to the wrong weights (*bold* read as italic), so any agent formatting for Slack — the documented channel format — got a degraded bell feed, with no workaround that avoids double-notifying. Convert the BELL's copy only, in _deliver_send_message_fallback, gated on send_to_slack: that predicate is true precisely when the caller formatted for Slack (the cron owner-DM default included), and false when a channel_target/channel_type send carries another channel's format. Every delivery leg still sends the caller's own bytes. The converter (slack/mrkdwn_markdown.py) is deliberately conservative: emphasis converts only at Slack's own word-edge boundaries so an already-Markdown body and snake_case identifiers pass through, only <scheme:...> angle forms convert so mentions and <!here> stay literal, and code spans are kept verbatim.
d8913b9 to
ed27d2d
Compare
|
Pushed Converted bell copy is re-scanned before storage. Conversion is a rendering step after the route's display scan: the sentinel strip and emphasis collapse can reassemble a secret a scan saw as split. Note also: this head already contains the escaped-bang parity fix from the previous round (your review of |
bolichen97
left a comment
There was a problem hiding this comment.
Approving ed27d2d. The bell copy is now re-scanned with redact_for_display(bell_text, _redact_all) after the conversion, and only on the Slack-bound path. test_a_slack_bound_send_rescans_the_converted_copy_for_secrets covers the split key. test/test_mrkdwn_to_markdown.py passes locally (36 passed). All six fork AI lanes pass on this head: GPT 6.1, Opus 5.5, Design, First Principles, Security Scope and UX.
I'll merge once the backend shards finish green.
AI-assisted, sent by CommunityCrew
…29906) One send_message call reaches two renderers with two grammars: Slack renders mrkdwn, while the notification center renders Markdown. A Slack-style link (<url|label>) therefore rendered as raw unclickable text in the bell, and the emphasis sigils mapped to the wrong weights (*bold* read as italic), so any agent formatting for Slack — the documented channel format — got a degraded bell feed, with no workaround that avoids double-notifying. Convert the BELL's copy only, in _deliver_send_message_fallback, gated on send_to_slack: that predicate is true precisely when the caller formatted for Slack (the cron owner-DM default included), and false when a channel_target/channel_type send carries another channel's format. Every delivery leg still sends the caller's own bytes. The converter (slack/mrkdwn_markdown.py) is deliberately conservative: emphasis converts only at Slack's own word-edge boundaries so an already-Markdown body and snake_case identifiers pass through, only <scheme:...> angle forms convert so mentions and <!here> stay literal, and code spans are kept verbatim. (cherry picked from commit 398d49b)
Problem / Motivation
Goal: A
send_messagecall formatted for Slack renders legibly on both of its surfaces — Slack-formatted in the channel, clickable and correctly emphasized in the dashboard notification center.When an agent delivers a message to Slack via
send_message, the gateway also creates a notification-center (bell) entry for the owner. The bell stores the Slack-mrkdwn text verbatim, but the notification center renders bodies as Markdown (NotificationDetailPanelrenders throughMarkdownRenderer; the companionsend_notificationdocuments its body as markdown). The grammars disagree on links, so every Slack-style link renders broken in the bell:Review ready: <https://example.com/reviews/123|REVIEW-123>renders a correct link in Slack and raw unclickable text —https://example.com/reviews/123|REVIEW-123— in the bell. Messages with several links per line become unreadable. Emphasis rides along:*bold*renders italic,~strike~/_italic_differ.Why it matters
Any agent that formats for Slack — the channel's own format — gets a degraded bell feed, and there is no workaround that avoids double-notifying: a separate
send_notificationcall would create a second bell entry alongside the mirrored one. Scheduled crons reporting links (reviews, tickets, dashboards) are the common case: their owner-DM sends always mirror to the bell.Not a goal
<scheme:...>angle forms, code spans verbatim); constructs outside that stay literal rather than risk corrupting a body.What changed (motivation → approach → change)
Symptom: Slack links and emphasis arrive broken in the bell. Root cause: one
send_messagecall reaches two renderers with two grammars —_deliver_send_message_fallbackmirrors the Slack-boundtextinto the bell verbatim, and the bell renders Markdown.Approach: convert the BELL's copy only, at the one place Slack-bound caller text enters the bell, gated on
send_to_slack— that predicate is true precisely when the caller formatted for Slack (the cron owner-DM default included) and false when achannel_target/channel_typesend carries another channel's format, which must reach the bell verbatim.Change:
src/kiro_crew/slack/mrkdwn_markdown.py(slack/format.pyis over the file-line cap):mrkdwn_to_markdownconverts<url|label>→[label](url), bare<url>→[url](url)(self-labelled, so a non-web scheme likevscode://that Markdown would not autolink stays clickable),*bold*→**bold**,_italic_→*italic*,~strike~→~~strike~~. Emphasis converts only at Slack's own word-edge boundaries, so snake_case and already-Markdown bodies pass through; mentions (<@U…>,<#C…|…>,<!here>) stay literal; inline and fenced code spans are kept verbatim; HTML entities pass through (a Markdown renderer decodes them, which is their mrkdwn reading). Every URL-shaped span is an atom the emphasis pass never reaches: existing Markdown links/images and bare URLs pass through verbatim, so a_or*inside any destination is path, never markup._deliver_send_message_fallbackpasses the converted copy tostate.notifywhensend_to_slack; the import is function-local because the facade rebinds owner functions ontohandlers.messaging's globals (same pattern asredactthere).messaging.md's delivery-ladder section, and a module row inslack-gateway.md.Backwards compatibility
Compatible: no API, schema, or delivery-leg behavior changes — only the bell's stored body text for Slack-bound sends, which was previously illegible.
delivered_to, outcome codes, and every egress leg are untouched.Removes nothing: the change adds a conversion on one stored copy; every existing reader of notification bodies keeps working (the body remains a plain string).
Tests
test/test_mrkdwn_to_markdown.py(19 tests):<url>drops brackets, parenthesized destinations get Markdown<...>bracketing,[/]in labels escaped, mentions/broadcasts stay literal, emphasis characters inside a destination are not emphasis.**bold**, existing Markdown links, and HTML entities all pass through.vscode://editor link both come out as self-labelled clickable links._/~/*round-trips unharmed (including a balanced-parens destination), a bare URL with delimiters is not emphasis, and Slack + Markdown links coexist on one line.send_to_slacksend reaches the bell as Markdown; achannel_typesend reaches the bell verbatim.Proof: not provable -- other: prove.py reports INCONCLUSIVE because reverting the production hunks removes the new module the test file imports, erroring at collection. Proven manually instead: with only
proactive_send.pyreverted to origin/main,test_a_slack_bound_send_reaches_the_bell_as_markdownfails with the raw-mrkdwn body (AssertionError: assert 'Ready: <http...-1> is *done*' == 'Ready: [R-1]...'); all 18 other tests pass.Manual verification
N/A — unit coverage sufficient: the conversion and its
send_to_slackgating are asserted at the same facade seam the route drives, and the frontend rendering path (MarkdownRenderer) is unchanged.Related Issues
None filed; symptom observed on 0.9.x–0.11.2.x installs.
Sibling sweep
Swept:
git grep -n "state\.notify(\|\.notify(" -- src/kiro_crewSibling:
src/kiro_crew/dashboard/messaging_api/agent_push.py-- app/agentsend_notificationpush -- not affected -- its body is documented and produced as markdown, never Slack mrkdwnSibling: remaining
state.notify(sites (update_notify, chat_api, chat_turn, chat_voice, apps) -- not affected -- each composes its own plain/Markdown body; none ingests a caller's Slack-formattedsend_messagetext, which enters the bell only through_deliver_send_message_fallbackPattern harvest
Rule candidate: review-prompt
Pattern: a body authored in one markup grammar stored onto a surface that renders another (mrkdwn vs Markdown) without a conversion or a format hint at the ingestion seam
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.