Skip to content

feat(types): add BlockChunk type to chat.{start,append,stop}Stream methods#2580

Merged
srtaalej merged 6 commits intomainfrom
ale-feat-block-chunks
May 6, 2026
Merged

feat(types): add BlockChunk type to chat.{start,append,stop}Stream methods#2580
srtaalej merged 6 commits intomainfrom
ale-feat-block-chunks

Conversation

@srtaalej
Copy link
Copy Markdown
Contributor

@srtaalej srtaalej commented May 5, 2026

Summary

This PR adds BlocksChunk model class to support the new blocks chunk type in the streaming API (chat.startStream, chat.appendStream, chat.stopStream). Follows the April 16, 2026 changelog which notes updates to the text-streaming API methods to support streaming blocks.

Testing

Sample app.js
import { App, LogLevel } from '@slack/bolt';
import { config } from 'dotenv';

config();

const app = new App({
  token: process.env.SLACK_BOT_TOKEN,
  socketMode: true,
  appToken: process.env.SLACK_APP_TOKEN,
  logLevel: LogLevel.DEBUG,
});

app.message(/^test blocks chunk$/, async ({ message, client, logger }) => {
  try {
    const streamer = client.chatStream({
      channel: message.channel,
      thread_ts: message.ts,
      recipient_team_id: message.team,
      recipient_user_id: message.user,
    });

    await streamer.append({
      markdown_text: "Here's a **card** streamed via `BlocksChunk`:\n\n",
    });

    await streamer.append({
      chunks: [
        {
          type: 'blocks',
          blocks: [
            {
              type: 'card',
              title: { type: 'mrkdwn', text: 'Streaming Card' },
              subtitle: { type: 'mrkdwn', text: 'Sent via BlocksChunk' },
              body: { type: 'mrkdwn', text: 'This card was streamed inside a chunks array.' },
            },
          ],
        },
      ],
    });

    await streamer.stop({
      chunks: [
        {
          type: 'blocks',
          blocks: [
            {
              type: 'carousel',
              elements: [
                {
                  type: 'card',
                  title: { type: 'mrkdwn', text: 'Card 1' },
                  subtitle: { type: 'mrkdwn', text: 'First' },
                  body: { type: 'mrkdwn', text: 'First card in carousel.' },
                },
                {
                  type: 'card',
                  title: { type: 'mrkdwn', text: 'Card 2' },
                  subtitle: { type: 'mrkdwn', text: 'Second' },
                  body: { type: 'mrkdwn', text: 'Second card in carousel.' },
                },
                {
                  type: 'card',
                  title: { type: 'mrkdwn', text: 'Card 3' },
                  subtitle: { type: 'mrkdwn', text: 'Third' },
                  body: { type: 'mrkdwn', text: 'Third card in carousel.' },
                },
              ],
            },
          ],
        },
      ],
    });
  } catch (error) {
    logger.error(error);
  }
});

(async () => {
  try {
    await app.start();
    app.logger.info('⚡️ Bolt app is running!');
  } catch (error) {
    app.logger.error('Failed to start the app', error);
  }
})();

Requirements

@srtaalej srtaalej requested a review from a team as a code owner May 5, 2026 21:09
@srtaalej srtaalej self-assigned this May 5, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

🦋 Changeset detected

Latest commit: 4589e89

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@slack/types Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@srtaalej srtaalej added semver:minor enhancement M-T: A feature request for new functionality pkg:types applies to `@slack/types` labels May 5, 2026
@srtaalej srtaalej added this to the types@next milestone May 5, 2026
@srtaalej srtaalej changed the title feat: add BlockChunk type to chat.{start,append,stop}Stream methods feat(pkg:types): add BlockChunk type to chat.{start,append,stop}Stream methods May 5, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.50%. Comparing base (21b0839) to head (4589e89).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2580   +/-   ##
=======================================
  Coverage   87.50%   87.50%           
=======================================
  Files          62       62           
  Lines       10256    10256           
  Branches      418      418           
=======================================
  Hits         8974     8974           
  Misses       1260     1260           
  Partials       22       22           
Flag Coverage Δ
cli-hooks 87.50% <ø> (ø)
cli-test 87.50% <ø> (ø)
logger 87.50% <ø> (ø)
oauth 87.50% <ø> (ø)
socket-mode 87.50% <ø> (ø)
web-api 87.50% <ø> (ø)
webhook 87.50% <ø> (ø)

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zimeg zimeg changed the title feat(pkg:types): add BlockChunk type to chat.{start,append,stop}Stream methods feat(types): add BlockChunk type to chat.{start,append,stop}Stream methods May 5, 2026
Copy link
Copy Markdown
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

@srtaalej Exciting times ahead for streaming chats! I'm marking this with a few changes requested before this merge:

⚠️ issue: The sample code doesn't have these block chunks shown in autocomplete. This doesn't error because arguments are passed through but it might not appear as an expected argument for developers.

Image

📚 todo: This is worth a note in the changesets too! I'm thinking we should document this as a web-api change while still releasing the types changes alongside this 🚀

Comment thread packages/types/src/chunk.ts Outdated
* Union type of all possible chunk types
*/
export type AnyChunk = MarkdownTextChunk | PlanUpdateChunk | TaskUpdateChunk;
export type AnyChunk = MarkdownTextChunk | PlanUpdateChunk | TaskUpdateChunk | BlocksChunk;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🧮 quibble: Also if possible can we order new entries in alphabetics?

Copy link
Copy Markdown
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

@srtaalej Forgive the unexpected editor configurations! I'm finding this appears in a new shell! 📠

This LGTM with the above note and I'm wondering if we want to discuss version schemes for these changes? 🔮

Using a patch version to signal changing fields has been practiced before while a minor might be used for new blocks altogether? Both do seem alright and I'm also curious about releasing this with web-api also since this is surfaced here? 📚

I'm not so confident about calling this a @slack/web-api change but it's something we can add tests for here also with a changeset? 🪬

srtaalej and others added 2 commits May 6, 2026 11:32
@srtaalej srtaalej merged commit 5bc7685 into main May 6, 2026
12 checks passed
@srtaalej srtaalej deleted the ale-feat-block-chunks branch May 6, 2026 15:43
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 pkg:types applies to `@slack/types` semver:patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants