Repository navigation
fix(macos): keep foreground tracking when browser context fails - #146
TimeToBuildBob wants to merge 7 commits into
Conversation
|
macos-latest failed at The rebase onto master after #145 dropped the #141 |
|
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 reviewThis PR refactors the macOS Swift watcher to keep foreground tracking when browser context (ScriptingBridge) fails, binding tracked app, AX observer, focused window, and emitted app identity to one PID. It adds a new macos_state.swift file with pure state-transition helpers and a Swift test suite, plus Python source-level wiring tests. The Makefile now compiles macos_state.swift into the production helper and adds a test-swift target. Needs a look — P2 onlyConfidence 4/5 ℹ️ Consensus was degraded on this run: 2 of 3 passes answered, so findings were filtered at 2-of-2 agreement rather than 2-of-3 — less filtered than usual; 2 of 3 fan-out jobs answered, so the findings above were filtered against less evidence than the threshold assumes. 1 finding ·
|
| commit | score | findings | engine | when |
|---|---|---|---|---|
8ac81d39c2f8 |
4/5 | 2 | llm | 2026-09-16 08:53 UTC |
9424b4f6a054 |
1/5 | 3 | llm | 2026-09-16 12:44 UTC |
90aad7fbb413 |
4/5 | 1 | llm | 2026-09-16 13:25 UTC |
fe2f5c1c7651 |
3/5 | 2 | llm | 2026-09-25 11:24 UTC |
194d002c6890 |
5/5 | 0 | llm | 2026-10-07 14:45 UTC |
194d002c6890 |
4/5 | 1 | llm | 2026-10-09 04:18 UTC |
2fb21ed97546 |
5/5 | 0 | llm | 2026-10-14 18:02 UTC |
Reviewed 2fb21ed97546 · openrouter/deepseek/deepseek-v4-flash-0731 · llm engine · 1204s · about this reviewer
Maintainer commands
@TimeToBuildBob review (own line) — fresh review · @TimeToBuildBob fix — a worker acts on the findings. Once per comment; 👀 = received.
|
@greptileai review |
|
|
@greptileai review |
fe2f5c1 to
194d002
Compare
|
Rebased onto master ( This PR moves browser scripting out of the old inline block into Python tests pass locally (104); the Swift build/state tests run on macOS CI. |
|
Conflict rebase blocked — architectural incompatibility with recent master changes. What landed on master after the last rebase (
Why it's not a simple rebase: This PR's restructuring of What the clean merge needs:
This needs a dedicated Swift session to produce the unified version. Filing a task. |
Rebase of ActivityWatch#141 (hawai-i) onto current master after ActivityWatch#145. Keep PID-based foreground reconciliation and emit a heartbeat when Chrome/Safari ScriptingBridge fails, so merging does not extend the previous application across the real browser interval. Preserve ActivityWatch#145 AX safety (axString/axElement) and observer teardown (unregister focused-window notification, track observedApp). Chrome context-failure fallback keeps app identity for tracking but drops title and URL: ScriptingBridge is the only incognito detector (Greptile P1 on ActivityWatch#141). Swift state tests now compile with the macOS 12 deployment target (Greptile P2). Co-Authored-By: hawai-i <32040032+hawai-i@users.noreply.github.com> Git-Session-Id: 9615c06b-2a11-592d-b1ad-299a3433e323
Adding macos_state.swift made macos.swift a non-script compilation unit. Top-level assignments (formatter options, encoder strategy, start()) are illegal outside main.swift. Restore the ActivityWatch#141 closure inits and @main wrapper that the rebase dropped. Git-Session-Id: ca3f0209-55b1-58ce-8820-82fb6f5bc8e0
PID-only AX guards accepted queued title-change events from a previous window of the same app. Bind title callbacks to the focused window. Safari ScriptingBridge failure kept the AX window title, unlike Chrome. Use the same keep-app / drop-title-URL fallback so private pages cannot leak via accessibility when context lookup fails. Git-Session-Id: 9a7625ed-1cac-5d98-b0d9-013b84aae02d
rebuildObserver created an AXObserver then returned on AXObserverAddNotification failure without adopting it, leaking the Mach port. Adopt and tear down through the ActivityWatch#139 path. Bind foreground identity in the caller so a failed install still emits a heartbeat. Git-Session-Id: 28375f79-1abe-5518-8f8c-75fcc067315a
The add-failure path never installed the observer in the run loop, so tearDownObserver's CFRunLoopRemoveSource was a no-op. Nil the managed reference instead; CFRelease would double-free a Swift-ARC CF type. Write the Swift state-test binary into a mktemp directory so make test does not execute a predictable path in /tmp. Git-Session-Id: 28375f79-1abe-5518-8f8c-75fcc067315a
If AXObserverAddNotification for kAXTitleChangedNotification fails once, keep the focused window but leave registration retryable so the next poll can install it. Poll heartbeats already carry the current AX title; this restores live title-change callbacks after a transient add failure. Git-Session-Id: 2b8b1429-6ecf-575e-b812-491b60c68d9e
Git-Session-Id: 857984da-6219-579c-b1f4-44a9cc88fa80
194d002 to
2fb21ed
Compare
|
Resolved the conflict and force-pushed the rebase onto current master (
Added Linux-runnable source-wiring regression checks; the exclusion check failed before the fix and passes afterward. In an isolated worktree environment: 160 Python tests + 11 subtests passed, mypy clean, diff whitespace check clean. Native Swift compilation/state tests still require macOS CI; no local native-build claim. GitHub now reports the PR mergeable, with fresh CI running. Also resolved the remaining repeated nil-window observer finding: removal is outside the optional new-window registration, and the existing Swift state test explicitly covers that path. No observer behavior change was needed. |
| let frontWindow = windows().first, | ||
| let activeTab = frontWindow.activeTab { | ||
| if frontWindow.mode == "incognito" { | ||
| data = NetworkMessage(app: "", title: "") |
There was a problem hiding this comment.
Summary
Rebase of #141 (hawai-i) onto current
masterafter #145. Original work is preserved and attributed (Co-Authored-By: hawai-i).Browser URL/title enrichment is optional, but the macOS Swift watcher used to return without a heartbeat when Chrome/Safari ScriptingBridge failed. Heartbeat merging then extended the previous application across the real browser interval.
This keeps #141's PID-based foreground reconciliation:
NSRunningApplicationfrom the workspace notificationConflict with #145
#145 landed on
masterafter #141 opened. The rebase keeps that work:axString/axElementCF type checks (the macOS: native helper crashes when NSHTTPURLResponse is bridged as a window-title string #144NSHTTPURLResponsecrash)observedApp(the [macOS] aw-watcher-window-macos leaks AXObserver/Mach ports, causing high wired memory #139 Mach-port leak)Unsafe
as? String/as! AXUIElementcasts from #141 are not carried forward.Greptile on #141
P1 (incognito): ScriptingBridge is the only Chrome incognito detector. The original fallback sent AX-derived app + title when that lookup failed. The rebase still emits the Chrome app identity (so tracking stays coherent) but drops title and URL. Successful incognito detection still blanks both app and title.
P2 (tests):
make test-swiftnow compiles with-target …-macosx$(MACOSX_DEPLOYMENT_TARGET)(12.0), matching the production helper.Validation
Python tests: 77 passed. mypy clean. Swift helper/tests need Darwin CI (
macos-latest).Related