Skip to content

fix(slack): keep pasted table blocks in the message text - #18786

Merged
iamwhatever merged 1 commit into
mainfrom
fix/slack-table-block
Oct 10, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/slack-table-block

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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 table block. 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

  • Other Slack block kinds (images, actions, inputs) are not touched.
  • No change to how forwarded messages or link unfurls are recovered.
  • No markdown table formatting: rows are plain a | b lines.

What changed (motivation → approach → change)

Before After
table block ignored each row becomes one a | b line
table lost when text is present table appended after the text
table-only message may be dropped table text is the message

Root cause: the Slack block reader in src/kiro_crew/slack/events.py knew only rich_text, section and context. And it only ran when the message text was empty.

The fix adds a table case to that reader. A cell is either raw_text or rich_text, and both are read. A new step in _route_message collects table blocks 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 table blocks; 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:

  • a table renders as one pipe row per line, rich_text and raw_text cells both read;
  • malformed rows are skipped and a cell with no text reads as empty, no crash;
  • a table in an attachment is appended to text that is already present;
  • a table-only message carries the table once, not twice;
  • a table inside a link-preview attachment is not appended.

Mutants checked by hand: removing the table case fails the first four; removing the append fails the attachment test; dropping the "already present" check fails the once test; removing the from_url skip 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.json from 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

  • 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

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 10, 2026 08:08
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 1b61f05353ccb513b5594cffb1a264585e54c345 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 1b61f05353ccb513b5594cffb1a264585e54c345 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check against a real Slack table paste whether the top-level text already carries its own rendering of the table. If it does, the not in text dedupe misses it and the agent gets the rows twice.

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of 1b61f05353ccb513b5594cffb1a264585e54c345 — 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/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

Collecting tables from attachments rests on an unverified shape: a pasted table arrives in event.blocks, and nothing shows Slack ever puts one in a plain attachment.

Not justified as shipped

  • Item 3 — inherited: the Goal is "a user pastes a spreadsheet table", but _extract_table_text also walks attachments and keeps any one without from_url (if isinstance(att, dict) and not att.get("from_url") and isinstance(att.get("blocks"), list)). Its only evidence is a test fixture {"attachments": [{"blocks": [_TABLE_BLOCK]}]} that has neither is_share nor is_msg_unfurl, and the description cites no Slack payload with that shape. It also uses a second filter (not from_url) beside _extract_shared_text's positive is_share/is_msg_unfurl check (src/kiro_crew/slack/events.py:2324).
    Subtraction: delete the for att in event.get("attachments") loop and read only event["blocks"]. A forward that carries a table already reaches _extract_blocks_text through _extract_shared_text.
    Clears when: a captured Slack payload (for example on Slack: pasted spreadsheet tables are dropped from the message text #18779) shows a pasted table inside an attachment, or the loop is deleted.

What this change ships

Inventory (4 items) — 3 justified

Intent: let the agent see the rows of a spreadsheet table pasted into Slack. This is a FIX.

  1. A table-only pasted message now reaches the agent as a | b rows instead of being dropped — justified
  2. A pasted table is now appended after the user's own text ("read this table") — justified
  3. Tables inside non-link-preview attachments are also appended — inherited, unverified payload shape
  4. A table already present in the recovered text is not appended a second time — justified

[FIRST-PRINCIPLES-REVIEWED] 1b61f05

Description read

[DESCRIPTION-READ] b9d6b33ee100809522e6c41edf22bc3c45317b54716030c7d9d4f5a71f2b8231

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 Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 1b61f05

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 1b61f05353ccb513b5594cffb1a264585e54c345: <one-sentence reason>

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • Unfurled table content can reach the prompt span=31efb881362c — fixed

_extract_table_text now skips any attachment with from_url, which every link unfurl and message unfurl carries.
A pasted table attachment has no from_url, so it is still read.
New test test_table_in_link_preview_attachment_is_not_appended shows an unfurl's table is not appended; removing the guard fails it.
Fixed in the next push on this branch.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • Item 3 — attachment loop reads every attachment span=fdd85dd1c01e — fixed

#18779 now records where the table arrives: the original report found pasted tables in event["attachments"][N]["blocks"], not flagged as share or unfurl (#18779 (comment)).
So the is_share/is_msg_unfurl filter would drop the very table this PR is for.
The leak the filter guards is link-preview text; the loop now skips attachments with from_url (every unfurl has it), with a test proving an unfurl's table is not appended.
Fixed in the next push on this branch.

@iamwhatever
iamwhatever force-pushed the fix/slack-table-block branch from 5f7dd6c to 314f594 Compare October 10, 2026 08:22
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 1b61f05

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 1b61f05353ccb513b5594cffb1a264585e54c345: <one-sentence reason>

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • Item 3 — attachment scan block-list vs allow-list span=3a035f74440a — rebutted

#18779's body now has "Where the table arrives": the original report inspected the payload and found pasted tables in event["attachments"][N]["blocks"], with no is_share/is_msg_unfurl/from_url.
The is_share/is_msg_unfurl allow-list would therefore drop the exact table this PR fixes; deleting the loop would too.
from_url excludes every link and message unfurl, the leak class _extract_shared_text guards; a test pins it.
Forwarded text recovery is unchanged: _extract_shared_text is not touched; only a table block, if present, is added.

@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 Oct 10, 2026
@iamwhatever
iamwhatever force-pushed the fix/slack-table-block branch from 314f594 to 1b61f05 Compare October 10, 2026 09:20
@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 Oct 10, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • Item 3 — attachment loop evidence span=45e6eb4b253a — rebutted

Same class as span=3a035f74440a on the previous head, unchanged by the rebase.
#18779 body records the reporter's payload analysis: pasted tables arrive in event["attachments"][N]["blocks"], with no is_share/is_msg_unfurl/from_url.
Deleting the loop would drop that table, so the Goal would not be met; from_url keeps every unfurl out, pinned by a test.
No live captured payload is on hand; a maintainer may rule on this with an override if the report is not enough.

@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 Oct 10, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

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: _extract_blocks_text had no table case and only ran when the text was empty. It now renders each row as a | b (both raw_text and rich_text cells), and _route_message adds table text after the user's own text unless that text already contains it. I read the full diff at 1b61f05. Base is main, every check is green and there are no change requests. The five new tests in TestPastedTableBlocks would fail on base. The from_url skip keeps link-unfurl tables out of the prompt, and a test pins it. On the First Principles CONCERNS (the attachment loop rests on a payload shape nobody captured): it has an evidence-backed rebuttal on the current head that cites the reporter's payload analysis in #18779. I accept it, because without the loop the reported case would stay broken. Reviewer note: the Design lane's PASS asks for a check that Slack's top-level text for a table paste does not carry its own rendering of the rows. If it does (for example tab-separated), the table_text not in text check at events.py:2396 misses it and the agent sees the rows twice. That ask has no disposition yet, so post one, and if a live paste shows that shape, follow up by dropping the append when the text already holds the cell values. One more small gap: no test covers a top-level blocks table that arrives together with non-empty text. — crew-pr-reviewer

@iamwhatever
iamwhatever enabled auto-merge (squash) October 10, 2026 18:38

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 whose type == "table" and returns "" if it finds none. The append at events.py:2395-2397 only runs when that result is not empty. I checked this directly: an event with text="hello" and an ordinary rich_text block gives an empty table text, so text is unchanged. The existing forward and Block Kit recovery at events.py:2391-2393 runs 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 a text: None cell 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_url are 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:2401 onward), 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.md does 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 in docs/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

  1. 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 table 3 sent 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_text and compare against that), instead of against the user's own text.
  2. A large table can appear twice. If text is 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 a rich_text block plus a maximum-size table. A message that is only a table is not affected (I checked). Fix #1 also fixes this.
  3. 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.
  4. 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 table case: 4 failures, namely test_table_block_renders_one_pipe_row_per_line, test_malformed_table_rows_are_skipped, test_table_in_attachment_is_appended_to_present_text and test_table_only_message_is_routed_once.
    • Remove the append step: test_table_in_attachment_is_appended_to_present_text fails.
    • Remove the "already present" check: test_table_only_message_is_routed_once fails.
    • Remove the from_url skip: test_table_in_link_preview_attachment_is_not_appended fails.
    • Remove the cell isinstance(c, dict) filter: test_malformed_table_rows_are_skipped fails.
    • Remove the row isinstance(row, list) check: test_malformed_table_rows_are_skipped fails.
    • Remove if any(cells): all pass (follow-up 4).

Not verified

  • The exact payload Slack sends for a pasted table, including whether its top-level text already 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 carry blocks but no from_url happen 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.

@iamwhatever
iamwhatever merged commit 955c2cc into main Oct 10, 2026
102 checks passed
@iamwhatever
iamwhatever deleted the fix/slack-table-block branch October 10, 2026 18:48
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 10, 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: pasted spreadsheet tables are dropped from the message text

2 participants