Skip to content

feat(desktop): 通知新增应用级提示音通道 (#3177) - #3257

Open
ningkaikok wants to merge 9 commits into
makecindy:mainfrom
ningkaikok:feat/3177-notification-chime
Open

feat(desktop): 通知新增应用级提示音通道 (#3177)#3257
ningkaikok wants to merge 9 commits into
makecindy:mainfrom
ningkaikok:feat/3177-notification-chime

Conversation

@ningkaikok

@ningkaikok ningkaikok commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

这次改了什么

摯要

为会话事件通知新增应用级提示音通道#3177)。后台跑长任务时,OS 通知音可能被勿扰/专注助手吞掉;Windows/Linux 又没有灵动岛的音效系统——完成/待回复/出错时用户完全无感。

实现遵循 issue 下维护者分析的边界:声音决策挂在现有唯一裁决点(fireSessionNotification 的失焦 gate、Orca worker 聚合、灵动岛去重之后),不在权限回调或确认卡组件里散播播放调用;提示音资产与事件映射复用灵动岛内置音效及语义(#3082 的经验)。

变更类型

  • feat 新功能

范围

  • 关联 Issue / 需求:feat: 任务完成声音提醒 + 后台审批/待操作主动提醒 #3177(方案对齐该 issue 维护者分析的行动建议)
  • 本 PR 包含:
    • 会话事件通知 channels 新增 sound 通道:开启时 renderer 在本地播放内置提示音,并把对应系统 toast 置静音(silent: true),避免 OS 音与应用音双响;未传时保持 Electron 默认行为,老调用方零改动
    • 提示音资产复用灵动岛内置音效(done→gem-collecterror→error-buzzneeds-reply→secret-chime),Vite asset import 引入,跨平台可用
    • 设置「通知」区块新增「声音提醒」独立开关(默认开,与桌面通知开关分开)
    • notificationService payload 运行时校验覆盖新字段
  • 明确不包含:
    • 自定义音效选择(首版仅内置默认音)
    • scheduler 直连路径(showDesktopSessionEvent main 直发)的应用级声音——该路径保持 OS 行为,如需覆盖可后续单独接
    • IM/hook 链路的审批提醒升级
  • 用户可见变化:有——设置「通知」区块多一个「声音提醒」开关;开启后失焦时的完成/待回复/出错通知带应用提示音
  • 是否存在 breaking change:无

UI 变化

  • 引用的设计规范:docs/design-rules/DESIGN.md
    • §4 Component Stylings:开关卡片沿用「桌面通知」既有卡片样式(rounded-xl / Card bg / 1px border),Switch 复用同一组件与 aria 模式
    • 颜色全部继承语义 token,无新增硬编码色值;文案走 i18n ×5 语言并通过术语表门禁
    • 双模式:开关卡片为纯文本+Switch,无自定义配色,Light/Dark 均由主题 token 保证(未做实机目检,如实说明)

怎么验证的

自动验证

pnpm --filter desktop exec vitest run src/main/__tests__/notificationService.test.ts   # 20/20(含新增 4 个 sound 通道用例)
pnpm --filter desktop typecheck                                                        # 通过
corepack pnpm check:i18n-glossary                                                      # 无新增违规
corepack pnpm test:unit:related                                                        # PASS
pnpm check:dco                                                                          # signed off

手工验证

macOS dev 构建(隔离沙箱)实机验证,通过 CDP 注入 Audio 探针观察真实播放行为:

  1. 声音链路:窗口失焦 + 会话完成 → gem-collect.mp3 实际播放(play() resolve,探针记录 played: true);
  2. 灵动岛去重:岛设置开启后触发同一事件 → 应用音跳过(探针为空),与桌面 toast 的既有去重同形状,无双响;
  3. 播放失败降级(review P2 场景):模拟 autoplay 被 NotAllowedError 拒绝 → playSessionEventSound 返回 false 且不抛错,channels.sound 保持 false,OS 通知音保留;
  4. 音量/时长为内置资产默认值,真实听感建议维护者体验后反馈,可再调。

未执行的验证

  • Windows/Linux 实机(本机仅 macOS);三平台的系统级静音交互(勿扰模式下的静默降级路径由代码保证:play().catch 静默失败,单测锁定不抛出)。

风险

风险分类

  • 无已知风险

影响与回滚

  • 影响范围:仅桌面通知的声音呈现与一个新设置开关;不涉及授权决策(提醒不参与任何授权判断)、不改 Agent 行为、无协议/schema 变更。
  • 回滚 / 降级方式:revert 本 PR 即可;关闭「声音提醒」开关也可即时回到旧行为。

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名(git commit -s,见 DCO
  • UI 改动已在「UI 变化」注明引用的设计规范章节
  • 未提交凭证、令牌或授权文件
  • 已补充必要文档
  • 已确认测试结果或说明未执行原因

后台跑长任务时,OS 通知音可能被勿扰/专注助手吞掉;Windows/Linux
又没有灵动岛的音效系统,完成/待回复/出错时用户无感。

- 会话事件通知新增 sound 通道:fireSessionNotification 裁决点
  (失焦 gate、Orca worker 聚合、灵动岛去重之后)播放应用内置提示音,
  并把该条系统 toast 置静音,避免 OS 音与应用音双响;
- 提示音资产与事件映射复用灵动岛内置音效及语义:
  done→gem-collect / error→error-buzz / needs-reply→secret-chime;
  renderer 直接 new Audio 播放,失败静默降级不阻断通知;
- 设置「通知」区块新增独立开关(默认开),localStorage 持久化;
- 未传 sound 通道的调用方保持 Electron 默认行为,零改动兼容。

Signed-off-by: 宁凯 <ningkaikok@163.com>
@ningkaikok
ningkaikok requested a review from a team as a code owner August 22, 2026 17:30

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3ba0c7ae53

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx Outdated
@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown

Greptile Summary

本 PR 为桌面会话通知新增可独立配置的应用级提示音,并在应用音成功启动或被同类声音合并时静音系统 toast,避免双响。

  • 新增完成、错误和待回复三类内置音效及 500ms 有界启动与失败降级
  • 扩展 renderer、preload 与 main 通知 payload 的 sound 通道
  • 新增声音提醒设置、默认值恢复、五种语言文案及相关测试

Confidence Score: 5/5

当前 HEAD 已完成此前提示音失败降级和等待有界化修复,未发现仍需阻止合并的故障。

未发现仍然存在的阻塞性故障。

Important Files Changed

Filename Overview
apps/desktop/src/renderer/lib/notificationSound.ts 实现提示音映射、同类事件合并、冷却、焦点取消与 500ms 启动超时,失败时返回 false 以保留系统声音。
apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx 在既有会话通知裁决点播放提示音,并在等待后重新校验焦点和数据所有者,再分发各通知通道。
apps/desktop/src/main/notificationService.ts 校验新增 sound 字段,并仅在 renderer 确认应用音已覆盖时为 Electron toast 设置 silent。
apps/desktop/src/renderer/hooks/useNotificationSettings.ts 增加应用提示音偏好的默认值、持久化和恢复默认能力。
apps/desktop/src/renderer/components/settings/NotificationSection.tsx 在通知设置中增加独立的声音提醒开关和恢复默认入口。

Reviews (8): Last reviewed commit: "docs(desktop): clarify notification soun..." | Re-trigger Greptile

Comment thread apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@ningkaikok 👋 这个 PR 还有 2 条 review conversation 没 resolve(apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi

Copy link
Copy Markdown
Contributor

这个 PR 给通知加了应用级提示音和设置入口,用户听得见也看得到,维护者确认门按产品类拦住了。请维护者在本 PR 上 Approve 放行,或 Request Changes 说明要改什么。讨论 issue:#3259

@MagicLizi MagicLizi added awaiting-discussion 等待维护者讨论(review-pr) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) labels Aug 22, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

命中 UI 路径(apps/desktop/src/renderer/assets/sounds/error-buzz.mp3 / apps/desktop/src/renderer/assets/sounds/gem-collect.mp3 / apps/desktop/src/renderer/assets/sounds/secret-chime.mp3 等)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范

review P2:playSessionEventSound 原实现吞掉 audio.play() 的 rejection,
但调用方仍无条件传 sound:true → 播放失败(autoplay 被拒/资源缺失)时
系统通知被置静音,用户反而完全听不到提醒。

- playSessionEventSound 改为返回 Promise<boolean>:play() resolve =
  实际出声,reject = 未发声;
- fireSessionNotification 先 await 播放结果,soundOn 才写进 channels,
  失败时保持 Electron 默认(silent:false),OS 通知音照常。

Signed-off-by: 宁凯 <ningkaikok@163.com>
@ningkaikok

Copy link
Copy Markdown
Contributor Author

已修复(5a7859f18):playSessionEventSound 现在返回 Promise<boolean>(play() resolve = 实际出声),fireSessionNotification 先 await 播放结果,只有确认开始播放才传 sound: true 让 toast 静音;播放失败时保持 Electron 默认行为,OS 通知音照常——保证至少有一条可听的提醒。新增/调整的单测覆盖了 silent 标志的互斥逻辑,typecheck 与定向测试全绿。

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a7859f185

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@ningkaikok 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

Signed-off-by: Dash <dashhuang@gmail.com>
Comment thread apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx Outdated

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0786171118

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/renderer/hooks/useNotificationSettings.ts
Signed-off-by: Dash <dashhuang@gmail.com>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1f36d8821

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@ningkaikok 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

Signed-off-by: Dash <dashhuang@gmail.com>
@MagicLizi

Copy link
Copy Markdown
Contributor

@ningkaikok 👋 这个 PR 目前与 main 有合并冲突,auto-review 因此暂时跳过、没法继续审查 / 合并。

请在本地 merge 最新的 origin/main 解决冲突后推送;冲突解除后,下一轮 auto-review 会自动重新处理这个 PR。

…n-chime

Signed-off-by: 宁凯 <ningkaikok@163.com>

# Conflicts:
#	apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b84cd73695

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/lib/notificationSound.ts
@MagicLizi

Copy link
Copy Markdown
Contributor

@ningkaikok 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/lib/notificationSound.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

review P1:同一批状态更新里多个会话同时完成/报错/待回复时,
每个事件都独立播放一个 Audio,多个相同 mp3 叠加失真;且各次
play() 都成功导致对应系统通知全部静音,用户只听到重叠噪音。

- 新增同类 1.5s 冷却(与灵动岛同语义路径的每类冷却一致):
  冷却窗口内的同类事件不再叠加播放,但返回 true 让其 toast
  照常静音——用户毫秒级前刚听过同一个音,无需 OS 音再补;
- 只统计成功播放:上次失败不进入冷却,同批后续事件仍会重试,
  保证至少一条可听提醒(P2 语义不变);
- 冷却按 kind 独立,不同终态音互不抑制。

Signed-off-by: 宁凯 <ningkaikok@163.com>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2cac4457fb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/lib/notificationSound.ts
Comment thread apps/desktop/src/renderer/hooks/useNotificationSettings.ts Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@ningkaikok 👋 这个 PR 还有 3 条 review conversation 没 resolve(apps/desktop/src/renderer/lib/notificationSound.ts / apps/desktop/src/renderer/hooks/useNotificationSettings.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@ningkaikok

ningkaikok commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

这轮 CI 的真实失败只有 Windows 1/2 中一个与本 PR 改动无关的超时:

  • packages/maker-core/src/memory/manager.scope.test.ts
  • 用例:scope 变化时关闭旧 db 并重建到新根 (owner 提交/切换)
  • 错误:默认 5s 超时

本 PR 没有修改 packages/maker-core;同一 maker-core shard 在上一轮 Windows CI 中完整通过(90.2s)。此前两次 Windows 红灯也分别来自 device-link ACK 计数和 Desktop crossProcessLock 耗时断言,失败点彼此不同;当前 Desktop、Linux 两个 shard、Windows 2/2、typecheck、DCO、Greptile 和 Git integration 均已通过,因此判断为 Windows runner 的无关计时波动。

我尝试执行 Re-run failed jobs,但 fork 作者没有上游仓库 Actions 的管理权限。麻烦维护者帮忙重跑本轮失败 jobs;如同一个 manager.scope 用例重跑后仍稳定超时,再另开维护项处理 Windows 文件系统测试预算,不在本功能 PR 中夹带修改。

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

Labels

awaiting-discussion 等待维护者讨论(review-pr) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants