Skip to content

fix(clock): resync the date tick on every update - #1909

Merged
eythaann merged 1 commit into
eythaann:masterfrom
z1pp090:fix/clock-resync
Oct 16, 2026
Merged

eythaann merged 1 commit into
eythaann:masterfrom
z1pp090:fix/clock-resync

Conversation

@z1pp090

@z1pp090 z1pp090 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Problem

libs/ui/svelte/runes/date.svelte.ts aligns its first timer to the minute boundary, but then re-arms itself with a fixed setTimeout(tick, 60000). Each timer fires a few ms late and the next one keeps that lateness, so the displayed minute slowly moves away from the real boundary and never recovers. Every monitor has its own webview, so each toolbar drifts by a different amount.

Seen here (Seelen 2.8.8, two monitors, seelen-ui running for 4 days): sampling a screen capture of both clocks every ~60 ms across two minute changes, the minute changed at :07.3 on the primary toolbar and at :34.5 on the secondary one, with the same offsets in both minutes. So the secondary clock showed the new minute ~27 s after the primary one.

Related to #94 (closed, but the last comments there say the clock is still behind).

Fix

Recompute the delay from the wall clock on every tick (the same expression the first tick already used), so the clock re-aligns to the boundary after every update instead of keeping the accumulated drift.

Verification

Dev build (seelen-ui + npm run build:ui) on Windows 11 with two monitors. To make the drift visible in minutes, I temporarily patched setTimeout in the webview so every timer fires 300 ms late (test-only patch, not part of this PR), and sampled both toolbar clocks every ~40 ms for 7 minutes:

rune minute change on the toolbars, minute after minute
before (fixed 60000 ms) :00.63, :00.95, :01.24, :01.57, :01.91, :02.17, :02.52 (about +0.31 s per minute, same on both monitors)
after (this PR) :00.32 to :00.38 every minute (the injected 300 ms, no accumulation)

Also: deno fmt, deno lint and ts-type-check pass (pre-commit hook), and CI is green on my fork.

Not tested: waiting for the natural drift to build up in a build with this change (the injected delay stands in for it), and I have not confirmed what exactly made each webview drift in my 4-day session; timer lateness is the explanation that fits the numbers.

The tick re-armed itself with a fixed 60000 ms delay, so the lateness of each timer
accumulated and the clock drifted away from the minute boundary, never recovering.
Each monitor has its own webview and drifts by a different amount, so the secondary
toolbar could show the new minute several seconds after the primary one.

Recompute the delay from the wall clock on every tick instead.
@greptile-apps

greptile-apps Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The clock now recalculates its timer delay after every update.

  • Date displays resync to the clock after every update.

Reviews (1) · Last reviewed commit: "fix(clock): resync the date tick on ever..." · Reviewed by Greptile

@eythaann
eythaann merged commit ad064df into eythaann:master Oct 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants