fix(insertion): make Windows/Linux paste shortcut configurable (#360)#377
Merged
fix(insertion): make Windows/Linux paste shortcut configurable (#360)#377
Conversation
模拟粘贴硬编码 Ctrl+V,kitty / alacritty / wezterm / gnome-terminal / foot 等 Linux 终端只接受 Ctrl+Shift+V,听写文本只剩在剪贴板里,看起来 像"什么也没插入"。issue #360 报告了 kitty 这个具体场景。 新增 `PasteShortcut` 枚举(`CtrlV` / `CtrlShiftV` / `ShiftInsert`)作为 UserPreferences 字段,串到 simulate_paste 的 enigo 路径。Settings → 录音 多了"模拟粘贴快捷键"一行,仅在非 macOS 显示(macOS 走 AX 直写 不受影响)。默认 `CtrlV` 与历史行为一致,老配置文件没有 pasteShortcut 字段时 `#[serde(default)]` 回退到默认值,不破坏既有用户。 涵盖: - types.rs:新枚举 + 字段 + UserPreferencesWire 串接 - insertion.rs:simulate_paste(shortcut),paste_keys 把枚举拆成 (modifiers, primary),按下/释放严格对称,中途出错也反向释放避免卡键 - coordinator.rs:从 prefs 读取,串到三个 insert 调用点 + Windows IME 链 - 前端 TS 类型 / Settings 选择器 / 5 种语言 i18n - 单元测试:默认 CtrlV、JSON 反序列化、paste_keys 三种映射 cargo test --lib 全部 181 通过;npm run build 干净。
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
… release `TakeWhile<Iter, _>` 不实现 `DoubleEndedIterator`,所以 `.take_while(..).rev()` 在 Linux target 上编译不过(macOS host 因为整段 cfg(not(macos)) 没编译,所以 之前 cargo check 没暴露)。改用 `modifiers[..pressed].iter().rev()`:切片的 Iter 实现 DoubleEndedIterator,可以安全 `.rev()`。 顺手简化错误恢复路径:用一个 `first_err` 累加器,press → click → release 三段任何一段先报错都先记下来,最后一次性返回。语义跟原版 simulate_paste 对齐,不留卡键。 cargo test --lib 仍然 181 passed。
PR Reviewer Guide 🔍(Review updated until commit 26e31f2)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit 644dc63 |
…hortcut # Conflicts: # openless-all/app/src-tauri/src/coordinator.rs
|
Persistent review updated to latest commit 26e31f2 |
5 tasks
pull Bot
pushed a commit
to yimmy23/openless
that referenced
this pull request
May 10, 2026
10 PRs landed on beta this cycle: - Open-Less#377 paste shortcut configurable (issue Open-Less#360) - Open-Less#386 TS UserPreferences updateChannel alignment - Open-Less#387 focus_target leak on Processing-phase cancel - Open-Less#388 [严重] MacHotkeyAdapter::shutdown stops CFRunLoop + tap - Open-Less#389 emit_capsule window.show/hide off audio thread - Open-Less#390 QA / dictation hotkey routing race - Open-Less#391 audio-mute spawn_blocking (async hygiene) - Open-Less#392 hotkey supervisor + global dispatcher exit signal - Open-Less#393 post-audit logic-review hotfixes (QA mute .await + focus_target Processing branch) - Open-Less#394 in-process credentials cache (kills repeated Keychain prompts) Bump 4 files: package.json, tauri.conf.json, Cargo.toml, Cargo.lock.
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
Summary
Ctrl+V,kitty / alacritty / wezterm / gnome-terminal / foot 等 Linux 终端只接受Ctrl+Shift+V,听写文本只剩在剪贴板里,看起来像"什么也没插入"。PasteShortcut枚举(CtrlV/CtrlShiftV/ShiftInsert)作为UserPreferences字段,串到simulate_paste的 enigo 路径;Settings → 录音 多了"模拟粘贴快捷键"一行,仅在非 macOS 显示(macOS 走 AX 直写不受影响)。CtrlV与历史行为一致,老配置文件没有pasteShortcut字段时#[serde(default)]回退到默认值——不破坏既有用户。Why this scope
issue 里用户提到两点:(1) 加粘贴方式配置,(2) 按前台程序自动检测。前者满足验收标准;后者在 Linux 上实际很难做(Wayland 多数情况下根本拿不到前台窗口的 class,X11 要再依赖 xprop/xdotool)。本 PR 只做 (1)——一个全局选择器,3 个预设覆盖现实里能遇到的所有终端。如果以后有需求再加自动检测。
Files changed
src-tauri/src/types.rs—PasteShortcut枚举 +UserPreferences.paste_shortcut(默认CtrlV),串接 wire 类型 /Default/Deserialize。src-tauri/src/insertion.rs—simulate_paste(shortcut)走新paste_keys()helper;insert/insert_via_clipboard_fallback三平台签名都带paste_shortcut(macOS 忽略)。modifier 按下/释放严格对称,中途失败反向释放避免卡键。src-tauri/src/coordinator.rs— 从prefs读paste_shortcut,串到三个 insert 调用点 + Windows IME 兜底链。src/lib/types.ts、src/lib/ipc.ts、src/lib/stylePrefs.test.ts、src/pages/Settings.tsx。zh-CN、zh-TW、en、ja、ko各加 5 个 key。Test plan
cargo test --manifest-path src-tauri/Cargo.toml --lib— 181 passed, 0 failed,新增 3 个测试:paste_shortcut_defaults_to_ctrl_v— 默认值 + 老配置反序列化都回到 CtrlVpaste_shortcut_round_trips_explicit_values— 三种取值的 JSON 互转paste_keys_match_configured_shortcut— 枚举 → enigo Key 映射(cfg(not(macos))门控)cargo check --manifest-path src-tauri/Cargo.toml(host = aarch64-apple-darwin)干净npm run build(tsc + vite build)干净capability.adapter !== 'macEventTap'门控)pasteShortcut字段)启动后不报错、行为不变Closes #360
PR Type
Bug fix, Enhancement, Tests
Description
Add
PasteShortcutconfig for Windows/Linux paste key ([area] #360)PasteShortcutwithCtrlV,CtrlShiftV,ShiftInsertUserPreferences.paste_shortcutfield (defaultCtrlV, backward compatible)Refactor
simulate_pasteto handle multiple modifiers safelypaste_keys()maps shortcut to modifiers+primary keyDoubleEndedIteratorcompile error on Linux with slice indexingPlumb shortcut setting through coordinator → insertion call chain
insert,insert_via_clipboard_fallback, Windows IME fallback paths all carry the preferenceAdd UI selector under Settings → Recording (non‑macOS only)
Unit tests for default value, deserialization round‑trip, and key mapping
Diagram Walkthrough
File Walkthrough
6 files
Define PasteShortcut enum and add to preferencesRefactor simulate_paste for configurable shortcutThread paste_shortcut through Windows IME and fallback pathsPass paste_shortcut from prefs to insert callsAdd PasteShortcut type to UserPreferences interfaceUpdate mock settings with new pasteShortcut field1 files
Add paste shortcut selector UI (non‑macOS)1 files
Include pasteShortcut in test preferences mock5 files
English translations for paste shortcut settingJapanese translations for paste shortcut settingKorean translations for paste shortcut settingSimplified Chinese translations for paste shortcut settingTraditional Chinese translations for paste shortcut setting