From 5109f38ca95dd3c2075dfaa53e4a8a75b69c7002 Mon Sep 17 00:00:00 2001 From: Max Barvian Date: Sat, 21 Feb 2026 08:59:31 -0800 Subject: [PATCH] Fix line drawing ahead of dot when unpausing During unpause catch-up, filterRight expanded past `now` as pauseProgress decayed, letting data points from the pause period (which have real-time timestamps ahead of the chart's lagging `now`) into the visible set. These mapped to X positions past the live tip, breaking the spline's monotone-X assumption and causing the line to extend past the dot. Fix: cap filterRight to `now` while time debt is active. --- src/useLivelineEngine.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/useLivelineEngine.ts b/src/useLivelineEngine.ts index 7ec679f..d715b46 100644 --- a/src/useLivelineEngine.ts +++ b/src/useLivelineEngine.ts @@ -732,9 +732,14 @@ export function useLivelineEngine( const rightEdge = now + windowSecs * buffer const leftEdge = rightEdge - windowSecs - // Filter visible points — when pausing, contract right edge to `now` - // so new data (with real-time timestamps) can't appear past the live dot - const filterRight = rightEdge - (rightEdge - now) * pauseProgress + // Filter visible points — when pausing, contract right edge to `now` + // so new data (with real-time timestamps) can't appear past the live dot. + // While draining time debt (catch-up), also cap at `now` — data from the + // pause period has real-time timestamps ahead of the chart's lagging `now`, + // and letting those through would place points past the live tip, breaking + // the spline's monotone-X assumption and causing the line to loop backward. + const rawFilterRight = rightEdge - (rightEdge - now) * pauseProgress + const filterRight = timeDebtRef.current > 0.01 ? Math.min(now, rawFilterRight) : rawFilterRight const visible: LivelinePoint[] = [] for (const p of effectivePoints) { if (p.time >= leftEdge - 2 && p.time <= filterRight) {