Skip to content

Add --rsc flow to create-react-on-rails-app#2430

Merged
justin808 merged 26 commits intomasterfrom
codex/add-rsc-option-to-create-react-app
Mar 9, 2026
Merged

Add --rsc flow to create-react-on-rails-app#2430
justin808 merged 26 commits intomasterfrom
codex/add-rsc-option-to-create-react-app

Conversation

@justin808
Copy link
Copy Markdown
Member

@justin808 justin808 commented Feb 16, 2026

Summary

  • add --rsc CLI flag to create-react-on-rails-app
  • include --rsc in generated rails generate react_on_rails:install args
  • install react_on_rails_pro automatically when --rsc is selected
  • update success output to point users to /hello_server for RSC scaffolds
  • update docs for create-react-on-rails-app options and flow
  • add unit tests for generator arg building (including --rsc combinations)

Why

Current CLI scaffolding cannot generate RSC apps directly, even though the install generator supports --rsc. This forces manual steps and creates confusion in docs and onboarding.

Verification

  • mise exec node@22 -- corepack pnpm --filter create-react-on-rails-app test
  • mise exec node@22 -- corepack pnpm --filter create-react-on-rails-app type-check
  • mise exec node@22 -- corepack pnpm exec eslint packages/create-react-on-rails-app/src/create-app.ts packages/create-react-on-rails-app/src/index.ts packages/create-react-on-rails-app/src/types.ts

Summary by CodeRabbit

  • New Features
    • Added a CLI --rsc option to enable React Server Components setup, update post-install route to /hello_server, and support both JS (.jsx) and TS (.tsx) templates.
  • Documentation
    • Updated quick start, help text, examples, options table, and added an explicit RSC generation command and combined-option examples.
  • User Guidance
    • Added preflight checks and clearer actionable messages when required remote packages aren’t available.
  • Tests
    • Added tests covering generator argument combinations including the new RSC flag.
  • Chores
    • Updated changelog and minor formatting tweaks.

Note

Medium Risk
Moderate risk because it changes the scaffolding/install flow (adds a new gem install path and generator flags) and introduces a failure mode if Pro gem access is misconfigured.

Overview
Adds an --rsc mode to create-react-on-rails-app, passing --rsc through to rails generate react_on_rails:install, installing react_on_rails_pro when selected, and updating the success output to direct users to /hello_server (vs /hello_world).

Updates CLI help text, docs, and the changelog to document the new flag and flow, and adds unit tests around buildGeneratorArgs to cover flag combinations (including ordering).

Written by Cursor Bugbot for commit cad1f6b. Configure here.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 16, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds React Server Components (RSC) support to the create-react-on-rails-app CLI: new --rsc flag and rsc in CliOptions, exported buildGeneratorArgs to include --rsc, canResolveRemoteGem preflight check, conditional installation of react_on_rails_pro, updated success route to /hello_server, and docs/tests updates.

Changes

Cohort / File(s) Summary
Type Definition
packages/create-react-on-rails-app/src/types.ts
Add rsc: boolean to CliOptions.
CLI & Core Logic
packages/create-react-on-rails-app/src/index.ts, packages/create-react-on-rails-app/src/create-app.ts
Add --rsc CLI option and logging; export buildGeneratorArgs(options) to include --rsc when set; createApp performs a preflight canResolveRemoteGem check, conditionally adds react_on_rails_pro, adjusts gem-install step text, and prints /hello_server when RSC enabled.
Utilities
packages/create-react-on-rails-app/src/utils.ts
Add exported canResolveRemoteGem(gemName: string) which creates a temp Gemfile and runs bundle add <gem> --strict --skip-install to probe remote gem availability, cleaning up on completion.
Tests
packages/create-react-on-rails-app/tests/create-app.test.ts, packages/create-react-on-rails-app/tests/utils.test.ts
Export and test buildGeneratorArgs across combinations (default, typescript, rspack, rsc); add mocks and tests for canResolveRemoteGem success/failure and RSC-related createApp flows.
Docs & Changelog
docs/getting-started/create-react-on-rails-app.md, CHANGELOG.md
Document --rsc option, examples, options table and Quick Start updates; add Unreleased changelog entry referencing PR.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as "create-react-on-rails-app CLI"
    participant Args as "buildGeneratorArgs()"
    participant Creator as "createApp"
    participant Bundler as "Bundler / Gem installer"
    participant UX as "Success printer"

    User->>CLI: run generator with --rsc and app name
    CLI->>Args: buildGeneratorArgs(options with rsc=true)
    Args-->>CLI: return generator args (includes --rsc)
    CLI->>Creator: invoke createApp with args
    Creator->>Bundler: install react_on_rails
    alt rsc enabled
        Creator->>Bundler: canResolveRemoteGem("react_on_rails_pro")
        Bundler-->>Creator: available / not available
        Creator->>Bundler: install react_on_rails_pro
    end
    Bundler-->>Creator: installation complete
    Creator->>UX: print success with route "/hello_server"
    UX-->>User: display final instructions with /hello_server
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 I hopped through code with a careful swerve,
Added --rsc and gave the server a nerve.
Gems checked and ready, route now unfurled,
Hello Server greets the React world! ✨

🚥 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 'Add --rsc flow to create-react-on-rails-app' directly and clearly summarizes the main change: adding React Server Components (RSC) flow support to the create-react-on-rails-app CLI tool.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/add-rsc-option-to-create-react-app

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 16, 2026

size-limit report 📦

Path Size
react-on-rails/client bundled (gzip) 62.6 KB (0%)
react-on-rails/client bundled (gzip) (time) 62.6 KB (0%)
react-on-rails/client bundled (brotli) 53.65 KB (0%)
react-on-rails/client bundled (brotli) (time) 53.65 KB (0%)
react-on-rails-pro/client bundled (gzip) 63.6 KB (0%)
react-on-rails-pro/client bundled (gzip) (time) 63.6 KB (0%)
react-on-rails-pro/client bundled (brotli) 54.62 KB (0%)
react-on-rails-pro/client bundled (brotli) (time) 54.62 KB (0%)
registerServerComponent/client bundled (gzip) 127.37 KB (0%)
registerServerComponent/client bundled (gzip) (time) 127.37 KB (0%)
registerServerComponent/client bundled (brotli) 61.61 KB (0%)
registerServerComponent/client bundled (brotli) (time) 61.61 KB (0%)
wrapServerComponentRenderer/client bundled (gzip) 121.94 KB (0%)
wrapServerComponentRenderer/client bundled (gzip) (time) 121.94 KB (0%)
wrapServerComponentRenderer/client bundled (brotli) 56.65 KB (0%)
wrapServerComponentRenderer/client bundled (brotli) (time) 56.65 KB (0%)

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Feb 16, 2026

Greptile Summary

Adds --rsc flag to the create-react-on-rails-app CLI, enabling one-command scaffolding of React Server Components apps. When used, the CLI automatically installs both react_on_rails and react_on_rails_pro gems, passes --rsc to the Rails install generator, and directs users to /hello_server instead of /hello_world.

  • CLI flag: New --rsc option in Commander, correctly threaded through CliOptionsbuildGeneratorArgs → generator invocation
  • Gem installation: Adds react_on_rails_pro via bundle add --strict when --rsc is set (the install generator's use_pro? method already treats --rsc as implying Pro)
  • Tests: New buildGeneratorArgs test suite covers individual flags and combinations; buildGeneratorArgs was exported for testability
  • Docs: Updated with --rsc examples, option table, and "What It Does" section
  • Missing CHANGELOG entry: Per AGENTS.md, user-visible features should be added to CHANGELOG.md — this PR doesn't include one

Confidence Score: 4/5

  • This PR is safe to merge — it adds a well-scoped CLI flag that follows existing patterns, with no breaking changes to current behavior.
  • Score of 4 reflects clean implementation following the established --rspack pattern, good test coverage for the buildGeneratorArgs function, and correct integration with the underlying Rails generator. Deducted one point for the missing CHANGELOG entry and the minor error-handling ambiguity when react_on_rails_pro install fails separately from react_on_rails.
  • packages/create-react-on-rails-app/src/create-app.ts — the two-step gem installation in the same try/catch could produce a confusing error message on partial failure.

Important Files Changed

Filename Overview
packages/create-react-on-rails-app/src/types.ts Adds rsc: boolean field to CliOptions interface — straightforward, correct type addition.
packages/create-react-on-rails-app/src/create-app.ts Core RSC logic: adds --rsc to generator args, installs react_on_rails_pro gem, routes success message to /hello_server. Error handling for the two-step gem install is functional but could be more specific about which gem failed.
packages/create-react-on-rails-app/src/index.ts Adds --rsc CLI option via Commander, passes it through to CliOptions, and updates help text. Clean integration following the existing --rspack pattern.
packages/create-react-on-rails-app/tests/create-app.test.ts New buildGeneratorArgs tests cover all flag combinations (rsc alone, rsc+rspack+typescript). Good coverage for the exported function.
docs/getting-started/create-react-on-rails-app.md Documentation updates for --rsc option: adds examples, option table entry, "What It Does" section, and RSC route info. Accurate and consistent with code changes.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as create-react-on-rails-app
    participant Rails as rails new
    participant Bundler as bundle add
    participant Generator as rails g react_on_rails:install

    User->>CLI: npx create-react-on-rails-app my-app --rsc
    CLI->>CLI: Validate app name & prerequisites
    CLI->>Rails: rails new my-app --database=postgresql --skip-javascript
    Rails-->>CLI: Rails app created

    CLI->>Bundler: bundle add react_on_rails --strict
    Bundler-->>CLI: react_on_rails added

    Note over CLI,Bundler: --rsc triggers Pro gem install
    CLI->>Bundler: bundle add react_on_rails_pro --strict
    Bundler-->>CLI: react_on_rails_pro added

    CLI->>Generator: bundle exec rails generate react_on_rails:install --rsc --ignore-warnings
    Note over Generator: use_pro? returns true (rsc implies pro)
    Generator-->>CLI: Pro + RSC setup complete

    CLI-->>User: Visit http://localhost:3000/hello_server
Loading

Last reviewed commit: 104b4c5

Copy link
Copy Markdown

@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.

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread packages/create-react-on-rails-app/src/create-app.ts
Copy link
Copy Markdown
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

🤖 Fix all issues with AI agents
In `@packages/create-react-on-rails-app/src/create-app.ts`:
- Around line 87-89: When options.rsc is true, the code directly calls
execLiveArgs('bundle', ['add', 'react_on_rails_pro', '--strict'], appPath) which
will fail for users who don't have the private react_on_rails_pro source
configured; add a preflight validation before that call in create-app.ts that
attempts to resolve the gem (for example by running a probe command like `gem
list -r react_on_rails_pro` or `bundle info react_on_rails_pro` and checking its
exit code) and if the gem cannot be resolved, abort the add and emit a clear,
actionable error via your logger explaining the required prerequisites
(configure private gem server or add a git-based Gemfile entry) and how to
proceed; update the branch around the execLiveArgs call and the accompanying
logStepDone message to only run when validation succeeds.
🧹 Nitpick comments (1)
docs/getting-started/create-react-on-rails-app.md (1)

43-43: Nit: The --rsc option description is slightly self-referential.

"Generate RSC setup (--rsc install flow)" restates the flag name rather than explaining what it does. Consider something like "Enable React Server Components (requires react_on_rails_pro)" for clarity.

Suggested wording
-| `--rsc`                      | Generate RSC setup (`--rsc` install flow)   | `false`       |
+| `--rsc`                      | Enable React Server Components (requires `react_on_rails_pro`) | `false`       |

Comment thread packages/create-react-on-rails-app/src/create-app.ts Outdated
@justin808 justin808 force-pushed the codex/add-rsc-option-to-create-react-app branch from ff678f6 to cad1f6b Compare February 23, 2026 00:38
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Feb 23, 2026

Review: Add --rsc flow to create-react-on-rails-app

The PR is clean and well-structured. The approach is straightforward and the tests added for buildGeneratorArgs are solid. A few issues worth addressing before merge:

Issues

1. Partial app state on react_on_rails_pro failure (create-app.ts ~L95-106)

If bundle add react_on_rails_pro fails, the user is left with:

  • A created Rails app directory
  • react_on_rails already added to Gemfile
  • No react_on_rails_pro

The error message says 'or rerun without --rsc' but the validateAppName check will block this because the directory already exists. The user is effectively stuck. The error message should tell them to delete the directory first before retrying.

2. No preemptive warning about Pro gem access

The current flow only tells users about the Pro gem requirement when it fails. Since react_on_rails_pro is a commercial/private gem requiring configured gem source access, a brief upfront notice when --rsc is detected would improve UX significantly. Something like: "Note: --rsc requires access to the react_on_rails_pro private gem source."

3. Compatibility between --rsc and --rspack is untested and undocumented

Both flags can be passed together (create-react-on-rails-app my-app --rsc --rspack). If the react_on_rails:install generator supports this combination, it should be documented and tested. If not, it should be validated and rejected early with a clear error message.

4. Missing tests for the createApp gem-install path

The new tests cover buildGeneratorArgs well, but there are no tests verifying:

  • That react_on_rails_pro is installed when --rsc is passed to createApp
  • The logStepDone message variant when RSC is used
  • The hello_server route in the success message

5. Minor: Static help text inconsistency (index.ts L105)

The static addHelpText block still says:

After setup, run bin/dev and visit http://localhost:3000/hello_world
Use --rsc to generate the HelloServer route at http://localhost:3000/hello_server

This is technically accurate, but the first line will read as a general instruction and could mislead RSC users into expecting /hello_world to exist. Consider making it clearer that the route depends on the selected mode.

Summary

The core feature logic is correct. Items 1 and 2 are the most impactful for user experience — partial state on failure is confusing, and no upfront warning about a commercial dependency is a potential surprise. Items 3–5 are lower priority but worth addressing.

Comment thread packages/create-react-on-rails-app/src/create-app.ts Outdated
Comment thread packages/create-react-on-rails-app/src/create-app.ts
Comment thread packages/create-react-on-rails-app/src/index.ts
Comment thread packages/create-react-on-rails-app/tests/create-app.test.ts
Copy link
Copy Markdown
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)
packages/create-react-on-rails-app/tests/create-app.test.ts (1)

68-104: Consider adding a rspack + rsc (no TypeScript) combination test.

The existing suite covers each flag independently and all three together, but the rspack: true, rsc: true, template: 'javascript' pairing — a realistic user workflow — isn't explicitly exercised.

✅ Suggested additional test case
  it('combines all enabled flags in order', () => {
    expect(
      buildGeneratorArgs({
        ...baseOptions,
        template: 'typescript',
        rspack: true,
        rsc: true,
      }),
    ).toEqual(['--typescript', '--rspack', '--rsc', '--ignore-warnings']);
  });
+
+  it('combines rspack and rsc flags without typescript', () => {
+    expect(
+      buildGeneratorArgs({ ...baseOptions, rspack: true, rsc: true }),
+    ).toEqual(['--rspack', '--rsc', '--ignore-warnings']);
+  });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/create-react-on-rails-app/tests/create-app.test.ts` around lines 68
- 104, Add a new unit test in the create-app.test.ts suite for
buildGeneratorArgs that covers the rspack + rsc combination with a javascript
template (i.e., { ...baseOptions, rspack: true, rsc: true, template:
'javascript' }) and assert the returned array equals
['--rspack','--rsc','--ignore-warnings']; place it alongside the existing cases
so the ordering behavior is verified for this realistic flag pairing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/create-react-on-rails-app/tests/create-app.test.ts`:
- Around line 68-104: Add a new unit test in the create-app.test.ts suite for
buildGeneratorArgs that covers the rspack + rsc combination with a javascript
template (i.e., { ...baseOptions, rspack: true, rsc: true, template:
'javascript' }) and assert the returned array equals
['--rspack','--rsc','--ignore-warnings']; place it alongside the existing cases
so the ordering behavior is verified for this realistic flag pairing.

@justin808 justin808 added codex PRs created from codex-named branches release:16.4.0-must-have Must-have for 16.4.0: critical bug/perf/usability labels Feb 25, 2026
@justin808 justin808 force-pushed the codex/add-rsc-option-to-create-react-app branch from cad1f6b to 4ecb98a Compare March 5, 2026 03:25
@justin808
Copy link
Copy Markdown
Member Author

Addressed all review comments on this PR:

  • Added an upfront --rsc prerequisite notice and preflight gem resolution check before app creation.
  • Improved react_on_rails_pro failure guidance to explicitly tell users to delete the created app directory before retrying without --rsc.
  • Clarified CLI help output for route selection and added --rspack --rsc usage example.
  • Added tests for rspack + rsc generator args and new createApp behavior coverage (RSC success path, preflight failure path, and pro-gem-install failure messaging).
  • Rebased onto latest master and re-ran tests plus manual CLI scenario checks (success/failure paths).

Comment thread packages/create-react-on-rails-app/src/utils.ts Outdated
Comment thread packages/create-react-on-rails-app/src/utils.ts Outdated
Comment thread packages/create-react-on-rails-app/src/index.ts
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 5, 2026

PR Review summary — see inline comments for details and code suggestions.

Bug 1 (blocking): canResolveRemoteGem always returns false (utils.ts:27-32). gem list --remote --exact prints a header line before the gem listing. After .trim() neither the startsWith nor equality check matches the gem name, so the preflight always fails and --rsc is completely unusable. Fix: add the --quiet flag to the gem list call.

Bug 2 (blocking): gem and bundle use separate source registries (utils.ts:27). gem list --remote queries ~/.gemrc sources; bundle add uses Bundler config. Users with Bundler-based access to the private gem are rejected by the preflight even though bundle add would succeed.

Minor: --rsc combined with --template javascript is not validated (index.ts:33). RSC requires TypeScript but the CLI accepts this combination silently and fails inside the generator. An early guard or auto-upgrade prevents user confusion.

Positive notes: preflight before Rails app creation avoids a half-baked directory on auth failure; error messaging is helpful; the buildGeneratorArgs and createApp test suites are clean and cover the right scenarios.

Copy link
Copy Markdown
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)
docs/getting-started/create-react-on-rails-app.md (1)

16-38: Add package-manager-agnostic invocation examples for end-user docs.

The new command examples are npx-only. Please also show Yarn and pnpm equivalents (for example, yarn create / pnpm dlx) in Quick Start or Options examples for consistency across docs.

Based on learnings: In all end-user documentation under docs/, ensure package-manager-agnostic installation instructions include npm, yarn, and pnpm.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/getting-started/create-react-on-rails-app.md` around lines 16 - 38,
Update the example invocations for create-react-on-rails-app so they are
package-manager-agnostic: for every npx create-react-on-rails-app example
(including the RSC, --template javascript, --rspack, --package-manager pnpm, and
combined-flag examples) add the equivalent yarn and pnpm variants (yarn create
react-on-rails-app ... and pnpm dlx create-react-on-rails-app ...), and ensure
the “For React Server Components (RSC)” line mentions the three ways to run the
command (npm/npx, yarn, pnpm) so all Options examples consistently show npm,
yarn, and pnpm forms.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@docs/getting-started/create-react-on-rails-app.md`:
- Around line 16-38: Update the example invocations for
create-react-on-rails-app so they are package-manager-agnostic: for every npx
create-react-on-rails-app example (including the RSC, --template javascript,
--rspack, --package-manager pnpm, and combined-flag examples) add the equivalent
yarn and pnpm variants (yarn create react-on-rails-app ... and pnpm dlx
create-react-on-rails-app ...), and ensure the “For React Server Components
(RSC)” line mentions the three ways to run the command (npm/npx, yarn, pnpm) so
all Options examples consistently show npm, yarn, and pnpm forms.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a757ceb4-9ffc-4def-8f24-a4e77c3751d3

📥 Commits

Reviewing files that changed from the base of the PR and between cad1f6b and 4ecb98a.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • docs/getting-started/create-react-on-rails-app.md
  • packages/create-react-on-rails-app/src/create-app.ts
  • packages/create-react-on-rails-app/src/index.ts
  • packages/create-react-on-rails-app/src/types.ts
  • packages/create-react-on-rails-app/src/utils.ts
  • packages/create-react-on-rails-app/tests/create-app.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/create-react-on-rails-app/src/index.ts
  • packages/create-react-on-rails-app/src/types.ts

Comment thread packages/create-react-on-rails-app/src/utils.ts Outdated
Comment thread packages/create-react-on-rails-app/src/create-app.ts Outdated
Comment thread packages/create-react-on-rails-app/src/create-app.ts Outdated
Comment thread packages/create-react-on-rails-app/src/create-app.ts
Comment thread packages/create-react-on-rails-app/tests/create-app.test.ts
logStep(4, TOTAL_STEPS, 'Done!');
printSuccessMessage(appName);
// Final success
logStepDone('Done!');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Redundant logStepDone call

logStepDone('React on Rails setup complete') is printed on line 197 (inside the try block immediately after the generator finishes), and then logStepDone('Done!') fires here on line 213 unconditionally. The user sees two consecutive green-checkmark lines with no actionable distinction between them.

The original code had a dedicated logStep(4, 4, 'Done!') numbered step which felt intentional. If the intention is to keep a final marker, consider removing the inner logStepDone('React on Rails setup complete') from the try block and keeping only this one, or simply dropping logStepDone('Done!') entirely and letting printSuccessMessage serve as the completion signal.

Suggested change
logStepDone('Done!');
printSuccessMessage(appName, options.rsc ? 'hello_server' : 'hello_world');

@@ -60,11 +108,16 @@ export function validateAppName(name: string): { success: boolean; error?: strin

export function createApp(appName: string, options: CliOptions): void {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No preflight check before starting the multi-step process for --rsc

When --rsc is used, the user runs through the full rails new + bundle add react_on_rails sequence before hitting the react_on_rails_pro installation step (step 3). If Pro isn't accessible from their Bundler/RubyGems setup — a likely scenario for new users who haven't configured a private gem server — they waste time on the first two steps, then get a cleanup and error message.

An earlier version of this PR's walkthrough (per CodeRabbit) mentioned a canResolveRemoteGem preflight in utils.ts, but that check doesn't appear in the current diff. Adding a pre-flight probe (even a simple bundle info react_on_rails_pro --no-color / gem search react_on_rails_pro) before rails new would save users significant frustration on a bad --rsc setup.

If adding the probe is out of scope for this PR, a clear note in the --rsc info block (already shown in index.ts) linking to Pro access/configuration is the minimum, and that is already there — but the failure UX after two successful steps is still rough.

test -f "$APP_RSC_JS_DIR/app/javascript/src/HelloServer/components/HelloServer.jsx"
grep -q "stream_react_component('HelloServer'" "$APP_RSC_JS_DIR/app/views/hello_server/index.html.erb"

grep -q "gem \"react_on_rails_pro\"" "$APP_RSC_TS_DIR/Gemfile"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Smoke test assertions couple tightly to generator output paths

Lines like:

test -f "$APP_RSC_JS_DIR/app/javascript/src/HelloServer/components/HelloServer.jsx"
grep -q "stream_react_component('HelloServer'" "$APP_RSC_JS_DIR/app/views/hello_server/index.html.erb"

hard-code specific file paths and template content that come from the RSC generator (in react_on_rails_pro). If the generator renames files or changes the helper call, these assertions will fail without obvious cause.

Consider adding a brief comment explaining where these expected paths come from so maintainers know to update the smoke test when the generator changes:

# Expected files generated by react_on_rails:install --rsc (from react_on_rails_pro generator)
test -f "$APP_RSC_JS_DIR/app/javascript/src/HelloServer/components/HelloServer.jsx"

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 9, 2026

Review Summary

Overall this is a clean, well-structured addition. The step counter logic is clear, error paths all clean up the app directory, unit tests are thorough, and the smoke test script is a nice contribution for local development. A few things worth addressing:

Issue 1 - No preflight check for react_on_rails_pro availability
With --rsc, the user completes rails new and bundle add react_on_rails before discovering Pro is not accessible. An early probe before step 1 would save time on misconfigured setups. An earlier iteration apparently had a canResolveRemoteGem helper in utils.ts worth revisiting. See inline comment at createApp line 109.

Issue 2 - react_on_rails_pro installed without --strict (undocumented intent)
bundleAddArgs with strict=false means no version constraint is passed when no local path is configured. If intentional (Pro may come from a private Gemserver), a one-line code comment would prevent future confusion. See inline comment at line 166.

Issue 3 - Double logStepDone after generator completes
logStepDone fires twice in a row after the generator succeeds: inside the try block then unconditionally on line 213. Two consecutive green checkmarks with no distinction. One should be removed. See inline comment at line 213.

Minor - Smoke test assertions tightly coupled to generator output
Checks like test -f .../HelloServer.jsx depend on react_on_rails_pro generator paths. A brief comment noting this would help maintainers know to update the smoke test when the generator changes.

What is good

  • Unit tests cover all new branches: RSC path, cleanup on each failure point, local gem path env vars, missing path early-exit.
  • The cleanupAppDirectory helper avoids duplicate cleanup logic across four failure points.
  • Smoke test covering JS, TS, and Rspack+RSC combinations is a valuable addition.
  • shakapacker_gem_version_from_lockfile regex fix correctly prefers GEM specs section over DEPENDENCIES constraints.

@justin808 justin808 merged commit 95401ba into master Mar 9, 2026
55 checks passed
@justin808 justin808 deleted the codex/add-rsc-option-to-create-react-app branch March 9, 2026 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex PRs created from codex-named branches enhancement full-ci release:16.4.0-must-have Must-have for 16.4.0: critical bug/perf/usability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant