Repository navigation
fix(macos): give Swift helper a bundle identity so its permission entry is created automatically - #150
fix(macos): give Swift helper a bundle identity so its permission entry is created automatically#150StreamOfRon wants to merge 4 commits into
Conversation
The helper retried checkAccess() with prompt:true every 10s, so a helper whose grant hadn't stuck (adhoc signature, or grant applied to the top-level app instead of the helper) re-prompted forever. Prompt once, then poll silently so a later manual grant still takes effect.
…ry is created automatically Embed Helper-Info.plist (CFBundleIdentifier net.activitywatch.aw-watcher-window-macos, CFBundleName 'ActivityWatch Window Helper') into aw-watcher-window-macos via __TEXT,__info_plist so TCC lists the helper by name when it prompts, instead of requiring users to manually locate the bare helper binary in the app bundle. Also log the missing-access state once per launch (naming the helper and the Settings location) and update the Python permission alert to match, so the silent-wait state is diagnosable without reintroducing repeated prompts.
|
| "To let ActivityWatch capture window titles, enable " | ||
| '"ActivityWatch Window Helper" (aw-watcher-window-macos) under ' |
There was a problem hiding this comment.
When the jxa or applescript strategy is selected, this alert still runs, but the Swift helper is not launched. The alert now tells users to enable that helper even though the permission check runs in the Python-side process. Granting the named helper does not resolve the missing access for script capture, so window data remains unavailable. The guidance needs to name the process that requires access for the selected strategy.
Knowledge Base Used:
There was a problem hiding this comment.
Addressed in 1a9671f: the alert now takes the capture strategy and names the Swift helper for swift, aw-watcher-window itself for jxa/applescript.
| swiftc -target "$(shell uname -m)-apple-macosx$(MACOSX_DEPLOYMENT_TARGET)" $^ -o $@ | ||
| aw_watcher_window/aw-watcher-window-macos: aw_watcher_window/macos.swift aw_watcher_window/Helper-Info.plist | ||
| swiftc -target "$(shell uname -m)-apple-macosx$(MACOSX_DEPLOYMENT_TARGET)" \ | ||
| -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __info_plist -Xlinker aw_watcher_window/Helper-Info.plist \ |
There was a problem hiding this comment.
Helper identity goes unchecked
This plist section is central to the permission-entry fix, but the macOS build check verifies only the deployment target, and the package smoke test does not launch the helper. Without an assertion that the packaged helper retains the __info_plist section and identifier, a later linker or packaging change could silently undo the fix.
Knowledge Base Used:
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.
Addressed in 1a9671f: new 'Check macOS helper bundle identity' CI step (after Package) asserts the packaged helper retains the __TEXT,__info_plist section and bundle identifier.
…dentity P1: the permission alert now names the process that actually needs access for the selected strategy (Swift helper for swift, aw-watcher-window itself for jxa/applescript) instead of always naming the Swift helper. P2: CI asserts the packaged helper retains the __TEXT,__info_plist section and bundle identifier, so a linker or packaging change cannot silently undo the permission-entry fix.
- Fix garbled alert copy (duplicated-word typo in the fallback sentence). - Co-locate hasLoggedMissingAccess with hasPromptedForAccess; both guard checkAccess(). - Makefile: compile the sole Swift source by explicit name instead of $<, with a note to keep UPX/strip off the helper so the __TEXT,__info_plist section survives packaging. - CI: assert the bundle identifier inside the decoded plist section rather than a bare strings match anywhere in the binary.
|
Thanks @StreamOfRon — embedding the identity is the right approach to #149, and the Looks right
Needs attention
macOS maintainer smoke test (cannot be done from Linux)
Merge order: #148 → #150 (rebase, fix the Makefile rule against #146 or vice versa) → #146. Or #146 first, then #150 rebased onto it with the rule above. Leaving the merge to a maintainer. |
Fixes #149.
Stacked on #148 (one-time prompt, currently unmerged) — this PR's diff includes that commit until #148 lands, then it will shrink to the identity commit alone.
Problem: the helper is a bare unix executable with no bundle identity, so when it prompts for Accessibility access, macOS does not add a usable entry to the permissions list — users must click +, dig into
Contents/Frameworks/aw_watcher_window/, and select the binary by hand.Change (4 files, +45/-4 on top of #148):
aw_watcher_window/Helper-Info.plist:CFBundleIdentifiernet.activitywatch.aw-watcher-window-macos,CFBundleName"ActivityWatch Window Helper".Makefile: embed it via__TEXT,__info_plistin thebuild-swiftrule (compile input switched frommacos.swift: one-time log on first silent trust-check failure naming the helper path and the Settings location (greptile P2 on fix(macos): prompt for accessibility access only once per launch #148 — silent-wait state is now diagnosable without re-prompting).macos_permissions.py: alert copy names "ActivityWatch Window Helper" + Settings path instead of generic "grant it permissions / remove and re-add".Verified:
make build-swiftclean (0 errors); section present viaotool -s __TEXT __info_plist; adhoc re-sign derivesIdentifier=net.activitywatch.aw-watcher-window-macos(previously a hash-suffixed id);pytest tests/78/78 pass.Caveats: nothing self-grants TCC — the user still approves once. On adhoc local builds grants are cdhash-keyed, so rebuilding invalidates them; only Developer ID signing gives persistence. End-to-end auto-add proof needs a
tccutil reset+ relaunch on a live machine (left as manual verification).