Skip to content

fix(slack): extract table blocks as row-delimited text in events (#18779) - #18788

Closed
Fire162 wants to merge 1 commit into
kirodotdev:mainfrom
Fire162:fix/slack-table-block-extraction
Closed

Fire162 wants to merge 1 commit into
kirodotdev:mainfrom
Fire162:fix/slack-table-block-extraction

Conversation

@Fire162

@Fire162 Fire162 commented Oct 10, 2026

Copy link
Copy Markdown

Summary

When users paste spreadsheet tables into Slack, Slack dispatches them as Block Kit table blocks. Previously:

  1. _extract_blocks_text only handled rich_text, section, and context blocks, silently dropping table blocks.
  2. In _route_message, block extraction only ran when top-level message text was empty or a generic fallback placeholder. If a user provided text alongside the pasted table (e.g., "read this table"), the table was omitted from the routed message body. If no text was provided, the message could be dropped entirely.

Changes

  • In _extract_blocks_text, add support for type == "table" blocks:
    • Iterates through rows and converts cell values (rich text elements, raw text, numbers, or stringified primitives) into strings.
    • Joins row cells with | and appends non-empty rows.
  • In _route_message, detect event-level table blocks when message text is present and append extracted table text separated by newlines if not already included.
  • Added comprehensive unit tests in test/test_events_forward.py covering:
    • Table block row and cell extraction (including rich text and numeric cells).
    • Routing messages where a table block accompanies non-empty text.
    • Routing messages where a table block arrives with empty text.

Fixes #18779

@Fire162
Fire162 requested review from a team and KiroCrewCaptain as code owners October 10, 2026 08:19
@Fire162
Fire162 requested a review from bolichen97 October 10, 2026 08:19
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 10, 2026

@bolichen97 bolichen97 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.

[operator: bolichen97]

Review of head e4c6304.

Recommendation: close as superseded. Thank you for the fix. Main already fixed #18779 through #18786 (merged 2026-10-10, merge commit 955c2cc). That PR adds the same table case and the same "append the table after the text" step. Issue #18779 is closed as completed.

Counts: 1 blocking, 2 should-fix, 1 nit.

Merge conflict. Both files conflict with main. src/kiro_crew/slack/events.py: main rewrote _extract_blocks_text with a lazy, budgeted renderer (_table_row_fragments, a table branch near line 2391) and added _extract_table_text plus a table-append step in _route_message (near line 2687). This PR edits the same two hunks. test/test_events_forward.py: #18786 added table tests in the same test classes. A rebase would give two table branches (the second unreachable) and two append steps.

Fork PR Description check. It fails because the body uses ## Summary / ### Changes. The template headings are required as written: ## Problem / Motivation, ## Why it matters, ## Not a goal, ## What changed, ## Tests. Edit the body from .github/PULL_REQUEST_TEMPLATE.md; no push is needed. PR Readiness stays red until that passes. This only matters if the PR is kept.

Checked, no finding: cell text is joined as plain text (no markup or command path is added); the table text joins the user's message text, so it keeps the same untrusted channel-message handling as any other Slack text. Empty rows are skipped; None cells become empty strings.

Inline findings below.

)
if inline:
parts.append(inline)
elif block_type == "table":

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.

blocking - Superseded by #18786 (merged 2026-10-10, 955c2cc). Main already has a table branch in _extract_blocks_text (main events.py ~2391, via _table_row_fragments). After a rebase this elif would sit beside it and never run. Fix: close this PR. If a test case here covers a shape main lacks, port only that test in a new PR on main.

if not text or text in _SLACK_BLOCK_FALLBACKS:
fallback = "" if text in _SLACK_BLOCK_FALLBACKS else text
text = _extract_shared_text(event) or fallback
elif any(isinstance(b, dict) and b.get("type") == "table" for b in (event.get("blocks") or [])):

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.

should-fix - This reads tables only from event["blocks"]. Tables inside attachments (a forwarded or shared message) are missed. Main's _extract_table_text also reads non-link-preview attachments and skips from_url unfurls. Fix (if kept): collect table blocks from the event and from attachments without from_url, as main does.

elif cell is None:
cell_texts.append("")
else:
cell_texts.append(str(cell))

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.

nit - str(cell) on an unknown cell type (list, bool, dict) puts a Python repr such as ['a'] or True into the agent text. Fix: render only str/int/float, else use an empty string.

else:
cell_texts.append(str(cell))
if any(cell_texts):
parts.append(" | ".join(cell_texts))

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.

should-fix - Size cap. The 16000-char cap (return result[:_MAX_RECOVERED_TEXT_CHARS], line 2229) is applied only after the whole string is built, so a very large pasted table (thousands of rows) is fully rendered in memory before the slice. Main fixed this with a budgeted renderer that stops at the cap. Fix (if kept): stop adding rows once the running length reaches _MAX_RECOVERED_TEXT_CHARS, and add a test with a table larger than the cap.

@iamwhatever

Copy link
Copy Markdown
Contributor

Thanks a lot for this fix, @Fire162. Closing because the same problem was fixed on main by #18786 ("fix(slack): keep pasted table blocks in the message text", merged 2026-10-10), which also closed #18779. src/kiro_crew/slack/events.py now appends pasted table blocks even when the message has text. If we got this wrong and your change covers a case #18786 misses, please reopen and let us know.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slack: pasted spreadsheet tables are dropped from the message text

3 participants