Skip to content

chore: rename generated layout hello_world → react_on_rails_default#2482

Open
ihabadham wants to merge 7 commits intomasterfrom
ihabadham/chore/layout-naming-cleanup
Open

chore: rename generated layout hello_world → react_on_rails_default#2482
ihabadham wants to merge 7 commits intomasterfrom
ihabadham/chore/layout-naming-cleanup

Conversation

@ihabadham
Copy link
Collaborator

@ihabadham ihabadham commented Feb 23, 2026

Summary

  • Rename the generator layout template from hello_world.html.erb to react_on_rails_default.html.erb
  • Update both controller templates (HelloWorldController, HelloServerController) to declare layout "react_on_rails_default"
  • Update base_generator.rb comment and file path string
  • Update generator specs and the rsc_hello_server_controller shared example
  • Rename the layout in react_on_rails_pro/spec/execjs-compatible-dummy
  • Add CHANGELOG entry

The layout's only purpose is to provide empty javascript_pack_tag / stylesheet_pack_tag calls for React on Rails auto-registration. It has no connection to the HelloWorld demo — and in RSC-only installs (--rsc without --redux), no HelloWorld controller is generated at all, making the name actively confusing.

Only affects newly generated apps. Existing apps are unchanged.

Notes

Test Plan

  • CI passes (generator specs, RuboCop)
  • assert_file "app/views/layouts/react_on_rails_default.html.erb" passes in all four RSC contexts
  • Both controller templates declare layout "react_on_rails_default"

Summary by CodeRabbit

  • Bug Fixes

    • Resolved errors during fresh React Server Components installs so generated apps build and register assets correctly; post-install messaging improved.
  • Changed

    • Renamed default layout used for newly generated apps to a neutral default.
    • Simplified server-side rendering setup in generated RSC views by relying on the default prerender behavior.

stream_react_component unconditionally forces prerender internally and
ignores any caller-supplied value. The template was passing prerender: true
with a comment claiming it "enables server-side rendering with streaming",
which is false — streaming is always enabled regardless.

Remove the redundant option and correct the comment. Also strengthen the
install generator spec to assert the generated view does not include
prerender: true.
generator_messages.rb had an inline if/else for render_label while the
adjacent render_example already delegated to a private build_render_example
method. Extract to build_render_label for consistency.

The three --rsc --redux/--typescript/--rspack contexts each had an identical
inline it block asserting HelloServerController content. Replace all four
(including the base --rsc context) with a shared example that also covers
the hello_server view, giving the combination contexts view coverage for free.
…or templates

The layout's purpose is to provide empty pack tags for React on Rails
auto-registration — it has no semantic connection to the HelloWorld demo.
In RSC-only installs, HelloServerController uses it with no HelloWorld
controller in sight, making the name confusing.

Rename the generator template file and update both controller templates
and base_generator.rb to reference react_on_rails_default.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 23, 2026

Walkthrough

Renames the generator layout from hello_world.html.erb to react_on_rails_default.html.erb, updates generated controllers and RSC wiring to use that layout, removes an explicit prerender: true in the RSC view, and consolidates generator tests using shared examples for HelloServer behavior.

Changes

Cohort / File(s) Summary
Generator base & changelog
CHANGELOG.md, react_on_rails/lib/generators/react_on_rails/base_generator.rb
Copy default layout now app/views/layouts/react_on_rails_default.html.erb instead of hello_world.html.erb; changelog documents the layout rename and RSC wiring fix.
Controller templates (generators & dummy app)
react_on_rails/lib/generators/react_on_rails/templates/base/.../app/controllers/hello_world_controller.rb, react_on_rails/lib/generators/react_on_rails/templates/rsc/base/.../app/controllers/hello_server_controller.rb, react_on_rails_pro/spec/execjs-compatible-dummy/app/controllers/hello_world_controller.rb
Updated generated controller templates and dummy app controller to declare layout "react_on_rails_default" (replacing "hello_world").
RSC view template
react_on_rails/lib/generators/react_on_rails/templates/rsc/base/app/views/hello_server/index.html.erb
Removed explicit prerender: true from stream_react_component invocation; relies on default prerender behavior.
Generator messages
react_on_rails/lib/generators/react_on_rails/generator_messages.rb
Added build_render_label(route:, rsc:) to centralize render-label construction; refactored after-install message to use it.
Tests & shared examples
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb, react_on_rails/spec/react_on_rails/support/shared_examples/rsc_generator_examples.rb, react_on_rails/spec/react_on_rails/support/shared_examples/base_generator_examples.rb
Replaced isolated HelloServer/HelloWorld assertions with shared_examples (rsc_hello_server_controller); updated expectations to reference the new layout filename and consolidated test coverage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I hopped through templates, tidy and neat,

Swapped names so generated pages meet,
RSC streams now find their place,
Tests grouped snug in shared-example space,
Tiny changes, a rabbit's cheerful beat.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: renaming the generated layout template from hello_world to react_on_rails_default across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ihabadham/chore/layout-naming-cleanup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link

greptile-apps bot commented Feb 23, 2026

Greptile Summary

Renamed the generator layout from hello_world.html.erb to react_on_rails_default.html.erb to better reflect its purpose. The layout provides empty javascript_pack_tag and stylesheet_pack_tag calls for React on Rails auto-registration and has no connection to the HelloWorld demo component.

Key changes:

  • Layout file renamed in generator templates
  • Both HelloWorldController and HelloServerController now declare layout "react_on_rails_default"
  • Generator specs updated to assert new layout filename
  • Specs deduplicated by extracting shared example rsc_hello_server_controller
  • Dummy fixture in execjs-compatible-dummy updated for consistency
  • Removed outdated prerender: true parameter from stream_react_component call in RSC view template

Issue found:

  • CHANGELOG.md line 36 still references old hello_world naming in the PR 2429 entry, should be updated to react_on_rails_default

Confidence Score: 4/5

  • Safe to merge with one minor CHANGELOG inconsistency to fix
  • The PR is a well-executed rename that consistently updates all references across generator templates, controllers, specs, and dummy fixtures. The code changes are straightforward and mechanical. The test deduplication using shared examples improves maintainability. Score is 4 instead of 5 due to the CHANGELOG inconsistency where PR 2429's entry still references the old hello_world naming that this PR is replacing.
  • CHANGELOG.md line 36 needs updating to reflect the new layout name

Important Files Changed

Filename Overview
CHANGELOG.md Added clear changelog entry documenting the layout rename from hello_world.html.erb to react_on_rails_default.html.erb
react_on_rails/lib/generators/react_on_rails/templates/base/base/app/controllers/hello_world_controller.rb Changed layout declaration from hello_world to react_on_rails_default
react_on_rails/lib/generators/react_on_rails/templates/rsc/base/app/controllers/hello_server_controller.rb Changed layout declaration from hello_world to react_on_rails_default
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb Updated specs to check for react_on_rails_default.html.erb and deduplicated RSC controller tests using shared example
react_on_rails/spec/react_on_rails/support/shared_examples/rsc_generator_examples.rb Created new shared example for HelloServerController specs that check for react_on_rails_default layout

Last reviewed commit: ede7f4f

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

11 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@claude
Copy link

claude bot commented Feb 23, 2026

Code Review

Overall this is a well-scoped rename with a clear rationale. The rename is applied consistently across generator templates, spec files, and the execjs-compatible-dummy fixture. A few observations:

Bundled unrelated changes

The PR title says "rename layout", but three additional concerns are folded in:

  1. fix: remove no-op prerender: true from RSC template view – correct fix, clearly committed separately, but it makes this PR do two different things. Worth calling out in the PR description (it is in the commit log but not in the Summary bullets).
  2. chore: extract build_render_label`` – pure refactor, unrelated to the rename. Fine on its own, but adds review surface area.
  3. Deduplication via include_examples "rsc_hello_server_controller" – good cleanup, but again separate concern.

None of these are blockers; they're all improvements. Just flagging for awareness.

Test coverage gaps

Non-RSC layout file not asserted. The four contexts that assert_file "app/views/layouts/react_on_rails_default.html.erb" are all --rsc contexts. For a plain rails g react_on_rails:install (no --rsc), neither base_generator_common nor any other shared example asserts that the layout file is generated. This pre-existed before this PR, but the rename is a natural point to close the gap and would guard against a regression in the non-RSC path.

react_on_rails_default layout not asserted in non-RSC controller. Similarly, the hello_world_controller.rb template now declares layout "react_on_rails_default", but there is no generator spec that verifies the generated controller contains that line for a non-RSC install.

Minor nit: CHANGELOG ordering

The new "Changed" section is placed before the existing "Fixed" section, which matches the conventional Keep-a-Changelog order (Added → Changed → Fixed). That's correct. One small wording suggestion: the entry references both the layout rename and the prerender: true fix (implicit via the template change), but the prerender: true fix isn't mentioned in the CHANGELOG at all. If it's intentional, that's fine; if it's an observable behaviour change for RSC demo apps, it might deserve a line.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Line 36: Update the Unreleased changelog entry for PR `#2429` to reflect the
rename from hello_world to react_on_rails_default introduced in PR `#2482`:
replace references to hello_world.html.erb and layout "hello_world" with
react_on_rails_default (e.g., the generator now always copies
react_on_rails_default.html.erb and HelloServerController uses layout
"react_on_rails_default") and ensure the sentence about post-install output
still mentioning stream_react_component is preserved or adjusted as needed to
match the final behavior.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b088857 and ede7f4f.

📒 Files selected for processing (11)
  • CHANGELOG.md
  • react_on_rails/lib/generators/react_on_rails/base_generator.rb
  • react_on_rails/lib/generators/react_on_rails/generator_messages.rb
  • react_on_rails/lib/generators/react_on_rails/templates/base/base/app/controllers/hello_world_controller.rb
  • react_on_rails/lib/generators/react_on_rails/templates/base/base/app/views/layouts/react_on_rails_default.html.erb
  • react_on_rails/lib/generators/react_on_rails/templates/rsc/base/app/controllers/hello_server_controller.rb
  • react_on_rails/lib/generators/react_on_rails/templates/rsc/base/app/views/hello_server/index.html.erb
  • react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb
  • react_on_rails/spec/react_on_rails/support/shared_examples/rsc_generator_examples.rb
  • react_on_rails_pro/spec/execjs-compatible-dummy/app/controllers/hello_world_controller.rb
  • react_on_rails_pro/spec/execjs-compatible-dummy/app/views/layouts/react_on_rails_default.html.erb

…or specs

- Update PR 2429 Fixed entry in CHANGELOG to reference react_on_rails_default
  instead of hello_world (both PRs ship in the same release)
- Add app/views/layouts/react_on_rails_default.html.erb to base_generator_common
  "copies common files" assertion (covers all non-RSC flag combinations)
- Add "creates HelloWorld controller with react_on_rails_default layout" it block
  to base_generator_common to assert the layout declaration in the generated
  controller

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@claude
Copy link

claude bot commented Feb 23, 2026

Code Review

This is a clean, well-executed rename. The change is correctly scoped and the implementation is consistent across all relevant files.

Correctness

prerender: true removal is correct. The explicit option was always redundant — stream_react_component internally forces options[:prerender] = true unconditionally (see react_on_rails_pro/app/helpers/react_on_rails_pro_helper.rb:129). Removing it from the template and the associated comment prevents developer confusion about whether the option does anything.

All layout references are updated. No stray layout "hello_world" declarations remain anywhere in the codebase. Both controller templates, the pro execjs-compatible-dummy fixture, and base_generator.rb are all consistently updated.

CHANGELOG is correct. The PR 2429 entry was also updated to use the new name — the greptile bot's comment about a CHANGELOG inconsistency is incorrect.

Test Quality

The refactoring to shared_examples "rsc_hello_server_controller" is a good improvement — the same four RSC generator contexts were each duplicating an inline it block. The removed let(:expected) in the helpful-message context is safe; those tests were rewritten to use flexible matching.

The new rsc_generator_examples.rb verifies that the controller declares the new layout and the view contains stream_react_component. One minor addition worth considering: an expect(content).not_to include('prerender: true') assertion in the view example would guard against the option being re-introduced accidentally. Low priority since the template is simple, but it would document the intentional removal.

No Issues Found

  • No security or performance concerns — this is purely a generator/template rename.
  • No existing-app breakage: the layout is only generated into fresh apps.
  • react_on_rails_default is a clear, descriptive name that correctly signals the layout belongs to React on Rails infrastructure rather than demo code.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
react_on_rails/spec/react_on_rails/support/shared_examples/base_generator_examples.rb (1)

22-26: Make the layout assertion tolerant to quote style.

This test will fail if the template uses single quotes or slightly different spacing. A regex keeps the intent while reducing brittleness.

🔧 Suggested tweak
-    assert_file "app/controllers/hello_world_controller.rb" do |content|
-      expect(content).to include('layout "react_on_rails_default"')
-    end
+    assert_file "app/controllers/hello_world_controller.rb" do |content|
+      expect(content).to match(/layout\s+["']react_on_rails_default["']/)
+    end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@react_on_rails/spec/react_on_rails/support/shared_examples/base_generator_examples.rb`
around lines 22 - 26, The assertion for the controller layout is brittle to
quote style and spacing; replace the literal include check inside the
assert_file block (the expect(content).to include('layout
"react_on_rails_default"') call) with a regex match that allows single or double
quotes and optional spacing, e.g. use expect(content).to
match(/layout\s+["']react_on_rails_default["']/) so the test accepts either
quote style and flexible whitespace.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@react_on_rails/spec/react_on_rails/support/shared_examples/base_generator_examples.rb`:
- Around line 22-26: The assertion for the controller layout is brittle to quote
style and spacing; replace the literal include check inside the assert_file
block (the expect(content).to include('layout "react_on_rails_default"') call)
with a regex match that allows single or double quotes and optional spacing,
e.g. use expect(content).to match(/layout\s+["']react_on_rails_default["']/) so
the test accepts either quote style and flexible whitespace.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ede7f4f and 7fb7859.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • react_on_rails/spec/react_on_rails/support/shared_examples/base_generator_examples.rb
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

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