Repository navigation
Conversation
ScriptingBridge addressed by bundle identifier launches the app if it is not running. Target the frontmost process by PID and skip if it already terminated. Fixes ActivityWatch#151. Git-Session-Id: d216
|
| guard !frontmost.isTerminated, | ||
| let chromeObject = SBApplication.init(processIdentifier: frontmost.processIdentifier) as? ChromeProtocol else { | ||
| log("Chrome is no longer running, skipping scripting request") | ||
| return |
There was a problem hiding this comment.
Misleading browser failure log The guard logs that Chrome is “no longer running” both when it has quit and when ScriptingBridge cannot create a proxy. If proxy creation fails for a running browser, this message hides the reason its URL and title were not captured. Please distinguish those cases; the Safari branch has the same issue.
There was a problem hiding this comment.
Fixed in f15ef16 — split the combined guard so the two failure paths log distinct messages:
frontmost.isTerminated→ "Chrome/Safari is no longer running, skipping scripting request"SBApplication(processIdentifier:)proxy creation returning nil → "Failed to create ScriptingBridge proxy for Chrome/Safari"
A still-running browser whose proxy creation fails now logs the real reason instead of "no longer running". No change to the quit-path protection.
| // Address the running process by PID and bail if it already quit: a | ||
| // bundle-identifier target makes ScriptingBridge relaunch a browser that just quit. | ||
| guard !frontmost.isTerminated, | ||
| let chromeObject = SBApplication.init(processIdentifier: frontmost.processIdentifier) as? ChromeProtocol else { |
There was a problem hiding this comment.
Browser quit lacks regression coverage The new termination guard and PID lookup have not been built or run on macOS, and the test target does not check this behavior. A macOS regression check that quits a frontmost browser would help catch a future change that relaunches it.
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!
There was a problem hiding this comment.
Thanks — dismissing as out of scope for this fix. The regression check would need a macOS host driving a real ScriptingBridge browser-quit scenario; our CI does run the suite on macos-latest, but it has no ScriptingBridge/AX harness, and this PR was developed on Linux so it is explicitly marked unverified on macOS pending @alexph-dev's repro (#151).
If the maintainers want it, the follow-up would be adding a unit-level test around a small injectable helper rather than an end-to-end UI test — that is a separate PR, not this one.
🤖 AI code reviewSafe to merge — no P0/P1 findings on latest reviewUpdated after inline dispositions on finding threads — this is the current state; the verdict below is frozen at review time and is kept as the historical record of that pass. Finding disposition
Changes the Chrome and Safari ScriptingBridge paths in aw_watcher_window/macos.swift to address the frontmost process by PID instead of bundle identifier, and adds an isTerminated guard before creating the SBApplication proxy, to avoid relaunching a browser that quit while frontmost. Needs a look — P2 onlyConfidence 4/5 1 finding ·
|
| commit | score | findings | engine | when |
|---|---|---|---|---|
952759e9ea27 |
4/5 | 1 | llm | 2026-10-02 01:51 UTC |
Reviewed f15ef168f17b · openrouter/deepseek/deepseek-v4-flash-0731 · llm engine · 35s · about this reviewer
Maintainer commands
@TimeToBuildBob review (own line) — fresh review · @TimeToBuildBob fix — a worker acts on the findings. Once per comment; 👀 = received.
…uard Greptile flagged that the combined guard logs "no longer running" both when the browser quit and when SBApplication proxy creation fails, hiding the real reason a URL/title was not captured for a still-running browser. Split the guard so each failure path logs its own message. No behavior change to the quit-path protection. Git-Session-Id: d6701f58-58d5-5268-a672-7825ee88d034
|
@greptileai review |
|
CI-green and mergeable (Greptile 5/5) — 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. |
Fixes #151.
Thanks @alexph-dev for the sharp diagnosis.
SBApplication(bundleIdentifier:)makes ScriptingBridge launch the app if it isn't running, so when Chrome/Safari quits while frontmost the watcher's follow-up request relaunches it.Change: address the frontmost process by PID (
SBApplication(processIdentifier:)) and skip the request iffrontmost.isTerminated, for both the Chrome and Safari paths.Not built or run: developed on Linux, so unverified on macOS. @alexph-dev, could you check it against your repro (quit Chrome while frontmost)? Based on master; may need a trivial rebase if #146 lands first.