Skip to content

Fix various issues around initial tty sizes + add test coverage#40722

Draft
OneBlue wants to merge 5 commits into
masterfrom
user/oneblue/tty-size-fix
Draft

Fix various issues around initial tty sizes + add test coverage#40722
OneBlue wants to merge 5 commits into
masterfrom
user/oneblue/tty-size-fix

Conversation

@OneBlue
Copy link
Copy Markdown
Collaborator

@OneBlue OneBlue commented Jun 5, 2026

Summary of the Pull Request

This change fixes various codepaths were the initial tty size of a command wouldn't be correctly set.

To change this properly, the tty size is now passed when a container is started, not created. This is required to properly support the wslc create, followed by wslc start -a case, since the tty size might be different between the create and start call.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Copilot AI review requested due to automatic review settings June 5, 2026 21:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to ensure the initial TTY size is applied correctly for container init/exec processes by moving TTY sizing to “start time” (rather than “create time”), and adds both unit and E2E coverage (including ConPTY/pseudoconsole scenarios) to validate sizing behavior and error handling.

Changes:

  • Introduces WSLCProcessStartOptions for passing TTY size (and detach keys) at container start/exec time, and threads TTY size through VM/root-namespace process creation.
  • Updates wslc console attach/relay flows to consistently configure interactive console mode and to pass console state through helpers.
  • Adds new TTY-size tests (invalid sizes rejected; expected size observed; pseudoconsole resize observed) across unit + E2E suites.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/windows/WSLCTests.cpp Adds unit coverage for invalid TTY sizes and correct init/exec TTY sizing; updates Start calls to use new start options.
test/windows/wslc/e2e/WSLCExecutor.h Adds PseudoConsole support and exposes stdout data + resize helpers for interactive sessions.
test/windows/wslc/e2e/WSLCExecutor.cpp Implements ConPTY-backed interactive runs, stdout snapshotting, and pseudoconsole resizing support.
test/windows/wslc/e2e/WSLCE2EHelpers.h Declares helper to validate pseudoconsole TTY sizing.
test/windows/wslc/e2e/WSLCE2EHelpers.cpp Implements retry-based verification of initial + resized TTY size via pseudoconsole output.
test/windows/wslc/e2e/WSLCE2EContainerRunTests.cpp Adds E2E test verifying container run -it respects initial/resized pseudoconsole size.
test/windows/wslc/e2e/WSLCE2EContainerExecTests.cpp Adds E2E test verifying container exec -it respects initial/resized pseudoconsole size.
src/windows/wslcsession/WSLCVirtualMachine.h Extends Linux process creation APIs to accept explicit TTY size.
src/windows/wslcsession/WSLCVirtualMachine.cpp Threads TTY size through process creation and PTY fork paths.
src/windows/wslcsession/WSLCSession.h Updates CreateRootNamespaceProcess signature to accept TTY size.
src/windows/wslcsession/WSLCSession.cpp Passes TTY size through to VM process creation.
src/windows/wslcsession/WSLCContainer.h Updates container Start/Exec APIs to take WSLCProcessStartOptions.
src/windows/wslcsession/WSLCContainer.cpp Uses start options for detach keys and sets console size on exec; resizes container TTY after start.
src/windows/wslcsession/ServiceProcessLauncher.cpp Passes stored rows/cols into VM process creation.
src/windows/wslc/services/SessionService.cpp Ensures interactive console mode is configured and passes console state into attach flow.
src/windows/wslc/services/ContainerService.cpp Computes and passes TTY size at start/exec time and threads console state through attach paths.
src/windows/wslc/services/ConsoleService.h Updates console attach/relay signatures to accept a ConsoleState&.
src/windows/wslc/services/ConsoleService.cpp Applies interactive mode configuration via passed-in ConsoleState.
src/windows/service/inc/wslc.idl Introduces WSLCProcessStartOptions and changes COM method signatures to accept it / pass TTY sizing separately.
src/windows/service/exe/PluginManager.cpp Updates call to new CreateRootNamespaceProcess signature.
src/windows/common/WSLCProcessLauncher.h Changes default TTY size defaults (24x80) and stores size separately from process options.
src/windows/common/WSLCProcessLauncher.cpp Moves TTY sizing into start options for exec/root namespace process creation.
src/windows/common/WslClient.cpp Ensures interactive mode is configured for debug shell console usage.
src/windows/common/WSLCContainerLauncher.h Exposes SetTtySize for container launcher.
src/windows/common/WSLCContainerLauncher.cpp Passes TTY size via start options when starting a created container.
src/windows/common/svccomm.cpp Ensures interactive mode is configured before reading console window size.
src/windows/common/ConsoleState.h Adds SetInteractiveMode() and tracks whether interactive config was applied.
src/windows/common/ConsoleState.cpp Splits interactive console configuration into an explicit method and improves state restoration semantics.

Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/service/inc/wslc.idl
Comment thread src/windows/wslc/services/ContainerService.cpp
Comment thread src/windows/wslc/services/ContainerService.cpp
Comment thread src/windows/wslcsession/WSLCContainer.cpp
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.

2 participants