Skip to content

sbx exec -it does not propagate host terminal size to the sandbox PTY #63

@kkyr

Description

@kkyr

Summary

When attaching to a running sandbox with sbx exec -it, the PTY allocated inside the sandbox has no window size set. stty size returns 0 0 and the shell falls back to COLUMNS=80, causing prompts and TUIs to wrap incorrectly. Resizing the host terminal window after attach does not fix it — the new size is never propagated either. Passing -t/--tty explicitly (in addition to or instead of -it) makes no difference.

Reproduction

Using the base claude-code template (no customisation):

sbx run claude .
sbx exec -it claude-myproject bash

Inside the sandbox:

agent@claude-myproject:~/workspace$ stty size
0 0
agent@claude-myproject:~/workspace$ echo $COLUMNS
80

Now resize the iTerm window (drag a corner) and re-check — size is still wrong:

agent@claude-myproject:~/workspace$ stty size
0 0
agent@claude-myproject:~/workspace$ echo $COLUMNS
80

Same result with explicit --tty:

$ sbx exec -i --tty claude-myproject bash
agent@claude-myproject:~/workspace$ stty size
0 0

Expected behaviour

stty size inside the sandbox should report the host terminal's actual rows/cols, matching what stty size returns on the host. SIGWINCH should be forwarded when the host window is resized. This matches the behaviour of docker exec -it.

Actual behaviour

  • Initial PTY size is 0 0 (kernel TIOCGWINSZ returns zeros).
  • COLUMNS defaults to 80, LINES is unset.
  • Host window resize is not propagated — size remains 0 0.
  • Shells, prompts, and TUIs render as if on an 80-column terminal, causing visible wrapping (e.g. long prompts wrap mid-word).
  • -t / --tty is accepted but has no effect on this behaviour — a PTY is allocated, but with zero dimensions.

Impact

  • Interactive shells render incorrectly when the host terminal is wider/taller than 80x24.
  • TUIs (Claude Code, vim, tmux, less, etc.) cannot lay out correctly.
  • Workarounds require the user to manually run stty rows N cols N after every attach, which is fragile and doesn't handle subsequent resizes.

Environment

  • sbx version: 0.26.1
  • Host OS: macOS Tahoe 26.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions