Implements
docs/plans/2026-07-22-001-fix-dashboard-remount-churn-plan.md: every
confirmed source of unnecessary unmount/remount churn in the dashboard,
plus a keep-alive layer for conversation- and terminal-bearing surfaces.
## What changed
**Keying / component identity (U1–U3)**
- Streaming chat segment key no longer embeds `entries.length` — an
expanded thinking block stays expanded while entries stream into it
(R1).
- Dock task list keys `TaskCard` rows by `task.id` (occurrence suffix
only for the duplicate-id anomaly) instead of `id-index` — no remount on
reorder/filter/status change (R2).
- `ProviderStatusBadge` / `GitHubStatusBadge` hoisted out of
ModelOnboardingModal's render body (R3); MCP server rows key by
`server.name` alone (R4).
**Keep-alive layer (U4–U6)**
- New shared `KeepAliveView` wrapper: visible = in-flow flex child;
hidden = out-of-flow `position:absolute; inset:0` with
`visibility:hidden; pointer-events:none` + `aria-hidden` (never
`display:none`, so xterm geometry never collapses).
- Planning Mode renders as a kept-alive sibling of the MainContent
switch after first open (per-project latch mirroring Quick Chat). While
hidden, the session-list SSE, recovery poll, and elapsed ticker suspend
via a new `active` prop; reveal re-subscribes and refreshes the sessions
list once. Payload-carrying entry points (initial-plan handoff, resume)
and project switches remount via a new
`modalManager.planningEntryGeneration` key, preserving pre-keep-alive
fresh-open semantics. `recordResumeEvent` instrumentation records
`remount` on first activation and `route-active` on reveal.
- Task-detail Terminal / Worktree-terminal / Planner-chat tabs stay
mounted-but-hidden after first open (per-task latches; task switch/close
still disposes fully). `SessionTerminal` gains `active`: reveal refits +
forces a font remeasure, and if the WS died while hidden it re-runs the
full attach lifecycle (dead-socket recovery).
- Popped-out task windows hide via FloatingWindow `hidden` instead of
leaving the render array; `TaskDetailContent` gains `active` so hidden
popups close their SSE/EventSource channels while the terminal WS stays
open. `visiblePoppedOutTaskEntries` remains the Escape-shortcut
consumer.
**Planning Mode internal-transition audit (U7)**
- Audit findings: session-list mode and mobile list/detail flips are
CSS-class transitions over one always-mounted detail pane (no
state-discarding unmounts); re-selecting the active session is an
early-return visibility restore; session switching intentionally reloads
from the session row (stream re-attach for generating sessions);
remaining index keys are on stateless lists. No product-code defects
found; regression tests now lock the always-mounted invariant on desktop
+ mobile.
**Cheap-view state (U8)**
- CommandCenter (active sub-tab + date range) and DevServerView
(selected script/task + typed-but-unsent command) persist per project
via `modalPersistence` and restore after their (intentional) unmount
round-trips. Also fixed the candidate auto-fill effect clobbering a
customized non-empty command.
## Symptom Verification
- **Original symptom:** streaming thinking blocks collapsed mid-stream;
terminals reconnected and lost scroll/input on tab flips; Planning Mode
lost in-flight interviews on navigation; popped-out windows vanished
off-view; dock cards remounted on reorder.
- **Exact reproduction:** (1) expand a thinking block during a stream;
(2) run a command in the Terminal tab, flip to Plan and back; (3) start
a planning interview, navigate Board and back; (4) pop out a task with
board/list-only scoping and switch views; (5) change a dock task's
status.
- **Assertion it is gone:** component-identity/instrumentation tests in
TaskChatTab, SessionTerminal, TaskDetailModal
(worktree/planner-chat/tabs), PlanningModeModal keep-alive +
internal-transitions, App keep-alive round-trip, and
App.taskPopupViewGating assert no remount and preserved state for each
repro, across desktop and mobile breakpoints.
## Verification
- File-scoped vitest: 23 files / 1091 tests green (all touched suites
plus FloatingWindow, TerminalModal, TaskPlannerChatTab,
lazy-loaded-views guard, App suites).
- `pnpm verify:fast`: PASS (13 steps — scoped typecheck/build, CLI
build, boot smoke).
- `pnpm check:changesets`: passes; changeset
`fix-dashboard-remount-churn` (`@runfusion/fusion` patch, labeled
format).
- Known pre-existing failures NOT caused by this branch (verified
failing at base a224c1111 in a clean worktree): 7 tests in
`TaskDetailModal.oversight-controls/oversight-mobile/models-progress-workflow`.
- jsdom cannot prove rendered-grid correctness for xterm reveal; per the
plan's risk note, manual browser verification of terminal reveal remains
recommended.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Switching views or tabs no longer resets Planning Mode, task details,
terminals, planner chats, or popped-out task windows.
* Streaming content remains expanded and stable as new entries arrive.
* Hidden views suspend background activity and resume correctly when
shown.
* Terminal sessions reconnect automatically when needed.
* **Improvements**
* Command Center and Dev Server selections persist per project.
* Custom Dev Server commands are preserved while browsing suggestions.
* Improved stability when reordering task lists and updating server
states.
* **Documentation**
* Updated dashboard guidance for hidden, retained task pop-ups and view
transitions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
66 lines
3.2 KiB
TypeScript
66 lines
3.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { render, screen } from "@testing-library/react";
|
|
import { KeepAliveView } from "../KeepAliveView";
|
|
/*
|
|
FNXC:DashboardTests 2026-07-26-07:25:
|
|
Gate check-no-cwd-relative-dashboard-test-reads rejects process.cwd()/bare app/ reads under packages/dashboard/app/__tests__. Load KeepAliveView.css via the module-relative cssFixture helper so root-launched Vitest does not ENOENT.
|
|
*/
|
|
import { loadComponentCss } from "../../test/cssFixture";
|
|
|
|
/*
|
|
FNXC:KeepAlive 2026-07-22-12:35:
|
|
The keep-alive wrapper contract (FN remount-churn fix R5/R8/R9): children stay mounted while hidden, hiding is visibility-based (never display:none, so xterm geometry never collapses to zero), the hidden state is out-of-flow (no layout space consumed beside the active view), and hidden wrappers carry aria-hidden.
|
|
*/
|
|
describe("KeepAliveView", () => {
|
|
it("keeps hidden children mounted with aria-hidden and the hidden class", () => {
|
|
const { rerender } = render(
|
|
<KeepAliveView hidden={false} testId="keep-alive-probe">
|
|
<input defaultValue="draft text" aria-label="probe input" />
|
|
</KeepAliveView>,
|
|
);
|
|
|
|
const wrapper = screen.getByTestId("keep-alive-probe");
|
|
expect(wrapper.className).toBe("keep-alive-view");
|
|
expect(wrapper).not.toHaveAttribute("aria-hidden");
|
|
|
|
const input = screen.getByLabelText("probe input") as HTMLInputElement;
|
|
input.value = "edited while visible";
|
|
|
|
rerender(
|
|
<KeepAliveView hidden testId="keep-alive-probe">
|
|
<input defaultValue="draft text" aria-label="probe input" />
|
|
</KeepAliveView>,
|
|
);
|
|
|
|
expect(wrapper.className).toBe("keep-alive-view keep-alive-view--hidden");
|
|
expect(wrapper).toHaveAttribute("aria-hidden", "true");
|
|
// Mounted-but-hidden: the same DOM node (and its uncommitted user state) survives.
|
|
expect((wrapper.querySelector("input") as HTMLInputElement).value).toBe("edited while visible");
|
|
|
|
rerender(
|
|
<KeepAliveView hidden={false} testId="keep-alive-probe">
|
|
<input defaultValue="draft text" aria-label="probe input" />
|
|
</KeepAliveView>,
|
|
);
|
|
expect(wrapper.className).toBe("keep-alive-view");
|
|
expect(wrapper).not.toHaveAttribute("aria-hidden");
|
|
expect((wrapper.querySelector("input") as HTMLInputElement).value).toBe("edited while visible");
|
|
});
|
|
|
|
it("hides via out-of-flow visibility, never display:none", () => {
|
|
const css = loadComponentCss("KeepAliveView.css");
|
|
const hiddenRuleStart = css.indexOf(".keep-alive-view--hidden");
|
|
expect(hiddenRuleStart).toBeGreaterThanOrEqual(0);
|
|
const hiddenRule = css.slice(hiddenRuleStart, css.indexOf("}", hiddenRuleStart));
|
|
|
|
expect(hiddenRule).toContain("visibility: hidden");
|
|
expect(hiddenRule).toContain("pointer-events: none");
|
|
// Out-of-flow while hidden so the invisible box consumes no layout space beside the active view.
|
|
expect(hiddenRule).toContain("position: absolute");
|
|
expect(hiddenRule).toContain("inset: 0");
|
|
expect(hiddenRule).not.toMatch(/\bdisplay\s*:\s*none\b/);
|
|
// Strip comments so prose like "(never display:none)" doesn't trip the declaration check.
|
|
expect(css.replace(/\/\*[\s\S]*?\*\//g, "")).not.toMatch(/\bdisplay\s*:\s*none\b/);
|
|
});
|
|
});
|