You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Flaky: panel-focus.it.test.ts 'focuses the composer input when the panel opens' failed once in a serial embed gate, green in isolation and clean re-run #346
Observed 2026-08-08 during the #326 branch gate (worktree, serial TURBO_CONCURRENCY=1 VITEST_MAX_FORKS=1, embed suite): one failure of packages/embed/test/panel-focus.it.test.ts > panel open focuses the composer > focuses the composer input when the panel opens, then 5/5 in isolation and 111/111 on a full clean embed re-run. Unrelated to the branch diff (no rebind/rpc-teardown in that test's path). Assertion text was lost (output filtered) — reproduce first.
Per the no-tolerated-flakes policy this owes a real fix, not a timeout bump alone. Suspect class: focus racing panel open animation under serial-gate machine load.
RCA session results (no fix shipped — root-cause trigger not yet provable):
Reproduced at 1-4/20 under CDP CPU throttling (rate 16-24); 0/40 unthrottled. Failure: expect(locator).toBeFocused() times out, composer stays inactive.
Proven mechanism (via patched focus/blur/remove/MutationObserver traces + probes in panel.tsx and rich-text-field.tsx):
apps/conciv/src/routes/panel.tsx:52-55 autofocuses once, keyed on open() + composer handle.
TipTap's focus command only calls view.focus() inside requestAnimationFrame — lands ~40-70ms late under load.
In that window, ChatPane's root <div class="contents"> (apps/conciv/src/pane/chat-pane.tsx:306) is removed from the DOM by a Suspense boundary above ChatPane switching to fallback, then re-attached without recreating components.
Removing the focused node drops focus to <body>; neither open() nor the handle changes, so the one-shot effect never re-fires. Focus lost permanently.
Missing link: which read re-suspends the boundary. The detach reproduces in ~45-50% of throttled runs independent of focus timing. Disproven hypotheses (guards added, detach persisted, all reverted): registryCatalog.data under enabled: connected(); sessions.data via row() / meta.data?.harness.id; rAF starvation; editor destroyed pre-rAF; attribute mutations; explicit blur.
Next step for whoever picks this up: build an unminified widget bundle (or reproduce in the pnpm dev vite host) so the Element.prototype.remove stack names the boundary, or instrument Solid's SuspenseContext to log which resource suspends. Preferred fix: make that read Suspense-safe (query.isPending ? undefined : query.data, the idiom at chat-pane.tsx:239) so panel content is never torn out — also fixes scroll/composer-state loss. Fallback: DOM-derived refocus rule (composer re-attached while open() and nothing focused) — carries focus-stealing risk, needs care.
A deterministic regression test needs server-side control of when the pane's late query first loads; page.route() can't delay individual calls now that widget RPC rides the WebSocket.
Reproduced again on 2026-08-10, on branch feat/tool-cards (PR #348), rebased onto e7529b87.
Same shape as the original report: failed once inside a serial @conciv/embed gate run, then passed on a clean forced re-run of the same package.
test/panel-focus.it.test.ts:50
expectLocator(composer(page)).toBeFocused() -> timed out
Failing run: TURBO_CONCURRENCY=1 VITEST_MAX_FORKS=1 turbo run test --filter=@conciv/embed — 26/27 files, 123/124 tests green, this the only failure.
Passing re-run: same command plus --force — 27/27 files, 124/124 tests green.
Two data points that may help narrow it:
It is not caused by the capture/tool-card work on that branch. Nothing in the failing path touches capture, CSS-bundle, or tool-request code, and the capture integration test in the same run passed.
It reproduced in a run that was already fully serialized (TURBO_CONCURRENCY=1 VITEST_MAX_FORKS=1), so whatever the race is, serializing the gate does not remove it.
Possibly related, given the failure is a focus assertion: this repo has a recorded landmine that ShadowRoot.activeElement returns null for focus held anywhere outside that root, so a focus assertion can be racing where the active element genuinely is rather than whether focus happened at all.
Activity
omridevk commentedon Aug 9, 2026
RCA session results (no fix shipped — root-cause trigger not yet provable):
Reproduced at 1-4/20 under CDP CPU throttling (rate 16-24); 0/40 unthrottled. Failure:
expect(locator).toBeFocused()times out, composer staysinactive.Proven mechanism (via patched focus/blur/remove/MutationObserver traces + probes in
panel.tsxandrich-text-field.tsx):apps/conciv/src/routes/panel.tsx:52-55autofocuses once, keyed onopen()+ composer handle.focuscommand only callsview.focus()insiderequestAnimationFrame— lands ~40-70ms late under load.<div class="contents">(apps/conciv/src/pane/chat-pane.tsx:306) is removed from the DOM by a Suspense boundary above ChatPane switching to fallback, then re-attached without recreating components.<body>; neitheropen()nor the handle changes, so the one-shot effect never re-fires. Focus lost permanently.Missing link: which read re-suspends the boundary. The detach reproduces in ~45-50% of throttled runs independent of focus timing. Disproven hypotheses (guards added, detach persisted, all reverted):
registryCatalog.dataunderenabled: connected();sessions.dataviarow()/meta.data?.harness.id; rAF starvation; editor destroyed pre-rAF; attribute mutations; explicit blur.Next step for whoever picks this up: build an unminified widget bundle (or reproduce in the
pnpm devvite host) so theElement.prototype.removestack names the boundary, or instrument Solid'sSuspenseContextto log which resource suspends. Preferred fix: make that read Suspense-safe (query.isPending ? undefined : query.data, the idiom atchat-pane.tsx:239) so panel content is never torn out — also fixes scroll/composer-state loss. Fallback: DOM-derived refocus rule (composer re-attached whileopen()and nothing focused) — carries focus-stealing risk, needs care.A deterministic regression test needs server-side control of when the pane's late query first loads;
page.route()can't delay individual calls now that widget RPC rides the WebSocket.🤖 Generated with Claude Code
omridevk commentedon Aug 10, 2026
Reproduced again on 2026-08-10, on branch
feat/tool-cards(PR #348), rebased ontoe7529b87.Same shape as the original report: failed once inside a serial
@conciv/embedgate run, then passed on a clean forced re-run of the same package.TURBO_CONCURRENCY=1 VITEST_MAX_FORKS=1 turbo run test --filter=@conciv/embed— 26/27 files, 123/124 tests green, this the only failure.--force— 27/27 files, 124/124 tests green.Two data points that may help narrow it:
TURBO_CONCURRENCY=1 VITEST_MAX_FORKS=1), so whatever the race is, serializing the gate does not remove it.Possibly related, given the failure is a focus assertion: this repo has a recorded landmine that
ShadowRoot.activeElementreturnsnullfor focus held anywhere outside that root, so a focus assertion can be racing where the active element genuinely is rather than whether focus happened at all.fix(app): isolate pane query reads behind suspense islands so the rou…
fix(app): isolate pane query reads behind suspense islands so the rou…
fix(test): wait for the live page plane, not the FAB, before tanstack…
fix(app): isolate pane query reads behind suspense islands so the rou…
fix(test): wait for the live page plane, not the FAB, before tanstack…
fix(app): isolate pane query reads behind suspense islands so the rou…
fix(test): wait for the live page plane, not the FAB, before tanstack…
fix(app): isolate pane query reads behind suspense islands so the rou…
fix(app): keep pane suspensions inside their islands so panel open ne…