[perf-remote] perf(renderer): gate unread badge scans - #13554
Merged
Conversation
Contributor
📝 WalkthroughWalkthroughThe unread dock badge hook now subscribes to worktree, tab, and unread-terminal-tab state with a shallow Zustand selector. It memoizes unread-count calculation before synchronizing the dock badge. Tests use the real app store, reset state between cases, and verify that unrelated updates and parent renders do not recount while relevant state changes do. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ELI5
Orca keeps an OS unread badge in sync. Before this change, every renderer state update asked, “How many unread workspaces do I have?” Answering could walk every workspace and every terminal tab—even when the update was only a remote host status or agent-status tick.
Remote Orca servers amplify both sides: they add workspaces/tabs to count and produce more unrelated renderer updates.
Now Orca reuses the count until one of the three things that can affect it actually changes. A remote session update that replaces terminal tabs still recounts; unrelated remote status and agent updates do not.
Synthetic benchmark
Median per unrelated store publication on Node 24. Each fixture has one terminal per worktree and one unread terminal in the final entry. This is a selector microbenchmark, not end-to-end frame timing.
Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildFocused validation:
0 → 1 → 0pnpm run check:code-quality:changed— zero findingspnpm run check:max-lines-ratchetgit diff --check origin/main...HEADAI Review Report
An adversarial test review found two low-severity gaps:
0 → 1 → 0.A production mutation audit found the selected worktree, tab, and unread containers are replaced rather than mutated in place, so shallow reference gating is safe. No correctness, cleanup, mock-pollution, or cross-platform issue remained after the changes.
Cross-platform review found no changed shortcut, label, path, shell, native-module, or Electron platform branch. The existing badge API behavior remains identical on macOS, Linux, and Windows.
Security Audit
No new input handling, command execution, filesystem path handling, auth, secrets, dependency, IPC, RPC, or remote-wire behavior. This only gates an existing renderer-side computation over existing in-memory state. No follow-up security work identified.
Notes