Repository navigation
Fix Windows app UI test flakes in thread detail, timeline auto-load and composer paste - #8083
Merged
Merged
Conversation
…nd composer paste - useAutoLoadOlderRows: block auto-starts after a load settles until React commits, so a second sentinel check in the same timers phase cannot re-request the page with a stale cursor; re-check once per settled page. - useThreadTimelineController test: hold pending frames so both checks run in one timers phase and the race is exercised deterministically. - ThreadDetailSecondaryContent test: stub the panel and the tab-content splits its warmup preloads; delete the real-panel hide-control test (covered by ThreadSecondaryPanel.collapseControl.test.tsx). - PromptBoxInternal test: load pasted-thread-links before the paste tests so module loading does not consume the 2 s conversion budget. - SplitThreadArea test: wait for the focus route commit before the store-only CLI-style open. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…othing The settle counter was a dependency of the frame-delayed sentinel check, so a load that resolved without changing the timeline (a split pane hidden by maximize returns immediately) re-rendered and re-checked once per frame forever. The counter now only forces the commit that returns the phase to idle; a real page already re-runs the check through the new cursor and loading state. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The useReducer dispatch, and a useState setter destructured without its value, are not recognised as stable, so the compiler rejected startLoad's manual memoization and the app build failed. Use the useState setter and list it in startLoad's dependencies. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/fix-windows-app-ui-test-flakes-thr_9z3dsijk75
branch
November 24, 2026 05:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Four
@bb/apptests failed intermittently on Windows CI this week (group C of the flake sweep: 18 + 8 + 2 + 1 failures since 11-17, including main on 11-17, 11-19 and 11-23). Each has its own cause:ThreadDetailSecondaryContent.test.tsx(up to 6 tests per failure, latest four on 11-23). The first test in the file that renders the inline panel waits for every module the panel's open-time warmup preloads.ThreadSecondaryPanelWithTabWarmuppreloads ten tab-content splits (terminal, browser deck, file preview, new tab, tab content), and the panel mock loaded the realThreadSecondaryPanelthroughimportOriginal. The lazy-module harness settles every in-flight import before afindBypolls. That was 4.6 s and 9.8 s in passing Windows runs on main, and past the 15 s limit in failing ones. The timed-out test then leaves itsact()open, so every later test in the file renders an empty<body><div/></body>. That explains the cascade ofinline-secondary-panelnot-found errors.PromptBoxInternal.test.tsx› keeps HTML code and authored links literal… (8 failures, latest 11-19). The composer's thread-link paste extension starts a 2 s conversion budget at paste time. It then dynamically importsmentions/pasted-thread-links(remark/unified). This test is the first paste in the file, so on a cold Windows worker that module load can use up the whole budget.finish()then runs before the module is loaded, and the paste is never converted (expected [] to have a length of 2 but got +0).useThreadTimelineController.test.tsx› keeps auto-loading when an older page settles before its loading state renders (2 failures). This is a real race inuseAutoLoadOlderRows. Two sentinel checks can run in the same timers phase: the effect's rAF→setTimeout(0)and the scroll-positionsetTimeout(0). The first starts an older-page load whose mocked request settles in microtasks, which clearsloadInFlightRef. The second then runs before React commits the new cursor. It reads a staleliveRefand requests the same page again with the old cursor. In the app that is a duplicate older-page request whose response is thrown away. In the test the duplicate consumes the next mocked page, so the real next load getsundefinedand throws. That disables auto-load, andhasOlderTimelineRowsstaystrue.SplitThreadArea.test.tsx› carries maximization through focus, CLI-style open, and pane move (1 failure, same SHA passed on attempt 2).focusPanesets the maximized pane synchronously, so the test's firstwaitForpassed before the focus navigation tothr-bhad committed. If that route commit landed after the test's store-only "CLI-style" open, route reconciliation moved focus back topane-2. In the app the real CLI path (onThreadPaneAction) navigates to the newly focused pane itself, so only the test's shortened open could lose to the stale route.What changed
apps/app/src/components/thread/timeline/useAutoLoadOlderRows.ts: a load now goesidle → loading → settled. Once settled, auto-load refuses to start again until React commits: settling forces that commit, and the layout effect that refreshesliveRefsets the phase back to idle. This replacesloadInFlightRef. Settling forces the commit with auseStatesetter, whichstartLoadlists as a dependency so React Compiler can keep its memoization (auseReducerdispatch or a setter destructured without its value fails the app build). The forced commit is not a dependency of the frame-delayed sentinel check: a real page already re-runs that check through its new cursor and loading state, and a load that changes nothing (a split pane hidden by maximize, whose controller returns immediately) must not re-check every frame. The first version of this PR had that dependency and re-rendered such a pane about 48 times a second;useAutoLoadOlderRows.test.tsxnow covers it.useThreadTimelineController.test.tsx: the auto-load race test holds the frames that are pending when the intersection fires and releases them in the same tick. Both checks then run in the same timers phase, so the test exercises the race on every run instead of by chance.ThreadDetailSecondaryContent.test.tsx: the panel mock is now a plain stub (noimportOriginal), and the five tab-content modules the warmup preloads are stubbed. This file renders none of them. Also deleted "keeps the panel's own hide control for the inline thread panel": it was the one test that rendered the real panel.ThreadDetailSecondaryContenthas passed noinlinePanelTogglesince Delete unused code, expired compatibility paths and redundant tests #4606, and the inline "Hide right panel" control is covered byThreadSecondaryPanel.collapseControl.test.tsx. ItsrenderActualPanelswitch is gone with it.PromptBoxInternal.test.tsx: the thread URL pastedescribeloadspasted-thread-linksinbeforeAll. Its tests then cover conversion within the 2 s budget, not cold module loading. The product budget is unchanged.SplitThreadArea.test.tsx: wait for the location to reachthr-bafter the focus command before simulating the CLI-style open.No server/daemon wire, CLI or doc changes.
How you verified
Reproduced each failure locally with its exact CI message, then checked the fix against the same reproduction:
expected true to be false). A trace shows the sameanchorSeq: 2page requested three times. The fixed hook passes 40/40.useAutoLoadOlderRows.test.tsxandThreadTimelineSurface.test.tsxpass.useAutoLoadOlderRowstest fails on that first version (6 loads in 5 frames). The race test still passes 20/20 with the final hook.pasted-thread-linksmodule load by 2.1 s reproducesexpected [] to have a length of 2 but got +0. 1.8 s passes, so the boundary is the product's 2 s timer, notwaitFor. With thebeforeAll, all 6 paste tests pass with the module load delayed 2.5 s.expected 'pane-2' to be 'pane-3'. The fixed test waits for that commit.ThreadSecondaryPanelTabContentload is left: vitest serves the mock to the first of six concurrent dynamic imports of that module and the real module to the rest.ThreadDetailSecondaryContent,SplitThreadArea,useThreadTimelineController,PromptBoxInternal,useAutoLoadOlderRows,ThreadTimelineSurface) together: 5/5 runs, 328/328 passing (329/329 with the new no-op load test after the follow-up commit), at host load averages of 64–185.pnpm exec turbo run typecheck lint --filter=@bb/apppasses;oxfmt --checkis clean.🤖 Generated with Claude Code