Skip to content

feat(model): add TaskCardBlock and UrlSourceElement - #1638

Open
srtaalej wants to merge 1 commit into
mainfrom
feat/block-kit-task-card
Open

feat(model): add TaskCardBlock and UrlSourceElement#1638
srtaalej wants to merge 1 commit into
mainfrom
feat/block-kit-task-card

Conversation

@srtaalej

@srtaalej srtaalej commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds TaskCardBlock layout block (task_card type) with all fields from docs
  • Adds UrlSourceElement for the sources field
  • Registers in GsonLayoutBlockFactory, adds Blocks.taskCard() helper
  • Includes parse and build tests in BlockKitTest and BlocksTest

Fields

Field Type Required
type "task_card" yes
task_id String yes
title String yes
status String (in_progress, complete, error) yes
details RichTextBlock no
output RichTextBlock no
sources List<UrlSourceElement> no
block_id String no
icon SlackIconObject no
hide_title Boolean no

Note: The docs example uses "pending" as a status value, but the API rejects it with invalid_blocks. Only in_progress, complete, and error are accepted.

Example usage

import static com.slack.api.model.block.Blocks.*;

var blocks = asBlocks(
    taskCard(t -> t
        .taskId("task_1")
        .title("Fetching weather data")
        .status("complete")
        .output(RichTextBlock.builder()
            .elements(Arrays.asList(
                RichTextSectionElement.builder()
                    .elements(Arrays.asList(
                        RichTextSectionElement.Text.builder()
                            .text("Found weather data for Chicago from 2 sources")
                            .build()
                    ))
                    .build()
            ))
            .build())
        .sources(Arrays.asList(
            UrlSourceElement.builder().url("https://weather.com/").text("weather.com").build(),
            UrlSourceElement.builder().url("https://www.accuweather.com/").text("accuweather.com").build()
        ))
    ),
    taskCard(t -> t
        .taskId("task_2")
        .title("Analyzing results")
        .status("in_progress")
    ),
    taskCard(t -> t
        .taskId("task_3")
        .title("Send notification")
        .status("error")
        .hideTitle(true)
        .output(RichTextBlock.builder()
            .elements(Arrays.asList(
                RichTextSectionElement.builder()
                    .elements(Arrays.asList(
                        RichTextSectionElement.Text.builder()
                            .text("Failed to reach notification service")
                            .build()
                    ))
                    .build()
            ))
            .build())
    )
);

Test plan

  • parseTaskCardBlock — deserializes JSON from docs example
  • buildTaskCardBlock — constructs via Blocks.taskCard() helper
  • testTaskCard — static helper test in BlocksTest
  • Tested in Slack UI via Socket Mode app with chatPostMessage

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.84%. Comparing base (e30ba9d) to head (5023106).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1638   +/-   ##
=========================================
  Coverage     72.84%   72.84%           
- Complexity     4533     4535    +2     
=========================================
  Files           482      482           
  Lines         14423    14425    +2     
  Branches       1512     1512           
=========================================
+ Hits          10506    10508    +2     
  Misses         3022     3022           
  Partials        895      895           
Flag Coverage Δ
jdk-14 72.84% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@srtaalej srtaalej self-assigned this Aug 28, 2026
@srtaalej srtaalej added enhancement M-T: A feature request for new functionality project:slack-api-model project:slack-api-model semver:minor labels Aug 28, 2026
@srtaalej
srtaalej marked this pull request as ready for review August 28, 2026 20:54
@srtaalej
srtaalej requested a review from a team as a code owner August 28, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement M-T: A feature request for new functionality project:slack-api-model project:slack-api-model semver:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant