Skip to content

Gate React on Rails AI prompt context - #1184

Merged
justin808 merged 3 commits into
mainfrom
codex/b2-ai-prompt-1162
Jul 1, 2026
Merged

Gate React on Rails AI prompt context#1184
justin808 merged 3 commits into
mainfrom
codex/b2-ai-prompt-1162

Conversation

@justin808

Copy link
Copy Markdown
Member

Summary

  • Gate the React on Rails section in generated AI analysis prompts on local app detection.
  • Detect React on Rails through package.json, Gemfile, or Gemfile.lock without adding a new CLI flag.
  • Preserve direct AiPromptGenerator.generatePrompt(...) default behavior unless callers explicitly disable the section.

Closes #1162

Validation

  • PATH=/Users/justin/.local/share/mise/installs/node/22.20.0/bin:/Users/justin/.local/share/mise/installs/yarn/1.22.22/bin:$PATH yarn test --runInBand --runTestsByPath test/package/configExporter/cli.test.js test/package/configExporter/aiPromptGenerator.test.js
  • PATH=/Users/justin/.local/share/mise/installs/node/22.20.0/bin:/Users/justin/.local/share/mise/installs/yarn/1.22.22/bin:$PATH yarn type-check
  • PATH=/Users/justin/.local/share/mise/installs/node/22.20.0/bin:/Users/justin/.local/share/mise/installs/yarn/1.22.22/bin:$PATH yarn lint
  • codex review --base origin/main clean

Notes

  • Full yarn test --runInBand was not used as the deciding check because this worktree lacks generated JS build artifacts and unrelated existing suites fail before this slice completes.
  • Full .agents/bin/validate is affected by the same local bare-node/mise shim hang observed in this batch; targeted checks above were run with the direct Node/Yarn path.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@justin808, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 6 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 271d0872-6e6d-4b07-87bb-519d791d00aa

📥 Commits

Reviewing files that changed from the base of the PR and between 1d7a12a and b56931c.

📒 Files selected for processing (4)
  • package/configExporter/aiPromptGenerator.ts
  • package/configExporter/cli.ts
  • test/package/configExporter/aiPromptGenerator.test.js
  • test/package/configExporter/cli.test.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/b2-ai-prompt-1162

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.

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR gates the React on Rails section in generated AI analysis prompts. The main changes are:

  • Added an optional prompt generator flag for React on Rails context.
  • Wired doctor-mode prompt generation to local app detection.
  • Added detection through package.json, Gemfile, and Gemfile.lock.
  • Added CLI tests for included and omitted prompt context.

Confidence Score: 4/5

The changed CLI prompt path needs fixes around app-root detection and metadata file reads.

  • A nested frontend root can hide parent Rails files and omit the React on Rails prompt section.
  • Transient Gemfile or Gemfile.lock read failures can skip the whole AI prompt.
  • The prompt generator option itself keeps the old direct-call default.

package/configExporter/cli.ts

Important Files Changed

Filename Overview
package/configExporter/aiPromptGenerator.ts Adds an optional context flag while preserving the default prompt content for direct callers.
package/configExporter/cli.ts Adds React on Rails usage detection for AI prompts, with false-negative and filesystem-read edge cases.
test/package/configExporter/cli.test.js Adds focused coverage for prompt context inclusion and omission.

Reviews (1): Last reviewed commit: "Gate AI prompt React on Rails context" | Re-trigger Greptile

Comment thread package/configExporter/cli.ts
Comment thread package/configExporter/cli.ts Outdated
Comment thread package/configExporter/cli.ts Outdated
Comment thread package/configExporter/cli.ts Outdated
@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review

Overall this is a clean, well-scoped fix. Detection logic (package.json deps, Gemfile, Gemfile.lock) is sound, the default behavior of AiPromptGenerator.generatePrompt is preserved for direct callers (options.includeReactOnRailsContext only disables the section when explicitly false), and both runDoctorMode call sites correctly thread appRoot through. New tests cover the three detection paths plus the "no detection" case.

A couple of minor points:

  1. Missing CHANGELOG entry. This is a user-visible fix (closes Doctor mode: gate React on Rails context in AI-ANALYSIS-PROMPT.md on react_on_rails detection #1162, changes when the React on Rails section appears in the generated AI-ANALYSIS-PROMPT.md) but CHANGELOG.md wasn't updated. Per this repo's convention, it should get a ### Fixed entry under [Unreleased] (there's already a ### Added entry from PR Add AI analysis prompt generator to config exporter #695 for the original AI prompt feature this refines).
  2. Error-handling asymmetry between packageJsonUsesReactOnRails and the two Gemfile helpers — left as an inline comment on cli.ts.
  3. Test coverage gap (nice-to-have): the new options.includeReactOnRailsContext parameter on AiPromptGenerator.generatePrompt isn't directly unit-tested in aiPromptGenerator.test.js — coverage is only indirect via the CLI detection tests. A couple of direct tests (explicit false, and default {} preserving old behavior) would isolate the generator's own contract from the CLI's detection logic.

No security or performance concerns — file reads are scoped to the already-trusted appRoot, and detection only runs once per doctor-mode invocation.

@justin808
justin808 force-pushed the codex/b2-ai-prompt-1162 branch from 5f1a525 to 0f685a4 Compare July 1, 2026 04:55
Comment thread package/configExporter/cli.ts
@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Summary

Solid, well-tested change. The detection logic (package.json / Gemfile / Gemfile.lock, with upward monorepo-aware walking) is defensive (try/catch around every file read, matching existing conventions in this file) and the new tests cover the main branches well, including the "marker files are actually directories" resiliency case. Backward compatibility for direct AiPromptGenerator.generatePrompt(...) callers is preserved since the option only opts out on an explicit false.

Findings:

  • Missing CHANGELOG.md entry. This PR fixes user-visible behavior (the AI prompt no longer always includes React on Rails guidance, closing Doctor mode: gate React on Rails context in AI-ANALYSIS-PROMPT.md on react_on_rails detection #1162) but doesn't touch CHANGELOG.md. Per this repo's contribution guidelines, bug fixes need a changelog entry under ### Fixed in [Unreleased].
  • Minor (inline comment on cli.ts): the upward directory walk for Rails-root detection has no bound other than the filesystem root, so in unusual nested layouts it could pick up an unrelated ancestor project's Gemfile/package.json. Low likelihood, not blocking — see inline comment for details.

No security or performance concerns — all detection is local, synchronous file reads bounded by directory depth, and gated behind doctor-mode's best-effort prompt generation (a failure here already can't break the export itself).

Comment thread package/configExporter/cli.ts
@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review summary

Overall this is a clean, well-tested change: gating the React on Rails section behind local detection (via package.json/Gemfile/Gemfile.lock) is a sensible fix for #1162, the AiPromptGenerator.generatePrompt default behavior is correctly preserved for direct callers (only skips the section when includeReactOnRailsContext === false), and all the file-read helpers (packageJsonUsesReactOnRails, gemfileUsesReactOnRails, gemfileLockUsesReactOnRails) fail closed via try/catch so a malformed or unreadable file can't crash writeAiAnalysisPrompt. Test coverage is solid, including the nested-frontend-root case and the "marker files are directories, not files" resilience test.

Two minor points (left as inline comments / noted here):

  1. Unbounded upward directory walk in reactOnRailsDetectionRoots (package/configExporter/cli.ts) — if no Rails marker exists anywhere in the ancestry, it walks all the way to the filesystem root. Matches the existing style of findAppRoot(), so not a new anti-pattern, but worth a depth cap given it now does more filesystem checks per level.
  2. No CHANGELOG.md entry. This is a user-visible behavior change (the generated AI-ANALYSIS-PROMPT.md content now differs based on detected React on Rails usage) and per the repo's CLAUDE.md guidelines, user-visible changes should get a CHANGELOG entry under ## [Unreleased].

No security or correctness issues found — all new file reads are scoped to specific filenames (package.json, Gemfile, Gemfile.lock) and only used to gate local prompt content, nothing is executed or transmitted externally.

Comment thread package/configExporter/cli.ts
@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Summary

Reviewed the change gating the "React on Rails Standard Configuration" section of the generated AI-ANALYSIS-PROMPT.md on actual detection of React on Rails (via package.json, Gemfile, or Gemfile.lock).

Overall: solid, well-tested change. AiPromptGenerator.generatePrompt correctly preserves its default (include the section) for direct callers who don't pass options, so this is backward compatible for consumers importing AiPromptGenerator directly (it's exported from package/configExporter/index.ts). The writeAiAnalysisPrompt change only affects doctor-mode output, matching the PR's stated scope. Detection logic correctly handles:

  • Nested frontend directories with a Rails Gemfile further up the tree.
  • Stopping the walk at a .git boundary so unrelated ancestor directories aren't scanned.
  • Unreadable/malformed marker files (e.g. Gemfile as a directory) failing closed rather than throwing.
  • npm scoped/unscoped dependency fields (dependencies/devDependencies/optionalDependencies/peerDependencies).

Test coverage in cli.test.js and aiPromptGenerator.test.js is thorough, including the boundary and unreadable-file edge cases.

Minor points:

  1. Left an inline note on reactOnRailsDetectionRoots (package/configExporter/cli.ts) — the upward directory walk has no depth cap, so in the rare case where no .git/Rails marker exists anywhere above appRoot, it will walk all the way to the filesystem root. Low impact in practice since appRoot is normally already the Rails root, but worth a defensive bound.
  2. No CHANGELOG.md entry was added. Since this fixes user-visible behavior (closes Doctor mode: gate React on Rails context in AI-ANALYSIS-PROMPT.md on react_on_rails detection #1162) and the repo convention adds a "Fixed" entry for this class of change, consider adding one via /update-changelog.

No security or correctness blockers found.

@justin808
justin808 merged commit 0413266 into main Jul 1, 2026
26 checks passed
@justin808
justin808 deleted the codex/b2-ai-prompt-1162 branch July 1, 2026 05:59
justin808 added a commit that referenced this pull request Jul 4, 2026
## Summary

Stamps the **`v10.2.0`** release section in `CHANGELOG.md` and adds the
user-visible entries that were still missing for PRs merged since
`v10.1.0`.

Header format matches the repo convention (`## [v10.2.0] - July 3,
2026`) and is parseable by `rakelib/release.rake`'s
`extract_changelog_section` (`## [v<npm-version>]`), so `bundle exec
rake release` / `sync_github_release` will pick up the notes
automatically.

### Changelog changes

- **Version header**: inserted `## [v10.2.0] - July 3, 2026` immediately
after `## [Unreleased]`; all accumulated entries now live under it, and
`## [Unreleased]` is empty.
- **Compare links**: `[unreleased]` now compares `v10.2.0...main`; added
`[v10.2.0]: …/compare/v10.1.0...v10.2.0`.

### New entries added (were missing)

| PR | Section | Note |
| --- | --- | --- |
| [#1187](#1187) | Added |
Babel 8 peer dependency support + preset option compatibility |
| [#1184](#1184) | Added |
Folded into the #695 AI-prompt entry (gates the React on Rails section
on app detection) |
| [#1142](#1142) | Fixed |
Rspack dev-server config no longer loads in static watch mode (fixes
#1137) |

### Already documented (carried into v10.2.0)

`#1180`, `#695`, `#1141`, `#1150`, `#1179`, `#1192`, `#1127`, `#1178`,
`#1161`, `#1147`.

### Reviewed and intentionally excluded (not user-visible)

Docs: `#1145`, `#1148`, `#1152`, `#1155`, `#1183`, `#1188`, `#1189`,
`#1193`.
CI: `#1151`, `#1168`, `#1171`.
Tests / fixtures: `#1128`, `#1154`, `#1167`, `#1186`.
Workflow / agent tooling: `#1153`, `#1176`, `#1182`.

(`#1107` is already documented under `## [v10.1.0]`.)

## Next step

After merge, run the repo's release task (no args) — it reads `v10.2.0`
from the changelog and creates the GitHub release from this section.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.

Doctor mode: gate React on Rails context in AI-ANALYSIS-PROMPT.md on react_on_rails detection

1 participant