Skip to content

fix(cli): wire /sessions slash command in the classic CLI - #25231

Closed
explainanalyze wants to merge 1 commit into
NousResearch:mainfrom
explainanalyze:fix/cli-sessions-slash-command
Closed

fix(cli): wire /sessions slash command in the classic CLI#25231
explainanalyze wants to merge 1 commit into
NousResearch:mainfrom
explainanalyze:fix/cli-sessions-slash-command

Conversation

@explainanalyze

Copy link
Copy Markdown
Contributor

What does this PR do?

Wires /sessions into the classic CLI's process_command() dispatcher.

The sessions command has been in the central COMMAND_REGISTRY since #20805 (May 2025) and surfaces in /help, tab-completion, and the gateway's known-commands list — but the legacy CLI never grew an elif canonical == "sessions" branch. The canonical name fell through and printed Unknown command: sessions even though it was a registered, documented command. The TUI was wired up correctly via the SessionPicker overlay (ui-tui/src/app/slash/commands/session.ts) and the gateway handles sessions browse (tui_gateway/server.py); only cli.py was missing.

Adds _handle_sessions_command() and an elif branch that routes to it. The classic CLI has no equivalent of the TUI's overlay primitive, so the no-arg behavior prints the same recent-sessions table that /resume already shows when called with no target. /sessions <id_or_title> delegates to _handle_resume_command() for behavioral parity with /resume.

Related Issue

No existing issue — discovered while users hit Unknown command: /sessions in the running CLI in v0.13.0.

Fixes the classic-CLI half of #20805 — that PR shipped the registry entry and TUI overlay but didn't wire the legacy process_command() dispatcher.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • cli.py: add _handle_sessions_command(cmd_original) method right after _handle_resume_command (lines 5921-5951)
  • cli.py: add elif canonical == "sessions" branch in process_command() next to the existing resume branch (line 7486-7487)
  • tests/cli/test_cli_init.py: four new regression tests in TestHistoryDisplay:
    • test_sessions_command_no_args_lists_recent_sessions — no-arg branch prints recent table via process_command() (locks in the dispatcher wiring)
    • test_sessions_list_subcommand_lists_recent_sessions/sessions list alias
    • test_sessions_with_target_delegates_to_resume/sessions <id>/resume <id>
    • test_sessions_command_is_dispatched — direct dispatcher-wiring assertion (catches the original regression even if all the inner handler logic is mocked out)

How to Test

  1. git checkout this branch, install editable, run hermes (classic CLI, not --tui).
  2. Type /sessions — should print the recent-sessions table, not Unknown command.
  3. Type /sessions list — same output as /sessions.
  4. Type /sessions <some-session-title-or-id> — should resume that session (same as /resume <…>).
  5. Run pytest tests/cli/test_cli_init.py -k sessions -q — six tests pass (the five new ones plus the existing test_resume_without_target_lists_recent_sessions which still passes unchanged).

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(cli):)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've run the relevant tests and they pass — pytest tests/cli/ tests/hermes_cli/test_session_browse.py tests/gateway/test_unknown_command.py -q → 718 passed
  • I've added regression tests
  • I've tested on my platform: macOS 26.4.1 (arm64), Python 3.11.14

Documentation & Housekeeping

  • No new config keys — N/A for cli-config.yaml.example
  • No architecture changes — N/A for CONTRIBUTING.md / AGENTS.md
  • Cross-platform: pure-Python dispatcher tweak, no platform-specific calls
  • Tool descriptions unaffected

Screenshots / Logs

Before (v0.13.0, classic CLI):

> /sessions
Unknown command: /sessions
Type /help for available commands

After (this PR):

> /sessions

  Recent sessions:

  Title                            Preview                                  Last Active   ID
  ─────────────────────────────── ──────────────────────────────────────── ───────────── ────────────────────────
  Checking Running Hermes Agent    check running gateways for hermes agent  2h ago        20260401_201329_d85961
  …

  Use /resume <session id or title> to continue where you left off.

The 'sessions' command has been registered in the central command
registry since NousResearch#20805 (May 2025) and surfaces in /help and tab-completion,
but the classic CLI's process_command() never had an elif branch for it.
The canonical name fell through and printed 'Unknown command: sessions'.
The TUI side was wired up correctly via the SessionPicker overlay; only
the legacy CLI was missing the dispatch.

Adds _handle_sessions_command() which mirrors /resume's no-arg behavior
inline (the CLI has no overlay primitive equivalent to the TUI picker):

- /sessions and /sessions list  → print the recent-sessions table
- /sessions <id_or_title>       → delegates to _handle_resume_command

Includes regression tests covering the dispatcher wiring (the original
bug) plus the three handler branches.
@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 May 13, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #23289 (and the broader /sessions wiring cluster: #22962, #24412, #23680). All wire the same elif canonical == "sessions" branch in process_command(). Canonical issue: #22951.

@explainanalyze

Copy link
Copy Markdown
Contributor Author

Surfacing the /sessions PR cluster for maintainer triage - five open PRs and a closed one all target the same wiring gap (canonical issue #22951):

PR Author Approach Notes
#21680 @liuhao1024 One-line alias sessions -> resume in hermes_cli/commands.py Smallest diff. Propagates to CLI dispatch, gateway, Telegram menu, Slack routing, autocomplete, and help for free. No new handler, no subcommand semantics.
#22962 @CalmProton New handler + dispatch in cli.py, also wires /indicator Bundles two fixes.
#23289 @LeonSGP43 New handler + dispatch in cli.py, also wires /indicator Author's local absolute paths leaked into PR body.
#24412 @Mind-Dragon New handler + dispatch, sessions only Already labeled duplicate.
#25231 (this) me New handler + dispatch, sessions only, four regression tests Latest, didn't catch the cluster before opening.
#23680 @rylena Mark /sessions CLI-only + wire dispatcher Closed by author May 13.

If the design intent is for /sessions to be a true alias of /resume, #21680 is the cleanest landing. If /sessions should grow its own semantics (list/browse subcommands distinct from resume), one of the dispatcher-branch PRs is the right shape.

Happy to close this if you'd like to consolidate around one of the others - just say which.

@teknium1

Copy link
Copy Markdown
Contributor

Salvaged into main as #25986 (#25986). Cherry-picked cleanly onto current main — your authorship preserved (git log shows phil.thomas@gametime.co). Also added you to scripts/release.py AUTHOR_MAP. Thanks for the fix — and the regression tests that lock the dispatcher wiring in place.

@teknium1

Copy link
Copy Markdown
Contributor

Salvaged via #25987 (merged commit d6c488f). Your commit was cherry-picked onto current main with your authorship preserved in git log — thanks for the clean fix and thorough regression tests. Both Discord users in #help (one on Windows, one in WSL) had hit Unknown command: /sessions; the dispatcher branch you added closes that gap.

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