Skip to content

perf(react): hoist static render values - #6841

Open
j15z wants to merge 1 commit into
perf/react-doctor-stable-keysfrom
perf/react-doctor-static-values
Open

perf(react): hoist static render values#6841
j15z wants to merge 1 commit into
perf/react-doctor-stable-keysfrom
perf/react-doctor-static-values

Conversation

@j15z

@j15z j15z commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

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: scrollingBoxes and frozenBoxes are filled during each render, so hoisting them would leak stale collaborator selections.

Metric Parent This PR
React Doctor total findings 3,488 3,483
Static-value warnings 6 2 confirmed false positives

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: Performance and maintainability improvement

Testing

  • npx react-doctor@latest --verbose: 3,483 findings; only the 2 mutable-array false positives remain
  • Type checks passed for @sim/app and docs
  • bun run check:api-validation passed
  • Biome passed across the complete 59-file stack

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

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.

@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 19, 2026 3:09am

Request Review

@cursor

cursor Bot commented Aug 19, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Refactor-only: stable references replace inline literals with no intended behavior change in search, SEO JSON-LD, chart layout, or tag dropdown logic.

Overview
Hoists static objects and maps out of hot paths so React and memoized hooks see stable references instead of new literals on every render or request.

Docs search APIlocaleMap becomes module-level LOCALE_MAP (with a short comment on simple for ja/zh) so each GET no longer allocates a new map.

Comparisons landing — Breadcrumb JSON-LD is moved to BREADCRUMB_JSON_LD at module scope instead of being built inside the page component.

Logs line chart — Chart padding is shared via CHART_PADDING instead of a per-render object in LineChartComponent.

Workflow tag dropdown — Empty variableInfoMap fallbacks use a single module-level EMPTY_VARIABLE_INFO_MAP (aligned with existing EMPTY_VARIABLES) across the tag computation useMemo early returns.

Reviewed by Cursor Bugbot for commit 4f74386. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR hoists static render and request values to module scope to avoid recreating them during execution.

  • Hoists the documentation search locale map.
  • Hoists comparison-page breadcrumb structured data.
  • Reuses stable chart padding and empty variable metadata constants.

Confidence Score: 4/5

The 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

Important Files Changed

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

Comment on lines +13 to +20
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` },
],
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Const assertions omitted

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!

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.

1 participant