Repository navigation
fix: restore every adopted client, not just opencode - #64
Merged
Merged
Conversation
"Restore all" on the Clients page, and the uninstall flow that reuses it,
looped over the detected clients and asked core to restore each one by its
display name. Core routes /clients/{id}/restore and looks clients up by id,
so only opencode was ever restored — it is the one client whose id and
display name are the same string. "Claude Code" and "Codex CLI" failed
before the request left the app, because a space cannot go into a URI;
"Zed" and "Aider" came back 404 "unknown client Zed".
Uninstall inherited all of it, and that is where it hurt: the step meant to
hand the user's other software back before this app goes away reported four
failures out of five and left those clients pointing at a gateway that was
about to disappear. The single-client button was never affected — it passes
c.id — so the bug only showed on the path a user takes once, at the moment
they have decided to leave.
Address core by id and keep the display name for what the user reads. The
choice now happens in restore_targets(), which returns (id, name) pairs for
the adopted clients, so a test can pin which field goes into the URL. That
test keeps opencode in the fixture on purpose: an id that happens to equal
its name is what made the wrong field look like it worked.
Also move restore_all's doc comment back onto restore_all — it had been
sitting on quit_app since #12.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The bug
restore_allinsrc-tauri/src/lib.rslooped over the detected clients and asked core to restore each one by its display name:Core routes
/clients/{id}/restoreand resolves it by id (tw-control/src/clients.rs,find(id)). The two differ for four of the five adoptable clients:claude-codeinvalid uri character(the space)codexzed未知的客户端 Zedaider未知的客户端 AideropencodeSo "Restore all" restored exactly one client, and
uninstall— which reusesrestore_all— inherited it. That is where it matters: the step that hands the user's other software back before the app goes away reported four failures out of five and left those clients pointing at a gateway that was about to disappear.The single-client button was never affected;
Clients.tsxpassesplan.c.id. The bug only appeared on the path a user takes once, at the moment they have decided to leave.The fix
Address core by id, keep the display name for what the user reads (
RestoreOutcome.clientis unchanged, so the toast and the uninstall log still say "Claude Code").tw_api::DetectedClientcarries both fields, so nothing new is needed from core.The choice is factored into
restore_targets(), which returns(id, name)pairs for the adopted clients — that gives the test a seam to pin which field goes into the URL, which is the whole of this bug.Test
restore_addresses_a_client_by_id_and_reports_it_by_namekeepsopencodein the fixture on purpose: an id that happens to equal its name is exactly what made the wrong field look like it worked. Reverting the fix fails it withThe fixture is built from the JSON core actually sends, so the field names
id/name/adopted_at_msare pinned too, and an unrelated field being added toDetectedClientdoes not break the test.Checked in
src-tauri:cargo clippy --all-targets -- -D warningsclean,cargo test105 passed.Also
restore_all's doc comment had been sitting onquit_appsince #12, with the two docs mashed into one block. Moved back.🤖 Generated with Claude Code