Skip to content

fix(cli): enable editing in custom model prompt - #90327

Closed
helix4u wants to merge 2 commits into
NousResearch:mainfrom
helix4u:fix/model-name-line-editing
Closed

fix(cli): enable editing in custom model prompt#90327
helix4u wants to merge 2 commits into
NousResearch:mainfrom
helix4u:fix/model-name-line-editing

Conversation

@helix4u

@helix4u helix4u commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds normal line editing to the custom model-name prompt. On an interactive terminal, the prompt now uses Hermes' existing prompt_toolkit dependency, so Left/Right and Ctrl+A/Ctrl+E edit the entered model name instead of printing raw escape bytes.

The helper is intentionally narrow: redirected input/output keeps the existing built-in input() path, imports stay lazy, and password or masked-secret prompts are unchanged.

The root cause was the transition from the curses model picker to a bare input("Enter model name: ") call. A scripted Python process does not initialize a readline-style editor for that call, so affected terminals pass cursor keys through as visible VT sequences.

Related Issue

Reported in the Discord support thread arrow keys are not correctly processed by CLI wizard.

Related open PRs #83045 and #40458 affect the curses picker itself, but neither changes the subsequent custom model-name prompt covered here.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • hermes_cli/cli_output.py: add a TTY-aware non-secret line-input helper backed by prompt_toolkit, with the existing built-in input() behavior retained for redirected streams or an unavailable dependency.
  • hermes_cli/auth.py: use that helper in both custom model-name branches, including the numbered fallback.
  • tests/hermes_cli/test_cli_output.py: cover Left/Right and Ctrl+A/Ctrl+E editing through a real prompt-toolkit pipe, plus the redirected-input fallback.
  • tests/hermes_cli/test_terminal_menu_fallbacks.py: verify both model-selector paths use the line editor.

How to Test

  1. Run hermes model and select a provider with a model picker.
  2. Choose Enter custom model name.
  3. Type a model name, move with Left/Right, and use Ctrl+A/Ctrl+E. The cursor should move and edits should be inserted at its position without visible escape bytes.
  4. Run tests/hermes_cli/test_cli_output.py and tests/hermes_cli/test_terminal_menu_fallbacks.py.

Local validation:

  • ruff check on all four changed files: passed
  • ruff format --check on the newly formatted helper and helper-test files: passed
  • git diff --check: passed
  • Focused Python tests were added but not run locally; GitHub CI is expected to run them.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) - N/A; no documented workflow changes
  • I've updated cli-config.yaml.example if I added/changed config keys - N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows - N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide
  • I've updated tool descriptions/schemas if I changed tool behavior - N/A

Screenshots / Logs

Not applicable. The regression is exercised with prompt-toolkit pipe input so the terminal key sequences remain deterministic in CI.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels Aug 19, 2026
@helix4u
helix4u marked this pull request as ready for review August 19, 2026 22:56
teknium1 added a commit that referenced this pull request Aug 20, 2026
…diting

Widens #90327's line_input() to the whole bug class: all 46 bare input()
free-text prompt sites across the setup wizards (model_setup_flows, setup,
config, gateway, auth, auth_commands, plugins_cmd, skills_hub, bundles,
setup_whatsapp_cloud, main) now route through line_input(), and the shared
cli_output.prompt() / setup.prompt() helpers do too — so every CLI wizard
gets cursor editing, not just the custom model prompt.

Redirected stdin and missing prompt_toolkit keep builtin input() behavior.
E2E: real PTY with raw escape bytes through line_input, cli_output.prompt,
and setup.prompt (arrows + Ctrl+A/E edit correctly); redirected-stdin
fallback verified.
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #90345 with your commit cherry-picked onto current main, authorship preserved in git log. We widened your line_input() fix to all 46 bare input() free-text prompt sites across the setup wizards plus the shared prompt() helpers. Thanks!

@teknium1 teknium1 closed this Aug 20, 2026
lisajlau pushed a commit to lisajlau/hermes-agent that referenced this pull request Aug 20, 2026
…diting

Widens NousResearch#90327's line_input() to the whole bug class: all 46 bare input()
free-text prompt sites across the setup wizards (model_setup_flows, setup,
config, gateway, auth, auth_commands, plugins_cmd, skills_hub, bundles,
setup_whatsapp_cloud, main) now route through line_input(), and the shared
cli_output.prompt() / setup.prompt() helpers do too — so every CLI wizard
gets cursor editing, not just the custom model prompt.

Redirected stdin and missing prompt_toolkit keep builtin input() behavior.
E2E: real PTY with raw escape bytes through line_input, cli_output.prompt,
and setup.prompt (arrows + Ctrl+A/E edit correctly); redirected-stdin
fallback verified.
bobaba76 pushed a commit to bobaba76/hermes-agent that referenced this pull request Aug 27, 2026
…diting

Widens NousResearch#90327's line_input() to the whole bug class: all 46 bare input()
free-text prompt sites across the setup wizards (model_setup_flows, setup,
config, gateway, auth, auth_commands, plugins_cmd, skills_hub, bundles,
setup_whatsapp_cloud, main) now route through line_input(), and the shared
cli_output.prompt() / setup.prompt() helpers do too — so every CLI wizard
gets cursor editing, not just the custom model prompt.

Redirected stdin and missing prompt_toolkit keep builtin input() behavior.
E2E: real PTY with raw escape bytes through line_input, cli_output.prompt,
and setup.prompt (arrows + Ctrl+A/E edit correctly); redirected-stdin
fallback verified.
melon-xf added a commit to melon-xf/hermes-agent that referenced this pull request Sep 3, 2026
…diting

Widens NousResearch#90327's line_input() to the whole bug class: all 46 bare input()
free-text prompt sites across the setup wizards (model_setup_flows, setup,
config, gateway, auth, auth_commands, plugins_cmd, skills_hub, bundles,
setup_whatsapp_cloud, main) now route through line_input(), and the shared
cli_output.prompt() / setup.prompt() helpers do too — so every CLI wizard
gets cursor editing, not just the custom model prompt.

Redirected stdin and missing prompt_toolkit keep builtin input() behavior.
E2E: real PTY with raw escape bytes through line_input, cli_output.prompt,
and setup.prompt (arrows + Ctrl+A/E edit correctly); redirected-stdin
fallback verified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants