Skip to content

Resync the clock when the wall clock is stepped - #13347

Open
ChaseC-130 wants to merge 7 commits into
omacom:quattrofrom
ChaseC-130:fix/clock-stale-after-resume
Open

ChaseC-130 wants to merge 7 commits into
omacom:quattrofrom
ChaseC-130:fix/clock-stale-after-resume

Conversation

@ChaseC-130

@ChaseC-130 ChaseC-130 commented Sep 26, 2026 •

Copy link
Copy Markdown

Close a laptop lid and open it again, and the bar clock still reads the time the lid closed at (or the previous day if suspended overnight across midnight, such as showing Friday instead of Saturday). date in a terminal is correct the whole time.

It does correct itself — but not for up to a full minute, and most of that minute passes behind the lock screen, so what you actually see is a stale clock on the bar you unlock into.

Refs #13275 — a Try Omarchy VM whose bar clock is "often incorrect, running slow and does not update for many minutes at a time". A paused or migrated VM steps the guest's wall clock the same way a suspend does, so this is a plausible fix for that report, but the issue does not mention suspend or compare the bar against date, so it is not referenced as closing.
Supersedes #10138 (rebased on current quattro with documentation merge conflict resolved).

Cause

SystemClock computes the delay to the top of the next minute from wall-clock time and arms a QTimer with that relative delay (schedule() in Quickshell). Relative Qt timers are measured on CLOCK_MONOTONIC, which does not advance while the machine is suspended.

So a clock with four seconds left to run when the lid closes still has four seconds left when it opens. How long the machine slept makes no difference — an eight-hour suspend and a ten-second one leave the same remainder to burn down. An NTP correction after a long time offline steps the clock the same way.

Fix

Wallclock, a qs.Commons singleton, watches for the wall-clock step and reports it. Wallclock.resync(clock) makes a SystemClock re-read the wall clock and reschedule from now — toggling enabled is the lever the type exposes for that. A clock its owner has disabled is left alone: enabling one is already a re-read, and writing the property would start a clock that was deliberately stopped and, since an assignment from JavaScript replaces a binding, take the binding that stopped it.

The calendar panel resyncs too, though only a panel left open across a suspend that crossed midnight can reach it (open() already refreshes). It resyncs rather than refreshing because refresh() calls goToToday(), and waking the machine is no reason to drag a calendar left open on another month back to this one.

Testing

  • test/shell.d/clock-test.sh passes with all step-detection predicate and wiring assertions (175 checks).
  • Verified in live Quickshell instance that the clock resyncs immediately upon wall-clock jump.
  • Headless Quickshell 0.3.1: a clock gated on a bound enabled keeps the binding across a resync while disabled, and a disabled SystemClock re-reads the wall clock when it is enabled again.
  • Seven mutants of Wallclock's own wiring (running, interval, threshold, the lastTick update, pragma Singleton, and each clock's id) now fail the test; all seven passed it before.

Fixes #13504

Fixes #7608

@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Verified: For suspend and wall-clock steps, the change does what the description says. The stated cause matches Quickshell 0.3.1 and Qt 6.11.2 source: SystemClock::schedule() arms a relative QTimer, Qt timers wait on CLOCK_MONOTONIC, and toggling enabled makes SystemClock re-read the time, emit dateChanged and reschedule from now. The Wallclock watchdog is itself a QML Timer on monotonic time, so it fires within about 1 s of resume and Date.now() then sees the whole gap. The clock ids in BarWidget.qml and Panel.qml resolve to each file's own SystemClock, and the panel's resync keeps a browsed month where refresh() would jump back to today. test/shell.d/clock-test.sh passes at the head (167 ok).

Headless Quickshell 0.3.1 run loading the PR's Wallclock.qml, WallclockMath.js and qmldir unchanged, with the wall clock stepped by a test-only shim that offsets CLOCK_REALTIME only (simulated step, no real suspend; two runs):

                            forward +8 h step     backward -8 h step
step -> jumped emitted      916-929 ms            894-933 ms
clock wired like the PR     updated in the same event (all cases)
unwired control clock       stale 41.8-42.2 s     stale 56.8-57.2 s
jumped events per run       2 over ~135 s (no false positives)

Wallclock.resync() removes a binding on enabled

resync(clock) assigns clock.enabled from JavaScript. In QML that removes any binding on the property and leaves it true. In both runtime runs, a clock declared enabled: root.clockWanted and resynced once stayed true after clockWanted went false; an identical clock that was not resynced followed the binding.

Impact: The two in-tree clocks have no binding on enabled, so they are unaffected. The new docs section presents Wallclock.resync(clock) as the pattern for plugins, so a plugin that binds enabled (for example to pause its clock while hidden) would lose that binding after the first wall-clock step.

Suggested change: Return early in resync when !clock.enabled (a disabled SystemClock re-reads the time when it is re-enabled anyway), and note in the docs that resync writes enabled, so it should not be used on a clock whose enabled is bound. The early return only keeps a paused clock paused; a bound clock that is currently enabled still loses its binding. This change was derived from source and not run.

Related open PRs on the same symptom

Open PRs #12277 (resume via logind PrepareForSleep, calling the clock widget's refresh()) and #9509 (omarchy-system-wake, run on unlock and idle-wake, calling omarchy-shell -q omarchy.clock refresh) address the same stale clock after wake, as did #10138, which this PR supersedes. Both of those paths reach the calendar's Panel.refresh(), which calls goToToday():

#12277: SystemSleep.resumed -> BarWidget.refresh() -> Panel.refresh() -> goToToday()
#9509:  omarchy-system-wake -> IPC omarchy.clock refresh -> BarWidget.refresh() -> Panel.refresh() -> goToToday()
#13347: Wallclock.jumped -> Wallclock.resync(clock)   (browsed month kept)

Impact: If either of those lands alongside this PR, a calendar left open on another month moves back to today on wake, which is the behaviour this PR's panel handler avoids. This is source-level and conditional on a combined merge; it was not run.

Suggested change: Land one wake-clock approach, or have the other paths resync the clocks rather than call Panel.refresh() on an open panel.

Issue link: Issue #13275 describes a Try Omarchy VM on an Apple M2 whose bar clock is "often incorrect, running slow and does not update for many minutes at a time". It does not mention suspend or compare the bar with date. This PR bounds staleness after a wall-clock step of at least 3 s. It does not change a bar that matches a wrong guest clock, and it does not react to corrections smaller than 3 s. GitHub lists #13275 as a closing reference, so merging closes it. Using Refs #13275 instead would keep the issue open, and asking the reporter whether date agreed with the bar would settle whether this PR addresses it.

Optional test improvement: 6 of 10 diagnostic mutants survive clock-test.sh: watchdog running: false, interval: 60000, threshold: 0, lastTick never reassigned, pragma Singleton removed, and the widget's SystemClock id renamed. The predicate assertions pass literal (…, 1000, 3000) arguments and the wiring checks match text, so nothing checks Wallclock's own running, interval, threshold or lastTick update. Asserting those lines and pragma Singleton would, by construction, catch 5 of the 6 survivors (not run).

Docs snippet: The example shows only import qs.Commons, but SystemClock is in the Quickshell module, so a copied snippet also needs import Quickshell.


Review information

Test scope: Source review of the diff against Quickshell 0.3.1, Qt 6.11.2 and the Linux clock documentation. clock-test.sh run at the head and base in an isolated sandbox, plus 10 diagnostic mutants. Wallclock exercised in a headless offscreen Quickshell 0.3.1 process with a simulated CLOCK_REALTIME step; no real suspend, NTP step or VM run. BarWidget.qml and Panel.qml were checked by source and by an equivalent harness, not loaded in the full shell. The cost of the 1 Hz watchdog was not measured. The related-PR interaction is source-level only.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

The bar clock keeps showing the time the lid closed at for up to a
minute after it opens.

SystemClock schedules its next tick as the delay to the top of the next
minute, and delays are measured on CLOCK_MONOTONIC, which stops while
the machine is suspended. A clock with four seconds left to run when the
lid closes still has four seconds left when it opens. How long the
machine slept makes no difference — an eight-hour suspend and a
ten-second one leave the same remainder to burn down. Most of that
minute passes behind the lock screen; what is left of it lands on the
bar the user unlocks into. An NTP correction after a long time offline
steps the clock the same way.

Checking the wall clock when a timer fires is the cheaper fix, and it is
the one the lock service already makes before blanking a freshly woken
screen. It does not transfer here, because SystemClock already does it:
setTime and schedule both fall back to the current time when the tick
they were waiting for turns out to be stale, which is why the clock
rights itself a minute after waking rather than staying wrong. It cannot
do better, because that check only runs when the late tick arrives, and
waiting for the tick is the bug.

So Wallclock runs the check on a schedule of its own — nothing else will
raise it, as logind announces a resume on a bus the shell does not
speak and a stepped clock announces nothing anywhere — and resync()
makes a SystemClock re-read the wall clock and reschedule from now. One
timer rather than one per widget is what the singleton is for: every bar
instantiates its own clock widget and calendar panel.

The calendar panel resyncs too, though only a panel left open across a
suspend that crossed midnight can reach it: open() already refreshes.
It resyncs rather than refreshing because refresh() calls goToToday(),
and waking the machine is no reason to drag a calendar left open on
another month back to this one.

resync() leaves a clock its owner has disabled alone. Enabling one is
already a re-read, so there is nothing there to force, and writing the
property would both start a clock that was deliberately stopped and —
since assigning a property from JavaScript replaces any binding on it —
take the binding that was holding it stopped. Neither clock in the tree
binds enabled, so this changes nothing for them; it is the pattern the
documentation hands to plugins that needed the guard, and the docs now
say that resync() writes enabled at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016DKT4jSou6grTnSjV46BJv
@ChaseC-130
ChaseC-130 force-pushed the fix/clock-stale-after-resume branch from 51d4279 to 4ca1505 Compare September 27, 2026 04:33
@ChaseC-130

Copy link
Copy Markdown
Author

Useful review, thanks. Three points became changes, one a PR body fix, one is a maintainer call.

resync() removes a binding on enabled — fixed

Reproduced before touching anything, in a headless Quickshell 0.3.1 process:

clock declared enabled: root.wanted, resynced once  ->  stayed true after wanted went false
identical clock, never resynced                     ->  followed the binding to false

If anything this is understated: on a clock its owner had disabled, the write does not just drop the binding, it starts the clock. resync() now returns early there. That costs nothing, because a disabled SystemClock does re-read when it is enabled again — checked rather than assumed:

SystemClock { enabled: false } built at 23:17:30, read 23:17:30 while disabled
enabled at 23:17:34                                 ->  read 23:17:34

And after the change:

enabled: root.paused (false)  ->  left alone; paused -> true still enabled it, binding intact
enabled: root.shown  (true)   ->  still resynced; binding still consumed

The enabled-and-bound case is documented rather than fixed, as you said it would have to be: enabled and precision are the only writable properties SystemClock has, so there is no lever that is not someone's possible binding. The docs now say resync writes enabled and point at gating the display's visible instead.

Docs snippet missing import Quickshell — fixed

Right, and the in-tree widget imports both. Added.

Test mutants — fixed, 167 -> 175 assertions

All six die now, plus a seventh you nearly had: the panel's SystemClock id is the same hole as the widget's, and its resync call names the same clock.

mutant at the head now
watchdog running: false survived killed
interval: 60000 survived killed
threshold: 0 survived killed
lastTick never reassigned survived killed
pragma Singleton removed survived killed
widget SystemClock id renamed survived killed
panel SystemClock id renamed survived killed

Plus one for the early return above, so a later cleanup cannot quietly restore the binding-stripping write.

Fixes #13275 -> Refs #13275 — changed in the PR body

Fair, and I should not have claimed it. #13275 is a Try Omarchy VM on an M2 with a bar clock "often incorrect, running slow and does not update for many minutes at a time" — no mention of suspend, no comparison against date. A paused or migrated VM does produce exactly this bug, CLOCK_MONOTONIC stopping while the guest's realtime is corrected behind it, so this is a plausible fix for it but not a confirmed one. Switched to Refs so merging leaves the issue open for the reporter.

Related open PRs #12277 / #9509 — maintainer call, no change here

The interaction is real. Worth adding that the approaches are not interchangeable: both of those hook a resume event, so an NTP step after a long time offline leaves the same stale clock with nothing to hook. This PR reacts to the step itself, whatever moved it. #10138 is my own, superseded by this one.

If one of those is preferred alongside this, the small version is for it to call Wallclock.resync() instead of Panel.refresh() while the panel is open — Wallclock is a qs.Commons singleton, so it is reachable from either path, and that keeps a browsed month put. Happy to rebase whichever way the maintainers want to go.

@llstrk

llstrk commented Sep 29, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Outcome: Follow-up at 4ca1505 on the earlier review: the binding, test and docs findings are resolved; #13275 now looks like a different bug.

#13275 looks like a wrong guest clock, not a stale bar

The reporter has since shown date itself ~22 h behind, with the bar matching it, so Wallclock has no step to detect. The PR body still calls this "a plausible fix", so readers may expect it to fix that issue.

Suggested change: Drop the #13275 reference and link #7608 and #13504, which match this PR's symptom.

Details

The reporter's reply: #13275 (comment) (date printed Sat Sep 26 10:25:02 AM PDT 2026 when Sun Sep 27 08:50:00 AM PDT 2026 was expected). This is read from the issue, not reproduced.

Related PRs. All four are open and reach Panel.refresh() → goToToday(), which moves a calendar left open on another month back to today (source-level, not run):

#12277: SystemSleep.resumed -> BarWidget.refresh() -> Panel.refresh() -> goToToday()
#9509:  omarchy-system-wake -> omarchy.clock refresh -> BarWidget.refresh() -> Panel.refresh()
#13541: 5 s stale-minute Timer -> BarWidget.refresh() -> Panel.refresh()
#13658: omarchy-system-sleep-monitor -> omarchy.clock refresh -> BarWidget.refresh() -> Panel.refresh()

The reconciliation in the author reply (the other paths calling Wallclock.resync() instead of Panel.refresh() while the panel is open) would avoid this. #10138 is also still open.

Verified:

  • clock-test.sh passes at the head (175 ok) and after merging into the pinned base c5b4db7 (175 ok).
  • Each of the 7 mutants in the author's table, plus removal of the early return, fails a new assertion at the head; the 7 survive at 51d4279.
  • In headless Quickshell 0.3.1, resync() leaves a clock bound to false disabled and bound; at 51d4279 it started that clock and dropped the binding. A clock bound to true is still re-read and still loses its binding, as the new docs say.
  • A disabled SystemClock re-reads the wall clock when it is enabled again.
  • The docs snippet now imports Quickshell.
Reproducer: resync and a bound enabled

Headless Quickshell 0.3.1 (Qt 6.11.2), offscreen platform, no compositor. Run from the root of a checkout; it copies that checkout's shell/Commons (with the PR's Wallclock.qml, WallclockMath.js and qmldir) unchanged into a temporary config.

#!/bin/bash
# Run from the root of an omarchy checkout. Needs quickshell (0.3.1 here); no
# compositor: the platform is offscreen and nothing opens a window.
set -u
dir=$(mktemp -d)
cp -r shell/Commons "$dir/Commons"
cat > "$dir/shell.qml" <<'QML'
import QtQuick
import Quickshell
import qs.Commons

ShellRoot {
  id: root
  property bool paused: false   // clock A: enabled bound to false
  property bool shown: true     // clock B: enabled bound to true
  property bool wanted: false   // clock D: disabled from the start
  property int changesA: 0
  property int changesB: 0

  function out(key, value) { console.log("RESULT " + key + " " + JSON.stringify(value)) }
  function hms(d) { return Qt.formatDateTime(d, "HH:mm:ss") }

  SystemClock { id: clockA; precision: SystemClock.Seconds; enabled: root.paused; onDateChanged: root.changesA++ }
  SystemClock { id: clockB; precision: SystemClock.Seconds; enabled: root.shown; onDateChanged: root.changesB++ }
  SystemClock { id: clockD; precision: SystemClock.Seconds; enabled: root.wanted }

  Timer {
    interval: 2500
    running: true
    onTriggered: {
      var a0 = root.changesA
      Wallclock.resync(clockA)
      root.out("A resync on enabled:false-bound clock", { enabled: clockA.enabled, dateChanged: root.changesA - a0 })
      root.paused = true;  root.out("A binding -> true", { enabled: clockA.enabled })
      root.paused = false; root.out("A binding -> false", { enabled: clockA.enabled })

      var b0 = root.changesB
      Wallclock.resync(clockB)
      root.out("B resync on enabled:true-bound clock", { enabled: clockB.enabled, dateChanged: root.changesB - b0 })
      root.shown = false; root.out("B binding -> false", { enabled: clockB.enabled })

      var whileDisabled = root.hms(clockD.date), now = root.hms(new Date())
      root.wanted = true
      root.out("D disabled clock", { readWhileDisabled: whileDisabled, now: now, readAfterEnable: root.hms(clockD.date) })
      Qt.quit()
    }
  }
}
QML
QT_QPA_PLATFORM=offscreen timeout 30 quickshell -p "$dir" --no-color 2>&1 | grep RESULT

At the PR head 4ca1505b0ccf999782f00a4b1ced68e107a63b90:

 DEBUG qml: RESULT A resync on enabled:false-bound clock {"enabled":false,"dateChanged":0}
 DEBUG qml: RESULT A binding -> true {"enabled":true}
 DEBUG qml: RESULT A binding -> false {"enabled":false}
 DEBUG qml: RESULT B resync on enabled:true-bound clock {"enabled":true,"dateChanged":1}
 DEBUG qml: RESULT B binding -> false {"enabled":true}
 DEBUG qml: RESULT D disabled clock {"readWhileDisabled":"04:38:51","now":"04:38:53","readAfterEnable":"04:38:53"}

At the previously reviewed head 51d42799e59e77e16143462555c8d59f00c987e0 (no early return):

 DEBUG qml: RESULT A resync on enabled:false-bound clock {"enabled":true,"dateChanged":1}
 DEBUG qml: RESULT A binding -> true {"enabled":true}
 DEBUG qml: RESULT A binding -> false {"enabled":true}
 DEBUG qml: RESULT B resync on enabled:true-bound clock {"enabled":true,"dateChanged":1}
 DEBUG qml: RESULT B binding -> false {"enabled":true}
 DEBUG qml: RESULT D disabled clock {"readWhileDisabled":"04:38:54","now":"04:38:56","readAfterEnable":"04:38:56"}

Clock A (paused through a binding) is left alone at the head and keeps its binding; at the previous head the resync started it and dropped the binding. Clock B (bound true) is still resynced and still loses its binding at both heads, which the new docs text states. Clock D shows a disabled SystemClock reporting its construction time while disabled and re-reading the wall clock when enabled.

Optional test improvement

Optional test improvement: Five small breakages still pass all 175 assertions: jumped never emitted, predicate negated, baseline taken before subtracting, WallclockMath.js import removed, jumped signal removed. In a headless run four of them stop step reports entirely and the negated predicate fires on every ordinary tick. Three assertions in the test's own style pass at the head (178 ok) and catch all five:

assert(/^import "WallclockMath\.js" as Detect$/m.test(wallclockCode), 'Wallclock imports the tested predicate')
assert(/^\s*signal jumped\(real deltaMs\)$/m.test(wallclockCode), 'Wallclock declares the signal the clocks listen for')
assert(/var elapsed = now - root\.lastTick\s*\n\s*root\.lastTick = now\s*\n\s*if \(Detect\.isDiscontinuity\(elapsed, root\.interval, root\.threshold\)\) root\.jumped\(elapsed\)/.test(wallclockCode), 'each tick measures from the previous one and reports a step')
Reproducer: unpinned watchdog lines

PR #13347 head 4ca1505b0ccf999782f00a4b1ced68e107a63b90. Run from the root of a checkout of that commit (needs node, perl, awk). The script edits shell/Commons/Wallclock.qml and test/shell.d/clock-test.sh in place and restores both.

Each of the five one-line edits below leaves the watchdog unable to report a step (or, for the negated predicate, makes it fire on every ordinary tick), and each still passes all 175 assertions. The second half adds three assertions in the test's own style; they pass on the unchanged head (178) and fail on each edit.

#!/bin/bash
# Run from the root of an omarchy checkout at 4ca1505b (PR #13347 head).
# Breaks one line of Wallclock's watchdog at a time, runs clock-test.sh, and
# restores the file. Then adds three assertions and repeats.
set -u
tmp=$(mktemp -d)
wc=shell/Commons/Wallclock.qml
test=test/shell.d/clock-test.sh
cp "$wc" "$tmp/Wallclock.qml.orig"
cp "$test" "$tmp/clock-test.sh.orig"

check() {
  bash "$test" >"$tmp/out" 2>&1
  local status=$?
  printf '  %-34s exit=%s ok=%s\n' "$1" "$status" "$(grep -c '^ok - ' "$tmp/out")"
}

mutate() {
  local name=$1; shift
  "$@"
  if cmp -s "$wc" "$tmp/Wallclock.qml.orig"; then echo "  $name: NOT APPLIED"; else check "$name"; fi
  cp "$tmp/Wallclock.qml.orig" "$wc"
}

run_all() {
  check 'unchanged'
  mutate 'jumped never emitted' perl -pi -e 's/\) root\.jumped\(elapsed\)$/) console.log(elapsed)/' "$wc"
  mutate 'predicate negated' perl -pi -e 's/if \(Detect\.isDiscontinuity\(/if (!Detect.isDiscontinuity(/' "$wc"
  mutate 'baseline taken before subtracting' perl -0pi -e 's/(      var elapsed = now - root\.lastTick\n)(      root\.lastTick = now\n)/$2$1/' "$wc"
  mutate 'WallclockMath import removed' perl -ni -e 'print unless /^import "WallclockMath\.js" as Detect$/' "$wc"
  mutate 'jumped signal removed' perl -ni -e 'print unless /^  signal jumped\(real deltaMs\)$/' "$wc"
}

echo "clock-test.sh as in the PR:"
run_all

cat > "$tmp/extra.js" <<'JSX'

// The emit itself, and what it needs: without these, a watchdog that never
// raises `jumped` still passes every assertion above.
assert(/^import "WallclockMath\.js" as Detect$/m.test(wallclockCode), 'Wallclock imports the tested predicate')
assert(/^\s*signal jumped\(real deltaMs\)$/m.test(wallclockCode), 'Wallclock declares the signal the clocks listen for')
assert(/var elapsed = now - root\.lastTick\s*\n\s*root\.lastTick = now\s*\n\s*if \(Detect\.isDiscontinuity\(elapsed, root\.interval, root\.threshold\)\) root\.jumped\(elapsed\)/.test(wallclockCode), 'each tick measures from the previous one and reports a step')
JSX
awk -v f="$tmp/extra.js" '$0 == "JS" { while ((getline l < f) > 0) print l } { print }' "$tmp/clock-test.sh.orig" > "$test"

echo "clock-test.sh with the three assertions added:"
run_all
cp "$tmp/clock-test.sh.orig" "$test"

Output (Node v26.7.0, bash 5.3):

clock-test.sh as in the PR:
  unchanged                          exit=0 ok=175
  jumped never emitted               exit=0 ok=175
  predicate negated                  exit=0 ok=175
  baseline taken before subtracting  exit=0 ok=175
  WallclockMath import removed       exit=0 ok=175
  jumped signal removed              exit=0 ok=175
clock-test.sh with the three assertions added:
  unchanged                          exit=0 ok=178
  jumped never emitted               exit=1 ok=175
  predicate negated                  exit=1 ok=175
  baseline taken before subtracting  exit=1 ok=175
  WallclockMath import removed       exit=1 ok=173
  jumped signal removed              exit=1 ok=174
More findings: qmldir conflicts with current quattro

qmldir conflicts with current quattro

#13435 appended ShellIpc to shell/Commons/qmldir where this PR appends Wallclock, so the PR no longer merges cleanly. Keeping both lines resolves it: clock-test.sh then passes (175 ok) and Wallclock loads in headless Quickshell.

Suggested change: Rebase onto quattro, keeping both registrations.

Reproducer (qmldir merge conflict)

In any clone of omacom/omarchy with the PR head fetched (git fetch origin pull/13347/head). Git 2.55.0.

Against the base recorded for the review, c5b4db77, the merge is clean:

$ git merge-tree --write-tree --name-only c5b4db77d68e7fbce5cf11120712ea322557e967 4ca1505b0ccf999782f00a4b1ced68e107a63b90; echo "exit=$?"
9a590944203b5856570d7c7654c5192062076808
exit=0

Against the quattro tip on 2026-09-29 (e332dc97), shell/Commons/qmldir conflicts:

$ git merge-tree --write-tree --name-only e332dc975d5f635294c497ebb54feb98dc3d89eb 4ca1505b0ccf999782f00a4b1ced68e107a63b90; echo "exit=$?"
4ce61f7d91fbfef735657ccdf0c71d6e38aa1b62
shell/Commons/qmldir

Auto-merging docs/omarchy-shell.md
Auto-merging shell/Commons/qmldir
CONFLICT (content): Merge conflict in shell/Commons/qmldir
Auto-merging shell/plugins/panels/clock/BarWidget.qml
Auto-merging shell/plugins/panels/clock/Panel.qml
Auto-merging test/shell.d/clock-test.sh
exit=1
$ git log --format="%h %s" -1 c231097d -- shell/Commons/qmldir
c231097d Answer omarchy-shell calls over the shell's own socket (#13435)

#13435 appended ShellIpc 1.0 ShellIpc.qml where the PR appends singleton Wallclock 1.0 Wallclock.qml. Keeping both lines resolves it; with that resolution test/shell.d/clock-test.sh passes (175 ok) and the PR's Wallclock loads in headless Quickshell.


Review information

Test scope: Source and sandbox tests at 4ca1505, with headless Quickshell 0.3.1 and a step simulated via Wallclock's baseline; no real clock change, suspend, NTP step or VM run.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

omarchybot and others added 2 commits October 3, 2026 06:29
quattro registered ShellIpc in shell/Commons/qmldir where this branch registers Wallclock; both registrations are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The wiring assertions checked that the predicate is called and that the baseline is updated, but not that the result raises `jumped`, nor that elapsed is measured before the baseline moves. Dropping the emit, negating the predicate, swapping those two lines, or removing the import or the signal each left every assertion passing while the bar stayed stale after a step; each now fails the test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 3, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and verified on a disposable VM built from the Omarchy ISO, running the shell from this branch.

Reproduction. With NTP off, I stepped the wall clock forward ten minutes just after a minute turned. This creates the same gap between wall-clock time and CLOCK_MONOTONIC that a suspend does, and I photographed the bar once a second. On quattro the bar still showed the old minute 14.6 s later. On this branch it showed the new minute within 1 s. With the widget's Wallclock connection removed from this branch, the bar went stale again. I did not run a real suspend, because the lock screen would hide the bar.

Tests. test/shell.d/clock-test.sh passes with 177 checks, plus bar-widget-contract, runtime-smoke and plugin-registry-contract. ./test/cli fails one assertion (vscode generated theme references current theme file), and it fails the same way on quattro. The full test/shell suite was not run.

Pushed to the branch:

  • A merge of quattro. Answer omarchy-shell calls over the shell's own socket #13435 registered ShellIpc in shell/Commons/qmldir on the line where this branch registers Wallclock, so the branch no longer merged. The merge keeps both registrations.
  • Three assertions in clock-test.sh. Before them, the test still passed if the watchdog never emitted jumped, if the predicate was negated, if the baseline moved before elapsed was measured, or if the import or the signal was removed. I made each of those five breakages on the VM: all passed the previous test and each fails this one. This is the gap the community review raised on September 29.

Second opinion. Codex Medium reviewed the change in two rounds. It confirmed against Quickshell's source that toggling enabled re-reads the time and reschedules synchronously, and that the calendar keeps a browsed month because the handler does not call refresh(). It found the test gap above. Its last round, on the current head, found nothing open. Where it agrees with my conclusions, its independence is not guaranteed.

Issues. This fixes #13504 and #7608, the stale bar clock after resume, and is now linked to close them. #13275 is the VM guest clock itself running wrong, with date matching the bar, so this PR does not address it.

Competing fixes. Four other open PRs fix the same bug: #12277 (logind PrepareForSleep watcher), #13541 (5 s minute check), #9509 (omarchy-system-wake) and #13658 (sleep-monitor restart). I asked Codex Medium to compare all five without giving it my answer, and it ranked this one first: it is the only one that also catches an NTP step and that leaves an open calendar on the month being browsed. #12277 is the strongest of the others and already carries ready. The other three either do not fire after every resume or update the label without re-arming the clock. #10138 is an older copy of this same commit.

Waiting on the maintainer to choose between this and #12277; only one of them should land.

@greptile-apps

greptile-apps Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the remaining automated-test gap is non-blocking.

Findings

  1. P2 Clock wiring lacks runtime coverage ▶

Summary

Adds a shared watchdog that notices wall-clock jumps and refreshes the bar clock and calendar.

  • The bar clock catches up as soon as wall-clock time jumps.
  • An open calendar catches up after a clock jump without changing months.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Watchdog tick] --> B{Clock moved beyond threshold?}
  B -->|Yes| C[Wallclock emits jumped]
  C --> D[Bar and calendar call clock.resync]
  D --> E[Read current date and restart timer]
  E --> F[Update label and calendar date]
Loading

Reviews (3) · Last reviewed commit: "Resync the clock's WallClock on a wall-c..." · Reviewed by Greptile

Comment thread test/shell.d/clock-test.sh Outdated
Comment on lines +280 to +285
assert(/singleton Wallclock 1\.0 Wallclock\.qml/.test(fs.readFileSync(root + '/shell/Commons/qmldir', 'utf8')), 'Wallclock is registered as a Commons singleton')
assert(/isDiscontinuity\(elapsed, root\.interval, root\.threshold\)/.test(wallclockCode), 'Wallclock reports a step using the tested predicate')
assert(/clock\.enabled = false\s*\n\s*clock\.enabled = true/.test(wallclockCode), 'Wallclock.resync toggles SystemClock off and back on to force a re-read')

assert(/target: Wallclock\s*\n\s*function onJumped\(\) \{ Wallclock\.resync\(clock\) \}/.test(widgetSource), 'clock widget resyncs when the wall clock steps')
assert(/target: Wallclock\s*\n\s*function onJumped\(\) \{ Wallclock\.resync\(clock\) \}/.test(panelCode), 'calendar panel resyncs when the wall clock steps')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Clock wiring lacks runtime coverage The new tests run the jump-detection calculation, but check the QML timer and resync wiring only by matching source text. A timer that never fires, or a clock that does not update after resync, could still pass. This is a non-blocking test gap; please add a QML test that runs the timer and checks that a jump updates a SystemClock.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

quattro's locale tests landed in clock-test.sh where this branch adds its Wallclock assertions, and both declare panelCode the same way; keep quattro's block, then the Wallclock assertions without the second declaration.
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 14, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This branch stopped merging after quattro added locale assertions to the end of test/shell.d/clock-test.sh, where this branch adds its Wallclock ones. Both sides declared the same panelCode constant. I pushed a merge of quattro (be4e94a) that keeps both blocks and the declaration once. No other file conflicted, and against quattro the pull request still adds only its seven files.

Re-verified at be4e94a on a disposable VM built from the Omarchy ISO, running the shell from this branch. With NTP off, I stepped the wall clock forward ten minutes just after a minute turned and cropped the bar clock about every 1.5 s. On quattro the bar kept the old minute for the full 20 s. On this branch it showed the new minute after 1.5 s. With the widget's Wallclock connection removed it stayed stale for 20 s again.

Tests. clock-test.sh passes with 189 checks, along with i18n, bar-widget-contract, runtime-smoke and plugin-registry-contract, and ./test/cli is green. The full ./test/shell run had 6 failing files out of 419, none of them about the clock. ascii, branding-about-animation and hyprland-startup-cursor-cold fail the same way on quattro. channel-sudo-boundary, screenrecording-process and ssh-reconnect pass when run alone, both here and on quattro.

Second opinion. Codex Medium reviewed the merge. It found the conflict resolution loses no assertion from either side. It also found that both connections still reach the SystemClock their label and calendar read, now that the panel builds its content on first open and a bar widget can sit in the tray drawer. Nothing on quattro adds a refresh path that undoes the fix. It found nothing open; it was told my conclusions, so its independence is not guaranteed.

What it waits on. Same as before: #12277 fixes the same bug through logind's PrepareForSleep and already carries ready, so the maintainer chooses which of the two lands. This one also catches an NTP step and leaves an open calendar on the month being browsed.

quattro's omacom#16334 removed the clock test's source-regex assertions, which conflicted with the Wallclock wiring assertions this branch appended after them. Resolved in the same spirit: the Wallclock source-regex assertions go too, and the six behavioural isDiscontinuity checks against WallclockMath.js stay.
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

The branch stopped merging after #16334 removed the source-text assertions from test/shell.d/clock-test.sh, which is where this branch appends its Wallclock assertions. I pushed a merge of quattro (20c89dc) that resolves it the way #16334 treated the rest of the file. It keeps the six isDiscontinuity checks, which run WallclockMath.js, and drops the regex assertions over Wallclock.qml, qmldir, BarWidget.qml and Panel.qml. Nothing from quattro is lost, and no other file conflicted.

Re-verified at 20c89dc on a disposable VM built from the Omarchy ISO, running the shell from each tree. With NTP off, I stepped the wall clock forward ten minutes 2–4 s after a minute turned, then cropped the bar clock every 1.5 s for 19 s. On quattro the bar kept the old minute for all 19 s. On this branch it showed the new minute in the first capture after the step. With the widget's Wallclock connection removed, it stayed stale for 19 s again.

Before, on quattro: 19 s after the clock was stepped to 13:56, the bar still reads 13:46
After, on this branch: 1.5 s after the clock was stepped to 13:55, the bar reads 13:55

Tests. clock-test.sh passes 107 checks, against 101 on quattro. i18n, bar-widget-contract and plugin-registry-contract pass, and ./test/cli is green. runtime-smoke fails one assertion (keepLoaded fixture service IPC responds), and it fails the same way on quattro. I did not run the full ./test/shell suite.

Second opinion. Codex Medium and muse-wonder (via pi, thinking high) reviewed the merge. Both found the conflict resolution loses nothing from quattro. They confirmed that both connections still reach the SystemClock the label and the calendar read after quattro's recent clock and panel changes, and that nothing on quattro refreshes the clock on resume. They found nothing open. They were told my reproduction results, so their independence is not guaranteed.

A collision with #16684. That PR, the fix for the daylight-saving log flood, replaces both SystemClocks with a Timer-based WallClock that has no enabled property. Wallclock.resync() returns early when !clock.enabled, so after #16684 lands the connections here would do nothing, and nothing would report it. #16684's WallClock arms a relative timer to the next minute, so it goes stale after a suspend just as SystemClock does, and it does not replace this fix. Whichever of the two lands second needs a small change: a re-read method on WallClock for these connections to call.

For the maintainer. AGENTS.md asks long-running shell code to react to events and keeps polling as a last resort. Wallclock wakes the shell once a second. It starts no process and is one shared timer, not one per monitor, and it does that because an NTP step has no signal the shell can listen to. #12277 fixes the same bug from logind's PrepareForSleep without polling, and it already carries ready. It does not catch an NTP step, and its refresh moves an open calendar back to the current month. Only one of the two should land, so this waits on the maintainer's choice. It stays without ready while #12277 has it.

omacom#16684 replaced SystemClock with a Timer-based WallClock, which has no enabled property, so Wallclock.resync returned early and both connections did nothing. WallClock now re-reads the time and re-arms from now when asked.
@omarchybot

Copy link
Copy Markdown
Collaborator

#16684 has merged, and as the last comment here expected, it left this fix doing nothing. It replaced both of the clock plugin's SystemClocks with a Timer-based WallClock, which has no enabled property, so Wallclock.resync(clock) returned at its !clock.enabled check and neither connection reached the clock. I pushed two commits: baa960c merges quattro with no conflicts, and be1fdf7 gives WallClock a resync() that re-reads the time and re-arms from now, with the bar's and the calendar's Wallclock connections pointed at it. Wallclock.resync(clock) is unchanged and still serves a plugin that uses its own SystemClock, as the docs section describes.

Re-verified at be1fdf7 on a disposable VM built from the Omarchy ISO, running the shell from each tree. With NTP off, I stepped the wall clock forward ten minutes 2 s after a minute turned, then cropped the bar clock every 1.5 s for 19 s. On quattro (c2818bb) the bar kept the old minute for all 19 s. On this branch it showed the new minute by the second capture, 1.5 s after the step. At baa960c, which is this branch without be1fdf7, it stayed stale for all 19 s.

Before, on quattro: 19 s after the clock was stepped to 05:40, the bar still reads 05:30
After, on this branch: 1.5 s after the clock was stepped to 05:47, the bar reads 05:47

Tests. clock-test.sh passes 113 checks, bar-widget-contract passes, and ./test/cli is green. The full ./test/shell suite fails the same 4 checks on this branch as on quattro: runtime-smoke's keepLoaded IPC, an ascii width check, a first-run git identity check and a branding animation. None of them touch the clock.

Second opinion. Codex Medium and muse-wonder (via pi, thinking high) reviewed the merge and the new commit. Both found nothing lost from quattro or from this branch. Both confirmed that resync() updates the bar label and the calendar's today without moving a month being browsed, and that nothing in the tree still hands a WallClock to Wallclock.resync. They found nothing open. I told them what #16684 had broken, so their independence is not guaranteed.

For the author. The description no longer matches the branch. It describes the plugin's clocks as SystemClocks and the test as 175 checks with seven wiring mutants. After #16334 and #16684, clock-test.sh keeps the six isDiscontinuity checks, and the plugin's own clocks resync through WallClock.resync(). With that change, nothing in the repository calls Wallclock.resync(clock) any more; it and its docs section are there only for third-party plugins.

For the maintainer. The choice from the last comment still stands, and this waits on it. Wallclock wakes the shell once a second, which AGENTS.md keeps as a last resort, because an NTP step has no event the shell can listen to. #12277 fixes the suspend case from logind's PrepareForSleep and carries ready. Reading its source, it resets the clocks by toggling enabled, the property WallClock lacks. Its refresh() also no longer sets displayDate, so it looks affected by #16684 the same way. It will be checked in its own review. This stays without ready while #12277 has it.

@omarchybot

Copy link
Copy Markdown
Collaborator

No new commits here since be1fdf7, and the branch still merges cleanly onto today's quattro. Since the last verification, the only change to the clock plugin on quattro is #18524's hover-reveal cleanup in Panel.qml, which doesn't touch the clock or its resync. So the worker results in the last comment still stand, and I didn't run them again.

A correction to the last comment. #12277 has been updated since. It now catches up through a new WallClock.catchUp() instead of toggling enabled, so it works with the WallClock that #16684 brought in. It no longer carries ready.

Competing fixes. Codex Medium compared the seven open fixes for #7608 (#9509, #10138, #12277, this one, #13541, #13804 and the new #18892) at their current heads, without being told which to prefer, and picked #12277. I checked its reasoning against the source and agree. #12277 is the older of the two that work on quattro today. It catches up on every logind resume, short ones included. It re-arms both clocks, and it leaves a month being browsed in the calendar alone. By the rule this project uses, the oldest fix wins unless a newer one is clearly better, and this one isn't:

Both differences are small, and neither is a defect that settles the choice.

What happens next. This waits on the maintainer to choose between this and #12277: a once-a-second watchdog in the shell, or a shell-side PrepareForSleep watcher. It won't be brought to ready while #12277 is the preferred fix. It keeps verified for be1fdf7.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bar clock shows pre-suspend time for up to a minute after resume Top bar date/time take 30-60+ seconds to update after waking up a laptop

4 participants