Repository navigation
Fix Resource Manager going empty when a runtime server is selected or stale - #7275
Conversation
… 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]>
f2e2451 to
98cfd83
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis 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)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
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 winMissing "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.
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."📝 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 }Source: Coding guidelines
🧹 Nitpick comments (1)
src/main/runtime-environment-focus-self-heal.ts (1)
55-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSilent fail-soft on registry read failure lacks explanation/diagnostics.
When
listKnownEnvironmentsthrows, the function returns without logging anything, leaving a potentially danglingactiveRuntimeEnvironmentIdin place with no diagnostic trail. This differs from every other clear/keep path, which either logs vialogClearedFocusor is a deliberate no-op with an implicit "keep" semantic that's easy to infer. A short comment (or alogcall) 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.tssrc/main/ipc/ephemeral-vm-runtime-handlers.tssrc/main/ipc/ephemeral-vm.test.tssrc/main/ipc/register-core-handlers.test.tssrc/main/ipc/register-core-handlers.tssrc/main/ipc/runtime-environments.test.tssrc/main/ipc/runtime-environments.tssrc/main/runtime-environment-focus-self-heal.test.tssrc/main/runtime-environment-focus-self-heal.tssrc/renderer/src/components/status-bar/ResourceUsageStatusSegment.rows.test.tsxsrc/renderer/src/components/status-bar/ResourceUsageStatusSegment.session-polling.test.tssrc/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsxsrc/renderer/src/components/status-bar/mergeSnapshotAndSessions.test.tssrc/renderer/src/components/status-bar/mergeSnapshotAndSessions.tssrc/renderer/src/components/status-bar/resource-manager-terminal-copy.test.tssrc/renderer/src/components/status-bar/resource-manager-terminal-copy.tssrc/renderer/src/components/status-bar/resource-usage-merge-types.tssrc/renderer/src/components/status-bar/resource-usage-open-slices.test.tssrc/renderer/src/components/status-bar/resource-usage-open-slices.tssrc/renderer/src/components/status-bar/resource-usage-space-scan-ready.test.tssrc/renderer/src/components/status-bar/resource-usage-space-scan-ready.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/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
Co-authored-by: Orca <[email protected]>
…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.
… stale (stablyai#7275) Co-authored-by: Orca <[email protected]>
…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.
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
· remotechip, 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.activeRuntimeEnvironmentIdis 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
runtimeEnvironmentActivegate from all three carriers (ResourceUsageStatusSegment.tsx,resource-usage-open-slices.ts,resource-usage-space-scan-ready.ts), keeping the popover-opengating that prevents closed-badge churn. The dead "hidden for runtime servers" strings are removed from code and all five locale catalogs.mergeSnapshotAndSessionsnow skips rows whose repo resolves to aruntime:execution host via the canonicalparseExecutionHostId(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.src/main/runtime-environment-focus-self-heal.tsruns 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)
SessionRow/WorktreeRowexported for row-level render tests.ResourceUsageStatusSegment.rows.test.tsx(SSH· remotechip + 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).open-gated empty slices), new memo keyed onreposidentity 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).activeRuntimeEnvironmentIdand 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 inorca-data.jsonon 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.pnpm tc(3 tsconfigs) pass; fullpnpm lintpass (incl. localization catalog + coverage); focused vitest — 10 files / 79+ tests pass.Reliability gate
''→null; registry throw → untouched.runtime:repos contribute zero rows while SSH/orphan rows persist; render tests pin the SSH· remotechip and kill buttons and the orphan kill button.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
· localcue in the popover header for actively-remote users, say so — deliberately not added here.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.