14 KiB
Clean Pierre Virtualizer Integration Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Make the Files Changed tab use @pierre/diffs Virtualizer correctly and consistently as the scroll root for every non-empty file list.
Architecture: Treat the Files Changed tab as a full-height application surface instead of a document-scrolling page. The route renders one virtualized diff pane, backed by Pierre's worker pool, stable per-file props, and explicit Pierre cache keys. The app shell and RunDetail parent route both pass full-height layout through to child routes that opt in.
Tech Stack: React 19, React Router, Tailwind CSS, Bun build scripts, @pierre/diffs 1.1.15, react-test-renderer, Bun test.
Summary
This is a greenfield cleanup, not a conservative compatibility patch. Remove the arbitrary file-count threshold and the optional Virtualizer fallback. Every non-empty Files Changed view should use Pierre's Virtualizer in the shape Pierre documents: a bounded scroll container with an inner content wrapper.
Implementation
-
Update
apps/fabro-web/app/layouts/app-shell.tsxto support full-height route surfaces.- Add support for a route handle flag named
fullHeight. - Detect it with
matches.some((m) => (m.handle as { fullHeight?: boolean } | undefined)?.fullHeight). - When enabled, make the outer app container
flex min-h-dvh flex-col. - When enabled, make
<main>min-h-0 flex-1. - When enabled, make the outlet wrapper
flex h-full min-h-0 flex-col. - Preserve existing non-full-height behavior for other routes.
- Add support for a route handle flag named
-
Update
apps/fabro-web/app/routes/run-detail.tsxto pass full-height layout through to full-height child routes.- Import
useMatchesfromreact-router. - Detect whether the active child route has
handle.fullHeightwith the same handle check used byAppShell. - When enabled, make the
RunDetailroot wrapperflex h-full min-h-0 flex-col. - When enabled, keep the breadcrumb, header, actions, and tab bar as fixed-height content with
shrink-0. - When enabled, change the outlet wrapper around
<Outlet />from document-flow layout tomt-6 min-h-0 flex-1. - Handle blocked runs explicitly. The current
isBlocked && pendingQuestions.length > 0branch renders anh-72spacer after<Outlet />; that spacer must not be a flex sibling competing with the virtualized pane for height. For full-height child routes, omit the sibling spacer and expose a CSS custom property such as--fabro-interview-dock-clearance: 18remon the outlet/root wrapper. For non-full-height child routes, preserve the existing spacer behavior. - Preserve existing document-flow classes when no active child route opts into
fullHeight.
- Import
-
Update
apps/fabro-web/app/routes/run-files.tsx.- Change the route handle to:
export const handle = { wide: true, fullHeight: true }; - Remove the ad hoc
maybeVirtualizer/ fallback component. - Remove the
files.length > 20branch. - Always render non-empty file lists through
VirtualizedDiffList. - Extract a memoized
RunFileRowcomponent that owns placeholder,MultiFileDiff, andPatchDiffrendering. - Pass
runIdandmeta.to_shainto eachRunFileRowso Pierre file cache keys can include run/version identity. - Use
useMemoinsideRunFileRowfor PierreoldFile,newFile, andoptionsprops so freshness ticks and revalidation do not force unnecessary reparsing. - Add stable
cacheKeyvalues to PierreoldFileandnewFileprops. Build each key from run id,meta.to_shawhen available, file side, file name, and a deterministic content hash. Pierre's worker-pool cache usescacheKey; object identity alone only helps React memoization andMultiFileDiff's localuseMemo. - Keep per-row Pierre
optionslimited to row-specific render behavior such asdiffStyleandexpandUnchanged. Do not use per-componentthemeas the source of truth underWorkerPoolContextProvider; the theme belongs in the provider'shighlighterOptions. - Keep
PatchDiffrows on the public ReactPatchDiffcomponent for now.PatchDiffPropsacceptspatchandoptionsbut does not expose a cache-key parameter, so memoize itspatchandoptionsinputs and accept that patch rows cannot get explicit worker-pool cache keys without switching to parsed metadata APIs. - Make every non-empty route wrapper participate in the full-height chain: root
h-full min-h-0 flex flex-col; toolbar/banner areashrink-0; sidebar/diff row containermin-h-0 flex-1; diff panemin-h-0 flex-1. - Ensure any interview-dock clearance is applied inside the scrollable diff content, not as a sibling below the virtualized pane. Use the CSS variable from
RunDetailin the virtualizer content padding so the last file can scroll above the dock.
- Change the route handle to:
-
Add
apps/fabro-web/app/routes/run-files/cache-keys.ts.- Export a small deterministic synchronous string hash helper, such as FNV-1a, so cache keys can be computed during render without async browser crypto.
- Export a
fileCacheKeyhelper that produces keys shaped like:fabro-run-file:${runId}:${toSha ?? "no-sha"}:${side}:${path}:${contentHash} - Keep the helper independent of React so it is easy to unit test.
-
Add
apps/fabro-web/app/routes/run-files/virtualized-diff-list.tsx.- Import
VirtualizerandWorkerPoolContextProviderfrom@pierre/diffs/react. - Import
workerFactoryfrom../../lib/pierre-diffs-worker. - Define stable module-level options:
const poolOptions = { workerFactory }; const highlighterOptions = { theme: "pierre-dark" }; - Render:
export function VirtualizedDiffList({ children }: { children: React.ReactNode }) { return ( <WorkerPoolContextProvider poolOptions={poolOptions} highlighterOptions={highlighterOptions} > <Virtualizer className="min-h-0 flex-1 overflow-auto pr-2" contentClassName="flex flex-col gap-2 pb-[calc(1rem+var(--fabro-interview-dock-clearance,0px))]" > {children} </Virtualizer> </WorkerPoolContextProvider> ); }
- Import
-
Update
apps/fabro-web/app/routes/run-files/file-tree-sidebar.tsx.- Remove document-scroll-oriented sticky positioning.
- Use a layout that belongs inside the route's full-height flex row:
className="flex min-h-0 w-72 shrink-0 flex-col gap-2 self-stretch" - Keep the tree itself
min-h-0 flex-1 overflow-hidden. - Preserve filtering, selection, status icons, and current public props.
-
Update
apps/fabro-web/app/routes/run-files/states.tsx.- Change
FileTreeSidebarSkeletonfrom document-scroll-oriented sticky viewport sizing to the same full-height flex shape as the real sidebar:className="flex min-h-0 w-72 shrink-0 flex-col self-stretch rounded-md border border-line bg-panel/40 motion-safe:animate-pulse" - Change
LoadingSkeleton'sreserveSidebarrow tomin-h-0 flex-1 gap-4and make the diff skeleton panemin-h-0 flex-1. - Keep the top toolbar skeleton as
shrink-0so initial loading uses the same height chain as the loaded route.
- Change
-
Add
apps/fabro-web/app/lib/pierre-diffs-worker.ts.- Implement:
export function workerFactory(): Worker { return new Worker( "/assets/pierre-diffs-worker/worker-portable.js", { type: "module" }, ); }
- Implement:
-
Update
apps/fabro-web/scripts/build.ts.- Copy Pierre worker assets after creating
dist/assets. - Source files:
node_modules/@pierre/diffs/dist/worker/worker-portable.js- every sibling file matching
node_modules/@pierre/diffs/dist/worker/wasm-*.js
- Destination directory:
dist/assets/pierre-diffs-worker/
- Do not hard-code Pierre's hashed WASM filename.
wasm-BaDzIkIn.jsis the current@pierre/diffs1.1.15 artifact, but that hash can change when the package updates. - Use
worker-portable.js, notworker.js, becauseworker.jscontains bare imports that the browser cannot resolve from a static URL in this Bun build.
- Copy Pierre worker assets after creating
Tests
-
Add
apps/fabro-web/app/routes/run-files/virtualized-diff-list.test.tsx.- Mock
@pierre/diffs/react. - Assert
WorkerPoolContextProviderreceivespoolOptions.workerFactory. - Assert
WorkerPoolContextProviderreceiveshighlighterOptions: { theme: "pierre-dark" }. - Assert
VirtualizerreceivesclassNamecontainingmin-h-0,flex-1, andoverflow-auto. - Assert
VirtualizerreceivescontentClassNamecontainingflex,flex-col,gap-2, and the interview-dock clearance CSS variable. - Use
gap-2because Pierre's installed default virtualfileGapis 8. If implementation changes back to a 16px visual gap, add a shared metrics object withfileGap: 16and pass it consistently toMultiFileDiffandPatchDiff.
- Mock
-
Add or extend tests for
apps/fabro-web/app/routes/run-detail.tsx.- Keep the existing pure unit tests.
- Add render tests using a data-router harness, because
useMatchesonly works under a data router. UsecreateMemoryRouterandRouterProvider, notMemoryRouter. - Build route objects with a parent
/runs/:idroute renderingRunDetailand a childfilesroute whose route object hashandle: { fullHeight: true }. - Inject route params the same way
apps/fabro-web/app/router.tsxdoes. Use a local test wrapper that callsuseParams()and renders:
or reuse the app route-wrapper pattern.<RunDetail params={params as { id: string }} /> - Wrap the rendered router with the real
ToastProviderandDemoModeProvider. - Mock run queries, run-question queries, run-events, and mutations so the component can render deterministically.
- Assert the
RunDetailroot wrapper receivesh-full,min-h-0,flex, andflex-col. - Assert the outlet wrapper receives
min-h-0andflex-1. - Cover the blocked-run full-height branch and assert the old
h-72spacer is not rendered as an outlet sibling while the dock still renders and the clearance CSS variable is set. - Cover the default branch and assert the document-flow wrapper remains unchanged for non-full-height child routes.
-
Add
apps/fabro-web/app/routes/run-files/cache-keys.test.ts.- Assert identical run id, SHA, side, path, and contents produce the same key.
- Assert changing file contents changes the key.
- Assert changing file name or side changes the key.
- Assert
null/missingtoShastill produces a deterministic key.
-
Add
apps/fabro-web/app/routes/run-files.render.test.tsx.- Mock
../lib/queriesto return run metadata and files. - Mock Pierre components with lightweight test doubles.
- Render with a real React Router harness, not bare component rendering:
<ToastProvider> <MemoryRouter initialEntries={["/runs/run_1/files"]}> <Routes> <Route path="/runs/:id/files" element={<RunFiles />} /> </Routes> </MemoryRouter> </ToastProvider> - Do not mock
useParamsoruseToast; the harness should exercise the real route and toast boundaries. - Render a 1-file payload and assert
Virtualizeris called once. - Render a 27-file payload and assert
Virtualizeris still called once. - Assert every file row exposes
data-run-file-row="true". - Assert
MultiFileDiffreceives the expecteddiffStyle. - Do not assert
themeonMultiFileDifforPatchDiff; underWorkerPoolContextProvider, theme is controlled byWorkerPoolContextProvider.highlighterOptions. - Assert
MultiFileDiffreceivesoldFile.cacheKeyandnewFile.cacheKey, and those keys are stable across an unrelated re-render.
- Mock
-
Update
apps/fabro-web/app/routes/run-files/pierre-smoke.test.tsx.- Remove optional-export fallback logic.
- Check callable exports for
MultiFileDiff,PatchDiff,Virtualizer, andWorkerPoolContextProvider.
-
Extend
apps/fabro-web/scripts/build.test.ts.- Run the production build.
- Assert
dist/assets/pierre-diffs-worker/worker-portable.jsexists. - Inspect
node_modules/@pierre/diffs/dist/worker/for upstreamwasm-*.jsfiles. - If upstream has one or more
wasm-*.jsfiles, assertdist/assets/pierre-diffs-worker/contains the samewasm-*.jsbasenames. For the current installed@pierre/diffs1.1.15 package, this means at least onewasm-*.jsfile should be copied.
Verification
-
Run targeted frontend tests:
cd apps/fabro-web bun test app/routes/run-detail.test.ts app/routes/run-files.test.ts app/routes/run-files.render.test.tsx app/routes/run-files/cache-keys.test.ts app/routes/run-files/virtualized-diff-list.test.tsx app/routes/run-files/pierre-smoke.test.tsx scripts/build.test.ts -
Run typecheck:
cd apps/fabro-web bun run typecheck -
Run production build:
cd apps/fabro-web bun run build -
Browser-check the reported run:
- Open
/runs/01KQW839X61WJ8MYWJB9P9WV66/files. - Confirm Chrome stays responsive.
- Confirm the diff list scrolls inside the Files Changed pane.
- Confirm sidebar selection updates the hash and focuses the selected row.
- Confirm keyboard
j/knavigation still moves between file rows. - Confirm mobile unified mode remains usable.
- Open
Assumptions
- Greenfield simplicity wins over preserving the old document-scroll behavior.
- Always using Pierre's virtualized path is preferred over threshold-based branching.
- Worker startup cost is acceptable for this tab; tune pool options later only if measured.
- No server, OpenAPI, Rust, or CSP changes are expected.