Skip to content

fix(runtime): sleep and stop resolve project-group folder workspaces - #35082

Merged
nwparker merged 1 commit into
mainfrom
fix/sta-12562-runtime-catalog
Oct 28, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/sta-12562-runtime-catalog

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​71 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​71
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​24 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11

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

  • 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.
  • pnpm check:changed --maxWorkers=2: 20 checks passed.
  • 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.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

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: Passed 5
Check name Status Explanation
Title check Passed 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 Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f78cf8f6-62f7-4110-8773-093cf2945335
Commits

Reviewing files that changed from the base of the PR and between daf806b and 5a6e74f.

Files selected for processing: 5
  • src/main/runtime/construction/runtime-construction-services.ts
  • src/main/runtime/project-group-folder-workspace-sleep.test.ts
  • src/main/runtime/session-graph/session-graph-authority.ts
  • src/main/runtime/terminal/stop/worktree-terminal-stop-targets.ts
  • src/main/runtime/terminal/stop/worktree-terminal-stop.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

return folderWorkspace
? folderWorkspaceKey(folderWorkspace.id)
: (await this.resolveWorktreeSelector(selector)).id
? this.folderWorkspaceToResolvedWorktree(folderWorkspace)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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)

options: { soleLivePtyId?: string } = {}
): Promise<RuntimeWorktreeTerminalSleepResult> {
const worktree = await this.resolveWorktreeSelector(worktreeSelector)
const worktree = await this.resolveWorkspaceSelector(worktreeSelector)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Stability & Availability · Heavy lift

Supported by static analysis

Script executed:

rg -n 'resolveSleepScope|runtime:' src/main/runtime/terminal/stop/*.ts | head -40
sed -n '240,340p' src/main/runtime/terminal/stop/worktree-terminal-stop.ts

Repository: stablyai/orca

Length of output: 4523


Script executed:

set -u
echo "== resolveSleepScope and helpers =="
rg -n -F -e 'export function resolveSleepScope' -e 'export function hostSleepKey' -e 'function anySleepKeyNames' -- src/main/runtime/terminal/stop/worktree-terminal-sleep-key.ts
sed -n '1,120p' src/main/runtime/terminal/stop/worktree-terminal-sleep-key.ts
echo "== resolveWorkspaceSelector definitions and callers =="
rg -n -F -e 'resolveWorkspaceSelector' -e 'resolveWorktreeSelector' -- src/main/runtime || test "$?" -eq 1
echo "== runtime host handling in folder workspace helpers =="
rg -n -F -e 'runtime:' -- src/shared/folder-workspace-worktree.ts src/shared/folder-workspace-execution-host.ts src/main/runtime/session-graph-authority.ts || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 17822


Script executed:

set -u
echo "== resolveWorkspaceSelector =="
sed -n '150,185p' src/main/runtime/session-graph/session-graph-authority.ts
echo "== resolveWorktreeLaunchHost =="
rg -n -F -e 'export function resolveWorktreeLaunchHost' -- src/main/runtime/worktree-launch-host-repo.ts || test "$?" -eq 1
rg -n -F -e 'export function resolveWorktreeLaunchHost' -A60 -- src/main/runtime/worktree-launch-host-repo.ts || test "$?" -eq 1
echo "== getConnectionExecutionHostId =="
rg -n -F -e 'export function getConnectionExecutionHostId' -A12 -- src/shared/execution-host.ts || test "$?" -eq 1
echo "== folder ResolvedWorktree conversion =="
rg -n -F -e 'runtime:' -e 'executionHostId' -e 'connectionId' -- src/shared/folder-workspace-worktree.ts || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 3596


Script executed:

set -u
echo "== folderWorkspaceToResolvedWorktree =="
rg -n -F -e 'folderWorkspaceToResolvedWorktree' -- src/main/runtime || test "$?" -eq 1
echo "== folder-workspace-worktree.ts full =="
sed -n '1,80p' src/shared/folder-workspace-worktree.ts
echo "== resolveWorktreeHostRouting =="
rg -n -F -e 'export function resolveWorktreeHostRouting' -- src/main/runtime || test "$?" -eq 1
echo "== getSshTargetIdForExecutionHost =="
rg -n -F -e 'export function getSshTargetIdForExecutionHost' -A12 -- src/shared/execution-host.ts || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 5990


Script executed:

set -u
echo "== terminal-workspace-scope folderWorkspaceToResolvedWorktree =="
sed -n '104,130p' src/main/runtime/terminal/launch/terminal-workspace-scope.ts
echo "== resolveWorktreeHostRouting =="
sed -n '20,36p' src/main/runtime/worktree-launch-host-repo.ts

Repository: stablyai/orca

Length of output: 2243


Script executed:

set -u
echo "== hostId fields in folder-workspace-worktree.ts =="
rg -n -F -e 'hostId' -e 'executionHostId' -- src/shared/folder-workspace-worktree.ts || test "$?" -eq 1
echo "== withoutWorktreeLineage =="
rg -n -F -e 'function withoutWorktreeLineage' -A12 -- src/main/runtime || test "$?" -eq 1
echo "== resolveWorktreeExecutionHost =="
rg -n -F -e 'export function resolveWorktreeExecutionHost' -A40 -- src/shared || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 5501


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.

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