Skip to content

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

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

feat(windows): 新增「始终使用 SendInput」开关,跳过听写时的 TSF 切换#734
HKLHaoBin wants to merge 2 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 "Always use SendInput" preference (default off)

  • Skip TSF IME switch during dictation when preference enabled

  • Fix serde JSON key mismatch for preference persistence

  • Add i18n translations and settings UI toggle


Diagram Walkthrough

flowchart LR
  A["User enables SendInput-only"] --> B{"begin_session"}
  B -- "pref on" --> C["Skip TSF prepare_session"]
  B -- "pref off" --> D["TSF as usual"]
  C --> E["end_session"]
  E --> F["insert_via_non_tsf_fallback or SendInput"]
  F --> G["Insert without IME switch"]
Loading

File Walkthrough

Relevant files
Enhancement
4 files
coordinator.rs
Make insert_via_non_tsf_fallback pub(super)                           
+11/-3   
dictation.rs
Implement SendInput-only path in begin/end session             
+33/-14 
types.ts
Add interface field for SendInput-only preference               
+2/-0     
RecordingInputSection.tsx
Add toggle UI for SendInput-only mode                                       
+13/-0   
Bug fix
1 files
types.rs
Add windows_sendinput_insertion_only preference with serde fix
+63/-0   
Documentation
5 files
en.ts
Add i18n strings for SendInput-only toggle                             
+2/-0     
ja.ts
Add Japanese i18n for SendInput-only toggle                           
+2/-0     
ko.ts
Add Korean i18n for SendInput-only toggle                               
+2/-0     
zh-CN.ts
Add Simplified Chinese i18n for SendInput-only toggle       
+2/-0     
zh-TW.ts
Add Traditional Chinese i18n for SendInput-only toggle     
+2/-0     
Miscellaneous
1 files
mock-data.ts
Add default value for windowsSendInputInsertionOnly           
+1/-0     
Tests
1 files
stylePrefs.test.ts
Add field to test preferences mock                                             
+1/-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

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

733 - Fully compliant

Compliant requirements:

  • New preference field added with serde default, rename, alias.
  • begin_session skips prepare_session when windows_sendinput_insertion_only is true.
  • end_session uses SendInput-only branch when windows_sendinput_insertion_only is true.
  • UI toggle placed above "允许非 TSF 兜底" and only on Windows.
  • i18n strings added for all 5 languages.
  • Unit tests for default, deserialization from correct and legacy keys, serialization, round-trip.
  • Unit test for dictation_error_code skipping TSF error in SendInput-only mode.
  • Legacy wrong-case key supported via serde alias.
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@HKLHaoBin

HKLHaoBin commented Jun 22, 2026

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant