Skip to content

Split monolithic PTY IPC module into organized submodules - #15172

Merged
AmethystLiang merged 14 commits into
mainfrom
split-ipc-pty
Aug 24, 2026
Merged

AmethystLiang merged 14 commits into
mainfrom
split-ipc-pty

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​574 $\color{#cf222e}{\Huge{\mathbf{−}}}$​49 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​525
Prod 76 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​10546 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8035 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2511

Problem

The PTY IPC handler module (src/main/ipc/pty.ts) grew to 8,007 lines, making it difficult to navigate, maintain, and test. Related functionality was scattered across one file instead of grouped by domain concern.

Solution

Refactored the monolithic module into ~70 focused submodules organized by concern:

  • delivery/ — PTY output delivery and backpressure
  • host-env/ — Spawn environment assembly and Codex home routing
  • ipc/ — Renderer IPC handlers (spawn, write, resize, inspect)
  • pane/ — Pane state and stable ownership
  • provider/ — PTY provider registry and lifecycle
  • runtime/ — Runtime PTY controller operations
  • session.ts — IPC session state and wiring

Each module is now a clear unit with single responsibility, imported only where needed. The main entry points (register-handlers.ts, register-headless-runtime.ts) wire dependencies.

Testing

  • Test file src/main/ipc/pty-startup-barrier-ordering.test.ts updated to read from split modules; assertion logic unchanged
  • No behavioral changes — refactor only

Checklist

  • This PR is small and focused
  • Before/after screenshots or videos: N/A (refactor only)
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path impact considered — no new platform code paths
  • pnpm lint passes (removed max-lines exclusion for pty.ts)

Loading
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