feat(hotkey): 录音方式新增「自动」——短按=切换式,长按=按住说话#789
Conversation
在「切换式 / 按住说话」外新增第三种录音方式 Auto:按下即开录, 松手时按按住时长判定语义 —— 短按(< 350ms)锁存为切换式(保持 录音,下次按下再停),长按(>= 350ms)当作按住说话(松手即停)。 已锁存后再次按下即停。 实现要点: - HotkeyMode 新增 Auto 变体(前后端类型同步) - Coordinator 在 handle_pressed/handle_released 解释边沿:按下记录 press_at,松手用 elapsed() 判定短/长按 - 判定在松手处理时测量,会被 begin_session 阻塞 bridge 的时长抬高; 350ms 阈值下仅当冷启动 >= 350ms 时短按可能误判为长按(可恢复), 常见快速启动下判定正确。该权衡避免改动跨平台的 P0 串行化热键路径 - 设置页新增第三个分段选项;标签/使用提示与 5 种语言 i18n 补齐 - 新增 2 个单元测试覆盖短按锁存 / 长按结束 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
PR Reviewer Guide 🔍(Review updated until commit e06e93e)Here are some key observations to aid the review process:
|
|
哇,这太酷了!我现在就开始审核工作。 |
|
Persistent review updated to latest commit 0ed29c2 |
|
Persistent review updated to latest commit ffd422c |
|
Persistent review updated to latest commit 42c67c6 |
H-Chris233
left a comment
There was a problem hiding this comment.
Request changes
P2:Auto 模式在快捷键设置页仍显示为 Toggle
openless-all/app/src/pages/settings/ShortcutsSection.tsx:77 仍使用二元判断:
hotkey.mode === 'hold'
? t('hotkey.modeHoldSuffix')
: t('hotkey.modeToggleSuffix')因此用户在“通用”设置页选择 auto 后,这里仍显示“开始 / 停止”,而上方录音方式显示“自动”;两处文案与实际语义矛盾。项目已经在 openless-all/app/src/lib/hotkey.ts 中集中处理了 auto(并且五种语言都有 hotkey.modeAutoSuffix),请复用该 helper 或补齐完整分支,至少让 auto 显示自动识别。
另外,coordinator.rs 中 hotkey_press_at 的注释仍写着用 elapsed() 判定,当前实现已改为事件时间戳,建议一并更新注释和 PR 描述。
本次复核确认:P1 的事件时间戳已贯穿各平台 adapter、bridge 和 coordinator,released_at - pressed_at 及 take() 清理逻辑正确;最新 CI(Android、Linux、Windows、macOS)均通过。
|
Persistent review updated to latest commit e06e93e |
User description
??
???????????????????????????????? App ????????????????????????????? PR ?????????????????????
??
??????????????????????????????????
??
HotkeyMode??Auto???????????serde"auto"?handle_pressed/handle_released?????Pressed/Released ????????Instant?????????????????/????
cargo check/cargo test???? 3 ??? + ?? coordinator ???/tsc --noEmit????Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
PR Type
Enhancement, Tests, Documentation
Description
Add "Auto" recording mode with smart toggle/hold based on press duration
Attach timestamps to press/release events across hotkey infrastructure
Update Coordinator: press starts session, release decides latch or stop
Add unit tests for auto short-tap latching and long-hold ending
Update frontend types, i18n (5 languages), and UI with new mode option
Diagram Walkthrough
File Walkthrough
14 files
Add timestamp to ComboHotkeyEvent variantsAdd hotkey_press_at field and update test injectionImplement Auto mode logic and add threshold constantPass timestamps through bridge loops for accuracyAttach Instant to Pressed/Released events and update testsAttach timestamp to fcitx hotkey eventsAdd Instant to stub ComboHotkeyEvent variantsAdd Instant to stub HotkeyEvent variantsAttach timestamps to combo events and update testsAdd Auto variant to HotkeyMode enumRefactor label/usage functions to support auto modeAdd 'auto' to HotkeyMode typeAdd third segment option for Auto modeUse hotkeyModeSuffix for dynamic suffix display5 files
Add English i18n entries for auto modeAdd Japanese i18n entries for auto modeAdd Korean i18n entries for auto modeAdd Chinese (Simplified) i18n entries for auto modeAdd Chinese (Traditional) i18n entries for auto mode