Skip to content

fix(tui): gate clampStdoutDimensions behind WSL detection (#35738) - #35766

Closed
irandoku wants to merge 1 commit into
NousResearch:mainfrom
irandoku:fix/warp-tui-layout
Closed

fix(tui): gate clampStdoutDimensions behind WSL detection (#35738)#35766
irandoku wants to merge 1 commit into
NousResearch:mainfrom
irandoku:fix/warp-tui-layout

Conversation

@irandoku

Copy link
Copy Markdown

Problem

clampStdoutDimensions() (PR #35657) patches process.stdout via Object.defineProperty to guard against bogus terminal dimensions (e.g. WSL's 131072×1). However, this breaks TUI layout in Warp terminal — the status bar and input prompt merge onto one line.

Root cause: Warp's process.stdout is not a standard Node TTY stream. The Object.defineProperty override changes how Ink reads terminal dimensions, causing the FlexBox layout inside AlternateScreen to miscalculate vertical space allocation.

Confirmed: WezTerm and other standard terminals are unaffected. Commenting out clampStdoutDimensions() fixes Warp.

Fixes #35738

Fix

Gate clampStdoutDimensions() behind WSL environment detection so it only runs where needed:

if (process.env.WSL_DISTRO_NAME || process.env.WSL_INTEROP) {
  clampStdoutDimensions()
}

Why this works:

  • WSL (the motivating case): WSL_DISTRO_NAME / WSL_INTEROP are always set → function runs → bogus 131072×1 is clamped ✅
  • Warp / WezTerm / Terminal.app / tmux: env vars unset → no patching → process.stdout untouched → layout works correctly ✅
  • No Ink core changes — the function and its behavior are preserved, just conditionally gated
  • No split-brain stdout identityprocess.stdout remains the canonical object everywhere

Testing

Environment WSL_DISTRO_NAME clampStdoutDimensions Result
WSL set ✅ runs 131072×1 clamped
Warp (macOS) unset ❌ skipped layout correct ✅ (verified by reporter)
WezTerm (macOS) unset ❌ skipped layout correct
macOS Terminal.app unset ❌ skipped layout correct
tmux in WSL set ✅ runs protected

Risk assessment

Minimal. The change is a 3-line conditional guard around an existing function. The function itself is unchanged. The only behavioral difference is that it no longer runs on non-WSL environments — which is the intended fix.

Cross-validated with Codex (GPT-5.5) which confirmed the approach is sound and identified that alternative approaches (replacing process.stdout with a proxy) would break Ink's instances.get(process.stdout) identity lookup.

…ch#35738)

clampStdoutDimensions() patches process.stdout via Object.defineProperty,
which breaks TUI layout in Warp terminal (status bar and input prompt
merge onto one line). Warp's process.stdout is not a standard Node TTY
stream, so the property descriptor override changes how Ink reads
terminal dimensions in alt-screen mode.

Gate the call behind WSL environment detection (WSL_DISTRO_NAME /
WSL_INTEROP) so the patch only runs where it's needed — WSL is the
environment that reports bogus dimensions (e.g. 131072x1).

Fixes NousResearch#35738
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels May 31, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing with #35764 which also fixes #35738. Both approaches gate clampStdoutDimensions() — this PR checks WSL env vars in entry.tsx, while #35764 checks TERM_PROGRAM via an extensible PROBLEMATIC_TERMINALS set in terminalDimensions.ts.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused Warp/WSL investigation. This is an automated hermes-sweeper review; the targeted behavior is already absent from current main.

@teknium1 teknium1 closed this Jul 13, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(tui): clampStdoutDimensions (#35657) breaks TUI layout in Warp terminal

3 participants