fix(windows-ime): force-skip TSF on non-zh hosts to stop ATOK/MS-IME hijack#362
fix(windows-ime): force-skip TSF on non-zh hosts to stop ATOK/MS-IME hijack#362katanumahotori wants to merge 2 commits intoOpen-Less:betafrom
Conversation
…hijack The bundled C++ TSF DLL hard-codes lang_id 0x0804 (zh-CN) in guids.h, which on a Japanese host either (a) hijacks the active IME to a chinese-IME profile and leaves it stuck after dictation, or (b) fails activation and falls back via SendInput, which competes with ATOK / Microsoft IME composition state. This PR is a stop-gap that forces prepare_session() to return unavailable() so all insertion goes through the clipboard+SendInput fallback in coordinator.rs. The proper fix is a per-host lang_id in both guids.h and windows_ime_profile.rs plus a DLL rebuild - tracked as a follow-up. Also bumps OPENLESS_TSF_LANG_ID from 0x0804 to 0x0411 (Japanese) in windows_ime_profile.rs as a partial mitigation for users who do manage to load the DLL. dead_code attributes added to the now-unused TSF helpers so the fork builds clean while the path is gated.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
PR Reviewer Guide 🔍(Review updated until commit c994675)Here are some key observations to aid the review process:
|
|
这就是为什么你直接关闭了整个tsf以及硬编码日文ID?我们不会合并你的pr,至少现在不会。虽然你提出的问题确实有价值,但你的实现方式不是很有用。 |
|
Thanks for the review. You're right that "force-skip + hard-coded lang_id" was a stop-gap. This commit replaces it with a per-host check:
Please take another look — I want to keep the fix minimal but actually useful. |
|
Persistent review updated to latest commit c994675 |
|
Thanks for the review. You're right — the current Rust-side per-host check is still only a partial fix. The proper solution requires parameterizing kOpenLessLangId in guids.h and rebuilding the C++ TSF DLL with a per-host (or build-time) lang_id, which I haven't done in this PR. Closing this to avoid noise. I'll resubmit only after the C++/DLL side is also in order. Sorry for the back-and-forth. |
User description
Why
The bundled C++ TSF DLL hard-codes
lang_id 0x0804(zh-CN) inguids.h. On a Japanese host this either:SendInput, which competes with ATOK / Microsoft IME composition state.End user impact: text comes out reordered (kanji pushed to the end while hiragana is queued in the IME composition window), or the user's IME is silently switched and they have to reset it manually.
What
This PR is a stop-gap that forces
prepare_session()inwindows_ime_session.rsto returnunavailable()so all insertion goes through the clipboard+SendInput fallback incoordinator.rs.windows_ime_session.rs—prepare_session()now short-circuits toUnavailablebefore attempting to load the TSF DLL.windows_ime_profile.rs— bumpsOPENLESS_TSF_LANG_IDdefault from0x0804to0x0411(Japanese) as a partial mitigation for users who do manage to load the DLL.windows_ime_ipc.rs,windows_ime_protocol.rs—dead_codeattributes added to the now-unused TSF helpers so the fork builds clean while the path is gated.Follow-up
The proper fix is a per-host
lang_idin bothguids.handwindows_ime_profile.rs, plus a DLL rebuild. Not in this PR.PR Type
Bug fix, Enhancement, Tests
Description
Force-skip TSF IME activation on non-Chinese hosts
Add runtime host UI language detection on Windows
Use dynamic language id for profile activation
Suppress dead code warnings for unused TSF helpers
Diagram Walkthrough
flowchart LR A["prepare_session() in\nwindows_ime_session.rs"] --> B["host_ui_lang_id()"] B --> C{"Primary language\nis Chinese?"} C -- "Yes" --> D["openless_tsf_lang_id()"] D --> E["activate_openless_profile()\nwith dynamic lang id"] C -- "No" --> F["Return unavailable()"] F --> G["Fallback to clipboard+SendInput"] D -.-> H[windows_ime_profile.rs new functions] E -.-> HFile Walkthrough
windows_ime_session.rs
Gate TSF session preparation on host UI languageopenless-all/app/src-tauri/src/windows_ime_session.rs
prepare_sessionto returnunavailable()on non-zh hostshost_ui_lang_id()windows_ime_profile.rs
Dynamic language‑id resolution and dead‑code suppressionopenless-all/app/src-tauri/src/windows_ime_profile.rs
OPENLESS_TSF_LANG_IDconstanthost_ui_lang_id()usingGetUserDefaultUILanguageon Windowsopenless_tsf_lang_id()that returns0x0804for zh hosts or hostlang id otherwise
activate_openless_profile()andis_openless_profile_active()touse dynamic lang id
#[allow(dead_code)]to several unused items (profile activation,constants, error variants)
windows_ime_ipc.rs
Suppress dead‑code warnings for unused IPC componentsopenless-all/app/src-tauri/src/windows_ime_ipc.rs
#[allow(dead_code)]onUnavailablevariant,WindowsImeIpcServerinner field and test helpers
windows_ime_protocol.rs
Allow dead code on unused protocol helperopenless-all/app/src-tauri/src/windows_ime_protocol.rs
#[allow(dead_code)]tois_result_for_pending_sessionfunction