🐛 fix(cli): wrap long approval commands in prompt

This commit is contained in:
墨綠BG 2026-05-01 20:29:32 +08:00 committed by Teknium
parent c7bee8f961
commit d6df38bb6b
2 changed files with 6 additions and 2 deletions

4
cli.py
View file

@ -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]] = []

View file

@ -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()