Skip to content

Unify text input handling and bump WASM ABI to 0.25.0#24

Open
Yus314 wants to merge 1 commit intomasterfrom
feat/text-input-ime-abi-025
Open

Unify text input handling and bump WASM ABI to 0.25.0#24
Yus314 wants to merge 1 commit intomasterfrom
feat/text-input-ime-abi-025

Conversation

@Yus314
Copy link
Copy Markdown
Owner

@Yus314 Yus314 commented Mar 30, 2026

WASM ABI 0.25.0: unify text input handling, fix GUI IME, and rename clipboard paste command

Summary

This PR does two related pieces of work:

  1. Rebuilds input handling around a shared TextInput semantic path.
  2. Bumps the WASM plugin ABI to kasane:plugin@0.25.0 and renames clipboard paste from Paste to PasteClipboard.

The immediate user-visible result is that GUI IME now works correctly, text-producing inputs are routed consistently, and clipboard paste is clearly separated from committed text input.

Problem

Before this change:

  • GUI IME enabled only partial support.
  • Preedit was discarded, so composing text was not visible.
  • Candidate window positioning was not synchronized to the rendered caret.
  • IME commit was treated as key input instead of text input.
  • Plain char input, IME commit, bracketed paste, and clipboard paste used different paths.
  • The plugin ABI still used Paste, even though its meaning had narrowed to host clipboard insertion.

Design

The main design decisions are:

  • Treat Preedit as GUI-local runtime state, not editor truth.
  • Treat committed text as TextInput(String), not KeyEvent.
  • Keep IME candidate positioning tied to rendered caret coordinates, not raw model cursor state.
  • Route focused surface input before editor/plugin fallback.
  • Unify text-producing inputs onto one semantic text pipeline.
  • Reserve a separate command only for host system clipboard insertion.
  • Make the clipboard rename explicit in WIT via an ABI bump.

Scope

This PR includes:

  • GUI IME state and rendering.
  • Core TextInput semantics.
  • Plugin and surface text-input routing.
  • Clipboard paste semantic cleanup.
  • WASM ABI bump to 0.25.0.
  • SDK/docs/manifests/artifacts updates.

Key Changes

IME / GUI

  • Added GUI-local IME state in kasane-gui.
  • Moved WindowEvent::Ime handling out of generic input conversion.
  • Rendered Preedit as an overlay.
  • Synced candidate window position via set_ime_cursor_area(...).
  • Added target binding so stale preedit is cleared when session/target changes.
  • Improved preedit rendering using cursor_range for active segment/caret display.

Core Input Model

  • Added InputEvent::TextInput(String).
  • Added core text-target resolution.
  • Normalized plain text chars into TextInput when a text target is active.
  • Routed IME commit, bracketed paste payloads, and plain text through the same semantic path.

Commands / Event Loop

  • Added Command::InsertText(String) as the semantic command.
  • Compiled InsertText to Kakoune Keys(...) only at the host boundary.
  • Added common event-loop dispatch so injected input, clipboard paste, and normal input share the same routing stages.

Plugin / Surface Routing

  • Added plugin observe/handle hooks for committed text input.
  • Added focused-surface text-input consume path.
  • Added focused-surface key consume path so surface routing is consistently surface-first.

Clipboard Paste / ABI

  • Renamed WIT command paste to paste-clipboard.
  • Renamed session-ready variant accordingly.
  • Bumped package ABI to kasane:plugin@0.25.0.
  • Updated host conversion, SDK helpers, manifests, fixtures, bundled plugins, and docs.

Important Behavioral Changes

  • GUI IME preedit is visible.
  • Candidate window follows the rendered caret.
  • IME commit no longer goes through key semantics.
  • Plain character input in active text targets now uses the text pipeline.
  • Bracketed paste payloads now preserve and route actual text.
  • Clipboard paste remains explicit and separate via PasteClipboard.
  • Focused surfaces can consume both key input and text input before editor/plugin fallback.

Migration

For plugin authors upgrading from ABI 0.24.0:

  • Update abi_version = "0.25.0" in kasane-plugin.toml.
  • Update SDK to kasane-plugin-sdk = "0.4".
  • Rename Command::Paste to Command::PasteClipboard.
  • Prefer the helper paste_clipboard().
  • Rebuild and reinstall the .wasm.

Committed text input and bracketed paste payloads do not use PasteClipboard.

Notable Fix During Rollout

While validating the ABI bump, bundled pane_manager.wasm was still exporting kasane:plugin/plugin-api@0.24.0. That stale artifact caused bundled discovery failures and extra diagnostics. This PR replaces it with the rebuilt 0.25.0 artifact and adds a regression test for manifest-path loading.

Tests Run

  • cargo test -p kasane-gui --lib
  • cargo test -p kasane-tui --lib
  • cargo test -p kasane-core state::tests::update -- --nocapture
  • cargo test -p kasane-core state::tests::input -- --nocapture
  • cargo test -p kasane-core event_loop::tests::surface -- --nocapture
  • cargo test -p kasane-core event_loop::tests::dispatch -- --nocapture
  • cargo test --manifest-path kasane-plugin-sdk/Cargo.toml -- --nocapture
  • cargo test -p kasane-wasm --lib -- --nocapture

Review Guide

Suggested review order:

  1. kasane-gui
  2. kasane-core/src/input
  3. kasane-core/src/state/update.rs
  4. kasane-core/src/plugin/*
  5. kasane-core/src/surface/*
  6. kasane-core/src/event_loop/*
  7. kasane-wasm/wit/plugin.wit
  8. kasane-wasm/src/convert/*
  9. SDK/docs/manifests/artifacts

Focus questions:

  • Is Preedit ownership correctly isolated to the GUI layer?
  • Is TextInput now the right semantic boundary for committed text?
  • Is the surface-first routing order correct?
  • Is PasteClipboard now semantically narrow and well-separated?
  • Does the ABI bump cover all host/SDK/artifact boundaries?

Risk Areas

  • Buffer text-target detection still uses heuristic information in some cases.
  • Unicode grapheme fidelity is improved but not fully reworked.
  • This is a real ABI break for WASM plugins and requires rebuilds.

Docs Updated

  • README.md
  • docs/plugin-development.md
  • docs/using-plugins.md
  • kasane-plugin-sdk/README.md

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