Skip to content

fix(desktop): delete old staged CLI versions - #53659

Merged
Hona merged 3 commits into
anomalyco:v2from
Hona:desktop-cli-cleanup
Oct 7, 2026
Merged

Hona merged 3 commits into
anomalyco:v2from
Hona:desktop-cli-cleanup

Conversation

@Hona

@Hona Hona commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Desktop copies its bundled CLI to userData/cli/<version>/ and runs the background service from that copy. Packaged builds never deleted old copies, so each update added about 200 MB. One install had 7 versions (1.4 GB).

flowchart LR
  A[Launch vN] --> B[Stage cli/vN]
  B --> C[ensure service vN]
  C --> D[Ready]
  C -. forked .-> E[Delete every cli/* except vN]
Loading
  • Run the existing cleanStages in packaged builds too. Before, only dev isolated mode ran it.
  • Run it after the service runs the current version, so no live process uses an older copy. On Windows, if an old service has not exited yet, the delete fails, gets logged, and runs again on the next launch.
  • Fork the cleanup so it does not delay the first window. A failure is logged and does not stop startup.
  • Keep the app.isPackaged || isolated check. Plain dev builds run the CLI from the source tree, which must not be cleaned.
  • A downgrade still works: installCli stages the copy again when its folder is missing.
  • Fix the v2 CLI command failed log. Effect.tryPromise wraps the execFile error, so the log always showed "An error occurred in Effect.tryPromise" with empty stdout and stderr. It now reads them from error.cause. The version cache is now parsed with a schema instead of typeof checks.
  • Move cleanStages to cli-stages.ts (no Electron import) and add a table test for upgrade, downgrade, prerelease, and only-current.

Nothing else references the old copies. "Install CLI" (macOS) and the WSL and SSH remote installers copy the binary. The service's Windows retained-image links are in the global cache.

@Hona
Hona requested a review from Brendonovich as a code owner October 7, 2026 01:53
Copilot AI balanced review requested due to automatic review settings October 7, 2026 01:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Hona
Hona enabled auto-merge (squash) October 7, 2026 02:04
@Hona
Hona merged commit a2b6005 into anomalyco:v2 Oct 7, 2026
9 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