Repository navigation
fix(slack): never cut a link, mention or channel token between posts - #37230
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the fix is a small, local change to the one cutter that runs after mrkdwn conversion, so it handles the cause directly, and every cut outside a [DESIGN-REVIEWED] 8827f9e Description read[DESCRIPTION-READ] fa0af7b8aa68edf351e9b2b95925339ba3246add9afad1f88a34c77cea853013 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: one hard-cut helper fixes a torn Slack token at the cutter that produces it (issue #37229), and a test fails on base. What this change shipsInventory (4 items) — 4 justifiedIntent: a long Slack reply split across posts keeps every link, mention and channel token whole. FIX.
[FIRST-PRINCIPLES-REVIEWED] 8827f9e Description read[DESCRIPTION-READ] 982c01f5cac3634366c760746e9dba43fac9ac5f6e0ebe8df58a201b2bd6f22d That sha256 names the PR description this verdict read. Recompute it with |
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: |
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: |
split_message cut a line too long for one post exactly at the limit. In converted mrkdwn that cut could land inside a <url|label> link, a <@u123> mention or a <#C123> channel. The first post then ended with a raw, unlinked "<https://example.com/docs/de", and the next began with "sign/section-44|the design doc>" as literal text. A cut that would land inside a token now moves back to the token's "<", so each post holds whole tokens. The cut stays a hard cut at the limit otherwise, as #28614 chose.
452a50e to
8827f9e
Compare
Code change approver recommendation: ApproveWhy: the decider estimates a 10% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. _hard_cut moves a cut that would land inside a Slack <...> token back to the token's '<', but only when the token closes on the same line, fits in one post, and its '<' comes after the last '>', the line start, any already-ruled-out cut and position 0, so every post still makes progress. Every other cut is unchanged. The code-block paths work: a plain hard cut that leaves only a reopened opener retries with that cut ruled out and lands at the limit, and the new fallback inside a reopened block cuts at the limit and closes the block. Callers only ever see a cut moved earlier on the same line: _settled_pieces, the pre-split in _render_blocks, the thinking-message delivery and stream.py. Slack-converted text escapes bare '<' and '>', so stray triggers are rare and harmless. Existing tests that pin exact cut positions use input with no '<'. Three new tests cover the fix, the token-longer-than-a-post case and the reopened-opener case, and each would fail without its part of the change. The spec line is updated. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (3 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: Slack message splitting moves a hard cut back to the start of a link, mention or channel token so the token posts whole; one formatter function plus tests. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/system-specs/modules/slack-gateway.md.
Problem / Motivation
Goal: A long Slack reply split into several posts never tears a link, mention or channel in two.
split_messagecut a line too long for one post exactly at the limit. In converted mrkdwn that cut could land inside a<url|label>link, a<@U123>mention or a<#C123>channel, so the first post ended with a raw, unlinked<https://example.com/docs/deand the next began withsign/section-44|the design doc>as literal text.Why it matters
Long replies full of links (doc lists, search results, PR roundups) are exactly the ones that get split, and they reach Slack through cron delivery, result posts, subagent replies and the dashboard's Slack mirror. A torn link is a dead link on both sides, and the reader sees broken markup instead of the label.
Not a goal
split_messagebreaks a line that has a usable line break.test_link_prose_behind_a_short_lead_in_is_cut_hard_not_at_a_spacepins it.What changed (motivation → approach → change)
Symptom: a Slack link torn across two posts shows as raw text on both. Cause:
_fenced_cuthard-cut a line with no usable break atchunk_limitwith no look at Slack's<...>tokens. Change: the hard cut now goes through a new_hard_cut, which moves a cut that lands inside a token back to that token's<, when the token closes on the same line and fits in one post. It never moves back to or before a cut already ruled out (the reopened fence opener), and when moving back to the<would still leave only that opener, the cut stays at the limit and is sealed like any other. Every other cut lands where it did. The Slack gateway spec line on final-message splitting says so.Backwards compatibility
Compatible: a cut outside a
<...>token, or one with a usable line break, lands exactly where it did; a cut inside a token moves earlier on the same line.Removes nothing: the change only moves a hard cut earlier.
Tests
test/test_slack_render_pipeline.py::test_a_long_line_is_never_cut_inside_a_slack_link: a 7,100-character paragraph of 80 links splits into posts that each hold whole tokens, all within the limit, and no post starts with a torn token's tail. Fails on main by assertion.test_a_token_longer_than_a_post_is_cut_at_the_limit_with_no_stub_post: a token longer than a post is cut at the limit, with no near-empty post before it.test_a_link_line_after_a_reopened_block_never_leaves_a_bare_opener_post(14 widths): a link line too long for one post right after a reopened code-block opener is cut at the limit and sealed, so no post is a bare opener and every post keeps its fences balanced. Three widths fail on452a50e10c15by assertion.test/test_slack*.py,test_messaging_split.pyand the othersplit_messagecallers' tests pass (6,828), including the code-block tests from fix(slack): close a code block cut between two posts and reopen it #36897 and fix(slack): skip a break too early in the chunk when splitting #28614's hard-cut test.Manual verification
N/A — unit coverage sufficient:
split_messageis a pure function and the tests read its posts directly; I did not post to a live Slack workspace.Related Issues
Fixes #37229
Sibling sweep
Swept: git grep -n -E "def (split_message|_lossless_blocks|_split_for_slack)(|_append_pieces" -- src/kiro_crew/slack
Sibling: src/kiro_crew/slack/format.py:_lossless_blocks -- not affected -- its blocks are rejoined into one text before conversion, so no post boundary falls in a token
Sibling: src/kiro_crew/slack/renderer.py:_split_for_slack -- not changed here -- it cuts the agent's unconverted text through the shared split_markdown_safe, not this cutter
Sibling: src/kiro_crew/slack/reply_pieces.py -- not affected -- it appends to one streamed message, so a cut never becomes a post boundary
Pattern harvest
Not generalizable: Slack's angle-bracket token syntax is the one this cutter alone sees after conversion.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.