The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): /diff session counts every line the gateway left out
kshitijk4poorc6d646e4619a
diff --git a/hermes_cli/cli_commands_mixin.py b/hermes_cli/cli_commands_mixin.pyindex a2c6b48eb2b..3880edffaa2 100644--- a/hermes_cli/cli_commands_mixin.py+++ b/hermes_cli/cli_commands_mixin.py@@ -641,9 +641,9 @@ class CLICommandsMixin(CLICommandsSessionToolsMixin):"""Print a diff, capped at ``limit`` lines (of ``total`` when its sender cut it) with a pointer to the --stat form."""print()diff_lines = diff.splitlines()- if (total := max(total, len(diff_lines))) > limit:- self._print_diff_text("\n".join(diff_lines[:limit]))- print(f"\n {_t('diff.more_lines', count=total - limit, hint=stat_hint)}")+ if (total := max(total, len(diff_lines))) > len(shown := diff_lines[:limit]):+ self._print_diff_text("\n".join(shown))+ print(f"\n {_t('diff.more_lines', count=total - len(shown), hint=stat_hint)}")else:self._print_diff_text(diff)diff --git a/hermes_cli/cli_commands_session_tools.py b/hermes_cli/cli_commands_session_tools.pyindex c8c58770705..e67a2b7a8a5 100644--- a/hermes_cli/cli_commands_session_tools.py+++ b/hermes_cli/cli_commands_session_tools.py@@ -328,7 +328,7 @@ def print_session_diff(cli, result: dict, stat_only: bool) -> None:return print(f" {_t('diff.no_session_changes')}")if stat:cli._print_diff_text(f"\n{stat}")- if diff and not stat_only:+ if (diff or result.get("diff_lines")) and not stat_only: # a body cut to nothing still names its linescli._print_diff_body(diff, _t("diff.stat_hint_session"), total=int(result.get("diff_lines") or 0))diff --git a/tests/hermes_cli/test_gateway_cli_commands.py b/tests/hermes_cli/test_gateway_cli_commands.pyindex edbf2557824..b3f5d7e5fe3 100644--- a/tests/hermes_cli/test_gateway_cli_commands.py+++ b/tests/hermes_cli/test_gateway_cli_commands.py@@ -55,6 +55,21 @@ def test_diff_session_renders_the_gateway_sessions_checkpoint_diff(gateway_cli,assert "a.py | 450 +" in out and "+edited 0" not in out+def test_diff_session_counts_lines_the_gateway_cut_to_fit_its_frame(gateway_cli, capsys):+ """CLI-26: a body the gateway cut below 400 lines to fit one frame names every line not shown."""+ body = "\n".join(f"+edited {i}" for i in range(100))+ cli, _conn = gateway_cli(**{"rollback.session_diff": {+ "enabled": True, "success": True, "stat": " a.py | 5000 +", "diff": body, "diff_lines": 5000}})+ cli.process_command("/diff session")+ out = capsys.readouterr().out+ assert "+edited 99" in out and "4900 more lines" in out+ # One line too long for any frame leaves no body; the cut is still named.+ cli, _conn = gateway_cli(**{"rollback.session_diff": {+ "enabled": True, "success": True, "stat": " a.py | 1 +", "diff": "", "diff_lines": 3}})+ cli.process_command("/diff session")+ assert "3 more lines" in capsys.readouterr().out++def test_diff_session_reports_a_session_without_checkpoints(gateway_cli, capsys):cli, _conn = gateway_cli(**{"rollback.session_diff": {"enabled": False}})assert cli.process_command("/diff session") is True