Skip to content

The agent that grows with you

fix(cli): treat GNU screen as a reflowing terminal

teknium19f288ba32a91
diff --git a/hermes_cli/cli_render.py b/hermes_cli/cli_render.py
index bb696ec084d..93a8e4310c3 100644
--- a/hermes_cli/cli_render.py
+++ b/hermes_cli/cli_render.py
@@ -546,25 +546,28 @@ def _ansi_drop_cells(line: str, cells: int) -> str:
return "".join(out)
-# Environment a terminal (or multiplexer) sets for its own children. Checked first: an xterm
+# Environment a terminal (or multiplexer) sets for its own children. A multiplexer is what the
+# CLI talks to, whatever terminal it runs in; after it, XTERM_VERSION is checked first: an xterm
# started from a VTE shell inherits VTE_VERSION but sets XTERM_VERSION itself.
-_NO_REFLOW_ENV = ("STY", "XTERM_VERSION")
-_REFLOW_ENV = ("TMUX", "VTE_VERSION", "KITTY_WINDOW_ID", "WT_SESSION", "KONSOLE_VERSION",
+_MULTIPLEXER_ENV = ("TMUX", "STY")
+_NO_REFLOW_ENV = ("XTERM_VERSION",)
+_REFLOW_ENV = ("VTE_VERSION", "KITTY_WINDOW_ID", "WT_SESSION", "KONSOLE_VERSION",
"ALACRITTY_WINDOW_ID", "WEZTERM_PANE", "GHOSTTY_RESOURCES_DIR")
_REFLOW_TERM_PROGRAMS = ("iTerm.app", "Apple_Terminal", "WezTerm", "vscode", "ghostty", "Tabby", "Hyper")
# TERM is all that survives ssh; these prefixes name terminals that truncate rows in place.
-_NO_REFLOW_TERM_PREFIXES = ("linux", "st", "screen", "mosh", "vt", "cons")
-_REFLOW_TERM_PREFIXES = ("tmux", "xterm-kitty", "alacritty", "foot", "xterm-ghostty", "wezterm", "contour")
+_NO_REFLOW_TERM_PREFIXES = ("linux", "st", "mosh", "vt", "cons")
+_REFLOW_TERM_PREFIXES = ("tmux", "screen", "xterm-kitty", "alacritty", "foot", "xterm-ghostty", "wezterm",
+ "contour")
def _terminal_reflows() -> bool | None:
"""Whether the terminal re-wraps the rows it shows when its width changes: ``True``
- (tmux, VTE, kitty, iTerm2, Terminal.app, WezTerm, Alacritty, Windows Terminal — a shrink
- pushes the rows that grew into scrollback), ``False`` (xterm, GNU screen, st, mosh, the
- Linux console keep every row in place, truncated) or ``None`` when nothing says (xterm or
- iTerm2 over ssh both look like ``TERM=xterm-256color``)."""
+ (tmux, GNU screen, VTE, kitty, iTerm2, Terminal.app, WezTerm, Alacritty, Windows Terminal —
+ a shrink pushes the rows that grew into scrollback), ``False`` (xterm, st, mosh, the Linux
+ console keep every row in place, truncated) or ``None`` when nothing says (xterm or iTerm2
+ over ssh both look like ``TERM=xterm-256color``)."""
env = os.environ
- if env.get("TMUX"):
+ if any(env.get(name) for name in _MULTIPLEXER_ENV):
return True
if any(env.get(name) for name in _NO_REFLOW_ENV):
return False