diff --git a/config/scripts/pr-e2e-gate-contract.test.mjs b/config/scripts/pr-e2e-gate-contract.test.mjs index df9c9cc4a60..476edee9bae 100644 --- a/config/scripts/pr-e2e-gate-contract.test.mjs +++ b/config/scripts/pr-e2e-gate-contract.test.mjs @@ -187,7 +187,7 @@ describe('PR E2E gate contract', () => { 'src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-test-harness.ts' ]) ).not.toContain('tests/e2e/paired-remote-terminal-materialization-reconnect.spec.ts') - expect(selectPrE2eSpecs(['src/main/ipc/pty.ts'])).not.toContain( + expect(selectPrE2eSpecs(['src/main/ipc/pty/register-handlers.ts'])).not.toContain( 'tests/e2e/paired-remote-terminal-materialization-reconnect.spec.ts' ) }) diff --git a/config/scripts/wsl-hook-relay-reattach-benchmark-electron-stub.mjs b/config/scripts/wsl-hook-relay-reattach-benchmark-electron-stub.mjs index 1cd45f2ade1..038fd6a7a7f 100644 --- a/config/scripts/wsl-hook-relay-reattach-benchmark-electron-stub.mjs +++ b/config/scripts/wsl-hook-relay-reattach-benchmark-electron-stub.mjs @@ -1,6 +1,6 @@ /** * Minimal `electron` module for wsl-hook-relay-reattach-benchmark.mjs, which loads the real - * src/main/ipc/pty.ts under plain node. Only the surfaces that main's PTY graph touches are + * src/main/ipc/pty/ handlers under plain node. Only the surfaces that main's PTY graph touches are * implemented; everything else stays undefined so an unexpected dependency fails loudly. */ import { homedir, tmpdir } from 'node:os' diff --git a/config/scripts/wsl-hook-relay-reattach-benchmark.mjs b/config/scripts/wsl-hook-relay-reattach-benchmark.mjs index b87c413eeb3..4856f76b514 100644 --- a/config/scripts/wsl-hook-relay-reattach-benchmark.mjs +++ b/config/scripts/wsl-hook-relay-reattach-benchmark.mjs @@ -287,7 +287,8 @@ async function main() { // Why: main's PTY graph reads app paths at import time; keep it inside a disposable directory. let userDataDir - let ptyIpc + let registerPtyHandlers + let killAllPty let cleanupPaths = [] let manager = null let staller = null @@ -302,8 +303,9 @@ async function main() { } }) // Why sequential: concurrent jiti.import calls can each instantiate the module graph, and two - // copies of wsl-hook-relay-manager.ts would leave pty.ts refreshing a singleton we never see. - ptyIpc = await jiti.import('../../src/main/ipc/pty.ts') + // copies of wsl-hook-relay-manager.ts would leave the PTY graph refreshing a singleton we never see. + ;({ registerPtyHandlers } = await jiti.import('../../src/main/ipc/pty/register-handlers.ts')) + ;({ killAllPty } = await jiti.import('../../src/main/ipc/pty/kill-all.ts')) const { WslHookRelayManager, wslHookRelayManager } = await jiti.import( '../../src/main/agent-hooks/wsl-hook-relay-manager.ts' ) @@ -318,7 +320,7 @@ async function main() { const { FLOATING_TERMINAL_WORKTREE_ID } = await jiti.import('../../src/shared/constants.ts') // Why: if jiti ever returns a second manager module, our monkey-patch would miss the singleton - // that ensureWslHookRelayForReattach (loaded via pty.ts) closes over — fail closed now. + // that ensureWslHookRelayForReattach (loaded via the PTY graph) closes over — fail closed now. const singletonProbe = [] const previousEnsure = wslHookRelayManager.ensureForDistro.bind(wslHookRelayManager) wslHookRelayManager.ensureForDistro = (probedDistro) => { @@ -331,7 +333,7 @@ async function main() { wslHookRelayManager.ensureForDistro = previousEnsure if (singletonProbe.length !== 1 || singletonProbe[0] !== '__bench-singleton-probe__') { throw new Error( - 'jiti duplicated the WSL hook-relay manager graph; reattach patch would not observe pty.ts' + 'jiti duplicated the WSL hook-relay manager graph; reattach patch would not observe the PTY spawn path' ) } @@ -354,9 +356,9 @@ async function main() { const relayRefreshes = [] let delivered = 0 - // Why: pty.ts refreshes through the production singleton, so route that singleton at the + // Why: the PTY spawn path refreshes through the production singleton, so route that singleton at the // benchmark-scoped manager instead of calling the reattach helper from here — a removed or - // mislocated integration call in pty.ts must fail this benchmark. + // mislocated integration call in the PTY spawn path must fail this benchmark. wslHookRelayManager.ensureForDistro = (refreshedDistro) => { relayRefreshes.push(refreshedDistro) manager?.ensureForDistro(refreshedDistro) @@ -367,7 +369,7 @@ async function main() { // hooks are on. This bench isolates the reattach call site (ensureWslHookRelayForReattach); // the manager's own hooks gate lives behind the ensureForDistro patch above, so it stays out // of the measurement — `manager` below resolves its own (enabled) managed-hook settings. - ptyIpc.registerPtyHandlers( + registerPtyHandlers( createRendererWindowStub(), runtime, undefined, @@ -520,7 +522,7 @@ async function main() { } finally { manager?.disposeAll() await staller?.stop() - ptyIpc?.killAllPty?.() + killAllPty?.() if (userDataDir) { rmSync(userDataDir, { recursive: true, force: true }) } diff --git a/src/main/daemon/daemon-entry-path-layouts.test.ts b/src/main/daemon/daemon-entry-path-layouts.test.ts index b960cbf9d8f..5e403488f6d 100644 --- a/src/main/daemon/daemon-entry-path-layouts.test.ts +++ b/src/main/daemon/daemon-entry-path-layouts.test.ts @@ -40,7 +40,8 @@ vi.mock('./client', () => moduleFactories.client()) vi.mock('./daemon-lifecycle-event', () => moduleFactories.daemonLifecycleEvent()) vi.mock('./daemon-spawner', () => moduleFactories.daemonSpawner()) vi.mock('./daemon-pty-adapter', () => moduleFactories.daemonPtyAdapter()) -vi.mock('../ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('../ipc/pty/provider/registry', () => moduleFactories.ptyProviderRegistry()) +vi.mock('../ipc/pty/provider/listener-lifecycle', () => moduleFactories.ptyListenerLifecycle()) const ASAR_APP_PATH = join('/packaged', 'resources', 'app.asar') const ASAR_UNPACKED_ENTRY = join( diff --git a/src/main/daemon/daemon-init-child-readiness.test.ts b/src/main/daemon/daemon-init-child-readiness.test.ts index 132e156534f..e3bc3dd767d 100644 --- a/src/main/daemon/daemon-init-child-readiness.test.ts +++ b/src/main/daemon/daemon-init-child-readiness.test.ts @@ -32,7 +32,8 @@ vi.mock('./client', () => moduleFactories.client()) vi.mock('./daemon-lifecycle-event', () => moduleFactories.daemonLifecycleEvent()) vi.mock('./daemon-spawner', () => moduleFactories.daemonSpawner()) vi.mock('./daemon-pty-adapter', () => moduleFactories.daemonPtyAdapter()) -vi.mock('../ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('../ipc/pty/provider/registry', () => moduleFactories.ptyProviderRegistry()) +vi.mock('../ipc/pty/provider/listener-lifecycle', () => moduleFactories.ptyListenerLifecycle()) describe('daemon-init: runRestartDaemon (7-step sequence)', () => { beforeEach(() => { diff --git a/src/main/daemon/daemon-init-child-startup-failure.test.ts b/src/main/daemon/daemon-init-child-startup-failure.test.ts index bfc229b3bf3..81f86f91b04 100644 --- a/src/main/daemon/daemon-init-child-startup-failure.test.ts +++ b/src/main/daemon/daemon-init-child-startup-failure.test.ts @@ -30,7 +30,8 @@ vi.mock('./client', () => moduleFactories.client()) vi.mock('./daemon-lifecycle-event', () => moduleFactories.daemonLifecycleEvent()) vi.mock('./daemon-spawner', () => moduleFactories.daemonSpawner()) vi.mock('./daemon-pty-adapter', () => moduleFactories.daemonPtyAdapter()) -vi.mock('../ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('../ipc/pty/provider/registry', () => moduleFactories.ptyProviderRegistry()) +vi.mock('../ipc/pty/provider/listener-lifecycle', () => moduleFactories.ptyListenerLifecycle()) describe('daemon-init: runRestartDaemon (7-step sequence)', () => { beforeEach(() => { diff --git a/src/main/daemon/daemon-init-dependency-mocks.ts b/src/main/daemon/daemon-init-dependency-mocks.ts index a76278a7a79..d70bc4a29e5 100644 --- a/src/main/daemon/daemon-init-dependency-mocks.ts +++ b/src/main/daemon/daemon-init-dependency-mocks.ts @@ -226,9 +226,11 @@ export function createDaemonInitModuleFactories(state: DaemonInitMockState) { daemonPtyAdapter: () => ({ DaemonPtyAdapter: MockDaemonPtyAdapter }), - ipcPty: () => ({ + ptyProviderRegistry: () => ({ getLocalPtyProvider: getLocalPtyProviderMock, - setLocalPtyProvider: setLocalPtyProviderMock, + setLocalPtyProvider: setLocalPtyProviderMock + }), + ptyListenerLifecycle: () => ({ unbindLocalProviderListeners: unbindLocalProviderListenersMock, rebindLocalProviderListeners: rebindLocalProviderListenersMock }), diff --git a/src/main/daemon/daemon-init-endpoint-adoption.test.ts b/src/main/daemon/daemon-init-endpoint-adoption.test.ts index 2222cec7e36..09cefa1adf9 100644 --- a/src/main/daemon/daemon-init-endpoint-adoption.test.ts +++ b/src/main/daemon/daemon-init-endpoint-adoption.test.ts @@ -44,7 +44,8 @@ vi.mock('./client', () => moduleFactories.client()) vi.mock('./daemon-lifecycle-event', () => moduleFactories.daemonLifecycleEvent()) vi.mock('./daemon-spawner', () => moduleFactories.daemonSpawner()) vi.mock('./daemon-pty-adapter', () => moduleFactories.daemonPtyAdapter()) -vi.mock('../ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('../ipc/pty/provider/registry', () => moduleFactories.ptyProviderRegistry()) +vi.mock('../ipc/pty/provider/listener-lifecycle', () => moduleFactories.ptyListenerLifecycle()) describe('daemon-init: runRestartDaemon (7-step sequence)', () => { beforeEach(() => { diff --git a/src/main/daemon/daemon-init-live-session-preservation.test.ts b/src/main/daemon/daemon-init-live-session-preservation.test.ts index d8f988112cb..58f0496ee1b 100644 --- a/src/main/daemon/daemon-init-live-session-preservation.test.ts +++ b/src/main/daemon/daemon-init-live-session-preservation.test.ts @@ -39,7 +39,8 @@ vi.mock('./client', () => moduleFactories.client()) vi.mock('./daemon-lifecycle-event', () => moduleFactories.daemonLifecycleEvent()) vi.mock('./daemon-spawner', () => moduleFactories.daemonSpawner()) vi.mock('./daemon-pty-adapter', () => moduleFactories.daemonPtyAdapter()) -vi.mock('../ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('../ipc/pty/provider/registry', () => moduleFactories.ptyProviderRegistry()) +vi.mock('../ipc/pty/provider/listener-lifecycle', () => moduleFactories.ptyListenerLifecycle()) describe('daemon-init: runRestartDaemon (7-step sequence)', () => { beforeEach(() => { diff --git a/src/main/daemon/daemon-init-macos-stable-launch-fallback.test.ts b/src/main/daemon/daemon-init-macos-stable-launch-fallback.test.ts index 45de6bf0992..2186b83972d 100644 --- a/src/main/daemon/daemon-init-macos-stable-launch-fallback.test.ts +++ b/src/main/daemon/daemon-init-macos-stable-launch-fallback.test.ts @@ -43,7 +43,8 @@ vi.mock('./client', () => moduleFactories.client()) vi.mock('./daemon-lifecycle-event', () => moduleFactories.daemonLifecycleEvent()) vi.mock('./daemon-spawner', () => moduleFactories.daemonSpawner()) vi.mock('./daemon-pty-adapter', () => moduleFactories.daemonPtyAdapter()) -vi.mock('../ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('../ipc/pty/provider/registry', () => moduleFactories.ptyProviderRegistry()) +vi.mock('../ipc/pty/provider/listener-lifecycle', () => moduleFactories.ptyListenerLifecycle()) vi.mock('./macos-daemon-launchd', async (importOriginal) => { const actual = await importOriginal() return { diff --git a/src/main/daemon/daemon-init-packaged-bundle-staleness.test.ts b/src/main/daemon/daemon-init-packaged-bundle-staleness.test.ts index 3d3578ba792..d89f3817e9a 100644 --- a/src/main/daemon/daemon-init-packaged-bundle-staleness.test.ts +++ b/src/main/daemon/daemon-init-packaged-bundle-staleness.test.ts @@ -40,7 +40,8 @@ vi.mock('./client', () => moduleFactories.client()) vi.mock('./daemon-lifecycle-event', () => moduleFactories.daemonLifecycleEvent()) vi.mock('./daemon-spawner', () => moduleFactories.daemonSpawner()) vi.mock('./daemon-pty-adapter', () => moduleFactories.daemonPtyAdapter()) -vi.mock('../ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('../ipc/pty/provider/registry', () => moduleFactories.ptyProviderRegistry()) +vi.mock('../ipc/pty/provider/listener-lifecycle', () => moduleFactories.ptyListenerLifecycle()) describe('daemon-init: runRestartDaemon (7-step sequence)', () => { beforeEach(() => { diff --git a/src/main/daemon/daemon-init-provider-installation.test.ts b/src/main/daemon/daemon-init-provider-installation.test.ts index 2de5fd5be84..4ab01e1fb87 100644 --- a/src/main/daemon/daemon-init-provider-installation.test.ts +++ b/src/main/daemon/daemon-init-provider-installation.test.ts @@ -47,7 +47,8 @@ vi.mock('./daemon-lifecycle-event', () => moduleFactories.daemonLifecycleEvent() vi.mock('./daemon-adoption-telemetry-event', () => moduleFactories.daemonAdoptionTelemetryEvent()) vi.mock('./daemon-spawner', () => moduleFactories.daemonSpawner()) vi.mock('./daemon-pty-adapter', () => moduleFactories.daemonPtyAdapter()) -vi.mock('../ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('../ipc/pty/provider/registry', () => moduleFactories.ptyProviderRegistry()) +vi.mock('../ipc/pty/provider/listener-lifecycle', () => moduleFactories.ptyListenerLifecycle()) describe('daemon-init: runRestartDaemon (7-step sequence)', () => { beforeEach(() => { diff --git a/src/main/daemon/daemon-init-replacement-reporting.test.ts b/src/main/daemon/daemon-init-replacement-reporting.test.ts index db5179840c2..aebf6384a63 100644 --- a/src/main/daemon/daemon-init-replacement-reporting.test.ts +++ b/src/main/daemon/daemon-init-replacement-reporting.test.ts @@ -42,7 +42,8 @@ vi.mock('./client', () => moduleFactories.client()) vi.mock('./daemon-lifecycle-event', () => moduleFactories.daemonLifecycleEvent()) vi.mock('./daemon-spawner', () => moduleFactories.daemonSpawner()) vi.mock('./daemon-pty-adapter', () => moduleFactories.daemonPtyAdapter()) -vi.mock('../ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('../ipc/pty/provider/registry', () => moduleFactories.ptyProviderRegistry()) +vi.mock('../ipc/pty/provider/listener-lifecycle', () => moduleFactories.ptyListenerLifecycle()) describe('daemon-init: runRestartDaemon (7-step sequence)', () => { beforeEach(() => { diff --git a/src/main/daemon/daemon-init-restart-sequence.test.ts b/src/main/daemon/daemon-init-restart-sequence.test.ts index 71417db986c..55f226b4bf2 100644 --- a/src/main/daemon/daemon-init-restart-sequence.test.ts +++ b/src/main/daemon/daemon-init-restart-sequence.test.ts @@ -40,7 +40,8 @@ vi.mock('./client', () => moduleFactories.client()) vi.mock('./daemon-lifecycle-event', () => moduleFactories.daemonLifecycleEvent()) vi.mock('./daemon-spawner', () => moduleFactories.daemonSpawner()) vi.mock('./daemon-pty-adapter', () => moduleFactories.daemonPtyAdapter()) -vi.mock('../ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('../ipc/pty/provider/registry', () => moduleFactories.ptyProviderRegistry()) +vi.mock('../ipc/pty/provider/listener-lifecycle', () => moduleFactories.ptyListenerLifecycle()) describe('daemon-init: runRestartDaemon (7-step sequence)', () => { beforeEach(() => { diff --git a/src/main/daemon/daemon-init-wedged-daemon-grace.test.ts b/src/main/daemon/daemon-init-wedged-daemon-grace.test.ts index 3c0f9ef8e43..f5bb209ac9e 100644 --- a/src/main/daemon/daemon-init-wedged-daemon-grace.test.ts +++ b/src/main/daemon/daemon-init-wedged-daemon-grace.test.ts @@ -40,7 +40,8 @@ vi.mock('./client', () => moduleFactories.client()) vi.mock('./daemon-lifecycle-event', () => moduleFactories.daemonLifecycleEvent()) vi.mock('./daemon-spawner', () => moduleFactories.daemonSpawner()) vi.mock('./daemon-pty-adapter', () => moduleFactories.daemonPtyAdapter()) -vi.mock('../ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('../ipc/pty/provider/registry', () => moduleFactories.ptyProviderRegistry()) +vi.mock('../ipc/pty/provider/listener-lifecycle', () => moduleFactories.ptyListenerLifecycle()) describe('daemon-init: runRestartDaemon (7-step sequence)', () => { beforeEach(() => { diff --git a/src/main/daemon/daemon-provider-census.test.ts b/src/main/daemon/daemon-provider-census.test.ts index 30aade980fd..0c6a4963355 100644 --- a/src/main/daemon/daemon-provider-census.test.ts +++ b/src/main/daemon/daemon-provider-census.test.ts @@ -1,6 +1,6 @@ import { afterEach, expect, it, vi } from 'vitest' -vi.mock('../ipc/pty', () => ({ setLocalPtyProvider: vi.fn() })) +vi.mock('../ipc/pty/provider/registry', () => ({ setLocalPtyProvider: vi.fn() })) import { DaemonPtyRouter } from './daemon-pty-router' import { createAdapter } from './daemon-pty-router-test-fixture' diff --git a/src/main/daemon/daemon-provider-init.ts b/src/main/daemon/daemon-provider-init.ts index 64e137952f2..dbfb91bd301 100644 --- a/src/main/daemon/daemon-provider-init.ts +++ b/src/main/daemon/daemon-provider-init.ts @@ -1,4 +1,5 @@ -import { getLocalPtyProvider, rebindLocalProviderListeners } from '../ipc/pty' +import { getLocalPtyProvider } from '../ipc/pty/provider/registry' +import { rebindLocalProviderListeners } from '../ipc/pty/provider/listener-lifecycle' import { isStartupDiagnosticsEnabled, logStartupDiagnostic } from '../startup/startup-diagnostics' import { checkDaemonHealth } from './daemon-health' import { collectPinnedDaemonVersions, pruneOldDaemonHosts } from './daemon-host-relocation' diff --git a/src/main/daemon/daemon-provider-restart.ts b/src/main/daemon/daemon-provider-restart.ts index 5c23c48ad22..203fcef7f15 100644 --- a/src/main/daemon/daemon-provider-restart.ts +++ b/src/main/daemon/daemon-provider-restart.ts @@ -1,4 +1,7 @@ -import { rebindLocalProviderListeners, unbindLocalProviderListeners } from '../ipc/pty' +import { + rebindLocalProviderListeners, + unbindLocalProviderListeners +} from '../ipc/pty/provider/listener-lifecycle' import { DegradedDaemonPtyProvider } from './degraded-daemon-pty-provider' import { cleanupFailedDaemonAdoption, diff --git a/src/main/daemon/daemon-provider-state.ts b/src/main/daemon/daemon-provider-state.ts index 14b76e2af7a..14044947543 100644 --- a/src/main/daemon/daemon-provider-state.ts +++ b/src/main/daemon/daemon-provider-state.ts @@ -1,4 +1,4 @@ -import { setLocalPtyProvider } from '../ipc/pty' +import { setLocalPtyProvider } from '../ipc/pty/provider/registry' import { DegradedDaemonPtyProvider } from './degraded-daemon-pty-provider' import { getDaemonRuntimeDir as getRuntimeDir } from './daemon-launch-paths' import { readDaemonPidRecord as readDaemonPidRecordAt } from './daemon-endpoint-incarnation' diff --git a/src/main/ipc/pty-agent-launch-pane-attach.test.ts b/src/main/ipc/pty-agent-launch-pane-attach.test.ts index 9f624dda440..77cc18fd860 100644 --- a/src/main/ipc/pty-agent-launch-pane-attach.test.ts +++ b/src/main/ipc/pty-agent-launch-pane-attach.test.ts @@ -1,7 +1,8 @@ import { afterEach, describe, expect, it, vi } from 'vitest' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { makePaneKey } from '../../shared/stable-pane-id' -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' import { resetAgentLaunchPanesForTests, trackRunningAgentLaunchPane diff --git a/src/main/ipc/pty-applied-size-reporting.test.ts b/src/main/ipc/pty-applied-size-reporting.test.ts index 87b8c5e086f..d87ca56055e 100644 --- a/src/main/ipc/pty-applied-size-reporting.test.ts +++ b/src/main/ipc/pty-applied-size-reporting.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it, vi } from 'vitest' import { onMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-buffer-snapshot-dispatch.test.ts b/src/main/ipc/pty-buffer-snapshot-dispatch.test.ts index 5be4194bc76..48cb2a5adf9 100644 --- a/src/main/ipc/pty-buffer-snapshot-dispatch.test.ts +++ b/src/main/ipc/pty-buffer-snapshot-dispatch.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it, vi } from 'vitest' import { onMock, spawnMock, trackMock, classifyErrorMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-codex-account-attribution.test.ts b/src/main/ipc/pty-codex-account-attribution.test.ts index 0e109a468e1..fd2c3ec3790 100644 --- a/src/main/ipc/pty-codex-account-attribution.test.ts +++ b/src/main/ipc/pty-codex-account-attribution.test.ts @@ -7,7 +7,8 @@ import { } from './pty-ipc-mock-registry' import { TEST_CODEX_HOME, TEST_CODEX_AUTH_JSON, TEST_MANAGED_ROOT } from './pty-ipc-test-constants' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-controller-owner-recovery.test.ts b/src/main/ipc/pty-controller-owner-recovery.test.ts index fe0dc938d6c..dfc334afca6 100644 --- a/src/main/ipc/pty-controller-owner-recovery.test.ts +++ b/src/main/ipc/pty-controller-owner-recovery.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it, vi } from 'vitest' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import type { AgentSessionOwnerBinding } from '../../shared/agent-session-host-authority' -import { clearProviderPtyState, setLocalPtyProvider } from './pty' +import { clearProviderPtyState } from './pty/provider/state-cleanup' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-controller-ownership-routing.test.ts b/src/main/ipc/pty-controller-ownership-routing.test.ts index d611a980e96..4c6f3c2401a 100644 --- a/src/main/ipc/pty-controller-ownership-routing.test.ts +++ b/src/main/ipc/pty-controller-ownership-routing.test.ts @@ -2,13 +2,10 @@ import { describe, expect, it, vi } from 'vitest' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import type { AgentSessionOwnerBinding } from '../../shared/agent-session-host-authority' import { LocalPtyProvider } from '../providers/local-pty-provider' -import { - registerPtyHandlers, - clearPtyOwnershipForConnection, - clearProviderPtyState, - setPtyOwnership, - setLocalPtyProvider -} from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { clearPtyOwnershipForConnection, clearProviderPtyState } from './pty/provider/state-cleanup' +import { setPtyOwnership } from './pty/provider/ownership-state' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-controller-process-inventory.test.ts b/src/main/ipc/pty-controller-process-inventory.test.ts index c0cfacaecfd..ab883f65ca9 100644 --- a/src/main/ipc/pty-controller-process-inventory.test.ts +++ b/src/main/ipc/pty-controller-process-inventory.test.ts @@ -53,7 +53,8 @@ vi.mock('../pi/titlebar-extension-service', () => ({ piTitlebarExtensionService: { buildPtyEnv: () => ({}), clearPty: vi.fn() } })) -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' import type { IPtyProvider, PtyProcessInfo } from '../providers/types' // The runtime's worktree.ps liveness refresh calls the aggregate inventory (no connectionId) diff --git a/src/main/ipc/pty-controller-spawn-admission.test.ts b/src/main/ipc/pty-controller-spawn-admission.test.ts index 65f5ba565c9..ed4356f6c6d 100644 --- a/src/main/ipc/pty-controller-spawn-admission.test.ts +++ b/src/main/ipc/pty-controller-spawn-admission.test.ts @@ -7,13 +7,10 @@ import { import { setupPtyIpcSuite } from './pty-ipc-test-harness' import type { AgentSessionOwnerBinding } from '../../shared/agent-session-host-authority' import { OrcaRuntimeService } from '../runtime/orca-runtime' -import { - registerPtyHandlers, - clearProviderPtyState, - setLocalPtyProvider, - isCurrentPtyExit, - restorePtyIncarnation -} from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { clearProviderPtyState } from './pty/provider/state-cleanup' +import { setLocalPtyProvider } from './pty/provider/registry' +import { isCurrentPtyExit, restorePtyIncarnation } from './pty/provider/ownership-state' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-cumulative-ack-accounting.test.ts b/src/main/ipc/pty-cumulative-ack-accounting.test.ts index 4761588606b..688081e6369 100644 --- a/src/main/ipc/pty-cumulative-ack-accounting.test.ts +++ b/src/main/ipc/pty-cumulative-ack-accounting.test.ts @@ -1,11 +1,9 @@ import { describe, expect, it, vi } from 'vitest' import { spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { - registerPtyHandlers, - getPtyRendererDeliveryDebugSnapshot, - setLocalPtyProvider -} from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { getPtyRendererDeliveryDebugSnapshot } from './pty/delivery/debug' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-daemon-controller-teardown.test.ts b/src/main/ipc/pty-daemon-controller-teardown.test.ts index 1fe6797ec72..3a964e61a74 100644 --- a/src/main/ipc/pty-daemon-controller-teardown.test.ts +++ b/src/main/ipc/pty-daemon-controller-teardown.test.ts @@ -1,6 +1,8 @@ import { describe, expect, it, vi } from 'vitest' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, setPtyOwnership, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setPtyOwnership } from './pty/provider/ownership-state' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-daemon-spawn-agent-home-env.test.ts b/src/main/ipc/pty-daemon-spawn-agent-home-env.test.ts index 48cff20c9dd..0ed74283181 100644 --- a/src/main/ipc/pty-daemon-spawn-agent-home-env.test.ts +++ b/src/main/ipc/pty-daemon-spawn-agent-home-env.test.ts @@ -9,7 +9,7 @@ import { delimiter, join } from 'node:path' import type { TuiAgent } from '../../shared/tui-agent' import { LEGACY_TERMINAL_SHIM_REMOTE_ENV_KEYS } from '../pty/legacy-terminal-shim-dir' import { wslHookRelayManager } from '../agent-hooks/wsl-hook-relay-manager' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-daemon-spawn-codex-auth.test.ts b/src/main/ipc/pty-daemon-spawn-codex-auth.test.ts index 0ecb8da064e..ec1b2a1a0bf 100644 --- a/src/main/ipc/pty-daemon-spawn-codex-auth.test.ts +++ b/src/main/ipc/pty-daemon-spawn-codex-auth.test.ts @@ -14,7 +14,8 @@ import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { createDaemonActiveProviderFixtures } from './pty-ipc-daemon-provider-fixtures' import { join } from 'node:path' import { SETUP_AGENT_SEQUENCE_STARTUP_COMMAND_ENV } from '../../shared/setup-agent-sequencing' -import { registerPtyHandlers, resolveCodexHomeAfterManagedAuthReadiness } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { resolveCodexHomeAfterManagedAuthReadiness } from './pty/host-env/codex-home' const consumerConfigHome = join(TEST_MANAGED_ROOT, 'opencode-consumer-config') diff --git a/src/main/ipc/pty-daemon-spawn-session-identity.test.ts b/src/main/ipc/pty-daemon-spawn-session-identity.test.ts index 1c0ddf590d2..dc288610945 100644 --- a/src/main/ipc/pty-daemon-spawn-session-identity.test.ts +++ b/src/main/ipc/pty-daemon-spawn-session-identity.test.ts @@ -2,7 +2,8 @@ import { describe, expect, it, vi } from 'vitest' import { openCodeClearPtyMock, piBuildPtyEnvMock, piClearPtyMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { createDaemonActiveProviderFixtures } from './pty-ipc-daemon-provider-fixtures' -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-daemon-spawn-wsl-runtime.test.ts b/src/main/ipc/pty-daemon-spawn-wsl-runtime.test.ts index cbeddb333cd..4cffc574dbc 100644 --- a/src/main/ipc/pty-daemon-spawn-wsl-runtime.test.ts +++ b/src/main/ipc/pty-daemon-spawn-wsl-runtime.test.ts @@ -7,7 +7,7 @@ import { } from './pty-ipc-daemon-provider-fixtures' import { delimiter, join } from 'node:path' import { _setWslCachesForTests } from '../wsl' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-daemon-ssh-lease-lifecycle.test.ts b/src/main/ipc/pty-daemon-ssh-lease-lifecycle.test.ts index d9538c92a86..9d93418448d 100644 --- a/src/main/ipc/pty-daemon-ssh-lease-lifecycle.test.ts +++ b/src/main/ipc/pty-daemon-ssh-lease-lifecycle.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it, vi } from 'vitest' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { TerminalIntentionalStops } from '../runtime/terminal-intentional-stops' -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-dead-owner-respawn.test.ts b/src/main/ipc/pty-dead-owner-respawn.test.ts index 7a72c0d53b4..e2a0123138f 100644 --- a/src/main/ipc/pty-dead-owner-respawn.test.ts +++ b/src/main/ipc/pty-dead-owner-respawn.test.ts @@ -3,7 +3,8 @@ import { withDurableRuntimeStore } from '../runtime/runtime-durable-store-fixtur import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { SessionNotFoundError } from '../daemon/daemon-errors' import { makePaneKey } from '../../shared/stable-pane-id' -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-delivery-health-heal.test.ts b/src/main/ipc/pty-delivery-health-heal.test.ts index 934a5bcdd37..3d646e975a1 100644 --- a/src/main/ipc/pty-delivery-health-heal.test.ts +++ b/src/main/ipc/pty-delivery-health-heal.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it, vi } from 'vitest' import { spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, getPtyRendererDeliveryDebugSnapshot } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { getPtyRendererDeliveryDebugSnapshot } from './pty/delivery/debug' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-dispatcher-handshake-osc-answers.test.ts b/src/main/ipc/pty-dispatcher-handshake-osc-answers.test.ts index 0753e637aec..977ee815219 100644 --- a/src/main/ipc/pty-dispatcher-handshake-osc-answers.test.ts +++ b/src/main/ipc/pty-dispatcher-handshake-osc-answers.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it, vi } from 'vitest' import { onMock, spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, getPtyRendererDeliveryDebugSnapshot } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { getPtyRendererDeliveryDebugSnapshot } from './pty/delivery/debug' import { _resetColorQueryReplyColorsForTest } from './pty/provider/registry' import { _resetPtyOwnerHostColorsForTest } from '../../shared/pty-owner-color-query-colors' import { _resetTerminalViewAttributesForTest } from '../runtime/terminal-view-attribute-store' diff --git a/src/main/ipc/pty-global-renderer-credit.test.ts b/src/main/ipc/pty-global-renderer-credit.test.ts index caeccfc572e..9194cb4b975 100644 --- a/src/main/ipc/pty-global-renderer-credit.test.ts +++ b/src/main/ipc/pty-global-renderer-credit.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it, vi } from 'vitest' import { spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, getPtyRendererDeliveryDebugSnapshot } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { getPtyRendererDeliveryDebugSnapshot } from './pty/delivery/debug' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-hidden-at-spawn-mark.test.ts b/src/main/ipc/pty-hidden-at-spawn-mark.test.ts index 240793eda1d..37d301d3af7 100644 --- a/src/main/ipc/pty-hidden-at-spawn-mark.test.ts +++ b/src/main/ipc/pty-hidden-at-spawn-mark.test.ts @@ -4,7 +4,7 @@ import { posixOnlyIt, makeDeferred } from './pty-ipc-test-constants' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { isHiddenRendererPty } from './pty-hidden-delivery-gate' import { OrcaRuntimeService } from '../runtime/orca-runtime' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' import { join } from 'node:path' // Why resolved rather than hardcoded: the wrapper tree is content-addressed. import { getShellReadyWrapperRoot } from '../providers/local-pty-shell-ready-wrapper-root' diff --git a/src/main/ipc/pty-ipc-daemon-provider-fixtures.ts b/src/main/ipc/pty-ipc-daemon-provider-fixtures.ts index 6d43b0dec35..c2068320dde 100644 --- a/src/main/ipc/pty-ipc-daemon-provider-fixtures.ts +++ b/src/main/ipc/pty-ipc-daemon-provider-fixtures.ts @@ -1,6 +1,7 @@ import { vi } from 'vitest' import type { TuiAgent } from '../../shared/tui-agent' -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' type IpcHandlerMap = Map unknown> diff --git a/src/main/ipc/pty-ipc-hidden-delivery-gate.test.ts b/src/main/ipc/pty-ipc-hidden-delivery-gate.test.ts index bfacfc96935..6ad9a5e4f94 100644 --- a/src/main/ipc/pty-ipc-hidden-delivery-gate.test.ts +++ b/src/main/ipc/pty-ipc-hidden-delivery-gate.test.ts @@ -2,7 +2,8 @@ import { describe, expect, it, vi } from 'vitest' import { spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { redactPtyIdForDiagnostics } from '../../shared/pty-delivery-diagnostics' -import { registerPtyHandlers, getPtyRendererDeliveryDebugSnapshot } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { getPtyRendererDeliveryDebugSnapshot } from './pty/delivery/debug' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-ipc-producer-flow-control.test.ts b/src/main/ipc/pty-ipc-producer-flow-control.test.ts index 53f45f2bcde..1c31d36167a 100644 --- a/src/main/ipc/pty-ipc-producer-flow-control.test.ts +++ b/src/main/ipc/pty-ipc-producer-flow-control.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it, vi } from 'vitest' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, getPtyRendererDeliveryDebugSnapshot } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { getPtyRendererDeliveryDebugSnapshot } from './pty/delivery/debug' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-ipc-provider-fixtures.ts b/src/main/ipc/pty-ipc-provider-fixtures.ts index 52346b44f2c..b0cf76d3a57 100644 --- a/src/main/ipc/pty-ipc-provider-fixtures.ts +++ b/src/main/ipc/pty-ipc-provider-fixtures.ts @@ -1,7 +1,8 @@ import { vi } from 'vitest' import type { Mock } from 'vitest' import type { AgentSessionOwnerBinding } from '../../shared/agent-session-host-authority' -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' import { makeDisposable } from './pty-ipc-test-constants' /** The node-pty process double plus the emitters that drive its registered handlers. */ diff --git a/src/main/ipc/pty-ipc-spawn-drivers.ts b/src/main/ipc/pty-ipc-spawn-drivers.ts index dde291ce072..1043bd4551e 100644 --- a/src/main/ipc/pty-ipc-spawn-drivers.ts +++ b/src/main/ipc/pty-ipc-spawn-drivers.ts @@ -1,6 +1,6 @@ import { vi } from 'vitest' import type { TuiAgent } from '../../shared/tui-agent' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' import { accessSyncMock, spawnMock, statSyncMock } from './pty-ipc-mock-registry' import { BUNDLED_CLI_PATH, BUNDLED_RESOURCES_PATH } from './pty-ipc-test-constants' diff --git a/src/main/ipc/pty-ipc-suite-environment.ts b/src/main/ipc/pty-ipc-suite-environment.ts index 949c1486f2d..9c1409214f8 100644 --- a/src/main/ipc/pty-ipc-suite-environment.ts +++ b/src/main/ipc/pty-ipc-suite-environment.ts @@ -51,7 +51,7 @@ import { LocalPtyProvider, _resetLocalPtyProviderStateForTest } from '../providers/local-pty-provider' -import { setLocalPtyProvider } from './pty' +import { setLocalPtyProvider } from './pty/provider/registry' import { _resetHiddenRendererPtyDeliveryGateForTest } from './pty-hidden-delivery-gate' import { __resetShellStartupEnvCache } from '../pty/shell-startup-env' import { _resetWslCachesForTests } from '../wsl' diff --git a/src/main/ipc/pty-launch-parity.test-fixture.ts b/src/main/ipc/pty-launch-parity.test-fixture.ts index f17206d7b26..4d95133eb21 100644 --- a/src/main/ipc/pty-launch-parity.test-fixture.ts +++ b/src/main/ipc/pty-launch-parity.test-fixture.ts @@ -3,7 +3,7 @@ // through the runtime controller registerPtyHandlers installs. Suites still declare the IPC vi.mock block. import { vi } from 'vitest' import type { Mock } from 'vitest' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' import { existsSyncMock, statSyncMock } from './pty-ipc-mock-registry' import type { PtyIpcSuiteFixtures } from './pty-ipc-test-harness' import { OrcaRuntimeService } from '../runtime/orca-runtime' diff --git a/src/main/ipc/pty-launch-race-test-fixture.ts b/src/main/ipc/pty-launch-race-test-fixture.ts index 471030bec8a..a83b328dcef 100644 --- a/src/main/ipc/pty-launch-race-test-fixture.ts +++ b/src/main/ipc/pty-launch-race-test-fixture.ts @@ -1,7 +1,7 @@ import { vi, type Mock } from 'vitest' import { makePaneKey } from '../../shared/stable-pane-id' import { WORKTREE_TERMINALS_SLEEPING_ERROR } from '../runtime/worktree-terminals-sleeping-error' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' type IpcHandlerMap = Map unknown> type LaunchRaceSpawnReply = { diff --git a/src/main/ipc/pty-listener-teardown-and-orphans.test.ts b/src/main/ipc/pty-listener-teardown-and-orphans.test.ts index 470582f3561..6302ce489f7 100644 --- a/src/main/ipc/pty-listener-teardown-and-orphans.test.ts +++ b/src/main/ipc/pty-listener-teardown-and-orphans.test.ts @@ -8,7 +8,8 @@ import { } from './pty-ipc-mock-registry' import { posixOnlyIt, makeDisposable } from './pty-ipc-test-constants' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, setLocalPtyProvider, getLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider, getLocalPtyProvider } from './pty/provider/registry' import { join } from 'node:path' // Why resolved rather than hardcoded: the wrapper tree is content-addressed. import { getShellReadyWrapperRoot } from '../providers/local-pty-shell-ready-wrapper-root' diff --git a/src/main/ipc/pty-login-shell-startup-commands.test.ts b/src/main/ipc/pty-login-shell-startup-commands.test.ts index a89aca38ea5..c75268e1109 100644 --- a/src/main/ipc/pty-login-shell-startup-commands.test.ts +++ b/src/main/ipc/pty-login-shell-startup-commands.test.ts @@ -8,7 +8,7 @@ import { posixOnlyIt } from './pty-ipc-test-constants' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { userInfo } from 'node:os' import { resetMacosLoginShellPreflightForTests } from '../providers/macos-tcc-login-shell' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' import { join } from 'node:path' import { POSIX_SHELL_STARTUP_COMMAND_ENV } from '../pty/posix-shell-startup-command' // Why resolved rather than hardcoded: the wrapper tree is content-addressed. @@ -192,7 +192,8 @@ describe('registerPtyHandlers', () => { try { await spawnAndGetCall({ cwd: '/tmp', command: 'echo hello' }) - const { getBashShellReadyRcfileContent } = await import('./pty') + const { getBashShellReadyRcfileContent } = + await import('../providers/local-pty-shell-ready-bash-rcfile') const bashRcContent = getBashShellReadyRcfileContent() expect(bashRcContent).toContain('source "$HOME/.bash_profile"') expect(bashRcContent).not.toContain('source "$HOME/.bashrc"') diff --git a/src/main/ipc/pty-output-batching-drain.test.ts b/src/main/ipc/pty-output-batching-drain.test.ts index 2a515e2634b..013e6d492a5 100644 --- a/src/main/ipc/pty-output-batching-drain.test.ts +++ b/src/main/ipc/pty-output-batching-drain.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it, vi } from 'vitest' import { spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-output-drain-rounds.test.ts b/src/main/ipc/pty-output-drain-rounds.test.ts index 29e0a7ffeba..94944b9011b 100644 --- a/src/main/ipc/pty-output-drain-rounds.test.ts +++ b/src/main/ipc/pty-output-drain-rounds.test.ts @@ -1,11 +1,11 @@ import { describe, expect, it, vi } from 'vitest' import { spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' +import { registerPtyHandlers } from './pty/register-handlers' import { - registerPtyHandlers, getPtyRendererDeliveryDebugSnapshot, resetPtyRendererDeliveryDebug -} from './pty' +} from './pty/delivery/debug' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-pane-claim-arbitration.test.ts b/src/main/ipc/pty-pane-claim-arbitration.test.ts index 50516ec3398..127b310e2d8 100644 --- a/src/main/ipc/pty-pane-claim-arbitration.test.ts +++ b/src/main/ipc/pty-pane-claim-arbitration.test.ts @@ -3,12 +3,10 @@ import { spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { makePaneKey } from '../../shared/stable-pane-id' import { OrcaRuntimeService } from '../runtime/orca-runtime' -import { - registerPtyHandlers, - clearProviderPtyState, - setLocalPtyProvider, - isCurrentPtyExit -} from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { clearProviderPtyState } from './pty/provider/state-cleanup' +import { setLocalPtyProvider } from './pty/provider/registry' +import { isCurrentPtyExit } from './pty/provider/ownership-state' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-pane-materialization-race.test.ts b/src/main/ipc/pty-pane-materialization-race.test.ts index e9c2938f53d..0ddb8574429 100644 --- a/src/main/ipc/pty-pane-materialization-race.test.ts +++ b/src/main/ipc/pty-pane-materialization-race.test.ts @@ -6,7 +6,9 @@ import { } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { makePaneKey } from '../../shared/stable-pane-id' -import { registerPtyHandlers, getPtyIdForPaneKey, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { getPtyIdForPaneKey } from './pty/pane/key-state' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-pane-reservation-settlement.test.ts b/src/main/ipc/pty-pane-reservation-settlement.test.ts index 7e67d8a9d55..78a0c2fdfde 100644 --- a/src/main/ipc/pty-pane-reservation-settlement.test.ts +++ b/src/main/ipc/pty-pane-reservation-settlement.test.ts @@ -2,7 +2,8 @@ import { describe, expect, it, vi } from 'vitest' import { spawnMock, registerPtyMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { makePaneKey } from '../../shared/stable-pane-id' -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-pane-restart-replace.test.ts b/src/main/ipc/pty-pane-restart-replace.test.ts index 80d52dbeecc..0b83bae43ee 100644 --- a/src/main/ipc/pty-pane-restart-replace.test.ts +++ b/src/main/ipc/pty-pane-restart-replace.test.ts @@ -3,7 +3,8 @@ import { describe, expect, it, vi } from 'vitest' import { setupPtyIpcSuite, type PtyIpcSuiteFixtures } from './pty-ipc-test-harness' import { TerminalKilledError } from '../daemon/daemon-pty-lifecycle-errors' import { makePaneKey } from '../../shared/stable-pane-id' -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' import { TerminalIntentionalStops } from '../runtime/terminal-intentional-stops' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) diff --git a/src/main/ipc/pty-pending-output-cap.test.ts b/src/main/ipc/pty-pending-output-cap.test.ts index 390abc3ef9c..0416719e8e8 100644 --- a/src/main/ipc/pty-pending-output-cap.test.ts +++ b/src/main/ipc/pty-pending-output-cap.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it, vi } from 'vitest' import { spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, getPtyRendererDeliveryDebugSnapshot } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { getPtyRendererDeliveryDebugSnapshot } from './pty/delivery/debug' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-persisted-incarnation-repair.test.ts b/src/main/ipc/pty-persisted-incarnation-repair.test.ts index 8d2ff0b1102..13766af39c2 100644 --- a/src/main/ipc/pty-persisted-incarnation-repair.test.ts +++ b/src/main/ipc/pty-persisted-incarnation-repair.test.ts @@ -4,7 +4,9 @@ import { statSyncMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { SessionNotFoundError, TerminalSessionOwnerUnverifiedError } from '../daemon/daemon-errors' import { makePaneKey } from '../../shared/stable-pane-id' -import { registerPtyHandlers, clearProviderPtyState, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { clearProviderPtyState } from './pty/provider/state-cleanup' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-renderer-inflight-credit.test.ts b/src/main/ipc/pty-renderer-inflight-credit.test.ts index 6629b7d3a09..5024f408d61 100644 --- a/src/main/ipc/pty-renderer-inflight-credit.test.ts +++ b/src/main/ipc/pty-renderer-inflight-credit.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it, vi } from 'vitest' import { spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-renderer-lifecycle-delivery-reset.test.ts b/src/main/ipc/pty-renderer-lifecycle-delivery-reset.test.ts index 544795e1f67..16070629c20 100644 --- a/src/main/ipc/pty-renderer-lifecycle-delivery-reset.test.ts +++ b/src/main/ipc/pty-renderer-lifecycle-delivery-reset.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it, vi } from 'vitest' import { spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, getPtyRendererDeliveryDebugSnapshot } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { getPtyRendererDeliveryDebugSnapshot } from './pty/delivery/debug' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-renderer-liveness-guard.test.ts b/src/main/ipc/pty-renderer-liveness-guard.test.ts index 08a925067d8..df60bbe71d6 100644 --- a/src/main/ipc/pty-renderer-liveness-guard.test.ts +++ b/src/main/ipc/pty-renderer-liveness-guard.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it, vi } from 'vitest' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { PtyWriteUnavailableError } from '../providers/pty-write-unavailable-error' import { TERMINAL_INPUT_CHUNK_MAX_BYTES } from '../../shared/terminal-input' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-renderer-send-failure-recovery.test.ts b/src/main/ipc/pty-renderer-send-failure-recovery.test.ts index 423288446f9..00870825a07 100644 --- a/src/main/ipc/pty-renderer-send-failure-recovery.test.ts +++ b/src/main/ipc/pty-renderer-send-failure-recovery.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it, vi } from 'vitest' import { spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, getPtyRendererDeliveryDebugSnapshot } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { getPtyRendererDeliveryDebugSnapshot } from './pty/delivery/debug' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-reset-input-modes.test.ts b/src/main/ipc/pty-reset-input-modes.test.ts index 55fa628078d..d335864fcea 100644 --- a/src/main/ipc/pty-reset-input-modes.test.ts +++ b/src/main/ipc/pty-reset-input-modes.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from 'vitest' import { onMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-restore-record-seeding.test.ts b/src/main/ipc/pty-restore-record-seeding.test.ts index 0f1646e7812..2a485a953f9 100644 --- a/src/main/ipc/pty-restore-record-seeding.test.ts +++ b/src/main/ipc/pty-restore-record-seeding.test.ts @@ -15,12 +15,10 @@ import { OrcaRuntimeService } from '../runtime/orca-runtime' import type { RuntimeResolvedWorktreeCache } from '../runtime/runtime-resolved-worktree-cache' import type { ResolvedWorktree } from '../runtime/runtime-worktree-path-identity' import { getWorktreeScanMutationRevision } from '../local-worktree-scan-generation' -import { - registerPtyHandlers, - clearProviderPtyState, - getPtyIdForPaneKey, - setLocalPtyProvider -} from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { clearProviderPtyState } from './pty/provider/state-cleanup' +import { getPtyIdForPaneKey } from './pty/pane/key-state' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-restored-appimage-cli-shim-refresh.test.ts b/src/main/ipc/pty-restored-appimage-cli-shim-refresh.test.ts index d42103dc518..ad52d8fefda 100644 --- a/src/main/ipc/pty-restored-appimage-cli-shim-refresh.test.ts +++ b/src/main/ipc/pty-restored-appimage-cli-shim-refresh.test.ts @@ -46,7 +46,7 @@ vi.mock('../codex/codex-state-db-backfill-recovery', () => import('./pty-ipc-mock-registry').then((m) => m.codexBackfillRecoveryModuleMock()) ) -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform')! diff --git a/src/main/ipc/pty-runtime-hidden-at-spawn-mark.test.ts b/src/main/ipc/pty-runtime-hidden-at-spawn-mark.test.ts index b4deb243b0b..185648b3cca 100644 --- a/src/main/ipc/pty-runtime-hidden-at-spawn-mark.test.ts +++ b/src/main/ipc/pty-runtime-hidden-at-spawn-mark.test.ts @@ -3,7 +3,7 @@ import { makeDeferred } from './pty-ipc-test-constants' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { isHiddenRendererPty } from './pty-hidden-delivery-gate' import { OrcaRuntimeService } from '../runtime/orca-runtime' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-runtime-kill-and-exit.test.ts b/src/main/ipc/pty-runtime-kill-and-exit.test.ts index 03081abc17a..6a0d9fabdf0 100644 --- a/src/main/ipc/pty-runtime-kill-and-exit.test.ts +++ b/src/main/ipc/pty-runtime-kill-and-exit.test.ts @@ -4,14 +4,10 @@ import { makeDeferred } from './pty-ipc-test-constants' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { LOCAL_EXECUTION_HOST_ID } from '../../shared/execution-host' import type { RuntimePtyController } from '../runtime/runtime-pty-controller-contract' -import { - registerPtyHandlers, - deletePtyOwnership, - setPtyOwnership, - setLocalPtyProvider, - rebindLocalProviderListeners, - getLocalPtyProvider -} from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { deletePtyOwnership, setPtyOwnership } from './pty/provider/ownership-state' +import { setLocalPtyProvider, getLocalPtyProvider } from './pty/provider/registry' +import { rebindLocalProviderListeners } from './pty/provider/listener-lifecycle' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-runtime-ssh-binding-persistence.test.ts b/src/main/ipc/pty-runtime-ssh-binding-persistence.test.ts index 5b41ee7c610..cafe08a8d68 100644 --- a/src/main/ipc/pty-runtime-ssh-binding-persistence.test.ts +++ b/src/main/ipc/pty-runtime-ssh-binding-persistence.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from 'vitest' import { spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-serializer-settlement-mapping.test.ts b/src/main/ipc/pty-serializer-settlement-mapping.test.ts index 45f0810a49a..78c8a17c675 100644 --- a/src/main/ipc/pty-serializer-settlement-mapping.test.ts +++ b/src/main/ipc/pty-serializer-settlement-mapping.test.ts @@ -3,12 +3,10 @@ import { spawnMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { makePaneKey } from '../../shared/stable-pane-id' import type * as WslManagedCliModule from '../cli/wsl-managed-cli' -import { - registerPtyHandlers, - clearProviderPtyState, - hasPendingRendererSerializerForPaneKey, - setLocalPtyProvider -} from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { clearProviderPtyState } from './pty/provider/state-cleanup' +import { hasPendingRendererSerializerForPaneKey } from './pty/pane/serializer-state' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-session-liveness-and-ownership.test.ts b/src/main/ipc/pty-session-liveness-and-ownership.test.ts index 47384791c2a..763c9e2f863 100644 --- a/src/main/ipc/pty-session-liveness-and-ownership.test.ts +++ b/src/main/ipc/pty-session-liveness-and-ownership.test.ts @@ -2,12 +2,9 @@ import { describe, expect, it, vi } from 'vitest' import { onMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { AGENT_SESSION_CLAIM_DIGEST_VERSION } from '../../shared/agent-session-host-authority' -import { - deletePtyOwnership, - registerPtyHandlers, - setPtyOwnership, - setLocalPtyProvider -} from './pty' +import { deletePtyOwnership, setPtyOwnership } from './pty/provider/ownership-state' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-spawn-codex-home-unavailable.test.ts b/src/main/ipc/pty-spawn-codex-home-unavailable.test.ts index f94d28ef4b7..72c3a2cd368 100644 --- a/src/main/ipc/pty-spawn-codex-home-unavailable.test.ts +++ b/src/main/ipc/pty-spawn-codex-home-unavailable.test.ts @@ -4,7 +4,7 @@ import { TEST_CODEX_HOME, TEST_CODEX_AUTH_JSON } from './pty-ipc-test-constants' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { createDaemonActiveProviderFixtures } from './pty-ipc-daemon-provider-fixtures' import { ManagedCodexHomeTemporarilyUnavailableError } from '../codex-accounts/host-codex-managed-home-ownership' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-spawn-cwd-fallback.test.ts b/src/main/ipc/pty-spawn-cwd-fallback.test.ts index 964156a6615..ddf1d55fde6 100644 --- a/src/main/ipc/pty-spawn-cwd-fallback.test.ts +++ b/src/main/ipc/pty-spawn-cwd-fallback.test.ts @@ -4,7 +4,7 @@ import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { FLOATING_TERMINAL_WORKTREE_ID } from '../../shared/constants' import { _setWslCachesForTests } from '../wsl' import { acquireWatcherRemovalGate } from './watcher-removal-gate' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-spawn-env-codex-home-routing.test.ts b/src/main/ipc/pty-spawn-env-codex-home-routing.test.ts index 1c2f4ebc465..1082a7a3d72 100644 --- a/src/main/ipc/pty-spawn-env-codex-home-routing.test.ts +++ b/src/main/ipc/pty-spawn-env-codex-home-routing.test.ts @@ -8,7 +8,7 @@ import { } from './pty-ipc-mock-registry' import { posixOnlyIt, TEST_CODEX_HOME, TEST_CODEX_AUTH_JSON } from './pty-ipc-test-constants' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-spawn-env-codex-resume-provenance.test.ts b/src/main/ipc/pty-spawn-env-codex-resume-provenance.test.ts index f3b30321c55..1cecd3a2b37 100644 --- a/src/main/ipc/pty-spawn-env-codex-resume-provenance.test.ts +++ b/src/main/ipc/pty-spawn-env-codex-resume-provenance.test.ts @@ -5,7 +5,9 @@ import { posixOnlyIt, TEST_MANAGED_ROOT } from './pty-ipc-test-constants' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { prepareCodexSessionResume } from '../codex/codex-session-resume-preparation' import { POSIX_SHELL_STARTUP_COMMAND_ENV } from '../pty/posix-shell-startup-command' -import { registerPtyHandlers, setLocalPtyProvider, type PrepareCodexSessionResume } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' +import type { PrepareCodexSessionResume } from './pty/host-env/types' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-spawn-env-terminal-basics.test.ts b/src/main/ipc/pty-spawn-env-terminal-basics.test.ts index 250000ef465..14c15704fd9 100644 --- a/src/main/ipc/pty-spawn-env-terminal-basics.test.ts +++ b/src/main/ipc/pty-spawn-env-terminal-basics.test.ts @@ -7,7 +7,8 @@ import { LocalPtyProvider } from '../providers/local-pty-provider' import { __resetPersistedWindowsPathCacheForTests } from '../pty/windows-environment-path' import { __setWindowsPathRegistryLoaderForTests } from '../pty/windows-path-registry-reader' import { wslHookRelayManager } from '../agent-hooks/wsl-hook-relay-manager' -import { registerPtyHandlers, buildPtyHostEnv } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { buildPtyHostEnv } from './pty/host-env/assembly' import { buildJcodeRuntimeDir, shouldInjectJcodeRuntimeDir } from '../../shared/jcode-runtime-dir' import { makePaneKey } from '../../shared/stable-pane-id' import { selectShellStartupFeatures } from '../shell-startup-features' diff --git a/src/main/ipc/pty-spawn-pi-owner-env.test.ts b/src/main/ipc/pty-spawn-pi-owner-env.test.ts index 168d253851d..2101fc13d97 100644 --- a/src/main/ipc/pty-spawn-pi-owner-env.test.ts +++ b/src/main/ipc/pty-spawn-pi-owner-env.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from 'vitest' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { createDaemonActiveProviderFixtures } from './pty-ipc-daemon-provider-fixtures' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-spawn-placement-threading.test.ts b/src/main/ipc/pty-spawn-placement-threading.test.ts index 386e74a8fcc..d54ef47711d 100644 --- a/src/main/ipc/pty-spawn-placement-threading.test.ts +++ b/src/main/ipc/pty-spawn-placement-threading.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it, vi } from 'vitest' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { makePaneKey } from '../../shared/stable-pane-id' import type { TerminalPanePlacement } from '../../shared/terminal-pane-placement' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-spawn-runtime-handle-binding.test.ts b/src/main/ipc/pty-spawn-runtime-handle-binding.test.ts index 4d215fc7976..6b5e5660512 100644 --- a/src/main/ipc/pty-spawn-runtime-handle-binding.test.ts +++ b/src/main/ipc/pty-spawn-runtime-handle-binding.test.ts @@ -11,7 +11,7 @@ import { makePaneSpawnReservationKey, reservePaneSpawn } from './pty/pane/spawn-reservation' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-ssh-stop-verdict.test.ts b/src/main/ipc/pty-ssh-stop-verdict.test.ts index 8b9efeca287..8599029026f 100644 --- a/src/main/ipc/pty-ssh-stop-verdict.test.ts +++ b/src/main/ipc/pty-ssh-stop-verdict.test.ts @@ -1,12 +1,9 @@ import { describe, expect, it, vi } from 'vitest' import { SSH_PROVIDER_UNREGISTERED_REASON } from '../../shared/pty-liveness-verdict' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { - registerPtyHandlers, - deletePtyOwnership, - setPtyOwnership, - getLocalPtyProvider -} from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { deletePtyOwnership, setPtyOwnership } from './pty/provider/ownership-state' +import { getLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-startup-barrier-and-listing.test.ts b/src/main/ipc/pty-startup-barrier-and-listing.test.ts index c20bd24464c..99ede3019f0 100644 --- a/src/main/ipc/pty-startup-barrier-and-listing.test.ts +++ b/src/main/ipc/pty-startup-barrier-and-listing.test.ts @@ -2,7 +2,9 @@ import { describe, expect, it, vi } from 'vitest' import { spawnMock } from './pty-ipc-mock-registry' import { makeDeferred } from './pty-ipc-test-constants' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers, setLocalPtyProvider, rebindLocalProviderListeners } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { setLocalPtyProvider } from './pty/provider/registry' +import { rebindLocalProviderListeners } from './pty/provider/listener-lifecycle' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-startup-swap-window-presence.test.ts b/src/main/ipc/pty-startup-swap-window-presence.test.ts index 335c2b1138e..8b073c03da1 100644 --- a/src/main/ipc/pty-startup-swap-window-presence.test.ts +++ b/src/main/ipc/pty-startup-swap-window-presence.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from 'vitest' import { makeDeferred } from './pty-ipc-test-constants' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-windows-shell-selection.test.ts b/src/main/ipc/pty-windows-shell-selection.test.ts index 6d42f7d0bed..1581148343a 100644 --- a/src/main/ipc/pty-windows-shell-selection.test.ts +++ b/src/main/ipc/pty-windows-shell-selection.test.ts @@ -11,7 +11,7 @@ import { POWERSHELL_OSC133_ARGS } from './pty-ipc-test-constants' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-write-ipc-validation.test.ts b/src/main/ipc/pty-write-ipc-validation.test.ts index 4217530c464..be18fa855b6 100644 --- a/src/main/ipc/pty-write-ipc-validation.test.ts +++ b/src/main/ipc/pty-write-ipc-validation.test.ts @@ -8,7 +8,9 @@ import { import { CLIPBOARD_TEXT_MEASURE_YIELD_CODE_UNITS } from '../../shared/clipboard-text' import { PtyWriteUnavailableError } from '../providers/pty-write-unavailable-error' import { wslHookRelayManager } from '../agent-hooks/wsl-hook-relay-manager' -import { registerPtyHandlers, deletePtyOwnership, setLocalPtyProvider } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' +import { deletePtyOwnership } from './pty/provider/ownership-state' +import { setLocalPtyProvider } from './pty/provider/registry' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) vi.mock('fs', () => import('./pty-ipc-mock-registry').then((m) => m.fsModuleMock())) diff --git a/src/main/ipc/pty-wsl-cwd-validation.test.ts b/src/main/ipc/pty-wsl-cwd-validation.test.ts index cfdb693d228..8f6f0e4d709 100644 --- a/src/main/ipc/pty-wsl-cwd-validation.test.ts +++ b/src/main/ipc/pty-wsl-cwd-validation.test.ts @@ -7,7 +7,7 @@ import { } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { _setWslCachesForTests } from '../wsl' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' import { join } from 'node:path' // Why resolved rather than hardcoded: the wrapper tree is content-addressed. import { getShellReadyWrapperRoot } from '../providers/local-pty-shell-ready-wrapper-root' diff --git a/src/main/ipc/pty.ts b/src/main/ipc/pty.ts deleted file mode 100644 index c735f4cad7f..00000000000 --- a/src/main/ipc/pty.ts +++ /dev/null @@ -1,33 +0,0 @@ -export { getBashShellReadyRcfileContent } from '../providers/local-pty-shell-ready-bash-rcfile' -export { - isCurrentPtyExit, - deletePtyOwnership, - setPtyOwnership, - restorePtyIncarnation, - getPtyIdsForConnection -} from './pty/provider/ownership-state' -export { getPtyIdForPaneKey, registerPaneKeyTeardownListener } from './pty/pane/key-state' -export { hasPendingRendererSerializerForPaneKey } from './pty/pane/serializer-state' -export type { - BuildPtyHostEnvOptions, - CodexHomeLaunchContext, - GetSelectedCodexHomePath, - PrepareCodexSessionResume, - CodexHomePtySpawnedLifecycleArgs -} from './pty/host-env/types' -export { resolveCodexHomeAfterManagedAuthReadiness } from './pty/host-env/codex-home' -export { buildPtyHostEnv } from './pty/host-env/assembly' -export { getLocalPtyProvider, setLocalPtyProvider } from './pty/provider/registry' -export { clearProviderPtyState, clearPtyOwnershipForConnection } from './pty/provider/state-cleanup' -export { - rebindLocalProviderListeners, - unbindLocalProviderListeners -} from './pty/provider/listener-lifecycle' -export type { PtyRendererDeliveryDebugSnapshot } from './pty/delivery/debug' -export { - getPtyRendererDeliveryDebugSnapshot, - resetPtyRendererDeliveryDebug -} from './pty/delivery/debug' -export { registerPtyHandlers } from './pty/register-handlers' -export { registerHeadlessPtyRuntime } from './pty/register-headless-runtime' -export { killAllPty } from './pty/kill-all' diff --git a/src/main/ipc/pty/register-without-renderer.test.ts b/src/main/ipc/pty/register-without-renderer.test.ts index e31329a1c77..bf467533fdc 100644 --- a/src/main/ipc/pty/register-without-renderer.test.ts +++ b/src/main/ipc/pty/register-without-renderer.test.ts @@ -2,12 +2,10 @@ import { EventEmitter } from 'node:events' import { describe, expect, it, vi } from 'vitest' import { OrcaRuntimeService } from '../../runtime/orca-runtime' import { setupPtyIpcSuite } from '../pty-ipc-test-harness' -import { - getLocalPtyProvider, - getPtyRendererDeliveryDebugSnapshot, - registerPtyHandlers, - setPtyOwnership -} from '../pty' +import { getLocalPtyProvider } from './provider/registry' +import { getPtyRendererDeliveryDebugSnapshot } from './delivery/debug' +import { registerPtyHandlers } from './register-handlers' +import { setPtyOwnership } from './provider/ownership-state' import { registerHeadlessPtyRuntime } from './register-headless-runtime' import { onMock } from '../pty-ipc-mock-registry' diff --git a/src/main/ipc/qoder-desktop-execution-host.test.ts b/src/main/ipc/qoder-desktop-execution-host.test.ts index 25f4e643a5e..a74622c362b 100644 --- a/src/main/ipc/qoder-desktop-execution-host.test.ts +++ b/src/main/ipc/qoder-desktop-execution-host.test.ts @@ -1,7 +1,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { createDaemonActiveProviderFixtures } from './pty-ipc-daemon-provider-fixtures' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' import { isCommandOnPath } from './preflight-command-exec' import { detectWslCommandsOnPath } from './preflight-wsl-agent-detection' import type * as FsPromises from 'node:fs/promises' diff --git a/src/main/ipc/qoder-independent-renderer-spawn-review.test.ts b/src/main/ipc/qoder-independent-renderer-spawn-review.test.ts index a9c20cc9ad3..84599606205 100644 --- a/src/main/ipc/qoder-independent-renderer-spawn-review.test.ts +++ b/src/main/ipc/qoder-independent-renderer-spawn-review.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from 'vitest' import { setupPtyIpcSuite } from './pty-ipc-test-harness' import { createDaemonActiveProviderFixtures } from './pty-ipc-daemon-provider-fixtures' -import { registerPtyHandlers } from './pty' +import { registerPtyHandlers } from './pty/register-handlers' import { detectAgentCommandsOnHost } from '../preflight/agent-detection' import { buildAgentStartupPlan, buildAgentResumeStartupPlan } from '../../shared/tui-agent-startup' import { agentStartedTelemetry } from '../agent-launch/agent-started-telemetry' diff --git a/src/main/ipc/register-core-handlers/register-core-handlers.ts b/src/main/ipc/register-core-handlers/register-core-handlers.ts index 9045aee3c22..669ccdd64bc 100644 --- a/src/main/ipc/register-core-handlers/register-core-handlers.ts +++ b/src/main/ipc/register-core-handlers/register-core-handlers.ts @@ -59,7 +59,7 @@ import { registerOrcaProfileHandlers } from '../orca-profiles' import { registerCodexAccountHandlers } from '../codex-accounts' import { registerAgentHookHandlers } from '../agent-hooks' import { registerCodexConfigSyncHandlers } from '../codex-config-sync' -import { getPtyIdForPaneKey } from '../pty' +import { getPtyIdForPaneKey } from '../pty/pane/key-state' import { registerClaudeAccountHandlers } from '../claude-accounts' import { registerOpenCodeGoCredentialsHandlers } from '../opencode-go-credentials' import { registerMiniMaxCredentialsHandlers } from '../minimax-credentials' diff --git a/src/main/ipc/ssh-app-shutdown.test.ts b/src/main/ipc/ssh-app-shutdown.test.ts index 1435a0615d4..06943fcd989 100644 --- a/src/main/ipc/ssh-app-shutdown.test.ts +++ b/src/main/ipc/ssh-app-shutdown.test.ts @@ -11,7 +11,6 @@ vi.mock('../ssh/ssh-connection-store', () => mocks.sshConnectionStore) vi.mock('./ssh-host-server-connect', () => mocks.hostServerConnect) vi.mock('../ssh/ssh-connection-manager', () => mocks.sshConnectionManager) vi.mock('../ssh/ssh-channel-multiplexer', () => mocks.sshChannelMultiplexer) -vi.mock('./pty', () => mocks.pty) vi.mock('../ssh/ssh-port-forward', () => mocks.sshPortForward) vi.mock('../ssh/ssh-port-scanner', () => mocks.sshPortScanner) diff --git a/src/main/ipc/ssh-connect-decision-cancellation.test.ts b/src/main/ipc/ssh-connect-decision-cancellation.test.ts index 13b802f13a2..a3f06e23b7c 100644 --- a/src/main/ipc/ssh-connect-decision-cancellation.test.ts +++ b/src/main/ipc/ssh-connect-decision-cancellation.test.ts @@ -11,7 +11,6 @@ vi.mock('../ssh/ssh-connection-store', () => mocks.sshConnectionStore) vi.mock('./ssh-host-server-connect', () => mocks.hostServerConnect) vi.mock('../ssh/ssh-connection-manager', () => mocks.sshConnectionManager) vi.mock('../ssh/ssh-channel-multiplexer', () => mocks.sshChannelMultiplexer) -vi.mock('./pty', () => mocks.pty) vi.mock('../ssh/ssh-port-forward', () => mocks.sshPortForward) vi.mock('../ssh/ssh-port-scanner', () => mocks.sshPortScanner) diff --git a/src/main/ipc/ssh-disconnect-cancellation.test.ts b/src/main/ipc/ssh-disconnect-cancellation.test.ts index ba666c250af..01f7d365aee 100644 --- a/src/main/ipc/ssh-disconnect-cancellation.test.ts +++ b/src/main/ipc/ssh-disconnect-cancellation.test.ts @@ -11,7 +11,6 @@ vi.mock('../ssh/ssh-connection-store', () => mocks.sshConnectionStore) vi.mock('./ssh-host-server-connect', () => mocks.hostServerConnect) vi.mock('../ssh/ssh-connection-manager', () => mocks.sshConnectionManager) vi.mock('../ssh/ssh-channel-multiplexer', () => mocks.sshChannelMultiplexer) -vi.mock('./pty', () => mocks.pty) vi.mock('../ssh/ssh-port-forward', () => mocks.sshPortForward) vi.mock('../ssh/ssh-port-scanner', () => mocks.sshPortScanner) diff --git a/src/main/ipc/ssh-handler-reregistration.test.ts b/src/main/ipc/ssh-handler-reregistration.test.ts index 9c3203233ff..cce94963345 100644 --- a/src/main/ipc/ssh-handler-reregistration.test.ts +++ b/src/main/ipc/ssh-handler-reregistration.test.ts @@ -11,7 +11,6 @@ vi.mock('../ssh/ssh-connection-store', () => mocks.sshConnectionStore) vi.mock('./ssh-host-server-connect', () => mocks.hostServerConnect) vi.mock('../ssh/ssh-connection-manager', () => mocks.sshConnectionManager) vi.mock('../ssh/ssh-channel-multiplexer', () => mocks.sshChannelMultiplexer) -vi.mock('./pty', () => mocks.pty) vi.mock('../ssh/ssh-port-forward', () => mocks.sshPortForward) vi.mock('../ssh/ssh-port-scanner', () => mocks.sshPortScanner) diff --git a/src/main/ipc/ssh-ipc-mock-shapes.ts b/src/main/ipc/ssh-ipc-mock-shapes.ts index 8ce34f58b0b..a8fb651610d 100644 --- a/src/main/ipc/ssh-ipc-mock-shapes.ts +++ b/src/main/ipc/ssh-ipc-mock-shapes.ts @@ -79,7 +79,6 @@ export type SshIpcMockModules = { sshConnectionStore: SshIpcMockModule sshConnectionManager: SshIpcMockModule sshChannelMultiplexer: SshIpcMockModule - pty: SshIpcMockModule sshPortForward: SshIpcMockModule sshPortScanner: SshIpcMockModule } diff --git a/src/main/ipc/ssh-ipc-module-mocks.ts b/src/main/ipc/ssh-ipc-module-mocks.ts index 1255cd6e5e5..1630be06283 100644 --- a/src/main/ipc/ssh-ipc-module-mocks.ts +++ b/src/main/ipc/ssh-ipc-module-mocks.ts @@ -150,15 +150,6 @@ export function createSshIpcMocks(): SshIpcMocks { } } }, - pty: { - clearPtyOwnershipForConnection: vi.fn(), - clearProviderPtyState: vi.fn(), - deletePtyOwnership: vi.fn(), - setPtyOwnership: vi.fn(), - getPtyIdsForConnection: vi.fn().mockReturnValue([]), - isCurrentPtyExit: vi.fn().mockReturnValue(true), - isRendererPtyOutputPaused: vi.fn().mockReturnValue(false) - }, sshPortForward: { SshPortForwardManager: class MockPortForwardManager { constructor() { diff --git a/src/main/ipc/ssh-ipc-test-harness.ts b/src/main/ipc/ssh-ipc-test-harness.ts index ba7f4283b4d..fc25e36c5a7 100644 --- a/src/main/ipc/ssh-ipc-test-harness.ts +++ b/src/main/ipc/ssh-ipc-test-harness.ts @@ -1,7 +1,6 @@ import { vi } from 'vitest' import type { Mock } from 'vitest' import { registerSshHandlers, resetSshHandlerStateForTests } from './ssh' -import { clearProviderPtyState, deletePtyOwnership, getPtyIdsForConnection } from './pty' import type { SshIpcMocks } from './ssh-ipc-module-mocks' import type { SshConnectionManagerMock, SshPortForwardManagerMock } from './ssh-ipc-mock-shapes' @@ -128,9 +127,6 @@ export function createSshIpcHarness(mocks: SshIpcMocks): SshIpcHarness { mockPortForwardManager.callbacksRef.current = null powerMonitorOnMock.mockReset() powerMonitorOffMock.mockReset() - vi.mocked(getPtyIdsForConnection).mockReset().mockReturnValue([]) - vi.mocked(clearProviderPtyState).mockReset() - vi.mocked(deletePtyOwnership).mockReset() registerSshHandlers(mockStore as never, () => mockWindow as never) } diff --git a/src/main/ipc/ssh-state-broadcast-fanout.test.ts b/src/main/ipc/ssh-state-broadcast-fanout.test.ts index 80a9e61fc7b..142ec3a94e7 100644 --- a/src/main/ipc/ssh-state-broadcast-fanout.test.ts +++ b/src/main/ipc/ssh-state-broadcast-fanout.test.ts @@ -11,7 +11,6 @@ vi.mock('../ssh/ssh-connection-store', () => mocks.sshConnectionStore) vi.mock('./ssh-host-server-connect', () => mocks.hostServerConnect) vi.mock('../ssh/ssh-connection-manager', () => mocks.sshConnectionManager) vi.mock('../ssh/ssh-channel-multiplexer', () => mocks.sshChannelMultiplexer) -vi.mock('./pty', () => mocks.pty) vi.mock('../ssh/ssh-port-forward', () => mocks.sshPortForward) vi.mock('../ssh/ssh-port-scanner', () => mocks.sshPortScanner) diff --git a/src/main/ipc/ssh-target-registry.test.ts b/src/main/ipc/ssh-target-registry.test.ts index 726da4520df..2691dac7cfd 100644 --- a/src/main/ipc/ssh-target-registry.test.ts +++ b/src/main/ipc/ssh-target-registry.test.ts @@ -11,7 +11,6 @@ vi.mock('../ssh/ssh-connection-store', () => mocks.sshConnectionStore) vi.mock('./ssh-host-server-connect', () => mocks.hostServerConnect) vi.mock('../ssh/ssh-connection-manager', () => mocks.sshConnectionManager) vi.mock('../ssh/ssh-channel-multiplexer', () => mocks.sshChannelMultiplexer) -vi.mock('./pty', () => mocks.pty) vi.mock('../ssh/ssh-port-forward', () => mocks.sshPortForward) vi.mock('../ssh/ssh-port-scanner', () => mocks.sshPortScanner) diff --git a/src/main/ipc/ssh.test.ts b/src/main/ipc/ssh.test.ts index 33b28c79f3c..785d48c4419 100644 --- a/src/main/ipc/ssh.test.ts +++ b/src/main/ipc/ssh.test.ts @@ -11,7 +11,6 @@ vi.mock('../ssh/ssh-connection-store', () => mocks.sshConnectionStore) vi.mock('./ssh-host-server-connect', () => mocks.hostServerConnect) vi.mock('../ssh/ssh-connection-manager', () => mocks.sshConnectionManager) vi.mock('../ssh/ssh-channel-multiplexer', () => mocks.sshChannelMultiplexer) -vi.mock('./pty', () => mocks.pty) vi.mock('../ssh/ssh-port-forward', () => mocks.sshPortForward) vi.mock('../ssh/ssh-port-scanner', () => mocks.sshPortScanner) diff --git a/src/main/ipc/workspace-cleanup.test.ts b/src/main/ipc/workspace-cleanup.test.ts index 3a35c574653..4d06bf53bbf 100644 --- a/src/main/ipc/workspace-cleanup.test.ts +++ b/src/main/ipc/workspace-cleanup.test.ts @@ -60,8 +60,6 @@ vi.mock('../memory/pty-registry', () => ({ listRegisteredPtys: listRegisteredPtysMock })) -vi.mock('./pty', () => ({})) - // Why: snapshot persistence does real file I/O; covered in workspace-cleanup-snapshot-ipc.test.ts. vi.mock('../workspace-cleanup-scan-snapshot', () => ({ persistWorkspaceCleanupScanResult: vi.fn(async () => undefined), diff --git a/src/main/ipc/worktrees-authoritative-local-metadata-pruning.test.ts b/src/main/ipc/worktrees-authoritative-local-metadata-pruning.test.ts index 7a30fa7365b..958a6fae2bc 100644 --- a/src/main/ipc/worktrees-authoritative-local-metadata-pruning.test.ts +++ b/src/main/ipc/worktrees-authoritative-local-metadata-pruning.test.ts @@ -98,7 +98,12 @@ vi.mock('../local-worktree-path-presence', async (importOriginal) => ({ vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) const REPO_ID = 'repo-1' const REPO_PATH = '/workspace/repo' diff --git a/src/main/ipc/worktrees-background-removal.test.ts b/src/main/ipc/worktrees-background-removal.test.ts index f5ff1550238..b272b4e0a22 100644 --- a/src/main/ipc/worktrees-background-removal.test.ts +++ b/src/main/ipc/worktrees-background-removal.test.ts @@ -87,7 +87,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) function remove(args: Record): Promise { // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: worktrees:remove resolves a RemoveWorktreeResult. diff --git a/src/main/ipc/worktrees-create-event-timing.test.ts b/src/main/ipc/worktrees-create-event-timing.test.ts index 4fe00b7c062..6871fe87e05 100644 --- a/src/main/ipc/worktrees-create-event-timing.test.ts +++ b/src/main/ipc/worktrees-create-event-timing.test.ts @@ -87,7 +87,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) vi.mock('../telemetry/client', () => ({ track: trackMock, diff --git a/src/main/ipc/worktrees-create-metadata-persistence.test.ts b/src/main/ipc/worktrees-create-metadata-persistence.test.ts index b77c0b521ee..4d57901e899 100644 --- a/src/main/ipc/worktrees-create-metadata-persistence.test.ts +++ b/src/main/ipc/worktrees-create-metadata-persistence.test.ts @@ -119,7 +119,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) describe('registerWorktreeHandlers', () => { let runtimeStub: WorktreeRuntimeStub diff --git a/src/main/ipc/worktrees-delete-pty-teardown.test.ts b/src/main/ipc/worktrees-delete-pty-teardown.test.ts index 7b9d2c90c51..1c904c9d7c0 100644 --- a/src/main/ipc/worktrees-delete-pty-teardown.test.ts +++ b/src/main/ipc/worktrees-delete-pty-teardown.test.ts @@ -86,7 +86,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) // Why: every removal and listing reply now names the catalog it produced or scanned. const anyCatalogVersion = { epoch: expect.any(String), sequence: expect.any(Number) } diff --git a/src/main/ipc/worktrees-detected-scan-cache.test.ts b/src/main/ipc/worktrees-detected-scan-cache.test.ts index 239805ddfd3..1cb9b3c4550 100644 --- a/src/main/ipc/worktrees-detected-scan-cache.test.ts +++ b/src/main/ipc/worktrees-detected-scan-cache.test.ts @@ -81,7 +81,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) describe('registerWorktreeHandlers', () => { beforeEach(() => { diff --git a/src/main/ipc/worktrees-discovery-metadata-backfill.test.ts b/src/main/ipc/worktrees-discovery-metadata-backfill.test.ts index 4a4683533db..58eb84888e1 100644 --- a/src/main/ipc/worktrees-discovery-metadata-backfill.test.ts +++ b/src/main/ipc/worktrees-discovery-metadata-backfill.test.ts @@ -76,7 +76,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) describe('registerWorktreeHandlers', () => { beforeEach(() => { diff --git a/src/main/ipc/worktrees-existing-branch-checkout.test.ts b/src/main/ipc/worktrees-existing-branch-checkout.test.ts index af38cfc910c..09487998aaa 100644 --- a/src/main/ipc/worktrees-existing-branch-checkout.test.ts +++ b/src/main/ipc/worktrees-existing-branch-checkout.test.ts @@ -84,7 +84,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) describe('registerWorktreeHandlers', () => { let runtimeStub: WorktreeRuntimeStub diff --git a/src/main/ipc/worktrees-failed-removal.test.ts b/src/main/ipc/worktrees-failed-removal.test.ts index b2563b433c5..087bd6d8950 100644 --- a/src/main/ipc/worktrees-failed-removal.test.ts +++ b/src/main/ipc/worktrees-failed-removal.test.ts @@ -95,7 +95,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) vi.mock('../git/worktree-removal', async (importOriginal) => ({ ...(await importOriginal()), diff --git a/src/main/ipc/worktrees-forget-local.test.ts b/src/main/ipc/worktrees-forget-local.test.ts index 2668d263ed2..4d382dab8e1 100644 --- a/src/main/ipc/worktrees-forget-local.test.ts +++ b/src/main/ipc/worktrees-forget-local.test.ts @@ -92,7 +92,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) describe('registerWorktreeHandlers', () => { let runtimeStub: WorktreeRuntimeStub diff --git a/src/main/ipc/worktrees-issue-command-overrides.test.ts b/src/main/ipc/worktrees-issue-command-overrides.test.ts index 26b7271a113..1c8814c7dcd 100644 --- a/src/main/ipc/worktrees-issue-command-overrides.test.ts +++ b/src/main/ipc/worktrees-issue-command-overrides.test.ts @@ -85,7 +85,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) const REMOTE_REPO_PATH = '/remote/repo' diff --git a/src/main/ipc/worktrees-lineage-hydration.test.ts b/src/main/ipc/worktrees-lineage-hydration.test.ts index 43385ee5b81..bacaff09602 100644 --- a/src/main/ipc/worktrees-lineage-hydration.test.ts +++ b/src/main/ipc/worktrees-lineage-hydration.test.ts @@ -78,7 +78,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) describe('registerWorktreeHandlers', () => { beforeEach(() => { diff --git a/src/main/ipc/worktrees-listing-fallback-rows.test.ts b/src/main/ipc/worktrees-listing-fallback-rows.test.ts index c2d4488fa55..79ea6dd4020 100644 --- a/src/main/ipc/worktrees-listing-fallback-rows.test.ts +++ b/src/main/ipc/worktrees-listing-fallback-rows.test.ts @@ -78,7 +78,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) describe('registerWorktreeHandlers', () => { beforeEach(() => { diff --git a/src/main/ipc/worktrees-local-base-ref-resolution.test.ts b/src/main/ipc/worktrees-local-base-ref-resolution.test.ts index c5db99b97e7..bd79a609ac1 100644 --- a/src/main/ipc/worktrees-local-base-ref-resolution.test.ts +++ b/src/main/ipc/worktrees-local-base-ref-resolution.test.ts @@ -84,7 +84,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) describe('registerWorktreeHandlers', () => { let runtimeStub: WorktreeRuntimeStub diff --git a/src/main/ipc/worktrees-local-create-flow.test.ts b/src/main/ipc/worktrees-local-create-flow.test.ts index 51052ed1e5c..97093580638 100644 --- a/src/main/ipc/worktrees-local-create-flow.test.ts +++ b/src/main/ipc/worktrees-local-create-flow.test.ts @@ -98,7 +98,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) describe('registerWorktreeHandlers', () => { let runtimeStub: WorktreeRuntimeStub diff --git a/src/main/ipc/worktrees-mutation-scan-generation-order.test.ts b/src/main/ipc/worktrees-mutation-scan-generation-order.test.ts index 0b5c8f31629..25ca946fe2c 100644 --- a/src/main/ipc/worktrees-mutation-scan-generation-order.test.ts +++ b/src/main/ipc/worktrees-mutation-scan-generation-order.test.ts @@ -87,7 +87,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) // Why the first step after the mutation, not the re-list: every await between them is a window in // which a listing can begin at the old generation yet see the mutation. diff --git a/src/main/ipc/worktrees-orphan-directory-cleanup.test.ts b/src/main/ipc/worktrees-orphan-directory-cleanup.test.ts index 40327ab8a78..623f88713e5 100644 --- a/src/main/ipc/worktrees-orphan-directory-cleanup.test.ts +++ b/src/main/ipc/worktrees-orphan-directory-cleanup.test.ts @@ -87,7 +87,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) // Why: every removal and listing reply now names the catalog it produced or scanned. const anyCatalogVersion = { epoch: expect.any(String), sequence: expect.any(Number) } diff --git a/src/main/ipc/worktrees-removal-recovery.test.ts b/src/main/ipc/worktrees-removal-recovery.test.ts index ddfd5886dbf..042ad22ed58 100644 --- a/src/main/ipc/worktrees-removal-recovery.test.ts +++ b/src/main/ipc/worktrees-removal-recovery.test.ts @@ -111,7 +111,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) // Why: every removal and listing reply now names the catalog it produced or scanned. const anyCatalogVersion = { epoch: expect.any(String), sequence: expect.any(Number) } diff --git a/src/main/ipc/worktrees-remove-archive-hooks.test.ts b/src/main/ipc/worktrees-remove-archive-hooks.test.ts index b5e82214f55..ccc1efd0b1e 100644 --- a/src/main/ipc/worktrees-remove-archive-hooks.test.ts +++ b/src/main/ipc/worktrees-remove-archive-hooks.test.ts @@ -93,7 +93,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) // The shared IPC surface types every handler as returning `unknown`; removal's contract is // narrower, and #19334's whole point is that a caller can name and branch on it. diff --git a/src/main/ipc/worktrees-remove-preflight.test.ts b/src/main/ipc/worktrees-remove-preflight.test.ts index 6c420f3beea..ded891c6ad3 100644 --- a/src/main/ipc/worktrees-remove-preflight.test.ts +++ b/src/main/ipc/worktrees-remove-preflight.test.ts @@ -89,7 +89,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) describe('registerWorktreeHandlers', () => { let runtimeStub: WorktreeRuntimeStub diff --git a/src/main/ipc/worktrees-setup-launch-sparse-checkout.test.ts b/src/main/ipc/worktrees-setup-launch-sparse-checkout.test.ts index 1ce4365f339..5785fa825ae 100644 --- a/src/main/ipc/worktrees-setup-launch-sparse-checkout.test.ts +++ b/src/main/ipc/worktrees-setup-launch-sparse-checkout.test.ts @@ -84,7 +84,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) describe('registerWorktreeHandlers', () => { beforeEach(() => { diff --git a/src/main/ipc/worktrees-ssh-pr-head-fetch.test.ts b/src/main/ipc/worktrees-ssh-pr-head-fetch.test.ts index 8363e12c4d1..c56955fa5da 100644 --- a/src/main/ipc/worktrees-ssh-pr-head-fetch.test.ts +++ b/src/main/ipc/worktrees-ssh-pr-head-fetch.test.ts @@ -78,7 +78,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) describe('registerWorktreeHandlers', () => { let runtimeStub: WorktreeRuntimeStub diff --git a/src/main/ipc/worktrees-ssh-repo-owner-resolution.test.ts b/src/main/ipc/worktrees-ssh-repo-owner-resolution.test.ts index 53deeb0f02e..4773de79308 100644 --- a/src/main/ipc/worktrees-ssh-repo-owner-resolution.test.ts +++ b/src/main/ipc/worktrees-ssh-repo-owner-resolution.test.ts @@ -88,7 +88,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) // Why: every removal and listing reply now names the catalog it produced or scanned. const anyCatalogVersion = { epoch: expect.any(String), sequence: expect.any(Number) } diff --git a/src/main/ipc/worktrees-test-module-mocks.ts b/src/main/ipc/worktrees-test-module-mocks.ts index d75185778c4..97a38aa6d35 100644 --- a/src/main/ipc/worktrees-test-module-mocks.ts +++ b/src/main/ipc/worktrees-test-module-mocks.ts @@ -240,7 +240,8 @@ export const worktreeTeardownModuleMock = () => ({ killAllProcessesForWorktree: killAllProcessesForWorktreeMock }) -export const ptyModuleMock = () => ({ - clearProviderPtyState: clearProviderPtyStateMock, - getLocalPtyProvider: getLocalPtyProviderMock +export const ptyRegistryModuleMock = () => ({ getLocalPtyProvider: getLocalPtyProviderMock }) + +export const ptyStateCleanupModuleMock = () => ({ + clearProviderPtyState: clearProviderPtyStateMock }) diff --git a/src/main/ipc/worktrees-windows.test.ts b/src/main/ipc/worktrees-windows.test.ts index 596ff07be52..f1eb0078854 100644 --- a/src/main/ipc/worktrees-windows.test.ts +++ b/src/main/ipc/worktrees-windows.test.ts @@ -129,10 +129,10 @@ vi.mock('../runtime/worktree-teardown', () => ({ killAllProcessesForWorktree: killAllProcessesForWorktreeMock })) -vi.mock('./pty', () => ({ - clearProviderPtyState: clearProviderPtyStateMock, - getLocalPtyProvider: getLocalPtyProviderMock +vi.mock('./pty/provider/state-cleanup', () => ({ + clearProviderPtyState: clearProviderPtyStateMock })) +vi.mock('./pty/provider/registry', () => ({ getLocalPtyProvider: getLocalPtyProviderMock })) vi.mock('../terminal-history-deletion', () => ({ deleteWorktreeHistoryDir: deleteWorktreeHistoryDirMock diff --git a/src/main/ipc/worktrees-wsl-runtime-routing.test.ts b/src/main/ipc/worktrees-wsl-runtime-routing.test.ts index 915e254e0eb..eca72e290c3 100644 --- a/src/main/ipc/worktrees-wsl-runtime-routing.test.ts +++ b/src/main/ipc/worktrees-wsl-runtime-routing.test.ts @@ -98,7 +98,12 @@ vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => vi.mock('../runtime/worktree-teardown', async () => (await import('./worktrees-test-module-mocks')).worktreeTeardownModuleMock() ) -vi.mock('./pty', async () => (await import('./worktrees-test-module-mocks')).ptyModuleMock()) +vi.mock('./pty/provider/registry', async () => + (await import('./worktrees-test-module-mocks')).ptyRegistryModuleMock() +) +vi.mock('./pty/provider/state-cleanup', async () => + (await import('./worktrees-test-module-mocks')).ptyStateCleanupModuleMock() +) /** Every create-path git call, including the base-ref probe now shared with the * speculative prefetch, must read the distro's ref store rather than host git's. */ diff --git a/src/main/ipc/worktrees/removal/register-worktree-forget-handlers.ts b/src/main/ipc/worktrees/removal/register-worktree-forget-handlers.ts index a7d4c2cfc68..3b02e1d57eb 100644 --- a/src/main/ipc/worktrees/removal/register-worktree-forget-handlers.ts +++ b/src/main/ipc/worktrees/removal/register-worktree-forget-handlers.ts @@ -9,7 +9,8 @@ import { getRepoExecutionHostId, parseExecutionHostId } from '../../../../shared import type { ExecutionHostId } from '../../../../shared/execution-host' import type { Repo } from '../../../../shared/repo-types' import { isFolderRepo } from '../../../../shared/repo-kind' -import { getLocalPtyProvider, clearProviderPtyState } from '../../pty' +import { getLocalPtyProvider } from '../../pty/provider/registry' +import { clearProviderPtyState } from '../../pty/provider/state-cleanup' import { killAllProcessesForWorktree } from '../../../runtime/worktree-teardown' import { invalidateAuthorizedRootsCache } from '../../registered-worktree-roots-cache' import { preservedBranchCleanupScopeKey } from '../../../../shared/preserved-branch-cleanup' diff --git a/src/main/ipc/worktrees/removal/remove-folder-workspace.ts b/src/main/ipc/worktrees/removal/remove-folder-workspace.ts index 36484656898..a6eb9d5de31 100644 --- a/src/main/ipc/worktrees/removal/remove-folder-workspace.ts +++ b/src/main/ipc/worktrees/removal/remove-folder-workspace.ts @@ -5,7 +5,8 @@ import { killAllProcessesForWorktree } from '../../../runtime/worktree-teardown' import { withWorktreeRemoveStageSpan } from '../../../observability/instrumentation' import { preservedBranchCleanupScopeKey } from '../../../../shared/preserved-branch-cleanup' import { notifyWorktreesChanged } from '../../worktree-remote' -import { clearProviderPtyState, getLocalPtyProvider } from '../../pty' +import { clearProviderPtyState } from '../../pty/provider/state-cleanup' +import { getLocalPtyProvider } from '../../pty/provider/registry' import type { RemoveWorktreeArgs } from '../ipc-context-schemas' import type { WorktreeIpcContext } from '../worktree-ipc-context' import { getFolderWorkspaceRootId } from '../folder-workspace-model' diff --git a/src/main/ipc/worktrees/removal/worktree-removal-ownership.ts b/src/main/ipc/worktrees/removal/worktree-removal-ownership.ts index 39d17a287c9..a3b17ce9b87 100644 --- a/src/main/ipc/worktrees/removal/worktree-removal-ownership.ts +++ b/src/main/ipc/worktrees/removal/worktree-removal-ownership.ts @@ -1,5 +1,6 @@ import type { OrcaRuntimeService } from '../../../runtime/orca-runtime' -import { getLocalPtyProvider, clearProviderPtyState } from '../../pty' +import { getLocalPtyProvider } from '../../pty/provider/registry' +import { clearProviderPtyState } from '../../pty/provider/state-cleanup' import { killAllProcessesForWorktree } from '../../../runtime/worktree-teardown' import type { Store } from '../../../persistence/loading-store/store' import { getRepoExecutionHostId } from '../../../../shared/execution-host' diff --git a/src/main/local-builds/local-build-compatibility.ts b/src/main/local-builds/local-build-compatibility.ts index f36fcf4678c..a8b60f80b00 100644 --- a/src/main/local-builds/local-build-compatibility.ts +++ b/src/main/local-builds/local-build-compatibility.ts @@ -6,7 +6,7 @@ import { import { DegradedDaemonPtyProvider } from '../daemon/degraded-daemon-pty-provider' import { getDaemonProvider } from '../daemon/daemon-provider-state' import { getAllDaemonAdapters } from '../daemon/daemon-provider-routing' -import { getLocalPtyProvider } from '../ipc/pty' +import { getLocalPtyProvider } from '../ipc/pty/provider/registry' import { LocalPtyProvider } from '../providers/local-pty-provider' export type LocalBuildCompatibilityResult = { diff --git a/src/main/orcad/main-preflight-order.test.ts b/src/main/orcad/main-preflight-order.test.ts index 5da4ac08d44..5b1bdd4831e 100644 --- a/src/main/orcad/main-preflight-order.test.ts +++ b/src/main/orcad/main-preflight-order.test.ts @@ -10,8 +10,8 @@ import { /** * The precondition is only worth anything if it runs first. A loader failure is not - * catchable, so a preflight that lands after `main()` has already reached - * `await import('../ipc/pty')` prevents nothing. + * catchable, so a preflight that lands after `main()` has already imported + * the PTY runtime prevents nothing. */ const { order, profileProbe, reserveStdout } = vi.hoisted(() => { const order: string[] = [] diff --git a/src/main/orcad/orcad-entry.ts b/src/main/orcad/orcad-entry.ts index 033b753d762..259f1510c25 100644 --- a/src/main/orcad/orcad-entry.ts +++ b/src/main/orcad/orcad-entry.ts @@ -159,7 +159,8 @@ async function startOrcadRuntime( ): Promise> { const { OrcaRuntimeService } = await import('../runtime/orca-runtime') const { OrcaRuntimeRpcServer } = await import('../runtime/runtime-rpc') - const { registerHeadlessPtyRuntime, getLocalPtyProvider } = await import('../ipc/pty') + const { registerHeadlessPtyRuntime } = await import('../ipc/pty/register-headless-runtime') + const { getLocalPtyProvider } = await import('../ipc/pty/provider/registry') const { getAppEnvironment } = await import('../../shared/app-environment') const { installOrcadObservability } = await import('./orcad-observability') closeOrcadObservability = installOrcadObservability() diff --git a/src/main/orcad/orcad-managed-idle-exit-host.ts b/src/main/orcad/orcad-managed-idle-exit-host.ts index e3826dcd712..499f6372f72 100644 --- a/src/main/orcad/orcad-managed-idle-exit-host.ts +++ b/src/main/orcad/orcad-managed-idle-exit-host.ts @@ -63,7 +63,7 @@ async function startOrcadManagedIdleExit( version: string } ): Promise { - const { getLocalPtyProvider } = await import('../ipc/pty') + const { getLocalPtyProvider } = await import('../ipc/pty/provider/registry') const { getDaemonEndpointFacts } = await import('../daemon/daemon-provider-state') const { countLiveOrcadDaemonSessions, retireOrcadDaemonIfIdle } = await import('./orcad-daemon-retirement') diff --git a/src/main/orcad/orcad-managed-idle-exit-provider-race.test.ts b/src/main/orcad/orcad-managed-idle-exit-provider-race.test.ts index a5ac52b1612..b909cc4b16c 100644 --- a/src/main/orcad/orcad-managed-idle-exit-provider-race.test.ts +++ b/src/main/orcad/orcad-managed-idle-exit-provider-race.test.ts @@ -11,7 +11,9 @@ const { hasLoadedProviders } = vi.hoisted(() => ({ hasLoadedProviders: vi.fn(() vi.mock('../native-chat/agent-session-wire/structured-agent-session-registry', () => ({ getStructuredAgentSessionHost: () => ({ hasLoadedProviders }) })) -vi.mock('../ipc/pty', () => ({ getLocalPtyProvider: () => ({ listProcesses: async () => [] }) })) +vi.mock('../ipc/pty/provider/registry', () => ({ + getLocalPtyProvider: () => ({ listProcesses: async () => [] }) +})) vi.mock('../daemon/daemon-init', () => ({ getDaemonEndpointFacts: () => null })) vi.mock('./orcad-daemon-retirement', () => ({ countLiveOrcadDaemonSessions: vi.fn(async () => 0), diff --git a/src/main/orcad/orcad-push-startup.test.ts b/src/main/orcad/orcad-push-startup.test.ts index b1dec6a8252..95c8e56ef9b 100644 --- a/src/main/orcad/orcad-push-startup.test.ts +++ b/src/main/orcad/orcad-push-startup.test.ts @@ -80,10 +80,10 @@ vi.mock('../runtime/agent-state-rules/agent-state-rules-live-update', () => ({ startAgentStateRulesLiveUpdates: () => {} })) vi.mock('../daemon/daemon-provider-state', () => ({ daemonOwnsFreshPersistentPtys: () => false })) -vi.mock('../ipc/pty', () => ({ - registerHeadlessPtyRuntime: async () => {}, - getLocalPtyProvider: () => null +vi.mock('../ipc/pty/register-headless-runtime', () => ({ + registerHeadlessPtyRuntime: async () => {} })) +vi.mock('../ipc/pty/provider/registry', () => ({ getLocalPtyProvider: () => null })) vi.mock('./orcad-profile-state-startup', () => ({ createOrcadProfileStateStartup: async () => { const error = state.profileStartupErrors.shift() diff --git a/src/main/providers/provider-dispatch.test.ts b/src/main/providers/provider-dispatch.test.ts index 6a9591dec89..013faa18f73 100644 --- a/src/main/providers/provider-dispatch.test.ts +++ b/src/main/providers/provider-dispatch.test.ts @@ -54,7 +54,7 @@ vi.mock('../pi/titlebar-extension-service', () => ({ piTitlebarExtensionService: { buildPtyEnv: () => ({}), clearPty: vi.fn() } })) -import { registerPtyHandlers } from '../ipc/pty' +import { registerPtyHandlers } from '../ipc/pty/register-handlers' describe('PTY provider dispatch', () => { const handlers = new Map unknown>() diff --git a/src/main/startup/codex-launch-preparation.ts b/src/main/startup/codex-launch-preparation.ts index 716b4830ef8..f60345640ac 100644 --- a/src/main/startup/codex-launch-preparation.ts +++ b/src/main/startup/codex-launch-preparation.ts @@ -1,4 +1,4 @@ -import type { CodexHomeLaunchContext } from '../ipc/pty' +import type { CodexHomeLaunchContext } from '../ipc/pty/host-env/types' import type { CodexAccountSelectionTarget } from '../codex-accounts/runtime-selection' import { codexHookService } from '../codex/hook-service' import { getDefaultWslDistro } from '../wsl' diff --git a/src/main/startup/headless-serve-ssh-registration.test.ts b/src/main/startup/headless-serve-ssh-registration.test.ts index b41fa91a167..9212d7923a6 100644 --- a/src/main/startup/headless-serve-ssh-registration.test.ts +++ b/src/main/startup/headless-serve-ssh-registration.test.ts @@ -11,7 +11,6 @@ vi.mock('../ssh/ssh-connection-store', () => mocks.sshConnectionStore) vi.mock('../ipc/ssh-host-server-connect', () => mocks.hostServerConnect) vi.mock('../ssh/ssh-connection-manager', () => mocks.sshConnectionManager) vi.mock('../ssh/ssh-channel-multiplexer', () => mocks.sshChannelMultiplexer) -vi.mock('../ipc/pty', () => mocks.pty) vi.mock('../ssh/ssh-port-forward', () => mocks.sshPortForward) vi.mock('../ssh/ssh-port-scanner', () => mocks.sshPortScanner) diff --git a/src/main/startup/main-process-pty-startup.ts b/src/main/startup/main-process-pty-startup.ts index 20136d4e9d5..64f7ea41f38 100644 --- a/src/main/startup/main-process-pty-startup.ts +++ b/src/main/startup/main-process-pty-startup.ts @@ -1,7 +1,7 @@ import { app } from 'electron' import { classifyError } from '../telemetry/classify-error' import { track } from '../telemetry/client' -import { getPtyIdForPaneKey } from '../ipc/pty' +import { getPtyIdForPaneKey } from '../ipc/pty/pane/key-state' import { getDaemonProvider, listLiveDaemonPtyIds } from '../daemon/daemon-provider-state' import { initDaemonPtyProvider } from '../daemon/daemon-provider-init' import { diff --git a/src/main/startup/main-process-quit-pending-writer.test.ts b/src/main/startup/main-process-quit-pending-writer.test.ts index c75d2191237..75aa1ffa6d2 100644 --- a/src/main/startup/main-process-quit-pending-writer.test.ts +++ b/src/main/startup/main-process-quit-pending-writer.test.ts @@ -11,7 +11,7 @@ const dependencies: Record> = { '../ipc/filesystem-watcher': { closeAllWatchers: settled() }, '../ipc/worktree-base-directory-watcher': { disposeWorktreeBaseDirectoryWatchers: settled() }, '../ipc/folder-repo-git-upgrade': { stopFolderRepoGitUpgradeWatch: idle() }, - '../ipc/pty': { killAllPty: idle() }, + '../ipc/pty/kill-all': { killAllPty: idle() }, '../daemon/daemon-provider-state': { disconnectDaemon: settled(), shutdownDaemon: settled() }, '../ipc/ssh-shutdown-drain': { beginSshShutdown: settled() }, '../agent-hooks/server': { agentHookServer: { stop: stopAgentHookServer } }, diff --git a/src/main/startup/main-process-quit-update-veto.test.ts b/src/main/startup/main-process-quit-update-veto.test.ts index 4164f2b039a..c21a87ddda0 100644 --- a/src/main/startup/main-process-quit-update-veto.test.ts +++ b/src/main/startup/main-process-quit-update-veto.test.ts @@ -5,7 +5,7 @@ const dependencyExports: [string, string[]][] = [ ['../ipc/filesystem-watcher', ['closeAllWatchers']], ['../ipc/worktree-base-directory-watcher', ['disposeWorktreeBaseDirectoryWatchers']], ['../ipc/folder-repo-git-upgrade', ['stopFolderRepoGitUpgradeWatch']], - ['../ipc/pty', ['killAllPty']], + ['../ipc/pty/kill-all', ['killAllPty']], ['../daemon/daemon-provider-state', ['disconnectDaemon', 'shutdownDaemon']], ['../ipc/ssh-shutdown-drain', ['beginSshShutdown']], ['../agent-hooks/server', ['agentHookServer']], diff --git a/src/main/startup/main-process-quit.ts b/src/main/startup/main-process-quit.ts index d96163ec377..df9901d665e 100644 --- a/src/main/startup/main-process-quit.ts +++ b/src/main/startup/main-process-quit.ts @@ -2,7 +2,7 @@ import { app, type Event } from 'electron' import { closeAllWatchers } from '../ipc/filesystem-watcher' import { disposeWorktreeBaseDirectoryWatchers } from '../ipc/worktree-base-directory-watcher' import { stopFolderRepoGitUpgradeWatch } from '../ipc/folder-repo-git-upgrade' -import { killAllPty } from '../ipc/pty' +import { killAllPty } from '../ipc/pty/kill-all' import { disconnectDaemon, shutdownDaemon } from '../daemon/daemon-provider-state' import { beginSshShutdown } from '../ipc/ssh-shutdown-drain' import { agentHookServer } from '../agent-hooks/server' diff --git a/src/main/startup/main-process-runtime-launch-activation.test.ts b/src/main/startup/main-process-runtime-launch-activation.test.ts index 9008145308e..3b40deb6021 100644 --- a/src/main/startup/main-process-runtime-launch-activation.test.ts +++ b/src/main/startup/main-process-runtime-launch-activation.test.ts @@ -43,10 +43,8 @@ vi.mock('../ipc/mobile', () => ({ registerMobileHandlers: vi.fn() })) vi.mock('../ipc/runtime-environment-mobile-relay-hosts', () => ({ createRuntimeEnvironmentMobileRelayHosts: vi.fn() })) -vi.mock('../ipc/pty', () => ({ - getLocalPtyProvider: vi.fn(), - registerHeadlessPtyRuntime: vi.fn() -})) +vi.mock('../ipc/pty/provider/registry', () => ({ getLocalPtyProvider: vi.fn() })) +vi.mock('../ipc/pty/register-headless-runtime', () => ({ registerHeadlessPtyRuntime: vi.fn() })) vi.mock('../providers/local-pty-provider', () => ({ LocalPtyProvider: class {} })) vi.mock('../browser/offscreen-browser-backend', () => ({ OffscreenBrowserBackend: class {} })) vi.mock('../browser/browser-manager', () => ({ browserManager: {} })) diff --git a/src/main/startup/main-process-runtime-launch.ts b/src/main/startup/main-process-runtime-launch.ts index 3d81b25c4f3..d9429a61d11 100644 --- a/src/main/startup/main-process-runtime-launch.ts +++ b/src/main/startup/main-process-runtime-launch.ts @@ -7,7 +7,8 @@ import { import { OrcaRuntimeRpcServer } from '../runtime/runtime-rpc' import { registerMobileHandlers } from '../ipc/mobile' import { createRuntimeEnvironmentMobileRelayHosts } from '../ipc/runtime-environment-mobile-relay-hosts' -import { getLocalPtyProvider, registerHeadlessPtyRuntime } from '../ipc/pty' +import { getLocalPtyProvider } from '../ipc/pty/provider/registry' +import { registerHeadlessPtyRuntime } from '../ipc/pty/register-headless-runtime' import { LocalPtyProvider } from '../providers/local-pty-provider' import { publishHeadlessRuntimeGraph } from '../runtime/headless-runtime-graph' import { OffscreenBrowserBackend } from '../browser/offscreen-browser-backend' diff --git a/src/main/startup/main-process-runtime-service.ts b/src/main/startup/main-process-runtime-service.ts index 5d4e1478a18..3f5c9d6b929 100644 --- a/src/main/startup/main-process-runtime-service.ts +++ b/src/main/startup/main-process-runtime-service.ts @@ -7,7 +7,8 @@ import { sessionSearchScopeCatalogFromStore } from '../ai-vault-search/session-s import { getCanonicalUserDataPath } from '../persistence/loading-store/user-data-path' import { app } from 'electron' import { OrcaRuntimeService } from '../runtime/orca-runtime' -import { getLocalPtyProvider, clearProviderPtyState } from '../ipc/pty' +import { getLocalPtyProvider } from '../ipc/pty/provider/registry' +import { clearProviderPtyState } from '../ipc/pty/provider/state-cleanup' import { agentHookServer } from '../agent-hooks/server' import { browserManager } from '../browser/browser-manager' import { loadAgentSessionClaimSigner } from '../runtime/agent-session-claim-identity' diff --git a/src/main/startup/synthetic-title-runtime.ts b/src/main/startup/synthetic-title-runtime.ts index 57782d7087d..8da2738860d 100644 --- a/src/main/startup/synthetic-title-runtime.ts +++ b/src/main/startup/synthetic-title-runtime.ts @@ -1,4 +1,4 @@ -import { registerPaneKeyTeardownListener, getPtyIdForPaneKey } from '../ipc/pty' +import { registerPaneKeyTeardownListener, getPtyIdForPaneKey } from '../ipc/pty/pane/key-state' import { agentHookServer } from '../agent-hooks/server' import type { AgentStatusState } from '../../shared/agent-status-types' import type { SyntheticAgentTitleProfile } from '../../shared/synthetic-agent-title' diff --git a/src/main/updater-linux-package-recovery-actions.test.ts b/src/main/updater-linux-package-recovery-actions.test.ts index 60912443180..6b48d0cc4fc 100644 --- a/src/main/updater-linux-package-recovery-actions.test.ts +++ b/src/main/updater-linux-package-recovery-actions.test.ts @@ -68,7 +68,7 @@ vi.mock('electron', () => ({ vi.mock('electron-updater', () => ({ autoUpdater: autoUpdaterMock })) vi.mock('./electron-updater-loader', () => ({ loadElectronAutoUpdater: () => autoUpdaterMock })) vi.mock('@electron-toolkit/utils', () => ({ is: { dev: false } })) -vi.mock('./ipc/pty', () => ({ killAllPty: vi.fn() })) +vi.mock('./ipc/pty/kill-all', () => ({ killAllPty: vi.fn() })) vi.mock('./updater-changelog', () => ({ fetchChangelog: vi.fn().mockResolvedValue(null) })) vi.mock('./updater-nudge', () => ({ fetchNudge: vi.fn().mockResolvedValue(null), diff --git a/src/main/updater-sqlite-profile-downgrade.test.ts b/src/main/updater-sqlite-profile-downgrade.test.ts index a283fe18d81..1053bd88512 100644 --- a/src/main/updater-sqlite-profile-downgrade.test.ts +++ b/src/main/updater-sqlite-profile-downgrade.test.ts @@ -8,7 +8,7 @@ vi.mock('electron', () => moduleFactories.electron()) vi.mock('electron-updater', () => moduleFactories.electronUpdater()) vi.mock('./electron-updater-loader', () => moduleFactories.electronUpdaterLoader()) vi.mock('@electron-toolkit/utils', () => moduleFactories.electronToolkitUtils()) -vi.mock('./ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('./ipc/pty/kill-all', () => moduleFactories.ptyKillAll()) vi.mock('./linux-update-package-type', () => moduleFactories.linuxUpdatePackageType()) vi.mock('./updater-lifecycle-diagnostics', () => moduleFactories.updaterLifecycleDiagnostics()) vi.mock('./updater-changelog', () => moduleFactories.updaterChangelog()) diff --git a/src/main/updater-test-harness.ts b/src/main/updater-test-harness.ts index 955ae25058a..11a94a460b4 100644 --- a/src/main/updater-test-harness.ts +++ b/src/main/updater-test-harness.ts @@ -46,7 +46,7 @@ type UpdaterModuleFactories = { electronUpdater: () => { autoUpdater: AutoUpdaterMock } electronUpdaterLoader: () => { loadElectronAutoUpdater: () => AutoUpdaterMock } electronToolkitUtils: () => { is: { dev: boolean } } - ipcPty: () => { killAllPty: UpdaterSpy } + ptyKillAll: () => { killAllPty: UpdaterSpy } linuxUpdatePackageType: () => { getLinuxPackageType: Mock<() => LinuxPackageType> getLinuxRootPackageType: Mock<() => 'deb' | 'rpm' | null> @@ -238,7 +238,7 @@ export function createUpdaterMocks(): UpdaterMocks { electronUpdater: () => ({ autoUpdater: autoUpdaterMock }), electronUpdaterLoader: () => ({ loadElectronAutoUpdater: loadGenerationScopedAutoUpdater }), electronToolkitUtils: () => ({ is: isMock }), - ipcPty: () => ({ killAllPty: killAllPtyMock }), + ptyKillAll: () => ({ killAllPty: killAllPtyMock }), // Why: only the marker resolver is faked so the real artifact capture/redaction path stays under test. linuxUpdatePackageType: () => ({ getLinuxPackageType: getLinuxPackageTypeMock, diff --git a/src/main/updater.build-channel-selection.test.ts b/src/main/updater.build-channel-selection.test.ts index 32253a57b45..6932143ea94 100644 --- a/src/main/updater.build-channel-selection.test.ts +++ b/src/main/updater.build-channel-selection.test.ts @@ -15,7 +15,7 @@ vi.mock('electron', () => moduleFactories.electron()) vi.mock('electron-updater', () => moduleFactories.electronUpdater()) vi.mock('./electron-updater-loader', () => moduleFactories.electronUpdaterLoader()) vi.mock('@electron-toolkit/utils', () => moduleFactories.electronToolkitUtils()) -vi.mock('./ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('./ipc/pty/kill-all', () => moduleFactories.ptyKillAll()) vi.mock('./linux-update-package-type', () => moduleFactories.linuxUpdatePackageType()) vi.mock('./updater-lifecycle-diagnostics', () => moduleFactories.updaterLifecycleDiagnostics()) vi.mock('./updater-changelog', () => moduleFactories.updaterChangelog()) diff --git a/src/main/updater.check-failure.test.ts b/src/main/updater.check-failure.test.ts index 5093052290f..53f3359686c 100644 --- a/src/main/updater.check-failure.test.ts +++ b/src/main/updater.check-failure.test.ts @@ -104,9 +104,7 @@ vi.mock('@electron-toolkit/utils', () => ({ is: isMock })) -vi.mock('./ipc/pty', () => ({ - killAllPty: killAllPtyMock -})) +vi.mock('./ipc/pty/kill-all', () => ({ killAllPty: killAllPtyMock })) vi.mock('./updater-nudge', () => ({ fetchNudge: vi.fn().mockResolvedValue(null), diff --git a/src/main/updater.check-preflight.test.ts b/src/main/updater.check-preflight.test.ts index 5e1476e8fb9..2a26a8df353 100644 --- a/src/main/updater.check-preflight.test.ts +++ b/src/main/updater.check-preflight.test.ts @@ -15,7 +15,7 @@ vi.mock('electron', () => moduleFactories.electron()) vi.mock('electron-updater', () => moduleFactories.electronUpdater()) vi.mock('./electron-updater-loader', () => moduleFactories.electronUpdaterLoader()) vi.mock('@electron-toolkit/utils', () => moduleFactories.electronToolkitUtils()) -vi.mock('./ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('./ipc/pty/kill-all', () => moduleFactories.ptyKillAll()) vi.mock('./linux-update-package-type', () => moduleFactories.linuxUpdatePackageType()) vi.mock('./updater-lifecycle-diagnostics', () => moduleFactories.updaterLifecycleDiagnostics()) vi.mock('./updater-changelog', () => moduleFactories.updaterChangelog()) diff --git a/src/main/updater.check-settlement.test.ts b/src/main/updater.check-settlement.test.ts index 6513dc40628..82d9aa144ac 100644 --- a/src/main/updater.check-settlement.test.ts +++ b/src/main/updater.check-settlement.test.ts @@ -14,7 +14,7 @@ vi.mock('electron', () => moduleFactories.electron()) vi.mock('electron-updater', () => moduleFactories.electronUpdater()) vi.mock('./electron-updater-loader', () => moduleFactories.electronUpdaterLoader()) vi.mock('@electron-toolkit/utils', () => moduleFactories.electronToolkitUtils()) -vi.mock('./ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('./ipc/pty/kill-all', () => moduleFactories.ptyKillAll()) vi.mock('./linux-update-package-type', () => moduleFactories.linuxUpdatePackageType()) vi.mock('./updater-lifecycle-diagnostics', () => moduleFactories.updaterLifecycleDiagnostics()) vi.mock('./updater-changelog', () => moduleFactories.updaterChangelog()) diff --git a/src/main/updater.feed-attempt-lifetime.test.ts b/src/main/updater.feed-attempt-lifetime.test.ts index 3df242dfa13..df278023d11 100644 --- a/src/main/updater.feed-attempt-lifetime.test.ts +++ b/src/main/updater.feed-attempt-lifetime.test.ts @@ -8,7 +8,7 @@ vi.mock('electron', () => moduleFactories.electron()) vi.mock('electron-updater', () => moduleFactories.electronUpdater()) vi.mock('./electron-updater-loader', () => moduleFactories.electronUpdaterLoader()) vi.mock('@electron-toolkit/utils', () => moduleFactories.electronToolkitUtils()) -vi.mock('./ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('./ipc/pty/kill-all', () => moduleFactories.ptyKillAll()) vi.mock('./linux-update-package-type', () => moduleFactories.linuxUpdatePackageType()) vi.mock('./updater-lifecycle-diagnostics', () => moduleFactories.updaterLifecycleDiagnostics()) vi.mock('./updater-changelog', () => moduleFactories.updaterChangelog()) diff --git a/src/main/updater.headless-serve-install.test.ts b/src/main/updater.headless-serve-install.test.ts index 0cffa0b7760..f7504df1f50 100644 --- a/src/main/updater.headless-serve-install.test.ts +++ b/src/main/updater.headless-serve-install.test.ts @@ -96,7 +96,7 @@ vi.mock('./linux-update-package-type', () => ({ isExternallyManagedLinuxInstall: () => false })) vi.mock('@electron-toolkit/utils', () => ({ is: { dev: false } })) -vi.mock('./ipc/pty', () => ({ killAllPty: killAllPtyMock })) +vi.mock('./ipc/pty/kill-all', () => ({ killAllPty: killAllPtyMock })) vi.mock('./updater-changelog', () => ({ fetchChangelog: vi.fn().mockResolvedValue(null) })) vi.mock('./updater-nudge', () => ({ fetchNudge: vi.fn().mockResolvedValue(null), diff --git a/src/main/updater.install-failure-cause.test.ts b/src/main/updater.install-failure-cause.test.ts index 95b539ca00e..22a5db36863 100644 --- a/src/main/updater.install-failure-cause.test.ts +++ b/src/main/updater.install-failure-cause.test.ts @@ -99,7 +99,7 @@ vi.mock('./electron-updater-loader', () => ({ loadElectronAutoUpdater: () => autoUpdaterMock })) vi.mock('@electron-toolkit/utils', () => ({ is: isMock })) -vi.mock('./ipc/pty', () => ({ killAllPty: killAllPtyMock })) +vi.mock('./ipc/pty/kill-all', () => ({ killAllPty: killAllPtyMock })) vi.mock('./updater-changelog', () => ({ fetchChangelog: vi.fn().mockResolvedValue(null) })) diff --git a/src/main/updater.linux-externally-managed.test.ts b/src/main/updater.linux-externally-managed.test.ts index ba7ab045213..f0a78fb4262 100644 --- a/src/main/updater.linux-externally-managed.test.ts +++ b/src/main/updater.linux-externally-managed.test.ts @@ -17,7 +17,7 @@ vi.mock('electron', () => moduleFactories.electron()) vi.mock('electron-updater', () => moduleFactories.electronUpdater()) vi.mock('./electron-updater-loader', () => moduleFactories.electronUpdaterLoader()) vi.mock('@electron-toolkit/utils', () => moduleFactories.electronToolkitUtils()) -vi.mock('./ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('./ipc/pty/kill-all', () => moduleFactories.ptyKillAll()) vi.mock('./linux-update-package-type', () => moduleFactories.linuxUpdatePackageType()) vi.mock('./updater-lifecycle-diagnostics', () => moduleFactories.updaterLifecycleDiagnostics()) vi.mock('./updater-changelog', () => moduleFactories.updaterChangelog()) diff --git a/src/main/updater.linux-root-package-install.test.ts b/src/main/updater.linux-root-package-install.test.ts index 01f489bd8ef..29a1e611a37 100644 --- a/src/main/updater.linux-root-package-install.test.ts +++ b/src/main/updater.linux-root-package-install.test.ts @@ -22,7 +22,7 @@ vi.mock('electron', () => moduleFactories.electron()) vi.mock('electron-updater', () => moduleFactories.electronUpdater()) vi.mock('./electron-updater-loader', () => moduleFactories.electronUpdaterLoader()) vi.mock('@electron-toolkit/utils', () => moduleFactories.electronToolkitUtils()) -vi.mock('./ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('./ipc/pty/kill-all', () => moduleFactories.ptyKillAll()) vi.mock('./linux-update-package-type', () => moduleFactories.linuxUpdatePackageType()) vi.mock('./updater-lifecycle-diagnostics', () => moduleFactories.updaterLifecycleDiagnostics()) vi.mock('./updater-changelog', () => moduleFactories.updaterChangelog()) diff --git a/src/main/updater.mac-install.test.ts b/src/main/updater.mac-install.test.ts index e153032b178..0365eb60c71 100644 --- a/src/main/updater.mac-install.test.ts +++ b/src/main/updater.mac-install.test.ts @@ -111,9 +111,7 @@ vi.mock('@electron-toolkit/utils', () => ({ is: isMock })) -vi.mock('./ipc/pty', () => ({ - killAllPty: killAllPtyMock -})) +vi.mock('./ipc/pty/kill-all', () => ({ killAllPty: killAllPtyMock })) vi.mock('./updater-changelog', () => ({ fetchChangelog: vi.fn().mockResolvedValue(null) diff --git a/src/main/updater.nudge-campaign.test.ts b/src/main/updater.nudge-campaign.test.ts index eb3faf1eaa2..6221c26599c 100644 --- a/src/main/updater.nudge-campaign.test.ts +++ b/src/main/updater.nudge-campaign.test.ts @@ -15,7 +15,7 @@ vi.mock('electron', () => moduleFactories.electron()) vi.mock('electron-updater', () => moduleFactories.electronUpdater()) vi.mock('./electron-updater-loader', () => moduleFactories.electronUpdaterLoader()) vi.mock('@electron-toolkit/utils', () => moduleFactories.electronToolkitUtils()) -vi.mock('./ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('./ipc/pty/kill-all', () => moduleFactories.ptyKillAll()) vi.mock('./linux-update-package-type', () => moduleFactories.linuxUpdatePackageType()) vi.mock('./updater-lifecycle-diagnostics', () => moduleFactories.updaterLifecycleDiagnostics()) vi.mock('./updater-changelog', () => moduleFactories.updaterChangelog()) diff --git a/src/main/updater.prerelease-fallback.test.ts b/src/main/updater.prerelease-fallback.test.ts index ae034980074..64b7c6dfd9b 100644 --- a/src/main/updater.prerelease-fallback.test.ts +++ b/src/main/updater.prerelease-fallback.test.ts @@ -8,7 +8,7 @@ vi.mock('electron', () => moduleFactories.electron()) vi.mock('electron-updater', () => moduleFactories.electronUpdater()) vi.mock('./electron-updater-loader', () => moduleFactories.electronUpdaterLoader()) vi.mock('@electron-toolkit/utils', () => moduleFactories.electronToolkitUtils()) -vi.mock('./ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('./ipc/pty/kill-all', () => moduleFactories.ptyKillAll()) vi.mock('./linux-update-package-type', () => moduleFactories.linuxUpdatePackageType()) vi.mock('./updater-lifecycle-diagnostics', () => moduleFactories.updaterLifecycleDiagnostics()) vi.mock('./updater-changelog', () => moduleFactories.updaterChangelog()) diff --git a/src/main/updater.publishing-window-feed.test.ts b/src/main/updater.publishing-window-feed.test.ts index 144eae55845..2e90d9eaefd 100644 --- a/src/main/updater.publishing-window-feed.test.ts +++ b/src/main/updater.publishing-window-feed.test.ts @@ -15,7 +15,7 @@ vi.mock('electron', () => moduleFactories.electron()) vi.mock('electron-updater', () => moduleFactories.electronUpdater()) vi.mock('./electron-updater-loader', () => moduleFactories.electronUpdaterLoader()) vi.mock('@electron-toolkit/utils', () => moduleFactories.electronToolkitUtils()) -vi.mock('./ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('./ipc/pty/kill-all', () => moduleFactories.ptyKillAll()) vi.mock('./linux-update-package-type', () => moduleFactories.linuxUpdatePackageType()) vi.mock('./updater-lifecycle-diagnostics', () => moduleFactories.updaterLifecycleDiagnostics()) vi.mock('./updater-changelog', () => moduleFactories.updaterChangelog()) diff --git a/src/main/updater.quit-and-install.test.ts b/src/main/updater.quit-and-install.test.ts index d5ba376e02e..6b8e598e796 100644 --- a/src/main/updater.quit-and-install.test.ts +++ b/src/main/updater.quit-and-install.test.ts @@ -21,7 +21,7 @@ vi.mock('electron', () => moduleFactories.electron()) vi.mock('electron-updater', () => moduleFactories.electronUpdater()) vi.mock('./electron-updater-loader', () => moduleFactories.electronUpdaterLoader()) vi.mock('@electron-toolkit/utils', () => moduleFactories.electronToolkitUtils()) -vi.mock('./ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('./ipc/pty/kill-all', () => moduleFactories.ptyKillAll()) vi.mock('./linux-update-package-type', () => moduleFactories.linuxUpdatePackageType()) vi.mock('./updater-lifecycle-diagnostics', () => moduleFactories.updaterLifecycleDiagnostics()) vi.mock('./updater-changelog', () => moduleFactories.updaterChangelog()) diff --git a/src/main/updater.startup-scheduling.test.ts b/src/main/updater.startup-scheduling.test.ts index 28574329560..5c7ae53793b 100644 --- a/src/main/updater.startup-scheduling.test.ts +++ b/src/main/updater.startup-scheduling.test.ts @@ -16,7 +16,7 @@ vi.mock('electron', () => moduleFactories.electron()) vi.mock('electron-updater', () => moduleFactories.electronUpdater()) vi.mock('./electron-updater-loader', () => moduleFactories.electronUpdaterLoader()) vi.mock('@electron-toolkit/utils', () => moduleFactories.electronToolkitUtils()) -vi.mock('./ipc/pty', () => moduleFactories.ipcPty()) +vi.mock('./ipc/pty/kill-all', () => moduleFactories.ptyKillAll()) vi.mock('./linux-update-package-type', () => moduleFactories.linuxUpdatePackageType()) vi.mock('./updater-lifecycle-diagnostics', () => moduleFactories.updaterLifecycleDiagnostics()) vi.mock('./updater-changelog', () => moduleFactories.updaterChangelog()) diff --git a/src/main/updater/updater-install-execution.ts b/src/main/updater/updater-install-execution.ts index 1f9a23b2b46..304fb97a150 100644 --- a/src/main/updater/updater-install-execution.ts +++ b/src/main/updater/updater-install-execution.ts @@ -1,5 +1,5 @@ import { BrowserWindow } from 'electron' -import { killAllPty } from '../ipc/pty' +import { killAllPty } from '../ipc/pty/kill-all' import { withUpdaterSpan } from '../observability/instrumentation' import { runWithLaunchPath } from '../startup/hydrate-shell-path' import { diff --git a/src/main/window/attach-main-window-services.test.ts b/src/main/window/attach-main-window-services.test.ts index 40c7647b900..15844ea081a 100644 --- a/src/main/window/attach-main-window-services.test.ts +++ b/src/main/window/attach-main-window-services.test.ts @@ -112,10 +112,8 @@ vi.mock('../ipc/worktree-change-invalidators', () => ({ runWorktreeChangeInvalidators: runWorktreeChangeInvalidatorsMock })) -vi.mock('../ipc/pty', () => ({ - getLocalPtyProvider: vi.fn(), - registerPtyHandlers: registerPtyHandlersMock -})) +vi.mock('../ipc/pty/provider/registry', () => ({ getLocalPtyProvider: vi.fn() })) +vi.mock('../ipc/pty/register-handlers', () => ({ registerPtyHandlers: registerPtyHandlersMock })) vi.mock('../ipc/ssh', () => ({ registerSshHandlers: registerSshHandlersMock })) vi.mock('../ipc/pty-management', () => ({ diff --git a/src/main/window/attach-main-window-services.ts b/src/main/window/attach-main-window-services.ts index ecbb3df6877..89637c61335 100644 --- a/src/main/window/attach-main-window-services.ts +++ b/src/main/window/attach-main-window-services.ts @@ -12,12 +12,12 @@ import { setRepoRemoteClientNotifier } from '../ipc/repos/repos-changed-notifica import { setWorktreeCatalogRemoteClientNotifier } from '../ipc/watched-worktree-catalog-notification' import { registerWorktreeHandlers } from '../ipc/worktrees' import { registerWorkspaceCleanupHandlers } from '../ipc/workspace-cleanup' -import { - registerPtyHandlers, - type CodexHomePtySpawnedLifecycleArgs, - type GetSelectedCodexHomePath, - type PrepareCodexSessionResume -} from '../ipc/pty' +import { registerPtyHandlers } from '../ipc/pty/register-handlers' +import type { + CodexHomePtySpawnedLifecycleArgs, + GetSelectedCodexHomePath, + PrepareCodexSessionResume +} from '../ipc/pty/host-env/types' import { registerDaemonManagementHandlers } from '../ipc/pty-management' import { registerSshHandlers } from '../ipc/ssh' import { browserManager } from '../browser/browser-manager' diff --git a/src/main/window/updater-package-recovery-ipc.test.ts b/src/main/window/updater-package-recovery-ipc.test.ts index 554ca4e23b5..6b6551092d8 100644 --- a/src/main/window/updater-package-recovery-ipc.test.ts +++ b/src/main/window/updater-package-recovery-ipc.test.ts @@ -34,7 +34,8 @@ vi.mock('electron', () => ({ vi.mock('../ipc/repos', () => ({ registerRepoHandlers: vi.fn() })) vi.mock('../ipc/worktrees', () => ({ registerWorktreeHandlers: vi.fn() })) vi.mock('../ipc/worktree-change-invalidators', () => ({ runWorktreeChangeInvalidators: vi.fn() })) -vi.mock('../ipc/pty', () => ({ getLocalPtyProvider: vi.fn(), registerPtyHandlers: vi.fn() })) +vi.mock('../ipc/pty/provider/registry', () => ({ getLocalPtyProvider: vi.fn() })) +vi.mock('../ipc/pty/register-handlers', () => ({ registerPtyHandlers: vi.fn() })) vi.mock('../memory/hydrate-local-pty-registry', () => ({ hydrateLocalPtyRegistryAtBoot: vi.fn() })) diff --git a/tests/e2e/terminal-account-restart.unit.test.ts b/tests/e2e/terminal-account-restart.unit.test.ts index 23bc83dd480..4fbd83ec232 100644 --- a/tests/e2e/terminal-account-restart.unit.test.ts +++ b/tests/e2e/terminal-account-restart.unit.test.ts @@ -3,7 +3,8 @@ import { afterEach, describe, expect, it, vi } from 'vitest' import { setupPtyIpcSuite, type PtyIpcSuiteFixtures } from '../../src/main/ipc/pty-ipc-test-harness' import { TerminalKilledError } from '../../src/main/daemon/daemon-pty-lifecycle-errors' import { makePaneKey } from '../../src/shared/stable-pane-id' -import { registerPtyHandlers, setLocalPtyProvider } from '../../src/main/ipc/pty' +import { registerPtyHandlers } from '../../src/main/ipc/pty/register-handlers' +import { setLocalPtyProvider } from '../../src/main/ipc/pty/provider/registry' import { TerminalIntentionalStops } from '../../src/main/runtime/terminal-intentional-stops' vi.mock('electron', () =>