nanocoder
nanocoder copied to clipboard
[Bug] `clipboardy` (and its `execa`/`semver` chain) is loaded at startup only for a copy button in the model database view
Description
ModelDatabaseDisplay is imported statically by the modal selectors, and source/commands/model-database.tsx imports clipboardy at the top only for a copy action. clipboardy pulls in execa (113 modules), get-stream, human-signals and, through clipboard-image -> run-jxa -> macos-version, semver (46 modules), even on Linux and Windows.
Environment
- OS: Windows 11 (10.0.26300)
- Node version: 22.22.3
- Nanocoder version: 1.31.0 (main at 5c2e6935)
Steps to Reproduce
- Build, then register a
module.registerHooksloadhook that counts loaded files. - Import
dist/app/index.jsand list the modules undernode_modules/execaandnode_modules/semver. - Follow the import chain from
App.js.
Evidence
- Chain:
app/App.js -> app/sections/interactive-app.js -> app/components/modal-selectors.js -> commands/model-database.js -> clipboardy/index.js -> clipboard-image -> run-jxa -> macos-version -> semver/index.js(source/app/components/modal-selectors.tsx:2,source/commands/model-database.tsx:1). - Blocking the edges into
clipboardyandexecain the startup import graph removes 232 of 1,459 modules (16%). clipboardyis also used bysource/commands/copy.tsandcommit.ts, but those are lazy commands, so onlymodel-databasematters.
Proposed Change
- In
source/commands/model-database.tsx, replace the top-level import withconst {default: clipboard} = await import('clipboardy')inside the copy handler. - Optionally lazy-load the component itself from
modal-selectors.tsx, the waylazy-registry.tsdoes for commands.
Expected Behavior
- The startup module list contains no
execa,semverorclipboardy. - Copying from the model database view still works.
pnpm run test:allpasses.
Additional Context
- Effort: S. Start with
source/commands/model-database.tsxandsource/app/components/modal-selectors.tsx. - Estimated saving: about 0.6-0.9 s on the test host (about 2.5-4 ms per module, mostly file-system calls); far less on a fast SSD with a warm cache. Confidence high on the module count, medium on the time.
- Risk: the first copy pays the import once. Specs:
modal-selectors.spec.tsx,model-database.spec.tsx.
hi @addyCooks can i take this one..
Go for it @Vishesh-Verma-07 !