Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
feat(app): freeze table header row and first column (#1809)
Andrew Mikofalvyceae636e36e0
diff --git a/.changeset/frozen-table-headers.md b/.changeset/frozen-table-headers.mdnew file mode 100644index 000000000..909c70c03--- /dev/null+++ b/.changeset/frozen-table-headers.md@@ -0,0 +1,7 @@+---+"@inkeep/open-knowledge": patch+---++Freeze table header row and first column when scrolling++Long tables now keep the top row (column headers) visible at the top of the editor as you scroll past it, and the first column always stays visible during horizontal scrolling.diff --git a/packages/app/package.json b/packages/app/package.jsonindex 69cd8f855..7a3ee6656 100644--- a/packages/app/package.json+++ b/packages/app/package.json@@ -25,7 +25,7 @@"measure:fuzz": "bash scripts/measure-fuzz.sh","measure:stress": "bash scripts/measure-stress.sh","perf:compare": "bash scripts/perf-compare.sh",- "test:e2e": "playwright test tests/stress/ux-interactions.e2e.ts tests/stress/file-tree-create.e2e.ts tests/stress/create-then-rename-editable.e2e.ts tests/stress/find-replace.e2e.ts tests/stress/editor-tabs.e2e.ts tests/stress/crdt-stress.e2e.ts tests/stress/slash-command.e2e.ts tests/stress/paste-fidelity.e2e.ts tests/stress/fr-7a-disconnect-source-mode.e2e.ts tests/stress/docs-open.e2e.ts tests/stress/asset-embed.e2e.ts tests/stress/asset-embed-advanced.e2e.ts tests/stress/asset-click-dispatch.e2e.ts tests/stress/handoff.e2e.ts tests/stress/multi-agent-presence.e2e.ts tests/stress/editor-mode-persistence.e2e.ts tests/stress/sidebar-search-pill.e2e.ts tests/stress/command-palette-semantic.e2e.ts tests/stress/agent-activity-panel.e2e.ts tests/stress/drop-pipeline-auto-open.e2e.ts tests/stress/command-palette-flicker.e2e.ts tests/stress/cm6-list-hanging-indent.e2e.ts tests/stress/ng7-rapid-nav-coherence.e2e.ts tests/stress/init-load-byte-stable.e2e.ts tests/stress/single-file-ephemeral.e2e.ts tests/stress/reveal-on-activate.e2e.ts tests/stress/selection-indicator.e2e.ts tests/stress/new-file-cross-doc-bleed.e2e.ts tests/stress/editor-mode-flip-cross-doc-bleed.e2e.ts tests/stress/editor-area-viewport-resize.e2e.ts tests/stress/qa-sidebar-responsive.e2e.ts tests/stress/prd-6955-reassertion-repro.e2e.ts tests/stress/prd-6955-reassertion-wedge.e2e.ts tests/stress/prd-6914-repro.e2e.ts",+ "test:e2e": "playwright test tests/stress/ux-interactions.e2e.ts tests/stress/file-tree-create.e2e.ts tests/stress/create-then-rename-editable.e2e.ts tests/stress/find-replace.e2e.ts tests/stress/editor-tabs.e2e.ts tests/stress/crdt-stress.e2e.ts tests/stress/slash-command.e2e.ts tests/stress/paste-fidelity.e2e.ts tests/stress/fr-7a-disconnect-source-mode.e2e.ts tests/stress/docs-open.e2e.ts tests/stress/frozen-table-headers.e2e.ts tests/stress/asset-embed.e2e.ts tests/stress/asset-embed-advanced.e2e.ts tests/stress/asset-click-dispatch.e2e.ts tests/stress/handoff.e2e.ts tests/stress/multi-agent-presence.e2e.ts tests/stress/editor-mode-persistence.e2e.ts tests/stress/sidebar-search-pill.e2e.ts tests/stress/command-palette-semantic.e2e.ts tests/stress/agent-activity-panel.e2e.ts tests/stress/drop-pipeline-auto-open.e2e.ts tests/stress/command-palette-flicker.e2e.ts tests/stress/cm6-list-hanging-indent.e2e.ts tests/stress/ng7-rapid-nav-coherence.e2e.ts tests/stress/init-load-byte-stable.e2e.ts tests/stress/single-file-ephemeral.e2e.ts tests/stress/reveal-on-activate.e2e.ts tests/stress/selection-indicator.e2e.ts tests/stress/new-file-cross-doc-bleed.e2e.ts tests/stress/editor-mode-flip-cross-doc-bleed.e2e.ts tests/stress/editor-area-viewport-resize.e2e.ts tests/stress/qa-sidebar-responsive.e2e.ts tests/stress/prd-6955-reassertion-repro.e2e.ts tests/stress/prd-6955-reassertion-wedge.e2e.ts tests/stress/prd-6914-repro.e2e.ts","test:e2e:install-browsers": "playwright install chromium webkit firefox","test:visual": "playwright test --config playwright.visual.config.ts","test:visual:update": "playwright test --config playwright.visual.config.ts --update-snapshots",diff --git a/packages/app/src/editor/TiptapEditor.tsx b/packages/app/src/editor/TiptapEditor.tsxindex 05487e2fb..4b05acf01 100644--- a/packages/app/src/editor/TiptapEditor.tsx+++ b/packages/app/src/editor/TiptapEditor.tsx@@ -41,6 +41,7 @@ import {import { useDocumentContext } from './DocumentContext';import { setEditorDocName } from './extensions/doc-context.ts';import { setEditorSourceMode } from './extensions/editor-mode-context.ts';+import { FrozenTableHeaders } from './extensions/frozen-table-headers.ts';import { sharedExtensions } from './extensions/shared.ts';import { uploadDecorationPlugin } from './image-upload/index.ts';import { getMountId } from './mount-id-registry';@@ -201,6 +202,7 @@ export function buildExtensionList(args: BuildEditorOptionsArgs): AnyExtension[]},}),...guard,+ FrozenTableHeaders,];}diff --git a/packages/app/src/editor/extensions/frozen-table-headers.test.ts b/packages/app/src/editor/extensions/frozen-table-headers.test.tsnew file mode 100644index 000000000..a73ae9985--- /dev/null+++ b/packages/app/src/editor/extensions/frozen-table-headers.test.ts@@ -0,0 +1,67 @@+import { describe, expect, it } from 'bun:test';+import { buildShiftKeyframes, computeFreezeRange } from './frozen-table-headers.ts';++describe('computeFreezeRange (scroll-driven animation ranges)', () => {+ it('returns null for a single-row table (header is the whole table)', () => {+ expect(computeFreezeRange(0, 0, 100, 40, 40)).toBeNull();+ });++ it('places startOffset where the table top meets the toolbar boundary', () => {+ const range = computeFreezeRange(0, 0, 156, 1000, 40);+ expect(range).toEqual({ startOffset: 100, endOffset: 1060, maxShift: 960 });+ });++ it('is invariant to the scroll position at which geometry is measured', () => {+ const atTop = computeFreezeRange(0, 0, 156, 1000, 40);+ const scrolled = computeFreezeRange(300, 0, 156 - 300, 1000, 40);+ expect(scrolled).toEqual(atTop);+ });++ it('agrees with the per-frame shift formula across the whole scroll range', () => {+ const containerTop = 0;+ const tableDocTop = 156; // table top in document space (scrollTop 0 measurement)+ const tableHeight = 1000;+ const headerHeight = 40;+ const range = computeFreezeRange(0, containerTop, tableDocTop, tableHeight, headerHeight);+ if (!range) throw new Error('expected a range');+ for (const scrollTop of [0, 50, 100, 101, 500, 1060, 1500]) {+ const animShift = Math.max(0, Math.min(scrollTop - range.startOffset, range.maxShift));+ const tableTop = tableDocTop - scrollTop;+ const expected = Math.max(+ 0,+ Math.min(containerTop + 56 - tableTop, tableHeight - headerHeight),+ );+ expect(animShift).toBe(expected);+ }+ });++ it('yields a negative startOffset for a table starting under the toolbar', () => {+ const range = computeFreezeRange(0, 0, 30, 400, 40);+ expect(range?.startOffset).toBe(-26);+ });+});++describe('buildShiftKeyframes', () => {+ const ty = (k: Keyframe): number =>+ Number(/translateY\((-?[\d.]+)px\)/.exec(String(k.transform))?.[1]);++ it('emits plateau-ramp-plateau keyframes for a mid-document table', () => {+ const frames = buildShiftKeyframes({ startOffset: 100, endOffset: 1000, maxShift: 900 }, 2000);+ expect(frames.map((f) => f.offset)).toEqual([0, 0.05, 0.5, 1]);+ expect(frames.map(ty)).toEqual([0, 0, 900, 900]);+ });++ it('clamps a negative startOffset (table already under the toolbar at scroll 0)', () => {+ const frames = buildShiftKeyframes({ startOffset: -50, endOffset: 150, maxShift: 200 }, 1000);+ expect(frames[0]?.offset).toBe(0);+ expect(ty(frames[0] as Keyframe)).toBe(50);+ expect(frames.map((f) => f.offset)).toEqual([0, 0.15, 1]);+ expect(frames.map(ty)).toEqual([50, 200, 200]);+ });++ it('keeps offsets non-decreasing and within [0, 1] when the freeze window exceeds scroll range', () => {+ const frames = buildShiftKeyframes({ startOffset: 500, endOffset: 3000, maxShift: 2500 }, 1000);+ expect(frames.map((f) => f.offset)).toEqual([0, 0.5, 1]);+ expect(frames.map(ty)).toEqual([0, 0, 500]);+ });+});diff --git a/packages/app/src/editor/extensions/frozen-table-headers.ts b/packages/app/src/editor/extensions/frozen-table-headers.tsnew file mode 100644index 000000000..4eb3a3b67--- /dev/null+++ b/packages/app/src/editor/extensions/frozen-table-headers.ts@@ -0,0 +1,356 @@+import { Extension } from '@tiptap/core';+import { Plugin, PluginKey } from 'prosemirror-state';++const TOOLBAR_HEIGHT = 56;++const FROZEN_SHADOW = '0 2px 4px rgba(0, 0, 0, 0.08)';++const DRIFT_RECOMPUTE_MS = 150;++interface ScrollTimelineOptions {+ source: Element | null;+ axis?: 'block' | 'inline' | 'x' | 'y';+}+type ScrollTimelineConstructor = new (options: ScrollTimelineOptions) => AnimationTimeline;++const ScrollTimelineImpl = (globalThis as { ScrollTimeline?: ScrollTimelineConstructor })+ .ScrollTimeline;++interface ScrollDrivenAnimationOptions extends KeyframeAnimationOptions {+ timeline?: AnimationTimeline | null;+}++export interface FreezeRange {+ startOffset: number;+ endOffset: number;+ maxShift: number;+}++export function computeFreezeRange(+ scrollTop: number,+ containerTop: number,+ tableTop: number,+ tableHeight: number,+ headerHeight: number,+): FreezeRange | null {+ const maxShift = tableHeight - headerHeight;+ if (maxShift <= 0) return null;+ const startOffset = scrollTop + tableTop - (containerTop + TOOLBAR_HEIGHT);+ return { startOffset, endOffset: startOffset + maxShift, maxShift };+}++interface AppliedFreeze {+ key: string;+ animations: Animation[];+}++const appliedFreezes = new WeakMap<HTMLTableCellElement, AppliedFreeze>();++function cancelFreeze(cell: HTMLTableCellElement): void {+ const prev = appliedFreezes.get(cell);+ if (!prev) return;+ for (const animation of prev.animations) animation.cancel();+ appliedFreezes.delete(cell);+}++function resetHeaderCells(firstRow: HTMLTableRowElement): void {+ for (const cell of Array.from(firstRow.cells)) {+ cancelFreeze(cell);+ }+}++const cellZIndex = (cell: HTMLTableCellElement): string => (cell.cellIndex === 0 ? '3' : '2');++export function buildShiftKeyframes(range: FreezeRange, scrollMax: number): Keyframe[] {+ return buildFreezeKeyframes(range, scrollMax, (shift) => ({+ transform: `translateY(${shift}px)`,+ }));+}++function buildFreezeKeyframes(+ range: FreezeRange,+ scrollMax: number,+ toProps: (shiftPx: number) => Omit<Keyframe, 'offset'>,+): Keyframe[] {+ if (!(scrollMax > 0)) {+ return [+ { offset: 0, ...toProps(0) },+ { offset: 1, ...toProps(0) },+ ];+ }+ const shiftAt = (scroll: number): number =>+ Math.max(0, Math.min(scroll - range.startOffset, range.maxShift));+ const breakpoints = Array.from(+ new Set(+ [0, range.startOffset / scrollMax, range.endOffset / scrollMax, 1].map((o) =>+ Math.max(0, Math.min(o, 1)),+ ),+ ),+ ).sort((a, b) => a - b);+ return breakpoints.map((offset) => ({+ offset,+ ...toProps(shiftAt(offset * scrollMax)),+ }));+}++/** Keyframes that flip between two constant states within 1px of scroll at+ * the freeze boundary. Constant on both sides, so main-thread updating of+ * these (non-composited) properties cannot lag visibly during scroll. */+function buildBoundaryFlipKeyframes(+ range: FreezeRange,+ scrollMax: number,+ pre: Omit<Keyframe, 'offset'>,+ post: Omit<Keyframe, 'offset'>,+): Keyframe[] {+ if (!(scrollMax > 0)) {+ return [+ { ...pre, offset: 0 },+ { ...pre, offset: 1 },+ ];+ }+ const flip = range.startOffset / scrollMax;+ if (flip <= 0)+ return [+ { ...post, offset: 0 },+ { ...post, offset: 1 },+ ];+ if (flip >= 1)+ return [+ { ...pre, offset: 0 },+ { ...pre, offset: 1 },+ ];+ const flipEnd = Math.min(flip + 1 / scrollMax, 1);+ return [+ { ...pre, offset: 0 },+ { ...pre, offset: flip },+ { ...post, offset: flipEnd },+ { ...post, offset: 1 },+ ];+}++function buildChromeKeyframes(range: FreezeRange, scrollMax: number, zIndex: string): Keyframe[] {+ return buildBoundaryFlipKeyframes(+ range,+ scrollMax,+ { zIndex: 'auto', boxShadow: 'none' },+ { zIndex, boxShadow: FROZEN_SHADOW },+ );+}++/** Occluder reveal: the static ::before block above each header cell (see+ * globals.css) becomes opaque while frozen. It is painted into the cell's+ * composited layer, so it tracks the transform pixel-for-pixel — unlike a+ * scroll-driven clip-path on the wrapper, which updates off the compositor+ * and can trail (or, across rebuild cycles, desync from) the header. */+function buildOccluderKeyframes(range: FreezeRange, scrollMax: number): Keyframe[] {+ return buildBoundaryFlipKeyframes(range, scrollMax, { opacity: '0' }, { opacity: '1' });+}++function applyScrollDrivenFreeze(+ cell: HTMLTableCellElement,+ timeline: AnimationTimeline,+ range: FreezeRange,+ scrollMax: number,+): void {+ const zIndex = cellZIndex(cell);+ const key = `sd|${range.startOffset}|${range.maxShift}|${scrollMax}|${zIndex}`;+ const prev = appliedFreezes.get(cell);+ if (prev?.key === key) return;+ if (prev) for (const animation of prev.animations) animation.cancel();++ const base: ScrollDrivenAnimationOptions = { timeline, fill: 'both', easing: 'linear' };+ const transformAnimation = cell.animate(buildShiftKeyframes(range, scrollMax), base);+ const chromeAnimation = cell.animate(buildChromeKeyframes(range, scrollMax, zIndex), base);+ const occluderAnimation = cell.animate(buildOccluderKeyframes(range, scrollMax), {+ ...base,+ pseudoElement: '::before',+ });+ appliedFreezes.set(cell, {+ key,+ animations: [transformAnimation, chromeAnimation, occluderAnimation],+ });+}++function applyInstantFreeze(cell: HTMLTableCellElement, shift: number): void {+ const zIndex = cellZIndex(cell);+ const key = `in|${shift}|${zIndex}`;+ const prev = appliedFreezes.get(cell);+ if (prev?.key === key) return;+ if (prev) for (const animation of prev.animations) animation.cancel();+ const animation = cell.animate(+ [{ transform: `translateY(${shift}px)`, zIndex, boxShadow: FROZEN_SHADOW }],+ { duration: 0, fill: 'forwards' },+ );+ const occluderAnimation = cell.animate([{ opacity: '1' }], {+ duration: 0,+ fill: 'forwards',+ pseudoElement: '::before',+ });+ appliedFreezes.set(cell, { key, animations: [animation, occluderAnimation] });+}++function computeAndApplyFrozenHeaders(+ scrollEl: HTMLElement,+ editorDom: HTMLElement,+ timeline: AnimationTimeline | null,+ onTableWrapper?: (wrapper: HTMLElement) => void,+): void {+ const containerTop = scrollEl.getBoundingClientRect().top;+ const scrollTop = scrollEl.scrollTop;+ const scrollMax = scrollEl.scrollHeight - scrollEl.clientHeight;+ const wrappers = editorDom.querySelectorAll<HTMLElement>('.tableWrapper');+ for (const wrapper of wrappers) {+ onTableWrapper?.(wrapper);+ const table = wrapper.querySelector('table');+ if (!table) continue;+ const firstRow = table.querySelector('tbody')?.rows[0];+ if (!firstRow || !Array.from(firstRow.cells).some((c) => c.tagName === 'TH')) {+ continue;+ }++ const tableRect = table.getBoundingClientRect();+ const headerRect = firstRow.getBoundingClientRect();+ const range = computeFreezeRange(+ scrollTop,+ containerTop,+ tableRect.top,+ tableRect.height,+ headerRect.height,+ );++ if (!range) {+ resetHeaderCells(firstRow);+ continue;+ }++ if (timeline) {+ if (scrollMax <= 0) {+ resetHeaderCells(firstRow);+ continue;+ }+ for (const cell of Array.from(firstRow.cells) as HTMLTableCellElement[]) {+ applyScrollDrivenFreeze(cell, timeline, range, scrollMax);+ }+ continue;+ }++ const shift = Math.max(0, Math.min(scrollTop - range.startOffset, range.maxShift));+ if (shift <= 0 || tableRect.bottom <= containerTop + TOOLBAR_HEIGHT) {+ resetHeaderCells(firstRow);+ continue;+ }+ for (const cell of Array.from(firstRow.cells) as HTMLTableCellElement[]) {+ applyInstantFreeze(cell, shift);+ }+ }+}++export const FrozenTableHeaders = Extension.create({+ name: 'frozenTableHeaders',++ addProseMirrorPlugins() {+ return [+ new Plugin({+ key: new PluginKey('frozenTableHeaders'),++ view(editorView) {+ let scrollEl: HTMLElement | null = null;+ let timeline: AnimationTimeline | null = null;+ let rafId: number | null = null;+ let driftTimer: ReturnType<typeof setTimeout> | null = null;+ let resizeObserver: ResizeObserver | null = null;+ let destroyed = false;+ const cvWired = new Set<HTMLElement>();++ const run = (): void => {+ if (destroyed || !scrollEl) return;+ computeAndApplyFrozenHeaders(+ scrollEl,+ editorView.dom as HTMLElement,+ timeline,+ wireChunkVisibility,+ );+ };++ const scheduleRun = (): void => {+ if (rafId != null) return;+ rafId = requestAnimationFrame(() => {+ rafId = null;+ run();+ });+ };++ function wireChunkVisibility(wrapper: HTMLElement): void {+ if (cvWired.has(wrapper)) return;+ cvWired.add(wrapper);+ wrapper.addEventListener('contentvisibilityautostatechange', scheduleRun);+ }++ const onScroll = (): void => {+ if (timeline) {+ if (driftTimer == null) scheduleRun();+ if (driftTimer != null) clearTimeout(driftTimer);+ driftTimer = setTimeout(() => {+ driftTimer = null;+ run();+ }, DRIFT_RECOMPUTE_MS);+ return;+ }+ scheduleRun();+ };++ requestAnimationFrame(() => {+ if (destroyed) return;+ scrollEl = (editorView.dom as HTMLElement).closest<HTMLElement>(+ '[data-testid="editor-scroll-container"]',+ );+ if (!scrollEl && import.meta.env.DEV) {+ console.warn(+ '[frozen-table-headers] editor-scroll-container not found; table headers will not freeze',+ );+ }+ if (scrollEl && ScrollTimelineImpl) {+ try {+ timeline = new ScrollTimelineImpl({ source: scrollEl, axis: 'block' });+ } catch {+ timeline = null;+ }+ }+ scrollEl?.addEventListener('scroll', onScroll, { passive: true });+ if (scrollEl && typeof ResizeObserver !== 'undefined') {+ resizeObserver = new ResizeObserver(scheduleRun);+ resizeObserver.observe(scrollEl);+ resizeObserver.observe(editorView.dom as HTMLElement);+ }+ run();+ });++ return {+ update(view, prevState) {+ if (prevState.doc.eq(view.state.doc)) return;+ run();+ },+ destroy() {+ destroyed = true;+ scrollEl?.removeEventListener('scroll', onScroll);+ resizeObserver?.disconnect();+ if (rafId != null) cancelAnimationFrame(rafId);+ if (driftTimer != null) clearTimeout(driftTimer);+ for (const wrapper of cvWired) {+ wrapper.removeEventListener('contentvisibilityautostatechange', scheduleRun);+ }+ cvWired.clear();+ for (const row of (+ editorView.dom as HTMLElement+ ).querySelectorAll<HTMLTableRowElement>(+ '.tableWrapper > table > tbody > tr:first-child',+ )) {+ resetHeaderCells(row);+ }+ },+ };+ },+ }),+ ];+ },+});diff --git a/packages/app/src/globals.css b/packages/app/src/globals.cssindex 6cec6a855..210bb6cc6 100644--- a/packages/app/src/globals.css+++ b/packages/app/src/globals.css@@ -1562,7 +1562,11 @@border-collapse: collapse;width: 100%;table-layout: fixed;- overflow: hidden;+ /* `clip`, not `hidden`: overflow:hidden makes the table itself a scroll+ container, which would capture the first-column `position: sticky` cells+ below (sticky constrains to the nearest scrollport — the cells must reach+ .tableWrapper's). clip clips identically without creating a scrollport. */+ overflow: clip;}.ProseMirror th,@@ -1611,6 +1615,63 @@cursor: col-resize;}+/* First-column sticky freeze (horizontal scroll). Works because .tableWrapper+ is the CSS scroll container for the x-axis. */+.ProseMirror .tableWrapper > table > tbody > tr > td:first-child,+.ProseMirror .tableWrapper > table > tbody > tr > th:first-child {+ position: sticky;+ left: 0;+ z-index: 1;+}++.ProseMirror .tableWrapper > table > tbody > tr > td:first-child {+ background-color: var(--background);+}++/* Corner cell (first column + header row) must clear both frozen row layer and+ sticky column layer when both are active simultaneously. */+.ProseMirror .tableWrapper > table > tbody > tr > th:first-child {+ background-color: var(--color-gray-50);+ z-index: 3;+}++/* Occluder above the frozen header (frozen-table-headers.ts): scrolled-past+ rows must not show in the translucent toolbar-fade slot above the pinned+ header. An opaque block riding each header cell's composited layer tracks+ the frozen header's transform pixel-for-pixel — unlike a scroll-driven+ clip-path on the wrapper, which updates on the main thread and trails the+ compositor during scroll. Hidden until the extension's scroll-driven+ opacity flip reveals it while frozen. The wrapper's own overflow clips the+ block at the table's top edge, so it never covers content above the table.+ ±1px horizontal overlap closes the seams over collapsed cell borders.+ height must stay >= TOOLBAR_HEIGHT (56px, frozen-table-headers.ts) so the+ block spans the whole toolbar-fade slot; 80px adds margin. */+.ProseMirror .tableWrapper > table > tbody > tr:first-child > th::before {+ content: "";+ position: absolute;+ left: -1px;+ right: -1px;+ bottom: 100%;+ height: 80px;+ background: var(--background);+ opacity: 0;+ pointer-events: none;+}++/* Print: neutralize the freeze. The WAAPI fill animations hold transform /+ occluder opacity at the on-screen scroll position, which would print the+ header mid-table; !important author declarations override animation+ effects in the cascade, so these win over the fills. */+@media print {+ .ProseMirror .tableWrapper > table > tbody > tr:first-child > th {+ transform: none;+ box-shadow: none;+ }+ .ProseMirror .tableWrapper > table > tbody > tr:first-child > th::before {+ opacity: 0;+ }+}+.ProseMirror p.is-empty::before {content: attr(data-placeholder);pointer-events: none;@@ -4472,6 +4533,10 @@ html.electron-mode [data-slot="sidebar-inner"] {background: var(--color-gray-900);}+.dark .ProseMirror .tableWrapper > table > tbody > tr > th:first-child {+ background: var(--color-gray-900);+}+/* Dark overrides — agent flash keyframes with boosted alpha for dark canvas */@keyframes agent-flash-dark {0% {diff --git a/packages/app/tests/stress/frozen-table-headers.e2e.ts b/packages/app/tests/stress/frozen-table-headers.e2e.tsnew file mode 100644index 000000000..4771f13ea--- /dev/null+++ b/packages/app/tests/stress/frozen-table-headers.e2e.ts@@ -0,0 +1,559 @@+import { expect, test, waitForActiveProviderSynced } from './_helpers';++const LONG_TABLE_MARKDOWN = `# Metric Tracker++| Metric | Count | Revenue | Growth |+|--------|-------|---------|--------|+| Alpha | 100 | 1250 | 42.0% |+| Beta | 107 | 1293 | 44.0% |+| Gamma | 114 | 1336 | 46.0% |+| Delta | 121 | 1379 | 48.0% |+| Epsilon | 128 | 1422 | 50.0% |+| Zeta | 135 | 1465 | 52.0% |+| Eta | 142 | 1508 | 54.0% |+| Theta | 149 | 1551 | 56.0% |+| Iota | 156 | 1594 | 58.0% |+| Kappa | 163 | 1637 | 60.0% |+| Lambda | 170 | 1680 | 62.0% |+| Mu | 177 | 1723 | 64.0% |+| Nu | 184 | 1766 | 66.0% |+| Xi | 191 | 1809 | 68.0% |+| Omicron | 198 | 1852 | 70.0% |+| Pi | 205 | 1895 | 72.0% |+| Rho | 212 | 1938 | 74.0% |+| Sigma | 219 | 1981 | 76.0% |+| Tau | 226 | 2024 | 78.0% |+| Upsilon | 233 | 2067 | 80.0% |+| Phi | 240 | 2110 | 82.0% |+| Chi | 247 | 2153 | 84.0% |+| Psi | 254 | 2196 | 86.0% |+| Omega | 261 | 2239 | 88.0% |+| Alpha-2 | 268 | 2282 | 90.0% |++## Notes++${Array.from({ length: 30 }, (_, i) => `Paragraph ${i + 1} of trailing prose so the table can scroll fully out of view.`).join('\n\n')}+`;++const WIDE_TABLE_MARKDOWN = `# Monthly KPIs++| Metric | January | February | March | April | May | Total |+|--------|---------|----------|-------|-------|-----|-------|+| Alpha | 100 | 105 | 110 | 115 | 120 | 550 |+| Beta | 112 | 117 | 122 | 127 | 132 | 610 |+| Gamma | 124 | 129 | 134 | 139 | 144 | 670 |+| Delta | 136 | 141 | 146 | 151 | 156 | 730 |+| Epsilon | 148 | 153 | 158 | 163 | 168 | 790 |+| Zeta | 160 | 165 | 170 | 175 | 180 | 850 |+| Eta | 172 | 177 | 182 | 187 | 192 | 910 |+| Theta | 184 | 189 | 194 | 199 | 204 | 970 |+`;++const VIRTUALIZED_TABLE_MARKDOWN = `# Long Report++${Array.from({ length: 40 }, (_, i) => `Intro paragraph ${i + 1} above the table.`).join('\n\n')}++## Data++| Metric | One | Two | Three | Four | Five |+|--------|-----|-----|-------|------|------|+${Array.from({ length: 200 }, (_, i) => `| Row-${i + 1} | ${i} | ${i * 2} | ${i * 3} | ${i * 4} | ${i * 5} |`).join('\n')}++## Appendix++${Array.from({ length: 40 }, (_, i) => `Closing paragraph ${i + 1} below the table.`).join('\n\n')}+`;++const PROSE_ABOVE_MARKDOWN = `# Spec Doc++## Background++${Array.from({ length: 28 }, (_, i) => `Background paragraph ${i + 1} with enough words to take a realistic amount of vertical space in the document flow.`).join('\n\n')}++## Risk Table++| # | Risk | Likelihood | Impact | Mitigation |+|---|------|------------|--------|------------|+${Array.from({ length: 12 }, (_, i) => `| R${i + 1} | Agent markdown write path ${i + 1} has higher latency than direct construction in the editor | LOW | LOW | Agent writes are at section level, parse and update adds only a few milliseconds which is negligible at realistic intervals ${i + 1} |`).join('\n')}++## Appendix++${Array.from({ length: 28 }, (_, i) => `Appendix paragraph ${i + 1} below the table so the document keeps scrolling.`).join('\n\n')}+`;++const SCROLL_SELECTOR = '[data-testid="editor-scroll-container"]';+const TOOLBAR_HEIGHT = 56;++/** Decode a screenshot in-browser and verify the band just above the pinned+ * header is visually flat (no text glyphs). Pixel-level evidence — computed+ * style cannot see a compositor-side desync, a screenshot can. */+async function scanSlotPixels(page: Parameters<typeof test>[1]['page']): Promise<number> {+ const band = await page.evaluate(() => {+ const table = document.querySelector('.ProseMirror .tableWrapper > table') as HTMLElement;+ const cell = (table.querySelector('tbody tr') as HTMLTableRowElement).cells[0];+ const r = table.getBoundingClientRect();+ return {+ headerTop: cell.getBoundingClientRect().top,+ left: r.left + 4,+ width: Math.min(r.width - 8, 800),+ viewportWidth: window.innerWidth,+ };+ });+ const png = (await page.screenshot()).toString('base64');+ return page.evaluate(+ async ({ png, band }) => {+ const img = new Image();+ img.src = `data:image/png;base64,${png}`;+ await img.decode();+ const scale = img.naturalWidth / band.viewportWidth;+ const c = document.createElement('canvas');+ c.width = img.naturalWidth;+ c.height = img.naturalHeight;+ const ctx = c.getContext('2d') as CanvasRenderingContext2D;+ ctx.drawImage(img, 0, 0);+ let maxStd = 0;+ for (let y = band.headerTop - 12; y <= band.headerTop - 2; y++) {+ const d = ctx.getImageData(+ Math.round(band.left * scale),+ Math.round(y * scale),+ Math.round(band.width * scale),+ 1,+ ).data;+ const lums: number[] = [];+ for (let i = 0; i < d.length; i += 4) lums.push(d[i] + d[i + 1] + d[i + 2]);+ const mean = lums.reduce((a, b) => a + b, 0) / lums.length;+ const std = Math.sqrt(lums.reduce((a, b) => a + (b - mean) ** 2, 0) / lums.length);+ maxStd = Math.max(maxStd, std);+ }+ return maxStd;+ },+ { png, band },+ );+}++test.setTimeout(60_000);++const twoFrames = (page: Parameters<typeof test>[1]['page']) =>+ page.evaluate(+ () => new Promise<void>((r) => requestAnimationFrame(() => requestAnimationFrame(r))),+ );++async function waitForQuiescence(+ page: Parameters<typeof test>[1]['page'],+ selector: string,+): Promise<void> {+ await page.evaluate(() => {+ const w = window as unknown as { __okPrevH?: number; __okStable?: number };+ w.__okPrevH = undefined;+ w.__okStable = 0;+ });+ await page.waitForFunction(+ (sel) => {+ const el = document.querySelector(sel) as HTMLElement | null;+ if (!el) return false;+ const w = window as unknown as { __okPrevH?: number; __okStable?: number };+ const h = el.scrollHeight;+ if (w.__okPrevH === h) {+ w.__okStable = (w.__okStable ?? 0) + 1;+ } else {+ w.__okStable = 0;+ w.__okPrevH = h;+ }+ return (w.__okStable ?? 0) >= 4;+ },+ selector,+ { timeout: 20_000, polling: 120 },+ );+}++/** Drive a real vertical scroll and let the extension respond. Returns the+ * computed shift (animations change computed style, not the style attribute),+ * the header's pin error vs. the expected toolbar boundary, and — for the+ * scroll-driven path — the shift error read SYNCHRONOUSLY after setting+ * scrollTop, before any rAF. A scroll-listener implementation cannot pass+ * that read (it trails the scroll by a frame — the visible "shake");+ * a ScrollTimeline animation is already correct at style-resolution time. */+async function scrollAndReadFreeze(+ page: Parameters<typeof test>[1]['page'],+ top: number,+): Promise<{+ frozen: boolean;+ shiftPx: number;+ pinErrorPx: number;+ syncShiftErrorPx: number | null;+}> {+ const settled = await page.evaluate(+ ({ sel, top, toolbarHeight }) =>+ new Promise<{ shiftPx: number; pinErrorPx: number }>((resolve) => {+ const scrollEl = document.querySelector(sel) as HTMLElement | null;+ scrollEl?.scrollTo({ top, behavior: 'instant' as ScrollBehavior });+ const started = performance.now();+ const tick = (): void => {+ const firstRow = document+ .querySelector('.ProseMirror .tableWrapper > table > tbody')+ ?.querySelector('tr') as HTMLTableRowElement | null;+ const cell = firstRow?.cells[0];+ if (!scrollEl || !cell) {+ resolve({ shiftPx: Number.NaN, pinErrorPx: Number.NaN });+ return;+ }+ const t = getComputedStyle(cell).transform;+ const shiftPx = t === 'none' ? 0 : new DOMMatrixReadOnly(t).m42;+ const expectedTop = scrollEl.getBoundingClientRect().top + toolbarHeight;+ const pinErrorPx = Math.abs(cell.getBoundingClientRect().top - expectedTop);+ if (pinErrorPx < 2 || performance.now() - started > 5_000) {+ resolve({ shiftPx, pinErrorPx });+ return;+ }+ requestAnimationFrame(tick);+ };+ requestAnimationFrame(tick);+ }),+ { sel: SCROLL_SELECTOR, top, toolbarHeight: TOOLBAR_HEIGHT },+ );++ let syncShiftErrorPx = Number.POSITIVE_INFINITY;+ for (let attempt = 0; attempt < 3 && !(syncShiftErrorPx < 1.5); attempt++) {+ syncShiftErrorPx = await page.evaluate(+ ({ sel, step }) =>+ new Promise<number>((resolve) => {+ const scrollEl = document.querySelector(sel) as HTMLElement | null;+ const cell = (+ document.querySelector(+ '.ProseMirror .tableWrapper > table > tbody tr',+ ) as HTMLTableRowElement | null+ )?.cells[0];+ if (!scrollEl || !cell) {+ resolve(Number.NaN);+ return;+ }+ const read = (): number => {+ const t = getComputedStyle(cell).transform;+ return t === 'none' ? 0 : new DOMMatrixReadOnly(t).m42;+ };+ const beforeShift = read();+ const beforeTop = scrollEl.scrollTop;+ scrollEl.scrollTo({ top: beforeTop + step, behavior: 'instant' as ScrollBehavior });+ requestAnimationFrame(() => {+ const scrolled = scrollEl.scrollTop - beforeTop;+ resolve(Math.abs(read() - beforeShift - scrolled));+ });+ }),+ { sel: SCROLL_SELECTOR, step: 40 },+ );+ }++ const final = await page.evaluate(+ ({ sel, toolbarHeight }) =>+ new Promise<{ shiftPx: number; pinErrorPx: number }>((resolve) => {+ const scrollEl = document.querySelector(sel) as HTMLElement | null;+ const started = performance.now();+ const tick = (): void => {+ const firstRow = document+ .querySelector('.ProseMirror .tableWrapper > table > tbody')+ ?.querySelector('tr') as HTMLTableRowElement | null;+ const cell = firstRow?.cells[0];+ if (!scrollEl || !cell) {+ resolve({ shiftPx: Number.NaN, pinErrorPx: Number.NaN });+ return;+ }+ const t = getComputedStyle(cell).transform;+ const shiftPx = t === 'none' ? 0 : new DOMMatrixReadOnly(t).m42;+ const expectedTop = scrollEl.getBoundingClientRect().top + toolbarHeight;+ const pinErrorPx = Math.abs(cell.getBoundingClientRect().top - expectedTop);+ if (pinErrorPx < 2 || performance.now() - started > 5_000) {+ resolve({ shiftPx, pinErrorPx });+ return;+ }+ requestAnimationFrame(tick);+ };+ requestAnimationFrame(tick);+ }),+ { sel: SCROLL_SELECTOR, toolbarHeight: TOOLBAR_HEIGHT },+ );++ return {+ frozen: final.shiftPx > 0.5,+ shiftPx: final.shiftPx,+ pinErrorPx: Math.max(settled.pinErrorPx, final.pinErrorPx),+ syncShiftErrorPx,+ };+}++test('no freeze before the table reaches the toolbar', async ({+ page,+ api,+ workerServer,+}, testInfo) => {+ await api.seedDocs([{ name: 'frozen-hdr-long-1', markdown: LONG_TABLE_MARKDOWN }]);+ await page.goto(`${workerServer.baseURL}/#/frozen-hdr-long-1`);+ await waitForActiveProviderSynced(page);+ await page.locator('table').first().waitFor({ state: 'visible' });+ await waitForQuiescence(page, SCROLL_SELECTOR);+ await twoFrames(page);+ const shiftPx = await page.evaluate(() => {+ const cell = document.querySelector('.ProseMirror .tableWrapper > table > tbody tr > th');+ if (!cell) return Number.NaN;+ const t = getComputedStyle(cell).transform;+ return t === 'none' ? 0 : new DOMMatrixReadOnly(t).m42;+ });+ expect(shiftPx).toBe(0);+ const occluderOpacity = await page.evaluate(() => {+ const cell = document.querySelector('.ProseMirror .tableWrapper > table > tbody tr > th');+ return cell ? getComputedStyle(cell, '::before').opacity : '';+ });+ expect(occluderOpacity).toBe('0');+ await page.screenshot({ path: testInfo.outputPath('unscrolled.png') });+});++test('header row pins below the toolbar on mid-table scroll', async ({+ page,+ api,+ workerServer,+}, testInfo) => {+ await api.seedDocs([{ name: 'frozen-hdr-long-2', markdown: LONG_TABLE_MARKDOWN }]);+ await page.goto(`${workerServer.baseURL}/#/frozen-hdr-long-2`);+ await waitForActiveProviderSynced(page);+ await page.locator('table').first().waitFor({ state: 'visible' });+ await waitForQuiescence(page, SCROLL_SELECTOR);+ const state = await scrollAndReadFreeze(page, 260);+ expect(state.frozen).toBe(true);+ expect(state.pinErrorPx).toBeLessThan(2);+ if (state.syncShiftErrorPx !== null) expect(state.syncShiftErrorPx).toBeLessThan(1.5);+ const occluder = await page.evaluate(() => {+ const cell = (+ document.querySelector('.ProseMirror .tableWrapper > table > tbody tr') as HTMLTableRowElement+ ).cells[0];+ const s = getComputedStyle(cell, '::before');+ return { opacity: s.opacity, height: Number.parseFloat(s.height) };+ });+ expect(occluder.opacity).toBe('1');+ expect(occluder.height).toBeGreaterThanOrEqual(56);+ expect(await scanSlotPixels(page)).toBeLessThan(10);+ await page.screenshot({ path: testInfo.outputPath('frozen-mid.png') });+});++test('header row stays pinned on deep scroll and releases past the table', async ({+ page,+ api,+ workerServer,+}, testInfo) => {+ await api.seedDocs([{ name: 'frozen-hdr-long-3', markdown: LONG_TABLE_MARKDOWN }]);+ await page.goto(`${workerServer.baseURL}/#/frozen-hdr-long-3`);+ await waitForActiveProviderSynced(page);+ await page.locator('table').first().waitFor({ state: 'visible' });+ await waitForQuiescence(page, SCROLL_SELECTOR);+ const state = await scrollAndReadFreeze(page, 620);+ expect(state.frozen).toBe(true);+ expect(state.pinErrorPx).toBeLessThan(2);+ if (state.syncShiftErrorPx !== null) expect(state.syncShiftErrorPx).toBeLessThan(1.5);+ await page.screenshot({ path: testInfo.outputPath('frozen-deep.png') });++ await page.evaluate((sel) => {+ const el = document.querySelector(sel) as HTMLElement | null;+ el?.scrollTo({ top: 5_000, behavior: 'instant' as ScrollBehavior });+ }, SCROLL_SELECTOR);+ await page.waitForFunction(+ () => {+ const table = document.querySelector('.ProseMirror .tableWrapper > table');+ const firstRow = table?.querySelector('tbody tr') as HTMLTableRowElement | null;+ const cell = firstRow?.cells[0];+ if (!table || !firstRow || !cell) return false;+ const maxShift =+ table.getBoundingClientRect().height - firstRow.getBoundingClientRect().height;+ const t = getComputedStyle(cell).transform;+ const shift = t === 'none' ? 0 : new DOMMatrixReadOnly(t).m42;+ return Math.abs(shift - Math.max(0, maxShift)) < 2;+ },+ undefined,+ { timeout: 5_000, polling: 'raf' },+ );+});++test('first column stays pinned during horizontal scroll after column resize', async ({+ page,+ api,+ workerServer,+}, testInfo) => {+ await api.seedDocs([{ name: 'frozen-hdr-wide', markdown: WIDE_TABLE_MARKDOWN }]);+ await page.goto(`${workerServer.baseURL}/#/frozen-hdr-wide`);+ await waitForActiveProviderSynced(page);+ await page.locator('table').first().waitFor({ state: 'visible' });+ await waitForQuiescence(page, SCROLL_SELECTOR);++ for (const colIndex of [5, 4, 3, 2, 1, 0]) {+ const border = await page.evaluate((idx) => {+ const row = document+ .querySelector('.ProseMirror .tableWrapper > table > tbody')+ ?.querySelector('tr') as HTMLTableRowElement | null;+ const cell = row?.cells[idx];+ if (!cell) return null;+ const r = cell.getBoundingClientRect();+ return { x: r.right - 1, y: r.top + r.height / 2 };+ }, colIndex);+ if (!border) throw new Error(`no header cell at index ${colIndex}`);+ await page.mouse.move(border.x, border.y);+ await page.mouse.move(border.x, border.y); // second move ensures handle decoration+ await page.locator('.column-resize-handle').first().waitFor({ state: 'attached' });+ await page.mouse.down();+ await page.mouse.move(border.x + 70, border.y, { steps: 6 });+ await page.mouse.up();+ await twoFrames(page);+ }+ const cellCenter = await page.evaluate(() => {+ const row = document+ .querySelector('.ProseMirror .tableWrapper > table > tbody')+ ?.querySelectorAll('tr')[2] as HTMLTableRowElement | undefined;+ const r = row?.cells[1]?.getBoundingClientRect();+ return r ? { x: r.left + r.width / 2, y: r.top + r.height / 2 } : null;+ });+ if (cellCenter) await page.mouse.move(cellCenter.x, cellCenter.y);+ await waitForQuiescence(page, SCROLL_SELECTOR);++ const sticky = await page.evaluate(() => {+ const wrapper = document.querySelector('.tableWrapper') as HTMLElement | null;+ if (!wrapper) return null;+ const row = wrapper.querySelector('table > tbody > tr:nth-child(2)') as HTMLTableRowElement;+ const beforeFirst = row.cells[0].getBoundingClientRect().left;+ const beforeSecond = row.cells[1].getBoundingClientRect().left;+ const overflow = wrapper.scrollWidth - wrapper.clientWidth;+ wrapper.scrollLeft = Math.min(260, overflow);+ return {+ overflow,+ scrollLeft: wrapper.scrollLeft,+ stickyDriftPx: Math.abs(row.cells[0].getBoundingClientRect().left - beforeFirst),+ neighborShiftPx: beforeSecond - row.cells[1].getBoundingClientRect().left,+ };+ });+ expect(sticky).not.toBeNull();+ expect(sticky?.overflow ?? 0).toBeGreaterThan(100);+ expect(sticky?.scrollLeft ?? 0).toBeGreaterThan(100);+ expect(sticky?.stickyDriftPx ?? 99).toBeLessThan(2);+ expect(sticky?.neighborShiftPx ?? 0).toBeGreaterThan(100);+ await twoFrames(page);+ await page.screenshot({ path: testInfo.outputPath('horizontal.png') });+});++test('virtualized long doc: both freezes hold on a 200-row table', async ({+ page,+ api,+ workerServer,+}, testInfo) => {+ await api.seedDocs([{ name: 'frozen-hdr-virtual', markdown: VIRTUALIZED_TABLE_MARKDOWN }]);+ await page.goto(`${workerServer.baseURL}/#/frozen-hdr-virtual`);+ await waitForActiveProviderSynced(page);+ await page.locator('table').first().waitFor({ state: 'attached' });+ await waitForQuiescence(page, SCROLL_SELECTOR);++ const chunkState = await page.evaluate(() => {+ const wrappers = document.querySelectorAll<HTMLElement>('.ProseMirror .ok-chunk-wrapper');+ const tableChunk = document.querySelector<HTMLElement>(+ '.ProseMirror .tableWrapper.ok-chunk-wrapper',+ );+ const deepRow = document.querySelectorAll<HTMLElement>(+ '.ProseMirror .tableWrapper > table > tbody > tr',+ )[150];+ return {+ total: wrappers.length,+ tableIsChunk: tableChunk != null,+ tableCv: tableChunk ? getComputedStyle(tableChunk).contentVisibility : 'n/a',+ deepRowSkipped: deepRow ? !deepRow.checkVisibility({ contentVisibilityAuto: true }) : null,+ };+ });+ console.log(`[virtualized] ${JSON.stringify(chunkState)}`);+ expect(chunkState.total).toBeGreaterThan(50);+ expect(chunkState.tableIsChunk).toBe(true);+ expect(chunkState.tableCv).toBe('auto');++ const tableDocTop = await page.evaluate((sel) => {+ const scrollEl = document.querySelector(sel) as HTMLElement;+ const table = document.querySelector('.ProseMirror .tableWrapper > table') as HTMLElement;+ const top =+ scrollEl.scrollTop + table.getBoundingClientRect().top - scrollEl.getBoundingClientRect().top;+ scrollEl.scrollTo({ top: top - 160, behavior: 'instant' as ScrollBehavior });+ return top;+ }, SCROLL_SELECTOR);+ await twoFrames(page);+ await twoFrames(page);+ for (const colIndex of [4, 3, 2, 1, 0]) {+ const border = await page.evaluate((idx) => {+ const row = document+ .querySelector('.ProseMirror .tableWrapper > table > tbody')+ ?.querySelector('tr') as HTMLTableRowElement | null;+ const cell = row?.cells[idx];+ if (!cell) return null;+ const r = cell.getBoundingClientRect();+ return { x: r.right - 1, y: r.top + r.height / 2 };+ }, colIndex);+ if (!border) throw new Error(`no header cell at index ${colIndex}`);+ await page.mouse.move(border.x, border.y);+ await page.mouse.move(border.x, border.y);+ await page.locator('.column-resize-handle').first().waitFor({ state: 'attached' });+ await page.mouse.down();+ await page.mouse.move(border.x + 80, border.y, { steps: 6 });+ await page.mouse.up();+ await twoFrames(page);+ }+ await waitForQuiescence(page, SCROLL_SELECTOR);++ const vertical = await scrollAndReadFreeze(page, tableDocTop + 2_000);+ expect(vertical.frozen).toBe(true);+ expect(vertical.pinErrorPx).toBeLessThan(2);+ if (vertical.syncShiftErrorPx !== null) expect(vertical.syncShiftErrorPx).toBeLessThan(1.5);++ const combined = await page.evaluate(() => {+ const wrapper = document.querySelector('.tableWrapper') as HTMLElement | null;+ if (!wrapper) return null;+ const row = wrapper.querySelector('table > tbody > tr:nth-child(5)') as HTMLTableRowElement;+ const headerRow = wrapper.querySelector('table > tbody > tr') as HTMLTableRowElement;+ const beforeFirst = row.cells[0].getBoundingClientRect().left;+ const beforeSecond = row.cells[1].getBoundingClientRect().left;+ const overflow = wrapper.scrollWidth - wrapper.clientWidth;+ wrapper.scrollLeft = Math.min(200, overflow);+ return {+ overflow,+ scrollLeft: wrapper.scrollLeft,+ stickyDriftPx: Math.abs(row.cells[0].getBoundingClientRect().left - beforeFirst),+ neighborShiftPx: beforeSecond - row.cells[1].getBoundingClientRect().left,+ cornerZ: getComputedStyle(headerRow.cells[0]).zIndex,+ headerZ: getComputedStyle(headerRow.cells[1]).zIndex,+ };+ });+ expect(combined).not.toBeNull();+ expect(combined?.overflow ?? 0).toBeGreaterThan(100);+ expect(combined?.stickyDriftPx ?? 99).toBeLessThan(2);+ expect(combined?.neighborShiftPx ?? 0).toBeGreaterThan(100);+ expect(combined?.cornerZ).toBe('3');+ expect(combined?.headerZ).toBe('2');+ await twoFrames(page);+ await page.screenshot({ path: testInfo.outputPath('virtualized-combined.png') });+});++test('slot above pinned header stays clean in a prose-heavy doc (pixel-verified)', async ({+ page,+ api,+ workerServer,+}, testInfo) => {+ await api.seedDocs([{ name: 'frozen-hdr-prose', markdown: PROSE_ABOVE_MARKDOWN }]);+ await page.goto(`${workerServer.baseURL}/#/frozen-hdr-prose`);+ await waitForActiveProviderSynced(page);+ await page.locator('table').first().waitFor({ state: 'attached' });+ await waitForQuiescence(page, SCROLL_SELECTOR);++ const tableDocTop = await page.evaluate((sel) => {+ const scrollEl = document.querySelector(sel) as HTMLElement;+ const table = document.querySelector('.ProseMirror .tableWrapper > table') as HTMLElement;+ return (+ scrollEl.scrollTop + table.getBoundingClientRect().top - scrollEl.getBoundingClientRect().top+ );+ }, SCROLL_SELECTOR);++ for (const delta of [120, 320, 520]) {+ const state = await scrollAndReadFreeze(page, tableDocTop + delta);+ expect(state.frozen).toBe(true);+ expect(state.pinErrorPx).toBeLessThan(2);+ const maxStd = await scanSlotPixels(page);+ expect(maxStd, `slot band not flat at delta ${delta}`).toBeLessThan(10);+ }+ await page.screenshot({ path: testInfo.outputPath('prose-above-frozen.png') });+});