Skip to content

test(chat-sidebar): stop the selector-scope test remounting rows on every render - #29255

Merged
KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
rohnkum:test/chat-sidebar-selector-scope-flake
Nov 4, 2026
Merged

KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
rohnkum:test/chat-sidebar-selector-scope-flake

Conversation

@rohnkum

@rohnkum rohnkum commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: website/src/test/ChatSidebar.selectorScope.test.tsx counts 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-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. 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

  • Any change to ChatSidebar or its rows; the remount comes from the test's own mock.
  • The 112 other test files with the same uncached mock: none of them counts renders. A shared cached mock is a separate change.
  • Longer waits: the warm-up and the windows keep their 100 ms and 50 ms.

What changed

  • website/src/test/ChatSidebar.selectorScope.test.tsx: the framer-motion mock keeps one component per tag in a Map, as ChatSidebar.rowMemo.test.tsx already 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)

  • Repro: 6 copies of the file, each case repeated 25 times (450 cases), run with --maxWorkers=6 next 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), with expected 2 to be +0 and expected 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. With KIROCREW_ACT_STRICT=1 the file passes with no act() warning, and it is not on the act() warning baseline.
  • npx eslint is 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.mock factory whose Proxy builds 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

…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
@rohnkum
rohnkum requested review from a team and KiroCrewCaptain as code owners November 3, 2026 17:27
@rohnkum
rohnkum requested a review from chenmingwei23 November 3, 2026 17:27
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Nov 3, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ⏭️ skipped

Revision 07398140431cb7f0927c673e2c2f2e8c4e6bb5bb ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Does not block merge.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 07398140431cb7f0927c673e2c2f2e8c4e6bb5bb via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of 07398140431cb7f0927c673e2c2f2e8c4e6bb5bb via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 07398140431cb7f0927c673e2c2f2e8c4e6bb5bb via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 0739814

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 07398140431cb7f0927c673e2c2f2e8c4e6bb5bb via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 0739814

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 4, 2026
@KiroCrewCaptain
KiroCrewCaptain merged commit b49a196 into kirodotdev:main Nov 4, 2026
92 checks passed

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky: ChatSidebar.selectorScope.test.tsx 'does not re-render on a subagent chunk for a DIFFERENT (background) slot'

3 participants