fix(hotkey): Wayland 下用 CLI 触发录音,修复 #420#427
Merged
Merged
Conversation
Wayland 协议禁止应用监听非聚焦窗口键盘事件,原 rdev 路径必然失效。 保留 X11 rdev 不动;Wayland 下走 stub HotkeyAdapter(不监听键盘), 通过 tauri-plugin-single-instance 把 `openless --toggle-dictation` 等 CLI 命令的 argv 转给主实例 coordinator,由桌面环境快捷键设置 绑定该命令实现全局触发。Settings → 录音 mount 时 invoke is_wayland_cli_mode 拉状态,显示绑命令引导 callout (GNOME / KDE / Hyprland / sway 四段步骤)。 新增: - src-tauri/src/cli.rs — CLI intent 解析 + 10 个单测 - docs/issue-420-wayland-hotkey-research.md — 方案调研文档 改动: - hotkey.rs Linux 分支:Wayland 检测命中走 WaylandCliAdapter stub (不再硬拒绝 wayland_unsupported) - lib.rs:single-instance 回调路由 argv → dispatch_cli_intent - commands.rs:新增 is_wayland_cli_mode IPC command - coordinator.rs:dictation_phase_for_cli + cli_toggle_qa_panel 暴露 CLI 入口,复用现有状态机 - Settings.tsx:WaylandHotkeyCallout 组件 + invoke pull 模型 - i18n × 5 locale:settings.recording.wayland.* 共 14 个键 macOS CGEventTap 和 Windows RegisterHotKey 路径零触碰。
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
摘要
修复 #420 — Debian/Wayland 桌面环境下录音快捷键不可用。
Wayland 协议禁止应用监听非聚焦窗口的键盘事件,原
rdev路径在 Wayland 必然失效,之前代码硬拒绝并报wayland_unsupported。本 PR 保留 X11 rdev 路径不动;Wayland 下改走 stub HotkeyAdapter(不监听键盘),通过tauri-plugin-single-instance把openless --toggle-dictation等 CLI 命令的 argv 转给主实例 coordinator,由桌面环境快捷键设置绑定该命令实现全局触发。Issue 用户原话方案:"建议补充对应的脚本或者命令让用户去系统设置中配置快捷键即可" — 本 PR 落地的就是这个方案。
改动文件
src-tauri/src/cli.rs(新建)src-tauri/src/hotkey.rsWaylandCliAdapterstub(不再硬拒绝)src-tauri/src/lib.rsdispatch_cli_intent;删一次性 emit,改 IPC pullsrc-tauri/src/commands.rsis_wayland_cli_modeIPC commandsrc-tauri/src/coordinator.rsdictation_phase_for_cli+cli_toggle_qa_panel暴露 CLI 入口src/pages/Settings.tsxWaylandHotkeyCallout组件 + invoke pull 模型src/lib/ipc.tsisWaylandCliModewrapper(mock 返回 false)src/i18n/{zh-CN,en,zh-TW,ja,ko}.tssettings.recording.wayland.*共 14 个键docs/issue-420-wayland-hotkey-research.md(新建)平台影响
测试
cargo check --manifest-path src-tauri/Cargo.toml: 0 errornpm run build: 通过cargo test --lib: 243 passed / 0 failed(含 cli 模块 10 个新测试)用户使用方式(Wayland)
PR 合并并发版后,用户在 Wayland 下打开 Settings → 录音 会看到引导 callout,按 GNOME / KDE / Hyprland / sway 各自步骤把
openless --toggle-dictation绑到桌面环境的自定义快捷键即可。遗留
WaylandCliAdapter的空跑 channel tx 让 bridge thread 空等(不影响功能,留后续 issue)GlobalShortcuts(GNOME 已支持,KDE Plasma 6 已支持)作为更原生的方案;本期先 CLI 兜底PR Type
Bug fix, Enhancement, Tests, Documentation
Description
Route Wayland shortcuts through CLI
--toggle-dictation,--toggle-qa,--cancelsingle-instanceReplace Wayland hotkey failure
Show setup guidance in Settings
Add tests and research docs
Diagram Walkthrough
File Walkthrough
11 files
Adds CLI intent parsing and testsExposes Wayland session detectionRoutes CLI intents through coordinatorDispatches CLI intents from startupAdds English Wayland setup textAdds Japanese Wayland setup textAdds Korean Wayland setup textAdds Simplified Chinese setup textAdds Traditional Chinese setup textAdds Wayland mode IPC wrapperShows Wayland shortcut setup callout1 files
Stubs Wayland hotkey listener path1 files
Documents Wayland hotkey research