Skip to content

feat(chat): add streaming options to thread.post()#388

Draft
dancer wants to merge 5 commits intomainfrom
josh/stream-post-options
Draft

feat(chat): add streaming options to thread.post()#388
dancer wants to merge 5 commits intomainfrom
josh/stream-post-options

Conversation

@dancer
Copy link
Copy Markdown
Contributor

@dancer dancer commented Apr 15, 2026

summary

adds StreamingPlan PostableObject for passing platform-specific streaming options through thread.post() instead of bypassing the Thread abstraction via adapter.stream() directly

const stream = new StreamingPlan(result.fullStream, {
  groupTasks: "plan",
  endWith: [feedbackBlock],
});
await thread.post(stream);
  • groupTasks controls task display mode ("plan" or "timeline")
  • endWith attaches Block Kit elements when the stream stops
  • updateIntervalMs controls fallback post+edit cadence
  • recipientUserId/recipientTeamId auto-populated from message context
  • adapters without native streaming fall back to post+edit automatically

test plan

  • ran pnpm --filter chat test - all tests pass
  • tested StreamingPlan with full options, groupTasks only, and endWith only
  • verified post() return type matches the PostableObject overload contract

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat Ready Ready Preview, Comment, Open in v0 Apr 15, 2026 1:31am
chat-sdk-nextjs-chat Ready Ready Preview, Comment, Open in v0 Apr 15, 2026 1:31am

Copy link
Copy Markdown
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

When a StreamMessage is passed to thread.post(), TypeScript infers the return type as Promise<StreamMessage> via the generic post<T extends PostableObject>(message: T): Promise<T> overload, but the runtime actually returns a SentMessage, causing type unsafety.

Fix on Vercel

…urn type

Rename per Malte's feedback - StreamingPlan better describes what the
options control (task grouping, stop blocks for streamed plans).

Fix type safety issue where post<T extends PostableObject>() returned
SentMessage at runtime instead of T. Now awaits handleStream() for
side effects and returns the original StreamingPlan instance.
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