Skip to content

fix(web-watcher): don't split browser sessions on keyboard and overlay events - #342

Merged
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
0xbrayo:fix/web-watcher-overlay-split
Dec 3, 2026
Merged

ErikBjare merged 1 commit into
ActivityWatch:masterfrom
0xbrayo:fix/web-watcher-overlay-split

Conversation

@0xbrayo

@0xbrayo 0xbrayo commented Oct 8, 2026

Copy link
Copy Markdown
Member

Part of #333.

WebWatcher ended the current browser session whenever it received an event from a non-browser package on a different window id. The on-screen keyboard is a separate window owned by the IME package, so typing in the browser ended the session, and the next browser event started a new one. Popups and other overlays did the same. One visit was logged as several fragments, and the title captured for the first fragment was reset.

Change

  • On a window change from a non-browser package, WebWatcher checks rootInActiveWindow and only ends the session if the active (focused) window is no longer a known browser.
  • IME and overlay windows don't take focus, so the browser stays the active window and the session continues.
  • Switching to a different browser is still handled by that browser's own events.

The extra rootInActiveWindow lookup only happens on window changes from non-browser packages, not on every event.

Testing

  • ./gradlew :mobile:testStandardDebugUnitTest passes.
  • This depends on live accessibility window state, so the existing coverage for it is the instrumented WebWatcherTest. I haven't run that here (it needs an emulator).

@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

WebWatcher now checks the active window before ending a browser session after an event from another package.

  • Browser visits stay open when keyboard and overlay windows appear.

Reviews (3) · Last reviewed commit: "fix(web-watcher): don't split browser se..." · Reviewed by Greptile

@0xbrayo
0xbrayo force-pushed the fix/web-watcher-overlay-split branch from 50984b7 to 3fe2179 Compare October 8, 2026 19:37
@0xbrayo

0xbrayo commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

🤖 Claude, on behalf of @0xbrayo

@greptile review

…y events

Any event from a different window ended the browser session, so the
keyboard (a separate IME window) or a popup ended and restarted the
visit while the user was still in the browser. Only end the session
when the browser is no longer the active window; IME and overlay
windows never take focus.
@0xbrayo
0xbrayo force-pushed the fix/web-watcher-overlay-split branch from 3fe2179 to a09c81c Compare October 19, 2026 17:18
@0xbrayo

0xbrayo commented Oct 19, 2026

Copy link
Copy Markdown
Member Author

🤖 Claude, on behalf of @0xbrayo

@greptile review

@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 a09c81c.

The guard lands on the right line: the !isKnownBrowser branch assumed "window changed away from a browser" means the browser session ended, which is false for windows that never take focus (IME, popup, overlay). Reading rootInActiveWindow instead of the event's package is the correct source for "did focus actually move".

What I checked:

  • rootInActiveWindow ?: return false falls back to the old behaviour (end the session) when the active window can't be read — fails closed, so this cannot invent a silently-endless session.
  • recycle() sits in a finally.
  • Browser→browser switching is unaffected: the test is membership in KNOWN_BROWSER_PACKAGES, so the incoming browser's own events do the handover and this branch only decides whether to end the outgoing session.

CI on this head: Test, Test E2E (29), Test release variant (R8 smoke), Build aw-server-rust all pass; Greptile pass.

Not coverable by CI, so please state it in the PR body when merging: on a device, a keyboard/popup/overlay interaction mid-session no longer splits it, and switching browsers still does. Approving — the merge click stays with the maintainer.

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.

3 participants