Skip to content

fix: match Helium with chrome web watcher bucket - #898

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

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

Conversation

@vedntp

@vedntp vedntp 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

@vedntp
vedntp marked this pull request as ready for review July 5, 2026 14:24

@TimeToBuildBob TimeToBuildBob left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the diff carefully. This is a clean, well-designed fix.

What it does: When Helium is running with the Chrome Web Store extension (reports to aw-watcher-web-chrome_*), the chrome query now includes helium in the app-name regex — but only when there's no dedicated aw-watcher-web-helium_* bucket, preventing double-counting when a proper Helium bucket exists.

Code quality: Good factoring — browserBucketMatches/browserBucketExists helpers keep the logic readable, and browserAppnameRegex cleanly handles the conditional case. Tests cover both configurations (with and without a dedicated Helium bucket), which is exactly the right coverage.

No concerns: Backward compatible — no behavior change when Helium is absent. The conditional regex routing is straightforward. Greptile also passed.

LGTM ✓

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Noting this was closed rather than merged — the Helium-in-chrome-bucket case is not in master, so flagging it here so it doesn't get lost:

  • Current src/queries.ts chrome bucket pattern is (?i)^(google[-_ ]?chrome|chrome|chromium|arc(\.exe)?$|dia(\.exe)?$) — no helium. helium exists only as its own key (net.imput.helium / aw-watcher-web-helium_*).
  • fix(queries): match Arc and Dia in the chrome appname patterns #928 added Arc/Dia to the chrome pattern and fix: add Helium to browser list #744 added the standalone Helium bucket, but neither covers the setup this PR fixes: the Chrome build of the extension running inside Helium, with events landing in aw-watcher-web-chrome_* while the active window app is Helium.
  • fix(queries): match Dia/Arc chrome forks and surface empty Browser view #949's chromeAppnameRegex(excludeForks) / CHROME_FORK_ALTS is the generalized form of this PR's design (same conditional-exclude idea, arc/dia instead of helium). It is green and awaiting merge; adding helium to that map reproduces this fix — double-count guard included — without a second code path.

The conditional-regex design here was the right call; thanks for it. I've tracked folding Helium into the #949 mechanism as a follow-up so it lands with that PR.

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