Skip to content

feat(windows): 新增「始终使用 SendInput」开关,跳过听写时的 TSF 切换#734

Open
HKLHaoBin wants to merge 5 commits into
Open-Less:betafrom
HKLHaoBin:feat/issue-733-windows-sendinput-only
Open

feat(windows): 新增「始终使用 SendInput」开关,跳过听写时的 TSF 切换#734
HKLHaoBin wants to merge 5 commits into
Open-Less:betafrom
HKLHaoBin:feat/issue-733-windows-sendinput-only

Conversation

@HKLHaoBin

@HKLHaoBin HKLHaoBin commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

User description

摘要

Fixes #733

新增 Windows 专用 opt-in 开关「始终使用 SendInput(不切换输入法)」。开启后听写 session 不再调用 prepare_session() 切换 OpenLess TSF,全程使用 SendInput Unicode 插入。同时修复设置开关保存后立刻回落的问题(serde JSON key 与前端不一致)。

修复 / 新增 / 改进

  • 新增偏好 windowsSendInputInsertionOnly / windows_sendinput_insertion_only(默认 false)
  • begin_session 条件跳过 windows_ime.prepare_session();插入走 insert_via_non_tsf_fallback
  • 设置页「插入与剪贴板」新增开关(仅 Windows),位于「允许非 TSF 兜底」上方
  • 修复 serde camelCase 产出 windowsSendinputInsertionOnly 导致前端 key 被忽略、开关保存回落
  • 补充 wire key 合同测试与 SendInput-only 模式下 dictation_error_code 单元测试

兼容

  • 不包含:Android IME、TSF DLL 修改、合并「允许非 TSF 兜底」开关
  • 对现有用户 / 本地环境 / 构建流程的影响:默认关闭,行为与现版一致;alias 兼容旧错误 key 写入的 preferences.json

测试计划

  • 命令:npm run build --prefix openless-all/app;CI workflow_dispatch(run 27925685545)全绿
  • 命令:cargo test windows_sendinput --lib(Windows CI job 通过)
  • 结果:Release Tauri run 27925685566 success,产物 openless-windows-x64
  • 证据路径:装包后验证开关持久化(preferences.json"windowsSendInputInsertionOnly": true);听写开始/结束任务栏输入法不变

PR Type

Enhancement, Bug fix


Description

  • Add Windows insertion mode (TSF/SendInput/Paste) and newline simulation options

  • Skip TSF IME switching when SendInput mode active, fixing IME restoration issues

  • Fix serde JSON key alignment so the toggle doesn't revert after save

  • Update UI and i18n for new settings across 5 languages


Diagram Walkthrough

flowchart LR
    begin["Begin Session"] --> modeCheck{"Windows Insertion Mode"}
    modeCheck -- "Tsf" --> prepareTsf["Prepare OpenLess IME (TSF)"]
    modeCheck -- "SendInput" --> skipPrepare["Skip prepare_session()"]
    modeCheck -- "Paste" --> skipPrepare
    endSession["End Session"] --> modeCheck2{"Windows Insertion Mode"}
    modeCheck2 -- "Tsf" --> tsfPath["Insert via TSF IME (existing)"]
    modeCheck2 -- "SendInput" --> sendinputPath["Insert via SendInput Unicode (skip IME)"]
    modeCheck2 -- "Paste" --> pastePath["Insert via Ctrl+V / clipboard paste"]
Loading

File Walkthrough

Relevant files
Tests
3 files
backend_rust.rs
Add Tauri stubs for Windows test harness                                 
+12/-0   
mock-data.ts
Add default windows insertion mode to mock data                   
+3/-0     
stylePrefs.test.ts
Add new fields to test preferences fixture                             
+3/-0     
Enhancement
7 files
coordinator.rs
Route insert via mode; add sendinput options                         
+36/-4   
dictation.rs
Skip TSF prepare when SendInput mode; update streaming     
+152/-17
insertion.rs
Adapt insert_via_unicode_keystrokes signature with options
+47/-65 
types.rs
Add WindowsInsertionMode, WindowsSendInputNewlineMode enums
+175/-0 
unicode_keystroke.rs
Add SendInput options, newline and tab support                     
+161/-8 
types.ts
Add WindowsInsertionMode and WindowsSendInputNewlineMode types
+12/-0   
RecordingInputSection.tsx
Add selection controls for insertion mode and newline mode
+46/-1   
Documentation
5 files
en.ts
Add English labels for new Windows insertion settings       
+10/-0   
ja.ts
Add Japanese labels for new Windows insertion settings     
+10/-0   
ko.ts
Add Korean labels for new Windows insertion settings         
+10/-0   
zh-CN.ts
Add Chinese simplified labels for new settings                     
+10/-0   
zh-TW.ts
Add Chinese traditional labels for new settings                   
+10/-0   

HKLHaoBin and others added 2 commits June 22, 2026 09:27
Add windowsSendInputInsertionOnly so users who cannot restore their IME after dictation can opt into Unicode SendInput without switching to OpenLess TSF at session start.

Open-Less#733

Co-authored-by: Cursor <cursoragent@cursor.com>
Serde camelCase produced windowsSendinputInsertionOnly while the UI sends windowsSendInputInsertionOnly, causing the toggle to revert after save. Add explicit rename/alias on UserPreferences wire types and contract tests.

Refs Open-Less#733

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit 1498c51)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

733 - Fully compliant

Compliant requirements:

  • 新增偏好字段并默认关闭。
  • begin_session 根据 windows_insertion_mode 决定是否调用 prepare_session
  • 一次性插入路径(SendInput mode)调用 insert_via_non_tsf_fallback(内部已包含选项)。
  • 流式插入路径在 SendInput mode 下继续使用 SendInput。
  • 失败兜底仍受 allow_non_tsf_insertion_fallback 控制。
  • 设置 UI 新增下拉选择 Windows 插入方式,包含 TSF、SendInput、粘贴三个选项。
  • SendInput 换行模拟子选项(Enter / Shift+Enter / CR+LF)仅在 SendInput 模式下显示。
  • 五语言 i18n 均已添加。
  • 单元测试覆盖新字段的默认值、序列化/反序列化、error_code 分支、streaming_eligible 等。
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@HKLHaoBin

HKLHaoBin commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author
f253e0ca4dcf222cc6f80de5871b4ffb ## 就是这个东西,不需要切换输入法,频繁遇到输入法切换问题的人有福了。 因为不需要切换输入法,所以杜绝了恢复输入法功能异常的问题。

• 引入 WindowsInsertionMode 枚举,用于管理文本插入策略(TSF、SendInput、粘贴)。
• 添加 WindowsSendInputNewlineMode 枚举,用于指定 SendInput 中的换行符处理方式。
• 更新 TextInserter,以支持 Windows 的新插入方法和选项。
• 重构 Unicode 按键处理,以适应换行符模拟模式。
• 增强用户偏好设置,包含新的插入模式及其各自的默认值。
• 更新 UI 组件,允许用户选择首选的插入方法和换行处理方式。
• 改进了英文、日文、韩文、简体中文和繁体中文新设置的本地化。
• 添加了测试以验证新功能,并确保文本插入符合预期行为。
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 9cac724

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 2318266

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 1498c51

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.

[Windows][feature] 新增「始终使用 SendInput」开关,避免听写后输入法无法还原

1 participant