fix(app): stabilize canvas refresh and borders

Fast Refresh preserves refs while rerunning effects, so canceled paint requests must release their retained IDs or unseen diff regions stop rendering. Paint the final expanded body’s reserved boundary pixel because no following header owns that seam.
This commit is contained in:
Mohamed Boudra
2026-08-17 21:14:38 +02:00
parent 8f7b3e8d75
commit 9e6e148ba2
5 changed files with 90 additions and 14 deletions
@@ -209,15 +209,7 @@ export function DiffSurface(props: DiffSurfaceProps) {
}, [loadedTypography, measurement, props.palette, viewport.height, viewport.width]);
const schedulePaint = useCallback(
(force = 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 (force) forcePaintRef.current = true;
if (frameRef.current === null) frameRef.current = requestAnimationFrame(paint);
},
[paint],
@@ -267,6 +259,8 @@ export function DiffSurface(props: DiffSurfaceProps) {
useEffect(
() => () => {
if (frameRef.current !== null) cancelAnimationFrame(frameRef.current);
// Fast Refresh preserves refs while rerunning effects. Release ownership of the canceled
// request so the refreshed renderer can schedule its first paint.
frameRef.current = null;
},
[],