Skip to content

fix(mobile): unblock targeted SSH session tab refresh - #17486

Merged
Jinwoo-H merged 3 commits into
mainfrom
aug30-sta5997-mobile-ssh-spinner
Aug 31, 2026
Merged

Jinwoo-H merged 3 commits into
mainfrom
aug30-sta5997-mobile-ssh-spinner

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​94 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​89
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​76 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​68

Summary

Mobile SSH session opens could spin forever because the host-side targeted session-tab RPC waited on a fleet-wide PTY/worktree census. A stalled unrelated SSH Git scan prevented the authoritative snapshot from reaching the client.

This change keeps targeted refreshes independent, resolves explicit Git/folder targets from cache or persisted metadata, scopes PTY inventory to the owning SSH provider, fails closed for paired/runtime-owned hosts, and retries one stale generation race. Aggregate fleet inventory remains coalesced.

Evidence

  • Deterministic injected SSH fixture: never-settling listWorktrees, persisted remote tab, live SSH PTY identity.
  • Production-reverted/origin-main oracle: red (null after bounded fake deadline).
  • Candidate oracle: green; unrelated Git scan is not called and exactly one target-provider PTY query is made.
  • Session publication suite: 17/17.
  • Full orca-runtime.test.ts: 1,216 passed, 1 skipped.
  • pnpm tc:node, changed-code quality, oxlint, formatting, and diff checks pass.

Review notes

Three independent gpt-5.6-sol architecture reviews completed. Two concrete issues found in the first candidate (fail-open repo inventory and folder-workspace target loss) were fixed before this PR; final review found no blockers.

No RPC/wire schema changes; local, SSH/relay, paired, folder-workspace, WSL, and mixed-version paths retain their existing contracts. No Linear or production/cloud state was changed.

@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown

Greptile Summary

The PR separates targeted mobile session-tab refreshes from fleet-wide PTY/worktree inventory so an unrelated stalled SSH scan cannot block opening a session.

  • Resolves explicit Git and folder targets from fresh cache or persisted metadata.
  • Queries only the target workspace’s owning PTY provider and fails closed for runtime-owned hosts.
  • Retries one stale targeted inventory generation while retaining aggregate refresh coalescing.
  • Adds regression and concurrency coverage for targeted SSH refresh behavior.

Confidence Score: 5/5

The PR appears safe to merge with no concrete changed-code defect established.

Targeted refreshes retain explicit host resolution, provider-scoped liveness checks, fail-closed runtime ownership, and bounded stale-generation recovery without an established tab-loss or publication regression.

Important Files Changed

Filename Overview
src/main/runtime/orca-runtime.ts Separates targeted and aggregate PTY refreshes, adds explicit target resolution and provider scoping, and retries one stale targeted generation.
src/main/runtime/orca-runtime.test.ts Adds a deterministic regression test proving targeted SSH tab listing does not invoke or wait for an unrelated worktree scan.
src/main/runtime/session-tabs-inventory-publication.test.ts Updates inventory concurrency coverage to assert independent targeted and aggregate refresh operations.

Sequence Diagram

sequenceDiagram
  participant M as Mobile client
  participant R as Orca runtime
  participant W as Target resolver
  participant P as Owning PTY provider
  M->>R: List tabs for explicit worktree
  R->>W: Resolve cached or persisted target
  W-->>R: Execution host
  alt Local or SSH target
    R->>P: List processes for owning provider
    P-->>R: Scoped PTY inventory
    R-->>M: Target session-tab snapshot
  else Paired runtime-owned target
    R-->>M: Inventory unavailable (fail closed)
  end
Loading

Reviews (1): Last reviewed commit: "Strengthen SSH session refresh oracle" | Re-trigger Greptile

@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

This PR decouples targeted (explicit worktree-id) mobile session-tab refreshes from the fleet-wide PTY/worktree census so a stalled unrelated SSH Git scan can no longer leave an SSH session open spinning. Fleet-wide and floating paths are unchanged, and no RPC/wire schema changes.

  • Targeted refresh bypasses the aggregate census — refreshMobileSessionPtyInventory routes non-floating targets straight to performMobileSessionPtyRecordsRefresh instead of coalescing behind pendingMobileSessionPtyAggregateInventoryRefresh.
  • Explicit-target worktree resolution — new listResolvedWorktreesForExplicitTarget resolves the target from the warm resolvedWorktreeCache or persisted folder/repo metadata (buildResolvedWorktreeFromId), never triggering a Git/SSH worktree scan.
  • Owner-scoped provider query — performMobileSessionPtyRecordsRefresh derives the execution host, fails closed (return null) for runtime-owned/paired hosts, and scopes the PTY list to the owning SSH provider (connectionId) or local provider.
  • Stale-generation retry — refreshPtyWorktreeRecordsWithControllerInventory gains a retryStale flag; when a concurrent fleet census fences out a targeted poll, it re-queries once so a user-driven open never returns empty.
  • Fail-open folder/repo resolution — buildResolvedWorktreeFromId reads getRepos?.(), and listKnownResolvedWorktreesForExplicitTarget returns the folder-workspace row (previously []).
  • Tests — a deterministic never-settling-listWorktrees SSH fixture in orca-runtime.test.ts, plus the updated session-tabs-inventory-publication.test.ts asserting targeted and aggregate refreshes run independently.

I traced the host-resolution chain (parseExecutionHostId, getRepoExecutionHostId, tryGetWorkspaceSessionHostIdForWorktree), the provider routing in src/main/ipc/pty/provider/registry.ts and src/main/ipc/pty/runtime/operations.ts (listProcesses(null) = local, listProcesses(id) = scoped SSH, host-scope = fleet), and the generation fencing around ptyControllerAggregateInventoryGeneration / ptyControllerInventoryGenerationByProvider. The parsedTargetHost.kind === 'runtime' fail-closed guard and the one-shot retryStale bound both behave as documented, and the floating-terminal sentinel still resolves to the local provider rather than tripping the runtime guard. No correctness, coverage, or wire-compatibility concerns.

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

@Jinwoo-H
Jinwoo-H merged commit 63d60e0 into main Aug 31, 2026
62 of 64 checks passed
nwparker added a commit to nwparker/orca that referenced this pull request Sep 1, 2026
…-refactor

main advanced 45 commits, six of them landing inside the orca-runtime.ts this
branch splits apart. Git resolves that as a plain "take one side", and either
side silently loses work, so each was ported into the module that now owns the
code:

- stablyai#17655 bound ref and worktree scans -> runtime-repository-ref-queries
- stablyai#17448 preserve user-set workspace names -> the worktree-create modules
- stablyai#17667 cut cold worktree-switch attach latency -> the mutation lock, including
  the deletion half (worktree-terminal-mutation-wait.ts is gone)
- stablyai#17718 preserve large agent prompt pastes -> the agent-prompt write path
- stablyai#17486 unblock targeted SSH session tab refresh -> the mobile refresh modules
- stablyai#17159 close readiness gaps -> 34 runtime hunks and 5 test hunks

Every added line of the six was checked against the merged tree; the unmatched
ones are all renames or line splits, verified individually.

Two defects surfaced while porting, both predating this merge:

- isMobileSessionSurfaceMembershipAllowed read a session accessor that answers
  null where main's answers undefined, so main's `session !== undefined` guard
  was always true and the fence stopped fencing. Three clauses found in neither
  main nor the split base had been added ahead of it to compensate, and one of
  them dropped a freshly published split leaf out of syncWindowGraph. Restored
  to main's control flow with the sentinel normalized; stablyai#17159's two new tests
  cover it from both directions.
- retiredMobileSessionPtyIds was write-only state this branch invented. Its only
  reader was the clause above, and it exists in neither main nor the split base.
- RuntimeTerminalWriter.writeAgentPrompt had no callers and still carried the
  chunked-paste shape stablyai#17718 replaced.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Fix targeted mobile SSH session tab refresh

* Preserve fail-open explicit workspace resolution

* Strengthen SSH session refresh oracle
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