Repository navigation
fix(slack): keep pasted table blocks in the message text - #18786
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check against a real Slack table paste whether the top-level [DESIGN-REVIEWED] 1b61f05 Description read[DESCRIPTION-READ] 942ed5ab66748996242ae4c5b7084c9297fc7746c340cc9f9cd84d8f46729ec0 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) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS Collecting tables from attachments rests on an unverified shape: a pasted table arrives in Not justified as shipped
What this change shipsInventory (4 items) — 3 justifiedIntent: let the agent see the rows of a spreadsheet table pasted into Slack. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 1b61f05 Description read[DESCRIPTION-READ] b9d6b33ee100809522e6c41edf22bc3c45317b54716030c7d9d4f5a71f2b8231 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: |
|
|
5f7dd6c to
314f594
Compare
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: |
|
314f594 to
1b61f05
Compare
|
|
Self-review (crew-pr-reviewer, read-only): RECOMMEND APPROVE Recommend approve. This fixes pasted Excel/Sheets tables getting dropped in Slack, and it fixes the root cause: |
buluoray
left a comment
There was a problem hiding this comment.
Verdict: approve. Reviewed at head 1b61f05353ccb513b5594cffb1a264585e54c345. Nothing blocking. Four small follow-ups are listed below.
What it brings
When someone pastes an Excel or Sheets table into Slack, the agent now gets the rows as a | b lines. Before this, a table pasted with text ("read this table") was dropped without any notice, and a message that was only a table could be dropped completely.
Verified (at head)
- Messages without a table read the same as before.
_extract_table_text(src/kiro_crew/slack/events.py:2361) collects only blocks whosetype == "table"and returns""if it finds none. The append atevents.py:2395-2397only runs when that result is not empty. I checked this directly: an event withtext="hello"and an ordinaryrich_textblock gives an empty table text, sotextis unchanged. The existing forward and Block Kit recovery atevents.py:2391-2393runs first and was not modified. - Length is capped. The table renderer goes through
_extract_blocks_text, which truncates to_MAX_RECOVERED_TEXT_CHARS = 16000(events.py:2069,:2201). A table at Slack's maximum size (100 rows × 20 cells × 500 chars) renders to exactly 16000 characters. In total, a routed message can be at most the user's own text plus one capped table block. - Malformed input fails closed. A non-list
rows, a non-list row, a non-dict cell, or atext: Nonecell is skipped or read as empty, and nothing raises (events.py:2184-2197). The worst case is that the table is left out, which is the same as the old behaviour. - Link previews stay out. Attachments that have
from_urlare skipped (events.py:2366), so text from an unfurled sheet is not added to the message body. - Trust level is unchanged. Table text comes from the sender's own message (or a non-unfurl attachment on it) and takes the same path as typed text. It is added before the origin, access and thread-follow checks (
events.py:2401onward), so none of those checks is skipped. Text that looks like an instruction inside a cell is passed through word for word, the same as if it had been typed. No new trust tier is created. - Spec and decisions:
docs/system-specs/modules/slack-gateway.mddoes not list which block kinds are recovered. Its one reference ("after forward and Block Kit recovery", in the thread-follow rule) is still accurate, because the append runs before that check. No entry indocs/decisions/deals with Slack block recovery. - CI on this head: 85 success, 13 skipped, 0 failure, 0 pending (all check-run pages read). Auto-merge is on (squash), and there were no other reviews when I checked, so this approval is the last gate.
Blocking
None.
Non-blocking follow-ups
- The "already present" check is a plain substring match.
table_text not in text(events.py:2396) treats a short table as already present whenever its text shows up anywhere in the message. For example, a one-cell table3sent with the text "check row 3" is dropped. It would be more exact to dedupe only against the text that recovery produced (keep the result of_extract_shared_textand compare against that), instead of against the user's own text. - A large table can appear twice. If
textis empty, the event has another block next to the table, and the combined render is over 16000 characters, the recovered text gets cut at 16000. The table text then no longer matches as a substring, so it is appended a second time and the agent receives about twice the content. I reproduced this with arich_textblock plus a maximum-size table. A message that is only a table is not affected (I checked). Fix #1 also fixes this. - Truncation gives no signal. A table that hits the 16000 cap is cut in the middle of a row, with no marker. A short
… (table truncated)suffix would let the agent tell the user that it did not see every row. - One guard is not pinned by a test. If the
if any(cells)check (events.py:2196) is removed, every test still passes. Without it, an all-empty row becomes a blank line, which is harmless. A one-line test with an empty row would pin it.
Tests / mutations
test/test_events_forward.py+test/test_slack_events_coverage.py: 271 passed at head.- Mutations (each one reverted afterwards, worktree clean at the end):
- Remove the
tablecase: 4 failures, namelytest_table_block_renders_one_pipe_row_per_line,test_malformed_table_rows_are_skipped,test_table_in_attachment_is_appended_to_present_textandtest_table_only_message_is_routed_once. - Remove the append step:
test_table_in_attachment_is_appended_to_present_textfails. - Remove the "already present" check:
test_table_only_message_is_routed_oncefails. - Remove the
from_urlskip:test_table_in_link_preview_attachment_is_not_appendedfails. - Remove the cell
isinstance(c, dict)filter:test_malformed_table_rows_are_skippedfails. - Remove the row
isinstance(row, list)check:test_malformed_table_rows_are_skippedfails. - Remove
if any(cells): all pass (follow-up 4).
- Remove the
Not verified
- The exact payload Slack sends for a pasted table, including whether its top-level
textalready holds some rendering of the table. I checked the fixture's shape against the code, not against a live workspace. - Whether forwarded-message (
is_share) attachments that carryblocksbut nofrom_urlhappen in practice. In that case a forwarded table would now be appended too, which is a small change to forwards beyond what the PR body describes. - How the routed text is framed later, inside the prompt builder. That code is outside this diff.
Problem / Motivation
Goal: When a user pastes a spreadsheet table into Slack, the agent sees the table rows.
Slack sends a pasted Excel or Sheets table as a
tableblock. Crew dropped it. With text like "read this table", the agent got the text only. With no text, the message could be dropped.Why it matters
Pasting spreadsheet rows is a common way for non-developers to share data. Today the agent answers as if no table was sent.
Not a goal
a | blines.What changed (motivation → approach → change)
tableblock ignoreda | blineRoot cause: the Slack block reader in
src/kiro_crew/slack/events.pyknew onlyrich_text,sectionandcontext. And it only ran when the message text was empty.The fix adds a
tablecase to that reader. A cell is eitherraw_textorrich_text, and both are read. A new step in_route_messagecollectstableblocks from the message and its attachments, skipping link previews (from_url) so unfurl text stays out. It appends them after the text, unless the text already holds them.Backwards compatibility
Compatible: only adds text for
tableblocks; every other message reads the same.Removes nothing: the change only adds a block kind and an append step.
Tests
test/test_events_forward.py::TestPastedTableBlocks:rich_textandraw_textcells both read;Mutants checked by hand: removing the
tablecase fails the first four; removing the append fails the attachment test; dropping the "already present" check fails the once test; removing thefrom_urlskip fails the link-preview test.Known inherited red: Build Wheel, Build Desktop, Frontend Tests (1) and E2E (stub) fail on a stale
ui-index.generated.jsonfrom main; the fix is #18753. This diff touches no frontend file.Run:
python -m pytest test/test_events_forward.py test/test_slack_events_coverage.py -q→ 271 passed. flake8, isort, mypy (events.py), black gate and the flake-pattern ratchet pass. semgrep is not installed on this host; CI's SAST job runs it.Manual verification
N/A — unit coverage sufficient: the fixture mirrors the block shape Slack sends for a pasted table; no live Slack workspace was used.
Related Issues
Closes #18779
Fixes Taskei Mesh-574
Pattern harvest
Not generalizable: a missing case for one Slack block kind, not a repeatable code shape.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)