Skip to content

fix: clamp terminal dimensions to positive integers in attach plan - #35

Open
adi-IL wants to merge 1 commit into
e2b-dev:mainfrom
adi-IL:fix/attach-dimension-guard
Open

fix: clamp terminal dimensions to positive integers in attach plan#35
adi-IL wants to merge 1 commit into
e2b-dev:mainfrom
adi-IL:fix/attach-dimension-guard

Conversation

@adi-IL

@adi-IL adi-IL commented Aug 31, 2026

Copy link
Copy Markdown

When planAttach is called with missing, zero, or negative pane dimensions (such as during headless runs or uninitialized window metrics), rec.terminalCols === pane.cols and the resize calculation can produce 0, negative, or NaN geometry entries.

This change:

  • Clamps cols and rows in planAttach to positive integers with fallback to standard default geometry (80x24) when pane dimensions are non-positive or undefined.
  • Clamps dims() in src/attach.js to ensure positive dimensions when reading process.stdout.columns and process.stdout.rows.
  • Adds unit tests in test/attach-plan.test.js covering missing, zero, negative, and single-row geometry.

Tests

node --test test/*.test.js
# 286 tests, 0 failures

bash test/cli.test.sh
# 299 tests, 0 failures

@cla-bot cla-bot Bot added the cla-signed label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant