perf(frontend): keep editor/terminal stacks out of unrelated surfaces - #830
Merged
Neonforge98 merged 2 commits intoAug 17, 2026
Merged
Conversation
The WorkStation shared barrel (imported by ~80 files) re-exported three heavy edges — GitFileDiffSplit (dead code → all of CodeMirror), the SidebarModules block (evaluates the Terminal tab sidebar → xterm) and QuickActionsPanel (framer-motion) — so TeamInbox, ProjectManager, Settings, Simulator and even the agent-message renderer statically reached the editor and terminal stacks. Cut those re-exports (CodeEditor keeps its explicit SidebarModules import for the registrations), delete the unreferenced GitFileDiffSplit, and lazy-load the remaining on-demand users: agent-message SimulatorMessages (same pattern as user-message/thinking; drops its static reach from 1747 files incl. xterm/CodeMirror/react-syntax-highlighter/highlight.js/recharts/mammoth/jszip to none of them), SessionRawTranscriptDialog content, CanvasPreviewSurface A2UIRenderer/ReactArtifactRunner, SkillsCategoryView SkillEditorPanel, MarkdownEditor CodeMirrorEditor, CanvasApp source viewer. Editor-only consumers deep-import features/CodeMirror/Editor instead of the barrel. Guard: src/app/root/__tests__/featureBoundaries.test.ts asserts nine lazily loaded surfaces stay free of the editor/terminal/highlighter/chart stacks. Pre-commit hook ran. Total eslint: 14, total circular: 0
Pre-commit hook ran. Total eslint: 0, total circular: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second frontend RAM pass: stop the CodeMirror / xterm / syntax-highlighter / chart stacks from being loaded by surfaces that never render them. Measured with a static import-graph walk per lazy chunk root (
src/test/staticImportGraph.ts), before → after:engines/ChatPanel/events/stream/agent-message(every chat message)modules/MainApp/TeamInboxmodules/MainApp/Settings/SettingsSlotmodules/MainApp/AgentOrgsmodules/ProjectManager/{Projects,WorkItems,LinearProjects}engines/Simulator/indexmodules/WorkStation/shared/index.ts(barrel, ~80 importers)Production build: 565 → 583 chunks (new lazy boundaries), duplicated-module bytes 1.86 MB → 1.54 MB, total unchanged (code moves between chunks — the win is what a given surface loads into the heap).
Problem
modules/WorkStation/shared/index.tsre-exported three heavy edges:GitFileDiffSplit(unreferenced dead code → all offeatures/CodeMirror), theSidebarModulesblock (whose module evaluation registers the Terminal tab sidebar →engines/TerminalCore→ xterm + addons), andQuickActionsPanel(framer-motion). ~80 files import that barrel, so every workstation, PM, inbox and settings surface — and the agent-message renderer viaChat/Communication— statically reached the editor and terminal stacks.SimulatorMessagesinagent-message(its siblingsuser-message/thinkingalready lazy it), the raw-transcript content inSessionRawTranscriptDialog(its sibling view already lazies it),A2UIRenderer(recharts/@a2ui) andReactArtifactRunner(sucrase + embedded React runtime) insideCanvasPreviewSurface,SkillEditorPanelin Settings,CodeMirrorEditorinsideMarkdownEditor, the canvas "source" tab viewer.features/CodeMirrorbarrel, which also carries Diff, ConflictEditor, SqlEditor + sql-formatter.Solution
CodeEditor/index.tsximportsSidebarSlotfrom../shared/SidebarModules— the same import that already carried the side-effect registrations, so tab-sidebar registration is unchanged. Delete the unreferencedGitFileDiffSplit.React.lazy+Suspense fallback={null}at the on-demand render sites listed above (all follow existing precedents in the same files/siblings).@src/features/CodeMirror/Editorat the seven editor-only consumers.src/app/root/__tests__/featureBoundaries.test.ts: nine surfaces asserted free of the editor/terminal/highlighter/chart stacks; failure output prints the import chain.Potential risks
CodeEditor/index.tsximporting../shared/SidebarModules(previously the barrel evaluated it as a side effect for everyone). CodeEditor is the only host that resolvesSidebarSlot, so this is intended, but a future host in another module must importSidebarModulestoo — noted in the barrel comment.Validation / Test plan
pnpm typecheckclean;eslintclean on touched files (pre-commit lint-staged passed).pnpm test: 1110 files / 8720 tests green (includes the new boundary guard and the perf(frontend): break down the startup bundle and bound frontend leaks #829 guards).