Skip to content

fix(desktop): prune stale CLI stages in packaged builds - #53618

Closed
nedu-m wants to merge 1 commit into
anomalyco:v2from
nedu-m:fix/desktop-cli-prune-stages
Closed

nedu-m wants to merge 1 commit into
anomalyco:v2from
nedu-m:fix/desktop-cli-prune-stages

Conversation

@nedu-m

@nedu-m nedu-m commented Oct 6, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #53617

Type of change

  • Bug fix

What does this PR do?

The desktop app keeps every CLI build it stages under userData/cli/<version>/. The cleanup for those already exists, cleanStages in desktop-cli.ts, but its only call site in background-service.ts was guarded by isolated, which is !app.isPackaged && OPENCODE_DESKTOP_ISOLATED_SERVER === "1". That is false in every packaged build, so the cleanup never ran for released apps, while installCli still staged a new copy whenever the bundled CLI version changed. Each copy is about 175 MB, so the folder grew on every update. I had 1.4 GB across 8 builds.

This makes the prune run under the same condition that triggers staging, app.isPackaged || isolated. A non-isolated dev app still skips it, since it runs the repo binary in place and must not remove anything from the resources directory.

The dev branch has a different desktop implementation (background-cli.ts) whose installCli has no pruning at all, so it likely needs its own fix. This PR only covers the v2 line.

How did you verify your code works?

I traced the staging and cleanup paths to confirm they now share one condition, and checked the shipped 2.0.24 bundle to confirm cleanStages is present and was simply unreachable in production. I did not run the suite here, because a full monorepo install was not practical on this machine, so I have left the local-test box unticked rather than claim otherwise.

There is no test for this. desktop-cli.ts imports electron and a Vite ?raw asset at load, so it is not importable from the bun test harness as it stands. If you want coverage, I can extract the pruning loop into an electron-free module like store-cleanup.ts and add a test, either here or as a follow-up.

Screenshots / recordings

No UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

cleanStages only ran when the isolated dev server was enabled
(!app.isPackaged && OPENCODE_DESKTOP_ISOLATED_SERVER=1), so released
builds staged a new CLI copy on every version change and never removed
older ones. Each stage is roughly 175 MB, so userData/cli grew without
bound.

Prune under the same condition that triggers staging
(app.isPackaged || isolated) so packaged builds clean up on startup.

Fixes anomalyco#53617
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@nedu-m

nedu-m commented Oct 8, 2026

Copy link
Copy Markdown
Author

Superseded by #53659, which landed the same fix on v2: staged CLI pruning now gates on app.isPackaged || isolated (this PR's change) and adds cli-stages.ts plus tests. After rebasing, the only delta this branch would still carry is a named staged const, which is cosmetic, so I'm closing this to avoid a redundant merge. Thanks!

@nedu-m nedu-m closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant