Skip to content

feat: smooth terminal reflow on window resize (parity with opencode/Claude Code) #24164

@liw71750-dotcom

Description

@liw71750-dotcom

Problem

When resizing the terminal window, the classic CLI (non-TUI, Rich + prompt_toolkit based) does not reflow or re-render the conversation history to fit the new dimensions. This causes multiple visible artifacts:

  • Ghost/overlapping lines -- previous content remains at the old width
  • Broken table borders -- Rich tables are rendered at the stale width
  • Accumulated blank separator lines -- after each resize, extra blank lines pile up
  • Distorted scrollback -- when scrolling back through conversation history after a resize, formatting is misaligned
  • Status bar duplication -- the prompt/status area can appear as duplicate rows

In contrast, competitor tools handle this smoothly:

  • Claude Code -- uses full-screen alternate buffer with SIGWINCH-triggered complete re-render
  • Opencode -- recalculates layout on resize events, content reflows seamlessly
  • Both give an uninterrupted reading experience regardless of window size changes

Expected Behavior

Resizing the terminal should trigger a complete re-render of the entire conversation history and all active display elements (tables, messages, status bar) to fit the new viewport dimensions -- matching the smooth experience of opencode and Claude Code.

Additional Context

This issue is a tracking feature request that addresses the root cause. There are currently 34+ individual bug reports covering specific manifestations of this problem:

A comprehensive reflow solution would resolve all of these individual bugs.

Environment

  • macOS 26.4.1
  • Terminal: default (also reproduced in various terminal emulators)
  • Hermes Agent version: latest (main branch)

Suggested Approach

Investigate implementing a SIGWINCH signal handler that triggers a full re-render of the CLI display buffer, possibly by:

  1. Capturing the current conversation state
  2. Clearing the screen
  3. Re-rendering all content at the new terminal dimensions
  4. Preserving scrollback position where possible

For the Ink-based TUI mode (--tui), leverage React's re-render cycle with proper viewport dimensions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/cliCLI entry point, hermes_cli/, setup wizardcomp/tuiTerminal UI (ui-tui/ + tui_gateway/)type/featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions