Skip to content

fix(slack): keep the text when a truncation's only line break is early - #28677

Merged
RohanK6 merged 1 commit into
mainfrom
crew/conductor/early-trim-cut
Nov 3, 2026
Merged

RohanK6 merged 1 commit into
mainfrom
crew/conductor/early-trim-cut

Conversation

@RohanK6

@RohanK6 RohanK6 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A Slack reply cut to fit one message keeps as much of the text as fits, not just its first line.

Two Slack truncation cuts keep text up to the last line break in reach, even one two characters in. "Hi\n" plus a long body posts Hi and the truncation notice, and the rest of the reply is lost.

Why it matters

A Slack user whose long answer starts with a greeting or a heading sees almost nothing of it. The notice says the reply was cut, but the space that fits was thrown away.

Not a goal

  • Changing split_message or the stream appends. Those split into several pieces and are fix(slack): skip a break too early in the chunk when splitting #28614.
  • Changing the edit-diff truncation in acp/_dispatch_parts/surfaced_text.py. It keeps whole diff rows by design (its docstring), so a half-row never renders.
  • Changing the truncation notice or the limits.

What changed (motivation → approach → change)

A cut too near the start keeps almost nothing. The shared messaging.split splitter only counts a line break at least a quarter into the budget; these two cuts had no floor.

Cut Line break counts when Otherwise
to_slack_mrkdwn over SLACK_MAX_TEXT at least 1/4 into SLACK_MAX_TEXT cut at SLACK_MAX_TEXT
_truncated (one-message overflow) at least 1/4 into limit cut at limit

Both still add their truncation notice. A long reply with no line break at all was already cut where the limit falls; a line break near the start now takes that same path.

Backwards compatibility

Compatible: only replies over the limit change, and they keep more of their text; the notice and limits are the same.

Removes nothing: no key, path, record or public function is taken away.

Tests

test/test_slack_handler_rendering.py pins, for both cuts: a short first line before a long body keeps the text up to the limit; a line break a quarter in is still the cut.

Proof: PROVEN test/test_slack_handler_rendering.py::TestToSlackMrkdwnTruncation::test_an_early_line_break_does_not_cut_away_the_text, test/test_slack_handler_rendering.py::TestTruncatedOverflowCut::test_an_early_line_break_does_not_cut_away_the_text (head df98f7b)

The new tests are pure functions with no clock, I/O or ordering. The related Slack and ACP suites pass locally (13,709 tests). The full local-gate.py run times out on this busy host, so CI runs the full set.

Manual verification

N/A — unit coverage sufficient: both cuts are pure string functions, and the tests call them directly.

Related Issues

Fixes #28674

Sibling sweep

Swept: git grep -nF rfind -- src/kiro_crew
Sibling: src/kiro_crew/slack/format.py:936 -- changed here
Sibling: src/kiro_crew/slack/reply_pieces.py:76 -- tracked in #28614
Sibling: src/kiro_crew/acp/_dispatch_parts/surfaced_text.py:135 -- not affected -- keeps whole diff rows by design, so a half-row never renders
Sibling: src/kiro_crew/imessage/plaintext.py:230 -- not affected -- already carries the floor from #28277

Pattern harvest

Rule candidate: review-prompt
Pattern: a cut that takes the last line break in reach with no floor on how far into the budget it sits

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

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

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision df98f7bcd8f3967d5e7fc4488f9b42f9984f8109 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 2, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of df98f7bcd8f3967d5e7fc4488f9b42f9984f8109 — 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: a two-line floor fixes the two cuts that dropped the text (#28674), and the new tests pin the fix.

What this change ships

Inventory (3 items) — 3 justified

Intent: when a long Slack reply is cut to fit one message, the user still sees as much text as fits, not only the first line. This is a FIX.

  1. A reply over SLACK_MAX_TEXT whose only line break is early is now cut at the cap, not right after that line — justified
  2. A reply that overflows one message (_truncated) with an early line break is now cut at the limit — justified
  3. A line break at least a quarter into the budget is still where both cuts happen — justified

[FIRST-PRINCIPLES-REVIEWED] df98f7b

Description read

[DESCRIPTION-READ] 567c917c0cecc7dad447836a877ddec8f63f19a5769a4b7cd4e49d20937ec7b2

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 2, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: both cuts now use the same quarter-budget floor the shared splitter already uses, and the fallback to cutting at the limit was already the path for text with no line break.

Notes

  • A cut in the middle of a line can now split an open code fence, a <url|label> link or a redaction tag. Text with no line break could already be cut that way. A test with a short first line followed by a long fenced block would show whether the rendered output still holds up.

[DESIGN-REVIEWED] df98f7b

Description read

[DESCRIPTION-READ] 3bc5d1e6f60e8a0cb84c89383b4baaa30beed0f60af263d171acdbd8a6cec647

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 2, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] df98f7b

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

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

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] df98f7b

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

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 3, 2026
@RohanK6
RohanK6 enabled auto-merge (squash) November 3, 2026 05:13

@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 (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: Slack truncation no longer cuts at a line break near the start of the text, with tests.

@RohanK6
RohanK6 merged commit 41bade9 into main Nov 3, 2026
138 of 150 checks passed
@RohanK6
RohanK6 deleted the crew/conductor/early-trim-cut branch November 3, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slack truncation keeps only the first line when the only line break in reach is near the start

2 participants