WebWatcher: keyboard events still split visits in detected browsers (browserIsActiveWindow checks only the hard-coded list)

Open Beginner friendly
#435 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@TimeToBuildBob is already working on this.

Since Dec 4, 2026.

  • #437 by @TimeToBuildBob — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
android, kotlin
Domain
mobile

Research direction

Read watcher/WebWatcher.kt:318-325 and compare browserIsActiveWindow with isKnownBrowser and the active detected browser check around lines 229-230. Use the provided Robolectric keyboard event test as the starting point; the issue says the test harness is WebWatcherDestroyTest. Done means the test passes and keyboard events no longer split visits for active detected browsers.

Written by the indexing model from the issue text.

Description

bug

browserIsActiveWindow() (watcher/WebWatcher.kt:318-325) checks only KNOWN_BROWSER_PACKAGES. Visits are also opened for runtime-detected browsers (detectedBrowsers + probeMemory.isActive, lines 229-230). So for Vivaldi, DuckDuckGo, Kiwi and other detected browsers, any keyboard or overlay event from another window ends the visit (lines 239-242). That is the split #342 fixed, and the fix only applies to the hard-coded list.

This is deterministic and doesn't depend on any event's source node.

Failing test (Robolectric, same harness as WebWatcherDestroyTest; full file available on request):

    fun `keyboard event does not end a visit in a detected browser`() {
        val vivaldi = "com.vivaldi.browser"
        val writer = installRecordingWriter()
        setField("probeMemory", BrowserProbeMemory(null) {})
        setField("detectedBrowsers", mapOf(vivaldi to 1L))
        tracker().handleUrl("example.org", vivaldi)
        setField("lastWindowId", browserWindow)

        activeRoot(vivaldi)
        service.onAccessibilityEvent(event(keyboard, keyboardWindow))

        assertEquals("A keyboard event must not split a detected browser's visit", 0, writer.submitted)
        assertEquals(vivaldi, tracker().currentBrowser)
        assertEquals("example.org", tracker().handleUrl(null, null)?.url)
    }

Today one visit is written and the session is closed.

Fix direction: in browserIsActiveWindow, treat the active root's package as a browser if it is in KNOWN_BROWSER_PACKAGES or is an active detected browser, using the same predicate as isKnownBrowser.

Priority: medium (split visits for every detected browser while typing). This repo only has a priority: high label, so no priority label is set.

fingerprint: watcher/WebWatcher.kt — browserIsActiveWindow ignores detected browsers; keyboard events split their visits

Confirmed by code read on master 3b820d61, and independently re-checked. The test has not been run (no JDK on my host).

Dominant language
Kotlin
Stars
291
Forks
73
Avg merge
4d 5h
Merged PRs (30d)
27

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ActivityWatch/aw-android

All issues in ActivityWatch/aw-android

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.