Skip to content

refactor(ime): replace manual wire assembly with MessageBuilder/push_msg and add structured logging - #28

Merged
InternetOfTofu merged 1 commit into
google:virtwlfrom
kkimdev:wayland-ime-refactor-1
Jul 8, 2026
Merged

refactor(ime): replace manual wire assembly with MessageBuilder/push_msg and add structured logging#28
InternetOfTofu merged 1 commit into
google:virtwlfrom
kkimdev:wayland-ime-refactor-1

Conversation

@kkimdev

@kkimdev kkimdev commented Jul 8, 2026

Copy link
Copy Markdown

This is PR 1 of a stacked series (split from #27 for reviewability). It is a behavior-neutral refactor with zero protocol changes.

Every instance of the open-coded Wayland wire-format assembly pattern:

let mut msg = Vec::new();
msg.extend_from_slice(&sender_id.to_ne_bytes());
let len = (builder.payload.len() + 8) as u32;
let word2 = (len << 16) | opcode;
msg.extend_from_slice(&word2.to_ne_bytes());
msg.extend_from_slice(&builder.payload);
queue.push((msg, Vec::new()));

is replaced with a single call:

push_msg(&mut queue, sender_id, opcode, builder);

MessageBuilder::build_message produces byte-identical output, so this is behavior-neutral.

Also adds structured log::trace/debug/info instrumentation to every IME-related handler in both text_input.rs and keyboard.rs so the host↔guest event flow is observable in logs.

Next in the stack

  • PR 2: Core IME correctness — serial propagation, set_preedit_region/confirm_preedit handlers, commit_state fix, activation state machine
  • PR 3: Korean IME backspace hold heuristic

…sh_msg and add tracing

Replace the open-coded extend_from_slice + (len << 16) | opcode wire assembly
with the existing MessageBuilder::build_message helper wrapped in a push_msg
helper. MessageBuilder produces byte-identical wire output, so this is a
behavior-neutral refactor. Add structured log::trace/debug/info instrumentation
to every IME handler to make the host<->guest event flow observable.

This lays the groundwork (shared helpers + logging) for the follow-up IME
correctness fixes without changing any protocol behavior.
@kkimdev kkimdev changed the title refactor(ime): deduplicate wire-message building via MessageBuilder/push_msg and add tracing refactor(ime): replace manual wire assembly with MessageBuilder/push_msg and add structured logging Jul 8, 2026
@kkimdev

kkimdev commented Jul 8, 2026

Copy link
Copy Markdown
Author

Split from #27 to make review manageable. This PR is the behavior-neutral foundation (MessageBuilder refactor + logging). The follow-up PRs (core IME correctness, then the backspace heuristic) are being prepared and will each link back here.

@InternetOfTofu
InternetOfTofu merged commit acb718b into google:virtwl Jul 8, 2026
3 checks passed
@kkimdev
kkimdev deleted the wayland-ime-refactor-1 branch July 9, 2026 12:04
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.

2 participants