Skip to content

[codex] fix terminal dimension validation#2411

Merged
juliusmarminge merged 5 commits intomainfrom
t3code/terminal-startup-bug
Apr 30, 2026
Merged

[codex] fix terminal dimension validation#2411
juliusmarminge merged 5 commits intomainfrom
t3code/terminal-startup-bug

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented Apr 29, 2026

Summary

  • Raise the terminal dimension contract limits so valid xterm fit results from wide desktop windows are accepted.
  • Add a regression test for the reported cols: 423 startup size from issue [Bug]: #2395.

Root Cause

The desktop terminal opens by fitting xterm to the available drawer size and sending the resulting cols/rows to terminal.open. On wide Windows layouts, xterm can validly report more than 400 columns. The shared contract rejected cols: 423, so the server never created the terminal session. Follow-up input/resize calls then targeted a terminal thread that did not exist, producing the repeated Unknown terminal thread errors.

Fixes #2395.

Validation

  • bun run test src/terminal.test.ts from packages/contracts
  • bun fmt
  • bun lint
  • bun typecheck
  • bun run test

Note

Widen terminal dimension validation bounds in TerminalColsSchema and TerminalRowsSchema

Relaxes the accepted range for terminal dimensions to support ultrawide and non-standard terminal sizes. TerminalColsSchema now accepts 1–1000 (previously 20–400) and TerminalRowsSchema accepts 1–500 (previously 5–200).

Macroscope summarized 680951e.


Note

Low Risk
Small contract/test change that only broadens accepted numeric input ranges; low risk aside from potentially allowing unexpectedly large terminal allocations.

Overview
Relaxes terminal dimension validation in the shared contracts so terminal.open and terminal.resize accept much larger xterm fit results (cols 1–1000 vs 20–400, rows 1–500 vs 5–200).

Adds a regression test ensuring an ultrawide 423x40 open payload decodes successfully, and updates the invalid-bounds test to reflect the new minimum row constraint.

Reviewed by Cursor Bugbot for commit 680951e. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 28079194-c431-4018-a7e4-1a22926b0800

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/terminal-startup-bug

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Apr 29, 2026
@juliusmarminge juliusmarminge marked this pull request as ready for review April 29, 2026 23:58
- Allow smaller terminal dimensions on startup and resize
- Keep session/env schema limits aligned with runtime defaults
@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:XS 0-9 changed lines (additions + deletions). labels Apr 29, 2026
- Reflow terminal schema definitions
- Keep contract types and defaults unchanged
@juliusmarminge juliusmarminge enabled auto-merge (squash) April 29, 2026 23:59
@github-actions github-actions Bot added size:XS 0-9 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Apr 29, 2026
Comment thread packages/contracts/src/terminal.ts
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Apr 30, 2026

Approvability

Verdict: Approved

Simple validation relaxation to support ultrawide terminal dimensions. The change is permissive and self-contained with no security implications. The low-severity test coverage comment does not indicate a functional issue.

You can customize Macroscope's approvability policy. Learn more.

- Tighten terminal open validation in tests
- Cover startup bug where rows=0 should be invalid
- Simplify the sync decode helper signature
- Keep terminal contract tests aligned with current formatting
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Test no longer validates column bounds rejection
    • Changed cols from 10 (valid under relaxed schema min 1) to 0 (invalid) so the test now validates rejection of both column and row bounds.

Create PR

Preview
diff --git a/packages/contracts/src/terminal.test.ts b/packages/contracts/src/terminal.test.ts
--- a/packages/contracts/src/terminal.test.ts
+++ b/packages/contracts/src/terminal.test.ts
@@ -54,7 +54,7 @@ describe("TerminalOpenInput", () => {
       decodes(TerminalOpenInput, {
         threadId: "thread-1",
         cwd: "/tmp/project",
-        cols: 10,
+        cols: 0,
         rows: 0,
       }),
     ).toBe(false);

@@ -54,7 +54,7 @@ describe("TerminalOpenInput", () => {
       decodes(TerminalOpenInput, {
         threadId: "thread-1",
         cwd: "/tmp/project",
-        cols: 10,
+        cols: 0,
         rows: 0,
       }),
     ).toBe(false);

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 680951e. Configure here.

Comment thread packages/contracts/src/terminal.test.ts
@juliusmarminge juliusmarminge merged commit 02903f2 into main Apr 30, 2026
13 checks passed
@juliusmarminge juliusmarminge deleted the t3code/terminal-startup-bug branch April 30, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]:

1 participant