Skip to content

fix(build): bound runtime updater UI memory - #1663

Merged
branarakic merged 7 commits into
mainfrom
codex/runtime-build-exclude-evm
Jul 13, 2026
Merged

fix(build): bound runtime updater UI memory#1663
branarakic merged 7 commits into
mainfrom
codex/runtime-build-exclude-evm

Conversation

@branarakic

Copy link
Copy Markdown
Contributor

Summary

Follow-up to merged #1661:

  • make the runtime package plan a first-class module consumed by both the updater build and its regression test, addressing the review on fix(build): keep runtime updates within node limits #1661
  • replace Shiki's full 347-language/66-theme bundle with the 21 supported grammars and two UI themes
  • bound the existing Node UI build to a measured 896 MB V8 old-space ceiling

Why

The current canary rollout exposed two independent contributors to updater pressure. #1661 removed accidental Hardhat/solc compilation and is already on main. The remaining Vite build still imports Shiki's full registry: passing a language allow-list limits runtime initialization, but does not shrink Vite's module graph. Its 4096 MB V8 ceiling can therefore dominate the 1.5 GiB node service cgroup.

The fine-grained Shiki bundle reduces generated JS from 323 files / 13.66 MB to 23 files / 5.97 MB. Four measured UI builds succeeded at the 896 MB heap ceiling, with peak RSS reduced from 1.289 GB to roughly 1.229–1.261 GB. A 768 MB ceiling OOMed and 832 MB was judged too narrow.

This also replaces #1661's escaped package.json filter string with structured roots/exclusions in scripts/lib/runtime-build-plan.mjs; the runner and test consume that one canonical plan.

Validation

  • pnpm run build:runtime:packages (17 workspaces, no Hardhat)
  • pnpm run build:runtime
  • pnpm --dir packages/node-ui test (2,136 passed, 38 skipped)
  • pnpm --dir packages/cli exec vitest run test/node-ui-static.test.ts test/auto-update.test.ts (113 passed)
  • pnpm test:scripts (55 passed)
  • all 21 supported syntax aliases and both themes rendered through the real highlighter
  • four measured UI builds at the 896 MB heap ceiling
  • git diff --check

Comment thread packages/node-ui/src/ui/components/chat/shikiHighlighter.ts Outdated
Comment thread scripts/lib/__tests__/node-ui-shiki-imports.test.mjs
Comment thread packages/node-ui/src/ui/components/chat/shikiHighlighter.ts Outdated
Comment thread packages/node-ui/src/ui/components/chat/shikiLanguages.ts Outdated
Comment thread package.json
Comment thread scripts/build-runtime-packages.mjs Outdated
langs: [...SUPPORTED_LANGS],
}) as Promise<Highlighter>,
highlighterPromise = import('./shikiHighlighter.js').then((shiki) =>
shiki.createHighlighter() as Promise<Highlighter>,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Issue: Finish the Shiki facade instead of keeping half the boundary in CodeBlock

What's wrong
This PR introduces a Shiki facade, but the component still knows too much about the facade internals. The local Highlighter interface plus cast is a loose contract that can drift from the real facade return type, and it makes the abstraction feel unfinished rather than simplifying the component.

Example
Current shape: CodeBlock imports ./shikiHighlighter.js, calls createHighlighter(), casts it to a local Promise<Highlighter>, and owns the singleton promise. That leaves the Shiki boundary split across the React component and the facade.

Suggested direction
Make shikiHighlighter.ts the canonical owner of the highlighter type, singleton promise, and reset-on-error logic. Then CodeBlock can just ask for highlighted HTML and no longer needs a local structural type or cast.

For Agents
Look at CodeBlock.tsx and shikiHighlighter.ts. Preserve lazy loading, the singleton highlighter, and retry-after-failure behavior, but move the highlighter contract/cache into the facade, or export a highlightCode(code, lang, theme)/loadHighlighter() API that is typed at the boundary. Existing CodeBlock and markdown lazy-load tests should keep passing.

@branarakic
branarakic merged commit a85d1c9 into main Jul 13, 2026
46 checks passed
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.

2 participants