Repository navigation
fix(web-watcher): keep the browser's window after a tolerated keyboard event - #438
TimeToBuildBob wants to merge 2 commits into
Conversation
…d event A keyboard or overlay event tolerated by ActivityWatch#342 moved lastWindowId to the overlay's window, so the browser's next event counted as a window change. A Chromium page event has no url_bar under its source, so the null URL ended the visit and typing into a page split it. Keep lastWindowId on the browser's window for tolerated overlay events, and remember the overlay so its further events skip the active-window lookup. Fixes ActivityWatch#434 Git-Session-Id: 574c2071-b503-4d8a-a2d0-56f763debc78
|
What changed: 2 files, +133/-4 in Review guideKey files
Suggested verification
Auto-posted by |
browserIsActiveWindow() only accepted KNOWN_BROWSER_PACKAGES, while onAccessibilityEvent also tracks autodetected browsers. A keyboard event in an autodetected browser therefore ended its visit. Share one predicate. Git-Session-Id: 574c2071-b503-4d8a-a2d0-56f763debc78
Confidence Score: 4/5
[Medium impact] The change is contained to browser visit tracking. The PR appears safe to merge, with a non-blocking gap in tests for the overlay cache. Findings
Summary
Review was based on source inspection; tests were not run. Reviews (1) · Last reviewed commit: "fix(web-watcher): keep the browser's win..." · Reviewed by Greptile |
| // Keyboard window event while Chrome stays the active window: tolerated by #342. | ||
| activeRoot(chrome) | ||
| service.onAccessibilityEvent(event(keyboard, keyboardWindow)) | ||
| assertEquals(chrome, tracker().currentBrowser) | ||
|
|
||
| // The same kind of page event, now arriving after the keyboard's. | ||
| service.onAccessibilityEvent(event(chrome, browserWindow)) |
There was a problem hiding this comment.
Each test sends only one keyboard event per visit, so none exercises the new toleratedOverlayWindowId shortcut. Count rootInActiveWindow reads in a test: repeated events from the same overlay should skip the lookup, while a browser event or a different overlay should make the next lookup run. Without these checks, the cache can stop working or remain stale without failing the tests.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
🤖 AI code reviewThe PR changes Safe to merge — no P0/P1 findingsConfidence 5/5 ✅ No findings. The diff looks correct to me on this pass. Files changed (2) — the diff as I read it
Reviewed Maintainer commands
|
Fixes #434.
#342 stopped a keyboard or overlay event from ending a browser visit while the browser keeps focus, but it still moved
lastWindowIdto the keyboard's window. The browser's next event then counted as a window change. In Chromium-family browsers a page-content event (for example from the edited input) has nourl_barunder its source, so the URL is null and the visit ended. Typing into a page field split the visit.Change (
watcher/WebWatcher.kt):lastWindowId, so the browser's next event is on the same window and a null URL keeps the visit, as it already did without the keyboard event in between.rootInActiveWindowlookup. That keeps the binder calls per typing burst where they were before; the lookup runs again when a browser event or a different window arrives.browserIsActiveWindow()now uses the same tracked-browser check asonAccessibilityEvent. It only acceptedKNOWN_BROWSER_PACKAGES, so a keyboard event in an autodetected browser (feat(android): browser autodetect (rebased from #311) #372) ended its visit outright.Tests (
WebWatcherOverlayTest, Robolectric):Verified:
./gradlew testStandardDebugUnitTeston a JDK 17 host: 485 tests, 0 failures. With master'sWebWatcher.ktand the new test file, the first test fails withTyping into a page must not split the visit expected:<0> but was:<1>, as #434 predicted. Not traced on a device.