feat(capsule): 录音开始播放合成提示音 + 录音与输入设置开关#560
Merged
Merged
Conversation
按下录音热键进入 recording 状态时,capsule 窗口用 Web Audio API 即时合成 一段上升双音提示音,提醒「已开始录音」;离开 recording 即停。提示音独立于 showCapsule —— 胶囊隐藏时仍会响。 - 新增 audioCueOnRecord 偏好(默认开启),可在「录音与输入」设置里开关, 并提供「试听」按钮即时听效果。 - 后端 UserPreferences / UserPreferencesWire 持久化该字段并默认 true, 老配置缺字段按开启;补两条单测(缺字段默认开启 + 显式 false 往返保真)。 - 提示音合成抽成 lib/audioCue.ts:playRecordStartCue / stopAudioCue 两个 操作 + 纯函数音符规划(recordStartCueTones / cueTotalDurationMs),附 .test.ts。suspended 的 AudioContext 先 resume 再排期,无 Web Audio 时静默降级。 - i18n 五语(en / zh-CN / zh-TW / ja / ko)补齐 label / desc / preview。
PR Reviewer Guide 🔍(Review updated until commit 2784e97)Here are some key observations to aid the review process:
|
suspended 的 AudioContext 先 resume 再排期,若等待 resume 期间录音已结束 (stopAudioCue)或有新一轮播放,旧的 resume 回调不再排期,避免「录音已停、 提示音晚到」。引入 playGeneration 代号:stopAudioCue 自增并停节点; scheduleCueVoices 只 stopVoices 不动代号;deferred 播放回调比对代号决定是否排期。
|
Persistent review updated to latest commit 2784e97 |
appergb
pushed a commit
that referenced
this pull request
May 31, 2026
本次只动版本号,功能改动已在 #560 落盘: - 按下录音热键进入 recording 即播放 Web Audio 合成提示音,提醒「已开始录音」 - 新增 audioCueOnRecord 开关(默认开启),录音与输入设置可关闭 + 试听
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
背景 / 目标
新增「音频播放提醒」功能:按下录音热键开始录音时,用一段即时合成的提示音提醒用户「已开始录音」。听写场景里热键是隐形的,加一个开始音能明确告诉用户录音真的起来了(业界听写类 App 普遍如此)。
playRecordStartCue/stopAudioCue两个操作 + 设置开关)改动
前端
lib/audioCue.ts(新):Web Audio API 即时合成上升双音(A5→C#6)。playRecordStartCue()播放、stopAudioCue()关闭。recordStartCueTones()/cueTotalDurationMs()便于单测(audioCue.test.ts)。suspended的 AudioContext 先resume()再排期(避免 WKWebView/WebView2 上排到冻结时钟);无 Web Audio 时静默降级,绝不抛进录音主流程。components/Capsule.tsx:在 capsule 窗口监听capsule:state,检测进入recording的边沿就播放、离开就停。capsule 窗口始终存活并恒收事件,因此独立于 showCapsule——胶囊隐藏时仍会响。开关通过getSettings()+prefs:changed实时同步。pages/settings/RecordingInputSection.tsx:「录音与输入」里新增开关 + 说明 + 「试听」按钮。lib/types.ts:UserPreferences.audioCueOnRecord: boolean。后端(持久化)
src-tauri/src/types.rs:UserPreferences与持久化用的UserPreferencesWire都新增audio_cue_on_record,#[serde(default = "default_true")]—— 默认开启,老preferences.json缺字段也按开启。两处Defaultimpl 与 Wire→Prefs 转换同步更新。missing_audio_cue_on_record_pref_defaults_to_enabled、audio_cue_on_record_pref_round_trips_explicit_false(证明设置关闭后存盘往返不丢字段)。设计取舍
muteDuringRecording:提示音是 UI 反馈,单独由audioCueOnRecord控制。影响面(GitNexus 影响分析)
UserPreferencesupstream 直接引用 14 处,全部是 commands.rs 里的测试,0 条执行流受影响;且所有构造点都用..Default::default(),新增带默认值的字段向后兼容。实际风险:低。测试计划
已在本地验证(与 CI cross-platform 任务一致):
npm run build(tsc + vite)通过cargo test --lib audio_cue→ 2 passednpx tsx src/lib/audioCue.test.ts→ all assertions passed手动 QA(建议在合并后的 beta 包上覆盖):
PR Type
Enhancement, Tests
Description
Add recording start chime
Expose toggle and preview
Persist new user preference
Cover audio cue behavior
Diagram Walkthrough
File Walkthrough
3 files
Persist recording cue preference in backendDefault mock settings include audio cueAdd audio cue preference to types8 files
Play cue on recording transitionsAdd English recording cue stringsAdd Japanese recording cue stringsAdd Korean recording cue stringsAdd simplified Chinese cue labelsAdd traditional Chinese cue labelsSynthesize recording start chime in Web AudioAdd recording cue toggle and preview2 files
Test cue tone timing and shapeUpdate preference fixture for new field