feat(macos): persist heartbeat queue to disk across watcher restarts

Open
#163 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python, swift
Domain
backend, data

Research direction

Read PR #162 and inspect the HeartbeatSender actor and aw_watcher_window/macos.py; compare the Swift sender with aw_client.client.ActivityWatchClient and its persist-queue behavior. First determine whether the Python wrapper can receive structured heartbeats from the Swift binary. Done means pending heartbeats survive watcher restarts, using an approach selected after resolving that architecture question.

Written by the indexing model from the issue text.

Description

Background

PR #162 (merged 2026-10-10) replaced fire-and-forget per-heartbeat Tasks with a serialised HeartbeatSender actor that retries failures with exponential backoff and creates the bucket lazily. This fixes the immediate reliability gap.

The PR description explicitly notes two follow-ups:

Persisting the queue to disk across watcher restarts (the Python watchers get that from aw-client's persist-queue); the TODO about letting the Python wrapper own the sending still stands.

Gaps

1. In-memory queue is lost on watcher crash

The current HeartbeatSender queue survives a server outage (up to ~28 h at one heartbeat per 10 s), but is lost if the watcher process itself crashes. The Python-based watchers avoid this via aw-client's persist-queue which writes pending heartbeats to disk and replays them on restart.

Risk window: watcher crash after a server outage → queued backlog is dropped and the gap appears as idle time.

2. Python wrapper could own the sending

aw_watcher_window/macos.py spawns the Swift binary and proxies its output. An alternative architecture would have the Python wrapper intercept heartbeats from the Swift binary and route them through aw-client (which already has persist-queue). This would:

  • Remove the need for Swift-native persistence
  • Reuse the battle-tested aw-client persist-queue implementation
  • Let the macOS watcher benefit from future aw-client reliability improvements automatically

Open question: can the Python wrapper intercept Swift binary output as structured heartbeats rather than display strings? If not, this architecture is blocked and Swift-native persistence is the path.

Relation

  • Follows from: #162
  • Related: the Python watchers use aw-client persist-queue via aw_client.client.ActivityWatchClient
Dominant language
Python
Stars
133
Forks
92
Avg merge
5d 3h
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ActivityWatch/aw-watcher-window

All issues in ActivityWatch/aw-watcher-window

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.