Skip to content

Commit 4f74386

Browse files
committed
perf(react): hoist static render values
1 parent 63337d3 commit 4f74386

4 files changed

Lines changed: 29 additions & 27 deletions

File tree

  • apps
    • docs/app/api/search
    • sim/app
      • (landing)/comparisons
      • workspace/[workspaceId]
        • logs/components/dashboard/components/line-chart
        • w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown

apps/docs/app/api/search/route.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ export const revalidate = 0
99
const DEFAULT_SEARCH_LIMIT = 10
1010
const MAX_SEARCH_LIMIT = 20
1111

12+
/** Uses PostgreSQL's simple text-search configuration for unsupported Japanese and Chinese. */
13+
const LOCALE_MAP: Record<string, string> = {
14+
en: 'english',
15+
es: 'spanish',
16+
fr: 'french',
17+
de: 'german',
18+
ja: 'simple',
19+
zh: 'simple',
20+
}
21+
1222
function getSearchLimit(value: unknown): number {
1323
const limit = Number.parseInt(String(value ?? DEFAULT_SEARCH_LIMIT), 10)
1424

@@ -44,15 +54,7 @@ export async function GET(request: NextRequest) {
4454
const candidateLimit = limit * 3
4555
const similarityThreshold = 0.6
4656

47-
const localeMap: Record<string, string> = {
48-
en: 'english',
49-
es: 'spanish',
50-
fr: 'french',
51-
de: 'german',
52-
ja: 'simple', // PostgreSQL doesn't have Japanese support, use simple
53-
zh: 'simple', // PostgreSQL doesn't have Chinese support, use simple
54-
}
55-
const tsConfig = localeMap[locale] || 'simple'
57+
const tsConfig = LOCALE_MAP[locale] || 'simple'
5658

5759
const useVectorSearch = locale === 'en'
5860
let vectorResults: Array<{

apps/sim/app/(landing)/comparisons/page.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ import { JsonLd } from '@/app/(landing)/components/json-ld'
1010
import { LandingFAQ } from '@/app/(landing)/components/landing-faq'
1111

1212
const baseUrl = SITE_URL
13+
const BREADCRUMB_JSON_LD = {
14+
'@context': 'https://schema.org',
15+
'@type': 'BreadcrumbList',
16+
itemListElement: [
17+
{ '@type': 'ListItem', position: 1, name: 'Home', item: baseUrl },
18+
{ '@type': 'ListItem', position: 2, name: 'Comparisons', item: `${baseUrl}/comparisons` },
19+
],
20+
}
1321

1422
export const revalidate = 3600
1523

@@ -60,15 +68,6 @@ export const metadata: Metadata = buildLandingMetadata({
6068
})
6169

6270
export default function ComparisonHubPage() {
63-
const breadcrumbJsonLd = {
64-
'@context': 'https://schema.org',
65-
'@type': 'BreadcrumbList',
66-
itemListElement: [
67-
{ '@type': 'ListItem', position: 1, name: 'Home', item: baseUrl },
68-
{ '@type': 'ListItem', position: 2, name: 'Comparisons', item: `${baseUrl}/comparisons` },
69-
],
70-
}
71-
7271
const itemListJsonLd = {
7372
'@context': 'https://schema.org',
7473
'@type': 'ItemList',
@@ -96,7 +95,7 @@ export default function ComparisonHubPage() {
9695

9796
return (
9897
<>
99-
<JsonLd data={breadcrumbJsonLd} />
98+
<JsonLd data={BREADCRUMB_JSON_LD} />
10099
<JsonLd data={itemListJsonLd} />
101100
<JsonLd data={faqJsonLd} />
102101

apps/sim/app/workspace/[workspaceId]/logs/components/dashboard/components/line-chart/line-chart.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Button, cn } from '@sim/emcn'
33
import { generateShortId } from '@sim/utils/id'
44
import { formatDate, formatLatency } from '@/app/workspace/[workspaceId]/logs/utils'
55

6+
const CHART_PADDING = { top: 16, right: 28, bottom: 26, left: 26 } as const
7+
68
export interface LineChartPoint {
79
timestamp: string
810
value: number
@@ -34,7 +36,7 @@ function LineChartComponent({
3436
const [containerWidth, setContainerWidth] = useState<number | null>(null)
3537
const width = containerWidth ?? 0
3638
const height = 166
37-
const padding = { top: 16, right: 28, bottom: 26, left: 26 }
39+
const padding = CHART_PADDING
3840
useEffect(() => {
3941
if (!containerRef.current) return
4042
const element = containerRef.current

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { useWorkflowStore } from '@/stores/workflows/workflow/store'
4040
import type { BlockState } from '@/stores/workflows/workflow/types'
4141

4242
const EMPTY_VARIABLES: Variable[] = []
43+
const EMPTY_VARIABLE_INFO_MAP: Record<string, { type: string; id: string }> = {}
4344

4445
/**
4546
* Context for sharing nested navigation state between components.
@@ -1001,16 +1002,14 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
10011002
[inputValue, cursorPosition]
10021003
)
10031004

1004-
const emptyVariableInfoMap: Record<string, { type: string; id: string }> = {}
1005-
10061005
/**
10071006
* Computes tags, variable info, and block tag groups
10081007
*/
10091008
const { tags, variableInfoMap, blockTagGroups } = useMemo<TagComputationResult>(() => {
10101009
if (activeSourceBlockId) {
10111010
const sourceBlock = blocks[activeSourceBlockId]
10121011
if (!sourceBlock) {
1013-
return { tags: [], variableInfoMap: emptyVariableInfoMap, blockTagGroups: [] }
1012+
return { tags: [], variableInfoMap: EMPTY_VARIABLE_INFO_MAP, blockTagGroups: [] }
10141013
}
10151014

10161015
const blockConfig = getBlock(sourceBlock.type)
@@ -1034,9 +1033,9 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
10341033
},
10351034
]
10361035

1037-
return { tags: blockTags, variableInfoMap: emptyVariableInfoMap, blockTagGroups }
1036+
return { tags: blockTags, variableInfoMap: EMPTY_VARIABLE_INFO_MAP, blockTagGroups }
10381037
}
1039-
return { tags: [], variableInfoMap: emptyVariableInfoMap, blockTagGroups: [] }
1038+
return { tags: [], variableInfoMap: EMPTY_VARIABLE_INFO_MAP, blockTagGroups: [] }
10401039
}
10411040

10421041
const mergedSubBlocks = getMergedSubBlocks(activeSourceBlockId)
@@ -1063,12 +1062,12 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
10631062
},
10641063
]
10651064

1066-
return { tags: blockTags, variableInfoMap: emptyVariableInfoMap, blockTagGroups }
1065+
return { tags: blockTags, variableInfoMap: EMPTY_VARIABLE_INFO_MAP, blockTagGroups }
10671066
}
10681067

10691068
const hasInvalidBlocks = Object.values(blocks).some((block) => !block || !block.type)
10701069
if (hasInvalidBlocks) {
1071-
return { tags: [], variableInfoMap: emptyVariableInfoMap, blockTagGroups: [] }
1070+
return { tags: [], variableInfoMap: EMPTY_VARIABLE_INFO_MAP, blockTagGroups: [] }
10721071
}
10731072

10741073
const starterBlock = Object.values(blocks).find((block) => block.type === 'starter')

0 commit comments

Comments
 (0)