Repository navigation
Conversation
|
Replacing Instead of replacing (Review comment generated on behalf of @PCMan with AI assistance from Google Antigravity + Gemini 3.1 Pro) |
49adb08 to
75e3299
Compare
|
Both buckets are registered on
(Comment generated with assistance from omp (tensorfold/Qwen3.8-Flash-Next)) |
|
Heads are rewritten ( (Comment generated with assistance from omp (tensorfold/Qwen3.8-Flash-Next)) |
|
Thank you for updating However, there is still a runtime bug when the user actually selects the
Please update (Review comment generated on behalf of @PCMan with AI assistance from Google Antigravity + Gemini 3.1 Pro) |
EasyIME#481, follow-up to the review on EasyIME#1021: the rime ime.json now carries an additionalProfiles entry (the zh-CN twin of the zh-Hant-TW profile), but only the flat guid was known to the dispatchers, so a client that activates the second profile got no service. - python/serviceManager.py: TextServiceInfo gains additionalGuids, filled from additionalProfiles (each entry's guid, lowercased; an entry without a usable guid is skipped, as the flat keys already fall back), and TextServiceManager.load() registers the same info under each of them. - go-backend/server.go: additionalProfileGuids(imeConfig) reads the array and both the meow and the rime case register the factory for the primary and every profile GUID, so newClient finds one for the second profile too. - PIMETextService/PIMEImeModule.cpp: ImeModule::loadImeInfo matches the flat guid, then walks additionalProfiles, so onConfigure finds the ime.json from either profile GUID. - node/loadServices.js: loadServiceById compares the primary guid or any additionalProfiles[].guid. Validation on this tree: - python/python3/python.exe -m unittest discover -s tests -p "test_service_manager.py": Ran 10 tests ... OK. The new case asserts both keys are registered, that they map to the same TextServiceInfo, and that createService() on the additional GUID returns an instance. - go.exe test -count=1 ./... with APPDATA cleared (as tests/verify_windows.sh runs it): ok for pime-go, meow, rime and pime. Two new tests read the shipped go-backend/input_methods/rime/ime.json — the profile GUID is exactly {9882e350-9462-4d42-9882-7847044ea725} and differs from the primary {3f6b5a12-8d44-4e71-9a2e-6b4f9c1d2a30} — and a manifest with a missing or non-string guid and a non-object entry yields only the usable lowercased one. - node.exe test\loadServices.test.js passes with the fixture extended by additionalProfiles (one real profile, one entry without a guid, one null): lookup by the additional GUID returns the same module as the primary. - PIMEImeModule.cpp is compiled by the build-and-sign job; this box's vendored mingw carries no Windows SDK headers, so only the two pure C++ helpers build locally.
|
All four dispatchers now resolve the
Evidence on
|
|
Actually, the original design of ime.json was one ime.json per language profile. Won't it be simipler to just create multiple ime json files one per profile? |
76c9a3f to
8dee501
Compare
|
Tip: 8dee501 (3 commits on |
The EasyIME#1021 review round found the second language profile registered but not resolvable, and no layer went red: the round-one cases read the manifests (locale pairs, one extra entry, distinct GUID) and probed `LocaleNameToLCID`, so they proved the data while each backend's own fixture proved only what that fixture literally said. Three pins close the gap, each with a negative control. - `tests/test_service_manager.py`: `test_shipped_rime_manifest_registers_both_profiles` drives `TextServiceManager.load()` over the product tree instead of the synthetic one, asserts both GUIDs are keys, that they map to the same `TextServiceInfo`, and pins the two literals `DllRegisterServer` hands to `AddLanguageProfile`. Stubbing the registration loop in `python/serviceManager.py` reddens 2 cases (11 pass as-is). - `node/test/loadServices.test.js`: the fixture already carried `additionalProfiles` but asserted nothing on it. Now the extra GUID resolves to the same module as the primary, the lookup is case-insensitive on both sides, and a locale-only or null entry registers no key. Deleting the match arm in `node/loadServices.js` fails with `actual: null` (exit 1). - `tests/test_rime_registration_locale.py`: `test_every_profile_entry_carries_a_registration_guid` walks every backend's `input_methods/*/ime.json` and demands a flat guid, an object entry with its own guid per additional profile, and no guid naming two profiles — the shape `DllRegisterServer` and all four dispatchers read. 7 cases pass. The per-backend GUIDs stay unequal by design (`{9c2d6c68-…}` python, `{3f6b5a12-…}` go for rime, `{7a1c2e93-…}` for the go 喵喵 copy): each backend registers its own CLSID, so only the locale pair is a cross-twin invariant and that is what `test_twins_agree_on_one_locale_per_ime` compares. `go.exe test -count=1 ./...` with `APPDATA` cleared, as `tests/verify_windows.sh` runs it: ok for `pime-go`, `meow`, `rime` and `pime`; stubbing `additionalProfileGuids` fails both of its cases.
The EasyIME#1021 round-2 review settled the rule inside the PR thread only, so the next agent comparing twins "fixes" the unequal GUIDs and breaks registration: `DllRegisterServer` hands each `input_methods/*/ime.json` its own `guid` to `AddLanguageProfile`, and each backend's dispatcher matches only its own tree, so the unit that must be distinct is the pair inside one file — the flat `guid` plus each `additionalProfiles[].guid` — not the value shared across twins. - `docs/adr/0004-per-backend-profile-guids.md` (new): the within-file / cross-file rule, why the locale pair is the only cross-twin invariant (one IME once per language-list bucket, while the CLSID to profile map is per backend), the two consumers that must agree per file (`PIMETextService/DllEntry.cpp` `langProfileFromJson` plus that backend's own dispatcher), and the shipped manifest literals as the pinned exhibit. - `tests/test_rime_registration_locale.py`: the two adjudicating tests name the ADR in their comments, cited by heading, so the reasoning is one jump away. Validation on this tree: - `bash tests/check_line_citations.sh`: `checked 274 citation(s)`, rc 0. - `bash tests/check_tracker_layout.sh`: `checked 5 feature directories`, rc 0; 125 inside the linked worktree, where the gitignored `.scratch` does not live. - `bash tests/check_ai_declarations.sh`: `checked 4 added file(s)`, rc 0, and the staged form plus `check_sh_exec_bits.sh staged` also exit 0. - `python/python3/python.exe -m unittest discover -s tests -p "test_agent_docs.py"`: OK, 5 cases; `... -p "test_rime_registration_locale.py"`: OK, 7 cases, the edit being comment-only. The whole suite runs `OK (skipped=4)` over 301 tests; the pre-commit hook was stepped through by hand because its log path `$root/.git/pime-pre-commit-suite.log` is unusable where `.git` is a gitdir file. Fully generated by omp (Qwen3.8-Flash-Next) without human intervention.
|
CI is green on this head ( (Comment generated with assistance from omp (tensorfold/Qwen3.8-Flash-Next)) |
|
Thanks for looking into this! However, I prefer to stick to the original design: one If multiple input method profiles largely share the same implementation and data, the common module/engine can be moved to a shared package at the top level of the backend directory (next to Let me also think a bit more about whether we can further streamline how shared modules/profiles are structured. (Review comment generated with assistance from Antigravity + Gemini 4 Argon) |
8dee501 to
95f4737
Compare
|
Recut on
Local evidence for this head is in the body (python 8/12/9 tests OK on the bundled interpreter, go (Comment generated with assistance from omp (tensorfold/Qwen3.8-Flash-Next)) |
08df868 to
7782c4e
Compare
|
Head is |
7782c4e to
0c1cb91
Compare
|
Local Windows gate for this branch: |
|
中州韻的註冊語系建議改成「安裝時選擇」 背景 中州韻的語系問題由來已久。#481 在 2018 年就有人回報,當時的處理方式是自己改 registry,把 LanguageProfile\0x00000804 改成 0x00000404(見該 issue 中的 prime-0404.zip)。這個作法最早是從修改 CPatch 日文 IME 註冊語系的經驗沿用過來的。2019 年也有簡中使用者反過來,把其他 PIME 輸入法從 0x0404 改成 0x0804。可見兩邊的使用者都有需求,而且都是自己動手改 registry 解決。 The locale problem with Rime goes back a long way. It was reported in #481 back in 2018. The workaround then was to edit the registry by hand and change LanguageProfile\0x00000804 to 0x00000404 (see prime-0404.zip in that issue). The approach itself came from earlier experience changing the registered locale of the CPatch Japanese IME. In 2019, a Simplified Chinese user did the reverse and moved other PIME input methods from 0x0404 to 0x0804. Users on both sides need this, and all of them have been working around it by editing the registry themselves. 為什麼語系不只是「列在哪個語言清單」 Windows 會依目前的輸入語言決定不少行為。語系選錯,影響的是實際輸出的結果: Windows decides a number of behaviors based on the current input language. Picking the wrong locale changes what actually gets output: 非 Unicode 程式:送出的字會依輸入語言的 code page 轉換。0x0404 用 CP950(Big5),0x0804 用 CP936(GBK)。語系不對,舊程式收到的字就可能變成問號或亂碼。 Non-Unicode applications: committed text is converted using the code page of the input language: CP950 (Big5) for 0x0404, CP936 (GBK) for 0x0804. With the wrong locale, legacy applications may receive question marks or garbled text. 主控台和舊式程式:切換輸入語言時會帶出對應的字元集(WM_INPUTLANGCHANGE)。 Console and legacy applications: switching the input language reports the matching character set (WM_INPUTLANGCHANGE). Office 等會看輸入語言的程式:會依輸入語言自動切換字型、校對和拼字檢查的語言。#481 中簡中 Office 使用者遇到的就是這個問題。 Office and other applications that follow the input language: they switch fonts and the proofing and spell-check language automatically. This is exactly what the Simplified Chinese Office user in #481 ran into. 所以繁中使用者需要 zh-TW,簡中使用者需要 zh-CN。寫死任何一邊,都會讓另一邊的使用者在實際使用時出問題,而不只是清單裡找不到輸入法。 So Traditional Chinese users need zh-TW and Simplified Chinese users need zh-CN. Hard-coding either one causes real problems in daily use for the other group, not just a missing entry in the language list. 建議:在安裝程式裡選語系,維持一份 ime.json 對應一個語系 Proposal: choose the locale in the installer, keeping one ime.json per locale 這也是目前常見輸入法安裝程式的作法,例如小狼毫在安裝時就是讓使用者在繁體和簡體之間選一個。 This is also what common IME installers do today. Weasel (小狼毫), for example, asks the user to pick Traditional or Simplified Chinese at install time. 在安裝程式的 Rime 選項加一個「註冊語系:繁體中文 (zh-TW) / 簡體中文 (zh-CN)」。預設值跟著安裝程式的介面語言走,使用者可以自己改。 Add a “Registered locale: Traditional Chinese (zh-TW) / Simplified Chinese (zh-CN)” option to the installer’s Rime section. The default follows the installer’s UI language, and the user can change it. 套件裡附 ime.zh-TW.json 和 ime.zh-CN.json 兩份,安裝時依選擇複製成 ime.json。 Ship both ime.zh-TW.json and ime.zh-CN.json, and have the installer copy the chosen one to ime.json. profile GUID 維持原本的 {9C2D6C68-9EA6-4CFB-A769-7E619DB7F267} 不變(Go 版為 {3F6B5A12-…}),兩種語系都用這一個 GUID。 Keep the existing profile GUID {9C2D6C68-9EA6-4CFB-A769-7E619DB7F267} unchanged ({3F6B5A12-…} for the Go backend), and use it for both locales. 這樣做的好處 維持「一份 ime.json 一個語系」的設計,不改 manifest 格式,C++、Python、Node、Go 的派送邏輯都不用動。 It keeps the “one ime.json per locale” design. The manifest format does not change, and the dispatch logic in C++, Python, Node and Go stays as it is. 引擎不用搬家,也不用多開 rime-cn 資料夾。PIME 執行時跟現在完全一樣,只有安裝程式要改。 The engine does not move and no rime-cn folder is needed. PIME runs exactly as it does now; only the installer changes. GUID 不變,原本在簡中使用中州韻的人升級時只要選 zh-CN,使用者設定和詞庫都不受影響。 Because the GUID does not change, existing Simplified Chinese Rime users only need to pick zh-CN when upgrading. Their settings and user dictionaries are not affected. 繁中、簡中使用者都不必再自己改 registry。 Neither Traditional nor Simplified Chinese users have to edit the registry by hand anymore. 後續可以再考慮的方向 這個開關之後可以擴大到所有 PIME 輸入法(#481 中 2026-10-30 的留言有提過)。讓使用者在安裝時統一選擇註冊語系,也能順便解決簡中使用者想在簡中環境用新酷音等輸入法的需求。 This option could later be extended to every PIME input method (suggested in the 2026-10-30 comment on #481). Letting users choose the registered locale for all input methods at install time would also cover Simplified Chinese users who want to use Chewing and other PIME input methods in a Simplified Chinese environment. (Comment generated with assistance from Claude Code + Claude Opus 5.5) |
0c1cb91 to
d03bc30
Compare
中州韻輸入法 registers its TSF language profile from registration data: langProfileFromJson (PIMETextService/DllEntry.cpp) reads locale and fallbackLocale from the IME's ime.json, and libIME2 (ImeModule.cpp:registerLangProfiles) converts them with LocaleNameToLCID — retrying the RFC 1766 name only when the RFC 4646 one fails to convert — then calls AddLanguageProfile under LANGIDFROMLCID. The rime profile shipped zh-Hans-CN / zh-CN, so the profile only appeared for users who had Simplified Chinese enabled, while every other PIME input method declares zh-Hant-TW / zh-TW. Both buckets are kept rather than traded: each rime manifest now declares the Traditional pair as its primary profile and one additionalProfiles entry for the Simplified pair, each with its own profile GUID, so DllRegisterServer issues two AddLanguageProfile calls for the one CLSID and a user finds 中州韻輸入法 under either Windows input locale. langProfileFromJson returns the profiles it read (std::vector) and parses that array; the flat keys stay the first profile, so every other ime.json registers exactly as before, and an entry without guid or locale is skipped the way the flat keys already fall back. The python and go twins carry the same three keys because DllRegisterServer scans every backend's input_methods/*/ime.json, and one disagreeing twin would leave that registration in a single bucket. installer/installer.nsi needs no change: its PYTHON_CHS_SECTION_GROUP entry is the installer's own section grouping, independent of the TSF language profile, and both profiles come from these manifests. Architecture and design by asdf80730. Implementation generated with AI assistance from omp (tensorfold/Qwen3.8-Flash-Next).
The two ime.json manifests carry an additionalProfiles entry (the zh-CN twin
of the zh-Hant-TW profile), so the dispatchers and the config loader have to
know those GUIDs as well as the flat one:
- python/serviceManager.py: TextServiceInfo gains additionalGuids, filled from
additionalProfiles (each entry's guid, lowercased; an entry without a usable
guid is skipped, as the flat keys already fall back), and
TextServiceManager.load() registers the same info under each of them, so
createService() answers for the second profile too.
- go-backend/server.go: additionalProfileGuids(imeConfig) reads the array and
both the meow and the rime case register the factory for the primary and
every profile GUID, so newClient finds one for {9882e350-…}.
- PIMETextService/PIMEImeModule.cpp: ImeModule::loadImeInfo matches the flat
guid, then walks additionalProfiles, so onConfigure finds the ime.json from
either profile GUID.
- node/loadServices.js: loadServiceById compares the primary guid or any
additionalProfiles[].guid.
Verified with the project's local harness on the integration branch, where the
regression cases for these four seams live: the Python service-manager module
(10 tests, including both keys mapping to one TextServiceInfo and
createService() on the additional GUID), the Go packages under
`go test -count=1 ./...` (two cases reading the shipped manifest and the
skip-over-bad-entries behaviour), and the node loadServices test with
additionalProfiles in the fixture. PIMEImeModule.cpp is compiled by the
build-and-sign job.
Architecture and design by asdf80730. Implementation generated with AI
assistance from omp (tensorfold/Qwen3.8-Flash-Next).
`ImeModule::loadImeInfo` compared the flat `guid` and then walked `additionalProfiles` inline, so this one of the four dispatchers had no way to be exercised outside the `build-and-sign` job: the vendored mingw carries no Windows SDK headers. Extracting the match into `PIMETextService/ImeProfileGuids.h`, which includes only `<string>` and the header-only nlohmann json, keeps the behaviour and lets the two pure-C++ helper tests upstream already runs gain a third sibling case. - `imeProfileGuidEqual`: ASCII case-insensitive, the same comparison `stricmp` gave, so a lowercased client id still meets an upper-case manifest. - `imeProfileGuidMatches`: the flat `guid` first, then each `additionalProfiles` entry; a non-object entry, a missing or non-string `guid`, and an empty `guid` are skipped without throwing. - `loadImeInfo` calls it: the 17 inline lines become one call (22 lines changed, 15 fewer), and the first-match `break` of the backend scan is unchanged, so `onConfigure` resolves `ime.json` from either profile GUID. Architecture and design by asdf80730. Implementation generated with AI assistance from omp (tensorfold/Qwen3.8-Flash-Next).
One manifest is one Windows input language profile, so each dispatcher again compares the flat guid only: langProfileFromJson returns the single profile, the python and node dispatchers and the go loader match it directly, and the header-only helper loses the array walk. The rime engine serves zh-Hant-TW and zh-CN, so both backends now ship input_methods/rime and input_methods/rime-cn, each with its own profile GUID, while the shared engine (librime.py, rime_keyevent.py, rime_service.py, rime.dll, data/, icons/) sits once under python/rimebase and the two wrappers re-export one RimeTextService. The installer stages the engine folder plus the two IME folders. Architecture and design by asdf80730. Implementation generated with AI assistance from omp (tensorfold/Qwen3.8-Flash-Next).
The two fixture cases of the loader suite remove their temporary tree right after killing server.js, and on Windows the still-running child holds that directory as its cwd, so rmSync answers EBUSY. Both finally blocks now await the exit promise the starter already exposes before removing the tree. Architecture and design by asdf80730. Implementation generated with AI assistance from omp (Qwen3.8-Flash-Next).
d03bc30 to
97af092
Compare
fix(rime): register 中州韻 under both Chinese locales (#481)
Fixes #481
中州韻輸入法registers its TSF language profile from registration data:langProfileFromJson(PIMETextService/DllEntry.cpp) readslocaleandfallbackLocalefrom the IME'sime.json, andlibIME2(
ImeModule.cpp:registerLangProfiles) converts them withLocaleNameToLCID—retrying the RFC 1766 fallback only when the RFC 4646 name does not convert —
then calls
AddLanguageProfileunderLANGIDFROMLCID. The rime profileshipped
zh-Hans-CN/zh-CN, so the profile only appeared for users who hadSimplified Chinese enabled; every other PIME input method declares
zh-Hant-TW/zh-TW.Per your two notes, the original one-manifest-per-profile layout is kept and
the engine is shared:
python/input_methods/rime/ime.json(zh-Hant-TW/zh-TW) andpython/input_methods/rime-cn/ime.json(zh-CN/zh-CN), one Windowsinput language per folder, each with its own profile GUID, so
DllRegisterServerissues twoAddLanguageProfilecalls and neither localeloses the engine. The go twin pairs the same way under
go-backend/input_methods/.python/rimebase(librime.py,rime_keyevent.py,rime_service.py,rime.dll,data/,icons/), nextto
cinbase; eachinput_methods/folder carries only itsime.jsonand athin
rime_ime.pywrapper that re-exports the oneRimeTextService, sodata/PIME.yamland the icon set exist once.iconis now../rimebase/icon.ico, which the C++ reader resolves relative to themanifest's own directory.
flat
guid:langProfileFromJsonreturns the single profile it read,python/serviceManager.py,go-backend/server.go(case "rime", "rime-cn"),node/loadServices.jsandPIMETextService/PIMEImeModule.cppeach match oneguid, and the header-onlyPIMETextService/ImeProfileGuids.hhelper dropsthe array walk. No manifest carries
additionalProfilesany more.installer/installer.nsistagespython\rimebase(engine,data, opencc)plus the two IME folders; the
PYTHON_CHS_SECTION_GROUPentry is theinstaller's own grouping and is unchanged.
Validation on
08df868, run on the Windows box:python/python3/python.exe:python/python3/python.exe -m unittest discover -s tests -p "test_rime_registration_locale.py"→
Ran 8 tests ... OK(both folders per backend, one named GUID each, thepair each folder answers, twins agree on the locale pair);
... -p "test_service_manager.py"→Ran 12 tests ... OK(the two shippedpython manifests resolve by their own GUID to two infos over one engine
class);
... -p "test_rime_log_bounds.py"→Ran 9 tests ... OK.go.exe test -count=1 ./...(withAPPDATAcleared) →okforgithub.com/EasyIME/pime-go,input_methods/meow,input_methods/rime;the root package's two profile cases now read both folders.
node.exe test\loadServices.test.jspasses on a fixture with twofolders (
demo,demo-cn, distinct markers) plus a guid-less manifest thatregisters no key.
g++.exe -std=c++17 -O1 -staticcompiles and runstests/ime_profile_guids_test.cpp(each folder hits its own GUID, thefolders do not answer for each other, case-insensitive in both directions,
miss, missing
guidkey, emptyguid, non-stringguid,nulldocument).DllEntry.cpp,PIMEImeModule.cppand the rest of the TSF layer arecompiled by the
build-and-signjob; this box's vendored mingw carries noWindows SDK headers.
Architecture and design by asdf80730. Implementation generated with AI
assistance from omp (tensorfold/Qwen3.8-Flash-Next).