Skip to content

Fix Rust Chat App Tutorial not showing messages of other users live#4588

Open
OMGeeky wants to merge 3 commits intoclockworklabs:masterfrom
OMGeeky:patch-1
Open

Fix Rust Chat App Tutorial not showing messages of other users live#4588
OMGeeky wants to merge 3 commits intoclockworklabs:masterfrom
OMGeeky:patch-1

Conversation

@OMGeeky
Copy link

@OMGeeky OMGeeky commented Mar 8, 2026

Description of Changes

This fixes an Issue in the Rust Chat App Tutorial, that is caused by the Event Type Changes in 2.0

This resulted in other clients not receiving new messages, since they are now Event::Transaction and no longer included within the Event::Reducer

API and ABI breaking changes

I don't think any? I only changed a tutorial, the real change was in 2.0

Expected complexity level and risk

1

Testing

  • I ran the Tutorial app with these changes and messages started to appear as expected on the second client when writing something on the first.

There might be more places where this is an Issue, I just noticed this one while following the Tutorial.

Signed-off-by: Frederik <39029799+OMGeeky@users.noreply.github.com>
@CLAassistant
Copy link

CLAassistant commented Mar 8, 2026

CLA assistant check
All committers have signed the CLA.

Signed-off-by: Frederik <39029799+OMGeeky@users.noreply.github.com>
Copy link
Contributor

@gefjon gefjon left a comment

Choose a reason for hiding this comment

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

D'oh! I fixed this in the template (templates/chat-console-rs/src/main.rs), but forgot to update the tutorial.

In the template I used !matches!(ctx.event, Event::SubscribeApplied). Do you think that's more or less clear than your matches!(ctx.event, Event::Reducer(_) | Event::Transaction)? Personally I think excluding SubscribeApplied makes more sense than including the other two, but the !matches! looks pretty gnarly in Rust syntax.

@gefjon gefjon added documentation Improvements or additions to documentation docs deploy ASAP Important docs changes that should be deployed immediately. bugfix Fixes something that was expected to work differently labels Mar 10, 2026
@OMGeeky
Copy link
Author

OMGeeky commented Mar 10, 2026

D'oh! I fixed this in the template (templates/chat-console-rs/src/main.rs), but forgot to update the tutorial.

In the template I used !matches!(ctx.event, Event::SubscribeApplied). Do you think that's more or less clear than your matches!(ctx.event, Event::Reducer(_) | Event::Transaction)? Personally I think excluding SubscribeApplied makes more sense than including the other two, but the !matches! looks pretty gnarly in Rust syntax.

I'm relatively new to to spacetime-db but in my opinion I think it should be the explicit inclusion of Reducer and Transaction instead of exclusion of SubscribeApplied. The reason for that is that there are other variants like UnsubscribeApplied, Disconnected or SubscribeError and even if all of those are checked, the enum is maked as non_exhaustive so new variants might be added at any moment.
Also considering that we only want something to be printed here, if it is a new message and not other things, this callback should only care about printing new messages, no other info like SubscribeError etc. so we should filter for those explicitly in my opinion.

And yeah, !matches! looks pretty bad in Rust. I'd rather not invert and have an early return if we were to go that route instead

@gefjon
Copy link
Contributor

gefjon commented Mar 10, 2026

I'm relatively new to to spacetime-db but in my opinion I think it should be the explicit inclusion of Reducer and Transaction instead of exclusion of SubscribeApplied. The reason for that is that there are other variants like UnsubscribeApplied, Disconnected or SubscribeError and even if all of those are checked, the enum is maked as non_exhaustive so new variants might be added at any moment. Also considering that we only want something to be printed here, if it is a new message and not other things, this callback should only care about printing new messages, no other info like SubscribeError etc. so we should filter for those explicitly in my opinion.

And yeah, !matches! looks pretty bad in Rust. I'd rather not invert and have an early return if we were to go that route instead

This all works for me. Could you update the template code in templates/chat-console-rs/src/main.rs to do the same thing as you've done in the tutorial?

Signed-off-by: Frederik <39029799+OMGeeky@users.noreply.github.com>
@gefjon gefjon enabled auto-merge March 10, 2026 17:13
@OMGeeky
Copy link
Author

OMGeeky commented Mar 10, 2026

Thanks for the quick approval @gefjon. Anything I need to do about the one failing CI-Check?

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

Labels

bugfix Fixes something that was expected to work differently docs deploy ASAP Important docs changes that should be deployed immediately. documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants