Skip to content

fix(status-bar): Resource Manager closed badge terminal count + RAM seed - #9387

Merged
brennanb2025 merged 7 commits into
stablyai:mainfrom
mmarabel:fix/resource-manager-closed-badge
Jul 23, 2026
Merged

brennanb2025 merged 7 commits into
stablyai:mainfrom
mmarabel:fix/resource-manager-closed-badge

Conversation

@mmarabel

@mmarabel mmarabel commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the Resource Manager closed status-bar chip:

  1. Terminal count no longer uses tab/layout PTY wake-hint IDs (boundPtyIds), which inflated the badge (e.g. >_ 63 with only a handful of live sessions).
  2. Memory is seeded on workspace session ready so the chip is not stuck on — until the popover is opened.

Fixes #9386
Related: #8372 (same closed-vs-open counter dual source).

User-visible change

Before (closed) After (closed)
Inflated terminal count from wake hints Cached pty.listSessions() count
Memory shows — until click Memory seeded without opening the popover
Open panel looked correct Open panel unchanged (still real inventory)

Closed mode still does not continuously poll listSessions (perf). It seeds on session ready, refreshes on open/kill, drops exited sessions via pty.onExit, and re-inventories once when a new live mounted PTY appears while closed.

AI-agent review summary

  • Cross-platform: Renderer-only status-bar change; same IPC on macOS/Linux/Windows.
  • SSH/remote: Count still comes from pty.listSessions() (local daemon inventory); wake-hint IDs are no longer used as a closed proxy. Remote live ids that are not yet in the daemon list trigger a one-shot re-inventory when the live map changes.
  • Agent/integration: No agent spawn/resume path changes. Idle shells correctly continue to count as sessions once inventory is real.
  • Performance: No closed-state session poll interval. One seed of listSessions + memory.getSnapshot when session-ready; memory interval remains open-only.
  • UI quality: Closed chip matches open inventory semantics for the number; orphan (N) suffix remains open-only.
  • Security: No new IPC surface; existing listSessions / getSnapshot / onExit only.

Test plan

  • Unit: resource-session-inventory helpers
  • Unit: ResourceUsageStatusSegment session inventory source contracts (no wake-hint closed count; memory seed; no closed poll interval)
  • Manual: closed chip terminal count matches open panel list
  • Manual: closed chip shows RAM without opening Resource Manager first
  • Manual: create/kill terminal while closed updates badge without continuous polling lag

Screenshots (before; terminal / workspace names redacted)

Closed (wrong) Open (correct for same moment)
Closed chip ~63 Open panel >_ 5 (2)
Full UI closed chip 63
Memory — until click: dash Memory after load: 1.27 GB

Close-up of inflated closed chip:

6.33 GB · >_ 63

Reliability contract

  • Invariant: terminal-performance.no-hot-list-sessions — typing, focus, tab/workspace switch, visibility resume, resize, render, and per-pane liveness never call global pty.listSessions().
  • Failure source: [Bug]: Resource Manager closed status-bar badge shows wrong terminal count and "—" for RAM #9386; stale layout wake hints inflated the closed Resource Manager count and RAM was never seeded.
  • Oracle / gate: config/reliability-gates.jsonc; focused tests prove one readiness inventory seed, no closed interval, one coalesced read for unknown spawn IDs, zero additional reads for known-session reattach signals, exit fencing, and newest-refresh-wins ordering.
  • Provider/platform coverage: local, daemon, SSH, and WSL share the main/preload lifecycle path; remote-runtime/web inventory remains intentionally excluded. The shared path is platform-neutral; deterministic evidence ran on macOS, with live Linux/Windows coverage still open.
  • Performance budget: steady closed state and known reattach signals perform zero inventory reads; a batch of unknown background spawns performs one. Memory polling remains open-only after the one readiness seed.
  • Diagnostics: inventory failures continue to surface through the existing Resource Manager daemon/session error state; IPC and hook tests identify missing spawn/exit delivery and ordering regressions.
  • Residual gaps: no live Electron high-session count measurement or manual Linux/Windows/SSH run is attached yet.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 500b1cae-3fc3-4ca4-89a2-3464a13653fb

📥 Commits

Reviewing files that changed from the base of the PR and between 6ef3e14 and 42c7178.

📒 Files selected for processing (1)
  • config/reliability-gates.jsonc
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/reliability-gates.jsonc

📝 Walkthrough

Walkthrough

ResourceUsageStatusSegment now uses a cached daemon session inventory for badge counts and session state. The inventory is seeded after workspace session restoration, refreshed from daemon sessions and PTY lifecycle events, and pruned on exits or kill actions. PTY spawning now emits renderer lifecycle notifications, while session listing starts local and SSH inventory requests concurrently. Tests and reliability-gate metadata cover inventory behavior, lifecycle races, polling, and readiness seeding.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the closed badge terminal-count and RAM seeding fix.
Description check ✅ Passed The description is mostly complete and includes summary, screenshots, testing, review, security, and notes content, though not in the exact template.
Linked Issues check ✅ Passed The changes match #9386 by seeding RAM, switching closed counts to daemon inventory, and avoiding continuous closed-state polling.
Out of Scope Changes check ✅ Passed I don't see unrelated code changes; the config, IPC, hook, and tests all support the closed-badge inventory and RAM-seeding fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9acee167-f103-41ca-88f5-a0c080ef4833

📥 Commits

Reviewing files that changed from the base of the PR and between 403d681 and fcd4cfe6f6d694264b795c970fc08477b6088f65.

📒 Files selected for processing (6)
  • 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/resource-session-count-selector.test.ts
  • src/renderer/src/components/status-bar/resource-session-count-selector.ts
  • src/renderer/src/components/status-bar/resource-session-inventory.test.ts
  • src/renderer/src/components/status-bar/resource-session-inventory.ts
💤 Files with no reviewable changes (2)
  • src/renderer/src/components/status-bar/resource-session-count-selector.test.ts
  • src/renderer/src/components/status-bar/resource-session-count-selector.ts

@brennanb2025

Copy link
Copy Markdown
Contributor

Taking a look!

mmarabel and others added 3 commits July 20, 2026 20:07
…tory

The closed chip counted tab/layout PTY wake hints (inflating terminal
count) and never fetched memory until the popover opened (showing "—").
Cache listSessions for the badge, seed memory on session ready, and drop
the wake-hint closed selector.
CodeRabbit/React Doctor flagged mutating sessionInventoryRef during
render; keep the write in useEffect after commit.
@brennanb2025
brennanb2025 force-pushed the fix/resource-manager-closed-badge branch from d432ba1 to d620120 Compare July 21, 2026 03:17
@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for the fix — I took this over and pushed a maintainer follow-up. I rebased onto current main, kept the daemon-inventory and RAM seeding behavior, and replaced the mounted-pane create heuristic with explicit PTY spawn/exit lifecycle updates so background and reattached sessions stay accurate without closed-state polling; the inventory hook also coalesces batch spawns and guards out-of-order/exit races. Verified with 325 focused tests, the full typecheck, touched-file lint, React lint, and the max-lines ratchet.

brennanb2025 added a commit that referenced this pull request Jul 22, 2026
…rds (#9789)

* fix(sidebar): keep branch-discovered PR status visible on worktree cards

The sidebar status lane and the right checks panel read the same PR
caches but disagreed for unlinked worktrees: every successful GitHub PR
fetch mirrors the result into hostedReviewCache stamped with a
linked-style hint key ('github:<n>'), and getWorktreeCardPrDisplay
suppresses unlinked reviews with a non-empty hint. The checks panel
renders straight from prCache, so it showed "#9387 OPEN" while the same
worktree's card fell back to the plain branch icon.

Thread the branch-keyed PR cache number into getWorktreeCardPrDisplay as
corroboration: when the branch cache names the same PR the hosted entry
holds, the review provably belongs to this branch and stays visible.
WorktreeCard passes its existing cachedBranchFallbackGitHubPRNumber,
which is already guarded for linked metadata and the merged-head rule.

The hint stamping itself is unchanged on purpose: the 'github:' marker
also flags the entry as GitHub-scoped so neutral lookups still re-run
GitLab MR discovery.

* fix(sidebar): preserve PR lookup provenance

* fix(sidebar): preserve merged PR head guard

* test(github): assert exact refresh cache write

@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)
config/reliability-gates.jsonc (1)

2298-2318: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document the inventory-model assertions.

resource-session-inventory.test.ts is declared in testFiles and executed by the command, but has no assertionRefs entry. Add one so inventory construction, removal, and unknown-PTY detection remain auditable in this gate’s coverage map.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6f606318-09ae-4ac5-944b-f131450be47c

📥 Commits

Reviewing files that changed from the base of the PR and between d432ba186155b2115319fb96bc370684c2eceb9f and cd6f749.

📒 Files selected for processing (1)
  • config/reliability-gates.jsonc

@brennanb2025
brennanb2025 merged commit d4387b1 into stablyai:main Jul 23, 2026
4 checks passed
nwparker added a commit that referenced this pull request Jul 24, 2026
This reverts commit 8f40ddf (#10179).

Rebased on current main. The revert applied cleanly across the vast majority
of the 1,626-file PR; the remaining work was preserving PRs that had been built
on top of #10179 after it merged. All are preserved:

- #9990  perf(terminal): cold-restore replay
- #10213 fix(codex): TUI settings promotion
- #10135 fix(mobile): images in native chat
- #9387  fix(status-bar): Resource Manager badge + concurrent listSessions
- #9853  fix(app): bound wake/quit paths (phone-session-ended freeze)
- #10237 fix(claude-accounts): quote claude path for Windows (kept shell:false)

Because those PRs were written against helper modules/APIs that #10179
introduced, the minimal, typecheck-verified closure they depend on is kept so
the tree builds and every later-PR test passes:

- bounded file/JSON readers used by #10213/#9990 (agent-state-file-reader,
  node-bounded-file-reader, json-text-structure-limit, terminal-history limits)
- claimed-agent-pty-owner cap API + pty:listSessions admission (#9990/#9387)
- the mobile-E2EE outbound-memory-budget subsystem #9853 builds on
  (e2ee-channel, mobile-e2ee-*, ws-outbound-backpressure-queue,
  remote-runtime-request-frames/-memory-limits, map-with-concurrency, e2ee-crypto)

Everything else #10179 added (~555 files) is deleted; every file it modified
elsewhere is restored to its pre-#10179 state.

Verified: root typecheck (node+cli+web), mobile typecheck, full root test suite,
full mobile test suite, oxlint, localization catalog + coverage, reliability
gates, max-lines ratchet, and the CLI emit build all pass. Two checks fail only
locally and fail identically on clean origin/main (this clone's git-tag
namespace for verify:skill-bundle-manifest; an inherited GIT_CONFIG_* env for
one relay test) — both pass on a clean CI environment.

Co-authored-by: Orca <help@stably.ai>
nwparker added a commit that referenced this pull request Aug 5, 2026
…#12468)

* fix(status-bar): invalidate the CLI session count on kill and restart

`pty:management:killOne` / `killAll` / `restart` tear sessions down via `adapter.shutdown()` and broadcast nothing — unlike `pty:kill`, which ends in `sendPtyExitToRenderer`. The status-bar count is an event-sourced cache, so killing sessions from Manage Sessions or "Kill all terminals" left the `>_ N` chip frozen until the popover was opened, which itself triggers a refresh.

> [!NOTE]
> The dual-source split described in the issue text was already fixed by merged #9387. This closes a *different* remaining invalidation gap that produces the same reported symptom.

Broadcast the teardown so the chip updates without needing the popover opened.

Fixes #8372

Co-authored-by: Orca <help@stably.ai>

* test(e2e): add recordable proof for status-bar-cli-session-count

Fails on origin/main, passes on this branch.

Test: drops after Manage Sessions kills a foreign daemon session, popover never opened

Co-authored-by: Orca <help@stably.ai>

* fix(status-bar): avoid duplicate inventory refresh after kill all

---------

Co-authored-by: Orca <help@stably.ai>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…rds (stablyai#9789)

* fix(sidebar): keep branch-discovered PR status visible on worktree cards

The sidebar status lane and the right checks panel read the same PR
caches but disagreed for unlinked worktrees: every successful GitHub PR
fetch mirrors the result into hostedReviewCache stamped with a
linked-style hint key ('github:<n>'), and getWorktreeCardPrDisplay
suppresses unlinked reviews with a non-empty hint. The checks panel
renders straight from prCache, so it showed "stablyai#9387 OPEN" while the same
worktree's card fell back to the plain branch icon.

Thread the branch-keyed PR cache number into getWorktreeCardPrDisplay as
corroboration: when the branch cache names the same PR the hosted entry
holds, the review provably belongs to this branch and stays visible.
WorktreeCard passes its existing cachedBranchFallbackGitHubPRNumber,
which is already guarded for linked metadata and the merged-head rule.

The hint stamping itself is unchanged on purpose: the 'github:' marker
also flags the entry as GitHub-scoped so neutral lookups still re-run
GitLab MR discovery.

* fix(sidebar): preserve PR lookup provenance

* fix(sidebar): preserve merged PR head guard

* test(github): assert exact refresh cache write
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…eed (stablyai#9387)

* fix(status-bar): seed Resource Manager closed badge from daemon inventory

The closed chip counted tab/layout PTY wake hints (inflating terminal
count) and never fetched memory until the popover opened (showing "—").
Cache listSessions for the badge, seed memory on session ready, and drop
the wake-hint closed selector.

* fix(status-bar): update session inventory ref in an effect

CodeRabbit/React Doctor flagged mutating sessionInventoryRef during
render; keep the write in useEffect after commit.

* fix(status-bar): follow daemon session lifecycle events

* perf(status-bar): skip inventory scans for known PTYs

* perf(status-bar): bound resource inventory refreshes

---------

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…stablyai#12468)

* fix(status-bar): invalidate the CLI session count on kill and restart

`pty:management:killOne` / `killAll` / `restart` tear sessions down via `adapter.shutdown()` and broadcast nothing — unlike `pty:kill`, which ends in `sendPtyExitToRenderer`. The status-bar count is an event-sourced cache, so killing sessions from Manage Sessions or "Kill all terminals" left the `>_ N` chip frozen until the popover was opened, which itself triggers a refresh.

> [!NOTE]
> The dual-source split described in the issue text was already fixed by merged stablyai#9387. This closes a *different* remaining invalidation gap that produces the same reported symptom.

Broadcast the teardown so the chip updates without needing the popover opened.

Fixes stablyai#8372

Co-authored-by: Orca <help@stably.ai>

* test(e2e): add recordable proof for status-bar-cli-session-count

Fails on origin/main, passes on this branch.

Test: drops after Manage Sessions kills a foreign daemon session, popover never opened

Co-authored-by: Orca <help@stably.ai>

* fix(status-bar): avoid duplicate inventory refresh after kill all

---------

Co-authored-by: Orca <help@stably.ai>
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.

[Bug]: Resource Manager closed status-bar badge shows wrong terminal count and "—" for RAM

2 participants