fix(agents): stop reporting an uninstall that removed nothing - #713
Open
Adam-Dalloul wants to merge 1 commit into
Open
fix(agents): stop reporting an uninstall that removed nothing#713Adam-Dalloul wants to merge 1 commit into
Adam-Dalloul wants to merge 1 commit into
Conversation
Uninstall only ever removes the copy codeg manages. An agent installed somewhere else, on PATH or in ~/.local/bin or through a package manager, survives it untouched and is still exactly what the next connection launches. Both surfaces claimed otherwise: the install stream always completed with "<name> uninstalled successfully", and the settings panel forced the row to "not installed" and toasted "local version removed", even when nothing had been deleted at all. clear_agent_cache now reports whether it actually removed a managed tree, the uninstall re-probes afterwards, and the completion line names the version that is still there. The panel reads the same re-probe instead of assuming, so the row keeps showing what is really installed. Reported in xintaofei#631, where the reporter's own log has "No cached binary; using system C:\Users\...\.local\bin\opencode.exe from PATH" and the version status came straight back after a successful-looking uninstall.
This was referenced Sep 10, 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.
Fixes the second half of #631: uninstall reports success even when it removed nothing and the agent is still installed.
Uninstall only ever removes the copy codeg manages. An OpenCode that came from
~/.local/bin, a package manager, or anywhere else on PATH survives it untouched and is still exactly what the next connection launches. Both surfaces claimed otherwise: the install stream always completed with<name> uninstalled successfully, and the settings panel forced the agent row to "not installed" and toasted "local version removed", even for an agent codeg had never installed.Reproduction, from the log the reporter attached to the issue:
There is no managed tree for that agent, so
clear_agent_cachetakes its!dir.exists()early return,acp_uninstall_agent_corereportsOk, and the completion line says "uninstalled successfully". The next status read re-probes PATH and puts the version straight back, which is the "假成功" in the issue.What changes:
clear_agent_cachereturns whether it actually removed a managed tree.acp_uninstall_agent_corere-probes after the removal and builds its completion line from what really happened, naming the version that survived.Tests:
uninstall_completion_message_reports_what_actually_happenedpins all four outcomes and fails on the old unconditional message;survivingInstallVersioncovers the probe result the panel branches on.The first half of #631 (the binary cache "never lands where codeg reads it") is a separate matter and is not touched here. I could not reproduce it: the write path and the read path both derive
cache_dir()/<agent>/<version>/<platform>from the same helpers, and the reporter's own log shows the cache genuinely empty rather than misplaced, because enabling an agent does not download anything. I left a note on the issue.