Repository navigation
Keep connected on turbo-cable-stream-source through morph refreshes - #795
Merged
brunoprietog merged 2 commits intoNov 22, 2026
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change preserving the subscription-managed connected attribute during morph refreshes.
No open issues 🎉
What changed in this PR
Addresses #792 by preserving the subscription-managed connected attribute on turbo-cable-stream-source during morph refreshes, keeping Turbo’s system-test connection checks accurate.
Changes:
- Prevent morphing from changing the stream source’s own
connectedattribute. - Enable morph refreshes on the dummy message page and add a regression test.
- Update the checked-in JavaScript bundles with the fix.
| File | Description |
|---|---|
test/system/broadcasts_test.rb |
Tests that a stream source remains marked connected after a broadcast morph refresh. |
test/dummy/app/views/messages/show.html.erb |
Enables morph refreshes for the test page. |
app/javascript/turbo/cable_stream_source_element.js |
Cancels morph attribute changes targeting its own connected attribute. |
app/assets/javascripts/turbo.min.js |
Includes the fix in the minified bundle. |
app/assets/javascripts/turbo.js |
Includes the fix in the unminified bundle. |
Review effort: Balanced
brunoprietog
approved these changes
Nov 22, 2026
brunoprietog
left a comment
Contributor
There was a problem hiding this comment.
Thanks @lucidstack!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #792
TurboCableStreamSourceElementsetsconnectedon itself once its subscription is up, so the server-renderedturbo_stream_fromtag never includes it. When a page refreshes withmethod: :morph, idiomorph syncs the element's attributes with the new HTML and removesconnected— even though the subscription is still live. That makesconnect_turbo_cable_stream_sourcesand theconnected: trueselector inTurbo::SystemTestHelperwait on (or fail for) a stream that's working just fine.The element now cancels
turbo:before-morph-attributefor its ownconnectedattribute, so it keeps reflecting the subscription's state. The new system test morph-refreshes a message page withbroadcast_refreshand checks the stream source is stillconnectedafterwards; it fails without the change 👍PS: I've included the rebuilt
app/assets/javascriptsfiles, as CI checks they're checked in.