From d6df38bb6b0a8c78dc6088427eeaeb668b05717b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E7=B6=A0BG?= Date: Fri, 1 May 2026 20:29:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(cli):=20wrap=20long=20approv?= =?UTF-8?q?al=20commands=20in=20prompt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cli.py | 4 +++- tests/cli/test_cli_approval_ui.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cli.py b/cli.py index 4ae4c6f7029..ab0b2ab774a 100644 --- a/cli.py +++ b/cli.py @@ -9629,7 +9629,7 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin): show_full = state.get("show_full", False) title = "⚠️ Dangerous Command" - cmd_display = command if show_full or len(command) <= 70 else command[:70] + '...' + cmd_display = command choice_labels = { "once": "Allow once", "session": "Allow for this session", @@ -9653,6 +9653,8 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin): # Pre-wrap the mandatory content — command + choices must always render. cmd_wrapped = _wrap_panel_text(cmd_display, inner_text_width) + if not show_full and "view" in choices and len(cmd_wrapped) > 4: + cmd_wrapped = cmd_wrapped[:3] + ["… (choose Show full command)"] # (choice_index, wrapped_line) so we can re-apply selected styling below choice_wrapped: list[tuple[int, str]] = [] diff --git a/tests/cli/test_cli_approval_ui.py b/tests/cli/test_cli_approval_ui.py index df7c06a2d00..aeae5d92af1 100644 --- a/tests/cli/test_cli_approval_ui.py +++ b/tests/cli/test_cli_approval_ui.py @@ -154,7 +154,9 @@ class TestCliApprovalUi: assert "Dangerous Command" not in lines[0] assert any("Dangerous Command" in line for line in lines[1:3]) assert "Show full command" in rendered - assert "githubcli-archive-keyring.gpg" not in rendered + assert "githubcli-archive-" in rendered + assert "keyring.gpg" in rendered + assert "status=progress" in rendered def test_approval_display_shows_full_command_after_view(self): cli = _make_cli_stub()