From e484cd11cfd0f03d8e6ba3bcffc3186263828a91 Mon Sep 17 00:00:00 2001 From: bigsong <35025755+bigsongeth@users.noreply.github.com> Date: Sun, 2 Aug 2026 20:56:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(less-computer):=20=E3=80=8Chotkey=20disable?= =?UTF-8?q?d=E3=80=8D=E5=8F=AA=E5=9C=A8=E7=8A=B6=E6=80=81=E7=BF=BB?= =?UTF-8?q?=E8=BD=AC=E6=97=B6=E6=89=93=E4=B8=80=E6=AC=A1=E2=80=94=E2=80=94?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=B8=8D=E5=86=8D=E8=A2=AB=E5=AE=83=E5=88=B7?= =?UTF-8?q?=E7=88=86=20(#873)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit coding_agent_hotkey_supervisor_loop 每 5s 轮询一次绑定。没配 Less Computer 语音键的用户,每一轮都会落到同一条禁用分支并无条件打一行 「[less-computer] hotkey disabled」,稳定产出 720 行/小时。 实测一份连续跑了六天的 openless.log 里,这一行占了全部日志的 95% 以上 (132416 行中约 12.7 万行),文件涨到 11MB:真正有用的会话/错误日志被冲得 很难翻,日志轮转也被它提前触发,把更早的历史挤掉——排查线上问题时相当致命。 讽刺的是它刷得最凶的恰恰是没在用这个功能的人:一旦配上语音键,函数会走到 安装分支,反而一行都不打。 改成只在状态真正翻转成「禁用」时打一次,重新装上语音键时清掉标志位, 下次禁用仍会再打。禁用/启用的行为本身完全不变,只动日志。 Co-authored-by: Claude Fable 5 --- .../app/src-tauri/src/coordinator/hotkey_loops.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/openless-all/app/src-tauri/src/coordinator/hotkey_loops.rs b/openless-all/app/src-tauri/src/coordinator/hotkey_loops.rs index 3d6211a1..0dae854f 100644 --- a/openless-all/app/src-tauri/src/coordinator/hotkey_loops.rs +++ b/openless-all/app/src-tauri/src/coordinator/hotkey_loops.rs @@ -313,6 +313,16 @@ pub(super) fn coding_agent_hotkey_supervisor_loop(inner: Arc) { } } +/// 「Less Computer 语音键已禁用」是否已经打过日志。 +/// +/// supervisor 每 5s 轮询一次,没配语音键的用户每轮都会落到同一条禁用分支。无条件 +/// 打印会稳定产出 720 行/小时的同一句话 —— 实测一份跑了六天的 openless.log 里它占 +/// 了 95% 以上,真正有用的会话日志被冲得很难找,日志轮转也被它提前触发。 +/// 只在状态翻转成禁用时打一次;重新装上语音键时清掉,下次禁用还会再打。 +#[cfg(target_os = "macos")] +static LESS_COMPUTER_HOTKEY_DISABLED_LOGGED: std::sync::atomic::AtomicBool = + std::sync::atomic::AtomicBool::new(false); + pub(super) fn update_coding_agent_hotkey_binding_now(inner: &Arc) { #[cfg(not(target_os = "macos"))] { @@ -326,13 +336,16 @@ pub(super) fn update_coding_agent_hotkey_binding_now(inner: &Arc) { let prefs = inner.prefs.get(); let Some(binding) = prefs.coding_agent_voice_hotkey.clone() else { take_coding_agent_hotkeys_on_main_thread(inner); - log::info!("[less-computer] hotkey disabled"); + if !LESS_COMPUTER_HOTKEY_DISABLED_LOGGED.swap(true, Ordering::SeqCst) { + log::info!("[less-computer] hotkey disabled"); + } return; }; if !prefs.coding_agent_enabled || is_unconfigured_shortcut(&binding) { take_coding_agent_hotkeys_on_main_thread(inner); return; } + LESS_COMPUTER_HOTKEY_DISABLED_LOGGED.store(false, Ordering::SeqCst); if let Some(modifier_binding) = less_computer_modifier_binding(&binding) { take_coding_agent_combo_hotkey_on_main_thread(inner);