You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(bots): a groups notice names the room that changed, and only that room re-reads - #47523
When anything happened inside one bot group room (a message, a bot starting or finishing, an answer), Orca told every open window and phone "groups changed", without saying which room. So every open group room reloaded its latest 40 messages, even rooms where nothing happened. Now the notice says which room changed, and only that room reloads. Changes that touch every room (adding or removing members, rooms, or reconnecting) still reload everything, as before.
What Changed
A groups change notice can now name the rooms it touched (groupIds). Notices that land in the same short window are merged: their room lists are joined, and if any of them names no room, the merged notice names none, so every room reloads.
Changes that happen inside one room now name it: an owner's post, a turn's admission or delivery error, a reply that becomes the room's newest post, a member's answer or peer request, a stop, remote members' answers and asks, a scheduled run's post, a mail turn that never started, and a member's agent changing phase.
Desktop and phone room views reload only for a notice naming their group, or naming none. They still reload on reconnect, on returning to the foreground, and for notices from older hosts, which name no room.
Changes to the room list itself (create, edit, delete, membership, migration) stay host-wide. The sidebar's group list still refreshes on every groups notice, as before.
No visible change.
Why
Reloading every open room for a change in one room makes the work grow with the number of open rooms on every event. Reloading the one room an event names, and reloading everything only on reconnect, is the expected pattern for shared rooms. It also lets a room page carry more per post without that cost repeating for rooms that didn't change.
N/A: no visual or interaction change; rooms show the same content and refresh at the same moments for their own changes.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
src/shared/bots/bot-change-scope.test.ts checks how a notice window merges room ids and which rooms each notice reaches: named rooms only; every room once any change names none (or names an empty list), for a change of every kind, an older host's bare notice, or a kind this build doesn't know; no room for a notice of another kind; and the named rooms kept when a window reads a notice the bridge already read. It fails on main, where notices carry no room ids.
src/renderer/src/lib/bots-changed-window-event.performance.test.ts (perf contract) checks that every window listener shares one read of a notice, that only the named rooms' views re-read at 100 and 1,000 listeners, and that reading a notice doesn't copy its room list.
pnpm check:changed passes. CI covers Linux and Windows.
Performance
Less work: a change inside one room now reloads only the open views of that room, not every open room on the host. Host-wide changes and reconnects reload everything, as before. The notice gains a short list of room ids; each window reads a notice once for all its listeners, readers that want no room never walk the list, and an open room checks it through one set per notice.
Risk
The risk is a room missing a reload because a change names the wrong room or names one when it should name all. Every change that touches the room list stays host-wide, and an older host's notices name no room, so older or mixed versions keep the current behavior. A plain revert backs it out.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
…t room re-reads
Every change inside one group room (a post, a turn's admission or end, an
answer, a stop) sent a host-wide groups notice, and every open room on desktop
and phone re-read its 40-post page for it. The notice now names the room's group
when the change is inside one room; an open room re-reads only for its own
group, or for a notice that names none (roster edits, older hosts, reconnects).
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.
No actionable comments were generated in the recent review.
Walkthrough
Bot group update paths now include affected group IDs in change notifications. Change scopes accumulate, serialize, and parse those IDs. Desktop and mobile transcript hooks use the scope to determine whether a group change concerns the current room before rereading its transcript. Event listeners cache parsed scopes for each event detail object.
Merge Risk: Moderate · up to b10ed
Phone views may do extra work copying room lists for group notices that don't concern them. The author reports no repair for this. Resolve or explicitly accept it before merging.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: a groups notice now names the room that changed, so only that room re-reads. It uses the perf(bots) prefix and matches the changeset (bot-change-scope, groups.changed(…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description is thorough and covers every template section: ELI5, What Changed, Why, Linked Issue, Visual Proof (marked N/A with a reason), Testing, Performance, Risk with a level, Agent skill boun…
Full details: Title check
Explanation
The title names the main change: a groups notice now names the room that changed, so only that room re-reads. It uses the perf(bots) prefix and matches the changeset (bot-change-scope, groups.changed(groupId), per-room transcript rereads). It is a little long at 84 characters, but it is specific and clear.
Full details: Description check
Explanation
The description is thorough and covers every template section: ELI5, What Changed, Why, Linked Issue, Visual Proof (marked N/A with a reason), Testing, Performance, Risk with a level, Agent skill boundary, Notes, and Checklist. It explains the mechanism (groups notices now name affected rooms), the merge behavior, the fallback for older hosts and host-wide changes, and how to back it out with a plain revert. Minor gaps: the AI Disclosure section is empty (the template says to fill it in only for non-StablyAI members, so this may be acceptable), and the Testing section does not state which platforms were manually tested beyond noting that CI covers Linux and Windows. The Linked Issue cites #46084 as a partial fix and does not use the template's 'Fixes #' form; the template expects an actual linked issue for outside contributors. The author's note that the change lands before #47176 is a dependency note, not a closing reference.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 17ba2dce-e6b3-4fd1-a961-7969a64c9a6a
Commits
Reviewing files that changed from the base of the PR and between 808ef8c and b10edb4.
Files selected for processing: 2
src/shared/bots/bot-change-scope.test.ts
src/shared/bots/bot-change-scope.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
Perf scan: BLOCKED — one introduced P1. The localized page-read gate works, but the new room-ID payload is repeatedly copied before desktop listeners reject the notice, and room listeners search that array separately.
Reviewed base 31906e845718575b6aeb78fb2ea381c14167ff78 → HEAD 2d14127edaf687db0589dcf29545474573f3f6d6. The checkout HEAD matches the head being graded. All 18 changed files and the production publishers, transports and listeners below were inspected. No checkout files were changed.
P1 — Normalize and index room IDs once per notice, before fanout. Introducing lines: bot-change-scope.ts:256–258, with the new linear membership check at line 238.
Production route: room mutations/member phase transitions → BotChangeNotices → local IPC or remote client event → window event → eachonBotsChanged handler. In unchanged src/renderer/src/lib/bots-changed-window-event.ts:48–54, each same-host handler calls readBotChangeScopeWithItems before botChangeConcerns. The added .filter therefore visits and copies all G room IDs for every L listener, including chat-tree, Activity, Items, settings and access listeners whose interests reject a pure groups notice. The changed room callback then performs another linear includes per subscribed room. There is no room-count cap; coalescing limits frequency, not payload width. A burst naming many rooms is reachable through the changed per-room producers.
Executed deterministic check using the actual HEAD scope functions and desktop event helper, with base-source control, counted array accesses and real EventTarget dispatch:
Workload, one notice
Base room-ID copies
HEAD room-ID copies
HEAD membership element probes
Admitted page-read callbacks, base → HEAD
100 room listeners, 1 changed room
0
100
100
100 → 1
1,000 room listeners, 1 changed room
0
1,000
1,000
1,000 → 1
100 listeners interested only in status, 100 changed rooms
0
10,000
0
0 → 0
1,000 listeners interested only in status, 1,000 changed rooms
0
1,000,000
0
0 → 0
100 room listeners, all 100 rooms changed
0
10,000
5,050
100 → 100
1,000 room listeners, all 1,000 rooms changed
0
1,000,000
500,500
1,000 → 1,000
These are operation counts, not measured latency. Fleet pricing: for a stress population of 100 bot-view listeners and batches naming 100 rooms, sustained publication at 2 notices/s adds 20,000 ID visits/copies per renderer-second even when none of those listeners accepts groups. Scaling each population 10× gives 2,000,000 copies/s. Independently, the formula is L×G per frame: increasing only listeners or only changed-room width increases work linearly; increasing both makes it quadratic. Room membership searches add up to R×G probes per frame. The population assumptions are explicit workload dimensions, not a claim that every installation has 100 visible rooms. Bot-view listeners also exist outside visible room transcripts. This is unnecessary repeated work introduced before the skip gate, so P1 under the scan rules; no timing threshold is needed to establish that amplification. It consumes renderer CPU/allocation budget during busy multi-room updates.
Suggested repair: validate the scope once at the inbound event boundary, reuse the validated scope across listeners, and build one shared room-membership index per notice. Preserve host routing, unknown/legacy fallback and broad-change dominance. Add an operation-count guard at the desktop dispatch seam covering rejected interests and matching rooms at N/10N. This remedy was not implemented or validated in this review. Simply broadening large batches would restore the page-read amplification this PR is intended to remove.
Changed-work ledger. Let E be source events/s, G distinct named groups in one coalescing window, L same-host desktop listeners, R subscribed visible room/thread surfaces, A the surfaces whose group is named, S client-event wire subscriptions, P loaded transcript posts, and M room members/turns. Counts below concern added/changed work; surrounding storage and delivery work is unchanged unless stated.
Changed path
Trigger and population
Work, owner/thread and bound
bot-group-delivery.ts (all three sites)
Owner send/replayed send; rejected queued turn; each delivery completion
One existing change call at each site now carries one group ID. Host main/runtime, O(1) added work per call; delivery completion calls still scale with actual turns. No new timer, query, spawn or delivery.
bot-group-automation-run.ts
Each room automation run
One named change after storing/finding its post; O(1) added payload, same runtime lifetime.
bot-group-dead-mail-turns.ts
A read discovers a never-started mail turn and writes its failure
One named change per settled turn. Existing page traversal is up to 40 posts × their turns; checks dedupe in-flight work, remember up to roughly 5,000 operations and recheck open outcomes no sooner than 15 s. No new scan/retry.
bot-group-latest.ts
Member turn ends and its latest preview wins the stored order
One named change only when setLatest reports a kept preview. Existing journal read/member lookup unchanged.
bot-group-mention-handoffs.ts
Mention handoff transaction returns its stored/woken lines
One named change per serialized operation, not one added notice per mentioned bot. Existing M-sized reservation/delivery unchanged.
bot-group-peer-answer.ts
Answer append to a stored operation
One named change per saved answer; existing message update/text accumulation unchanged.
bot-group-peer-requests.ts
Mail turn is retargeted or appended
One named change on either branch. Replay early-return still skips it. Existing mail/root/history work unchanged. The separate worker-binding broad notice is unchanged.
bot-group-remote.ts
Remote ask batch settles, including failure
One named change in the batch's finally; no new per-peer RPC or request.
bot-group-remote-answers.ts
Room-mail arrival, including zero unread mail/error; startup recovery invokes the same path for rooms with unread mail
One named change per invocation on the existing notifying branches. Existing room inbox processing remains proportional to unread mail, with settled mail marked read; added payload is one ID.
bot-group-stop.ts
Owner stops a room/member/thread
One named change after the saved revision/member update. Existing member stop fanout unchanged.
Actual member phase transition, excluding observed ticks
Existing single host detector subscription; existing groupRoomOf lookup now returns its ID instead of being reduced to boolean. One named groups scope. Lookup still scans group records/thread members as before; no extra lookup introduced.
bot-group-runtime.ts + orca-runtime-bots.ts
Any above call; optional broad callers remain supported
O(1) array/object construction for one ID, passed to the existing host-owned coalescer. Local notifier plus client bus publication count unchanged.
bot-change-scope.ts accumulation/publication
Every admitted source call / each flushed batch
Set insertion proportional to supplied IDs; production changed callers supply one. O(G) retained IDs and one O(G) emitted array per window. Cleared by flush/dispose, broad scope dominates. Necessary changed-key union, but no fixed count/byte cap.
bot-change-scope.ts decoding/membership
Each inbound decode, each desktop listener, each interested room
O(G) filter/copy and O(G) membership search; repeated L/R times: finding above. Each predicate also constructs a fixed 11-kind Set; fixed size alone is not a separate finding.
One initial read; named notice gates before RPC: A reads rather than R. Every thread surface of a named group qualifies; thread IDs are not separately scoped. Hidden via isVisible=false unsubscribes. Matching reads still return ≤40 posts plus an earlier-page probe; byte size/member count are not capped by that row limit. Existing reducer merges/sorts P loaded posts.
Named groups gate now precedes both groupRead and readHostBots; unrelated pure-groups notice skips both. Bot/legacy/unknown changes still refresh. Existing item-read counters/count handling run before the new gate. One direct stream per mounted hook, stopped on effect cleanup; background event refresh gated by AppState.
Added shared test
Test invocation only
Three fixture room IDs and a few scope round trips; no shipped runtime work. Assertions inspected; the file itself was not run. Production functions were exercised by the separate check described here.
The recent-page backend is unchanged: bots.groups.read → readBotGroup → primary-key room record plus indexed roomMessages(...,40,...) and a one-row earlier probe; remote-answer/dead-mail handling can add work per returned turn/ask. JSON bytes and members remain output-dependent. This PR reduces how often unrelated rooms reach it; it does not introduce a storage rewrite or a new full-history read.
Publisher rates and idle accounting. One BotChangeNotices per host runtime, guarded by hasBots. Local desktop bots:changed and every S active runtime.clientEvents.subscribe stream receive the same notice; server publication does not filter by room interest. RuntimeClientEventBus visits its registered listeners. At quiescent idle: 0 bots notices/s and 0 new coalescer wakeups/s, base and HEAD. A sparse source event produces one next-tick frame, then one existing empty 500 ms tail wakeup. Sustained changes yield a leading frame then approximately 2 frames/s per wire/local notifier, unchanged. Counting/ordering can delay actual sends; no higher producer cadence was added.
Executed fake-clock check of the production coalescer: 60 s quiet → 0 timer callbacks/frames; isolated event → 1 notice + 1 empty tail timer; 1,000 changes at 100/s over 10 s → 21 frames, at most 50 room IDs/frame, then zero timers after settling. Disposal canceled a pending notice. The constructor parameter property was mechanically lowered for Node's type stripper; unused pane-ID imports were stubbed. No scheduling method was replaced.
Semantic no-op frames remain possible: zero-unread remote-mail arrivals and replayed source operations still notify. Under a continuous no-op source they can occupy the same ~2 frames/s; there is no content equality check. That behavior predates this span. For a single named changed room, the other R−A room listeners receive frames with no relevant change, but HEAD now suppresses their transcript RPCs. Each such desktop listener still pays the new decoder cost.
Listener census at HEAD, including unchanged consumers. Every row receives the publisher rate above when attached to that host; pure-groups effects are below. Unspecified dynamic counts depend on mounted consumers, not total persisted chats. They are counted explicitly as per-instance versus shared owners; no live app census was taken.
Desktop listener(s)
Ownership and pure-groups behavior
use-bot-group-transcript.ts
One window listener per visible room/thread hook; A recent-page RPCs/frame, R callbacks/membership checks. Cleanup removes listener; stale replies ignored, existing in-flight RPC is not aborted.
lib/bot-group-list.ts
One shared window listener while any group watcher exists, not one per row. One full bots.groups.list per frame, regardless of group IDs; no in-flight dedupe. bot-group-catalog-snapshot.ts publishes to every catalog subscriber and flattens/stamps group lists. Pre-existing broad work.
Per mounted hook subscriptions, underlying reads shared by keyed store. Their configured interests exclude groups, so no RPC on pure groups; scope decoding happens first. Hidden-window request deferral remains.
Shared service listeners (tool listener remains window-lifetime once installed; other two while attached); settings/bot interests reject groups after decode.
One listener per watched reader family; chats/threads/bot and lookAround/bot respectively. Reject groups after decode.
lib/bot-access-requests.ts
Shared installed follower, access only; rejects pure groups after decode.
native-chat/NativeChatClientAskRequestCard.tsx
One unfiltered listener per unsettled request card; every same-host frame starts an outcome RPC until settled/unmounted. Pre-existing card-count fanout.
webhooks/use-webhook-data.ts
Direct BOTS_CHANGED_EVENT listener per nonempty reader store, bypassing the scoped helper. Every notice refreshes subscribed keys, including other-host keys; one in-flight read/key plus an again flag, visible poller with 1 s cooldown. Separate 30 s/5 min fallback unchanged. Pre-existing broad invalidation.
Desktop transport census: local runtime-window-lifecycle.ts notifier → preload/api/bot-changes-bridge.ts → app-lifetime bridge → window dispatch; remote runtime client subscription → runtime-client-ipc-bridge.ts → paired window dispatch. Both preserve group IDs through the shared decoder. Local notifier targets its attached authoritative window; remote/client bus count is S active subscriptions, not all paired devices or all fleet hosts.
Phone listener(s)
Ownership and pure-groups behavior
host-bot-refresh.ts used by use-mobile-bot-group-transcript.ts
One direct client-event subscription per visible hook; outer interests accept groups, then new room gate skips unrelated transcript/bot reads. Existing itemReads.rooms still increments for every groups notice; visible group Items drawer can still list all groups via use-mobile-bot-group-items.tsx.
Same helper used by use-route-bot.ts
One subscription per ready route; BOT_VIEW/items/access interests exclude groups, so no route refresh after scope decoding.
One direct subscription per supported mounted chat; chats interest rejects pure groups after decode.
home/bots/home-bots-query.ts through query/host-event-router.ts
Query signal accepts groups; shared query refresh floor 3 s, so under sustained load at most about 1/3 fetch/s per active key. Reads computer/server bot answers and full group list; pre-existing.
Shared stream listener per catalog lifecycle; every foreground groups event increments the host key, feeding existing serialized listing refresh. Lists include group list, bots and associated summaries; broad scope remains pre-existing.
bots/use-host-bot-chat-trees.ts
One shared-stream callback per mounted list owner; iterates wanted trees and checks BOT_WORK_KINDS per bot, so pure groups starts no paired-host tree read. Pre-existing traversal; group-ID decode now also occurs once here.
Shared-wire consumers for worktree names, relay-host list and each host-preference owner; reject botsChanged by event type, so no groups work beyond callback dispatch.
subscribeSharedClientEvents shares one physical event wire per client for the latter consumers and the query router; the direct subscribeRuntimeClientEvents helper used by room/route/asks is separate. Unsubscribe removes listeners; final shared consumer releases the wire in a microtask. Existing startHostBotRefresh wakes every 3 s (1/3 wakeup/s per hook) even with a healthy stream, but skips RPC when listed+ready; background callbacks skip refresh. Base → HEAD idle wakeup rate is unchanged. No new subscription or interval is added by this PR.
Host in-process client-event listeners were also checked: client-events RPC subscribers forward botsChanged; window lifecycle's auxiliary listener, connector host/cloud hello listeners, notification acknowledgement listener, workspace-cleanup watcher, crew watcher, phone-push listener, sort-stamp producer, sidebar temporal title observer, workspace/detected-checkout producers, sidebar catalog/settings watchers and relay-host-list announcer all gate on other event types. They receive the existing bus callback but start no inventory/scan/publish for botsChanged. The changed phase detector remains one host subscription, not one per room.
Pre-existing amplification retained, not attributed to this span. At F group notices/s: full desktop group listings still read/parse all H groups once per catalog owner per frame, then notify its subscribers; phone Home/list/drawer paths likewise retain broad listing work. At F≈2 and H=100/1,000 this is 200/2,000 group-record parses/s per desktop catalog owner, before payload/member bytes. Unsettled client request cards can issue F×C outcome RPCs/s (200/2,000 at C=100/1,000); webhook invalidation still visits all subscribed keys. Member phase lookup still scans group/thread/member records on actual transitions. Matching transcript reducers still merge/sort their P loaded posts. Worker-binding bot-group-peer-requests.ts:269, membership edits, migration and reorder still publish broad groups notices, and broad notices still reread every visible room. These paths existed at base; the new gate reduces a subset rather than making them newly reachable. None is a separate introduced blocker here.
Six-question dispositions and regression-class screen.
Work before skip: finding — per-listener room-array decode precedes interest rejection. Transcript RPC admission itself is correctly narrowed.
Ownership/fanout: reviewed via census; no new owners/wires, but new L×G decode and R×G membership work. Shared group catalog remains broad.
Thread/storage: host/main retains existing synchronous SQLite page/list work; added payload aggregation runs there, repeated decoding/index searches run on desktop renderer/phone JS. No new subprocess/native work. No timing claim.
Growth/progress: finding above; G is window-scoped but uncapped. Broad/unknown/legacy fallback and both orders of broad+named coalescing passed correctness controls. Existing 40-post pagination advances by sequence; no new cutoff/retry frontier.
Execution host: traced local IPC and remote client-event preservation; no platform-specific process/path/probe changes. Live Windows/Linux/SSH/phone transport performance was not measured.
Teardown/idle: listener removal prevented further callbacks in the executed desktop check; coalescer disposal/settling passed fake-clock checks. Visibility/AppState, reconnect full refresh and shared-wire cleanup inspected. Existing in-flight reads only discard stale results; no newly added cancellation/resource owner. Real renderer/phone lifecycle and delayed item-count send ordering were not executed.
Touched recurring classes: unused construction before skip and hot-path collection searches finding; whole-snapshot/broad-subscription refresh matched, pre-existing (census above); per-instance page reads improved by source and operation checks; unchanged-input/no-op publication pre-existing, producer cadence unchanged; idle wakeups/polling no added timer/subscription, quiet coalescer checks passed; keyed retention window-scoped IDs cleared on flush/dispose; synchronous main SQLite existing calls become less reachable for unrelated rooms. No new eager import, filesystem/git scan, process fanout or persisted field.
Evidence limits. Checks ran on macOS, Node v26.5.0, through the test gate, using type-stripped production modules and counted proxy arrays; no dependency install/build or files were needed. The dispatch check mounted actual helper listeners, not React components; admitted callbacks stand for the RPC call sites, not executed database/network requests. No packaged Electron, native phone, CPU/frame/heap capture or live fleet census was run. The demonstrated result is excessive operation/allocation count, plus correct localized read admission and cleanup controls; it is not a measured UI stall or a complete application benchmark. The P1 is source-proven and reproduced independently of those measurement gaps.
…ok its rooms up in a set
Every bot view in a window re-read and copied the notice's room list, and each
room searched it in turn. The window now reads a notice once and shares it,
and a room's check is a set lookup built once per notice. A room list with no
room in it names none, so every room re-reads.
Replacing namedRooms(...).has(...) with groupIds.includes(...) leaves both assertions unchanged. The contract therefore misses a regression to repeated linear membership scans.
Add an operation-count case against botGroupRoomConcerned with many matching rooms. Count room-ID visits against a hardcoded bound. Keep the shared-scope assertions.
As per coding guidelines, a perf contract “counts operations at the layer that owns the behavior” and “fails when that fix is reverted.”
Source: Coding guidelines
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 039dd801-b6e8-4104-98eb-1bdced2ca6c3
Commits
Reviewing files that changed from the base of the PR and between 2d14127 and 1e8badd.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Performance re-scan: no introduced P0/P1 findings against 31906e845718575b6aeb78fb2ea381c14167ff78..1e8baddc17ffff8d8ec2c5e9d11b31e59e1e94e6 (all 20 changed files). The P1 in the previous scan is repaired. A change inside one named room still reaches the existing host notification listeners, but only that room's transcript readers start page reads. This verdict covers performance, not overall merge readiness.
Repair verification — executed operation counts. Production scope and desktop event-helper modules were loaded from base, previous head 2d14127edaf6, and this head. Counted proxy arrays measured actual ID entries read; actual event-helper listeners measured scope identity, admission and removal. L = desktop listeners, R = room predicates, G = distinct room IDs in a notice.
The base admitted all L room page reads on a groups notice; the repair admitted only the named rooms in all six dispatch workloads. Cross-host events admitted zero callbacks; after unsubscribe, another event admitted zero callbacks.
At bots-changed-window-event.ts:28, a WeakMap keyed by event detail now shares one decode across window listeners. At bot-change-scope.ts:238, another WeakMap builds a Set once for that decoded ID-array identity, followed by Set.has per room. Thus room-ID work is O(G + R), replacing O(L×G + R×G); decoding unrelated bot/item fields is also shared by desktop listeners. The two weak keys do not create a strong, lifetime-long registry of notices.
At F≈2 notices/s and L=R=1,000, G=100, the previous head paid 200,000 decoder ID visits/s plus 190,100 membership-array visits/s. HEAD pays 200 decoder ID visits/s, 200 set-input visits/s, and 2,000 Set.has calls/s. Existing event dispatch still calls L listeners; the new predicate's kind checking is bounded by the 11 defined kinds. These are operation counts, not measured CPU times. L/R=100 and 1,000 model the 100-agent population and 10× growth independently from changed-room burst width; they are stress populations, not a live device census.
Changed work: trigger, population and bound. Host work runs on the owning runtime's main/Node event loop; desktop predicates run on renderer JS; phone predicates run on phone JS. No added subprocess, filesystem inventory, persistent field, timer or subscription.
Changed path
Production trigger / frequency
Added or changed work, population and bound
bot-group-automation-run.ts:87
Accepted/replayed automation post, before delivery
Existing notice now carries the message's one group ID: O(1) per call, no new run or delivery.
bot-group-delivery.ts:128,169,276
Saved owner post; rejected queued turn; each delivery's finally
One ID per existing notice. Delivery count can follow recipient turns, but the PR adds no delivery loop or notification site.
bot-group-dead-mail-turns.ts:110
A returned turn is settled as never started
Existing notice names its current message's room; O(1) added payload per settled turn.
bot-group-latest.ts:68
Completed member reply wins the saved-latest check
One ID; existing kept/latest gate preserved. No notification per text delta is added.
bot-group-mention-handoffs.ts:145
Mention handoff saves its room lines
One ID per existing notifying reservation callback; no added per-member discovery or send.
bot-group-peer-answer.ts:34
Answer saved to its operation's post
One ID per save. Existing turn update and answer accumulation unchanged.
bot-group-peer-requests.ts:179,235
Retargeted or newly reserved mail turn
One ID on either existing notifying branch. Existing replay skip and mail/history work unchanged.
bot-group-remote.ts:255
Remote-ask batch settles, success or failure
One ID in existing finally; no added per-peer request.
bot-group-remote-answers.ts:197,234
Remote room-mail arrival, including no unread mail/error; startup settlement invokes this path
One ID per existing notifying branch. Existing unread-mail processing advances by marking settled mail read; no new history read.
bot-group-stop.ts:48
Owner stops room/member/thread after saving members
One ID per existing notice; member cancellation fanout unchanged.
Actual pane phase transition, excluding observed ticks
Existing single detector subscription and existing group-room lookup now retain the group ID instead of reducing the result to boolean. No second lookup. One named scope when found.
O(1) array/object for a single ID, into the existing host coalescer. Same notifier and client-bus publication count.
bot-change-scope.ts:158,203,265
Admitted source event; each batch publication; inbound decode
Set insertion for supplied IDs (changed callers supply one); one O(G) array of the changed-key union on flush; O(G) validation/copy per inbound decode. G is distinct changed rooms in that batch, not total saved rooms/chats/history. No count/byte cap; pending union resets on flush/dispose. Broad/any dominates named scope. Transport cost is proportional to IDs actually published × existing receiving streams, not IDs × desktop room listeners.
One decode per detail, one set build per ID-array identity, constant-size kind check and one indexed membership lookup per room. Weak keys follow notice lifetime; no expiry poll. N/10N counts above.
Desktop use-bot-group-transcript.ts:54
Visible mount; groups notice; explicit older-page action
New gate precedes RPC: A matching room/thread views read, rather than all R. A includes every visible thread surface of the named group; this is group-level, not thread-level scoping. One initial read remains. Cleanup unsubscribes and ignores stale completions; existing in-flight RPC is not aborted.
Gate precedes both groupRead and readHostBots. Unrelated pure-groups changes start neither. Bot changes and broad/legacy/unknown notices retain full refresh. Existing Items counters/count application before the gate remain. MobileBotGroupChat.tsx supplies navigation focus; MobileBotGroupRoom.tsx:107 also gates connection. No new hidden-room owner.
Two added test files
Test invocation only
Fixed fixture subscriptions/scopes: shared test covers coalescing/fallback; performance test uses 100/1,000 listeners. No shipped work. Assertions inspected; those Vitest files were not run. The independent operation checks above exercised production code and fail the previous implementation. The committed performance test guards shared scope identity/admitted reads, but does not itself count membership-array visits.
The unchanged backend page route is bots.groups.read → readBotGroup (bot-group-delivery.ts:292): primary-key group read, indexed room/thread page of ≤40 posts, and a one-row earlier-page probe. bot-group-store-tables.ts:92 indexes the same group/thread expression used by roomMessages. Post/member/answer bytes and turns are output-dependent; 40 rows does not cap bytes. Remote-answer/dead-mail settlement and reducer merge/sort over P already loaded posts remain existing costs. This PR makes those paths less reachable for unrelated rooms, with no broadened storage gate.
Publisher and listener rates. One BotChangeNotices per host runtime, with the existing hasBots guard. On flush, orca-runtime-bots.ts:325 sends the same scope to its attached desktop notifier and client-event bus; RuntimeClientEventBus.emit visits registered listeners. Every S active client-events stream forwards botsChanged without room-interest filtering. Actual S is active subscriptions, not all paired devices/hosts.
Executed fake-clock checks of the production coalescer on base and HEAD agreed:
60 s quiescent: 0 frames and 0 timer callbacks.
Isolated event: 1 next-tick notice plus 1 empty 500 ms tail callback.
1,000 distinct room changes at 100/s for 10 s: 21 notices, 22 timer callbacks including the empty tail; HEAD carried at most 50 IDs/frame and all 1,000 IDs across the frames.
After settling: no pending timer. Disposing a pending notice canceled it.
Under sustained input, F is approximately 2 frames/s after the leading frame, per notifier/stream; idle F=0. Counted Items sends can delay frames behind their existing ordering chain; this PR does not change that chain. Added wire bytes are O(sum of named ID lengths), e.g. roughly 39G bytes for UUID-sized IDs before envelope overhead: about 3.9 KB at G=100, per receiving stream, or ~7.8 KB/s at F=2. There is no room-listener multiplier on that payload within a desktop window. Independent wire recipients each still decode their incoming payload.
Listener census at HEAD. All rows below receive F same-host groups notifications/s when subscribed (0 idle, ~2/s sustained); other-host events are rejected where stated. “Reject” means zero downstream group-triggered RPCs, not zero callback execution. Counts are ownership formulas from source, not a live mounted-instance count.
Desktop listener(s)
Population / groups-event consequence
use-bot-group-transcript.ts
One per visible room/thread hook: R callbacks, A page RPCs/frame. Only this row uses room-ID membership.
lib/bot-group-list.ts
One shared window listener while any group watcher exists. One full groups.list/frame for the changed host, independent of group IDs; resulting bot-group-catalog-snapshot.ts publication stamps/flattens lists and calls its subscriber set. Existing broad work, no in-flight dedupe.
One listener per watched reader family; chats/threads/bot and lookAround/bot interests reject groups.
lib/bot-access-requests.ts
Shared installed access follower; rejects groups.
native-chat/NativeChatClientAskRequestCard.tsx
One unfiltered listener per unsettled request card, removed on settlement/unmount. Every same-host frame starts one outcome RPC/card. Existing C-card fanout.
webhooks/use-webhook-data.ts
Direct window listeners bypass scoped helper: up to four nonempty reader stores (summary, list, calls, pending summary). Every groups event, even another host's, visits all subscribed keys; one in-flight request/key with an again flag and visible poller cooldown of 1 s. Existing 30 s / 5 min fallback.
Desktop transport: local runtime-window-lifecycle.ts notifier → preload/api/bot-changes-bridge.ts (one decode per bridge callback) → app-lifetime bridge → window dispatch; remote runtime stream → runtime-client-ipc-bridge.ts (one decode) → paired dispatch. Shared window decode adds one more stage per notice, independent of listener count. Both routes preserve group IDs. Bridge/subscription cleanup is unchanged.
Phone listener(s)
Population / groups-event consequence
host-bot-refresh.ts for room transcript
One direct event wire per visible connected hook. Decodes once for that wire; new gate skips unrelated page and bot reads. Existing itemReads.rooms still increments for groups; an open Items drawer (use-mobile-bot-group-items.tsx) can still reread its full group list.
Same helper for use-route-bot.ts
One direct wire per ready enabled route; BOT_VIEW/items/access interests exclude groups, so no route refresh after decode.
use-mobile-paired-server-asks.ts
One direct wire per supported connected mounted chat session; chats interest rejects groups after decode.
home/bots/home-bots-query.ts via query/host-event-router.ts
Shared stream/router; groups match the query signal. Existing 3 s refresh floor limits sustained fetches to about 1/3/s per active query key; reads host/server bot answers and full group lists.
Shared stream callback per catalog lifecycle. Foreground groups event advances host listing key, with existing serialized listing refresh. Broad bot/group/summary work remains.
bots/use-host-bot-chat-trees.ts
Shared stream callback per mounted list owner; one scope decode, then existing traversal of wanted trees with BOT_WORK_KINDS check per bot. Pure groups starts no tree RPC.
Per name owner / shared relay-host feed / shared preference projection. Reject botsChanged by event type; no group inventory or scope decode.
The latter families share one physical subscribeSharedClientEvents wire per client; room/route/ask helper wires remain separate. Each distinct stream/decoding consumer pays O(G) for its received scope; there is no newly added per-row room subscription or per-room linear membership search. Shared-wire fanout already snapshots its listener set. Final unsubscribe releases the shared wire in a microtask.
Existing startHostBotRefresh intervals wake at 1/3 callback/s per mounted hook even with a healthy stream, skipping refresh when listed+ready. Base → HEAD: host/main and renderer gain 0 new steady-idle wakeups/s; phone gains 0, retaining that existing 1/3/s/hook fallback wakeup. The event-driven coalescer is idle at 0/s on both refs. Background event refresh is gated by AppState.
Host in-process census: RPC client-events subscribers forward at F; the window's auxiliary listener, connector host/cloud listeners, notification-attention acknowledgement listener, workspace-cleanup watcher, crew watcher, phone-push listener, sort-stamp producer, sidebar temporal title observer, workspace/detected-checkout producers, sidebar catalog/SSH watchers, and relay-host-list announcer all reject botsChanged by type. Each receives the existing bus callback, with zero downstream inventory or publication for it. The desktop's remote mobile-relay workspace watcher (runtime-environment-mobile-relay-hosts.ts:278) also receives the stream but only accepts ready/worktreesChanged/reposChanged. Phase detection is still one host subscription; observed ticks do not publish.
Pre-existing amplification retained, not introduced by this span. At F=2/s and H=100/1,000 saved groups, a desktop catalog owner still lists/parses 200/2,000 group records/s and publishes to its mounted catalog subscribers. Phone list/Home/drawer paths retain broad reads; Home's floor makes its full-list rate ≤~H/3 records/s per active key. For C=100/1,000 unsettled desktop request cards, outcome reads remain F×C = 200/2,000 RPCs/s. Webhook invalidation still visits K subscribed keys per event (F×K visits/s), with the per-key request gates above. A member phase transition still calls BotGroupStore.memberOf: list/parse H groups and search their thread/member populations until found, once per actual transition; this existed in the old boolean lookup. No additional lookup is introduced.
Worker binding (bot-group-peer-requests.ts:269), membership edits, migration and reorder still send broad groups notices. Broad/older notices still reread R visible room pages at F×R, and the zero-unread remote-mail branch can still send a semantic no-op frame. Matching transcript reducers still merge/sort P loaded posts. These paths predate base; HEAD neither raises their event rate nor removes an existing admission gate. They limit the scope of the improvement and are not new blockers.
Six-question dispositions.
Work before skip: reviewed. Desktop repeated decoding/index scans repaired by measured counts; transcript admission gates precede page RPCs on both clients. Generic inbound validation remains once per receiving decode owner, as listed.
Ownership multiplication: reviewed through the complete listener census. No new owners/wires; desktop payload/index work shared rather than multiplied by rooms. Existing broad consumers explicitly priced above.
Thread/storage: reviewed. New accumulation is host JS, matching is renderer/phone JS; unchanged synchronous indexed SQLite page/list work on host main becomes less reachable for unrelated rooms. No timing/CPU assertion.
Growth/progress: checked with independent L/R and G scaling, 1,000-change burst and semantic controls. Pending IDs represent required changed outputs once per batch; flush/dispose reset them. No new history cursor, cutoff or retry queue. Existing pagination progresses by sequence.
Execution host: local IPC, remote stream preservation and phone dispatch traced. No platform-specific shell/path/native/probe changes. No live Windows/Linux/SSH/native-phone performance measurement.
Obsolete work/idle: desktop listener teardown and coalescer cancellation/settling executed; phone background/foreground and cleanup controls executed. Weak-map lifetime and production visibility/shared-wire cleanup inspected. Existing in-flight reads discard stale replies rather than aborting transport; no new cancellation owner.
Touched recurring classes: unused construction/hot-path searches — matched, repair verified; whole-snapshot/broad subscriptions and per-instance IO — localized transcript admission improved, remaining broad work pre-existing; unchanged-input/no-op publication — pre-existing cadence retained; idle polling/wakeups — no addition, fake-clock control agrees with base; keyed retention — weak caches and batch-owned union, no strong cumulative registry; synchronous main SQLite — existing indexed calls, reduced reachability; startup imports — only the existing small shared scope module, no new SDK/adapter startup graph. No matching added subprocess fanout, whole-file rewrite, persistent state or global worktree/history scan.
Evidence limits. Checks ran on macOS with Node v26.5.0 through tc-gate, without installing dependencies, building or modifying files. Modules were type-stripped in memory. Desktop used actual helper listeners with a minimal window-event bus, not mounted React views. Coalescer check extracted the production class, mechanically lowered its constructor parameter property, and supplied fake timers; scheduling methods were unchanged. Phone exercised the production hook refresh closure, startHostBotRefresh and event-subscription helper with minimal React/AppState/network boundaries: unrelated room → 0 page/0 bot reads at HEAD versus 1/1 at base; matching/broad/legacy/bot/unknown → 1/1; status-only → 0/0; background → 0 reads; foreground → full read; cleanup removed stream, interval and AppState listener. Scope round trips passed named union, both broad-coalescing orders, any-kind, unknown-kind, legacy, empty/malformed-list fallback, and non-groups exclusion.
No packaged Electron/native-phone run, database/network execution, CPU/frame/heap profile, live mounted-population census or slow-device timing was taken. Transport and SQLite bounds are source inspection; the reported runtime result is operation/admission count, not a measured latency claim.
Problem: every change inside one bot group room (a post, a turn starting or ending, an answer, a stop) sent a host-wide "groups" notice, and every open room on desktop and phone reloaded its latest 40 posts for it, even rooms where nothing happened.
Change: the notice names the room's group when the change is inside one room; an open room reloads only for its own group, or for a notice that names none (room-list changes, older hosts, reconnect, foreground). The sidebar's group list still refreshes on every groups notice, as before. No visible change.
Fixed during review
Perf scan P1 (comment 7096130854): every window listener re-read and copied the notice's room list, and each room searched it linearly. The window now reads a notice once and shares it; a room's check is a set lookup built once per notice. Perf-contract test bots-changed-window-event.performance.test.ts fails on the earlier head.
Claude P2: a room list that is empty after reading (malformed or future peer) now means every room.
Verified
bot-change-scope.test.ts (merge invariant, fails on main) and the perf contract above; pnpm check:changed passes; CI green.
Claude review: READY (first pass and repair pass on 1e8badd).
Blinded Codex regression audit on 1e8badd: SAFE (traced every writer to desktop and phone readers, batching, older/newer peers, paired hosts).
Perf scan re-run on 1e8badd: no P0/P1 (comment 7096390714).
QA: qa=tests; no screen or layout change. The Linux remote check was skipped: that machine is down tonight.
Perf re-scan: BLOCKED — one remaining introduced P1 on the phone path. Repair 1e8baddc fixes the desktop per-listener room-array copies and linear membership searches from comment 7096130854. The shared decoder still adds those copies to phone listeners before their interest/background gates.
Graded base 31906e845718575b6aeb78fb2ea381c14167ff78 → HEAD 072e6b170d8cfff93a81910cc04a333ff09838d3, including the entire merged diff (20 files), unchanged production consumers and desktop renderer. The checkout and PR head both matched that head. No repository files were edited.
P1 — Phone consumers still copy every named room before rejecting the notice
Introducing change: bot-change-scope.ts:270–274 adds a full groupIds.filter(...) allocation to every readBotChangeScope call. Desktop now shares one decoded scope, but phone callers do not:
host-bot-refresh.ts:60–66 decodes before checking interest and before refreshInForeground checks AppState. This helper serves visible group rooms and each ready bot session route (use-route-bot.ts); the latter excludes groups entirely.
use-mobile-paired-server-asks.ts:92–99 decodes per supported mounted chat, then rejects a pure groups notice. Its subscription has no visibility/AppState gate.
use-host-bot-chat-trees.ts:112 and host-worktree-refresh.ts:103 independently decode the same event from the shared phone stream. Neither uses room IDs. The shared transport shares the wire, not the decoded scope.
Production trigger: the changed room-mutation/member-phase producers → host coalescer → every attached runtime.clientEvents.subscribe → these callbacks. With G distinct changed rooms/frame and L decoding phone subscribers, this adds L × G ID visits/copies/frame on phone JS, including subscribers producing zero outputs. No room-count cap or room-interest filtering exists at publication. The new WeakMap in the desktop event helper is absent from these routes; the room-membership WeakMap cannot help because each decode makes a different array.
Executed deterministic evidence, loading the actual scope, startHostBotRefresh and direct subscription helper from base and HEAD, with a fake client, active AppState and healthy stream. Interest was ['chats']; the event was groups only. Counted the production array-filter inputs; initial reads were excluded.
One notice
Base room-ID copies
HEAD room-ID copies
Refresh callbacks after notice
1 listener, 100 named rooms
0
100
0
1 listener, 1,000 named rooms
0
1,000
0
100 listeners, 100 named rooms
0
10,000
0
1,000 listeners, 1,000 named rooms
0
1,000,000
0
The 100/1,000 listener cases are independent scale workloads, not an assertion that a phone currently mounts that many screens. The one-listener control already proves new record-dependent work for an irrelevant notice. More mounted subscriptions multiply it; the web host stack retains route descriptors and hides older screens with display:none, and these route/ask subscriptions are not focus-scoped. No app census was taken.
Fleet pricing at sustained F≈2 frames/s: L=1, G=100 → 200 unnecessary visits/copies/s; G=1,000 → 2,000/s. At L=100, G=100 → 20,000/s; scaling both dimensions 10× → 2,000,000/s. Increasing either dimension alone multiplies work linearly. Busy hosts therefore spend phone JS/allocation budget on room identifiers that the consumer discards. This is a source-proven count regression before the skip gate, P1, without a fabricated latency claim. It is introduced by the overall span, not newly introduced by the repair commit.
Repair direction: admit by kind/foreground before decoding unused room data, or make room decoding lazy/owned at a shared inbound boundary and keep unrelated consumers from materializing the room list. Merely caching desktop notices leaves this path unchanged; merely caching a shared phone event would not eliminate copies on independent direct streams. Preserve legacy/unknown-kind fallback, broad-change dominance, host routing, reconnect freshness and genuine group updates. Add a deterministic check at the phone subscription seam: rejected groups notices must not traverse/copy the room array at G and 10G; meaningful chats/group refreshes and cleanup must still work. No repair was made in this audit.
Executed the real desktop emitter/listener helper and scope functions at base, repair parent 1e8baddc^, and HEAD using EventTarget dispatch. Counted room-array filtering, old linear membership probes, Set construction entries, scope identities and admitted read callbacks.
Desktop workload, one notice
Before repair: copies / linear probes
HEAD: copies / room-index builds / indexed IDs
HEAD admitted page-read callbacks
100 room listeners, 1 named room
100 / 100
1 / 1 / 1
1
1,000 room listeners, 1 named room
1,000 / 1,000
1 / 1 / 1
1
100 status-only listeners, 100 named rooms
10,000 / 0
100 / 0 / 0
0
1,000 status-only listeners, 1,000 named rooms
1,000,000 / 0
1,000 / 0 / 0
0
100 room listeners, all 100 rooms named
10,000 / 5,050
100 / 1 / 100
100
1,000 room listeners, all 1,000 rooms named
1,000,000 / 500,500
1,000 / 1 / 1,000
1,000
Accepted desktop callbacks shared exactly one scope identity per notice. HEAD has one O(G) decode per window event and one lazy O(G) index, then O(1) room membership per listener; the existing O(L) event dispatch remains. Base admitted all R room callbacks for a groups notice; HEAD admits A surfaces belonging to named groups. Preload/remote ingress performs an additional decode once at that boundary, not per desktop listener.
Executed HEAD correctness controls: union of named changes, broad changes in either order, empty-list broad fallback, bare legacy notice, unknown kind, other-host rejection, meaningful mobile chats update, and unsubscribe preventing later callbacks/removing fake-client subscriptions. The pre-repair empty-list control failed as expected; HEAD passed. The two added test files were inspected, not run as Vitest suites; the independent checks exercised production functions without installing dependencies or creating repository files.
Changed-work ledger: trigger → population → bound
Notation: E source changes/s; G distinct named groups in a batching window; L desktop listeners; R subscribed visible room/thread surfaces; A surfaces whose group is named; S wire subscriptions; P loaded transcript posts; M room members/turns. Host work runs on the runtime/Electron-main JS owner; desktop and phone predicates run on their respective JS threads.
Changed piece
Trigger/population
Added or changed work and bound
bot-group-delivery.ts, three sites
Send/replayed send, rejected queued turn, each turn completion
Existing notice now carries one group ID: O(1) extra construction/call. Completion cadence follows actual turns M; no additional delivery, query or subprocess.
bot-group-automation-run.ts
Each automation send
One named notice after stored/found post; O(1) added payload.
bot-group-dead-mail-turns.ts
Read discovers and settles a never-started mail turn
One named notice per settled operation. Existing in-flight/recheck tracking unchanged; page processing is ≤40 posts × their turns.
bot-group-latest.ts
Ended member turn whose preview wins saved ordering
One named notice only when kept; existing journal/member lookup unchanged.
bot-group-mention-handoffs.ts
Serialized mention handoff
One named notice per existing serialized operation; existing work over mentioned members unchanged.
bot-group-peer-answer.ts
Save an answer
One named notice per save; existing record/text update unchanged.
bot-group-peer-requests.ts, two sites
Retarget a mail turn or append its line
One named notice on either notifying branch; replay early-return still skips it. Separate worker-binding broad notice unchanged.
bot-group-remote.ts
Remote ask batch finishes or fails
One named notice in existing batch finally, not a new per-peer call.
bot-group-remote-answers.ts, two sites
Mail arrival, including no unread mail/error; startup recovery for unread rooms
One named notice per existing notifying invocation. Existing unread-mail processing remains proportional to unread rows, then marks consumed mail read.
bot-group-stop.ts
Owner stops a room/member/thread
One named notice after saved update; existing M-member stop fanout unchanged.
Actual pane phase transition; observed ticks excluded
Same single detector subscription and same groupRoomOf lookup, now retains returned group ID. One singleton scope when member found. Existing group/thread/member scan is not repeated by the change.
bot-group-runtime.ts + orca-runtime-bots.ts
Above named callers and unchanged broad callers
Optional singleton array/object into existing coalescer, O(1) for changed callers; no new subscription or cadence.
bot-change-scope.ts: accumulation/publication
E source calls / each flush
One Set insertion per supplied changed ID; changed callers supply one. O(G) temporary union and emitted array, cleared/replaced on flush; broad scope dominates. No fixed G/byte cap: this is necessary changed-key output, not a scan of all stored groups. At 10× changed keys, necessary output is 10×.
Same file: decoding/predicate
Each inbound decode and interested room check
O(G) copy per decode; lazy O(G) Set per array identity plus expected O(1) room membership. Desktop decode shared; phone repeated copies are the P1 above. Kind checks allocate a fixed 11-entry Set, independent of fleet size.
bots-changed-window-event.ts
Same-host window event × L listeners
New WeakMap shares scope by event-detail identity; host rejection precedes decode. O(G + L), not O(G×L), on desktop. No new listener/timer; weak keys do not create a process-lifetime event history.
Desktop transcript hook
Mount/show, named/broad groups event, explicit earlier-page action
Initial read unchanged. Named events admit A reads, previously R; other rooms issue zero transcript RPCs. Every thread surface of a named group qualifies. Hidden isVisible=false removes listener. Existing stale-reply guard ignores late results; RPCs already running are not canceled.
New gate skips both groupRead and readHostBots on unrelated pure-groups notices. Existing item/count bookkeeping occurs before it; bot/legacy/unknown notices still refresh. Existing direct subscription and fallback interval unchanged.
Both added test files
Explicit test execution only
Fixed fixture work plus 100/1,000 listener test cases. No shipped runtime execution. Desktop test asserts shared scope/read admission, but does not count Set builds or cover phone decodes; independent checks above supply those operation counts.
Unchanged admitted-page backend: bots.groups.read → readBotGroup → primary-key room record, indexed thread/group roomMessages(...,40,...), and a one-row earlier-page probe. Existing worker-operation lookups/remote-answer/dead-mail handling scale with returned turns/asks; 40 rows is not a byte/member cap. The schema has a matching (group_id, coalesce(json_extract(record,'$.threadId'),''), sequence) index. No new database migration, write, filesystem scan, child process, startup inventory or full-history read is introduced. Matching reducers still merge/sort P already-loaded posts.
Publication rates and complete listener census
Rates applying to every attached listener below: quiescent idle 0 bots notices/s, base and HEAD. One sparse source event gives a next-tick notice and one existing empty 500 ms tail timer. Under continuous changes, leading notice then approximately F=2 notices/s, per local notifier or active wire; no increased publication frequency. Source calls themselves remain E/s; the coalescer unions only supplied IDs. S wire subscriptions entail S deliveries of the payload; there is no per-room server filter.
Executed production-coalescer fake-clock control at base and HEAD: 60 s quiet → 0 callbacks/frames; isolated change → 1 frame, 2 timer callbacks, then 0 timers; 1,000 changes at 100/s over 10 s → 21 frames, 22 timer callbacks, then 0 timers, both refs. HEAD carried at most 50 room IDs/frame for that workload. Disposal canceled a pending frame. The constructor parameter property was mechanically lowered for Node's type stripper and unused pane-ID imports stubbed; scheduling methods were unchanged.
Desktop transport: one local window notifier → bots:changed → preload decoder → app-lifetime bridge → window event. A paired-host runtime stream → runtime-client-ipc-bridge.ts → paired window event. Both preserve room IDs. Remote frames are per attached stream, not multiplied by every fleet host. Each listener below receives the stated idle/load rate while attached; effect rates specify pure groups frames.
Desktop listener at HEAD, unchanged files included
Census/lifetime and downstream rate under groups load
components/bots/use-bot-group-transcript.ts
One listener per visible room/thread hook; R membership checks/frame, A page RPCs/frame. Cleanup removes listener.
One shared window listener while watchers >0. F full host-group-list RPCs/s; publication stamps/flattens lists and notifies all catalog subscribers. No in-flight dedupe; pre-existing.
components/bots/use-bot-host-read.ts
One listener per mounted hook; production users are chat tree, Activity, paired-server asks and Items read stores. Keyed stores share reads; interests exclude groups, so 0 group-caused RPCs. Hidden-window deferral unchanged.
One unfiltered listener per unsettled mounted request card C; F×C outcome RPCs/s, until settled/unmounted. Pre-existing.
webhooks/use-webhook-data.ts
Direct event listener per nonempty store (four store families), bypasses scoped helper. Every frame visits all K keys regardless of host; one in-flight read/key plus again, existing visibility/cooldown policy. Pre-existing; no scope decode here.
All same-host onBotsChanged listeners share the repaired desktop decode, including those rejecting groups; other-host listeners return before it.
Phone listener at HEAD
Census/lifetime and downstream rate under groups load
host-bot-refresh.ts for visible group transcript
One direct wire per visible hook; F decodes/s/hook, then named gate admits only matching group/broad refreshes. Existing itemReads.rooms still increments per groups frame, so an open Items drawer can still reload the broad group list.
Same helper for use-route-bot.ts
One direct wire per ready enabled bot route; F decodes/s/route, then rejects groups, 0 refreshes. P1 cost before rejection.
use-mobile-paired-server-asks.ts
One direct wire per supported connected mounted chat; F decodes/s/chat, then rejects groups. No visibility gate; P1 cost.
use-host-bot-chat-trees.ts
One shared-wire callback per mounted list owner, foreground only; F independent decodes/s/owner and traversal of wanted trees; BOT_WORK_KINDS excludes groups, so no paired tree RPC. New G-copy is unused here.
One router per query client/host client; queries selected from cache per event. Home accepts groups and rereads answers/full group list, with 3 s floor (about 1/3 fetch/s per active key). No shared scope-decoder call here.
use-live-worktree-name.ts
Shared-wire callback per focused name owner; rejects botsChanged by event type. 0 group-caused reads/decodes.
relay-hosts-feed.ts
Shared feed stream while wanted; rejects botsChanged by event type. 0 group-caused reads/decodes.
mobile-native-chat-host-preference.ts
Shared-wire callback per retained preference owner; rejects botsChanged by event type. 0 group-caused reads/decodes.
subscribeSharedClientEvents owns one physical wire per client for its consumers; the direct room/route/ask helper opens separate wires. Both remove subscriptions on cleanup; final shared release tears down its wire in a microtask. Existing startHostBotRefresh has 1/3 interval wakeup/s per hook, even with a healthy stream, but makes no fallback RPC while listed+streamReady; that rate is unchanged. New background room-list decoding still happens before AppState rejection in that helper.
Host bus census: RuntimeClientEventBus visits every registered callback once/frame. client-events.ts forwards groups to each S active wire; window notifier sends the local IPC separately. The following other bus listeners reject groups by event type and do no group-triggered scans/publications: window auxiliary notices; connector host listener; connector cloud hello listener; notification attention acknowledgement listener (ipc/notifications/notifications.ts); workspace-cleanup watcher; crew watch; terminal phone-push listener; sort-stamp producer; sidebar temporal title observer; detected-checkout producer; workspace-row producer; sidebar feed catalog watchers and SSH watcher; relay-host-list announcer (including the pairing bridge). Ownership is runtime/service lifetime or the named watcher lifecycle, not one listener per stored record; sidebar catalog watchers exist per subscribed feed domain and crew watches per active owner. Their bots-event idle/load callback rates are 0/F each, unchanged. The changed phase detector is one host subscription, not one per room.
Pre-existing amplification retained
These do not by themselves block this span; the new gate makes none newly reachable:
Desktop group catalog still reads/parses H groups per groups frame, publishes to all catalog subscribers, and can overlap reads. At F≈2, H=100/1,000 → 200/2,000 group records/s per catalog owner, plus record/member bytes. Phone Home, host lists and open group Items drawers retain broad listings.
Unsettled desktop request cards issue F×C outcome RPCs/s: 200/2,000 at C=100/1,000. Webhook notices still visit K keys/frame, including unrelated hosts.
Member-phase ownership still reads group records and scans threads/members; same lookup existed at base. Transcript reducers still merge/sort P loaded posts on matching refreshes, and matching page reads can overlap. No new cancellation/backpressure mechanism was added.
Remote-mail arrivals with zero unread rows and replayed operations can still send no-op notices at F; publication has no equality check. Membership/create/delete/reorder/migration and worker binding retain broad notices, so those still refresh every visible room. This span narrows localized updates rather than increasing those rates.
Existing ordered sends can retain queued notices if an earlier asynchronous items count stalls; the repair does not change that queue/progress policy. Room-ID storage per retained notice is output-dependent. No new timer, retry loop or long-lived registry was added.
Full census above. No new wires/listeners, desktop O(G+L); phone still O(G×decoders). Existing broad catalog/card/webhook fanout identified separately.
3. Thread/storage
New union runs on host/main, decode/index on renderer/phone JS. Existing indexed SQLite page/list paths inspected. No new sync filesystem/native/subprocess work; no timing assertion.
4. Growth/progress
Necessary changed-ID union/output is O(G), not persisted-room inventory. Desktop membership expected O(1); phone copy amplification is the finding. Existing paginated rows and recovery owners inspected; byte/turn sizes are output-dependent, not capped by 40 rows.
5. Execution host
Local IPC and paired/client-event routing inspected; no platform-specific code or SSH subprocess change. Executed on macOS Node v26.5.0, not native phone/Windows/Linux/SSH. Transport and device CPU/latency remain unmeasured.
6. Stop/release
Unsubscribe/dispose controls passed. Hidden room hooks stop listening; stale replies ignored rather than aborting RPC. New caches use weak keys with no permanent registry of notices. Existing phone fallback interval and retained-route behavior described above.
Touched regression classes: unused/pre-skip collection work — phone P1, desktop repaired; hot-path linear membership — repaired and counted; per-instance repeated reads/broad invalidation — transcript narrowing verified, remaining broad paths pre-existing; whole-snapshot publication — changed path carries only changed IDs, O(G) necessary output; new idle wakeups/fixed-cadence loop — no new cadence, base/HEAD fake-clock parity; no-op publication — pre-existing; sync SQLite/re-reading unchanged input — backend unchanged and less frequently admitted for unrelated rooms; per-entity lifetime/retention — weak caches plus teardown checked; unbounded fanout/queues — no new read admission, existing overlap/count queue noted; eager startup imports — new imports are the small shared scope module, no SDK/adapter or startup I/O added. Other regression classes had no matching changed mechanism.
Evidence limits: deterministic source-function operation counts and fake clocks, plus source trace of all listed consumers; no packaged app, native device run, heap/CPU profile, SQL timing, or real network delivery measurement. No claim of measured jank or battery use. The phone amplification is proven work, not deferred to a residual-risk note. Repository remained unchanged.
…ever while reading the notice
Every phone subscriber copied a groups notice's room list while reading the
notice, even those that then ignored it. The list is now kept as received and
walked once per notice, only by an open room's check.
Count room-element reads, not only array identity.
This assertion passes if readBotChangeScope traverses every room and then returns the original array. It does not establish the zero-traversal behavior named by the test.
Add counted element access and assert exactly zero reads during decoding. Keep the identity assertion if needed. As per coding guidelines, a perf contract “counts operations at the layer that owns the behavior” against hardcoded values.
Source: Coding guidelines
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: db6958eb-de24-4d72-913b-5ac85dabaa99
Commits
Reviewing files that changed from the base of the PR and between 072e6b1 and 808ef8c.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
No remaining P0/P1 performance regression found against 31906e845718575b6aeb78fb2ea381c14167ff78. Graded head: b10edb400890b33f8edea228ae60f7a5e1fa48c7. The P1 in comment 7096914261 is repaired: phone readers which do not need a room no longer copy or traverse the room-ID list before rejecting the notice. This supersedes that comment's blocked verdict for the new head. This is a performance verdict, not a merge-readiness determination.
Repair verification and executed evidence
At bot-change-scope.ts:277, decoding keeps the received array by identity. Only botGroupRoomConcerned validates/indexes its elements, once per array identity through the weak cache at lines 249–255. Subsequent room membership queries use Set.has. Reading an already decoded/structured-cloned scope preserves its received IDs.
Executed deterministic checks through tc-gate node --input-type=module, using target source functions, proxy-counted array element reads, injected transport/timers, and a base/previous-head control:
Workload
Previous reviewed head 072e6b17
Current head
100 decoders rejecting groups; 100 named IDs
10,000 ID element reads
0
1,000 decoders rejecting groups; 1,000 named IDs
1,000,000 ID element reads
0
100 interested room checks sharing a 100-ID source array
—
100 ID element reads total
1,000 interested room checks sharing a 1,000-ID source array
—
1,000 ID element reads total
Desktop event: 100 room listeners, 1 named room
—
1 decoded scope identity; 100 callbacks; 1 page admission, 1 ID element read
Desktop event: 1,000 room listeners, 10 named rooms
—
1 decoded scope identity; 1,000 callbacks; 10 page admissions, 10 ID element reads
Also executed the actual phone startHostBotRefresh and subscribeRuntimeClientEvents functions with 1,000 rejecting owners and a 1,000-ID notice: 0 refresh callbacks and 0 ID element reads, both active and background. Unsubscribing returned fake wire, interval and AppState listener counts to zero. Matching-room, unrelated-room and broad-notice recovery controls passed. Desktop unsubscribe produced zero subsequent callbacks.
Compatibility controls passed for merged named rooms; broad changes dominating scoped changes in either order; unscoped/legacy notices; unknown kinds; empty/all-invalid ID lists; non-groups rejection; and decode → structured clone → decode. Missing/unknown scope still refreshes rather than losing freshness.
Publication fake-clock control, base versus HEAD: 60 seconds quiet produced 0 callbacks/frames; an isolated change produced 1 frame, 2 timer callbacks, then no retained timer; 1,000 changes at 100/s over 10 seconds produced 21 frames, 22 timer callbacks, then no retained timer, at both refs. Disposing a pending notice prevented its emission.
Harness limits: macOS, Node v26.5.0; source TypeScript was stripped in memory, imports supplied as bindings, and the notifier's constructor parameter property mechanically lowered. The desktop event check used Node EventTarget/CustomEvent and an identity host normalizer for the already normalized local ID. Page admissions count calls through the production predicate, not completed database/network requests. No files in the checkout were edited, no dependencies installed, and no app build/device run performed. The two added test files were inspected; this report's counts come from the independent executed checks above, not an assertion that their Vitest suite ran.
Changed work: trigger, population, bound
Notation: E = source changes/s; F = coalesced notices/s; G = distinct changed room IDs in one notice; L = attached window listeners; R = visible room/thread consumers of this host; A = those whose group is named. For scale checks use 100/1,000 agents, listeners and rooms independently of the 750/7,500 worktree dimension. No changed path inventories worktrees, repositories, remotes, refs, terminals or transcript history to construct the room scope.
Changed piece
Production trigger / population
Work, owner and bound
bot-group-automation-run.ts
One saved automation post
One existing notification now supplies its message's group ID: O(1) scalar lookup/singleton array on host/main. Existing delivery unchanged.
bot-group-dead-mail-turns.ts
Settling a dead mail turn while processing page turns
One existing notification per settled turn names that message's room. No additional page scan or notification.
bot-group-delivery.ts (three sites)
Send/replayed send; queued-turn validation failure; each admitted delivery finishing
One singleton scope per existing call. Message/turn population and deliveries are unchanged; completion can notify once per turn, then coalesces.
bot-group-latest.ts
Completed member reply actually retained as latest
One singleton scope under the existing kept gate; no new journal read.
bot-group-mention-handoffs.ts
Saved mention handoff
One singleton scope per existing saved handoff; recipient traversal/delivery unchanged.
bot-group-peer-answer.ts
Save peer answer
One existing notification names the answer's group.
bot-group-peer-requests.ts (two sites)
Retarget existing mail turn or reserve a new one
One existing notification names the resolved group's ID. No new bot/member scan.
bot-group-remote-answers.ts (two sites)
Room mail arrival/recovery, including zero unread rows or read failure
One existing notification names the provided group ID. Existing unread-row work and marking read unchanged.
bot-group-remote.ts
Remote ask batch completes/fails
One existing notification in the batch finally names the message's room; no new per-peer publication.
bot-group-stop.ts
Owner stops room/thread/member
One existing notification names the updated group. Existing member-stop fanout unchanged.
One host-owned detector subscription. Same botSessions.groupRoomOf lookup as base; now keeps the returned ID instead of a boolean. At most one singleton groups scope per transition. Existing ownership scan is described below.
bot-group-runtime.ts + orca-runtime-bots.ts
Above callers and unchanged broad callers
O(1) singleton array/object for these localized calls into the existing coalescer; no new listener/cadence. Broad callers retain broad semantics.
bot-change-scope.ts: accumulation/publication
E calls, then each flush
One Set insertion per supplied changed ID (one in changed production callers); O(G) union/array/output per flush on host/main. This is the required changed-key output, not all stored rooms. G has no fixed numeric/byte cap; it is bounded by distinct named changes accumulated before the flush, and pending state is replaced at the flush. Broad scope dominates.
Same file: decode/room membership
Inbound scope read; then only interested room checks
O(1) new room-list work per decoder, zero ID visits before the room gate. First interested check validates G entries and constructs a Set; subsequent checks of that same array have expected O(1) membership, with a fixed 11-kind check. O(G) weakly held index per live array, no permanent notice registry. Distinct physical wire payloads have distinct arrays/indexes.
bots-changed-window-event.ts
Window notice × existing L listeners
Host mismatch returns before decoding. WeakMap shares one decoded scope per event-detail identity: room-list work O(G + R), not O(G×L); event delivery still visits L callbacks as before. Other scope fields are also decoded once per detail. No added listener/timer.
Desktop use-bot-group-transcript.ts
Mount/show, groups event, explicit older-page action
Initial/older-page reads unchanged. Named notice admits A page reads instead of R, including visible threads belonging to the named group. Visibility/unmount removes the subscription. Existing stale-result guard remains; in-flight RPCs are not aborted.
Pure groups notices for another room skip both groupRead and readHostBots. Matching/bot/broad/unknown notices retain recovery. Existing item/count bookkeeping precedes this gate and is unchanged. Hook teardown removes its direct subscription and interval.
Both added test files
Explicit test execution only
Fixed compatibility fixtures and 100/1,000-listener performance fixtures; no application runtime execution or new runtime resource. Identity assertion fails with the previous copying decoder.
At F≈2, one changed room among R=100/1,000 visible room consumers now admits 2 page reads/s, versus 200/2,000/s before, when A=1. Callbacks still number F×R; they now perform fixed kind checks and indexed membership instead of each issuing a page read. At G=100/1,000 a needed shared index visits 200/2,000 ID entries/s per receiving array owner, not G×L; uninterested phone decoders visit 0, independent of G and decoder count. These are operation counts, not measured milliseconds.
Admitted backend is unchanged: bots.groups.read → readBotGroup (bot-group-delivery.ts:292) → primary-key group read, indexed roomMessages(...,40,...), and a one-row earlier-page probe. bot-group-store-tables.ts:92 has the matching (group_id, coalesce(json_extract(record,'$.threadId'),''), sequence) index. Forty posts caps rows, not bytes or turns/members. Existing answer/dead-mail and operation lookups follow returned asks/turns. Existing reducers merge/sort all P loaded posts on matching refreshes. No added migration, synchronous filesystem operation, subprocess, database write or startup inventory.
Publication rate and listener census at HEAD
All attached listeners below receive 0 bots notices/s in quiescent idle, before and after. A sparse source burst emits next tick; continuous changes emit a leading notice then approximately F=2/s at the unchanged 500 ms coalescer. Short bursts can emit on either side of that window; this is not a strict sliding-second cap. One empty tail timer ends the schedule. Source mutation calls remain E/s.
Transport route: host notifier → local bots:changed IPC → preload decoder → app-lifetime window bridge; paired-host client-event stream → runtime-client-ipc-bridge.ts → paired window event. Both retain room IDs through decoding. Each S active client-event wire gets F frames/s, with O(G) ID payload serialization/copying per delivery; the host bus visits each registered callback once/frame. No per-room server filter or new subscription is added. The following census includes unchanged consumers; rates below refer to pure groups notices under load. Mixed/broad notices retain their existing interests.
Desktop listener / owner
Census, load work and release
components/bots/use-bot-group-transcript.ts
One per visible room/thread hook: F membership checks/s, F page reads/s only if named. Unsubscribe on hide/cleanup.
One shared window listener while watchers >0: F full changed-host group-list RPCs/s; stamp/flatten and catalog listener publication per accepted response. Last watcher unsubscribes. Pre-existing broad work.
components/bots/use-bot-host-read.ts
One per mounted hook for chat tree, Activity, paired-server asks and Items stores; keyed stores share actual reads. Interests exclude groups: 0 groups-caused RPCs. Listener removed on cleanup; hidden-window deferral unchanged.
lib/bot-host-per-bot-read.ts → own chats / Up next unseen
One shared listener per watched reader family (two families), not per row; chats/threads/bot or lookAround/bot interest: 0 groups-caused reads. Last watcher releases listener.
One unfiltered listener per mounted unsettled request card C: F×C outcome RPCs/s, until settled/unmounted. Pre-existing.
webhooks/use-webhook-data.ts
Direct window listener per nonempty read-store family (four families), bypassing scope decoder. Each frame visits K registered keys without host/kind filtering, requesting refresh or setting again; one in-flight read/key, existing visibility/cooldown policy. Last entry removes listener. Pre-existing.
All same-host scoped desktop listeners share the event-detail decode even if their interest then rejects groups. Other-host listeners reject first. Direct webhook listeners do not decode scopes.
Phone listener / owner
Census, load work and release
host-bot-refresh.ts → visible group transcript
One direct wire per visible hook: F scope decodes/s with 0 room-ID traversal in decode, then only matching/broad room refresh. Existing itemReads.rooms still bumps for every groups frame; an open Items drawer can reread the broad group list.
Same helper → use-route-bot.ts
One direct wire per enabled/ready route: F decodes/s, rejects groups, 0 ID visits and 0 refreshes for them.
use-mobile-paired-server-asks.ts
One direct wire per supported connected mounted chat: F decodes/s, rejects groups, 0 ID visits/reads. Existing lack of visibility gate unchanged.
use-host-bot-chat-trees.ts
Shared-wire callback per mounted list owner, foreground only: F decodes/s and traversal of wanted trees; BOT_WORK_KINDS rejects groups, 0 paired-tree RPCs and 0 room-ID visits.
Router per query-client/host-client owner; searches signalled query cache and schedules only active/focused queries. Home accepts groups and reads answers/full groups, 3 s floor (≤about 1/3 fetch/s per active key). No scope-decoder room walk.
use-live-worktree-name.ts
Shared-wire callback per focused name owner; rejects botsChanged by event type: 0 groups-caused reads/decodes.
relay-hosts-feed.ts
Shared wire while feed wanted; rejects botsChanged: 0 groups-caused reads/decodes.
subscribeSharedClientEvents owns one physical wire per client for its listeners, tears it down in a microtask after final release, and drops obsolete-wire deliveries. Direct room/route/ask subscriptions remain separate physical wires as at base; distinct received payload arrays can each need an index when a room actually uses them. The direct helper removes subscription/AppState listener/interval on cleanup. Its existing 3 s fallback interval contributes 1/3 interval wakeup/s per hook at both base and HEAD, even with a healthy stream; it issues no fallback read while listed+streamReady and no background refresh. The changed room handling adds 0 idle wakeups/s on host/main, desktop renderer, or phone JS.
Host-bus census:RuntimeClientEventBus sends each frame to all registered callbacks. client-events.ts forwards groups to each active wire, independently of the local window notifier. All other bus listener families below reject groups by event type and initiate 0 downstream groups work (their callback arrival rate is still 0 idle / F load): window auxiliary client notices; connector host refresh; connector cloud hello; notification-attention acknowledgement; workspace cleanup; crew runtime watch; terminal-agent phone push; sort-stamp producer; sidebar temporal terminal-title observer; detected-checkout producer; workspace-row producer; sidebar feed catalog watchers and SSH watcher; mobile-relay host-list announcer, including the pairing bridge's instance. These are service/runtime lifetimes or active watcher/feed/crew lifecycles, not one callback per stored chat/worktree. The agent-phase detector is one separate host subscription; observed changes return before room lookup. No changed subscription census.
Pre-existing amplification retained, not introduced or amplified by this diff
These remain performance concerns in the application; the new gate neither increases their trigger rate nor makes them newly reachable:
Desktop group catalog scans/parses H group records per groups frame and publishes the catalog to all its subscribers. At F≈2 and H=100/1,000: 200/2,000 records/s, plus member/record bytes; catalog reads can overlap. Phone Home/host lists and visible group Items drawers also retain broad group listings. itemReads.rooms remains broad before the new transcript gate.
Unsettled desktop request cards issue F×C outcome calls: 200/2,000 RPCs/s at C=100/1,000. Webhook stores visit K keys each groups frame, including unrelated hosts: 2K visits/s at F≈2, before their existing visibility/in-flight/cooldown rules. Query router still searches registered signalled queries per event; phone tree listeners still traverse wanted trees even when the scope rejects their RPCs.
Phase ownership still calls store.memberOf, which reads the group list and searches group/thread members (bot-group-store.ts:130); the previous boolean path called the same function once. With 100 phase transitions/s and H=100/1,000 groups, worst-case list traversal is 10,000/100,000 group records/s, plus threads/members. No new scan was added to recover the ID.
Matching transcript refreshes still merge/sort P loaded posts, not only the 40 incoming rows: about F×A×O(P log P) work. Matching reads can overlap; stale replies are ignored, not canceled. Both already existed, and unrelated-room admission is reduced.
No-op remote-mail/replayed-operation notifications remain possible. Broad membership/create/delete/reorder/migration/worker-binding changes still refresh all visible rooms, intentionally unchanged. The existing send-order chain can retain notices behind a stalled asynchronous items-count request; this PR adds required changed-ID payloads to notices, without altering that queue's scheduling/recovery policy.
Six scan questions and touched regression classes
Question
Disposition
1. Work before skip
Reviewed: prior phone room-list copy removed and operation-count control fails at the previous head. Desktop shares one decode; room RPC gate precedes reads. Existing phone item bookkeeping/broad listeners identified above.
2. Ownership multiplication
Reviewed: full host/desktop/phone census above. No new wires or listeners. Shared notice array indexes once; independent wire payloads priced separately.
3. Thread/storage
Reviewed: new union on host/main; scope/index on renderer/phone JS. Indexed page path and pre-existing whole group-list reads traced. No added native/fs/SQLite write/subprocess. CPU/SQL/network times unmeasured.
4. Growth/progress
Reviewed: O(G) required changed-key output/index, fixed work for an uninterested room-list decoder, no persisted-room inventory. Coalescer drains/reset verified; broad/unknown fallback preserves recovery. Existing loaded-page/member/history work separated above.
5. Execution host
Source trace covers local IPC, paired runtime stream and mobile shared/direct subscriptions. No OS-specific probe, path or subprocess added. Executed on macOS Node only; native phone, Windows, Linux and real remote-link latency not measured.
6. Stop/release
Reviewed: production helper teardown, desktop unsubscribe and coalescer disposal executed. Cache keys are weak; no lifetime-long notice history. Hidden room hooks unsubscribe; AppState blocks background refresh. Already-running reads are not canceled, as at base.
Touched regression class
Disposition
Pre-skip collection work / hot-path repeated membership
Matched and disproved for new room-ID work: 0 visits in rejecting decoders; G visits once per used array, then indexed membership.
Emits only G changed IDs, not an H-room snapshot. Necessary output grows with changed keys, not all saved rooms.
No-op publication
Pre-existing sites retain their rate; no new notification call sites or loosened publication gate.
Fixed-cadence loops / steady-idle wakeups
No new cadence. Base/HEAD fake-clock counts identical; existing phone fallback unchanged.
Sync SQLite / rereading unchanged input
Existing admitted backend unchanged; unrelated room reads removed. Broad list reads and matching page/reducer work remain pre-existing.
Per-entity lifetime/retention
New caches use weak keys; no permanent per-room registry. Pending accumulation flushes/disposes; listener teardown checked.
Fanout/queues / hidden owners
No new read admission or physical wire. Existing fanout, in-flight overlap, background decoder invocation and ordered send queue traced; room-ID traversal no longer happens for unused decodes.
Startup imports
New value imports use the small shared scope module; no SDK/adapter, startup I/O or eager inventory introduced. Initial visible-room read remains unchanged.
Other recurring classes had no matching changed mechanism. Worktree/repo/remote/ref/history dimensions were screened separately: the diff adds no traversal or subprocess proportional to those dimensions. Necessary G-key union/transport/index work remains output-dependent at 10× changed-key volume; unused decoders remain at zero room-ID visits even then.
Evidence is deterministic counts plus source inspection of the paths named above. No packaged-app timing, CPU/GPU/heap profile, transport-byte measurement, native-device measurement or full application QA is claimed. Those device/runtime costs are unmeasured; there is no unresolved source-proven regression being deferred to that limitation.
Problem: every change inside one bot group room (a post, a turn starting or ending, an answer, a stop) sent a host-wide "groups" notice, and every open room on desktop and phone reloaded its latest 40 posts for it, even rooms where nothing happened.
Change: the notice names the room's group when the change is inside one room. An open room reloads only for its own group, or for a notice that names none: room-list changes, older hosts, an empty list, reconnect and foreground. The sidebar's group list still refreshes on every groups notice. No visible change.
Fixed during review
Perf P1 (7096130854): window listeners each re-read and copied the room list, and each room searched it linearly. Now each window reads a notice once and shares it, and a room checks one set per notice.
Perf P1 (7096914261): phone subscribers copied the room list while reading every notice. Now the list is kept as received, and only an open room's check walks it.
Claude P1 (review 4): desktop reads each notice twice (bridge, then window), and the repair above dropped the rooms on the second read, so every room reloaded again. Fixed in b10edb4, with a test that reads twice.
CodeRabbit (2 threads) and a Claude P2: an empty room list now reaches every room, both when notices are merged and when they're read.
bot-change-scope.test.ts (fails on main) and the perf contract bots-changed-window-event.performance.test.ts. pnpm check:changed passes. CI is green.
Claude review: READY.
Blinded Codex regression audit: SAFE. It ran 512 notice combinations, a notice read four times in a row, and 100 and 1,000 listeners, on local, paired-host and phone paths.
Perf scan: clean (7097245004).
QA: qa=tests, since no screen or layout changed. Linux remote check (Omarchy, 28 cores): REMOTE-CHECK PASS b10edb400890b33f8edea228ae60f7a5e1fa48c7 (43 checks passed).
Deferred (P2)
botGroupRoomConcerned builds an 11-entry kind set per call (botChangeConcerns already does the same). This is a small fixed cost.
The perf contract sends a host-shaped notice. The double-read step is covered by the unit test, not end to end.
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
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.
ELI5
When anything happened inside one bot group room (a message, a bot starting or finishing, an answer), Orca told every open window and phone "groups changed", without saying which room. So every open group room reloaded its latest 40 messages, even rooms where nothing happened. Now the notice says which room changed, and only that room reloads. Changes that touch every room (adding or removing members, rooms, or reconnecting) still reload everything, as before.
What Changed
groupschange notice can now name the rooms it touched (groupIds). Notices that land in the same short window are merged: their room lists are joined, and if any of them names no room, the merged notice names none, so every room reloads.No visible change.
Why
Reloading every open room for a change in one room makes the work grow with the number of open rooms on every event. Reloading the one room an event names, and reloading everything only on reconnect, is the expected pattern for shared rooms. It also lets a room page carry more per post without that cost repeating for rooms that didn't change.
Linked Issue
Part of the fix for #46084 (lands before #47176).
Visual Proof
N/A: no visual or interaction change; rooms show the same content and refresh at the same moments for their own changes.
Testing
src/shared/bots/bot-change-scope.test.tschecks how a notice window merges room ids and which rooms each notice reaches: named rooms only; every room once any change names none (or names an empty list), for a change of every kind, an older host's bare notice, or a kind this build doesn't know; no room for a notice of another kind; and the named rooms kept when a window reads a notice the bridge already read. It fails on main, where notices carry no room ids.src/renderer/src/lib/bots-changed-window-event.performance.test.ts(perf contract) checks that every window listener shares one read of a notice, that only the named rooms' views re-read at 100 and 1,000 listeners, and that reading a notice doesn't copy its room list.pnpm check:changedpasses. CI covers Linux and Windows.Performance
Less work: a change inside one room now reloads only the open views of that room, not every open room on the host. Host-wide changes and reconnects reload everything, as before. The notice gains a short list of room ids; each window reads a notice once for all its listeners, readers that want no room never walk the list, and an open room checks it through one set per notice.
Risk
The risk is a room missing a reload because a change names the wrong room or names one when it should name all. Every change that touches the room list stays host-wide, and an older host's notices name no room, so older or mixed versions keep the current behavior. A plain revert backs it out.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)