Repository navigation
fix(web-watcher): don't split browser sessions on keyboard and overlay events - #342
Conversation
[Medium impact] The PR appears safe to merge; no new blocking issue was found. Summary
Reviews (3) · Last reviewed commit: "fix(web-watcher): don't split browser se..." · Reviewed by Greptile |
50984b7 to
3fe2179
Compare
…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.
3fe2179 to
a09c81c
Compare
TimeToBuildBob
left a comment
There was a problem hiding this comment.
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 falsefalls 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 afinally.- 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.
Part of #333.
WebWatcherended 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
WebWatcherchecksrootInActiveWindowand only ends the session if the active (focused) window is no longer a known browser.The extra
rootInActiveWindowlookup only happens on window changes from non-browser packages, not on every event.Testing
./gradlew :mobile:testStandardDebugUnitTestpasses.WebWatcherTest. I haven't run that here (it needs an emulator).