Repository navigation
Conversation
aw-client's wait_for_start() gives the server 10 seconds and raises 'did not start in time' on a slow boot, killing the watcher. The bucket is already registered with queued=True and heartbeats are queued, so the client's persistent queue creates the bucket and replays heartbeats once the server answers. Same fix as ActivityWatch/aw-watcher-afk#93. Refs ActivityWatch/activitywatch#1525 Git-Session-Id: da745699-4420-404b-a5de-c076703d380c
|
| heartbeats = [payload["data"] for _, url, payload in requests_[1:]] | ||
| assert all("/heartbeat?pulsetime=" in url for _, url, _ in requests_[1:]) | ||
| assert heartbeats[0] == {"app": "editor", "title": "one"} | ||
| assert {"app": "editor", "title": "two"} in heartbeats |
There was a problem hiding this comment.
test_records_offline_then_creates_bucket_before_replaying checks the first heartbeat and whether title two appears anywhere, but never checks title three or its position. The expected count also comes from the queue itself, so a missing sample can shrink both sides of that check. A dropped third sample or reordered later samples could therefore pass.
Assert that all three sampled windows appear in their original order, allowing any extra heartbeats that aw-client deliberately adds.
There was a problem hiding this comment.
Fixed in 9e1728c. The test now pins the exact replayed sequence ([one, two], in order) and fixes the expected count at 2 instead of deriving it from the queue. It also asserts that three is in aw-client's pre-merge cache (client.last_heartbeat[bucket_id]). A queued heartbeat is enqueued only when the next, different sample arrives, so the newest sample is never in the queue at shutdown. That is client behaviour, not a dropped sample. Each of the three samples is now accounted for, so a dropped or reordered sample fails the test.
|
CI-green and mergeable — waiting only on a maintainer click. This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted. |
🤖 AI code reviewRemoves the client.wait_for_start() call from main() so the watcher starts recording immediately, relying on the persistent queue to create the bucket and replay heartbeats once the server is available. Adds tests/test_startup.py with an OfflineServer that patches requests to simulate a down server, verifying offline recording, bucket creation before replay, and offline shutdown preserving queued heartbeats. Safe to merge — no P0/P1 findingsConfidence 5/5 ✅ No thread-worthy findings. Advisory notes follow; they are retained without opening review threads. 1 advisory finding (summary-only, not scored)These P2 guard, heuristic, trade-off, or documentation claims are retained for judgment without opening review threads.
The test's How this was verified: The OfflineServer always returns 200 for all requests, including bucket creation. The real server would return 404 for a missing bucket, but the test does not simulate that. This could cause the client to not create the bucket, but the test's assertions might still pass because the client sends the bucket creation request regardless. The test is not hermetic but it's a trade-off. Consensus: 2/3 passes agreed — pass 1 looked and disagreed Files changed (2) — the diff as I read it
Reviewed Maintainer commands
|
The replay test only checked the first heartbeat and that 'two' appeared somewhere, and derived the expected count from the queue itself, so a dropped or reordered sample could pass. Pin the exact replayed sequence and assert the newest sample sits in aw-client's pre-merge cache. Git-Session-Id: 9c782e13-0b54-5cb3-80d6-f34dbcb77d0d
|
@greptileai review |
aw-watcher-afk 5aaab742 -> 2762612e (ActivityWatch/aw-watcher-afk#93: keep recording while the server starts) aw-watcher-window c8814e49 -> e2752196 (ActivityWatch/aw-watcher-window#164: don't exit when aw-server starts slowly at boot) Both fix commits are ancestors of the pinned SHAs. Minimal bump to the merge commits only; no unrelated watcher changes are pulled in. Git-Session-Id: 286d8831-484c-4f42-8c75-c884eaee25ea
Same startup failure as ActivityWatch/activitywatch#1525, in the window watcher.
main()callsclient.wait_for_start()before recording; aw-client gives the server 10 seconds and then raisesServer at http://127.0.0.1:5600 did not start in time, so a slow (Windows) boot kills the watcher. The afk watcher got the same fix in ActivityWatch/aw-watcher-afk#93.The wait is redundant: the bucket is already registered with
queued=Trueand every heartbeat is queued, so the client's persistent queue creates the bucket and replays heartbeats once the server answers. The macOS swift helper already retries delivery and creates its bucket lazily (#162).Verified —
tests/test_startup.pydrivesmain()with the realaw-clientand its SQLite queue against a server that is down until the test brings it up:Both fail on master (blocked in
wait_for_start) and pass with this change; stable over 5 reruns. Full suite 109 passed, mypy clean.Refs ActivityWatch/activitywatch#1525