Skip to content

Replace inquire with rustyline for interactive CLI input#33

Merged
v3g42 merged 7 commits intofix/distrifrom
claude/enhance-cli-multiline-rJR5r
Mar 27, 2026
Merged

Replace inquire with rustyline for interactive CLI input#33
v3g42 merged 7 commits intofix/distrifrom
claude/enhance-cli-multiline-rJR5r

Conversation

@v3g42
Copy link
Copy Markdown
Contributor

@v3g42 v3g42 commented Mar 27, 2026

Summary

Migrated the interactive chat input handling from the inquire crate to rustyline for improved terminal interaction and history management.

Key Changes

  • Replaced input library: Switched from inquire::Text to rustyline::Editor for readline-style input handling
  • Refactored autocomplete system:
    • Renamed DistriAutocomplete to DistriHelper to align with rustyline's trait-based architecture
    • Implemented rustyline traits (Completer, Hinter, Validator, Highlighter, Helper)
    • Removed history management from the autocomplete struct (now handled by rustyline's built-in history)
    • Simplified completion to only support slash commands (removed history-based suggestions)
  • Improved history handling:
    • Leveraged rustyline's native history persistence via load_history() and save_history()
    • Fixed history file path to use proper home directory resolution ($HOME or $USERPROFILE)
    • Removed custom history serialization logic
  • Enhanced user experience:
    • Added placeholder hint: " /help for commands... Ask me anything" (shown when input is empty)
    • Enabled bracketed paste support for multi-line text handling
    • Removed the manual "Tab to autocomplete" help message (rustyline provides native UI feedback)
    • Updated help text to mention arrow key navigation for history
  • Simplified error handling: Replaced inquire::InquireError variants with rustyline::error::ReadlineError

Implementation Details

  • The DistriHelper struct now implements rustyline's Completer trait, returning Pair objects with display and replacement text
  • History is automatically managed by rustyline with auto_add_history(true) configuration
  • Completion is limited to the first 15 fuzzy-matched slash commands
  • The hint system provides contextual help only when the input line is empty

https://claude.ai/code/session_017YeCUYbAKZqsGV4599Rrso

claude and others added 7 commits March 26, 2026 17:18
Switches the interactive chat input from inquire::Text to rustyline with
bracket paste mode enabled, so pasted multi-line text stays as a single
message instead of being split on each newline. Adds slash-command tab
completion via rustyline's Completer trait and a placeholder hint via
Hinter. History is now managed natively by rustyline with arrow-key
navigation.

https://claude.ai/code/session_017YeCUYbAKZqsGV4599Rrso
…sion

- Replace "assistant:" label with "◆ agent_name:" using the current agent's
  display name instead of a generic role label
- Add /tools slash command to toggle tool call output on/off, letting users
  hide noisy tool blocks and focus on agent responses
- Suppress internal probe calls (load_skill("?"), discovery GET requests)
  from non-verbose output since they're agent internals
- Show thread ID in welcome header and on exit so users can easily resume
  sessions with /resume last or /resume <id>
- Show short thread ID when context is cleared via /clear

https://claude.ai/code/session_017YeCUYbAKZqsGV4599Rrso
Use rustyline's ConditionalEventHandler to bind Ctrl+O as a toggle for
tool output visibility. The hint text updates to show "[tools hidden ·
Ctrl+O]" when tools are hidden. Shared state via Arc<AtomicBool> between
the helper (for hints) and the handler (for toggling). Help message now
has a dedicated KEYBOARD SHORTCUTS section.

https://claude.ai/code/session_017YeCUYbAKZqsGV4599Rrso
- Add --resume <id|last> flag to both `tui` and `run` commands so users
  can resume a thread directly from the CLI without entering interactive
  mode first
- Implement double Ctrl+C to exit: first press shows a hint, second
  press within 2 seconds exits. Ctrl+D still exits immediately
- Print thread message history when resuming (via --resume flag or
  /resume command), showing user prompts and assistant responses in a
  compact gray format so the user has context
- Add get_thread_messages() to the Distri client for fetching thread
  message history from the server

https://claude.ai/code/session_017YeCUYbAKZqsGV4599Rrso
@v3g42 v3g42 merged commit e7f0bdb into fix/distri Mar 27, 2026
@v3g42 v3g42 deleted the claude/enhance-cli-multiline-rJR5r branch March 30, 2026 19:25
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.

2 participants