Skip to content

Commit 0b626bc

Browse files
ihabadhamclaude
andcommitted
Address PR review feedback
- pages_controller.rb: scope `before_action :set_comments` to actions that use @comments (index, no_router) — server_components/simple/rescript no longer trigger an unused query. - server_components.html.erb: drop hardcoded `id:` from stream_react_component call. RoR auto-generates stable unique IDs; hardcoding risks DOM-id collisions if the helper is ever called twice and diverges from the default pattern used by /no_router and /simple. - CommentsFeed.jsx: flip RSC_SUSPENSE_DEMO_DELAY to opt-in (=== 'true'). The previous opt-out guard (!== 'false') made the 800ms delay fire by default in any deploy without the env var explicitly set. app.yml: add RSC_SUSPENSE_DEMO_DELAY=true to the review-app template so the demo still shows the streaming fallback visibly. - ServerInfo.jsx: drop the Hostname row. The K8s pod name (e.g. rails-5fc66bddf6-r8b5r) is infrastructure-fingerprinting fodder for forks deployed publicly, and ServerInfo's "look, server-side data" intent is fully covered by the remaining six fields. - stores-registration.js: add a one-line comment noting why 'use client' sits on a webpack pack entry (excludes the registration code's dependency graph from the RSC bundle). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f2d0d3d commit 0b626bc

6 files changed

Lines changed: 10 additions & 8 deletions

File tree

.controlplane/templates/app.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ spec:
3434
value: '2'
3535
- name: RENDERER_URL
3636
value: http://localhost:3800
37+
# Enable the artificial Suspense demo delay so the streaming fallback is
38+
# visible on the review-app. Off by default in production deployments.
39+
- name: RSC_SUSPENSE_DEMO_DELAY
40+
value: 'true'
3741
# RENDERER_PASSWORD and REACT_ON_RAILS_PRO_LICENSE must be created in the
3842
# Control Plane Secret named by {{APP_SECRETS}} before deploy. cpflow
3943
# resolves {{APP_SECRETS}} to `{APP_PREFIX}-secrets` — which means review

app/controllers/pages_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class PagesController < ApplicationController
44
include ReactOnRails::Controller
55
include ReactOnRailsPro::Stream
6-
before_action :set_comments
6+
before_action :set_comments, only: %i[index no_router]
77

88
def index
99
# NOTE: The below notes apply if you want to set the value of the props in the controller, as

app/views/pages/server_components.html.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
props: { comments: @server_components_comments },
33
prerender: true,
44
auto_load_bundle: true,
5-
trace: Rails.env.development?,
6-
id: "ServerComponentsPage-react-component-0") %>
5+
trace: Rails.env.development?) %>

client/app/bundles/server-components/components/CommentsFeed.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import TogglePanel from './TogglePanel';
77
const marked = new Marked();
88
marked.use(gfmHeadingId());
99

10-
// Default-on small delay so the surrounding <Suspense> fallback is visible
11-
// in the demo. Set RSC_SUSPENSE_DEMO_DELAY=false to disable (CI / tests).
10+
// Opt-in delay so the surrounding <Suspense> fallback is visible in the demo.
11+
// Set RSC_SUSPENSE_DEMO_DELAY=true to enable; defaults off in production.
1212
async function CommentsFeed({ comments = [] }) {
13-
if (process.env.RSC_SUSPENSE_DEMO_DELAY !== 'false') {
13+
if (process.env.RSC_SUSPENSE_DEMO_DELAY === 'true') {
1414
await new Promise((resolve) => {
1515
setTimeout(resolve, 800);
1616
});

client/app/bundles/server-components/components/ServerInfo.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ function ServerInfo() {
1414
totalMemory: (os.totalmem() / (1024 * 1024 * 1024)).toFixed(1),
1515
freeMemory: (os.freemem() / (1024 * 1024 * 1024)).toFixed(1),
1616
cpus: os.cpus().length,
17-
hostname: os.hostname(),
1817
};
1918

2019
// Using lodash on the server — this 70KB+ library stays server-side
@@ -29,7 +28,6 @@ function ServerInfo() {
2928
totalMemory: 'Total RAM (GB)',
3029
freeMemory: 'Free RAM (GB)',
3130
cpus: 'CPU Cores',
32-
hostname: 'Hostname',
3331
};
3432

3533
return (

client/app/packs/stores-registration.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// 'use client' keeps this pack and its store imports out of the RSC bundle.
12
'use client';
23

34
import ReactOnRails from 'react-on-rails-pro';

0 commit comments

Comments
 (0)