Skip to content

feat: add Safari browser support#791

Open
F1Justin wants to merge 1 commit intoActivityWatch:masterfrom
F1Justin:add-safari-browser-support
Open

feat: add Safari browser support#791
F1Justin wants to merge 1 commit intoActivityWatch:masterfrom
F1Justin:add-safari-browser-support

Conversation

@F1Justin
Copy link
Copy Markdown

Summary

Safari is not listed in browser_appnames or browser_appname_regex, so aw-watcher-web-safari buckets are never matched and the Activity > Browser view always shows "No data" for Safari users.

  • Adds safari: ['com.apple.Safari'] to browser_appnames
  • Adds safari: '(?i)^safari(浏览器)?$' to browser_appname_regex, anchored to avoid false positives; also covers the macOS Chinese localization (Safari浏览器)
  • Adds a unit test for both variants

Test plan

  • npm test passes (14 tests)
  • Verify Activity > Browser view shows data when aw-watcher-web-safari_<hostname> bucket exists with events

🤖 Generated with Claude Code

Add Safari to the browser tracking definitions so that
aw-watcher-web-safari buckets are recognized and queried in the
Activity > Browser view.

- bundle ID: com.apple.Safari
- regex: matches 'Safari' and 'Safari浏览器' (macOS Chinese localization),
  anchored to avoid false positives (e.g. SafariBrowser)
- unit test covering both English and Chinese app name variants

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 24, 2026 03:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Safari support to the browser-bucket matching logic so Safari users’ aw-watcher-web-safari_<hostname> buckets are correctly recognized and included in the Activity > Browser view.

Changes:

  • Add Safari bundle ID (com.apple.Safari) to exact-match browser app names used for window/app correlation.
  • Add a Safari-specific app-name regex (including macOS Chinese localization variant) to the regex matcher set.
  • Add a unit test validating Safari matching (positive and negative cases).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/queries.ts Extends browser bucket/app matching to include Safari via exact app name and regex pattern.
test/unit/queries.test.node.ts Adds coverage ensuring the Safari regex matches expected app names and avoids a false positive.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 24, 2026

Greptile Summary

This PR adds first-class Safari browser support to the Activity > Browser view by registering Safari in both lookup maps (browser_appnames and browser_appname_regex), following the exact same pattern used for every other supported browser. Without these entries, aw-watcher-web-safari buckets were silently ignored and Safari users always saw "No data".

Key changes:

  • src/queries.ts: Adds safari: ['com.apple.Safari'] to browser_appnames (bundle ID used as a fallback exact match) and safari: '(?i)^safari(浏览器)?$' to browser_appname_regex (anchored, case-insensitive, covers both the standard English name and the macOS Chinese-locale name Safari浏览器).
  • test/unit/queries.test.node.ts: Adds a dedicated test covering capitalised, lowercase, and Chinese-locale variants, plus a negative assertion for SafariBrowser to guard against overly broad matching.

The regex is correctly more strict than several existing patterns (anchored with ^…$) and the test coverage is consistent with the rest of the suite. No issues found.

Confidence Score: 5/5

  • Safe to merge — minimal, well-targeted change with no risk to existing browser integrations.
  • The change is a two-line addition that strictly follows the established pattern for every other browser in the file. The regex is properly anchored to avoid false positives, the bundle ID entry is consistent with peer entries, and a dedicated unit test validates all expected match and non-match cases. No existing behaviour is modified.
  • No files require special attention.

Important Files Changed

Filename Overview
src/queries.ts Adds safari to browser_appnames (bundle ID com.apple.Safari) and browser_appname_regex (anchored, case-insensitive, with optional Chinese-locale suffix) — follows the same pattern as all existing browsers with no issues.
test/unit/queries.test.node.ts Adds a focused test for the Safari regex covering the capitalized, lowercase, and Chinese-locale variants, plus a false-positive guard; consistent with the existing test style.

Sequence Diagram

sequenceDiagram
    participant UI as aw-webui (Browser View)
    participant BW as browsersWithBuckets()
    participant BE as browserEvents()
    participant AW as aw-server query engine

    UI->>BW: bid_browsers (list of known bucket IDs)
    BW->>BW: _.includes(bucket_id, "safari")<br/>matches "aw-watcher-web-safari_<host>"
    BW-->>BE: [("safari", "aw-watcher-web-safari_<host>")]
    BE->>AW: query_bucket("aw-watcher-web-safari_<host>")
    AW-->>BE: raw tab events
    BE->>AW: filter_keyvals(events, "app", ["com.apple.Safari"])
    BE->>AW: filter_keyvals_regex(events, "app", "(?i)^safari(浏览器)?$")
    AW-->>BE: window events where Safari was active
    BE->>AW: filter_period_intersect(tab_events, safari_window_events)
    AW-->>UI: browser_events (Safari URLs, domains, titles)
Loading

Reviews (1): Last reviewed commit: "feat: add Safari browser support to brow..." | Re-trigger Greptile

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