fix(console): report an unusable remote working directory before minting (CHOO-1416) - #373
Open
abeldantas wants to merge 2 commits into
Open
fix(console): report an unusable remote working directory before minting (CHOO-1416)#373abeldantas wants to merge 2 commits into
abeldantas wants to merge 2 commits into
Conversation
…ing (CHOO-1416) Creating a remote agent whose directory's parent didn't exist failed at the first credentials write with a raw FileSystemError, after the identity was already minted on the gateway — leaving an agent that exists in Switch and nowhere else. The directory is the one free-text input in the flow and was only ever touched at write time. inspectRemoteDir answers it in two stats from an fs rooted at the host (one rooted at a missing directory cannot stat its way out): directory and creatable proceed, file and missing are refused before anything is minted, and the modal says which and names the parent to create. Ported from #137 (pre-rename branch); fix only, without that branch's dead-code sweep.
abeldantas
requested review from
amaudruz and
christian-mcdermott
as code owners
September 4, 2026 15:01
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new missing status is documented and messaged as “parent doesn’t exist,” but it can also mean “parent exists but is a file,” producing incorrect user-facing guidance.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR improves the remote-agent creation flow in Switch Console by validating a remote agent’s working directory before minting a gateway identity, preventing orphaned Switch-side agents when the directory is unusable.
Changes:
- Introduces a shared remote working-directory inspection model (
RemoteDirInspection) plus a usability predicate (isUsableRemoteDir). - Adds a main-process SSH-based
inspectRemoteDir()check and wires it intoaddAgentahead of identity registration, returning a typeddirectory-missingfailure. - Extends renderer error handling and telemetry enums to represent the new failure mode, with tests covering the new behavior.
File summaries
| File | Description |
|---|---|
| console/apps/switch-console-desktop/src/shared/core/switch-servers/switch-servers.ts | Extends shared provisioning result union with a typed directory-missing failure payload. |
| console/apps/switch-console-desktop/src/shared/core/remote-hosts/remote-dir.ts | Adds shared inspection/status types and a helper to decide if a remote dir is usable. |
| console/apps/switch-console-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx | Surfaces directory-missing as a user-facing toast in the add-agent modal. |
| console/apps/switch-console-desktop/src/main/core/telemetry/events.ts | Adds directory_missing as a structured failure reason for agent creation telemetry. |
| console/apps/switch-console-desktop/src/main/core/agents/remote-dir.ts | Implements inspectRemoteDir() via an SSH filesystem rooted at / to inspect the target dir and its parent. |
| console/apps/switch-console-desktop/src/main/core/agents/remote-dir.test.ts | Adds focused unit tests for all inspection outcomes and error/cleanup behavior. |
| console/apps/switch-console-desktop/src/main/core/agents/add-agent.ts | Performs the remote dir inspection before minting and returns directory-missing when unusable. |
| console/apps/switch-console-desktop/src/main/core/agents/add-agent.test.ts | Verifies refusal happens before minting and that local adds don’t probe SSH. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Context
That branch had a bunch of dead code and got sort of deprecated.
Summary
inspectRemoteDirdecides in two stats from a host-rooted fs:directoryandcreatable(missing leaf, parent exists) proceed exactly as before;fileandmissingare refused up front.SshFileSystemis untouched: an fs rooted at a working directory still cannot create that directory's ancestors — the fix is ordering, not permission.