feat: Terminal Backend PTY Support#41
Open
guitarrapc wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new MiniPty.Terminal layer to provide a node-pty-shaped, push-based PTY backend suitable for xterm.js/editor integrations, while extending core MiniPty with exit-status + signal parity needed by those frontends.
Changes:
- Introduces
MiniPty.Terminal(PtyTerminalpush facade +PtyWebSocketBridgewith ACK/watermark flow control). - Extends core session lifecycle with
PtyExitStatus, Unix termination signal reporting (ExitStatus,WaitForExitStatusAsync), andKill(PtySignal). - Adds focused tests, a browser WebSocket sample (
WebTerminal), and updates docs/CI/packaging to include the new package and sample.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/MiniPty.Tests/PtyWebSocketBridgeTests.cs | Adds in-memory WebSocket bridge tests (framing, control messages, flow control, teardown). |
| tests/MiniPty.Tests/PtyTests.cs | Adds core tests for exit-status/signal reporting and signal-based kill semantics. |
| tests/MiniPty.Tests/PtyTerminalTests.cs | Adds tests for the push-based terminal facade ordering, pause/resume, and teardown semantics. |
| tests/MiniPty.Tests/MiniPty.Tests.csproj | References the new MiniPty.Terminal project from tests. |
| src/MiniPty/PtySignal.cs | Introduces PtySignal enum for cross-platform logical signal identifiers. |
| src/MiniPty/PtySession.cs | Adds ExitStatus, Kill(PtySignal), and WaitForExitStatusAsync. |
| src/MiniPty/PtyExitStatus.cs | Adds PtyExitStatus value type (exit code + optional Unix signal). |
| src/MiniPty/Internal/WindowsPtyBackend.cs | Implements ExitSignal (null) and Kill(PtySignal) validation/termination behavior. |
| src/MiniPty/Internal/UnixPtyBackend.cs | Captures termination signal from wait status, implements ExitSignal and Kill(PtySignal). |
| src/MiniPty/Internal/UnixInterop.cs | Adds Unix signal constants (HUP/INT/QUIT/TERM/USR1/USR2 variants). |
| src/MiniPty/Internal/IPtyBackend.cs | Extends backend contract with ExitSignal and Kill(PtySignal). |
| src/MiniPty.Terminal/PtyWebSocketBridge.cs | Adds the WebSocket bridge with protocol handling and teardown semantics. |
| src/MiniPty.Terminal/PtyTerminalOptions.cs | Adds terminal output handler delegate/options (backpressure via awaiting). |
| src/MiniPty.Terminal/PtyTerminal.cs | Adds push-based terminal facade with pause/resume and deterministic teardown. |
| src/MiniPty.Terminal/PtyBridgeOptions.cs | Adds bridge configuration (watermarks, caps, close timeouts) + validation. |
| src/MiniPty.Terminal/MiniPty.Terminal.csproj | New packable package project for the terminal backend. |
| src/MiniPty.Terminal/Internal/BridgeJson.cs | Source-generated STJ control-message parsing/serialization (AOT-safe). |
| src/MiniPty.Terminal/Internal/BridgeFlowControl.cs | Implements watermark/ACK flow control driving Pause/Resume. |
| scripts/pack-with-native.sh | Packs the new MiniPty.Terminal NuGet alongside existing packages. |
| samples/WebTerminal.cs | Adds browser demo + smoke mode for CI, using HttpListener + WebSocket bridge. |
| README.md | Documents new Terminal package, signal exit-status, and sample usage. |
| MiniPty.slnx | Adds MiniPty.Terminal to the solution. |
| .github/workflows/build.yaml | Adds WebTerminal to the NativeAOT publish/run sample loop. |
| .github/workflows/benchmark.yaml | Switches dotnet setup action usage for benchmark workflow. |
| .github/docs/specs/terminal.md | New spec describing terminal facade + WebSocket bridge protocol/flow control. |
| .github/docs/specs/lifecycle.md | Documents WaitForExitStatusAsync and Kill(PtySignal) lifecycle semantics. |
| .github/docs/specs/core_session.md | Adds exit-status/signal contract and updates use case 4 to use Terminal package. |
| .github/docs/specs/console.md | Updates console spec to point editor backend work to MiniPty.Terminal. |
| .github/docs/spec.md | Updates package map and implemented scope to include MiniPty.Terminal. |
| .github/docs/references/pty_crossplatform.md | Documents cross-platform signal kill + signal exit-status reporting behavior. |
| .github/docs/plans/plan_minipty_next.md | Records that editor backend parity items are now implemented. |
| .github/docs/plans/plan_editor_backend.md | Adds implemented plan/decision record for the editor/terminal backend. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MiniPty.Terminal, a terminal backend package for xterm.js and editor terminal integrations.PtyTerminalas a push-based PTY facade with output callbacks, completion ordering, input, resize, kill, and pause/resume flow control.PtyWebSocketBridgefor raw binary PTY I/O plus JSON control messages over WebSocket.Intent
MiniPty’s core session API is pull-based, while frontend terminals usually expect a node-pty-like backend shape. This PR adds that backend layer without changing the core PTY ownership model or adding third-party dependencies, while preserving NativeAOT compatibility.
Expected Behavior
Completionresolves.Pause()andResume()stop and resume output delivery without dropping data.resize,ack, and server-sideexitcontrol messages.