Repository navigation
test(chat-sidebar): settle queries before counting selector renders - #31788
KiroCrewCaptain merged 1 commit into
Conversation
The selector-scope tests counted renders after a fixed 100 ms warm-up and the row-animation gate. That gate waits only for the reads that place rows. The chat-tags query is outside it, and its answer hands every memoized row a new `tagById`, so each row renders once more. On a loaded runner that answer landed inside the cross-slot test's measured window, which then read 2 (two rows) instead of 0.
First Principles Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this test-only change goes after the actual source of the extra renders (the chat-tags query still in flight) instead of making the fixed waits longer. [DESIGN-REVIEWED] 1352536 Description read[DESCRIPTION-READ] a380f1724195fa2891a3a41ff1d2ecd3bc3ed748ace68e086acf644ac4bee195 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 a test file and adds or changes nothing a user sees. [UX-REVIEWED] 1352536 Description read[DESCRIPTION-READ] 3a737bf0125568e197b6881307dca017521d4060c521df6884b14d930fb2fc63 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 |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (1 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: test-only change: the sidebar render-count test waits for queries to settle before measuring.
Problem / Motivation
Goal:
website/src/test/ChatSidebar.selectorScope.test.tsxstarts counting renders only after the sidebar's own queries have settled, so a late chat-tags answer is never counted as a render the dispatch caused.The cross-slot case
does not re-render on a subagent chunk for a DIFFERENT (background) slotcan readexpected 2 to be +0at line 153 (issue below). #29255 removed one source of those extra renders, the framer-motion mock remounting rows. A second source remains onmain.Why it matters
The test fails on pull requests that touch no sidebar code, and each red run costs a re-run or a maintainer's look.
Not a goal
ChatSidebar, its rows or the tags query.What changed (motivation → approach → change)
The tests count renders after a fixed 100 ms warm-up and
settleSidebarRowAnim(). That gate waits only for the reads that place rows. The['chat-tags']query is outside it, and its answer hands every memoized row a newtagById, so each row renders once more. When the answer lands after the warm-up, a window that should read 0 reads 2 (two rows).The three tests now call one
settleSidebar(queryClient)helper. After the existing warm-up and row-animation gate, it waits until theQueryClienthas no query in flight. Then it lets one zero-delay timer pass insideact, because react-query queues its observer notifications on a zero-delay timer when a query settles. Only then is the counter reset.Backwards compatibility
Compatible: test-only change.
Removes nothing: the fixed warm-up stays, and a wait on in-flight queries is added after it.
Tests
Proof: not provable -- frontend test (prove.py runs Python only)
api.chatTagsresolve after 250 ms. Onorigin/mainthe cross-slot case fails with the CI assertionexpected 2 to be +0. On this branch all 3 cases pass.npx vitest run src/test/ChatSidebar.selectorScope.test.tsx20 times, all green.--sequence.shuffle --sequence.seed=26392, all green.ChatSidebar.rowMemo.test.tsxandChatSidebar.test.tsx, 14 passed.Manual verification
N/A: test-only change, covered by the runs above.
Screenshots / video
Why no screenshot: the diff changes only a test file and renders nothing new.
Related Issues
Closes #31785
Sibling sweep
Swept:
grep -rlE "rendersDuring|renders\.n|renderCount|sidebarRenders" website/src/testfiltered to files that mention ChatSidebarSibling: website/src/test/ChatSidebar.selectorScope.test.tsx -- changed here
Sibling: website/src/test/ChatPage.drawerFrameBudget.test.tsx -- not affected -- it mocks ChatSidebar with a stub, so the tags query never runs
Pattern harvest
Rule candidate: review-prompt
Pattern: a test that counts renders after a fixed warm-up also counts the commits of any query still in flight; wait for
queryClient.isFetching() === 0and one zero-delay tick before resetting the counter.Checklist