v0.21.2.0 fix(remote): self-heal unregistered remote projects after Add Project#55
Merged
Merged
Conversation
Adds a per-row project_root field (absolute path of the project on the host) to LsJSONWorkspace and the matching laptop-side RemoteWorkspace parser. Additive — older laptops ignore the field, older remotes leave it empty. No behavior change yet; consumed in the next commit.
…project warnings Three compounding pieces of the "I added a project on tower from the TUI, the toast said success, but Enter on its (main) row errors with project not registered for that host" trap, fixed end to end. - refreshRemoteCmd calls a new autoRegisterRemoteOrphans helper on every tick. For each (host, project) pair the remote reported a project_root for and the laptop's hosts.json doesn't have, validate the path and reg.AddProject it. Skips errored hosts, dedups across workspaces of the same project, no-ops when project_root is empty (older remotes). Same path-safety contract as the v0.20 result-file channel. - registerRemoteAddProject now returns the reason it couldn't auto-register instead of swallowing it into a log warning. The success toast carries a "⚠ <reason>" follow-up with the literal manual-recovery command, and the toast window stretches from 3s to 8s when a warning is present so the user can read and copy it. - update_attach.go's "project not registered for that host" hint was pointing at canopy project add --host, but the CLI only accepts --on. Fixed the flag and put the project name in the right argv slot. Six regression tests cover all three branches (attach error wording, toast with/without warning, orphan registration happy path, no-op for empty project_root, path validation rejection, errored-host skip).
Co-Authored-By: Claude Opus 4.7 <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.
Summary
Closes the trap where adding a remote project from the TUI looked successful but attaching to its
(main)row errored withproject not registered for that host— and the suggested recovery command used a flag the CLI doesn't accept.Wire protocol
canopy ls --jsonemits a new per-rowproject_rootfield (absolute path on the host). Additive; pre-v0.21.2 laptops parse and ignore.Self-heal
refreshRemoteCmdnow callsautoRegisterRemoteOrphanson every tick. For each(host, project)pair the remote sent aproject_rootfor and the laptop'shosts.jsondoesn't have, validate the path against the same safety contract as the v0.20 result-file channel andreg.AddProjectit. Idempotent. No-op when the remote is too old to send the field.Surface failures, don't swallow them
registerRemoteAddProjectreturns the reason it couldn't auto-register instead of dropping it into~/.canopy/log/canopy.log. The success toast renders⚠ <reason>with the literal manual-recovery command and stretches from 3 s to 8 s so the user can copy it.Correct the broken hint
update_attach.go:211was suggestingcanopy project add --host tower <path>, butcanopy project addaccepts--on, not--host. Fixed flag and arg order.Test Coverage
Six regression tests in
internal/ui/remote_project_recovery_test.go:TestAttachRemoteRow_NotRegisteredErrorWording— asserts--onand correct arg orderTestShowAddProjectToast_WarningRendersInToast— toast carries warning + extended expiryTestAutoRegisterRemoteOrphans_RegistersUnknownProject— happy path + dedup + on-disk persistenceTestAutoRegisterRemoteOrphans_SkipsEmptyProjectRoot— older-remote graceful degradationTestAutoRegisterRemoteOrphans_RejectsInvalidPath— relative paths and control chars rejectedTestAutoRegisterRemoteOrphans_SkipsFailedHost— errored hosts don't poison the registryAll paths in the diff have direct test coverage.
go test ./...andgo test -tags=e2e ./...both pass.Caveat
The self-heal needs the remote canopy to also be on v0.21.2+ (so it emits
project_root). For users whose remote is still pre-v0.21.2, the corrected attach error message gives them a copy-pasteable manual recovery command.Test plan
go test ./...passesgo test -tags=e2e ./...passesgo build ./...clean🤖 Generated with Claude Code