perf(services): keep the services snapshot out of the client route chunk#890
Conversation
The /services client home page value-imported defaultServiceSlug from @/lib/services, compiling the ~915 KB services snapshot (~100 KB gzip) into its route chunk for one static href. The server page now computes the slug and passes it as a prop. Bundle budget swings from +3.13% over to -3.97% under the enforced baseline, which is ratcheted down to 1,309,286 bytes gzip so CI locks the win. Ledger row included. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
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:
📝 WalkthroughWalkthroughThe ChangesServices bundle flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ceabc04d75
ℹ️ 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".
Addresses the Codex P2 on PR #890: the Reviewed HEAD cell held prose because the row predated its own single-batch commit; it now cites the reviewed implementation commit ceabc04, keeping the exact-hash ledger lookup functional. Row remains keyed by PR number + branch ref. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 92a92eab2e
ℹ️ 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".
Addresses the Codex P2 on PR #890: the ratcheted bundle budget's 10% tolerance still sits above the pre-fix total, so it cannot catch a re-introduction of the services-snapshot client import on its own. This source-level boundary test fails the unit suite (inside verify:cheap) the moment any client module value-imports @/lib/services; type-only imports remain allowed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 57b28021a3
ℹ️ 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.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/services-client-boundary.test.ts`:
- Line 12: Update VALUE_IMPORT_PATTERN to exclude named imports whose specifiers
are exclusively type-only, including multiline forms, while continuing to match
imports that contain runtime bindings. Preserve rejection of other runtime
imports from "`@/lib/services`".
- Line 12: Broaden VALUE_IMPORT_PATTERN to detect runtime side-effect imports
and re-exports from "`@/lib/services`" in addition to regular value imports, while
continuing to allow import type statements. Update the boundary check without
changing its intended rejection of runtime service usage.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b8a08e09-d65a-4c8f-9fdd-c571dfb2d4de
📒 Files selected for processing (1)
tests/services-client-boundary.test.ts
… services guard Addresses the Codex and CodeRabbit findings on PR #890: the boundary now walks value-import graphs from every 'use client' entry (a helper without the directive still lands in the client chunk), treats side-effect imports and value re-exports as runtime, and stops flagging named type-only import clauses that compile away. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d955b58836
ℹ️ 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".
Addresses the Codex P2 on PR #890: relative specifiers like ../lib/services resolved in the graph walk but never set the services-import flag; the guard now matches the resolved module path in addition to the alias text. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83c9293210
ℹ️ 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.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/services-client-boundary.test.ts`:
- Around line 15-21: The import-boundary detection must also reject dynamic
import() expressions and reliably detect "use client" directives beyond the
first 400 characters. Update the logic using SIDE_EFFECT_IMPORT_PATTERN,
FROM_STATEMENT_PATTERN, and the surrounding directive check to recognize dynamic
imports and scan the full directive prologue after leading comments and
whitespace, while preserving existing handling for static imports and exports.
- Around line 98-101: Update the isClientEntry detection in the graph.set entry
to inspect the full source prologue rather than source.slice(0, 400). Ensure a
"use client" directive remains detected when preceded by a long header comment,
while preserving the existing directive-matching behavior.
🪄 Autofix (Beta)
❌ Autofix failed (check again to retry)
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 368f63e5-155b-4b33-91d3-abfca2332b9c
📒 Files selected for processing (1)
tests/services-client-boundary.test.ts
…ices guard Addresses the round-4 Codex and CodeRabbit findings on PR #890: dynamic import() expressions now count as runtime edges (they still emit client JavaScript), and 'use client' detection parses the complete comment/ whitespace prologue instead of capping at 400 characters. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. The agent ran but didn't make any changes. The issues may already be fixed or require manual intervention. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 838624535e
ℹ️ 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".
Addresses the round-5 Codex finding on PR #890: dynamic imports with webpack/Next magic comments before the specifier now count as runtime edges. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32533572b4
ℹ️ 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".
Addresses the Codex P2 on PR #890: the cell held prose after the SHA, defeating the ledger's exact rev-parse match; context moved to the branch/ref cell. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
Summary
Phase 4 of the approved plan — the measured performance pass. The audit (production build + enforced-budget reading + analyzer treemap, artifacts in the session scratchpad) found the client bundle +3.13% over its enforced 1,363,382-byte gzip baseline, with one real, evidence-backed defect:
/servicesclient home page value-importeddefaultServiceSlugfrom@/lib/servicesfor a single static href — compiling the ~915 KB services snapshot (~100 KB gzip) into its route chunk.src/app/services/page.tsx(server) computes the slug and passes it as a prop;services-home-page.tsxbuilds its task cards from the prop and no longer imports the services module.bundle-budget.jsonis ratcheted down 1,363,382 → 1,309,286 bytes gzip, so the blocking CI Build job locks the win permanently.Deliberately untouched per the audit rules: pdfjs-dist (123 KB) and cross-mode-differentials data (121 KB) are already correctly lazy; the suspected forms-catalog dashboard leak was disproved (type-only import, bundles nothing); #718's freshly-remediated paths avoided.
Verification
npm run build+npm run check:bundle-budget -- --jsonbefore/after — verdict swing +3.13% → −3.97%;-- --updateapplied for the ratchet.npm run test— 2789 passed / 1 failed: the known container-onlypdf-extraction-budgetartifact (clean-main baselined; hosted-CI-green through feat(pwa): retirement kill-switch, offline-version binding guard, and dev teardown flag #826/feat(pwa): manifest launch/display fallbacks, monochrome icons, iOS install hint #835/feat(pwa): align the offline page with the permanent colour direction #872).npm run verify:cheap— green to the same single artifact; typecheck/lint/format clean.npm run verify:ui— 219 passed / 2 failed (5.9m): the two long-established container-only artifacts (ui-pwain-incognito installability,ui-smokePDF-canvas mobile), both hosted-CI-green on all three prior phase PRs; theui-toolsspec covering the/servicessurface passed. No new failures.npm run verify:pr-local— unit stage 2789 passed / 1 failed (same artifact); the production build + ratcheted bundle budget re-run as this PR's blocking hosted CI Build job.Verification not run: Lighthouse (dev-server churn in the container; the bundle evidence fully determined this fix set).
Clinical Governance Preflight
Not applicable — a bundling-boundary refactor of how one string reaches a client component, plus the budget baseline file. No data, retrieval, clinical output, privacy, or provider behavior changes; the services data itself still loads exactly as before on the server and via the registry API.
Risk and rollout
Notes
44a4c511. Ledger row included in this single-batch push..next/devgenerated-type corruptions from the long-lived dev server were resolved by stopping the server and setting the generated dir aside (reversible); nothing was hand-deleted.🤖 Generated with Claude Code
https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
Generated by Claude Code
Summary by CodeRabbit