Skip to content

feat(terminal): bounded key polling and diagnostic styling for FastLED migration #178

Description

@zackees

Context

Coordinated with FastLED/cli#229 and draft FastLED/cli#242. Two source investigations confirmed the production consumer is commands.rs manual rebuild polling through keyboard::check_for_space, plus four yellow diagnostic formatting sites in source.rs, wasm_build.rs and compile_stream.rs. The unused public start_listener exposes Crossterm KeyEvent and an unbounded std channel; receiver drop is noticed only after another key arrives.

Existing kernel prior art matters: platform::terminal::input selects the Windows capture core, with an unsupported neutral Unix implementation. Separately, pty-gated TerminalInputSession has real Linux/macOS termios/poll/read implementations and Windows capture, with mode restoration on Drop. Unix reads at most 65536 bytes per chunk; Windows uses a background VecDeque. These are raw terminal chunks, not equivalent to one decoded Crossterm event. Scanning chunks for spaces would mistake some terminal escape sequences or pasted input for rebuild keys.

Proposal

Provide a facade-owned bounded terminal key-polling contract and diagnostic styling sufficient to remove direct Crossterm from FastLED. Reuse and harden existing host input ownership where practical; do not introduce a second runtime or unbounded pump. Keep rebuild-key selection, noninteractive fallback, warning text and color policy in the app. Resolve ownership of the unused listener explicitly rather than migrate its leaking public backend type mechanically.

Acceptance criteria

  • Focused RED test/repro before implementation, then GREEN and broad checks in each changed repository.
  • Public key/event and style interfaces expose no Crossterm or native host types.
  • Polling has bounded waits and storage, exclusive input ownership, noninteractive behavior, cancellation/Drop restoration and observable errors; repeated/released keys, modifiers, escape sequences and queued input have documented behavior.
  • Generic parsing, input ownership and restoration tests live upstream, with real Unix PTY and Windows console evidence. Keep app tests for Space/Enter rebuild policy and existing warning formatting.
  • Remove direct Crossterm manifest/import references after adoption; no whole-chunk substring shortcut for key matching.
  • Feature isolation, native CI, review, release and exact published adoption before closing this migration.

Decisions

  • Extend the current terminal capability where possible: existing host implementations mean a new private backend is not justified by the initial unsupported-input observation alone.
  • Start from the actual synchronous one-shot poll consumer; do not create a listener or general terminal emulator solely for an unused helper.
  • Retain FastLED product decisions locally and move generic terminal mechanisms/tests upstream.
  • No build-speed claim without comparable measurements.

Related issues

#155 tracks the complete FastLED migration. The browser xterm.js work in FastLED is separate from this native keyboard input boundary.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions