Skip to content

fix(runtime): bound persisted graph hydration for large profiles - #11832

Merged
brennanb2025 merged 1 commit into
stablyai:mainfrom
OrcaWin:OrcaWin/fix-runtime-graph-large-profile-lag
Aug 1, 2026
Merged

brennanb2025 merged 1 commit into
stablyai:mainfrom
OrcaWin:OrcaWin/fix-runtime-graph-large-profile-lag

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • scan persisted host sessions once and hydrate only worktrees with serve/SSH-owned PTY candidates
  • treat removed folder workspaces as absent during read-only graph hydration and filter their renderer snapshots
  • invalidate mobile-sync memoization on folder deletion and defer saved-runtime mirror subscriptions until the runtime is healthy
  • preserve strict failures for session mutations plus existing SSH/serve and offscreen-headless hydration behavior

Why

The affected Windows profile has 239 persisted workspace entries and 723 tabs, but no persisted serve/SSH-owned pane candidates. The old graph publication path performed about 86,150 tab checks by rescanning full sessions per graph workspace. The new path performs 723 checks (~119x fewer).

There are two related release regressions:

The installed 1.4.163-rc.3 main process is formally hung, runtime/computer-use bridge calls time out, Windows recorded AppHangB1, and terminal typing outside Orca remains normal. I recommend blocking rc.3 promotion and cutting another RC with this fix.

Full machine, release-ancestry, trace, profile, ruled-out-candidate, dump-location, and validation evidence is intentionally committed for review in docs/reference/diagnostics/2026-07-31-runtime-graph-lag-regression.md. Per review request, that temporary file can be removed before merge. The dump itself is not committed.

Validation

  • pnpm run typecheck:node
  • pnpm run typecheck:web
  • targeted oxlint on all seven TypeScript files
  • 2/2 direct main-process regressions
  • 3/3 SSH/serve hydration-preservation tests
  • 50/50 renderer graph/mirror tests
  • commit hook: oxlint, React Doctor oxlint, oxfmt
  • git diff --check

@greptile-apps

greptile-apps Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes two release regressions that hung the main process on a Windows profile with 239 workspace entries and 723 tabs: a repeated per-workspace session scan introduced in #9994 (reducing ~86,150 checks to 723 via a single one-pass getWorkspaceSessionHydrationTargets scan), and a folder_workspace_not_found throw on stale folder snapshot keys introduced in #11271 (now a null-return that silently skips hydration for removed workspaces).

  • Main process (orca-runtime.ts): getWorkspaceSessionHydrationTargets enumerates each host session exactly once, builds a worktreeId → session map filtered to serve/SSH-candidate worktrees (non-offscreen) or all persisted worktrees (offscreen), and passes the pre-scanned session through the hydration call chain so no redundant store reads occur.
  • Renderer (sync-runtime-graph.ts): folderWorkspaces is added to the mobile-session sync key so folder removal triggers re-sync; buildMobileSessionTabSnapshots filters and evicts stale folder entries from its snapshot cache.
  • Renderer (web-session-tabs-sync.ts, new runtime-session-mirror-targets.ts): Mirror subscriptions are now deferred until a runtime environment has reported a successful health probe, extracted into a testable helper with 3 unit tests.

Confidence Score: 5/5

Safe to merge after removing the diagnostic file; no regressions identified in the new hydration logic or renderer sync paths.

The one-pass hydration scan correctly limits worktree inclusion to sessions where ownerHostId === hostId, stale folder workspaces are cleanly excluded via null returns rather than exceptions, and the pre-scanned session is threaded through the call chain without introducing new fetch paths. All 7 changed files have strong test coverage directly exercising the regression scenarios.

Files Needing Attention: The diagnostic file docs/reference/diagnostics/2026-07-31-runtime-graph-lag-regression.md should be removed before merge.

Important Files Changed

Filename Overview
src/main/runtime/orca-runtime.ts Core fix: adds getWorkspaceSessionHydrationTargets for one-pass session scanning, refactors tryGetWorkspaceSessionHostIdForWorktree to return null for stale folder workspaces, threads pre-scanned workspaceSession through the hydration call chain
src/main/runtime/orca-runtime.test.ts Adds three new regression tests and updates an existing SSH/serve test to pass mobileSessionTabs: [] so the new hydration-scan code path is exercised
src/renderer/src/runtime/sync-runtime-graph.ts Adds folderWorkspaces to the mobile-session sync key and filters stale folder-workspace worktrees out of buildMobileSessionTabSnapshots with cache eviction
src/renderer/src/lib/runtime-session-mirror-targets.ts New helper filtering getRuntimeSessionMirrorEnvironmentIds to environments with a resolved status.status and a known runtimeEnvironments entry
src/renderer/src/runtime/web-session-tabs-sync.ts Replaces inline environment-key computation with getReachableRuntimeSessionMirrorTargets, deferring mirror subscriptions until runtimes report a healthy status
src/renderer/src/runtime/sync-runtime-graph.test.ts Adds folder-workspace removal coverage including cache-eviction and version-bump after removal and restore
src/renderer/src/lib/runtime-session-mirror-targets.test.ts New unit tests covering health-probe gating, missing-environment exclusion, and legacy pairingRevision fallback

Reviews (3): Last reviewed commit: "fix(runtime): bound persisted graph hydr..." | Re-trigger Greptile

Comment on lines +37 to +79
| Live `folderWorkspaces` | 0 |
| Stale `folder:*` session keys | 2 |
| Local `tabsByWorktree` entries | 116 |
| Local persisted tabs | 397 |
| Saved-runtime `tabsByWorktree` entries | 123 |
| Saved-runtime persisted tabs | 326 |
| Total persisted tabs inspected by the graph path | 723 |
| Persisted workspaces with a serve/SSH-owned PTY candidate | 0 |

The stale keys are:

```text
folder:2573f8cc-8e3a-4e16-bf2b-95f8bae2eb1d
folder:5e144304-2c66-4571-aa46-552a3338b928
```

For this profile, the pre-fix graph publication performs approximately 86,150 tab checks because it rescans an entire host session for each graph workspace. The fixed one-pass candidate discovery performs 723 checks, about 119 times fewer. Because this profile has no runtime-owned persisted pane candidate, the correct result is no ordinary runtime hydration work after that single pass.

## Live-process evidence

The app was deliberately left running so diagnostics could be collected without destroying roughly 110 active/saved sessions.

| Observation | Evidence |
| --- | --- |
| Main process hung | PID 43984 (`Orca`), Windows `Responding=False`, about 303 MB private bytes at the latest sample |
| Renderer still present | PID 33908 (`Orca`), about 390 MB private bytes at the latest sample |
| No resource saturation | Repeated sampling did not show sustained CPU or GPU saturation; this is consistent with event-loop starvation/blocking rather than machine-wide overload |
| Runtime bridge unavailable | `orca status --json`, computer-use capabilities, and computer-use app enumeration all timed out against the wedged app |
| Trace stopped with app state | `C:\Users\neil\AppData\Roaming\orca\logs\main.trace.ndjson` stopped at 14:39:15, four seconds after the profile's last write |
| Main trace showed Git pressure | `git.exec` completions peaked at 219/min at 14:34 and 213/min at 14:33, then continued at 195, 183, 162, and 148/min through 14:38 |
| Windows recorded a real hang | Application log Event 1002 (`Application Hang`) at 12:08:43; WER Event 1001 at 12:08:41 classified the failure as `AppHangB1` |

A compact dump of the hung main process was captured at:

```text
C:\Users\neil\orca\diagnostics\orca-main-43984-hang-20260731-154629.dmp
```

It is 7,100,310 bytes. The dump is intentionally **not** committed to this repository.

## Why the two regressions amplify each other

The stable regression makes graph publication scale with graph workspaces multiplied by all tabs in the selected persisted session. Large profiles therefore pay repeated whole-session scans even when every tab is locally owned and no hydration is necessary.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 PII in committed diagnostic file

The file contains the affected user's Windows username (neil) in absolute file-system paths (C:\Users\neil\AppData\..., C:\Users\neil\orca\...). The PR description notes this file is temporary and can be removed before merge — it should be before this lands in the default branch's git history, since git history is effectively permanent once a branch is merged.

Comment thread src/main/runtime/orca-runtime.ts Resolved
@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@brennanb2025, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 1 minute

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 873670ac-f43d-4a84-b4e8-0648aad8ae0f

📥 Commits

Reviewing files that changed from the base of the PR and between 8a0d7a348e2774d78c568ad8dbcfc92da982db36 and 14cb346.

📒 Files selected for processing (7)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/lib/runtime-session-mirror-targets.test.ts
  • src/renderer/src/lib/runtime-session-mirror-targets.ts
  • src/renderer/src/runtime/sync-runtime-graph.test.ts
  • src/renderer/src/runtime/sync-runtime-graph.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
📝 Walkthrough

Walkthrough

Runtime graph hydration now resolves missing folder workspaces without throwing, discovers runtime-owned worktrees from host sessions, and reuses loaded workspace-session data during reconciliation. Mobile session synchronization now tracks folder workspace changes and removes snapshots for deleted folder workspaces. Runtime mirror subscription keys now use reachable targets with runtime, connection-generation, and pairing-revision values. Tests cover graph readiness, session read counts, snapshot filtering, cache eviction, and mirror target selection.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and validation, but it omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add all required template sections, state whether visual changes exist, document AI and security reviews, confirm cross-platform checks, and complete the testing checklist.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: limiting persisted graph hydration for large profiles.
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.

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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/runtime/sync-runtime-graph.ts (1)

765-784: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Evict snapshots for removed folder workspaces.

Line 778 skips a removed folder workspace, but cache cleanup later checks the unfiltered worktreeIds set. A stale folder key can therefore retain its mobileSessionSnapshotCacheByWorktree entry indefinitely and reuse its old snapshot if that ID returns.

Track published worktree IDs and use that set for cache cleanup. Add a test that primes the cache, removes the folder workspace, and verifies eviction.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7fbc1309-be84-4e6f-bef1-f41f98f0aa41

📥 Commits

Reviewing files that changed from the base of the PR and between e493795 and fcae9f1963bf0f3a031d8d6590c7dba0be9bf22f.

📒 Files selected for processing (8)
  • docs/reference/diagnostics/2026-07-31-runtime-graph-lag-regression.md
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/lib/runtime-session-mirror-targets.test.ts
  • src/renderer/src/lib/runtime-session-mirror-targets.ts
  • src/renderer/src/runtime/sync-runtime-graph.test.ts
  • src/renderer/src/runtime/sync-runtime-graph.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts

Comment on lines +123 to +124
pnpm exec oxlint <the seven changed TypeScript files>
PASS

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Replace the placeholder with the executed file list.

The command is not runnable. List the seven TypeScript files so readers can reproduce the lint validation.

Proposed fix
-pnpm exec oxlint <the seven changed TypeScript files>
+pnpm exec oxlint \
+  src/main/runtime/orca-runtime.ts \
+  src/main/runtime/orca-runtime.test.ts \
+  src/renderer/src/runtime/sync-runtime-graph.ts \
+  src/renderer/src/runtime/sync-runtime-graph.test.ts \
+  src/renderer/src/lib/runtime-session-mirror-targets.ts \
+  src/renderer/src/lib/runtime-session-mirror-targets.test.ts \
+  src/renderer/src/runtime/web-session-tabs-sync.ts
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pnpm exec oxlint <the seven changed TypeScript files>
PASS
pnpm exec oxlint \
src/main/runtime/orca-runtime.ts \
src/main/runtime/orca-runtime.test.ts \
src/renderer/src/runtime/sync-runtime-graph.ts \
src/renderer/src/runtime/sync-runtime-graph.test.ts \
src/renderer/src/lib/runtime-session-mirror-targets.ts \
src/renderer/src/lib/runtime-session-mirror-targets.test.ts \
src/renderer/src/runtime/web-session-tabs-sync.ts
PASS

@brennanb2025
brennanb2025 force-pushed the OrcaWin/fix-runtime-graph-large-profile-lag branch from fcae9f1 to 8a0d7a3 Compare August 1, 2026 00:36
@brennanb2025

Copy link
Copy Markdown
Contributor

Electron validation (8a0d7a348e)

Validated the pushed branch in an isolated Orca dev profile via CDP and the real Electron renderer/main-process boundary.

  • Attached to the intended worktree instance and loaded the PR worktree through the real repository IPC.
  • Workspace hydration reached ready state with zero renderer console errors.
  • Injected a disposable persisted session matching the reported scale: 239 workspace entries and 717 ordinary tabs.
  • The real runtime.syncWindowGraph IPC completed in 2.9 ms and returned graphStatus ready.
  • Restored and flushed the disposable session immediately afterward.
  • Exercised rendered sidebar controls after the graph publication; the window remained responsive.

pr11832-electron-validation.png

Remaining gap: this macOS host currently has no PTY devices available, so a new terminal process could not be allocated. The screenshot proves the rendered app remained responsive after the large-profile graph publication, but it is not evidence of successful terminal typing. Live Windows input remains to be checked after the wedged remote instance can be safely restarted.

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

🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.test.ts (1)

27006-27025: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Fix the duplicate assertion; restore the missing readiness check.

Line 27023 and line 27024 assert the exact same expression: expect(getWorkspaceSession).toHaveBeenCalledTimes(1). The test title says "hydrates runtime-owned candidates from one host-session read," and the line-range change summary states the test verifies "synchronization reaches the ready state." The graphStatus check is missing. Both sibling tests in this block ("keeps the graph ready when a mobile snapshot references a removed folder workspace" and "scans ordinary persisted sessions once instead of once per graph workspace") end with expect(runtime.getStatus().graphStatus).toBe('ready').

Without this check, the test does not verify that syncWindowGraph actually completes successfully when 100 runtime-owned worktree candidates are present in the persisted session but absent from the mobileSessionTabs snapshot. A regression that leaves the graph in 'reloading' or 'unavailable' after this hydration path would not be caught.

♻️ Proposed fix
     runtime.syncWindowGraph(1, { tabs: [], leaves: [], mobileSessionTabs: [] })
 
     expect(getWorkspaceSession).toHaveBeenCalledTimes(1)
-    expect(getWorkspaceSession).toHaveBeenCalledTimes(1)
+    expect(runtime.getStatus().graphStatus).toBe('ready')
   })

Based on learnings, this deferred finding is anchored here per the line_range_change_details guidance for lines 27006-27025.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f8ef24d1-4045-466e-8f6c-2570ecf4b65b

📥 Commits

Reviewing files that changed from the base of the PR and between fcae9f1963bf0f3a031d8d6590c7dba0be9bf22f and 8a0d7a348e2774d78c568ad8dbcfc92da982db36.

📒 Files selected for processing (7)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/lib/runtime-session-mirror-targets.test.ts
  • src/renderer/src/lib/runtime-session-mirror-targets.ts
  • src/renderer/src/runtime/sync-runtime-graph.test.ts
  • src/renderer/src/runtime/sync-runtime-graph.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/renderer/src/lib/runtime-session-mirror-targets.test.ts
  • src/renderer/src/lib/runtime-session-mirror-targets.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/runtime/sync-runtime-graph.test.ts
  • src/renderer/src/runtime/sync-runtime-graph.ts
  • src/main/runtime/orca-runtime.ts

@brennanb2025
brennanb2025 force-pushed the OrcaWin/fix-runtime-graph-large-profile-lag branch from 8a0d7a3 to 14cb346 Compare August 1, 2026 00:47
@brennanb2025
brennanb2025 merged commit 33ad64b into stablyai:main Aug 1, 2026
42 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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.

2 participants