Refactor terminal architecture to use Pty Host pattern#352
Merged
gregpriday merged 1 commit intomainfrom Dec 2, 2025
Merged
Conversation
- Implement PtyClient stub in Main process for IPC communication - Create pty-host.ts UtilityProcess entry point with PtyManager/TerminalObserver - Define message protocol types for host-client IPC (shared/types/pty-host.ts) - Update main.ts to initialize PtyClient instead of direct PtyManager usage - Add TerminalManager union type to support both PtyManager and PtyClient - Fix transition-state callback resolution with request correlation IDs - Reset ready promise on host restart to prevent race conditions - Null child process reference on exit to prevent posting to dead port
Collaborator
Author
|
Terminal architecture refactor to Pty Host pattern disconnected the InputTracker service. Clear command detection (/clear, /new, /reset) broke. Fixed in #919. Regression audit for training data. |
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
This PR refactors the terminal architecture to use the Pty Host pattern, moving terminal management into a separate UtilityProcess for improved Main thread responsiveness and concurrent agent scalability.
Closes #350
Changes Made
Technical Details
Architecture: The new pattern isolates CPU-intensive terminal I/O and state analysis in a separate UtilityProcess, preventing Main thread blocking. PtyClient provides a drop-in replacement for PtyManager with the same synchronous API surface, but all operations are forwarded to the host via IPC.
Restart Handling: The client automatically restarts the host up to 3 times on crashes, with exponential backoff. Terminal spawns are tracked locally and respawned after successful restart.
IPC Protocol: Request/response pairs use correlation IDs to handle concurrent operations correctly. Health checks run every 30s to detect hung hosts.