feat: add REACT_ON_RAILS_BASE_PORT for concurrent worktree port management#3142
feat: add REACT_ON_RAILS_BASE_PORT for concurrent worktree port management#3142
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds deterministic base-port support via Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as bin/dev
participant PS as ReactOnRails::Dev::PortSelector
participant SM as ReactOnRails::Dev::ServerManager
participant Svc as Services (Rails, Webpack, Node-Renderer)
Dev->>PS: select_ports()
alt REACT_ON_RAILS_BASE_PORT detected
PS->>PS: validate base_port (1..MAX_BASE_PORT)
PS->>PS: derive rails=base+0, webpack=base+1, renderer=base+2
PS-->>Dev: {rails, webpack, renderer}
else CONDUCTOR_PORT detected
PS->>PS: parse conductor as base
PS->>PS: derive rails=base+0, webpack=base+1, renderer=base+2
PS-->>Dev: {rails, webpack, renderer}
else
PS->>PS: use explicit envs or probe free ports
PS-->>Dev: {rails, webpack, nil}
end
Dev->>SM: configure_ports(selected)
alt selected.renderer present
SM->>SM: set ENV["PORT"], ENV["SHAKAPACKER_DEV_SERVER_PORT"] (overwrite)
SM->>SM: set ENV["RENDERER_PORT"], ENV["REACT_RENDERER_URL"]
SM-->>Svc: processes inherit envs
else
SM->>SM: apply explicit/env-default PORT and dev-server using ||=
SM->>SM: set REACT_RENDERER_URL only if RENDERER_PORT present and URL unset
SM-->>Svc: processes inherit envs (no renderer)
end
Svc->>Svc: bind services to assigned ports
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Code ReviewOverviewThis PR adds a What Works Well
IssuesBug (medium) — derived ports can overflow 65535. Misleading log when Minor — Nice-to-have — Test Coverage GapThere's no test for the scenario where DocsThe new process-managers.md section and SummaryThe approach is sound and the feature is useful. The port-overflow bug is the one concrete correctness issue to fix before merging. The log/priority conflict is worth at least a decision: either document that base port always wins (and change 🤖 Generated with Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37a9ae17d4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Greptile SummaryAdds Prior review concerns — derived renderer port exceeding 65535 and test-environment isolation — have been addressed. Two minor points remain:
Confidence Score: 5/5Safe to merge — no blocking issues; remaining findings are minor UX/edge-case P2s. Previous P0/P1 concerns (renderer port > 65535, test env isolation) have been fully addressed. The two remaining issues are P2: a missing warning for out-of-range base ports (silent fallback is safe) and a false-negative in the port-prefix substring check (only affects the warning, not actual behavior). Test coverage is thorough and the core port-selection logic is correct. react_on_rails/lib/react_on_rails/dev/port_selector.rb and react_on_rails/lib/react_on_rails/dev/server_manager.rb have the minor findings noted above. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([bin/dev start]) --> B{REACT_ON_RAILS_BASE_PORT or CONDUCTOR_PORT set?}
B -->|Yes - first valid var wins| C[base_port returns Integer]
C --> D[select_ports: derive rails=base+0, webpack=base+1, renderer=base+2]
D --> E[apply_base_port_env: unconditionally set PORT, SHAKAPACKER_DEV_SERVER_PORT, RENDERER_PORT, REACT_RENDERER_URL]
B -->|No| F{PORT or SHAKAPACKER_DEV_SERVER_PORT set?}
F -->|Yes| G[Use explicit per-service vars]
F -->|No| H[Auto-detect free ports starting from defaults]
G --> I[apply_explicit_port_env: PORT and WEBPACK assigned conditionally]
H --> I
I --> J{RENDERER_PORT set?}
J -->|No| K([Done - renderer not configured])
J -->|Yes| L{REACT_RENDERER_URL set?}
L -->|No| M[Derive URL from RENDERER_PORT]
L -->|Yes - port matches| N([Done - consistent])
L -->|Yes - port mismatch| O[Warn: vars disagree]
E --> P([ENV_KEYS_TO_PRESERVE propagated to spawned process manager])
M --> P
N --> P
O --> P
Reviews (3): Last reviewed commit: "fix: second round of port selector revie..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@react_on_rails/lib/react_on_rails/dev/port_selector.rb`:
- Around line 98-102: The base_port method currently allows ENV values up to
65_535 but then derives additional ports as base+1 and base+2; update the
validation in base_port (and any use of BASE_PORT_ENV_VARS) to ensure the chosen
base plus the highest offset (2) stays ≤ 65_535 (i.e., accept bases in the range
1..65_533), so change the conditional that returns val to check val between 1
and (65_535 - 2) and reject/skip values outside that safe range.
In `@react_on_rails/lib/react_on_rails/dev/server_manager.rb`:
- Around line 842-845: The current code may set ENV["REACT_RENDERER_URL"] using
selected[:renderer] even when an existing ENV["RENDERER_PORT"] was preserved;
update the logic so REACT_RENDERER_URL is constructed from the effective port
value (the ENV["RENDERER_PORT"] after the ||= assignment) rather than from
selected[:renderer]; locate the block that references selected[:renderer] in
server_manager.rb (the if selected[:renderer] branch) and change the URL
construction to use ENV["RENDERER_PORT"] (or a local port variable assigned from
ENV["RENDERER_PORT"]) so the URL always matches the actual RENDERER_PORT in use.
In `@react_on_rails/spec/react_on_rails/dev/port_selector_spec.rb`:
- Around line 10-15: Wrap each around hook's example.run in a begin...ensure so
ENV cleanup always runs (e.g., change the around do |example| block that sets
ENV["REACT_ON_RAILS_BASE_PORT"] to use begin; example.run; ensure ... end), and
in the "CONDUCTOR_PORT only" and "out-of-range base port" contexts explicitly
unset or restore both ENV["REACT_ON_RAILS_BASE_PORT"] and ENV["CONDUCTOR_PORT"]
(capture old values, set the test values, run example, then in ensure restore
originals or delete the keys when nil) so base_port's lookup order cannot be
influenced by ambient env vars.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e7ac5b86-7952-413d-89b3-278d22119277
📒 Files selected for processing (17)
docs/oss/building-features/process-managers.mdreact_on_rails/lib/generators/react_on_rails/pro_setup.rbreact_on_rails/lib/generators/react_on_rails/templates/base/base/.env.examplereact_on_rails/lib/react_on_rails/dev/port_selector.rbreact_on_rails/lib/react_on_rails/dev/server_manager.rbreact_on_rails/spec/dummy/Procfile.devreact_on_rails/spec/dummy/Procfile.dev-prod-assetsreact_on_rails/spec/dummy/Procfile.dev-static-assetsreact_on_rails/spec/dummy/Procfile.dev.no.turbolinksreact_on_rails/spec/react_on_rails/dev/port_selector_spec.rbreact_on_rails/spec/react_on_rails/generators/install_generator_spec.rbreact_on_rails/spec/react_on_rails/support/shared_examples/pro_generator_examples.rbreact_on_rails_pro/spec/dummy/Procfile.devreact_on_rails_pro/spec/dummy/Procfile.prodreact_on_rails_pro/spec/dummy/Procfile.staticreact_on_rails_pro/spec/execjs-compatible-dummy/Procfile.devreact_on_rails_pro/spec/execjs-compatible-dummy/Procfile.dev-static
## Summary - Applies `prettier --write` to five tracked docs files that are currently out of compliance on `main`. - No content changes — only whitespace/table-alignment fixes produced by Prettier. ## Why this is needed The formatting drift landed via a docs-only merge to `main`. The `lint-js-and-ruby.yml` workflow is conditionally skipped for docs-only commits on `main` (see the job condition at [`.github/workflows/lint-js-and-ruby.yml:79-87`](https://github.com/shakacode/react_on_rails/blob/main/.github/workflows/lint-js-and-ruby.yml#L79-L87)), so the check never ran on merge. It surfaces on every subsequent code-touching PR because the lint job runs for those (e.g. [#3151](#3151), [#3148](#3148), [#3142](#3142), [#3097](#3097)). Merging this unblocks the `build` → `Check formatting` step on those PRs. ## Test plan - [x] `pnpm start format.listDifferent` passes for the five files - [x] Diff is purely whitespace — no link targets, code blocks, or prose changed 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Improved formatting across API reference, core concepts, migration, and RSC docs: refined table layouts, adjusted column alignment, and standardized emphasis for clearer warnings. * Updated link text and phrasing for several guides for clearer navigation. * Reformatted code examples and JSX/Route snippets for more compact, consistent presentation and improved readability. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
4216467 to
8da5a8a
Compare
Code ReviewOverall this is a clean, well-motivated feature. The implementation is straightforward and the test coverage is solid. I found a few issues worth addressing before merge. Bug: base-port priority not enforced in
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8da5a8a004
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
♻️ Duplicate comments (2)
react_on_rails/lib/react_on_rails/dev/server_manager.rb (1)
836-843:⚠️ Potential issue | 🟠 MajorApply selected ports as the effective env values.
PortSelectornow gives the base port higher priority, but||=lets pre-existingPORT/SHAKAPACKER_DEV_SERVER_PORT/RENDERER_PORToverride that selection before child processes start. This can makeREACT_ON_RAILS_BASE_PORT=4000still boot on stale per-service ports, and it also preserves the previously flagged renderer URL drift.🐛 Proposed fix
def configure_ports selected = PortSelector.select_ports - ENV["PORT"] ||= selected[:rails].to_s - ENV["SHAKAPACKER_DEV_SERVER_PORT"] ||= selected[:webpack].to_s + ENV["PORT"] = selected[:rails].to_s + ENV["SHAKAPACKER_DEV_SERVER_PORT"] = selected[:webpack].to_s if selected[:renderer] - ENV["RENDERER_PORT"] ||= selected[:renderer].to_s - ENV["REACT_RENDERER_URL"] ||= "http://localhost:#{selected[:renderer]}" + ENV["RENDERER_PORT"] = selected[:renderer].to_s + ENV["REACT_RENDERER_URL"] ||= "http://localhost:#{ENV['RENDERER_PORT']}" end rescue PortSelector::NoPortAvailable => e🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@react_on_rails/lib/react_on_rails/dev/server_manager.rb` around lines 836 - 843, The configure_ports method currently uses ||= which lets pre-existing ENV values override PortSelector.select_ports; change the assignments in configure_ports (the selected = PortSelector.select_ports block) to always set ENV["PORT"], ENV["SHAKAPACKER_DEV_SERVER_PORT"], and when selected[:renderer] set ENV["RENDERER_PORT"] and ENV["REACT_RENDERER_URL"] using direct assignment (=) so the selected ports become the effective env values for child processes and the renderer URL is updated consistently.react_on_rails/lib/react_on_rails/dev/port_selector.rb (1)
98-102:⚠️ Potential issue | 🟠 MajorValidate the base port against the highest derived offset.
Line 101 accepts
65_534and65_535, butselect_portsderiveswebpack = base + 1andrenderer = base + 2, producing invalid ports above65_535.🐛 Proposed fix
def base_port + max_base_port = 65_535 - BASE_PORT_RENDERER_OFFSET BASE_PORT_ENV_VARS.each do |var| val = ENV[var]&.to_i - return val if val&.between?(1, 65_535) + return val if val&.between?(1, max_base_port) end nil end🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@react_on_rails/lib/react_on_rails/dev/port_selector.rb` around lines 98 - 102, The base_port method currently accepts ENV values up to 65_535 but select_ports computes webpack = base + 1 and renderer = base + 2, which can yield ports > 65_535; update the validation in base_port (method name base_port, referenced by select_ports) to enforce an upper bound of 65_533 (i.e., ensure val.between?(1, 65_533) or subtract the maximum derived offset before validation) so that adding +1 and +2 cannot produce invalid ports.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@react_on_rails/lib/react_on_rails/dev/port_selector.rb`:
- Around line 98-102: The base_port method currently accepts ENV values up to
65_535 but select_ports computes webpack = base + 1 and renderer = base + 2,
which can yield ports > 65_535; update the validation in base_port (method name
base_port, referenced by select_ports) to enforce an upper bound of 65_533
(i.e., ensure val.between?(1, 65_533) or subtract the maximum derived offset
before validation) so that adding +1 and +2 cannot produce invalid ports.
In `@react_on_rails/lib/react_on_rails/dev/server_manager.rb`:
- Around line 836-843: The configure_ports method currently uses ||= which lets
pre-existing ENV values override PortSelector.select_ports; change the
assignments in configure_ports (the selected = PortSelector.select_ports block)
to always set ENV["PORT"], ENV["SHAKAPACKER_DEV_SERVER_PORT"], and when
selected[:renderer] set ENV["RENDERER_PORT"] and ENV["REACT_RENDERER_URL"] using
direct assignment (=) so the selected ports become the effective env values for
child processes and the renderer URL is updated consistently.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 89dd322b-8ac2-4e3f-9f75-b9ef2476038a
📒 Files selected for processing (18)
.gitignoredocs/oss/building-features/process-managers.mdreact_on_rails/lib/generators/react_on_rails/pro_setup.rbreact_on_rails/lib/generators/react_on_rails/templates/base/base/.env.examplereact_on_rails/lib/react_on_rails/dev/port_selector.rbreact_on_rails/lib/react_on_rails/dev/server_manager.rbreact_on_rails/spec/dummy/Procfile.devreact_on_rails/spec/dummy/Procfile.dev-prod-assetsreact_on_rails/spec/dummy/Procfile.dev-static-assetsreact_on_rails/spec/dummy/Procfile.dev.no.turbolinksreact_on_rails/spec/react_on_rails/dev/port_selector_spec.rbreact_on_rails/spec/react_on_rails/generators/install_generator_spec.rbreact_on_rails/spec/react_on_rails/support/shared_examples/pro_generator_examples.rbreact_on_rails_pro/spec/dummy/Procfile.devreact_on_rails_pro/spec/dummy/Procfile.prodreact_on_rails_pro/spec/dummy/Procfile.staticreact_on_rails_pro/spec/execjs-compatible-dummy/Procfile.devreact_on_rails_pro/spec/execjs-compatible-dummy/Procfile.dev-static
✅ Files skipped from review due to trivial changes (13)
- .gitignore
- react_on_rails_pro/spec/execjs-compatible-dummy/Procfile.dev-static
- react_on_rails/spec/dummy/Procfile.dev-static-assets
- react_on_rails/spec/dummy/Procfile.dev.no.turbolinks
- react_on_rails/spec/dummy/Procfile.dev-prod-assets
- react_on_rails_pro/spec/execjs-compatible-dummy/Procfile.dev
- react_on_rails/lib/generators/react_on_rails/pro_setup.rb
- react_on_rails_pro/spec/dummy/Procfile.prod
- react_on_rails/lib/generators/react_on_rails/templates/base/base/.env.example
- react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb
- react_on_rails/spec/react_on_rails/support/shared_examples/pro_generator_examples.rb
- react_on_rails/spec/dummy/Procfile.dev
- docs/oss/building-features/process-managers.md
🚧 Files skipped from review as they are similar to previous changes (3)
- react_on_rails_pro/spec/dummy/Procfile.static
- react_on_rails_pro/spec/dummy/Procfile.dev
- react_on_rails/spec/react_on_rails/dev/port_selector_spec.rb
Addresses review comments on PR #3142 (REACT_ON_RAILS_BASE_PORT): - Validate base port against the largest derived offset so base+N stays within the valid TCP port range (1..65_535). A base of 65_534 previously passed validation but produced an invalid renderer port of 65_536. - Enforce the documented priority chain ("base port > explicit per-service env vars") in ServerManager.configure_ports. The former `||=` assignments silently preserved a pre-existing PORT/SHAKAPACKER_DEV_SERVER_PORT, making the effective Rails port disagree with the "Base port detected..." log line. When a base port is active, per-service env vars are now assigned unconditionally. - Preserve RENDERER_PORT and REACT_RENDERER_URL across Bundler.with_unbundled_env by adding them to ProcessManager::ENV_KEYS_TO_PRESERVE. Previously they were dropped for process managers launched outside the bundler context. - Derive REACT_RENDERER_URL from an explicit RENDERER_PORT in non-base-port worktrees when the user set the port but not the URL. - Remove the unused DEFAULT_RENDERER_PORT constant (the 3800 fallback only lives in Procfile shell expressions). - Add port_selector_spec cases for the max-safe and overflow base ports, and server_manager_spec cases for base-port priority override and explicit-RENDERER_PORT URL sync. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Review Feedback Addressed (commit b6e16df)I (Claude Code) went through all inline review comments from @claude, @cursor, @chatgpt-codex-connector, @coderabbitai, and @greptile and addressed every real issue raised. After triage (deduplicating overlapping comments across reviewers), six distinct concerns were identified and all six are now fixed in a single commit. Fixes
TestsAdded 5 new specs to On the bot summary comments (@claude, @greptile, @coderabbitai)Their summary bodies restate the inline findings that are already addressed above — no separate action needed. The earlier CodeRabbit "processing" notice is a stale status post. All 16 unresolved review threads are now resolved. |
|
To use Codex here, create an environment for this repo. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainLet me quickly verify the key changes in the updated code. 🏁 Script executed: Length of output: 58432
Everything looks solid. The 🧠 Learnings used |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 53c62ee026
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d328f8b4b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5ef6d50242
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 9 total unresolved issues (including 8 from previous reviews).
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Kill command targets wrong port from localhost renderer URL
- The kill-port fallback now extracts an explicit port from localhost renderer URLs before falling back to the default renderer port.
Or push these changes by commenting:
@cursor push 5487ee342c
Preview (5487ee342c)
diff --git a/react_on_rails/lib/react_on_rails/dev/server_manager.rb b/react_on_rails/lib/react_on_rails/dev/server_manager.rb
--- a/react_on_rails/lib/react_on_rails/dev/server_manager.rb
+++ b/react_on_rails/lib/react_on_rails/dev/server_manager.rb
@@ -87,11 +87,29 @@
def configured_renderer_port_for_kill
raw_port = ENV.fetch("RENDERER_PORT", nil)
return raw_port.strip.to_i if valid_port_string?(raw_port)
+
+ local_renderer_url_port = configured_local_renderer_url_port_for_kill
+ return local_renderer_url_port if local_renderer_url_port
+
return nil if remote_renderer_url_configured?
3800
end
+ def configured_local_renderer_url_port_for_kill
+ %w[REACT_RENDERER_URL RENDERER_URL].each do |var|
+ url = ENV.fetch(var, nil)
+ next if url.nil? || url.strip.empty? || !localhost_renderer_url?(url)
+ next unless url.match?(URL_WITH_EXPLICIT_PORT_RE)
+
+ return URI.parse(url).port
+ rescue URI::InvalidURIError
+ next
+ end
+
+ nil
+ end
+
def remote_renderer_url_configured?
%w[REACT_RENDERER_URL RENDERER_URL].any? do |var|
url = ENV.fetch(var, nil)You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit db313f1. Configure here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db313f17d2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Code Review: PR #3142OverviewWell-structured PR solving a real pain point (port conflicts across concurrent worktrees/agent sandboxes) with a clean priority-chain design. Test coverage is thorough and inline documentation is unusually good. One clear bug found where a test documents behavior that the implementation does not actually provide. Bug:
|
Code Review: PR #3142 —
|
Two genuine bugs and 14 polish items from the latest bot reviews. Bugs: - run_production_like rescues PortSelector::NoPortAvailable so an exhausted port range exits cleanly instead of producing an unhandled Ruby backtrace, mirroring configure_ports. - warn_if_derived_ports_in_use accepts a pro_renderer keyword so OSS apps without the Pro renderer don't see a confusing "port base+2 (renderer) is already in use" warning when an unrelated service binds the renderer port. Polish: - Strip-and-write-back whitespace-padded but-otherwise-valid PORT / SHAKAPACKER_DEV_SERVER_PORT to match RENDERER_PORT normalization. - Prefix the RENDERER_PORT-without-URL derivation message with WARNING: so grep WARNING filtering catches it. - valid_port_string? uses the existing TCP_PORT_MAX constant. - sync_renderer_port_and_url calls warn_url_without_port without pretending its return value is meaningful. - file_manager.rb: SOCKET_PROBE_TIMEOUT_SECS hoisted to class body and reduced from 1.0s to 0.15s; dead File.readlink nil/empty guard removed. - cleanup_socket_files (kill flow) now uses the same overmind*.sock glob as FileManager#cleanup_overmind_sockets so renamed/copied variants are removed. - local_renderer_url_port_for_kill caches the parsed URI so localhost_renderer_url? doesn't re-parse the same string. Helper factored out as localhost_hostname?. - Procfile.static delegates to `pnpm run node-renderer` so future package.json flag additions propagate without divergence. - Docs: PortSelector#select_ports ENV mutation note strengthened with YARD-style @side_effect; killable_ports comments why pro_renderer_active? rarely fires during kill; warn_if_legacy message notes RENDERER_URL still activates the Pro path; CONDUCTOR_PORT caveat extended with the future-semantics-change failure mode. Specs: - New: PortSelector skips renderer port-in-use warning when pro_renderer is false. - New: run_production_like exits cleanly on NoPortAvailable. - New: kill flow cleans up renamed/copied overmind sockets via the shared glob. - Existing cleanup_socket_files spec updated to stub the new glob. All bots' "addressed" items from PR review summaries are covered or verified already-addressed in earlier commits (4dce031..a7d748a). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Round 22 review wrap-up — 16 fixes from claude/cursor/codex botsAll new review threads opened against commit Bugs fixed
Polish
Documentation
Already addressed earlier in this PR (resolved with rationale)Comments r3181025355, r3180916302, r3180974669, r3180966942, r3180803438 — all addressed by Verification
I (Claude Code) made these changes in a fresh worktree on |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b1cc0bb7f1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # * `[^@/:]+` for a regular hostname/IPv4 whose charset excludes | ||
| # `/` and `:` so the `:\d+` port anchor lands on the authority | ||
| # separator without backtracking into the host. | ||
| URL_WITH_EXPLICIT_PORT_RE = %r{://(?:[^@/]*@)?(?:\[[^\]]+\]|[^@/:]+):\d+} |
There was a problem hiding this comment.
Anchor explicit-port regex to authority boundary
URL_WITH_EXPLICIT_PORT_RE can match the :<digits> portion of userinfo (e.g. http://user:3800@localhost) instead of only matching a host port, because the pattern is not constrained to the end of the authority segment. In that case local_renderer_url_port_for_kill treats a URL with no explicit host port as explicit and uses URI.parse(url).port (defaulting to 80), so bin/dev kill may target port 80 and terminate an unrelated local service; the same false-positive also affects renderer URL/port mismatch checks.
Useful? React with 👍 / 👎.


Summary
REACT_ON_RAILS_BASE_PORTenv var that derives all service ports from a single base value (Rails = base+0, webpack = base+1, renderer = base+2)CONDUCTOR_PORTas a fallback, so Conductor.build works out of the box${PORT:-3000}and${RENDERER_PORT:-3800}patterns instead of hardcoded valuesRENDERER_PORTandREACT_RENDERER_URLenv vars for automatic Pro Node Renderer configurationThis enables coding agent tools (Conductor.build, Codex, Quad Code, etc.) to run multiple worktrees concurrently without port conflicts — just set one env var and everything works.
Changes
Core logic:
PortSelector: new base port priority tier (checked before explicit env vars and auto-detect)ServerManager.configure_ports: setsRENDERER_PORTandREACT_RENDERER_URLwhen base port is activeProcfile templates (all now use env var fallbacks):
Procfile.dev,Procfile.dev-prod-assets,Procfile.dev-static-assetsProcfile.dev,Procfile.prod,Procfile.staticpro_setup.rb): uses${RENDERER_PORT:-3800}in generated Procfile linesDocumentation:
.env.example: documents base port,RENDERER_PORT, andREACT_RENDERER_URLprocess-managers.md: new "Coding Agent / CI Integration" and "Manual Worktree Port Setup (Pro)" sectionsTest plan
REACT_ON_RAILS_BASE_PORT=4000 bin/devprints correct port assignments🤖 Generated with Claude Code
Note
Medium Risk
Medium risk because it changes
bin/devport/env handling (including unconditional overrides in base-port mode) andbin/dev killtargeting, which could disrupt local dev setups if env vars or remote renderer URLs are configured unexpectedly.Overview
Adds a deterministic base-port mode to
bin/dev: whenREACT_ON_RAILS_BASE_PORT(orCONDUCTOR_PORT) is set, Rails/webpack/node-renderer ports are derived as base+0/+1/+2 and applied consistently acrossdevelopment,static, andprodmodes, with warnings when pre-set env values are overridden.Improves dev reliability by cleaning up copied/stale Overmind sockets and
tmp/pids/server.pid(including cross-directory PID detection), expandingbin/dev killto target base-port-derived ports and renderer ports when applicable, and normalizing invalid/whitespace port env vars.Standardizes Pro renderer configuration on
REACT_RENDERER_URL(warns on legacyRENDERER_URLusage), auto-derivesREACT_RENDERER_URLfromRENDERER_PORTwhen missing, and updates Procfiles/generator templates/docs/tests to use${PORT:-…}/${RENDERER_PORT:-…}defaults and the new env-var conventions.Reviewed by Cursor Bugbot for commit b1cc0bb. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Behavior Changes
Documentation
Tests
Chores