Skip to content

diag(qt): IME 事件与提交字节观测 (#155) - #207

Merged
JavaZeroo merged 2 commits into
mainfrom
diag/qt-ime-log
Oct 29, 2026
Merged

JavaZeroo merged 2 commits into
mainfrom
diag/qt-ime-log

Conversation

@JavaZeroo

Copy link
Copy Markdown
Owner

内容

给 Qt 终端加可选的 IME 观测(默认关闭,未设置的运行不写任何文件):

  • 环境变量 TERMFORGE_QT_IME_LOG 指定 JSONL 路径;
  • 每个 inputMethodEvent 记录一行:kind(preedit / commit / cancel)、bytes、UTF-8 十六进制;
  • 只观测,不改变发送逻辑。

真机验证(隔离 VM,固定微软拼音,我们的 Qt 应用)

把应用部署到 VM 后聚焦窗口,用 keybd_event 发送 n i h a o 与空格选择候选,得到完整序列:

{"kind":"preedit","bytes":1,"utf8":"6e"}
{"kind":"preedit","bytes":2,"utf8":"6e69"}
{"kind":"preedit","bytes":4,"utf8":"6e692768"}
{"kind":"preedit","bytes":5,"utf8":"6e69276861"}
{"kind":"preedit","bytes":6,"utf8":"6e692768616f"}
{"kind":"cancel","bytes":0,"utf8":""}
{"kind":"commit","bytes":6,"utf8":"e4bda0e5a5bd"}

逐行含义:组合串从 n 增长到 ni'hao(6e692768616f),随后组合被清空(cancel),最后提交「你好」(e4bda0e5a5bd)。

即:真实系统输入法在我们的应用里完成了组合 → 取消 → 提交,且提交的正是 UTF-8 的「你好」。

边界

Refs #155

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T21:19:57.434754Z 57df48a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Records kind and UTF-8 bytes for preedit, commit and cancel so a fixed-IME run can show what the widget delivered without changing the send path.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 57df48a8e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (preedit != preedit_) { preedit_ = preedit; update(); }
if (preedit != preedit_) {
if (!preedit.isEmpty()) ime_log("preedit", preedit);
else if (!preedit_.isEmpty()) ime_log("cancel", QString());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Distinguish composition commits from cancellations in the log

When logging is enabled, committing an active composition with an empty preedit and nonempty commit string produces both a cancel record and a commit record for the same event. This occurs in the existing src/qt/shell_smoke.cpp sequence that sends composing followed by committed; no cancellation actually occurs. Consequently, the diagnostic output cannot reliably distinguish successful composition completion from cancellation, undermining the IME evidence this change is intended to collect. Check the commit string before classifying an empty preedit as cancellation, or record the event's preedit and commit fields together without inferring a cancellation.

Useful? React with 👍 / 👎.

…#155

The caret cell is what the IME uses to place its candidate window, so the log now carries row, column, widget-relative caret rectangle and the widget global origin for each event.
@JavaZeroo
JavaZeroo merged commit c380d7a into main Oct 29, 2026
6 checks passed
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.

1 participant