Skip to content

feat(web): expose public ts property on ChatStream - #1880

Merged
srtaalej merged 3 commits into
mainfrom
ale-make-ts-public
Jun 2, 2026
Merged

feat(web): expose public ts property on ChatStream#1880
srtaalej merged 3 commits into
mainfrom
ale-make-ts-public

Conversation

@srtaalej

@srtaalejsrtaalej commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a public read-only ts property to ChatStream and AsyncChatStream, enabling users to call chat.update as a fallback when the server closes a stream due to undocumented timeouts.

Resolves#1859

Background

When Slack's server-side timeout kills a stream, both chat.appendStream and chat.stopStream return message_not_in_streaming_state. The message still exists but is stuck as a broken pill in the UI. The only recovery path is chat.update(ts=...), but ts was previously a private attribute (_stream_ts).

Changes

  • slack_sdk/web/chat_stream.py: Added ts property (read-only, returns Optional[str])
  • slack_sdk/web/async_chat_stream.py: Same (auto-generated via codegen)
  • tests/slack_sdk/web/test_chat_stream.py: Added test verifying ts is None before flush and set after
code snippet
fromslack_sdkimportWebClientfromslack_sdk.errorsimportSlackApiErrorclient=WebClient(token=...)
defsend_streaming(channel, thread_ts, team_id, user_id, content_iter):
stream=client.chat_stream(
channel=channel,
thread_ts=thread_ts,
recipient_team_id=team_id,
recipient_user_id=user_id,
)
full_text=""stream_alive=Trueforchunkincontent_iter:
full_text+=chunkifstream_alive:
try:
stream.append(markdown_text=chunk)
exceptSlackApiErrorase:
ife.response["error"] =="message_not_in_streaming_state":
stream_alive=Falseelse:
raiseifnotstream_alive:
client.chat_update(channel=channel, ts=stream.ts, text=full_text)
ifstream_alive:
stream.stop()
else:
client.chat_update(channel=channel, ts=stream.ts, text=full_text)

Test plan

  • Existing ChatStream tests pass
  • New test verifies ts is None before first flush and set after
  • CI passes

@srtaalej
srtaalej requested a review from a team as a code ownerMay 27, 2026 18:02
@srtaalejsrtaalej self-assigned this May 27, 2026
@srtaalejsrtaalej added enhancement M-T: A feature request for new functionality discussion M-T: An issue where more input is needed to reach a decision labels May 27, 2026
@codecov

codecovBot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@ Coverage Diff @@## main #1880 +/- ##
=======================================
Coverage 84.12% 84.13% =======================================
Files 117 117 Lines 13340 13346 +6 =======================================
+ Hits 11222 11228 +6 
Misses 2118 2118 

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

@WilliamBergaminWilliamBergamin 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.

Awesome work 💯 this look good

Could we mirror the unit test to cover the async implementation, once added I think we are good to merge 🙏

@zimegzimeg modified the milestones: 3.x, 3.43.0May 28, 2026
@srtaalejsrtaalej removed the discussion M-T: An issue where more input is needed to reach a decision label May 29, 2026

@WilliamBergaminWilliamBergamin 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.

🚀

@srtaalej
srtaalej merged commit be8be5e into mainJun 2, 2026
18 checks passed
@srtaalej
srtaalej deleted the ale-make-ts-public branch June 2, 2026 03:21
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementM-T: A feature request for new functionalitysemver:minorVersion: 3xweb-client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

message_not_in_streaming_state after undocumented timeouts hit

3 participants

@srtaalej@WilliamBergamin@zimeg