Skip to content

fix(message): render messages/_message partial in broadcasts#143

Merged
newstler merged 1 commit intomainfrom
fix/user-partial
Apr 14, 2026
Merged

fix(message): render messages/_message partial in broadcasts#143
newstler merged 1 commit intomainfrom
fix/user-partial

Conversation

@newstler
Copy link
Copy Markdown
Owner

Summary

  • Fixes a production ActionView::MissingTemplate: Missing partial messages/_user error that started after the ruby_llm bump from 1.11.0 → 1.14.1 in Bump anthropic from 1.6.0 to 1.10.0 #102.
  • Pins the broadcasts_to partial to messages/message so turbo-rails stops falling back to RubyLLM's role-based to_partial_path.

Root cause

ruby_llm 1.14.1 introduced a to_partial_path override in RubyLLM::ActiveRecord::MessageMethods that returns "messages/<role>" (user/assistant/system/tool). The app's Message#broadcasts_to had no explicit partial:, so turbo-rails used to_partial_path and looked up non-existent partials like messages/_user.html.erb. The app has a single role-aware _message.html.erb.

Every message save — real chats and system chats (summaries, testimonials, translations) — crashed Turbo::Streams::ActionBroadcastJob. The underlying saves succeeded, but Turbo Stream subscribers never received updates, silently breaking live chat UI refresh for real users.

Test plan

  • Added MessageTest#test_broadcasts_create_using_messages/message_partial_regardless_of_role — saves a Message with each role (user/assistant/system/tool) and asserts the enqueued broadcast job renders without raising. Confirmed it reproduces the production error against the unfixed code.
  • rails test test/models/ — all 191 tests pass.
  • rubocop clean.
  • brakeman clean.

🤖 Generated with Claude Code

RubyLLM 1.14.1 added a `to_partial_path` override returning
"messages/<role>" (user/assistant/system/tool). With the bump from
1.11.0 in #102, turbo-rails' `broadcasts_to` stopped finding a partial
because the app only has a single role-aware `_message.html.erb`. Every
message save crashed Turbo::Streams::ActionBroadcastJob with
ActionView::MissingTemplate, silently breaking live chat UI updates for
subscribers (real chats, summaries, testimonials, translations).

Pin the broadcast partial explicitly. Added a regression test that
saves a Message with every role and asserts the enqueued broadcast job
renders cleanly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@newstler newstler merged commit 2843e81 into main Apr 14, 2026
5 checks passed
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.

1 participant