diff --git a/hermes_cli/claw.py b/hermes_cli/claw.py index e62efe47e..377609f40 100644 --- a/hermes_cli/claw.py +++ b/hermes_cli/claw.py @@ -541,7 +541,7 @@ def _cmd_cleanup(args): ) print_info("Stop OpenClaw first: systemctl --user stop openclaw-gateway.service") print() - if not auto_yes: + if not auto_yes and not dry_run: if not sys.stdin.isatty(): print_info("Non-interactive session — aborting. Stop OpenClaw and re-run.") return diff --git a/tests/hermes_cli/test_claw.py b/tests/hermes_cli/test_claw.py index e32c4a1df..ee8558f49 100644 --- a/tests/hermes_cli/test_claw.py +++ b/tests/hermes_cli/test_claw.py @@ -583,6 +583,33 @@ class TestCmdCleanup: assert not openclaw.exists() assert not clawdbot.exists() + def test_dry_run_still_shows_preview_when_running_in_non_interactive_session(self, tmp_path, capsys): + openclaw = tmp_path / ".openclaw" + openclaw.mkdir() + ws = openclaw / "workspace" + ws.mkdir() + (ws / "todo.json").write_text("{}") + + args = Namespace(source=None, dry_run=True, yes=False) + fake_stdin = MagicMock() + fake_stdin.isatty.return_value = False + + with ( + patch.object(claw_mod, "_find_openclaw_dirs", return_value=[openclaw]), + patch.object( + claw_mod, + "_detect_openclaw_processes", + return_value=["openclaw process(es) (PIDs: 1234)"], + ), + patch("sys.stdin", fake_stdin), + ): + claw_mod._cmd_cleanup(args) + + captured = capsys.readouterr() + assert "OpenClaw appears to be still running" in captured.out + assert "Non-interactive session — aborting" not in captured.out + assert "Would archive" in captured.out + # --------------------------------------------------------------------------- # _print_migration_report