Skip to content

fix: resolve source app from Apple Event sender - #4

Merged
andyzasl merged 2 commits into
andyzasl:mainfrom
a-shcherba:fix/source-app-event-sender
Oct 31, 2026
Merged

andyzasl merged 2 commits into
andyzasl:mainfrom
a-shcherba:fix/source-app-event-sender

Conversation

@a-shcherba

@a-shcherba a-shcherba commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

When Browserly becomes the foreground application while handling an incoming URL, sourceApp rules can fail because both URL handlers identify the foreground app as the sender. For example, a rule for ru.keepcoder.Telegram can fall through to the default browser while history records com.browserly.app as the source.

Resolve the sender from the Apple Event's keySenderPIDAttr using NSRunningApplication(processIdentifier:). Both the explicit URL event handler and the application delegate callback use the same resolver; the latter reads NSAppleEventManager.currentAppleEvent. Missing, invalid, or unresolvable sender metadata produces an unknown source rather than attributing the URL to an unrelated foreground application. Existing configuration remains valid.

Adds regression coverage for Telegram routing, missing events and sender attributes, invalid PIDs and descriptor types, unsigned sender PIDs (including out-of-range values), unavailable processes, and a real running application lookup.

Validation:

  • Release build using Xcode: passed.
  • Standalone routing validation: passed.
  • Routing performance benchmark: passed.
  • Native Apple Event probe on macOS 27.0.1: confirmed that keySenderPIDAttr arrives as typeUInt32 (magn), and the resolver now accepts it.
  • SourceAppResolverTests: 8 tests passed.

Manual end-to-end verification on macOS 27.0.1: clicking a link in Telegram now records ru.keepcoder.Telegram as the source, matches the Telegram source-app rule, and routes to Safari. Command-line URL attribution and forwarding between Browserly instances are outside this change.

@andyzasl
andyzasl merged commit 9c72ad2 into andyzasl:main Oct 31, 2026
1 of 2 checks passed
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.

2 participants