Skip to content

Delete the TUI key-translation round-trip through crossterm (~300 lines) — share one decoder with GTK #826

Description

@JDonaghy

Problem

The TUI takes a quadraui::Key from the runner, converts it back into a crossterm event, then re-decodes it:

  1. src/tui_main/shell_app.rs:3614synth_keyevent turns the quadraui::Key back into crossterm
  2. src/tui_main/mod.rs:809-911translate_key (103 lines)
  3. src/tui_main/mod.rs:789-808tui_key_to_engine_name
  4. src/tui_main/mod.rs:753-788shift_map_us
  5. src/tui_main/shell_app.rs:3171-3578 — ~200 lines of per-panel KeyCode tables inside handle_focus_owner_key

GTK decodes the same quadraui::Key to the same engine names in ~40 lines inline (src/app.rs:6807-6850) plus map_gtk_key_name (:617-639).

Both produce identical spellings"Escape", "Return", "BackSpace", etc. The TUI's round-trip through crossterm is pure overhead, and it is the largest single block of TUI-only code that is not irreducible: ~300 lines.

Fix

One shared decoder in render.rs:

render::engine_key_from_ui(key, mods, keyboard_enhanced) -> (String, Option<char>, bool)

Delete synth_keyevent, translate_key, tui_key_to_engine_name and shift_map_us; have both backends call the shared function. The per-panel KeyCode tables in handle_focus_owner_key should then be expressible against engine key names rather than crossterm variants.

Watch keyboard_enhanced — the TUI sets it in setup and it changes how some chords arrive. It must be a parameter of the shared decoder, not a TUI-local branch.

Note for reference: <C-h>, <C-j> and <C-c> arrive as ctrl+h/ctrl+j/ctrl+c under crossterm; the Vim-conformance chain (#800-807) depends on those spellings. Do not change the engine-facing names.

Acceptance

  • Black-box tests required, both backends. Key decoding is the highest-blast-radius surface in the editor.
  • Cover: plain keys, shifted keys, ctrl chords, alt chords, function keys, Escape/Return/BackSpace/Tab, and per-panel focus routing.
  • The Neovim-oracle harness (tests/nvim_conformance.rs, 1,432 cases behind KNOWN_DEVIATIONS) is the regression net here — it must stay green, and no label may start passing or failing unexpectedly.
  • State in the PR that the new tests fail against unfixed develop.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coordTracked by coord-tui pipelineplatformPlatform-specific (macOS, Windows, Linux)status:readyRefined and ready to enter the work pipeline

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions