Skip to content

[Feature]: TUI Autocompletion: Tab Key Does Not Accept Completions #15622

@0xharryriddle

Description

@0xharryriddle

Problem or Use Case

The Hermes TUI (terminal UI) displays a dropdown for message autocompletion — slash commands (e.g., /help, /model) when typing /, and file paths when typing @. However, pressing Tab does nothing; the highlighted suggestion is never inserted. This is a regression from the original prompt_toolkit-based CLI, where Tab accepted completions automatically.

Impact:

  • Users cannot use keyboard-driven completion — they must type full commands manually
  • The dropdown is purely decorative, providing visual feedback without functional acceptance
  • Breaks expected terminal UI conventions (Tab cycles/accepts, Shift+Tab goes backward)

Proposed Solution

Wire the completion state from useCompletion through to the TextInput component and implement Tab/Shift+Tab key handling:

  1. Pass completion props (completions, compIdx, compReplace, setCompIdx) from AppLayoutTextInput
  2. Extend TextInputProps interface to include these fields
  3. Intercept Tab and Shift+Tab in TextInput's key handler:
    • Tab: accepts the current completion, inserts text at the compReplace range, positions cursor after inserted text
    • Shift+Tab: cycles backward through the completions list via setCompIdx
  4. Ensure proper typing in interfaces.ts (setCompIdx as StateSetter<number>) and include compReplace in AppLayoutComposerProps and useMainApp state construction

This approach is minimal and localized — no changes to useCompletion, gateway RPCs, or overlay rendering. It restores the old CLI's acceptance behavior in the new TUI.

Alternatives Considered

  • Handle acceptance in parent (AppLayout): Would require lifting edit state upward and breaking the encapsulated TextInput edit model. Rejected — TextInput already owns the text state and cursor; acceptance belongs there.
  • Global key capture at app.tsx level: Adds indirection and complicates prop drilling. Rejected — TextInput already receives key events; keeping logic local is cleaner.
  • Disable Tab for completions and use Enter: Misaligns with terminal UX norms (Tab is standard for completion acceptance in prompt_toolkit, readline, etc.). Rejected — would create inconsistency.
  • Re-implement entire completion system: Unnecessary — the dropdown renders correctly and completion data is already flowing to appOverlays. Only acceptance logic was missing.

Feature Type

Other

Scope

Small (single file, < 50 lines)

Contribution

  • I'd like to implement this myself and submit a PR

Debug Report (optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/tuiTerminal UI (ui-tui/ + tui_gateway/)sweeper:implemented-on-mainSweeper: behavior already present on current maintype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions