Skip to content

dash-TUI: extract a shared append/backspace key handler for text-input buffers #770

Closed

Description

@jussielo-amd

Nine modules in crates/rocm-dash-tui each independently implement the same "append or backspace a char into a String buffer on a KeyCode::Char/KeyCode::Backspace key event" logic for their text-input fields:

  • src/ui/folder_browser.rs
  • src/ui/bench_run.rs (four separate input fields)
  • src/ui/install_manager.rs (its own small type_char/backspace dispatcher)
  • src/ui/logs_view.rs
  • src/ui/onboarding.rs
  • src/ui/command_screen.rs
  • src/ui/serve_wizard.rs (three separate input fields)
  • src/ui/model_picker.rs
  • src/ui/runtime_manager.rs

All of these are append-only (no cursor movement, no mid-string editing), so the actual shared surface is small: a single free function in src/ui/widgets.rs, something like fn apply_char_key(buf: &mut String, key: KeyCode) -> bool (returning whether the key was consumed), would collapse all nine near-identical match arms into one call site each.

This is one of a handful of shared-component opportunities surfaced in an audit of the dash-TUI's widget layer (see AGENTS.md's "Shared UI components" section, which documents ui/job_console.rs, ui/panel.rs, and ui/theme.rs::job_status_color as the existing reuse points this project follows) — filed as a standalone, scoped follow-up rather than bundled with unrelated changes.

Documentation: once this lands, add a bullet for apply_char_key to AGENTS.md's "Shared UI components" section (dash-TUI group), next to the other ui/-module entries, so the next text-input field reaches for it instead of writing a tenth copy.

Activity

  1. added
    enhancementNew feature or request
    ux-opportunitiesShared-component / DRY opportunities surfaced by codebase audits
    on Oct 28, 2026
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

    enhancementNew feature or requestux-opportunitiesShared-component / DRY opportunities surfaced by codebase audits

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions