Skip to content

fix(terminal): resize the shell when the screen size changes - #462

Open
Mayaskara25 wants to merge 1 commit into
yuga-hashimoto:mainfrom
Mayaskara25:fix/terminal-resize
Open

Mayaskara25 wants to merge 1 commit into
yuga-hashimoto:mainfrom
Mayaskara25:fix/terminal-resize

Conversation

@Mayaskara25

Copy link
Copy Markdown

Problem. The terminal's pty was sized once, when the shell started. Opening or closing the keyboard and rotating the phone left programs drawing for the wrong size; full-screen tools like Claude Code barely fit.

Cause. Java cannot resize the pty that script owns inside the sandbox, so stty ran once before the shell.

Fix. A small helper inside the sandbox reads rows columns lines from a named pipe in the shared workspace and applies them with stty -F. That makes the kernel send SIGWINCH to the foreground program, which redraws. The helper exits with the shell. ProcessTerminalSession.resize writes to the pipe without blocking. TerminalViewModel debounces size changes (150 ms), and the emulator follows the new width and height.

Testing. Tested on a Samsung Galaxy F41 (SM-F415F) with Codex 0.172.0 and Claude Code 2.1.332.

  • New tests in LocalTerminalLauncherTest, AnsiTerminalEmulatorTest and TerminalViewModelTest; all terminal tests pass.
  • On the device: stty size changes from 11 44 to 9 95 on rotation, and Codex's TUI fills the screen.

🤖 Generated with Claude Code

Opening the keyboard or rotating left programs drawing for the old size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant