Skip to content

Keep empty remote workspaces empty on selection - #19591

Closed
xungua wants to merge 5 commits into
stablyai:mainfrom
xungua:xungua/pr-empty-workspace-20260908
Closed

xungua wants to merge 5 commits into
stablyai:mainfrom
xungua:xungua/pr-empty-workspace-20260908

Conversation

@xungua

@xungua xungua commented Sep 8, 2026 •

Copy link
Copy Markdown

ELI5

Selecting an empty remote workspace leaves it empty.

What Changed

Remove activation/snapshot auto-creation and the unused wake predicate; preserve manual creation and existing-tab recovery.

Why

Workspace selection is not permission to create a shell.

Linked Issue

Fixes #17681.

Visual Proof

Actual Orca Electron UI in an isolated profile. The same empty folder workspace runs the pre-fix/final wake functions; remote transport is mocked and terminal creation uses an isolated local shell. Not live SSH validation.

Before — selection creates an unwanted terminal.

Before: an empty workspace gains Terminal 1

After — selection keeps the workspace empty.

After: the workspace stays selected with zero terminal tabs

Testing

443 tests passed on macOS, covering visibility races, wake recovery, manual creation and folder workspaces. Renderer typecheck, changed-file lint and formatting passed. Electron/CDP before/after capture passed.

Full macOS validation (Node 24, pnpm 12): pnpm lint, pnpm typecheck, pnpm test --maxWorkers=4, and pnpm build all executed. Typecheck and complete desktop/Web/native build passed.

Full suite at ad40e0bf2e: 76,604 passed / 10 failed / 391 skipped. Final-HEAD serial follow-ups: 48 passed; performance/timeout failures cleared without relaxing assertions or policies. Commit 35da23979d fixes the missed empty-snapshot test expectation; all 16 frame-ordering tests pass.

Still failing: 4 real Claude CLI startup checks (5/10-second initialization deadlines) and 1 English runtime-catalog test. All reproduced on base bba68b1. Full lint fails on the same 7 catalog entries; later extraction/coverage gates passed separately. Full lint/test are not green.

  • Automated regressions added/updated.
  • Manual native Windows/Linux and live SSH QA: not run.

AI Disclosure

OpenAI Codex.

Review

Self-reviewed; Pullfrog reports no new issues. Human review pending.

Agent skill upstream boundary

  • N/A: no upstream agent-skill material copied.

Notes

No new permissions, platform-specific paths/shortcuts, Git commands or wire fields. Folder workspaces and remote ownership considered; full mobile/platform QA remains unrun.

Checklist

  • Small, focused change; problem and rationale explained.
  • Before/after proof attached, or N/A explained.
  • Correctness, security and performance reviewed.
  • Cross-platform, SSH and compatibility impact considered.
  • Full repository lint/typecheck/test/build executed; results above.
  • Full typecheck and build passed.
  • Full lint/test green: baseline failures documented above.

@xungua
xungua marked this pull request as ready for review September 8, 2026 14:07
@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 19045755-0492-42d9-8f98-ec8cf0704720

📥 Commits

Reviewing files that changed from the base of the PR and between ad40e0b and 35da239.

📒 Files selected for processing (1)
  • src/renderer/src/runtime/host-session-mirror-hydration-frame-ordering.test.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change keeps empty remote workspaces empty during wake handling. The active web session subscription no longer bootstraps or respawns runtime terminals from session snapshots. The related decision helpers and exports were removed. Tests cover empty workspaces, snapshot synchronization, visibility recovery, and respawn tracking.

Priority: ➖ Normal — Schedule this remote workspace behavior change because it prevents unwanted terminal creation and duplicate tabs while preserving manual creation and existing-tab recovery.

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 35da2

Empty remote workspaces now remain empty during focus, wake, and snapshot synchronization rather than creating unwanted terminal tabs. The covered synchronization and recovery behavior is ready to merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #17681 by removing automatic terminal creation for empty remote workspaces, preventing duplicate or replacement terminals, preserving empty tab state, and retaining manual cr…
Out of Scope Changes check ✅ Passed The code, tests, documentation comments, and removed runtime predicates are directly related to the linked issue and stated objectives. No unrelated functional changes are evident.
Docstring Coverage ✅ Passed Docstring coverage is 92.31% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 10 files.
Title check ✅ Passed The title clearly and concisely states the main behavior change: empty remote workspaces remain empty when selected.
Description check ✅ Passed The description covers the required sections, explains the change and rationale, links issue #17681, provides visual proof, documents testing and known baseline failures, and records remaining platfor…

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.

@pullfrog pullfrog 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.

ℹ️ No critical issues — the change cleanly collapses two redundant terminal-creation paths and makes empty remote workspaces behave like empty local ones. One minor cleanup suggestion below.

Reviewed changes

  • Removed shouldBootstrapInitialWebRuntimeTerminal and shouldRespawnWebRuntimeTerminalAfterWake — the two subscription-driven session.tabs.createTerminal paths in web-session-tabs-sync that were the source of the "sometimes two terminals" bug from #17681.
  • Added an empty guard to ensureWebRuntimeWorktreeTerminalAfterWake — an empty tabsByWorktree now returns early, so selecting an empty remote workspace no longer seeds a shell; the renderableTabCount === 0 guard is simplified since tabs.length === 0 is excluded earlier.
  • Preserved recovery and manual creation — the after-wake path still respawns dead PTYs for existing (slept) tab rows, and the + button path (openNewTerminalTabInActiveWorkspace → createWebRuntimeSessionTerminal) is untouched.
  • Updated/removed tests and a stale providesInitialSurface comment accordingly.

ℹ️ Nitpicks

  • shouldSkipWebRuntimeWakeTerminalRespawn in src/renderer/src/runtime/web-runtime-wake-terminal-respawn.ts is now dead — its only production caller was the removed respawn path in active-session-subscription.ts, leaving just its own unit test. Consider deleting the export and its test cases while you're here. (beginWebRuntimeWakeTerminalRespawn / endWebRuntimeWakeTerminalRespawn remain in use via web-runtime-worktree-terminal-after-wake.ts, and clearWebRuntimeWakeTerminalRespawnForWorktree / clearAllWebRuntimeWakeTerminalRespawn are still used by tracking-lifecycle.ts.)

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Removed the dead shouldSkipWebRuntimeWakeTerminalRespawn predicate — its only production caller was the wake-respawn path deleted in the prior commit, so the export and its import are gone from web-runtime-wake-terminal-respawn.ts.
  • Reworked web-runtime-wake-terminal-respawn.test.ts — assertions that previously probed the in-flight set through shouldSkipWebRuntimeWakeTerminalRespawn now assert beginWebRuntimeWakeTerminalRespawn return values directly, and a new case covers clearAllWebRuntimeWakeTerminalRespawn (still used by tracking-lifecycle.ts).

This resolves the one nitpick from the prior review (shouldSkipWebRuntimeWakeTerminalRespawn was dead code). The predicate is gone everywhere, the remaining functions in the module are all still referenced, and the updated tests pass.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Re-aligned the empty-snapshot hydration test with the empty-workspace contract — host-session-mirror-hydration-frame-ordering.test.tsx now publishes an authoritative empty host snapshot and asserts createTerminal is not called while the parked resume is still replayed, replacing the old test that mocked a wake-respawn spawn rejection — a scenario the tabs.length === 0 guard made unreachable.

The delta is a single test file encoding the empty guard added in the earlier commits; production behavior was already reviewed and approved. The suite passes locally (16/16).

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@mmarabel

Copy link
Copy Markdown
Contributor

The same duplicate is reachable from the slept-agent path — and one producer survives this diff

Waking a slept workspace on a paired runtime (orca serve) opens two tabs: a bare shell plus the correctly resumed agent session. Host-side evidence — the runtime's own terminal history for that worktree, two PTYs ~0.25 s apart at the wake gesture:

pty what started
serve-a1710f89-… runtime-owned bare shell, empty prompt, cwd /data/projects/hetzner-vps 19:37:13.789Z
48658f24-…::/data/projects/hetzner-vps@@c32ed425 the resumed session (agent transcript restored) 19:37:14.020Z

So it is not just extra tab chrome: every wake also leaves a real shell process on the host.

Mechanism: shouldRespawnWebRuntimeTerminalAfterWake matches exactly the slept shape — the host reports zero terminal tabs (its PTYs were stopped), the client still holds the tab row, and no local PTY is live — and it has no notion that the paused row is an agent pane that wakes itself. The shell lands 0.25 s before the resume finishes. Removing this predicate and the bootstrap covers the reported case, and it is worth naming the slept-agent trigger next to #17681's empty-workspace one, since the symptoms differ (here the workspace legitimately has a tab; the extra one is the shell).

One residual path not covered by the current diff: ensureWebRuntimeWorktreeTerminalAfterWake keeps its session.tabs.createTerminal call, and its hasMirroredHostTabs guard only skips rows with a mirrored web-terminal- id. A client-side row (for example one the client's own resume created) still spawns a shell during activation. Renderer repro, same state in both cases (one preserved agent row, its PTY dead, host holding nothing):

  • row id web-terminal-… → no create (guard holds)
  • row id client-local → one session.tabs.createTerminal({ activate: true, selectWorktree: false })

Guarding that create on "the paused row is a slept agent pane" too, or folding it into the same removal, would close the family.

One review question I can't answer from the diff: this predicate was added for a workspace whose tab chrome lost its PTYs ("sleep keeps tab rows but terminal.stop clears host PTYs"). Does the existing-tab recovery path still materialize a slept plain terminal on a runtime host once this create is gone? If not, that shape may regress to a permanently surface-less tab. Related closed reports: #19735, #13716.

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.

[Bug]: Focusing a runtime-owned workspace seeds a terminal every time, and sometimes two

2 participants