From 36d1a39f7f78c12871dd11e1cb9dad6f12c704fc Mon Sep 17 00:00:00 2001 From: Dmitry Orlov Date: Thu, 30 Apr 2026 12:04:29 +0200 Subject: [PATCH 1/2] Fix ps ignoring --status filter when combined with -a/--all The --status flag was silently discarded when -a was used because the entire status-resolution block was guarded by `if not args.all`. Changed the default to None so explicit --status is always respected regardless of -a. --- contree_cli/cli/ps.py | 10 ++++++---- tests/test_ps.py | 7 +++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/contree_cli/cli/ps.py b/contree_cli/cli/ps.py index b6e5b00..778d00e 100644 --- a/contree_cli/cli/ps.py +++ b/contree_cli/cli/ps.py @@ -40,7 +40,7 @@ class PsArgs(ArgumentsProtocol): quiet: bool = False all: bool = False show_max: int | None = None - status: str = "EXECUTING" + status: str | None = None kind: str | None = None since: datetime | None = None until: datetime | None = None @@ -82,8 +82,8 @@ def setup_parser(p: argparse.ArgumentParser) -> SetupResult: p.add_argument( *FLAGS["status"], choices=tuple(itertools.chain.from_iterable(STATUS_CHOICES.items())), - default="EXECUTING", - help="Filter by status", + default=None, + help="Filter by status (default: active only, unless -a is used)", ) p.add_argument( *FLAGS["kind"], @@ -174,11 +174,13 @@ def cmd_ps(args: PsArgs) -> None: formatter: OutputFormatter = FORMATTER.get() status: str | None = None - if not args.all: + if args.status is not None: if len(args.status) == 1: status = STATUS_CHOICES.get(args.status, args.status) else: status = args.status + elif not args.all: + status = "EXECUTING" since: str | None = None if args.since is not None: diff --git a/tests/test_ps.py b/tests/test_ps.py index 31ec4b4..4d28204 100644 --- a/tests/test_ps.py +++ b/tests/test_ps.py @@ -182,6 +182,13 @@ def test_all_flag_no_status_param(self, contree_client): _run_cmd(contree_client, ops, all=True) assert "status=" not in contree_client.request_paths[0] + def test_all_with_explicit_status(self, contree_client, capsys): + """--all combined with --status sends the status filter.""" + ops = [_make_op(0, status="FAILED")] + _run_cmd(contree_client, ops, all=True, status="FAILED") + assert "status=FAILED" in contree_client.request_paths[0] + assert "op-0" in capsys.readouterr().out + @pytest.mark.parametrize( "short,full", list(STATUS_CHOICES.items()), From d4bc7e3f23a3e2b5d0e1977ec7f0b9c733b8a156 Mon Sep 17 00:00:00 2001 From: Mosquito Date: Thu, 30 Apr 2026 12:27:19 +0200 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- contree_cli/cli/ps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contree_cli/cli/ps.py b/contree_cli/cli/ps.py index 778d00e..2d593a2 100644 --- a/contree_cli/cli/ps.py +++ b/contree_cli/cli/ps.py @@ -83,7 +83,7 @@ def setup_parser(p: argparse.ArgumentParser) -> SetupResult: *FLAGS["status"], choices=tuple(itertools.chain.from_iterable(STATUS_CHOICES.items())), default=None, - help="Filter by status (default: active only, unless -a is used)", + help="Filter by status (default: EXECUTING only, unless -a is used)", ) p.add_argument( *FLAGS["kind"],