Skip to content

fix(slack): never cut a link, mention or channel token between posts - #37230

Merged
RohanK6 merged 1 commit into
mainfrom
crew/conductor/slack-split-link
Nov 16, 2026
Merged

RohanK6 merged 1 commit into
mainfrom
crew/conductor/slack-split-link

Conversation

@RohanK6

@RohanK6 RohanK6 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A long Slack reply split into several posts never tears a link, mention or channel in two.

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, so the first post ended with a raw, unlinked <https://example.com/docs/de and the next began with sign/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

  • Where split_message breaks a line that has a usable line break.
  • Cutting at a space instead of mid-word: fix(slack): skip a break too early in the chunk when splitting #28614 chose a hard cut at the limit, and test_link_prose_behind_a_short_lead_in_is_cut_hard_not_at_a_space pins it.
  • A single token longer than a whole post, which cannot move whole and is still cut at the limit.

What changed (motivation → approach → change)

Symptom: a Slack link torn across two posts shows as raw text on both. Cause: _fenced_cut hard-cut a line with no usable break at chunk_limit with 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 on 452a50e10c15 by assertion.
  • test/test_slack*.py, test_messaging_split.py and the other split_message callers' 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.
  • Proof: PROVEN test/test_slack_render_pipeline.py::test_a_long_line_is_never_cut_inside_a_slack_link (head 8827f9e)

Manual verification

N/A — unit coverage sufficient: split_message is 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

  • 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

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

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

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 8827f9ea793baebef0a44f097d8227620604f0ee 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 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

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 <…> token lands where it did before.

[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 .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 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 8827f9ea793baebef0a44f097d8227620604f0ee — 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: 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 ships

Inventory (4 items) — 4 justified

Intent: a long Slack reply split across posts keeps every link, mention and channel token whole. FIX.

  1. A line with no usable break now gets cut just before a <url|label>, <@U…> or <#C…> token that fits in one post, not inside it. — justified
  2. A link line too long for one post, right after a reopened code-block opener, is still cut at the limit and sealed, so no post is just a bare opener. — justified
  3. A token longer than a whole post is still cut at the limit, with no stub post before it. — justified
  4. The slack-gateway spec line on final-message splitting now describes the token-safe cut. — justified

[FIRST-PRINCIPLES-REVIEWED] 8827f9e

Description read

[DESCRIPTION-READ] 982c01f5cac3634366c760746e9dba43fac9ac5f6e0ebe8df58a201b2bd6f22d

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 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 8827f9ea793baebef0a44f097d8227620604f0ee — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 8827f9e

Verdict parsed from the review's SHA-scoped output markers for commit 8827f9ea793baebef0a44f097d8227620604f0ee.

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

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 8827f9ea793baebef0a44f097d8227620604f0ee and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8827f9e

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

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 14, 2026
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.
@RohanK6
RohanK6 force-pushed the crew/conductor/slack-split-link branch from 452a50e to 8827f9e Compare November 14, 2026 17:21
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 14, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: 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 8827f9ea79 · 74 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 14, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 16, 2026
@RohanK6
RohanK6 enabled auto-merge (squash) November 16, 2026 05:03

@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 (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.

@RohanK6
RohanK6 merged commit 1b45338 into main Nov 16, 2026
154 of 156 checks passed
@RohanK6
RohanK6 deleted the crew/conductor/slack-split-link branch November 16, 2026 05:05
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 16, 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.

Slack posts tear a link, mention or channel in two when a long line is split

2 participants