Skip to content

Commit 691912b

Browse files
committed
perf(bundle): stop three routes shipping the block and tool registries
The public /integrations page downloaded, parsed and executed 19.54 MB of JavaScript, 15.52 MB of which was the tool registry — 4,351 tool configs, to render a catalog of names and icons. It arrived as `<script async>` in the initial HTML, so the browser fetched and ran it on load. Measured on a production build, chunks referenced by the page's own HTML: /integrations 19.54 MB -> 3.55 MB across 41 chunks (-82%) No chunk over 1 MB remains on that route. credit-usage also loses its copy. Three separate import edges, all the same shape: a module mixing pure helpers with registry-backed ones, so importing the pure half dragged in all 282 block configs and the tool registry behind them. - `lib/integrations/index.ts` built POPULAR_WORKFLOWS at module scope via `getAllBlockMeta()` and re-exported registry functions. The landing grid is a client component, so importing anything from that barrel inherited the whole graph. POPULAR_WORKFLOWS moves to its own module — its one real consumer is a server page — and the re-export goes, which .claude/rules/sim-imports.md already forbids and which nothing imported through the barrel. - `blocks/icon-color.ts` mixed pure contrast maths (`getTileIconColorClass`, `isLightTileColor`, used by the landing page) with `getBareIconStyle`, which reads `getAllBlocks()`. Split by dependency into `blocks/brand-icon-style.ts`; all six of its consumers are under app/workspace/** where the registry is already legitimately present. - `credit-usage-view.tsx` imported a date formatter from the logs feature's `utils.ts`, which also exports registry-backed badge components. `formatDateShort` has three consumers across three features, so it moves to `lib/core/utils/date-display.ts` per the repo's utils-location rule. Not addressed: account/settings/[section] still reaches the registry through workspace-permissions-provider -> socket-provider, one of the four known client edges from the module-graph audit rather than a stray import. It is also loaded via `dynamic()`, so it is likely lazy rather than on first paint. That belongs with the registry split, not here. workspace/* keeps its copy, which is correct — the editor needs tool params and outputs.
1 parent c0e7ea9 commit 691912b

16 files changed

Lines changed: 174 additions & 120 deletions

File tree

apps/sim/app/(landing)/integrations/(shell)/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import {
66
type FAQItem,
77
INTEGRATIONS,
88
type Integration,
9-
POPULAR_WORKFLOWS,
109
toIntegrationSummary,
1110
} from '@/lib/integrations'
11+
import { POPULAR_WORKFLOWS } from '@/lib/integrations/popular-workflows'
1212
import { withFilteredNoindex } from '@/lib/landing/seo'
1313
import { JsonLd } from '@/app/(landing)/components/json-ld'
1414
import { LandingFAQ } from '@/app/(landing)/components/landing-faq'

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/mention/mention-chip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { cn } from '@sim/emcn'
33
import type { ReactNodeViewProps } from '@tiptap/react'
44
import { NodeViewWrapper, ReactNodeViewRenderer } from '@tiptap/react'
55
import { useParams, useRouter } from 'next/navigation'
6-
import { getBareIconStyle, type StyleableIcon } from '@/blocks/icon-color'
6+
import { getBareIconStyle, type StyleableIcon } from '@/blocks/brand-icon-style'
77
import { mentionIcon } from './mention-icon'
88
import { MarkdownMention, type MentionAttrs } from './mention-node'
99
import { simLinkPath } from './sim-link'

apps/sim/app/workspace/[workspaceId]/home/components/chat-context-kind-registry/chat-context-kind-registry.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { AgentSkillsIcon, McpIcon } from '@/components/icons'
1414
import { getDocumentIcon } from '@/components/icons/document-icons'
1515
import type { ChatContextKind, ChatMessageContext } from '@/app/workspace/[workspaceId]/home/types'
16-
import { getBareIconStyle } from '@/blocks/icon-color'
16+
import { getBareIconStyle } from '@/blocks/brand-icon-style'
1717
import { getBlockRegistry } from '@/blocks/registry'
1818

1919
interface RenderIconArgs {

apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/agent-group/tool-call-item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import { getReadTargetBlock } from '@/lib/copilot/tools/client/read-block'
1313
import { extractStreamingStringArgument } from '@/lib/copilot/tools/streaming-args'
1414
import { getToolStatusDisplayTitle, getWaitCountdownTitle } from '@/lib/copilot/tools/tool-display'
15-
import { getBareIconStyle } from '@/blocks/icon-color'
15+
import { getBareIconStyle } from '@/blocks/brand-icon-style'
1616
import { getBlockByToolName } from '@/blocks/registry'
1717
import type { ToolCallStatus } from '../../../../types'
1818
import { resolveToolDisplayState } from '../../utils'

apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-registry/resource-registry.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import type {
2121
MothershipResource,
2222
MothershipResourceType,
2323
} from '@/app/workspace/[workspaceId]/home/types'
24-
import { getBareIconStyle, type StyleableIcon } from '@/blocks/icon-color'
24+
import { getBareIconStyle, type StyleableIcon } from '@/blocks/brand-icon-style'
2525
import { logKeys } from '@/hooks/queries/logs'
2626
import { mothershipChatKeys } from '@/hooks/queries/mothership-chats'
2727
import { scheduleKeys } from '@/hooks/queries/schedules'

apps/sim/app/workspace/[workspaceId]/home/components/suggested-actions/suggested-actions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import { useParams } from 'next/navigation'
99
import { usePostHog } from 'posthog-js/react'
1010
import { GmailIcon, SlackIcon } from '@/components/icons'
1111
import {
12-
getAllBlockMeta,
1312
INTEGRATIONS,
1413
type OAuthServiceMatch,
1514
resolveOAuthServiceForIntegration,
1615
resolveOAuthServiceForSlug,
1716
} from '@/lib/integrations'
1817
import { captureEvent } from '@/lib/posthog/client'
1918
import { ConnectOAuthModal } from '@/app/workspace/[workspaceId]/components/connect-oauth-modal'
20-
import { getBareIconStyle } from '@/blocks/icon-color'
19+
import { getBareIconStyle } from '@/blocks/brand-icon-style'
20+
import { getAllBlockMeta } from '@/blocks/registry'
2121
import type { ModuleTag } from '@/blocks/types'
2222
import { useWorkspaceCredentials } from '@/hooks/queries/credentials'
2323
import { useKnowledgeBasesQuery } from '@/hooks/queries/kb/knowledge'

apps/sim/app/workspace/[workspaceId]/logs/logs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import type {
3333
WorkflowLogSummary,
3434
} from '@/lib/api/contracts/logs'
3535
import { dollarsToCredits } from '@/lib/billing/credits/conversion'
36+
import { formatDateShort } from '@/lib/core/utils/date-display'
3637
import {
3738
getEndDateFromTimeRange,
3839
getStartDateFromTimeRange,
@@ -91,7 +92,6 @@ import {
9192
DELETED_WORKFLOW_LABEL,
9293
extractRetryInput,
9394
formatDate,
94-
formatDateShort,
9595
getDisplayStatus,
9696
type LogStatus,
9797
parseDuration,

apps/sim/app/workspace/[workspaceId]/logs/utils.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -188,31 +188,6 @@ export function formatLatency(ms: number): string {
188188
return formatDuration(ms, { precision: 2 }) ?? '—'
189189
}
190190

191-
export function formatDateShort(dateStr: string): string {
192-
const hasTime = dateStr.includes('T')
193-
const [datePart, timePart] = dateStr.split('T')
194-
const [, month, day] = datePart.split('-').map(Number)
195-
const months = [
196-
'Jan',
197-
'Feb',
198-
'Mar',
199-
'Apr',
200-
'May',
201-
'Jun',
202-
'Jul',
203-
'Aug',
204-
'Sep',
205-
'Oct',
206-
'Nov',
207-
'Dec',
208-
]
209-
const dateLabel = `${months[month - 1]} ${day}`
210-
if (hasTime && timePart) {
211-
return `${dateLabel} ${timePart.slice(0, 5)}`
212-
}
213-
return dateLabel
214-
}
215-
216191
export const formatDate = (dateString: string) => {
217192
const date = new Date(dateString)
218193
return {

apps/sim/app/workspace/[workspaceId]/settings/billing/credit-usage/credit-usage-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { useRouter } from 'next/navigation'
1818
import { useQueryStates } from 'nuqs'
1919
import type { UsageLogEntry, UsageLogPeriod } from '@/lib/api/contracts/user'
2020
import { formatApportionedCreditCost, formatCreditsLabel } from '@/lib/billing/credits/conversion'
21+
import { formatDateShort } from '@/lib/core/utils/date-display'
2122
import { USAGE_LOG_SOURCE_LABELS } from '@/app/api/users/me/usage-logs/source-labels'
22-
import { formatDateShort } from '@/app/workspace/[workspaceId]/logs/utils'
2323
import {
2424
creditUsageParsers,
2525
creditUsageUrlKeys,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { getWorkflowSearchLabelHighlight } from '@/app/workspace/[workspaceId]/w
2424
import { useDependsOnGate } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-depends-on-gate'
2525
import { useSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-value'
2626
import { useActiveSearchTarget } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/providers/active-search-target-provider'
27-
import { getBareIconStyle, type StyleableIcon } from '@/blocks/icon-color'
27+
import { getBareIconStyle, type StyleableIcon } from '@/blocks/brand-icon-style'
2828
import type { SubBlockConfig } from '@/blocks/types'
2929
import { useWorkspaceCredential, useWorkspaceCredentials } from '@/hooks/queries/credentials'
3030
import { useOAuthCredentials } from '@/hooks/queries/oauth/oauth-credentials'

0 commit comments

Comments
 (0)