Skip to content

fix(app): keep pane suspensions inside their islands so panel open never disposes the composer (#434) - #440

Merged
omridevk merged 1 commit into
mainfrom
fix/434-panel-suspense-detach
Aug 12, 2026
Merged

fix(app): keep pane suspensions inside their islands so panel open never disposes the composer (#434)#440
omridevk merged 1 commit into
mainfrom
fix/434-panel-suspense-detach

Conversation

@omridevk

Copy link
Copy Markdown
Contributor

Root cause

panel-focus-stability.browser.test.tsx flaked under CPU starvation: the composer's input handle registered→focused→released 3-4× per panel open, with the final .focus() landing mid-teardown and the assertion timing out with focus on <body>.

Three investigation rounds (two candidate mechanisms disproven by direct logging along the way — the <Show keyed> object-literal and an attachments memo leak) converged on: makeToolViewCtx invokes its harnessId callback eagerly in ChatPane's imperative body, before any JSX — and before any of the #391 Suspense islands exist. That callback read meta.data unguarded; per @tanstack/solid-query's useBaseQuery, a .data read while pending with no cached value hits the suspense-registering resource accessor. Executing under ChatPane's own owner, the suspension traces up to the Match-level Suspense @tanstack/solid-router wraps every route match in (dist/esm/Match.js:355) — the #346/#391 detach mechanism, through an eager pre-JSX read #391's islands could not cover. A slow /rpc/meta/models therefore suspended the whole route match, detaching and remounting ChatPane per flap; under starvation the window is wide enough for the focus assertion to catch it.

Fix

Guard the read the same way this file already guards imageInput: meta.isPending ? '' : (meta.data?.harness.id ?? ''). No new pattern, no behavior change (harnessId already fell back to '' while undefined). One line.

Tests

Extended all three focus-stability tests with a composer DOM-identity guard (capture editor node at first-visible, assert isSameNode after settle). Honest labeling: this does not fail on unstarved main (verified by reverting the fix and rerunning) — the failure needs CPU starvation — so it's a standing guard against detach/remount regressions, not a red/green proof. The starved-rig repro that characterized the failure (firefox 5/10 at --cpus 1) was retired mid-investigation by direction.

The markers/list-delay test's failures from the original starved runs found no second eager read (dividers reads are island-contained via compiler-emitted lazy getters — verified against compiled output); most plausibly spillover from the meta-driven remount storm in the same browser session.

Gates

typecheck ✓, lint ✓, full @conciv/app suite --force serial: 28 files / 105 tests ✓, fallow audit: pass.

Closes #434

🤖 Generated with Claude Code

…ver disposes the composer (#434)

ChatPane builds its ToolViewCtx eagerly, in imperative body code that runs
before any of its JSX (and before any of the #391 Suspense islands) exist.
makeToolViewCtx() immediately invokes the harnessId callback passed to it
(harnessId: deps.harnessId()), which read meta.data unguarded. Per
@tanstack/solid-query's useBaseQuery, .data reads while a query is pending
with no cached value call the underlying resource accessor
(queryResource()), which is solid-query's Suspense-registering read. That
read executed under ChatPane's own owner, which traces up through the
Show in ChatPaneRoute to the Match-level Suspense that @tanstack/solid-router
wraps every route match in (node_modules/@tanstack/solid-router
dist/esm/Match.js:355) -- not any of the #391 islands, which only own their
own JSX children and can't retroactively cover code that ran before they
were created. So a slow /rpc/meta/models response suspended the whole
route match, detaching and remounting ChatPane -- exactly the #346/#391
mechanism, just through an eager pre-JSX read #391 didn't touch.

The fix follows the guard pattern already established in this same file
(imageInput already checks meta.isPending before touching meta.data): guard
harnessId the same way, so the read never fires while meta is pending and
never registers a suspense boundary. No new pattern, no behavior change --
harnessId already fell back to '' whenever meta.data was undefined.

Investigated but not changed: the markers/list-delay failure the prior
round also isolated. dividersAt/dividersInRange only read markers.data
inside JSX already wrapped by the Thread Suspense island (chat-pane.tsx
line 317, from #391). Solid's JSX children are compiler-emitted getters, so
these reads are lazily evaluated exactly when Suspense (and further-nested
<For>/<Show> primitives) evaluate their children -- confirmed against the
babel-preset-solid compiled output for this exact code shape, solid-router's
Match/Outlet source, and the Thread.Messages implementation in
@conciv/ui-kit-chat. No second eager, unguarded read of markers.data was
found anywhere reachable from ChatPane. Empirically, an instrumented
onCleanup on ChatPane showed a single mount/dispose pair (at teardown)
across 10 unstarved runs of all three focus-stability tests, both before
and after this fix -- consistent with the established finding that the
failure needs CPU starvation to manifest, which this investigation does not
reproduce.

Extends panel-focus-stability.browser.test.tsx with a composer DOM identity
check (captures the editor node once visible, asserts isSameNode once
settled) as a standing guard against detach/remount. This does not fail on
unstarved main with the bug present (confirmed by reverting the fix and
rerunning), so it is a guard, not a proven red/green regression test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@omridevk, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 28 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d2ce66b2-603b-4529-a330-a03bdd23b68e

📥 Commits

Reviewing files that changed from the base of the PR and between f6874a2 and 46a3ac9.

📒 Files selected for processing (2)
  • apps/conciv/src/pane/chat-pane.tsx
  • apps/conciv/test/panel-focus-stability.browser.test.tsx

Comment @coderabbitai help to get the list of available commands.

@omridevk
omridevk requested a balanced review from Copilot August 12, 2026 13:25
@omridevk
omridevk merged commit fc64ab5 into main Aug 12, 2026
26 checks passed
@omridevk
omridevk deleted the fix/434-panel-suspense-detach branch August 12, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flaky: panel-focus-stability.browser.test.tsx under CPU starvation (both browsers)

1 participant