computeLineDiff(compareSource, source), [compareSource, source]);
+ const diff = computeLineDiff(compareSource, source);
// Use the right side for display (shows the "new" content with change markers)
const diffLines = diff.right;
// Filter out empty alignment lines to avoid unnecessary whitespace
@@ -188,14 +158,11 @@ function getInlineChangeClass(type: 'unchanged' | 'added' | 'removed', side: 'ba
interface CellOutputsProps {
outputs: CellOutput[];
- isVisible?: boolean;
}
-function CellOutputs({ outputs, isVisible = true }: CellOutputsProps): React.ReactElement {
- // Text placeholders for images prevent ResizeObserver feedback loops.
- // Opacity optimization improves performance for off-screen cells without triggering dimension changes.
+function CellOutputs({ outputs }: CellOutputsProps): React.ReactElement {
return (
-
+
{outputs.map((output, i) => (
))}
@@ -265,24 +232,4 @@ function ImagePlaceholder({ mimeType }: { mimeType: string }): React.ReactElemen
);
}
-/**
- * Custom comparator for React.memo.
- * Compares props that affect rendered output, treating drag handler reference
- * changes as equal if their defined/undefined status hasn't changed.
- */
-function areCellContentPropsEqual(prev: CellContentProps, next: CellContentProps): boolean {
- if (prev.cell !== next.cell) return false;
- if (prev.cellIndex !== next.cellIndex) return false;
- if (prev.side !== next.side) return false;
- if (prev.isConflict !== next.isConflict) return false;
- if (prev.compareCell !== next.compareCell) return false;
- if (prev.showOutputs !== next.showOutputs) return false;
- if (prev.isVisible !== next.isVisible) return false;
- // Drag handlers: only care if defined/undefined changed (affects draggable attribute),
- // not about reference identity (the actual handler logic is stable)
- if (Boolean(prev.onDragStart) !== Boolean(next.onDragStart)) return false;
- if (Boolean(prev.onDragEnd) !== Boolean(next.onDragEnd)) return false;
- return true;
-}
-
-export const CellContent = React.memo(CellContentInner, areCellContentPropsEqual);
+export const CellContent = CellContentInner;
diff --git a/src/web/client/ConflictResolver.tsx b/src/web/client/ConflictResolver.tsx
index f43501b..e6ab649 100644
--- a/src/web/client/ConflictResolver.tsx
+++ b/src/web/client/ConflictResolver.tsx
@@ -3,7 +3,7 @@
* @description Main React component for the conflict resolution UI.
*/
-import React, { useState, useCallback, useMemo, useRef, useEffect } from 'react';
+import React, { useState, useRef, useEffect } from 'react';
import { sortByPosition } from '../../positionUtils';
import { normalizeCellSource } from '../../notebookUtils';
import type {
@@ -18,12 +18,6 @@ import type {
} from './types';
import { MergeRow } from './MergeRow';
-// Virtualization constants
-const INITIAL_VISIBLE_ROWS = 20; // Number of rows to render initially
-const DEFAULT_ROW_HEIGHT = 200; // Default height for unmeasured rows (fallback)
-const VIRTUALIZATION_OVERSCAN_ROWS = 5; // Number of rows to render outside viewport for smooth scrolling
-const RESIZE_OBSERVER_DEBOUNCE_MS = 150; // Debounce ResizeObserver updates to prevent rapid state changes
-const HEIGHT_CHANGE_THRESHOLD = 5; // Minimum height change (in pixels) to trigger an update
const INITIAL_MARK_AS_RESOLVED = true;
const INITIAL_RENUMBER_EXECUTION_COUNTS = true;
@@ -86,12 +80,9 @@ export function ConflictResolver({
onResolve,
onCancel,
}: ConflictResolverProps): React.ReactElement {
- const initialRows = useMemo(() => {
- if (conflict.type === 'semantic' && conflict.semanticConflict) {
- return buildMergeRowsFromSemantic(conflict.semanticConflict);
- }
- return [];
- }, [conflict]);
+ const initialRows = conflict.type === 'semantic' && conflict.semanticConflict
+ ? buildMergeRowsFromSemantic(conflict.semanticConflict)
+ : [];
const [choices, setChoices] = useState
-
+
{conflict.autoResolveResult && conflict.autoResolveResult.autoResolvedCount > 0 && (
✓
@@ -913,29 +711,10 @@ export function ConflictResolver({
- {/*
- Virtualization Strategy: Content Windowing
-
- We render ALL row wrapper divs in the normal document flow here.
- This allows the browser to calculate the correct document height and scrollbar natively,
- and allows ResizeObserver to measure the actual height of every row (even "off-screen" ones).
-
- True virtualization (removing nodes) would require absolute positioning and estimating heights,
- which breaks the sticky headers and variable-height content flow.
-
- Optimization comes from passing `isVisible` to the MergeRow component.
- When `isVisible` is false, MergeRow skips rendering expensive content (like syntax highlighting
- and diffs), rendering lightweight placeholders instead.
- */}
-
);
}
-
-/**
- * Custom comparator for React.memo.
- * Avoids re-rendering rows not affected by drag operations or state changes.
- */
-function areMergeRowPropsEqual(prev: MergeRowProps, next: MergeRowProps): boolean {
- // Core content & identity
- if (prev.row !== next.row) return false;
- if (prev.rowIndex !== next.rowIndex) return false;
- if (prev.conflictIndex !== next.conflictIndex) return false;
- if (prev.resolutionState !== next.resolutionState) return false;
-
- // Display flags
- if (prev.isDragging !== next.isDragging) return false;
- if (prev.showOutputs !== next.showOutputs) return false;
- if (prev.isVisible !== next.isVisible) return false;
- if (prev.enableCellDrag !== next.enableCellDrag) return false;
- if (prev.rowDragEnabled !== next.rowDragEnabled) return false;
-
- // Drop target: only re-render if THIS row's drop target status changed
- const prevIsTarget = prev.dropTarget?.rowIndex === prev.rowIndex;
- const nextIsTarget = next.dropTarget?.rowIndex === next.rowIndex;
- if (prevIsTarget !== nextIsTarget) return false;
- if (nextIsTarget && prev.dropTarget?.side !== next.dropTarget?.side) return false;
-
- // Callbacks (should be stable via useCallback, but verify)
- if (prev.onSelectChoice !== next.onSelectChoice) return false;
- if (prev.onUpdateContent !== next.onUpdateContent) return false;
- if (prev.onCommitContent !== next.onCommitContent) return false;
-
- return true;
-}
-
-export const MergeRow = React.memo(MergeRowInner, areMergeRowPropsEqual);
+export const MergeRow = MergeRowInner;
From fa5af7e6c6831736241a7811e2ca9e11b2dceb47 Mon Sep 17 00:00:00 2001
From: Avni2000