Skip to content

fix(windows): separate taskbar minimization from close to tray - #199

Merged
zouyonghe merged 1 commit into
AstrBotDevs:mainfrom
zouyonghe:fix/windows-window-controls
Nov 21, 2026
Merged

zouyonghe merged 1 commit into
AstrBotDevs:mainfrom
zouyonghe:fix/windows-window-controls

Conversation

@zouyonghe

@zouyonghe zouyonghe commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Windows 的窗口最小化会触发失焦事件。旧逻辑在检测到最小化后又隐藏窗口,导致点击最小化按钮或任务栏图标时,窗口可能直接从任务栏消失到托盘。

Summary / 改动概述

  • Windows 普通最小化与任务栏切换交给系统,不再由失焦事件触发托盘隐藏。
  • 关闭主窗口时提供原生提示:最小化到托盘、退出或取消。可记住选择,或从托盘菜单恢复关闭时询问。退出仍复用现有后端清理流程。
  • 保持非 Windows 行为不变,并增加事件路由及偏好保存和重置的回归测试。

Verification / 验证方式

  • LC_ALL=C make test lint 通过:276 项 Rust 测试、224 项脚本测试。现有 signal_probe_reports_a_missing_pid_as_exited 测试依赖 kill 的英文错误提示,在本机默认日语 locale 下会失败;本 PR 不改动该逻辑。
  • x86_64-pc-windows-gnu 交叉构建通过。
  • Wine 冒烟测试覆盖托盘、退出并记住、取消(即使已勾选记住)、关闭对话框。
  • 尚未在 Windows 实机验证 Explorer 任务栏交互。建议在实机上用标题栏和任务栏图标分别最小化、恢复,再验证关闭提示与托盘重置。

Checklist / 检查清单

  • 未改变公开 API 或设置文件兼容性。
  • 已执行本地检查并记录平台验证范围。
  • 未修改工作流或依赖版本;只启用现有 windows-sys 的功能。

Summary by Sourcery

Separate Windows taskbar minimization from tray hiding and provide a configurable close workflow with persistence and reset support.

New Features:

  • Add a Windows close prompt allowing users to minimize to the tray, quit, cancel, and optionally remember their choice.
  • Add a Windows tray action to reset the remembered close preference.

Bug Fixes:

  • Prevent Windows taskbar minimization and restoration from unintentionally hiding the window in the system tray.

Enhancements:

  • Preserve existing non-Windows minimize and close behavior while routing Windows window events separately.
  • Persist Windows close preferences without affecting legacy desktop settings.

Build:

  • Enable the Windows controls API required by the native close prompt.

Documentation:

  • Document the distinction between minimizing and closing on Windows in English and Chinese FAQs.

Tests:

  • Add regression coverage for Windows event routing and remembered close preference persistence and reset behavior.

Leave taskbar minimization to Windows. Prompt on close and persist an explicitly remembered choice, with a tray action to restore the prompt.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. A remembered Windows close choice is persisted and can make later closes quit the app or hide it to the tray; if the choice is wrong, it can be reset from the tray menu. The saved setting may remain after reverting and take effect again if this code returns, but it is bounded and repairable.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@zouyonghe
zouyonghe merged commit b2779ce into AstrBotDevs:main Nov 21, 2026
4 checks passed
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.

1 participant