Skip to content

Fix Resource Manager session polling lag - #7050

Merged
Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/fix-resource-manager-session-poll-lag
Jul 1, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/fix-resource-manager-session-poll-lag

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Stop Resource Manager from polling global daemon terminal sessions every 10s while the popover is closed.
  • Keep session inventory refreshes on explicit Resource Manager use: open, kill, restart, and kill-orphan actions.
  • Use renderer-owned PTY bindings for the closed status-bar terminal count so typing does not pay for daemon-wide inventory.

Measurement

  • On Jinwoo's main Orca profile, daemon-v18 owned ~146 sessions.
  • Passive monitor showed ~10s-periodic daemon ping stalls while typing, with spikes around 516-1039ms.
  • The timing matched the closed Resource Manager session poll interval.

Verification

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/status-bar/ResourceUsageStatusSegment.session-polling.test.ts src/renderer/src/components/status-bar/resource-session-bindings.test.ts
  • pnpm exec oxlint src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx src/renderer/src/components/status-bar/ResourceUsageStatusSegment.session-polling.test.ts
  • pnpm exec tsc --noEmit --project tsconfig.json
  • Temporary E2E probe confirmed window.api.pty.listSessions() stayed at 0 calls for 12.5s while Resource Manager was closed.

Made with Orca 🐋


Open in Stage

@ghost

ghost commented Jul 1, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 3 individual chapters for you:

Title
1 Remove background session polling logic
2 Implement renderer-owned session count for closed state
3 Verify polling behavior with unit tests
Open in Stage

Chapters generated by Stage for commit a0e5286 on Jul 1, 2026 9:57pm UTC.

@coderabbitai

coderabbitai Bot commented Jul 1, 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: 866e0dad-3dae-4493-876f-b59bd066e951

📥 Commits

Reviewing files that changed from the base of the PR and between d0e1a70 and a0e5286.

📒 Files selected for processing (1)
  • src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx

📝 Walkthrough

Walkthrough

This change modifies ResourceUsageStatusSegment.tsx to stop continuous background polling of session data. Session inventory now refreshes only when the popover opens or after session actions, while memory snapshot polling uses a single interval while the popover is open. Session count logic now uses closedSessionCount and triggerSessionCount for badge, tooltip, and ARIA label rendering. A new test file checks that session polling does not occur while the popover is closed.

Changes

Cohort / File(s) Summary
Polling constants Removed visibility-interval import; replaced SESSIONS_POLL_MS with POLL_MS
Popover effects Reworked open/close effects to refresh sessions on open/action rather than continuous polling
Count derivation & UI Introduced closedSessionCount/triggerSessionCount; updated badge, tooltip, ARIA label, comments
Test Added source-check test verifying no session polling while popover is closed

Sequence Diagram(s)

Included above in the hidden artifact for the polling effect layer.

Suggested labels: area:renderer, status-bar, refactor

Suggested reviewers: none identified from provided context

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary, measurement, and verification, but omits required screenshots, testing checklist, AI review report, security audit, and notes sections. Add the missing template sections, including screenshots or no-visual-change note, test checklist, AI review report, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing Resource Manager session polling lag.
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

🧹 Nitpick comments (4)
src/renderer/src/components/status-bar/ResourceUsageStatusSegment.session-polling.test.ts (3)

9-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Source-string assertions are brittle proxies for behavior.

The test never renders the component or exercises timers; it checks for the literal absence of identifiers (installWindowVisibilityInterval, SESSIONS_POLL_MS) and a static count of listSessions() occurrences. A behavior-preserving rename or an additional, properly-gated call site would fail this test even though the actual regression (background polling while closed) is not reintroduced. Conversely, a regression that reintroduces polling under a differently-named helper or interval constant would slip through undetected.

Consider replacing this with an actual behavioral test that renders ResourceUsageStatusSegment, mocks window.api.pty.listSessions, uses fake timers to advance well past the polling interval while the popover stays closed, and asserts the mock was not called — mirroring the manual E2E probe described in the PR objectives.


13-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Hardcoded call-count assertion is fragile.

toHaveLength(1) locks the test to exactly one textual occurrence of window.api.pty.listSessions(). Any legitimate addition of another correctly-gated call site (e.g. a future explicit refresh trigger) breaks this test for reasons unrelated to the polling regression it's meant to catch.


15-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Ordering check depends on exact substring match of the guard condition.

indexOf('if (!open || runtimeEnvironmentActive)') ties the test to the exact formatting/wording of the guard in the source file. Any harmless reformatting (e.g. splitting the condition across lines, renaming runtimeEnvironmentActive) silently makes openEffectIndex return -1, and since indexOf(x, -1) behaves like indexOf(x, 0), refreshIndex could still be found after index -1, potentially producing a false pass on the ordering check while the toBeGreaterThanOrEqual(0) assertion is what actually catches it. The test's protection here relies entirely on incidental string matching rather than verifying real effect-execution order.

src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx (1)

980-987: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Update the orphan-count comment to match the new open gate.

Line 983 now intentionally returns 0 while closed, so the comment above should say orphan counts require daemon inventory and are only computed while the popover is open; the closed badge uses renderer-owned PTY bindings instead. 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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9479c4bf-adab-4d72-871b-ecb3bd409958

📥 Commits

Reviewing files that changed from the base of the PR and between 8afa84a and d0e1a70.

📒 Files selected for processing (2)
  • src/renderer/src/components/status-bar/ResourceUsageStatusSegment.session-polling.test.ts
  • src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx

@Jinwoo-H
Jinwoo-H merged commit dc81613 into main Jul 1, 2026
1 check passed
AmethystLiang pushed a commit that referenced this pull request Jul 30, 2026
Added open-only sessions re-poll (SESSION_LIST_POLL_MS) and clear sessionsError on popover close; blocks stale-session (C1) and stuck daemon-unreachable badge (C2).
AmethystLiang pushed a commit that referenced this pull request Jul 30, 2026
Added open-only sessions re-poll (SESSION_LIST_POLL_MS) and clear sessionsError on popover close; blocks stale-session (C1) and stuck daemon-unreachable badge (C2).

Co-authored-by: orca-bug-scan-bot <[email protected]>
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
…ai#7066)

Added open-only sessions re-poll (SESSION_LIST_POLL_MS) and clear sessionsError on popover close; blocks stale-session (C1) and stuck daemon-unreachable badge (C2).

Co-authored-by: orca-bug-scan-bot <[email protected]>
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