Skip to content

test(chat-sidebar): settle queries before counting selector renders - #31788

Merged
KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
unstablebrainiac:test/selector-scope-query-settle
Nov 7, 2026
Merged

KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
unstablebrainiac:test/selector-scope-query-settle

Conversation

@unstablebrainiac

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: website/src/test/ChatSidebar.selectorScope.test.tsx starts 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) slot can read expected 2 to be +0 at line 153 (issue below). #29255 removed one source of those extra renders, the framer-motion mock remounting rows. A second source remains on main.

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, its rows or the tags query.
  • Longer fixed waits: the 100 ms warm-up and the 50 ms counted windows keep their sizes.

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 new tagById, 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 the QueryClient has no query in flight. Then it lets one zero-delay timer pass inside act, 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)

  • Forced condition (a late chat-tags answer): a throwaway change makes the mocked api.chatTags resolve after 250 ms. On origin/main the cross-slot case fails with the CI assertion expected 2 to be +0. On this branch all 3 cases pass.
  • Repeats: npx vitest run src/test/ChatSidebar.selectorScope.test.tsx 20 times, all green.
  • Shuffled: --sequence.shuffle --sequence.seed=26392, all green.
  • Beside neighbours: with ChatSidebar.rowMemo.test.tsx and ChatSidebar.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/test filtered to files that mention ChatSidebar
Sibling: 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() === 0 and one zero-delay tick before resetting the counter.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

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.
@github-actions github-actions Bot added the fork Pull request from a fork (external contributor) label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

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

Revision 13525360a787cb1a30b5f17f8f359a8eda718e67 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 6, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

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

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 .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 6, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of 13525360a787cb1a30b5f17f8f359a8eda718e67 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 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 .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 6, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 1352536

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

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

Review details

No findings.
[GPT-REVIEWED] 1352536

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 7, 2026 02:05

@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 sidebar render-count test waits for queries to settle before measuring.

@KiroCrewCaptain
KiroCrewCaptain merged commit c4e2488 into kirodotdev:main Nov 7, 2026
93 of 100 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 7, 2026
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 counts a late chat-tags render as the dispatch's

2 participants