Skip to content

Conversation

grdsdev
Copy link
Contributor

@grdsdev grdsdev commented Sep 30, 2025

Summary

  • Added ReplayOption type for configuring broadcast replay
  • Added replay field to RealtimeChannelBroadcastConfig
  • Added BroadcastMeta type for replay metadata
  • Added meta field to BroadcastPayload to receive replay information

Changes

This PR implements broadcast replay support following the pattern from realtime-js PR #540:

  1. ReplayOption: New TypedDict with since (int) and optional limit (int)
  2. RealtimeChannelBroadcastConfig: Added optional replay field
  3. BroadcastMeta: New TypedDict with replayed (bool) and id (str)
  4. BroadcastPayload: Added optional meta field

Usage

# Configure broadcast with replay
channel = client.channel('my-channel', {
    'config': {
        'broadcast': {
            'self': True,
            'ack': True,
            'replay': {
                'since': 1234567890,
                'limit': 100
            }
        }
    }
})

# Broadcast callback receives meta field
def on_broadcast(payload):
    if payload.get('meta', {}).get('replayed'):
        print(f"Replayed message: {payload['meta']['id']}")

Test plan

  • Verify type checking passes
  • Test broadcast replay configuration
  • Verify meta field is properly typed in callbacks

🤖 Generated with Claude Code

Added ReplayOption type and replay field to RealtimeChannelBroadcastConfig
to support configuring broadcast replay with 'since' timestamp and optional
'limit' parameter. Added BroadcastMeta type and meta field to BroadcastPayload
for receiving replay metadata including replayed status and message id.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@grdsdev grdsdev requested review from edgurgel and a team September 30, 2025 19:32
@coveralls
Copy link

coveralls commented Sep 30, 2025

Pull Request Test Coverage Report for Build 18227834373

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.005%) to 93.876%

Files with Coverage Reduction New Missed Lines %
src/realtime/types.py 5 95.54%
Totals Coverage Status
Change from base Build 18227491171: 0.005%
Covered Lines: 8722
Relevant Lines: 9291

💛 - Coveralls

@grdsdev grdsdev requested a review from o-santi October 1, 2025 18:36
Copy link
Contributor

@o-santi o-santi left a comment

Choose a reason for hiding this comment

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

I don't think these changes in particular are enough to make it work, because RealtimeChannelBroadcastConfig is not directly sent over wire, but instead read from inside subscribe. I believe you need to read that information inside the function to generate the config_payload correctly.

@grdsdev grdsdev requested a review from o-santi October 2, 2025 08:48
@grdsdev
Copy link
Contributor Author

grdsdev commented Oct 2, 2025

I don't think these changes in particular are enough to make it work, because RealtimeChannelBroadcastConfig is not directly sent over wire, but instead read from inside subscribe. I believe you need to read that information inside the function to generate the config_payload correctly.

@o-santi just wrote a few tests to confirm this, and the config is properly sent over, no need for additional changes, can you review it again?

Copy link
Contributor

@o-santi o-santi left a comment

Choose a reason for hiding this comment

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

I see what is happening. replay is a subfield of broadcast, which is already read from inside subscribe, so it is sent normally by wire. Small nitpick on temp file but should be correct.

@@ -0,0 +1 @@
v2.47.2 No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this file is supposed to exist.

@o-santi o-santi changed the title feat: add support for broadcast replay configuration feat(realtime): add support for broadcast replay configuration Oct 3, 2025
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.

4 participants