Skip to content

fix: add 600ms activation cooldown after end_session for Toggle mode (#545)#571

Merged
H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:fix/545-toggle-cooldown
Jun 1, 2026
Merged

fix: add 600ms activation cooldown after end_session for Toggle mode (#545)#571
H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:fix/545-toggle-cooldown

Conversation

@H-Chris233
Copy link
Copy Markdown
Collaborator

@H-Chris233 H-Chris233 commented Jun 1, 2026

User description

背景

Issue #545 报告 Toggle 模式下快速三连按时,第 3 次按键会在胶囊离场动画期间误激活新听写。

改动

在 coordinator 层增加 timer-based busy gate,冷却时长 600ms(覆盖胶囊 EXIT_ANIM_MS 360ms + 余量):

文件 改动
`coordinator.rs` 新增 `POST_SESSION_COOLDOWN_MS = 600` 常量 + `session_cooldown_until` 字段
`coordinator/dictation.rs` `handle_pressed` 的 `(Toggle, Idle)` 分支增加冷却检查
`coordinator/dictation.rs` `end_session` 成功收尾时设置冷却
`coordinator/dictation.rs` `cancel_session` 将 phase 设为 Idle 时同步设置冷却

不受影响

  • Hold 模式:冷却仅在 `(Toggle, Idle)` 分支检查,Hold 走 `(Hold, Idle)` 不受影响
  • 错误/取消后的立即重试:error 提前返回路径不设冷却,用户出错后可立即重试
  • Starting 阶段的连按:已有 `request_stop_during_starting` 逻辑
  • 现有 HOTKEY_DEBOUNCE (250ms):防抖与冷却互补,冷却占主导

验证

  • `cargo build`: ✅ 成功
  • `cargo test`: ✅ 358/358 通过
  • Code review 子代理: ✅ 确认设计正确,修复了 `cancel_session` 遗漏的冷却

Closes #545


PR Type

Bug fix


Description

  • Add 600ms activation cooldown after end_session/cancel_session

  • Block toggle hotkey in Idle phase during cooldown

  • Prevent triple-press Third key from starting new dictation


Diagram Walkthrough

flowchart LR
  Press["Hotkey Pressed (Toggle, Idle)"] --> Check{Cooldown expired?}
  Check -- Yes --> Begin["begin_session"]
  Check -- No --> Ignore["Ignore (blocked)"]
  Begin --> End["end_session / cancel_session"]
  End --> SetCooldown["Set POST_SESSION_COOLDOWN_MS"]
  SetCooldown --> CapsuleIdle["schedule_capsule_idle"]
Loading

File Walkthrough

Relevant files
Enhancement
coordinator.rs
Add cooldown constant and state field                                       

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

  • Added POST_SESSION_COOLDOWN_MS constant (600ms)
  • Added session_cooldown_until field to Inner struct
  • Initialized field in constructor
+11/-0   
Bug fix
dictation.rs
Implement cooldown check and set in session endpoints       

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

  • Added cooldown check in handle_pressed for (Toggle, Idle) branch
  • Set cooldown timestamp in end_session after setting phase to Idle
  • Set cooldown timestamp in cancel_session when phase set to Idle
+25/-0   

…pen-Less#545)

在 coordinator 层增加 timer-based busy gate:end_session / cancel_session
将 phase 设为 Idle 时记录冷却时间戳;handle_pressed 的 (Toggle, Idle)
分支在 begin_session 前检查该冷却,未过期则忽略本次按键。

冷却时长 600ms(覆盖胶囊 EXIT_ANIM_MS 360ms + 余量),既拦截
三连按的第 3 次误触,也不影响用户主动重新激活。

- coordinator.rs: 新增 POST_SESSION_COOLDOWN_MS 常量 + Inner 字段
- dictation.rs: handle_pressed 增加冷却检查
- dictation.rs: end_session / cancel_session 成功收尾时设置冷却
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

545 - Partially compliant

Compliant requirements:

  • 三连按语义(Toggle):第1激活;第2关闭;第3次忽略(通过 cooldown 实现)。
  • 与动画修复不冲突:保留现有UI行为,在coordinator层添加冷却检查。
  • 关闭/取消路径可用:cancel_session 和 end_session 都设置冷却,取消路径不受影响。
  • 回归:Hold模式(走 Hold,Idle 分支,不检查冷却);Starting 阶段已有独立处理。

Non-compliant requirements:

  • 完全结束后才允许再激活:冷却仅持续600ms,胶囊UI可能在2秒后才完全隐藏。但冷却覆盖了动画关键期(360ms),作者解释为设计选择,是否符合「完全结束」的定义需由维护者最终确认。

Requires further human verification:

  • 胶囊UI在冷却期满后(600ms)是否仍处于离场动画或隐藏过程中?若用户此时再次激活,是否会出现视觉不一致?需人工测试确认。
⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@H-Chris233 H-Chris233 merged commit c87bab4 into Open-Less:beta Jun 1, 2026
4 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.

[ui] 听写快速连按应在上一轮完全结束前忽略激活(动画已缓解,逻辑未改)

1 participant