Skip to content

[Task] F4 — Virtualize comparison rows and columns with sticky alignment #23

Closed

Description

@DavidVFitzGerald

Delivery phase

Phase 1 - frontend with mock services. Milestone F4; task key F4-04.

Goal

Keep hundreds of columns and thousands of variable-height rows usable without mounting the entire cell matrix.

Context and authority

Read AGENTS.md, docs/product/LCA_diff_PRD.md, docs/engineering/LCA_diff_Implementation_Specification.md, docs/engineering/roadmap.md, and docs/team/product-manager.md. Do not read archive/reference folders. Current governance/spec documents are prepared on branch docs/agent-workflow; acceptance/merge authority follows docs/adr/README.md, not proposed ADR status. Any contract deviation needs an ADR and both current document updates in the same PR.

Specification §§6.3–6.4, 6.6, 9.1–9.2 behavior 18. Planned files: apps/frontend/src/components/comparison/ shared grid, viewport hooks, CSS and browser tests (planned).

Requirements and constraints

Use appropriate virtual-grid primitives and TanStack Query with bounded overscan, row windows and column windows. Derive mixed-sign heights from whole-row summaries, not mounted cells. Preserve stable row keys and scroll anchoring as asynchronous data arrives; no arbitrary process cap.

All work runs in containers with synthetic mock data and no API/Firebase/cloud dependency. Keep HTTP/auth/fixtures behind typed services and mock adapters; components consume contracts rather than fixtures. Follow Software Engineer and QA role handoffs, commit focused increments referencing this issue, and leave it open for QA/review.

Acceptance criteria

  • AC1 — A deterministic workload of at least 200 columns and 2,000 rows renders only viewport/overscan cells and makes bounded window requests; record counts and workload.
  • AC2 — Horizontal scrolling keeps process headers and cells aligned, while metadata headers remain vertically sticky.
  • AC3 — A bounded sticky left block visibly retains all seven Flows identifying fields in specified order without consuming the entire grid when sidebars are open.
  • AC4 — Mixed-sign rows measure/reposition correctly, retain index-based subtle alternating stripes, and do not produce header drift or repeated scroll jumps.
  • AC5 — Switching viewport, resizing or collapsing sidebars cancels obsolete windows and retains readable tab-specific minimum column widths.
  • AC6 — The grid exposes useful accessible row/column identity and keyboard navigation without placing focus on unmounted or incorrect cells.

Out of scope and follow-ups

Flows-specific composition is #24, drag actions #25, Scores identifier fields #28, full performance evidence #26. No export/zoom/resizable-column post-MVP work.

Verification plan

Run on the Docker host: ./dev shell, then inside /workspaces/lca-diff: npm --prefix apps/frontend run format:check, npm --prefix apps/frontend run lint, npm --prefix apps/frontend run typecheck, npm --prefix apps/frontend run test:unit, and npm --prefix apps/frontend run build. These scripts are established by F1, not claimed available today. Browser scenarios use npm --prefix apps/frontend run test:e2e -- --project=chromium (F1 establishes the pinned Playwright tool/browser setup). No host package installs.

Add Chromium Playwright scrolling/resize/sidebars cases for the 200×2,000 synthetic workload with mixed-height rows. Assert bounded DOM/request counts and header/identifier alignment. Unit-test range/height bookkeeping where behavior cannot be covered by browser assertions.

Record exact commands/results and delivered SHA in the engineering handoff. QA independently checks every criterion at that SHA and reports PASS/FAIL/BLOCKED; unavailable required checks are not passing.

Dependencies and readiness

Blocking predecessors: #20, #21, #22. Also requires verified M1 container runtime and merged bootstrap/M2 configuration; later milestones are planned, not implementation-ready while predecessors remain open. PM must recheck dependencies and actual interfaces before marking READY.

Activity

  1. added
    task
    frontend
    blocked
    on Nov 13, 2026
  2. DavidVFitzGerald commented on Nov 13, 2026

    @DavidVFitzGerald
    OwnerAuthor

    PM: BLOCKED

    Groomed using docs/team/product-manager.md for F4, Phase 1 — frontend with mock services. Documentation review: PASS for scope, required sections, specification coverage and acyclic dependency links; this is not application QA or implementation readiness.

    Blocking predecessor issues: #20, #21, #22. The M1 runtime gate (#2) and merged bootstrap/M2 configuration (#3) also remain required. PM must recheck merged dependencies and current interfaces before changing this to READY.

    Engineer implements one issue, commits regularly and hands the delivered SHA plus exact container checks to independent QA; do not close before QA, review and approved merge. No backend/Firebase/cloud credentials or host installations are required for Phase 1.

  3. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    PM note carried from #16 (D9), not a readiness change: #16 adds no browser-reachable mock-scenario switch. Its paging, latency and large-catalog evidence is component-level, through an injected createMockDiscovery. The 200×2,000 Chromium workload here will need a browser-reachable large synthetic scenario. When this issue is groomed, decide that mechanism (or accept component-level evidence) explicitly. Any switch must be validated, mock-mode only, visibly identified as demo and never a fallback. If it is added, it should also offer a large discovery tree for the F3/Phase 1 browser evidence (#19 AC6, #34). An ADR is needed only if it changes composition/configuration contracts beyond the existing ones.

  4. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    PM: READY (recheck, stacked)

    Dependencies

    Interfaces checked

    Large browser scenario (resolves the PM note carried from #16)

    • Switch: a URL parameter, ?mock-scenario=large, read only at the composition root, only when VITE_SERVICE_MODE=mock.
    • Content: discovery and comparison catalogs that share at least 200 processes, plus at least 2,000 rows. The rows have deterministic per-process mixed signs, zeros and absences.
    • Validation:
      • An unknown value shows the existing configuration error; it never falls back.
      • Any non-mock mode still rejects the request.
      • The demo banner names the scenario.
    • ADR: none needed. This selects synthetic fixtures inside the existing explicit mock adapter. It adds no service mode or adapter and changes no real configuration contract. It is documented in apps/frontend/src/services/README.md.

    Scope split with #24

  5. removed
    blocked
    on Nov 14, 2026
  6. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: READY FOR QA

    Criteria

    • AC1 — implemented. Workload: ?mock-scenario=large gives 2,224 rows × 220 process columns.
      • DOM in Chromium (1440 × 900): at most about 25 rows and 440 cells mounted. Asserted bounds: ≤ 40 rows and < 800 cells in e2e; ≤ 26 rows and ≤ 17 columns in jsdom.
      • Initial reads in jsdom: 1 row page of 100, 1 summary request (≤ 100 rows × all 220 processes), and ≤ 2 cell tiles of ≤ 1,000 cells each.
      • Deep scroll to row 1500: ≤ 17 row pages of 100, ≤ 4 summary requests, ≤ 8 further tiles, and obsolete tiles are aborted.
    • AC2 — implemented. The header strip and the cells stay horizontally synced in both directions. Chromium shows header and column boxes within 1 px after scrolling, and the header strip's y position is unchanged by vertical scrolling.
    • AC3 — implemented. The bounded sticky block is 36% of the grid width, clamped to 300–560 px. It shows Type, Flow Name, Location, Process Name, Category, Subcategory and Unit, in order, in the corner and in every row. In Chromium all seven are visible, the block stays ≤ 45% of the grid with sidebars open, and it stays pinned at the grid's left edge.
    • AC4 — implemented.
      • Heights come from summaries; mixed rows are taller.
      • Contiguous row starts are exact, because heights are rounded to whole px.
      • Stripes follow the index, checked via computed colours in Chromium.
      • No scroll jumps: scrollTop and the first row are unchanged after settling.
    • AC5 — implemented. Collapsing the processes sidebar widens the grid while columns keep their 120–240 bounds. A 1,100 px viewport gives the Flows minimum of 120 px, with alignment re-checked. Windows that leave the viewport are cancelled, so new viewport sizes read new tiles.
    • AC6 — implemented.
      • ARIA: role=grid with row and column counts, aria-rowindex on rows, a rowheader with all seven fields, and gridcells with aria-colindex whose names start with the process name.
      • One roving tab stop. Arrows, Home/End, Ctrl+Home/End and PageUp/PageDown focus only mounted, correct cells.
      • A loading cell keeps focus when its data arrives.

    Commands

    All run in the workspace container.

    Command Result
    format:check pass
    lint pass
    typecheck pass
    build pass
    test:unit (twice) 28 files, 364 tests pass
    test:e2e -- --project=chromium 21/21 pass

    Notes and limitations

    Next: independent QA at 4a9411b.

  7. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: FAIL

    • Reviewed SHA: 4a9411b on feat/f4-virtual-grid (PR F4: windowed comparison grid with the Flows mount and large mock workload (#23) #68). The review diff is git diff 15ba70d..4a9411b.
    • Mode: Phase 1, explicit mock services only. Nothing here validates a real backend, auth or data security.
    • Environment: existing lca-diff-dev workspace container. All tooling ran through docker compose --project-directory . -f compose.yaml exec -T workspace bash -lc 'cd /workspaces/lca-diff && …'. Nothing was installed on the host.
    • Historical folders: not used.
    • Checkout state: unchanged, with a clean git status --short. Temporary probes (e2e/zz-qa-*.spec.ts, src/services/mock/zz-qa-grid.test.tsx, and mutants in a container-local /tmp copy) were deleted afterwards.

    Required checks

    Command (npm --prefix apps/frontend run …) Result
    format:check pass
    lint pass (--max-warnings 0)
    typecheck pass
    build pass (388.21 kB JS)
    test:unit, run 1 28 files, 364/364 pass
    test:unit, run 2 28 files, 364/364 pass
    test:e2e -- --project=chromium 21/21 pass, including flows-grid.spec.ts (2 tests), process-headers.spec.ts and the @smoke journeys

    Criteria

    AC1 — PASS (DOM and reads bounded)

    • Workload: ?mock-scenario=large gives 2,224 rows × 220 process columns.
    • Probes: Chromium probes covered 60 random jumps at one per animation frame, the bottom-right corner, 30 wheel steps and resizes to 1920×1200, 1100×700, 2560×1440 and 960×800.
    • Peak DOM: 32 rows, 832 gridcells, 22 process headers and 5,753 grid nodes, all at 2560×1440. At 1440×900 the grid held 17–23 rows and 187–414 cells.
    • Bottom-right: reaches row 2,224 and column 219.
    • jsdom scroll storm (my probe, 5 ms latency, 40 random jumps):
      • 94 cell reads, each ≤ 1,000 cells; 74 of them aborted.
      • 16 summary reads, all 100 rows × 220 processes.
      • 17 row pages, all limit=100.
      • No whole-matrix read.

    AC2 — PASS (alignment and pinned headers)

    • Alignment: I measured every visible value column against its process header. Max |dx| was 0 px and max |dw| was 0 px in every case below:
      • after scrollLeft of 1, 777, 12,345 and the maximum
      • after scrollTop of 50,000
      • after collapsing, expanding, then collapsing again while scrolled fully right
      • at each of the four viewport sizes
    • Corner: the corner's right edge equals the sticky block's right edge.
    • Scroll sync: the strip's scrollLeft equals the grid's scrollLeft, and their maximum scroll widths match.
    • Vertical pin: the header strip's y position does not change under vertical scrolling.

    AC3 — PASS, with an observation (O2)

    • Fields: all seven fields are present, in order, from 960 to 2560 px with the processes sidebar open.
    • Block bounds: the block is 299–559 px wide, which is 24–42% of the grid. Even at 960 px, a 421 px value area remains.
    • Readability: see O2.

    AC4 — FAIL (D1, selection changes)

    • Within one comparison:
      • Mixed rows are taller. Every value cell's height equals its row's height, including after selection changes.
      • Stripes follow the index.
      • Scroll anchoring: I jumped to the end, then scrolled up 3,000, 6,000, 20,000, 40,000 and 30,000 px into regions whose summaries were never loaded. For 1.2 s after each step I sampled every frame. The top visible row and its offset never changed: one sample (≤ 1 px) per step, for rows 2158, 2051, 1673, 913 and 338.
    • Selection changes: any selection change throws away the scroll position. See D1.

    AC5 — PASS (resize, sidebar and cancellation)

    • Column widths: the Flows minimum of 120 px holds at narrow widths. Collapsing the sidebar widens the grid and alignment holds (AC2 evidence).
    • Cancellation: obsolete tiles are aborted (74/94 above). My mutation M4 (read cells for every loaded row) makes the deep-scroll test fail.

    AC6 — PASS for navigation; the selection-change focus loss is part of D1

    • Navigation: I probed Arrow keys, Home and End, Ctrl+Home and Ctrl+End, PageUp and PageDown, edge no-ops and 40 quick ArrowDown plus 30 ArrowRight presses. Focus always landed on the expected data-row/data-col, in the viewport, never under the sticky block, with exactly one tabindex=0.
    • Scrolled away: after scrolling away with the mouse, ArrowDown continues from the active cell (row 41, column 29) and brings it into view.
    • Tab round trip: Shift+Tab then Tab returns to the active cell.
    • Reorder and removal: after a reorder (store.move) the tab stop follows the process by key. After the active process is removed, exactly one tab stop remains.

    Defect

    D1 — Medium: any selection change collapses the grid to 0 rows, resets the scroll to the top, drops keyboard focus and re-reads everything

    Where:

    • apps/frontend/src/components/comparison/useFlowGrid.ts:65–76: process_ids in selection order keys flowRowPages, and rowCount = loadedPages[0]?.total_count ?? 0, with no previous comparison retained.
    • ComparisonGrid.tsx:157: measured heights are reset per token.

    Repro (Chromium, 1440×900):

    1. Open /?mock-scenario=large, sign in and select all 220 processes.
    2. Set the grid's scrollTop to 70,000 (about row 1,340).
    3. Remove one process with its "Remove … from selection" button.

    Expected vs actual:

    • Expected: the reading position stays near the same flows. The column is removed or appended immediately (§6.3), and asynchronous row arrival causes no scroll jump (§9.1). This is the issue requirement "preserve stable row keys and scroll anchoring as asynchronous data arrives".
    • Actual:
      • aria-rowcount drops to 0 and every row unmounts. The canvas height becomes 0, so scrollTop is 0 (logged: top: 70327 before, top: 0 after).
      • Re-adding the process via the tree while at scrollTop 90,205 also returns to top: 0.
      • No loading indicator is rendered meanwhile (FlowsBody ignores data.loading).

    Pure reorder (jsdom probe):

    • Keyboard focus at row 1 on the Gamma column, then store.move(Gamma, 0).
    • The grid immediately reports aria-rowcount=0 with 0 rows mounted, and flowRows is called again with the reordered process_ids.
    • Focus falls to <body>, although the tab stop later correctly resolves to Gamma at column 0.
    • A display-only reorder therefore discards the loaded rows, summaries, position and focus. §9.1 suggests canonical, sorted ID arrays to avoid this.
    • [Task] F4 — Add shared column drag, keyboard reorder and global removal #25's drag reorder will expose it directly. Today, reorder exists only in the store API.

    Impact:

    • No stale data: no stale heights, errors or wrong tokens were observed. Cell and row heights agreed after removal, re-add and deep scrolling, and the console had no errors.
    • Lost place: users lose their position on every add, remove or reorder.

    Suggested direction (engineering's choice):

    • Key row reads independently of column order, or keep the previous comparison's rows as placeholder data.
    • Re-anchor on row_key across tokens.

    If PM decides to re-scope this to #24/#25 instead, that needs an explicit, linked follow-up on those issues. QA does not waive it.

    Test strength (mutation checks in a container-local copy; flows-grid.test.tsx)

    Every mutant was detected (each fails ≥ 1 test):

    Mutant Failing test
    M1: active row not kept mounted focus tests (2)
    M2: summary heights never applied heights/stripes test
    M3: header not synced from body alignment test
    M4: cells read for all loaded rows deep-scroll bounds test
    M5: stripes by mounted position heights/stripes test
    M6: summaries for every loaded page deep-scroll bounds test

    Boundary, scenario and ADR

    • Scenario validation:
      • In the browser, ?mock-scenario=LARGE, = (empty), =default and =large%20 each show the configuration error with no demo banner.
      • Unit tests cover non-mock modes and non-string values.
      • The large banner names the scenario.
      • The parameter is read only in main.tsx and validated only in composition.ts.
    • No ADR needed (defensible): the switch only selects synthetic fixtures inside the explicit mock adapter. It adds no mode, adapter or real configuration contract, and is documented in services/README.md.
    • Import boundaries:
      • Components import only services/contracts types and app/queries.
      • No fixtures, fetch or Firebase are used in components/comparison/.
      • Lint boundary rules pass.
    • [Task] F4 — Build shared process headers and comparability warnings #21/[Task] F4 — Implement exact signed-bar geometry and full-precision value tooltips #22 regressions: none.
      • comparison-headers.test.tsx and process-headers.spec.ts pass.
      • The rowHeight change (Math.ceil of chart height plus padding) adds less than 1 px of padding and leaves the chart geometry exact.
      • The present-value tooltip is aria-hidden, and the accessible name already holds the full lexeme. N/A cells keep aria-describedby.

    Observations (non-blocking)

    • O1 — Low: the always-mounted active row keeps its off-screen cells aria-busy "Loading" after you scroll away. Its summary page leaves the window, so 11 cells in row 1 stay pending while you are deep in the grid. They are not visible, but assistive technology can reach them.
    • O2 — Low (deferral not tracked): identifying values are heavily ellipsized at widths ≤ 1440 px with the sidebar open, e.g. "Ref…" and "Synthetic tra…" at 1280. Corner labels are clipped from Location onwards. Values have title hover and the full text is in the row header's accessible name, but no visual focus reveal exists. The handoff defers readability to [Task] F4 — Assemble the Flows comparison with exact missingness and cell warnings #24, but [Task] F4 — Assemble the Flows comparison with exact missingness and cell warnings #24's text does not mention it; the coordinator or PM should link it there.
    • O3 — Info: the processes sidebar makes the document about 214 px taller than the viewport at 900 px height. Scrolling the page moves the pinned grid headers up with it. The comparison pane itself fits the viewport.
    • O4 — Info: documented limitations are acceptable for [Task] F4 — Virtualize comparison rows and columns with sticky alignment #23: tooltips clipped at the scroller edges, and sequential 100-row cursor pages on far jumps.

    Next action

    Engineering fixes D1, or PM explicitly re-scopes it with linked follow-ups. QA then re-checks the new SHA with flows-grid unit and e2e tests plus a selection-change probe.

  8. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: READY FOR QA (round 2)

    Branch feat/f4-virtual-grid, delivered SHA b5a2488, PR #68 (stacked on #67). Changes since the FAIL at 4a9411b: git diff 4a9411b..b5a2488.

    D1 fix: selection changes no longer empty the grid

    useFlowGrid.ts:

    • Row pages and summaries are read for the canonical sorted process set. A column reorder keeps the same comparison and token and re-reads no rows or summaries.
    • placeholderData: keepPreviousData: while a changed selection loads, the previous comparison stays shown. The grid is aria-busy, and an "Updating the comparison…" status region is shown.
    • While that previous comparison is shown, no summary, tile or next-page reads are issued with its token.

    ComparisonGrid.tsx:

    • Measured heights are no longer reset per token.
    • Rows stay index-keyed, so DOM nodes and focus survive.
    • Cached heights are corrected, with scroll anchoring, as new summaries arrive.

    Regression tests

    • jsdom (flows-grid.test.tsx):
      • Remove, then re-add, a process while scrolled to row 1300. The row count never drops to 0, the grid is busy then idle, the focused row stays within 1 px of its viewport position, focus stays on the same node, values return, and a re-added column appears immediately.
      • Reorder keeps the row and summary read counts, and the tab stop follows its process.
      • Both tests fail against the 4a9411b versions of useFlowGrid.ts, ComparisonGrid.tsx and FlowsGrid.tsx, run in a temporary container copy.
    • Chromium (e2e/flows-grid.spec.ts): QA's repro. After deep scrolling, removing a process from the selected list keeps the rows, values and scroll position (within one row).

    Commands

    All run in the workspace container.

    Command Result
    format:check pass
    lint pass
    typecheck pass
    build pass
    test:unit (twice) 366/366 pass
    test:e2e -- --project=chromium 21/21 pass

    Observations

    Next: QA recheck at b5a2488.

  9. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: FAIL

    Round 2 recheck of #23 (F4-04) at SHA b5a2488 (feat/f4-virtual-grid, PR #68, stacked on #67 at 15ba70d). I reviewed git diff 4a9411b..b5a2488 and the full change git diff 15ba70d..b5a2488.

    • Mode: Phase 1, mock services only. Real backend, auth and security are not validated.
    • Environment: existing lca-diff-dev workspace container (rootless Docker). Nothing was installed on the host.
    • Probes: run in a container-local copy of apps/frontend (/tmp/qa23b, since deleted). No tracked file was changed, and git status --short is clean.

    Summary. The D1 symptoms reported in round 1 are fixed. The grid no longer empties, scrollTop is kept, the DOM focus node survives, reorders re-read nothing, and no read uses an old token. One part of D1's expected behaviour is still missing: "the reading position stays near the same flows". When a selection change adds or removes rows above the viewport, the pixel offset is kept but the visible flows shift by that number of rows. A bulk change of 110 processes shows flows 110 rows away, and the keyboard tab stop is left off-screen. This is reported as D2 below.

    Required checks (container)

    All commands use docker compose --project-directory . -f compose.yaml exec -T workspace bash -lc 'cd /workspaces/lca-diff && npm --prefix apps/frontend run <script>'.

    Script Result
    format:check pass ("All matched files use Prettier code style!")
    lint pass (exit 0, --max-warnings 0)
    typecheck pass (exit 0)
    build pass (index-DBu5_Jh5.js 388.47 kB)
    test:unit, run 1 28 files, 366/366 pass
    test:unit, run 2 28 files, 366/366 pass
    test:e2e -- --project=chromium 21/21 pass (36.1 s)

    D1 recheck: PASS for the reported symptoms; the anchoring residual is D2

    Chromium probe. 1440×900, /?mock-scenario=large, all 220 processes, grid at scrollTop 69,830 (about row 1,338), a deep value cell focused. I sampled every animation frame from each action until it settled.

    Action Min aria-rowcount during transition Rows mounted (min) scrollTop Busy/status First visible flow before → after
    A: remove 1 (selected list) 2,223 (never 0) 21 69,830 → 69,831 3 frames, then cleared 001114 → 001115 (1-row shift)
    B: re-add the same process (tree) 2,223 21 kept 0 frames (cached set) 001115 → 001114
    C: bulk deselect 110 (filter "generated 0001", "Deselect all matches") 2,114 21 69,830 kept 3 frames, then cleared 001114 → 001224 (110-row shift)
    D: bulk reselect 110 2,114 21 kept 0 frames 001224 → 001114
    E: 5 rapid removals, no waits 2,219 21 kept 14 frames, then cleared 001114 → 001119
    F: shrink while at the very end (deselect 110) 2,109 16 115,657 → 110,439 (browser clamp) 4 frames, then cleared Rows 2098–2107 visible; no blank viewport
    Clear all, then reselect — — 0 (new grid) — Empty state shows ("Compare process flows"); reselect renders from the top

    Across every action:

    • The grid stayed connected.
    • Every rendered value cell's height equalled its row's height.
    • Exactly one tabindex=0 remained.
    • No role=alert appeared, and the console had no errors or warnings.
    • Between the old and new comparison, deep rows briefly show legitimate aria-busy "Loading…" row headers while cursor pages reload sequentially.

    jsdom probe. Uses the flows-grid.test.tsx harness with 15 ms mock latency and store-driven changes while deep (scrollTop 70,327, focus on row 1348, column 2). For each step I checked:

    • the aria-rowcount/aria-busy transitions, via a MutationObserver;
    • the read deltas;
    • a stale audit: every mounted, loaded row's Flow Name, row height and cell heights, and every value cell's amount or absence, compared with fresh direct mock reads for the current selection (flowRows all pages, flowSummaries, then rowGeometry, then flowCells);
    • a token audit: every flowCells request's process ids ⊆ its token's process set, every flowSummaries set equal to its token's set, and no error results.
    Step Transitions (rowcount/busy) Reads (rows / summaries) Stale audit Token audit
    Remove #5 2224/- → 2224/true → 2223/- 14 / 1 24 rows, 288 cells, 0 problems 0 bad, 0 errors
    Re-add #5 2223 → 2224 (cached, no busy) 0 / 0 0 problems 0 bad
    Remove 3 (new set) → 2224/true → 2221/- 14 / 1 0 problems 0 bad
    Add several (3) → 2224 (cached) 0 / 0 0 problems 0 bad
    Bulk deselect 100 → 2224/true → 2124/- 14 / 1 0 problems 0 bad
    store.move column 2 → 0 no transition, not busy 0 / 0 0 problems 0 bad
    Three changes in one tick → 2124/true → 2123/- 14 / 1 0 problems 0 bad
    Four changes in separate ticks, 5 ms apart 2123/true → 2122/true → 2123/true → 2123/- (never 0) — 0 problems 8 tokens, 0 bad, 0 errors
    • Values: they return for the new comparison, and none are stale after the update completes.
    • Old token: it is never used for new columns.
    • During an update: the previous rows stay, with every value cell pending. No old values are presented as current.

    New regression tests. I confirmed that both new tests fail against the 4a9411b versions of useFlowGrid.ts, ComparisonGrid.tsx and FlowsGrid.tsx (2 failed, 7 passed), and also with only the old useFlowGrid.ts. Targeted mutants on b5a2488:

    Mutant Failing test
    N1: keepPreviousData removed the remove/re-add test
    N2: canonical sort removed the reorder test
    N3: the three updating guards removed (old-token summary, tile and next-page reads) none: 9/9 pass. See O6.

    New defect

    D2 (Medium): residual of D1. Row-set changes above the viewport shift the visible flows. Scrolling keeps the pixel offset but is not anchored on rows. The tab stop and DOM focus can also end up on different flows.

    Where:

    • apps/frontend/src/components/comparison/useFlowGrid.ts:85-90: keepPreviousData, then the new comparison is swapped in by index.
    • apps/frontend/src/components/comparison/ComparisonGrid.tsx:107-117: the active row is re-resolved by rowKey within ±200 rows.
    • ComparisonGrid.tsx:286-288: rows are index-keyed.
    • Nothing records the first visible row_key before the swap or restores it afterwards.

    Repro (Chromium, 1440×900):

    1. Open /?mock-scenario=large, sign in and select all 220 processes.
    2. Set the grid's scrollTop to 70,000 and wait for the values.
    3. Note the first visible flow: "Synthetic generated flow 001114".
    4. Type "generated 0001" in the "Process Name" search box and click "Deselect all matches". This removes 110 processes, so 110 Reference rows sort above the viewport.

    Expected: the same flows stay in view, or the nearest surviving flow if the anchor row itself was removed. This is the round-1 D1 expectation, §9.1 "avoid scroll-jump when rows arrive asynchronously", and the issue requirement "preserve stable row keys and scroll anchoring".

    Actual:

    • scrollTop is unchanged, but the first visible flow becomes "Synthetic generated flow 001224". The view has silently moved 110 flows.
    • Removing a single process shifts the view by one row, which is why the new e2e check (tolerance below 52 px of scrollTop) passes.
    • With real BAFU data, a deselection also removes the process's Reference row and any unique Technosphere rows above the Ecosphere rows. Users reading Ecosphere flows will therefore see the content shift on most bulk changes.
    • Keyboard: the tab stop follows the focused flow by key to row 1232 (stopInView: false), far off-screen from where the user was reading.
    • Divergent focus (jsdom, store-driven): focus was on row 1348, column 2, flow 001124. After deselectMany of 100 processes, document.activeElement stays on DOM node 1348/2, which now shows flow 001224 with tabindex=-1. The single tabindex=0 is on 1248/2 (flow 001124). For a one-process removal, activeElement is on 1348/2 (flow 001125) and the stop on 1347/2 (flow 001124).
    • Reachability of the divergence: today's UI removes processes from the sidebar, which takes focus, so the divergence is latent. The §6.3 header × removal ([Task] F4 — Add shared column drag, keyboard reorder and global removal #25) would remove processes while focus stays in the grid and expose it.

    Suggested direction (engineering's choice):

    • Before the swap, capture the first visible row's row_key/sort_key and its offset.
    • Once the new comparison's pages cover that region, scroll so that row, or the first surviving row at or after its sort_key, sits at the same offset.
    • Resolve the active cell to the same flow and move DOM focus with it, so focus and the tab stop never diverge.
    • Add a regression test with a multi-row change above the viewport, asserting the first visible flow's identity rather than scrollTop.

    If PM decides instead to re-scope cross-comparison anchoring to #24 or #25, that needs an explicit, linked follow-up. QA does not waive it.

    AC1–AC6 regression (round-1 Chromium probe re-run at b5a2488, 7/7 pass, plus the suites above)

    AC1 — PASS

    • DOM bounds: the most mounted at any point was 32 rows, 832 cells, 22 headers and 5,730 nodes, at 2560×1440. After fast scrolling it was 23 rows and 414 cells.
    • Reads: unchanged from round 1, and the bounded-reads unit test passes.

    AC2 — PASS

    • Alignment: maxDx and maxDw are 0 at 960 to 2560 px, at scrollLeft 1, 777, 12,345 and the far right, and with the sidebar collapsed and expanded.
    • Header strip: its scrollLeft equals the grid's.

    AC3 — PASS. All seven fields are present, in order, in a 300–560 px block.

    AC4 — PASS within a comparison; the cross-comparison shift is D2

    • Anchoring after jumping to the end: I scrolled up 3k, 6k, 20k, 40k and 30k px. Each step kept exactly one first-row/offset sample (rows 2158, 2051, 1673, 913 and 338).
    • Stripes: still follow the row index.

    AC5 — PASS. Resize and sidebar collapse keep minimum widths and alignment, and cancellation is unchanged.

    AC6 — PASS for navigation, with the D2 caveat for selection changes

    • Keyboard stress: passes. Shift+Tab then Tab returns to the active cell.
    • Reorder (store.move): focus and the tab stop follow the process to its new column, with 0 row and 0 summary re-reads.
    • Removing the focused process's column: in a rapid sequence, this drops DOM focus to <body> with one tab stop left. That is expected for a removed column.

    Edge cases

    • Stale heights: cells always use the current summary's geometry. The stale audit found 0 mismatches across every step, and no loaded cell ever had a height different from its row's.
      • Transient pending-row heights: after a bulk deselect I jumped to a region measured under the previous comparison. For 4 frames, 8 of 23 pending rows were drawn at heights cached for that index from the old comparison (e.g. 92 px) while their pending cells were 52 px. They were corrected when the summary arrived. See O5.
    • Rapid changes: PASS. Same-tick and separate-tick sequences never reach 0 rows, end not busy, and leave 0 stale values and 0 bad tokens.
    • Row count shrinking below the scroll position: PASS in Chromium. The browser clamps scrollTop (115,657 → 110,439), the last rows (2098–2107) render, and no blank viewport or error appears.

    Documentation

    • services/README.md "Selection changes": accurate about the canonical set, the busy/status state and no old-token reads. "scroll position and focus are kept" is accurate only for the pixel offset and DOM node. It should say that rows are not re-anchored across comparisons, or be updated with the D2 fix.
    • Wording: "Rows are keyed by index within one comparison token" is now true across tokens too.
    • O1: left as is. That is acceptable (Low, announced as loading).
    • O2/O3: the PM note on [Task] F4 — Assemble the Flows comparison with exact missingness and cell warnings #24 adequately carries them.
    • O4: accepted.
    • ADR: none needed. The change is an implementation choice within the contract, and §9.1 already recommends canonical sorted ID arrays.

    Observations (non-blocking)

    • O5 — Low: cached heights are not reset (by design), so pending rows away from the summarized window briefly render at the previous comparison's heights for that index. This has no effect on data or bar geometry.
    • O6 — Low, test gap: no unit or e2e test covers adding a never-before-seen process while the previous comparison is shown. Re-adding hits the cached set, so removing the updating guards (N3) goes undetected, although the mock would reject such reads as INVALID.
    • O7 — Low, latent: with an empty selection, useFlowGrid keeps updating=true and the previous rowCount. A disabled query plus keepPreviousData makes isPlaceholderData true. In jsdom, FlowsGrid mounted directly stays "Updating the comparison…" with 2,123 rows and 0 columns after store.clear(). The app is unaffected today because App.tsx unmounts FlowsGrid on an empty selection. Guard it if [Task] F4 — Assemble the Flows comparison with exact missingness and cell warnings #24 renders the grid for empty states.

    Next action

    Engineering fixes D2 (row-anchored position and consistent focus across comparisons), adds a test that asserts the visible flow's identity, and updates the README. Alternatively, PM explicitly re-scopes D2 with a linked follow-up. QA then re-checks the new SHA: the flows-grid unit and e2e tests plus the selection-change probes above.

  10. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: READY FOR QA (round 3)

    Branch feat/f4-virtual-grid, delivered SHA dc4cf9f, PR #68 (stacked on #67). Changes since the FAIL at b5a2488: git diff b5a2488..dc4cf9f.

    D2 fix: the view is anchored on flows, not pixels

    • ComparisonGrid.tsx:
      • While idle, it records the flow at the viewport top and the offset into it.
      • When the shown row set changes (version, the comparison token), it asks its owner to load until that flow is located (onSeek), then scrolls so the flow is back at the same offset.
      • The active cell is resolved through locate(rowKey) across the whole loaded set, not ±200 rows.
      • Keyboard focus is restored to the active cell when it belonged to the grid and its node changed. Grid focus ownership is cleared on a blur to an outside element or a pointer press outside the grid, so a sidebar click never has focus pulled back.
    • useFlowGrid.ts:
      • New seekKey argument: keeps fetching row pages until that key is loaded.
      • New locate(key): returns the index, undefined while it may still be in an unloaded page, or null if absent.

    Tests

    • jsdom (flows-grid.test.tsx): while deep at row 1300, with a cell focused, deselect 110 processes in one store update, then reselect them. The test checks that:

      • the previous comparison stays shown, busy, with the status text
      • after the update, the same flow is still the row at the viewport top
      • the focused flow is in view and keeps DOM focus with tabindex=0
      • values return, and re-added columns appear immediately
      • no summary or cell reads are issued while the grid is busy (O6)

      This test fails against the b5a2488 versions of the three grid files, run in a temporary container copy.

    • Chromium (e2e/flows-grid.spec.ts): QA's D2 repro. While deep, filter Process Name "generated 0001" and Deselect all matches. Asserts that rows are shown, the row count drops, and the flow at the viewport top is unchanged.

    Commands

    All run in the workspace container.

    Command Result
    format:check pass
    lint pass
    typecheck pass
    build pass
    test:unit (twice) 366/366 pass
    test:e2e -- --project=chromium 21/21 pass

    Observations

    • O5 (rows waiting for data briefly use the previous comparison's heights): left as is. Values and bar geometry always come from the current summary.
    • O6: covered by the new busy-read assertion.
    • O7 (an empty selection keeps updating and the previous row count): not reachable today, because App.tsx unmounts the grid when nothing is selected. Noted for [Task] F4 — Assemble the Flows comparison with exact missingness and cell warnings #24 if it renders the grid for empty states.
    • README: "Selection changes" was corrected, and a new "View anchoring" entry was added.

    Next: QA recheck at dc4cf9f.

  11. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: FAIL

    Round 3 recheck of #23 (F4-04).

    Verified SHA dc4cf9f (branch feat/f4-virtual-grid, PR #68 head dc4cf9f; stacked on #67 / 15ba70d)
    Mode Phase 1 mock services only (/?mock-scenario=large: 220 processes × 2,000+ flows). No real backend, auth or data-security claims.
    Environment Existing lca-diff-dev workspace container (rootless Docker). Nothing installed on the host.
    Diff reviewed git diff b5a2488..dc4cf9f, plus the full #23 change 15ba70d..dc4cf9f for regressions

    Probes. All probes ran in a container-local copy of apps/frontend (/tmp/qa23c, since removed). Diagnostic console.log instrumentation was added to that copy only. The shared checkout was not modified, and git status --short is clean.

    Verdict. The fix works for the case it tests: a bulk deselect of 110 processes while deep. In Chromium, though, the restored position is overridden or drifts when row heights are corrected after the restore. As a result, adding never-seen processes still shifts the view by 110 flows, and single or small removals still shift it by 1 to 11 flows. A user's own scroll during an update is also undone. D2 is therefore not fixed for most selection changes.

    Required checks (all in the workspace container)

    Command form: docker compose --project-directory . -f compose.yaml exec -T workspace bash -lc 'cd /workspaces/lca-diff && npm --prefix apps/frontend run <script>'

    Script Result
    format:check pass ("All matched files use Prettier code style!")
    lint pass (0 warnings)
    typecheck pass
    build pass (389.79 kB JS)
    test:unit, run 1 28 files, 366/366 pass
    test:unit, run 2 28 files, 366/366 pass
    test:e2e -- --project=chromium 21/21 pass (35.4 s)

    1. D2: FAIL

    The tables below give, for each change, the first visible flow (the row containing the viewport top) and its offset, before and after. "Kept" means the same flow at the same offset.

    Chromium, 1440×900:

    Change while deep Before After Result
    Bulk deselect, "generated 0001" (110 processes, scrollTop ≈ 70,000) flow 001113 at −9 px (row 1337) flow 001113 at −9 px (row 1227) kept
    Re-add the same 110 (cached comparison) flow 001113 at −9 px flow 001113 at −9 px (row 1337) kept
    Single removal ("Remove … from selection", sidebar), scrollTop 70,000 001122 at −48 001128 at −63 shifted +6 flows
    Single removal, scrollTop 30,000 000353 at −48 000363 at −19 shifted +10
    Single removal, scrollTop 100,000 001661 at −40 001672 at −42 shifted +11
    Single removal, scrollTop 50,000 000714 at −70 000719 at −16 shifted +5
    Single removal, scrollTop 85,000 001362 at −75 001373 at −36 shifted +11
    Single removal, scrollTop 10,000 (Reference region) row 192 at −16 row 192 at −16 kept
    Single removal (sequence in R3-1) 001113 at −9 001117 at −46 shifted +4
    Deselect "generated 0002" at scrollTop 100,000 001686 at −63 001687 at −11 shifted +1
    Add never-seen processes: select 110 ("generated 0001"), scroll to 60,000, then select all 220 001039 at −44 (row 1153) 000929 at −44 (row 1153), scrollTop 60,368 → 60,369 shifted −110 flows; this is D2 unchanged
    Later removal after a stalled/overridden restore, scrollTop 90,000 001480 at −3 001481 at −3 shifted +1
    Anchored flow removed: Reference row of "…generated 000018" at row 60; deselect "generated" (216 processes) Reference row at −10 row 60 = Ecosphere flow 000062 at −10 (scrollTop 3,130 → 3,429) falls back to index/pixel. Not "nearest surviving flow". See O8.
    Reorder (store.move, jsdom; no browser reorder UI yet) — token unchanged, no restore; focus follows the process to its new column kept
    Rapid: deselectMany(110), then selectMany(47), deselect(1) and move, 5 ms apart (jsdom, latency 30) 001076 at −20; focus 1310/2 on flow 001086 001076 at row 1237; focus and tab stop 1247/1 on flow 001086 (process moved to column 1) kept, 0 busy reads

    Root cause, from instrumentation in the container copy. For the never-seen add, the seek works: row pages load up to 1,300, locate returns 1263, and the restore calls scrollTo(66328 + 44). Yet the element ends at 60,369, the old offset plus 1 px. For the single removal at 70,000, the restore scrolls to 70,275 (correct), but 300 ms later the element is at 70,643 (+368 px).

    The restored position is therefore overwritten after the restore. The most likely cause is the summary-height resizeItem microtask (ComparisonGrid.tsx:186-197). It runs after the restore's scrollTo (ComparisonGrid.tsx:226), and the virtualizer's scroll-anchoring adjustments are computed against its own internal scrollOffset, which still holds the pre-restore value. The O5 stale per-index heights make those corrections large.

    Engineering should confirm the mechanism. The observable failure does not depend on it.

    Focus and tab stop.

    • Bulk deselect (Chromium, cell 1341/8 focused, then "Deselect all matches" clicked): DOM focus stays on the button, which is correct and not stolen. The single tab stop moves by key to 1231/8, still on flow 001117 and in view.
    • Deselect of 110 with focus in the grid (jsdom): focus 1312/5 on flow 001088 becomes 1202/5 on flow 001088, tabindex=0, one stop.
    • Focus outside the grid is never stolen in any of these cases:
      • after focusing an outside button (pointerdown plus focus)
      • after a body press plus blur
      • after a Tab-style blur with relatedTarget
      • in Chromium: after an outside click, a keyboard Enter on "Deselect all matches", and a click on "Select all matches"
    • Grid scrollbar click (Chromium): keeps focus on the cell (1400/10).
    • Sign out with a cell focused: no errors, and the grid unmounts.
    • Residual, latent (O9): removing the focused column while the grid owns focus (jsdom store-driven) leaves DOM focus on 1312/5, which now shows flow 001089 with tabindex=-1. The tab stop is on 1311/5 (flow 001088). Today's UI cannot reach this, because sidebar removal takes focus. [Task] F4 — Add shared column drag, keyboard reorder and global removal #25's header × would reach it.

    Seeking and reads.

    • The seek fetches pages strictly sequentially. For a 1,480 anchor it loaded pages to 1,800 and stopped with seeking=false. Normal cursor paging continues afterwards.
    • The O6 busy-read assertion works: mutant M4 below kills it. Every probe recorded 0 busy reads.
    • If the anchor is absent, locate can return null only once every page is loaded, so an absent anchor loads every row page. There is no sort-key early stop (O8).

    Regression test strength. Each mutant was applied to the container copy and run against flows-grid.test.tsx:

    Mutant Result
    R0: b5a2488 versions of the three grid files the new test fails (1 failed, 8 passed)
    M1: restore scrollTo removed fails
    M3: focus restore removed fails
    M4: updating guards removed (O6/N3) fails
    M6: offset into the anchor row dropped (into: 0) fails
    M2: seek removed (`
    M5: active row resolved only within ±200 9/9 pass

    No test covers additions above the viewport, single removals, or height corrections after a restore. These are exactly the failing cases.

    2. Regressions: PASS apart from the D3/D4 interactions

    • D1: no change empties the grid. Sampled frames always show rows, with aria-busy and "Updating the comparison…" during the load, and the row count never reaches 0.
    • AC1–AC6: the round-1 Chromium AC probe (DOM and request bounds, alignment at several widths and scroll positions, sidebar collapse/expand, the seven fields in a 300–560 px block, anchoring while summaries arrive above, jump to end and scroll up, keyboard stress and the Tab round trip) was re-run at dc4cf9f: 7/7 pass, 45 assertions. The bounded-read, deep paging/cancel, reorder and stripe unit tests pass.
    • Ordinary scrolling: the anchor is applied only on a version change, so it does not fight ordinary scrolling.
      • Wheel, 20 × 400 px: scrollTop is monotonic (64,605 → 72,605).
      • PageDown ×5 then PageUp ×2 from a focused cell: offsets 72,122 → 74,506 → 73,928, with focus following (1396/5) and one stop in view.
      • Jump to end, then up 20k: stable (row 2183, then row 1832).
      • Scrollbar drag: inconclusive. Headless Chromium did not move on a drag at the right edge, so this is not claimed.
    • Restore after an in-flight user scroll: fights the user (D4).

    3. New risk areas

    • Document pointerdown listener and restore-on-lost-focus: PASS. There is no focus stealing after outside clicks, keyboard Tab-away, sidebar buttons or sign-out, and a grid scrollbar click keeps cell focus. The listener is capture-phase and removed on unmount.
    • No scroll jumps after a restore when summaries or heights arrive: FAIL (D3). The view moves +203 to +568 px after the restore, which either changes the first visible flow or fully undoes the restore.

    4. Documentation: FAIL (follows D3)

    • services/README.md "View anchoring" (lines 467–473) states that "rows added or removed above never shift what is read". That is inaccurate at dc4cf9f: see the tables above.
    • "Selection changes": accurate.
    • O5: left as is, but it now feeds D3, because stale per-index heights are corrected after the restore.
    • O6: resolved, with a busy-read assertion that M4 kills.
    • O7: accepted, since App.tsx unmounts the grid for an empty selection.
    • ADR: none needed. This is an implementation choice within the contract.

    Defects

    D3 (Medium): anchoring is overridden or drifts after row heights are corrected (residual of D2).

    • Where: apps/frontend/src/components/comparison/ComparisonGrid.tsx:186-197, the resizeItem microtask, interacting with the restore at ComparisonGrid.tsx:219-228 (scrollTo at :226). The README claim is at apps/frontend/src/services/README.md:467-473.
    • Repro A (Chromium, 1440×900):
      1. Open /?mock-scenario=large and sign in.
      2. Click the level-1 tree item.
      3. Type "generated 0001" in "Process Name" and click "Select all matches" (110 processes).
      4. Set the grid's scrollTop to 60,000 and wait for the values. The first visible row is flow 001039 at −44 px.
      5. Clear the search and click .tree-check on the first level-2 item, adding the other 110 processes.
    • Expected A: flow 001039 stays at −44 px (now row 1263).
    • Actual A: the restore runs scrollTo(66372), but scrollTop ends at 60,369. The first visible row is flow 000929, so the view moved 110 flows.
    • Repro B:
      1. Select all 220 processes.
      2. Open "Selected processes" and set scrollTop to 70,000 (flow 001122 at −48).
      3. Click the third "Remove … from selection".
    • Expected B: flow 001122 stays at −48.
    • Actual B: the view shows flow 001128 at −63 (scrollTop 70,327 → restore 70,275 → 70,643). This reproduces at 30k, 50k, 85k and 100k with shifts of +5 to +11 flows.
    • Impact: the §9.1 scroll jump, and the issue's "preserve stable row keys and scroll anchoring", for any change other than a large removal. Additions are the common case when building a comparison.
    • Suggested direction: engineering's choice. Restore only after the virtualizer has seen the new offset, or by using rowWindow.scrollToOffset/scrollToIndex so its internal offset is consistent. Re-apply or verify the anchor once the window's summaries and heights have landed. Then add tests for an addition above the viewport and for a single removal, asserting the flow's identity and offset after the heights settle. Those tests would also kill M2.

    D4 (Medium): user scrolling during an update, or before the scrolled-to rows load, is undone.

    • Where: ComparisonGrid.tsx:231-237. The anchor is recorded only while idle and only on a loaded row, so a scroll made while busy or onto pending rows keeps the pre-change anchor.
    • Repro (jsdom, latency 300 ms):
      1. Select all and scroll to row 1300 (flow 001076).
      2. Call deselectMany on 110 processes. The grid is busy.
      3. While "Updating the comparison…" is shown, scroll to row 1500 (the first visible row becomes row 1474).
    • Expected: the view stays where the user scrolled.
    • Actual: when the update lands, the view jumps back to flow 001076 (scrollTop 61,880).
    • Chromium repro: use CPU throttle ×20. Deep at 70,327 (flow 001122), click "Deselect all matches" and immediately set scrollTop to 90,000 (row 1718). After settling, the view is back at flow 001122 (scrollTop 64,605).
    • Impact: the anchor logic fights user scrolling. Updates are short with the mock (about 100 ms), but with the real API this is a visible snap-back.
    • Suggested direction: engineering's choice. Re-anchor on a user scroll even while busy, for example on the loaded previous-comparison row's key, or cancel the pending restore when the user scrolls.

    Observations (non-blocking)

    • O8 (Low): when the anchored flow itself disappears, the view keeps its index/pixel position rather than the nearest surviving flow. locate returns null only after all row pages are loaded, with no sort-key early stop. This is acceptable as a degrade, but worth doing alongside D3.
    • O9 (Low, latent): removing the focused column while the grid owns focus leaves DOM focus on a non-stop cell showing a different flow (details above). [Task] F4 — Add shared column drag, keyboard reorder and global removal #25 will make this reachable.
    • O10 (Low, test gap): mutants M2 (seek) and M5 (±200 resolution) survive the suite.

    Next action

    Engineering fixes D3 and D4, corrects the README, and adds the tests described above. QA then rechecks the new SHA with the flows-grid unit and e2e tests and these Chromium probes: addition of never-seen processes, single removals at several depths, scroll during busy, and the anchored flow removed.

  12. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: READY FOR QA (round 4)

    Branch feat/f4-virtual-grid, delivered SHA 3976241, PR #68 (stacked on #67). Changes since the FAIL at dc4cf9f: git diff dc4cf9f..3976241.

    Design: the grid anchors the view itself

    The virtualizer's own size adjustment is turned off (shouldAdjustScrollPositionOnItemSizeChange = () => false).

    • ComparisonGrid.tsx:
      • Recording: after every scroll it records up to 12 loaded rows from the viewport top, with their layout starts. If no row in view is loaded, it keeps the previous pins.
      • Pinning: after any layout change, it finds the first recorded flow still present and scrolls by exactly how far that flow's start moved. Layout changes are the layout effect and the height-correction microtask right after resizeItem. The adjustment is relative, so it never undoes a scroll in progress (D4).
      • Removed flows: rows load in order, so finding a later recorded flow means earlier ones were removed. If every recorded flow is gone, the grid re-anchors on what is in view (O8).
      • Reporting: it reports the anchor flows to its owner (onAnchor).
      • Focus: while the grid owns focus, focus moves back to the active cell whenever the focused node now shows another flow or process (O9).
    • useFlowGrid.ts:
      • It reads anchorKeys() when the selection changes. The previous comparison stays shown (updating: busy, no summary or cell reads) until an anchor flow is loaded in the new one, or no pages remain.
      • The grid then puts that flow back in place in the same layout pass, so the new rows never appear at a stale position.
      • This replaces the round-3 seek round trip.

    Results with QA's round-3 probes

    Unchanged QA copies, run in the container and then removed.

    Case Before (dc4cf9f) Now
    Single removals at 10k–100k (Chromium) +4 to +11 flows same flow and offset at all six depths
    Adding 110 never-seen processes 110-flow shift, plus an interim frame of other flows flow 001039 at −44 px in every sampled frame
    Deselecting "generated 0002" +1 flow same flow and offset
    Scrolling during a busy update (jsdom, 300 ms) snapped back to flow 001076 the user's scroll distance from the anchor is kept
    Anchored flow removed kept the pixel position, then drifted re-anchors on the rows in view

    Focus: it follows the flow during rapid changes. Removing the focused column moves focus to the active cell, and focus is never stolen from outside the grid. No console problems were logged in any probe.

    New regression tests

    • jsdom (flows-grid.test.tsx):
      • Adding processes above the view: a MutationObserver samples the top row on every DOM change, and the only flow ever seen is the anchor. The test also checks identity and offset after heights settle.
      • Single removal after heights settle.
      • Scrolling while busy is not undone (300 ms latency).
      • Adding processes and scrolling while busy fail against the dc4cf9f grid files.
      • The single-removal drift doesn't reproduce in jsdom.
    • Chromium (e2e/flows-grid.spec.ts): a single removal at depth, checked once rows in view are loaded plus a 500 ms pause, then the bulk "Deselect all matches" check.
      • With the dc4cf9f grid files this fails, moving from flow 000545 to 000553. It passes now.
    • Flaky test: composition.test.tsx's large-scenario test now has an explicit 20 s timeout. It builds the 220 × 2,000 catalog and hit the default 5 s once under parallel load.

    Commands

    All run in the workspace container.

    Command Result
    format:check pass
    lint pass
    typecheck pass
    build pass
    test:unit (3 runs, after the timeout fix) 369/369 each time
    test:e2e -- --project=chromium 21/21 pass

    Documentation

    The README "View anchoring" section was rewritten, and the height note corrected.

    Remaining observations

    Next: QA recheck at 3976241.

  13. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: PASS

    Round 4 recheck of #23 (F4-04), PR #68.

    Verified SHA 3976241 on feat/f4-virtual-grid, in the shared checkout. HEAD was confirmed; the tree was clean before and after.
    Mode Phase 1 mock services only. Real backend, auth and data security are not claimed.
    Environment The existing lca-diff-dev workspace container (rootless Docker). Nothing was installed on the host.
    Probes and mutations Run in a container-only copy (/tmp/qa23d, with node_modules symlinked). No tracked file was modified, and no zz-qa-* file was ever placed in the app tree.

    Verdict: D2, D3 and D4 are fixed on every path QA exercised. There are no regressions in D1 or AC1–AC6, and normal scrolling is not fought. One new Low defect remains on an error-recovery path (D5 below). I consider it non-blocking, but it needs to be fixed in #68 or tracked in a linked follow-up. There are also test-gap observations.

    Required checks

    All were run in the container with cd /home/david/projects/LCA-diff && docker compose --project-directory . -f compose.yaml exec -T workspace bash -lc 'cd /workspaces/lca-diff && npm --prefix apps/frontend run <script>'.

    Script Result
    format:check pass ("All matched files use Prettier code style!")
    lint pass (--max-warnings 0)
    typecheck pass
    build pass (JS bundle 390.54 kB)
    test:unit, run 1 369/369, 28 files, 67.7 s
    test:unit, run 2 369/369, 28 files, 68.9 s
    test:e2e -- --project=chromium 21/21, 38.4 s

    Composition timeout change: this is test-only. The large-scenario composition test takes about 4.4 s, close to the default 5 s, because it builds the 220 × 2,000+ catalogue. A 20 s ceiling is reasonable and does not hide a product slowdown.

    1. D2, D3 and D4: PASS

    The round-3 probes were re-run unchanged.

    Chromium (zz-qa-r3.spec.ts, zz-qa-r3b.spec.ts, 1440×900, /?mock-scenario=large): 7/7 ran, and no console errors or warnings were logged.

    • Single removals at six depths (R3-6), formerly D3:

      Depth Before After
      70k flow 001122 at −8 001122 at −8
      30k 000353 at −48 000353 at −48
      100k 001675 at −7 001675 at −7
      50k 000727 at −49 000727 at −49
      85k 001376 at −2 001376 at −2
      10k unchanged unchanged

      At dc4cf9f the same cases shifted by +4 to +11 flows.

    • Adding 110 never-seen processes (R3-2/R3-7), formerly D2/D3: flow 001039 stays at −44 px (row 1153 → 1263). Every rAF-sampled frame, including the busy frame, shows 001039 at −44: ["60368 1153:001039:-44","… B","66372 1263:001039:-44","66822 1263:001039:-44"].

    • After scrolling +4,800 px: scrollTop is 71,622, the expected 66,822 + 4,800, so there is no late jump.

    • Later removal at 90k: flow 001468 stays at −14.

    • Bulk "Deselect all matches" and re-add (R3-1): flow 001113 stays at −9 in all frames (rows 1337 → 1227 → 1337).

      • Focus follows its flow (001117) and is not stolen: it stays on the clicked "Deselect all matches" button, or on the body.
    • Deselecting "generated 0002" at 100k (R3-5): flow 001686 stays at −23 in all frames.

    jsdom (zz-qa-r3*.test.tsx): 9/9 ran.

    • P2, adding never-seen processes: flow 001036 stays at −20. Busy reads: 0.
    • P4, rapid successive changes: flow 001076 stays at −20, and focus follows flow 001086 to its new row and column. Busy reads: 0.
    • P5a–d: focus follows the flow, and is not stolen after outside focus, a body press or Tab-away.

    D4, scrolling during an update:

    • jsdom P1 (latency 300 ms, scroll to row 1500 while busy): the view is not snapped back to the old anchor.
    • New Chromium R4-1, under CPU throttle ×20:
      1. Start deep at 70,287 (flow 001122).
      2. Click "Deselect all matches".
      3. While busy, scroll +300 onto loaded rows. The top row is now flow 001127 at −7.
      4. After settling, the top row is still 001127 at −7 (row 1351 → 1241). Frames: ["70287 1346:001122:-8","… B","70587 1351:001127:-7 B","64539 1241:001127:-7","64825 1241:001127:-7"].
    • New jsdom Q2/Q2b: a scroll made during the placeholder phase, and one made during the seek phase onto loaded rows, keep the flow scrolled to.
      • Q2b: 001031 stays at −18 (row 1145 → 1255).
      • Q2: 001080's start stays at −61. Its row became shorter, so 001081 is now at the top, at −9.
      • Busy reads: none.

    O8, anchored flow removed:

    • Chromium R3-3: the flow at the top of the view is removed (a reference flow). The view keeps row 60 at −10, re-anchors on the surviving flow now there (000062), and then holds it while heights correct (3130 → 3429, same flow and offset).
    • jsdom P3b/Q3: when all 12 recorded flows disappear, the view keeps index 40 and then stays stable. The hold cost is noted in O11. Sensible.

    O9, focused column removed while the grid owns focus: handled. In jsdom P5e/P6, DOM focus ends on the single tab stop, the same flow 001088 in the active cell, with one stop.

    • Mutation check (N5 below): with the new focus clause disabled, DOM focus is left on 1312/5, showing flow 001089, a non-stop cell. So the fix is real. No repository test catches its removal (O10).

    New tests fail without the fix.

    • With the dc4cf9f versions of the three grid files in the copy, the new unit tests "adds processes above…", "single removal once heights settle" and "does not undo a scroll…" all fail: 3 failed, 9 passed.

    • Mutations of the new code (each mutant applied in the copy, then reverted):

      Mutant Unit flows-grid.test.tsx e2e flows-grid.spec.ts
      N1: virtualizer size adjustment re-enabled killed (2 tests) –
      N2: no pin after height correction killed –
      N3: hold removed (updating = placeholder) killed –
      N8: no seek page fetching during the hold killed –
      N4: no record() in onScroll survives – (effectively equivalent: pin() re-records on every render)
      N5: focus clause for changed meaning removed (O9) survives survives (2 passed)
      N6: only the first pin considered survives survives
      N7: no re-anchor when every pin is gone (O8) survives survives

    2. Regressions: PASS

    • D1: no sampled Chromium frame showed an empty grid during any selection change. During loads the grid was aria-busy with "Updating the comparison…". The bounded-read, deep paging/cancel, reorder and stripe unit tests pass.
    • AC1–AC6: the repository's flows-grid.spec.ts covers bounds, alignment, the seven fields, heights/stripes, resize/sidebar, keyboard/Tab and the new single-removal and bulk anchoring checks. It passes within the 21/21 run. The R3-4/R3-5 probes repeat the stress cases.
    • Normal scrolling is not fought:
      • Wheel 20 × 400 px: scrollTop is monotonic (84,686 → 92,686).
      • PageDown ×5 / PageUp ×2: offsets 92,191 → 94,597 → 94,018, with focus following and one stop, in view.
      • Ctrl+End, then wheel up into unsummarized rows (R4-2): after six steps of −3,000 px each, the top flow is identical 30 ms after the wheel and after settling.
      • Continuous wheel up (25 × −500): the top row index decreases monotonically (1901 → 1687). scrollTop has two small upward corrections (93,559 → 93,755 and 87,755 → 88,330) during which the top flow stays the same. That is the pin absorbing height corrections above, with no visible content jump.
      • Jump to end, then up 20k: stable.
      • Scrollbar drag: inconclusive. Headless Chromium does not move on a mouse drag of the thumb, even with its position computed (scrollbar width 15). Not claimed.

    3. New risk areas: PASS, with D5

    • Hold termination: the hold ends when an anchor flow is located (P2: 14 row pages), when no pages remain (Q3), or on a row-page error.
    • Reads during the hold: only row pages are read for the new comparison. Busy-time summary and cell reads were 0 in P2, P4 and Q1–Q2b.
    • Hold length when every anchor is absent (O11): with latency 100 ms, the hold read all 18 row pages over 2.5 s before showing the new rows (Q3).
    • State updated during render: setPrevious uses React's previous-render pattern on the same component. It terminates, because the next render has previous === fresh. No React warnings appeared in jsdom, and no console errors or warnings in any Chromium probe.
    • Focus restoration:
      • No loop: in Q5, after a focused-column removal there were 2 focusin events, then none over a further 1.5 s, including a scroll.
      • No focus stealing after outside focus, a body press, Tab-away, sidebar or keyboard deselect, or sign-out (P5b–d, R3-1, R3-4).
    • Error during the hold (D5): the error surfaces correctly. The hold ends, aria-busy clears, and the alert "Flow values could not be loaded. Retry" appears with a working Retry button. After Retry, however, the view is not re-anchored (see D5).

    4. Documentation: PASS

    • services/README.md "View anchoring" (from line 467) and the corrected height note match the behaviour observed: relative pins, 12 recorded flows, the virtualizer's adjustment off, the hold "until an anchor flow is loaded … or no pages remain", re-anchoring when all recorded flows are gone, and focus following the active cell.
    • Minor omission: the README does not say that a row-page error also ends the hold.
    • ADR: none needed. These are implementation choices within the contract, and no PRD or specification deviation was found.

    Defects

    D5 (Low, non-blocking): after a row-page error during the hold, Retry does not restore the anchor.

    • Where: apps/frontend/src/components/comparison/useFlowGrid.ts:116-124. seeking requires !isError, so an error ends the hold, and setPrevious(fresh) at :137 then commits the new comparison.
      • After Retry, row pages are fetched only to the viewport plus ROW_LOOKAHEAD = 25 (:22, :141), so an anchor that moved further down is never loaded.
      • In ComparisonGrid.tsx:253/:267 its pins stay pending, so the view keeps the stale pixel offset.
    • Repro (jsdom probe Q1-3, latency 30 ms):
      1. Select processes 0–109 and scroll to row 1150 (flow 001036 at −20).
      2. Select the other 110 processes, and make the 3rd row page of the new comparison return TEMPORARILY_UNAVAILABLE.
      3. The alert and Retry appear.
      4. Click Retry and wait until idle.
    • Expected: flow 001036 at −20 (row 1260), as without the error.
    • Actual: flow 000925 at −28 (row 1149). The view is 110 flows away, the D2 symptom.
    • Control (Q1-1): when the first page fails, Retry does restore 001036 at row 1260.
    • Impact: only after a transient error. A real backend makes this more likely, because a long hold is many sequential page reads. Mock-only users cannot hit it without fault injection.
    • Suggested direction: engineering's choice. Resume the hold after a retry (keep previous until an anchor is located), or keep fetching while any pin is pending.

    Observations (non-blocking)

    • O10 (Low, test gap): N5 (the O9 focus fix), N6 (the later-pin fallback) and N7 (the O8 re-anchor) survive both the unit and e2e suites.
      • The new D4 unit test asserts the old anchor's offset only if (old), so that check is conditional.
    • O11 (Low): when every recorded flow is removed, the hold reads every row page before showing the new rows (18 pages, about 2.5 s at 100 ms latency here). With a real API and a large comparison this is a long "Updating…" state with stale rows. Engineering noted it as the O8 limit. Consider a page cap or an early stop on sort keys in Phase 2.
    • O12 (Low, also present in earlier rounds): if the first page of a new comparison fails, the grid shows 0 rows with the error and Retry (Q1-1), instead of the previous comparison. Retry recovers correctly.
    • O13 (Low, UX): at scrollTop 0, adding processes whose rows sort above keeps the old first flow in place. The new top rows end up above the viewport (Q4: scrollTop 0 → 104, row 2 at the top). This is consistent with flow anchoring; product may prefer to stay at the top.
    • O5 and O7: unchanged, and accepted as Engineering describes.

    Commands (probes)

    All run in the workspace container, in the copy /tmp/qa23d.

    • npx vitest run src/services/mock/zz-qa-r3.test.tsx src/services/mock/zz-qa-r3b.test.tsx: 9 passed (observational)
    • npx vitest run src/services/mock/zz-qa-r4.test.tsx: Q1, Q3, Q4 and Q5 ran. Q2's second half timed out in the probe's own helper; it was rewritten as Q2b.
    • npx vitest run src/services/mock/zz-qa-r4b.test.tsx: Q1-1, Q1-3 and Q2b, 3 passed (observational)
    • npx playwright test e2e/zz-qa-r3.spec.ts e2e/zz-qa-r3b.spec.ts --project=chromium: 7 passed
    • npx playwright test e2e/zz-qa-r4.spec.ts --project=chromium: 3 passed (R4-1, R4-2, R4-3)
    • Mutation scripts mutate4.sh, mutate5.sh and mutate6.sh: results in the table above; every mutant was reverted and cmp-verified against the checkout.
    • git status --short: empty before and after.

    Next action

    Coordinator: decide whether D5 and the O10 gaps are fixed in #68 or tracked in a linked follow-up issue before merge. Otherwise #23 is ready for maintainer review. QA does not close, label or merge.

  14. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Coordinator: QA round 4 PASS at 3976241 (#23 (comment)).

    Status: ready for maintainer review. PR #68 is stacked on #67 (#22). Merge #67 first; #68 is then retargeted to main.

  15. added 2 commits that reference this issue on Nov 15, 2026
  16. DavidVFitzGerald commented on Nov 15, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Coordinator: QA PASS (round 4, tree of 3976241), required checks passed on head dc1f06e, maintainer merged PR #68. Closing. Follow-up defect tracked in #69.

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    frontendtask

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions