Skip to content

fix: match Helium with chrome web watcher bucket#898

Open
vp275 wants to merge 2 commits into
ActivityWatch:masterfrom
vp275:codex/helium-chrome-web-bucket
Open

fix: match Helium with chrome web watcher bucket#898
vp275 wants to merge 2 commits into
ActivityWatch:masterfrom
vp275:codex/helium-chrome-web-bucket

Conversation

@vp275

@vp275 vp275 commented Jul 4, 2026

Copy link
Copy Markdown

Summary

  • Match Helium for Chrome web watcher buckets when no dedicated Helium bucket exists.
  • Avoid matching Helium through the Chrome bucket when an aw-watcher-web-helium_* bucket is also present.
  • Add regression tests for both bucket configurations.

Why

Helium can install and run the Chrome Web Store ActivityWatch extension, which reports URL events into an aw-watcher-web-chrome_* bucket. In that setup, the active window app name is Helium, so the Chrome bucket filter would otherwise drop those browser events even though the data exists.

The PR now also guards the edge case where both a Chrome-extension bucket and a dedicated Helium bucket are present, so the same Helium browsing activity is not claimed by both browser paths.

Test

npm test -- --selectProjects node --runTestsByPath test/unit/queries.test.node.ts
npx prettier --check src/queries.ts test/unit/queries.test.node.ts

@greptile-apps

greptile-apps Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes the Chrome web watcher bucket (aw-watcher-web-chrome_*) recognize Helium as an active-window app name, enabling URL events captured by the Chrome Web Store extension running inside Helium to be counted correctly. It also avoids double-counting when a dedicated aw-watcher-web-helium_* bucket is simultaneously present by stripping helium from the Chrome app-name regex in that case.

  • Extracts browserBucketMatches / browserBucketExists helpers and adds browserAppnameRegex which dynamically selects between the standard Chrome regex and a Helium-augmented variant depending on whether a Helium bucket exists in the current session.
  • browser_appname_regex.chrome (the exported constant) is unchanged; only the runtime query path is affected via the new browserAppnameRegex function.
  • Two targeted regression tests verify both the Helium-inclusive (Chrome-only) and Helium-exclusive (Chrome + Helium) bucket configurations.

Confidence Score: 5/5

Safe to merge — the change is well-scoped, the exported browser_appname_regex constant is untouched, and the new runtime path is exercised by dedicated regression tests.

The logic is straightforward: a new helper checks whether any bucket ID contains 'helium' and selects the appropriate Chrome regex accordingly. The two bucket configurations (Chrome-only, Chrome+Helium) are each covered by a regression test. No existing behavior is altered when neither bucket pattern applies.

No files require special attention.

Important Files Changed

Filename Overview
src/queries.ts Adds two helper functions (browserBucketMatches, browserBucketExists) and browserAppnameRegex to conditionally include Helium in the Chrome app-name regex only when no dedicated Helium bucket is present, preventing double-counting.
test/unit/queries.test.node.ts Adds fullDesktopQuery import and two new regression tests covering Chrome-only and Chrome+Helium bucket configurations; correctly guards both the Helium-inclusion and Helium-exclusion paths.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[browserEvents called] --> B[browsersWithBuckets: find browsers with matching bucket IDs]
    B --> C{For each browser with a bucket}
    C --> D[Get exact app-name list from browser_appnames]
    C --> E[Call browserAppnameRegex]
    E --> F{browserName === 'chrome'?}
    F -- No --> G[Return browser_appname_regex for that browser]
    F -- Yes --> H{browserBucketExists: any bucket ID contains 'helium'?}
    H -- No helium bucket --> I[Return chrome_appname_regex_with_helium]
    H -- Helium bucket exists --> J[Return chrome_appname_regex]
    G --> K[filter_keyvals_regex on window events]
    I --> K
    J --> K
    K --> L[Merge exact + regex window matches]
    L --> M[filter_period_intersect: browser URL events intersect active window periods]
    M --> N[Accumulate into browser_events]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[browserEvents called] --> B[browsersWithBuckets: find browsers with matching bucket IDs]
    B --> C{For each browser with a bucket}
    C --> D[Get exact app-name list from browser_appnames]
    C --> E[Call browserAppnameRegex]
    E --> F{browserName === 'chrome'?}
    F -- No --> G[Return browser_appname_regex for that browser]
    F -- Yes --> H{browserBucketExists: any bucket ID contains 'helium'?}
    H -- No helium bucket --> I[Return chrome_appname_regex_with_helium]
    H -- Helium bucket exists --> J[Return chrome_appname_regex]
    G --> K[filter_keyvals_regex on window events]
    I --> K
    J --> K
    K --> L[Merge exact + regex window matches]
    L --> M[filter_period_intersect: browser URL events intersect active window periods]
    M --> N[Accumulate into browser_events]
Loading

Reviews (2): Last reviewed commit: "fix: avoid double-counting Helium bucket..." | Re-trigger Greptile

@vp275 vp275 marked this pull request as ready for review July 5, 2026 14:24
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.

1 participant