perf(react): hoist static render values - #6841
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryLow Risk Overview Docs search API — Comparisons landing — Breadcrumb JSON-LD is moved to Logs line chart — Chart padding is shared via Workflow tag dropdown — Empty Reviewed by Cursor Bugbot for commit 4f74386. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThe PR hoists static render and request values to module scope to avoid recreating them during execution.
Confidence Score: 4/5The PR appears safe to merge, with only a non-blocking TypeScript convention issue affecting the newly hoisted object constants. The hoisted values preserve existing runtime behavior and are not mutated, but three new object constants lack the repository-required const assertions. Files Needing Attention: apps/sim/app/(landing)/comparisons/page.tsx, apps/docs/app/api/search/route.ts, and tag-dropdown.tsx
|
| Filename | Overview |
|---|---|
| apps/docs/app/api/search/route.ts | Hoists the locale-to-PostgreSQL-search-configuration map without changing lookup behavior, but omits the required const assertion. |
| apps/sim/app/(landing)/comparisons/page.tsx | Hoists static breadcrumb JSON-LD while preserving rendered data, but the constant lacks the repository-required const assertion. |
| apps/sim/app/workspace/[workspaceId]/logs/components/dashboard/components/line-chart/line-chart.tsx | Hoists immutable chart padding with an appropriate const assertion; all consumers remain read-only. |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx | Safely shares an empty read-only-in-practice metadata map, though its declaration omits the required const assertion. |
Reviews (1): Last reviewed commit: "perf(react): hoist static render values" | Re-trigger Greptile
| const BREADCRUMB_JSON_LD = { | ||
| '@context': 'https://schema.org', | ||
| '@type': 'BreadcrumbList', | ||
| itemListElement: [ | ||
| { '@type': 'ListItem', position: 1, name: 'Home', item: baseUrl }, | ||
| { '@type': 'ListItem', position: 2, name: 'Comparisons', item: `${baseUrl}/comparisons` }, | ||
| ], | ||
| } |
There was a problem hiding this comment.
The newly hoisted BREADCRUMB_JSON_LD object lacks the repository-required as const assertion, leaving its inferred properties unnecessarily widened and mutable. The same changed-code pattern appears in LOCALE_MAP and EMPTY_VARIABLE_INFO_MAP.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
Four values that do not depend on a render or request are now created once at module load. This removes repeated allocation and gives consumers a stable reference without changing their values.
This is stack PR 3 of 3 and depends on #6840. The two remaining React Doctor warnings are intentional:
scrollingBoxesandfrozenBoxesare filled during each render, so hoisting them would leak stale collaborator selections.Type of Change
Testing
npx react-doctor@latest --verbose: 3,483 findings; only the 2 mutable-array false positives remain@sim/appanddocsbun run check:api-validationpassedChecklist
Screenshots/Videos
Not applicable. The hoisted values and their runtime contents are unchanged.
Post-Deploy Monitoring & Validation
No additional operational monitoring is required. These constants preserve their previous values and do not change user-visible behavior.