fix(app): stabilize diff reviews and workspace tabs

Reuse measured diff geometry when review controls open, keeping the interaction responsive on large changes. Preserve complete tab-track snapshots while exact content widths settle so new tabs and retained workspaces do not flash or truncate.
This commit is contained in:
Mohamed Boudra
2026-08-17 21:14:38 +02:00
parent c7b103a2cd
commit 8f7b3e8d75
10 changed files with 433 additions and 96 deletions
@@ -95,7 +95,6 @@ export function DiffSurface(props: DiffSurfaceProps) {
loadedTypography,
measurement,
props.palette,
reviewActions,
t,
] as const;
const previous = reusableModelRef.current;
@@ -210,7 +209,15 @@ export function DiffSurface(props: DiffSurfaceProps) {
}, [loadedTypography, measurement, props.palette, viewport.height, viewport.width]);
const schedulePaint = useCallback(
(force = true) => {
if (force) forcePaintRef.current = true;
if (force) {
forcePaintRef.current = true;
// Fast Refresh preserves refs. A request owned by the previous module can leave a stale
// id behind, which would otherwise prevent every subsequent canvas repaint.
if (frameRef.current !== null) {
cancelAnimationFrame(frameRef.current);
frameRef.current = null;
}
}
if (frameRef.current === null) frameRef.current = requestAnimationFrame(paint);
},
[paint],
@@ -260,6 +267,7 @@ export function DiffSurface(props: DiffSurfaceProps) {
useEffect(
() => () => {
if (frameRef.current !== null) cancelAnimationFrame(frameRef.current);
frameRef.current = null;
},
[],
);