Skip to content

Fix Resource Manager going empty when a runtime server is selected or stale - #7275

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-resources-manager-runtime
Jul 4, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-resources-manager-runtime

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the Resource Manager rendering permanently empty — "Local resource usage hidden for runtime servers." with refresh/clear disabled ("Unavailable for runtime servers") — for users working in ordinary local workspaces. Reported on Discord (v1.4.118, "it happens in all my workspaces… I'm in a regular worktree in my local machine"); tracked in Linear STA-1279.

What changes: the Resource Manager always shows this machine's usage. It only ever samples the local Electron PTY/resource daemon, so it no longer blanks itself when a remote runtime server is the globally focused host — and a stale focused-server id (server removed or lost after being selected) is self-healed to Local at app startup, so it can no longer silently disable the Resource Manager (or route startup hydration through a ghost host) forever.

What does not change: SSH rows keep their · remote chip, null metrics, and kill actions; runtime-server-hosted workspaces still never appear in the list (now enforced per-row instead of by blanking the whole panel); a focused server that is merely offline stays focused — self-heal only clears ids that no longer resolve to a known user-managed server.

Root cause

Since the multi-host workbench (#5071), settings.activeRuntimeEnvironmentId is only the global default-host focus — not "the app is remote." The Resource Manager gated all local sampling on it. Two failure modes: (1) any legitimately focused runtime server hid local usage in every workspace; (2) a dangling id (e.g. server removed outside the Settings pane) stuck forever — with no user-managed servers the status-bar host picker renders nothing, so there was no indication a "runtime server" was selected and no way back. Reproduced end-to-end before the fix (evidence on STA-1279).

Design approach

  • Un-gate: removed the runtimeEnvironmentActive gate from all three carriers (ResourceUsageStatusSegment.tsx, resource-usage-open-slices.ts, resource-usage-space-scan-ready.ts), keeping the popover-open gating that prevents closed-badge churn. The dead "hidden for runtime servers" strings are removed from code and all five locale catalogs.
  • Per-row scoping: mergeSnapshotAndSessions now skips rows whose repo resolves to a runtime: execution host via the canonical parseExecutionHostId(getRepoExecutionHostId(...)) (keep-rule: local/SSH/orphan/unattributed are kept). Today's daemon inputs are local/SSH-only, so this is a guard against future misattribution — asserted as such in code and tests.
  • Self-heal: new src/main/runtime-environment-focus-self-heal.ts runs at main-process boot (right after the Store loads, before any window): a focus id that doesn't resolve to a known user-managed server is cleared to null with one diagnostic log line; '' normalizes to null; registry read failure fails soft (focus untouched); reachability is deliberately not checked. The in-process environment removers (IPC remove handler, ephemeral-VM teardown) also clear a matching focus immediately with renderer notification.

Pipeline results (Brennan's PR process)

  • Design review: 3 rounds (Claude+Codex reviewers), 13 findings folded in (e.g. third gate file; orphan-bucket keep-rule; live consumers of the terminal-copy helper; the session-polling source-string revert trap), round 3 clean.
  • Implementation: per design, no deviations. One addition beyond the doc during verification: SessionRow/WorktreeRow exported for row-level render tests.
  • Completeness verification: independent read-only pass — 8 PASS, 2 PARTIAL, 1 blocker (row-presentation regression test missing). Blocker closed with ResourceUsageStatusSegment.rows.test.tsx (SSH · remote chip + kill affordances, orphan-bucket kill affordance); the log-count assertion nit was also added. Accepted deviation: the ''-normalize path logs a diagnostic (design table didn't specify one).
  • Headline behavior: implemented (both halves; no narrowing).
  • Perf audit: clean across all five hot paths — closed-badge work unchanged (open-gated empty slices), new memo keyed on repos identity only, O(1) row scoping, self-heal does zero I/O unless a focus id is actually persisted, and the always-mounted badge drops a settings subscription (net win).
  • Code review loop: clean in 1 round, two parallel reviewers, zero actionable findings. Reviewer-confirmed: Ports segment does NOT share this bug (scopes per owner worktree, not global focus) — no follow-up needed there.
  • Validation (brennan-test-changes): verdict land. Live Electron e2e on a fresh throwaway profile: baseline popover healthy; injected a dangling activeRuntimeEnvironmentId and performed a real main-process restart (not a renderer reload — self-heal runs at boot). After restart: setting self-healed to null in memory AND in orca-data.json on disk, popover fully populated with enabled actions, zero occurrences of the removed copy anywhere in the DOM, real MB badge, exact one-line diagnostic emitted ([runtime-environment-focus] cleared active runtime environment: dangling id ghost-env-validation), zero console errors. Focused unit suites: 79 tests across the touched files, all passing.
  • Checks run: full pnpm tc (3 tsconfigs) pass; full pnpm lint pass (incl. localization catalog + coverage); focused vitest — 10 files / 79+ tests pass.

Reliability gate

  • Self-heal matrix unit-tested: known user-managed id kept; dangling id cleared+logged once; ephemeral-VM id cleared+logged once; null/absent untouched; ''→null; registry throw → untouched.
  • Kill scoping pinned at both layers: merge tests prove runtime: repos contribute zero rows while SSH/orphan rows persist; render tests pin the SSH · remote chip and kill buttons and the orphan kill button.
  • Session polling stays open-gated (source assertion updated 'if (!open || runtimeEnvironmentActive)' → 'if (!open)' — the retained guard is the test's actual intent).

Risks, non-goals, and flagged decisions

  • Flagged for review (deliberate product change): with a runtime server focused, local usage is now always visible. If you want a small "This computer"/· local cue in the popover header for actively-remote users, say so — deliberately not added here.
  • Non-goals (tracked in STA-1279): Add Project host picker persisting global focus on selection/cancel; host-picker visibility redesign.
  • Accepted gaps: CLI-process server removal live-heals only at next app launch (the Resource Manager itself is no longer affected either way); no live runtime server in the validation rig (the valid-focus case is behaviorally identical for this surface — the gate keyed only on the id being set).

Manual validation evidence

Full-window before/after screenshots were captured during the live e2e run (baseline popover, and the previously-stuck dangling-id state showing full local usage after restart with the on-disk setting healed to null). Per repo policy evidence images are not committed; they are in the validation session record and can be attached here on request.

… stale

The Resource Manager only ever samples the local PTY/resource daemon, but
it blanked entirely whenever settings.activeRuntimeEnvironmentId was set -
including when the focused server no longer existed, which left it
permanently empty with no recovery path (STA-1279).

- Un-gate the segment from global host focus; scope rows per repo
  execution host instead (runtime-hosted rows excluded, local/SSH/orphan
  kept with their kill affordances).
- Self-heal a dangling focus id at main-process boot and clear focus in
  the in-process environment removers.
- Remove the now-dead 'hidden for runtime servers' states and strings
  across all locale catalogs.

Co-authored-by: Orca <[email protected]>
@brennanb2025
brennanb2025 force-pushed the brennanb2025/fix-resources-manager-runtime branch from f2e2451 to 98cfd83 Compare July 4, 2026 00:18
@coderabbitai

coderabbitai Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ad771960-9c38-40cc-8e65-13c3f03777b7

📥 Commits

Reviewing files that changed from the base of the PR and between 98cfd83 and 073a511.

📒 Files selected for processing (3)
  • src/main/runtime-environment-focus-self-heal.ts
  • src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx
  • src/renderer/src/components/status-bar/mergeSnapshotAndSessions.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/renderer/src/components/status-bar/mergeSnapshotAndSessions.ts
  • src/main/runtime-environment-focus-self-heal.ts
  • src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx

📝 Walkthrough

Walkthrough

This change adds runtime environment focus self-healing, wired into app startup, ephemeral VM cleanup, and runtime environment removal. It updates runtime environment handler registration to receive the store. It also removes runtime-environment-active gating from resource usage selectors, copy helpers, the status bar component, and readiness logic, while adding runtime-scoped repo filtering to merged snapshot/session data and updating related tests and locale strings.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed, but it doesn't follow the required template and is missing explicit Screenshots, AI Review cross-platform confirmation, and Security Audit sections. Add the required sections with explicit headings, include screenshots or 'No visual change', and document testing, cross-platform review, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main fix: Resource Manager no longer goes empty when a runtime server is selected or stale.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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/components/status-bar/mergeSnapshotAndSessions.ts (1)

187-222: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Missing "why" comment on the Step 1 runtime-scope guard.

The analogous guard in Step 2 (lines 253-254) explains the rationale ("current daemon inputs are local/SSH only..."), but this Step 1 guard has no comment explaining why snapshot worktrees for runtime-scoped repos are skipped here.

📝 Proposed fix
     for (const wt of snapshot.worktrees as readonly WorktreeMemory[]) {
+      // Why: runtime-hosted repos have no local resource sample and no safe
+      // kill/restart actions; exclude their rows entirely rather than showing
+      // stale/misleading local-truth data for them.
       if (isRuntimeScopedRepo(wt.repoId)) {
         continue
       }
As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."

Source: Coding guidelines

🧹 Nitpick comments (1)
src/main/runtime-environment-focus-self-heal.ts (1)

55-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Silent fail-soft on registry read failure lacks explanation/diagnostics.

When listKnownEnvironments throws, the function returns without logging anything, leaving a potentially dangling activeRuntimeEnvironmentId in place with no diagnostic trail. This differs from every other clear/keep path, which either logs via logClearedFocus or is a deliberate no-op with an implicit "keep" semantic that's easy to infer. A short comment (or a log call) would make the fail-soft intent explicit for future maintainers debugging a stuck "empty Resource Manager" report.

As per coding guidelines, non-obvious behavior driven by a constraint should carry a short comment explaining why.

♻️ Proposed fix
   let environments: KnownRuntimeEnvironment[]
   try {
     environments = listKnownEnvironments(userDataPath)
   } catch {
+    // Why: a corrupt/unreadable registry must not crash startup or clear a
+    // possibly-valid focus; leave the persisted id untouched and retry next launch.
     return
   }

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bd600ba4-90a2-45f6-b762-c9ef1d632f5c

📥 Commits

Reviewing files that changed from the base of the PR and between a4661f1 and f2e2451393131c18dd2c18a0e556384decdc06dc.

📒 Files selected for processing (26)
  • src/main/index.ts
  • src/main/ipc/ephemeral-vm-runtime-handlers.ts
  • src/main/ipc/ephemeral-vm.test.ts
  • src/main/ipc/register-core-handlers.test.ts
  • src/main/ipc/register-core-handlers.ts
  • src/main/ipc/runtime-environments.test.ts
  • src/main/ipc/runtime-environments.ts
  • src/main/runtime-environment-focus-self-heal.test.ts
  • src/main/runtime-environment-focus-self-heal.ts
  • src/renderer/src/components/status-bar/ResourceUsageStatusSegment.rows.test.tsx
  • src/renderer/src/components/status-bar/ResourceUsageStatusSegment.session-polling.test.ts
  • src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx
  • src/renderer/src/components/status-bar/mergeSnapshotAndSessions.test.ts
  • src/renderer/src/components/status-bar/mergeSnapshotAndSessions.ts
  • src/renderer/src/components/status-bar/resource-manager-terminal-copy.test.ts
  • src/renderer/src/components/status-bar/resource-manager-terminal-copy.ts
  • src/renderer/src/components/status-bar/resource-usage-merge-types.ts
  • src/renderer/src/components/status-bar/resource-usage-open-slices.test.ts
  • src/renderer/src/components/status-bar/resource-usage-open-slices.ts
  • src/renderer/src/components/status-bar/resource-usage-space-scan-ready.test.ts
  • src/renderer/src/components/status-bar/resource-usage-space-scan-ready.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
💤 Files with no reviewable changes (6)
  • src/renderer/src/components/status-bar/resource-usage-space-scan-ready.ts
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/ja.json

@brennanb2025
brennanb2025 merged commit 748bced into main Jul 4, 2026
1 check passed
@brennanb2025
brennanb2025 deleted the brennanb2025/fix-resources-manager-runtime branch July 4, 2026 00:53
nwparker added a commit that referenced this pull request Jul 4, 2026
…fix garbled comments (#7322)

Quality pass on renderer/shared PRs merged 2026-07-03:

- WorktreeTitleInlineRename: skip the truncation measure + ResizeObserver in `wrapTitle`
  mode, where wrapped titles never truncate — it could only churn unused state (#7307).
- editor slice: reuse the `removeEditorStateForReplacedPreview` helper this PR added
  instead of a hand-rolled copy of the same six-field eviction (drops ~50 lines) (#6476).
- useFileExplorerTree: extract `readWorktreeDirectory` so the connectionId/settings
  assembly for `readRuntimeDirectory` lives in one place, not three (#6321).
- comment-markdown-github-attachment-media: extract a shared `AttachmentFallbackLink`
  for the image/video error-fallback link (#6759).
- repository-icon-github: fold the two near-identical live resolvers into one
  parameterized `resolveRepositoryIdentityLive`; trim a 3-line comment to 2 (#6507).
- resource-usage-open-slices: delete the `shouldReadPopoverSlices` identity wrapper and
  inline `open` at the four call sites (#7275).
- BrowserPane: drop the pointerEvents assignment already applied inside
  `ensureBrowserPageWebview` for the reused-webview path (#6958).
- github slice: fix two garbled "…a commit main confirmed…" comments (#7277).
- runtime-file-client: trim the binary-file fallback comment to its whys (#6606).
- composer-branch-selection: drop the inline comment that restated the JSDoc (#6748).
- TabBarQuickCommandsButton: correct the stale "+ Command" comment (button shows no +).

No behavior change (the editor-helper reuse is behavior-equivalent, only more
conservative on an edge case); typecheck, oxlint, react-doctor, oxfmt, and touched
unit suites all pass.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…fix garbled comments (stablyai#7322)

Quality pass on renderer/shared PRs merged 2026-07-03:

- WorktreeTitleInlineRename: skip the truncation measure + ResizeObserver in `wrapTitle`
  mode, where wrapped titles never truncate — it could only churn unused state (stablyai#7307).
- editor slice: reuse the `removeEditorStateForReplacedPreview` helper this PR added
  instead of a hand-rolled copy of the same six-field eviction (drops ~50 lines) (stablyai#6476).
- useFileExplorerTree: extract `readWorktreeDirectory` so the connectionId/settings
  assembly for `readRuntimeDirectory` lives in one place, not three (stablyai#6321).
- comment-markdown-github-attachment-media: extract a shared `AttachmentFallbackLink`
  for the image/video error-fallback link (stablyai#6759).
- repository-icon-github: fold the two near-identical live resolvers into one
  parameterized `resolveRepositoryIdentityLive`; trim a 3-line comment to 2 (stablyai#6507).
- resource-usage-open-slices: delete the `shouldReadPopoverSlices` identity wrapper and
  inline `open` at the four call sites (stablyai#7275).
- BrowserPane: drop the pointerEvents assignment already applied inside
  `ensureBrowserPageWebview` for the reused-webview path (stablyai#6958).
- github slice: fix two garbled "…a commit main confirmed…" comments (stablyai#7277).
- runtime-file-client: trim the binary-file fallback comment to its whys (stablyai#6606).
- composer-branch-selection: drop the inline comment that restated the JSDoc (stablyai#6748).
- TabBarQuickCommandsButton: correct the stale "+ Command" comment (button shows no +).

No behavior change (the editor-helper reuse is behavior-equivalent, only more
conservative on an edge case); typecheck, oxlint, react-doctor, oxfmt, and touched
unit suites all pass.
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