windlass icon indicating copy to clipboard operation
windlass copied to clipboard

Logs pane: a reader scrolled up drifts about 1 px a second once the 2,000 line cap is reached

Open Sulaiman-Dauda opened this issue 3 weeks ago • 0 comments

Found while testing main (39a6cbc, what v0.61 will be) on a fresh VPS, in headless Chromium against a real service printing about 50 lines a second.

Since #112 the logs pane holds a reader's place when they scroll up, including after the pane reaches its 2,000 line cap (LOG_CAP in web/src/components/LogsTab.tsx) and starts dropping rows above them. On a real stream past the cap, the place is held only roughly. The line at the top of the view slides down about 1 px a second:

Seconds after scrolling up 0 2 4 6 8 10
Line's distance from the pane's top, px 1 3 4 6 8 10

About 540 lines arrived and 540 rows were dropped in those 10 seconds. Before the cap is reached the line does not move at all (21 px before and after 15 seconds), so the drift comes from the correction made when rows are dropped, in web/src/components/TermPane.tsx.

The cause is not confirmed. A likely one is rounding: the correction is measured with getBoundingClientRect, which returns fractions of a pixel, and scrollTop may be stored as a whole number, so each correction can lose a fraction.

web/e2e/logs-pane.spec.ts has "a reader scrolled up keeps their place while lines arrive past the cap". It passes, so its bursts or its tolerance do not show this.

What to do

  1. Make that spec fail first: many small bursts past the cap, then assert the anchored line's position is the same to the pixel.
  2. Fix the correction so the error does not add up. Following at the bottom, and switching Follow off and on, must keep working as the other tests in that spec check.

Sulaiman-Dauda avatar Nov 10 '26 09:11 Sulaiman-Dauda