Repository navigation
test(chat-sidebar): stop the selector-scope test remounting rows on every render - #29255
Conversation
…very render The test's framer-motion mock built a new forwardRef component on every `motion.<tag>` read. Each sidebar commit therefore handed React a new element type, which remounted the session rows under it, and the remounted rows' query observers and mount effects re-rendered them again. On an idle machine that finished inside the 100 ms warm-up. On a loaded runner it spilled into the 50 ms windows the tests count, so a window that should read 0 renders read 1 or 2 (twice on Frontend Tests shard 4). The mock now keeps one component per tag for the file, as ChatSidebar.rowMemo.test.tsx already does. With 12 CPU-bound processes and 6 vitest workers running 6 copies of the file at 25 repeats per case, 5 of 450 cases failed before the change and 0 of 1350 (three rounds) after. Closes kirodotdev#28905
First Principles Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS This only changes a test mock, and it fixes the remount at its cause instead of waiting longer. It removes nothing and renders nothing new. [DESIGN-REVIEWED] 0739814 Description read[DESCRIPTION-READ] 964a452fd6379e17dd16bcd16fcbb9f1ce78d8d378cf14f1391ebc24d192ada3 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 change only touches a test file, so it adds no user-visible control and needs no screenshot. [UX-REVIEWED] 0739814 Description read[DESCRIPTION-READ] 3912f41b5f87fc61cf1eecf709c66eaa5d9a3e971e8e090023354bafe9910ed4 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. |
buluoray
left a comment
There was a problem hiding this comment.
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:
Approving 0739814.
This fixes the flaky ChatSidebar.selectorScope.test.tsx (#28905), which turned main's Frontend Tests (4) red on df3be59 ("does not re-render on a subagent chunk for the ACTIVE slot when count unchanged", expected 1 to be 0).
The cause it names is right: the framer-motion mock's Proxy built a new motion.<tag> component on every property read, so each sidebar commit saw a new element type and remounted the rows below it. Their mount work then landed inside the render-count windows. Caching one component per tag keeps the type stable, so the counted renders are only the ones the store subscription causes. The change is test-only, one file, and leaves every assertion as it was.
Checks: I approved this fork PR's workflow runs. On this head the frontend shards are green, and no check has failed (66 passed, 2 backend shards still running when I looked). I could not run the file locally: the shared node_modules here is missing a dependency, so vite failed to load the suite. I did not do a repeat-run proof of the flake fix.
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 selector-scope sidebar test caches one mocked motion component per tag so rows stop remounting on every render.
Problem / Motivation
Goal:
website/src/test/ChatSidebar.selectorScope.test.tsxcounts only the renders a dispatch causes, so its windows read 0 on a loaded runner as they do on an idle one.The file's
framer-motionmock built a newforwardRefcomponent on everymotion.<tag>read. Each sidebar commit therefore handed React a new element type, which remounted the session rows under it. The trace shows each sidebar render followed by the rows'['instances']query observers being removed and added again. The remounted rows' observers and mount effects then re-rendered them once more. On an idle machine this finished inside the test's 100 ms warm-up. On a loaded runner it spilled into the 50 ms windows the tests count: the control window at line 153 read 2 renders on Frontend Tests shard 4 (runs on #27921 and #27563, both quoted in #28905).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
ChatSidebaror its rows; the remount comes from the test's own mock.What changed
website/src/test/ChatSidebar.selectorScope.test.tsx: theframer-motionmock keeps one component per tag in aMap, asChatSidebar.rowMemo.test.tsxalready does, so a sidebar commit no longer remounts the rows. Two comments now say the counter counts session-row renders, since the mocked hook is called by each row.Tests
Proof: not provable -- frontend test (prove.py runs Python only)
--maxWorkers=6next to 12 CPU-bound processes. Before the change, 5 of 450 failed: 3 at line 153 (the failure in Flaky: ChatSidebar.selectorScope.test.tsx 'does not re-render on a subagent chunk for a DIFFERENT (background) slot' #28905) and 2 at line 183 (the same race in the active-slot case), withexpected 2 to be +0andexpected 1 to be +0. After it, 0 of 1350 failed over three rounds.npx vitest run src/test/ChatSidebar.selectorScope.test.tsx src/test/ChatSidebar.rowMemo.test.tsx: 14 passed. WithKIROCREW_ACT_STRICT=1the file passes with no act() warning, and it is not on the act() warning baseline.npx eslintis clean on the file.Sibling sweep
Swept:
grep -rl "get: (_t, tag: string) => make(tag)" website/src(the uncached mock, 113 files) against the files that count renders (renders.n,renderCount,rendersDuring). This file is the only one in both.Sibling: website/src/test/ChatSidebar.selectorScope.test.tsx -- changed here
Sibling: website/src/test/ChatSidebar.rowMemo.test.tsx -- not affected -- it already caches one component per tag
Pattern harvest
Rule candidate: review-prompt
Pattern: a
vi.mockfactory whoseProxybuilds a new component on every property read gives React a new element type each render, so everything under it remounts. Any test that counts renders, effects or focus under such a mock reads remount work as its own. Build each component once and return the cached one.Closes #28905