Skip to content

feat(gui): 任务栏图标运行状态指示(变色 + 数量圆点) - #280

Open
inkdust2021 wants to merge 1 commit into
Stack-Cairn:mainfrom
inkdust2021:feat/taskbar-activity-indicator
Open

feat(gui): 任务栏图标运行状态指示(变色 + 数量圆点)#280
inkdust2021 wants to merge 1 commit into
Stack-Cairn:mainfrom
inkdust2021:feat/taskbar-activity-indicator

Conversation

@inkdust2021

Copy link
Copy Markdown
Contributor

功能

有任务(会话正在生成回复)进行时,任务栏/Dock 图标给出可见指示;全部结束后自动恢复原状:

平台 变色 数量圆点
Windows set_icon 换成琥珀色着色图标 set_overlay_icon 叠加红底白字角标(1-9,超过显示 9+)
macOS —(Tauri 2.11.5 未暴露 Dock 图标替换 API) set_badge_count 原生 Dock 红点数字
Linux set_badge_count 尽力而为(Unity 系桌面)

实现

  • 前端ChatPage 已维护并发运行会话集合 runningConversationIds,新增 useTaskbarActivity hook 把 size 经新命令 taskbar_set_activity 同步给桌面端;组件卸载时清零,invoke 失败静默(不影响聊天主流程)。
  • Rustcommands/app/taskbar.rs):
    • Windows 角标由内置 3x5 点阵字形渲染(纯像素操作,零新增依赖);活跃图标在内嵌 128x128-windows.png 上做 55% 琥珀色线性混合,双双缓存于 OnceLock
    • 纯渲染/混合逻辑不做 cfg 门控,任意平台可编译可测试(CI 为 ubuntu);仅平台 API 调用按 #[cfg] 分发。

验证

  • cargo test taskbar --lib:4 个单元测试通过(字形上限 9+、圆形角标透明边界与文字像素、不同数量渲染差异、着色保留 alpha);
  • 所用 Windows 专属 API 面(set_overlay_icon / set_icon / Image::*)已在 x86_64-pc-windows-msvc 目标下编译验证;
  • tscbiome(触及文件零新增告警)、pnpm test:frontend(1285 通过)、mirror check(109 文件)、git diff --check 全部通过;
  • 本机 macOS 实测路径为 Dock 原生角标;Windows 端视觉效果欢迎协助验证。

Mirror the number of running conversations onto the desktop shell so
users can see agent progress without focusing the window:

- Windows: tint the taskbar icon amber while tasks run and overlay a
  red badge showing the count (1-9, then 9+) rendered from an embedded
  3x5 bitmap font — no new dependencies. Both reset when idle.
- macOS: native Dock badge via set_badge_count (Dock icon tinting is
  not exposed by Tauri 2.11.5).
- Linux: set_badge_count best effort (Unity-style desktops).

The frontend syncs runningConversationIds.size through the new
taskbar_set_activity command and clears the badge on unmount.

@coder-hhx coder-hhx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复核最新提交 feac4dd2,确认有一项 Windows 图标恢复问题:

P3 · 请恢复 Tauri 实际配置的默认窗口图标

crates/agent-gui/src/pages/chat/hooks/useTaskbarActivity.ts:16 会在首次挂载时立即发送 count = 0,因此 crates/agent-gui/src-tauri/src/commands/app/taskbar.rs:70 在应用刚启动、尚无任务时就会替换启动图标。

当前 Windows 配置使用 icons/icon-windows.ico。Tauri 2.11.5 / tauri-codegen 2.6.3 会从该 ICO 的第一个 16×16 frame 构造默认窗口图标;这里却用 128x128-windows.png 调用 set_icon()。这不是恢复原始 icon,而是换成另一个尺寸的 HICON,标题栏/任务栏图标可能发生可见变化或被重新缩放。每次任务归零也会重复替换。

建议从 window.app_handle().default_window_icon() 恢复 Tauri 实际使用的默认图标(或在首次变色前保存原 icon),不要用单独的 PNG 作为“原状”。现有 Rust 测试覆盖了角标绘制,但没有覆盖默认图标恢复语义。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants