Skip to content

macos: recognize frontmost Safari web apps by display name - #45

Open
charan-rathore wants to merge 1 commit into
awlevin:mainfrom
charan-rathore:fix/safari-web-app-display-name
Open

charan-rathore wants to merge 1 commit into
awlevin:mainfrom
charan-rathore:fix/safari-web-app-display-name

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Summary

Fixes #39. Safari's Add to Dock web apps report the generic process name Web App but have distinct displayed names. activate("YouTube") could bring one to the front and still time out because the confirmation compared Web App with YouTube. The next capture also reported Web App, losing which site app was open.

A shared frontmost-name helper now asks System Events for the displayed name only when the process name is Web App. Ordinary apps keep their process name and PID path without the extra lookup. If the displayed-name query fails, it falls back to Web App rather than inventing an identity or claiming activation succeeded.

Checks

  • uv run --no-sync ruff check .: passed.
  • uv run --no-sync ruff format --check .: passed.
  • uv run --no-sync pytest -q: 616 passed, 3 skipped, 1 xfailed on Linux.
  • Fake AppleScript tests cover a regular app without an extra lookup, a Safari web app with the displayed name and successful activation, and a failed lookup that does not falsely report success.

Caveat

No live Safari web app was launched or measured. The behavior is checked through fake System Events replies. PR #18 also edits activate for app launch and name matching, but leaves the frontmost-name functions unchanged; this fix stays in those functions and their shared helper.

Instinct assisted.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

This is green on CI and conflict-free on my end. Is there anything you'd like changed before it can land? Happy to adjust.

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.

activate() fails for Safari web apps

1 participant