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

未关闭 适合新手
#435 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@TimeToBuildBob 已经在做这个了。

开始于 2026年12月4日。

  • #437 来自 @TimeToBuildBob —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
android, kotlin
领域
mobile

调研方向

阅读 watcher/WebWatcher.kt:318-325,并将 browserIsActiveWindow 与 isKnownBrowser 以及第 229-230 行附近对当前检测到的活动浏览器的检查进行比较。以提供的 Robolectric 键盘事件测试为起点;issue 指出测试框架是 WebWatcherDestroyTest。测试通过,并且键盘事件不再拆分当前检测到的活动浏览器的访问记录,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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).

主要语言
Kotlin
星标
291
派生
73
平均合并
4 天 5 小时
30 天内合并 PR
27

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ActivityWatch/aw-android 的其他 Issue

查看 ActivityWatch/aw-android 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。