Skip to content

feat(config): add exclude_apps option to suppress logging for matched apps - #156

Merged
ErikBjare merged 13 commits into
ActivityWatch:masterfrom
TimeToBuildBob:feat/exclude-apps
Oct 14, 2026
Merged

ErikBjare merged 13 commits into
ActivityWatch:masterfrom
TimeToBuildBob:feat/exclude-apps

Conversation

@TimeToBuildBob

@TimeToBuildBob TimeToBuildBob commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Highest-demand forum request (23 posts, ~17k views): Add an exclude list.

Users sometimes want specific apps — password managers, adult content, private notes — to never appear in their activity log at all. The existing --exclude-title only redacts the title but still logs the app name and emits the event. This PR adds exclude_apps: a list of regex patterns that suppress the entire event before it reaches the server.

What this changes

  • config.py: new exclude_apps = [] default config key; new --exclude-apps CLI flag (regex patterns, can specify multiple). Read with config.get("exclude_apps", []) for backward compatibility with older configs.
  • main.py: transform_window() returns None when the window's app field matches any pattern, applied before the research transform (a matching app must never be logged, Research Edition included); patterns are compiled case-insensitively via a shared helper, matching the Swift side. heartbeat_loop() skips the heartbeat on None.
  • macos.swift + macos_cli.py: --exclude-apps is wired through build_swift_command to the Swift helper, which matches the frontmost application before any browser processing — an excluded app neither emits a heartbeat nor surfaces titles/URLs in logs, and incognito Chrome (whose app name is cleared) is still suppressed. It also drops the pending heartbeat so the next elapsed-time pulse cannot extend the preceding app's event across the excluded interval. This closes the gap where the default macOS swift strategy silently bypassed exclusions.
  • tests/test_main.py: unit tests covering matched/unmatched/partial/empty cases, research-mode precedence, case-insensitive compilation, and Swift command wiring; existing fixtures updated for the new key.

Behavior note: excluded time is a gap

A suppressed window emits no heartbeat and does not close the previous event with a sentinel/empty heartbeat — a sentinel would itself be logged, defeating the feature. The server only extends the previous event within pulsetime, so the excluded interval appears as a gap in the timeline rather than being attributed to the prior window.

Usage

Config file (aw-watcher-window.toml):

[aw-watcher-window]
exclude_apps = ["1Password", "KeePassXC", "org\\.gnome\\.Seahorse"]

CLI:

aw-watcher-window --exclude-apps 1Password KeePassXC

Test plan

  • python -m pytest tests/ -q — 87 passed
  • macOS swiftc build of macos.swift (CI make build on macos-latest) — validates the new --exclude-apps argument parsing
  • Manual: run watcher with --exclude-apps 1Password, open 1Password, confirm no event appears in the aw-server bucket

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Adds app exclusion filtering to window activity logging.

The PR appears safe to merge based on the reviewed changes.

Summary

The PR adds app-pattern exclusions to both the Python polling path and the default macOS Swift helper, suppressing matched heartbeats and breaking the heartbeat chain across excluded time. The latest changes split non-X error backoff into short sleeps so an orphaned watcher can exit sooner.

  • Exclusions run before research transformation and, in Swift, before browser processing.
  • No new actionable issue was identified in the changes since the previous review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Capture foreground app] --> B{Matches exclude_apps?}
  B -->|Yes| C[Skip heartbeat and break pulse chain]
  B -->|No| D[Apply privacy transform]
  D --> E[Send heartbeat]
Loading

Reviews (5) · Last reviewed commit: "fix(exclude-apps): chunk the sustained-e..." · Reviewed by Greptile

Comment thread aw_watcher_window/config.py Resolved
Comment thread aw_watcher_window/main.py Resolved
Comment thread aw_watcher_window/main.py Resolved
@TimeToBuildBob

TimeToBuildBob commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 AI code review

Adds an exclude_apps config key and --exclude-apps CLI flag that suppress heartbeats for matching app names. Wires the flag through build_swift_command into the macOS Swift helper, which checks the frontmost app before browser processing and drops pending heartbeats. In the Python heartbeat loop, transform_window returns None for matching apps and the loop skips the heartbeat, using pulsetime=0 for the next heartbeat to break the merge chain. Adds tests for config coercion, transform behavior, and heartbeat-loop sequencing.

Safe to merge — no P0/P1 findings

Confidence 5/5

✅ No findings. The diff looks correct to me on this pass.

Files changed (6) — the diff as I read it
  • aw_watcher_window/config.py — Adds exclude_apps default, --exclude-apps argument, and string-to-list coercion with validation.
  • aw_watcher_window/macos.swift — Adds excludeAppPatterns, --exclude-apps parsing, appShouldBeExcluded check, and dropForExclusion/breakMerge logic.
  • aw_watcher_window/macos_cli.py — Adds exclude_apps parameter and emits --exclude-apps flags for each pattern.
  • aw_watcher_window/main.py — Renames try_compile_title_regex to try_compile_regex, adds exclude_apps to transform and heartbeat loop, and adds pulsetime=0 chain-break logic.
  • tests/test_config.py — Adds tests for exclude_apps string/list coercion and invalid config errors.
  • tests/test_main.py — Adds tests for transform_window exclusion, regex compilation, heartbeat-loop skipping, and updates fixtures.
Previous review passes
commit score findings engine when
5ade4e1cc55f 3/5 3 llm 2026-10-02 06:41 UTC
6f72f4ea7ded 5/5 0 llm 2026-10-02 11:53 UTC
fa46c6327d0a 3/5 2 llm 2026-10-03 03:10 UTC
dd372860cd5e 4/5 2 llm 2026-10-03 03:53 UTC
0c109c58fb7e 4/5 3 llm 2026-10-03 05:03 UTC
870f414e287f 4/5 2 llm 2026-10-03 06:03 UTC
f5bcacf7a628 4/5 2 llm 2026-10-07 13:40 UTC
7cbb33cfc9f5 3/5 1 llm 2026-10-07 17:24 UTC
975fac889573 5/5 0 llm 2026-10-07 18:01 UTC
8e3d378b44eb 5/5 0 llm 2026-10-09 04:54 UTC

Reviewed dca2077694de · openrouter/deepseek/deepseek-v4-flash-0731 · llm engine · 54s · about this reviewer

Maintainer commands

@TimeToBuildBob review (own line) — fresh review · @TimeToBuildBob fix — a worker acts on the findings. Once per comment; 👀 = received.

Comment thread tests/test_main.py Resolved
Comment thread aw_watcher_window/main.py Resolved
Comment thread aw_watcher_window/main.py Fixed
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

Comment thread aw_watcher_window/macos.swift Resolved
Comment thread aw_watcher_window/macos.swift Resolved
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Addressed the review findings — head 6f72f4e, all CI green (macOS/Ubuntu/typecheck).

CI red — parse_args read config["exclude_apps"] unconditionally, so any config dict without the key (including the two existing test_config fixtures) raised KeyError. Now read with config.get("exclude_apps", []), backward compatible with pre-existing configs.

Research mode bypass — transform_window returned through the research branch before the exclusion check, so a configured sensitive app still produced a Research Edition heartbeat. Exclusion now runs first: a matching app is never logged, research mode included.

Default macOS strategy ignored exclusions — --exclude-apps is now threaded through build_swift_command into the Swift helper. The check matches the frontmost application before any browser processing, so an excluded app neither emits a heartbeat nor leaks its title/URL into logs, and incognito Chrome (whose app name is cleared to "") is still suppressed. Suppression also drops the pending heartbeat, so the next elapsed-time pulse cannot refresh the preceding app's event across the excluded interval.

Case consistency — Python now compiles exclusion patterns with IGNORECASE through a shared try_compile_regex helper (with an invalid-pattern exit), matching Swift's .caseInsensitive, so one config behaves identically on Linux/Windows and macOS.

Tests — 87 passing, including heartbeat_loop integration (excluded app → no heartbeat; logged app → heartbeat sent), research-mode precedence, case-insensitive compilation, and Swift command wiring.

Behavior note: a suppressed window leaves a gap rather than closing the previous event with a sentinel heartbeat, since a sentinel would itself be logged; the server only merges within pulsetime.

Greptile re-triggered after the push.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Checked the latest Greptile pass on 6f72f4e (4/5, no new inline findings). Its remaining note says the excluded-time attribution on the Swift path isn't "fully fixed", but I traced every entry point: the AX observer callbacks, focusedAppChanged and the 10s pollActiveWindow timer all funnel through windowTitleChanged, where the exclusion check now runs first and sets oldHeartbeat = nil. After an excluded interval the next allowed heartbeat therefore sees no previous event: no refresh of the old app's event and a 1s pulse, so the excluded time stays a gap.

One theoretical residue: a sendHeartbeat Task already in flight at the moment of exclusion could re-set oldHeartbeat when its HTTP call returns. That is a millisecond-wide localhost window, and I can't compile or test Swift here, so I'm not changing it blind. No further code changes from me; this is ready for human review.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Pushed fa46c63 to close the one remaining unresolved thread (CodeQL mixed-returns in try_compile_regex): the except re.error branch now uses an explicit raise SystemExit(1) instead of exit(1), so the function no longer has an implicit return None path. Behavior is unchanged — exit(1) already raises SystemExit — and tests/ -q passes locally (87 passed).

All Greptile threads are now resolved. The 4/5 score reflects the macOS Swift excluded-time note, which I traced in the previous comment (every entry point funnels through windowTitleChanged, where exclusion sets oldHeartbeat = nil first). No further code changes from me; CI is re-running on the new head — this is ready for human review.

Comment thread aw_watcher_window/main.py Fixed
Comment thread aw_watcher_window/main.py Resolved
Comment thread tests/test_main.py Resolved
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Merge recommendation — adjudication of escalated review findings

Fixed (this session)

  • P2 test-defect (tests/test_main.py:325, our reviewer): added test_heartbeat_loop_excluded_app_between_allowed_windows in dd37286 — drives [Editor, 1Password(excluded), Editor] through heartbeat_loop and asserts the client receives exactly ["Editor", "Editor"], never the excluded window's data. pytest tests/ -q → 88 passed, 11 subtests passed.

Remaining (non-blocking, disposed)

  • P1 (aw_watcher_window/main.py:222, our reviewer) — rejected, thread resolved. Heartbeat merging requires identical event data in both layers, so the finding's Editor → excluded → Chrome example cannot occur:
    • client pre-merge aw_transform.heartbeats.heartbeat_merge returns a merge only when last_event.data == heartbeat.data;
    • server aw-server-rust aw_transform::heartbeat returns None on heartbeat.data != last_event.data before it considers pulsetime.
      The only real residue — the same app/title flanking the excluded window (Editor → 1Password → Editor) — is an inherent ≤pulsetime (2s default) attribution trade-off, unavoidable without a sentinel heartbeat that would itself be logged, which is exactly what this feature avoids. The privacy guarantee holds: the excluded app and title are never sent to the client or server. The macOS path takes the same approach (drops the pending heartbeat on exclusion).

Verified against: dd372860cd5e47c06a26256eabc5319ebadd5912

CI: pending on dd37286 (test-only commit; prior head fa46c632 was fully green — Analyze, CodeQL, macOS/Ubuntu/Windows, typecheck). Not watched; next monitoring cycle confirms.

Domain risk: the macOS Swift helper has no CI coverage here — the excluded-window/same-app merge semantics are exercised only through the Python path's new test. A maintainer manual smoke test on macOS (brief switch into an excluded app between two same-app intervals) would confirm the oldHeartbeat = nil behavior.

Convergence: greptile-convergence.py verdict converged — 0 unresolved P1/P2/P3; round_convergence.stable_rounds = 0 (of 2 required). All 5 prior Greptile P1 threads are resolved; the 2 remaining were our own reviewer's, both disposed this session. No further Greptile trigger.

Not merging — stopping at maintainer judgment.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI is now green on dd37286 — Analyze, CodeQL, macOS/Ubuntu/Windows, typecheck all pass. PR is MERGEABLE with 0 unresolved threads. No further code changes from me; ready for maintainer review.

Comment thread aw_watcher_window/macos.swift Resolved
Comment thread tests/test_main.py Resolved
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Addressed the two P2 findings from the 04:09 AI review in 0c109c5:

  • macos.swift — in-flight send could resurrect a cleared heartbeat: fixed structurally. sendHeartbeat snapshots the previous heartbeat and an exclusion generation synchronously before the async send, the exclusion path bumps the generation, and the task only writes oldHeartbeat back when the generation is unchanged. An excluded interval can no longer be merged onto the preceding app via an in-flight refresh. (This also removes an oldHeartbeat! force-unwrap that could trap if exclusion nilled it before the task ran.)
  • tests/test_main.py — vacuous title assertion: the excluded window's title now carries its app name, so the assertion actually fails if exclusion is bypassed (verified: with exclude_apps=[] the titles become ['file.py', '1Password — Vault', 'file.py']).

Both threads are resolved. pytest tests/ -q → 88 passed, 11 subtests passed. CI is re-running on 0c109c5; the macOS job compiles the Swift helper. No further code changes from me — ready for maintainer review.

Comment thread aw_watcher_window/macos.swift Resolved
Comment thread aw_watcher_window/config.py Resolved
Comment thread tests/test_main.py Resolved
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Handled the 05:04 AI review pass on 0c109c5. Dispositions:

  • P2 aw_watcher_window/macos.swift:499 — rejected (false positive). The generation check guards oldHeartbeat state, not attribution. A heartbeat's timestamp is in the payload and is fixed while the preceding app is still frontmost, so a send that lands after the excluded app becomes active still records the preceding app at its own timestamp; its pulsetime (timeSinceLastHeartbeat + 1) is derived from that app's own previous heartbeat and cannot extend it into the excluded interval. The excluded app itself never produces a heartbeat — windowTitleChanged returns before sendHeartbeat. Replied + resolved inline.
  • P2 tests/test_main.py:346 — rejected (non-actionable). The finding's own text says the test is "not defective per se" and defers to the macos.swift finding, which is a false positive. The test guards client-side suppression across a sequence; server pulsetime merge semantics for the same-app flanking case are an accepted inherent trade-off (a sentinel heartbeat would itself be logged, defeating the feature). Replied + resolved inline.
  • P2 aw_watcher_window/config.py:50 — fixed in 870f414. A bare-string config value (exclude_apps = "1Password") is now coerced to a single pattern instead of being iterated character-by-character by nargs='+'. Added tests for the string (coerced) and list (preserved) forms; tests/ -q → 90 passed. Replied + resolved inline.

0 unresolved review threads; CI re-running on 870f414. No further code changes planned from my side — ready for maintainer review.

Comment thread aw_watcher_window/macos.swift Resolved
Comment thread tests/test_main.py Resolved
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Merge recommendation — convergence adjudication (head 870f414)

Adjudication pass on the escalated review state. No code changes this session — both remaining threads were our own AI reviewer's P2 findings, and their own verification text concludes each is non-defective.

Fixed: none this session (adjudication only; the two prior rounds' P1s were fixed across 51aff4b→870f414).

Remaining (non-blocking), each disposed with a reply + resolve:

  • macos.swift:642 — accepted trade-off. The comment is an ordering justification (exclusion must run before browser processing, because incognito Chrome would clear the app name to "" by the time a later check saw it), not a claim that the check sees a cleared name. localizedName is consistent with the file's existing frontmost.localizedName == "Safari" branch; unifying macOS/Python app-name identity is a cross-platform refactor out of scope here.
  • tests/test_main.py:366 — rejected (false positive). The test is correct, as the finding's own analysis states: the primary catch is [hb.data["app"] for hb in heartbeats] == ["Editor", "Editor"], which fails on any bypass; the title assertion is intentionally complementary and the inline comment says exactly that. No test change needed.
  • Summary-only advisory config.py:54 (a non-string element in a mixed TOML array raises TypeError rather than re.error) — accepted robustness guard, not scored, no thread opened.

Verified against: head 870f414e287f4eef1b295812b18608fa5b8ff65d (newest AI-review marker sha 870f414e287f matches head — adjudication is on a reviewed head).

CI: all green — Analyze (python), CodeQL, macOS / Ubuntu / Windows, typecheck.

Domain risk: the macOS Swift exclusion path (AxObserver windowTitleChanged, focusedAppChanged, 10s poll, incognito-Chrome branch) is not exercised by CI on this runner set — a maintainer manual smoke test on macOS (exclude an app, confirm no heartbeat and a gap over the excluded interval; then check incognito Chrome) is the remaining confidence gap.

Convergence: greptile-convergence.py verdict converged — no unresolved P1 or P2 findings; round_convergence reports stable_rounds: 0 (status new_blocking, two P1 rounds of 3+2, all addressed), at the attempt cap. No re-trigger.

Cross-repo, pull-only — not self-mergeable. Stopping at maintainer merge judgment.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Rebased onto master (f825398) to clear the conflict; new head 5fe8f99.

Two conflicts, both from master moving underneath:

No behaviour changes. Locally: 117 tests pass, and mypy reports no issues.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Rebased again onto master (c8814e4, after #157 landed); new head f5bcacf. One conflict in aw_watcher_window/main.py: kept #157's error-dedup constants and this PR's shared try_compile_regex(pattern) helper (replaces try_compile_title_regex). Tests 120 passed, make typecheck clean locally.

Comment thread aw_watcher_window/config.py Resolved
Comment thread tests/test_main.py Resolved
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Merge recommendation — convergence adjudication

  • Fixed: config-validation gap (config.py) — exclude_apps now validates like exclude_titles after parse_args (bare string coerced; int/bool/table/non-string list → parser.error). Commit f435f57, tests added (test_invalid_exclude_apps_config_errors, 4 param cases). Local suite: 123 passed, 1 skipped.
  • Remaining (non-blocking): one test-coverage observation on test_heartbeat_loop_excluded_app_between_allowed_windows — the test verifies the privacy guarantee it exists for; gap attribution across the excluded interval is aw-server's pulsetime merge behavior, out of this watcher's scope. Dismissed on the inline thread.
  • Verified against: head f435f57 for the fix (previous head f5bcacf7a628 for the two reviewed findings — the validation finding is checked directly against the fix commit).
  • CI: green on f5bcacf (Analyze, CodeQL, macOS/Ubuntu/Windows tests, typecheck); fresh run for f435f57 in progress.
  • Domain risk: the macOS Swift exclusion path (appShouldBeExcluded, heartbeat generation counter) is not exercised by CI — a maintainer manual test excluding one app on macOS is the one thing worth doing before merge.
  • Convergence: detector reports 2 stable rounds at score 4/5 with only non-blocking findings; attempt cap reached, so this adjudication closes the loop. No further review rounds from my side — ready for maintainer judgment.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

The Analyze (python) (CodeQL) failure on the previous head was infra, not code: the job ran 2h28m and failed with no failing step, while every recent CodeQL run in this repo — including this same branch the day before — passed. All test/typecheck checks were green.

No rerun permission as a contributor, so pushed an empty commit (7cbb33c) to retrigger fresh CI. No code changes.

Comment thread aw_watcher_window/main.py Resolved
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

@greptile-apps

This comment has been minimized.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

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.

TimeToBuildBob and others added 13 commits October 11, 2026 08:12
… apps

Users can now configure a list of regex patterns in aw-watcher-window's config
to prevent specific apps from ever being logged. Matching windows are dropped
before the heartbeat is sent — no data ever leaves the client.

  # In aw-watcher-window's config file:
  exclude_apps = ["1Password", "keepassxc"]

  # Or via CLI:
  aw-watcher-window --exclude-apps 1Password keepassxc

This is distinct from --exclude-title (which still logs the app name). The new
option gives privacy-conscious users a clean way to suppress sensitive apps
entirely.

Closes #N (forum.activitywatch.net/t/add-an-exclude-list/345)

Git-Session-Id: 0012
…OS swift path

- config: read exclude_apps with .get() so configs/tests without the key
  don't crash parse_args (fixes 2 failing tests)
- transform_window: apply exclude_apps before the research transform — a
  matching app must never be logged, research mode included
- macos: wire --exclude-apps through build_swift_command and the Swift
  helper so the default macOS swift strategy honours exclusions instead of
  silently bypassing them

Git-Session-Id: 77f733c5-217c-5d05-bb77-a00832ca811f
- use one try_compile_regex helper (IGNORECASE + invalid-pattern guard) for
  both exclude_titles and exclude_apps, so a config value matches the same on
  Linux/Windows (Python) as on macOS (Swift .caseInsensitive)
- document that a suppressed heartbeat intentionally leaves a gap rather than
  closing the previous event with a sentinel

Git-Session-Id: 77f733c5-217c-5d05-bb77-a00832ca811f
…eartbeats

Git-Session-Id: 77f733c5-217c-5d05-bb77-a00832ca811f
- move the Swift exclusion check ahead of the Chrome/Safari/Firefox branches
  so an excluded app cannot surface titles/URLs in logs, and so incognito
  Chrome (whose app name is cleared to "") is still suppressed
- drop oldHeartbeat when suppressing: otherwise the next heartbeat's
  elapsed-time pulse refreshes the preceding app's event across the excluded
  interval, recording excluded time as another app's activity

Git-Session-Id: 77f733c5-217c-5d05-bb77-a00832ca811f
…d-returns)

Git-Session-Id: d3074d53-f945-581b-95a4-61bf83bfaf6c
Git-Session-Id: f83f2353-d267-5fff-ac1f-6114a9d60d4e
…artbeat

The exclusion path clears oldHeartbeat synchronously to keep the excluded
interval a gap, but sendHeartbeat only assigned oldHeartbeat after its async
network send completed. A send in flight at the moment of exclusion would
therefore re-populate the cleared heartbeat, and the next allowed app's
heartbeat would merge the preceding app's event across the excluded interval.

Snapshot the previous heartbeat and an exclusion generation counter before
starting the task, read the previous data from the snapshot (also removing a
force-unwrap of a possibly-cleared global), and skip the write-back when an
exclusion happened meanwhile.

Also make the flanked-window test's title assertion meaningful: the excluded
window's title now carries its app name, so the assertion fails if exclusion
is ever bypassed (previously it passed vacuously).

Git-Session-Id: bc8df157-00ca-5747-a672-894c8dc16185
…ttern

A bare TOML string (`exclude_apps = "1Password"`) is natural for a single
app, but argparse's `nargs='+'` passes a string default through unchanged and
main.py then iterates it character-by-character, compiling each character as a
regex and silently excluding far more apps than intended. Coerce a string
default to a one-element list at the config read site.

Git-Session-Id: 06f6d005-e246-548d-b9bd-7c05dab33f56
A TOML value like exclude_apps = 17 or a table reached main.py unvalidated:
the int case crashed with TypeError on iteration and a table silently
compiled its keys as patterns. Mirror the exclude_titles validation with
a parser.error after parse_args.

Git-Session-Id: e9426c64-f25f-5a23-9d5e-a31e179615b8
…iling step)

Git-Session-Id: b2b8d4dd-1fbc-574c-b9c2-752a23d63c9a
The server merges an incoming heartbeat into the last stored event when
the gap is within the heartbeat's pulsetime. After an excluded window,
the next allowed-app heartbeat carried compute_pulsetime(poll_time), so
a visit to an excluded app shorter than that window was merged into the
preceding app's event — attributing excluded time to another app and
leaking the switch.

Python: track the exclusion and send the first post-exclusion heartbeat
with pulsetime=0, breaking the merge chain without emitting any event
for the excluded app. The excluded interval is now a real gap.

Swift: same fix — after the exclusion clears oldHeartbeat, the next
heartbeat used since_last(0)+1 = 1s pulsetime, still merging sub-second
visits. A pulse-break flag now forces pulsetime 0 on that send.

Also corrects the misleading incognito-Chrome comment (the exclusion
check sees the real localizedName, not the cleared app name) and the
misleading bypass-detection comment in the flanked-windows test.

Git-Session-Id: 597d23ac-9d3a-5be6-acde-2183b9bdfe09
…is noticed

The X-connection backoff already sleeps in 1-second chunks with a
getppid() check, but the generic sustained-error backoff (added by this
PR) slept the whole extra interval (up to ~59s) in one call. An orphaned
watcher on a non-X strategy could thus keep running for nearly a minute
after parent shutdown. Sleep in 1s chunks with the same parent-death
check; update the backoff tests to assert the chunked behaviour while
still verifying the 60s total-interval cap.

Git-Session-Id: 251a57be-d656-5c30-abfe-89b0eba787bf
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Merge conflict resolved — the branch was rebased onto current master (master had moved underneath it: #155's _is_xconn_error/_warn_wayland_once helpers and #157's error-dedup constants, both kept alongside this PR's shared try_compile_regex helper).

Current state at head dca2077:

  • MERGEABLE / merge state CLEAN
  • All 6 checks green — CodeQL, Analyze (python), typecheck, tests on ubuntu/macos/windows
  • AI review 5/5, no unresolved threads

Cross-repo and pull-only for the bot, so this is waiting only on a maintainer merge click. Nothing further to fix from my side.

@ErikBjare

Copy link
Copy Markdown
Member

@TimeToBuildBob This is certainly one way, but doesn't feel very easily configured (doesn't respect settings set in webui/on server). How does it relate to the privacy filter feature in the server? What would be the best UX/feature design here? (better policy options like drop or redact)

Worth a separate issue for, I'll merge this in the meantime.

@ErikBjare
ErikBjare merged commit 1d07782 into ActivityWatch:master Oct 14, 2026
6 checks passed
ErikBjare pushed a commit that referenced this pull request Oct 14, 2026
PR #156 added the --exclude-apps option but the startup test fixture's
parse_args mock was missing exclude_apps=[] in its SimpleNamespace,
causing main() to raise AttributeError and both tests to fail across
all platforms.

Git-Session-Id: f4473ca7-7cc0-433b-a9ad-a1b68c47b487
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.

3 participants