Skip to content

refactor: use say_stream helper instead of client.chat_stream - #82

Merged
zimeg merged 2 commits into
mainfrom
use-say-stream-helper
Nov 18, 2026
Merged

zimeg merged 2 commits into
mainfrom
use-say-stream-helper

Conversation

@zimeg

@zimeg zimeg commented May 19, 2026

Copy link
Copy Markdown
Member

Summary

Replace manual client.chat_stream() calls with the say_stream context utility, which automatically injects channel, thread_ts, recipient_team_id, and recipient_user_id from the listener context.

This simplifies the message handler by removing the need to manually extract and pass these values from payload and context.

def message(
    logger: Logger,
    message: dict,
    say: Say,
    say_stream: SayStream,
    set_status: SetStatus,
):
    set_status(status="thinking...")
    streamer = say_stream(task_display_mode="plan")
    streamer.append(markdown_text="Hello!")
    streamer.stop()

Requirements

Replace manual client.chat_stream() calls with the say_stream context
utility, which automatically injects channel, thread_ts, recipient IDs.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg
zimeg requested a review from a team as a code owner May 19, 2026 04:32
@zimeg zimeg self-assigned this May 19, 2026
@zimeg zimeg added the enhancement New feature or request label May 19, 2026
@zimeg
zimeg enabled auto-merge (squash) May 19, 2026 04:36

@srtaalej srtaalej left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This branch is 95 commits behind main but merges cleanly. On the merged result with main's deps (slack-bolt==1.30.0), ruff check and ruff format --check pass ✅ I checked against bolt's attaching_conversation_kwargs middleware that say_stream fills in the same channel, thread_ts, and recipient_user_id that were passed by hand before. It also falls back to enterprise_id for recipient_team_id, which is a small win for org installs. I didn't do a live run in Slack because I don't have a working token right now, so I checked this against the source instead.\n\nOne follow-up, not blocking: listeners/events/app_mentioned.py on main still calls client.chat_stream(...) by hand. It could switch to say_stream too, either here or in a follow-up, so the sample stays consistent. LGTM!

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg
zimeg merged commit 7dfefa3 into main Nov 18, 2026
3 checks passed
@zimeg
zimeg deleted the use-say-stream-helper branch November 18, 2026 04:30
@zimeg

zimeg commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

🌟 Thanks for the kind review @srtaalej!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants