From 7d36533aeb0fe4fd5680d3285ffbeb50f8908035 Mon Sep 17 00:00:00 2001 From: LeonSGP43 <154585401+LeonSGP43@users.noreply.github.com> Date: Mon, 4 May 2026 02:38:27 -0700 Subject: [PATCH] fix(pty): default TERM for resize probes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Preserve explicit caller overrides, but backfill a sensible default TERM=xterm-256color when missing or blank in the spawn env. CI often runs without TERM in the parent process, which makes terminal probes like 'tput cols' fail before winsize reads. Salvage of #15278's core code fix only — the test changes conflict with subsequent test refactors on main that now exercise TIOCGWINSZ directly instead of via 'tput'. Co-authored-by: LeonSGP43 <154585401+LeonSGP43@users.noreply.github.com> --- hermes_cli/pty_bridge.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hermes_cli/pty_bridge.py b/hermes_cli/pty_bridge.py index 9a8a73bad..66fdb4ac7 100644 --- a/hermes_cli/pty_bridge.py +++ b/hermes_cli/pty_bridge.py @@ -108,9 +108,14 @@ class PtyBridge: "(or pip install -e '.[pty]')." ) raise PtyUnavailableError("Pseudo-terminals are unavailable.") - # Let caller-supplied env fully override inheritance; if they pass - # None we inherit the server's env (same semantics as subprocess). - spawn_env = os.environ.copy() if env is None else env + # PTY-hosted programs expect TERM to describe the terminal type. + # CI often runs without TERM in the parent process, which makes + # simple terminal probes like `tput cols` fail before winsize reads. + # Preserve explicit caller overrides, but backfill a sensible default + # when TERM is missing or blank. + spawn_env = (os.environ.copy() if env is None else env.copy()) + if not spawn_env.get("TERM"): + spawn_env["TERM"] = "xterm-256color" proc = ptyprocess.PtyProcess.spawn( # type: ignore[union-attr] list(argv), cwd=cwd,