Skip to content

Add convenience result builder APIs and fix critical bugs#1

Merged
diegotl merged 4 commits intomainfrom
feature/convenience-builder-api
Feb 3, 2026
Merged

Add convenience result builder APIs and fix critical bugs#1
diegotl merged 4 commits intomainfrom
feature/convenience-builder-api

Conversation

@diegotl
Copy link
Owner

@diegotl diegotl commented Feb 2, 2026

Summary

This PR adds comprehensive result builder syntax for Slack Block Kit components and fixes several critical bugs identified in code review.

New Features

Result Builder APIs

Added @resultBuilder support for cleaner, more Swift-like construction of Slack blocks:

  • ActionsBlock: Actions { ButtonElement(...) } instead of Actions([...])
  • ContextBlock: Context { TextContextElement(...) } instead of Context([...])
  • SectionBlock fields: Section(fields: Fields { Field.markdown("...") })
  • SelectElement options: StaticSelectElement(options: Options { Option(...) })
  • OverflowElement options: OverflowElement(options: Options { ... })
  • OptionGroup: OptionGroup(options: Options { ... })

Supports conditional statements (if, switch) and loops (for, while) within builders.

Convenience Helpers

  • Field.markdown() / Field.plainText() for section fields
  • TextContextElement.markdown() for markdown context elements
  • DatePickerElement.formatDate() for YYYY-MM-DD date formatting

Integration Tests

  • Added comprehensive integration test suite (80+ tests)
  • Uses SLACK_TEST_WEBHOOK_URL environment variable for configuration

Bug Fixes

  • Rate limit handling: Fixed unreachable 429 status check (moved before isSuccess)
  • InputBlock: Fixed dispatch_action coding key (was incorrectly dispatch_action_config)
  • InputBlock: Fixed element decoding using superDecoder() for nested types
  • DatePickerElement: Changed initialDate from Int to String (YYYY-MM-DD format)
  • TextContextElement: Added configurable type field for proper markdown/plain_text support
  • URLSessionNetworkClient: Removed unused decoder property

Test Results

All 88 tests pass.

API Compatibility

All changes verified against official Slack Block Kit API.

Implements a result builder-based API for creating Slack messages
with a more declarative and ergonomic syntax.

Changes:
- Add MessageBuilder result builder for block construction
- Add convenience functions for all block types (Section, Divider, Header, Image, Context, Actions, Input, Call)
- Add Message initializer supporting builder syntax with all Message options
- Add tests for builder API including conditional blocks and all options
- Update README with builder API examples

This maintains full backward compatibility while providing a cleaner
API for common use cases.
- Add result builders for ActionsBlock, ContextBlock, and SectionBlock fields
- Add result builders for StaticSelectElement, MultiStaticSelectElement, OverflowElement, and OptionGroup
- Add Field helper enum for cleaner Section fields API
- Update README and all tests to use new builder syntax
- Add comprehensive integration test suite with documentation
- Configure integration tests to use SLACK_TEST_WEBHOOK_URL environment variable

All builders support conditionals, loops, and optional elements for cleaner, more expressive message construction.
- Fix rate limit handling by checking 429 before isSuccess
- Fix InputBlock dispatch_action coding key (was dispatch_action_config)
- Fix InputBlock element decoding using superDecoder
- Fix DatePickerElement initialDate to String (YYYY-MM-DD format)
- Fix TextContextElement to support configurable type field
- Remove unused decoder from URLSessionNetworkClient
- Add formatDate helper to DatePickerElement for proper date formatting
- Add markdown static helper to TextContextElement
@diegotl diegotl changed the title Add convenience builder API for cleaner message construction Add convenience result builder APIs and fix critical bugs Feb 3, 2026
Repository owner deleted a comment from chatgpt-codex-connector bot Feb 3, 2026
Repository owner deleted a comment from chatgpt-codex-connector bot Feb 3, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7eb8abd97

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Set blocks to nil when builder produces empty array to avoid Slack API rejection
@diegotl diegotl merged commit 4482c9c into main Feb 3, 2026
1 check passed
@diegotl diegotl deleted the feature/convenience-builder-api branch February 3, 2026 22:52
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.

1 participant