Repository navigation
perf(web): keep the slot list still while sessions stream - #23877
Conversation
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed head cad8b06. The change looks good to me, and I have no findings to raise.
What I checked:
touchSlotActivitysends an unsettled bump to the overlay only when the row already haslast_turn_ts, so nothing the sidebar orders or tints by stops moving. Rows withoutlast_turn_tsstill take the row write.- Overlay bumps skip
stampSlotWrite. That is safe here: an olderfetchSlotsreply can now replace the row, butdropCaughtUpLastTskeeps the newer entry, so recency still never moves back. - The overlay key uses the same
k:prefix thatslotKeyOfStampstrips, so the prune inreconcileSlotsmatches live keys, and a key such as__proto__cannot reach the prototype. selectSubagentsBySlotreturns the previous object while every per-slotsubagentsmap keeps its identity, and the three count selectors still skip the aliased active slot.- Unread watermarks (
markSlotUnread,markSlotRead, the focus and arrival relays,switchSlot, the toggle action) all read the live value throughslotLastTsOf.
Not verified: I did not run the frontend tests locally. I relied on the test list in the description.
What still blocks approval (maintainer checks, not changes for you):
- This PR changes 21 files and is a perf change, so it needs a maintainer approval rather than an automated one.
- Two red checks do not come from this diff. Dependency License Gate fails because dependency review is not enabled on the repository. Sensitive Change Review could not read the PR from the API and needs a re-run.
- The AI review lanes do not run on fork PRs, so no lane verdict exists for this head, and several required checks were still running when I looked.
Merge order note: once this lands, any open PR that adds a direct .last_ts read will fail slotLastTs.readers.test.ts until it reads through store/slotLastTs or adds a // last-ts: marker.
cad8b06 to
060c01c
Compare
|
chore (non-blocking): pushed 060c01c to fix the Frontend Lint & Type Check failure. |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: mid-turn Notes
[DESIGN-REVIEWED] 4d8cdf4 Description read[DESCRIPTION-READ] 852bf2dafaa0b81b40d424e9f3598c0dc93d21a4f6d21d8111c184624fef1df6 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The diff only changes store state and selector plumbing. It adds and changes no controls, strings or layout, so it needs no screenshots. [UX-REVIEWED] 4d8cdf4 Description read[DESCRIPTION-READ] 053f91043e3be0bd818d5bd619e23624cfdd125219d05827f3d02cee46693b49 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. All 16 base Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: stop background streaming sessions from re-rendering the chat page and sidebar on every streamed row. This is a FIX (perf, #23876).
[FIRST-PRINCIPLES-REVIEWED] 4d8cdf4 Description read[DESCRIPTION-READ] d3fccd97812530d1a0d9613602ac48f1f9274a817e2555f34e44da365779dc4b That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Head branch was pushed to by a user without write access
|
issue (blocking): fixed in d64fab5. Overlay bumps lose protection against stale slot fetches.
|
060c01c to
d64fab5
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed at d64fab5. Compared with the previously approved head, the only change is that the mid-turn last_ts bump held in the slotLastTs overlay now also stamps the slot write sequence, so a fetchSlots reply serialized before the bump cannot restore an older last_ts once a slots frame drops the overlay entry. The new clobber test covers that race, and the early return on a non-finite or not-newer ts keeps the old no-write behavior. No new findings. Approving at this head; auto-merge waits for the required checks and readiness.
Head branch was pushed to by a user without write access
d64fab5 to
431ad81
Compare
|
issue (blocking): fixed in 431ad81. The artifact send-to-session picker read the raw slot list.
This push also replaces the d64fab5 CI run, whose Await Fast Gate step read a cancelled duplicate Fast Gate run and skipped the test shards. |
|
note (non-blocking): CI run 40149993172 on 431ad81 is red only because Await Fast Gate read a cancelled Fast Gate run. That cancelled run, 40149993771, was created one second after 40149993194, which succeeded. The same thing happened on d64fab5, with run 40147800120 cancelled and 40147799957 succeeding. Coverage Gate then fails closed because the test shards were skipped. Every review lane, Screenshot Evidence and Sensitive Change Review pass on this head. Could a maintainer rerun the failed jobs of run 40149993172? The fork account cannot, and a third same-tree push looks likely to hit the same race. |
431ad81 to
f7d327f
Compare
|
chore (non-blocking): pushed f7d327f, which fixes the two frontend shard failures the rerun of 431ad81 found. Thanks for the rerun.
Locally, |
f7d327f to
baae247
Compare
|
chore (non-blocking): rebased on main as baae247 after #23712 landed. That PR moved the body of |
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed at baae247 (rebased on main). The change since the last review is small and looks good:
- The sub-agent count test moved from
src/test/dashboardSlice.slotLastTs.test.tstosrc/store/subagentsBySlot.test.ts. Code outsidesrc/storeno longer importsstore/chat/subagentsdirectly, which is what the chat state ownership test asks for. sameRecordValuesinstore/chat/subagents.tsis now a plainfunctioninstead of a generic arrow. The module level i18n test parses the file as TSX, where<V>(...) =>reads as JSX, so thei18nT()call inside the reducer at line 670 looked like module scope. With the generic arrow gone that false hit goes away. No other generic arrows remain in the file.- The rebase moved the overlay branch from
touchSlotActivityinto the sharedapplySlotActivityhelper on main, so the per frame stream flush now follows the same rule. The logic is unchanged.
Six question security check on this head: no auth, no new external input parsing, no trust boundary, no sandbox, no approval gate, no secret handling. All answers are no.
What I checked: the two commits compared with range diff, plus the two test rules read against the new source. I could not run the frontend suite locally. Approval waits for CI: the workflow runs on this head are still waiting for maintainer approval, and PR Readiness is not passed yet.
|
praise: first-principles review PASS on baae247 noted. It names no item to change, so nothing changes.
|
|
praise: design review PASS on baae247 noted. It names no item to change, so nothing changes.
|
|
praise: ux review PASS on baae247 noted. It names no item to change, so nothing changes.
|
Each streamed assistant or tool row ran touchSlotActivity, which wrote last_ts onto the row and replaced the dashboard.slots array. Everything subscribed to the list re-rendered (the chat page, the sidebar shell, tab strips, every row's menus) for a value the list does not order or label by once a row has last_turn_ts. Those mid-turn bumps now go to dashboard.slotLastTs. Every last_ts reader goes through store/slotLastTs, which returns the newer of the overlay and the row value; a source test fails on an unmarked direct read. The sub-agent count selectors read per-slot subagents maps instead of the whole slotActivity map, so a background tool row does not recount them.
baae247 to
4d8cdf4
Compare
|
chore (non-blocking): pushed 4d8cdf4, rebased on current main. CI on baae247 failed the file line cap because main had grown |
bolichen97
left a comment
There was a problem hiding this comment.
Approving at 4d8cdf4. The send-to-session menu now orders sessions by their newest message during a turn, like the other session lists, and the new test covers that order. The store file is back under the 2000 line cap. No red check and no blocking review lane at this head. Auto-merge waits for the required checks.
Problem / Motivation
Goal: The chat page and the sidebar stop re-rendering for every assistant or tool row while sessions stream in the background.
Each streamed assistant or tool row runs
touchSlotActivity, which writeslast_tsonto the slot row and replaces thedashboard.slotsarray. Everything that subscribes to the list re-renders: ChatPage, the sidebar shell, the tab strips and every sidebar row with its Radix menu wrappers. None of them showslast_tsfor a row that haslast_turn_ts, because the sidebar orders, groups and tints bylast_turn_ts || last_ts || created.The sidebar's sub-agent count selectors take the whole
chat.slotActivitymap as input. That map changes on every background tool row, so they recount every slot even though nosubagentsmap changed.Why it matters
On the render benchmark's S1 scenario (222 sessions, 5 streaming in the background, 30 s), the slot list changed 7 times and the page did 21,305 component renders, 1,026 of them WindowedSessionRow. The remaining sidebar render work (row menus, selector fan-out) is planned on top of this change, so it has to land first.
Not a goal
slotspushes that differ only inlast_ts.What changed (motivation → approach → change)
Mid-turn
last_tsbumps move off the row, so the slot list keeps its identity while a turn streams.touchSlotActivitywrites an unsettled bump on a row that haslast_turn_tsinto a newdashboard.slotLastTsmap and leaves the row and the array alone. It still stamps the write, as a row write does. A settled bump, or a bump on a row with nolast_turn_ts(which sorts bylast_ts), writes the row as before.store/slotLastTs.tsreturns the newer of the map entry and the row value. The unread watermarks inmarkSlotUnread,markSlotRead,attention.ts,slotSwitch.ts,useSessionActions.tsandMembersPageThread.tsxread through it.selectSlotsWithLiveLastTs, which merges the map into the rows. These are the command palette, the recents provider, the command bar, Worlds (useAgentSync), the artifact send-to-session picker and the broadcast picker. They still update on every bump while mounted.last_tsat or past it, and when an authoritative list drops the key. An older list keeps the entry, so recency never moves back.slotLastTs.readers.test.tsfails on any.last_tsread outside the helper that lacks a// last-ts: <why>marker. Six reads carry one, for rows already merged or reached only withoutlast_turn_ts.selectSubagentsBySlotmapsslotActivityto its per-slotsubagentsmaps and returns the previous object while those maps keep their identity. The three sidebar count selectors andselectSubagentActivityCountread it.Backwards compatibility
Compatible:
slotLastTsis new client-only store state, andlast_tskeeps its type and its server value on the row.Reader: website/src/store/dashboardSlice.ts:markSlotUnread -- chat -- fallback watermark reads slotLastTsOf; "markSlotUnread falls back to the live last_ts as its watermark"
Reader: website/src/store/dashboardSlice.ts:markSlotRead -- chat -- shared-clear watermark reads slotLastTsOf
Reader: website/src/hooks/websocket/attention.ts:emitSlotRead -- chat -- read relay watermark reads slotLastTsOf
Reader: website/src/store/chat/slotSwitch.ts:_newestSlotTs -- chat -- reads slotLastTsOf
Reader: website/src/hooks/useSessionActions.ts:toggleRead -- chat -- reads slotLastTsOf
Reader: website/src/pages/members/MembersPageThread.tsx:activeSlotLastTs -- crew page -- reads selectSlotLastTs
Reader: website/src/components/commandPalette/slotRecency.ts:slotRecency -- app -- callers pass selectSlotsWithLiveLastTs rows; recentsProvider.test.ts and CommandPalette.test.tsx pass
Reader: website/src/components/ArtifactSendToSession.tsx:useArtifactSendToSession -- app -- subscribes to selectSlotsWithLiveLastTs; ArtifactSendToSession.test.tsx "orders a session that is mid-turn by its newest message"
Reader: website/src/hooks/useAgentSync.ts:useAgentSync -- app -- subscribes to selectSlotsWithLiveLastTs; useAgentSync.recencyOrder.test.tsx passes
Reader: website/src/lib/broadcastTargets.ts:broadcastTargets -- chat -- BroadcastPanel passes withLiveLastTs rows; BroadcastPanel.test.tsx passes
Reader: website/src/pages/chat/sessionOrder.ts:slotActivityTs -- chat -- reads last_ts only without last_turn_ts, and those rows still take every bump
Reader: website/src/utils/recencyTint.ts:computeRecentRank -- chat -- same ladder as slotActivityTs; recencyTint.test.ts passes
Tests
website/src/test/dashboardSlice.slotLastTs.test.ts(new, 9 cases). A streaming bump keeps the slots array and row and moves the live value. A row withoutlast_turn_tsstill gets the row write. Bumps never move backwards, and an equal time is no write. A settled bump writes the row and drops the entry. A caught-up list drops the entry, an older list keeps it, and a list without the key drops it.markSlotUnreadfalls back to the live value.withLiveLastTskeeps identity when nothing moved.website/src/store/subagentsBySlot.test.ts(new): a tool row that replacesslotActivitybut not itssubagentsmap leaves the count selector result unchanged. It sits insrc/storebecause only store code may importstore/chat/subagentsdirectly.website/src/test/dashboardSlice.fetchSlotsClobber.test.ts: a mid-turn bump held off the row is stamped like a row write, so afetchSlotsreply serialized before it cannot restore the olderlast_tsafter a slots frame drops the entry. It fails with the stamp removed. The touched files passed 3 runs under--sequence.shuffle, seeds 1 to 3.website/src/test/ArtifactSendToSession.test.tsx: the send-to-session picker ranks a session that is mid-turn by its overlaylast_ts. It fails with the raw slot list. Passed 3 shuffled runs.website/src/test/slotLastTs.readers.test.ts(new): the direct-read ban described above, plus a check that its pattern still matches.BroadcastPanel.test.tsxrenders inside the store Provider, since the panel now reads the map.CommandBarOverlay.owners.test.tsxfollows the renamed subscription line.run_scoped_tests.py --surface frontendselects pass (883 tests).tsc -p tsconfig.app.jsonand eslint on the changed files are clean.Manual verification
Render benchmark from #23431 (
scripts/bench-render.mjs), applied on origin/main c24c7bc without and with this change, desktop, 30 s window, 3 runs per cell. A local counter added to the script counteddashboard.slotsidentity changes. The table shows the median run; runs 2 and 3 matched exactly on both sides.dashboard.slotschangesThe idle scenario is unchanged: 4 commits, 1059 renders. Selector calls stay flat, because the dispatch count is the same and every mounted selector still runs per dispatch.
Screenshots / video
Why no screenshot: the change keeps the slot list's identity while sessions stream, and every surface shows the same values as before.
Related Issues
Fixes #23876
Checklist