Commit Graph
152 Commits
Author SHA1 Message Date
Jia Sui a3b1e4380c feat(server): 模糊音首次启用播种规则并持久化标记
总开关默认关不变;出厂态(fuzzy_seeded 未置位)第一次开总开关时,用一次
WriteConfiguredValues 批量写 13 键(总开关 + 11 规则全 true + 播种标记),
单文件原子写无部分失败态。标记置位后总开关任何翻动只写总开关一个键,
用户修剪过的选择在临时停用/恢复间原样保留。

播种信号靠持久化标记而不是「规则位全零」:用户故意全部取消勾选后位图
同样是零,无标记会把每次开启都误判成首次启用。fuzzy_seeded 是内部键,
设置快照不下发不展示;两份 toml 模板补键,缺键会被升级合并丢弃导致
老用户升级后误重播种。设置页勾选态由 host 处理 configUpdate 后重发的
configSnapshot 驱动,前端无播种逻辑。

新增首次播种用例(播种全开、修剪子集反复开关、重启保持、全取消后不
重播种);默认值三形态补标记断言;既有往返/门控/注入用例改走不门控
视图或规则键直设,避开播种路径保持用例意图纯净。
2026-09-13 09:33:14 +08:00
Jia Sui b807f50d69 feat(server): 模糊音增加总开关并在聚合 getter 门控
[input] 新增 fuzzy_pinyin 总开关,默认关;GetConfiguredFuzzyPinyinOptions
在总开关关时返回全零 options,规则位缓存保留,临时停用后重开立即恢复。
设置页快照改用不门控的规则位视图,总开关关闭时复选框仍展示已存勾选;
configUpdate 分发把精确分支 input.fuzzy_pinyin 排在 fuzzy_ 前缀分支之前。
注入用例改为带总开关的 A-B-A-B,新增门控与默认值断言。
2026-09-13 09:12:45 +08:00
Jia Sui feb7db6de4 feat(server): 模糊音规则接入配置与会话注入
- [input] 段新增 11 个平铺模糊音键(fuzzy_z_zh … fuzzy_uan_uang,默认全关),
  读取用固定键表驱动,键名即 FuzzyPinyinRule 枚举名小写,单一映射可评审;
  位掩码缓存 uint32,reload 先清零再按位合成
- GetConfiguredFuzzyPinyinOptions 合成引擎选项,SetConfiguredFuzzyPinyinRule
  按键写盘(未知名拒绝且不动位图), ApplyConfiguration 每键注入,
  全拼与双拼同路径生效,设置改动即时生效
- settings_app configSnapshot 补 11 字段,ApplyConfigUpdate 用 input.fuzzy_
  前缀分发;windows_webview2 死宿主不接线(InitWebviewSettingsWnd 零调用者)
- 测试:默认值三形态、逐键往返与 0x7ff 合成、未知键拒绝、
  全拼/双拼 zhang→zang 候选注入用例;开发模板同步 11 键
2026-09-13 08:35:25 +08:00
fanluskyandCarry 63eab2f88f refactor(server): 滚轮翻页复用键盘翻页逻辑并移出按键热路径
在 #351 的基础上收敛几处实现:

- CloseContextMenu 里新增的 hover 清理和 Present 原本无条件执行,而
  ShowFromGlobalState 和 Hide 每次按键都会调它。没有菜单时按键路径上会多出
  一次整屏重绘,画的还是更新前的旧场景。改为只在确实有 popup 要销毁时才做。
- 分页与动态扩充的逻辑从键盘路径复制了一份。抽成
  ExpandCandidatesKeepingPagePosition 和 MoveCandidatePage,键盘与滚轮共用。
- 每一格滚轮直接投一个任务,而每个任务都可能回引擎和用户词库。改为在队列里
  合并成 page_steps,一次快速滚动只重绘一次。
- 窗口层不再直接调 EnqueueCandidateUiAction,改为与其它候选窗动作一致,
  PostMessage 到宿主 WndProc(WM_PAGE_CANDIDATE)。EnqueueCandidateUiAction
  的序号校验随之恢复原样。
- 滚轮累加拆成纯函数 CandidateWheel::ConsumeWheelDelta 并补上单元测试;
  候选窗隐藏时忽略迟到的滚轮消息。

滚轮翻页仍然把页内高亮重置为首项,键盘翻页仍然保留原有的页内索引。

Co-authored-by: Carry <xu762556@outlook.com>
2026-09-13 00:16:18 +08:00
Carry 0fb8001022 feat(server): support mouse wheel paging on candidate window (fixes #81) 2026-09-12 19:46:24 +08:00
fanlusky aba4851f90 test: do not require a lattice sentence from the locked dictionaries
Whether a whole-sentence candidate is produced depends on which
dictionaries and local models are installed, so the CI product data
yields none and the presence requirement failed there.  Check the
canonical reading of whatever whole-sentence candidates do appear, and
assert the shuangpin-to-quanpin conversion unconditionally instead --
that conversion is the value the fix attaches to those candidates.
2026-09-12 16:01:42 +08:00
fanlusky e835e09c20 fix(engine): give whole-sentence fallback candidates a canonical pinyin
The Google-pinyin whole-sentence candidate is inserted at index 0 in both
quanpin and shuangpin, so it is what Space commits.  All four construction
sites built it without a canonical quanpin reading, so when it finished a
word-creation session update_creating_word_progress() had no reading to
join and can_store stayed false: the prefix plus the sentence went to the
host app but were never learned.

Carry the converted quanpin segmentation on those candidates, and extract
the early-return storage condition into a testable predicate.
2026-09-12 15:53:54 +08:00
fanlusky a7779d2b05 refactor(engine): 将 engine 从 submodule 内嵌为仓内一等组件
`vendor/MetasequoiaImeEngine` submodule 改为 `engine/` 目录,导入的是
product-lock.json 原本钉住的提交 c810d201,逐文件核对过 blob,因此这是一次
搬迁而不是引擎升级。引擎自己的嵌套 submodule(googlepinyinime-rev、utfcpp、
miniaudio)按各自 gitlink 一并展开,来源与提交见 engine/UPSTREAM.md。

Windows 专门化裁掉了不属于本产品的部分:whisper.cpp 与本地推理 provider、
macOS 示例宿主、整个 dictionary/ 建库流水线、上游 CI 与 release-please 配置。
词库仍按 product-lock.json 在构建时取发布产物。

引擎不再进 product-lock.json:没有 gitlink 就没有可比对的东西,锁里写一个上游
commit 等于宣称这棵树仍等于上游,而第一个 Windows 专门化改动落地时这句话就假了。
verify-contracts / verify-checkout 随之移除,verify-published 保留。

CI 与工具链:引擎源码并入根 scripts/format.sh(删掉引擎自己的那份,避免两套排除
列表分叉);引擎 voice.yml 里的 silero_vad.onnx 摘要校验移到本仓 lock job;
engine-bump-triage 工作流与其测试删除;gitsubmodule 的 dependabot 频率由 daily
改为 monthly。

README、README.en、AGENTS.md、CONTRIBUTING、docs/product-release.md 及各子目录
文档同步说明新的位置与边界。
2026-09-12 03:40:48 +08:00
fanlusky 54e5c68f94 refactor(server): clear the Server and test /W4 warnings
Most of them come from logging that is compiled out. The disabled DIAG_LOGF /
FANY_IPC_LOG* macros expanded to `((void)0)`, so every HRESULT and parameter
that exists only to be logged looked unreferenced (C4189/C4100). They now
expand to `((void)sizeof(DiscardLogArgs(__VA_ARGS__)))`: the arguments stay in
an unevaluated context, so nothing is computed and no side effect runs, but the
names count as used.

The rest:

- C4100: commented out the parameter names that are genuinely unused
  (WinMain's hPrevInstance/nCmdShow, AdjustWndPosition's hwnd/height, the
  WebView2 callbacks' sender, and the no-op logging sinks).
- C4189/C4101: removed the dead locals and the unused catch bindings left over
  with the log statements.
- C4244: made the DIP-to-pixel and int-to-float conversions explicit in
  globals.h, ime_windows.cpp and the menu placement.
- C4456: renamed the shadowing `hwnd` and `lock` locals.
- C4005: guarded the tests' `#define NOMINMAX` with #ifndef; the test targets
  already define it on the command line.

Release builds clean and ctest passes for the server, the tests and msimeui.
Warnings under vendor/ are untouched: those are submodules with their own
repositories.
2026-09-12 00:55:57 +08:00
古明四季 116a82d3b5 fix(installer): 保留升级时的自定义翻译配置 2026-09-11 23:25:37 +08:00
Neptrue_Lin 3eb82c7878 Merge branch 'develop' into feat/issue-234-rime-dict-import 2026-09-11 20:06:16 +08:00
Lu Fan(SonnyCalcr) 0eaa35eed1 Merge pull request #274 from linyanm/fix/issue-155-settings-lag
fix(server,ui-html): 降低设置窗口拖动与工具栏首屏卡顿
2026-09-10 21:33:31 +08:00
fanlusky 9447881c54 Merge branch 'develop' into fix/dictionary-replay-non-ascii-path
Conflict resolutions:

* windows/src/Utils/FanyUtils.h -- develop deleted GetIMEDataDirPath too
  (via #273), so both sides had identical content and the whole-file
  conflict was only develop's .gitattributes LF normalisation. Took
  develop's version; the symbol is now gone repo-wide.

* server/src/skin/candidate_skin_catalog.cpp -- #273 landed the same
  wide-path manifest read on develop. Took develop's code verbatim so
  this hunk is a no-op against develop, keeping only the comment that
  explains why toml::parse_file(manifest.string()) is unusable here.

* server/tests/src/test_quanpin_scheme.cpp (x2) -- union: this branch's
  test::Utf8(db_path) plus develop's `both` autocorrect-flag local.

Verified: server Release build clean, 282 tests pass.
2026-09-10 20:50:17 +08:00
fanlusky 093b485124 Merge branch 'develop' into fix/issue-242-settings-cannot-save
冲突解决:

- windows/src/Utils/FanyUtils.h:develop 通过新增的 .gitattributes 把整个文件
  从 CRLF 规范化成 LF,与本分支删除 GetIMEDataDirPath() 声明的改动整文件冲突。
  取 develop 的 LF 版本,再删掉该声明。
- server/tests/src/test_config_non_ascii_path.cpp:仅 include 块冲突,取两侧并集
  (algorithm/filesystem/fstream/iterator/string/system_error)。另修正一处错误的
  自动合并——develop 新增的候选回退字体断言本属于
  config_round_trips_under_non_ascii_profile_path,git 却按上下文并进了本分支新增的
  config_migrates_legacy_acp_mangled_path,已移回原测试。
2026-09-10 19:33:43 +08:00
Jia Sui fe7b4ab37d fix(server): 修复 test_quanpin_scheme 在 CI MSVC 下编译失败
- 跨不同长度数组的初始化列表推导不出共同指针类型(C3535):改为边界对
  + lambda 遍历,语义与原双表循环一致
- QuanpinAutocorrectCutRejectsInputsOutOfScope 引用了另一用例的局部 none:
  改为字面量 0u
- 根因:本地验证时构建失败被日志截断掩盖,ctest 跑了陈旧二进制给出假绿;
  已改为显式检查构建退出码并确认测试用例进入二进制
2026-09-10 17:42:55 +08:00
Jia Sui 2fcd57c88d style(server): 全拼纠错相关代码过 scripts/format.sh
- 生成脚本 Count 行模板改为单行,与 clang-format 输出一致,
  生成器 --check 与 format.sh --check 从此不再互斥
- test_quanpin_scheme 格式化
2026-09-10 17:32:17 +08:00
Jia Sui f8f13e7083 feat(server): 全拼纠错分类开关配置接线与候选标记
- 配置拆为 quanpin.autocorrect_transposition/neighbor 平铺键(默认关),
  旧键 autocorrect 废弃不读取不迁移;写入时段缺失自动追加,
  出厂模板无 [quanpin] 段时设置页保存不再静默失败
- engine_input_session 用 Engine 命名常量合成位掩码注入
- settings_app 补 configSnapshot quanpin 段与 ApplyConfigUpdate 路由
- BuildCurrentCandidatePage 按 corrected_from 给 view.text 追加纠错标记,
  msimeui 与 WebView2 两渲染路径共同源单点注入,提交/词频路径不受污染
- 生成脚本 add_variant 键长下限 2→3(2 字母空间归简拼),重建表 747+3244
- 测试:AC9 配置往返与旧键忽略、开关矩阵适配新签名、守卫用例
2026-09-10 17:31:51 +08:00
Aegon8719 dea9292814 issue-55 候选窗支持可配置的有序回落字体 2026-09-09 18:03:56 +08:00
fanlusky ac8394291b fix(tests): keep the shared test header free of engine dependencies
The portable test target builds on a bare Linux runner with no vcpkg tree, so
the UTF-8 path helper cannot live in test_framework.h -- including the engine's
data_path.h there broke the sanitizer build. Move it to test_utf8_path.h, which
only the Windows tests that need it include.
2026-09-09 04:48:56 +08:00
fanlusky 55605973d8 fix: build filesystem paths as UTF-8, not through the ANSI code page
Narrow strings in this repo are UTF-8, but std::filesystem converts narrow
strings through the system ANSI code page. The two agree only on ASCII, so any
path crossing that boundary breaks for users whose profile directory is not
ASCII -- and on a code page that cannot represent the characters at all,
path::string() throws rather than mangling.

The user dictionary replay tool hit exactly that. It handed the journal API
paths converted with path::string(); on a Chinese user name the conversion
threw, the exception escaped main(), and MSVC fastfailed the process with
0xC0000409. The installer treats any non-zero exit from replay as fatal, by
design, so those users could not upgrade at all. Build the paths from the wide
form via path_from_utf8/path_to_utf8 instead, and wrap main() so an unexpected
failure reports a diagnosable message and exit 1 rather than a fastfail code.

The skin catalog had the same defect: toml::parse_file(manifest.string())
routed the manifest path through the ANSI code page, and skins live under the
user profile. The throw escaped past the toml handlers around it. Read the file
through the wide path and parse the text instead.

Also drop FanyUtils::GetIMEDataDirPath, which built a path from the ANSI
environment block and dereferenced getenv without a null check. It had no
callers.

Tests cover the three layers this spans: the conversion contract itself, the
journal API in-process, the replay tool as the installer actually launches it,
and the skin catalog. Each non-ASCII case is paired with an ASCII control so a
failure says whether the path encoding or the data caused it. The replay and
skin tests were both confirmed to fail with their fix reverted.

Test fixtures pass paths through the new test::Utf8 helper rather than
path::string(), since the temp directory sits inside the user profile too.
2026-09-09 04:35:34 +08:00
linym c07aa8e878 fix(server,ui-html): 降低设置窗口激活卡顿 (#155)
激活时不再重推整份配置;HTML 按 UTF-8 二进制读取;契约脚本移到标记之后;最大化按钮矩形用 rAF 合并。
2026-09-08 22:47:26 +08:00
linym 075fbb2a84 fix(server): persist settings after leftover non-ASCII config paths
Elevated setup left high-IL config.toml that medium-IL Settings never
rewrote on machines hit by the ANSI path bug. Make the data directory
writable, migrate ACP-mangled leftovers, rebuild unparseable files, and
keep remaining asset paths on wchar_t.

Fixes #242
2026-09-08 22:42:26 +08:00
linyanmandlinym 6e03f57747 fix(server): 全拼导入按汉字数选择切分并识别文件编码 (#270)
无分隔拼音按汉字数另选完整切分,避免西安/xian 误报音节数不一致。设置页按 BOM 识别 UTF-8/UTF-16,无效 UTF-8 再回退 GBK。带撇号的水杉导出三列 TSV 本身已合法,回归测试钉住该格式。

Co-authored-by: linym <lin.yanming@foxmail.com>
2026-09-08 22:52:45 +09:00
linym 2776e157b0 style(server): wrap dictionary import test to satisfy clang-format 2026-09-08 20:58:57 +08:00
linym 28a0c03500 feat(server): 批量导入兼容 Rime userdb.txt 与 dict.yaml 2026-09-08 20:45:14 +08:00
Aegon8719 6ff1cff42d issue-52 加入简繁切换快捷键;增加候选词翻页快捷键组合、增加以词定字快捷键组合;
issue-55 候选词与辅助码间保留一个半角空格。
2026-09-08 14:07:48 +08:00
fanlusky de4d3acf45 fix(config): handle non-ASCII (e.g. Chinese) user profile paths
std::filesystem::path(std::string) and path::string() convert through the
system ANSI code page, so a non-ASCII (e.g. Chinese) user profile path on a
non-UTF-8 (GBK 936) system was corrupted and every config read/write failed
with "设置保存失败"; on a code page that cannot represent the characters
path::string() threw, crashing the Server at startup in a watchdog restart loop.

Never route config paths through the ANSI narrow encoding:
- build g_config_path and the legacy voice path from the wide accessors;
- read config by opening the wide path + toml::parse(text) instead of
  toml::parse_file(path.string()) (LoadImeConfig, MigrateLegacyVoiceInputConfig);
- build and open the TSF shared config path as a wide std::filesystem::path.

Add a regression test that round-trips config read/write under a Chinese
profile path.
2026-09-08 02:20:37 +08:00
Evan Hu 84ef90cc8d fix(server): test valid escaped CSS URLs 2026-09-07 13:37:22 +09:00
Evan Hu 8972593b3e style(server): format skin CSS policy 2026-09-07 13:32:09 +09:00
Evan Hu 818069f9c3 fix(server): make release probes non-interactive 2026-09-07 13:28:25 +09:00
Evan Hu 205cafa4f5 fix(skin): @import 剥离只匹配真正的 at-rule;补转义绕过的不变量说明与用例
自查时发现的两处。

**@import 匹配过宽会损坏合法皮肤。** 此前在任意位置匹配 `@import`,于是 `.a{content:"@import //x";color:red}` 会被从 `@` 切到该声明的分号,留下一个未闭合的字符串和一份坏掉的样式表——为了保护皮肤反而弄坏了一个本来没问题的皮肤。改成只在 at-rule 能出现的位置匹配:样式表开头,或 `;` / `}` 之后;并要求关键字后面不是字母数字,避免 `@importantthing` 被当成 `@import`。

**CSS 转义不是漏洞,但原因不显然,值得钉死。** 样式表可以写 `url("https:\/\/host/x.png")`,浏览器解转义后得到一个可用的远程 URL,而字面文本里没有 `://`,分类器给出的是 Embed 而不是 Drop。这是安全的,但安全性来自 Embed 能产出什么:要么把文件内联成 data: 负载,要么回退到 candidate-skins 虚拟主机下的 URL,两者都无法命名皮肤作者选定的 origin。转义过的 `..` 同理——它以字面转义文本的形式进入文件系统查找,不会穿越,也永远不会被写回文档。

也就是说,真正保护候选窗的不变量是「Embed 永不产出攻击者命名的 origin」,而不是「Drop 拦住了远程 URL 的每一种写法」。把这条写进头文件,并补一个用例钉住「转义写法永远不落到 Keep」——将来若有人改动 Embed 的回退逻辑让它原样输出 URL,这个洞会重新打开,用例会先失败。

本机以 -Wall -Wextra -Wpedantic -Werror + ASan/UBSan 编译运行 8/8 通过,portable 目标经 CMake + ctest 验证,clang-format 干净。
2026-09-06 19:33:39 +09:00
Evan Hu 680fdfa648 fix(skin): 丢弃第三方皮肤 CSS 里的远程引用,不再原样注入候选窗
皮肤是用户往 %LOCALAPPDATA%\metasequoiaime\skins 里丢的文件夹,是彻头彻尾的第三方内容,而它的 CSS 会被内联进候选窗文档。此前 IsRewritableSkinCssUrl() 对含 :// 的 URL 直接返回 false,而 false 分支把原始 url("…") 原封不动写回样式表——也就是说 `background-image: url(https://attacker/beacon.png)` 会在每一次候选窗渲染时向外发一个请求,泄露「此人此刻正在打字」以及 IP。这直接推翻了 PRIVACY.md 的 "Local conversion never contacts the network",而那句话是这个项目最强的信任资产。

问题出在这个判断只有两态:不可重写就等于放行。实际上有三类:

- Embed——皮肤包内的相对路径,读文件内联;
- Keep——本身就是惰性的 data: 负载和文档内 #fragment 引用,照原样保留;
- Drop——任何会让候选窗向皮肤包之外取数据的写法。丢掉 URL 后声明不完整,CSS 会整条丢弃,这正是想要的结果。

Drop 覆盖 http/https/ftp 等带 scheme 的、协议相对的 //host/x(不写 scheme 但照样出网)、路径穿越,以及会逃出皮肤包的绝对路径。

url() 不是唯一入口:`@import "https://…"` 根本不含 url() token,扫描器永远看不到它。补 StripRemoteImports() 做前置处理,只删远程 @import,本地的保留。

skin.preview 来自皮肤自己的 skin.toml,此前直接进 EmbedSkinCssUrl。现在同样过一遍分类,不因为它是通过 manifest 字段到达就被信任。

判断逻辑抽到 server/src/webview2/skin_css_policy.{h,cpp},不依赖任何 Windows API,配 6 个用例覆盖三类判定与两种 @import 写法。本机以 -Wall -Wextra 编译运行全部通过。
2026-09-06 18:05:09 +09:00
Evan 688972b28c Merge remote-tracking branch 'origin/main' into pr184-merge
# Conflicts:
#	server/src/session/input_session.h
2026-09-06 15:31:05 +09:00
Evan Hu ac805078e4 refactor(server): carry engine online queries through asynchronous candidate tasks 2026-09-06 13:24:03 +09:00
Evan Hu 9785ecd4bf fix(server): revalidate queued online candidate generations on apply 2026-09-06 13:17:50 +09:00
Evan Hu a533d5aa2b Merge remote-tracking branch 'origin/main' into chore/oss-hardening
# Conflicts:
#	AGENTS.md
2026-09-06 13:06:54 +09:00
Evan 42238a2af6 style: 用 .clang-format 重排 server / windows / ui / log
一次性重排,无任何行为改动。四个目录各自的 .clang-format 放在仓库里已久,但全组织只有
MSIME-Linux 在 CI 里执行 clang-format 检查,这边 149 个文件里有 149 个不符合自己声明的风格。

已逐文件核对语义等价:去掉空白、注释与相邻字符串字面量拆分之后,全部 149 个文件与重排前逐字节
相同。差异只有三类——缩进与换行、clang-format 补的 } // namespace 结尾注释、以及长字符串被拆成
相邻字面量(C++ 保证自动拼接)。

这个提交会写进 .git-blame-ignore-revs。
2026-09-06 12:13:47 +09:00
Evan 6341b4fffc fix(server): 出厂配置的占位凭据不再被当作真凭据
IsPlaceholderToken 与 IsUsableSecret 都只识别 `<YOUR_OWN_` 前缀,而 config.default.toml 实际使用
`<YOUR_XXX>` 和 `FAKESECRET_` 两种写法,18 个占位符无一被识别。叠加 ai_assistant.enabled、
voice_input.voice_input、tencent_tmt.enabled 三项默认为 true,全新安装在用户未做任何配置的情况下
就会把输入串发往 api.deepseek.com、把候选文本发往 tmt.tencentcloudapi.com——请求虽然鉴权失败,
内容已经离开本机。

两处判定改为按占位符的形状判断,并新增 test_default_config_credentials:它直接读安装器实际打包的
config.default.toml,逐条校验没有任何凭据被当成可用值,因此换一种占位符写法也会被拦下。
2026-09-06 11:56:11 +09:00
Evan 2b8bf937d9 fix(server): adopt isolated engine sessions and helpcode annotations (#178) 2026-09-06 11:44:30 +09:00
Evan 2562026a2a fix: 修复审计发现的候选页竞态、管道权限、TSF 空指针与皮肤 CSS 逃逸等八项缺陷 (#169)
* fix(server): publish candidate pages as immutable snapshots

Global::candidate_ui is a plain global with no lock. The IPC worker rebuilds and destroys its vectors while the UI thread paints from them, and the handoff is an asynchronous PostMessage, so the worker returns to its loop and pops the next task without waiting. A second keystroke, or an async english.db candidate arrival, could free the page_views buffer and its strings while FillItemsFromUi held a reference into it. ShowItemContextMenu reads the same vectors from a mouse callback with no message handoff at all.

The worker now copies each finished page into an immutable snapshot and publishes it at the single point where the rebuild completes; every UI-thread reader loads that snapshot once and reads only its own copy. PostMessage is deliberately left alone: the worker also serves UI-originated tasks, so a synchronous handoff would invite a cross-thread deadlock.

* fix(server): bound the aux and diagnostic pipe reads

Both listeners serve a single pipe instance inline and polled a NOWAIT handle for as long as the process ran, breaking only on a read that succeeded or failed with something other than ERROR_NO_DATA. A client that connected and never wrote held the only instance forever, so the loop never returned to ConnectNamedPipe and no later client was accepted, permanently losing the langbar right-click channel and the terminal-deactivation teardown fallback.

Give both loops the same deadline the hello reads already use and go back to accepting when it expires.

* fix(server): snapshot the voice config and replace config.toml atomically

GetConfiguredVoiceInput handed out a reference to a global that LoadImeConfig rewrites from the IPC worker thread, clearing and refilling two std::map members and around twenty strings. The voice control thread and the low-level keyboard hook, which copies the struct on every keystroke, walked those nodes as they were freed. LoadImeConfig now parses into a local and publishes it in one step under a process-local shared_mutex, and the getter returns a snapshot by value. The file lock is deliberately not reused for readers: it is a named cross-process mutex with a five second wait, and taking it in a keyboard hook would stall typing system-wide.

WriteConfiguredValue also reopened the live config.toml with ios::trunc, so a crash mid-write destroyed the user settings and could leave the file unparseable for good. It now goes through WriteFileTextAtomically, which this file already uses elsewhere. That makes the directory entry swap atomic; it does not flush, so it is not a durability guarantee.

* fix(ipc): restrict the server pipes to the owning account

The pipe DACL granted Everyone FILE_ALL_ACCESS. That bit set includes FILE_CREATE_PIPE_INSTANCE, so any local account could add an instance to a name this server already owned and answer part of the connections in its place. The names are machine-global with no per-user component, and the TSF client opened them with no SQOS, so a squatter could also impersonate the connecting thread.

Build the descriptor from the process owner SID and admit only LocalSystem, that account, and app containers with connect-only rights so UWP text input still works; fail pipe creation outright when the SID cannot be resolved rather than falling back to something permissive. Pass FILE_FLAG_FIRST_PIPE_INSTANCE on the first instance of each name so a squatted name fails loudly, and request SECURITY_IDENTIFICATION on the client side.

Authenticating the peer process after connect is a larger change to the handshake and is not attempted here.

* fix(tsf): guard the null focus paths and unadvise the compartment sink

_CandidateChangeNotification treated ITfThreadMgr::GetFocus and ITfDocumentMgr::GetTop as if they could only fail through a FAILED HRESULT. Both return S_OK with a null out-pointer when nothing has focus or the document stack is empty, and the results were dereferenced unconditionally, so an external UILess host calling Finalize while focus moved away crashed the host application. The sibling _RequestCancelComposition in the same class already checks both.

CLangBarItemButton::CleanUp only unregistered the compartment inside the SUCCEEDED branch of a CoCreateInstance, then deleted the sink regardless. This TIP registers COM-less activation support, where that call does fail, and the sink was freed while TSF still held it advised. Unadvising never needed the thread manager, so it now runs unconditionally before the deletes.

* fix(ui): drop the cached visuals when the scene is replaced

Window caches focused, hovered and captured Visual pointers into the scene tree, and SetScene destroyed that tree without clearing them. Toggling the input mode rebuilds the floating toolbar scene, so the next mouse move dispatched a virtual call through a freed object.

Clear all three before the assignment, and release the capture only when this window actually holds it: an adopted HWND may never have called SetCapture, and capturedVisual_ is set even when it did not.

* fix(settings): scope external skin CSS through the CSS parser

injectScopedSkinCss concatenated a skin toolbar.css into an @scope block as text. Block nesting is textual, so a leading close brace in the skin ended the block early and the rest styled the whole settings window. The host validates only the skin file name, never the body, and candidatePreviewCss interpolated unvalidated colour strings into rule bodies the same way.

Create the scope rule empty and re-insert every rule parsed out of the skin as a child of it, so nothing lands outside however the braces are balanced, and accept a colour only in the plain notations we actually render.

* fix(release): gate the dictionary source commit on its default branch

verify_published iterated only data["repositories"], but the dictionary block pins a source_commit exactly like they do. The manifest check merely proves the release agrees with the lock about that commit, which a branch commit satisfies just as happily, so a dictionary built from an unmerged branch shipped with the provenance the gate exists to refuse.

Run the dictionary through the same loop under its own name, resolving its repository from the lock. A retired dictionary repository that no longer answers is reported rather than failing the release: its published artifacts are immutable history, and being unable to re-check them is not the same as finding them unmerged.
2026-09-06 10:31:48 +09:00
Evan Hu cf872efc52 refactor(server): share batch voice encoding and provider codecs 2026-09-06 04:35:40 +09:00
Evan Hu 06bba15d4f fix(server): keep settings I/O off UI thread and bound dictionary rendering 2026-09-06 03:31:40 +09:00
Evan Hu b5d07f11eb fix(server): reduce WebView message and first-paint overhead 2026-09-06 03:05:36 +09:00
Evan Hu 8e54b79547 merge(main): retain direct shared local-mode calls and remove legacy adapters 2026-09-06 00:27:39 +09:00
Evan Hu 6783ff7175 refactor(session): use shared composition and local queries with one candidate view model 2026-09-06 00:26:38 +09:00
Evan Hu 60fce0f043 Merge branch main into feat/generic-pinyin-order-correction
唯一冲突是 engine 子模块指针,取 main 的当前值(其中已含本 PR 依赖的
MSIME-Engine#1,以及后续的 #20 门控修复)。
2026-09-05 23:34:30 +09:00
Evan 6ba26c3baf Merge pull request #30 from metasequoiaime/architecture/product-contracts
Use shared IPC definitions and negotiate main client sessions
2026-09-05 23:23:03 +09:00
Evan Hu 8a36ee264a test(quanpin): expect four-syllable alternatives and bound them at five
The engine pin moved 55839c8 -> 127019f in the previous commit, and that range contains 86c5fa7 "fix(quanpin): enumerate alternative segmentations for four-syllable input". QuanpinDictionaryOnlyTriesMultipleSegmentationsForAtMostThreeSyllables asserted the behaviour that fix deliberately changed, so it failed here and, through the product lock, in MSIME-Windows' locked-Server integration job as well.

The engine is the authoritative layer: quanpin/quanpin_dictionary.cpp declares kMaxSyllablesForMultipleSegmentations = 4 and gates enumeration on segments.size() <= that. Four syllables now enumerate alternatives; five still do not. The test says exactly that, with a tbl_6_x fixture row so the five-syllable case would have something to find if the bound ever moved silently.
2026-09-05 23:00:52 +09:00
Evan Hu e9c8fd4077 Merge remote-tracking branch 'origin/main' into pr2 2026-09-05 22:51:54 +09:00
Evan e6e4d593d3 refactor: use the engine's local mode queries instead of this repository's copies (#29)
The engine absorbed the six local mode queries during the cross-platform work,
and MSIME-Linux has been driving them in production since. This repository kept
its own implementations of the same six features, so date-time, emoji, kaomoji,
jianpin, quick-phrase and unicode each existed twice and were free to drift.

Deletes this repository's copies and points the eight call sites in
event_listener.cpp plus the two async workers at metasequoia::local_modes.

The shuangpin profile is the part to look at. The old modules resolved the
*configured* scheme themselves:

    GetShuangpinProfile(shuangpin_schema.empty() ? GetConfiguredShuangpinSchema()
                                                 : shuangpin_schema)

The engine takes a resolved ShuangpinProfile and defaults it to Xiaohe. Taking
that default would have decoded J mode, emoji and kaomoji as Xiaohe for every
user on Ziranma, Shoudao or Microsoft shuangpin, so every call site passes the
configured profile explicitly through a ConfiguredShuangpinProfile() helper.

The database path needs the same care in the other direction. The old modules
took a UTF-8 std::string and handed it straight to sqlite3_open_v2; the engine
takes a std::filesystem::path and converts back with path_to_utf8 before
opening. The two async workers therefore bridge with path_from_utf8 rather than
constructing a path from the narrow string, which on Windows would interpret a
non-ASCII data directory in the active code page.

The four existing test files are kept and re-pointed at the engine functions
with every expectation byte-identical, including the seventeen date-time format
strings and the four shuangpin schemes jianpin covers. They are the equivalence
check: if the engine's port diverged from what this repository shipped, those
assertions fail rather than the difference reaching users.
2026-09-05 22:20:17 +09:00