Skip to content

fix(agents): stop reporting an uninstall that removed nothing - #713

Open
Adam-Dalloul wants to merge 1 commit into
xintaofei:mainfrom
Adam-Dalloul:fix/agent-uninstall-reports-truth
Open

fix(agents): stop reporting an uninstall that removed nothing#713
Adam-Dalloul wants to merge 1 commit into
xintaofei:mainfrom
Adam-Dalloul:fix/agent-uninstall-reports-truth

Conversation

@Adam-Dalloul

Copy link
Copy Markdown
Contributor

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:

[ACP][OpenCode] No cached binary; using system C:\Users\...\.local\bin\opencode.exe from PATH

There is no managed tree for that agent, so clear_agent_cache takes its !dir.exists() early return, acp_uninstall_agent_core reports Ok, 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_cache returns whether it actually removed a managed tree.
  • acp_uninstall_agent_core re-probes after the removal and builds its completion line from what really happened, naming the version that survived.
  • The agent settings panel reads the same re-probe instead of assuming, so the row keeps showing what is genuinely installed and the toast says an outside install is still in use.

Tests: uninstall_completion_message_reports_what_actually_happened pins all four outcomes and fails on the old unconditional message; survivingInstallVersion covers 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.

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.
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.

1 participant