You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(runtime): sleep and stop resolve project-group folder workspaces - #35082
Choosing Sleep on a folder workspace in a project group always failed with "Failed to sleep workspace", and no terminal stopped. Sleep and stop now find these workspaces the same way opening a terminal already does.
What Changed
Before: Sleep, stop, close-all and exact-stop looked the workspace up with the Git-only selector resolver. That resolver lists only rows that come from repos. A project-group folder workspace (folder:<uuid>) has no repo row, so every call failed with selector_not_found. The renderer then showed the generic "check the host connection" toast.
After: One shared resolver in session-graph-authority.ts, resolveWorkspaceSelector, tries the folder workspace first and then falls back to Git. Browser, emulator and the four stop-family commands all use it.
Browser still requires a usable folder path (requireUsableFolderPath).
Sleep and stop don't, so you can still sleep a workspace whose folder is gone.
No new resolver was added. The folder branch is the same resolveFolderWorkspaceSelector / resolveFolderWorkspaceLaunchScope code that launch and file targets already use.
Why
The stop family was the only workspace-wide path that never got the folder branch. The regression likely dates from #31564, which moved sleep into main. Teaching the Git resolver about folder keys was the alternative. I didn't take it: about 50 callers, removal among them, depend on it matching Git rows only.
Linked Issue
Fixes STA-12562. Reported through Orca feedback by toshi-brain, thanks for the detailed trace.
Visual Proof
N/A. The change is in runtime resolution. The visible result is that Sleep succeeds instead of showing an error toast.
Testing
Automated tests added/updated. src/main/runtime/project-group-folder-workspace-sleep.test.ts fails on main with selector_not_found and passes with this change.
Every test file that imports or calls the changed methods: 35 files, 1980 tests, all passed. This covers the sleep/teardown/stop-exact specs, the browser and emulator tests, folder-workspace PTY identity and the PTY launch parity tests.
Codex review: clean. Independent Opus review: no P0–P2. Its P3 notes are for follow-ups: SSH folder rows missing connectionId fail safe, and stop/close/SSH-fence cases could get more test coverage.
Notes
Host fencing is unchanged. Folder workspaces take their host from executionHostId, then connectionId, then local, so SSH, runtime and WSL folders are still stopped only on their own host. This is all in main, so client/server versions don't matter and the wire is unchanged.
The change adds a shared resolver for folder workspace and Git worktree selectors. Emulator and browser workspace lookup use this resolver. Terminal close, stop, sleep, and exact-stop operations now use it as well. A regression test covers sleeping a project-group folder workspace without a repo row.
Priority: Normal
Merge Risk: Moderate · up to 5a6e7
Sleep, stop and close now work for project-group folder workspaces, but for folders that inherit an SSH host from their group, close and stop can leave remote terminals running. Runtime-hosted folder sleep state can also fail to block new terminals. Resolve the folder's effective host before merging, or accept these gaps explicitly.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title names the main change: sleep and stop now resolve project-group folder workspaces. It follows the fix(runtime) convention and is specific, though it omits close-all and exact-stop.
Description check
The description follows the template. It has ELI5, What Changed, Why, Linked Issue (STA-12562, though it is not in the 'Fixes #' form), Visual Proof marked N/A with a reason, Testing with a checked au…
Docstring Coverage
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description follows the template. It has ELI5, What Changed, Why, Linked Issue (STA-12562, though it is not in the 'Fixes #' form), Visual Proof marked N/A with a reason, Testing with a checked automated-tests box, and Notes covering host fencing and wire compatibility. The Review, Agent skill upstream boundary, and AI Disclosure sections are absent. The Linked Issue uses a Jira-style ID rather than a GitHub issue number, and the 'Fixes #' placeholder was replaced, so a reviewer should confirm it meets the outside-contributor linking rule. The manual testing box is unchecked, and the checklist is not filled in.
Resolution
Optional cleanup: confirm the linked issue meets the repository's linking rule (replace the STA-12562 reference with a 'Fixes #' GitHub issue if one exists). Tick the manual-testing box if manual testing was done, or state that it was not. Add the Agent skill upstream boundary and AI Disclosure answers, or mark them not applicable. Tick the checklist items once they are confirmed.
Full details: Docstring Coverage
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 5 files.
Finishing Touches
📝 Generate docstrings
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Functional Correctness · Heavy lift
Preserve the folder workspace’s resolved host.
If a folder inherits an SSH connection from its project group, folderWorkspaceToResolvedWorktree(folderWorkspace) assigns a local host when the folder row has no connectionId. Folder path resolution explicitly supports that inheritance. closeTerminalsForWorktree and stopTerminalsForWorktree then apply a local PTY fence and can leave the remote terminals running. Resolve the folder’s host before conversion, and use the same host for launch and teardown. (raw.githubusercontent.com)
Key runtime-hosted folder sleeps by their runtime host.
For a folder workspace whose executionHostId is runtime:…, resolveSleepScope drops the runtime host before it builds the sleep key. The key becomes the local host key, so sleep state for that folder does not match the key that spawns on the runtime host check. A runtime-hosted terminal can then spawn while the folder is asleep. Build the sleep key from the resolved host id, not from the SSH connection id.
This path only became reachable for folder workspaces through the selector change in this PR. The key collapse itself is in the shared resolver and would also affect Git worktrees whose repo row is runtime-hosted.
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
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.
ELI5
Choosing Sleep on a folder workspace in a project group always failed with "Failed to sleep workspace", and no terminal stopped. Sleep and stop now find these workspaces the same way opening a terminal already does.
What Changed
folder:<uuid>) has no repo row, so every call failed withselector_not_found. The renderer then showed the generic "check the host connection" toast.session-graph-authority.ts,resolveWorkspaceSelector, tries the folder workspace first and then falls back to Git. Browser, emulator and the four stop-family commands all use it.requireUsableFolderPath).resolveFolderWorkspaceSelector/resolveFolderWorkspaceLaunchScopecode that launch and file targets already use.Why
The stop family was the only workspace-wide path that never got the folder branch. The regression likely dates from #31564, which moved sleep into main. Teaching the Git resolver about folder keys was the alternative. I didn't take it: about 50 callers, removal among them, depend on it matching Git rows only.
Linked Issue
Fixes STA-12562. Reported through Orca feedback by toshi-brain, thanks for the detailed trace.
Visual Proof
N/A. The change is in runtime resolution. The visible result is that Sleep succeeds instead of showing an error toast.
Testing
src/main/runtime/project-group-folder-workspace-sleep.test.tsfails on main withselector_not_foundand passes with this change.pnpm check:changed --maxWorkers=2: 20 checks passed.connectionIdfail safe, and stop/close/SSH-fence cases could get more test coverage.Notes
Host fencing is unchanged. Folder workspaces take their host from
executionHostId, thenconnectionId, then local, so SSH, runtime and WSL folders are still stopped only on their own host. This is all in main, so client/server versions don't matter and the wire is unchanged.