Skip to content

feat(instance): pass terminal window size from Web UI to PTY - #11

Merged
linletian merged 3 commits into
developfrom
feature/passing-window-size
Mar 11, 2026
Merged

linletian merged 3 commits into
developfrom
feature/passing-window-size

Conversation

@linletian

Copy link
Copy Markdown
Owner

Summary

  • Add PTY support using github.com/creack/pty library
  • Implement window size propagation from Web UI to backend PTY
  • Add resize event handling in WebSocket connection
  • Frontend sends resize events with 100ms debouncing

This enables interactive programs (vim, less, tmux) to respond correctly when users resize the terminal in the Web UI.

Changes

  • go.mod/go.sum: Add pty dependency
  • internal/instance/manager.go: Use pty.Start(), add Resize method
  • internal/app/app.go: Parse and handle resize messages
  • internal/ui/static/index.html: Send resize events from xterm.js

Test plan

  • Start an instance and connect via WebSocket TTY
  • Resize browser window / terminal panel
  • Verify interactive programs see the new size (e.g., run vim and check :version output)

- Use pty.Start() instead of script command to enable true PTY
- Add Resize method to Manager for handling cols/rows updates
- Parse resize messages in WebSocket handler
- Frontend sends resize events with debouncing (100ms)

This enables interactive programs (vim, less, etc.) to respond
correctly when users resize the terminal in the Web UI.
Add three test cases:
- TestResize_InvalidParams: validates empty/whitespace id and invalid cols/rows
- TestResize_NotFound: validates error for nonexistent instance
- TestResize_Success: creates real PTY and verifies resize works correctly
@linletian
linletian force-pushed the feature/passing-window-size branch from 5322079 to 68afeee Compare March 11, 2026 13:59
Ubuntu CI doesn't have zsh installed, causing TestResize_Success to fail.
@linletian
linletian merged commit 1496293 into develop Mar 11, 2026
2 checks passed
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