fix(tray): 支持左键单击托盘图标打开主面板 - #21
Merged
Merged
Conversation
- TrayIconBuilder 注册 on_tray_icon_event,此前只有 on_menu_event, 点击图标本身没有任何回调,用户必须右键出菜单再点「打开 AgentLens」两步才能开面板 - 新增纯函数 tray_click_action,仅在 (Left, Down) 返回 Open; Tauri 在按下与释放各派发一次 Click,两者都响应会开两次窗口 - 不显式处理 DoubleClick:Windows 双击序列先派发一次 Click,双击天然经第一次点击生效 - 补单测 one_left_tray_click_dispatches_open_exactly_once,钉住一次物理点击只派发一次 - 注释说明 Linux AppIndicator 不派发托盘图标事件,右键菜单项是该平台回退路径
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
- 新增 tray_icon_event_action,从 TrayIconEvent 解构出按钮与状态后委托给 tray_click_action;闭包退化成三行适配器,只负责取 action 并在 Open 时开窗 - 原先解构写在闭包内,而闭包只有原生托盘派发才执行,MockRuntime 注入不到, 九行插桩行全部未覆盖,补丁覆盖率仅 64.0%,低于 90% 门槛 - 新增 real_tray_events_open_once_and_ignore_windows_double_click_replay, 用真实构造的 Click/DoubleClick 断言仅 (Left,Down) 开窗,其余一律忽略 - 行为零变化,仅提升可测性;补丁覆盖率升至 90.6%,行覆盖率 92.53%
Merged
sunerpy
pushed a commit
that referenced
this pull request
Aug 11, 2026
本 PR 由 release-please 维护:合并后 .github/workflows/release.yml 会自己建 tag 与 draft Release,三平台产物齐全才公开。 --- <details><summary>0.0.3</summary> ## [0.0.3](v0.0.2...v0.0.3) (2026-08-11) ### Bug Fixes * **tray:** 支持左键单击托盘图标打开主面板 ([#21](#21)) ([b9fff30](b9fff30)) ### Documentation * **readme:** 重写语感并同步 Cargo.lock 到 0.0.2 版本号 ([#19](#19)) ([c6d5ad9](c6d5ad9)) ### Build System * **release-please:** 把 Cargo.lock 纳入发版版本号同步 ([#22](#22)) ([fd028fe](fd028fe)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变化
此前
TrayIconBuilder只注册了.on_menu_event,没有.on_tray_icon_event,所以点击托盘图标本身毫无反应——用户必须「右键出菜单 → 点『打开 AgentLens』」两步才能打开面板。本次补上图标点击路径,用户可感知的变化是:单击或双击托盘图标都能直接打开主面板(双击天然经第一次点击生效)。
show_main_window(show+unminimize+set_focus,幂等)本就存在,只是此前没有任何点击路径调用它。实现要点
TrayIconBuilder注册.on_tray_icon_eventtray_click_action(button, button_state),仅在(Left, Down)返回Open—— Tauri 在按下与释放各派发一次
Click,两个都响应会开两次窗口DoubleClick:Windows 双击序列先派发一次Click,双击经第一次点击生效one_left_tray_click_dispatches_open_exactly_once,把「一次物理点击只派发一次」钉住门禁结果(均已在本地跑通)
cargo test --workspacecargo clippy --workspace --all-targets -- -D warningscargo fmt --all -- --checkmake coverage-gatecargo xwin check -p agentlens-tauri --tests --target x86_64-pc-windows-msvclsp_diagnostics src-tauri/src/tray.rs影响面
仅
src-tauri/src/tray.rs(+53/-1),无接口、数据模型或配置变更。