Repository navigation
perf(desktop): ship the bundled CLI version instead of spawning for it - #49762
Merged
Merged
Conversation
This was referenced Sep 18, 2026
Every launch spawned the bundled 200 MB CLI executable for --version and waited ~380 ms for it before the background service, WSL support and, because windows are created after every layer builds, the window itself. The version only changes when an update replaces the executable, so keep it in the settings store keyed by the executable's path, size and mtime and only spawn when that identity changes. Packaged build, warm service, 5 launches (median ms since spawn): renderer process 851 -> 512, window visible 1085 -> 778, shell visible 1289 -> 961.
The prebuild copies the CLI out of an npm package directory whose package.json version is exactly what the executable prints for --version, so write it to resources/opencode-cli.version and package it with the executable. The desktop reads that file first, which means a packaged app never spawns the CLI for its version, including the first launch after an install or update (previously ~400 ms, or seconds while the antivirus scanned the fresh binary). The per-identity cache remains as the fallback for an executable without the file. afterPack fails the package when the version file is missing or empty.
Hona
force-pushed
the
cli-version-cache
branch
from
September 18, 2026 23:33
5c2eaad to
a0f5811
Compare
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
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.
Every launch spawned the bundled 240 MB CLI executable just to read its version string, and the main process waited ~380 ms for it before the background service, WSL support and — because windows are created after every layer has built — the window itself. On the first launch after an install or update it was worse: ~3 s while the antivirus scanned the freshly staged binary.
Two commits:
@opencode/cli-<target>@<version>for dev,OPENCODE_CLI_DIST/<target>/for beta/prod) whosepackage.jsonversion is exactly the string the executable prints for--version. It now writes that toresources/opencode-cli.version; electron-builder packages it next to the executable andafterPackfails when it is missing or empty. The desktop reads it first — a packaged app never spawns the CLI for its version, first launch included.(bench timeline, fresh profile, so the 90 ms staging copy of the executable is also visible)
Measured with
bun run bench:startup(#49758): packagedv2build, isolated home, warm service, 5 launches, median ms since process spawn.