The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): /undo typo no longer quits the CLI; +3 slash-command papercuts
Teknium3f67921fca59
diff --git a/cli.py b/cli.pyindex 93a6680fcc3..ee210f7905e 100644--- a/cli.py+++ b/cli.py@@ -11638,8 +11638,12 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):from hermes_state import SessionDBnew_title = SessionDB.sanitize_title(raw_title)except ValueError as e:+ # sanitize_title rejected the input (e.g. too long).+ # Print that one reason and stop — don't fall+ # through to the "empty after cleanup" branch and+ # print a second, contradictory error (SC-05)._cprint(f" {e}")- new_title = None+ return Trueif not new_title:_cprint(" Title is empty after cleanup. Please use printable characters.")elif self._session_db.get_session(self.session_id):@@ -11729,9 +11733,14 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):_undo_n = int(_undo_parts[1])except ValueError:print(f"(._.) Invalid count {_undo_parts[1]!r} — use /undo or /undo N.")- return+ return True # bad arg — command handled, keep the REPL aliveif _undo_n < 1:_undo_n = 1+ # Nothing to undo → say so immediately; don't pop a destructive+ # confirmation dialog for a guaranteed no-op (SC-06).+ if not self.conversation_history:+ print("(._.) No messages to undo.")+ return True_undo_desc = ("This removes the last user/assistant exchange from history."if _undo_n == 1diff --git a/hermes_cli/cli_commands_mixin.py b/hermes_cli/cli_commands_mixin.pyindex f3dcd7399fc..93b221fc595 100644--- a/hermes_cli/cli_commands_mixin.py+++ b/hermes_cli/cli_commands_mixin.py@@ -1048,7 +1048,7 @@ class CLICommandsMixin:session_meta = self._session_db.get_session(target_id)if not session_meta:_cprint(f" Session not found: {target}")- _cprint(" Use /history or `hermes sessions list` to see available sessions.")+ _cprint(" Use /sessions or `hermes sessions list` to see available sessions.")return# If the target is the empty head of a compression chain, redirect todiff --git a/hermes_cli/commands.py b/hermes_cli/commands.pyindex ee8eda30a4f..56624a16915 100644--- a/hermes_cli/commands.py+++ b/hermes_cli/commands.py@@ -263,7 +263,7 @@ COMMAND_REGISTRY: list[CommandDef] = [CommandDef("diff", "Show git changes in the working directory", "Info",args_hint="[staged|all|session] [--stat] [path...]",subcommands=("staged", "all", "session")),- CommandDef("verbose", "Cycle tool progress display: off -> new -> all -> verbose -> log",+ CommandDef("verbose", "Cycle tool progress display: off -> new -> all -> verbose","Configuration", cli_only=True,gateway_config_gate="display.tool_progress_command",busy_policy="dispatch"),diff --git a/tests/cli/test_slash_undo_title_robustness.py b/tests/cli/test_slash_undo_title_robustness.pynew file mode 100644index 00000000000..1a7d2181533--- /dev/null+++ b/tests/cli/test_slash_undo_title_robustness.py@@ -0,0 +1,55 @@+"""Regression tests for slash-command dispatch robustness (round-3 QA).++Covers:+- SC-01: `/undo <non-numeric>` must NOT quit the CLI (process_command returns+ True to keep the REPL alive), and must not raise.+- SC-06: `/undo` on an empty session reports "nothing to undo" without popping+ a destructive-confirmation dialog.+- SC-05: `/title <too-long>` prints exactly one error, not the contradictory+ "too long" + "empty after cleanup" pair.+"""++from unittest.mock import patch++from tests.cli.test_cli_init import _make_cli+++def test_undo_non_numeric_count_keeps_repl_alive():+ """`/undo abc` returned a bare None → REPL treated it as exit (SC-01)."""+ cli = _make_cli()+ cli.conversation_history = [+ {"role": "user", "content": "hi"},+ {"role": "assistant", "content": "hello"},+ ]+ # Must not raise, and must return True (truthy → REPL continues).+ result = cli.process_command("/undo abc")+ assert result is True+++def test_undo_empty_session_no_confirmation_dialog():+ """`/undo` with no history must short-circuit before the destructive prompt (SC-06)."""+ cli = _make_cli()+ cli.conversation_history = []++ called = {"confirm": False}++ def _spy_confirm(*a, **k):+ called["confirm"] = True+ return "approved"++ with patch.object(cli, "_confirm_destructive_slash", _spy_confirm):+ result = cli.process_command("/undo")++ assert result is True+ assert called["confirm"] is False # no confirmation for a guaranteed no-op+++def test_title_too_long_prints_single_error(capsys):+ """`/title <500 chars>` must print one error, not two contradictory ones (SC-05)."""+ cli = _make_cli()+ result = cli.process_command("/title " + "A" * 500)+ out = capsys.readouterr().out+ assert result is True+ # The length error should fire; the contradictory "empty after cleanup"+ # message must NOT also appear.+ assert "empty after cleanup" not in out.lower()