Skip to content

feat(hotkey): 录音方式新增「自动」——短按=切换式,长按=按住说话#789

Merged
H-Chris233 merged 5 commits into
Open-Less:betafrom
bigsongeth:feat/recording-mode-auto
Jul 12, 2026
Merged

feat(hotkey): 录音方式新增「自动」——短按=切换式,长按=按住说话#789
H-Chris233 merged 5 commits into
Open-Less:betafrom
bigsongeth:feat/recording-mode-auto

Conversation

@bigsongeth

@bigsongeth bigsongeth commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

User description

??

???????????????????????????????? App ????????????????????????????? PR ?????????????????????

??

??????????????????????????????????

  • ???< 350ms? ? ?????????????????
  • ???? 350ms? ? ?????????
  • ??????????

??

  • HotkeyMode ?? Auto ???????????serde "auto"?
  • Coordinator ? handle_pressed / handle_released ?????Pressed/Released ???????? Instant?????????????????/??
  • ?????Pressed/Released ???????????Coordinator ?????????? 350ms????? bridge ?????????????
  • ???????????????/????? 5 ??? i18n ??
  • ?? 3 ?????????????/????????????/??????

??

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

flowchart LR
  press["Press hotkey (Auto mode)"] --> start["Begin session + record press_at"]
  release["Release hotkey"] --> dur["Check press duration >= 350ms?"]
  dur -- "Yes (long hold)" --> end_hold["End session (push-to-talk)"]
  dur -- "No (short tap)" --> latch["Latch as toggle mode: keep recording"]
  latch --> press_again["Next press stops session"]
Loading

File Walkthrough

Relevant files
Enhancement
14 files
combo_hotkey.rs
Add timestamp to ComboHotkeyEvent variants                             
+8/-6     
coordinator.rs
Add hotkey_press_at field and update test injection           
+93/-4   
dictation.rs
Implement Auto mode logic and add threshold constant         
+64/-6   
hotkey_loops.rs
Pass timestamps through bridge loops for accuracy               
+16/-16 
hotkey.rs
Attach Instant to Pressed/Released events and update tests
+35/-20 
linux_fcitx.rs
Attach timestamp to fcitx hotkey events                                   
+2/-5     
combo_hotkey.rs
Add Instant to stub ComboHotkeyEvent variants                       
+3/-2     
hotkey.rs
Add Instant to stub HotkeyEvent variants                                 
+3/-2     
side_aware_combo.rs
Attach timestamps to combo events and update tests             
+19/-42 
types.rs
Add Auto variant to HotkeyMode enum                                           
+3/-0     
hotkey.ts
Refactor label/usage functions to support auto mode           
+27/-29 
types.ts
Add 'auto' to HotkeyMode type                                                       
+1/-1     
RecordingInputSection.tsx
Add third segment option for Auto mode                                     
+1/-0     
ShortcutsSection.tsx
Use hotkeyModeSuffix for dynamic suffix display                   
+8/-2     
Documentation
5 files
en.ts
Add English i18n entries for auto mode                                     
+3/-0     
ja.ts
Add Japanese i18n entries for auto mode                                   
+3/-0     
ko.ts
Add Korean i18n entries for auto mode                                       
+3/-0     
zh-CN.ts
Add Chinese (Simplified) i18n entries for auto mode           
+3/-0     
zh-TW.ts
Add Chinese (Traditional) i18n entries for auto mode         
+3/-0     

在「切换式 / 按住说话」外新增第三种录音方式 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>
@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit e06e93e)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@H-Chris233

Copy link
Copy Markdown
Collaborator

哇,这太酷了!我现在就开始审核工作。

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 0ed29c2

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit ffd422c

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 42c67c6

@H-Chris233 H-Chris233 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.rshotkey_press_at 的注释仍写着用 elapsed() 判定,当前实现已改为事件时间戳,建议一并更新注释和 PR 描述。

本次复核确认:P1 的事件时间戳已贯穿各平台 adapter、bridge 和 coordinator,released_at - pressed_attake() 清理逻辑正确;最新 CI(Android、Linux、Windows、macOS)均通过。

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit e06e93e

@H-Chris233 H-Chris233 merged commit b8acb9b into Open-Less:beta Jul 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants