The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(setup): let SSH wizard reset a saved port back to 22
beardthelionc347e50936f8
diff --git a/hermes_cli/setup_terminal.py b/hermes_cli/setup_terminal.pyindex f6e1f16da63..dceba1abf58 100644--- a/hermes_cli/setup_terminal.py+++ b/hermes_cli/setup_terminal.py@@ -243,6 +243,10 @@ def _setup_backend_ssh(config: dict) -> None:values.append(value)if value and (env_var != "TERMINAL_SSH_PORT" or value != "22"):_setup.save_env_value(env_var, value)+ elif env_var == "TERMINAL_SSH_PORT" and value == "22":+ # Answering the default must undo a previously saved non-default port:+ # skipping the save alone would leave the stale value in .env.+ _setup.remove_env_value(env_var)host, user, port, ssh_key = valuesif host and _setup.prompt_yes_no(" Test SSH connection?", True):_setup.print_info(" Testing connection...")diff --git a/tests/hermes_cli/test_setup_terminal.py b/tests/hermes_cli/test_setup_terminal.pynew file mode 100644index 00000000000..f127b7521d2--- /dev/null+++ b/tests/hermes_cli/test_setup_terminal.py@@ -0,0 +1,41 @@+"""Tests for hermes_cli/setup_terminal.py backend wizards."""++import pytest++from hermes_cli.config import save_env_value, get_env_value+from hermes_cli import setup as setup_mod+from hermes_cli import setup_terminal+++def ssh_wizard(tmp_path, monkeypatch):+ """Drive ``_setup_backend_ssh`` with scripted answers, SSH test declined."""+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ monkeypatch.delenv("TERMINAL_SSH_PORT", raising=False)++ def run(answers):+ it = iter(answers)+ monkeypatch.setattr(setup_mod, "prompt", lambda label, default="": next(it))+ monkeypatch.setattr(setup_mod, "prompt_yes_no", lambda label, default=True: False)+ setup_terminal._setup_backend_ssh({})++ return run+++def test_ssh_port_reset_to_22_removes_saved_port(ssh_wizard):+ # A stored non-default port must be removable: answering "22" restores the+ # default, it does not silently leave the old value in .env.+ save_env_value("TERMINAL_SSH_PORT", "2222")+ ssh_wizard(["host.example.com", "me", "22", "/tmp/key"])+ assert get_env_value("TERMINAL_SSH_PORT") is None+++def test_ssh_port_22_with_nothing_saved_stays_clean(ssh_wizard):+ ssh_wizard(["host.example.com", "me", "22", "/tmp/key"])+ assert get_env_value("TERMINAL_SSH_PORT") is None+++def test_ssh_port_non_default_still_saves(ssh_wizard):+ # Control: the deliberate skip is only for the default; a real port persists.+ ssh_wizard(["host.example.com", "me", "2222", "/tmp/key"])+ assert get_env_value("TERMINAL_SSH_PORT") == "2222"