Skip to content

persistent_output replay strips ANSI/Rich formatting after terminal resize #24017

@sherman-yang

Description

@sherman-yang

Summary

When display.persistent_output: true is set, terminal resize triggers
_recover_after_resizeerase_screen() + _replay_output_history().
The replayed content is plain text only — all Rich Markdown rendering
(tables, code blocks, bold, panels) is lost.

Root Cause

_record_output_history strips all ANSI escape codes before storing
(cli.py ~line 1416):

clean = _ANSI_CONTROL_RE.sub("", str(text)).replace("\r", "").rstrip("\n")

So the history buffer only contains raw text. When replayed, Rich-rendered
output (tables, borders, colors) is gone.

Additionally, _recover_after_resize sends \x1b[3J (erase saved lines),
which wipes the terminal's native scrollback buffer (including iTerm2),
leaving no fallback for the user to scroll up and see prior output.

Affected Config

display:
  final_response_markdown: render   # Rich Markdown enabled
  streaming: false                  # Rich Panel used for final response
  persistent_output: true

Expected Behavior

After resize, replayed history should preserve the same Rich formatting
that was originally rendered — or at minimum, not erase the terminal's
native scrollback (\x1b[3J) so the terminal's own scrollback buffer
(iTerm2, Warp, etc.) acts as a fallback.

Suggested Fix

Store rendered ANSI output in _OUTPUT_HISTORY (before stripping), and
replay with _pt_print(_PT_ANSI(entry)) instead of plain text.
Alternatively, skip \x1b[3J so the terminal's native scrollback
(iTerm2, Warp, etc.) acts as a fallback.

Environment

  • Hermes Agent v0.13.0 (2026.5.7)
  • macOS / iTerm2
  • Python 3.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/cliCLI entry point, hermes_cli/, setup wizardtype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions