mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(claw): preserve dry-run preview in non-interactive cleanup
This commit is contained in:
parent
77e04a29d5
commit
e722384ad9
2 changed files with 28 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue