Repository navigation
fix(imessage): skip a break too early in the chunk when splitting - #28277
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this is a small fix to a pure function, it targets the real cause (tiers had no floors), and it can be reverted cleanly. Notes
[DESIGN-REVIEWED] 96ae078 Description read[DESCRIPTION-READ] 1f27077f49ca313096669af1ccd9aea6a6aa7afe60f67866c3fb92b11f0070c4 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 |
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: |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the floors fix the cut rule that caused #28275, the URL fallback keeps a cut that main already makes, and the floors match the shared splitter's. What this change shipsInventory (4 items) — 4 justifiedIntent: a long iMessage reply that opens with a short line goes out in the fewest messages that fit. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 96ae078 Description read[DESCRIPTION-READ] 70574ed24edcf7cab2d3ef66730b601e836af971cc455e1bb6029788290130e3 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: |
1fd92d8 to
96ae078
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (2 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: bug fix in iMessage plain-text chunking: a paragraph, line or space break counts only when it reaches its share of the limit, so a short lead-in no longer costs an extra message; covered by new unit tests, including parity with the shared Markdown splitter.
Problem / Motivation
Goal: A long iMessage reply that opens with a short line is sent in as few messages as fit, the way the shared splitter already sends it.
chunk_plaintextcuts at the last paragraph, line or space break in reach, however near the start."Hi\n\n"plus a 6,000-character answer is sent as 3 messages (2, 4000, 2000) when 2 fit.Why it matters
Every iMessage user who gets a long answer that opens with a greeting, a title or a one-word line gets a stray tiny bubble and one more message than needed.
Not a goal
What changed (motivation → approach → change)
Symptom: a short opening line becomes its own message. Cause:
_preferred_cuttakes any break with an index above 0. Fix: each tier gets a floor, taken from the ladder insplit_markdown_safe. A paragraph break must sit at least halfway in, a line break or a space at least a quarter in. A break below its floor falls to the next tier. With no tier left, the last break is still taken when the word after it fits one chunk, so a long URL behindOpen:moves whole. A word longer than any chunk is hard-cut to fill the budget.Backwards compatibility
Compatible: same function and signature; every chunk stays within the limit and no text is lost.
Removes nothing: only where a long reply is cut moves.
Tests
test/test_imessage_plaintext.py, new classTestAnEarlyBreakDoesNotStrandTheBudget:Guards that pass on main and on this change: a long URL behind a short lead-in moves whole; a paragraph a quarter to halfway in splits the same as
split_markdown_safe; a paragraph halfway in, a line or space a quarter in, and a 9,000-character run keep their cuts.Proof: PROVEN test/test_imessage_plaintext.py::TestAnEarlyBreakDoesNotStrandTheBudget::test_a_short_greeting_paragraph_does_not_cost_a_message, test/test_imessage_plaintext.py::TestAnEarlyBreakDoesNotStrandTheBudget::test_a_short_greeting_before_wrapped_prose_does_not_cost_a_message, test/test_imessage_plaintext.py::TestAnEarlyBreakDoesNotStrandTheBudget::test_an_early_line_break_falls_through_to_a_later_space, test/test_imessage_plaintext.py::TestAnEarlyBreakDoesNotStrandTheBudget::test_an_early_space_falls_through_to_a_hard_cut, test/test_imessage_plaintext.py::TestAnEarlyBreakDoesNotStrandTheBudget::test_an_early_paragraph_falls_through_to_a_later_line_break (head 96ae078)
Determinism: pure string functions, no clock, I/O or order.
test_imessage_plaintext.pypassed 5 repeats with-n0, once with-n 4, and once in a shuffled order (seed 4271). Related backend set viascripts/local-gate.py: 5988 passed, 5 skipped.Manual verification
N/A — unit coverage sufficient:
chunk_plaintextis a pure function and the tests drive it with the exact reply shapes.Related Issues
Fixes #28275
Sibling sweep
Swept: git grep -nE "rfind(" -- "src/kiro_crew/*.py" (every break search in a splitter or truncator)
Sibling: src/kiro_crew/messaging/split.py -- not affected -- it holds the floors this change copies
Sibling: src/kiro_crew/slack/format.py:1223 -- tracked in #27600
Sibling: src/kiro_crew/slack/reply_pieces.py:76 -- tracked in #27600
Both Slack splitters have the same early-cut shape: they take the last newline (or space) in reach, however near the start. They are left for a separate follow-up PR, opened once our #27600 (open on
slack/format.py) lands.Sibling: src/kiro_crew/tips_text.py:96 -- not affected -- truncates one tip, never splits into messages
Pattern harvest
Not generalizable: the one channel splitter with its own break ladder lacked the floors of the shared ladder; the shared one has them.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement