Repository navigation
fix(slack): skip a break too early in the chunk when splitting - #28614
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The new helper is a second copy of iMessage's break-floor algorithm. That is a note, because the iMessage function is private and also handles paragraph breaks and graphemes. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: a long Slack reply that opens with a short line goes out with no extra near-empty message. This is a FIX (#28607; the new tests fail on base).
[FIRST-PRINCIPLES-REVIEWED] 6ba1047 Description read[DESCRIPTION-READ] 06d51db4e7280409547df93e14f0c32357c214c355cdbbb6908db879db9670ae That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this changes only where the two Slack splitters cut, every character still arrives, and the change is easy to revert. Notes
[DESIGN-REVIEWED] 6ba1047 Description read[DESCRIPTION-READ] 1c8e0e021cd4f2c4091858c4855c5ca5726322c8345b01b13ecae85183359c38 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 |
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: |
8fbd8b2 to
6ba1047
Compare
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (7 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: the Slack splitters skip a line break too early in the chunk, through one shared break-point helper, with 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/messaging.md, docs/system-specs/modules/slack-gateway.md.
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.
…37230) 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.
Problem / Motivation
Goal: A long Slack reply that opens with a short line goes out in as few messages as it needs, not one extra tiny one.
Both Slack splitters cut at the last line break in reach, even one two characters in.
"Hi\n"plus a 5,000-character answer posts three messages (Hi, then 3,900, then 1,116) instead of two. The streamed reply does the same with its appends.Why it matters
Every Slack user who gets a long answer that starts with a greeting or a heading sees a near-empty message before the real one. That is noise in the thread and one more API call per reply.
Not a goal
split_messageat a space. It still breaks only at line breaks, then hard-cuts, as today._truncated, theSLACK_MAX_TEXTtrim informat.py) and the internal_lossless_blockspre-split. Each yields one message, so an early cut there adds no post.What changed (motivation → approach → change)
A cut point too near the start strands most of the budget. The shared
messaging.splitsplitter only counts a line break at least a quarter into the chunk; the Slack splitters had no floor. #28277 gave iMessage the same floor.split_message(separate posts)_append_pieces(stream appends)Both use one new helper,
slack/break_point.last_break. The "next line fits" rule keeps a long URL behind a short lead-in whole, as today. The Slack specs (messaging.md,slack-gateway.md) describe the floor.Backwards compatibility
Compatible: only where a long reply is cut changes; every character still arrives, and short replies are untouched.
Removes nothing: no key, path, record or public function is taken away.
Tests
TestSplitMessageSkipsAnEarlyBreakintest/test_slack_handler_rendering.pypins: a short first line before one long line or long prose costs no message; a line break a quarter in is still taken; an early break falls through to a later one; a line that fits a post, or the last post, moves whole; link prose behind a short lead-in is hard-cut, never cut at a space.test/test_slack_renderer.pypins the same floor for_append_pieces, and that a break a quarter in and a URL that fits still move as today.Proof: PROVEN test/test_slack_handler_rendering.py::TestSplitMessageSkipsAnEarlyBreak::test_a_short_first_line_before_one_long_line_costs_no_message, test/test_slack_handler_rendering.py::TestSplitMessageSkipsAnEarlyBreak::test_a_short_first_line_before_long_prose_costs_no_message, test/test_slack_handler_rendering.py::TestSplitMessageSkipsAnEarlyBreak::test_link_prose_behind_a_short_lead_in_is_cut_hard_not_at_a_space, test/test_slack_renderer.py::TestStreamMachinery::test_append_pieces_skip_a_break_too_early_in_the_piece (head 6ba1047)
The new tests are pure functions with no clock, I/O or ordering. The related Slack, messaging and iMessage suites (7,654 tests) pass locally. The full
local-gate.pyrun timed out on a busy host, so CI runs the full set.Manual verification
N/A — unit coverage sufficient: both splitters are pure string functions, and the tests call them directly.
Related Issues
Fixes #28607
Sibling sweep
Swept: git grep -nF rfind -- src/kiro_crew
Sibling: src/kiro_crew/slack/format.py:1225 -- changed here
Sibling: src/kiro_crew/slack/reply_pieces.py:77 -- changed here
Sibling: src/kiro_crew/imessage/plaintext.py:230 -- not affected -- already carries the floor from #28277
Sibling: src/kiro_crew/acp/_dispatch_parts/surfaced_text.py:135 -- not affected -- a one-shot diff truncation, not a splitter
Pattern harvest
Rule candidate: review-prompt
Pattern: a splitter that takes the last separator in reach with no floor on how far into the chunk it sits
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement