Commit d1b0184
authored
improvement(perf): cut server-only and unused code out of the workspace client bundles (#6975)
* improvement(perf): cut server-only and unused code out of the workspace client bundles
Every workspace route shipped JavaScript it never executes. Four independent
import edges, each fixed by moving a symbol rather than changing behaviour:
- js-tiktoken's BPE rank tables (5.4 MB source / 2.5 MB wire) reached the
workflow editor because the tokenization barrel re-exported the exact
counters alongside the character heuristics. Split into
lib/tokenization/accurate.ts, which the barrel no longer re-exports.
- crypto-browserify (~105 KB gzip, all 26 workspace routes) came from the
Salesforce and Gong triggers importing webhook provider modules that reach
node:crypto through @sim/security. The two symbols they actually needed are
now in crypto-free modules.
- tables, files and knowledge each imported one dependency-free hook from the
sidebar-hooks barrel, whose other exports reach the 5 MB generated
tool-metadata artifact. Deep-imported per the code-splitting rule in
sim-imports.md.
- lib/workflows/subblocks/display.ts imported a string constant from a React
module under app/, inverting the app/lib layering. Moved to lib/.
Also adds a loading boundary to chat/[chatId]. Without one, a dynamic route is
prefetched as nothing, so clicking a chat held the previous chat on screen for
the whole server round trip.
Measured on a production build, JS downloaded before the load event:
/w/[workflowId] 7.38 MB -> 4.80 MB (-35%)
/logs 4.57 MB -> 4.44 MB
/knowledge 4.35 MB -> 4.22 MB
/home 4.57 MB -> 4.44 MB
crypto-browserify no longer appears in any shipped chunk. The tool-registry
boundary baseline is retightened so the reclaimed graph weight cannot silently
regress.
* improvement(sidebar): move useContextMenu to shared hooks
Review flagged the four workspace routes deep-importing `useContextMenu` from
the sidebar's hooks barrel as a barrel-convention violation. Fair — the
code-splitting exception in sim-imports.md is written for `lazy()` splits, and
these are static imports.
The hook was in the wrong place to begin with. It is entirely generic — no
sidebar-specific references, just right-click state and positioning — and nine
consumers across tables, files, knowledge, home, the terminal and the preview
editor already reached across features to get it. Moved to `@/hooks`, the
repo's shared-hooks location, and every consumer including the sidebar's own
now imports it from there.
This satisfies the barrel convention rather than making an exception to it, and
keeps the graph win: tables, knowledge and files stay off the sidebar barrel's
path to `stores/workflow-diff -> serializer -> tools/metadata`, unchanged at
20.19 / 20.89 / 21.37 MB of reachable source.1 parent 3a04426 commit d1b0184
39 files changed
Lines changed: 445 additions & 380 deletions
File tree
- apps/sim
- app/workspace/[workspaceId]
- chat/[chatId]
- files
- home/components/mothership-view/components/resource-content/components/terminal-session
- knowledge
- [id]
- [documentId]
- components/chunk-editor
- logs
- components
- dashboard/components/workflows-list
- log-details
- settings/secrets/[credentialId]/components/secret-usage-panel
- tables
- w
- [workflowId]/components
- panel/components/editor/components/sub-block/components/workflow-selector
- terminal
- components/output-panel
- components
- preview/components/preview-editor
- sidebar
- components/workflow-list
- components
- folder-item
- workflow-item
- hooks
- executor/handlers/agent
- hooks
- lib
- embeddings
- tokenization
- webhooks/providers
- workflows
- subblocks
- triggers
- gong
- salesforce
- scripts
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | 131 | | |
133 | 132 | | |
134 | 133 | | |
| |||
147 | 146 | | |
148 | 147 | | |
149 | 148 | | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | | - | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
| |||
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | 100 | | |
102 | 101 | | |
103 | 102 | | |
| |||
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
| |||
92 | 91 | | |
93 | 92 | | |
94 | 93 | | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | | - | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
61 | | - | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | | - | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
0 commit comments