Repository navigation
feat(hosts): Resource Manager lists the owning host's processes - #27263
Conversation
While the Resource Manager is open, each paired server that hosts one of this client's projects is asked for its own process samples through the existing diagnostics.memory method, and those rows render under the server's projects, named by host and without a kill control. A server that cannot answer is named as unknown instead of looking idle.
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to A server session with the same ID as a local session can hide the local row. This is a narrow mergeability risk that merits owner awareness or a fix. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
498ded2b-833a-4f00-bd94-384e026fc5fb
📒 Files selected for processing (18)
src/renderer/src/components/status-bar/ResourceUsageStatusSegment.rows.test.tsxsrc/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-session-labels.tssrc/renderer/src/components/status-bar/resource-usage-folder-merge.test.tssrc/renderer/src/components/status-bar/resource-usage-merge-types.tssrc/renderer/src/components/status-bar/resource-usage-popover-body.tsxsrc/renderer/src/components/status-bar/resource-usage-session-rows.tsxsrc/renderer/src/components/status-bar/resource-workspace-host.tssrc/renderer/src/components/status-bar/runtime-host-resources.test.tssrc/renderer/src/components/status-bar/runtime-host-resources.tssrc/renderer/src/components/status-bar/use-resource-usage-actions.tssrc/renderer/src/components/status-bar/use-resource-usage-derived-model.test.tsxsrc/renderer/src/components/status-bar/use-resource-usage-derived-model.tssrc/renderer/src/components/status-bar/use-resource-usage-status-controller.tssrc/renderer/src/components/status-bar/use-runtime-host-resources.tssrc/renderer/src/i18n/locales/en.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| const sessions: UnifiedSessionRow[] = wt.sessions.map((s) => { | ||
| seenSessionIds.add(s.sessionId) | ||
| const tabId = index.ptyIdToTabId.get(s.sessionId) ?? null | ||
| return { | ||
| sessionId: s.sessionId, | ||
| paneKey: s.paneKey, | ||
| pid: s.pid, | ||
| label: resolveSnapshotSessionLabel(s, row.worktreeId, index), | ||
| bound: ctx.workspaceSessionReady && boundPtyIds.has(s.sessionId), | ||
| agentOwnership: ownershipBySessionId.get(s.sessionId) ?? 'unknown', | ||
| tabId, | ||
| cpu: s.cpu, | ||
| memory: s.memory, | ||
| hasLocalSamples: true, | ||
| ...(row.readOnly ? { readOnly: true } : {}) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -n -C3 'function makePtySessionId|parsePtySessionId|@@' src/shared/pty-session-id-format.tsRepository: stablyai/orca
Length of output: 1399
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- mergeSnapshotAndSessions.ts ---'
nl -ba src/renderer/src/components/status-bar/mergeSnapshotAndSessions.ts | sed -n '1,260p'
printf '%s\n' '--- runtime host resource ingestion references ---'
rg -n -C4 --glob '*.{ts,tsx}' 'ingestSampledWorktree|readOnly|runtimeHostId|seenSessionIds' src/renderer/src/components/status-bar src/renderer/src | sed -n '1,360p'
printf '%s\n' '--- PTY session ID implementation ---'
nl -ba src/shared/pty-session-id-format.ts | sed -n '1,180p'
printf '%s\n' '--- session ID creation and daemon-row filtering ---'
rg -n -C3 --glob '*.{ts,tsx}' 'makePtySessionId|ptyIdToTabId|boundPtyIds|ownershipBySessionId|sessionId.*@@|@@.*sessionId' src | sed -n '1,360p'Repository: stablyai/orca
Length of output: 42182
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- runtime-host resource types and producer ---'
rg -n -C5 --glob '*.{ts,tsx}' 'runtimeHostResources|diagnostics\.memory|memory.*worktrees|WorktreeMemory|host\.worktrees' src/renderer src/main src/shared | sed -n '1,420p'
printf '%s\n' '--- focused merge tests around remote samples and collisions ---'
rg -n -C12 --glob 'mergeSnapshotAndSessions.test.ts' 'remote|readOnly|seenSessionIds|collision|same.*session|sessionId' src/renderer/src/components/status-bar/mergeSnapshotAndSessions.test.ts | sed -n '1,420p'Repository: stablyai/orca
Length of output: 41948
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- runtime-host response parser ---'
nl -ba src/renderer/src/components/status-bar/runtime-host-resources.ts | sed -n '90,190p'
printf '%s\n' '--- local collector session handoff ---'
rg -n -C8 --glob '*.{ts,tsx}' 'sessions\.push|sessionId:|listRegisteredPtys|registerPty' src/main/memory/collector.ts src/main/ipc/pty.ts src/main/memory/pty-registry.ts | sed -n '1,300p'Repository: stablyai/orca
Length of output: 10297
Keep remote session IDs out of local merge state.
If a server sample uses the same raw ID as a local daemon session, the read-only sample enters seenSessionIds, so Step 2 skips the local daemon row. It can also inherit local tab binding and agent ownership.
For read-only rows, skip the seenSessionIds insert and clear local interaction state.
Suggested fix
--- "a/src/renderer/src/components/status-bar/mergeSnapshotAndSessions.ts"
+++ "b/src/renderer/src/components/status-bar/mergeSnapshotAndSessions.ts"
@@ -106,20 +106,22 @@
}
): void {
const repo = ensureRepo(row.repoId, row.repoName)
const sessions: UnifiedSessionRow[] = wt.sessions.map((s) => {
- seenSessionIds.add(s.sessionId)
- const tabId = index.ptyIdToTabId.get(s.sessionId) ?? null
+ if (!row.readOnly) {
+ seenSessionIds.add(s.sessionId)
+ }
+ const tabId = row.readOnly ? null : (index.ptyIdToTabId.get(s.sessionId) ?? null)
return {
sessionId: s.sessionId,
paneKey: s.paneKey,
pid: s.pid,
label: resolveSnapshotSessionLabel(s, row.worktreeId, index),
- bound: ctx.workspaceSessionReady && boundPtyIds.has(s.sessionId),
- agentOwnership: ownershipBySessionId.get(s.sessionId) ?? 'unknown',
+ bound: !row.readOnly && ctx.workspaceSessionReady && boundPtyIds.has(s.sessionId),
+ agentOwnership: row.readOnly ? 'unknown' : (ownershipBySessionId.get(s.sessionId) ?? 'unknown'),
tabId,
cpu: s.cpu,
memory: s.memory,
hasLocalSamples: true,
...(row.readOnly ? { readOnly: true } : {})
}
})📝 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.
| const sessions: UnifiedSessionRow[] = wt.sessions.map((s) => { | |
| seenSessionIds.add(s.sessionId) | |
| const tabId = index.ptyIdToTabId.get(s.sessionId) ?? null | |
| return { | |
| sessionId: s.sessionId, | |
| paneKey: s.paneKey, | |
| pid: s.pid, | |
| label: resolveSnapshotSessionLabel(s, row.worktreeId, index), | |
| bound: ctx.workspaceSessionReady && boundPtyIds.has(s.sessionId), | |
| agentOwnership: ownershipBySessionId.get(s.sessionId) ?? 'unknown', | |
| tabId, | |
| cpu: s.cpu, | |
| memory: s.memory, | |
| hasLocalSamples: true, | |
| ...(row.readOnly ? { readOnly: true } : {}) | |
| } | |
| const sessions: UnifiedSessionRow[] = wt.sessions.map((s) => { | |
| if (!row.readOnly) { | |
| seenSessionIds.add(s.sessionId) | |
| } | |
| const tabId = row.readOnly ? null : (index.ptyIdToTabId.get(s.sessionId) ?? null) | |
| return { | |
| sessionId: s.sessionId, | |
| paneKey: s.paneKey, | |
| pid: s.pid, | |
| label: resolveSnapshotSessionLabel(s, row.worktreeId, index), | |
| bound: !row.readOnly && ctx.workspaceSessionReady && boundPtyIds.has(s.sessionId), | |
| agentOwnership: row.readOnly ? 'unknown' : (ownershipBySessionId.get(s.sessionId) ?? 'unknown'), | |
| tabId, | |
| cpu: s.cpu, | |
| memory: s.memory, | |
| hasLocalSamples: true, | |
| ...(row.readOnly ? { readOnly: true } : {}) | |
| } |
ELI5
When your projects live on an Orca server, the Resource Manager now shows what that server's terminals are using, under those projects, with the server's name next to each row. Before, it only ever showed this computer, so a heavily loaded server looked like nothing was running.
What Changed
diagnostics.memorymethod (the same one behindorca diagnostics memory) throughcallRuntimeRpcfor each runtime environment found in the repos' and workspaces' execution host ids. The reply is treated as untrusted: unknown fields are ignored and malformed rows are dropped. The merge attributes a server row to a project only when this client places that project on that same server (runtime:<id>); any other row from the server keeps a host-qualified id so it never merges into a same-id row from another host. This computer's own samples are still kept out of server-hosted projects, as before.mergeSnapshotAndSessions.tsintoresource-session-labels.tsunchanged, to keep the merge file under the line limit.Why
The design called for a new
resources.listmethod behind ahost-resources.v1capability. Servers already answerdiagnostics.memory(since June) with exactly the per-workspace, per-terminal samples the panel renders, computed on the server for its own terminals. Reusing it means no wire change: no new method, no new capability, no new permission, and old servers work as soon as the client updates. A server older than that method answersmethod_not_found, which the panel turns into the "update server" note the design asked for.Only an open panel polls, so a closed status-bar chip never contacts the server. Server rows are read-only because ending a remote terminal needs that host's ownership checks, which is a separate change.
Linked Issue
Fixes #24464
Visual Proof
N/A in this run: the machine is load-capped (no local Electron). The row rendering (server name instead of "remote", no kill button) and the notices are covered by component tests.
Testing
mergeSnapshotAndSessions.test.ts: a server's samples render under the project it hosts, with the server's name, history and read-only sessions; this computer's sample of the same id stays out; a server row for a project this client places elsewhere stays in its own host-qualified group. Onmain, the merge had no input for server samples and dropped server-hosted projects entirely.runtime-host-resources.test.ts: only runtime host ids are polled; malformed rows and sessions are dropped;method_not_found→ "update"; any other failure → "unknown", never an empty list.ResourceUsageStatusSegment.rows.test.tsx: server rows show the server name and no kill control.pnpm tc:web,pnpm test src/renderer/src/components/status-bar/(66 files), oxlint,pnpm run check:code-quality:changed.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)