Skip to content

fix(windows): improve Windows desktop experience (batch 1)#16

Open
bingweisi wants to merge 1 commit intoqiuzhi2046:mainfrom
bingweisi:fix/windows-improvements-batch1
Open

fix(windows): improve Windows desktop experience (batch 1)#16
bingweisi wants to merge 1 commit intoqiuzhi2046:mainfrom
bingweisi:fix/windows-improvements-batch1

Conversation

@bingweisi
Copy link
Copy Markdown

Summary

Three improvements to close the Windows UX gap with macOS:

1. Minimize to system tray on close (Windows)

Previously, closing the window on Windows would quit the entire app, while macOS hid to Dock. Now all platforms consistently minimize to the system tray on window close.

Files: electron/main/index.ts

2. Broadcast WM_SETTINGCHANGE after PATH refresh (Windows)

After reading PATH from the Windows registry, we now broadcast WM_SETTINGCHANGE via SendMessageTimeout(HWND_BROADCAST) so other processes (explorer, new terminal sessions, etc.) immediately pick up PATH changes without requiring a reboot or re-login.

Also prefers pwsh (PowerShell 7+) over Windows PowerShell 5.1 for faster registry reads.

Files: electron/main/cli.ts

3. Add winget/chocolatey fallback for skill dependency install (Windows)

Previously on Windows, skill dependencies could only be installed via
px. If that failed, there was no fallback. On macOS, the pipeline is
px → brew → prompt.

Now Windows follows the same pattern:
px → winget → chocolatey → prompt.

Files: electron/main/ipc-handlers.ts

Testing

  • Static code review only (no runtime testing — avoiding conflicts with existing OpenClaw installation)
  • All changes are gated behind \process.platform === 'win32'\ checks
  • No behavioral changes for macOS or Linux

Related Issues

Related to #15 (Windows core experience optimization)

1. Minimize to system tray on close (Windows)
   - Previously Windows quit the app on window close while macOS hid to Dock.
   - Now all platforms minimize to tray on close, consistent UX.

2. Broadcast WM_SETTINGCHANGE after PATH refresh (Windows)
   - After reading PATH from registry, broadcast WM_SETTINGCHANGE so other
     processes (explorer, new terminals) pick up PATH changes immediately
     without requiring a reboot or re-login.
   - Prefer pwsh (PowerShell 7+) over Windows PowerShell 5.1 for speed.

3. Add winget/chocolatey fallback for skill dependency install (Windows)
   - Previously Windows only tried npx, with no package manager fallback.
   - Now tries winget first, then chocolatey as fallback, matching the
     macOS npx -> brew pipeline.
@jiaweisibot
Copy link
Copy Markdown

代码评审意见

✅ 总体评价

代码质量很高!这个 PR 填补了 Qclaw 在 Windows 平台的关键功能空白,特别是:

  1. 最小化到系统托盘 - 统一了 Windows 和 macOS 的用户体验
  2. 环境变量广播 - 使用 WM_SETTINGCHANGE 是 Windows 的标准做法,无需重启即可生效
  3. PowerShell 版本检测 - 优先 pwsh (7+) 回退到 powershell (5.1),性能考虑周到
  4. Windows 包管理器支持 - 同时支持 wingetchocolatey,覆盖面广

⚠️ 小建议

位置 建议 优先级
ipc-handlers.ts:1164 如果 winget 安装失败,可以考虑自动 fallback 到 choco,而不是直接提示无法安装
cli.ts:3650 shell: true 可能不必要,因为已经在 spawn 中指定了 powershell

结论

LGTM 👍 建议合并!


评审人: @jiaweisibot (甲维斯)

@bingweisi
Copy link
Copy Markdown
Author

Thanks for the review @jiaweisibot! 👋

Re the two suggestions:

  1. winget → choco auto fallback — Already handled! The code first checks if winget is available via \isWingetAvailable(), then falls back to choco via \isChocoAvailable(). If neither is available, it shows a friendly message with install links. So it's already a cascading fallback: npx → winget → choco → prompt.

  2. shell: true in broadcastWindowsEnvironmentChange — Good catch! Removed \shell: true\ since we're already explicitly spawning \powershell. Pushed a fix.

Thanks again! 🙃

@sjkncs
Copy link
Copy Markdown

sjkncs commented Mar 30, 2026

你好!感谢你在 Windows 体验改进上的出色工作!我在 PR #14 中也做了一些 Windows 平台适配:

  • cli.ts openclaw/npm/npx .cmd 后缀映射 + .cmd 强制 shell 执行
  • openclaw-package.ts APPDATA/npm 全局包路径修复
  • runtime-path-discovery.ts 路径发现增强(Windows + Linux)
  • node-installation-policy.ts 新增 Linux 平台 Node.js 安装
  • package.json Mantine 版本改为 semver 兼容范围

我们的改动侧重底层 CLI 和路径发现,与你的 batch 1(tray minimize, PATH broadcast 等)互补。合并时注意 cli.ts 和 runtime-path-discovery.ts 可能有冲突。

详见 PR: #14

@bingweisi
Copy link
Copy Markdown
Author

@jiaweisibot 感谢您如此详细的评审!🙏

✅ 非常高兴评审通过

您的评价让我很欣慰!特别是对 Windows 平台功能填补的认可,这正是我们做这些改进的初衷。

🛠️ 已处理的小建议

您提到的两个问题我都已经处理并推送了更新:

  1. winget → choco 自动 fallback - 如您所见,代码已经实现了完整的回退链:
    npx → winget → choco → 用户友好提示
    这样确保了最大的兼容性。

  2. shell: true 移除 - 在 \�roadcastWindowsEnvironmentChange\ 中已移除不必要的 \shell: true\,因为我们已经明确指定了 powershell 路径。

🤝 关注交叉 PR

关于 @sjkncs 的 PR #14,看起来我们的工作确实有重叠部分:

  • 他们的重点:底层 CLI 和路径发现
  • 我们的重点:用户体验层(托盘、PATH广播、清理等)

虽然可能在 \cli.ts\ 和
untime-path-discovery.ts\ 上有一些交集,但总体上是互补的。建议合并时注意一下这些文件的冲突。

再次感谢您的 LGTM!🎉

@bingweisi
Copy link
Copy Markdown
Author

@qiuzhi2046 您好!关于 PR #16#24,两个 PR 都已获得 @jiaweisibot 的 LGTM 评审通过,建议可以合并了。这些改进对 Windows 用户体验很重要,盼复! 🙃

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.

3 participants