Skip to content

fix(cli): preserve chat -q answer by gating exit-summary screen clear (salvage #53025) - #60926

Merged
teknium1 merged 2 commits into
mainfrom
salvage-53025
Jul 8, 2026
Merged

fix(cli): preserve chat -q answer by gating exit-summary screen clear (salvage #53025)#60926
teknium1 merged 2 commits into
mainfrom
salvage-53025

Conversation

@teknium1

@teknium1 teknium1 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Salvage of #53025 by @Tranquil-Flowhermes chat -q "<prompt>" no longer wipes the assistant's answer off the screen right after printing it. Fixes #53009.

Root cause: the single-query path calls _print_exit_summary() immediately after cli.chat(query), and that unconditionally ran _clear_terminal_on_exit() (ESC[3J ESC[2J ESC[H on a TTY) — erasing the just-printed answer and leaving only the exit summary.

Changes

  • cli.py: _print_exit_summary(clear_screen=True) — the single-query path passes clear_screen=False; interactive-exit behavior ([Bug]: Hermes Agent does not cleanly hand control back to CLI after session ends #38252) is unchanged
  • tests/cli/test_chat_q_exit_clear.py: new regression tests (contributor's)
  • Follow-up (ours): tests/cli/test_single_query_session_finalize.py — FakeCLI stub updated for the new kwarg (was TypeError-ing in the PR's CI)

Validation

Result
tests/cli/test_chat_q_exit_clear.py + test_single_query_session_finalize.py all pass
Premise verified on main wipe reproduced by reading cli.py:12748 / 16172

Contributor commit cherry-picked with authorship preserved (rebase-merge).

Infographic

chat-q-preserve

Tranquil-Flow and others added 2 commits July 8, 2026 06:38
…#53009)

In single-query (-q) mode, the assistant's final answer was printed and
then immediately erased by _print_exit_summary() — which unconditionally
called _clear_terminal_on_exit() (ESC[3J ESC[2J ESC[H]). The answer was
present in the session store but invisible in the terminal.

The clear is only needed for interactive TUI teardown (#38928) where
prompt_toolkit chrome must be cleaned up. Add a clear_screen parameter
to _print_exit_summary() (default True, preserving interactive behavior)
and pass False from the single-query call site so the answer stays
visible above the exit summary.

Regression tests cover:
- clear_screen=True (default) calls _clear_terminal_on_exit()
- clear_screen=False skips the clear
- Single-query -q path passes False end-to-end
- Interactive path still clears (preserving #38928)
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists labels Jul 8, 2026
@teknium1
teknium1 merged commit 58e1647 into main Jul 8, 2026
31 checks passed
@teknium1
teknium1 deleted the salvage-53025 branch July 8, 2026 14:59

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Comment (172 additions — preserve chat -q answer by gating exit-summary screen clear)

Scope

Fixes a bug where the -q answer would be cleared by the exit-summary screen. Salvage of #53025.

Observations

  • Adds gating logic to prevent exit-summary screen from clearing the answer.
  • The print() on line 43 appears in a CLI context for user feedback — appropriate.
  • Salvage PR referencing #53025 — good for reviewer context.

Recommendation

Looks reasonable. Human reviewer should confirm the salvage relationship and the fix scope.


Reviewed by Hermes Agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: chat -q final response is erased instantly by the exit-summary screen clear in a TTY

4 participants