Skip to content

Windows:新增内置任务完成提示弹窗,并支持点击聚焦终端#165

Open
sixsixla wants to merge 12 commits into
lessweb:mainfrom
sixsixla:feature/windows-notify
Open

Windows:新增内置任务完成提示弹窗,并支持点击聚焦终端#165
sixsixla wants to merge 12 commits into
lessweb:mainfrom
sixsixla:feature/windows-notify

Conversation

@sixsixla
Copy link
Copy Markdown

@sixsixla sixsixla commented Jun 5, 2026

Windows:新增内置任务完成提示,并支持点击聚焦终端

概述

这个 PR 改进了 Deep Code CLI 在 Windows 上的默认任务完成通知体验。

Deep Code CLI 是一个很有价值的终端 AI 工具,把 DeepSeek v4 这类模型能力很好地融入到了日常工程工作流中。感谢作者持续开发和维护这个项目。

项目已经提供了灵活的 notify 机制,方便用户接入自己的通知脚本。这个 PR 希望在不影响现有自定义能力的前提下,为 Windows 用户补上一个开箱即用的内置桌面提示。

当 AI 完成一轮回复后,Deep Code 会显示一个紧凑的桌面提示,内容包含最近一次用户问题和 AI 回复开头。用户点击提示后,会尝试恢复并聚焦启动 CLI 的终端窗口。

效果截图

download

动机

Deep Code CLI 常用于需要等待一段时间的工程任务,也可能同时开启多个 CLI 终端并行使用。用户经常会在 AI 执行期间切到其它窗口工作,因此任务完成后的反馈很重要。

这个 PR 希望让 Windows 默认体验更完整:

  • AI 回复完成后给出内置桌面提示,尽量贴近 Windows 系统提示体验。
  • 提示里展示足够上下文,方便用户判断是哪次任务完成。
  • 点击提示可以回到正确的 Deep Code CLI 终端。
  • 保持作者原本设计的灵活性:自定义 notify 脚本仍然优先。

实现方式

  • 新增 Windows 内置通知脚本,基于 Windows Forms 显示桌面提示。
  • 显示提示时播放系统提示音,点击提示后执行短暂缩放/淡出动画。
  • 支持点击提示后恢复并聚焦启动 CLI 的终端窗口,包括终端最小化的情况。
  • 将最近一次用户问题通过 QUESTION 环境变量传给通知脚本。
  • 内置提示只在 Windows 且未配置自定义 notify 时启用。
  • 更新中英文通知文档。
  • 增加 smoke test,覆盖终端窗口解析、最小化恢复和点击聚焦路径。

行为边界

现有自定义通知行为保持不变:

  • 配置了 notify 时,继续执行用户自定义脚本。
  • 未配置 notify 且运行在 Windows 时,才使用内置桌面提示。
  • 非 Windows 平台行为不变。

测试

已通过:

npm run check
npx tsx --test src\tests\settings-and-notify.test.ts
powershell.exe -ExecutionPolicy Bypass -NoProfile -File templates\tools\deepcode-notify.ps1 -ValidateOnly
powershell.exe -ExecutionPolicy Bypass -NoProfile -File templates\tools\test-notify.ps1
git diff --check
npm run bundle

构建后手动运行新产物:

node dist\cli.js

手动验收:

powershell.exe -ExecutionPolicy Bypass -NoProfile -File templates\tools\test-notify.ps1 -CurrentTerminalClickTest

已验证场景:

  • 能显示任务完成提示。
  • 显示提示时会播放系统提示音。
  • 终端在后台时,点击提示可以聚焦终端。
  • 终端最小化时,点击提示可以恢复并聚焦终端。
  • 点击提示后,提示会执行缩放/淡出动画并消失。
  • 点击关闭按钮只关闭提示,不触发终端聚焦。

说明

本地 Windows 环境也尝试运行了:

npm test

通知相关测试通过;完整测试套件在本地 Windows 上有若干失败,集中在临时目录清理阶段,错误为 fs.rmSync 抛出 EPERM。这些失败看起来与本 PR 的通知改动无关,因此没有把 Windows 临时目录清理问题纳入这个 PR 的范围。

总结

感谢作者把 Deep Code CLI 做成了一个很轻、很直接的终端 AI 工具。这个 PR 主要是在现有 notify 设计之上补齐 Windows 的默认体验,让用户在不配置额外脚本的情况下,也能及时知道任务完成,并一键回到正确的终端窗口。

sixsixla added 12 commits June 4, 2026 20:34
Add a bundled PowerShell script (templates/tools/deepcode-notify.ps1) that: - Captures the console window HWND via GetConsoleWindow - Shows a BalloonTip notification when a task completes/fails - On click, activates the originating terminal via SetForegroundWindow Extend notify.ts with launchBuiltinNotify() and resolveBuiltinNotifyPath() so the CLI can resolve and invoke the bundled script without user configuration. Update SessionManager.maybeNotifyTaskCompletion() to fall back to the built-in notification on Windows when no external notify script is configured.
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