exec: forward pty resize end-to-end (runtime + CLI)#83
Conversation
Add InitialTtySize and ResizeCh to runtime.ExecOptions (mirrored on devcontainer.ExecOptions) so callers driving an interactive exec can: - set the initial pty geometry at create time, matching the host terminal so curses apps don't render at 80x24 until first redraw - stream subsequent size updates for the lifetime of the exec, so resizing the terminal window reflows the in-container application Docker backend: pass ConsoleSize to ExecCreate and run a small goroutine that drains the resize channel into ExecResize daemon calls. The goroutine coalesces bursts (keeps only the latest size when several updates arrive between API round-trips) so a fast drag doesn't back up. Apple-container backend: out of scope for this commit; falls back to the no-resize behavior it already exhibits. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
\`devcontainer exec\` used to only put stdin into raw mode and forward stdio — every interactive program kept rendering at 80x24 regardless of the actual terminal size, and resizing the window did nothing. Wire the runtime resize plumbing now that it exists. setupTty grows into a ttyState struct carrying: - initial: term.GetSize at exec start → passed as InitialTtySize so the pty is created at the right geometry - resize: a channel fed by a SIGWINCH listener goroutine that emits the new size on every window-resize signal → passed as ResizeCh so the daemon resizes the pty in-flight - restore: cancels the SIGWINCH listener and restores cooked-mode stdin; always safe to call (no-op when tty is false) The goroutine bounds its lifetime on a context cancelled by restore, so it exits cleanly when Exec returns or the user Ctrl-Cs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR adds end-to-end support for terminal size initialization and dynamic resizing in exec operations. The runtime API gains a ChangesTTY Size and Resize Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Fixes terminal-resize misbehavior in `devcontainer exec`: interactive programs render at 80x24 until first redraw and ignore subsequent window resizes.
Two commits:
1. `runtime: forward pty resize through ExecContainer`
Adds `InitialTtySize` and `ResizeCh` to `runtime.ExecOptions` (mirrored on `devcontainer.ExecOptions`).
Docker backend:
Apple-container backend: out of scope here; falls back to the no-resize behavior it already exhibits.
2. `cli: forward SIGWINCH into exec resize channel`
`setupTty` becomes a `ttyState` struct carrying:
The listener goroutine binds its lifetime to a context cancelled by `restore`, so it exits cleanly when `Exec` returns or the user `Ctrl-C`s.
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit