Skip to content

refactor(pty): no ipc/pty.ts barrel - #27798

Merged
OrcaWin merged 2 commits into
mainfrom
OrcaWin/p399-2-9
Oct 12, 2026
Merged

OrcaWin merged 2 commits into
mainfrom
OrcaWin/p399-2-9

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 135 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​334 $\color{#cf222e}{\Huge{\mathbf{−}}}$​206 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​128
Prod 33 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63 $\color{#cf222e}{\Huge{\mathbf{−}}}$​93 $\color{#cf222e}{\Huge{\mathbf{−}}}$​30

ELI5

src/main/ipc/pty.ts was a file that only re-exported names from about a dozen real terminal modules. Every caller now imports from the module that actually owns the name, and the pass-through file is gone.

What Changed

  • Deleted src/main/ipc/pty.ts (33 lines of re-exports). There was no logic in it.
  • 20 production files (startup, updater, daemon, orcad, worktree removal, window wiring) now import directly from ipc/pty/provider/registry, ipc/pty/kill-all, ipc/pty/register-handlers, ipc/pty/register-headless-runtime, ipc/pty/pane/key-state, ipc/pty/provider/state-cleanup, ipc/pty/provider/listener-lifecycle, ipc/pty/host-env/* and so on. This includes the two dynamic await import(...) calls in orcad.
  • Tests that called vi.mock on the barrel now mock the module the code under test really imports. The shared mock factories were split to match: ipcPty became ptyKillAll in the updater harness, ptyProviderRegistry and ptyListenerLifecycle in the daemon-init mocks, and ptyRegistryModuleMock and ptyStateCleanupModuleMock in the worktree mocks.
  • The SSH IPC tests mocked the barrel and reset three PTY mocks, but nothing in that graph imports PTY code since the SSH terminal stack was removed. That mock, its type slot and the resets are deleted. workspace-cleanup.test.ts had an empty vi.mock('./pty', () => ({})), which is deleted too.
  • The WSL hook-relay benchmark script, and two quit-teardown tests that list modules by path, now name the concrete modules.

Users see no difference. The same functions run in the same order; only the import paths changed.

Why

AGENTS.md and the Phase 3.99 design (K30) forbid barrels. Mocking a barrel hid which module a test really depended on. One example: the SSH tests kept stubbing PTY ownership for a code path that no longer exists. Mocking the owning module makes those dependencies visible.

I considered keeping one combined mock that covers several modules, but that hides the dependency again. Splitting each mock along module lines is what makes stale mocks like the SSH ones show up.

Net lines: production −21 (+47/−68), tests +119 (+349/−230). Nearly all of the test growth comes from one-line barrel mocks becoming two module mocks, which the formatter wraps across lines.

Linked Issue

Phase 3.99 cleanup, PR 2.9 (internal plan). No issue.

Visual Proof

N/A. This is an import-path refactor with no UI or behaviour change.

Testing

Dead-code proof: a resolver script followed every relative specifier in src, config, tests and mobile (this includes the @ts-nocheck files, vi.mock, vi.importActual and dynamic imports) and found 0 references to src/main/ipc/pty left. A string sweep also checked .github.

  • pnpm tc: clean

  • pnpm test on all 135 touched or affected test files: 1282 tests passed. This covers every rewritten vi.mock site plus tests/e2e/terminal-account-restart.unit.test.ts.

  • config/scripts/pr-e2e-gate-contract.test.mjs: passed. node --check on the benchmark script: passed.

  • pnpm run build:electron-vite, build:cli and build:orcad all succeed. orcad reports zero electron imports.

  • oxlint on changed files and pnpm run check:code-quality:changed: 0 new findings. pnpm lint: passed.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Independent read-only P0/P1 review run in parallel with self-review.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Cross-platform, SSH, mobile, wire: no runtime behaviour, wire format or platform branch changes. The module graph is the same set of modules minus one pass-through file.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 79cd7ce2-bac4-43b3-bd34-8fcc311df53c

📥 Commits

Reviewing files that changed from the base of the PR and between 57a7c22 and 4ba6cf3.


📒 Files selected for processing (168)
  • config/scripts/pr-e2e-gate-contract.test.mjs
  • config/scripts/wsl-hook-relay-reattach-benchmark-electron-stub.mjs
  • config/scripts/wsl-hook-relay-reattach-benchmark.mjs
  • src/main/daemon/daemon-entry-path-layouts.test.ts
  • src/main/daemon/daemon-init-child-readiness.test.ts
  • src/main/daemon/daemon-init-child-startup-failure.test.ts
  • src/main/daemon/daemon-init-dependency-mocks.ts
  • src/main/daemon/daemon-init-endpoint-adoption.test.ts
  • src/main/daemon/daemon-init-live-session-preservation.test.ts
  • src/main/daemon/daemon-init-macos-stable-launch-fallback.test.ts
  • src/main/daemon/daemon-init-packaged-bundle-staleness.test.ts
  • src/main/daemon/daemon-init-provider-installation.test.ts
  • src/main/daemon/daemon-init-replacement-reporting.test.ts
  • src/main/daemon/daemon-init-restart-sequence.test.ts
  • src/main/daemon/daemon-init-wedged-daemon-grace.test.ts
  • src/main/daemon/daemon-provider-census.test.ts
  • src/main/daemon/daemon-provider-init.ts
  • src/main/daemon/daemon-provider-restart.ts
  • src/main/daemon/daemon-provider-state.ts
  • src/main/ipc/pty-agent-launch-pane-attach.test.ts
  • src/main/ipc/pty-applied-size-reporting.test.ts
  • src/main/ipc/pty-buffer-snapshot-dispatch.test.ts
  • src/main/ipc/pty-codex-account-attribution.test.ts
  • src/main/ipc/pty-controller-owner-recovery.test.ts
  • src/main/ipc/pty-controller-ownership-routing.test.ts
  • src/main/ipc/pty-controller-process-inventory.test.ts
  • src/main/ipc/pty-controller-spawn-admission.test.ts
  • src/main/ipc/pty-cumulative-ack-accounting.test.ts
  • src/main/ipc/pty-daemon-controller-teardown.test.ts
  • src/main/ipc/pty-daemon-spawn-agent-home-env.test.ts
  • src/main/ipc/pty-daemon-spawn-codex-auth.test.ts
  • src/main/ipc/pty-daemon-spawn-session-identity.test.ts
  • src/main/ipc/pty-daemon-spawn-wsl-runtime.test.ts
  • src/main/ipc/pty-daemon-ssh-lease-lifecycle.test.ts
  • src/main/ipc/pty-dead-owner-respawn.test.ts
  • src/main/ipc/pty-delivery-health-heal.test.ts
  • src/main/ipc/pty-dispatcher-handshake-osc-answers.test.ts
  • src/main/ipc/pty-global-renderer-credit.test.ts
  • src/main/ipc/pty-hidden-at-spawn-mark.test.ts
  • src/main/ipc/pty-ipc-daemon-provider-fixtures.ts
  • src/main/ipc/pty-ipc-hidden-delivery-gate.test.ts
  • src/main/ipc/pty-ipc-producer-flow-control.test.ts
  • src/main/ipc/pty-ipc-provider-fixtures.ts
  • src/main/ipc/pty-ipc-spawn-drivers.ts
  • src/main/ipc/pty-ipc-suite-environment.ts
  • src/main/ipc/pty-launch-parity.test-fixture.ts
  • src/main/ipc/pty-launch-race-test-fixture.ts
  • src/main/ipc/pty-listener-teardown-and-orphans.test.ts
  • src/main/ipc/pty-login-shell-startup-commands.test.ts
  • src/main/ipc/pty-output-batching-drain.test.ts
  • src/main/ipc/pty-output-drain-rounds.test.ts
  • src/main/ipc/pty-pane-claim-arbitration.test.ts
  • src/main/ipc/pty-pane-materialization-race.test.ts
  • src/main/ipc/pty-pane-reservation-settlement.test.ts
  • src/main/ipc/pty-pane-restart-replace.test.ts
  • src/main/ipc/pty-pending-output-cap.test.ts
  • src/main/ipc/pty-persisted-incarnation-repair.test.ts
  • src/main/ipc/pty-renderer-inflight-credit.test.ts
  • src/main/ipc/pty-renderer-lifecycle-delivery-reset.test.ts
  • src/main/ipc/pty-renderer-liveness-guard.test.ts
  • src/main/ipc/pty-renderer-send-failure-recovery.test.ts
  • src/main/ipc/pty-reset-input-modes.test.ts
  • src/main/ipc/pty-restore-record-seeding.test.ts
  • src/main/ipc/pty-restored-appimage-cli-shim-refresh.test.ts
  • src/main/ipc/pty-runtime-hidden-at-spawn-mark.test.ts
  • src/main/ipc/pty-runtime-kill-and-exit.test.ts
  • src/main/ipc/pty-runtime-ssh-binding-persistence.test.ts
  • src/main/ipc/pty-serializer-settlement-mapping.test.ts
  • src/main/ipc/pty-session-liveness-and-ownership.test.ts
  • src/main/ipc/pty-spawn-codex-home-unavailable.test.ts
  • src/main/ipc/pty-spawn-cwd-fallback.test.ts
  • src/main/ipc/pty-spawn-env-codex-home-routing.test.ts
  • src/main/ipc/pty-spawn-env-codex-resume-provenance.test.ts
  • src/main/ipc/pty-spawn-env-terminal-basics.test.ts
  • src/main/ipc/pty-spawn-pi-owner-env.test.ts
  • src/main/ipc/pty-spawn-placement-threading.test.ts
  • src/main/ipc/pty-spawn-runtime-handle-binding.test.ts
  • src/main/ipc/pty-ssh-stop-verdict.test.ts
  • src/main/ipc/pty-startup-barrier-and-listing.test.ts
  • src/main/ipc/pty-startup-swap-window-presence.test.ts
  • src/main/ipc/pty-windows-shell-selection.test.ts
  • src/main/ipc/pty-write-ipc-validation.test.ts
  • src/main/ipc/pty-wsl-cwd-validation.test.ts
  • src/main/ipc/pty.ts
  • src/main/ipc/pty/register-without-renderer.test.ts
  • src/main/ipc/qoder-desktop-execution-host.test.ts
  • src/main/ipc/qoder-independent-renderer-spawn-review.test.ts
  • src/main/ipc/register-core-handlers/register-core-handlers.ts
  • src/main/ipc/ssh-app-shutdown.test.ts
  • src/main/ipc/ssh-connect-decision-cancellation.test.ts
  • src/main/ipc/ssh-disconnect-cancellation.test.ts
  • src/main/ipc/ssh-handler-reregistration.test.ts
  • src/main/ipc/ssh-ipc-mock-shapes.ts
  • src/main/ipc/ssh-ipc-module-mocks.ts
  • src/main/ipc/ssh-ipc-test-harness.ts
  • src/main/ipc/ssh-state-broadcast-fanout.test.ts
  • src/main/ipc/ssh-target-registry.test.ts
  • src/main/ipc/ssh.test.ts
  • src/main/ipc/workspace-cleanup.test.ts
  • src/main/ipc/worktrees-authoritative-local-metadata-pruning.test.ts
  • src/main/ipc/worktrees-background-removal.test.ts
  • src/main/ipc/worktrees-create-event-timing.test.ts
  • src/main/ipc/worktrees-create-metadata-persistence.test.ts
  • src/main/ipc/worktrees-delete-pty-teardown.test.ts
  • src/main/ipc/worktrees-detected-scan-cache.test.ts
  • src/main/ipc/worktrees-discovery-metadata-backfill.test.ts
  • src/main/ipc/worktrees-existing-branch-checkout.test.ts
  • src/main/ipc/worktrees-failed-removal.test.ts
  • src/main/ipc/worktrees-forget-local.test.ts
  • src/main/ipc/worktrees-issue-command-overrides.test.ts
  • src/main/ipc/worktrees-lineage-hydration.test.ts
  • src/main/ipc/worktrees-listing-fallback-rows.test.ts
  • src/main/ipc/worktrees-local-base-ref-resolution.test.ts
  • src/main/ipc/worktrees-local-create-flow.test.ts
  • src/main/ipc/worktrees-mutation-scan-generation-order.test.ts
  • src/main/ipc/worktrees-orphan-directory-cleanup.test.ts
  • src/main/ipc/worktrees-removal-recovery.test.ts
  • src/main/ipc/worktrees-remove-archive-hooks.test.ts
  • src/main/ipc/worktrees-remove-preflight.test.ts
  • src/main/ipc/worktrees-setup-launch-sparse-checkout.test.ts
  • src/main/ipc/worktrees-ssh-pr-head-fetch.test.ts
  • src/main/ipc/worktrees-ssh-repo-owner-resolution.test.ts
  • src/main/ipc/worktrees-test-module-mocks.ts
  • src/main/ipc/worktrees-windows.test.ts
  • src/main/ipc/worktrees-wsl-runtime-routing.test.ts
  • src/main/ipc/worktrees/removal/register-worktree-forget-handlers.ts
  • src/main/ipc/worktrees/removal/remove-folder-workspace.ts
  • src/main/ipc/worktrees/removal/worktree-removal-ownership.ts
  • src/main/local-builds/local-build-compatibility.ts
  • src/main/orcad/main-preflight-order.test.ts
  • src/main/orcad/orcad-entry.ts
  • src/main/orcad/orcad-managed-idle-exit-host.ts
  • src/main/orcad/orcad-managed-idle-exit-provider-race.test.ts
  • src/main/orcad/orcad-push-startup.test.ts
  • src/main/providers/provider-dispatch.test.ts
  • src/main/startup/codex-launch-preparation.ts
  • src/main/startup/headless-serve-ssh-registration.test.ts
  • src/main/startup/main-process-pty-startup.ts
  • src/main/startup/main-process-quit-pending-writer.test.ts
  • src/main/startup/main-process-quit-update-veto.test.ts
  • src/main/startup/main-process-quit.ts
  • src/main/startup/main-process-runtime-launch-activation.test.ts
  • src/main/startup/main-process-runtime-launch.ts
  • src/main/startup/main-process-runtime-service.ts
  • src/main/startup/synthetic-title-runtime.ts
  • src/main/updater-linux-package-recovery-actions.test.ts
  • src/main/updater-sqlite-profile-downgrade.test.ts
  • src/main/updater-test-harness.ts
  • src/main/updater.build-channel-selection.test.ts
  • src/main/updater.check-failure.test.ts
  • src/main/updater.check-preflight.test.ts
  • src/main/updater.check-settlement.test.ts
  • src/main/updater.feed-attempt-lifetime.test.ts
  • src/main/updater.headless-serve-install.test.ts
  • src/main/updater.install-failure-cause.test.ts
  • src/main/updater.linux-externally-managed.test.ts
  • src/main/updater.linux-root-package-install.test.ts
  • src/main/updater.mac-install.test.ts
  • src/main/updater.nudge-campaign.test.ts
  • src/main/updater.prerelease-fallback.test.ts
  • src/main/updater.publishing-window-feed.test.ts
  • src/main/updater.quit-and-install.test.ts
  • src/main/updater.startup-scheduling.test.ts
  • src/main/updater/updater-install-execution.ts
  • src/main/window/attach-main-window-services.test.ts
  • src/main/window/attach-main-window-services.ts
  • src/main/window/updater-package-recovery-ipc.test.ts
  • tests/e2e/terminal-account-restart.unit.test.ts

💤 Files with no reviewable changes (13)
  • src/main/ipc/ssh-disconnect-cancellation.test.ts
  • src/main/ipc/workspace-cleanup.test.ts
  • src/main/ipc/ssh.test.ts
  • src/main/ipc/ssh-ipc-module-mocks.ts
  • src/main/ipc/ssh-target-registry.test.ts
  • src/main/ipc/ssh-state-broadcast-fanout.test.ts
  • src/main/ipc/ssh-ipc-test-harness.ts
  • src/main/ipc/ssh-connect-decision-cancellation.test.ts
  • src/main/startup/headless-serve-ssh-registration.test.ts
  • src/main/ipc/ssh-app-shutdown.test.ts
  • src/main/ipc/pty.ts
  • src/main/ipc/ssh-handler-reregistration.test.ts
  • src/main/ipc/ssh-ipc-mock-shapes.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.



📝 Walkthrough

Walkthrough

The src/main/ipc/pty.ts re-export module was removed. Production code, tests, fixtures, and mock factories now import or mock PTY functionality through dedicated modules, including handler registration, provider registry, state cleanup, listener lifecycle, and kill-all modules. The WSL reattach benchmark now imports PTY registration and cleanup directly. Test behavior is otherwise described as unchanged.


Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 4ba6c

This change redirects PTY imports to their owning modules without changing the reviewed startup ordering. No material user-facing risk remains, so the PR is mergeable.

Pre-merge checks | Passed 4 | Inconclusive 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 50 files. (105 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the main change: removal of the src/main/ipc/pty.ts barrel.
Description check Passed The description is comprehensive. It covers the change, rationale, affected areas, testing, compatibility considerations, and checklist. It states that no linked issue exists, which is acceptable only…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 50 files. (105 skipped: 105 over the file limit.)


✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin merged commit aeffeb4 into main Oct 12, 2026
52 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