diff --git a/config/reliability-gates.jsonc b/config/reliability-gates.jsonc index 3956d883388..55e41534060 100644 --- a/config/reliability-gates.jsonc +++ b/config/reliability-gates.jsonc @@ -9272,7 +9272,7 @@ "invariant": "Reconnect, replay, or lifecycle observations from a viewer that negotiated explicit close intent must never kill a live PTY. A capable reasonless close must keep and republish; a legacy paired viewer must retain current-main behavior because its intentional close and cleanup echo are wire-identical. Lifecycle close requires the exact observed publication, terminal, environment, and authoritative liveness, never signals a process, and leaves renderer-owned or partial-split retirement to its owner. Legacy daemon hello and warm reattachment remain non-destructive.", "oracle": "Start isolated v25 and v26 daemon generations with one capable-viewer PTY and one legacy-viewer PTY per generation in four target worktrees plus an unaddressed control PTY in a fifth worktree. Route them through the production desktop scanner, runtime, RPC dispatcher, renderer-close relay, and daemon router. First issue sequential reasonless closes from an authenticated capable connection and require refusal, snapshot republish, zero shutdown calls, exact process survival, and post-close I/O. Then issue the byte-identical requests without the negotiated capability and require current-main behavior: two ordered immediate shutdowns, session-killed events, and exact root/descendant death, while capable and control PTYs survive. An observer lists all targets before, between, and after while issuing zero closes. Unit contracts also require in-process reasonless refusal, legacy runtime/mobile compatibility, explicit user closes, encrypted client-auth advertisement, and old-server lifecycle calls never to fall back.", "commands": [ - "pnpm exec vitest run --config config/vitest.config.ts src/main/daemon/daemon-server-kill-attribution.test.ts src/main/runtime/orca-runtime.test.ts src/main/runtime/remote-runtime-request-connection.integration.test.ts src/main/runtime/rpc/runtime-close-attribution-topology.test.ts src/main/runtime/rpc/methods/session-tabs.test.ts src/main/runtime/rpc/methods/session-tabs-schemas.test.ts src/main/runtime/rpc/e2ee-channel.test.ts src/main/runtime/rpc/e2ee-channel-v2.test.ts src/main/runtime/rpc/mobile-socket-wiring.test.ts src/main/runtime/rpc/runtime-client-capabilities.test.ts src/shared/remote-runtime-client.test.ts src/shared/remote-runtime/requests/remote-runtime-request-connection.test.ts src/shared/remote-runtime-shared-control-connection.test.ts src/cli/runtime/websocket-transport.test.ts src/renderer/src/web/web-runtime-client.test.ts src/renderer/src/runtime/web-runtime-session.test.ts src/renderer/src/runtime/web-session-close-intent.test.ts src/renderer/src/runtime/web-session-tabs-sync.test.ts src/renderer/src/components/terminal/terminal-tab-actions.test.ts src/renderer/src/components/terminal/terminal-close-incarnation.test.ts src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.ts", + "pnpm exec vitest run --config config/vitest.config.ts src/main/daemon/daemon-server-kill-attribution.test.ts src/main/runtime/orca-runtime.test.ts src/main/runtime/remote-runtime-request-connection.integration.test.ts src/main/runtime/rpc/runtime-close-attribution-topology.test.ts src/main/runtime/rpc/methods/session-tabs.test.ts src/main/runtime/rpc/methods/session-tabs-schemas.test.ts src/main/runtime/rpc/e2ee-channel.test.ts src/main/runtime/rpc/e2ee-channel-v2.test.ts src/main/runtime/rpc/mobile-socket-wiring.test.ts src/main/runtime/rpc/runtime-client-capabilities.test.ts src/shared/remote-runtime-client.test.ts src/shared/remote-runtime/requests/remote-runtime-request-connection.test.ts src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts src/cli/runtime/websocket-transport.test.ts src/renderer/src/web/web-runtime-client.test.ts src/renderer/src/runtime/web-runtime-session.test.ts src/renderer/src/runtime/web-session-close-intent.test.ts src/renderer/src/runtime/web-session-tabs-sync.test.ts src/renderer/src/components/terminal/terminal-tab-actions.test.ts src/renderer/src/components/terminal/terminal-close-incarnation.test.ts src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.ts", "pnpm exec playwright test tests/e2e/daemon-generation-reconnect-safety.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1", "pnpm exec playwright test tests/e2e/daemon-generation-legacy-close-safety.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1" ], @@ -9289,7 +9289,7 @@ "src/main/runtime/rpc/runtime-client-capabilities.test.ts", "src/shared/remote-runtime-client.test.ts", "src/shared/remote-runtime/requests/remote-runtime-request-connection.test.ts", - "src/shared/remote-runtime-shared-control-connection.test.ts", + "src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts", "src/cli/runtime/websocket-transport.test.ts", "src/renderer/src/web/web-runtime-client.test.ts", "src/renderer/src/runtime/web-runtime-session.test.ts", @@ -9374,7 +9374,7 @@ ] }, { - "file": "src/shared/remote-runtime-shared-control-connection.test.ts", + "file": "src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts", "assertions": [ "the reconnecting shared-control client advertises close-intent support in encrypted authentication" ] @@ -11921,7 +11921,7 @@ "pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts src/main/runtime/rpc/terminal-multiplex-initial-snapshot-buffering.test.ts src/main/runtime/rpc/terminal-multiplex-snapshot-serialization.test.ts src/main/runtime/rpc/terminal-multiplex-pty-wait-capacity.test.ts src/main/runtime/rpc/terminal-subscribe-buffer.test.ts src/renderer/src/components/terminal-pane/parked-terminal-byte-watcher.test.ts src/renderer/src/components/terminal-pane/terminal-side-effect-facts-handler.test.ts src/renderer/src/components/terminal-pane/pty-connection-hidden-replay.test.ts src/renderer/src/components/terminal-pane/pty-connection-visibility-and-exit.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-activation-inventory-fallback.test.ts src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.test.ts src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.test.ts src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.ts src/renderer/src/components/terminal-pane/terminal-parked-watcher-reconciliation.test.ts src/renderer/src/components/terminal-pane/terminal-parked-watcher-partial-reconciliation.test.ts src/renderer/src/components/terminal-pane/terminal-parking-e2e-overrides.test.ts src/renderer/src/runtime/remote-runtime-terminal-stall-recovery.test.ts src/renderer/src/runtime/runtime-client-events.test.ts src/renderer/src/web/web-preload-api-runtime-environment.test.ts src/main/ipc/runtime-environments/runtime-environments-pairing.test.ts", "pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/terminal-subscriber-driven-daemon-attach.test.ts", "pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/session-tabs-inventory-publication.test.ts src/main/runtime/rpc/methods/session-tabs-inventory-census-race.test.ts src/main/runtime/rpc/methods/session-tabs.test.ts src/renderer/src/runtime/host-session-mirror-empty-inventory-settle.test.ts src/main/daemon/terminal-host-agent-session.test.ts tests/e2e/session-tabs-empty-inventory-daemon-oracle.unit.test.ts --maxWorkers=1", - "pnpm exec vitest run --config config/vitest.config.ts src/shared/remote-runtime-shared-control-connection.test.ts", + "pnpm exec vitest run --config config/vitest.config.ts src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts", "pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/runtime/remote-runtime-terminal-parse-backpressure.test.ts", "pnpm exec vitest run --config config/vitest.config.ts src/main/ipc/pty-ipc-hidden-delivery-gate.test.ts", "SKIP_BUILD=1 pnpm exec playwright test tests/e2e/paired-remote-terminal-host-restart-background-sync.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1", @@ -11975,7 +11975,7 @@ "src/renderer/src/runtime/remote-runtime-terminal-parse-backpressure.test.ts", "src/renderer/src/runtime/runtime-client-events.test.ts", "src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-activation-inventory-fallback.test.ts", - "src/shared/remote-runtime-shared-control-connection.test.ts", + "src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts", "tests/e2e/paired-remote-terminal-lossy-initial-snapshot.spec.ts", "tests/e2e/paired-remote-terminal-truncated-tail-first-paint.spec.ts", "tests/e2e/paired-remote-terminal-stall-recovery.spec.ts", @@ -12414,7 +12414,7 @@ "date": "2026-07-29", "runner": "local", "platform": "macos", - "command": "pnpm exec vitest run --config config/vitest.config.ts src/shared/remote-runtime-shared-control-connection.test.ts", + "command": "pnpm exec vitest run --config config/vitest.config.ts src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts", "result": "passed", "durationSeconds": 3.16, "summary": "All 27 encrypted shared-control tests passed. The new oracle was red on rc.1-equivalent behavior with the exact Refreshing remote runtime control transport error, then passed with one replacement connection, one delivered host RPC, and zero retained pending bytes." @@ -13317,7 +13317,7 @@ "pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/startup/ssh-startup-reconnect.test.ts src/renderer/src/lib/resolved-worktree-execution-host.test.ts src/renderer/src/components/terminal/background-terminal-worktree-mount.test.ts src/renderer/src/runtime/sync-runtime-graph-scheduling.test.ts src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.test.ts src/renderer/src/components/terminal-pane/pty-connection-spawn-and-startup.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-host-surface-replacement.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-stream-reconnect.test.ts src/renderer/src/runtime/remote-runtime-session-tabs-inflight.test.ts src/renderer/src/runtime/web-session-terminal-handle-events.test.ts src/renderer/src/store/slices/terminal-pty-identity-replacement.test.ts", "pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/pty-transport-reattach-admission.test.ts src/renderer/src/components/terminal-pane/pty-transport-detach-attach-handoff.test.ts", "pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/terminal-error-accumulation.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-attach-subscription.test.ts --reporter=dot", - "pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-attach-subscription.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-host-surface-replacement.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-stream-reconnect.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-expired-pane-recovery.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-create-outcome-recovery.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-create-handoff.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-state.test.ts src/renderer/src/components/terminal-pane/TerminalRemoteRuntimeReconnectBanner.test.tsx src/renderer/src/components/terminal-pane/terminal-remote-runtime-recovery-ui-state.test.ts src/shared/remote-runtime-socket-liveness.test.ts src/shared/remote-runtime-shared-control-connection.test.ts src/shared/remote-runtime-shared-control-socket-generation.test.ts src/shared/remote-runtime-client-error-classification.test.ts src/main/runtime/rpc/remote-runtime-server-heartbeat.test.ts src/main/runtime/rpc/methods/terminal-create-idempotency.test.ts src/main/runtime/orca-runtime-terminal-create-idempotency.test.ts", + "pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-attach-subscription.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-host-surface-replacement.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-stream-reconnect.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-expired-pane-recovery.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-create-outcome-recovery.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-create-handoff.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-state.test.ts src/renderer/src/components/terminal-pane/TerminalRemoteRuntimeReconnectBanner.test.tsx src/renderer/src/components/terminal-pane/terminal-remote-runtime-recovery-ui-state.test.ts src/shared/remote-runtime-socket-liveness.test.ts src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts src/shared/remote-runtime/control/remote-runtime-shared-control-socket-generation.test.ts src/shared/remote-runtime-client-error-classification.test.ts src/main/runtime/rpc/remote-runtime-server-heartbeat.test.ts src/main/runtime/rpc/methods/terminal-create-idempotency.test.ts src/main/runtime/orca-runtime-terminal-create-idempotency.test.ts", "pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/hooks/ipc-events/direct-ssh-connect-reply-routing.test.ts src/renderer/src/store/slices/terminals-hydration.test.ts src/renderer/src/store/slices/repos-ssh-host-reconciliation.test.ts src/renderer/src/hooks/direct-ssh-state-routing.test.ts src/renderer/src/components/terminal-pane/pty-connection-spawn-and-startup.test.ts src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.test.ts --reporter=dot", "pnpm exec vitest run --config config/vitest.config.ts src/main/ipc/ssh/ssh.test.ts src/main/ipc/worktrees-ssh-repo-owner-resolution.test.ts src/main/ipc/worktrees-lineage-hydration.test.ts src/main/runtime/public-ssh-state.test.ts src/main/ssh/connection/ssh-connection-manager.test.ts src/main/ssh/connection/ssh-connection.test.ts src/main/ssh/ssh-provider-authority.test.ts src/preload/ssh-authority-forwarding.test.ts src/renderer/src/runtime/runtime-client-events.test.ts src/renderer/src/runtime/runtime-environment-ssh-state.test.ts src/shared/ssh-retained-payload-admission.test.ts --reporter=dot", "pnpm exec electron-vite build --mode e2e", @@ -13350,8 +13350,8 @@ "src/renderer/src/runtime/web-session-terminal-handle-events.test.ts", "src/renderer/src/store/slices/terminal-pty-identity-replacement.test.ts", "src/shared/remote-runtime-socket-liveness.test.ts", - "src/shared/remote-runtime-shared-control-connection.test.ts", - "src/shared/remote-runtime-shared-control-socket-generation.test.ts", + "src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts", + "src/shared/remote-runtime/control/remote-runtime-shared-control-socket-generation.test.ts", "src/shared/remote-runtime-client-error-classification.test.ts", "src/main/runtime/rpc/remote-runtime-server-heartbeat.test.ts", "src/main/runtime/rpc/methods/terminal-create-idempotency.test.ts", @@ -13673,7 +13673,7 @@ "date": "2026-07-21", "runner": "local", "platform": "macos", - "command": "pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-attach-subscription.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-host-surface-replacement.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-stream-reconnect.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-expired-pane-recovery.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-create-outcome-recovery.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-create-handoff.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-state.test.ts src/renderer/src/components/terminal-pane/TerminalRemoteRuntimeReconnectBanner.test.tsx src/renderer/src/components/terminal-pane/terminal-remote-runtime-recovery-ui-state.test.ts src/shared/remote-runtime-socket-liveness.test.ts src/shared/remote-runtime-shared-control-connection.test.ts src/shared/remote-runtime-shared-control-socket-generation.test.ts src/shared/remote-runtime-client-error-classification.test.ts src/main/runtime/rpc/remote-runtime-server-heartbeat.test.ts src/main/runtime/rpc/methods/terminal-create-idempotency.test.ts src/main/runtime/orca-runtime-terminal-create-idempotency.test.ts", + "command": "pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-attach-subscription.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-host-surface-replacement.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-stream-reconnect.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-expired-pane-recovery.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-create-outcome-recovery.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport-create-handoff.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-recovery-state.test.ts src/renderer/src/components/terminal-pane/TerminalRemoteRuntimeReconnectBanner.test.tsx src/renderer/src/components/terminal-pane/terminal-remote-runtime-recovery-ui-state.test.ts src/shared/remote-runtime-socket-liveness.test.ts src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts src/shared/remote-runtime/control/remote-runtime-shared-control-socket-generation.test.ts src/shared/remote-runtime-client-error-classification.test.ts src/main/runtime/rpc/remote-runtime-server-heartbeat.test.ts src/main/runtime/rpc/methods/terminal-create-idempotency.test.ts src/main/runtime/orca-runtime-terminal-create-idempotency.test.ts", "result": "passed", "durationSeconds": 5, "summary": "Eleven fault-injection and recovery-UI files and 127 tests passed, covering suspended heartbeat clocks, stale socket, PTY, and create generations, canonical pre-ready close recovery with one replacement subscription, cold and repeated PTY reattachment, authoritative health, bounded PTY and terminal-create recovery, post-probe timeout clipping, manually retryable create cutoff, accurate capability-probe failures, same-PTY manual reconnect, pane-state cleanup, fatal error deduplication, stable create identity, cross-process PTY adoption, and fail-closed legacy inventory." diff --git a/config/scripts/ci-shard-timings.json b/config/scripts/ci-shard-timings.json index b563c78a29f..5464c517c9f 100644 --- a/config/scripts/ci-shard-timings.json +++ b/config/scripts/ci-shard-timings.json @@ -11795,12 +11795,12 @@ "src/shared/remote-runtime/requests/remote-runtime-request-frames.test.ts": 280, "src/shared/remote-runtime/requests/remote-runtime-request-response-router.test.ts": 243, "src/shared/remote-runtime/requests/remote-runtime-request-websocket.test.ts": 406, - "src/shared/remote-runtime-shared-control-connection.test.ts": 3965, - "src/shared/remote-runtime-shared-control-keepalive-refresh.test.ts": 287, - "src/shared/remote-runtime-shared-control-reconnect.test.ts": 257, + "src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts": 3965, + "src/shared/remote-runtime/control/remote-runtime-shared-control-keepalive-refresh.test.ts": 287, + "src/shared/remote-runtime/control/remote-runtime-shared-control-reconnect.test.ts": 257, "src/shared/remote-runtime/requests/remote-runtime-shared-control-retired-request-ids.test.ts": 40, - "src/shared/remote-runtime-shared-control-socket-generation.test.ts": 197, - "src/shared/remote-runtime-shared-control-standing-intent.test.ts": 961, + "src/shared/remote-runtime/control/remote-runtime-shared-control-socket-generation.test.ts": 197, + "src/shared/remote-runtime/control/remote-runtime-shared-control-standing-intent.test.ts": 961, "src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-close.test.ts": 261, "src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-start.test.ts": 308, "src/shared/remote-runtime/requests/remote-runtime-shared-control-subscriptions.test.ts": 275, diff --git a/config/scripts/remote-shared-control-retirement-probe.ts b/config/scripts/remote-shared-control-retirement-probe.ts index 8c38b312a1d..7a8428fc8ca 100644 --- a/config/scripts/remote-shared-control-retirement-probe.ts +++ b/config/scripts/remote-shared-control-retirement-probe.ts @@ -1,6 +1,6 @@ import { getDefaultUserDataPath } from '../../src/cli/runtime/metadata' -import type { PairingOffer } from '../../src/shared/pairing' -import { RemoteRuntimeSharedControlConnection } from '../../src/shared/remote-runtime-shared-control-connection' +import type { PairingOffer } from '../../src/shared/mobile-relay-pairing-offer' +import { RemoteRuntimeSharedControlConnection } from '../../src/shared/remote-runtime/control/remote-runtime-shared-control-connection' import { resolveEnvironment, resolveEnvironmentPairingOffer diff --git a/config/scripts/vitest-node-runtime-files.mjs b/config/scripts/vitest-node-runtime-files.mjs index 00c0e3fecd0..c779b275f13 100644 --- a/config/scripts/vitest-node-runtime-files.mjs +++ b/config/scripts/vitest-node-runtime-files.mjs @@ -175,7 +175,7 @@ const NODE_RUNTIME_INCLUDE = [ 'src/main/ipc/renderer-shutdown-checkpoint-sleep-records.test.ts', 'src/main/runtime/structured-agent-session-startup-tab-restore.test.ts', 'src/main/runtime/structured-agent-session-windowless-layout-host.test.ts', - 'src/shared/remote-runtime-shared-control-connection.test.ts', + 'src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts', 'src/main/runtime/mobile-cloud-relay/relay-control-client.test.ts', 'src/main/ipc/filesystem-watcher-ignore-real.test.ts', 'src/main/ipc/runtime-environments/runtime-environment-preference.test.ts', diff --git a/src/main/ipc/runtime-environments/runtime-environment-diagnostics-broadcast.ts b/src/main/ipc/runtime-environments/runtime-environment-diagnostics-broadcast.ts index 13c06c80c64..2c943609d63 100644 --- a/src/main/ipc/runtime-environments/runtime-environment-diagnostics-broadcast.ts +++ b/src/main/ipc/runtime-environments/runtime-environment-diagnostics-broadcast.ts @@ -1,5 +1,5 @@ import { BrowserWindow } from 'electron' -import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../../shared/remote-runtime-shared-control-types' +import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../../shared/remote-runtime/control/remote-runtime-shared-control-types' import { RUNTIME_ENVIRONMENT_DIAGNOSTICS_CHANNEL } from '../../../shared/runtime-environment-diagnostics' export type RuntimeEnvironmentDiagnosticsEvent = { diff --git a/src/main/ipc/runtime-environments/runtime-environment-federated-read-transport.bench.test.ts b/src/main/ipc/runtime-environments/runtime-environment-federated-read-transport.bench.test.ts index 49b8681daac..0e72f9a1917 100644 --- a/src/main/ipc/runtime-environments/runtime-environment-federated-read-transport.bench.test.ts +++ b/src/main/ipc/runtime-environments/runtime-environment-federated-read-transport.bench.test.ts @@ -4,7 +4,7 @@ import { performance } from 'node:perf_hooks' import { join } from 'node:path' import { describe, expect, it, vi } from 'vitest' import { sendRemoteRuntimeRequest } from '../../../shared/remote-runtime-client' -import { RemoteRuntimeSharedControlConnection } from '../../../shared/remote-runtime-shared-control-connection' +import { RemoteRuntimeSharedControlConnection } from '../../../shared/remote-runtime/control/remote-runtime-shared-control-connection' import { RuntimeEnvironmentStoreSchema } from '../../../shared/runtime-environments' const runLiveBenchmark = isFederatedReadBenchmarkEnabled(process.env.ORCA_FEDERATED_READ_BENCH) diff --git a/src/main/ipc/runtime-environments/runtime-environment-request-connections.test.ts b/src/main/ipc/runtime-environments/runtime-environment-request-connections.test.ts index 3054ff8718c..45a66805263 100644 --- a/src/main/ipc/runtime-environments/runtime-environment-request-connections.test.ts +++ b/src/main/ipc/runtime-environments/runtime-environment-request-connections.test.ts @@ -2,7 +2,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest' import { closeSharedControlTestServers, createSharedControlTestServer -} from '../../../shared/remote-runtime-shared-control-test-server' +} from '../../../shared/remote-runtime/control/remote-runtime-shared-control-test-server' import { applyRuntimeEnvironmentCapabilityVerdict, captureRuntimeEnvironmentCapabilityEvidence, diff --git a/src/main/ipc/runtime-environments/runtime-environment-request-connections.ts b/src/main/ipc/runtime-environments/runtime-environment-request-connections.ts index b287b8fee51..c208c185774 100644 --- a/src/main/ipc/runtime-environments/runtime-environment-request-connections.ts +++ b/src/main/ipc/runtime-environments/runtime-environment-request-connections.ts @@ -10,12 +10,12 @@ import type { RuntimeRpcResponse } from '../../../shared/runtime-rpc-envelope' import { RemoteRuntimeRequestConnection } from '../../../shared/remote-runtime/requests/remote-runtime-request-connection' -import { RemoteRuntimeSharedControlConnection } from '../../../shared/remote-runtime-shared-control-connection' +import { RemoteRuntimeSharedControlConnection } from '../../../shared/remote-runtime/control/remote-runtime-shared-control-connection' import { probeAllRemoteRuntimeSocketsNow } from '../../../shared/remote-runtime-socket-liveness' import type { RemoteRuntimeSharedConnectionDiagnostics, RemoteRuntimeSharedSubscription -} from '../../../shared/remote-runtime-shared-control-types' +} from '../../../shared/remote-runtime/control/remote-runtime-shared-control-types' import { isRuntimeEnvironmentManuallyDisconnected } from './runtime-environment-manual-disconnect' import { publishRuntimeEnvironmentDiagnostics } from './runtime-environment-diagnostics-broadcast' import { sharedControlEnvironmentPolicy } from './runtime-environment-shared-control-policy' diff --git a/src/main/ipc/runtime-environments/runtime-environment-runtime-pinned-send.test.ts b/src/main/ipc/runtime-environments/runtime-environment-runtime-pinned-send.test.ts index 274b5129708..f193ba4bf1c 100644 --- a/src/main/ipc/runtime-environments/runtime-environment-runtime-pinned-send.test.ts +++ b/src/main/ipc/runtime-environments/runtime-environment-runtime-pinned-send.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from 'vitest' import { requestSharedControl } from '../../../shared/remote-runtime/requests/remote-runtime-shared-control-requests' -import type { SharedControlPendingRequest } from '../../../shared/remote-runtime-shared-control-types' +import type { SharedControlPendingRequest } from '../../../shared/remote-runtime/control/remote-runtime-shared-control-types' import type { KnownRuntimeEnvironment } from '../../../shared/runtime-environments' import { getPreferredPairedRuntimeConnection } from '../../../shared/runtime-environments' import type * as RemoteRuntimeClient from '../../../shared/remote-runtime-client' diff --git a/src/main/ipc/runtime-environments/runtime-environment-shared-control-policy.ts b/src/main/ipc/runtime-environments/runtime-environment-shared-control-policy.ts index 0d22496d227..02205df5099 100644 --- a/src/main/ipc/runtime-environments/runtime-environment-shared-control-policy.ts +++ b/src/main/ipc/runtime-environments/runtime-environment-shared-control-policy.ts @@ -1,4 +1,4 @@ -import type { RemoteRuntimeSharedControlConnectionOptions } from '../../../shared/remote-runtime-shared-control-types' +import type { RemoteRuntimeSharedControlConnectionOptions } from '../../../shared/remote-runtime/control/remote-runtime-shared-control-types' import { isRuntimeEnvironmentCapabilityPaused } from './runtime-environment-capability-evidence' import { isRuntimeEnvironmentManuallyDisconnected } from './runtime-environment-manual-disconnect' import { handleSharedControlRefusal } from './runtime-environment-pairing-refusal-registry' diff --git a/src/main/ipc/runtime-environments/runtime-environment-status-connection.test.ts b/src/main/ipc/runtime-environments/runtime-environment-status-connection.test.ts index c908683b27f..eec6208ede9 100644 --- a/src/main/ipc/runtime-environments/runtime-environment-status-connection.test.ts +++ b/src/main/ipc/runtime-environments/runtime-environment-status-connection.test.ts @@ -8,7 +8,7 @@ import { REMOTE_RUNTIME_SHARED_CONTROL_CAPABILITY } from '../../../shared/protoc import { createSharedControlTestServer, closeSharedControlTestServers -} from '../../../shared/remote-runtime-shared-control-test-server' +} from '../../../shared/remote-runtime/control/remote-runtime-shared-control-test-server' import { getRuntimeEnvironmentStatus } from './runtime-environment-status-probe' import { getRuntimeEnvironmentStatusOwner, diff --git a/src/main/runtime/remote-runtime-request-connection.integration.test.ts b/src/main/runtime/remote-runtime-request-connection.integration.test.ts index 617de85f75e..ede029def0b 100644 --- a/src/main/runtime/remote-runtime-request-connection.integration.test.ts +++ b/src/main/runtime/remote-runtime-request-connection.integration.test.ts @@ -7,7 +7,7 @@ import { getDefaultRepoHookSettings } from '../../shared/constants' import type { Repo } from '../../shared/repo-types' import { parsePairingCode } from '../../shared/pairing' import { RemoteRuntimeRequestConnection } from '../../shared/remote-runtime/requests/remote-runtime-request-connection' -import { RemoteRuntimeSharedControlConnection } from '../../shared/remote-runtime-shared-control-connection' +import { RemoteRuntimeSharedControlConnection } from '../../shared/remote-runtime/control/remote-runtime-shared-control-connection' import { subscribeRemoteRuntimeRequest } from '../../shared/remote-runtime-client' import type { RuntimeClientEvent, diff --git a/src/preload/api/runtime-api.ts b/src/preload/api/runtime-api.ts index a2310a73a67..571fe2244f3 100644 --- a/src/preload/api/runtime-api.ts +++ b/src/preload/api/runtime-api.ts @@ -17,7 +17,7 @@ import type { BrowserClientHostPlacementPreparationRequest, BrowserPageCreationPlacement } from '../../shared/browser-client-host-placement' -import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../shared/remote-runtime-shared-control-types' +import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../shared/remote-runtime/control/remote-runtime-shared-control-types' import type { WslOrcadAccountNotAppliedEvent } from '../../shared/wsl-orcad-account-notice' export type RuntimeEnvironmentSubscriptionHandle = { diff --git a/src/preload/api/runtime-environments-bridge.ts b/src/preload/api/runtime-environments-bridge.ts index 66904e39971..7934d892f36 100644 --- a/src/preload/api/runtime-environments-bridge.ts +++ b/src/preload/api/runtime-environments-bridge.ts @@ -7,7 +7,7 @@ import type { VerifyAndAddRuntimeEnvironmentResult } from '../../shared/remote-p import type { RuntimeStatus } from '../../shared/runtime-types' import type { RuntimeRpcResponse } from '../../shared/runtime-rpc-envelope' import type { PublicKnownRuntimeEnvironment } from '../../shared/runtime-environments' -import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../shared/remote-runtime-shared-control-types' +import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../shared/remote-runtime/control/remote-runtime-shared-control-types' import { RUNTIME_ENVIRONMENT_DIAGNOSTICS_CHANNEL } from '../../shared/runtime-environment-diagnostics' import { WSL_ORCAD_ACCOUNT_NOT_APPLIED_CHANNEL, diff --git a/src/renderer/src/components/status-bar/RuntimeHostStatusRow.tsx b/src/renderer/src/components/status-bar/RuntimeHostStatusRow.tsx index f8206199544..6c25f5e230b 100644 --- a/src/renderer/src/components/status-bar/RuntimeHostStatusRow.tsx +++ b/src/renderer/src/components/status-bar/RuntimeHostStatusRow.tsx @@ -13,7 +13,7 @@ import { isConnectedRuntimeHostState, type RuntimeHostConnectionState } from '@/runtime/runtime-host-connection-state' -import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../../../shared/remote-runtime-shared-control-types' +import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../../../shared/remote-runtime/control/remote-runtime-shared-control-types' import type { RuntimeHostBlockedCopy } from './remote-host-connection-status' function runtimeStatusLabel(state: RuntimeHostConnectionState): string { diff --git a/src/renderer/src/components/status-bar/remote-host-connection-status.test.ts b/src/renderer/src/components/status-bar/remote-host-connection-status.test.ts index bd96ebd3ee5..2401c3a9116 100644 --- a/src/renderer/src/components/status-bar/remote-host-connection-status.test.ts +++ b/src/renderer/src/components/status-bar/remote-host-connection-status.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../../../shared/remote-runtime-shared-control-types' +import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../../../shared/remote-runtime/control/remote-runtime-shared-control-types' import { runtimeHostBlockedCopy, runtimeHostConnectionDetail, diff --git a/src/renderer/src/components/status-bar/remote-host-connection-status.ts b/src/renderer/src/components/status-bar/remote-host-connection-status.ts index d581e96349c..30a7266c339 100644 --- a/src/renderer/src/components/status-bar/remote-host-connection-status.ts +++ b/src/renderer/src/components/status-bar/remote-host-connection-status.ts @@ -1,6 +1,6 @@ import { translate } from '@/i18n/i18n' import type { SshConnectionStatus } from '../../../../shared/ssh-types' -import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../../../shared/remote-runtime-shared-control-types' +import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../../../shared/remote-runtime/control/remote-runtime-shared-control-types' import type { RuntimeHostBlockedReason } from '../../../../shared/runtime-host-status' import type { RuntimePairingRepairRoute } from '../../../../shared/runtime-environments' import { diff --git a/src/renderer/src/runtime/runtime-status-probe-diagnostics.ts b/src/renderer/src/runtime/runtime-status-probe-diagnostics.ts index 6f42496b987..a0af22638ec 100644 --- a/src/renderer/src/runtime/runtime-status-probe-diagnostics.ts +++ b/src/renderer/src/runtime/runtime-status-probe-diagnostics.ts @@ -1,4 +1,4 @@ -import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../../shared/remote-runtime-shared-control-types' +import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../../shared/remote-runtime/control/remote-runtime-shared-control-types' import { RuntimeRpcCallError } from './runtime-rpc-result' export function extractRuntimeTransportDiagnostics( diff --git a/src/renderer/src/store/slices/runtime-status-refresh-diagnostics.test.ts b/src/renderer/src/store/slices/runtime-status-refresh-diagnostics.test.ts index d62a6abb9e7..be634f42977 100644 --- a/src/renderer/src/store/slices/runtime-status-refresh-diagnostics.test.ts +++ b/src/renderer/src/store/slices/runtime-status-refresh-diagnostics.test.ts @@ -1,5 +1,5 @@ import { afterEach, describe, expect, it, vi } from 'vitest' -import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../../../shared/remote-runtime-shared-control-types' +import type { RemoteRuntimeSharedConnectionDiagnostics } from '../../../../shared/remote-runtime/control/remote-runtime-shared-control-types' import { refreshRuntimeEnvironmentStatus } from './runtime-status-refresh' import { stubRuntimeEnvironmentBridge } from '../../runtime/runtime-environment-bridge-fixture' diff --git a/src/renderer/src/web/web-runtime-status-owner.test.ts b/src/renderer/src/web/web-runtime-status-owner.test.ts index 7abfe6f19f4..8c430c33b98 100644 --- a/src/renderer/src/web/web-runtime-status-owner.test.ts +++ b/src/renderer/src/web/web-runtime-status-owner.test.ts @@ -3,7 +3,7 @@ import WebSocket from 'ws' import { createSharedControlTestServer, closeSharedControlTestServers -} from '../../../shared/remote-runtime-shared-control-test-server' +} from '../../../shared/remote-runtime/control/remote-runtime-shared-control-test-server' import { WebRuntimeClient } from './web-runtime-client' const clients: WebRuntimeClient[] = [] diff --git a/src/shared/execution-host-registry-shared-control-connect.test.ts b/src/shared/execution-host-registry-shared-control-connect.test.ts index 34512bad7f3..1bd60fb5f6d 100644 --- a/src/shared/execution-host-registry-shared-control-connect.test.ts +++ b/src/shared/execution-host-registry-shared-control-connect.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest' import { buildExecutionHostRegistry } from './execution-host-registry' import { RUNTIME_PROTOCOL_VERSION } from './protocol-version' -import type { RemoteRuntimeSharedConnectionDiagnostics } from './remote-runtime-shared-control-types' +import type { RemoteRuntimeSharedConnectionDiagnostics } from './remote-runtime/control/remote-runtime-shared-control-types' import type { RuntimeHostStatusSnapshot } from './runtime-host-status' import { RuntimeHostStatusOwner } from './runtime-host-status-owner' import type { RuntimeStatus } from './runtime-types' diff --git a/src/shared/remote-runtime-outbound-admission.test.ts b/src/shared/remote-runtime-outbound-admission.test.ts index 57eeba8cb6d..298b7d19b05 100644 --- a/src/shared/remote-runtime-outbound-admission.test.ts +++ b/src/shared/remote-runtime-outbound-admission.test.ts @@ -22,8 +22,8 @@ import { } from './remote-runtime-memory-limits' import { getRemoteRuntimeRequestAdmissionEvidence } from './remote-runtime/requests/remote-runtime-prepared-request-admission' import { RemoteRuntimeRequestConnection } from './remote-runtime/requests/remote-runtime-request-connection' -import { RemoteRuntimeSharedControlConnection } from './remote-runtime-shared-control-connection' -import { waitForSharedControlReadyWithTimeout } from './remote-runtime-shared-control-ready' +import { RemoteRuntimeSharedControlConnection } from './remote-runtime/control/remote-runtime-shared-control-connection' +import { waitForSharedControlReadyWithTimeout } from './remote-runtime/control/remote-runtime-shared-control-ready' type InspectableRequestConnection = { close: () => void diff --git a/src/shared/remote-runtime-shared-control-refresh.ts b/src/shared/remote-runtime-shared-control-refresh.ts deleted file mode 100644 index 3f003ba067f..00000000000 --- a/src/shared/remote-runtime-shared-control-refresh.ts +++ /dev/null @@ -1,9 +0,0 @@ -export function refreshRemoteRuntimeSharedControl(options: { - intentionallyClosed: boolean - ready: boolean - refresh(): void -}): void { - if (!options.intentionallyClosed && !options.ready) { - options.refresh() - } -} diff --git a/src/shared/remote-runtime-socket-resume-probe.test.ts b/src/shared/remote-runtime-socket-resume-probe.test.ts index 0bc3ff5751d..afc329d301e 100644 --- a/src/shared/remote-runtime-socket-resume-probe.test.ts +++ b/src/shared/remote-runtime-socket-resume-probe.test.ts @@ -3,7 +3,7 @@ import { probeAllRemoteRuntimeSocketsNow, startRemoteRuntimeSocketLiveness } from './remote-runtime-socket-liveness' -import { SharedControlReconnectScheduler } from './remote-runtime-shared-control-reconnect' +import { SharedControlReconnectScheduler } from './remote-runtime/control/remote-runtime-shared-control-reconnect' // Regression for #9092: after sleep a socket can still read OPEN while its path is gone, and the // normal cadence took ~30-40 s to notice; resume now probes every socket with a short deadline. diff --git a/src/shared/remote-runtime-transport-error-agreement.test.ts b/src/shared/remote-runtime-transport-error-agreement.test.ts index 33b9403df37..7d7bf85c222 100644 --- a/src/shared/remote-runtime-transport-error-agreement.test.ts +++ b/src/shared/remote-runtime-transport-error-agreement.test.ts @@ -41,7 +41,7 @@ import { remoteRuntimeTimeoutError, remoteRuntimeUnavailableError } from './remote-runtime/requests/remote-runtime-request-frames' -import { formatSharedControlCloseMessage } from './remote-runtime-shared-control-protocol' +import { formatSharedControlCloseMessage } from './remote-runtime/control/remote-runtime-shared-control-protocol' import { RuntimeRpcCallQueueOverloadError } from './runtime-rpc-call-queue' import { withRemoteRuntimeTailscaleHint } from './remote-runtime-tailscale-hint' import { MAX_TIMER_DELAY_MS } from './timer-delay' diff --git a/src/shared/remote-runtime-shared-control-admission.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-admission.ts similarity index 93% rename from src/shared/remote-runtime-shared-control-admission.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-admission.ts index e526ba1bb95..2be4047b24b 100644 --- a/src/shared/remote-runtime-shared-control-admission.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-admission.ts @@ -1,10 +1,10 @@ -import { RemoteRuntimeClientError } from './remote-runtime-client-error' +import { RemoteRuntimeClientError } from '../../remote-runtime-client-error' import { measureRemoteRuntimeSubscriptionParams, REMOTE_RUNTIME_MAX_RETAINED_SUBSCRIPTION_BYTES, REMOTE_RUNTIME_MAX_SUBSCRIPTIONS, serializeRemoteRuntimeRpcRequest -} from './remote-runtime-memory-limits' +} from '../../remote-runtime-memory-limits' import type { SharedControlLogicalSubscription } from './remote-runtime-shared-control-types' export function admitSharedControlSubscription(args: { diff --git a/src/shared/remote-runtime-shared-control-auth-refusal.test.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-auth-refusal.test.ts similarity index 96% rename from src/shared/remote-runtime-shared-control-auth-refusal.test.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-auth-refusal.test.ts index d4dd2e1ac7b..b83f573bd4b 100644 --- a/src/shared/remote-runtime-shared-control-auth-refusal.test.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-auth-refusal.test.ts @@ -1,6 +1,6 @@ import { afterEach, describe, expect, it, vi } from 'vitest' import { RemoteRuntimeSharedControlConnection } from './remote-runtime-shared-control-connection' -import { isRecoverableRemoteRuntimeConnectionError } from './remote-runtime-client-error-classification' +import { isRecoverableRemoteRuntimeConnectionError } from '../../remote-runtime-client-error-classification' import { closeSharedControlTestServers, createSharedControlTestServer diff --git a/src/shared/remote-runtime-shared-control-connection-actions.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-connection-actions.ts similarity index 67% rename from src/shared/remote-runtime-shared-control-connection-actions.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-connection-actions.ts index a0d8bb3ec39..e95de8ad99e 100644 --- a/src/shared/remote-runtime-shared-control-connection-actions.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-connection-actions.ts @@ -1,13 +1,12 @@ import * as sharedControlProtocol from './remote-runtime-shared-control-protocol' import * as sharedControlState from './remote-runtime-shared-control-state' -import { closeSharedControlConnectionSubscription } from './remote-runtime/requests/remote-runtime-shared-control-subscription-close' -import * as sharedControlSubscriptions from './remote-runtime/requests/remote-runtime-shared-control-subscriptions' + +import * as sharedControlSubscriptions from '../requests/remote-runtime-shared-control-subscriptions' import * as sharedControlSend from './remote-runtime-shared-control-send' import type { SharedControlLogicalSubscription, SharedControlPendingRequest } from './remote-runtime-shared-control-types' -import type { SharedControlRetiredRequestIds } from './remote-runtime/requests/remote-runtime-shared-control-retired-request-ids' export function sendSharedControlRequest(args: { pendingRequests: Map> @@ -33,15 +32,6 @@ export function sendSharedControlRequest(args: { }) } -export function sendSharedControlSubscription(args: { - subscriptions: Map> - subscription: SharedControlLogicalSubscription - deviceToken: string - send: (payload: unknown) => boolean -}): void { - sharedControlSend.sendSharedControlSubscription(args) -} - export function replaySharedControlSubscriptions(args: { subscriptions: Map> send: (subscription: SharedControlLogicalSubscription) => void @@ -60,7 +50,7 @@ export function replayRuntimeControlSubscriptions(args: { return replaySharedControlSubscriptions({ subscriptions: args.subscriptions, send: (subscription) => - sendSharedControlSubscription({ + sharedControlSend.sendSharedControlSubscription({ subscriptions: args.subscriptions, subscription, deviceToken: args.deviceToken, @@ -69,13 +59,3 @@ export function replayRuntimeControlSubscriptions(args: { tagReplayedResponses: args.tagReplayedResponses }) } - -export function closeSharedControlSubscription(args: { - subscriptions: Map> - retiredRequestIds: SharedControlRetiredRequestIds - requestId: string - deviceToken: string - send: (payload: unknown) => boolean -}): void { - closeSharedControlConnectionSubscription(args) -} diff --git a/src/shared/remote-runtime-shared-control-connection-frame.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-connection-frame.ts similarity index 87% rename from src/shared/remote-runtime-shared-control-connection-frame.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-connection-frame.ts index de9f902b34f..9eccb8afc2d 100644 --- a/src/shared/remote-runtime-shared-control-connection-frame.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-connection-frame.ts @@ -1,16 +1,16 @@ import type WebSocket from 'ws' -import { sendRemoteRuntimeTokenAuth } from './remote-runtime-client-handshake' +import { sendRemoteRuntimeTokenAuth } from '../../remote-runtime-client-handshake' import { toRemoteRuntimeClientError } from './remote-runtime-shared-control-protocol' -import type { PairedE2EEClientHandshake } from './paired-e2ee-client-handshake' +import type { PairedE2EEClientHandshake } from '../../paired-e2ee-client-handshake' import { handleSharedControlTextFrame } from './remote-runtime-shared-control-frame-handler' -import type { RemoteRuntimeClientError } from './remote-runtime-client-error' +import type { RemoteRuntimeClientError } from '../../remote-runtime-client-error' import type { SharedControlConnectionState, SharedControlLogicalSubscription, SharedControlPendingRequest, SharedControlReadyWaiter } from './remote-runtime-shared-control-types' -import type { SharedControlRetiredRequestIds } from './remote-runtime/requests/remote-runtime-shared-control-retired-request-ids' +import type { SharedControlRetiredRequestIds } from '../requests/remote-runtime-shared-control-retired-request-ids' export function handleRuntimeControlTextFrame(args: { frame: string diff --git a/src/shared/remote-runtime-shared-control-connection.test.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts similarity index 97% rename from src/shared/remote-runtime-shared-control-connection.test.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts index 11e23f52ef8..f403e602057 100644 --- a/src/shared/remote-runtime-shared-control-connection.test.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-connection.test.ts @@ -1,18 +1,18 @@ -import { pairedRuntimeConnectionFromOffer } from './paired-runtime-connection' -import type { PairedE2EEClientHandshake } from './paired-e2ee-client-handshake' -import { createFixedKeyLegacyHandshakeForTest } from './paired-e2ee-fixed-key-test-fixture' +import { pairedRuntimeConnectionFromOffer } from '../../paired-runtime-connection' +import type { PairedE2EEClientHandshake } from '../../paired-e2ee-client-handshake' +import { createFixedKeyLegacyHandshakeForTest } from '../../paired-e2ee-fixed-key-test-fixture' import path from 'node:path' import { afterEach, describe, expect, it, vi } from 'vitest' import { REMOTE_RUNTIME_MAX_PENDING_RPC_BYTES, retainedRemoteRuntimeJsonStringBytes, serializeRemoteRuntimeRpcRequest -} from './remote-runtime-memory-limits' -import { getRemoteRuntimeRequestAdmissionEvidence } from './remote-runtime/requests/remote-runtime-prepared-request-admission' -import { remoteRuntimeClientCapabilities } from './remote-runtime-client-capabilities' +} from '../../remote-runtime-memory-limits' +import { getRemoteRuntimeRequestAdmissionEvidence } from '../requests/remote-runtime-prepared-request-admission' +import { remoteRuntimeClientCapabilities } from '../../remote-runtime-client-capabilities' import { RemoteRuntimeSharedControlConnection } from './remote-runtime-shared-control-connection' import * as sharedControlProtocol from './remote-runtime-shared-control-protocol' -import { isRuntimeSubscriptionReplayResponse } from './runtime-subscription-replay' +import { isRuntimeSubscriptionReplayResponse } from '../../runtime-subscription-replay' import { closeSharedControlTestServers, createSharedControlTestServer as createServer diff --git a/src/shared/remote-runtime-shared-control-connection.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-connection.ts similarity index 91% rename from src/shared/remote-runtime-shared-control-connection.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-connection.ts index 1955c4f5c03..6efdac0de9c 100644 --- a/src/shared/remote-runtime-shared-control-connection.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-connection.ts @@ -1,20 +1,20 @@ -import type { PairedE2EEClientHandshake } from './paired-e2ee-client-handshake' +import type { PairedE2EEClientHandshake } from '../../paired-e2ee-client-handshake' import type WebSocket from 'ws' -import type { PairedRuntimeConnection } from './paired-runtime-connection' -import type { RemoteRuntimeClientError } from './remote-runtime-client-error' -import { remoteRuntimeClientCapabilities } from './remote-runtime-client-capabilities' -import { remoteRuntimeUnavailableError } from './remote-runtime/requests/remote-runtime-request-frames' +import type { PairedRuntimeConnection } from '../../paired-runtime-connection' +import type { RemoteRuntimeClientError } from '../../remote-runtime-client-error' +import { remoteRuntimeClientCapabilities } from '../../remote-runtime-client-capabilities' +import { remoteRuntimeUnavailableError } from '../requests/remote-runtime-request-frames' import { openSharedControlSocket } from './remote-runtime-shared-control-open' import { closeSharedControlAfterError } from './remote-runtime-shared-control-refusal' import * as sharedControlReady from './remote-runtime-shared-control-ready' import * as sharedControlProtocol from './remote-runtime-shared-control-protocol' import { SharedControlReconnectScheduler } from './remote-runtime-shared-control-reconnect' -import { requestSharedControl } from './remote-runtime/requests/remote-runtime-shared-control-requests' -import { SharedControlRetiredRequestIds } from './remote-runtime/requests/remote-runtime-shared-control-retired-request-ids' +import { requestSharedControl } from '../requests/remote-runtime-shared-control-requests' +import { SharedControlRetiredRequestIds } from '../requests/remote-runtime-shared-control-retired-request-ids' import { SharedControlReadyStableResetTimer } from './remote-runtime-shared-control-stability' import * as sharedControlState from './remote-runtime-shared-control-state' import { closeSharedControlSocket } from './remote-runtime-shared-control-socket-close' -import { startSharedControlSubscription } from './remote-runtime/requests/remote-runtime-shared-control-subscription-start' +import { startSharedControlSubscription } from '../requests/remote-runtime-shared-control-subscription-start' import { SharedControlSocketGeneration } from './remote-runtime-shared-control-socket-generation' import { refreshRemoteRuntimeSharedControl } from './remote-runtime-shared-control-refresh' import { SharedControlDiagnosticsTracker } from './remote-runtime-shared-control-diagnostics' @@ -22,6 +22,8 @@ import { ensureSharedControlReady } from './remote-runtime-shared-control-ready- import { handleRuntimeControlTextFrame } from './remote-runtime-shared-control-connection-frame' import * as sharedControlActions from './remote-runtime-shared-control-connection-actions' import type * as SharedControlTypes from './remote-runtime-shared-control-types' +import { sendSharedControlSubscription } from './remote-runtime-shared-control-send' +import { closeSharedControlConnectionSubscription } from '../requests/remote-runtime-shared-control-subscription-close' type PendingRequest = SharedControlTypes.SharedControlPendingRequest type LogicalSubscription = SharedControlTypes.SharedControlLogicalSubscription @@ -96,7 +98,7 @@ export class RemoteRuntimeSharedControlConnection { signal, ensureReady: () => this.ensureReadyWithTimeout(timeoutMs, signal), sendSubscription: (subscription) => - sharedControlActions.sendSharedControlSubscription({ + sendSharedControlSubscription({ subscriptions: this.subscriptions, subscription, deviceToken: this.connection.credential.deviceToken, @@ -146,13 +148,8 @@ export class RemoteRuntimeSharedControlConnection { refreshRemoteRuntimeSharedControl({ intentionallyClosed: this.intentionallyClosed, ready: this.isReady(), - refresh: () => { - this.closeSocket( - remoteRuntimeUnavailableError('Refreshing remote runtime control transport.'), - true - ) - this.open() - } + close: (error) => this.closeSocket(error, true), + open: () => this.open() }) } private ensureReadyWithTimeout(timeoutMs: number, signal?: AbortSignal): Promise { @@ -250,7 +247,7 @@ export class RemoteRuntimeSharedControlConnection { } private closeSubscription(requestId: string): void { - sharedControlActions.closeSharedControlSubscription({ + closeSharedControlConnectionSubscription({ subscriptions: this.subscriptions, retiredRequestIds: this.retiredRequestIds, requestId, diff --git a/src/shared/remote-runtime-shared-control-diagnostics-log.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-diagnostics-log.ts similarity index 100% rename from src/shared/remote-runtime-shared-control-diagnostics-log.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-diagnostics-log.ts diff --git a/src/shared/remote-runtime-shared-control-diagnostics.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-diagnostics.ts similarity index 100% rename from src/shared/remote-runtime-shared-control-diagnostics.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-diagnostics.ts diff --git a/src/shared/remote-runtime-shared-control-frame-dispatch.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-frame-dispatch.ts similarity index 80% rename from src/shared/remote-runtime-shared-control-frame-dispatch.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-frame-dispatch.ts index a700dfe9641..208e6bbd36e 100644 --- a/src/shared/remote-runtime-shared-control-frame-dispatch.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-frame-dispatch.ts @@ -1,8 +1,8 @@ -import type { parseRemoteRuntimeRpcFrame } from './remote-runtime/requests/remote-runtime-request-frames' +import type { parseRemoteRuntimeRpcFrame } from '../requests/remote-runtime-request-frames' import { logUnknownSharedControlResponse } from './remote-runtime-shared-control-diagnostics-log' -import type { SharedControlRetiredRequestIds } from './remote-runtime/requests/remote-runtime-shared-control-retired-request-ids' -import { sendRetiredSharedControlCleanupRequest } from './remote-runtime/requests/remote-runtime-shared-control-subscription-close' -import { handleSharedControlLogicalResponse } from './remote-runtime/requests/remote-runtime-shared-control-subscriptions' +import type { SharedControlRetiredRequestIds } from '../requests/remote-runtime-shared-control-retired-request-ids' +import { sendRetiredSharedControlCleanupRequest } from '../requests/remote-runtime-shared-control-subscription-close' +import { handleSharedControlLogicalResponse } from '../requests/remote-runtime-shared-control-subscriptions' import { refreshSharedControlPendingRequestTimeouts, resolveSharedControlPendingResponse diff --git a/src/shared/remote-runtime-shared-control-frame-handler.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-frame-handler.ts similarity index 88% rename from src/shared/remote-runtime-shared-control-frame-handler.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-frame-handler.ts index 61b8364db91..230d4000f90 100644 --- a/src/shared/remote-runtime-shared-control-frame-handler.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-frame-handler.ts @@ -1,13 +1,13 @@ -import type { PairedE2EEClientHandshake } from './paired-e2ee-client-handshake' +import type { PairedE2EEClientHandshake } from '../../paired-e2ee-client-handshake' import { remoteRuntimeAuthReplyError, remoteRuntimeReadyError, remoteRuntimeUnavailableError -} from './remote-runtime/requests/remote-runtime-request-frames' -import type { RemoteRuntimeClientError } from './remote-runtime-client-error' +} from '../requests/remote-runtime-request-frames' +import type { RemoteRuntimeClientError } from '../../remote-runtime-client-error' import { dispatchSharedControlFrame } from './remote-runtime-shared-control-frame-dispatch' import { parseSharedControlFrame } from './remote-runtime-shared-control-protocol' -import type { SharedControlRetiredRequestIds } from './remote-runtime/requests/remote-runtime-shared-control-retired-request-ids' +import type { SharedControlRetiredRequestIds } from '../requests/remote-runtime-shared-control-retired-request-ids' import { resolveSharedControlReadyWaiters } from './remote-runtime-shared-control-state' import type { SharedControlConnectionState, diff --git a/src/shared/remote-runtime-shared-control-keepalive-refresh.test.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-keepalive-refresh.test.ts similarity index 97% rename from src/shared/remote-runtime-shared-control-keepalive-refresh.test.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-keepalive-refresh.test.ts index e93ea26a818..836b0eedb1d 100644 --- a/src/shared/remote-runtime-shared-control-keepalive-refresh.test.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-keepalive-refresh.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { requestSharedControl } from './remote-runtime/requests/remote-runtime-shared-control-requests' +import { requestSharedControl } from '../requests/remote-runtime-shared-control-requests' import { refreshSharedControlPendingRequestTimeouts, resolveSharedControlPendingResponse diff --git a/src/shared/remote-runtime-shared-control-open.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-open.ts similarity index 89% rename from src/shared/remote-runtime-shared-control-open.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-open.ts index 541002f91aa..c6cf7bbdd89 100644 --- a/src/shared/remote-runtime-shared-control-open.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-open.ts @@ -1,16 +1,16 @@ import type WebSocket from 'ws' -import type { PairedRuntimeConnection } from './paired-runtime-connection' -import type { RemoteRuntimeClientError } from './remote-runtime-client-error' -import { remoteRuntimeUnavailableError } from './remote-runtime/requests/remote-runtime-request-frames' +import type { PairedRuntimeConnection } from '../../paired-runtime-connection' +import type { RemoteRuntimeClientError } from '../../remote-runtime-client-error' +import { remoteRuntimeUnavailableError } from '../requests/remote-runtime-request-frames' import { openRemoteRuntimeWebSocket, type RemoteRuntimeWebSocket -} from './remote-runtime/requests/remote-runtime-request-websocket' +} from '../requests/remote-runtime-request-websocket' import { formatSharedControlCloseMessage } from './remote-runtime-shared-control-protocol' import { startRemoteRuntimeSocketLiveness, type RemoteRuntimeSocketLivenessOptions -} from './remote-runtime-socket-liveness' +} from '../../remote-runtime-socket-liveness' export function openSharedControlSocket( connection: PairedRuntimeConnection, diff --git a/src/shared/remote-runtime-shared-control-protocol.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-protocol.ts similarity index 94% rename from src/shared/remote-runtime-shared-control-protocol.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-protocol.ts index 337e1631f32..64c74a7a895 100644 --- a/src/shared/remote-runtime-shared-control-protocol.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-protocol.ts @@ -1,11 +1,11 @@ -import type { PairedE2EEClientHandshake } from './paired-e2ee-client-handshake' +import type { PairedE2EEClientHandshake } from '../../paired-e2ee-client-handshake' import type WebSocket from 'ws' -import { RemoteRuntimeClientError } from './remote-runtime-client-error' -import { serializeRemoteRuntimePayload } from './remote-runtime-memory-limits' +import { RemoteRuntimeClientError } from '../../remote-runtime-client-error' +import { serializeRemoteRuntimePayload } from '../../remote-runtime-memory-limits' import { invalidRemoteRuntimeResponseError, parseRemoteRuntimeRpcFrame -} from './remote-runtime/requests/remote-runtime-request-frames' +} from '../requests/remote-runtime-request-frames' import type { SharedControlConnectionState, SharedControlLogicalSubscription diff --git a/src/shared/remote-runtime-shared-control-ready-wait.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-ready-wait.ts similarity index 90% rename from src/shared/remote-runtime-shared-control-ready-wait.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-ready-wait.ts index b2629b3f0a2..66b15d7a8a6 100644 --- a/src/shared/remote-runtime-shared-control-ready-wait.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-ready-wait.ts @@ -1,4 +1,4 @@ -import type { PairedE2EEClientHandshake } from './paired-e2ee-client-handshake' +import type { PairedE2EEClientHandshake } from '../../paired-e2ee-client-handshake' import type WebSocket from 'ws' import type { SharedControlConnectionState, diff --git a/src/shared/remote-runtime-shared-control-ready.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-ready.ts similarity index 87% rename from src/shared/remote-runtime-shared-control-ready.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-ready.ts index f769f51674f..9fc0fd30b02 100644 --- a/src/shared/remote-runtime-shared-control-ready.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-ready.ts @@ -1,9 +1,9 @@ -import type { PairedE2EEClientHandshake } from './paired-e2ee-client-handshake' +import type { PairedE2EEClientHandshake } from '../../paired-e2ee-client-handshake' import WebSocket from 'ws' -import { abortSignalReason } from './abort-signal-reason' -import { RemoteRuntimeClientError } from './remote-runtime-client-error' -import { REMOTE_RUNTIME_MAX_READY_WAITERS } from './remote-runtime-memory-limits' -import { remoteRuntimeUnavailableError } from './remote-runtime/requests/remote-runtime-request-frames' +import { abortSignalReason } from '../../abort-signal-reason' +import { RemoteRuntimeClientError } from '../../remote-runtime-client-error' +import { REMOTE_RUNTIME_MAX_READY_WAITERS } from '../../remote-runtime-memory-limits' +import { remoteRuntimeUnavailableError } from '../requests/remote-runtime-request-frames' import type { SharedControlConnectionState, SharedControlReadyWaiter diff --git a/src/shared/remote-runtime-shared-control-reconnect.test.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-reconnect.test.ts similarity index 100% rename from src/shared/remote-runtime-shared-control-reconnect.test.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-reconnect.test.ts diff --git a/src/shared/remote-runtime-shared-control-reconnect.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-reconnect.ts similarity index 100% rename from src/shared/remote-runtime-shared-control-reconnect.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-reconnect.ts diff --git a/src/shared/remote-runtime/control/remote-runtime-shared-control-refresh.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-refresh.ts new file mode 100644 index 00000000000..4f5c8f17e87 --- /dev/null +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-refresh.ts @@ -0,0 +1,13 @@ +import { remoteRuntimeUnavailableError } from '../requests/remote-runtime-request-frames' + +export function refreshRemoteRuntimeSharedControl(options: { + intentionallyClosed: boolean + ready: boolean + close: (error: Error) => void + open: () => void +}): void { + if (!options.intentionallyClosed && !options.ready) { + options.close(remoteRuntimeUnavailableError('Refreshing remote runtime control transport.')) + options.open() + } +} diff --git a/src/shared/remote-runtime-shared-control-refusal.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-refusal.ts similarity index 92% rename from src/shared/remote-runtime-shared-control-refusal.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-refusal.ts index e8b38c0e026..3a48bfe8e8e 100644 --- a/src/shared/remote-runtime-shared-control-refusal.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-refusal.ts @@ -1,5 +1,5 @@ -import type { RemoteRuntimeClientError } from './remote-runtime-client-error' -import { remoteRuntimeUnavailableError } from './remote-runtime/requests/remote-runtime-request-frames' +import type { RemoteRuntimeClientError } from '../../remote-runtime-client-error' +import { remoteRuntimeUnavailableError } from '../requests/remote-runtime-request-frames' import type { SharedControlSocketGeneration } from './remote-runtime-shared-control-socket-generation' import type { SharedControlLogicalSubscription } from './remote-runtime-shared-control-types' diff --git a/src/shared/remote-runtime-shared-control-send.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-send.ts similarity index 86% rename from src/shared/remote-runtime-shared-control-send.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-send.ts index 6db2715385b..a67efedf8aa 100644 --- a/src/shared/remote-runtime-shared-control-send.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-send.ts @@ -1,5 +1,5 @@ -import { remoteRuntimeUnavailableError } from './remote-runtime/requests/remote-runtime-request-frames' -import { takeRemoteRuntimePreparedRequest } from './remote-runtime/requests/remote-runtime-prepared-request-admission' +import { remoteRuntimeUnavailableError } from '../requests/remote-runtime-request-frames' +import { takeRemoteRuntimePreparedRequest } from '../requests/remote-runtime-prepared-request-admission' import { finishSharedControlSubscription } from './remote-runtime-shared-control-state' import type { SharedControlLogicalSubscription, diff --git a/src/shared/remote-runtime-shared-control-socket-close.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-socket-close.ts similarity index 93% rename from src/shared/remote-runtime-shared-control-socket-close.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-socket-close.ts index 6e49cea0195..aa1df795cb1 100644 --- a/src/shared/remote-runtime-shared-control-socket-close.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-socket-close.ts @@ -1,7 +1,7 @@ import type WebSocket from 'ws' import { logSharedControlSocketClose } from './remote-runtime-shared-control-diagnostics-log' import { closeSharedControlSocketState } from './remote-runtime-shared-control-state' -import { finishCloseAfterReadySubscriptions } from './remote-runtime/requests/remote-runtime-shared-control-subscriptions' +import { finishCloseAfterReadySubscriptions } from '../requests/remote-runtime-shared-control-subscriptions' import type { SharedControlConnectionState, SharedControlLogicalSubscription, diff --git a/src/shared/remote-runtime-shared-control-socket-generation.test.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-socket-generation.test.ts similarity index 94% rename from src/shared/remote-runtime-shared-control-socket-generation.test.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-socket-generation.test.ts index 674a22c1162..a4a06c95e30 100644 --- a/src/shared/remote-runtime-shared-control-socket-generation.test.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-socket-generation.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it, vi } from 'vitest' -import { remoteRuntimeUnavailableError } from './remote-runtime/requests/remote-runtime-request-frames' +import { remoteRuntimeUnavailableError } from '../requests/remote-runtime-request-frames' import { SharedControlSocketGeneration } from './remote-runtime-shared-control-socket-generation' describe('SharedControlSocketGeneration', () => { diff --git a/src/shared/remote-runtime-shared-control-socket-generation.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-socket-generation.ts similarity index 93% rename from src/shared/remote-runtime-shared-control-socket-generation.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-socket-generation.ts index 7654c85389d..b670dcdc470 100644 --- a/src/shared/remote-runtime-shared-control-socket-generation.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-socket-generation.ts @@ -1,4 +1,4 @@ -import type { RemoteRuntimeClientError } from './remote-runtime-client-error' +import type { RemoteRuntimeClientError } from '../../remote-runtime-client-error' import type { SharedControlLogicalSubscription } from './remote-runtime-shared-control-types' export class SharedControlSocketGeneration { diff --git a/src/shared/remote-runtime-shared-control-stability.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-stability.ts similarity index 100% rename from src/shared/remote-runtime-shared-control-stability.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-stability.ts diff --git a/src/shared/remote-runtime-shared-control-standing-intent.test.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-standing-intent.test.ts similarity index 98% rename from src/shared/remote-runtime-shared-control-standing-intent.test.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-standing-intent.test.ts index 3f272c13bd8..1eab8b7371b 100644 --- a/src/shared/remote-runtime-shared-control-standing-intent.test.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-standing-intent.test.ts @@ -1,6 +1,6 @@ -import { pairedRuntimeConnectionFromOffer } from './paired-runtime-connection' +import { pairedRuntimeConnectionFromOffer } from '../../paired-runtime-connection' import { afterEach, describe, expect, it, vi } from 'vitest' -import { RemoteRuntimeClientError } from './remote-runtime-client-error' +import { RemoteRuntimeClientError } from '../../remote-runtime-client-error' import { RemoteRuntimeSharedControlConnection } from './remote-runtime-shared-control-connection' import { SharedControlReconnectScheduler } from './remote-runtime-shared-control-reconnect' import type { SharedControlLogicalSubscription } from './remote-runtime-shared-control-types' diff --git a/src/shared/remote-runtime-shared-control-state.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-state.ts similarity index 91% rename from src/shared/remote-runtime-shared-control-state.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-state.ts index 48ad5633eae..3d805e2c670 100644 --- a/src/shared/remote-runtime-shared-control-state.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-state.ts @@ -1,15 +1,15 @@ -import type { RemoteRuntimeClientError } from './remote-runtime-client-error' -import { releaseRemoteRuntimePreparedRequest } from './remote-runtime/requests/remote-runtime-prepared-request-admission' -import { remoteRuntimeUnavailableError } from './remote-runtime/requests/remote-runtime-request-frames' -import type { RuntimeRpcResponse } from './runtime-rpc-envelope' +import type { RemoteRuntimeClientError } from '../../remote-runtime-client-error' +import { releaseRemoteRuntimePreparedRequest } from '../requests/remote-runtime-prepared-request-admission' +import { remoteRuntimeUnavailableError } from '../requests/remote-runtime-request-frames' +import type { RuntimeRpcResponse } from '../../runtime-rpc-envelope' import type { SharedControlLogicalSubscription, SharedControlPendingRequest, SharedControlReadyWaiter } from './remote-runtime-shared-control-types' import { getSubscriptionId, isEndResult } from './remote-runtime-shared-control-protocol' -import { withReconnectJitter } from './reconnect-jitter' -import { tagRuntimeSubscriptionReplayResponse } from './runtime-subscription-replay' +import { withReconnectJitter } from '../../reconnect-jitter' +import { tagRuntimeSubscriptionReplayResponse } from '../../runtime-subscription-replay' export function rejectSharedControlPendingRequest( pendingRequests: Map>, diff --git a/src/shared/remote-runtime-shared-control-test-server.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-test-server.ts similarity index 97% rename from src/shared/remote-runtime-shared-control-test-server.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-test-server.ts index 7cbd10c00d5..9f3e62aa5fc 100644 --- a/src/shared/remote-runtime-shared-control-test-server.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-test-server.ts @@ -1,7 +1,7 @@ import { pairedRuntimeConnectionFromOffer, type PairedRuntimeConnection -} from './paired-runtime-connection' +} from '../../paired-runtime-connection' import type { AddressInfo } from 'node:net' import { WebSocketServer, type WebSocket } from 'ws' import { @@ -11,8 +11,9 @@ import { generateKeyPair, publicKeyFromBase64, publicKeyToBase64 -} from './e2ee-crypto' -import { encodePairingOffer, parsePairingCode, type PairingOffer } from './pairing' +} from '../../e2ee-crypto' +import { encodePairingOffer, parsePairingCode } from '../../pairing' +import type { PairingOffer } from '../../mobile-relay-pairing-offer' export type SharedControlTestServer = { pairing: PairedRuntimeConnection diff --git a/src/shared/remote-runtime-shared-control-types.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-types.ts similarity index 88% rename from src/shared/remote-runtime-shared-control-types.ts rename to src/shared/remote-runtime/control/remote-runtime-shared-control-types.ts index 2ce51d30226..f842bc3cf52 100644 --- a/src/shared/remote-runtime-shared-control-types.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-types.ts @@ -1,8 +1,8 @@ -import type { RuntimeRpcResponse } from './runtime-rpc-envelope' -import type { RemoteRuntimeClientError } from './remote-runtime-client-error' -import type { RemoteRuntimePreparedRequest } from './remote-runtime/requests/remote-runtime-prepared-request-admission' -import type { RuntimeCapability } from './protocol-version' -import type { RemoteRuntimeSocketLivenessOptions } from './remote-runtime-socket-liveness' +import type { RuntimeRpcResponse } from '../../runtime-rpc-envelope' +import type { RemoteRuntimeClientError } from '../../remote-runtime-client-error' +import type { RemoteRuntimePreparedRequest } from '../requests/remote-runtime-prepared-request-admission' +import type { RuntimeCapability } from '../../protocol-version' +import type { RemoteRuntimeSocketLivenessOptions } from '../../remote-runtime-socket-liveness' export type SharedControlConnectionState = | 'closed' diff --git a/src/shared/remote-runtime/requests/remote-runtime-shared-control-requests.ts b/src/shared/remote-runtime/requests/remote-runtime-shared-control-requests.ts index d549f90c5d2..d620cb012a4 100644 --- a/src/shared/remote-runtime/requests/remote-runtime-shared-control-requests.ts +++ b/src/shared/remote-runtime/requests/remote-runtime-shared-control-requests.ts @@ -8,9 +8,9 @@ import { } from './remote-runtime-prepared-request-admission' import { remoteRuntimeTimeoutError } from './remote-runtime-request-frames' import type { RuntimeOrchestrationEnvelope, RuntimeRpcResponse } from '../../runtime-rpc-envelope' -import { toRemoteRuntimeClientError } from '../../remote-runtime-shared-control-protocol' -import { rejectSharedControlPendingRequest } from '../../remote-runtime-shared-control-state' -import type { SharedControlPendingRequest } from '../../remote-runtime-shared-control-types' +import { toRemoteRuntimeClientError } from '../control/remote-runtime-shared-control-protocol' +import { rejectSharedControlPendingRequest } from '../control/remote-runtime-shared-control-state' +import type { SharedControlPendingRequest } from '../control/remote-runtime-shared-control-types' const MAX_RETAINED_METHOD_CHARS = 256 diff --git a/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-close.test.ts b/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-close.test.ts index 37d34b9ae69..faca5ebc863 100644 --- a/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-close.test.ts +++ b/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-close.test.ts @@ -5,7 +5,7 @@ import { sendRetiredSharedControlCleanupRequest } from './remote-runtime-shared-control-subscription-close' import { createSharedControlSubscription } from './remote-runtime-shared-control-subscriptions' -import type { SharedControlLogicalSubscription } from '../../remote-runtime-shared-control-types' +import type { SharedControlLogicalSubscription } from '../control/remote-runtime-shared-control-types' describe('shared-control subscription retirement', () => { it('retires a closed subscription and its cleanup request', () => { diff --git a/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-close.ts b/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-close.ts index be623685d03..80aabe9383c 100644 --- a/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-close.ts +++ b/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-close.ts @@ -3,7 +3,7 @@ import { closeSharedControlLogicalSubscription, sendSharedControlCleanupRequest } from './remote-runtime-shared-control-subscriptions' -import type { SharedControlLogicalSubscription } from '../../remote-runtime-shared-control-types' +import type { SharedControlLogicalSubscription } from '../control/remote-runtime-shared-control-types' export function closeSharedControlConnectionSubscription(args: { subscriptions: Map> diff --git a/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-start.test.ts b/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-start.test.ts index 1cff5de96b6..f2ea9ba78e0 100644 --- a/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-start.test.ts +++ b/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-start.test.ts @@ -3,7 +3,7 @@ import { startSharedControlSubscription } from './remote-runtime-shared-control- import { closeSharedControlConnectionSubscription } from './remote-runtime-shared-control-subscription-close' import { handleSharedControlLogicalResponse } from './remote-runtime-shared-control-subscriptions' import { SharedControlRetiredRequestIds } from './remote-runtime-shared-control-retired-request-ids' -import type { SharedControlLogicalSubscription } from '../../remote-runtime-shared-control-types' +import type { SharedControlLogicalSubscription } from '../control/remote-runtime-shared-control-types' it.each([true, false])( 'cleans up replayed setup aborted with host id known=%s', diff --git a/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-start.ts b/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-start.ts index 9f3570f3e2e..31a10a56411 100644 --- a/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-start.ts +++ b/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscription-start.ts @@ -1,13 +1,13 @@ import { throwIfSignalAborted } from '../../abort-signal-reason' import { randomUUID } from 'node:crypto' import { remoteRuntimeUnavailableError } from './remote-runtime-request-frames' -import { admitSharedControlSubscription } from '../../remote-runtime-shared-control-admission' +import { admitSharedControlSubscription } from '../control/remote-runtime-shared-control-admission' import { createSharedControlSubscription } from './remote-runtime-shared-control-subscriptions' import type { RemoteRuntimeSharedSubscription, SharedControlLogicalSubscription, SharedControlSubscriptionCallbacks -} from '../../remote-runtime-shared-control-types' +} from '../control/remote-runtime-shared-control-types' export async function startSharedControlSubscription(args: { subscriptions: Map> diff --git a/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscriptions.test.ts b/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscriptions.test.ts index 735e9848152..b9cd212b940 100644 --- a/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscriptions.test.ts +++ b/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscriptions.test.ts @@ -6,7 +6,7 @@ import { handleSharedControlLogicalResponse, replaySharedControlSubscriptions } from './remote-runtime-shared-control-subscriptions' -import type { SharedControlLogicalSubscription } from '../../remote-runtime-shared-control-types' +import type { SharedControlLogicalSubscription } from '../control/remote-runtime-shared-control-types' function makeSubscriptions(): { subscriptions: Map> diff --git a/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscriptions.ts b/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscriptions.ts index 1d2d048ca4b..b1124277653 100644 --- a/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscriptions.ts +++ b/src/shared/remote-runtime/requests/remote-runtime-shared-control-subscriptions.ts @@ -1,14 +1,17 @@ import { randomUUID } from 'node:crypto' import type { RuntimeRpcResponse } from '../../runtime-rpc-envelope' -import { getCleanupRequest, getSubscriptionId } from '../../remote-runtime-shared-control-protocol' +import { + getCleanupRequest, + getSubscriptionId +} from '../control/remote-runtime-shared-control-protocol' import { finishSharedControlSubscription, handleSharedControlSubscriptionResponse -} from '../../remote-runtime-shared-control-state' +} from '../control/remote-runtime-shared-control-state' import type { SharedControlLogicalSubscription, SharedControlSubscriptionCallbacks -} from '../../remote-runtime-shared-control-types' +} from '../control/remote-runtime-shared-control-types' export function createSharedControlSubscription(args: { requestId: string diff --git a/src/shared/runtime-host-status.ts b/src/shared/runtime-host-status.ts index db28469ff6b..b9c5a5ab0d2 100644 --- a/src/shared/runtime-host-status.ts +++ b/src/shared/runtime-host-status.ts @@ -1,4 +1,4 @@ -import type { RemoteRuntimeSharedConnectionDiagnostics } from './remote-runtime-shared-control-types' +import type { RemoteRuntimeSharedConnectionDiagnostics } from './remote-runtime/control/remote-runtime-shared-control-types' import type { RuntimeRpcFailure, RuntimeRpcResponse } from './runtime-rpc-envelope' import type { RuntimeStatus } from './runtime-types' diff --git a/src/shared/runtime-session-contracts.ts b/src/shared/runtime-session-contracts.ts index 68da5a23a46..d87f3605b79 100644 --- a/src/shared/runtime-session-contracts.ts +++ b/src/shared/runtime-session-contracts.ts @@ -1,7 +1,7 @@ import type { MobileProjectSectionCatalog } from './mobile-project-sections-contract' import type { AgentStatusOrchestrationContext } from './agent-status-types' import type { RemoteServerUpdateSupport } from './remote-server-update' -import type { RemoteRuntimeSharedConnectionDiagnostics } from './remote-runtime-shared-control-types' +import type { RemoteRuntimeSharedConnectionDiagnostics } from './remote-runtime/control/remote-runtime-shared-control-types' import type { RuntimeHostConnectionState } from './runtime-host-connection-state' import type { RuntimeCapability } from './protocol-version' import type {