mirror of
https://github.com/stablyai/orca.git
synced 2026-09-28 00:02:41 +00:00
The agent hook-completion notification subscriber runs syncAgentHookCompletionNotificationSettings() -> pruneClosedPaneCoordinators() on every store notify — which includes every OSC title/spinner frame, since tabsByWorktree reallocates on each. The prune looped every coordinator and, for each, re-flattened Object.values(tabsByWorktree).flat().find(...) to resolve its tab, i.e. O(coordinators x total-tabs) of array allocation + scan per notify. Unlike the sibling mobile-sync path, it had no gate. Build the paneKey->tab index once per prune pass and thread it through paneCanReceiveHookCompletion / paneKeyHasUnsuppressedPtyHint (single-call sites keep the direct lookup). First-wins index matches the previous flat().find() semantics exactly. Also skip the pass entirely when no coordinators are tracked (the common idle case). Tests: selective prune across many coordinators still evicts only the panes that lost liveness, and tabsByWorktree is read exactly once per prune pass regardless of coordinator count (pre-fix: once per coordinator). Co-authored-by: Orca <help@stably.ai>