Skip to content

fix(hotkey): 250ms debounce on pressed-edge dispatch#409

Merged
appergb merged 1 commit into
betafrom
pr/hotkey-debounce-250ms
May 11, 2026
Merged

fix(hotkey): 250ms debounce on pressed-edge dispatch#409
appergb merged 1 commit into
betafrom
pr/hotkey-debounce-250ms

Conversation

@appergb
Copy link
Copy Markdown
Collaborator

@appergb appergb commented May 11, 2026

User description

Summary

  • 相邻 < 250ms 的 hotkey press 边沿直接丢弃,记 log 方便排查
  • 解决:微动开关回弹 / 用户手抖双击 / 用户连点过快 → 空转写报错 + ASR session 抢资源

主要改动

  • `coordinator.rs::Inner` 新增 `last_hotkey_dispatch_at: Mutex<Option>` 字段(2 个构造点同步初始化)
  • `coordinator/dictation.rs` 加 `HOTKEY_DEBOUNCE = 250ms` 常量,`handle_pressed_edge` 入口检查时间戳

与 `hotkey_trigger_held` 互补:held 防 press-without-release,本检查防 press-release-press 三连过快。用户正常使用(不会快于 4 次/秒)不会触发。

Test plan

  • `cargo check --manifest-path src-tauri/Cargo.toml` pass
  • CI 三平台 cargo check pass
  • 真机:正常切换式录音不受影响(每按一次都生效)
  • 真机:故意 50ms 内连按两次,第二下应被 log "debounced" 丢弃

PR Type

Bug fix


Description

  • Add 250ms pressed-edge debounce

  • Drop rapid hotkey repeats

  • Initialize dispatch timestamp state


Diagram Walkthrough

flowchart LR
  A["Pressed hotkey edge"] --> B["250ms debounce check"]
  B -- "too soon" --> C["Log and drop"]
  B -- "accepted" --> D["Route to dictation or QA"]
Loading

File Walkthrough

Relevant files
Bug fix
coordinator.rs
Track last hotkey dispatch timestamp                                         

openless-all/app/src-tauri/src/coordinator.rs

  • Add last_hotkey_dispatch_at to Inner
  • Document the debounce purpose and scope
  • Initialize the new mutex in both constructors
+7/-0     
dictation.rs
Debounce rapid hotkey press edges                                               

openless-all/app/src-tauri/src/coordinator/dictation.rs

  • Define a 250ms HOTKEY_DEBOUNCE constant
  • Check elapsed time before handling pressed edges
  • Update the timestamp only for accepted edges
  • Log debounced presses for easier debugging
+24/-0   

避免微动开关回弹 / 用户手抖双击造成的空转写报错和 ASR session 抢资源:
相邻 < 250ms 的 press 边沿直接丢弃,记 log。

- coordinator.rs: Inner 新增 last_hotkey_dispatch_at: Mutex<Option<Instant>>
- coordinator/dictation.rs: HOTKEY_DEBOUNCE 常量 + handle_pressed_edge 入口检查

与 hotkey_trigger_held 互补:held 防 press-without-release,本检查防
press-release-press 三连过快。每个有效边沿都会更新时间戳;用户正常使用
(不会快于 4 次/秒)不会触发。
@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

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

@appergb appergb merged commit 6a1986e into beta May 11, 2026
4 checks passed
@appergb appergb deleted the pr/hotkey-debounce-250ms branch May 11, 2026 16:32
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.

1 participant