From 5704ebfdcec7f4a7f2421f51c565aba710d91831 Mon Sep 17 00:00:00 2001 From: eowca <4008965+eowca@users.noreply.github.com> Date: Thu, 26 Nov 2026 08:19:03 +0100 Subject: [PATCH] Print source-wait resume commands with the selected config Architecture-Review: unchanged; the timeout message changes while wait budgets and terminal verdicts are preserved. Co-Authored-By: Codex --- src/loopzero/cli.py | 21 ++++++++++++--------- tests/test_cli.py | 16 ++++++++-------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/loopzero/cli.py b/src/loopzero/cli.py index aed8f2c9..408d8b62 100644 --- a/src/loopzero/cli.py +++ b/src/loopzero/cli.py @@ -1320,7 +1320,7 @@ def _wait_with_deadline( allow_skipped=allow_skipped, initial=initial) deadline = started + timeout if time.monotonic() >= deadline: - _print_check_wait_timeout(pr) + _print_check_wait_timeout(pr, args) return None reported_timeout = False try: @@ -1331,17 +1331,20 @@ def _wait_with_deadline( reported_timeout = waited is None except github.ReadDeadline: if not reported_timeout: - _print_check_wait_timeout(pr) + _print_check_wait_timeout(pr, args) return None return waited -def _print_check_wait_timeout(pr: github.PR) -> None: - if pr.mergeable == "UNKNOWN": - print(f"timed out waiting for GitHub to compute mergeability on {pr.head_sha[:12]}") - else: - print(f"timed out waiting for required checks on {pr.head_sha[:12]}") - +def _print_check_wait_timeout(pr: github.PR, args: argparse.Namespace | None) -> None: + waiting_for = "GitHub to compute mergeability" if pr.mergeable == "UNKNOWN" else "required checks" + command = ["loopzero", args.command if args else "ready", "--wait"] + if args and args.config: + command.insert(1, f"--config={args.config}") + print( + f"timed out waiting for {waiting_for} on {pr.head_sha[:12]}. " + f"Run `{shlex.join(command)}` to resume on this head." + ) def _verify_wait_snapshot( args: argparse.Namespace | None, wt: Path, config: Config, head: str, current_head: str, @@ -1420,7 +1423,7 @@ def _wait_for_checks( f"triggers and permissions for head {pr.head_sha[:12]}; after correcting the cause, " "rerun the same `--wait` command" ) - _print_check_wait_timeout(current) + _print_check_wait_timeout(current, args) return None diff --git a/tests/test_cli.py b/tests/test_cli.py index ca25c35f..7acb2ef6 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -2554,7 +2554,7 @@ def test_wait_for_github_mergeability(wt, gh, capsys, monkeypatch, command, sett if settled == "CONFLICTING": assert code == 1 and "has merge conflicts" in out + err elif settled == "UNKNOWN": - assert code == 3 and "timed out waiting for GitHub to compute mergeability" in out + assert code == 3 and out.endswith(f"timed out waiting for GitHub to compute mergeability on {head[:12]}. Run `loopzero {command} --wait` to resume on this head.\n") else: assert code == (0 if command == "ready" else 3) assert requests == ([(REPO, 7, head, "main")] @@ -2642,12 +2642,12 @@ def sleep(seconds): clock += seconds monkeypatch.setattr(cli, "_sleep", sleep) - code, out, err = run(capsys, "ready", f"--wait={wait}") - + (wt / "-retry config.toml").write_bytes((wt / "workflow.toml").read_bytes()) + code, out, err = run(capsys, "--config", "./-retry config.toml", "ready", f"--wait={wait}") assert (code, err) == (expected, "") assert out.endswith({ 0: f"ready: {URL}\n", 1: f"not ready: required check 'checks' is failure{FAILED_CHECK_HINT}\n", - 3: f"timed out waiting for required checks on {head[:12]}\n", + 3: f"timed out waiting for required checks on {head[:12]}. Run `loopzero '--config=-retry config.toml' ready --wait` to resume on this head.\n", }[expected]) @@ -2732,7 +2732,7 @@ def advance(seconds): [30.0, 5.0] if initial_pending else [30.0]) assert out.endswith(f"ready: {URL}\n" if expected == 0 else f"not ready: required check 'checks' is failure{FAILED_CHECK_HINT}\n" if expected == 1 else - f"timed out waiting for required checks on {head[:12]}\n") + f"timed out waiting for required checks on {head[:12]}. Run `loopzero ready --wait` to resume on this head.\n") assert sum(c["argv"][:2] == ["pr", "ready"] for c in gh.calls) == 1 @@ -2813,7 +2813,7 @@ def advance(seconds): assert marked_at == [210.0] assert sleeps == [30.0, 60.0, 120.0, 30.0] + ([] if run_appears else [30.0, 30.0]) assert out.endswith(f"ready: {URL}\n" if run_appears else - f"timed out waiting for required checks on {head[:12]}\n") + f"timed out waiting for required checks on {head[:12]}. Run `loopzero ready --wait` to resume on this head.\n") assert sum(c["argv"][:2] == ["pr", "ready"] for c in gh.calls) == 1 @@ -3303,7 +3303,7 @@ def test_merge_wait_times_out_on_pending_checks_with_exit_three( code, out, err = run(capsys, "merge", "--wait=0") assert (code, err) == (3, "") - assert f"timed out waiting for required checks on {head[:12]}" in out + assert f"timed out waiting for required checks on {head[:12]}. Run `loopzero merge --wait` to resume on this head." in out assert wt.exists() and all(c["argv"][:2] != ["pr", "merge"] for c in gh.calls) @@ -3332,7 +3332,7 @@ def slow_check(argv, *, timeout, **kwargs): assert (code, err) == (3, "") assert budgets == pytest.approx([8.0]) - assert f"timed out waiting for required checks on {head[:12]}" in out + assert f"timed out waiting for required checks on {head[:12]}. Run `loopzero merge --wait` to resume on this head." in out assert all(c["argv"][:2] != ["pr", "merge"] for c in gh.calls)