Conversation
WalkthroughThis PR introduces Slack Block Kit formatting support by adding a Button/ButtonGroup API, enhancing parser and rendering logic with TypedValue handling, implementing a SlackFormatter that converts data structures to Slack Block Kit JSON, and integrating Slack format throughout the formatting pipeline. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant HTTP as HTTP Handler
participant Manager as FormatManager
participant Formatter as SlackFormatter
participant Output
Client->>HTTP: Request with Slack format
HTTP->>Manager: Identify "slack" format
Manager->>Manager: Resolve to Slack formatter
Manager->>Formatter: Format(data)
Formatter->>Formatter: Parse data structure
Formatter->>Formatter: Build Slack blocks<br/>(text, sections, buttons)
Formatter->>Formatter: Marshal to Block Kit JSON
Formatter-->>Manager: JSON string
Manager-->>HTTP: Formatted output
HTTP-->>Output: Slack Block Kit JSON<br/>+ Content-Type header
Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
09c09f2 to
0a5cbb2
Compare
1388ab3 to
4d882cb
Compare
Add explicit batch timeout to prevent race between batch and item timeouts that could cause test flakiness.
4d882cb to
c4cb8c1
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
api/table.go (1)
192-206: Bug: Using Markdown-formatted text as map key will cause lookup failures.Line 198 uses
TransformerMarkdown(header)forfieldName, but therowmap is keyed by plain string field names. Ifheader.Markdown()returns different text thanheader.String()(e.g., with formatting), the map lookup on line 201 will fail to find matching cells.The
fieldNameshould useheader.String()to match the map keys, whileTransformerMarkdownshould only be used for display values.🐛 Proposed fix
if i < len(t.FieldNames) && t.FieldNames[i] != "" { fieldName = t.FieldNames[i] } else { - fieldName = TransformerMarkdown(header) + fieldName = header.String() }
🤖 Fix all issues with AI agents
In `@formatters/slack_formatter.go`:
- Around line 631-640: The current byte-based splitting loop that breaks a long
string `line` into chunks using `line[start:end]` can split multi-byte UTF-8
runes; change the logic in the long-line handling (the loop that appends to
`parts`) to be rune-aware: convert `line` to a slice of runes (e.g., `runes :=
[]rune(line)`), compute chunk boundaries using `max` as a rune count (or derive
a rune-based limit), and append substrings using `string(runes[start:end])` so
multi-byte characters are preserved; keep the existing `flush()` and `parts`
append behavior but operate on rune slices instead of raw bytes.
- Around line 549-555: The truncateSlackHeader function currently slices bytes
and may split UTF-8 runes; change truncateSlackHeader to be rune-aware by
converting text to a []rune (e.g., runes := []rune(text)), compare len(runes) to
slackHeaderMax, and return string(runes[:slackHeaderMax]) when truncation is
needed so multi-byte characters are not split; keep the constant slackHeaderMax
but treat it as a rune/character limit within the function.
- Around line 557-563: The truncateSlackButton function currently slices bytes,
which can split multibyte UTF-8 characters; update
SlackFormatter.truncateSlackButton to perform rune-aware truncation using runes
(e.g., convert text to []rune or use utf8 utilities) and return the first
slackButtonMax runes so multi-byte characters are preserved (keep the
slackButtonMax constant and function name unchanged).
🧹 Nitpick comments (1)
api/table.go (1)
222-237: Consider moving type definition before variable declarations.The
TextTransformertype (line 237) is defined after the variables that use it (lines 222-235). While Go allows this, placing the type definition first improves readability and follows conventional Go code organization.♻️ Suggested reordering
+type TextTransformer func(t Textable) string + var TransformerANSI TextTransformer = func(t Textable) string { return t.ANSI() } var TransformerString TextTransformer = func(t Textable) string { return t.String() } var TransformerHTML TextTransformer = func(t Textable) string { return t.HTML() } var TransformerMarkdown TextTransformer = func(t Textable) string { return t.Markdown() } - -type TextTransformer func(t Textable) string
- Fix markdown key lookup bug in table.go by using header.String() instead of TransformerMarkdown(header) since row map is keyed by plain strings - Fix UTF-8 truncation in truncateSlackHeader, truncateSlackButton, and splitSlackText by using rune-based operations to prevent multi-byte character corruption - Reorder TextTransformer type definition before variables that use it
## [1.13.0](v1.12.2...v1.13.0) (2026-01-20) ### ✨ Features * slack blocks formatter ([#59](#59)) ([b4203d3](b4203d3))
|
🎉 This PR is included in version 1.13.0 |
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.