Decode Action Cable broadcasts - #3
Merged
Merged
Conversation
Use Action Cable's documented JSON decoder for the custom stream callback so observable invalidations receive raw Turbo Stream HTML instead of encoded strings.
Package the Action Cable decoding fix as version 0.4.2 after validating the full suite and built gem.
Greptile SummaryThe PR fixes Action Cable delivery by decoding JSON-encoded broadcasts before observable invalidation processing and bumps the gem to version 0.4.2.
Confidence Score: 5/5The PR appears safe to merge with no actionable defects identified. The channel now decodes the JSON representation produced by Action Cable before applying existing invalidation parsing, and the regression covers both scalar updates and component refreshes across that boundary. Important Files Changed
Sequence DiagramsequenceDiagram
participant Adapter as Broadcast Adapter
participant AC as Action Cable
participant Channel as ActorChannel
participant Client as Subscriber
Adapter->>AC: broadcast Turbo Stream HTML
AC->>AC: JSON-encode payload
AC->>Channel: deliver encoded payload
Channel->>Channel: ActiveSupport::JSON.decode
Channel->>Channel: parse invalidation metadata
Channel->>Client: transmit raw Turbo Stream HTML
Reviews (1): Last reviewed commit: "chore: prepare 0.4.2 release" | Re-trigger Greptile |
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.
Summary
Root cause
ActionCable.server.broadcastJSON-encodes messages by default. Rails only applies its default JSON decoder whenstream_fromuses the built-in retransmitter; a custom callback defaults tocoder: nil.SolidObjects::ActorChannelneeds a custom callback for observable filtering and component invalidation, so it now follows Rails' documented callback pattern withcoder: ActiveSupport::JSON.Validation
bundle exec rake: 211 tests, 823 assertionsNo database migration is required.