From 6d5edf8c3350cfb8b5e35f6aecea8a1f8a8ef9bf Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Mon, 2 Nov 2026 23:36:23 -0800 Subject: [PATCH] refactor(main): organize WSL discovery filesystem and execution owners (#37722) * refactor(main): organize WSL discovery filesystem and execution owners * refactor(main): consolidate defining-owner path imports --- .github/workflows/pr.yml | 2 +- config/flaky-test-pattern-baseline.txt | 6 +- config/main-sync-spawn-baseline.txt | 2 +- .../scripts/check-main-sync-spawn-ratchet.mjs | 11 +- .../check-main-sync-spawn-ratchet.test.mjs | 42 ++++-- config/scripts/ci-shard-timings.json | 90 ++++++------ config/scripts/ci-unit-files.mjs | 2 +- config/scripts/pr-package-test-paths.mjs | 4 +- config/scripts/pr-shell-contract-prefixes.mjs | 4 +- .../win32-test-lane-registration.test.mjs | 4 +- config/scripts/wsl-e2e-lane-contract.test.mjs | 4 +- config/tsconfig.tc.web.json | 25 ++-- .../agent-hooks/wsl-agent-plugin-readiness.ts | 2 +- src/main/agent-hooks/wsl-hook-relay-deps.ts | 9 +- .../agent-hooks/wsl-hook-relay-launch.test.ts | 4 +- src/main/agent-hooks/wsl-hook-relay-launch.ts | 6 +- .../wsl-hook-relay-recovery.test.ts | 8 +- .../wsl-hook-relay-state-machine.ts | 2 +- .../trust/agent-workspace-trust.test.ts | 2 +- .../trust/agent-workspace-trust.ts | 2 +- .../cached-session-list-wsl-probe.test.ts | 8 +- src/main/ai-vault/cached-session-list.test.ts | 8 +- src/main/ai-vault/cached-session-list.ts | 6 +- .../opencode-wsl-runtime-preparation.test.ts | 2 +- .../opencode-wsl-runtime-preparation.ts | 4 +- src/main/ai-vault/session-delete.test.ts | 2 +- src/main/ai-vault/session-delete.ts | 2 +- src/main/ai-vault/session-scanner-devin-db.ts | 2 +- ...ession-scanner-opencode-wsl-client.test.ts | 4 +- .../session-scanner-opencode-wsl-client.ts | 6 +- .../ai-vault/session-scanner-service-entry.ts | 5 +- .../session-scanner-service-wsl-notes.ts | 2 +- .../session-scanner-wsl-stop-gaps.test.ts | 18 ++- ...omation-wsl-distro-stopped-refusal.test.ts | 4 +- src/main/automations/dispatch-refusal.ts | 2 +- .../claude-command-process.test.ts | 2 +- .../claude-accounts/claude-command-process.ts | 2 +- .../claude-profile-wsl-router.test.ts | 10 +- .../claude-profile-wsl-router.ts | 8 +- .../runtime-auth-service.test.ts | 2 +- .../claude-accounts/runtime-auth-service.ts | 4 +- ...claude-folder-trust-file-wsl-guest.test.ts | 4 +- src/main/claude/claude-folder-trust-file.ts | 2 +- src/main/cli/wsl-cli-installer.test.ts | 2 +- src/main/cli/wsl-cli-installer.ts | 6 +- src/main/cli/wsl-cli-login-path.test.ts | 2 +- .../wsl-cli-registration-reconciliation.ts | 4 +- .../codex-accounts/codex-config-mirror.ts | 7 +- .../codex-login-session-wsl-open.test.ts | 2 +- .../codex-accounts/codex-login-session.ts | 2 +- .../codex-managed-home-lifecycle.ts | 5 +- .../codex-managed-home-path-wsl-check.test.ts | 14 +- .../codex-accounts/codex-managed-home-path.ts | 5 +- .../legacy-wsl-runtime-auth-drain.test.ts | 2 +- .../legacy-wsl-runtime-auth-drain.ts | 2 +- ...ntime-home-history-sharing-opt-out.test.ts | 7 +- ...time-home-rate-limit-pinned-distro.test.ts | 6 +- .../runtime-home-service-home-routing.ts | 6 +- .../runtime-home-service-launch.ts | 4 +- .../runtime-home-service-managed-home.ts | 2 +- .../runtime-home-service-wsl.ts | 2 +- .../runtime-home-wsl-managed-accounts.test.ts | 26 ++-- ...time-home-wsl-passive-restore-prep.test.ts | 8 +- .../runtime-home-wsl-session-bridge.test.ts | 32 +++-- .../runtime-home-wsl-sibling-bridge.test.ts | 2 +- .../runtime-home-wsl-system-default.test.ts | 12 +- .../service-wsl-accounts.test.ts | 92 +++++------- .../service-wsl-test-results.ts | 2 +- .../wsl-codex-auth-batch-reader.ts | 2 +- src/main/codex/codex-hook-wsl-runtime.ts | 2 +- .../codex-hook-wsl-stopped-distro.test.ts | 2 +- .../codex-runtime-home-launch-preparation.ts | 2 +- src/main/codex/codex-session-index-heal.ts | 2 +- ...odex-state-db-backfill-recovery-process.ts | 2 +- src/main/codex/codex-trust-grant-host.ts | 2 +- .../codex/codex-wsl-hook-install-plan.test.ts | 2 +- src/main/codex/codex-wsl-hook-install-plan.ts | 4 +- .../codex/codex-wsl-hook-user-acts.test.ts | 4 +- .../codex/managed-wsl-home-shell-preflight.ts | 2 +- .../wsl-codex-session-bridge-index.test.ts | 10 +- .../codex/wsl-codex-session-bridge.test.ts | 6 +- src/main/codex/wsl-codex-session-bridge.ts | 8 +- ...y-adapter-wsl-distro-loss-relaunch.test.ts | 2 +- ...daemon-pty-adapter-wsl-distro-loss.test.ts | 2 +- ...y-adapter-wsl-passive-restore-hold.test.ts | 4 +- src/main/daemon/daemon-pty-session-spawn.ts | 2 +- .../daemon/daemon-wsl-bridge-boot-identity.ts | 6 +- .../daemon-wsl-bridge-exit-no-boot.test.ts | 6 +- .../daemon/daemon-wsl-bridge-exit.test.ts | 4 +- src/main/daemon/daemon-wsl-bridge-exit.ts | 2 +- .../daemon-wsl-hold-read-anchor.test.ts | 8 +- .../daemon/daemon-wsl-passive-restore-hold.ts | 2 +- .../pty-subprocess/shell-launch-plan.ts | 4 +- .../daemon/terminal-host-wsl-context.test.ts | 4 +- src/main/daemon/wsl-session-context.ts | 3 +- .../destination-serialized-local-rename.ts | 2 +- .../default-wsl-cli-fallback.ts | 4 +- .../git/command-runner/git-process-env.ts | 2 +- .../git/command-runner/git-ssh-policy-env.ts | 2 +- src/main/git/command-runner/glab-exec-file.ts | 2 +- .../command-runner/local-git-runtime-route.ts | 2 +- .../wsl-command-resolution-allowlist.test.ts | 4 +- .../command-runner/wsl-command-resolution.ts | 8 +- .../git/command-runner/wsl-host-failure.ts | 5 +- .../command-runner/wsl-path-translation.ts | 4 +- .../git/default-wsl-cli-fallback-gate.test.ts | 15 +- src/main/git/local-git-object-quarantine.ts | 2 +- ...l-repo-ref-maintenance-wsl-stopped.test.ts | 9 +- src/main/git/local-repo-ref-maintenance.ts | 2 +- src/main/git/repo-detection.ts | 3 +- src/main/git/runner-wsl-gh-fallback.test.ts | 8 +- .../runner-wsl-linked-gitdir-windows.test.ts | 9 +- src/main/git/runner.ts | 2 - src/main/git/windows-worktree-removal.ts | 2 +- src/main/git/worktree-git-path.ts | 2 +- src/main/git/worktree-removal.ts | 2 +- src/main/git/wsl-git-read-environment.ts | 2 +- .../git/wsl-process-group-termination.test.ts | 6 +- src/main/git/wsl-process-group-termination.ts | 8 +- .../wsl-windows-checkout-git-probe.test.ts | 2 +- .../git/wsl-windows-checkout-git-probe.ts | 2 +- src/main/git/wsl-worktree-git-path.test.ts | 2 +- src/main/git/wsl-worktree-git-path.ts | 5 +- .../client/check/check-job-log-execution.ts | 2 +- .../check/check-job-log-routing.test.ts | 8 +- .../github/github-enterprise-repository.ts | 2 +- .../github-ssh-host-alias-resolution.ts | 2 +- ...esh-coordinator-wsl-stopped-distro.test.ts | 6 +- src/main/github/pr-refresh-coordinator.ts | 2 +- src/main/github/pr-refresh-queue-drainer.ts | 4 +- src/main/github/pr-start-point-wsl-gate.ts | 2 +- .../gitlab/gitlab-project-ref-resolution.ts | 2 +- src/main/ipc/ai-vault-resume.ts | 2 +- src/main/ipc/ai-vault-scan-coalescing.test.ts | 4 +- .../ipc/ai-vault-unresolved-owner.test.ts | 2 +- src/main/ipc/ai-vault.test.ts | 2 +- src/main/ipc/app.test.ts | 10 +- src/main/ipc/app.ts | 3 +- .../cli-appimage-stale-registration.test.ts | 2 +- src/main/ipc/cli.test.ts | 6 +- src/main/ipc/cli.ts | 9 +- src/main/ipc/dropped-path-resolution.ts | 3 +- .../filesystem/filesystem-allowed-roots.ts | 2 +- src/main/ipc/filesystem/filesystem-auth.ts | 5 +- .../filesystem-branch-compare-diff.test.ts | 2 +- .../filesystem-chunk-read-handler.ts | 2 +- ...lesystem-commit-message-generation.test.ts | 2 +- ...tem-commit-message-model-discovery.test.ts | 2 +- ...esystem-conflict-operation-routing.test.ts | 2 +- ...system-content-search-cancellation.test.ts | 12 +- .../filesystem-download-transfers.test.ts | 2 +- .../filesystem-file-content-unc-drive.test.ts | 4 +- .../filesystem-git-commit-dispatch.test.ts | 2 +- ...filesystem-git-model-discovery-handlers.ts | 2 +- .../filesystem-git-status-handlers.ts | 2 +- .../filesystem-git-status-staging.test.ts | 2 +- ...tem-list-files-handler-name-filter.test.ts | 2 +- ...lesystem-markdown-document-listing.test.ts | 2 +- .../ipc/filesystem/filesystem-mutations.ts | 2 +- .../filesystem/filesystem-path-containment.ts | 2 +- ...pull-request-linked-issue-lifetime.test.ts | 2 +- .../filesystem-read-dir-unc-drive.test.ts | 4 +- .../filesystem/filesystem-read-handlers.ts | 7 +- .../filesystem-search-rg-timeout.test.ts | 12 +- .../filesystem-symlink-directory-entries.ts | 2 +- .../filesystem/filesystem-write-handlers.ts | 4 +- .../filesystem-wsl-stopped-distro-git.test.ts | 6 +- ...ilesystem-wsl-stopped-distro-reads.test.ts | 9 +- src/main/ipc/filesystem/filesystem.test.ts | 4 +- .../filesystem/git-remote/compare-handlers.ts | 2 +- .../filesystem/git-remote/sync-handlers.ts | 2 +- .../filesystem/local-disk-bytes-replace.ts | 2 +- .../local-disk-write-precondition.ts | 2 +- .../ipc/filesystem/local-regular-file-read.ts | 2 +- .../filesystem-watcher-local-install.test.ts | 8 +- .../filesystem-watcher-local-install.ts | 6 +- .../filesystem/watchers/wsl-watcher-spawn.ts | 2 +- .../filesystem/wsl-gated-worktree-git-read.ts | 2 +- ...-status-upstream-ref-watch-request.test.ts | 4 +- .../git-status-upstream-ref-watch-request.ts | 2 +- ...ithub-pr-refresh-document-lifetime.test.ts | 2 +- src/main/ipc/github-repo-routing.ts | 2 +- .../ipc/github-wsl-runtime-routing.test.ts | 2 +- src/main/ipc/gitlab-work-item-handlers.ts | 2 +- src/main/ipc/gitlab.test.ts | 2 +- .../register-worktree-hook-check-handler.ts | 2 +- ...gister-worktree-hook-inspection-handler.ts | 4 +- ...worktree-hook-inspection-unc-drive.test.ts | 4 +- src/main/ipc/hosted-review.test.ts | 4 +- src/main/ipc/hosted-review.ts | 2 +- src/main/ipc/local-file-access-resolution.ts | 2 +- .../ipc/native-chat-wsl-open-wake.test.ts | 4 +- .../ipc/preflight-agent-detection.test.ts | 4 +- src/main/ipc/preflight-agent-refresh.test.ts | 4 +- .../ipc/preflight-host-cli-status.test.ts | 4 +- .../ipc/preflight-wsl-agent-detection.test.ts | 2 +- src/main/ipc/preflight-wsl-agent-detection.ts | 2 +- src/main/ipc/preflight-wsl-command.test.ts | 2 +- src/main/ipc/preflight-wsl-command.ts | 2 +- src/main/ipc/preflight-wsl-refusal-retry.ts | 7 +- .../ipc/preflight-wsl-stopped-distro.test.ts | 10 +- src/main/ipc/preflight.ts | 2 +- src/main/ipc/project-folder-link-path.ts | 2 +- .../pty-attach-view-joins-main-start.test.ts | 2 +- .../pty-claude-agent-view-readiness.test.ts | 2 +- ...ty-degraded-fallback-single-ingest.test.ts | 2 +- .../pty-spawn-saved-resume-admission.test.ts | 2 +- .../ipc/pty-spawn-scaling.performance.test.ts | 2 +- .../pty-applied-size-reporting.test.ts | 2 +- .../pty-buffer-snapshot-dispatch.test.ts | 2 +- .../delivery/pty-delivery-health-heal.test.ts | 2 +- .../pty-global-renderer-credit.test.ts | 2 +- .../delivery/pty-ipc-gap-escape-state.test.ts | 2 +- .../pty-ipc-hidden-delivery-gate.test.ts | 2 +- .../pty-output-batching-drain.test.ts | 2 +- .../delivery/pty-pending-output-cap.test.ts | 2 +- .../pty-renderer-inflight-credit.test.ts | 2 +- ...-renderer-lifecycle-delivery-reset.test.ts | 2 +- src/main/ipc/pty/host-env/assembly.ts | 2 +- src/main/ipc/pty/host-env/codex-home.ts | 2 +- .../spawn-cwd-wsl-stopped-folder.test.ts | 6 +- src/main/ipc/pty/host-env/spawn-cwd.ts | 2 +- .../startup-cwd-directory-exists.test.ts | 4 +- .../host-env/startup-cwd-directory-exists.ts | 2 +- src/main/ipc/pty/provider/local-configure.ts | 2 +- .../ipc/pty/pty-absent-pane-respawn.test.ts | 2 +- .../pty-activation-inventory-scope.test.ts | 2 +- .../pty/pty-agent-launch-pane-attach.test.ts | 2 +- .../ipc/pty/pty-antigravity-launch.test.ts | 2 +- .../pty/pty-closed-pane-spawn-refusal.test.ts | 2 +- .../pty/pty-codex-account-attribution.test.ts | 2 +- .../pty-controller-ownership-routing.test.ts | 2 +- .../pty-controller-spawn-admission.test.ts | 2 +- .../pty-daemon-controller-teardown.test.ts | 2 +- .../pty-daemon-spawn-agent-home-env.test.ts | 2 +- .../pty/pty-daemon-spawn-codex-auth.test.ts | 2 +- .../pty-daemon-spawn-session-identity.test.ts | 2 +- .../pty/pty-daemon-spawn-wsl-runtime.test.ts | 6 +- .../ipc/pty/pty-dead-owner-respawn.test.ts | 2 +- ...y-dispatcher-handshake-osc-answers.test.ts | 2 +- .../ipc/pty/pty-hidden-at-spawn-mark.test.ts | 2 +- .../pty/pty-ipc-hidden-restore-ack.test.ts | 2 +- src/main/ipc/pty/pty-ipc-mock-registry.ts | 2 +- src/main/ipc/pty/pty-ipc-suite-environment.ts | 2 +- src/main/ipc/pty/pty-launch-parity.test.ts | 4 +- .../ipc/pty/pty-launch-race-parity.test.ts | 2 +- .../pty-listener-teardown-and-orphans.test.ts | 2 +- .../pty-login-shell-startup-commands.test.ts | 2 +- .../pty/pty-pane-claim-arbitration.test.ts | 2 +- .../pty/pty-pane-materialization-race.test.ts | 2 +- .../pty-pane-reservation-settlement.test.ts | 2 +- .../ipc/pty/pty-pane-restart-replace.test.ts | 2 +- .../pty-persisted-incarnation-repair.test.ts | 2 +- .../pty/pty-renderer-liveness-guard.test.ts | 2 +- .../pty/pty-restore-record-seeding.test.ts | 2 +- .../pty-runtime-hidden-at-spawn-mark.test.ts | 2 +- .../ipc/pty/pty-runtime-kill-and-exit.test.ts | 2 +- ...ty-runtime-ssh-binding-persistence.test.ts | 2 +- .../pty-serializer-settlement-mapping.test.ts | 2 +- ...pty-session-liveness-and-ownership.test.ts | 2 +- .../pty-spawn-codex-home-unavailable.test.ts | 2 +- ...pty-spawn-cwd-fallback-hung-folder.test.ts | 2 +- .../ipc/pty/pty-spawn-cwd-fallback.test.ts | 4 +- .../pty/pty-spawn-env-agent-overlays.test.ts | 2 +- .../pty-spawn-env-codex-home-routing.test.ts | 2 +- ...-spawn-env-codex-resume-provenance.test.ts | 2 +- .../pty/pty-spawn-env-terminal-basics.test.ts | 2 +- .../pty-spawn-runtime-handle-binding.test.ts | 2 +- ...pty-spawn-wsl-passive-restore-hold.test.ts | 4 +- src/main/ipc/pty/pty-ssh-stop-verdict.test.ts | 2 +- .../pty-startup-barrier-and-listing.test.ts | 2 +- .../pty-startup-swap-window-presence.test.ts | 2 +- .../pty/pty-windows-shell-selection.test.ts | 2 +- .../ipc/pty/pty-write-ipc-validation.test.ts | 2 +- .../ipc/pty/register-without-renderer.test.ts | 2 +- ...pawn-preflight-wsl-background-hold.test.ts | 6 +- src/main/ipc/pty/spawn-execute.ts | 5 +- ...spawn-host-env-wsl-passive-restore.test.ts | 8 +- src/main/ipc/pty/spawn-host-env.ts | 4 +- src/main/ipc/pty/spawn-startup-target.ts | 2 +- src/main/ipc/pty/wsl-terminal-spawn.ts | 2 +- .../ipc/qoder-desktop-execution-host.test.ts | 2 +- ...-independent-renderer-spawn-review.test.ts | 2 +- .../ipc/repos-remote-base-ref-queries.test.ts | 4 +- .../repos/base-ref-default-wsl-gate.test.ts | 6 +- src/main/ipc/repos/base-ref-query-handlers.ts | 2 +- src/main/ipc/repos/local-repo-registration.ts | 2 +- src/main/ipc/shell-path-existence-handlers.ts | 2 +- ...ell-paths-exist-wsl-stopped-distro.test.ts | 4 +- ...ll-install-management-ipc-handlers.test.ts | 2 +- .../skill-install-management-ipc-handlers.ts | 2 +- src/main/ipc/skills.test.ts | 39 ++++-- src/main/ipc/skills.ts | 2 +- src/main/ipc/worktree-logic-wsl.test.ts | 6 +- src/main/ipc/worktree-logic.ts | 3 +- ...thoritative-local-metadata-pruning.test.ts | 2 +- .../ipc/worktrees-detected-scan-cache.test.ts | 2 +- .../ipc/worktrees-wsl-runtime-routing.test.ts | 2 +- .../register-worktree-prefetch-handler.ts | 2 +- ...ktree-base-directory-watch-targets.test.ts | 2 +- .../listing/detected-provider-listing.ts | 2 +- .../listing/detected-worktree-scan-cache.ts | 5 +- ...ected-worktree-scan-listing-distro.test.ts | 4 +- .../listing/wsl-distro-starting-scan.ts | 2 +- .../wsl-stopped-worktree-listing.test.ts | 8 +- .../listing/wsl-stopped-worktree-listing.ts | 9 +- .../registered-worktree-root-probes.ts | 5 +- ...tered-worktree-root-stopped-distro.test.ts | 4 +- .../ipc/wsl-drive-project-handlers.test.ts | 2 +- src/main/ipc/wsl-drive-project-handlers.ts | 2 +- .../ipc/wsl-drive-unc-conversion-handlers.ts | 10 +- src/main/ipc/wsl-host-handlers.ts | 2 +- src/main/ipc/wsl-move-driver-wiring.ts | 2 +- .../ipc/wsl-move-orchestrator-wiring.test.ts | 8 +- src/main/ipc/wsl-move-orchestrator-wiring.ts | 6 +- src/main/kimi/kimi-runtime-home.test.ts | 2 +- src/main/kimi/kimi-runtime-home.ts | 4 +- src/main/media/local-preview-grant-file.ts | 2 +- .../media/preview-grant-range-read.test.ts | 4 +- .../host-readable-transcript-path.test.ts | 12 +- .../host-readable-transcript-path.ts | 6 +- .../native-chat/native-chat-media-path.ts | 2 +- src/main/native-chat/native-chat-open-wake.ts | 2 +- ...ession-file-resolver-wsl-scan-gate.test.ts | 10 +- .../session-file-resolver-wsl.test.ts | 16 ++- ...nscript-watch-engine-wsl-lifecycle.test.ts | 2 +- .../transcript-watch-wsl-exact-path.test.ts | 10 +- .../transcript-watch-wsl-stall.test.ts | 2 +- .../wsl-transcript-running-admission.test.ts | 6 +- .../wsl-transcript-running-admission.ts | 2 +- .../wsl-transcript-running-observer.test.ts | 4 +- .../wsl-transcript-running-observer.ts | 4 +- .../wsl-transcript-watcher-running-guard.ts | 2 +- .../opencode/opencode-launch-capabilities.ts | 2 +- .../opencode-wsl-probe-environment.test.ts | 4 +- .../repo-lifecycle-operations.ts | 4 +- .../moving-wsl-projects/wsl-move-fence.ts | 2 +- .../wsl-move-host-readiness.ts | 2 +- .../wsl-move-moved-distro-check.ts | 2 +- .../wsl-move-scope-guard.ts | 2 +- .../moving-wsl-projects/wsl-move-startup.ts | 2 +- .../persistence-repo-lifecycle.test.ts | 2 +- ...orkspace-port-attribution-wsl-gate.test.ts | 4 +- .../ports/local-workspace-port-attribution.ts | 2 +- src/main/preflight/agent-detection.ts | 4 +- .../preflight-wsl-stopped-distro.test.ts | 8 +- .../workspace-agent-detection.test.ts | 4 +- .../preflight/workspace-agent-detection.ts | 2 +- .../folder-workspace-path-status.ts | 2 +- .../providers/local-filesystem-provider.ts | 2 +- .../local-pty-executable-spawn.test.ts | 2 +- .../local-pty/local-pty-launch-context.ts | 2 +- .../local-pty/local-pty-launch-plan.ts | 3 +- ...al-pty-provider-foreground-process.test.ts | 20 ++- .../local-pty-provider-io-events.test.ts | 20 ++- ...cal-pty-provider-session-inventory.test.ts | 20 ++- ...local-pty-provider-shell-readiness.test.ts | 20 ++- .../local-pty-provider-shutdown.test.ts | 20 ++- ...ocal-pty-provider-spawn-cwd-safety.test.ts | 20 ++- .../local-pty-provider-spawn-env.test.ts | 20 ++- .../local-pty-provider-spawn-session.test.ts | 20 ++- ...-pty-provider-windows-shell-launch.test.ts | 22 ++- .../local-pty/local-pty-session-operations.ts | 2 +- .../local-pty-shell-ready-bash-rcfile.ts | 4 +- .../local-pty-shell-ready-wrapper-fileset.ts | 2 +- ...y-spawn-environment-wsl-background.test.ts | 4 +- .../local-pty-windows-spawn-environment.ts | 2 +- src/main/providers/windows-shell-args.ts | 3 +- ...ing-directory-validation-retention.test.ts | 2 +- .../working-directory-validation.test.ts | 2 +- .../providers/working-directory-validation.ts | 2 +- .../pty/history/terminal-history-deletion.ts | 4 +- .../terminal-history-tombstone-retry.test.ts | 4 +- src/main/pty/history/terminal-history.test.ts | 7 +- src/main/pty/history/terminal-history.ts | 2 +- .../zsh-startup-wrapper-builder.ts | 4 +- .../claude-managed-account-usage.ts | 2 +- .../rate-limits/claude-profile-usage.test.ts | 2 +- src/main/rate-limits/codex-fetcher.test.ts | 2 +- src/main/rate-limits/codex-fetcher.ts | 2 +- .../codex-rate-limit-wsl-home-gate.test.ts | 4 +- .../codex-rate-limit-wsl-home-gate.ts | 4 +- src/main/rate-limits/inactive-codex-home.ts | 2 +- .../ripgrep/bundled-ripgrep-text-search.ts | 2 +- .../ripgrep/bundled-ripgrep-wsl-routing.ts | 2 +- .../agent-launch-scope-runtime.test.ts | 2 +- src/main/runtime/files/file-reads.ts | 4 +- .../opencode-wsl-folder-launch-host.test.ts | 2 +- .../orca-runtime-create-base-prefetch.test.ts | 2 +- .../orca-runtime-test-mocks/setup.spec.ts | 4 +- .../wsl-stopped-distro-worktree-scan.spec.ts | 2 +- .../runtime/rpc/methods/host-capabilities.ts | 3 +- .../methods/preflight-selected-target.test.ts | 2 +- .../runtime/rpc/methods/preflight.test.ts | 2 +- src/main/runtime/rpc/methods/skills.test.ts | 2 +- src/main/runtime/rpc/methods/skills.ts | 2 +- .../runtime-agent-terminal-startup.test.ts | 2 +- ...er-workspace-wsl-failed-start-pane.test.ts | 4 +- ...-folder-workspace-wsl-launch-scope.test.ts | 4 +- ...time-gitlab-worktree-base-wsl-gate.test.ts | 4 +- .../runtime/runtime-hosted-review-commands.ts | 2 +- .../runtime-repository-fork-backfill.ts | 2 +- .../runtime-repository-hooks-commands.test.ts | 2 +- .../runtime-repository-hooks-commands.ts | 4 +- .../runtime/runtime-repository-ref-queries.ts | 2 +- ...time-repository-registration-controller.ts | 4 +- .../runtime-skill-install-authority.ts | 2 +- .../runtime/runtime-skill-install-queries.ts | 2 +- .../runtime-wsl-background-read-gate.test.ts | 4 +- .../runtime-wsl-background-read-gate.ts | 2 +- .../session-graph/session-graph-authority.ts | 2 +- .../runtime/terminal-kitty-temporary-roots.ts | 3 +- .../runtime/terminal/terminal-file-path.ts | 3 +- .../terminal/terminal-path-resolver.ts | 2 +- .../workspaces/workspace-repo-scan-refresh.ts | 2 +- .../skills/claude-plugin-skill-sources-wsl.ts | 4 +- .../discovery-wsl-stopped-distro.test.ts | 4 +- src/main/skills/discovery.ts | 2 +- .../skill-discovery-stopped-wsl-roots.ts | 2 +- src/main/skills/skill-discovery-target.ts | 6 +- .../skill-discovery-wsl-alias-sharing.test.ts | 2 +- .../skill-discovery-wsl-plugins.test.ts | 4 +- src/main/skills/skill-discovery-wsl.ts | 4 +- .../skill-install-discovery-wsl.test.ts | 4 +- .../skills/skill-provider-runtime-roots.ts | 2 +- .../skill-wsl-delete.integration.test.ts | 2 +- .../skill-wsl-install-filesystem.test.ts | 2 +- .../skills/skill-wsl-install-filesystem.ts | 2 +- .../skill-wsl-provider-detection.test.ts | 2 +- .../skills/skill-wsl-provider-detection.ts | 2 +- .../ssh-expired-lease-pane-readoption.test.ts | 14 +- .../ssh-reattach-pane-cardinality.test.ts | 6 +- ...odex-launch-per-agent-hook-opt-out.test.ts | 2 +- src/main/startup/main-process-quit.ts | 2 +- .../startup/main-process-ready-foundation.ts | 2 +- .../wsl-holder-uninstall-preflight.test.ts | 6 +- .../startup/wsl-holder-uninstall-preflight.ts | 3 +- src/main/telemetry/wsl-usage-reporter.ts | 12 +- .../source-control-wsl-launch.test.ts | 2 +- .../source-control-wsl-prompt.test.ts | 2 +- .../workspace-hooks/hook-runtime-target.ts | 2 +- src/main/workspace-hooks/hooks.test.ts | 2 +- src/main/workspace-hooks/hooks.ts | 4 +- .../workspace-hooks/issue-command-file.ts | 2 +- .../issue-command-wsl-stopped-distro.test.ts | 4 +- .../workspace-hooks/worktree-runner-script.ts | 4 +- ...-git-enrichment-wsl-stopped-distro.test.ts | 4 +- ...epo-git-remote-identity-enrichment.test.ts | 6 +- .../repo-git-remote-identity-enrichment.ts | 2 +- ...po-git-username-enrichment-wsl-act.test.ts | 6 +- .../catalog/repo-git-username-enrichment.ts | 4 +- ...rktree-create-preparation-wsl-root.test.ts | 4 +- .../worktree-root-preparation.test.ts | 6 +- .../creation/worktree-root-preparation.ts | 2 +- .../local-project-runtime-resolution.ts | 7 +- .../project-runtime-git-options.test.ts | 2 +- .../project-runtime-git-router.ts | 4 +- ...ct-runtime-read-git-options-opt-in.test.ts | 2 +- .../removal/local-worktree-filesystem.ts | 4 +- .../retirement/worktree-name-retirement.ts | 4 +- .../worktree-retirement-discovery-wsl.test.ts | 2 +- .../worktree-retirement-discovery.ts | 2 +- .../removal/worktree-background-removal.ts | 2 +- src/main/workspaces/removal/worktree-trash.ts | 2 +- src/main/wsl-approved-root-race.wsl.test.ts | 4 +- src/main/wsl-env.ts | 1 - .../discovery/distro-catalog.test.ts} | 128 +++-------------- .../discovery/distro-catalog.ts} | 86 ++---------- .../discovery}/preflight-wsl-cache.ts | 0 .../{ => wsl/discovery}/wsl-availability.ts | 4 +- .../wsl-background-distro-gate.test.ts | 4 +- .../discovery}/wsl-background-distro-gate.ts | 4 +- .../wsl-background-exec-gate.test.ts | 4 +- .../wsl-background-exec-gate.ts | 2 +- .../wsl-console-running-distros.test.ts | 0 .../discovery}/wsl-console-running-distros.ts | 4 +- .../wsl/{ => discovery}/wsl-default-distro.ts | 2 +- .../wsl/{ => discovery}/wsl-distro-boot-id.ts | 6 +- .../wsl-distro-holder-command.ts | 4 +- ...sl-distro-holder-process-classification.ts | 2 +- .../wsl-distro-holder-record.ts | 4 +- .../wsl-distro-holder-script.test.ts | 2 +- .../wsl-distro-holder-types.ts | 2 +- .../{ => discovery}/wsl-distro-holder.test.ts | 7 +- .../wsl/{ => discovery}/wsl-distro-holder.ts | 21 +-- .../discovery}/wsl-distro-list-output.test.ts | 0 .../discovery}/wsl-distro-list-output.ts | 0 .../wsl-distro-list-single-flight.test.ts | 2 +- .../wsl-distro-registry-id.test.ts | 0 .../{ => discovery}/wsl-distro-registry-id.ts | 0 .../{ => wsl/discovery}/wsl-distro-retry.ts | 0 .../{ => discovery}/wsl-distro-unsupported.ts | 8 +- .../{ => wsl/discovery}/wsl-home-cache.ts | 0 .../wsl-home-unless-stopped.ts | 8 +- .../wsl-last-seen-running-age.test.ts | 0 .../discovery}/wsl-lost-list-output.test.ts | 2 +- .../wsl-registered-distro-fallback.ts | 2 +- .../discovery}/wsl-running-distro-cache.ts | 0 .../wsl-running-distro-stop.test.ts | 0 .../discovery}/wsl-running-distros.test.ts | 8 +- .../wsl-stopped-worktree-rescan-registry.ts | 0 .../wsl-user-act-scope.test.ts | 0 .../wsl/{ => discovery}/wsl-user-act-scope.ts | 0 .../{ => wsl/execution}/wsl-bash-command.ts | 4 +- .../wsl-command-channel.test.ts | 0 .../{ => execution}/wsl-command-channel.ts | 2 +- .../{ => execution}/wsl-command-loop-pool.ts | 4 +- .../{ => execution}/wsl-command-loop.test.ts | 2 +- .../wsl/{ => execution}/wsl-command-loop.ts | 2 +- .../{ => wsl/execution}/wsl-exe-process.ts | 11 ++ .../{ => execution}/wsl-executable-path.ts | 0 .../wsl-executable-path.win32.test.ts | 0 .../wsl-interop-health.test.ts | 4 +- .../wsl/{ => execution}/wsl-interop-health.ts | 6 +- .../wsl-interop-registration.test.ts | 0 .../wsl-interop-registration.ts | 0 .../wsl-interop-spawn-directory.test.ts | 0 .../execution}/wsl-interop-spawn-directory.ts | 0 .../wsl-managed-cli-path-restore.test.ts | 0 .../wsl-managed-cli-path-restore.ts | 0 .../wsl-node-runtime-download-budget.ts | 2 +- .../wsl-node-runtime-prefetch.test.ts | 2 +- .../wsl-node-runtime-prefetch.ts | 10 +- .../{ => execution}/wsl-process-failure.ts | 0 .../wsl/{ => execution}/wsl-runner.test.ts | 4 +- src/main/wsl/{ => execution}/wsl-runner.ts | 13 +- .../{ => execution}/wsl-runner.wsl.test.ts | 2 +- .../wsl/filesystem/unc-path-access.test.ts | 132 ++++++++++++++++++ src/main/wsl/filesystem/unc-path-access.ts | 50 +++++++ .../wsl-automount-root.test.ts | 9 +- .../{ => filesystem}/wsl-automount-root.ts | 12 +- .../filesystem}/wsl-contained-delete.ts | 2 +- .../wsl-directory-probe-command.ts | 2 +- .../wsl-directory-upload.test.ts | 5 +- .../{ => filesystem}/wsl-directory-upload.ts | 16 +-- .../wsl-drive-project-new-default.test.ts | 4 +- .../wsl-drive-project-new-default.ts | 16 +-- .../wsl-drive-project-windows-git.test.ts | 6 +- .../wsl-drive-project-windows-git.ts | 16 +-- .../wsl-drive-unc-conversion-journal.ts | 4 +- .../wsl-drive-unc-conversion-renderer.test.ts | 0 .../wsl-drive-unc-conversion-renderer.ts | 4 +- .../wsl-drive-unc-conversion-run.test.ts | 8 +- .../wsl-drive-unc-conversion-run.ts | 18 +-- .../wsl-drive-unc-conversion-startup.test.ts | 28 ++-- .../wsl-drive-unc-conversion-startup.ts | 16 +-- .../wsl-drive-unc-conversion-stores.ts | 14 +- .../wsl-drive-unc-discovery-shadows.ts | 10 +- .../wsl-drive-unc-identity-rewrite.test.ts | 0 .../wsl-drive-unc-identity-rewrite.ts | 19 +-- .../{ => filesystem}/wsl-drive-unc-mounts.ts | 14 +- .../wsl-drive-unc-project-scope.test.ts | 13 +- .../wsl-drive-unc-project-scope.ts | 21 ++- .../wsl-drive-unc-state-rewrite.test.ts | 12 +- .../wsl-drive-unc-state-rewrite.ts | 24 ++-- .../wsl-running-path-filter.test.ts | 4 +- .../filesystem}/wsl-running-path-filter.ts | 4 +- .../wsl-sh-cwd-report.node-pty.test.ts | 4 +- .../filesystem}/wsl-shell-cwd-report.test.ts | 8 +- .../filesystem}/wsl-shell-cwd-report.ts | 0 .../{ => filesystem}/wsl-unc-access-denied.ts | 4 +- .../wsl-unc-access-gate-user-act.test.ts | 6 +- .../wsl-unc-access-gate.test.ts | 14 +- .../{ => filesystem}/wsl-unc-access-gate.ts | 13 +- .../filesystem}/wsl-unc-delete.test.ts | 6 +- .../{ => wsl/filesystem}/wsl-unc-delete.ts | 8 +- .../filesystem}/wsl-unc-delete.wsl.test.ts | 0 .../wsl-unc-drive-file-content.test.ts | 8 +- .../wsl-unc-drive-fs-path.test.ts | 0 .../{ => filesystem}/wsl-unc-drive-fs-path.ts | 2 +- .../history}/wsl-fish-history-cleanup.test.ts | 0 .../history}/wsl-fish-history-cleanup.ts | 6 +- src/main/wsl/wsl-guest-environment.test.ts | 2 +- src/main/wsl/wsl-guest-environment.ts | 4 +- src/main/wsl/wsl-guest-pane-processes.test.ts | 6 +- src/main/wsl/wsl-guest-pane-processes.ts | 4 +- src/main/wsl/wsl-guest-process-table.test.ts | 8 +- src/main/wsl/wsl-guest-process-table.ts | 4 +- src/main/wsl/wsl-host-add-admission.ts | 2 +- src/main/wsl/wsl-host-connector.test.ts | 4 +- src/main/wsl/wsl-host-connector.ts | 9 +- src/main/wsl/wsl-host-distro-list.test.ts | 2 +- src/main/wsl/wsl-host-distro-list.ts | 9 +- src/main/wsl/wsl-host-first-connect.test.ts | 2 +- src/main/wsl/wsl-host-first-connect.ts | 2 +- src/main/wsl/wsl-host-runtime-call.ts | 2 +- src/main/wsl/wsl-host-service.ts | 2 +- .../wsl/wsl-host-uninstall-server-stop.ts | 2 +- src/main/wsl/wsl-orcad-bridge-activity.ts | 2 +- .../wsl/wsl-orcad-connect-stop-fence.test.ts | 9 +- src/main/wsl/wsl-orcad-connect-stop-fence.ts | 6 +- src/main/wsl/wsl-orcad-connection-errors.ts | 4 +- src/main/wsl/wsl-orcad-connection-types.ts | 2 +- src/main/wsl/wsl-orcad-connection.ts | 2 +- .../wsl/wsl-orcad-deploy-app-update.test.ts | 2 +- src/main/wsl/wsl-orcad-deploy.test.ts | 2 +- src/main/wsl/wsl-orcad-deploy.ts | 9 +- src/main/wsl/wsl-orcad-held-context.test.ts | 2 +- src/main/wsl/wsl-orcad-held-context.ts | 4 +- src/main/wsl/wsl-orcad-host-transport.test.ts | 2 +- src/main/wsl/wsl-orcad-host-transport.ts | 16 +-- src/main/wsl/wsl-orcad-liveness-evidence.ts | 4 +- src/main/wsl/wsl-orcad-liveness-recovery.ts | 4 +- src/main/wsl/wsl-orcad-liveness-state.ts | 2 +- .../wsl/wsl-orcad-liveness-stopping-poll.ts | 2 +- .../wsl/wsl-orcad-liveness-supervisor.test.ts | 2 +- src/main/wsl/wsl-orcad-liveness-supervisor.ts | 2 +- src/main/wsl/wsl-orcad-liveness-wiring.ts | 4 +- src/main/wsl/wsl-orcad-midturn-stop-lane.ts | 2 +- ...rcad-real-distro-idle-release-lane.test.ts | 13 +- .../wsl/wsl-orcad-real-distro-lane.test.ts | 13 +- .../wsl/wsl-orcad-stdio-bridge-e9.test.ts | 4 +- src/main/wsl/wsl-orcad-stdio-bridge.ts | 2 +- .../wsl-orcad-update-move-hold-driver.test.ts | 2 +- .../wsl/wsl-orphan-holder-release.test.ts | 4 +- src/main/wsl/wsl-orphan-holder-release.ts | 9 +- src/main/wsl/wsl-pinned-runtime.ts | 2 +- .../pty-agent-pane-launch.test.ts | 2 +- .../wsl-drive-unc-state-dispositions.ts | 2 +- src/wsl-guest/preflight-handler.test.ts | 10 +- src/wsl-guest/preflight-handler.ts | 3 +- ...lder-project-runtime-contract.unit.test.ts | 11 +- .../pty-spawn-cwd-folder-owner.unit.test.ts | 2 +- .../e2e/terminal-account-restart.unit.test.ts | 2 +- tests/e2e/wsl-drive-unc-conversion.spec.ts | 2 +- 625 files changed, 1729 insertions(+), 1545 deletions(-) rename src/main/{ => ssh/connection}/ssh-expired-lease-pane-readoption.test.ts (87%) rename src/main/{ => ssh/connection}/ssh-reattach-pane-cardinality.test.ts (97%) delete mode 100644 src/main/wsl-env.ts rename src/main/{wsl.test.ts => wsl/discovery/distro-catalog.test.ts} (87%) rename src/main/{wsl.ts => wsl/discovery/distro-catalog.ts} (80%) rename src/main/{ => wsl/discovery}/preflight-wsl-cache.ts (100%) rename src/main/{ => wsl/discovery}/wsl-availability.ts (97%) rename src/main/{ => wsl/discovery}/wsl-background-distro-gate.test.ts (98%) rename src/main/{ => wsl/discovery}/wsl-background-distro-gate.ts (99%) rename src/main/wsl/{ => discovery}/wsl-background-exec-gate.test.ts (98%) rename src/main/wsl/{ => discovery}/wsl-background-exec-gate.ts (98%) rename src/main/{ => wsl/discovery}/wsl-console-running-distros.test.ts (100%) rename src/main/{ => wsl/discovery}/wsl-console-running-distros.ts (96%) rename src/main/wsl/{ => discovery}/wsl-default-distro.ts (97%) rename src/main/wsl/{ => discovery}/wsl-distro-boot-id.ts (80%) rename src/main/wsl/{ => discovery}/wsl-distro-holder-command.ts (97%) rename src/main/wsl/{ => discovery}/wsl-distro-holder-process-classification.ts (93%) rename src/main/wsl/{ => discovery}/wsl-distro-holder-record.ts (97%) rename src/main/wsl/{ => discovery}/wsl-distro-holder-script.test.ts (99%) rename src/main/wsl/{ => discovery}/wsl-distro-holder-types.ts (97%) rename src/main/wsl/{ => discovery}/wsl-distro-holder.test.ts (98%) rename src/main/wsl/{ => discovery}/wsl-distro-holder.ts (94%) rename src/main/{ => wsl/discovery}/wsl-distro-list-output.test.ts (100%) rename src/main/{ => wsl/discovery}/wsl-distro-list-output.ts (100%) rename src/main/{ => wsl/discovery}/wsl-distro-list-single-flight.test.ts (99%) rename src/main/wsl/{ => discovery}/wsl-distro-registry-id.test.ts (100%) rename src/main/wsl/{ => discovery}/wsl-distro-registry-id.ts (100%) rename src/main/{ => wsl/discovery}/wsl-distro-retry.ts (100%) rename src/main/wsl/{ => discovery}/wsl-distro-unsupported.ts (86%) rename src/main/{ => wsl/discovery}/wsl-home-cache.ts (100%) rename src/main/wsl/{ => discovery}/wsl-home-unless-stopped.ts (84%) rename src/main/{ => wsl/discovery}/wsl-last-seen-running-age.test.ts (100%) rename src/main/{ => wsl/discovery}/wsl-lost-list-output.test.ts (99%) rename src/main/{ => wsl/discovery}/wsl-registered-distro-fallback.ts (98%) rename src/main/{ => wsl/discovery}/wsl-running-distro-cache.ts (100%) rename src/main/{ => wsl/discovery}/wsl-running-distro-stop.test.ts (100%) rename src/main/{ => wsl/discovery}/wsl-running-distros.test.ts (97%) rename src/main/{ => wsl/discovery}/wsl-stopped-worktree-rescan-registry.ts (100%) rename src/main/wsl/{ => discovery}/wsl-user-act-scope.test.ts (100%) rename src/main/wsl/{ => discovery}/wsl-user-act-scope.ts (100%) rename src/main/{ => wsl/execution}/wsl-bash-command.ts (73%) rename src/main/wsl/{ => execution}/wsl-command-channel.test.ts (100%) rename src/main/wsl/{ => execution}/wsl-command-channel.ts (97%) rename src/main/wsl/{ => execution}/wsl-command-loop-pool.ts (95%) rename src/main/wsl/{ => execution}/wsl-command-loop.test.ts (98%) rename src/main/wsl/{ => execution}/wsl-command-loop.ts (98%) rename src/main/{ => wsl/execution}/wsl-exe-process.ts (73%) rename src/main/wsl/{ => execution}/wsl-executable-path.ts (100%) rename src/main/wsl/{ => execution}/wsl-executable-path.win32.test.ts (100%) rename src/main/wsl/{ => execution}/wsl-interop-health.test.ts (98%) rename src/main/wsl/{ => execution}/wsl-interop-health.ts (96%) rename src/main/wsl/{ => execution}/wsl-interop-registration.test.ts (100%) rename src/main/wsl/{ => execution}/wsl-interop-registration.ts (100%) rename src/main/{ => wsl/execution}/wsl-interop-spawn-directory.test.ts (100%) rename src/main/{ => wsl/execution}/wsl-interop-spawn-directory.ts (100%) rename src/main/{ => wsl/execution}/wsl-managed-cli-path-restore.test.ts (100%) rename src/main/{ => wsl/execution}/wsl-managed-cli-path-restore.ts (100%) rename src/main/wsl/{ => execution}/wsl-node-runtime-download-budget.ts (86%) rename src/main/wsl/{ => execution}/wsl-node-runtime-prefetch.test.ts (97%) rename src/main/wsl/{ => execution}/wsl-node-runtime-prefetch.ts (91%) rename src/main/wsl/{ => execution}/wsl-process-failure.ts (100%) rename src/main/wsl/{ => execution}/wsl-runner.test.ts (99%) rename src/main/wsl/{ => execution}/wsl-runner.ts (95%) rename src/main/wsl/{ => execution}/wsl-runner.wsl.test.ts (98%) create mode 100644 src/main/wsl/filesystem/unc-path-access.test.ts create mode 100644 src/main/wsl/filesystem/unc-path-access.ts rename src/main/wsl/{ => filesystem}/wsl-automount-root.test.ts (96%) rename src/main/wsl/{ => filesystem}/wsl-automount-root.ts (94%) rename src/main/{ => wsl/filesystem}/wsl-contained-delete.ts (98%) rename src/main/{ => wsl/filesystem}/wsl-directory-probe-command.ts (93%) rename src/main/wsl/{ => filesystem}/wsl-directory-upload.test.ts (98%) rename src/main/wsl/{ => filesystem}/wsl-directory-upload.ts (92%) rename src/main/wsl/{ => filesystem}/wsl-drive-project-new-default.test.ts (97%) rename src/main/wsl/{ => filesystem}/wsl-drive-project-new-default.ts (89%) rename src/main/wsl/{ => filesystem}/wsl-drive-project-windows-git.test.ts (98%) rename src/main/wsl/{ => filesystem}/wsl-drive-project-windows-git.ts (92%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-conversion-journal.ts (95%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-conversion-renderer.test.ts (100%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-conversion-renderer.ts (94%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-conversion-run.test.ts (97%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-conversion-run.ts (92%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-conversion-startup.test.ts (92%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-conversion-startup.ts (91%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-conversion-stores.ts (92%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-discovery-shadows.ts (86%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-identity-rewrite.test.ts (100%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-identity-rewrite.ts (93%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-mounts.ts (80%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-project-scope.test.ts (95%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-project-scope.ts (92%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-state-rewrite.test.ts (95%) rename src/main/wsl/{ => filesystem}/wsl-drive-unc-state-rewrite.ts (89%) rename src/main/{ => wsl/filesystem}/wsl-running-path-filter.test.ts (88%) rename src/main/{ => wsl/filesystem}/wsl-running-path-filter.ts (82%) rename src/main/{ => wsl/filesystem}/wsl-sh-cwd-report.node-pty.test.ts (98%) rename src/main/{ => wsl/filesystem}/wsl-shell-cwd-report.test.ts (90%) rename src/main/{ => wsl/filesystem}/wsl-shell-cwd-report.ts (100%) rename src/main/wsl/{ => filesystem}/wsl-unc-access-denied.ts (91%) rename src/main/wsl/{ => filesystem}/wsl-unc-access-gate-user-act.test.ts (81%) rename src/main/wsl/{ => filesystem}/wsl-unc-access-gate.test.ts (96%) rename src/main/wsl/{ => filesystem}/wsl-unc-access-gate.ts (92%) rename src/main/{ => wsl/filesystem}/wsl-unc-delete.test.ts (96%) rename src/main/{ => wsl/filesystem}/wsl-unc-delete.ts (89%) rename src/main/{ => wsl/filesystem}/wsl-unc-delete.wsl.test.ts (100%) rename src/main/wsl/{ => filesystem}/wsl-unc-drive-file-content.test.ts (90%) rename src/main/wsl/{ => filesystem}/wsl-unc-drive-fs-path.test.ts (100%) rename src/main/wsl/{ => filesystem}/wsl-unc-drive-fs-path.ts (95%) rename src/main/{ => wsl/history}/wsl-fish-history-cleanup.test.ts (100%) rename src/main/{ => wsl/history}/wsl-fish-history-cleanup.ts (92%) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 97d1a5876e2..3a9d0584328 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -865,7 +865,7 @@ jobs: src/renderer/src/components/terminal-pane/fish-color-scheme-child-stdin.node-pty.test.ts \ src/shared/fish-query-reply-child-stdin.node-pty.test.ts \ src/shared/fish-wsl-cwd-report.node-pty.test.ts \ - src/main/wsl-sh-cwd-report.node-pty.test.ts \ + src/main/wsl/filesystem/wsl-sh-cwd-report.node-pty.test.ts \ src/shared/pty-reply-echo-shapes.node-pty.test.ts \ src/shared/startup-shell-portability.live-shell.test.ts \ src/shared/posix-command-path-lookup.test.ts diff --git a/config/flaky-test-pattern-baseline.txt b/config/flaky-test-pattern-baseline.txt index 1829bb1788d..c9cb4c7dbaa 100644 --- a/config/flaky-test-pattern-baseline.txt +++ b/config/flaky-test-pattern-baseline.txt @@ -448,7 +448,7 @@ 1 test-no-real-time-wait:src/main/worker-thread-child-process/worker-thread-child-process.test.ts 1 test-no-real-time-wait:src/main/workspaces/creation/preparation/worktree-create-preparation-cancellation.test.ts 1 test-no-real-time-wait:src/main/workspaces/creation/preparation/worktree-preparation-discard-retry.test.ts -3 test-no-real-time-wait:src/main/wsl/wsl-command-loop.test.ts +3 test-no-real-time-wait:src/main/wsl/execution/wsl-command-loop.test.ts 1 test-no-real-time-wait:src/main/wsl/wsl-orcad-connection.test.ts 2 test-no-real-time-wait:src/main/wsl/wsl-orcad-real-distro-lane.test.ts 1 test-no-real-time-wait:src/main/wsl/wsl-orcad-stdio-bridge.test.ts @@ -1005,7 +1005,7 @@ 2 test-no-wall-clock:src/main/windows/windows-pty-job.win32.test.ts 1 test-no-wall-clock:src/main/workspaces/removal/worktree-removal-close-records.test.ts 3 test-no-wall-clock:src/main/wsl/wsl-orcad-real-distro-lane.test.ts -4 test-no-wall-clock:src/main/wsl/wsl-runner.wsl.test.ts +4 test-no-wall-clock:src/main/wsl/execution/wsl-runner.wsl.test.ts 1 test-no-wall-clock:src/renderer/src/app-shell/visible-review-reporting.test.ts 7 test-no-wall-clock:src/renderer/src/components/worktree-jump/WorktreeJumpPalette.recent-tabs.behavior.test.tsx 8 test-no-wall-clock:src/renderer/src/components/worktree-jump/WorktreeJumpPalette.recent-tabs.test.tsx @@ -1262,7 +1262,7 @@ 1 test-timeout-needs-reason:src/main/windows/windows-msys-job.win32.test.ts 6 test-timeout-needs-reason:src/main/windows/windows-pty-job.win32.test.ts 8 test-timeout-needs-reason:src/main/worker-thread-child-process/worker-thread-child-process.test.ts -6 test-timeout-needs-reason:src/main/wsl/wsl-runner.wsl.test.ts +6 test-timeout-needs-reason:src/main/wsl/execution/wsl-runner.wsl.test.ts 4 test-timeout-needs-reason:src/packages/process-host/src/run-process.test.ts 5 test-timeout-needs-reason:src/renderer/src/components/sidebar/WorktreeCard.compact-hover.test.tsx 2 test-timeout-needs-reason:src/renderer/src/components/sidebar/WorktreeCard.host-badge-toggle.test.tsx diff --git a/config/main-sync-spawn-baseline.txt b/config/main-sync-spawn-baseline.txt index ec46de14863..efcac62eab0 100644 --- a/config/main-sync-spawn-baseline.txt +++ b/config/main-sync-spawn-baseline.txt @@ -42,7 +42,7 @@ 2 src/main/startup/cli-launch-redirect.ts 1 src/main/startup/linux-secret-service-probe.ts 1 src/main/workspace-hooks/worktree-runner-script.ts -3 src/main/wsl.ts +3 src/main/wsl/discovery/distro-catalog.ts 2 src/main/pty/shell-startup/zsh-startup-hook-pty-harness.ts 1 src/shared/fish-binary-requirement.ts 1 src/shared/openssh-default-shell.ts diff --git a/config/scripts/check-main-sync-spawn-ratchet.mjs b/config/scripts/check-main-sync-spawn-ratchet.mjs index 6a392c2a91c..2582b217cf1 100644 --- a/config/scripts/check-main-sync-spawn-ratchet.mjs +++ b/config/scripts/check-main-sync-spawn-ratchet.mjs @@ -37,15 +37,20 @@ const GATED_FAMILIES = [ advice: { gitExecFileSync: 'use gitExecFileAsync' } }, { - modules: ['src/main/wsl'], + modules: ['src/main/wsl/discovery/distro-catalog'], advice: { getWslHome: 'use getWslHomeAsync', - listWslDistros: 'use listWslDistrosAsync', + listWslDistros: 'use listWslDistrosAsync' + } + }, + { + modules: ['src/main/wsl/filesystem/unc-path-access'], + advice: { wslUncDirectoryExists: 'use wslUncDirectoryExistsAsync' } }, { - modules: ['src/main/wsl-availability', 'src/main/wsl'], + modules: ['src/main/wsl/discovery/wsl-availability'], advice: { isWslAvailable: 'use isWslAvailableAsync' } }, { diff --git a/config/scripts/check-main-sync-spawn-ratchet.test.mjs b/config/scripts/check-main-sync-spawn-ratchet.test.mjs index 43e4136472e..2ac17003d37 100644 --- a/config/scripts/check-main-sync-spawn-ratchet.test.mjs +++ b/config/scripts/check-main-sync-spawn-ratchet.test.mjs @@ -47,10 +47,14 @@ describe('main sync-spawn ratchet', () => { ).toEqual({ count: 1, symbols: ['execSync'] }) }) - it('retains exports whose module name is inherited from the containing directory', () => { - expect(uses("export * from '.'", 'src/main/wsl/consumer.ts')).toEqual({ - count: 4, - symbols: ['getWslHome', 'isWslAvailable', 'listWslDistros', 'wslUncDirectoryExists'] + it.each([ + ['discovery/distro-catalog', ['getWslHome', 'listWslDistros']], + ['discovery/wsl-availability', ['isWslAvailable']], + ['filesystem/unc-path-access', ['wslUncDirectoryExists']] + ])('retains exports inherited from the containing directory: %s', (owner, symbols) => { + expect(uses("export * from '.'", `src/main/wsl/${owner}/consumer.ts`)).toEqual({ + count: symbols.length, + symbols }) }) @@ -86,7 +90,7 @@ describe('main sync-spawn ratchet', () => { ['runProcessSync'] ], [ - "import { getWslHome, listWslDistros } from './wsl.ts'\nconst read = sync ? getWslHome : listWslDistros\nread()", + "import { getWslHome, listWslDistros } from './wsl/discovery/distro-catalog.ts'\nconst read = sync ? getWslHome : listWslDistros\nread()", 3, ['getWslHome', 'listWslDistros'] ], @@ -155,14 +159,26 @@ describe('main sync-spawn ratchet', () => { "import { grantDirAcl } from './windows/windows-directory-acl'\ngrantDirAcl(dir)", 'grantDirAcl' ], - ["import { getWslHome } from './wsl'\ngetWslHome(distro)", 'getWslHome'], - ["import { listWslDistros } from './wsl'\nlistWslDistros()", 'listWslDistros'], [ - "import { wslUncDirectoryExists } from './wsl'\nwslUncDirectoryExists(p)", + "import { getWslHome } from './wsl/discovery/distro-catalog'\ngetWslHome(distro)", + 'getWslHome' + ], + [ + "import { listWslDistros } from './wsl/discovery/distro-catalog'\nlistWslDistros()", + 'listWslDistros' + ], + [ + "import { wslUncDirectoryExists } from './wsl/filesystem/unc-path-access'\nwslUncDirectoryExists(p)", 'wslUncDirectoryExists' ], - ["import { isWslAvailable } from './wsl'\nisWslAvailable()", 'isWslAvailable'], - ["import { isWslAvailable } from './wsl-availability'\nisWslAvailable()", 'isWslAvailable'], + [ + "import { isWslAvailable } from './wsl/discovery/wsl-availability'\nisWslAvailable()", + 'isWslAvailable' + ], + [ + "import { isWslAvailable } from './wsl/discovery/wsl-availability'\nisWslAvailable()", + 'isWslAvailable' + ], [ "import { isPwshAvailable } from './pty/shell-startup/pwsh'\nisPwshAvailable()", 'isPwshAvailable' @@ -181,7 +197,7 @@ describe('main sync-spawn ratchet', () => { expect( uses( 'export function listWslDistros() { return [] }\nexport function first() { return listWslDistros()[0] }', - 'src/main/wsl.ts' + 'src/main/wsl/discovery/distro-catalog.ts' ) ).toEqual({ count: 1, symbols: ['listWslDistros'] }) }) @@ -199,7 +215,9 @@ describe('main sync-spawn ratchet', () => { }) it('resolves backslash paths in both the importing file and the specifier', () => { - expect([...(gatedSymbolsFor('src\\main\\foo\\x.ts', '..\\wsl') ?? [])]).toContain('getWslHome') + expect([ + ...(gatedSymbolsFor('src\\main\\foo\\x.ts', '..\\wsl\\discovery\\distro-catalog') ?? []) + ]).toContain('getWslHome') }) it.each(['import {', 'const broken = ;'])( diff --git a/config/scripts/ci-shard-timings.json b/config/scripts/ci-shard-timings.json index 386d0f4cc57..6c2dc040dcd 100644 --- a/config/scripts/ci-shard-timings.json +++ b/config/scripts/ci-shard-timings.json @@ -6607,8 +6607,8 @@ "src/main/sqlite/sync-database-concurrent-backup.test.ts": 1141, "src/main/sqlite/sync-database-portability.test.ts": 147, "src/main/sqlite/sync-database.test.ts": 860, - "src/main/ssh-expired-lease-pane-readoption.test.ts": 2799, - "src/main/ssh-reattach-pane-cardinality.test.ts": 1778, + "src/main/ssh/connection/ssh-expired-lease-pane-readoption.test.ts": 2799, + "src/main/ssh/connection/ssh-reattach-pane-cardinality.test.ts": 1778, "src/main/ssh/config/ssh-config-alias-claim.test.ts": 58, "src/main/ssh/config/ssh-config-host-picker.test.ts": 221, "src/main/ssh/config/ssh-config-loader-regression.test.ts": 102, @@ -7126,41 +7126,41 @@ "src/main/workspaces/creation/worktree-root-preparation.test.ts": 180, "src/main/workspaces/removal/worktree-trash.test.ts": 126, "src/main/wsl-approved-root-race.wsl.test.ts": 102, - "src/main/wsl-background-distro-gate.test.ts": 674, - "src/main/wsl-console-running-distros.test.ts": 57, - "src/main/wsl-distro-list-output.test.ts": 43, - "src/main/wsl-distro-list-single-flight.test.ts": 88, - "src/main/wsl-fish-history-cleanup.test.ts": 158, - "src/main/wsl-interop-spawn-directory.test.ts": 52, - "src/main/wsl-last-seen-running-age.test.ts": 84, - "src/main/wsl-lost-list-output.test.ts": 135, - "src/main/wsl-managed-cli-path-restore.test.ts": 68, + "src/main/wsl/discovery/wsl-background-distro-gate.test.ts": 674, + "src/main/wsl/discovery/wsl-console-running-distros.test.ts": 57, + "src/main/wsl/discovery/wsl-distro-list-output.test.ts": 43, + "src/main/wsl/discovery/wsl-distro-list-single-flight.test.ts": 88, + "src/main/wsl/history/wsl-fish-history-cleanup.test.ts": 158, + "src/main/wsl/execution/wsl-interop-spawn-directory.test.ts": 52, + "src/main/wsl/discovery/wsl-last-seen-running-age.test.ts": 84, + "src/main/wsl/discovery/wsl-lost-list-output.test.ts": 135, + "src/main/wsl/execution/wsl-managed-cli-path-restore.test.ts": 68, "src/main/wsl-move-incidental-writes.test.ts": 1170, "src/main/wsl-move-scan-pruning.test.ts": 1824, - "src/main/wsl-running-distro-stop.test.ts": 42, - "src/main/wsl-running-distros.test.ts": 201, - "src/main/wsl-running-path-filter.test.ts": 57, - "src/main/wsl-shell-cwd-report.test.ts": 111, - "src/main/wsl-unc-delete.test.ts": 102, - "src/main/wsl-unc-delete.wsl.test.ts": 93, - "src/main/wsl.test.ts": 148, - "src/main/wsl/wsl-automount-root.test.ts": 108, - "src/main/wsl/wsl-background-exec-gate.test.ts": 69, - "src/main/wsl/wsl-command-channel.test.ts": 57, - "src/main/wsl/wsl-command-loop.test.ts": 6057, - "src/main/wsl/wsl-directory-upload.test.ts": 409, - "src/main/wsl/wsl-distro-holder-script.test.ts": 28870, - "src/main/wsl/wsl-distro-holder.test.ts": 328, - "src/main/wsl/wsl-distro-registry-id.test.ts": 77, - "src/main/wsl/wsl-drive-project-new-default.test.ts": 212, - "src/main/wsl/wsl-drive-project-windows-git.test.ts": 249, - "src/main/wsl/wsl-drive-unc-conversion-renderer.test.ts": 123, - "src/main/wsl/wsl-drive-unc-conversion-run.test.ts": 621, - "src/main/wsl/wsl-drive-unc-conversion-startup.test.ts": 1265, - "src/main/wsl/wsl-drive-unc-identity-rewrite.test.ts": 123, - "src/main/wsl/wsl-drive-unc-project-scope.test.ts": 123, - "src/main/wsl/wsl-drive-unc-state-rewrite.test.ts": 299, - "src/main/wsl/wsl-executable-path.win32.test.ts": 38, + "src/main/wsl/discovery/wsl-running-distro-stop.test.ts": 42, + "src/main/wsl/discovery/wsl-running-distros.test.ts": 201, + "src/main/wsl/filesystem/wsl-running-path-filter.test.ts": 57, + "src/main/wsl/filesystem/wsl-shell-cwd-report.test.ts": 111, + "src/main/wsl/filesystem/wsl-unc-delete.test.ts": 102, + "src/main/wsl/filesystem/wsl-unc-delete.wsl.test.ts": 93, + "src/main/wsl/discovery/distro-catalog.test.ts": 148, + "src/main/wsl/filesystem/wsl-automount-root.test.ts": 108, + "src/main/wsl/discovery/wsl-background-exec-gate.test.ts": 69, + "src/main/wsl/execution/wsl-command-channel.test.ts": 57, + "src/main/wsl/execution/wsl-command-loop.test.ts": 6057, + "src/main/wsl/filesystem/wsl-directory-upload.test.ts": 409, + "src/main/wsl/discovery/wsl-distro-holder-script.test.ts": 28870, + "src/main/wsl/discovery/wsl-distro-holder.test.ts": 328, + "src/main/wsl/discovery/wsl-distro-registry-id.test.ts": 77, + "src/main/wsl/filesystem/wsl-drive-project-new-default.test.ts": 212, + "src/main/wsl/filesystem/wsl-drive-project-windows-git.test.ts": 249, + "src/main/wsl/filesystem/wsl-drive-unc-conversion-renderer.test.ts": 123, + "src/main/wsl/filesystem/wsl-drive-unc-conversion-run.test.ts": 621, + "src/main/wsl/filesystem/wsl-drive-unc-conversion-startup.test.ts": 1265, + "src/main/wsl/filesystem/wsl-drive-unc-identity-rewrite.test.ts": 123, + "src/main/wsl/filesystem/wsl-drive-unc-project-scope.test.ts": 123, + "src/main/wsl/filesystem/wsl-drive-unc-state-rewrite.test.ts": 299, + "src/main/wsl/execution/wsl-executable-path.win32.test.ts": 38, "src/main/wsl/wsl-guest-environment.test.ts": 120, "src/main/wsl/wsl-guest-pane-process-script-cost.test.ts": 213, "src/main/wsl/wsl-guest-pane-processes.test.ts": 48, @@ -7184,9 +7184,9 @@ "src/main/wsl/wsl-host-service.test.ts": 1436, "src/main/wsl/wsl-host-uninstall-server-stop.test.ts": 751, "src/main/wsl/wsl-hosts-policy-live-update.test.ts": 239, - "src/main/wsl/wsl-interop-health.test.ts": 234, - "src/main/wsl/wsl-interop-registration.test.ts": 52, - "src/main/wsl/wsl-node-runtime-prefetch.test.ts": 102, + "src/main/wsl/execution/wsl-interop-health.test.ts": 234, + "src/main/wsl/execution/wsl-interop-registration.test.ts": 52, + "src/main/wsl/execution/wsl-node-runtime-prefetch.test.ts": 102, "src/main/wsl/wsl-orcad-account-env.test.ts": 117, "src/main/wsl/wsl-orcad-active-probe.test.ts": 347, "src/main/wsl/wsl-orcad-bridge-activity.test.ts": 668, @@ -7217,13 +7217,13 @@ "src/main/wsl/wsl-orcad-watch.test.ts": 447, "src/main/wsl/wsl-orphan-holder-release.test.ts": 265, "src/main/wsl/wsl-pinned-runtime.test.ts": 263, - "src/main/wsl/wsl-runner.test.ts": 98, - "src/main/wsl/wsl-runner.wsl.test.ts": 75, - "src/main/wsl/wsl-unc-access-gate-user-act.test.ts": 81, - "src/main/wsl/wsl-unc-access-gate.test.ts": 1677, - "src/main/wsl/wsl-unc-drive-file-content.test.ts": 80, - "src/main/wsl/wsl-unc-drive-fs-path.test.ts": 51, - "src/main/wsl/wsl-user-act-scope.test.ts": 50, + "src/main/wsl/execution/wsl-runner.test.ts": 98, + "src/main/wsl/execution/wsl-runner.wsl.test.ts": 75, + "src/main/wsl/filesystem/wsl-unc-access-gate-user-act.test.ts": 81, + "src/main/wsl/filesystem/wsl-unc-access-gate.test.ts": 1677, + "src/main/wsl/filesystem/wsl-unc-drive-file-content.test.ts": 80, + "src/main/wsl/filesystem/wsl-unc-drive-fs-path.test.ts": 51, + "src/main/wsl/discovery/wsl-user-act-scope.test.ts": 50, "src/main/zcode/hook-service.test.ts": 186, "src/main/zcode/zcode-plan-api-key-store-native-windows.test.ts": 47, "src/main/zcode/zcode-plan-api-key-store-plaintext-rollback.test.ts": 180, diff --git a/config/scripts/ci-unit-files.mjs b/config/scripts/ci-unit-files.mjs index 1fd7e6c28b2..39ecc7b8932 100644 --- a/config/scripts/ci-unit-files.mjs +++ b/config/scripts/ci-unit-files.mjs @@ -40,7 +40,7 @@ export const UNIT_EXCLUDE = [ 'src/renderer/src/components/terminal-pane/fish-color-scheme-child-stdin.node-pty.test.ts', 'src/shared/fish-query-reply-child-stdin.node-pty.test.ts', 'src/shared/fish-wsl-cwd-report.node-pty.test.ts', - 'src/main/wsl-sh-cwd-report.node-pty.test.ts', + 'src/main/wsl/filesystem/wsl-sh-cwd-report.node-pty.test.ts', 'src/shared/pty-reply-echo-shapes.node-pty.test.ts', 'src/shared/startup-shell-portability.live-shell.test.ts', 'src/shared/posix-command-path-lookup.test.ts', diff --git a/config/scripts/pr-package-test-paths.mjs b/config/scripts/pr-package-test-paths.mjs index 6589df74a01..743d50e9631 100644 --- a/config/scripts/pr-package-test-paths.mjs +++ b/config/scripts/pr-package-test-paths.mjs @@ -84,9 +84,9 @@ export const WINDOWS_BOUNDARY_TESTS = [ 'src/main/daemon/node-pty-windows-output-error.win32.test.ts', 'src/main/persistence/profile-state/profile-state-access-windows-native.win32.test.ts', 'src/main/pty/process-retirement/windows-live-tree-kill.win32.test.ts', - 'src/main/wsl/wsl-runner.test.ts', + 'src/main/wsl/execution/wsl-runner.test.ts', 'src/main/wsl/wsl-guest-environment.test.ts', - 'src/main/wsl/wsl-executable-path.win32.test.ts', + 'src/main/wsl/execution/wsl-executable-path.win32.test.ts', 'src/main/claude-accounts/claude-profile-history-windows.test.ts', 'src/shared/source-scan/source-tree-scan.test.ts', 'src/main/cli/wsl-cli-powershell-boundary.test.ts', diff --git a/config/scripts/pr-shell-contract-prefixes.mjs b/config/scripts/pr-shell-contract-prefixes.mjs index ba603497cb6..eecf573d6e7 100644 --- a/config/scripts/pr-shell-contract-prefixes.mjs +++ b/config/scripts/pr-shell-contract-prefixes.mjs @@ -15,8 +15,8 @@ export const SHELL_PREFIXES = [ 'src/shared/pty-reply-echo-shapes', 'src/shared/startup-shell-portability', 'src/shared/posix-command-path-lookup', - 'src/main/wsl-shell-cwd-report', - 'src/main/wsl-sh-cwd-report', + 'src/main/wsl/filesystem/wsl-shell-cwd-report', + 'src/main/wsl/filesystem/wsl-sh-cwd-report', 'src/shared/wsl-login-shell-command', 'config/patches/node-pty@', 'config/scripts/ensure-native-runtime', diff --git a/config/scripts/win32-test-lane-registration.test.mjs b/config/scripts/win32-test-lane-registration.test.mjs index 31686f70f19..fb5adae1dcd 100644 --- a/config/scripts/win32-test-lane-registration.test.mjs +++ b/config/scripts/win32-test-lane-registration.test.mjs @@ -53,9 +53,9 @@ const MANUAL_OPT_IN = [ // `runRealWsl = … && ORCA_REAL_WSL_DELETE_TEST === '1'`; real distro traversal race. 'src/main/wsl-approved-root-race.wsl.test.ts', // Same flag; real UNC delete against a distro. - 'src/main/wsl-unc-delete.wsl.test.ts', + 'src/main/wsl/filesystem/wsl-unc-delete.wsl.test.ts', // `enabled = platform === 'win32' && ORCA_REAL_WSL_RUNNER_TEST === '1'`; mutates a real distro's ~/.profile. - 'src/main/wsl/wsl-runner.wsl.test.ts' + 'src/main/wsl/execution/wsl-runner.wsl.test.ts' ] const TEST_FILE_PATTERN = /\.(?:test|spec)\.(?:ts|tsx|mjs|cjs|js)$/ diff --git a/config/scripts/wsl-e2e-lane-contract.test.mjs b/config/scripts/wsl-e2e-lane-contract.test.mjs index 626ff53810f..e30f7a8cc11 100644 --- a/config/scripts/wsl-e2e-lane-contract.test.mjs +++ b/config/scripts/wsl-e2e-lane-contract.test.mjs @@ -9,8 +9,8 @@ describe('real WSL terminal lane', () => { it.each([ 'config/scripts/verify-wsl-e2e-participation.mjs', 'config/scripts/verify-playwright-participation.mjs', - 'src/main/wsl-availability.ts', - 'src/main/wsl/wsl-runner.ts', + 'src/main/wsl/discovery/wsl-availability.ts', + 'src/main/wsl/execution/wsl-runner.ts', 'src/main/pty/shell-startup/wsl-orca-env.ts', 'src/shared/wsl-login-shell-command.ts', 'src/shared/shell-argument-quoting.ts', diff --git a/config/tsconfig.tc.web.json b/config/tsconfig.tc.web.json index 4c6322b225b..af88ce9bef6 100644 --- a/config/tsconfig.tc.web.json +++ b/config/tsconfig.tc.web.json @@ -64,18 +64,19 @@ "../src/main/ipc/worktree-display-name.ts", "../src/main/ipc/worktree-linked-work-item-metadata.ts", "../src/main/ipc/worktree-metadata-merge.ts", - "../src/main/wsl-availability.ts", - "../src/main/wsl-directory-probe-command.ts", - "../src/main/wsl-distro-list-output.ts", - "../src/main/wsl-distro-retry.ts", - "../src/main/wsl-running-distro-cache.ts", - "../src/main/wsl-home-cache.ts", - "../src/main/wsl.ts", - "../src/main/wsl-interop-spawn-directory.ts", - "../src/main/wsl-exe-process.ts", - "../src/main/wsl-console-running-distros.ts", - "../src/main/wsl-registered-distro-fallback.ts", - "../src/main/wsl/wsl-distro-registry-id.ts", + "../src/main/wsl/discovery/wsl-availability.ts", + "../src/main/wsl/filesystem/wsl-directory-probe-command.ts", + "../src/main/wsl/discovery/wsl-distro-list-output.ts", + "../src/main/wsl/discovery/wsl-distro-retry.ts", + "../src/main/wsl/discovery/wsl-running-distro-cache.ts", + "../src/main/wsl/discovery/wsl-home-cache.ts", + "../src/main/wsl/discovery/distro-catalog.ts", + "../src/main/wsl/filesystem/unc-path-access.ts", + "../src/main/wsl/execution/wsl-interop-spawn-directory.ts", + "../src/main/wsl/execution/wsl-exe-process.ts", + "../src/main/wsl/discovery/wsl-console-running-distros.ts", + "../src/main/wsl/discovery/wsl-registered-distro-fallback.ts", + "../src/main/wsl/discovery/wsl-distro-registry-id.ts", "../src/main/persistence/applying-settings/ui-state-read.ts", "../src/main/persistence/tracking-repos/worktree-identity-migration.ts", "../src/main/persistence/tracking-repos/worktree-identity-row-repoint.ts", diff --git a/src/main/agent-hooks/wsl-agent-plugin-readiness.ts b/src/main/agent-hooks/wsl-agent-plugin-readiness.ts index 6051e9d391b..c0c95fae4e8 100644 --- a/src/main/agent-hooks/wsl-agent-plugin-readiness.ts +++ b/src/main/agent-hooks/wsl-agent-plugin-readiness.ts @@ -11,7 +11,7 @@ import { } from '../../shared/pi-agent-kind' import type { TuiAgent } from '../../shared/tui-agent' import { wslHookRelayManager, type WslHookRelayManager } from './wsl-hook-relay-manager' -import { blockedWslDistroForExec } from '../wsl/wsl-background-exec-gate' +import { blockedWslDistroForExec } from '../wsl/discovery/wsl-background-exec-gate' export async function awaitExplicitAgentPluginGuestReadiness(args: { isWsl: boolean diff --git a/src/main/agent-hooks/wsl-hook-relay-deps.ts b/src/main/agent-hooks/wsl-hook-relay-deps.ts index 264b00cfb44..a9f6341ec7b 100644 --- a/src/main/agent-hooks/wsl-hook-relay-deps.ts +++ b/src/main/agent-hooks/wsl-hook-relay-deps.ts @@ -25,15 +25,18 @@ import { spawnWslRelayProcess } from './wsl-hook-relay-launch' import { waitForWslRelaySentinel } from './wsl-hook-relay-sentinel' -import { resolveWslDefaultDistro as resolveSharedWslDefaultDistro } from '../wsl/wsl-default-distro' -import { deferUntilWslDistroRunning, isWslDistroRunning } from '../wsl-background-distro-gate' +import { resolveWslDefaultDistro as resolveSharedWslDefaultDistro } from '../wsl/discovery/wsl-default-distro' +import { + deferUntilWslDistroRunning, + isWslDistroRunning +} from '../wsl/discovery/wsl-background-distro-gate' import { isWslAgentHookRelayEnabled } from '../../shared/agent-hook-relay' import { wslBridgePtyPresence, type WslBridgePtyPresence } from './wsl-bridge-pty-presence' import { readDaemonBridgeSessions, type DaemonBridgeSessionVerdict } from './wsl-bridge-daemon-sessions' -import { blockedWslDistroForExec } from '../wsl/wsl-background-exec-gate' +import { blockedWslDistroForExec } from '../wsl/discovery/wsl-background-exec-gate' // Concurrent wsl.exe spawns can trigger transient E_UNEXPECTED failures. export const WSL_RELAY_TRANSIENT_RETRY_DELAY_MS = 2_000 diff --git a/src/main/agent-hooks/wsl-hook-relay-launch.test.ts b/src/main/agent-hooks/wsl-hook-relay-launch.test.ts index 17e33d01c9e..b78a9ab61d5 100644 --- a/src/main/agent-hooks/wsl-hook-relay-launch.test.ts +++ b/src/main/agent-hooks/wsl-hook-relay-launch.test.ts @@ -4,7 +4,7 @@ import type * as ProcessHost from '@orca/process-host' import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' -import { resetWslInteropSpawnDirectoryCache } from '../wsl-interop-spawn-directory' +import { resetWslInteropSpawnDirectoryCache } from '../wsl/execution/wsl-interop-spawn-directory' const { spawnProcessMock } = vi.hoisted(() => ({ spawnProcessMock: vi.fn((..._args: unknown[]) => ({ pid: 1 })) @@ -14,7 +14,7 @@ vi.mock('@orca/process-host', async (importOriginal) => ({ ...(await importOriginal()), spawnProcess: spawnProcessMock })) -vi.mock('../wsl/wsl-executable-path', () => ({ +vi.mock('../wsl/execution/wsl-executable-path', () => ({ resolveWslExecutablePath: () => 'C:\\Windows\\System32\\wsl.exe' })) diff --git a/src/main/agent-hooks/wsl-hook-relay-launch.ts b/src/main/agent-hooks/wsl-hook-relay-launch.ts index 70df6b33055..e69cae0e486 100644 --- a/src/main/agent-hooks/wsl-hook-relay-launch.ts +++ b/src/main/agent-hooks/wsl-hook-relay-launch.ts @@ -13,10 +13,10 @@ import { type WslRelayStartupFailure } from './wsl-hook-relay-sentinel' import { addOrcaWslInteropEnv } from '../pty/shell-startup/wsl-orca-env' -import { runWslProcess } from '../wsl/wsl-runner' -import { resolveWslExecutablePath } from '../wsl/wsl-executable-path' +import { runWslProcess } from '../wsl/execution/wsl-runner' +import { resolveWslExecutablePath } from '../wsl/execution/wsl-executable-path' import { buildWslExecArgs } from '../../shared/wsl-login-shell-command' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' +import { resolveWslInteropSpawnCwd } from '../wsl/execution/wsl-interop-spawn-directory' import { WSL_HOOK_RELAY_BUNDLE_NAME, WSL_HOOK_RELAY_DIR, diff --git a/src/main/agent-hooks/wsl-hook-relay-recovery.test.ts b/src/main/agent-hooks/wsl-hook-relay-recovery.test.ts index 125f523c508..f9976140279 100644 --- a/src/main/agent-hooks/wsl-hook-relay-recovery.test.ts +++ b/src/main/agent-hooks/wsl-hook-relay-recovery.test.ts @@ -1,3 +1,4 @@ +import type * as WslBackgroundDistroGate from '../wsl/discovery/wsl-background-distro-gate' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { WslRelayRecovery, type WslRelayRecoveryState } from './wsl-hook-relay-recovery' @@ -12,8 +13,11 @@ import { const { noteWslDistroMayHaveStoppedMock } = vi.hoisted(() => ({ noteWslDistroMayHaveStoppedMock: vi.fn() })) -vi.mock('../wsl/wsl-unc-access-gate', () => ({ - noteWslDistroMayHaveStopped: noteWslDistroMayHaveStoppedMock +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ + ...(await importOriginal()), + ...(await (() => ({ + noteWslDistroMayHaveStopped: noteWslDistroMayHaveStoppedMock + }))()) })) beforeEach(() => vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] })) diff --git a/src/main/agent-hooks/wsl-hook-relay-state-machine.ts b/src/main/agent-hooks/wsl-hook-relay-state-machine.ts index 971be46a1d2..069a73ca434 100644 --- a/src/main/agent-hooks/wsl-hook-relay-state-machine.ts +++ b/src/main/agent-hooks/wsl-hook-relay-state-machine.ts @@ -3,7 +3,7 @@ import type { WslHookRelayManagerDeps } from './wsl-hook-relay-deps' import type { WslRelayDistroState, WslRelayRestartSetup } from './wsl-hook-relay-state' import { wslHookRelayStateKey } from './wsl-hook-relay-state-key' import { FAILURE_COOLDOWN_MAX_MS } from './wsl-hook-relay-deps' -import { noteWslDistroMayHaveStopped } from '../wsl/wsl-unc-access-gate' +import { noteWslDistroMayHaveStopped } from '../wsl/discovery/wsl-background-distro-gate' type RelayFailureState = { distro: string diff --git a/src/main/agent-launch/trust/agent-workspace-trust.test.ts b/src/main/agent-launch/trust/agent-workspace-trust.test.ts index 3a9ff7d5840..85f4fe67fa7 100644 --- a/src/main/agent-launch/trust/agent-workspace-trust.test.ts +++ b/src/main/agent-launch/trust/agent-workspace-trust.test.ts @@ -43,7 +43,7 @@ vi.mock('../../claude/claude-folder-trust-file', async (importOriginal) => { }) import { applyAgentWorkspaceTrust, type AgentTrustLaunchContext } from './agent-workspace-trust' -import { clearWslHomeCache, rememberWslHome } from '../../wsl-home-cache' +import { clearWslHomeCache, rememberWslHome } from '../../wsl/discovery/wsl-home-cache' import { AGENT_TRUST_WRITE_DEADLINE_MS, SHORT_AGENT_TRUST_WRITE_DEADLINE_MS diff --git a/src/main/agent-launch/trust/agent-workspace-trust.ts b/src/main/agent-launch/trust/agent-workspace-trust.ts index 74ddcd1c68b..1593ea86b46 100644 --- a/src/main/agent-launch/trust/agent-workspace-trust.ts +++ b/src/main/agent-launch/trust/agent-workspace-trust.ts @@ -10,7 +10,7 @@ import type { AgentWorkspaceTrustSpawnRequest } from '../../../shared/agent-work import { parseWslUncPath } from '../../../shared/wsl-paths' import { applyWorkspaceTrustOnThisHost, launchedAgentHome } from './execution-host-workspace-trust' import { getLocalCodexTrustConfigFiles } from '../../codex/codex-home-paths' -import { getCachedWslHome } from '../../wsl-home-cache' +import { getCachedWslHome } from '../../wsl/discovery/wsl-home-cache' export type AgentTrustLaunchContext = { /** The final spawn env, before the host's own process env. */ diff --git a/src/main/ai-vault/cached-session-list-wsl-probe.test.ts b/src/main/ai-vault/cached-session-list-wsl-probe.test.ts index e06f1e2cbda..daa81bf0f6b 100644 --- a/src/main/ai-vault/cached-session-list-wsl-probe.test.ts +++ b/src/main/ai-vault/cached-session-list-wsl-probe.test.ts @@ -19,8 +19,12 @@ vi.mock('./opencode-wsl-runtime-preparation', () => ({ prepareOpenCodeWslReaders: vi.fn(async () => []) })) -import { _resetWslCachesForTests, _setWslCachesForTests, listWslDistrosAsync } from '../wsl' -import { filterPathsToRunningWslDistrosAsync } from '../wsl-running-path-filter' +import { + _resetWslCachesForTests, + _setWslCachesForTests, + listWslDistrosAsync +} from '../wsl/discovery/distro-catalog' +import { filterPathsToRunningWslDistrosAsync } from '../wsl/filesystem/wsl-running-path-filter' import { configureAiVaultSessionSources, getAiVaultWslHomeDirs, diff --git a/src/main/ai-vault/cached-session-list.test.ts b/src/main/ai-vault/cached-session-list.test.ts index d0b9464c13b..03a1e2724d3 100644 --- a/src/main/ai-vault/cached-session-list.test.ts +++ b/src/main/ai-vault/cached-session-list.test.ts @@ -32,15 +32,17 @@ vi.mock('./session-scanner-service-spawn', async (importOriginal) => ({ ...(await importOriginal()), scanAiVaultSessionsInService })) -vi.mock('../wsl', () => ({ +vi.mock('../wsl/discovery/distro-catalog', () => ({ getCachedWslDistros, hasCachedWslDistros })) -vi.mock('../wsl/wsl-home-unless-stopped', () => ({ +vi.mock('../wsl/discovery/wsl-home-unless-stopped', () => ({ readRunningWslHomeDirsUnlessStopped, listLastKnownRunningWslHomeDirs })) -vi.mock('../wsl-running-path-filter', () => ({ filterPathsToRunningWslDistrosAsync })) +vi.mock('../wsl/filesystem/wsl-running-path-filter', () => ({ + filterPathsToRunningWslDistrosAsync +})) import { getAiVaultWslHomeDirs, diff --git a/src/main/ai-vault/cached-session-list.ts b/src/main/ai-vault/cached-session-list.ts index fad78f249ab..e354e05b5dc 100644 --- a/src/main/ai-vault/cached-session-list.ts +++ b/src/main/ai-vault/cached-session-list.ts @@ -6,16 +6,16 @@ import { resetAiVaultScannerBackgroundForTests, scanAiVaultSessionsInBackground } from './session-scanner-background' -import { getCachedWslDistros, hasCachedWslDistros } from '../wsl' +import { getCachedWslDistros, hasCachedWslDistros } from '../wsl/discovery/distro-catalog' import { listLastKnownRunningWslHomeDirs, readRunningWslHomeDirsUnlessStopped -} from '../wsl/wsl-home-unless-stopped' +} from '../wsl/discovery/wsl-home-unless-stopped' import { carryOverUnconfirmedWslSessions, resetAiVaultWslSessionCarryover } from './ai-vault-wsl-session-carryover' -import { filterPathsToRunningWslDistrosAsync } from '../wsl-running-path-filter' +import { filterPathsToRunningWslDistrosAsync } from '../wsl/filesystem/wsl-running-path-filter' import { isAiVaultScanCancelledError, type AiVaultListArgs, diff --git a/src/main/ai-vault/opencode-wsl-runtime-preparation.test.ts b/src/main/ai-vault/opencode-wsl-runtime-preparation.test.ts index 2bd490fe023..dcac1c6e4e5 100644 --- a/src/main/ai-vault/opencode-wsl-runtime-preparation.test.ts +++ b/src/main/ai-vault/opencode-wsl-runtime-preparation.test.ts @@ -22,7 +22,7 @@ vi.mock('../../shared/app-environment', () => ({ getPath: () => 'C:/profile' }) })) -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess: mocks.run })) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: mocks.run })) // The admission gate asks the running list for the path's distro; `running` stands in for it. vi.mock('../native-chat/wsl-transcript-running-admission', () => ({ admitWslTranscriptPath: async (path: string) => { diff --git a/src/main/ai-vault/opencode-wsl-runtime-preparation.ts b/src/main/ai-vault/opencode-wsl-runtime-preparation.ts index fbab66dc32c..97953cf7e39 100644 --- a/src/main/ai-vault/opencode-wsl-runtime-preparation.ts +++ b/src/main/ai-vault/opencode-wsl-runtime-preparation.ts @@ -18,8 +18,8 @@ import { } from '../managed-server/install/orcad-remote-node-runtime' import { REMOTE_NODE_RUNTIME_READY } from '../ssh/orcad-remote-node-runtime-report' import { getRemoteHostPlatform } from '../ssh/ssh-remote-platform' -import { runWslProcess, type WslSpec } from '../wsl/wsl-runner' -import { describeWslProcessFailure } from '../wsl/wsl-process-failure' +import { runWslProcess, type WslSpec } from '../wsl/execution/wsl-runner' +import { describeWslProcessFailure } from '../wsl/execution/wsl-process-failure' import { admitWslTranscriptPath } from '../native-chat/wsl-transcript-running-admission' import { AI_VAULT_SCAN_ISSUE_COPY } from '../../shared/ai-vault-scan-issue-copy' import type { OpenCodeWslRuntime } from './session-scanner-opencode-wsl-runtime' diff --git a/src/main/ai-vault/session-delete.test.ts b/src/main/ai-vault/session-delete.test.ts index 015a87931cc..3f4f2d7aa77 100644 --- a/src/main/ai-vault/session-delete.test.ts +++ b/src/main/ai-vault/session-delete.test.ts @@ -24,7 +24,7 @@ vi.mock('node:fs/promises', () => ({ realpath: realpathMock })) -vi.mock('../wsl-unc-delete', () => ({ +vi.mock('../wsl/filesystem/wsl-unc-delete', () => ({ tryDeleteWslUncPath: tryDeleteWslUncPathMock, WslDeleteValidationError: WslDeleteValidationErrorMock })) diff --git a/src/main/ai-vault/session-delete.ts b/src/main/ai-vault/session-delete.ts index 4354de15866..03a798d9a61 100644 --- a/src/main/ai-vault/session-delete.ts +++ b/src/main/ai-vault/session-delete.ts @@ -8,7 +8,7 @@ import { validateAiVaultSessionDeleteTarget, type ValidateAiVaultSessionDeleteTargetArgs } from './session-delete-target' -import { tryDeleteWslUncPath, WslDeleteValidationError } from '../wsl-unc-delete' +import { tryDeleteWslUncPath, WslDeleteValidationError } from '../wsl/filesystem/wsl-unc-delete' import { isENOENT } from '../ipc/filesystem/filesystem-path-containment' /** Desktop moves to Trash; a plain-Node host has none, so it removes permanently after the user confirmed. */ diff --git a/src/main/ai-vault/session-scanner-devin-db.ts b/src/main/ai-vault/session-scanner-devin-db.ts index dc65d2f2ede..c658164748f 100644 --- a/src/main/ai-vault/session-scanner-devin-db.ts +++ b/src/main/ai-vault/session-scanner-devin-db.ts @@ -1,5 +1,5 @@ import { parseWslUncPath } from '../../shared/wsl-paths' -import { wasWslDistroLastSeenRunningSettled } from '../wsl-background-distro-gate' +import { wasWslDistroLastSeenRunningSettled } from '../wsl/discovery/wsl-background-distro-gate' import { WSL_TRANSCRIPT_RUNNING_LEASE_MS } from '../native-chat/wsl-transcript-running-admission' import { AsyncLocalStorage } from 'node:async_hooks' import { dirname, join } from 'node:path' diff --git a/src/main/ai-vault/session-scanner-opencode-wsl-client.test.ts b/src/main/ai-vault/session-scanner-opencode-wsl-client.test.ts index dc583bd5cc1..c4f3aaf0a22 100644 --- a/src/main/ai-vault/session-scanner-opencode-wsl-client.test.ts +++ b/src/main/ai-vault/session-scanner-opencode-wsl-client.test.ts @@ -19,10 +19,10 @@ vi.mock('../native-chat/wsl-transcript-running-admission', () => ({ vi.mock('./session-scanner-opencode-sqlite-process-client', () => ({ createOpenCodeSqliteProcessClient: mocks.create })) -vi.mock('../wsl/wsl-executable-path', () => ({ +vi.mock('../wsl/execution/wsl-executable-path', () => ({ resolveWslExecutablePath: () => 'C:\\Windows\\System32\\wsl.exe' })) -vi.mock('../wsl-interop-spawn-directory', () => ({ +vi.mock('../wsl/execution/wsl-interop-spawn-directory', () => ({ resolveWslInteropSpawnCwd: () => 'C:\\Windows' })) import { diff --git a/src/main/ai-vault/session-scanner-opencode-wsl-client.ts b/src/main/ai-vault/session-scanner-opencode-wsl-client.ts index 74229c52e5b..f377fc8cffd 100644 --- a/src/main/ai-vault/session-scanner-opencode-wsl-client.ts +++ b/src/main/ai-vault/session-scanner-opencode-wsl-client.ts @@ -2,10 +2,10 @@ import type { AiVaultSession } from '../../shared/ai-vault-types' import { waitForPromiseWithSignal, throwIfSignalAborted } from '../../shared/abort-signal-reason' import { buildWslExecArgs } from '../../shared/wsl-login-shell-command' import { parseWslUncPath } from '../../shared/wsl-paths' -import { resolveWslExecutablePath } from '../wsl/wsl-executable-path' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' +import { resolveWslExecutablePath } from '../wsl/execution/wsl-executable-path' +import { resolveWslInteropSpawnCwd } from '../wsl/execution/wsl-interop-spawn-directory' import { admitWslTranscriptPath } from '../native-chat/wsl-transcript-running-admission' -import { noteWslDistroMayHaveStopped } from '../wsl/wsl-unc-access-gate' +import { noteWslDistroMayHaveStopped } from '../wsl/discovery/wsl-background-distro-gate' import { createOpenCodeSqliteProcessClient } from './session-scanner-opencode-sqlite-process-client' import type { OpenCodeSqliteWorkerClient } from './session-scanner-opencode-sqlite-worker-client' import type { OpenCodeWslRuntime } from './session-scanner-opencode-wsl-runtime' diff --git a/src/main/ai-vault/session-scanner-service-entry.ts b/src/main/ai-vault/session-scanner-service-entry.ts index e23e621b6cc..d2f0a313c3a 100644 --- a/src/main/ai-vault/session-scanner-service-entry.ts +++ b/src/main/ai-vault/session-scanner-service-entry.ts @@ -24,7 +24,10 @@ import { import { readAiVaultSessionTitlesFromFiles } from './session-title-file-reader' import { resolveHostReadableAiVaultTitleRequests } from './session-title-request-paths' import { listLocalAiVaultSubagentSessions } from './session-subagent-reader' -import { noteWslDistroMayHaveStopped, noteWslDistroWoken } from '../wsl-background-distro-gate' +import { + noteWslDistroMayHaveStopped, + noteWslDistroWoken +} from '../wsl/discovery/wsl-background-distro-gate' if (!process.send) { throw new Error('AI Vault service requires a parent IPC channel.') diff --git a/src/main/ai-vault/session-scanner-service-wsl-notes.ts b/src/main/ai-vault/session-scanner-service-wsl-notes.ts index 2215579a751..36ce6caac64 100644 --- a/src/main/ai-vault/session-scanner-service-wsl-notes.ts +++ b/src/main/ai-vault/session-scanner-service-wsl-notes.ts @@ -1,4 +1,4 @@ -import { onWslDistroGateNote } from '../wsl-background-distro-gate' +import { onWslDistroGateNote } from '../wsl/discovery/wsl-background-distro-gate' type WslNoteChannel = { send(message: unknown, callback: (error: Error | null) => void): boolean diff --git a/src/main/ai-vault/session-scanner-wsl-stop-gaps.test.ts b/src/main/ai-vault/session-scanner-wsl-stop-gaps.test.ts index d1d9b19a8e9..63c70b598df 100644 --- a/src/main/ai-vault/session-scanner-wsl-stop-gaps.test.ts +++ b/src/main/ai-vault/session-scanner-wsl-stop-gaps.test.ts @@ -17,11 +17,15 @@ vi.mock('./session-scanner-opencode-sqlite-open', async (importOriginal) => ({ ...(await importOriginal()), readOpenCodeDatabase: mocks.readDb })) -vi.mock('../wsl/wsl-executable-path', () => ({ resolveWslExecutablePath: () => 'wsl.exe' })) -vi.mock('../wsl-interop-spawn-directory', () => ({ resolveWslInteropSpawnCwd: () => 'C:\\' })) +vi.mock('../wsl/execution/wsl-executable-path', () => ({ + resolveWslExecutablePath: () => 'wsl.exe' +})) +vi.mock('../wsl/execution/wsl-interop-spawn-directory', () => ({ + resolveWslInteropSpawnCwd: () => 'C:\\' +})) -import { _resetWslCachesForTests } from '../wsl' -import { _resetWslBackgroundDistroGateForTests } from '../wsl-background-distro-gate' +import { _resetWslCachesForTests } from '../wsl/discovery/distro-catalog' +import { _resetWslBackgroundDistroGateForTests } from '../wsl/discovery/wsl-background-distro-gate' import { WSL_TRANSCRIPT_RUNNING_LEASE_MS } from '../native-chat/wsl-transcript-running-admission' import { configureOpenCodeWslReaders, @@ -31,9 +35,9 @@ import { devinSessionsIndexForSidecar, resetDevinSessionsIndexCacheForTests } from './session-scanner-devin-db' -import { listRunningWslHomeDirsUnlessStopped } from '../wsl/wsl-home-unless-stopped' -import { clearWslHomeCache, rememberWslHome } from '../wsl-home-cache' -import { _resetRunningWslDistroCacheForTests } from '../wsl-running-distro-cache' +import { listRunningWslHomeDirsUnlessStopped } from '../wsl/discovery/wsl-home-unless-stopped' +import { clearWslHomeCache, rememberWslHome } from '../wsl/discovery/wsl-home-cache' +import { _resetRunningWslDistroCacheForTests } from '../wsl/discovery/wsl-running-distro-cache' import { localAiVaultScanRoots } from './cached-session-list' const DB = '\\\\wsl.localhost\\Ubuntu\\home\\ada\\.opencode\\opencode.db' diff --git a/src/main/automations/automation-wsl-distro-stopped-refusal.test.ts b/src/main/automations/automation-wsl-distro-stopped-refusal.test.ts index b7a461293dc..75e1fbfd489 100644 --- a/src/main/automations/automation-wsl-distro-stopped-refusal.test.ts +++ b/src/main/automations/automation-wsl-distro-stopped-refusal.test.ts @@ -7,7 +7,7 @@ import type { Automation } from '../../shared/automations-types' import { removeTreeSync } from '../../shared/windows-transient-lock-removal' import type { Store } from '../persistence/loading-store/store' import { closeTestStores, createStore, testState } from '../persistence/persistence-test-harness' -import type * as UncGate from '../wsl/wsl-unc-access-gate' +import type * as UncGate from '../wsl/filesystem/wsl-unc-access-gate' import { AutomationService } from './service' const blocked = vi.hoisted(() => @@ -27,7 +27,7 @@ vi.mock('../workspaces/execution-host/project-runtime-git-options', async (impor getLocalProjectWorktreeGitOptions: () => projectGit.wslDistro ? { wslDistro: projectGit.wslDistro } : {} })) -vi.mock('../wsl/wsl-unc-access-gate', async (importOriginal) => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', async (importOriginal) => ({ ...(await importOriginal()), blockedWslDistroForPath: blocked })) diff --git a/src/main/automations/dispatch-refusal.ts b/src/main/automations/dispatch-refusal.ts index 6f55390c4b1..7a68ea69317 100644 --- a/src/main/automations/dispatch-refusal.ts +++ b/src/main/automations/dispatch-refusal.ts @@ -10,7 +10,7 @@ import { resolveAutomationRunTarget, type AutomationRunTargetResult } from './ru import type { AutomationRunWriter } from './automation-run-writer' import { wslMoveRepoBackoff } from '../persistence/moving-wsl-projects/wsl-move-background-backoff' import { isOrcadFencedAutomation } from './orcad-fenced-automation' -import { blockedWslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' import { getLocalProjectWorktreeGitOptions } from '../workspaces/execution-host/project-runtime-git-options' import { AUTOMATION_RUN_FAILURE_COPY, diff --git a/src/main/claude-accounts/claude-command-process.test.ts b/src/main/claude-accounts/claude-command-process.test.ts index b23f759b192..90924a65aaa 100644 --- a/src/main/claude-accounts/claude-command-process.test.ts +++ b/src/main/claude-accounts/claude-command-process.test.ts @@ -25,7 +25,7 @@ vi.mock('@orca/process-host', () => ({ } })) vi.mock('../codex-cli/command', () => ({ resolveClaudeCommand: () => 'claude' })) -vi.mock('../wsl/wsl-executable-path', () => ({ +vi.mock('../wsl/execution/wsl-executable-path', () => ({ resolveWslExecutablePath: () => 'C:\\Windows\\System32\\wsl.exe' })) diff --git a/src/main/claude-accounts/claude-command-process.ts b/src/main/claude-accounts/claude-command-process.ts index 8bbf97e4218..bd8aade68ce 100644 --- a/src/main/claude-accounts/claude-command-process.ts +++ b/src/main/claude-accounts/claude-command-process.ts @@ -12,7 +12,7 @@ import { isWindowsOnlyAgentCommand, windowsOnlyCliMessage } from '../codex-cli/windows-only-agent-cli' -import { resolveWslExecutablePath } from '../wsl/wsl-executable-path' +import { resolveWslExecutablePath } from '../wsl/execution/wsl-executable-path' import { buildWindowsCommandInvocation } from './windows-command-invocation' import { terminateClaudeProcess } from './claude-login-process-termination' diff --git a/src/main/claude-accounts/claude-profile-wsl-router.test.ts b/src/main/claude-accounts/claude-profile-wsl-router.test.ts index bf913249bba..87896d6eb69 100644 --- a/src/main/claude-accounts/claude-profile-wsl-router.test.ts +++ b/src/main/claude-accounts/claude-profile-wsl-router.test.ts @@ -1,4 +1,4 @@ -import type { BlockedWslDistro } from '../wsl/wsl-unc-access-gate' +import type { BlockedWslDistro } from '../wsl/filesystem/wsl-unc-access-gate' import { spawnSync } from 'node:child_process' import { existsSync, @@ -15,7 +15,7 @@ import { join, resolve } from 'node:path' import { build } from 'esbuild' import { afterEach, describe, expect, it, vi } from 'vitest' import type { ClaudeManagedAccount } from '../../shared/managed-account-types' -import type { WslSpec } from '../wsl/wsl-runner' +import type { WslSpec } from '../wsl/execution/wsl-runner' import type * as WslPaths from '../../shared/wsl-paths' const guest = vi.hoisted( @@ -29,7 +29,7 @@ vi.mock('../../shared/wsl-paths', async (original) => ({ ...(await original()), toWindowsWslPath: (linuxPath: string) => linuxPath })) -vi.mock('../wsl', () => ({ +vi.mock('../wsl/discovery/distro-catalog', () => ({ getWslHomeAsync: async (distro: string) => `\\\\wsl.localhost\\${distro}${guest.home}`, listRunningWslDistrosAsync: async () => ['Ubuntu'] })) @@ -38,8 +38,8 @@ const gate = vi.hoisted(() => ({ async (_path: string, _distro?: string | null): Promise => null ) })) -vi.mock('../wsl/wsl-unc-access-gate', () => ({ blockedWslDistroForPath: gate.blocked })) -vi.mock('../wsl/wsl-runner', () => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', () => ({ blockedWslDistroForPath: gate.blocked })) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: async (spec: WslSpec) => { if (guest.failure) { return { ...guest.failure, stderr: '', timedOut: false } diff --git a/src/main/claude-accounts/claude-profile-wsl-router.ts b/src/main/claude-accounts/claude-profile-wsl-router.ts index 96ba92460d6..77096d1c7f3 100644 --- a/src/main/claude-accounts/claude-profile-wsl-router.ts +++ b/src/main/claude-accounts/claude-profile-wsl-router.ts @@ -9,12 +9,12 @@ import { } from '../../shared/claude-profile-routing' import { WSL_CLAUDE_PROFILE_HELPER_FILENAME } from '../../shared/remote-bundle-artifacts' import { parseWslUncPath, toWindowsWslPath } from '../../shared/wsl-paths' -import { getWslHomeAsync, listRunningWslDistrosAsync } from '../wsl' +import { getWslHomeAsync, listRunningWslDistrosAsync } from '../wsl/discovery/distro-catalog' import { ensureWslPinnedRuntime } from '../wsl/wsl-pinned-runtime' import { relayBundleCandidates } from '../ssh/relay-bundle-paths' -import { runWslProcess, type WslSpec } from '../wsl/wsl-runner' -import { describeWslProcessFailure } from '../wsl/wsl-process-failure' -import { blockedWslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { runWslProcess, type WslSpec } from '../wsl/execution/wsl-runner' +import { describeWslProcessFailure } from '../wsl/execution/wsl-process-failure' +import { blockedWslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' import { claudeProfileMarkerPath, type ClaudeProfileDescriptor } from './claude-profile-paths' import type { ClaudeProfileRouterSettings } from './claude-profile-router' import { claudeProfileMissing, claudeProfileSetupFailed } from './claude-profile-launch-errors' diff --git a/src/main/claude-accounts/runtime-auth-service.test.ts b/src/main/claude-accounts/runtime-auth-service.test.ts index 80fe277025a..38141690390 100644 --- a/src/main/claude-accounts/runtime-auth-service.test.ts +++ b/src/main/claude-accounts/runtime-auth-service.test.ts @@ -18,7 +18,7 @@ const fakes = vi.hoisted(() => ({ vi.mock('../../shared/app-environment', () => ({ getAppEnvironment: () => ({ getPath: () => '/data/orca' }) })) -vi.mock('../wsl', () => ({ +vi.mock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: (distro: string) => `/wsl/${distro}/home` })) diff --git a/src/main/claude-accounts/runtime-auth-service.ts b/src/main/claude-accounts/runtime-auth-service.ts index 3c3801b9f1a..f9e665c5db2 100644 --- a/src/main/claude-accounts/runtime-auth-service.ts +++ b/src/main/claude-accounts/runtime-auth-service.ts @@ -3,8 +3,8 @@ import { getAppEnvironment } from '../../shared/app-environment' import { toWindowsWslPath } from '../../shared/wsl-paths' import { resolveLocalAccountRuntimeTarget } from '../../shared/local-account-runtime' import type { Store } from '../persistence/loading-store/store' -import { isWslDistroRunning } from '../wsl-background-distro-gate' -import { getDefaultWslDistro, getWslHome } from '../wsl' +import { isWslDistroRunning } from '../wsl/discovery/wsl-background-distro-gate' +import { getDefaultWslDistro, getWslHome } from '../wsl/discovery/distro-catalog' import { ClaudeProfileRouter } from './claude-profile-router' import { ClaudeWslProfileRouter } from './claude-profile-wsl-router' import { diff --git a/src/main/claude/claude-folder-trust-file-wsl-guest.test.ts b/src/main/claude/claude-folder-trust-file-wsl-guest.test.ts index 278f50d0c03..d09b419e381 100644 --- a/src/main/claude/claude-folder-trust-file-wsl-guest.test.ts +++ b/src/main/claude/claude-folder-trust-file-wsl-guest.test.ts @@ -13,7 +13,7 @@ import { import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type { WslResult, WslSpec } from '../wsl/wsl-runner' +import type { WslResult, WslSpec } from '../wsl/execution/wsl-runner' import { grantClaudeFolderTrust } from './claude-folder-trust-file' const { DISTRO, GUEST_PREFIX, guest } = vi.hoisted(() => ({ @@ -72,7 +72,7 @@ vi.mock('proper-lockfile', () => ({ })) const runWslProcess = vi.hoisted(() => vi.fn<(spec: WslSpec) => Promise>()) -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess })) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess })) async function guestChmod(spec: WslSpec): Promise { const [reference, separator, target] = spec.args ?? [] diff --git a/src/main/claude/claude-folder-trust-file.ts b/src/main/claude/claude-folder-trust-file.ts index d4b720d8aee..7df013be164 100644 --- a/src/main/claude/claude-folder-trust-file.ts +++ b/src/main/claude/claude-folder-trust-file.ts @@ -15,7 +15,7 @@ import { lock } from 'proper-lockfile' import { renameFileWithWindowsRetry } from '../codex-accounts/fs-utils' import { runKeyedSerializedOperation } from '../cli/keyed-promise-queue' import { parseWslUncPath } from '../../shared/wsl-paths' -import { runWslProcess } from '../wsl/wsl-runner' +import { runWslProcess } from '../wsl/execution/wsl-runner' import type { ClaudeRuntimeAuthPreparation } from '../claude-accounts/runtime-auth/runtime-auth-types' export type ClaudeTrustPathStyle = 'posix' | 'win32' diff --git a/src/main/cli/wsl-cli-installer.test.ts b/src/main/cli/wsl-cli-installer.test.ts index 5e2b20229fe..9c99a4dab85 100644 --- a/src/main/cli/wsl-cli-installer.test.ts +++ b/src/main/cli/wsl-cli-installer.test.ts @@ -7,7 +7,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' const runWslProcessMock = vi.hoisted(() => vi.fn()) -vi.mock('../wsl/wsl-runner', () => ({ +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) diff --git a/src/main/cli/wsl-cli-installer.ts b/src/main/cli/wsl-cli-installer.ts index 478d8d3ad01..6db7fe9db9c 100644 --- a/src/main/cli/wsl-cli-installer.ts +++ b/src/main/cli/wsl-cli-installer.ts @@ -1,7 +1,7 @@ import type { CliInstallStatus } from '../../shared/cli-install-types' -import { getDefaultWslDistro } from '../wsl' -import { runWslProcess } from '../wsl/wsl-runner' -import { describeWslProcessFailure } from '../wsl/wsl-process-failure' +import { getDefaultWslDistro } from '../wsl/discovery/distro-catalog' +import { runWslProcess } from '../wsl/execution/wsl-runner' +import { describeWslProcessFailure } from '../wsl/execution/wsl-process-failure' import { CliInstaller } from './cli-installer' import { buildManagedLegacyRemoveCommand, diff --git a/src/main/cli/wsl-cli-login-path.test.ts b/src/main/cli/wsl-cli-login-path.test.ts index 427a9ffd276..e5d3481e9f3 100644 --- a/src/main/cli/wsl-cli-login-path.test.ts +++ b/src/main/cli/wsl-cli-login-path.test.ts @@ -3,7 +3,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' const runWslProcessMock = vi.hoisted(() => vi.fn()) -vi.mock('../wsl/wsl-runner', () => ({ +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) diff --git a/src/main/cli/wsl-cli-registration-reconciliation.ts b/src/main/cli/wsl-cli-registration-reconciliation.ts index b7edc00e891..c3bf4298c1f 100644 --- a/src/main/cli/wsl-cli-registration-reconciliation.ts +++ b/src/main/cli/wsl-cli-registration-reconciliation.ts @@ -1,10 +1,10 @@ import type { CliInstallState, CliInstallStatus } from '../../shared/cli-install-types' -import { listWslDistrosAsync } from '../wsl' +import { listWslDistrosAsync } from '../wsl/discovery/distro-catalog' import { deferUntilWslDistroRunning, isWslDistroRunning, listConfirmedRunningWslDistros -} from '../wsl-background-distro-gate' +} from '../wsl/discovery/wsl-background-distro-gate' import { CliInstaller } from './cli-installer' import { getWslCliRegistrationCandidates, diff --git a/src/main/codex-accounts/codex-config-mirror.ts b/src/main/codex-accounts/codex-config-mirror.ts index b156e3748cf..316df630d7b 100644 --- a/src/main/codex-accounts/codex-config-mirror.ts +++ b/src/main/codex-accounts/codex-config-mirror.ts @@ -1,16 +1,15 @@ import { existsSync, readFileSync } from 'node:fs' import { homedir } from 'node:os' import { join } from 'node:path' -import { parseWslUncPath } from '../../shared/wsl-paths' +import { parseWslUncPath, toWindowsWslPath } from '../../shared/wsl-paths' import { ensureCodexDaemonSocketGuard, syncSystemConfigIntoManagedCodexHome } from '../codex/codex-config-mirror' import { readCodexTopLevelModelProvider } from '../codex/codex-model-provider-config' import type { Store } from '../persistence/loading-store/store' -import { toWindowsWslPath } from '../wsl' -import { wasWslDistroLastSeenRunningSettled } from '../wsl-background-distro-gate' -import { WSL_UNC_RUNNING_LEASE_MS } from '../wsl/wsl-unc-access-gate' +import { wasWslDistroLastSeenRunningSettled } from '../wsl/discovery/wsl-background-distro-gate' +import { WSL_UNC_RUNNING_LEASE_MS } from '../wsl/filesystem/wsl-unc-access-gate' export type CanonicalCodexConfig = { contents: string diff --git a/src/main/codex-accounts/codex-login-session-wsl-open.test.ts b/src/main/codex-accounts/codex-login-session-wsl-open.test.ts index abb8e835cc6..7e1c5d0fd04 100644 --- a/src/main/codex-accounts/codex-login-session-wsl-open.test.ts +++ b/src/main/codex-accounts/codex-login-session-wsl-open.test.ts @@ -5,7 +5,7 @@ import { join } from 'node:path' import { PassThrough } from 'node:stream' import { afterEach, describe, expect, it, vi } from 'vitest' -vi.mock('../wsl/wsl-runner', () => ({ +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: vi.fn(async () => ({ environmentResolved: true, code: 0, diff --git a/src/main/codex-accounts/codex-login-session.ts b/src/main/codex-accounts/codex-login-session.ts index 74812d8e40d..630305fe782 100644 --- a/src/main/codex-accounts/codex-login-session.ts +++ b/src/main/codex-accounts/codex-login-session.ts @@ -7,7 +7,7 @@ import { parseWslUncPath } from '../../shared/wsl-paths' import { resolveCodexCommand } from '../codex-cli/command' import { codexSpawnEnoent } from '../codex-cli/windows-only-agent-cli' import { getSpawnArgsForWindows } from '../../shared/windows-batch-spawn' -import { runWslProcess } from '../wsl/wsl-runner' +import { runWslProcess } from '../wsl/execution/wsl-runner' import { parseCodexLoginAuthUrl } from './codex-login-auth-url' import { DEVICE_AUTH_TIMEOUT_MS, parseCodexDeviceAuthPrompt } from './codex-device-auth-prompt' import { loginAuthChanged, readLoginAuthSnapshot } from './codex-login-auth-snapshot' diff --git a/src/main/codex-accounts/codex-managed-home-lifecycle.ts b/src/main/codex-accounts/codex-managed-home-lifecycle.ts index 2229ecfe3ca..5f7312b297e 100644 --- a/src/main/codex-accounts/codex-managed-home-lifecycle.ts +++ b/src/main/codex-accounts/codex-managed-home-lifecycle.ts @@ -6,9 +6,8 @@ import { WINDOWS_RM_RETRY_DELAY_MS } from '../../shared/windows-transient-lock-removal' import { quotePosixShell } from '../../shared/shell-argument-quoting' -import { parseWslUncPath } from '../../shared/wsl-paths' -import { toWindowsWslPath } from '../wsl' -import { runWslProcess } from '../wsl/wsl-runner' +import { parseWslUncPath, toWindowsWslPath } from '../../shared/wsl-paths' +import { runWslProcess } from '../wsl/execution/wsl-runner' import type { CodexAccountAddTarget, ManagedCodexHomeLocation } from './codex-account-service-types' import { writeFileAtomically } from './fs-utils' import { ManagedCodexHomeTemporarilyUnavailableError } from './host-codex-managed-home-ownership' diff --git a/src/main/codex-accounts/codex-managed-home-path-wsl-check.test.ts b/src/main/codex-accounts/codex-managed-home-path-wsl-check.test.ts index 4ced381582b..b2cdae593fb 100644 --- a/src/main/codex-accounts/codex-managed-home-path-wsl-check.test.ts +++ b/src/main/codex-accounts/codex-managed-home-path-wsl-check.test.ts @@ -1,11 +1,15 @@ +import type * as WslPaths from '../../shared/wsl-paths' import { afterEach, beforeEach, expect, it, vi } from 'vitest' -import type { WslResult, WslSpec } from '../wsl/wsl-runner' +import type { WslResult, WslSpec } from '../wsl/execution/wsl-runner' const runWslProcess = vi.hoisted(() => vi.fn<(spec: WslSpec) => Promise>()) -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess })) -vi.mock('../wsl', () => ({ - toWindowsWslPath: (linuxPath: string, distro: string) => - `\\\\wsl.localhost\\${distro}${linuxPath}` +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess })) +vi.mock('../../shared/wsl-paths', async (importOriginal) => ({ + ...(await importOriginal()), + ...(await (() => ({ + toWindowsWslPath: (linuxPath: string, distro: string) => + `\\\\wsl.localhost\\${distro}${linuxPath}` + }))()) })) import { CodexManagedHomePath } from './codex-managed-home-path' diff --git a/src/main/codex-accounts/codex-managed-home-path.ts b/src/main/codex-accounts/codex-managed-home-path.ts index 586882aeaa6..2cb24b2159f 100644 --- a/src/main/codex-accounts/codex-managed-home-path.ts +++ b/src/main/codex-accounts/codex-managed-home-path.ts @@ -3,11 +3,10 @@ import { join, resolve } from 'node:path' import { getAppEnvironment } from '../../shared/app-environment' import { buildPosixStdoutFence } from '../../shared/posix-stdout-fence' import { quotePosixShell } from '../../shared/shell-argument-quoting' -import { parseWslUncPath } from '../../shared/wsl-paths' +import { parseWslUncPath, toWindowsWslPath } from '../../shared/wsl-paths' import type { CodexManagedAccount } from '../../shared/managed-account-types' import { getSystemCodexHomePath } from '../codex/codex-home-paths' -import { toWindowsWslPath } from '../wsl' -import { runWslProcess } from '../wsl/wsl-runner' +import { runWslProcess } from '../wsl/execution/wsl-runner' import { assertOwnedHostCodexManagedHomePath } from './host-codex-managed-home-ownership' const WSL_MANAGED_HOME_TIMEOUT_MS = 5_000 diff --git a/src/main/codex-accounts/legacy-wsl-runtime-auth-drain.test.ts b/src/main/codex-accounts/legacy-wsl-runtime-auth-drain.test.ts index a70b2707cc5..65e9d2c2477 100644 --- a/src/main/codex-accounts/legacy-wsl-runtime-auth-drain.test.ts +++ b/src/main/codex-accounts/legacy-wsl-runtime-auth-drain.test.ts @@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' const { runWslProcessMock } = vi.hoisted(() => ({ runWslProcessMock: vi.fn() })) -vi.mock('../wsl/wsl-runner', () => ({ +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) diff --git a/src/main/codex-accounts/legacy-wsl-runtime-auth-drain.ts b/src/main/codex-accounts/legacy-wsl-runtime-auth-drain.ts index c591d612b22..c4ce2aa3e4a 100644 --- a/src/main/codex-accounts/legacy-wsl-runtime-auth-drain.ts +++ b/src/main/codex-accounts/legacy-wsl-runtime-auth-drain.ts @@ -2,7 +2,7 @@ import { createHash } from 'node:crypto' import { posix as pathPosix } from 'node:path' import { wslCodexRuntimeHomeForGuestHome } from '../pty/shell-startup/codex-home-wsl-env' import { WSL_SESSION_BRIDGE_TIMEOUT_MS } from '../codex/wsl-codex-session-bridge-script' -import { runWslProcess } from '../wsl/wsl-runner' +import { runWslProcess } from '../wsl/execution/wsl-runner' import { compareCodexAuthFreshness, codexAuthIsFresher } from './codex-auth-identity' import { APPLY_LEGACY_AUTH_SCRIPT, diff --git a/src/main/codex-accounts/runtime-home-history-sharing-opt-out.test.ts b/src/main/codex-accounts/runtime-home-history-sharing-opt-out.test.ts index 73a4b2a200f..42842ad8ff5 100644 --- a/src/main/codex-accounts/runtime-home-history-sharing-opt-out.test.ts +++ b/src/main/codex-accounts/runtime-home-history-sharing-opt-out.test.ts @@ -117,7 +117,10 @@ describe('the Codex history-sharing opt-out (#24511)', () => { vi.doMock('../codex/wsl-codex-session-bridge', () => ({ startWslCodexSessionBridgeInBackground: bridges.wsl })) - vi.doMock('../wsl', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome })) + vi.doMock('../wsl/discovery/distro-catalog', () => ({ + getDefaultWslDistro: () => 'Ubuntu', + getWslHome: () => wslHome + })) const accountsRoot = join(wslHome, '.local', 'share', 'orca', 'codex-accounts') const wslAccount = (id: string) => ({ id, @@ -152,7 +155,7 @@ describe('the Codex history-sharing opt-out (#24511)', () => { expect(bridges.wsl).not.toHaveBeenCalled() } finally { vi.doUnmock('../codex/wsl-codex-session-bridge') - vi.doUnmock('../wsl') + vi.doUnmock('../wsl/discovery/distro-catalog') if (originalPlatform) { Object.defineProperty(process, 'platform', originalPlatform) } diff --git a/src/main/codex-accounts/runtime-home-rate-limit-pinned-distro.test.ts b/src/main/codex-accounts/runtime-home-rate-limit-pinned-distro.test.ts index f006dc04789..19b74edb754 100644 --- a/src/main/codex-accounts/runtime-home-rate-limit-pinned-distro.test.ts +++ b/src/main/codex-accounts/runtime-home-rate-limit-pinned-distro.test.ts @@ -10,7 +10,9 @@ import { testState } from './runtime-home-service-test-harness' -vi.mock('../wsl/wsl-background-exec-gate', () => ({ blockedWslDistroForExec: async () => null })) +vi.mock('../wsl/discovery/wsl-background-exec-gate', () => ({ + blockedWslDistroForExec: async () => null +})) vi.mock('electron', () => ({ app: { getPath: () => testState.userDataDir } })) vi.mock(import('node:os'), async (importOriginal) => ({ ...(await importOriginal()), @@ -62,7 +64,7 @@ describe('Codex quota poll home with a gated, pinned WSL distro (E9)', () => { setupRuntimeHomeTest() Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome, getWslHomeAsync: async () => wslHome diff --git a/src/main/codex-accounts/runtime-home-service-home-routing.ts b/src/main/codex-accounts/runtime-home-service-home-routing.ts index 24064c8fe92..d3707b73935 100644 --- a/src/main/codex-accounts/runtime-home-service-home-routing.ts +++ b/src/main/codex-accounts/runtime-home-service-home-routing.ts @@ -1,9 +1,9 @@ import { posix as pathPosix } from 'node:path' import { parseWslUncPath, toLinuxPath, toWindowsWslUncPath } from '../../shared/wsl-paths' import { normalizeRuntimePathForComparison } from '../../shared/cross-platform-path' -import { getDefaultWslDistro, getWslHome } from '../wsl' -import { getCachedWslHome } from '../wsl-home-cache' -import { isWslDistroRunning } from '../wsl-background-distro-gate' +import { getDefaultWslDistro, getWslHome } from '../wsl/discovery/distro-catalog' +import { getCachedWslHome } from '../wsl/discovery/wsl-home-cache' +import { isWslDistroRunning } from '../wsl/discovery/wsl-background-distro-gate' import { getSystemCodexHomePath, resolveOrcaManagedCodexHomePath, diff --git a/src/main/codex-accounts/runtime-home-service-launch.ts b/src/main/codex-accounts/runtime-home-service-launch.ts index b2988bef073..4c0457b7287 100644 --- a/src/main/codex-accounts/runtime-home-service-launch.ts +++ b/src/main/codex-accounts/runtime-home-service-launch.ts @@ -20,8 +20,8 @@ import { resolveCodexSessionBackfillPaths } from '../codex/codex-session-backfil import type { CodexSessionBackfillDate } from '../codex/codex-session-backfill-types' import { ManagedCodexHomeTemporarilyUnavailableError } from './host-codex-managed-home-ownership' import { CodexRuntimeHomeRouting } from './runtime-home-service-home-routing' -import { blockedWslDistroForExec } from '../wsl/wsl-background-exec-gate' -import { getWslHomeAsync } from '../wsl' +import { blockedWslDistroForExec } from '../wsl/discovery/wsl-background-exec-gate' +import { getWslHomeAsync } from '../wsl/discovery/distro-catalog' export abstract class CodexRuntimeHomeLaunch extends CodexRuntimeHomeRouting { protected initializeLastSyncedState(): void { diff --git a/src/main/codex-accounts/runtime-home-service-managed-home.ts b/src/main/codex-accounts/runtime-home-service-managed-home.ts index f03f27b2e5b..d2cbecfd15e 100644 --- a/src/main/codex-accounts/runtime-home-service-managed-home.ts +++ b/src/main/codex-accounts/runtime-home-service-managed-home.ts @@ -26,7 +26,7 @@ import { hasCompletedCodexSessionBackfillMarker, markCodexSessionBackfillMarkerNeedsFullScan } from '../codex/codex-session-backfill-marker' -import { getDefaultWslDistro } from '../wsl' +import { getDefaultWslDistro } from '../wsl/discovery/distro-catalog' import { startWslCodexSessionBridgeInBackground } from '../codex/wsl-codex-session-bridge' import type { CodexAccountSelectionTarget } from './runtime-selection' import type { CodexManagedAccount } from '../../shared/managed-account-types' diff --git a/src/main/codex-accounts/runtime-home-service-wsl.ts b/src/main/codex-accounts/runtime-home-service-wsl.ts index 971385b3b9d..0812b0c134d 100644 --- a/src/main/codex-accounts/runtime-home-service-wsl.ts +++ b/src/main/codex-accounts/runtime-home-service-wsl.ts @@ -5,7 +5,7 @@ import { getSelectedCodexAccountIdForTarget, type CodexAccountSelectionTarget } from './runtime-selection' -import { getDefaultWslDistro, getWslHome } from '../wsl' +import { getDefaultWslDistro, getWslHome } from '../wsl/discovery/distro-catalog' import { hasRecordedLegacyWslCodexPane } from '../codex/codex-pane-account-registry' import { startLegacyWslRuntimeAuthDrain, diff --git a/src/main/codex-accounts/runtime-home-wsl-managed-accounts.test.ts b/src/main/codex-accounts/runtime-home-wsl-managed-accounts.test.ts index 8f3711ba21c..d4b1864cb97 100644 --- a/src/main/codex-accounts/runtime-home-wsl-managed-accounts.test.ts +++ b/src/main/codex-accounts/runtime-home-wsl-managed-accounts.test.ts @@ -17,7 +17,9 @@ import { } from './runtime-home-service-test-harness' // These launches are the user's own, so the E9 exec gate lets their prep run. -vi.mock('../wsl/wsl-background-exec-gate', () => ({ blockedWslDistroForExec: async () => null })) +vi.mock('../wsl/discovery/wsl-background-exec-gate', () => ({ + blockedWslDistroForExec: async () => null +})) vi.mock('electron', () => ({ app: { getPath: () => testState.userDataDir @@ -45,7 +47,7 @@ describe('CodexRuntimeHomeService', () => { const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome, getWslHomeAsync: async () => wslHome @@ -116,7 +118,7 @@ describe('CodexRuntimeHomeService', () => { const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome, getWslHomeAsync: async () => wslHome @@ -183,7 +185,7 @@ describe('CodexRuntimeHomeService', () => { const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome, getWslHomeAsync: async () => wslHome @@ -242,7 +244,7 @@ describe('CodexRuntimeHomeService', () => { const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome, getWslHomeAsync: async () => wslHome @@ -323,7 +325,7 @@ describe('CodexRuntimeHomeService', () => { const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome, getWslHomeAsync: async () => wslHome @@ -392,7 +394,7 @@ describe('CodexRuntimeHomeService', () => { vi.doUnmock('../codex/codex-home-paths') vi.doUnmock('../codex/wsl-codex-session-bridge') vi.doUnmock('./legacy-wsl-runtime-auth-drain') - vi.doUnmock('../wsl') + vi.doUnmock('../wsl/discovery/distro-catalog') if (originalPlatform) { Object.defineProperty(process, 'platform', originalPlatform) } @@ -403,7 +405,7 @@ describe('CodexRuntimeHomeService', () => { const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome, getWslHomeAsync: async () => wslHome @@ -486,7 +488,7 @@ describe('CodexRuntimeHomeService', () => { 2_000 ) const linuxHomePath = '/mnt/c/Users/alice/orca/codex-accounts/drive-account/home' - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => 'C:\\Users\\alice', getWslHomeAsync: async () => 'C:\\Users\\alice' @@ -580,7 +582,7 @@ describe('CodexRuntimeHomeService', () => { vi.doUnmock('../codex/wsl-codex-session-bridge') vi.doUnmock('./legacy-wsl-runtime-auth-drain') vi.doUnmock('./wsl-codex-auth-batch-reader') - vi.doUnmock('../wsl') + vi.doUnmock('../wsl/discovery/distro-catalog') if (originalPlatform) { Object.defineProperty(process, 'platform', originalPlatform) } @@ -596,7 +598,7 @@ describe('CodexRuntimeHomeService', () => { 'system-refresh', 2_000 ) - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => 'C:\\Users\\alice', getWslHomeAsync: async () => 'C:\\Users\\alice' @@ -660,7 +662,7 @@ describe('CodexRuntimeHomeService', () => { vi.doUnmock('../codex/wsl-codex-session-bridge') vi.doUnmock('./legacy-wsl-runtime-auth-drain') vi.doUnmock('./wsl-codex-auth-batch-reader') - vi.doUnmock('../wsl') + vi.doUnmock('../wsl/discovery/distro-catalog') if (originalPlatform) { Object.defineProperty(process, 'platform', originalPlatform) } diff --git a/src/main/codex-accounts/runtime-home-wsl-passive-restore-prep.test.ts b/src/main/codex-accounts/runtime-home-wsl-passive-restore-prep.test.ts index 1daad0044fd..03d378f88fb 100644 --- a/src/main/codex-accounts/runtime-home-wsl-passive-restore-prep.test.ts +++ b/src/main/codex-accounts/runtime-home-wsl-passive-restore-prep.test.ts @@ -13,8 +13,8 @@ import { } from './runtime-home-service-test-harness' // The real rule: a stopped distro blocks, except for a user act on it. -vi.mock('../wsl/wsl-background-exec-gate', async () => { - const { isWslUserActFor, runAsWslUserAct } = await import('../wsl/wsl-user-act-scope') +vi.mock('../wsl/discovery/wsl-background-exec-gate', async () => { + const { isWslUserActFor, runAsWslUserAct } = await import('../wsl/discovery/wsl-user-act-scope') return { blockedWslDistroForExec: async (distro: string | null | undefined) => distro && !isWslUserActFor(distro) ? { distro, state: 'stopped' } : null, @@ -39,7 +39,7 @@ function wslMocks() { syncInstructions: vi.fn(), syncConfig: vi.fn() } - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: mocks.getWslHome, getWslHomeAsync: mocks.getWslHomeAsync @@ -129,7 +129,7 @@ describe('Codex launch prep for a stopped WSL distro', () => { it('the same launch as a user act warms the home off the main thread and drains', async () => { const mocks = wslMocks() const { CodexRuntimeHomeService } = await import('./runtime-home-service') - const { runAsWslExecUserAct } = await import('../wsl/wsl-background-exec-gate') + const { runAsWslExecUserAct } = await import('../wsl/discovery/wsl-background-exec-gate') // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the harness store implements the Store methods the runtime home service reads. const service = new CodexRuntimeHomeService(accountStore(true) as never) diff --git a/src/main/codex-accounts/runtime-home-wsl-session-bridge.test.ts b/src/main/codex-accounts/runtime-home-wsl-session-bridge.test.ts index 3d857a9a94f..ab624ce58af 100644 --- a/src/main/codex-accounts/runtime-home-wsl-session-bridge.test.ts +++ b/src/main/codex-accounts/runtime-home-wsl-session-bridge.test.ts @@ -19,7 +19,9 @@ import { } from './runtime-home-service-test-harness' // These launches are the user's own, so the E9 exec gate lets their prep run. -vi.mock('../wsl/wsl-background-exec-gate', () => ({ blockedWslDistroForExec: async () => null })) +vi.mock('../wsl/discovery/wsl-background-exec-gate', () => ({ + blockedWslDistroForExec: async () => null +})) vi.mock('electron', () => ({ app: { getPath: () => testState.userDataDir @@ -51,7 +53,7 @@ describe('CodexRuntimeHomeService', () => { startWslCodexSessionBridgeInBackground })) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome, getWslHomeAsync: async () => wslHome @@ -88,7 +90,7 @@ describe('CodexRuntimeHomeService', () => { expect(existsSync(join(wslRuntimeHomePath, 'AGENTS.md'))).toBe(false) } finally { vi.doUnmock('../codex/wsl-codex-session-bridge') - vi.doUnmock('../wsl') + vi.doUnmock('../wsl/discovery/distro-catalog') if (originalPlatform) { Object.defineProperty(process, 'platform', originalPlatform) } @@ -102,7 +104,7 @@ describe('CodexRuntimeHomeService', () => { startWslCodexSessionBridgeInBackground: vi.fn(() => Promise.resolve()) })) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome, getWslHomeAsync: async () => wslHome @@ -145,7 +147,7 @@ describe('CodexRuntimeHomeService', () => { expect(existsSync(baselinePath)).toBe(false) } finally { vi.doUnmock('../codex/wsl-codex-session-bridge') - vi.doUnmock('../wsl') + vi.doUnmock('../wsl/discovery/distro-catalog') if (originalPlatform) { Object.defineProperty(process, 'platform', originalPlatform) } @@ -160,7 +162,7 @@ describe('CodexRuntimeHomeService', () => { startWslCodexSessionBridgeInBackground })) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome, getWslHomeAsync: async () => wslHome @@ -186,7 +188,7 @@ describe('CodexRuntimeHomeService', () => { }) } finally { vi.doUnmock('../codex/wsl-codex-session-bridge') - vi.doUnmock('../wsl') + vi.doUnmock('../wsl/discovery/distro-catalog') if (originalPlatform) { Object.defineProperty(process, 'platform', originalPlatform) } @@ -201,7 +203,7 @@ describe('CodexRuntimeHomeService', () => { startWslCodexSessionBridgeInBackground })) const wslHome = join(testState.userDataDir, 'debian-wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => null, getWslHome: (distro: string) => (distro === 'Debian' ? wslHome : null), getWslHomeAsync: async (distro: string) => (distro === 'Debian' ? wslHome : null) @@ -261,7 +263,7 @@ describe('CodexRuntimeHomeService', () => { }) } finally { vi.doUnmock('../codex/wsl-codex-session-bridge') - vi.doUnmock('../wsl') + vi.doUnmock('../wsl/discovery/distro-catalog') vi.doUnmock('../../shared/wsl-paths') if (originalPlatform) { Object.defineProperty(process, 'platform', originalPlatform) @@ -277,7 +279,7 @@ describe('CodexRuntimeHomeService', () => { startWslCodexSessionBridgeInBackground })) const wslHome = join(testState.userDataDir, 'ubuntu-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome, getWslHomeAsync: async () => wslHome @@ -336,7 +338,7 @@ describe('CodexRuntimeHomeService', () => { } finally { vi.doUnmock('./legacy-wsl-runtime-auth-drain') vi.doUnmock('../codex/wsl-codex-session-bridge') - vi.doUnmock('../wsl') + vi.doUnmock('../wsl/discovery/distro-catalog') if (originalPlatform) { Object.defineProperty(process, 'platform', originalPlatform) } @@ -350,7 +352,7 @@ describe('CodexRuntimeHomeService', () => { Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) const guestHome = join(testState.userDataDir, 'ubuntu-home') const wslHome = `\\\\wsl.localhost\\Ubuntu${guestHome.replaceAll('/', '\\')}` - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome, getWslHomeAsync: async () => wslHome @@ -384,7 +386,7 @@ describe('CodexRuntimeHomeService', () => { ) })) const drainTasks: Promise[] = [] - vi.doMock('../wsl/wsl-runner', () => ({ + vi.doMock('../wsl/execution/wsl-runner', () => ({ runWslProcess: vi.fn( async (options: { args?: string[]; script: string; shell?: 'bash' }) => { try { @@ -514,8 +516,8 @@ describe('CodexRuntimeHomeService', () => { vi.doUnmock('../codex/codex-home-paths') vi.doUnmock('./legacy-wsl-runtime-auth-drain') vi.doUnmock('./wsl-codex-auth-batch-reader') - vi.doUnmock('../wsl/wsl-runner') - vi.doUnmock('../wsl') + vi.doUnmock('../wsl/execution/wsl-runner') + vi.doUnmock('../wsl/discovery/distro-catalog') if (originalPlatform) { Object.defineProperty(process, 'platform', originalPlatform) } diff --git a/src/main/codex-accounts/runtime-home-wsl-sibling-bridge.test.ts b/src/main/codex-accounts/runtime-home-wsl-sibling-bridge.test.ts index 424102ce789..6ea745edc18 100644 --- a/src/main/codex-accounts/runtime-home-wsl-sibling-bridge.test.ts +++ b/src/main/codex-accounts/runtime-home-wsl-sibling-bridge.test.ts @@ -31,7 +31,7 @@ vi.mock('../codex/wsl-codex-session-bridge', () => ({ })) let wslHome = '' -vi.mock('../wsl', () => ({ +vi.mock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome })) diff --git a/src/main/codex-accounts/runtime-home-wsl-system-default.test.ts b/src/main/codex-accounts/runtime-home-wsl-system-default.test.ts index ad177f2e199..242ac117055 100644 --- a/src/main/codex-accounts/runtime-home-wsl-system-default.test.ts +++ b/src/main/codex-accounts/runtime-home-wsl-system-default.test.ts @@ -39,7 +39,7 @@ describe('CodexRuntimeHomeService', () => { const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome })) @@ -75,7 +75,7 @@ describe('CodexRuntimeHomeService', () => { const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome })) @@ -142,7 +142,7 @@ describe('CodexRuntimeHomeService', () => { const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome })) @@ -213,7 +213,7 @@ describe('CodexRuntimeHomeService', () => { const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome })) @@ -254,7 +254,7 @@ describe('CodexRuntimeHomeService', () => { const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) const wslHome = join(testState.userDataDir, 'wsl-home') - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => wslHome })) @@ -303,7 +303,7 @@ describe('CodexRuntimeHomeService', () => { it('passes the Linux source config directory for mounted-drive WSL homes', async () => { const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) - vi.doMock('../wsl', () => ({ + vi.doMock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu', getWslHome: () => 'C:\\Users\\alice' })) diff --git a/src/main/codex-accounts/service-wsl-accounts.test.ts b/src/main/codex-accounts/service-wsl-accounts.test.ts index 5caa160a23c..ba4f2f192c7 100644 --- a/src/main/codex-accounts/service-wsl-accounts.test.ts +++ b/src/main/codex-accounts/service-wsl-accounts.test.ts @@ -13,7 +13,7 @@ import { registerCodexAccountsTestHomes, testState } from './service-test-harness' -import type { WslSpec } from '../wsl/wsl-runner' +import type { WslSpec } from '../wsl/execution/wsl-runner' import { withOwnershipCheck, wslFailed, wslOk } from './service-wsl-test-results' // Keep asserted config bytes independent of platform socket-path limits. @@ -67,13 +67,7 @@ describe('CodexAccountService config sync', () => { return { distro: 'Ubuntu', linuxPath: wslLinuxCanonicalHomePath } } return null - } - })) - // The distro runs: the config mirror may read its home. - vi.doMock('../wsl-background-distro-gate', () => ({ - wasWslDistroLastSeenRunningSettled: () => true - })) - vi.doMock('../wsl', () => ({ + }, toWindowsWslPath: (linuxPath: string) => linuxPath === wslLinuxCanonicalHomePath || linuxPath === `${wslLinuxCanonicalHomePath}/config.toml` @@ -82,6 +76,10 @@ describe('CodexAccountService config sync', () => { : wslCanonicalHomePath : wslManagedHomePath })) + // The distro runs: the config mirror may read its home. + vi.doMock('../wsl/discovery/wsl-background-distro-gate', () => ({ + wasWslDistroLastSeenRunningSettled: () => true + })) const settings = createSettings({ codexManagedAccounts: [ @@ -131,7 +129,7 @@ describe('CodexAccountService config sync', () => { writeFileSync(wslCanonicalConfigPath, 'model_instructions_file = "instructions.md"\n', 'utf-8') vi.doMock('node:child_process', () => ({ execFileSync: vi.fn(), spawn: vi.fn() })) - vi.doMock('../wsl/wsl-runner', () => ({ + vi.doMock('../wsl/execution/wsl-runner', () => ({ runWslProcess: withOwnershipCheck( () => wslLinuxHomePath, async () => wslOk() @@ -139,13 +137,7 @@ describe('CodexAccountService config sync', () => { })) vi.doMock('../../shared/wsl-paths', () => ({ parseWslUncPath: (path: string) => - path === wslManagedHomePath ? { distro: 'Ubuntu', linuxPath: wslLinuxHomePath } : null - })) - // The distro runs: the config mirror may read its home. - vi.doMock('../wsl-background-distro-gate', () => ({ - wasWslDistroLastSeenRunningSettled: () => true - })) - vi.doMock('../wsl', () => ({ + path === wslManagedHomePath ? { distro: 'Ubuntu', linuxPath: wslLinuxHomePath } : null, toWindowsWslPath: (linuxPath: string) => linuxPath.endsWith('/config.toml') ? wslCanonicalConfigPath @@ -153,6 +145,10 @@ describe('CodexAccountService config sync', () => { ? wslCanonicalHomePath : wslManagedHomePath })) + // The distro runs: the config mirror may read its home. + vi.doMock('../wsl/discovery/wsl-background-distro-gate', () => ({ + wasWslDistroLastSeenRunningSettled: () => true + })) const settings = createSettings({ codexManagedAccounts: [ @@ -274,7 +270,7 @@ describe('CodexAccountService config sync', () => { execFileSync: vi.fn(), spawn: spawnMock })) - vi.doMock('../wsl/wsl-runner', () => ({ + vi.doMock('../wsl/execution/wsl-runner', () => ({ runWslProcess: withOwnershipCheck(ownershipCheck, runWslProcessMock) })) vi.doMock('../../shared/wsl-paths', () => ({ @@ -283,13 +279,7 @@ describe('CodexAccountService config sync', () => { ? { distro: 'Debian', linuxPath: wslLinuxHomePath } : path === wslConfigHomePath ? { distro: 'Debian', linuxPath: '/home/alice/.codex' } - : null - })) - // The distro runs: the config mirror may read its home. - vi.doMock('../wsl-background-distro-gate', () => ({ - wasWslDistroLastSeenRunningSettled: () => true - })) - vi.doMock('../wsl', () => ({ + : null, toWindowsWslPath: (linuxPath: string) => linuxPath.endsWith('/.codex/config.toml') ? wslConfigPath @@ -297,6 +287,10 @@ describe('CodexAccountService config sync', () => { ? wslConfigHomePath : wslManagedHomePath })) + // The distro runs: the config mirror may read its home. + vi.doMock('../wsl/discovery/wsl-background-distro-gate', () => ({ + wasWslDistroLastSeenRunningSettled: () => true + })) const settings = createSettings() const store = createStore(settings) @@ -375,20 +369,18 @@ describe('CodexAccountService config sync', () => { execFileSync: vi.fn(), spawn: spawnMock })) - vi.doMock('../wsl/wsl-runner', () => ({ + vi.doMock('../wsl/execution/wsl-runner', () => ({ runWslProcess: withOwnershipCheck(ownershipCheck, runWslProcessMock) })) vi.doMock('../../shared/wsl-paths', () => ({ parseWslUncPath: (path: string) => - path === wslManagedHomePath ? { distro: 'Debian', linuxPath: wslLinuxHomePath } : null + path === wslManagedHomePath ? { distro: 'Debian', linuxPath: wslLinuxHomePath } : null, + toWindowsWslPath: () => wslManagedHomePath })) // The distro runs: the config mirror may read its home. - vi.doMock('../wsl-background-distro-gate', () => ({ + vi.doMock('../wsl/discovery/wsl-background-distro-gate', () => ({ wasWslDistroLastSeenRunningSettled: () => true })) - vi.doMock('../wsl', () => ({ - toWindowsWslPath: () => wslManagedHomePath - })) const settings = createSettings() const store = createStore(settings) @@ -455,20 +447,18 @@ describe('CodexAccountService config sync', () => { execFileSync: vi.fn(), spawn: spawnMock })) - vi.doMock('../wsl/wsl-runner', () => ({ + vi.doMock('../wsl/execution/wsl-runner', () => ({ runWslProcess: withOwnershipCheck(ownershipCheck, runWslProcessMock) })) vi.doMock('../../shared/wsl-paths', () => ({ parseWslUncPath: (path: string) => - path === wslManagedHomePath ? { distro: 'Debian', linuxPath: wslLinuxHomePath } : null + path === wslManagedHomePath ? { distro: 'Debian', linuxPath: wslLinuxHomePath } : null, + toWindowsWslPath: () => wslManagedHomePath })) // The distro runs: the config mirror may read its home. - vi.doMock('../wsl-background-distro-gate', () => ({ + vi.doMock('../wsl/discovery/wsl-background-distro-gate', () => ({ wasWslDistroLastSeenRunningSettled: () => true })) - vi.doMock('../wsl', () => ({ - toWindowsWslPath: () => wslManagedHomePath - })) const settings = createSettings() const store = createStore(settings) @@ -556,7 +546,7 @@ describe('CodexAccountService config sync', () => { execFileSync: vi.fn(), spawn: spawnMock })) - vi.doMock('../wsl/wsl-runner', () => ({ + vi.doMock('../wsl/execution/wsl-runner', () => ({ runWslProcess: withOwnershipCheck(ownershipCheck, runWslProcessMock) })) vi.doMock('../../shared/wsl-paths', () => ({ @@ -566,15 +556,13 @@ describe('CodexAccountService config sync', () => { distro: 'Ubuntu', linuxPath: `${wslLinuxHomePath}${path.slice(wslManagedHomePath.length).replaceAll('\\', '/')}` } - : null + : null, + toWindowsWslPath: () => wslManagedHomePath })) // The distro runs: the config mirror may read its home. - vi.doMock('../wsl-background-distro-gate', () => ({ + vi.doMock('../wsl/discovery/wsl-background-distro-gate', () => ({ wasWslDistroLastSeenRunningSettled: () => true })) - vi.doMock('../wsl', () => ({ - toWindowsWslPath: () => wslManagedHomePath - })) const settings = createSettings({ codexManagedAccounts: [ @@ -699,7 +687,7 @@ describe('CodexAccountService config sync', () => { execFileSync: vi.fn(), spawn: spawnMock })) - vi.doMock('../wsl/wsl-runner', () => ({ + vi.doMock('../wsl/execution/wsl-runner', () => ({ runWslProcess: withOwnershipCheck(ownershipCheck, runWslProcessMock) })) vi.doMock('../../shared/wsl-paths', () => ({ @@ -709,15 +697,13 @@ describe('CodexAccountService config sync', () => { distro: 'Ubuntu', linuxPath: `${wslLinuxHomePath}${path.slice(wslManagedHomePath.length).replaceAll('\\', '/')}` } - : null + : null, + toWindowsWslPath: () => wslManagedHomePath })) // The distro runs: the config mirror may read its home. - vi.doMock('../wsl-background-distro-gate', () => ({ + vi.doMock('../wsl/discovery/wsl-background-distro-gate', () => ({ wasWslDistroLastSeenRunningSettled: () => true })) - vi.doMock('../wsl', () => ({ - toWindowsWslPath: () => wslManagedHomePath - })) const settings = createSettings({ codexManagedAccounts: [ @@ -784,7 +770,7 @@ describe('CodexAccountService config sync', () => { writeFileSync(join(wslManagedHomePath, '.orca-managed-home'), 'account-1\n', 'utf-8') vi.doMock('node:child_process', () => ({ execFileSync: vi.fn(), spawn: vi.fn() })) - vi.doMock('../wsl/wsl-runner', () => ({ + vi.doMock('../wsl/execution/wsl-runner', () => ({ runWslProcess: withOwnershipCheck( (_distro, script) => { expect(script).toContain("expected_marker='account-1'") @@ -801,15 +787,13 @@ describe('CodexAccountService config sync', () => { })) vi.doMock('../../shared/wsl-paths', () => ({ parseWslUncPath: (path: string) => - path === wslManagedHomePath ? { distro: 'Ubuntu', linuxPath: wslLinuxHomePath } : null + path === wslManagedHomePath ? { distro: 'Ubuntu', linuxPath: wslLinuxHomePath } : null, + toWindowsWslPath: () => wslManagedHomePath })) // The distro runs: the config mirror may read its home. - vi.doMock('../wsl-background-distro-gate', () => ({ + vi.doMock('../wsl/discovery/wsl-background-distro-gate', () => ({ wasWslDistroLastSeenRunningSettled: () => true })) - vi.doMock('../wsl', () => ({ - toWindowsWslPath: () => wslManagedHomePath - })) const settings = createSettings({ codexManagedAccounts: [ diff --git a/src/main/codex-accounts/service-wsl-test-results.ts b/src/main/codex-accounts/service-wsl-test-results.ts index 9b5cedfd305..cc1443fabf5 100644 --- a/src/main/codex-accounts/service-wsl-test-results.ts +++ b/src/main/codex-accounts/service-wsl-test-results.ts @@ -1,5 +1,5 @@ import { expect, vi } from 'vitest' -import type { WslResult, WslSpec } from '../wsl/wsl-runner' +import type { WslResult, WslSpec } from '../wsl/execution/wsl-runner' export function wslOk(stdout = ''): WslResult { return { environmentResolved: true, code: 0, stdout, stderr: '', timedOut: false } diff --git a/src/main/codex-accounts/wsl-codex-auth-batch-reader.ts b/src/main/codex-accounts/wsl-codex-auth-batch-reader.ts index 40870fcd5ef..53805c060b7 100644 --- a/src/main/codex-accounts/wsl-codex-auth-batch-reader.ts +++ b/src/main/codex-accounts/wsl-codex-auth-batch-reader.ts @@ -1,4 +1,4 @@ -import { runWslProcess } from '../wsl/wsl-runner' +import { runWslProcess } from '../wsl/execution/wsl-runner' export type WslCodexAuthRead = | { kind: 'missing' | 'unreadable' } diff --git a/src/main/codex/codex-hook-wsl-runtime.ts b/src/main/codex/codex-hook-wsl-runtime.ts index 79ac953de95..c5571208839 100644 --- a/src/main/codex/codex-hook-wsl-runtime.ts +++ b/src/main/codex/codex-hook-wsl-runtime.ts @@ -35,7 +35,7 @@ import type { CodexWslRuntimeHookInstallPlan, WslCanonicalPathSettlement } from './codex-wsl-hook-install-plan' -import { blockedWslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' /** True when touching the distro's `\\wsl.localhost` files now would start it (E9); a user act passes. */ export async function isWslHookDistroBlocked(distro: string): Promise { diff --git a/src/main/codex/codex-hook-wsl-stopped-distro.test.ts b/src/main/codex/codex-hook-wsl-stopped-distro.test.ts index e3c02ed0390..beda3b2227e 100644 --- a/src/main/codex/codex-hook-wsl-stopped-distro.test.ts +++ b/src/main/codex/codex-hook-wsl-stopped-distro.test.ts @@ -12,7 +12,7 @@ const mocks = vi.hoisted(() => ({ createPlan: vi.fn() })) -vi.mock('../wsl/wsl-unc-access-gate', async (importOriginal) => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', async (importOriginal) => ({ ...(await importOriginal>()), blockedWslDistroForPath: mocks.blocked })) diff --git a/src/main/codex/codex-runtime-home-launch-preparation.ts b/src/main/codex/codex-runtime-home-launch-preparation.ts index 5340a52e590..9e30d8a40e7 100644 --- a/src/main/codex/codex-runtime-home-launch-preparation.ts +++ b/src/main/codex/codex-runtime-home-launch-preparation.ts @@ -3,7 +3,7 @@ import type { CodexAccountSelectionTarget } from '../codex-accounts/runtime-sele import type { CodexRuntimeHomeService } from '../codex-accounts/runtime-home-service' import type { GlobalSettings } from '../../shared/global-settings-types' import { codexHookService } from './hook-service' -import { getDefaultWslDistro } from '../wsl' +import { getDefaultWslDistro } from '../wsl/discovery/distro-catalog' import { isAgentStatusHooksEnabledForAgent } from '../agent-hooks/managed-agent-hook-controls' import { reconcileCodexHooksForLaunch } from './codex-hook-reconcile' import { grantCodexSandboxReadOnManagedHome } from './codex-windows-sandbox-read-grant' diff --git a/src/main/codex/codex-session-index-heal.ts b/src/main/codex/codex-session-index-heal.ts index 0a6e8a70940..93c65c1b3c6 100644 --- a/src/main/codex/codex-session-index-heal.ts +++ b/src/main/codex/codex-session-index-heal.ts @@ -3,7 +3,7 @@ import { resolveCodexCommand } from '../codex-cli/command' import { isTransientSqliteContention } from '../sqlite/sqlite-read-failure' import { CODEX_SHORT_LIVED_PROBE_APP_SERVER_ARGS } from '../codex-cli/codex-read-only-app-server-args' import { buildWslCodexAppServerArgs } from '../codex-accounts/wsl-codex-command' -import { resolveWslExecutablePath } from '../wsl/wsl-executable-path' +import { resolveWslExecutablePath } from '../wsl/execution/wsl-executable-path' import { getCodexSessionBackfillStateDirPath } from './codex-home-paths' import { resolveCodexSessionBackfillPaths } from './codex-session-backfill' import { diff --git a/src/main/codex/codex-state-db-backfill-recovery-process.ts b/src/main/codex/codex-state-db-backfill-recovery-process.ts index cb68cc91235..ce7b0bb1dfb 100644 --- a/src/main/codex/codex-state-db-backfill-recovery-process.ts +++ b/src/main/codex/codex-state-db-backfill-recovery-process.ts @@ -11,7 +11,7 @@ import { import type { CodexAppServerSpawn } from './app-server/codex-app-server-process-tree-kill' import { stopSupervisedChildProcess } from '../provider-process/supervised-child-process-stop' import { guardSupervisedProviderGroup } from '../provider-process/provider-group-orphan-guard' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' +import { resolveWslInteropSpawnCwd } from '../wsl/execution/wsl-interop-spawn-directory' const BACKFILL_RECOVERY_KILL_SITE = 'codex-state-db-backfill-recovery' // Keep owner-death and explicit shutdown on the same stdin-drain policy. diff --git a/src/main/codex/codex-trust-grant-host.ts b/src/main/codex/codex-trust-grant-host.ts index 0f7314d416f..d735980854c 100644 --- a/src/main/codex/codex-trust-grant-host.ts +++ b/src/main/codex/codex-trust-grant-host.ts @@ -11,7 +11,7 @@ import { type CodexTrustGrantBinaryStamp, type CodexTrustGrantLedgerHome } from './codex-trust-grant-ledger' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' +import { resolveWslInteropSpawnCwd } from '../wsl/execution/wsl-interop-spawn-directory' // Allow cold-distro and login-shell startup while bounding launch preparation. const WSL_GRANT_TIMEOUT_MS = 30_000 diff --git a/src/main/codex/codex-wsl-hook-install-plan.test.ts b/src/main/codex/codex-wsl-hook-install-plan.test.ts index ec71e7c3347..53f0476ffd3 100644 --- a/src/main/codex/codex-wsl-hook-install-plan.test.ts +++ b/src/main/codex/codex-wsl-hook-install-plan.test.ts @@ -7,7 +7,7 @@ const { runProcessMock, blockedForExecMock } = vi.hoisted(() => ({ })) vi.mock('@orca/process-host', () => ({ runProcess: runProcessMock })) -vi.mock('../wsl/wsl-background-exec-gate', () => ({ +vi.mock('../wsl/discovery/wsl-background-exec-gate', () => ({ blockedWslDistroForExec: blockedForExecMock })) diff --git a/src/main/codex/codex-wsl-hook-install-plan.ts b/src/main/codex/codex-wsl-hook-install-plan.ts index 1bdf26f91d3..2fa529906f6 100644 --- a/src/main/codex/codex-wsl-hook-install-plan.ts +++ b/src/main/codex/codex-wsl-hook-install-plan.ts @@ -1,8 +1,8 @@ import { runProcess } from '@orca/process-host' import { posix as pathPosix, win32 as pathWin32 } from 'node:path' import { parseWslUncPath } from '../../shared/wsl-paths' -import { wslExeProcessSpec, wslExeStdout } from '../wsl-exe-process' -import { blockedWslDistroForExec } from '../wsl/wsl-background-exec-gate' +import { wslExeProcessSpec, wslExeStdout } from '../wsl/execution/wsl-exe-process' +import { blockedWslDistroForExec } from '../wsl/discovery/wsl-background-exec-gate' export type CodexWslRuntimeHookTarget = { runtime?: 'host' | 'wsl' diff --git a/src/main/codex/codex-wsl-hook-user-acts.test.ts b/src/main/codex/codex-wsl-hook-user-acts.test.ts index 1f22dc94cdf..e4ad336c0d8 100644 --- a/src/main/codex/codex-wsl-hook-user-acts.test.ts +++ b/src/main/codex/codex-wsl-hook-user-acts.test.ts @@ -16,12 +16,12 @@ vi.mock('./codex-hook-reconcile', () => ({ reconcileCodexHooksForLaunch: vi.fn() vi.mock('./codex-windows-sandbox-read-grant', () => ({ grantCodexSandboxReadOnManagedHome: vi.fn() })) -vi.mock('../wsl', async (importOriginal) => ({ +vi.mock('../wsl/discovery/distro-catalog', async (importOriginal) => ({ ...(await importOriginal>()), getDefaultWslDistro: () => 'Ubuntu' })) -import { isWslUserActFor } from '../wsl/wsl-user-act-scope' +import { isWslUserActFor } from '../wsl/discovery/wsl-user-act-scope' import { prepareManagedWslCodexHomeBeforeShellLaunch } from './managed-wsl-home-shell-preflight' import { createCodexRuntimeHomeLaunchPreparation } from './codex-runtime-home-launch-preparation' diff --git a/src/main/codex/managed-wsl-home-shell-preflight.ts b/src/main/codex/managed-wsl-home-shell-preflight.ts index 3de2085df7d..0e700b95af3 100644 --- a/src/main/codex/managed-wsl-home-shell-preflight.ts +++ b/src/main/codex/managed-wsl-home-shell-preflight.ts @@ -3,7 +3,7 @@ import type { AgentHookInstallStatus } from '../../shared/agent-hook-types' import { withTimeout } from '../../shared/promise-timeout-fallback' import type { CodexWslRuntimeHookTarget } from './codex-wsl-hook-install-plan' import { codexHookService } from './hook-service' -import { runAsWslUserAct } from '../wsl/wsl-unc-access-gate' +import { runAsWslUserAct } from '../wsl/filesystem/wsl-unc-access-gate' import { isAbsolutePosixPathWithoutDotSegments, resolveManagedWslCodexHome, diff --git a/src/main/codex/wsl-codex-session-bridge-index.test.ts b/src/main/codex/wsl-codex-session-bridge-index.test.ts index fe42db9e1d0..3fe6a1dbf5a 100644 --- a/src/main/codex/wsl-codex-session-bridge-index.test.ts +++ b/src/main/codex/wsl-codex-session-bridge-index.test.ts @@ -1,5 +1,5 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' -import type { WslResult, WslSpec } from '../wsl/wsl-runner' +import type { WslResult, WslSpec } from '../wsl/execution/wsl-runner' import type { createCodexAccountStateDb, healPendingCodexAccountThreads @@ -16,8 +16,10 @@ vi.mock('./app-server/codex-app-server-session', () => ({ })) // The E9 running check has its own cases; these cover the chain once the distro runs. -vi.mock('../wsl/wsl-unc-access-gate', () => ({ assertWslUncPathRunning: async () => {} })) -vi.mock('../wsl/wsl-runner', () => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', () => ({ + assertWslUncPathRunning: async () => {} +})) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) @@ -26,7 +28,7 @@ vi.mock('./codex-account-session-bridge', () => ({ })) import { _internals, startWslCodexSessionBridgeInBackground } from './wsl-codex-session-bridge' -import { noteWslDistroMayHaveStopped } from '../wsl-background-distro-gate' +import { noteWslDistroMayHaveStopped } from '../wsl/discovery/wsl-background-distro-gate' const MANAGED_HOME = '\\\\wsl.localhost\\Ubuntu\\home\\alice\\.local\\share\\orca\\codex-accounts\\a1\\home' diff --git a/src/main/codex/wsl-codex-session-bridge.test.ts b/src/main/codex/wsl-codex-session-bridge.test.ts index 4997f79d40c..9841dc91758 100644 --- a/src/main/codex/wsl-codex-session-bridge.test.ts +++ b/src/main/codex/wsl-codex-session-bridge.test.ts @@ -9,8 +9,10 @@ const { runWslProcessMock } = vi.hoisted(() => ({ })) // The E9 running check has its own cases; these cover the chain once the distro runs. -vi.mock('../wsl/wsl-unc-access-gate', () => ({ assertWslUncPathRunning: async () => {} })) -vi.mock('../wsl/wsl-runner', () => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', () => ({ + assertWslUncPathRunning: async () => {} +})) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) diff --git a/src/main/codex/wsl-codex-session-bridge.ts b/src/main/codex/wsl-codex-session-bridge.ts index c45b11bffdb..5f2a2258a6f 100644 --- a/src/main/codex/wsl-codex-session-bridge.ts +++ b/src/main/codex/wsl-codex-session-bridge.ts @@ -1,10 +1,10 @@ import { posix as pathPosix } from 'node:path' import { normalizeRuntimePathForComparison } from '../../shared/cross-platform-path' import { parseWslUncPath } from '../../shared/wsl-paths' -import { runWslProcess } from '../wsl/wsl-runner' -import { assertWslUncPathRunning } from '../wsl/wsl-unc-access-gate' -import type { onRunningWslDistrosStopped } from '../wsl-running-distro-cache' -import { onWslDistroGateNote } from '../wsl-background-distro-gate' +import { runWslProcess } from '../wsl/execution/wsl-runner' +import { assertWslUncPathRunning } from '../wsl/filesystem/wsl-unc-access-gate' +import type { onRunningWslDistrosStopped } from '../wsl/discovery/wsl-running-distro-cache' +import { onWslDistroGateNote } from '../wsl/discovery/wsl-background-distro-gate' import { isCodexAccountSessionBridgeStopping } from './codex-account-session-bridge' import { runCodexAppServerSession } from './app-server/codex-app-server-session' import { diff --git a/src/main/daemon/daemon-pty-adapter-wsl-distro-loss-relaunch.test.ts b/src/main/daemon/daemon-pty-adapter-wsl-distro-loss-relaunch.test.ts index d8c6f4434c2..f0b8c18a4a1 100644 --- a/src/main/daemon/daemon-pty-adapter-wsl-distro-loss-relaunch.test.ts +++ b/src/main/daemon/daemon-pty-adapter-wsl-distro-loss-relaunch.test.ts @@ -3,7 +3,7 @@ import './mock-descendant-sweep' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { join } from 'node:path' import { rmSync } from 'node:fs' -import type { WslRunningDistrosRead } from '../wsl-background-distro-gate' +import type { WslRunningDistrosRead } from '../wsl/discovery/wsl-background-distro-gate' import { DaemonPtyAdapter } from './daemon-pty-adapter' import type { DaemonPtyAdapterOptions } from './daemon-pty-runtime-state' import { DaemonServer } from './daemon-server' diff --git a/src/main/daemon/daemon-pty-adapter-wsl-distro-loss.test.ts b/src/main/daemon/daemon-pty-adapter-wsl-distro-loss.test.ts index b5522ece232..6fb97157854 100644 --- a/src/main/daemon/daemon-pty-adapter-wsl-distro-loss.test.ts +++ b/src/main/daemon/daemon-pty-adapter-wsl-distro-loss.test.ts @@ -3,7 +3,7 @@ import { mkdtempSync, rmSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it, onTestFinished, vi } from 'vitest' -import type { WslRunningDistrosRead } from '../wsl-background-distro-gate' +import type { WslRunningDistrosRead } from '../wsl/discovery/wsl-background-distro-gate' import type { DaemonPtyAdapter } from './daemon-pty-adapter' import type { DaemonServer } from './daemon-server' import { setActiveSink } from '../observability/tracer' diff --git a/src/main/daemon/daemon-pty-adapter-wsl-passive-restore-hold.test.ts b/src/main/daemon/daemon-pty-adapter-wsl-passive-restore-hold.test.ts index 8bb6a998279..4ff3c9b8540 100644 --- a/src/main/daemon/daemon-pty-adapter-wsl-passive-restore-hold.test.ts +++ b/src/main/daemon/daemon-pty-adapter-wsl-passive-restore-hold.test.ts @@ -1,7 +1,7 @@ import './mock-descendant-sweep' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { rmSync } from 'node:fs' -import type * as DistroGate from '../wsl-background-distro-gate' +import type * as DistroGate from '../wsl/discovery/wsl-background-distro-gate' import type { DaemonServer } from './daemon-server' import type { DaemonPtyAdapter } from './daemon-pty-adapter' import { createMockSubprocess, startDaemonAdapterHarness } from './daemon-pty-adapter-test-harness' @@ -13,7 +13,7 @@ const readState = vi.hoisted(() => 'stopped' ) ) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: readState })) diff --git a/src/main/daemon/daemon-pty-session-spawn.ts b/src/main/daemon/daemon-pty-session-spawn.ts index 7bf3d21764a..98f332f0742 100644 --- a/src/main/daemon/daemon-pty-session-spawn.ts +++ b/src/main/daemon/daemon-pty-session-spawn.ts @@ -24,7 +24,7 @@ import { injectWslFishHistoryEnv, logHistoryInjection } from '../pty/history/terminal-history' -import { addWslEnvKeys } from '../wsl-env' +import { addWslEnvKeys } from '../../shared/wsl-env' import { holdPassiveRestoreOfStoppedWslDistro } from './daemon-wsl-passive-restore-hold' export abstract class DaemonPtySessionSpawn extends DaemonPtySpawnResult { diff --git a/src/main/daemon/daemon-wsl-bridge-boot-identity.ts b/src/main/daemon/daemon-wsl-bridge-boot-identity.ts index dcbcc46412a..5313478b22f 100644 --- a/src/main/daemon/daemon-wsl-bridge-boot-identity.ts +++ b/src/main/daemon/daemon-wsl-bridge-boot-identity.ts @@ -6,9 +6,9 @@ import { isWslDistroRunningForBackgroundWork, noteWslDistroMayHaveStopped -} from '../wsl-background-distro-gate' -import { onRunningWslDistrosStopped } from '../wsl-running-distro-cache' -import { readWslDistroBootId } from '../wsl/wsl-distro-boot-id' +} from '../wsl/discovery/wsl-background-distro-gate' +import { onRunningWslDistrosStopped } from '../wsl/discovery/wsl-running-distro-cache' +import { readWslDistroBootId } from '../wsl/discovery/wsl-distro-boot-id' export type WslBridgeBootIdentityDeps = { isRunning: (distro: string) => Promise diff --git a/src/main/daemon/daemon-wsl-bridge-exit-no-boot.test.ts b/src/main/daemon/daemon-wsl-bridge-exit-no-boot.test.ts index 244677a0b5c..c7a8024ccbf 100644 --- a/src/main/daemon/daemon-wsl-bridge-exit-no-boot.test.ts +++ b/src/main/daemon/daemon-wsl-bridge-exit-no-boot.test.ts @@ -7,7 +7,7 @@ const wslMocks = vi.hoisted(() => ({ vi.fn<(options?: { requireConfirmed?: boolean; startedAfter?: number }) => Promise>(), listWslDistrosAsync: vi.fn<() => Promise>() })) -vi.mock('../wsl', () => wslMocks) +vi.mock('../wsl/discovery/distro-catalog', () => wslMocks) import { _resetWslBackgroundDistroGateForTests, @@ -15,11 +15,11 @@ import { noteWslDistroMayHaveStopped, readConfirmedRunningWslDistros, wasWslDistroLastSeenRunningSettled -} from '../wsl-background-distro-gate' +} from '../wsl/discovery/wsl-background-distro-gate' import { _resetRunningWslDistroCacheForTests, resolveRunningWslDistros -} from '../wsl-running-distro-cache' +} from '../wsl/discovery/wsl-running-distro-cache' import { PRODUCTION_WSL_BRIDGE_BOOT_IDENTITY_DEPS, WslBridgeBootIdentity diff --git a/src/main/daemon/daemon-wsl-bridge-exit.test.ts b/src/main/daemon/daemon-wsl-bridge-exit.test.ts index c82a3940270..6722cc0a2e5 100644 --- a/src/main/daemon/daemon-wsl-bridge-exit.test.ts +++ b/src/main/daemon/daemon-wsl-bridge-exit.test.ts @@ -1,9 +1,9 @@ import { afterEach, describe, expect, it, vi } from 'vitest' -import type { WslRunningDistrosRead } from '../wsl-background-distro-gate' +import type { WslRunningDistrosRead } from '../wsl/discovery/wsl-background-distro-gate' import { _resetRunningWslDistroCacheForTests, resolveRunningWslDistros -} from '../wsl-running-distro-cache' +} from '../wsl/discovery/wsl-running-distro-cache' import { checkWslBridgeDistro } from './daemon-wsl-bridge-exit' afterEach(() => { diff --git a/src/main/daemon/daemon-wsl-bridge-exit.ts b/src/main/daemon/daemon-wsl-bridge-exit.ts index 8627347baa3..cdece28cd02 100644 --- a/src/main/daemon/daemon-wsl-bridge-exit.ts +++ b/src/main/daemon/daemon-wsl-bridge-exit.ts @@ -9,7 +9,7 @@ import { readConfirmedRunningWslDistros, settledWslRunningReadAnchor, type WslRunningDistrosRead -} from '../wsl-background-distro-gate' +} from '../wsl/discovery/wsl-background-distro-gate' /** The code a synthetic host-loss exit carries, as after a daemon crash. */ export const WSL_DISTRO_LOSS_EXIT_CODE = -1 diff --git a/src/main/daemon/daemon-wsl-hold-read-anchor.test.ts b/src/main/daemon/daemon-wsl-hold-read-anchor.test.ts index e168a095d2d..6159efd90bb 100644 --- a/src/main/daemon/daemon-wsl-hold-read-anchor.test.ts +++ b/src/main/daemon/daemon-wsl-hold-read-anchor.test.ts @@ -1,13 +1,13 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as WslModule from '../wsl' +import type * as WslModule from '../wsl/discovery/distro-catalog' import { _resetWslBackgroundDistroGateForTests, noteWslDistroMayHaveStopped -} from '../wsl-background-distro-gate' +} from '../wsl/discovery/wsl-background-distro-gate' import { _resetRunningWslDistroCacheForTests, resolveRunningWslDistros -} from '../wsl-running-distro-cache' +} from '../wsl/discovery/wsl-running-distro-cache' import { parseWslDistroHold } from '../../shared/wsl-distro-stopped-hold' import { holdPassiveRestoreOfStoppedWslDistro, @@ -20,7 +20,7 @@ const running = vi.hoisted(() => { return value }) const probe = vi.hoisted(() => vi.fn(async () => [...running.distros])) -vi.mock('../wsl', async (importOriginal) => ({ +vi.mock('../wsl/discovery/distro-catalog', async (importOriginal) => ({ ...(await importOriginal()), listRunningWslDistrosAsync: (options: Parameters[1]) => resolveRunningWslDistros(probe, options) diff --git a/src/main/daemon/daemon-wsl-passive-restore-hold.ts b/src/main/daemon/daemon-wsl-passive-restore-hold.ts index 794593bcebd..db6116df28e 100644 --- a/src/main/daemon/daemon-wsl-passive-restore-hold.ts +++ b/src/main/daemon/daemon-wsl-passive-restore-hold.ts @@ -1,4 +1,4 @@ -import { readWslDistroRunningState } from '../wsl-background-distro-gate' +import { readWslDistroRunningState } from '../wsl/discovery/wsl-background-distro-gate' import { wslDistroHoldMessage } from '../../shared/wsl-distro-stopped-hold' import type { PtySpawnOptions } from '../providers/pty-provider-contract' diff --git a/src/main/daemon/pty-subprocess/shell-launch-plan.ts b/src/main/daemon/pty-subprocess/shell-launch-plan.ts index b39d45e4e0f..5977f916736 100644 --- a/src/main/daemon/pty-subprocess/shell-launch-plan.ts +++ b/src/main/daemon/pty-subprocess/shell-launch-plan.ts @@ -32,8 +32,8 @@ import { } from '../../providers/windows-shell-args' import { resolveUnixShellPath } from '../../providers/local-pty/local-pty-executable-spawn' import { selectShellStartupFeatures } from '../../pty/shell-startup/shell-startup-features' -import { parseWslPath } from '../../wsl' -import { addWslEnvKeys } from '../../wsl-env' +import { parseWslPath } from '../../wsl/filesystem/unc-path-access' +import { addWslEnvKeys } from '../../../shared/wsl-env' import { recognizeAgentProcessFromCommandLine, type RecognizedAgentProcess diff --git a/src/main/daemon/terminal-host-wsl-context.test.ts b/src/main/daemon/terminal-host-wsl-context.test.ts index 998c21fd8c5..61586fd71dd 100644 --- a/src/main/daemon/terminal-host-wsl-context.test.ts +++ b/src/main/daemon/terminal-host-wsl-context.test.ts @@ -1,8 +1,8 @@ import './mock-descendant-sweep' import { afterEach, describe, expect, it, vi } from 'vitest' -import type * as WslModule from '../wsl' +import type * as WslModule from '../wsl/discovery/distro-catalog' -vi.mock('../wsl', async (importOriginal) => ({ +vi.mock('../wsl/discovery/distro-catalog', async (importOriginal) => ({ ...(await importOriginal()), getDefaultWslDistro: () => 'Ubuntu' })) diff --git a/src/main/daemon/wsl-session-context.ts b/src/main/daemon/wsl-session-context.ts index a594d6d9344..3aaf6134f72 100644 --- a/src/main/daemon/wsl-session-context.ts +++ b/src/main/daemon/wsl-session-context.ts @@ -1,6 +1,7 @@ import { splitWorktreeIdForFilesystem } from '../../shared/worktree/id' import { isWslShellName } from '../../shared/local-windows-terminal-runtime' -import { getDefaultWslDistro, parseWslPath } from '../wsl' +import { getDefaultWslDistro } from '../wsl/discovery/distro-catalog' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' import { parsePtySessionId } from '../../shared/pty-session-id-format' import { parseWslUncPath } from '../../shared/wsl-paths' diff --git a/src/main/filesystem/destination-serialized-local-rename.ts b/src/main/filesystem/destination-serialized-local-rename.ts index 076ed784770..8ecd9b345ec 100644 --- a/src/main/filesystem/destination-serialized-local-rename.ts +++ b/src/main/filesystem/destination-serialized-local-rename.ts @@ -1,7 +1,7 @@ import { realpath, rename } from 'node:fs/promises' import { dirname, normalize } from 'node:path' import { assertNoClobberRenameDestinationAvailable } from '../../shared/filesystem-rename-collision' -import { windowsFsPath } from '../wsl/wsl-unc-drive-fs-path' +import { windowsFsPath } from '../wsl/filesystem/wsl-unc-drive-fs-path' // Parent-scoped serialization covers Unicode aliases without guessing filesystem collation. const pendingRenamesByParent = new Map>() diff --git a/src/main/git/command-runner/default-wsl-cli-fallback.ts b/src/main/git/command-runner/default-wsl-cli-fallback.ts index fcf715db484..a963602813c 100644 --- a/src/main/git/command-runner/default-wsl-cli-fallback.ts +++ b/src/main/git/command-runner/default-wsl-cli-fallback.ts @@ -1,9 +1,9 @@ -import { blockedWslDistroForExec } from '../../wsl/wsl-background-exec-gate' +import { blockedWslDistroForExec } from '../../wsl/discovery/wsl-background-exec-gate' import { runAsWslUserAct, WslDistroStoppedError, WslDistroUnverifiableError -} from '../../wsl/wsl-unc-access-gate' +} from '../../wsl/filesystem/wsl-unc-access-gate' import { defaultWslCliDistro, resolveDefaultWslCli, diff --git a/src/main/git/command-runner/git-process-env.ts b/src/main/git/command-runner/git-process-env.ts index eee838cf2b6..1cd361783a1 100644 --- a/src/main/git/command-runner/git-process-env.ts +++ b/src/main/git/command-runner/git-process-env.ts @@ -1,4 +1,4 @@ -import { addWslEnvKeys } from '../../wsl-env' +import { addWslEnvKeys } from '../../../shared/wsl-env' import { appendGitConfigEnv, gitCredentialPromptGuardEnv diff --git a/src/main/git/command-runner/git-ssh-policy-env.ts b/src/main/git/command-runner/git-ssh-policy-env.ts index dc863eaed76..dfdcd035483 100644 --- a/src/main/git/command-runner/git-ssh-policy-env.ts +++ b/src/main/git/command-runner/git-ssh-policy-env.ts @@ -1,4 +1,4 @@ -import { addWslEnvKeys } from '../../wsl-env' +import { addWslEnvKeys } from '../../../shared/wsl-env' import { buildGitSshPolicyEnv, GIT_SSH_CONFIG_ARGS, diff --git a/src/main/git/command-runner/glab-exec-file.ts b/src/main/git/command-runner/glab-exec-file.ts index f7b57478463..088064440a3 100644 --- a/src/main/git/command-runner/glab-exec-file.ts +++ b/src/main/git/command-runner/glab-exec-file.ts @@ -1,4 +1,4 @@ -import { addWslEnvKeys } from '../../wsl-env' +import { addWslEnvKeys } from '../../../shared/wsl-env' import { extractExecError, parseRetryAfterMs } from '../exec-error' import { resolveCommand } from './wsl-command-resolution' import { resolveDefaultWslCliFallback } from './default-wsl-cli-fallback' diff --git a/src/main/git/command-runner/local-git-runtime-route.ts b/src/main/git/command-runner/local-git-runtime-route.ts index 9dcfcd3f1ee..5e9b0383851 100644 --- a/src/main/git/command-runner/local-git-runtime-route.ts +++ b/src/main/git/command-runner/local-git-runtime-route.ts @@ -4,7 +4,7 @@ * two on one checkout is what lets one Git prune the other's worktrees (risk R36). A UNC cwd already * names its distro; a caller that must run the host's Git anyway says so with `hostGit: true`. */ -import { isWslDistroNotFoundFailure } from '../../wsl/wsl-distro-unsupported' +import { isWslDistroNotFoundFailure } from '../../wsl/discovery/wsl-distro-unsupported' import type { GitAdmissionTier } from './git-exec-options' type RoutableGitOptions = { diff --git a/src/main/git/command-runner/wsl-command-resolution-allowlist.test.ts b/src/main/git/command-runner/wsl-command-resolution-allowlist.test.ts index fbcf75397b3..feefc6d5ad8 100644 --- a/src/main/git/command-runner/wsl-command-resolution-allowlist.test.ts +++ b/src/main/git/command-runner/wsl-command-resolution-allowlist.test.ts @@ -10,7 +10,9 @@ vi.mock('node:child_process', async (original) => ({ spawn: spawnMock, execFileSync: execFileSyncMock })) -vi.mock('../../wsl-background-distro-gate', () => ({ noteWslDistroLaunched: vi.fn() })) +vi.mock('../../wsl/discovery/wsl-background-distro-gate', () => ({ + noteWslDistroLaunched: vi.fn() +})) import { resolveCommand } from './wsl-command-resolution' import { gitExecFileSync } from './git-exec-file-sync' diff --git a/src/main/git/command-runner/wsl-command-resolution.ts b/src/main/git/command-runner/wsl-command-resolution.ts index aee44d5d2ca..16d55f8d68f 100644 --- a/src/main/git/command-runner/wsl-command-resolution.ts +++ b/src/main/git/command-runner/wsl-command-resolution.ts @@ -1,5 +1,7 @@ import { assertWslDistroAllowed } from '@orca/process-host/wsl-distro-allowlist' -import { getDefaultWslDistro, parseWslPath, type WslPathInfo } from '../../wsl' +import { getDefaultWslDistro } from '../../wsl/discovery/distro-catalog' +import { parseWslPath } from '../../wsl/filesystem/unc-path-access' +import type { WslUncPathInfo as WslPathInfo } from '../../../shared/wsl-paths' import { buildWslCapturedLoginShellCommand, buildWslExecArgs, @@ -14,8 +16,8 @@ import { type WslProcessGroupTermination } from '../wsl-process-group-termination' import { translateArgForWsl, translateArgsForWsl } from './wsl-path-translation' -import { resolveWslInteropSpawnCwd } from '../../wsl-interop-spawn-directory' -import { noteWslDistroLaunched } from '../../wsl-background-distro-gate' +import { resolveWslInteropSpawnCwd } from '../../wsl/execution/wsl-interop-spawn-directory' +import { noteWslDistroLaunched } from '../../wsl/discovery/wsl-background-distro-gate' // Carry Git locale pins in the WSL command; these assignment values are shell-safe. const GIT_OUTPUT_LOCALE_SHELL_PREFIX = Object.entries(UNTRANSLATED_GIT_OUTPUT_ENV) diff --git a/src/main/git/command-runner/wsl-host-failure.ts b/src/main/git/command-runner/wsl-host-failure.ts index b240069994e..6fac413652c 100644 --- a/src/main/git/command-runner/wsl-host-failure.ts +++ b/src/main/git/command-runner/wsl-host-failure.ts @@ -1,4 +1,7 @@ -import { isWslHostFailureExitCode, readWslHostDiagnostic } from '../../wsl/wsl-process-failure' +import { + isWslHostFailureExitCode, + readWslHostDiagnostic +} from '../../wsl/execution/wsl-process-failure' import type { ResolvedCommand } from './wsl-command-resolution' function outputText(value: unknown): string { diff --git a/src/main/git/command-runner/wsl-path-translation.ts b/src/main/git/command-runner/wsl-path-translation.ts index 3ebfdda8d30..5538e91aa36 100644 --- a/src/main/git/command-runner/wsl-path-translation.ts +++ b/src/main/git/command-runner/wsl-path-translation.ts @@ -1,5 +1,5 @@ -import { isDrvfsLinuxPath, toWindowsWslUncPath } from '../../../shared/wsl-paths' -import { parseWslPath, toWindowsWslPath } from '../../wsl' +import { isDrvfsLinuxPath, toWindowsWslPath, toWindowsWslUncPath } from '../../../shared/wsl-paths' +import { parseWslPath } from '../../wsl/filesystem/unc-path-access' /** Windows arguments need Linux spellings for WSL Git: UNC paths become native and drives map under /mnt. */ export function translateArgsForWsl(args: string[]): string[] { diff --git a/src/main/git/default-wsl-cli-fallback-gate.test.ts b/src/main/git/default-wsl-cli-fallback-gate.test.ts index 8e41b958b56..e5c6f1fc7fa 100644 --- a/src/main/git/default-wsl-cli-fallback-gate.test.ts +++ b/src/main/git/default-wsl-cli-fallback-gate.test.ts @@ -2,8 +2,8 @@ // background work (rate limits, auth status, Settings, task-source probes). import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { fakeSpawnReturning } from '../../shared/__fixtures__/fake-spawned-child' -import type * as WslModule from '../wsl' -import type * as BackgroundDistroGate from '../wsl-background-distro-gate' +import type * as WslModule from '../wsl/discovery/distro-catalog' +import type * as BackgroundDistroGate from '../wsl/discovery/wsl-background-distro-gate' const { spawnMock, getDefaultWslDistroMock, readWslDistroRunningStateMock } = vi.hoisted(() => ({ spawnMock: vi.fn(), @@ -17,20 +17,23 @@ vi.mock('child_process', () => ({ spawn: spawnMock })) -vi.mock('../wsl', async (importOriginal) => ({ +vi.mock('../wsl/discovery/distro-catalog', async (importOriginal) => ({ ...(await importOriginal()), getDefaultWslDistro: getDefaultWslDistroMock })) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: readWslDistroRunningStateMock })) import { ghExecFileAsync, glabExecFileAsync, setDefaultWslDistroOverride } from './runner' import { _resetGhRateLimitBreaker } from './gh-rate-limit-breaker' -import { runAsWslExecUserAct } from '../wsl/wsl-background-exec-gate' -import { WslDistroStoppedError, WslDistroUnverifiableError } from '../wsl/wsl-unc-access-gate' +import { runAsWslExecUserAct } from '../wsl/discovery/wsl-background-exec-gate' +import { + WslDistroStoppedError, + WslDistroUnverifiableError +} from '../wsl/filesystem/wsl-unc-access-gate' import { starOrca } from '../github/client/fetch/orca-star' const originalPlatform = process.platform diff --git a/src/main/git/local-git-object-quarantine.ts b/src/main/git/local-git-object-quarantine.ts index e613ec87e9c..13dfaa24f0c 100644 --- a/src/main/git/local-git-object-quarantine.ts +++ b/src/main/git/local-git-object-quarantine.ts @@ -7,7 +7,7 @@ import { type GitObjectsDirectory } from '../../shared/git-object-quarantine' import { toLinuxPath, toWindowsWslPath } from '../../shared/wsl-paths' -import { parseWslPath } from '../wsl' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' import { usesHostGitForWslLinkedWorktree } from './wsl-linked-worktree-git-routing' import { readRepoCommonDirFromGit } from './worktree-list-reader' diff --git a/src/main/git/local-repo-ref-maintenance-wsl-stopped.test.ts b/src/main/git/local-repo-ref-maintenance-wsl-stopped.test.ts index 9020ae471e0..0acc7c715aa 100644 --- a/src/main/git/local-repo-ref-maintenance-wsl-stopped.test.ts +++ b/src/main/git/local-repo-ref-maintenance-wsl-stopped.test.ts @@ -1,8 +1,11 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type * as GitRunner from './runner' -import type * as WslUncAccessGate from '../wsl/wsl-unc-access-gate' +import type * as WslUncAccessGate from '../wsl/filesystem/wsl-unc-access-gate' import { RepoRefMaintenance } from '../../shared/repo-ref-maintenance' -import { WslDistroStoppedError, WslDistroUnverifiableError } from '../wsl/wsl-unc-access-gate' +import { + WslDistroStoppedError, + WslDistroUnverifiableError +} from '../wsl/filesystem/wsl-unc-access-gate' const mocks = vi.hoisted(() => ({ gitExecFileAsync: vi.fn(), @@ -12,7 +15,7 @@ vi.mock('./runner', async (importOriginal) => ({ ...(await importOriginal()), gitExecFileAsync: mocks.gitExecFileAsync })) -vi.mock('../wsl/wsl-unc-access-gate', async (importOriginal) => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', async (importOriginal) => ({ ...(await importOriginal()), assertWslUncPathRunning: mocks.assertWslUncPathRunning, // Off Windows no path maps to a distro; stand in for the WSL repo's UNC root. diff --git a/src/main/git/local-repo-ref-maintenance.ts b/src/main/git/local-repo-ref-maintenance.ts index c2868c490ec..b61612dadc2 100644 --- a/src/main/git/local-repo-ref-maintenance.ts +++ b/src/main/git/local-repo-ref-maintenance.ts @@ -18,7 +18,7 @@ import { maintainRepoPackIndex } from './repo-pack-index-maintenance' import { gitExecFileAsync } from './runner' -import { assertWslUncPathRunning, wslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { assertWslUncPathRunning, wslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' import { readRepoCommonDirFromGit } from './worktree-list-reader' // Maintain native/WSL repos locally; SSH maintenance belongs on its execution host. diff --git a/src/main/git/repo-detection.ts b/src/main/git/repo-detection.ts index 08fe18e9827..4bcce65db90 100644 --- a/src/main/git/repo-detection.ts +++ b/src/main/git/repo-detection.ts @@ -1,8 +1,7 @@ import { existsSync, statSync } from 'node:fs' import { basename, dirname, resolve } from 'node:path' import { normalizeRuntimePathSeparators } from '../../shared/cross-platform-path' -import { parseWslUncPath } from '../../shared/wsl-paths' -import { toWindowsWslPath } from '../wsl' +import { parseWslUncPath, toWindowsWslPath } from '../../shared/wsl-paths' import { scanGitMarkerSync, resolveRealPathSync } from './repo-git-marker-scan' import { gitRepoOutput, diff --git a/src/main/git/runner-wsl-gh-fallback.test.ts b/src/main/git/runner-wsl-gh-fallback.test.ts index bd9d5c43496..1a4b3a525ff 100644 --- a/src/main/git/runner-wsl-gh-fallback.test.ts +++ b/src/main/git/runner-wsl-gh-fallback.test.ts @@ -1,11 +1,11 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as BackgroundDistroGate from '../wsl-background-distro-gate' +import type * as BackgroundDistroGate from '../wsl/discovery/wsl-background-distro-gate' import { createFakeSpawnedChild, fakeSpawnDispatch, fakeSpawnReturning } from '../../shared/__fixtures__/fake-spawned-child' -import type * as WslModule from '../wsl' +import type * as WslModule from '../wsl/discovery/distro-catalog' import { windowsSystem32Binary } from '@orca/process-host/windows-system-binary' const { execFileSyncMock, spawnMock, getDefaultWslDistroMock } = vi.hoisted(() => ({ @@ -15,7 +15,7 @@ const { execFileSyncMock, spawnMock, getDefaultWslDistroMock } = vi.hoisted(() = })) // The default-distro fallback asks whether the distro runs before it may start it (E9). -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: vi.fn(async () => 'running') })) @@ -26,7 +26,7 @@ vi.mock('child_process', () => ({ spawn: spawnMock })) -vi.mock('../wsl', async (importOriginal) => ({ +vi.mock('../wsl/discovery/distro-catalog', async (importOriginal) => ({ ...(await importOriginal()), getDefaultWslDistro: getDefaultWslDistroMock })) diff --git a/src/main/git/runner-wsl-linked-gitdir-windows.test.ts b/src/main/git/runner-wsl-linked-gitdir-windows.test.ts index 18ebe1878ba..c3d77c1d7cd 100644 --- a/src/main/git/runner-wsl-linked-gitdir-windows.test.ts +++ b/src/main/git/runner-wsl-linked-gitdir-windows.test.ts @@ -2,13 +2,8 @@ import { execFileSync } from 'node:child_process' import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' import { join } from 'node:path' import { afterEach, describe, expect, it } from 'vitest' -import { - gitExecFileAsync, - gitExecFileAsyncBuffer, - gitStreamStdout, - toLinuxPath, - toWindowsWslPath -} from './runner' +import { gitExecFileAsync, gitExecFileAsyncBuffer, gitStreamStdout } from './runner' +import { toLinuxPath, toWindowsWslPath } from '../../shared/wsl-paths' import { listWorktrees } from './worktree' import { resetWslLinkedWorktreeGitRoutingForTests } from './wsl-linked-worktree-git-routing' diff --git a/src/main/git/runner.ts b/src/main/git/runner.ts index 857bce55439..a3fcbf5f741 100644 --- a/src/main/git/runner.ts +++ b/src/main/git/runner.ts @@ -32,5 +32,3 @@ export { ghExecFileAsync, ghExecFileWithScopeAsync } from './command-runner/gh-e export { glabExecFileAsync, redirectPortedHostnameToEnv } from './command-runner/glab-exec-file' export { wslAwareSpawn } from './command-runner/wsl-aware-spawn' export { translateWslOutputPaths } from './command-runner/wsl-path-translation' - -export { parseWslPath, toLinuxPath, toWindowsWslPath, isWslPath } from '../wsl' diff --git a/src/main/git/windows-worktree-removal.ts b/src/main/git/windows-worktree-removal.ts index 1079357bf99..78420b1c409 100644 --- a/src/main/git/windows-worktree-removal.ts +++ b/src/main/git/windows-worktree-removal.ts @@ -2,7 +2,7 @@ import { join, resolve } from 'node:path' import { readFile } from 'node:fs/promises' import { lstat, readdir } from '../filesystem/asar-transparent-fs' import { removeHostCheckout } from '../filesystem/host-tree-removal' -import { parseWslPath } from '../wsl' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' import { CLIENT_REMOVAL_HOME } from '../workspaces/removal/worktree-removal-home-guard' import { assertWorktreeUnlockedForRemoval, diff --git a/src/main/git/worktree-git-path.ts b/src/main/git/worktree-git-path.ts index 634a87f8643..db63870a9e3 100644 --- a/src/main/git/worktree-git-path.ts +++ b/src/main/git/worktree-git-path.ts @@ -7,7 +7,7 @@ import { readFileSync, statSync } from 'node:fs' import { join, resolve, win32 } from 'node:path' import { parseWslUncPath, toWindowsWslUncPath } from '../../shared/wsl-paths' -import { wslDrivePathUnderRoots } from '../wsl/wsl-automount-root' +import { wslDrivePathUnderRoots } from '../wsl/filesystem/wsl-automount-root' // Git keeps these per worktree; everything else under the git dir (`hooks/`, `info/`, `objects/`, // `refs/`, `config`, `packed-refs`, …) lives in the common dir, which only real Git resolves. diff --git a/src/main/git/worktree-removal.ts b/src/main/git/worktree-removal.ts index 2d69750a1a3..94d08c2441a 100644 --- a/src/main/git/worktree-removal.ts +++ b/src/main/git/worktree-removal.ts @@ -5,7 +5,7 @@ import { assertWorktreeUnlockedForRemoval } from '../../shared/worktree/removal' import { windowsLongPathGitArgs } from '../../shared/windows-long-path-git-args' import { removeHostTree } from '../filesystem/host-tree-removal' import { withSpan } from '../observability/tracer' -import { parseWslPath } from '../wsl' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' import { gitExecFileAsync } from './runner' import { runWithGitReadCacheInvalidation } from './status' import { deleteBranchAfterWorktreeRemoval } from './worktree-branch-removal' diff --git a/src/main/git/wsl-git-read-environment.ts b/src/main/git/wsl-git-read-environment.ts index 8b450759aea..6ae6df59f6c 100644 --- a/src/main/git/wsl-git-read-environment.ts +++ b/src/main/git/wsl-git-read-environment.ts @@ -4,7 +4,7 @@ import { buildWslCapturedLoginShellCommand, buildWslExecArgs } from '../../shared/wsl-login-shell-command' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' +import { resolveWslInteropSpawnCwd } from '../wsl/execution/wsl-interop-spawn-directory' export type WslGitReadEnvironment = { gitPath: string; home: string; path: string } diff --git a/src/main/git/wsl-process-group-termination.test.ts b/src/main/git/wsl-process-group-termination.test.ts index f0845c1d718..f50c9007eee 100644 --- a/src/main/git/wsl-process-group-termination.test.ts +++ b/src/main/git/wsl-process-group-termination.test.ts @@ -1,14 +1,14 @@ import type { ChildProcess } from 'node:child_process' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as BackgroundDistroGate from '../wsl-background-distro-gate' +import type * as BackgroundDistroGate from '../wsl/discovery/wsl-background-distro-gate' const { runWslProcessMock, readWslDistroRunningStateMock } = vi.hoisted(() => ({ runWslProcessMock: vi.fn(), readWslDistroRunningStateMock: vi.fn() })) -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: readWslDistroRunningStateMock })) diff --git a/src/main/git/wsl-process-group-termination.ts b/src/main/git/wsl-process-group-termination.ts index a20284ce9e8..2a45e7439b2 100644 --- a/src/main/git/wsl-process-group-termination.ts +++ b/src/main/git/wsl-process-group-termination.ts @@ -2,10 +2,10 @@ import { randomUUID } from 'node:crypto' import type { ProcessTerminationBarrier } from '@orca/process-host/process-spec' import { quotePosixShell } from '../../shared/shell-argument-quoting' -import { runWslProcess } from '../wsl/wsl-runner' -import { WSL_UNC_RUNNING_LEASE_MS, wslDistroForPath } from '../wsl/wsl-unc-access-gate' -import { isWslUserActFor } from '../wsl/wsl-user-act-scope' -import { readWslDistroRunningState } from '../wsl-background-distro-gate' +import { runWslProcess } from '../wsl/execution/wsl-runner' +import { WSL_UNC_RUNNING_LEASE_MS, wslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' +import { isWslUserActFor } from '../wsl/discovery/wsl-user-act-scope' +import { readWslDistroRunningState } from '../wsl/discovery/wsl-background-distro-gate' const GUEST_TERMINATION_ATTEMPTS = 40 const GUEST_TERMINATION_INTERVAL_SECONDS = '0.025' diff --git a/src/main/git/wsl-windows-checkout-git-probe.test.ts b/src/main/git/wsl-windows-checkout-git-probe.test.ts index 00c1300237b..662ced838ae 100644 --- a/src/main/git/wsl-windows-checkout-git-probe.test.ts +++ b/src/main/git/wsl-windows-checkout-git-probe.test.ts @@ -1,5 +1,5 @@ import { afterEach, describe, expect, it, vi } from 'vitest' -import type { WslResult } from '../wsl/wsl-runner' +import type { WslResult } from '../wsl/execution/wsl-runner' import { pendingWslWindowsCheckoutGitConfig, resetWslWindowsCheckoutProbesForTests, diff --git a/src/main/git/wsl-windows-checkout-git-probe.ts b/src/main/git/wsl-windows-checkout-git-probe.ts index d73c177c0bc..06ea1e71803 100644 --- a/src/main/git/wsl-windows-checkout-git-probe.ts +++ b/src/main/git/wsl-windows-checkout-git-probe.ts @@ -2,7 +2,7 @@ import { stat } from 'node:fs/promises' import { win32 } from 'node:path' import { runProcess } from '@orca/process-host' import { resolveSelectedLocalCommand } from '../ipc/command-path-resolver' -import { runWslProcess, type WslResult, type WslSpec } from '../wsl/wsl-runner' +import { runWslProcess, type WslResult, type WslSpec } from '../wsl/execution/wsl-runner' import { translateArgForWsl } from './command-runner/wsl-path-translation' import { acquireGitAdmission } from './command-runner/git-subprocess-admission' import { nonInteractiveGitEnv } from './command-runner/git-process-env' diff --git a/src/main/git/wsl-worktree-git-path.test.ts b/src/main/git/wsl-worktree-git-path.test.ts index 3bf671043f0..c388fce34cc 100644 --- a/src/main/git/wsl-worktree-git-path.test.ts +++ b/src/main/git/wsl-worktree-git-path.test.ts @@ -7,7 +7,7 @@ const { gitExecFileAsyncMock, readWorktreeGitPathMock } = vi.hoisted(() => ({ vi.mock('./command-runner/git-exec-file', () => ({ gitExecFileAsync: gitExecFileAsyncMock })) vi.mock('./worktree-git-path', () => ({ readWorktreeGitPath: readWorktreeGitPathMock })) -vi.mock('../wsl/wsl-automount-root', async (importOriginal) => ({ +vi.mock('../wsl/filesystem/wsl-automount-root', async (importOriginal) => ({ ...(await importOriginal()), knownWslAutomountRoots: () => ['/mnt/'] })) diff --git a/src/main/git/wsl-worktree-git-path.ts b/src/main/git/wsl-worktree-git-path.ts index d5f4c57ea9d..416e85ec2f9 100644 --- a/src/main/git/wsl-worktree-git-path.ts +++ b/src/main/git/wsl-worktree-git-path.ts @@ -1,6 +1,9 @@ import { win32 } from 'node:path' import { parseWslUncPath, toWindowsWslUncPath } from '../../shared/wsl-paths' -import { knownWslAutomountRoots, wslDrivePathUnderRoots } from '../wsl/wsl-automount-root' +import { + knownWslAutomountRoots, + wslDrivePathUnderRoots +} from '../wsl/filesystem/wsl-automount-root' import { gitExecFileAsync } from './command-runner/git-exec-file' import { readWorktreeGitPath } from './worktree-git-path' diff --git a/src/main/github/client/check/check-job-log-execution.ts b/src/main/github/client/check/check-job-log-execution.ts index ccc7c107873..1497dc4b705 100644 --- a/src/main/github/client/check/check-job-log-execution.ts +++ b/src/main/github/client/check/check-job-log-execution.ts @@ -1,5 +1,5 @@ import { normalizeGhAccountBinding } from '../../../../shared/github/account-binding' -import { parseWslPath } from '../../../wsl' +import { parseWslPath } from '../../../wsl/filesystem/unc-path-access' import { githubReadExecutionScope } from '../../github-read-execution-scope' import type { GitHubApiRepository } from '../../github-api-repository' import type { GhExecOptions } from '../github-exec-scope' diff --git a/src/main/github/client/check/check-job-log-routing.test.ts b/src/main/github/client/check/check-job-log-routing.test.ts index c9b37155563..fbf5aa79f6f 100644 --- a/src/main/github/client/check/check-job-log-routing.test.ts +++ b/src/main/github/client/check/check-job-log-routing.test.ts @@ -1,23 +1,23 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as BackgroundDistroGate from '../../../wsl-background-distro-gate' +import type * as BackgroundDistroGate from '../../../wsl/discovery/wsl-background-distro-gate' import { fakeSpawnDispatch, createFakeSpawnedChild } from '../../../../shared/__fixtures__/fake-spawned-child' -import type * as WslModule from '../../../wsl' +import type * as WslModule from '../../../wsl/discovery/distro-catalog' import { attachLogFixture, failedLogJob } from './check-job-log-test-fixture' import { startCheckJobLogDownload } from './check-job-log-download' import { prCheckLogTailCache } from './check-job-log-tails' import { setDefaultWslDistroOverride } from '../../../git/runner' const { spawnMock, distroMock } = vi.hoisted(() => ({ spawnMock: vi.fn(), distroMock: vi.fn() })) // The default-distro fallback asks whether the distro runs before it may start it (E9). -vi.mock('../../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: vi.fn(async () => 'running') })) vi.mock('node:child_process', async (original) => ({ ...(await original()), spawn: spawnMock })) -vi.mock('../../../wsl', async (original) => ({ +vi.mock('../../../wsl/discovery/distro-catalog', async (original) => ({ ...(await original()), getDefaultWslDistro: distroMock })) diff --git a/src/main/github/github-enterprise-repository.ts b/src/main/github/github-enterprise-repository.ts index f583e983c75..0d75c5903d6 100644 --- a/src/main/github/github-enterprise-repository.ts +++ b/src/main/github/github-enterprise-repository.ts @@ -18,7 +18,7 @@ import { gitHubSshConfigHostAlias } from './github-remote-identity-parsing' import { resolveSshConfigHostname } from './github-ssh-host-alias-resolution' -import { parseWslPath } from '../wsl' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' import { isStableMissingGitRemoteError } from '../git/stable-missing-git-remote-error' import { requireReachableGitRoute } from '../providers/execution-host-provider-dispatch' import { getConnectionExecutionHostId } from '../../shared/execution-host' diff --git a/src/main/github/github-ssh-host-alias-resolution.ts b/src/main/github/github-ssh-host-alias-resolution.ts index 44b7abdd798..fcf59465688 100644 --- a/src/main/github/github-ssh-host-alias-resolution.ts +++ b/src/main/github/github-ssh-host-alias-resolution.ts @@ -1,6 +1,6 @@ import type { GitHubOwnerRepo } from '../../shared/github/pull-request-types' import { commandExecFileAsync } from '../git/runner' -import { parseWslPath } from '../wsl' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' import { resolveWithSshG } from '../ssh/config/ssh-g-config-resolution' import { gitHubSshConfigHostAlias, diff --git a/src/main/github/pr-refresh-coordinator-wsl-stopped-distro.test.ts b/src/main/github/pr-refresh-coordinator-wsl-stopped-distro.test.ts index 8de95463914..c3ca3325a23 100644 --- a/src/main/github/pr-refresh-coordinator-wsl-stopped-distro.test.ts +++ b/src/main/github/pr-refresh-coordinator-wsl-stopped-distro.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as WslUncAccessGateModule from '../wsl/wsl-unc-access-gate' +import type * as WslUncAccessGateModule from '../wsl/filesystem/wsl-unc-access-gate' const { coordinatorMocks, moduleMocks } = await vi.hoisted(async () => { const moduleMocks = await import('./pr-refresh-coordinator-test-mocks') @@ -18,7 +18,7 @@ vi.mock('./github-api-repository', () => ) vi.mock('./rate-limit', () => moduleMocks.rateLimitModuleMock(coordinatorMocks)) vi.mock('../ipc/ui', () => moduleMocks.ipcUiModuleMock(coordinatorMocks)) -vi.mock('../wsl/wsl-unc-access-gate', async (importOriginal) => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', async (importOriginal) => ({ ...(await importOriginal()), blockedWslDistroForPath: gate.blockedWslDistroForPath, wslDistroForPath: gate.wslDistroForPath @@ -50,7 +50,7 @@ describe('PR refresh for a stopped WSL distro (E9)', () => { it("drains outside a user act that scheduled it, so a stopped distro's queue is not admitted", async () => { const { reportVisiblePRRefreshCandidates } = await import('./pr-refresh-coordinator') - const { isWslUserActFor, runAsWslUserAct } = await import('../wsl/wsl-user-act-scope') + const { isWslUserActFor, runAsWslUserAct } = await import('../wsl/discovery/wsl-user-act-scope') const drainedInsideAct: boolean[] = [] gate.blockedWslDistroForPath.mockImplementation(async () => { drainedInsideAct.push(isWslUserActFor('Ubuntu')) diff --git a/src/main/github/pr-refresh-coordinator.ts b/src/main/github/pr-refresh-coordinator.ts index 2894e420fc9..ae3349cd07d 100644 --- a/src/main/github/pr-refresh-coordinator.ts +++ b/src/main/github/pr-refresh-coordinator.ts @@ -23,7 +23,7 @@ import { PRRefreshQueueDrainer, type PRRefreshRegistrationCheck } from './pr-ref import { prRefreshRateLimitPausedUntil } from './pr-refresh-rate-limit-gate' import { PRRefreshRetryState } from './pr-refresh-retry-state' import { PRRefreshVisibility } from './pr-refresh-visibility' -import { blockedWslDistroForPath, wslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath, wslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' const retry = new PRRefreshRetryState() const queue = new PRRefreshQueue((key) => retry.reset(key)) diff --git a/src/main/github/pr-refresh-queue-drainer.ts b/src/main/github/pr-refresh-queue-drainer.ts index 511a1987652..2e65aaa488e 100644 --- a/src/main/github/pr-refresh-queue-drainer.ts +++ b/src/main/github/pr-refresh-queue-drainer.ts @@ -18,8 +18,8 @@ import type { PRRefreshEventPublisher } from './pr-refresh-event-publisher' import { type PRRefreshPacing, usesActiveRefreshPacing } from './pr-refresh-pacing' import type { PRRefreshQueue, PRRefreshQueueEntry } from './pr-refresh-queue' import { prRefreshRateLimitPausedUntil } from './pr-refresh-rate-limit-gate' -import { blockedWslDistroForPath, wslDistroForPath } from '../wsl/wsl-unc-access-gate' -import { outsideWslUserAct } from '../wsl/wsl-user-act-scope' +import { blockedWslDistroForPath, wslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' +import { outsideWslUserAct } from '../wsl/discovery/wsl-user-act-scope' import type { PRRefreshRetryState } from './pr-refresh-retry-state' import type { PRRefreshVisibility } from './pr-refresh-visibility' diff --git a/src/main/github/pr-start-point-wsl-gate.ts b/src/main/github/pr-start-point-wsl-gate.ts index 2f198a9895a..7cd1665c67a 100644 --- a/src/main/github/pr-start-point-wsl-gate.ts +++ b/src/main/github/pr-start-point-wsl-gate.ts @@ -4,7 +4,7 @@ import { guardWslUncPathAccess, WslDistroStoppedError, WslDistroUnverifiableError -} from '../wsl/wsl-unc-access-gate' +} from '../wsl/filesystem/wsl-unc-access-gate' /** * Resolves a PR start point unless its repo's WSL distro is stopped (E9): a background push-target diff --git a/src/main/gitlab/gitlab-project-ref-resolution.ts b/src/main/gitlab/gitlab-project-ref-resolution.ts index 03d9773a853..cb3d37ab107 100644 --- a/src/main/gitlab/gitlab-project-ref-resolution.ts +++ b/src/main/gitlab/gitlab-project-ref-resolution.ts @@ -1,6 +1,6 @@ import { glabExecFileAsync } from '../git/runner' import type { GitAdmissionTier } from '../git/command-runner/git-exec-options' -import { addWslEnvKeys } from '../wsl-env' +import { addWslEnvKeys } from '../../shared/wsl-env' import { isTransientGitProbeError, readRemoteUrl } from '../git/remote-url-probe' import { NEGATIVE_ENTRY_TTL_MS } from '../git/remote-ref-probe-cache' import { readLocalGitConfigSignature } from '../github/local-git-config-signature' diff --git a/src/main/ipc/ai-vault-resume.ts b/src/main/ipc/ai-vault-resume.ts index 0e12128e52b..3316fb20304 100644 --- a/src/main/ipc/ai-vault-resume.ts +++ b/src/main/ipc/ai-vault-resume.ts @@ -12,7 +12,7 @@ import { assertLegacyAiVaultResumeAllowed } from '../ai-vault/structured-session import { tryEnsureStructuredAgentSessionHostForResume } from '../runtime/agent-session/structured-agent-session-host-refusal' import { copyStructuredChatConversation } from '../ai-vault/structured-chat-conversation-copy' import { wakeNativeChatTranscriptDistro } from '../native-chat/native-chat-open-wake' -import { wslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { wslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' export type AiVaultResumeHandlerOptions = { ensureStructuredSessionOwnership?: () => Promise diff --git a/src/main/ipc/ai-vault-scan-coalescing.test.ts b/src/main/ipc/ai-vault-scan-coalescing.test.ts index ad9c554c7f0..354c53a5867 100644 --- a/src/main/ipc/ai-vault-scan-coalescing.test.ts +++ b/src/main/ipc/ai-vault-scan-coalescing.test.ts @@ -37,11 +37,11 @@ import { invalidateAiVaultSessionListCache } from '../ai-vault/cached-session-li import { registerRuntimeEnvironmentSubscriptionHandlers } from './runtime-environments/runtime-environment-subscription-handlers' import { advanceRuntimeEnvironmentTransportGeneration } from './runtime-environments/runtime-environment-transport-generation' import type { subscribeRuntimeEnvironment } from './runtime-environments/runtime-environment-transport-routing' -vi.mock('../wsl', () => ({ +vi.mock('../wsl/discovery/distro-catalog', () => ({ listRunningWslHomeDirsAsync: vi.fn().mockResolvedValue([]), hasCachedWslDistros: vi.fn(() => false) })) -vi.mock('../wsl-running-path-filter', () => ({ +vi.mock('../wsl/filesystem/wsl-running-path-filter', () => ({ filterPathsToRunningWslDistrosAsync: vi.fn(async (paths: readonly string[]) => [...paths]) })) const { _internals, registerAiVaultHandlers } = await import('./ai-vault') diff --git a/src/main/ipc/ai-vault-unresolved-owner.test.ts b/src/main/ipc/ai-vault-unresolved-owner.test.ts index 32bffa935f9..36db14ab6ca 100644 --- a/src/main/ipc/ai-vault-unresolved-owner.test.ts +++ b/src/main/ipc/ai-vault-unresolved-owner.test.ts @@ -14,7 +14,7 @@ vi.mock('../ai-vault/session-scanner-service-spawn', async (importOriginal) => ( scanAiVaultSessionsInService: mocks.scanLocalSessions })) -vi.mock('../wsl', () => ({ +vi.mock('../wsl/discovery/distro-catalog', () => ({ listRunningWslDistrosAsync: vi.fn().mockResolvedValue([]), listRunningWslHomeDirsAsync: vi.fn().mockResolvedValue([]), hasCachedWslDistros: vi.fn(() => false) diff --git a/src/main/ipc/ai-vault.test.ts b/src/main/ipc/ai-vault.test.ts index 219dca7b5a9..69694be58d3 100644 --- a/src/main/ipc/ai-vault.test.ts +++ b/src/main/ipc/ai-vault.test.ts @@ -52,7 +52,7 @@ vi.mock('../ai-vault/session-scanner-parse-cache', async (importOriginal) => { } }) -vi.mock('../wsl', () => ({ +vi.mock('../wsl/discovery/distro-catalog', () => ({ listRunningWslDistrosAsync: vi.fn().mockResolvedValue([]), listRunningWslHomeDirsAsync: vi.fn().mockResolvedValue([]), hasCachedWslDistros: vi.fn(() => false) diff --git a/src/main/ipc/app.test.ts b/src/main/ipc/app.test.ts index e69fd9df07e..dc8844aa992 100644 --- a/src/main/ipc/app.test.ts +++ b/src/main/ipc/app.test.ts @@ -1,3 +1,4 @@ +import type * as WslAvailability from '../wsl/discovery/wsl-availability' import { EventEmitter } from 'node:events' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type * as AppRelaunch from '../startup/quit/app-relaunch' @@ -142,8 +143,13 @@ const windowsProbes = vi.hoisted(() => ({ isPwshAvailableAsync: vi.fn(async () => true) })) -vi.mock('../wsl', () => ({ - isWslAvailableAsync: windowsProbes.isWslAvailableAsync, +vi.mock('../wsl/discovery/wsl-availability', async (importOriginal) => ({ + ...(await importOriginal()), + ...(await (() => ({ + isWslAvailableAsync: windowsProbes.isWslAvailableAsync + }))()) +})) +vi.mock('../wsl/discovery/distro-catalog', () => ({ listWslDistros: windowsProbes.listWslDistros, listWslDistrosAsync: windowsProbes.listWslDistrosAsync })) diff --git a/src/main/ipc/app.ts b/src/main/ipc/app.ts index 3ee3480aab7..79319d43cf0 100644 --- a/src/main/ipc/app.ts +++ b/src/main/ipc/app.ts @@ -16,7 +16,8 @@ import { quitProcess } from '../startup/process-quit-request' import type { Store } from '../persistence/loading-store/store' import { getDevInstanceIdentity } from '../startup/dev-instance-identity' import { isPwshAvailableAsync } from '../pty/shell-startup/pwsh' -import { isWslAvailableAsync, listWslDistrosAsync } from '../wsl' +import { isWslAvailableAsync } from '../wsl/discovery/wsl-availability' +import { listWslDistrosAsync } from '../wsl/discovery/distro-catalog' import { isGitBashAvailable } from '../pty/shell-startup/git-bash' import { setUnreadDockBadgeCount } from '../dock/unread-badge' import { destroySystemTray, rebuildSystemTrayMenu } from '../tray/system-tray' diff --git a/src/main/ipc/cli-appimage-stale-registration.test.ts b/src/main/ipc/cli-appimage-stale-registration.test.ts index 44a209146b0..bd486daae22 100644 --- a/src/main/ipc/cli-appimage-stale-registration.test.ts +++ b/src/main/ipc/cli-appimage-stale-registration.test.ts @@ -58,7 +58,7 @@ vi.mock('../startup/hydrate-shell-path', () => ({ mergePathSegments: mocks.mergePathSegments })) -vi.mock('../wsl', () => ({ getDefaultWslDistro: vi.fn() })) +vi.mock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: vi.fn() })) import { registerCliHandlers } from './cli' diff --git a/src/main/ipc/cli.test.ts b/src/main/ipc/cli.test.ts index fb8147c3480..baecf1a0aa3 100644 --- a/src/main/ipc/cli.test.ts +++ b/src/main/ipc/cli.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as BackgroundDistroGate from '../wsl-background-distro-gate' +import type * as BackgroundDistroGate from '../wsl/discovery/wsl-background-distro-gate' const { handlers, @@ -36,8 +36,8 @@ vi.mock('../startup/hydrate-shell-path', () => ({ hydrateShellPath: vi.fn(async () => ({ ok: false })), mergePathSegments: vi.fn() })) -vi.mock('../wsl', () => ({ getDefaultWslDistro: getDefaultWslDistroMock })) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: getDefaultWslDistroMock })) +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: readWslDistroRunningStateMock })) diff --git a/src/main/ipc/cli.ts b/src/main/ipc/cli.ts index 30a833f8f6e..63c40c6142e 100644 --- a/src/main/ipc/cli.ts +++ b/src/main/ipc/cli.ts @@ -18,9 +18,12 @@ import { import { runSerializedWslCliRegistrationOperation } from '../cli/wsl-cli-registration-operation' import { getCanonicalUserDataPath } from '../persistence/loading-store/user-data-path' import { hydrateShellPath, mergePathSegments } from '../startup/hydrate-shell-path' -import { getDefaultWslDistro } from '../wsl' -import { blockedWslDistroForExec, runAsWslExecUserAct } from '../wsl/wsl-background-exec-gate' -import { isWslDistroNotFoundFailure } from '../wsl/wsl-distro-unsupported' +import { getDefaultWslDistro } from '../wsl/discovery/distro-catalog' +import { + blockedWslDistroForExec, + runAsWslExecUserAct +} from '../wsl/discovery/wsl-background-exec-gate' +import { isWslDistroNotFoundFailure } from '../wsl/discovery/wsl-distro-unsupported' import { resolveAppImageRuntimeIdentity } from '../updater/linux-package/appimage-runtime-identity' const APPIMAGE_REPAIR_RETRY_MS = 30_000 diff --git a/src/main/ipc/dropped-path-resolution.ts b/src/main/ipc/dropped-path-resolution.ts index 9fcf0a1ffa7..b4eb0623c44 100644 --- a/src/main/ipc/dropped-path-resolution.ts +++ b/src/main/ipc/dropped-path-resolution.ts @@ -1,4 +1,5 @@ -import { parseWslPath, toLinuxPath } from '../wsl' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' +import { toLinuxPath } from '../../shared/wsl-paths' export function resolveLocalDroppedPathsForAgent(paths: string[], worktreePath: string): string[] { // Local WSL shells need dropped Windows paths rewritten into their Linux namespace. diff --git a/src/main/ipc/filesystem/filesystem-allowed-roots.ts b/src/main/ipc/filesystem/filesystem-allowed-roots.ts index ed78fa5ea24..b6edee04f18 100644 --- a/src/main/ipc/filesystem/filesystem-allowed-roots.ts +++ b/src/main/ipc/filesystem/filesystem-allowed-roots.ts @@ -1,7 +1,7 @@ import { isAbsolute, resolve } from 'node:path' import type { RuntimeStore } from '../../runtime/runtime-store-contract' import { computeWorkspaceRootWithin, getWorktreePathSettings } from '../worktree-logic' -import { wslHomeUnlessStopped } from '../../wsl/wsl-home-unless-stopped' +import { wslHomeUnlessStopped } from '../../wsl/discovery/wsl-home-unless-stopped' import { getWorktreeMirrorDistroForRuntime } from '../../workspaces/execution-host/project-runtime-git-options' import { resolveLocalProjectRuntimesForRepos } from '../../workspaces/execution-host/local-project-runtime-resolution' import { isPathInsideOrEqual } from '../../../shared/cross-platform-path' diff --git a/src/main/ipc/filesystem/filesystem-auth.ts b/src/main/ipc/filesystem/filesystem-auth.ts index 1b5427d9c59..eee820933b9 100644 --- a/src/main/ipc/filesystem/filesystem-auth.ts +++ b/src/main/ipc/filesystem/filesystem-auth.ts @@ -1,7 +1,10 @@ import { resolve, dirname, basename } from 'node:path' import type { RuntimeStore } from '../../runtime/runtime-store-contract' import { lstat } from 'node:fs/promises' -import { realpathAcrossWslDriveMount, windowsFsPath } from '../../wsl/wsl-unc-drive-fs-path' +import { + realpathAcrossWslDriveMount, + windowsFsPath +} from '../../wsl/filesystem/wsl-unc-drive-fs-path' import { PATH_OUTSIDE_ALLOWED_DIRECTORIES } from '../../../shared/local-file-access' import { getAllowedRoots } from './filesystem-allowed-roots' import { isDescendantOrEqual, isENOENT, normalizeExistingPath } from './filesystem-path-containment' diff --git a/src/main/ipc/filesystem/filesystem-branch-compare-diff.test.ts b/src/main/ipc/filesystem/filesystem-branch-compare-diff.test.ts index db0481bac68..63e0c191339 100644 --- a/src/main/ipc/filesystem/filesystem-branch-compare-diff.test.ts +++ b/src/main/ipc/filesystem/filesystem-branch-compare-diff.test.ts @@ -34,7 +34,7 @@ vi.mock('../../git/worktree-listing', async (importOriginal) => { vi.mock('electron', async () => (await import('./filesystem-test-harness')).electronMock) vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( diff --git a/src/main/ipc/filesystem/filesystem-chunk-read-handler.ts b/src/main/ipc/filesystem/filesystem-chunk-read-handler.ts index 9a7c66583fc..c972ea47e60 100644 --- a/src/main/ipc/filesystem/filesystem-chunk-read-handler.ts +++ b/src/main/ipc/filesystem/filesystem-chunk-read-handler.ts @@ -5,7 +5,7 @@ import { SshHostNotServedError } from '../../providers/ssh-host-not-served-error import { resolveLocalFileRequestPath } from '../local-file-access-resolution' import type { LocalFileAccess } from '../../../shared/local-file-access' import type { FilesystemHandlerContext } from './filesystem-handler-context' -import { guardWslUncPathAccess } from '../../wsl/wsl-unc-access-gate' +import { guardWslUncPathAccess } from '../../wsl/filesystem/wsl-unc-access-gate' export function registerFilesystemChunkReadHandler({ store }: FilesystemHandlerContext): void { ipcMain.handle( diff --git a/src/main/ipc/filesystem/filesystem-commit-message-generation.test.ts b/src/main/ipc/filesystem/filesystem-commit-message-generation.test.ts index 17c0ecdc0c2..26083d014d0 100644 --- a/src/main/ipc/filesystem/filesystem-commit-message-generation.test.ts +++ b/src/main/ipc/filesystem/filesystem-commit-message-generation.test.ts @@ -36,7 +36,7 @@ vi.mock('../../git/worktree-listing', async (importOriginal) => { vi.mock('electron', async () => (await import('./filesystem-test-harness')).electronMock) vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( diff --git a/src/main/ipc/filesystem/filesystem-commit-message-model-discovery.test.ts b/src/main/ipc/filesystem/filesystem-commit-message-model-discovery.test.ts index 80308f639fd..e622f13a94d 100644 --- a/src/main/ipc/filesystem/filesystem-commit-message-model-discovery.test.ts +++ b/src/main/ipc/filesystem/filesystem-commit-message-model-discovery.test.ts @@ -32,7 +32,7 @@ vi.mock('../../git/worktree-listing', async (importOriginal) => { vi.mock('electron', async () => (await import('./filesystem-test-harness')).electronMock) vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( diff --git a/src/main/ipc/filesystem/filesystem-conflict-operation-routing.test.ts b/src/main/ipc/filesystem/filesystem-conflict-operation-routing.test.ts index af9f42b6b72..40c9f30c8bd 100644 --- a/src/main/ipc/filesystem/filesystem-conflict-operation-routing.test.ts +++ b/src/main/ipc/filesystem/filesystem-conflict-operation-routing.test.ts @@ -32,7 +32,7 @@ vi.mock('../../git/worktree-listing', async (importOriginal) => { vi.mock('electron', async () => (await import('./filesystem-test-harness')).electronMock) vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( diff --git a/src/main/ipc/filesystem/filesystem-content-search-cancellation.test.ts b/src/main/ipc/filesystem/filesystem-content-search-cancellation.test.ts index b9b700e642a..7b0115edfc4 100644 --- a/src/main/ipc/filesystem/filesystem-content-search-cancellation.test.ts +++ b/src/main/ipc/filesystem/filesystem-content-search-cancellation.test.ts @@ -1,3 +1,4 @@ +import type * as WslPaths from '../../../shared/wsl-paths' import { isAbsolute } from 'node:path' import { spawnProcess } from '@orca/process-host' import { EventEmitter } from 'node:events' @@ -38,9 +39,14 @@ vi.mock('../../git/runner', () => ({ wslAwareSpawn: wslAwareSpawnMock })) -vi.mock('../../wsl', () => ({ - parseWslPath: parseWslPathMock, - toWindowsWslPath: toWindowsWslPathMock +vi.mock('../../wsl/filesystem/unc-path-access', () => ({ + parseWslPath: parseWslPathMock +})) +vi.mock('../../../shared/wsl-paths', async (importOriginal) => ({ + ...(await importOriginal()), + ...(await (() => ({ + toWindowsWslPath: toWindowsWslPathMock + }))()) })) vi.mock('./filesystem-auth', () => ({ diff --git a/src/main/ipc/filesystem/filesystem-download-transfers.test.ts b/src/main/ipc/filesystem/filesystem-download-transfers.test.ts index 4d944e1d667..709bf63d7c6 100644 --- a/src/main/ipc/filesystem/filesystem-download-transfers.test.ts +++ b/src/main/ipc/filesystem/filesystem-download-transfers.test.ts @@ -37,7 +37,7 @@ vi.mock('../../git/worktree-listing', async (importOriginal) => { vi.mock('electron', async () => (await import('./filesystem-test-harness')).electronMock) vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( diff --git a/src/main/ipc/filesystem/filesystem-file-content-unc-drive.test.ts b/src/main/ipc/filesystem/filesystem-file-content-unc-drive.test.ts index 706aba91d3e..498a564ea75 100644 --- a/src/main/ipc/filesystem/filesystem-file-content-unc-drive.test.ts +++ b/src/main/ipc/filesystem/filesystem-file-content-unc-drive.test.ts @@ -35,7 +35,7 @@ vi.mock('../../git/worktree-listing', async (importOriginal) => { vi.mock('./local-disk-write-precondition', () => diskPreconditionMock) vi.mock('electron', async () => (await import('./filesystem-test-harness')).electronMock) // The distro these UNC fixtures name counts as running, so the boot gate lets the touch through. -vi.mock('../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: async () => 'running' })) @@ -49,7 +49,7 @@ vi.mock('node:fs/promises', async () => ({ mkdir: mkdirMock })) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( diff --git a/src/main/ipc/filesystem/filesystem-git-commit-dispatch.test.ts b/src/main/ipc/filesystem/filesystem-git-commit-dispatch.test.ts index 99921fe1469..7f972e87bb6 100644 --- a/src/main/ipc/filesystem/filesystem-git-commit-dispatch.test.ts +++ b/src/main/ipc/filesystem/filesystem-git-commit-dispatch.test.ts @@ -38,7 +38,7 @@ vi.mock('../../git/worktree-listing', async (importOriginal) => { vi.mock('electron', async () => (await import('./filesystem-test-harness')).electronMock) vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( diff --git a/src/main/ipc/filesystem/filesystem-git-model-discovery-handlers.ts b/src/main/ipc/filesystem/filesystem-git-model-discovery-handlers.ts index 2cf4215ec90..2e879cc8037 100644 --- a/src/main/ipc/filesystem/filesystem-git-model-discovery-handlers.ts +++ b/src/main/ipc/filesystem/filesystem-git-model-discovery-handlers.ts @@ -6,7 +6,7 @@ import { type DiscoverCommitMessageModelsResult } from '../../text-generation/commit-message-text-generation' import { prepareLocalCommitMessageAgentEnv } from '../../text-generation/commit-message-agent-environment' -import { parseWslPath } from '../../wsl' +import { parseWslPath } from '../../wsl/filesystem/unc-path-access' import { resolveModelDiscoveryLocalPath, getLocalAgentRuntimeTarget diff --git a/src/main/ipc/filesystem/filesystem-git-status-handlers.ts b/src/main/ipc/filesystem/filesystem-git-status-handlers.ts index 788bd02a35e..1678d093416 100644 --- a/src/main/ipc/filesystem/filesystem-git-status-handlers.ts +++ b/src/main/ipc/filesystem/filesystem-git-status-handlers.ts @@ -42,7 +42,7 @@ import { noteWslDistroWokenForPath, runAsWslUserAct, wslDistroForPath -} from '../../wsl/wsl-unc-access-gate' +} from '../../wsl/filesystem/wsl-unc-access-gate' export function registerFilesystemGitStatusHandlers(context: FilesystemHandlerContext): void { const { store, gitStatusCancellations } = context diff --git a/src/main/ipc/filesystem/filesystem-git-status-staging.test.ts b/src/main/ipc/filesystem/filesystem-git-status-staging.test.ts index 887d755ebcf..32698d4d813 100644 --- a/src/main/ipc/filesystem/filesystem-git-status-staging.test.ts +++ b/src/main/ipc/filesystem/filesystem-git-status-staging.test.ts @@ -43,7 +43,7 @@ vi.mock('../../git/worktree-listing', async (importOriginal) => { vi.mock('electron', async () => (await import('./filesystem-test-harness')).electronMock) vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( diff --git a/src/main/ipc/filesystem/filesystem-list-files-handler-name-filter.test.ts b/src/main/ipc/filesystem/filesystem-list-files-handler-name-filter.test.ts index 13a25fb0741..3c0a6018ddd 100644 --- a/src/main/ipc/filesystem/filesystem-list-files-handler-name-filter.test.ts +++ b/src/main/ipc/filesystem/filesystem-list-files-handler-name-filter.test.ts @@ -26,7 +26,7 @@ vi.mock('../../git/worktree-listing', async (importOriginal) => { vi.mock('electron', async () => (await import('./filesystem-test-harness')).electronMock) vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( diff --git a/src/main/ipc/filesystem/filesystem-markdown-document-listing.test.ts b/src/main/ipc/filesystem/filesystem-markdown-document-listing.test.ts index b9c60c7d624..3650f272472 100644 --- a/src/main/ipc/filesystem/filesystem-markdown-document-listing.test.ts +++ b/src/main/ipc/filesystem/filesystem-markdown-document-listing.test.ts @@ -46,7 +46,7 @@ vi.mock('../local-worktree-runtime-options', () => ({ vi.mock('electron', async () => (await import('./filesystem-test-harness')).electronMock) vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( diff --git a/src/main/ipc/filesystem/filesystem-mutations.ts b/src/main/ipc/filesystem/filesystem-mutations.ts index 1587c94b0aa..aa361dcd224 100644 --- a/src/main/ipc/filesystem/filesystem-mutations.ts +++ b/src/main/ipc/filesystem/filesystem-mutations.ts @@ -30,7 +30,7 @@ import { abortWhenRendererGone } from '../renderer-lifetime-abort' import { sweepAbandonedRuntimeUploadTempPath } from '../runtime-upload-temp-sweep' import type { RuntimeUploadFileStreamRequest } from '../../../shared/runtime-upload-staging-contract' import { resolveEnvironment } from '../../../shared/runtime-environment-store' -import { windowsFsPath } from '../../wsl/wsl-unc-drive-fs-path' +import { windowsFsPath } from '../../wsl/filesystem/wsl-unc-drive-fs-path' export function registerFilesystemMutationHandlers(store: Store): void { ipcMain.handle( diff --git a/src/main/ipc/filesystem/filesystem-path-containment.ts b/src/main/ipc/filesystem/filesystem-path-containment.ts index 8ed72d91c66..3dc0f11a339 100644 --- a/src/main/ipc/filesystem/filesystem-path-containment.ts +++ b/src/main/ipc/filesystem/filesystem-path-containment.ts @@ -1,6 +1,6 @@ import { resolve, relative, isAbsolute, sep, dirname } from 'node:path' import { statSync } from 'node:fs' -import { realpathAcrossWslDriveMount } from '../../wsl/wsl-unc-drive-fs-path' +import { realpathAcrossWslDriveMount } from '../../wsl/filesystem/wsl-unc-drive-fs-path' import { isDefinitiveAbsence } from '../../../shared/definitive-filesystem-absence' /** Check native-path containment; accept Unicode-equivalent spellings only after proving filesystem identity. */ diff --git a/src/main/ipc/filesystem/filesystem-pull-request-linked-issue-lifetime.test.ts b/src/main/ipc/filesystem/filesystem-pull-request-linked-issue-lifetime.test.ts index 46cc2fbb209..9b624cca90a 100644 --- a/src/main/ipc/filesystem/filesystem-pull-request-linked-issue-lifetime.test.ts +++ b/src/main/ipc/filesystem/filesystem-pull-request-linked-issue-lifetime.test.ts @@ -36,7 +36,7 @@ vi.mock('../../git/worktree-listing', async (importOriginal) => { vi.mock('electron', async () => (await import('./filesystem-test-harness')).electronMock) vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( diff --git a/src/main/ipc/filesystem/filesystem-read-dir-unc-drive.test.ts b/src/main/ipc/filesystem/filesystem-read-dir-unc-drive.test.ts index ddfa8b35df8..990e705af52 100644 --- a/src/main/ipc/filesystem/filesystem-read-dir-unc-drive.test.ts +++ b/src/main/ipc/filesystem/filesystem-read-dir-unc-drive.test.ts @@ -32,14 +32,14 @@ vi.mock('../../git/worktree-listing', async (importOriginal) => { vi.mock('./local-disk-write-precondition', () => diskPreconditionMock) vi.mock('electron', async () => (await import('./filesystem-test-harness')).electronMock) // The distro these UNC fixtures name counts as running, so the boot gate lets the touch through. -vi.mock('../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: async () => 'running' })) vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock('node:fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( diff --git a/src/main/ipc/filesystem/filesystem-read-handlers.ts b/src/main/ipc/filesystem/filesystem-read-handlers.ts index ab521fe8be7..adfa8e98b3f 100644 --- a/src/main/ipc/filesystem/filesystem-read-handlers.ts +++ b/src/main/ipc/filesystem/filesystem-read-handlers.ts @@ -26,8 +26,11 @@ import type { FilesystemHandlerContext } from './filesystem-handler-context' import { registerFilesystemChunkReadHandler } from './filesystem-chunk-read-handler' import { grantRemoteFilePreview, readLocalFilePreview } from '../../media/media-preview-protocol' import { readPreviewGrantRange } from '../../media/preview-grant-range-read' -import { windowsFsPath } from '../../wsl/wsl-unc-drive-fs-path' -import { assertWslUncPathRunning, guardWslUncPathAccess } from '../../wsl/wsl-unc-access-gate' +import { windowsFsPath } from '../../wsl/filesystem/wsl-unc-drive-fs-path' +import { + assertWslUncPathRunning, + guardWslUncPathAccess +} from '../../wsl/filesystem/wsl-unc-access-gate' import { parseRemoteFilePreviewAddress } from '../../../shared/remote-file-preview-address' import { readLocalFileContent, diff --git a/src/main/ipc/filesystem/filesystem-search-rg-timeout.test.ts b/src/main/ipc/filesystem/filesystem-search-rg-timeout.test.ts index ca6b1be7bf9..766ffd82e28 100644 --- a/src/main/ipc/filesystem/filesystem-search-rg-timeout.test.ts +++ b/src/main/ipc/filesystem/filesystem-search-rg-timeout.test.ts @@ -1,3 +1,4 @@ +import type * as WslPaths from '../../../shared/wsl-paths' import { EventEmitter } from 'node:events' import type { ChildProcess } from 'node:child_process' import { beforeEach, describe, expect, it, vi } from 'vitest' @@ -38,9 +39,14 @@ vi.mock('../../git/runner', () => ({ wslAwareSpawn: wslAwareSpawnMock })) -vi.mock('../../wsl', () => ({ - parseWslPath: parseWslPathMock, - toWindowsWslPath: toWindowsWslPathMock +vi.mock('../../wsl/filesystem/unc-path-access', () => ({ + parseWslPath: parseWslPathMock +})) +vi.mock('../../../shared/wsl-paths', async (importOriginal) => ({ + ...(await importOriginal()), + ...(await (() => ({ + toWindowsWslPath: toWindowsWslPathMock + }))()) })) vi.mock('./filesystem-auth', () => ({ diff --git a/src/main/ipc/filesystem/filesystem-symlink-directory-entries.ts b/src/main/ipc/filesystem/filesystem-symlink-directory-entries.ts index 5dbdf03dc76..7a77f355072 100644 --- a/src/main/ipc/filesystem/filesystem-symlink-directory-entries.ts +++ b/src/main/ipc/filesystem/filesystem-symlink-directory-entries.ts @@ -3,7 +3,7 @@ import { stat } from 'node:fs/promises' import { join } from 'node:path' import type { DirEntry } from '../../../shared/filesystem-entry-types' import { mapWithConcurrency } from '../../../shared/map-with-concurrency' -import { windowsFsPath } from '../../wsl/wsl-unc-drive-fs-path' +import { windowsFsPath } from '../../wsl/filesystem/wsl-unc-drive-fs-path' export function classifyFilesystemDirectoryEntries( dirPath: string, diff --git a/src/main/ipc/filesystem/filesystem-write-handlers.ts b/src/main/ipc/filesystem/filesystem-write-handlers.ts index 59982d4b041..dd75f941a8c 100644 --- a/src/main/ipc/filesystem/filesystem-write-handlers.ts +++ b/src/main/ipc/filesystem/filesystem-write-handlers.ts @@ -3,7 +3,7 @@ import { lstat, rm, writeFile } from 'node:fs/promises' import type { SshMutationExpectation } from '../../../shared/ssh-types' import { assertSshMutationExpectation } from '../../ssh/connection/ssh-connection-generation' import { SshHostNotServedError } from '../../providers/ssh-host-not-served-error' -import { tryDeleteWslUncPath } from '../../wsl-unc-delete' +import { tryDeleteWslUncPath } from '../../wsl/filesystem/wsl-unc-delete' import type { LocalFileAccess } from '../../../shared/local-file-access' import { resolveDesktopAuthorizedPath, @@ -20,7 +20,7 @@ import type { import { writeLocalTextFileWithDiskPrecondition } from './local-disk-write-precondition' import { replaceLocalFileBytesIfUnchanged } from './local-disk-bytes-replace' import type { FileBytesWritePrecondition } from '../../../shared/file-bytes-write' -import { windowsFsPath } from '../../wsl/wsl-unc-drive-fs-path' +import { windowsFsPath } from '../../wsl/filesystem/wsl-unc-drive-fs-path' import { TRASH_DELETE_FAILED_MESSAGE } from '../../../shared/trash-delete-failure' export function registerFilesystemWriteHandlers(context: FilesystemHandlerContext): void { diff --git a/src/main/ipc/filesystem/filesystem-wsl-stopped-distro-git.test.ts b/src/main/ipc/filesystem/filesystem-wsl-stopped-distro-git.test.ts index 4c957c970d4..3bb508f0897 100644 --- a/src/main/ipc/filesystem/filesystem-wsl-stopped-distro-git.test.ts +++ b/src/main/ipc/filesystem/filesystem-wsl-stopped-distro-git.test.ts @@ -37,7 +37,7 @@ vi.mock('electron', async () => (await import('./filesystem-test-harness')).elec const isWslDistroRunningMock = vi.hoisted(() => vi.fn(async (_distro: string, _options?: unknown) => false) ) -vi.mock('../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: async (distro: string, options: unknown) => (await isWslDistroRunningMock(distro, options)) ? 'running' : 'stopped' @@ -45,7 +45,7 @@ vi.mock('../../wsl-background-distro-gate', async (importOriginal) => ({ vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock('node:fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( @@ -82,7 +82,7 @@ vi.mock( ) import { registerFilesystemHandlers } from './filesystem' -import { WslDistroStoppedError } from '../../wsl/wsl-unc-access-gate' +import { WslDistroStoppedError } from '../../wsl/filesystem/wsl-unc-access-gate' const UNC_ROOT = '\\\\wsl.localhost\\Ubuntu\\home\\me\\repo' const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') diff --git a/src/main/ipc/filesystem/filesystem-wsl-stopped-distro-reads.test.ts b/src/main/ipc/filesystem/filesystem-wsl-stopped-distro-reads.test.ts index 1dd158a4492..7716a9946af 100644 --- a/src/main/ipc/filesystem/filesystem-wsl-stopped-distro-reads.test.ts +++ b/src/main/ipc/filesystem/filesystem-wsl-stopped-distro-reads.test.ts @@ -34,14 +34,14 @@ vi.mock('electron', async () => (await import('./filesystem-test-harness')).elec const readStateMock = vi.hoisted(() => vi.fn(async (_distro: string, _options?: unknown): Promise => 'stopped') ) -vi.mock('../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: readStateMock })) vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock('node:fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( @@ -78,7 +78,10 @@ vi.mock( ) import { registerFilesystemHandlers } from './filesystem' -import { WslDistroStoppedError, WslDistroUnverifiableError } from '../../wsl/wsl-unc-access-gate' +import { + WslDistroStoppedError, + WslDistroUnverifiableError +} from '../../wsl/filesystem/wsl-unc-access-gate' const UNC_ROOT = '\\\\wsl.localhost\\Ubuntu\\home\\me\\repo' const UNC_FILE = `${UNC_ROOT}\\README.md` diff --git a/src/main/ipc/filesystem/filesystem.test.ts b/src/main/ipc/filesystem/filesystem.test.ts index 35de00487ef..5ead7b05585 100644 --- a/src/main/ipc/filesystem/filesystem.test.ts +++ b/src/main/ipc/filesystem/filesystem.test.ts @@ -45,14 +45,14 @@ vi.mock('../../git/worktree-listing', async (importOriginal) => { vi.mock('./local-disk-write-precondition', () => diskPreconditionMock) vi.mock('electron', async () => (await import('./filesystem-test-harness')).electronMock) // The distro these UNC fixtures name counts as running, so the boot gate lets the touch through. -vi.mock('../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: async () => 'running' })) vi.mock('fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock('node:fs/promises', async () => (await import('./filesystem-test-harness')).fsPromisesMock) vi.mock( - '../../wsl-unc-delete', + '../../wsl/filesystem/wsl-unc-delete', async () => (await import('./filesystem-test-harness')).wslUncDeleteMock ) vi.mock( diff --git a/src/main/ipc/filesystem/git-remote/compare-handlers.ts b/src/main/ipc/filesystem/git-remote/compare-handlers.ts index d26b08797a2..b7d2937c0b7 100644 --- a/src/main/ipc/filesystem/git-remote/compare-handlers.ts +++ b/src/main/ipc/filesystem/git-remote/compare-handlers.ts @@ -11,7 +11,7 @@ import type { FilesystemHandlerContext } from '../filesystem-handler-context' import type { GitAdmissionTier } from '../../../git/command-runner/git-exec-options' import { requireReachableGitRoute } from '../../../providers/execution-host-provider-dispatch' import { getConnectionExecutionHostId } from '../../../../shared/execution-host' -import { assertWslUncPathRunning } from '../../../wsl/wsl-unc-access-gate' +import { assertWslUncPathRunning } from '../../../wsl/filesystem/wsl-unc-access-gate' export function registerGitRemoteCompareHandlers(context: FilesystemHandlerContext): void { const { store } = context diff --git a/src/main/ipc/filesystem/git-remote/sync-handlers.ts b/src/main/ipc/filesystem/git-remote/sync-handlers.ts index 2c1c22e1ad8..eaa98891c3a 100644 --- a/src/main/ipc/filesystem/git-remote/sync-handlers.ts +++ b/src/main/ipc/filesystem/git-remote/sync-handlers.ts @@ -16,7 +16,7 @@ import { ipcGitWorktreeTarget, materializeWorktreePushTargetRemote } from '../.. import type { FilesystemHandlerContext } from '../filesystem-handler-context' import { requireReachableGitRoute } from '../../../providers/execution-host-provider-dispatch' import { getConnectionExecutionHostId } from '../../../../shared/execution-host' -import { assertWslUncPathRunning } from '../../../wsl/wsl-unc-access-gate' +import { assertWslUncPathRunning } from '../../../wsl/filesystem/wsl-unc-access-gate' export function registerGitRemoteSyncHandlers(context: FilesystemHandlerContext): void { const { store } = context diff --git a/src/main/ipc/filesystem/local-disk-bytes-replace.ts b/src/main/ipc/filesystem/local-disk-bytes-replace.ts index 371a74e8233..212ec8a2ca3 100644 --- a/src/main/ipc/filesystem/local-disk-bytes-replace.ts +++ b/src/main/ipc/filesystem/local-disk-bytes-replace.ts @@ -5,7 +5,7 @@ import { basename, dirname, join } from 'node:path' import type { FileBytesWritePrecondition } from '../../../shared/file-bytes-write' import { FILE_WRITE_OK, type FileWriteResult } from '../../../shared/file-write-disk-precondition' import { renameFileWithWindowsRetryAsync } from '../../../shared/windows-retry-file-operations' -import { windowsFsPath } from '../../wsl/wsl-unc-drive-fs-path' +import { windowsFsPath } from '../../wsl/filesystem/wsl-unc-drive-fs-path' import { isENOENT } from './filesystem-path-containment' import { runLocalEditorWrite } from './local-disk-write-precondition' import { assertLocalWriteTargetIsRegularFile } from './local-regular-file-read' diff --git a/src/main/ipc/filesystem/local-disk-write-precondition.ts b/src/main/ipc/filesystem/local-disk-write-precondition.ts index ae048276a29..72f34f607d2 100644 --- a/src/main/ipc/filesystem/local-disk-write-precondition.ts +++ b/src/main/ipc/filesystem/local-disk-write-precondition.ts @@ -18,7 +18,7 @@ import { readlink, realpath, stat, writeFile } from 'node:fs/promises' import { basename, dirname, join, normalize, resolve } from 'node:path' import { runKeyedSerializedOperation } from '../../cli/keyed-promise-queue' import { serializedParentDirectoryKey } from '../../filesystem/destination-serialized-local-rename' -import { windowsFsPath } from '../../wsl/wsl-unc-drive-fs-path' +import { windowsFsPath } from '../../wsl/filesystem/wsl-unc-drive-fs-path' import { assertLocalWriteTargetIsRegularFile, FileTooLargeError, diff --git a/src/main/ipc/filesystem/local-regular-file-read.ts b/src/main/ipc/filesystem/local-regular-file-read.ts index 9aa1076aa90..3eea3c43714 100644 --- a/src/main/ipc/filesystem/local-regular-file-read.ts +++ b/src/main/ipc/filesystem/local-regular-file-read.ts @@ -1,7 +1,7 @@ import { constants, type Stats } from 'node:fs' import { open, type FileHandle } from 'node:fs/promises' import { isENOENT } from './filesystem-path-containment' -import { windowsFsPath } from '../../wsl/wsl-unc-drive-fs-path' +import { windowsFsPath } from '../../wsl/filesystem/wsl-unc-drive-fs-path' export const NOT_A_REGULAR_FILE_MESSAGE = 'Not a regular file' diff --git a/src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.test.ts b/src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.test.ts index 44213916e27..01cbd603f57 100644 --- a/src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.test.ts +++ b/src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { WatcherProcessFailure } from '../watcher-process/parcel-watcher-process-failure' -import type * as WslBackgroundDistroGate from '../../../wsl-background-distro-gate' +import type * as WslBackgroundDistroGate from '../../../wsl/discovery/wsl-background-distro-gate' const { createLocalWatcherMock, createWslWatcherMock, statMock, blockedWslDistroForPathMock } = vi.hoisted(() => ({ @@ -14,10 +14,10 @@ const { createLocalWatcherMock, createWslWatcherMock, statMock, blockedWslDistro const { noteWslDistroMayHaveStoppedMock } = vi.hoisted(() => ({ noteWslDistroMayHaveStoppedMock: vi.fn() })) -vi.mock('../../../wsl/wsl-unc-access-gate', () => ({ +vi.mock('../../../wsl/filesystem/wsl-unc-access-gate', () => ({ blockedWslDistroForPath: blockedWslDistroForPathMock })) -vi.mock('../../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), noteWslDistroMayHaveStopped: noteWslDistroMayHaveStoppedMock })) @@ -39,7 +39,7 @@ import { watcherLifecycleState } from './filesystem-watcher-lifecycle-state' import { _resetWslBackgroundDistroGateForTests, noteWslDistrosRunning -} from '../../../wsl-background-distro-gate' +} from '../../../wsl/discovery/wsl-background-distro-gate' function install(rootKey: string): ReturnType { return installLocalWatcher( diff --git a/src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.ts b/src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.ts index 0befb95cde2..2297a0e1497 100644 --- a/src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.ts +++ b/src/main/ipc/filesystem/watchers/filesystem-watcher-local-install.ts @@ -1,5 +1,5 @@ import { stat } from 'node:fs/promises' -import { isWslPath } from '../../../wsl' +import { isWslPath } from '../../../wsl/filesystem/unc-path-access' import { WATCHER_IGNORE_DIRS } from './filesystem-watcher-ignore' import { createWslWatcher, type WatchedRoot } from './filesystem-watcher-wsl' import { WatcherChildCapacityError } from '../watcher-process/parcel-watcher-child-registry' @@ -21,8 +21,8 @@ import type { WaitForLocalWatcherRetry } from './filesystem-watcher-local-capaci import { noteWslDistroMayHaveStopped, deferUntilWslDistroRunning -} from '../../../wsl-background-distro-gate' -import { blockedWslDistroForPath } from '../../../wsl/wsl-unc-access-gate' +} from '../../../wsl/discovery/wsl-background-distro-gate' +import { blockedWslDistroForPath } from '../../../wsl/filesystem/wsl-unc-access-gate' import { clearWslRootStatRetry, nextWslRootStatRetry diff --git a/src/main/ipc/filesystem/watchers/wsl-watcher-spawn.ts b/src/main/ipc/filesystem/watchers/wsl-watcher-spawn.ts index 65bbad60800..88db2150c2f 100644 --- a/src/main/ipc/filesystem/watchers/wsl-watcher-spawn.ts +++ b/src/main/ipc/filesystem/watchers/wsl-watcher-spawn.ts @@ -1,6 +1,6 @@ import { spawnProcess } from '@orca/process-host' import type { PipedChildProcess } from '@orca/process-host/process-spec' -import { resolveWslInteropSpawnCwd } from '../../../wsl-interop-spawn-directory' +import { resolveWslInteropSpawnCwd } from '../../../wsl/execution/wsl-interop-spawn-directory' /** Start the in-distro poll script; process-host applies the internal distro allowlist. */ export function spawnWslWatcherProcess(distro: string, linuxPath: string): PipedChildProcess { diff --git a/src/main/ipc/filesystem/wsl-gated-worktree-git-read.ts b/src/main/ipc/filesystem/wsl-gated-worktree-git-read.ts index 7ade5d9418e..63feffac394 100644 --- a/src/main/ipc/filesystem/wsl-gated-worktree-git-read.ts +++ b/src/main/ipc/filesystem/wsl-gated-worktree-git-read.ts @@ -7,7 +7,7 @@ import { noteWslDistroWokenForPath, runAsWslUserAct, wslDistroForPath -} from '../../wsl/wsl-unc-access-gate' +} from '../../wsl/filesystem/wsl-unc-access-gate' /** * Resolves a registered worktree and runs its Git read, refusing first when that would boot a diff --git a/src/main/ipc/git-status-upstream-ref-watch-request.test.ts b/src/main/ipc/git-status-upstream-ref-watch-request.test.ts index 99f4f0012b2..c2e7aa55368 100644 --- a/src/main/ipc/git-status-upstream-ref-watch-request.test.ts +++ b/src/main/ipc/git-status-upstream-ref-watch-request.test.ts @@ -9,7 +9,7 @@ const mocks = vi.hoisted(() => ({ setWatch: vi.fn(), isWslDistroRunning: vi.fn(async () => true) })) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: async () => (await mocks.isWslDistroRunning()) ? 'running' : 'stopped' @@ -29,7 +29,7 @@ vi.mock('./worktrees/creation/worktree-base-directory-watcher', () => ({ import { applyGitStatusUpstreamRefWatchRequest } from './git-status-upstream-ref-watch-request' import { SshHostNotServedError } from '../providers/ssh-host-not-served-error' -import { WslDistroStoppedError } from '../wsl/wsl-unc-access-gate' +import { WslDistroStoppedError } from '../wsl/filesystem/wsl-unc-access-gate' describe('applyGitStatusUpstreamRefWatchRequest', () => { beforeEach(() => { diff --git a/src/main/ipc/git-status-upstream-ref-watch-request.ts b/src/main/ipc/git-status-upstream-ref-watch-request.ts index 550e16646bf..9284a588297 100644 --- a/src/main/ipc/git-status-upstream-ref-watch-request.ts +++ b/src/main/ipc/git-status-upstream-ref-watch-request.ts @@ -11,7 +11,7 @@ import { setWorktreeGitStatusRefWatch } from './worktrees/creation/worktree-base import type { GitStatusRefBindingRequest } from './worktree-git-status-ref-watch' import { requireReachableGitRoute } from '../providers/execution-host-provider-dispatch' import { getConnectionExecutionHostId } from '../../shared/execution-host' -import { assertWslUncPathRunning } from '../wsl/wsl-unc-access-gate' +import { assertWslUncPathRunning } from '../wsl/filesystem/wsl-unc-access-gate' export type GitStatusUpstreamRefWatchRequest = GitStatusRefBindingRequest diff --git a/src/main/ipc/github-pr-refresh-document-lifetime.test.ts b/src/main/ipc/github-pr-refresh-document-lifetime.test.ts index cea64ae837e..cc15d99c849 100644 --- a/src/main/ipc/github-pr-refresh-document-lifetime.test.ts +++ b/src/main/ipc/github-pr-refresh-document-lifetime.test.ts @@ -18,7 +18,7 @@ vi.mock('../github/client', () => ({ getPRForBranch: vi.fn(), getPRForBranchOutc vi.mock('../github/pr-refresh-rate-limit-gate', () => ({ prRefreshRateLimitPausedUntil: async () => null })) -vi.mock('../wsl/wsl-unc-access-gate', () => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', () => ({ wslDistroForPath: () => null, blockedWslDistroForPath: async () => null })) diff --git a/src/main/ipc/github-repo-routing.ts b/src/main/ipc/github-repo-routing.ts index 7b7640f9048..2075bd7e4bf 100644 --- a/src/main/ipc/github-repo-routing.ts +++ b/src/main/ipc/github-repo-routing.ts @@ -15,7 +15,7 @@ import { getLocalProjectGhExecOptions, type LocalProjectGhExecOptions } from '../workspaces/execution-host/project-runtime-git-options' -import { guardWslUncPathAccess, WslDistroStoppedError } from '../wsl/wsl-unc-access-gate' +import { guardWslUncPathAccess, WslDistroStoppedError } from '../wsl/filesystem/wsl-unc-access-gate' export type GitHubRepoScopedArgs = { repoPath: string diff --git a/src/main/ipc/github-wsl-runtime-routing.test.ts b/src/main/ipc/github-wsl-runtime-routing.test.ts index 82e2d3c9dff..521bec7416b 100644 --- a/src/main/ipc/github-wsl-runtime-routing.test.ts +++ b/src/main/ipc/github-wsl-runtime-routing.test.ts @@ -14,7 +14,7 @@ vi.mock('../telemetry/client', () => mocks.telemetry) vi.mock('../telemetry/cohort-classifier', () => mocks.cohort) vi.mock('./ui', () => mocks.ui) // Routing is under test here, in a running distro; the stopped case lives in github-wsl-stopped-distro. -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: async () => 'running' })) diff --git a/src/main/ipc/gitlab-work-item-handlers.ts b/src/main/ipc/gitlab-work-item-handlers.ts index e53cbc0b5b8..233f30e859a 100644 --- a/src/main/ipc/gitlab-work-item-handlers.ts +++ b/src/main/ipc/gitlab-work-item-handlers.ts @@ -12,7 +12,7 @@ import { getWorkItemDetails } from '../gitlab/work-item-details' import type { ProjectRef } from '../gitlab/gl-utils' import type { GitLabRepoSelectorArgs } from './gitlab-repo-access' import { assertRegisteredRepo, localGitOptionArgs, repoConnectionId } from './gitlab-repo-access' -import { guardWslUncPathAccess } from '../wsl/wsl-unc-access-gate' +import { guardWslUncPathAccess } from '../wsl/filesystem/wsl-unc-access-gate' export function registerGitLabWorkItemHandlers(store: Store): void { ipcMain.handle( diff --git a/src/main/ipc/gitlab.test.ts b/src/main/ipc/gitlab.test.ts index 937b96fc004..c69af371180 100644 --- a/src/main/ipc/gitlab.test.ts +++ b/src/main/ipc/gitlab.test.ts @@ -68,7 +68,7 @@ const { getProjectSlugMock: vi.fn() })) const readWslDistroRunningStateMock = vi.hoisted(() => vi.fn()) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: readWslDistroRunningStateMock })) diff --git a/src/main/ipc/hooks/register-worktree-hook-check-handler.ts b/src/main/ipc/hooks/register-worktree-hook-check-handler.ts index b7e6c4bd65b..fae4e6ce384 100644 --- a/src/main/ipc/hooks/register-worktree-hook-check-handler.ts +++ b/src/main/ipc/hooks/register-worktree-hook-check-handler.ts @@ -3,7 +3,7 @@ import { getRepoDialableSshTargetId, type ExecutionHostId } from '../../../share import { isFolderRepo } from '../../../shared/repo-kind' import { hasHooksFile, loadHooks, hasUnrecognizedOrcaYamlKeys } from '../../workspace-hooks/hooks' import { resolveRepoForExecutionHost } from '../worktrees/repo-host-ownership' -import { blockedWslDistroForPath } from '../../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath } from '../../wsl/filesystem/wsl-unc-access-gate' import type { WorktreeIpcContext } from '../worktrees/worktree-ipc-context' export function registerWorktreeHookCheckHandler(context: WorktreeIpcContext): void { diff --git a/src/main/ipc/hooks/register-worktree-hook-inspection-handler.ts b/src/main/ipc/hooks/register-worktree-hook-inspection-handler.ts index 83ba23498f3..c5feca04304 100644 --- a/src/main/ipc/hooks/register-worktree-hook-inspection-handler.ts +++ b/src/main/ipc/hooks/register-worktree-hook-inspection-handler.ts @@ -3,8 +3,8 @@ import { getRepoDialableSshTargetId, type ExecutionHostId } from '../../../share import { isFolderRepo } from '../../../shared/repo-kind' import { inspectSetupScriptImportCandidates } from '../../../shared/setup-script-imports' import { joinWorktreeRelativePath } from '../../runtime/runtime-relative-paths' -import { windowsFsPath } from '../../wsl/wsl-unc-drive-fs-path' -import { blockedWslDistroForPath } from '../../wsl/wsl-unc-access-gate' +import { windowsFsPath } from '../../wsl/filesystem/wsl-unc-drive-fs-path' +import { blockedWslDistroForPath } from '../../wsl/filesystem/wsl-unc-access-gate' import { readFile, stat } from 'node:fs/promises' import { isENOENT } from '../filesystem/filesystem-path-containment' import { resolveRepoForExecutionHost } from '../worktrees/repo-host-ownership' diff --git a/src/main/ipc/hooks/worktree-hook-inspection-unc-drive.test.ts b/src/main/ipc/hooks/worktree-hook-inspection-unc-drive.test.ts index 1b24db302bb..4aeafa4d844 100644 --- a/src/main/ipc/hooks/worktree-hook-inspection-unc-drive.test.ts +++ b/src/main/ipc/hooks/worktree-hook-inspection-unc-drive.test.ts @@ -7,7 +7,9 @@ const mocks = vi.hoisted(() => ({ stat: vi.fn(), blocked: vi.fn<(path: string) => Promise<{ distro: string; state: 'stopped' } | null>>() })) -vi.mock('../../wsl/wsl-unc-access-gate', () => ({ blockedWslDistroForPath: mocks.blocked })) +vi.mock('../../wsl/filesystem/wsl-unc-access-gate', () => ({ + blockedWslDistroForPath: mocks.blocked +})) vi.mock('electron', () => ({ ipcMain: { diff --git a/src/main/ipc/hosted-review.test.ts b/src/main/ipc/hosted-review.test.ts index 357a1c0d9c9..53932697eec 100644 --- a/src/main/ipc/hosted-review.test.ts +++ b/src/main/ipc/hosted-review.test.ts @@ -30,7 +30,7 @@ const { readWslDistroRunningStateMock: vi.fn() })) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: readWslDistroRunningStateMock })) @@ -70,7 +70,7 @@ vi.mock('../workspaces/catalog/repo-worktrees', () => ({ import { registerHostedReviewHandlers } from './hosted-review' import { readHostedReviewForBranch } from '../source-control/hosted-review' import type { HostedReviewInfo } from '../../shared/hosted-review' -import { WslDistroStoppedError } from '../wsl/wsl-unc-access-gate' +import { WslDistroStoppedError } from '../wsl/filesystem/wsl-unc-access-gate' import { WorktreeCatalogUnavailableError } from '../../shared/worktree/worktree-catalog-availability' type HandlerMap = Record unknown> diff --git a/src/main/ipc/hosted-review.ts b/src/main/ipc/hosted-review.ts index e4604989d31..5d979a20637 100644 --- a/src/main/ipc/hosted-review.ts +++ b/src/main/ipc/hosted-review.ts @@ -25,7 +25,7 @@ import { import { getWorktreeSharedLinkPaths } from '../git/worktree-shared-directories' import { getRepoExecutionHostId, getRepoSshConnectionId } from '../../shared/execution-host' import { getStoredRepoExecutionHostId } from '../workspaces/execution-host/repo-execution-host' -import { guardWslUncPathAccess } from '../wsl/wsl-unc-access-gate' +import { guardWslUncPathAccess } from '../wsl/filesystem/wsl-unc-access-gate' function assertRegisteredRepo(repoPath: string, store: Store, repoId?: string): Repo { if (repoId) { diff --git a/src/main/ipc/local-file-access-resolution.ts b/src/main/ipc/local-file-access-resolution.ts index 07c9cac78b4..ddeb43d78d0 100644 --- a/src/main/ipc/local-file-access-resolution.ts +++ b/src/main/ipc/local-file-access-resolution.ts @@ -16,7 +16,7 @@ import { isWindowsReservedDeviceName } from './automatic-load-path-text' import { NOT_A_REGULAR_FILE_MESSAGE } from './filesystem/local-regular-file-read' -import { realpathAcrossWslDriveMount, windowsFsPath } from '../wsl/wsl-unc-drive-fs-path' +import { realpathAcrossWslDriveMount, windowsFsPath } from '../wsl/filesystem/wsl-unc-drive-fs-path' import { resolveProjectFolderLinkPath } from './project-folder-link-path' const USER_FILE_NEEDS_ABSOLUTE_PATH_MESSAGE = diff --git a/src/main/ipc/native-chat-wsl-open-wake.test.ts b/src/main/ipc/native-chat-wsl-open-wake.test.ts index 94cfffd2b23..c87bbb7940d 100644 --- a/src/main/ipc/native-chat-wsl-open-wake.test.ts +++ b/src/main/ipc/native-chat-wsl-open-wake.test.ts @@ -68,8 +68,8 @@ vi.mock('../native-chat/wsl-transcript-fs-process-dispatch', async (importOrigin openWslTranscriptFsProcess: async (path: string) => open(onShare(path), 'r') })) -import { _resetWslCachesForTests } from '../wsl' -import { _resetWslBackgroundDistroGateForTests } from '../wsl-background-distro-gate' +import { _resetWslCachesForTests } from '../wsl/discovery/distro-catalog' +import { _resetWslBackgroundDistroGateForTests } from '../wsl/discovery/wsl-background-distro-gate' import { resetWslTranscriptFsGateForTests } from '../native-chat/wsl-transcript-fs-gate' import { readNativeChatTranscriptTail } from '../native-chat/transcript-watch' import { diff --git a/src/main/ipc/preflight-agent-detection.test.ts b/src/main/ipc/preflight-agent-detection.test.ts index a7e514d46f3..0ca0c08c763 100644 --- a/src/main/ipc/preflight-agent-detection.test.ts +++ b/src/main/ipc/preflight-agent-detection.test.ts @@ -35,13 +35,13 @@ const { const runWslProcessMock = vi.hoisted(() => vi.fn()) // These cases cover a running distro; the E9 stopped-distro gate has its own suite. -vi.mock('../wsl/wsl-background-exec-gate', () => ({ +vi.mock('../wsl/discovery/wsl-background-exec-gate', () => ({ assertWslDistroRunningForExec: async () => {}, runAsWslExecUserAct: async (_distro: unknown, act: () => Promise) => act() })) // WSL detection uses runWslProcess, so child_process mocks cannot observe it. -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) vi.mock('electron', () => ({ ipcMain: { diff --git a/src/main/ipc/preflight-agent-refresh.test.ts b/src/main/ipc/preflight-agent-refresh.test.ts index 432e93e4759..f63a6439266 100644 --- a/src/main/ipc/preflight-agent-refresh.test.ts +++ b/src/main/ipc/preflight-agent-refresh.test.ts @@ -42,13 +42,13 @@ vi.mock('../wsl/wsl-guest-environment', async (original) => ({ invalidateWslGuestEnvironment: invalidateGuest })) // These cases cover a running distro; the E9 stopped-distro gate has its own suite. -vi.mock('../wsl/wsl-background-exec-gate', () => ({ +vi.mock('../wsl/discovery/wsl-background-exec-gate', () => ({ assertWslDistroRunningForExec: async () => {}, runAsWslExecUserAct: async (_distro: unknown, act: () => Promise) => act() })) // WSL detection uses runWslProcess, so child_process mocks cannot observe it. -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) vi.mock('electron', () => ({ ipcMain: { diff --git a/src/main/ipc/preflight-host-cli-status.test.ts b/src/main/ipc/preflight-host-cli-status.test.ts index 9436bb3ab36..a89bc0bfa93 100644 --- a/src/main/ipc/preflight-host-cli-status.test.ts +++ b/src/main/ipc/preflight-host-cli-status.test.ts @@ -37,7 +37,7 @@ const { })) // These cases cover a running distro; the E9 stopped-distro gate has its own suite. -vi.mock('../wsl/wsl-background-exec-gate', () => ({ +vi.mock('../wsl/discovery/wsl-background-exec-gate', () => ({ assertWslDistroRunningForExec: async () => {}, runAsWslExecUserAct: async (_distro: unknown, act: () => Promise) => act() })) @@ -71,7 +71,7 @@ vi.mock('@orca/process-host', () => ({ }) })) -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) vi.mock('../startup/hydrate-shell-path', () => ({ hydrateShellPath: hydrateShellPathMock, diff --git a/src/main/ipc/preflight-wsl-agent-detection.test.ts b/src/main/ipc/preflight-wsl-agent-detection.test.ts index f988853cc25..158362dfc3c 100644 --- a/src/main/ipc/preflight-wsl-agent-detection.test.ts +++ b/src/main/ipc/preflight-wsl-agent-detection.test.ts @@ -5,7 +5,7 @@ import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' const runWslProcessMock = vi.hoisted(() => vi.fn()) -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) import { detectWslCommandsOnPath } from './preflight-wsl-agent-detection' import { buildPosixCommandPathLookupScript } from '../../shared/posix-command-path-lookup' diff --git a/src/main/ipc/preflight-wsl-agent-detection.ts b/src/main/ipc/preflight-wsl-agent-detection.ts index 3b89e1b4df8..0cbb01eb89e 100644 --- a/src/main/ipc/preflight-wsl-agent-detection.ts +++ b/src/main/ipc/preflight-wsl-agent-detection.ts @@ -2,7 +2,7 @@ import { quotePosixShell } from '../../shared/shell-argument-quoting' import path from 'node:path' import { buildPosixFallbackPathPrelude } from '../../shared/posix-version-manager-bin-dirs' import { buildPosixCommandPathLookupScript } from '../../shared/posix-command-path-lookup' -import { runWslProcess } from '../wsl/wsl-runner' +import { runWslProcess } from '../wsl/execution/wsl-runner' const WSL_AGENT_DETECTION_TIMEOUT_MS = 10000 const WSL_AGENT_DETECTION_PREFIX = '__ORCA_AGENT_PATH__' diff --git a/src/main/ipc/preflight-wsl-command.test.ts b/src/main/ipc/preflight-wsl-command.test.ts index 456823ff0be..ecfbdfbc19b 100644 --- a/src/main/ipc/preflight-wsl-command.test.ts +++ b/src/main/ipc/preflight-wsl-command.test.ts @@ -5,7 +5,7 @@ import { join } from 'node:path' import { beforeEach, describe, expect, it, vi } from 'vitest' const runWslProcessMock = vi.hoisted(() => vi.fn()) -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) import { runPreflightCommandInWsl } from './preflight-wsl-command' diff --git a/src/main/ipc/preflight-wsl-command.ts b/src/main/ipc/preflight-wsl-command.ts index 0ec44997e1b..b331c7d2910 100644 --- a/src/main/ipc/preflight-wsl-command.ts +++ b/src/main/ipc/preflight-wsl-command.ts @@ -1,5 +1,5 @@ import { buildPosixFallbackPathPrelude } from '../../shared/posix-version-manager-bin-dirs' -import { runWslProcess } from '../wsl/wsl-runner' +import { runWslProcess } from '../wsl/execution/wsl-runner' import type { WslPreflightTarget } from './preflight-wsl-agent-detection' export type PreflightWslCommandResult = { stdout: string; stderr: string } diff --git a/src/main/ipc/preflight-wsl-refusal-retry.ts b/src/main/ipc/preflight-wsl-refusal-retry.ts index b9edd8a8543..46ac1a4f2f4 100644 --- a/src/main/ipc/preflight-wsl-refusal-retry.ts +++ b/src/main/ipc/preflight-wsl-refusal-retry.ts @@ -1,6 +1,9 @@ import { BrowserWindow } from 'electron' -import { deferUntilWslDistroRunning } from '../wsl-background-distro-gate' -import { WslDistroStoppedError, WslDistroUnverifiableError } from '../wsl/wsl-unc-access-gate' +import { deferUntilWslDistroRunning } from '../wsl/discovery/wsl-background-distro-gate' +import { + WslDistroStoppedError, + WslDistroUnverifiableError +} from '../wsl/filesystem/wsl-unc-access-gate' export const PREFLIGHT_WSL_DISTRO_RUNNING_CHANNEL = 'preflight:wslDistroRunning' const RETRY_KEY = 'preflight-refused' diff --git a/src/main/ipc/preflight-wsl-stopped-distro.test.ts b/src/main/ipc/preflight-wsl-stopped-distro.test.ts index f2bc3e337fa..674860d1fbb 100644 --- a/src/main/ipc/preflight-wsl-stopped-distro.test.ts +++ b/src/main/ipc/preflight-wsl-stopped-distro.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as BackgroundDistroGate from '../wsl-background-distro-gate' +import type * as BackgroundDistroGate from '../wsl/discovery/wsl-background-distro-gate' const mocks = vi.hoisted(() => ({ handlers: new Map Promise>(), @@ -19,9 +19,11 @@ vi.mock('electron', () => ({ mocks.handlers.set(channel, handler) } })) -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess: mocks.runWslProcess })) -vi.mock('../wsl', () => ({ listWslDistrosAsync: mocks.listWslDistrosAsync })) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: mocks.runWslProcess })) +vi.mock('../wsl/discovery/distro-catalog', () => ({ + listWslDistrosAsync: mocks.listWslDistrosAsync +})) +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: mocks.readWslDistroRunningState, deferUntilWslDistroRunning: (distro: string, key: string, task: () => unknown) => diff --git a/src/main/ipc/preflight.ts b/src/main/ipc/preflight.ts index c1ebf7782c0..44a2b6a3188 100644 --- a/src/main/ipc/preflight.ts +++ b/src/main/ipc/preflight.ts @@ -18,7 +18,7 @@ import type { import { readZCodeInteractiveCapability } from '../zcode/interactive-capability' import { getPreflightWslTarget } from './preflight-runtime-target' -import { runAsWslExecUserAct } from '../wsl/wsl-background-exec-gate' +import { runAsWslExecUserAct } from '../wsl/discovery/wsl-background-exec-gate' import { deferRefusedPreflight } from './preflight-wsl-refusal-retry' type AgentDetectionRequest = PreflightRuntimeContext & { enabledOnly?: boolean } diff --git a/src/main/ipc/project-folder-link-path.ts b/src/main/ipc/project-folder-link-path.ts index 9ac6e30724a..f8264d29489 100644 --- a/src/main/ipc/project-folder-link-path.ts +++ b/src/main/ipc/project-folder-link-path.ts @@ -1,7 +1,7 @@ import { basename, dirname, isAbsolute, join, resolve } from 'node:path' import { lstat } from 'node:fs/promises' import { PATH_ACCESS_DENIED_MESSAGE } from './filesystem/filesystem-auth' -import { realpathAcrossWslDriveMount, windowsFsPath } from '../wsl/wsl-unc-drive-fs-path' +import { realpathAcrossWslDriveMount, windowsFsPath } from '../wsl/filesystem/wsl-unc-drive-fs-path' /** List only folders reached through a symlink whose own folder is inside a project. */ export async function resolveProjectFolderLinkPath( diff --git a/src/main/ipc/pty-attach-view-joins-main-start.test.ts b/src/main/ipc/pty-attach-view-joins-main-start.test.ts index 821440edca5..4c579d2f45d 100644 --- a/src/main/ipc/pty-attach-view-joins-main-start.test.ts +++ b/src/main/ipc/pty-attach-view-joins-main-start.test.ts @@ -45,7 +45,7 @@ vi.mock('../pi/titlebar-extension-service', () => vi.mock('../pty/shell-startup/pwsh', () => import('./pty/pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../wsl', async (importOriginal) => +vi.mock('../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty/pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../telemetry/client', () => diff --git a/src/main/ipc/pty-claude-agent-view-readiness.test.ts b/src/main/ipc/pty-claude-agent-view-readiness.test.ts index 64d95ac811b..733eeb9e0b1 100644 --- a/src/main/ipc/pty-claude-agent-view-readiness.test.ts +++ b/src/main/ipc/pty-claude-agent-view-readiness.test.ts @@ -27,7 +27,7 @@ vi.mock('../pi/titlebar-extension-service', () => vi.mock('../pty/shell-startup/pwsh', () => import('./pty/pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../wsl', async (importOriginal) => +vi.mock('../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty/pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../telemetry/client', () => diff --git a/src/main/ipc/pty-degraded-fallback-single-ingest.test.ts b/src/main/ipc/pty-degraded-fallback-single-ingest.test.ts index 1f0e5fbd0c4..f75fd0a6fdb 100644 --- a/src/main/ipc/pty-degraded-fallback-single-ingest.test.ts +++ b/src/main/ipc/pty-degraded-fallback-single-ingest.test.ts @@ -30,7 +30,7 @@ vi.mock('../pi/titlebar-extension-service', () => vi.mock('../pty/shell-startup/pwsh', () => import('./pty/pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../wsl', async (importOriginal) => +vi.mock('../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty/pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../telemetry/client', () => diff --git a/src/main/ipc/pty-spawn-saved-resume-admission.test.ts b/src/main/ipc/pty-spawn-saved-resume-admission.test.ts index 075037ec36a..ec508c1f33e 100644 --- a/src/main/ipc/pty-spawn-saved-resume-admission.test.ts +++ b/src/main/ipc/pty-spawn-saved-resume-admission.test.ts @@ -33,7 +33,7 @@ vi.mock('../pi/titlebar-extension-service', () => vi.mock('../pty/shell-startup/pwsh', () => import('./pty/pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../wsl', async (importOriginal) => +vi.mock('../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty/pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../telemetry/client', () => diff --git a/src/main/ipc/pty-spawn-scaling.performance.test.ts b/src/main/ipc/pty-spawn-scaling.performance.test.ts index ed2113944c8..46ac7a769a7 100644 --- a/src/main/ipc/pty-spawn-scaling.performance.test.ts +++ b/src/main/ipc/pty-spawn-scaling.performance.test.ts @@ -39,7 +39,7 @@ vi.mock('../pi/titlebar-extension-service', () => vi.mock('../pty/shell-startup/pwsh', () => import('./pty/pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../wsl', async (importOriginal) => +vi.mock('../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty/pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../telemetry/client', () => diff --git a/src/main/ipc/pty/delivery/pty-applied-size-reporting.test.ts b/src/main/ipc/pty/delivery/pty-applied-size-reporting.test.ts index 7581ce464f7..160f1040182 100644 --- a/src/main/ipc/pty/delivery/pty-applied-size-reporting.test.ts +++ b/src/main/ipc/pty/delivery/pty-applied-size-reporting.test.ts @@ -25,7 +25,7 @@ vi.mock('../../../pi/titlebar-extension-service', () => vi.mock('../../../pty/shell-startup/pwsh', () => import('../pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../../wsl', async (importOriginal) => +vi.mock('../../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../../telemetry/client', () => diff --git a/src/main/ipc/pty/delivery/pty-buffer-snapshot-dispatch.test.ts b/src/main/ipc/pty/delivery/pty-buffer-snapshot-dispatch.test.ts index a2fc9e90973..65762531eb6 100644 --- a/src/main/ipc/pty/delivery/pty-buffer-snapshot-dispatch.test.ts +++ b/src/main/ipc/pty/delivery/pty-buffer-snapshot-dispatch.test.ts @@ -25,7 +25,7 @@ vi.mock('../../../pi/titlebar-extension-service', () => vi.mock('../../../pty/shell-startup/pwsh', () => import('../pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../../wsl', async (importOriginal) => +vi.mock('../../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../../telemetry/client', () => diff --git a/src/main/ipc/pty/delivery/pty-delivery-health-heal.test.ts b/src/main/ipc/pty/delivery/pty-delivery-health-heal.test.ts index 2fe31de0f83..e763f1114a1 100644 --- a/src/main/ipc/pty/delivery/pty-delivery-health-heal.test.ts +++ b/src/main/ipc/pty/delivery/pty-delivery-health-heal.test.ts @@ -25,7 +25,7 @@ vi.mock('../../../pi/titlebar-extension-service', () => vi.mock('../../../pty/shell-startup/pwsh', () => import('../pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../../wsl', async (importOriginal) => +vi.mock('../../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../../telemetry/client', () => diff --git a/src/main/ipc/pty/delivery/pty-global-renderer-credit.test.ts b/src/main/ipc/pty/delivery/pty-global-renderer-credit.test.ts index 140762974ee..49d2400e865 100644 --- a/src/main/ipc/pty/delivery/pty-global-renderer-credit.test.ts +++ b/src/main/ipc/pty/delivery/pty-global-renderer-credit.test.ts @@ -25,7 +25,7 @@ vi.mock('../../../pi/titlebar-extension-service', () => vi.mock('../../../pty/shell-startup/pwsh', () => import('../pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../../wsl', async (importOriginal) => +vi.mock('../../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../../telemetry/client', () => diff --git a/src/main/ipc/pty/delivery/pty-ipc-gap-escape-state.test.ts b/src/main/ipc/pty/delivery/pty-ipc-gap-escape-state.test.ts index 22dbd135d66..67eb9f97002 100644 --- a/src/main/ipc/pty/delivery/pty-ipc-gap-escape-state.test.ts +++ b/src/main/ipc/pty/delivery/pty-ipc-gap-escape-state.test.ts @@ -23,7 +23,7 @@ vi.mock('../../../pi/titlebar-extension-service', () => vi.mock('../../../pty/shell-startup/pwsh', () => import('../pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../../wsl', async (importOriginal) => +vi.mock('../../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../../telemetry/client', () => diff --git a/src/main/ipc/pty/delivery/pty-ipc-hidden-delivery-gate.test.ts b/src/main/ipc/pty/delivery/pty-ipc-hidden-delivery-gate.test.ts index bb478d7d55e..ce4f01f9829 100644 --- a/src/main/ipc/pty/delivery/pty-ipc-hidden-delivery-gate.test.ts +++ b/src/main/ipc/pty/delivery/pty-ipc-hidden-delivery-gate.test.ts @@ -26,7 +26,7 @@ vi.mock('../../../pi/titlebar-extension-service', () => vi.mock('../../../pty/shell-startup/pwsh', () => import('../pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../../wsl', async (importOriginal) => +vi.mock('../../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../../telemetry/client', () => diff --git a/src/main/ipc/pty/delivery/pty-output-batching-drain.test.ts b/src/main/ipc/pty/delivery/pty-output-batching-drain.test.ts index 6d42b2761fa..dc101cebfe7 100644 --- a/src/main/ipc/pty/delivery/pty-output-batching-drain.test.ts +++ b/src/main/ipc/pty/delivery/pty-output-batching-drain.test.ts @@ -26,7 +26,7 @@ vi.mock('../../../pi/titlebar-extension-service', () => vi.mock('../../../pty/shell-startup/pwsh', () => import('../pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../../wsl', async (importOriginal) => +vi.mock('../../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../../telemetry/client', () => diff --git a/src/main/ipc/pty/delivery/pty-pending-output-cap.test.ts b/src/main/ipc/pty/delivery/pty-pending-output-cap.test.ts index 5e98d340587..067bdd53ae9 100644 --- a/src/main/ipc/pty/delivery/pty-pending-output-cap.test.ts +++ b/src/main/ipc/pty/delivery/pty-pending-output-cap.test.ts @@ -25,7 +25,7 @@ vi.mock('../../../pi/titlebar-extension-service', () => vi.mock('../../../pty/shell-startup/pwsh', () => import('../pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../../wsl', async (importOriginal) => +vi.mock('../../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../../telemetry/client', () => diff --git a/src/main/ipc/pty/delivery/pty-renderer-inflight-credit.test.ts b/src/main/ipc/pty/delivery/pty-renderer-inflight-credit.test.ts index 73bdc393af9..c3e84b2f7a1 100644 --- a/src/main/ipc/pty/delivery/pty-renderer-inflight-credit.test.ts +++ b/src/main/ipc/pty/delivery/pty-renderer-inflight-credit.test.ts @@ -26,7 +26,7 @@ vi.mock('../../../pi/titlebar-extension-service', () => vi.mock('../../../pty/shell-startup/pwsh', () => import('../pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../../wsl', async (importOriginal) => +vi.mock('../../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../../telemetry/client', () => diff --git a/src/main/ipc/pty/delivery/pty-renderer-lifecycle-delivery-reset.test.ts b/src/main/ipc/pty/delivery/pty-renderer-lifecycle-delivery-reset.test.ts index 9600290eff5..7444d701ff0 100644 --- a/src/main/ipc/pty/delivery/pty-renderer-lifecycle-delivery-reset.test.ts +++ b/src/main/ipc/pty/delivery/pty-renderer-lifecycle-delivery-reset.test.ts @@ -25,7 +25,7 @@ vi.mock('../../../pi/titlebar-extension-service', () => vi.mock('../../../pty/shell-startup/pwsh', () => import('../pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../../wsl', async (importOriginal) => +vi.mock('../../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../../telemetry/client', () => diff --git a/src/main/ipc/pty/host-env/assembly.ts b/src/main/ipc/pty/host-env/assembly.ts index 684ab9e88f8..83f4e3a5d99 100644 --- a/src/main/ipc/pty/host-env/assembly.ts +++ b/src/main/ipc/pty/host-env/assembly.ts @@ -10,7 +10,7 @@ import { ensureOpenCodeStartupPromptForLaunch } from '../../../opencode/opencode import { mimoCodeHookService } from '../../../mimo/hook-service' import { agentHookServer } from '../../../agent-hooks/server' import { wslHookRelayManager } from '../../../agent-hooks/wsl-hook-relay-manager' -import { wslInteropHealthMonitor } from '../../../wsl/wsl-interop-health' +import { wslInteropHealthMonitor } from '../../../wsl/execution/wsl-interop-health' import { piTitlebarExtensionService } from '../../../pi/titlebar-extension-service' import { prependOrcaCliDirToChildPath } from '../../../cli/orca-cli-child-path' import { getManagedWslCliDir, getWslCliCommandName } from '../../../cli/wsl-managed-cli' diff --git a/src/main/ipc/pty/host-env/codex-home.ts b/src/main/ipc/pty/host-env/codex-home.ts index c33dee34a65..2fec5588e32 100644 --- a/src/main/ipc/pty/host-env/codex-home.ts +++ b/src/main/ipc/pty/host-env/codex-home.ts @@ -18,7 +18,7 @@ import { isWslCodexHomeForHost } from '../../../pty/shell-startup/codex-home-wsl-env' import { isWslShellName } from '../../../../shared/local-windows-terminal-runtime' -import { parseWslPath } from '../../../wsl' +import { parseWslPath } from '../../../wsl/filesystem/unc-path-access' import { isWslTerminalSpawn } from '../wsl-terminal-spawn' export function shouldSkipCodexHomeEnvForWindowsShell( diff --git a/src/main/ipc/pty/host-env/spawn-cwd-wsl-stopped-folder.test.ts b/src/main/ipc/pty/host-env/spawn-cwd-wsl-stopped-folder.test.ts index d794500aba2..8fe4b032e8c 100644 --- a/src/main/ipc/pty/host-env/spawn-cwd-wsl-stopped-folder.test.ts +++ b/src/main/ipc/pty/host-env/spawn-cwd-wsl-stopped-folder.test.ts @@ -1,12 +1,12 @@ import type * as FsPromises from 'node:fs/promises' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as BackgroundDistroGateModule from '../../../wsl-background-distro-gate' +import type * as BackgroundDistroGateModule from '../../../wsl/discovery/wsl-background-distro-gate' import type * as WslMoveScopeGuardModule from '../../../persistence/moving-wsl-projects/wsl-move-scope-guard' import type { Store } from '../../../persistence/loading-store/store' import type { FolderWorkspace } from '../../../../shared/folder-workspace-types' import { folderWorkspaceKey } from '../../../../shared/workspace-scope' import { wslDistroHoldMessage } from '../../../../shared/wsl-distro-stopped-hold' -import { isWslUserActFor } from '../../../wsl/wsl-user-act-scope' +import { isWslUserActFor } from '../../../wsl/discovery/wsl-user-act-scope' const mocks = vi.hoisted(() => ({ stat: vi.fn<(path: string) => Promise<{ isDirectory(): boolean }>>(), @@ -16,7 +16,7 @@ vi.mock('node:fs/promises', async (importOriginal) => ({ ...(await importOriginal()), stat: mocks.stat })) -vi.mock('../../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: mocks.readWslDistroRunningState })) diff --git a/src/main/ipc/pty/host-env/spawn-cwd.ts b/src/main/ipc/pty/host-env/spawn-cwd.ts index 764ef4abe8f..2e9ed563ed0 100644 --- a/src/main/ipc/pty/host-env/spawn-cwd.ts +++ b/src/main/ipc/pty/host-env/spawn-cwd.ts @@ -30,7 +30,7 @@ import { blockedWslDistroForPath, runAsWslUserAct, wslDistroForPath -} from '../../../wsl/wsl-unc-access-gate' +} from '../../../wsl/filesystem/wsl-unc-access-gate' /** * A new PTY needs a workspace no WSL move is taking, and a folder that still exists. Reattaching to diff --git a/src/main/ipc/pty/host-env/startup-cwd-directory-exists.test.ts b/src/main/ipc/pty/host-env/startup-cwd-directory-exists.test.ts index bc64d444217..37b52ab6ad4 100644 --- a/src/main/ipc/pty/host-env/startup-cwd-directory-exists.test.ts +++ b/src/main/ipc/pty/host-env/startup-cwd-directory-exists.test.ts @@ -1,10 +1,10 @@ import { describe, expect, it, vi } from 'vitest' import { stat } from 'node:fs/promises' -import { wslUncDirectoryExistsAsync } from '../../../wsl' +import { wslUncDirectoryExistsAsync } from '../../../wsl/filesystem/unc-path-access' import { probeRecoveredStartupCwdDirectory } from './startup-cwd-directory-exists' vi.mock('node:fs/promises', () => ({ stat: vi.fn() })) -vi.mock('../../../wsl', () => ({ wslUncDirectoryExistsAsync: vi.fn() })) +vi.mock('../../../wsl/filesystem/unc-path-access', () => ({ wslUncDirectoryExistsAsync: vi.fn() })) describe('recovered folder evidence', () => { it.each([ diff --git a/src/main/ipc/pty/host-env/startup-cwd-directory-exists.ts b/src/main/ipc/pty/host-env/startup-cwd-directory-exists.ts index a8550d23d63..a399f9d62b1 100644 --- a/src/main/ipc/pty/host-env/startup-cwd-directory-exists.ts +++ b/src/main/ipc/pty/host-env/startup-cwd-directory-exists.ts @@ -1,6 +1,6 @@ import { stat } from 'node:fs/promises' import { isWslUncPath } from '../../../../shared/wsl-paths' -import { wslUncDirectoryExistsAsync } from '../../../wsl' +import { wslUncDirectoryExistsAsync } from '../../../wsl/filesystem/unc-path-access' export async function probeLocalStartupCwdDirectory(path: string): Promise { try { diff --git a/src/main/ipc/pty/provider/local-configure.ts b/src/main/ipc/pty/provider/local-configure.ts index c48c1f57e30..72290e45cef 100644 --- a/src/main/ipc/pty/provider/local-configure.ts +++ b/src/main/ipc/pty/provider/local-configure.ts @@ -7,7 +7,7 @@ import { isAgentStatusHooksEnabled } from '../../../agent-hooks/managed-agent-ho import { isPwshAvailableAsync } from '../../../pty/shell-startup/pwsh' import { LocalPtyProvider } from '../../../providers/local-pty/local-pty-provider' import type { LocalPtyProviderOptions } from '../../../providers/local-pty/local-pty-provider-types' -import { runAsWslLaunchUserAct } from '../../../wsl/wsl-background-exec-gate' +import { runAsWslLaunchUserAct } from '../../../wsl/discovery/wsl-background-exec-gate' import { addOrcaWslInteropEnv, stampWslOrchestrationCompatibilityHost diff --git a/src/main/ipc/pty/pty-absent-pane-respawn.test.ts b/src/main/ipc/pty/pty-absent-pane-respawn.test.ts index c7ef985d087..61ed0dfeb64 100644 --- a/src/main/ipc/pty/pty-absent-pane-respawn.test.ts +++ b/src/main/ipc/pty/pty-absent-pane-respawn.test.ts @@ -40,7 +40,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-activation-inventory-scope.test.ts b/src/main/ipc/pty/pty-activation-inventory-scope.test.ts index c0d5ba30ab6..e28ebe47d8b 100644 --- a/src/main/ipc/pty/pty-activation-inventory-scope.test.ts +++ b/src/main/ipc/pty/pty-activation-inventory-scope.test.ts @@ -25,7 +25,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-agent-launch-pane-attach.test.ts b/src/main/ipc/pty/pty-agent-launch-pane-attach.test.ts index 83b918c7eca..8b8e7eea85c 100644 --- a/src/main/ipc/pty/pty-agent-launch-pane-attach.test.ts +++ b/src/main/ipc/pty/pty-agent-launch-pane-attach.test.ts @@ -39,7 +39,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-antigravity-launch.test.ts b/src/main/ipc/pty/pty-antigravity-launch.test.ts index a77d7227329..f05a1713960 100644 --- a/src/main/ipc/pty/pty-antigravity-launch.test.ts +++ b/src/main/ipc/pty/pty-antigravity-launch.test.ts @@ -43,7 +43,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-closed-pane-spawn-refusal.test.ts b/src/main/ipc/pty/pty-closed-pane-spawn-refusal.test.ts index 08abb7a93f0..cc093b00df3 100644 --- a/src/main/ipc/pty/pty-closed-pane-spawn-refusal.test.ts +++ b/src/main/ipc/pty/pty-closed-pane-spawn-refusal.test.ts @@ -33,7 +33,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-codex-account-attribution.test.ts b/src/main/ipc/pty/pty-codex-account-attribution.test.ts index d52e0d6f71c..7e3cef815ea 100644 --- a/src/main/ipc/pty/pty-codex-account-attribution.test.ts +++ b/src/main/ipc/pty/pty-codex-account-attribution.test.ts @@ -32,7 +32,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-controller-ownership-routing.test.ts b/src/main/ipc/pty/pty-controller-ownership-routing.test.ts index 7389e10b15d..5912cb993d7 100644 --- a/src/main/ipc/pty/pty-controller-ownership-routing.test.ts +++ b/src/main/ipc/pty/pty-controller-ownership-routing.test.ts @@ -28,7 +28,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-controller-spawn-admission.test.ts b/src/main/ipc/pty/pty-controller-spawn-admission.test.ts index c6aaf309615..1d4f613ae59 100644 --- a/src/main/ipc/pty/pty-controller-spawn-admission.test.ts +++ b/src/main/ipc/pty/pty-controller-spawn-admission.test.ts @@ -35,7 +35,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-daemon-controller-teardown.test.ts b/src/main/ipc/pty/pty-daemon-controller-teardown.test.ts index 5e68392f09f..76ef7d4b575 100644 --- a/src/main/ipc/pty/pty-daemon-controller-teardown.test.ts +++ b/src/main/ipc/pty/pty-daemon-controller-teardown.test.ts @@ -29,7 +29,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-daemon-spawn-agent-home-env.test.ts b/src/main/ipc/pty/pty-daemon-spawn-agent-home-env.test.ts index 2e0c2b4ce93..a7498e2f171 100644 --- a/src/main/ipc/pty/pty-daemon-spawn-agent-home-env.test.ts +++ b/src/main/ipc/pty/pty-daemon-spawn-agent-home-env.test.ts @@ -32,7 +32,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-daemon-spawn-codex-auth.test.ts b/src/main/ipc/pty/pty-daemon-spawn-codex-auth.test.ts index b27d8b4267c..8414e5cc9bc 100644 --- a/src/main/ipc/pty/pty-daemon-spawn-codex-auth.test.ts +++ b/src/main/ipc/pty/pty-daemon-spawn-codex-auth.test.ts @@ -40,7 +40,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-daemon-spawn-session-identity.test.ts b/src/main/ipc/pty/pty-daemon-spawn-session-identity.test.ts index b30e7b3510d..bcfd7027958 100644 --- a/src/main/ipc/pty/pty-daemon-spawn-session-identity.test.ts +++ b/src/main/ipc/pty/pty-daemon-spawn-session-identity.test.ts @@ -37,7 +37,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-daemon-spawn-wsl-runtime.test.ts b/src/main/ipc/pty/pty-daemon-spawn-wsl-runtime.test.ts index 837defefdde..07815cefc4a 100644 --- a/src/main/ipc/pty/pty-daemon-spawn-wsl-runtime.test.ts +++ b/src/main/ipc/pty/pty-daemon-spawn-wsl-runtime.test.ts @@ -6,7 +6,7 @@ import { createDaemonActiveProviderFixtures } from './pty-ipc-daemon-provider-fixtures' import { delimiter, join } from 'node:path' -import { _setWslCachesForTests } from '../../wsl' +import { _setWslCachesForTests } from '../../wsl/discovery/distro-catalog' import { registerPtyHandlers } from './register-handlers' vi.mock('electron', () => import('./pty-ipc-mock-registry').then((m) => m.electronModuleMock())) @@ -30,7 +30,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => @@ -55,7 +55,7 @@ vi.mock('../../codex/codex-state-db-backfill-recovery', () => import('./pty-ipc-mock-registry').then((m) => m.codexBackfillRecoveryModuleMock()) ) // Fake-win32 runs have no wsl.exe: the distro runs, so main's background-start hold passes (E9). -vi.mock('../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: vi.fn(async () => 'running') })) diff --git a/src/main/ipc/pty/pty-dead-owner-respawn.test.ts b/src/main/ipc/pty/pty-dead-owner-respawn.test.ts index 82352b32dd4..85efbe891e8 100644 --- a/src/main/ipc/pty/pty-dead-owner-respawn.test.ts +++ b/src/main/ipc/pty/pty-dead-owner-respawn.test.ts @@ -29,7 +29,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-dispatcher-handshake-osc-answers.test.ts b/src/main/ipc/pty/pty-dispatcher-handshake-osc-answers.test.ts index a9d84aed833..a133c92db5d 100644 --- a/src/main/ipc/pty/pty-dispatcher-handshake-osc-answers.test.ts +++ b/src/main/ipc/pty/pty-dispatcher-handshake-osc-answers.test.ts @@ -28,7 +28,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-hidden-at-spawn-mark.test.ts b/src/main/ipc/pty/pty-hidden-at-spawn-mark.test.ts index eaec6fa4377..090f4f3feeb 100644 --- a/src/main/ipc/pty/pty-hidden-at-spawn-mark.test.ts +++ b/src/main/ipc/pty/pty-hidden-at-spawn-mark.test.ts @@ -30,7 +30,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-ipc-hidden-restore-ack.test.ts b/src/main/ipc/pty/pty-ipc-hidden-restore-ack.test.ts index c287c7015df..3273ab10887 100644 --- a/src/main/ipc/pty/pty-ipc-hidden-restore-ack.test.ts +++ b/src/main/ipc/pty/pty-ipc-hidden-restore-ack.test.ts @@ -25,7 +25,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-ipc-mock-registry.ts b/src/main/ipc/pty/pty-ipc-mock-registry.ts index a2daee37770..3f36b4e479c 100644 --- a/src/main/ipc/pty/pty-ipc-mock-registry.ts +++ b/src/main/ipc/pty/pty-ipc-mock-registry.ts @@ -1,6 +1,6 @@ import { vi } from 'vitest' import type { Mock } from 'vitest' -import type * as Wsl from '../../wsl' +import type * as Wsl from '../../wsl/filesystem/unc-path-access' import type * as FsPromises from 'node:fs/promises' // vi.mock hoists per file; shared factories keep every split suite on the same spy instances. diff --git a/src/main/ipc/pty/pty-ipc-suite-environment.ts b/src/main/ipc/pty/pty-ipc-suite-environment.ts index d74b691db8c..101d1337637 100644 --- a/src/main/ipc/pty/pty-ipc-suite-environment.ts +++ b/src/main/ipc/pty/pty-ipc-suite-environment.ts @@ -55,7 +55,7 @@ import { import { setLocalPtyProvider } from './provider/registry' import { _resetHiddenRendererPtyDeliveryGateForTest } from './delivery/pty-hidden-delivery-gate' import { __resetShellStartupEnvCache } from '../../pty/shell-startup/shell-startup-env' -import { _resetWslCachesForTests } from '../../wsl' +import { _resetWslCachesForTests } from '../../wsl/discovery/distro-catalog' export type PtyIpcTestWebContents = { id: number diff --git a/src/main/ipc/pty/pty-launch-parity.test.ts b/src/main/ipc/pty/pty-launch-parity.test.ts index d3ec7c4c1ca..e82099bf04d 100644 --- a/src/main/ipc/pty/pty-launch-parity.test.ts +++ b/src/main/ipc/pty/pty-launch-parity.test.ts @@ -76,7 +76,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('node:fs/promises', async (importOriginal) => @@ -133,7 +133,7 @@ vi.mock('../../../shared/openssh-default-shell', () => ({ readOpenSshDefaultShell: vi.fn(() => '') })) // Fake-win32 runs have no wsl.exe: the distro runs, so main's background-start hold passes (E9). -vi.mock('../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: vi.fn(async () => 'running') })) diff --git a/src/main/ipc/pty/pty-launch-race-parity.test.ts b/src/main/ipc/pty/pty-launch-race-parity.test.ts index a0ad35bbad3..fe31b5a2679 100644 --- a/src/main/ipc/pty/pty-launch-race-parity.test.ts +++ b/src/main/ipc/pty/pty-launch-race-parity.test.ts @@ -62,7 +62,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-listener-teardown-and-orphans.test.ts b/src/main/ipc/pty/pty-listener-teardown-and-orphans.test.ts index 3aa0134f58c..d3449e891d9 100644 --- a/src/main/ipc/pty/pty-listener-teardown-and-orphans.test.ts +++ b/src/main/ipc/pty/pty-listener-teardown-and-orphans.test.ts @@ -35,7 +35,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-login-shell-startup-commands.test.ts b/src/main/ipc/pty/pty-login-shell-startup-commands.test.ts index 8e7bb668800..f86b65f4312 100644 --- a/src/main/ipc/pty/pty-login-shell-startup-commands.test.ts +++ b/src/main/ipc/pty/pty-login-shell-startup-commands.test.ts @@ -35,7 +35,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-pane-claim-arbitration.test.ts b/src/main/ipc/pty/pty-pane-claim-arbitration.test.ts index 39dc56c32d5..9ad622b2e90 100644 --- a/src/main/ipc/pty/pty-pane-claim-arbitration.test.ts +++ b/src/main/ipc/pty/pty-pane-claim-arbitration.test.ts @@ -30,7 +30,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-pane-materialization-race.test.ts b/src/main/ipc/pty/pty-pane-materialization-race.test.ts index 1d28cb041bf..83ca2e3ca83 100644 --- a/src/main/ipc/pty/pty-pane-materialization-race.test.ts +++ b/src/main/ipc/pty/pty-pane-materialization-race.test.ts @@ -31,7 +31,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-pane-reservation-settlement.test.ts b/src/main/ipc/pty/pty-pane-reservation-settlement.test.ts index 422f14faa6b..5b6323ae3d8 100644 --- a/src/main/ipc/pty/pty-pane-reservation-settlement.test.ts +++ b/src/main/ipc/pty/pty-pane-reservation-settlement.test.ts @@ -26,7 +26,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-pane-restart-replace.test.ts b/src/main/ipc/pty/pty-pane-restart-replace.test.ts index bf55b981174..480a8ad6837 100644 --- a/src/main/ipc/pty/pty-pane-restart-replace.test.ts +++ b/src/main/ipc/pty/pty-pane-restart-replace.test.ts @@ -31,7 +31,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-persisted-incarnation-repair.test.ts b/src/main/ipc/pty/pty-persisted-incarnation-repair.test.ts index e4fe7a92b4c..ecca0410cfa 100644 --- a/src/main/ipc/pty/pty-persisted-incarnation-repair.test.ts +++ b/src/main/ipc/pty/pty-persisted-incarnation-repair.test.ts @@ -34,7 +34,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-renderer-liveness-guard.test.ts b/src/main/ipc/pty/pty-renderer-liveness-guard.test.ts index 068cf96431a..f96f3057fa9 100644 --- a/src/main/ipc/pty/pty-renderer-liveness-guard.test.ts +++ b/src/main/ipc/pty/pty-renderer-liveness-guard.test.ts @@ -26,7 +26,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-restore-record-seeding.test.ts b/src/main/ipc/pty/pty-restore-record-seeding.test.ts index 8124a4d70ea..37df2196911 100644 --- a/src/main/ipc/pty/pty-restore-record-seeding.test.ts +++ b/src/main/ipc/pty/pty-restore-record-seeding.test.ts @@ -43,7 +43,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-runtime-hidden-at-spawn-mark.test.ts b/src/main/ipc/pty/pty-runtime-hidden-at-spawn-mark.test.ts index 27b3269c063..456c80d06b6 100644 --- a/src/main/ipc/pty/pty-runtime-hidden-at-spawn-mark.test.ts +++ b/src/main/ipc/pty/pty-runtime-hidden-at-spawn-mark.test.ts @@ -27,7 +27,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-runtime-kill-and-exit.test.ts b/src/main/ipc/pty/pty-runtime-kill-and-exit.test.ts index 09bb1e05f3f..fe3320dd3ac 100644 --- a/src/main/ipc/pty/pty-runtime-kill-and-exit.test.ts +++ b/src/main/ipc/pty/pty-runtime-kill-and-exit.test.ts @@ -30,7 +30,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-runtime-ssh-binding-persistence.test.ts b/src/main/ipc/pty/pty-runtime-ssh-binding-persistence.test.ts index 85b307e76da..efd8ed800ec 100644 --- a/src/main/ipc/pty/pty-runtime-ssh-binding-persistence.test.ts +++ b/src/main/ipc/pty/pty-runtime-ssh-binding-persistence.test.ts @@ -24,7 +24,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-serializer-settlement-mapping.test.ts b/src/main/ipc/pty/pty-serializer-settlement-mapping.test.ts index c6b82b6cbee..0b85c788cd6 100644 --- a/src/main/ipc/pty/pty-serializer-settlement-mapping.test.ts +++ b/src/main/ipc/pty/pty-serializer-settlement-mapping.test.ts @@ -30,7 +30,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-session-liveness-and-ownership.test.ts b/src/main/ipc/pty/pty-session-liveness-and-ownership.test.ts index 8d1d2e5ec4e..eeb72306485 100644 --- a/src/main/ipc/pty/pty-session-liveness-and-ownership.test.ts +++ b/src/main/ipc/pty/pty-session-liveness-and-ownership.test.ts @@ -28,7 +28,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-spawn-codex-home-unavailable.test.ts b/src/main/ipc/pty/pty-spawn-codex-home-unavailable.test.ts index 118bed4e4ca..1ca731b933c 100644 --- a/src/main/ipc/pty/pty-spawn-codex-home-unavailable.test.ts +++ b/src/main/ipc/pty/pty-spawn-codex-home-unavailable.test.ts @@ -28,7 +28,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-spawn-cwd-fallback-hung-folder.test.ts b/src/main/ipc/pty/pty-spawn-cwd-fallback-hung-folder.test.ts index 8a39d28590c..2c9b5a582c1 100644 --- a/src/main/ipc/pty/pty-spawn-cwd-fallback-hung-folder.test.ts +++ b/src/main/ipc/pty/pty-spawn-cwd-fallback-hung-folder.test.ts @@ -34,7 +34,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-spawn-cwd-fallback.test.ts b/src/main/ipc/pty/pty-spawn-cwd-fallback.test.ts index e7c8a61ff9f..589ddda56a0 100644 --- a/src/main/ipc/pty/pty-spawn-cwd-fallback.test.ts +++ b/src/main/ipc/pty/pty-spawn-cwd-fallback.test.ts @@ -7,7 +7,7 @@ import { existsSyncMock } from './pty-ipc-mock-registry' import { setupPtyIpcSuite } from './pty-ipc-test-harness' -import { _setWslCachesForTests } from '../../wsl' +import { _setWslCachesForTests } from '../../wsl/discovery/distro-catalog' import { acquireWatcherRemovalGate } from '../watcher-removal-gate' import { registerPtyHandlers } from './register-handlers' import { join } from 'node:path' @@ -34,7 +34,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('node:fs/promises', async (importOriginal) => diff --git a/src/main/ipc/pty/pty-spawn-env-agent-overlays.test.ts b/src/main/ipc/pty/pty-spawn-env-agent-overlays.test.ts index 40a24e97e88..95b8751a460 100644 --- a/src/main/ipc/pty/pty-spawn-env-agent-overlays.test.ts +++ b/src/main/ipc/pty/pty-spawn-env-agent-overlays.test.ts @@ -39,7 +39,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-spawn-env-codex-home-routing.test.ts b/src/main/ipc/pty/pty-spawn-env-codex-home-routing.test.ts index 2d4c4a77974..8778200c8dc 100644 --- a/src/main/ipc/pty/pty-spawn-env-codex-home-routing.test.ts +++ b/src/main/ipc/pty/pty-spawn-env-codex-home-routing.test.ts @@ -31,7 +31,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-spawn-env-codex-resume-provenance.test.ts b/src/main/ipc/pty/pty-spawn-env-codex-resume-provenance.test.ts index ab21d47513c..c23729f4080 100644 --- a/src/main/ipc/pty/pty-spawn-env-codex-resume-provenance.test.ts +++ b/src/main/ipc/pty/pty-spawn-env-codex-resume-provenance.test.ts @@ -30,7 +30,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-spawn-env-terminal-basics.test.ts b/src/main/ipc/pty/pty-spawn-env-terminal-basics.test.ts index 5eab84c35b4..2235f0b3aa3 100644 --- a/src/main/ipc/pty/pty-spawn-env-terminal-basics.test.ts +++ b/src/main/ipc/pty/pty-spawn-env-terminal-basics.test.ts @@ -51,7 +51,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-spawn-runtime-handle-binding.test.ts b/src/main/ipc/pty/pty-spawn-runtime-handle-binding.test.ts index dc3e6d9b7d9..12503b83a22 100644 --- a/src/main/ipc/pty/pty-spawn-runtime-handle-binding.test.ts +++ b/src/main/ipc/pty/pty-spawn-runtime-handle-binding.test.ts @@ -34,7 +34,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-spawn-wsl-passive-restore-hold.test.ts b/src/main/ipc/pty/pty-spawn-wsl-passive-restore-hold.test.ts index a9f667f2093..f280288d588 100644 --- a/src/main/ipc/pty/pty-spawn-wsl-passive-restore-hold.test.ts +++ b/src/main/ipc/pty/pty-spawn-wsl-passive-restore-hold.test.ts @@ -25,7 +25,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('node:fs/promises', async (importOriginal) => @@ -55,7 +55,7 @@ vi.mock('../../codex/codex-state-db-backfill-recovery', () => const runningStateMock = vi.hoisted(() => vi.fn(async (_distro: string, _options?: { startedAfter?: number }) => 'stopped') ) -vi.mock('../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: runningStateMock })) diff --git a/src/main/ipc/pty/pty-ssh-stop-verdict.test.ts b/src/main/ipc/pty/pty-ssh-stop-verdict.test.ts index 52b70edef2d..9df9d0dc749 100644 --- a/src/main/ipc/pty/pty-ssh-stop-verdict.test.ts +++ b/src/main/ipc/pty/pty-ssh-stop-verdict.test.ts @@ -30,7 +30,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-startup-barrier-and-listing.test.ts b/src/main/ipc/pty/pty-startup-barrier-and-listing.test.ts index 5595463c687..cc79cb73fca 100644 --- a/src/main/ipc/pty/pty-startup-barrier-and-listing.test.ts +++ b/src/main/ipc/pty/pty-startup-barrier-and-listing.test.ts @@ -27,7 +27,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-startup-swap-window-presence.test.ts b/src/main/ipc/pty/pty-startup-swap-window-presence.test.ts index ee97f09f8c7..423330f6660 100644 --- a/src/main/ipc/pty/pty-startup-swap-window-presence.test.ts +++ b/src/main/ipc/pty/pty-startup-swap-window-presence.test.ts @@ -24,7 +24,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-windows-shell-selection.test.ts b/src/main/ipc/pty/pty-windows-shell-selection.test.ts index 8f2483703de..6b4090a9f57 100644 --- a/src/main/ipc/pty/pty-windows-shell-selection.test.ts +++ b/src/main/ipc/pty/pty-windows-shell-selection.test.ts @@ -34,7 +34,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/pty-write-ipc-validation.test.ts b/src/main/ipc/pty/pty-write-ipc-validation.test.ts index 4fd359ddd9c..1f1ed23b0e4 100644 --- a/src/main/ipc/pty/pty-write-ipc-validation.test.ts +++ b/src/main/ipc/pty/pty-write-ipc-validation.test.ts @@ -34,7 +34,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/register-without-renderer.test.ts b/src/main/ipc/pty/register-without-renderer.test.ts index 9986f618cb5..e27192aa075 100644 --- a/src/main/ipc/pty/register-without-renderer.test.ts +++ b/src/main/ipc/pty/register-without-renderer.test.ts @@ -30,7 +30,7 @@ vi.mock('../../pi/titlebar-extension-service', () => vi.mock('../../pty/shell-startup/pwsh', () => import('./pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../wsl', async (importOriginal) => +vi.mock('../../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../../telemetry/client', () => diff --git a/src/main/ipc/pty/runtime/spawn-preflight-wsl-background-hold.test.ts b/src/main/ipc/pty/runtime/spawn-preflight-wsl-background-hold.test.ts index 2e1be2667e9..472a4744c05 100644 --- a/src/main/ipc/pty/runtime/spawn-preflight-wsl-background-hold.test.ts +++ b/src/main/ipc/pty/runtime/spawn-preflight-wsl-background-hold.test.ts @@ -1,15 +1,15 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as BackgroundDistroGateModule from '../../../wsl-background-distro-gate' +import type * as BackgroundDistroGateModule from '../../../wsl/discovery/wsl-background-distro-gate' import { wslDistroHoldMessage } from '../../../../shared/wsl-distro-stopped-hold' import { prepareRuntimePtySpawn } from './spawn-preflight' import { createRuntimePtySpawnState, type RuntimePtySpawnArgs } from './spawn-state' import { makeRuntimePtySpawnTestDeps } from './spawn-preflight-test-deps-fixture' -import { isWslUserActFor } from '../../../wsl/wsl-user-act-scope' +import { isWslUserActFor } from '../../../wsl/discovery/wsl-user-act-scope' const mocks = vi.hoisted(() => ({ readWslDistroRunningState: vi.fn<() => Promise<'running' | 'stopped' | 'unverifiable'>>() })) -vi.mock('../../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: mocks.readWslDistroRunningState })) diff --git a/src/main/ipc/pty/spawn-execute.ts b/src/main/ipc/pty/spawn-execute.ts index 1570f0826cb..be3d9dffb4d 100644 --- a/src/main/ipc/pty/spawn-execute.ts +++ b/src/main/ipc/pty/spawn-execute.ts @@ -1,7 +1,10 @@ import type { PtySpawnResult } from '../../providers/pty-provider-contract' import { ptyIncarnationById } from './provider/ownership-state' import { ensureWslHookRelayForReattach } from '../../agent-hooks/wsl-hook-relay-reattach' -import { noteWslDistroWoken, noteWslDistrosRunning } from '../../wsl-background-distro-gate' +import { + noteWslDistroWoken, + noteWslDistrosRunning +} from '../../wsl/discovery/wsl-background-distro-gate' import { agentSessionOwners, assertSpawnReplyWasLive, diff --git a/src/main/ipc/pty/spawn-host-env-wsl-passive-restore.test.ts b/src/main/ipc/pty/spawn-host-env-wsl-passive-restore.test.ts index 2e17da57c38..3387ef0d94d 100644 --- a/src/main/ipc/pty/spawn-host-env-wsl-passive-restore.test.ts +++ b/src/main/ipc/pty/spawn-host-env-wsl-passive-restore.test.ts @@ -23,22 +23,22 @@ vi.mock('@orca/process-host', async (importOriginal) => ({ runProcess: mocks.regQuery })) // wsl.exe's own list is unavailable, so the default comes from the registry alone. -vi.mock('../../wsl', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/distro-catalog', async (importOriginal) => ({ ...(await importOriginal>()), listWslDistrosAsync: async () => [] })) vi.mock('../../codex/codex-state-db-backfill-recovery', () => ({ ensureCodexStateDbBackfillRecoveryStarted: mocks.ensureBackfill })) -vi.mock('../../wsl/wsl-unc-access-gate', async (importOriginal) => ({ +vi.mock('../../wsl/filesystem/wsl-unc-access-gate', async (importOriginal) => ({ ...(await importOriginal>()), blockedWslDistroForPath: mocks.blockedPath })) import { resolvePtySpawnHostEnv } from './spawn-host-env' import { noCodexResumeLaunch, stripSequencedStartupResumeArgv } from './host-env/codex-resume' -import { isWslUserActFor } from '../../wsl/wsl-user-act-scope' -import { resetWslDefaultDistroForTests } from '../../wsl/wsl-default-distro' +import { isWslUserActFor } from '../../wsl/discovery/wsl-user-act-scope' +import { resetWslDefaultDistroForTests } from '../../wsl/discovery/wsl-default-distro' import type { IPtyProvider } from '../../providers/pty-provider-contract' import type { CodexAccountSelectionTarget } from '../../codex-accounts/runtime-selection' diff --git a/src/main/ipc/pty/spawn-host-env.ts b/src/main/ipc/pty/spawn-host-env.ts index a0ea2ab367b..44317683066 100644 --- a/src/main/ipc/pty/spawn-host-env.ts +++ b/src/main/ipc/pty/spawn-host-env.ts @@ -18,8 +18,8 @@ import { stampWslOrchestrationCompatibilityHost } from '../../pty/shell-startup/ import { getRuntimeSourceStamp } from '../../runtime/host-descriptor' import type { OrcaRuntimeService } from '../../runtime/orca-runtime' import { buildPtyHostEnv } from './host-env/assembly' -import { blockedWslDistroForPath } from '../../wsl/wsl-unc-access-gate' -import { runAsWslLaunchUserAct } from '../../wsl/wsl-background-exec-gate' +import { blockedWslDistroForPath } from '../../wsl/filesystem/wsl-unc-access-gate' +import { runAsWslLaunchUserAct } from '../../wsl/discovery/wsl-background-exec-gate' import { codexHomePathsEqual, getCompatibleSelectedCodexHomePath, diff --git a/src/main/ipc/pty/spawn-startup-target.ts b/src/main/ipc/pty/spawn-startup-target.ts index d60568defee..6fc66876d6c 100644 --- a/src/main/ipc/pty/spawn-startup-target.ts +++ b/src/main/ipc/pty/spawn-startup-target.ts @@ -24,7 +24,7 @@ import { wslHoldReadAnchor as wslHoldReadAnchorNow } from '../../daemon/daemon-wsl-passive-restore-hold' import { normalizeWindowsTerminalCwd } from '../../providers/windows-shell-args' -import { wslUncDirectoryExistsAsync } from '../../wsl' +import { wslUncDirectoryExistsAsync } from '../../wsl/filesystem/unc-path-access' import { getCodexSelectionTargetForPty } from './host-env/codex-home' import { probeLocalStartupCwdDirectory } from './host-env/startup-cwd-directory-exists' diff --git a/src/main/ipc/pty/wsl-terminal-spawn.ts b/src/main/ipc/pty/wsl-terminal-spawn.ts index 646eebb7727..2dff7f8cb2d 100644 --- a/src/main/ipc/pty/wsl-terminal-spawn.ts +++ b/src/main/ipc/pty/wsl-terminal-spawn.ts @@ -1,5 +1,5 @@ import { isWslShellName } from '../../../shared/local-windows-terminal-runtime' -import { parseWslPath } from '../../wsl' +import { parseWslPath } from '../../wsl/filesystem/unc-path-access' /** A local terminal that runs in WSL: a WSL shell, or a folder under `\\wsl.localhost\…`. */ export function isWslTerminalSpawn( diff --git a/src/main/ipc/qoder-desktop-execution-host.test.ts b/src/main/ipc/qoder-desktop-execution-host.test.ts index 5e3732dc6ce..ae4b11708e1 100644 --- a/src/main/ipc/qoder-desktop-execution-host.test.ts +++ b/src/main/ipc/qoder-desktop-execution-host.test.ts @@ -46,7 +46,7 @@ vi.mock('../pi/titlebar-extension-service', () => vi.mock('../pty/shell-startup/pwsh', () => import('./pty/pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../wsl', async (importOriginal) => +vi.mock('../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty/pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../telemetry/client', () => 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 05c849e74a2..9fd7e8b7cf3 100644 --- a/src/main/ipc/qoder-independent-renderer-spawn-review.test.ts +++ b/src/main/ipc/qoder-independent-renderer-spawn-review.test.ts @@ -34,7 +34,7 @@ vi.mock('../pi/titlebar-extension-service', () => vi.mock('../pty/shell-startup/pwsh', () => import('./pty/pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../wsl', async (importOriginal) => +vi.mock('../wsl/filesystem/unc-path-access', async (importOriginal) => (await import('./pty/pty-ipc-mock-registry')).wslModuleMock(await importOriginal()) ) vi.mock('../telemetry/client', () => diff --git a/src/main/ipc/repos-remote-base-ref-queries.test.ts b/src/main/ipc/repos-remote-base-ref-queries.test.ts index b012d53ee56..732441100d4 100644 --- a/src/main/ipc/repos-remote-base-ref-queries.test.ts +++ b/src/main/ipc/repos-remote-base-ref-queries.test.ts @@ -3,7 +3,7 @@ import type * as GitExecFileModule from '../git/command-runner/git-exec-file' import { beforeEach, describe, expect, it, vi } from 'vitest' import type * as GitRunner from '../git/runner' import type * as RepoModule from '../git/repo' -import type * as WslUncAccessGate from '../wsl/wsl-unc-access-gate' +import type * as WslUncAccessGate from '../wsl/filesystem/wsl-unc-access-gate' const { reposMocks, moduleMocks, gitRepoProbeMocks } = await vi.hoisted(async () => { const moduleMocks = await import('./repos-remote-test-harness') @@ -44,7 +44,7 @@ vi.mock('../workspaces/creation/worktree-root-preparation', () => moduleMocks.worktreeRootPreparationModuleMock(reposMocks) ) // The stopped-distro gate has its own tests; here it must not hide the routing under test. -vi.mock('../wsl/wsl-unc-access-gate', async (importOriginal) => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', async (importOriginal) => ({ ...(await importOriginal()), blockedWslDistroForPath: vi.fn(async () => null) })) diff --git a/src/main/ipc/repos/base-ref-default-wsl-gate.test.ts b/src/main/ipc/repos/base-ref-default-wsl-gate.test.ts index c6be2d9803d..5a18345fac4 100644 --- a/src/main/ipc/repos/base-ref-default-wsl-gate.test.ts +++ b/src/main/ipc/repos/base-ref-default-wsl-gate.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as DistroGateModule from '../../wsl-background-distro-gate' +import type * as DistroGateModule from '../../wsl/discovery/wsl-background-distro-gate' import type { Repo } from '../../../shared/repo-types' const mocks = vi.hoisted(() => { @@ -33,7 +33,7 @@ vi.mock('../../git/repo', () => ({ vi.mock('../../workspaces/execution-host/project-runtime-git-options', () => ({ getProjectRuntimeReadGitOptions: () => mocks.state.gitOptions })) -vi.mock('../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: vi.fn(async () => mocks.state.distroState) })) @@ -42,7 +42,7 @@ import { registerBaseRefQueryHandlers } from './base-ref-query-handlers' import { _resetWslBackgroundDistroGateForTests, noteWslDistrosRunning -} from '../../wsl-background-distro-gate' +} from '../../wsl/discovery/wsl-background-distro-gate' import { RuntimeRepositoryRefQueries } from '../../runtime/runtime-repository-ref-queries' const WSL_REPO = '\\\\wsl.localhost\\Ubuntu\\home\\me\\repo' diff --git a/src/main/ipc/repos/base-ref-query-handlers.ts b/src/main/ipc/repos/base-ref-query-handlers.ts index 89952efb602..4d351f47014 100644 --- a/src/main/ipc/repos/base-ref-query-handlers.ts +++ b/src/main/ipc/repos/base-ref-query-handlers.ts @@ -14,7 +14,7 @@ import { } from '../../../shared/execution-host' import { getBaseRefDefault, getRemoteCount, searchBaseRefDetails } from '../../git/repo' import { getProjectRuntimeReadGitOptions } from '../../workspaces/execution-host/project-runtime-git-options' -import { blockedWslDistroForPath } from '../../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath } from '../../wsl/filesystem/wsl-unc-access-gate' import { broadcastWhenWslDistroRunning } from '../preflight-wsl-refusal-retry' export function registerBaseRefQueryHandlers(store: Store): void { diff --git a/src/main/ipc/repos/local-repo-registration.ts b/src/main/ipc/repos/local-repo-registration.ts index 6ab5b6b7d47..68232584d9e 100644 --- a/src/main/ipc/repos/local-repo-registration.ts +++ b/src/main/ipc/repos/local-repo-registration.ts @@ -14,7 +14,7 @@ import { getRepoExecutionHostId, LOCAL_EXECUTION_HOST_ID } from '../../../shared import { findProjectAtSameRealPath } from '../../workspaces/catalog/project-realpath-identity' import { detectRepoIconAndUpstream } from '../../repository-icons/repo-icon-autodetect' import { prepareLocalWorktreeRootForRepo } from '../../workspaces/creation/worktree-root-preparation' -import { describeWslUncAccessDenied } from '../../wsl/wsl-unc-access-denied' +import { describeWslUncAccessDenied } from '../../wsl/filesystem/wsl-unc-access-denied' export async function addLocalRepoFromPath( store: Store, diff --git a/src/main/ipc/shell-path-existence-handlers.ts b/src/main/ipc/shell-path-existence-handlers.ts index 8a16dae47d5..8aeffca51f0 100644 --- a/src/main/ipc/shell-path-existence-handlers.ts +++ b/src/main/ipc/shell-path-existence-handlers.ts @@ -4,7 +4,7 @@ import { type ShellPathExistence } from '../../shared/path-existence-batch' import { pathExists } from './shell-owned-path-target' -import { guardWslUncPathAccess, WslDistroStoppedError } from '../wsl/wsl-unc-access-gate' +import { guardWslUncPathAccess, WslDistroStoppedError } from '../wsl/filesystem/wsl-unc-access-gate' /** Existence checks of host paths; a stopped WSL distro's UNC path is refused unless a user act asks (E9). */ export function registerShellPathExistenceHandlers(): void { diff --git a/src/main/ipc/shell-paths-exist-wsl-stopped-distro.test.ts b/src/main/ipc/shell-paths-exist-wsl-stopped-distro.test.ts index b266bfd25a8..39a6e5c0ad5 100644 --- a/src/main/ipc/shell-paths-exist-wsl-stopped-distro.test.ts +++ b/src/main/ipc/shell-paths-exist-wsl-stopped-distro.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as BackgroundDistroGate from '../wsl-background-distro-gate' +import type * as BackgroundDistroGate from '../wsl/discovery/wsl-background-distro-gate' import type * as ShellOwnedPathTarget from './shell-owned-path-target' const mocks = vi.hoisted(() => ({ @@ -16,7 +16,7 @@ vi.mock('electron', () => ({ shell: {}, dialog: {} })) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: mocks.readWslDistroRunningState })) diff --git a/src/main/ipc/skill-install-management-ipc-handlers.test.ts b/src/main/ipc/skill-install-management-ipc-handlers.test.ts index dc8de356288..136ef784ee9 100644 --- a/src/main/ipc/skill-install-management-ipc-handlers.test.ts +++ b/src/main/ipc/skill-install-management-ipc-handlers.test.ts @@ -30,7 +30,7 @@ vi.mock('../skills/skill-runtime-capability', () => ({ supportsSkillRuntimeManagement: supportsManagementMock })) -vi.mock('../wsl', () => ({ listWslDistrosAsync: vi.fn(async () => []) })) +vi.mock('../wsl/discovery/distro-catalog', () => ({ listWslDistrosAsync: vi.fn(async () => []) })) import { registerSkillInstallManagementIpcHandlers } from './skill-install-management-ipc-handlers' diff --git a/src/main/ipc/skill-install-management-ipc-handlers.ts b/src/main/ipc/skill-install-management-ipc-handlers.ts index 7854223c5d6..45dce52929d 100644 --- a/src/main/ipc/skill-install-management-ipc-handlers.ts +++ b/src/main/ipc/skill-install-management-ipc-handlers.ts @@ -18,7 +18,7 @@ import { supportsSkillRuntimeBundleInstall, supportsSkillRuntimeManagement } from '../skills/skill-runtime-capability' -import { listWslDistrosAsync } from '../wsl' +import { listWslDistrosAsync } from '../wsl/discovery/distro-catalog' import { callRuntimeEnvironment } from './runtime-environments/runtime-environment-transport-routing' import { handleMainWindowSkillIpc } from './skill-ipc-main-window' import { getRuntimeEnvironmentRegistryRoot } from './runtime-environments/runtime-environment-registry-root' diff --git a/src/main/ipc/skills.test.ts b/src/main/ipc/skills.test.ts index a818336f250..5d95fa9312e 100644 --- a/src/main/ipc/skills.test.ts +++ b/src/main/ipc/skills.test.ts @@ -1,5 +1,6 @@ +import type * as WslPaths from '../../shared/wsl-paths' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as WslUncAccessGateModule from '../wsl/wsl-unc-access-gate' +import type * as WslUncAccessGateModule from '../wsl/filesystem/wsl-unc-access-gate' const { registerSkillCloudIpcHandlersMock, @@ -43,7 +44,7 @@ vi.mock('../skills/skill-discovery-wsl', () => ({ discoverSkillObservationInWsl: discoverSkillObservationInWslMock })) -vi.mock('../wsl/wsl-unc-access-gate', async (importOriginal) => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', async (importOriginal) => ({ ...(await importOriginal()), assertWslUncPathRunning: assertWslUncPathRunningMock })) @@ -52,25 +53,35 @@ vi.mock('./skill-cloud-ipc-handlers', () => ({ registerSkillCloudIpcHandlers: registerSkillCloudIpcHandlersMock })) -vi.mock('../wsl', () => ({ +vi.mock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: getDefaultWslDistroMock, getWslHome: getWslHomeMock, - getWslHomeAsync: async (distro: string) => getWslHomeMock(distro), - parseWslPath: parseWslPathMock, - toLinuxPath: (pathValue: string) => { - if (pathValue === '\\\\wsl.localhost\\Ubuntu\\home\\alice') { - return '/home/alice' + getWslHomeAsync: async (distro: string) => getWslHomeMock(distro) +})) +vi.mock('../wsl/filesystem/unc-path-access', () => ({ + parseWslPath: parseWslPathMock +})) +vi.mock('../../shared/wsl-paths', async (importOriginal) => ({ + ...(await importOriginal()), + ...(await (() => ({ + toLinuxPath: (pathValue: string) => { + if (pathValue === '\\\\wsl.localhost\\Ubuntu\\home\\alice') { + return '/home/alice' + } + if (pathValue === 'C:\\repo\\worktree') { + return '/mnt/c/repo/worktree' + } + return pathValue } - if (pathValue === 'C:\\repo\\worktree') { - return '/mnt/c/repo/worktree' - } - return pathValue - } + }))()) })) import { registerSkillsHandlers } from './skills' import { clearSkillDiscoveryCaches } from '../skills/skill-discovery-target' -import { WslDistroStoppedError, WslDistroUnverifiableError } from '../wsl/wsl-unc-access-gate' +import { + WslDistroStoppedError, + WslDistroUnverifiableError +} from '../wsl/filesystem/wsl-unc-access-gate' describe('registerSkillsHandlers', () => { const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') diff --git a/src/main/ipc/skills.ts b/src/main/ipc/skills.ts index 2b9dc562df5..14ae9532665 100644 --- a/src/main/ipc/skills.ts +++ b/src/main/ipc/skills.ts @@ -17,7 +17,7 @@ import { resolveSkillDiscoveryTarget } from '../skills/skill-discovery-target' import { unavailableWhileWslDistroStopped } from '../skills/skill-discovery-stopped-wsl-roots' -import { runAsWslUserAct, wslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { runAsWslUserAct, wslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' import { registerSkillCloudIpcHandlers } from './skill-cloud-ipc-handlers' import { handleMainWindowSkillIpc } from './skill-ipc-main-window' diff --git a/src/main/ipc/worktree-logic-wsl.test.ts b/src/main/ipc/worktree-logic-wsl.test.ts index d2724c0aee6..ed9f300011d 100644 --- a/src/main/ipc/worktree-logic-wsl.test.ts +++ b/src/main/ipc/worktree-logic-wsl.test.ts @@ -7,9 +7,11 @@ const { getWslHomeMock, getWslHomeAsyncMock, parseWslPathMock } = vi.hoisted(() parseWslPathMock: vi.fn() })) -vi.mock('../wsl', () => ({ +vi.mock('../wsl/discovery/distro-catalog', () => ({ getWslHome: getWslHomeMock, - getWslHomeAsync: getWslHomeAsyncMock, + getWslHomeAsync: getWslHomeAsyncMock +})) +vi.mock('../wsl/filesystem/unc-path-access', () => ({ parseWslPath: parseWslPathMock })) diff --git a/src/main/ipc/worktree-logic.ts b/src/main/ipc/worktree-logic.ts index 3f037897b86..2fa0f673044 100644 --- a/src/main/ipc/worktree-logic.ts +++ b/src/main/ipc/worktree-logic.ts @@ -9,7 +9,8 @@ import { setEmojiShortcodeDatasetLoader } from '../../shared/emoji-shortcode-catalog' import { requireEmojiShortcodeDataset } from './deferred-emoji-shortcode-dataset' -import { getWslHome, getWslHomeAsync, parseWslPath } from '../wsl' +import { getWslHome, getWslHomeAsync } from '../wsl/discovery/distro-catalog' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' setEmojiShortcodeDatasetLoader(requireEmojiShortcodeDataset) 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 8b468edf2e6..00f57a4a340 100644 --- a/src/main/ipc/worktrees-authoritative-local-metadata-pruning.test.ts +++ b/src/main/ipc/worktrees-authoritative-local-metadata-pruning.test.ts @@ -33,7 +33,7 @@ vi.mock('../git/worktree-scan-cache', async (importOriginal) => { } }) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: async () => 'running' })) diff --git a/src/main/ipc/worktrees-detected-scan-cache.test.ts b/src/main/ipc/worktrees-detected-scan-cache.test.ts index 654cb6ebe88..0a44d56e596 100644 --- a/src/main/ipc/worktrees-detected-scan-cache.test.ts +++ b/src/main/ipc/worktrees-detected-scan-cache.test.ts @@ -19,7 +19,7 @@ vi.mock('../git/worktree-scan-cache', async (importOriginal) => { } }) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: async () => 'running' })) diff --git a/src/main/ipc/worktrees-wsl-runtime-routing.test.ts b/src/main/ipc/worktrees-wsl-runtime-routing.test.ts index 1636dda0b6b..21f067ce0ee 100644 --- a/src/main/ipc/worktrees-wsl-runtime-routing.test.ts +++ b/src/main/ipc/worktrees-wsl-runtime-routing.test.ts @@ -41,7 +41,7 @@ vi.mock('../git/worktree-scan-cache', async (importOriginal) => { } }) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: runningStateMock })) diff --git a/src/main/ipc/worktrees/create/register-worktree-prefetch-handler.ts b/src/main/ipc/worktrees/create/register-worktree-prefetch-handler.ts index 8a6e419275d..4a16f998b6d 100644 --- a/src/main/ipc/worktrees/create/register-worktree-prefetch-handler.ts +++ b/src/main/ipc/worktrees/create/register-worktree-prefetch-handler.ts @@ -3,7 +3,7 @@ import { prefetchWorktreeCreateBase } from '../../../workspaces/creation/worktre import { prepareWorktreeCreateForRepo } from '../../../workspaces/creation/preparation/worktree-create-preparation' import { getWorktreeCreatePrefetchGitOptions } from '../../../workspaces/execution-host/project-runtime-git-options' import type { WorktreeIpcContext } from '../worktree-ipc-context' -import { blockedWslDistroForPath } from '../../../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath } from '../../../wsl/filesystem/wsl-unc-access-gate' export function registerWorktreePrefetchHandler(context: WorktreeIpcContext): void { const { store, runtime } = context diff --git a/src/main/ipc/worktrees/creation/worktree-base-directory-watch-targets.test.ts b/src/main/ipc/worktrees/creation/worktree-base-directory-watch-targets.test.ts index 7acf2e38a8f..5c78392698f 100644 --- a/src/main/ipc/worktrees/creation/worktree-base-directory-watch-targets.test.ts +++ b/src/main/ipc/worktrees/creation/worktree-base-directory-watch-targets.test.ts @@ -11,7 +11,7 @@ const { readFileMock, realpathMock, statMock, wslHomeMock, wslHomeAsyncMock } = wslHomeAsyncMock: vi.fn(async (): Promise => null) })) -vi.mock('../../../wsl', async (importOriginal) => ({ +vi.mock('../../../wsl/discovery/distro-catalog', async (importOriginal) => ({ ...(await importOriginal>()), getWslHome: wslHomeMock, getWslHomeAsync: wslHomeAsyncMock diff --git a/src/main/ipc/worktrees/listing/detected-provider-listing.ts b/src/main/ipc/worktrees/listing/detected-provider-listing.ts index 6cfa53fed40..3344d22e1a6 100644 --- a/src/main/ipc/worktrees/listing/detected-provider-listing.ts +++ b/src/main/ipc/worktrees/listing/detected-provider-listing.ts @@ -39,7 +39,7 @@ import { readAllWorktreeMetaForRepo } from '../../../persistence/host-qualified- import { classifyWorktreeScanFailure } from '../../../../shared/worktree-scan-failure' import { scanUntilNotOvertaken } from './overtaken-scan-rerun' import { withoutInFlightWorktreeCreates } from '../../../workspaces/creation/worktree-create-in-flight' -import { releaseWslStoppedWorktreeRescan } from '../../../wsl-stopped-worktree-rescan-registry' +import { releaseWslStoppedWorktreeRescan } from '../../../wsl/discovery/wsl-stopped-worktree-rescan-registry' import { listWslStoppedWorktrees, rescanWorktreesWhenWslDistroRuns, diff --git a/src/main/ipc/worktrees/listing/detected-worktree-scan-cache.ts b/src/main/ipc/worktrees/listing/detected-worktree-scan-cache.ts index 7f8e11da29b..60eb7923619 100644 --- a/src/main/ipc/worktrees/listing/detected-worktree-scan-cache.ts +++ b/src/main/ipc/worktrees/listing/detected-worktree-scan-cache.ts @@ -25,7 +25,10 @@ import { requireLocalWorktreeMetadataPrune } from '../../../workspaces/catalog/local-worktree-metadata-prune-gate' import { pruneMetadataMissingFromAuthoritativeLocalScan } from './authoritative-local-worktree-metadata-pruning' -import { assertWslUncPathRunning, wslDistroForPath } from '../../../wsl/wsl-unc-access-gate' +import { + assertWslUncPathRunning, + wslDistroForPath +} from '../../../wsl/filesystem/wsl-unc-access-gate' // Coalesce renderer polls while bounding external-change lag. export const DETECTED_WORKTREE_SCAN_CACHE_TTL_MS = 5_000 diff --git a/src/main/ipc/worktrees/listing/detected-worktree-scan-listing-distro.test.ts b/src/main/ipc/worktrees/listing/detected-worktree-scan-listing-distro.test.ts index c80186d16f7..da7447cb55c 100644 --- a/src/main/ipc/worktrees/listing/detected-worktree-scan-listing-distro.test.ts +++ b/src/main/ipc/worktrees/listing/detected-worktree-scan-listing-distro.test.ts @@ -8,7 +8,7 @@ const mocks = vi.hoisted(() => ({ registerRoots: vi.fn(), running: vi.fn(async () => true) })) -vi.mock('../../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: async () => ((await mocks.running()) ? 'running' : 'stopped') })) @@ -32,7 +32,7 @@ const { applyFreshDetectedWorktreeScanSideEffects, listDetectedGitWorktrees } = await import('./detected-worktree-scan-cache') -const { WslDistroStoppedError } = await import('../../../wsl/wsl-unc-access-gate') +const { WslDistroStoppedError } = await import('../../../wsl/filesystem/wsl-unc-access-gate') const repo: Repo = { id: 'repo-1', diff --git a/src/main/ipc/worktrees/listing/wsl-distro-starting-scan.ts b/src/main/ipc/worktrees/listing/wsl-distro-starting-scan.ts index bb3e58c15bf..440cd72e21d 100644 --- a/src/main/ipc/worktrees/listing/wsl-distro-starting-scan.ts +++ b/src/main/ipc/worktrees/listing/wsl-distro-starting-scan.ts @@ -2,7 +2,7 @@ import type { Store } from '../../../persistence/loading-store/store' import { getRepoDialableSshTargetId } from '../../../../shared/execution-host' import { isFolderRepo } from '../../../../shared/repo-kind' import { getLocalProjectWorktreeGitOptions } from '../../../workspaces/execution-host/project-runtime-git-options' -import { runAsWslUserAct, wslDistroForPath } from '../../../wsl/wsl-unc-access-gate' +import { runAsWslUserAct, wslDistroForPath } from '../../../wsl/filesystem/wsl-unc-access-gate' import { listDetectedWorktreesForCapturedRepo } from './detected-provider-listing' import { findExactRepoOwner, isCapturedRepoCurrent } from './worktree-host-ownership' diff --git a/src/main/ipc/worktrees/listing/wsl-stopped-worktree-listing.test.ts b/src/main/ipc/worktrees/listing/wsl-stopped-worktree-listing.test.ts index 6a8e5634652..8917f0a812f 100644 --- a/src/main/ipc/worktrees/listing/wsl-stopped-worktree-listing.test.ts +++ b/src/main/ipc/worktrees/listing/wsl-stopped-worktree-listing.test.ts @@ -23,13 +23,13 @@ vi.mock('@orca/process-host', async (importOriginal) => ({ const { listDetectedWorktreesForCapturedRepo } = await import('./detected-provider-listing') const { setWslStoppedWorktreeRescanNotifier } = await import('./wsl-stopped-worktree-listing') const { WslDistroStoppedError, WslDistroUnverifiableError } = - await import('../../../wsl/wsl-unc-access-gate') + await import('../../../wsl/filesystem/wsl-unc-access-gate') const { _resetWslBackgroundDistroGateForTests, noteWslDistroWoken, noteWslDistrosRunning } = - await import('../../../wsl-background-distro-gate') + await import('../../../wsl/discovery/wsl-background-distro-gate') const { scanWorktreesStartingWslDistro } = await import('./wsl-distro-starting-scan') -const { isWslUserActFor } = await import('../../../wsl/wsl-user-act-scope') +const { isWslUserActFor } = await import('../../../wsl/discovery/wsl-user-act-scope') const { _pendingWslStoppedWorktreeRescanCount, _resetWslStoppedWorktreeRescansForTests } = - await import('../../../wsl-stopped-worktree-rescan-registry') + await import('../../../wsl/discovery/wsl-stopped-worktree-rescan-registry') const REPO_PATH = '\\\\wsl.localhost\\Ubuntu\\home\\me\\repo' const FEATURE_PATH = '\\\\wsl.localhost\\Ubuntu\\home\\me\\feature' diff --git a/src/main/ipc/worktrees/listing/wsl-stopped-worktree-listing.ts b/src/main/ipc/worktrees/listing/wsl-stopped-worktree-listing.ts index e06feedb7d8..45fc94c52ac 100644 --- a/src/main/ipc/worktrees/listing/wsl-stopped-worktree-listing.ts +++ b/src/main/ipc/worktrees/listing/wsl-stopped-worktree-listing.ts @@ -9,12 +9,15 @@ import { areWorktreePathsEqual } from '../../../git/worktree-path-comparison' import { deferUntilWslDistroRunning, onWslDistroGateNote -} from '../../../wsl-background-distro-gate' -import { WslDistroStoppedError, WslDistroUnverifiableError } from '../../../wsl/wsl-unc-access-gate' +} from '../../../wsl/discovery/wsl-background-distro-gate' +import { + WslDistroStoppedError, + WslDistroUnverifiableError +} from '../../../wsl/filesystem/wsl-unc-access-gate' import { holdWslStoppedWorktreeRescan, releaseWslStoppedWorktreeRescan -} from '../../../wsl-stopped-worktree-rescan-registry' +} from '../../../wsl/discovery/wsl-stopped-worktree-rescan-registry' import { mergeWorktree } from '../../worktree-metadata-merge' import { buildDisconnectedDetectedWorktrees } from './folder-workspace-catalog' import { diff --git a/src/main/ipc/worktrees/removal/registered-worktree-root-probes.ts b/src/main/ipc/worktrees/removal/registered-worktree-root-probes.ts index a794f1e049c..e539353f764 100644 --- a/src/main/ipc/worktrees/removal/registered-worktree-root-probes.ts +++ b/src/main/ipc/worktrees/removal/registered-worktree-root-probes.ts @@ -7,7 +7,10 @@ import { resolveLocalProjectRuntimesForRepos } from '../../../workspaces/executi import type { RegisteredWorktreeRootStore as RootStore } from './registered-worktree-root-store' import { getWorktreeMirrorDistroForRuntime } from '../../../workspaces/execution-host/project-runtime-git-options' import { listRepoWorktreeGraph } from '../../../workspaces/catalog/repo-worktrees' -import { blockedWslDistroForPath, wslDistroForPath } from '../../../wsl/wsl-unc-access-gate' +import { + blockedWslDistroForPath, + wslDistroForPath +} from '../../../wsl/filesystem/wsl-unc-access-gate' const CREATED_WORKTREE_ROOT_PROBE_TIMEOUT_MS = 1_000 const AUTHORIZED_ROOTS_REBUILD_CONCURRENCY = 8 diff --git a/src/main/ipc/worktrees/removal/registered-worktree-root-stopped-distro.test.ts b/src/main/ipc/worktrees/removal/registered-worktree-root-stopped-distro.test.ts index a3f5f4ae9ac..184e0a6ade9 100644 --- a/src/main/ipc/worktrees/removal/registered-worktree-root-stopped-distro.test.ts +++ b/src/main/ipc/worktrees/removal/registered-worktree-root-stopped-distro.test.ts @@ -10,7 +10,7 @@ const mocks = vi.hoisted(() => ({ realpath: vi.fn(), running: vi.fn(async () => true) })) -vi.mock('../../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: async () => ((await mocks.running()) ? 'running' : 'stopped') })) @@ -24,7 +24,7 @@ vi.mock('../../../workspaces/execution-host/local-project-runtime-resolution', ( resolveLocalProjectRuntimesForRepos: mocks.runtimes })) import { resolveAuthorizedPath } from '../../filesystem/filesystem-auth' -import { runAsWslUserAct } from '../../../wsl/wsl-unc-access-gate' +import { runAsWslUserAct } from '../../../wsl/filesystem/wsl-unc-access-gate' import { __resetCreatedWorktreeRootsForTests, invalidateAuthorizedRootsCache, diff --git a/src/main/ipc/wsl-drive-project-handlers.test.ts b/src/main/ipc/wsl-drive-project-handlers.test.ts index 9bdc22f3b40..a0dbf5dfb22 100644 --- a/src/main/ipc/wsl-drive-project-handlers.test.ts +++ b/src/main/ipc/wsl-drive-project-handlers.test.ts @@ -17,7 +17,7 @@ const conversion = vi.hoisted(() => ({ previewWslDriveProjectWindowsGit: vi.fn(async () => ({ blockers: [] })), convertWslDriveProjectToWindowsGit: vi.fn(async () => ({ ok: false, blockers: [] })) })) -vi.mock('../wsl/wsl-drive-project-windows-git', () => conversion) +vi.mock('../wsl/filesystem/wsl-drive-project-windows-git', () => conversion) vi.mock('./wsl-drive-unc-conversion-handlers', () => ({ registerWslDriveUncConversionHandlers: vi.fn() })) diff --git a/src/main/ipc/wsl-drive-project-handlers.ts b/src/main/ipc/wsl-drive-project-handlers.ts index e57dd88e7e6..7949dea0a06 100644 --- a/src/main/ipc/wsl-drive-project-handlers.ts +++ b/src/main/ipc/wsl-drive-project-handlers.ts @@ -15,7 +15,7 @@ import { convertWslDriveProjectToWindowsGit, previewWslDriveProjectWindowsGit, type WslDriveProjectDeps -} from '../wsl/wsl-drive-project-windows-git' +} from '../wsl/filesystem/wsl-drive-project-windows-git' export const WSL_DRIVE_PROJECT_HANDLER_CHANNELS = [ 'wslDriveProject:preview', diff --git a/src/main/ipc/wsl-drive-unc-conversion-handlers.ts b/src/main/ipc/wsl-drive-unc-conversion-handlers.ts index 3ec46c16728..709ed4550c1 100644 --- a/src/main/ipc/wsl-drive-unc-conversion-handlers.ts +++ b/src/main/ipc/wsl-drive-unc-conversion-handlers.ts @@ -18,23 +18,23 @@ import type { Store } from '../persistence/loading-store/store' import { pauseWslMoveScope } from '../persistence/moving-wsl-projects/wsl-move-driver-pause' import type { OrcaRuntimeService } from '../runtime/orca-runtime' import { quitProcess } from '../startup/process-quit-request' -import { startWslDriveUncConversion } from '../wsl/wsl-drive-unc-conversion-run' +import { startWslDriveUncConversion } from '../wsl/filesystem/wsl-drive-unc-conversion-run' import { lastWslDriveUncConversionOutcomes, type WslDriveUncConversionOutcome -} from '../wsl/wsl-drive-unc-conversion-startup' +} from '../wsl/filesystem/wsl-drive-unc-conversion-startup' import { wslHostsGateOpen, wslHostsOptedIn } from '../wsl/wsl-host-gate' import { createWslMoveDriverDeps } from './wsl-move-driver-wiring' import { getTrustedUIRendererWebContents } from './ui' import { listPendingWslDriveUncRendererRewrites, recordWslDriveUncRendererStoreRewritten -} from '../wsl/wsl-drive-unc-conversion-renderer' -import { WSL_DRIVE_UNC_MAIN_STORE_IDS } from '../wsl/wsl-drive-unc-conversion-stores' +} from '../wsl/filesystem/wsl-drive-unc-conversion-renderer' +import { WSL_DRIVE_UNC_MAIN_STORE_IDS } from '../wsl/filesystem/wsl-drive-unc-conversion-stores' import type { WslDriveUncPendingRendererRewrite } from '../../shared/wsl-drive-unc-renderer-store-keys' import type { WslMoveRecordStoreRewrittenResult } from '../../shared/wsl-move/wsl-move-renderer-rewrite-types' import { readWorktreeLinks } from './wsl-drive-project-handlers' -import { readWslDistroDriveMounts } from '../wsl/wsl-drive-unc-mounts' +import { readWslDistroDriveMounts } from '../wsl/filesystem/wsl-drive-unc-mounts' export const WSL_DRIVE_UNC_CONVERSION_CHANNELS = [ 'wslDriveUnc:convert', diff --git a/src/main/ipc/wsl-host-handlers.ts b/src/main/ipc/wsl-host-handlers.ts index a42cc5955ab..05e417d29be 100644 --- a/src/main/ipc/wsl-host-handlers.ts +++ b/src/main/ipc/wsl-host-handlers.ts @@ -42,7 +42,7 @@ import { } from '../wsl/wsl-orcad-host-account-push' import { wslOrcadHostSupports } from '../wsl/wsl-orcad-host-environments' import { wslHostConnectOptions } from '../wsl/wsl-host-connect-request' -import { wireWslNodeRuntimePrefetch } from '../wsl/wsl-node-runtime-prefetch' +import { wireWslNodeRuntimePrefetch } from '../wsl/execution/wsl-node-runtime-prefetch' export const WSL_HOST_HANDLER_CHANNELS = [ 'wslHosts:listDistros', diff --git a/src/main/ipc/wsl-move-driver-wiring.ts b/src/main/ipc/wsl-move-driver-wiring.ts index c0827fbd1f8..2ad70b0981a 100644 --- a/src/main/ipc/wsl-move-driver-wiring.ts +++ b/src/main/ipc/wsl-move-driver-wiring.ts @@ -83,7 +83,7 @@ import { makeTerminalScrollbackSnapshotRef } from '../pty/scrollback/terminal-sc import { pauseWorkspacesForProjectMove } from '../window/project-move-pause' import { getWslHostService } from '../wsl/wsl-host-service-instance' import { readWslGuestProcessTable } from '../wsl/wsl-guest-process-table' -import { isWslDistroRegistered } from '../wsl/wsl-distro-registry-id' +import { isWslDistroRegistered } from '../wsl/discovery/wsl-distro-registry-id' import { defaultWslOrcadEnvironmentId } from '../wsl/wsl-orcad-deploy' import { ptyPaneKey } from './pty/pane/key-state' import { tryGetProviderForPty } from './pty/provider/registry' diff --git a/src/main/ipc/wsl-move-orchestrator-wiring.test.ts b/src/main/ipc/wsl-move-orchestrator-wiring.test.ts index 5edeedc623c..95d83158998 100644 --- a/src/main/ipc/wsl-move-orchestrator-wiring.test.ts +++ b/src/main/ipc/wsl-move-orchestrator-wiring.test.ts @@ -52,11 +52,13 @@ vi.mock('../../shared/wsl-host-deployment-store', () => ({ return { deployments: [], unreadableEnvironmentIds: new Set() } } })) -vi.mock('../wsl/wsl-distro-registry-id', () => ({ readWslDistroRegistrations: async () => null })) +vi.mock('../wsl/discovery/wsl-distro-registry-id', () => ({ + readWslDistroRegistrations: async () => null +})) vi.mock('../wsl/wsl-orcad-deploy', () => ({ defaultWslOrcadEnvironmentId: (distro: string) => `wsl:${distro}` })) -vi.mock('../wsl-background-distro-gate', () => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', () => ({ readConfirmedRunningWslDistros: async () => { runningRead.hook?.() return host.running @@ -515,7 +517,7 @@ describe('WSL move orchestrator wiring', () => { // so its reads of a just-connected distro pass; a wake's reads stay background work. it('runs the driver for Check again as the user act, and for a wake as background work', async () => { vi.stubEnv(WSL_HOSTS_INTERNAL_GATE_ENV, '1') - const { isWslUserActFor } = await import('../wsl/wsl-user-act-scope') + const { isWslUserActFor } = await import('../wsl/discovery/wsl-user-act-scope') const seen: boolean[] = [] const original = driver.previewWslMove.getMockImplementation() driver.previewWslMove.mockImplementation( diff --git a/src/main/ipc/wsl-move-orchestrator-wiring.ts b/src/main/ipc/wsl-move-orchestrator-wiring.ts index bfd62703de7..dac1defa64f 100644 --- a/src/main/ipc/wsl-move-orchestrator-wiring.ts +++ b/src/main/ipc/wsl-move-orchestrator-wiring.ts @@ -23,7 +23,7 @@ import type { WslMoveHostReadiness } from '../persistence/moving-wsl-projects/wsl-move-orchestrator-ports' import { prepareWslMoveHost } from '../persistence/moving-wsl-projects/wsl-move-host-readiness' -import { readConfirmedRunningWslDistros } from '../wsl-background-distro-gate' +import { readConfirmedRunningWslDistros } from '../wsl/discovery/wsl-background-distro-gate' import { defaultWslOrcadEnvironmentId } from '../wsl/wsl-orcad-deploy' import { readWslMoveOrchestratorRecords, @@ -35,10 +35,10 @@ import { wslMoveOrchestratorEventProps } from '../telemetry/wsl-move-orchestrator-telemetry' import { runTrackedWslMove } from '../telemetry/wsl-move-telemetry' -import { readWslDistroRegistrations } from '../wsl/wsl-distro-registry-id' +import { readWslDistroRegistrations } from '../wsl/discovery/wsl-distro-registry-id' import { wslHostsAcceptNewWork, wslHostsGateOpen, wslHostsOptedIn } from '../wsl/wsl-host-gate' import { wslHostAddRefusal } from '../wsl/wsl-host-add-admission' -import { runAsWslUserAct } from '../wsl/wsl-unc-access-gate' +import { runAsWslUserAct } from '../wsl/filesystem/wsl-unc-access-gate' import { getWslHostService } from '../wsl/wsl-host-service-instance' import { onWslHostUserAction } from '../wsl/wsl-host-user-actions' import { getTrustedUIRendererWebContents, getTrustedUIRendererWindow } from './ui' diff --git a/src/main/kimi/kimi-runtime-home.test.ts b/src/main/kimi/kimi-runtime-home.test.ts index 7cad982351b..5c9fe4050a1 100644 --- a/src/main/kimi/kimi-runtime-home.test.ts +++ b/src/main/kimi/kimi-runtime-home.test.ts @@ -6,7 +6,7 @@ const wslMocks = vi.hoisted(() => ({ getWslHomeAsync: vi.fn<(distro: string) => Promise>() })) -vi.mock('../wsl', () => wslMocks) +vi.mock('../wsl/discovery/distro-catalog', () => wslMocks) vi.mock('node:os', () => ({ homedir: () => 'C:\\Users\\neil' })) import { getHostKimiHome, resolveKimiHome } from './kimi-runtime-home' diff --git a/src/main/kimi/kimi-runtime-home.ts b/src/main/kimi/kimi-runtime-home.ts index 83998aa6d16..d96fc414a17 100644 --- a/src/main/kimi/kimi-runtime-home.ts +++ b/src/main/kimi/kimi-runtime-home.ts @@ -6,8 +6,8 @@ import { type LocalAccountRuntimeTarget } from '../../shared/local-account-runtime' import type { GlobalSettings } from '../../shared/global-settings-types' -import { getWslHomeAsync, listWslDistrosAsync } from '../wsl' -import { isWslDistroRunning } from '../wsl-background-distro-gate' +import { getWslHomeAsync, listWslDistrosAsync } from '../wsl/discovery/distro-catalog' +import { isWslDistroRunning } from '../wsl/discovery/wsl-background-distro-gate' export type KimiHomeResolution = LocalAccountRuntimeTarget & { /** null when the distro is missing or stopped, or its home could not be probed. */ diff --git a/src/main/media/local-preview-grant-file.ts b/src/main/media/local-preview-grant-file.ts index d7e95cd5f53..c3a2d6992d8 100644 --- a/src/main/media/local-preview-grant-file.ts +++ b/src/main/media/local-preview-grant-file.ts @@ -2,7 +2,7 @@ import type { Store } from '../persistence/loading-store/store' import { filePreviewForPath, isDocumentPreview } from '../../shared/file-preview-kind' import { resolveLocalFileRequestPath } from '../ipc/local-file-access-resolution' import { openLocalRegularFile } from '../ipc/filesystem/local-regular-file-read' -import { guardWslUncPathAccess } from '../wsl/wsl-unc-access-gate' +import { guardWslUncPathAccess } from '../wsl/filesystem/wsl-unc-access-gate' import type { LocalPreviewTarget, PreviewGrant } from './preview-grant-registry' /** diff --git a/src/main/media/preview-grant-range-read.test.ts b/src/main/media/preview-grant-range-read.test.ts index 73889655a23..bfa4ee5e46d 100644 --- a/src/main/media/preview-grant-range-read.test.ts +++ b/src/main/media/preview-grant-range-read.test.ts @@ -9,12 +9,12 @@ vi.mock('electron', () => ({ protocol: { handle: vi.fn() } })) vi.mock('../ipc/local-file-access-resolution', () => ({ resolveLocalFileRequestPath: vi.fn(async (filePath: string) => filePath) })) -vi.mock('../wsl/wsl-unc-access-gate', () => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', () => ({ guardWslUncPathAccess: vi.fn((_path: string, access: () => Promise) => access()) })) import { resolveLocalFileRequestPath } from '../ipc/local-file-access-resolution' -import { guardWslUncPathAccess } from '../wsl/wsl-unc-access-gate' +import { guardWslUncPathAccess } from '../wsl/filesystem/wsl-unc-access-gate' import { readLocalFilePreview } from './media-preview-protocol' import { readPreviewGrantRange } from './preview-grant-range-read' diff --git a/src/main/native-chat/host-readable-transcript-path.test.ts b/src/main/native-chat/host-readable-transcript-path.test.ts index a9eb0070208..0c73b29faf9 100644 --- a/src/main/native-chat/host-readable-transcript-path.test.ts +++ b/src/main/native-chat/host-readable-transcript-path.test.ts @@ -11,18 +11,20 @@ const wslMocks = vi.hoisted(() => ({ vi.mock('./wsl-transcript-running-admission', () => ({ admitWslTranscriptPath: wslMocks.admitWslTranscriptPath })) -vi.mock('../wsl/wsl-home-unless-stopped', async () => { - const wsl = await import('../wsl') +vi.mock('../wsl/discovery/wsl-home-unless-stopped', async () => { + const wsl = await import('../wsl/discovery/distro-catalog') return { wslHomeUnlessStopped: (distro: string) => wsl.getWslHomeAsync(distro), listRunningWslHomeDirsUnlessStopped: () => wsl.listRunningWslHomeDirsAsync() } }) -vi.mock('../wsl', () => ({ - listRunningWslHomeDirsAsync: wslMocks.listRunningWslHomeDirsAsync, +vi.mock('../wsl/discovery/distro-catalog', () => ({ + listRunningWslHomeDirsAsync: wslMocks.listRunningWslHomeDirsAsync +})) +vi.mock('../wsl/filesystem/unc-path-access', () => ({ resolveWslGuestRealDirAsync: wslMocks.resolveWslGuestRealDirAsync })) -vi.mock('../wsl-running-path-filter', () => ({ +vi.mock('../wsl/filesystem/wsl-running-path-filter', () => ({ filterPathsToRunningWslDistrosAsync: wslMocks.filterPathsToRunningWslDistrosAsync })) diff --git a/src/main/native-chat/host-readable-transcript-path.ts b/src/main/native-chat/host-readable-transcript-path.ts index 3ac9795db35..72f7835b253 100644 --- a/src/main/native-chat/host-readable-transcript-path.ts +++ b/src/main/native-chat/host-readable-transcript-path.ts @@ -6,16 +6,16 @@ import { wslHomeSessionDirs, type SessionHomeAgent } from '../ai-vault/session-scanner-roots' -import { resolveWslGuestRealDirAsync } from '../wsl' +import { resolveWslGuestRealDirAsync } from '../wsl/filesystem/unc-path-access' import { listRunningWslHomeDirsUnlessStopped, wslHomeUnlessStopped -} from '../wsl/wsl-home-unless-stopped' +} from '../wsl/discovery/wsl-home-unless-stopped' import { admitWslTranscriptPath } from './wsl-transcript-running-admission' import { filterPathsToRunningWslDistrosAsync, filterPathsToWslDistros -} from '../wsl-running-path-filter' +} from '../wsl/filesystem/wsl-running-path-filter' import { wslGatedAccess } from './wsl-transcript-fs-access' import { WslTranscriptFsError, wslTranscriptFsRefusal } from './wsl-transcript-fs-gate' diff --git a/src/main/native-chat/native-chat-media-path.ts b/src/main/native-chat/native-chat-media-path.ts index 5ed8ac490d4..914e0b66f3f 100644 --- a/src/main/native-chat/native-chat-media-path.ts +++ b/src/main/native-chat/native-chat-media-path.ts @@ -18,7 +18,7 @@ import { import { readNodeFileWithinLimit } from '../../shared/node-bounded-file-reader' import { isENOENT } from '../ipc/filesystem/filesystem-path-containment' import { needsWslHostResolution } from './host-readable-transcript-path' -import { parseWslPath } from '../wsl' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' import { admitTranscriptPath } from './transcript-path-admission' export type NativeChatMediaPathResolution = diff --git a/src/main/native-chat/native-chat-open-wake.ts b/src/main/native-chat/native-chat-open-wake.ts index ba8f9ba1309..5fe9c332af9 100644 --- a/src/main/native-chat/native-chat-open-wake.ts +++ b/src/main/native-chat/native-chat-open-wake.ts @@ -8,7 +8,7 @@ import { blockedWslDistroForPath, runAsWslUserAct, wslDistroForPath -} from '../wsl/wsl-unc-access-gate' +} from '../wsl/filesystem/wsl-unc-access-gate' import { wslGatedAccess } from './wsl-transcript-fs-access' import { WSL_TRANSCRIPT_RUNNING_LEASE_MS } from './wsl-transcript-running-admission' import { agentHookServer } from '../agent-hooks/server' diff --git a/src/main/native-chat/session-file-resolver-wsl-scan-gate.test.ts b/src/main/native-chat/session-file-resolver-wsl-scan-gate.test.ts index aea84ac6a0a..bb05febc56c 100644 --- a/src/main/native-chat/session-file-resolver-wsl-scan-gate.test.ts +++ b/src/main/native-chat/session-file-resolver-wsl-scan-gate.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as WslRunningPathFilterModule from '../wsl-running-path-filter' +import type * as WslRunningPathFilterModule from '../wsl/filesystem/wsl-running-path-filter' import type * as WslTranscriptFsGateModule from './wsl-transcript-fs-gate' const WSL_SESSIONS_DIR = '\\\\wsl.localhost\\Ubuntu\\home\\ada\\.codex\\sessions' @@ -31,19 +31,19 @@ vi.mock('../ai-vault/session-scanner-discovery', () => ({ })) // These cases cover root and path policy; the E9 gate has its own suite. vi.mock('./wsl-transcript-running-admission', () => ({ admitWslTranscriptPath: async () => {} })) -vi.mock('../wsl/wsl-home-unless-stopped', async () => { - const wsl = await import('../wsl') +vi.mock('../wsl/discovery/wsl-home-unless-stopped', async () => { + const wsl = await import('../wsl/discovery/distro-catalog') return { wslHomeUnlessStopped: (distro: string) => wsl.getWslHomeAsync(distro), listRunningWslHomeDirsUnlessStopped: () => wsl.listRunningWslHomeDirsAsync() } }) -vi.mock('../wsl', () => ({ +vi.mock('../wsl/discovery/distro-catalog', () => ({ getWslHomeAsync: vi.fn(async () => '\\\\wsl.localhost\\Ubuntu\\home\\ada'), listRunningWslDistrosAsync: vi.fn(async () => ['Ubuntu']), listRunningWslHomeDirsAsync: vi.fn(async () => ['\\\\wsl.localhost\\Ubuntu\\home\\ada']) })) -vi.mock('../wsl-running-path-filter', async (importOriginal) => ({ +vi.mock('../wsl/filesystem/wsl-running-path-filter', async (importOriginal) => ({ ...(await importOriginal()), filterPathsToRunningWslDistrosAsync: mocks.filterPathsToRunningWslDistrosAsync })) diff --git a/src/main/native-chat/session-file-resolver-wsl.test.ts b/src/main/native-chat/session-file-resolver-wsl.test.ts index 3c404670b76..d66c8d8b0bb 100644 --- a/src/main/native-chat/session-file-resolver-wsl.test.ts +++ b/src/main/native-chat/session-file-resolver-wsl.test.ts @@ -11,21 +11,23 @@ const DEBIAN_ROLLOUT_UNC = ROLLOUT_UNC.replace('Ubuntu', 'Debian') // These cases cover root and path policy; the E9 gate has its own suite. vi.mock('./wsl-transcript-running-admission', () => ({ admitWslTranscriptPath: async () => {} })) -vi.mock('../wsl/wsl-home-unless-stopped', async () => { - const wsl = await import('../wsl') +vi.mock('../wsl/discovery/wsl-home-unless-stopped', async () => { + const wsl = await import('../wsl/discovery/distro-catalog') return { wslHomeUnlessStopped: (distro: string) => wsl.getWslHomeAsync(distro), listRunningWslHomeDirsUnlessStopped: () => wsl.listRunningWslHomeDirsAsync() } }) -vi.mock('../wsl', () => ({ +vi.mock('../wsl/discovery/distro-catalog', () => ({ listWslDistrosAsync: vi.fn(async () => ['Ubuntu', 'Debian']), listRunningWslDistrosAsync: vi.fn(async () => ['Ubuntu', 'Debian']), listRunningWslHomeDirsAsync: vi.fn(async () => [ UBUNTU_HOME, UBUNTU_HOME.replace('Ubuntu', 'Debian') ]), - getWslHomeAsync: vi.fn(async (distro: string) => UBUNTU_HOME.replace('Ubuntu', distro)), + getWslHomeAsync: vi.fn(async (distro: string) => UBUNTU_HOME.replace('Ubuntu', distro)) +})) +vi.mock('../wsl/filesystem/unc-path-access', () => ({ resolveWslGuestRealDirAsync: vi.fn(async (_distro: string, dir: string) => dir) })) @@ -73,7 +75,11 @@ vi.mock('../ai-vault/session-scanner-discovery', () => ({ import { resetHostReadableTranscriptPathCacheForTests } from './host-readable-transcript-path' import { resolveSessionFilePath } from './session-file-resolver' -import { getWslHomeAsync, listRunningWslHomeDirsAsync, listWslDistrosAsync } from '../wsl' +import { + getWslHomeAsync, + listRunningWslHomeDirsAsync, + listWslDistrosAsync +} from '../wsl/discovery/distro-catalog' const realPlatform = process.platform diff --git a/src/main/native-chat/transcript-watch-engine-wsl-lifecycle.test.ts b/src/main/native-chat/transcript-watch-engine-wsl-lifecycle.test.ts index 053f5451af1..9d2cdc393c7 100644 --- a/src/main/native-chat/transcript-watch-engine-wsl-lifecycle.test.ts +++ b/src/main/native-chat/transcript-watch-engine-wsl-lifecycle.test.ts @@ -15,7 +15,7 @@ const mocks = vi.hoisted(() => ({ stat: vi.fn() })) -vi.mock('../wsl-running-path-filter', () => ({ +vi.mock('../wsl/filesystem/wsl-running-path-filter', () => ({ filterPathsToRunningWslDistrosAsync: mocks.filterRunning })) vi.mock('node:fs/promises', async (importOriginal) => ({ diff --git a/src/main/native-chat/transcript-watch-wsl-exact-path.test.ts b/src/main/native-chat/transcript-watch-wsl-exact-path.test.ts index 084e18ac38d..575eb1450d3 100644 --- a/src/main/native-chat/transcript-watch-wsl-exact-path.test.ts +++ b/src/main/native-chat/transcript-watch-wsl-exact-path.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type * as NodeFsPromisesModule from 'node:fs/promises' -import type * as WslRunningPathFilterModule from '../wsl-running-path-filter' +import type * as WslRunningPathFilterModule from '../wsl/filesystem/wsl-running-path-filter' import { parseWslUncPath } from '../../shared/wsl-paths' const UBUNTU_HOME = '\\\\wsl.localhost\\Ubuntu\\home\\ada' @@ -26,19 +26,19 @@ vi.mock('./transcript-watch-engine', () => ({ })) // These cases cover root and path policy; the E9 gate has its own suite. vi.mock('./wsl-transcript-running-admission', () => ({ admitWslTranscriptPath: async () => {} })) -vi.mock('../wsl/wsl-home-unless-stopped', async () => { - const wsl = await import('../wsl') +vi.mock('../wsl/discovery/wsl-home-unless-stopped', async () => { + const wsl = await import('../wsl/discovery/distro-catalog') return { wslHomeUnlessStopped: (distro: string) => wsl.getWslHomeAsync(distro), listRunningWslHomeDirsUnlessStopped: () => wsl.listRunningWslHomeDirsAsync() } }) -vi.mock('../wsl', () => ({ +vi.mock('../wsl/discovery/distro-catalog', () => ({ getWslHomeAsync: mocks.getWslHomeAsync, listRunningWslDistrosAsync: mocks.listRunningWslDistrosAsync, listRunningWslHomeDirsAsync: vi.fn(async () => [UBUNTU_HOME]) })) -vi.mock('../wsl-running-path-filter', async (importOriginal) => ({ +vi.mock('../wsl/filesystem/wsl-running-path-filter', async (importOriginal) => ({ ...(await importOriginal()), filterPathsToRunningWslDistrosAsync: mocks.filterPathsToRunningWslDistrosAsync })) diff --git a/src/main/native-chat/transcript-watch-wsl-stall.test.ts b/src/main/native-chat/transcript-watch-wsl-stall.test.ts index 6dac57937cd..7fd41d757ab 100644 --- a/src/main/native-chat/transcript-watch-wsl-stall.test.ts +++ b/src/main/native-chat/transcript-watch-wsl-stall.test.ts @@ -11,7 +11,7 @@ const mocks = vi.hoisted(() => ({ })) vi.mock('./session-file-resolver', () => ({ resolveSessionFilePath: mocks.resolve })) -vi.mock('../wsl-running-path-filter', () => ({ +vi.mock('../wsl/filesystem/wsl-running-path-filter', () => ({ filterPathsToRunningWslDistrosAsync: vi.fn(async (paths: readonly string[]) => [...paths]) })) vi.mock('./transcript-native-watcher', () => ({ diff --git a/src/main/native-chat/wsl-transcript-running-admission.test.ts b/src/main/native-chat/wsl-transcript-running-admission.test.ts index 2fb13d371ff..116a09f0d6a 100644 --- a/src/main/native-chat/wsl-transcript-running-admission.test.ts +++ b/src/main/native-chat/wsl-transcript-running-admission.test.ts @@ -17,12 +17,12 @@ vi.mock('./wsl-transcript-fs-process-dispatch', async (importOriginal) => ({ closeWslTranscriptFsProcess: async () => {} })) -import { _resetWslCachesForTests } from '../wsl' +import { _resetWslCachesForTests } from '../wsl/discovery/distro-catalog' import { _resetWslBackgroundDistroGateForTests, noteWslDistroMayHaveStopped -} from '../wsl-background-distro-gate' -import { runAsWslUserAct } from '../wsl/wsl-unc-access-gate' +} from '../wsl/discovery/wsl-background-distro-gate' +import { runAsWslUserAct } from '../wsl/filesystem/wsl-unc-access-gate' import { openTranscriptFile, readTranscriptFile, wslGatedReaddir } from './wsl-transcript-fs-access' import { resetWslTranscriptFsGateForTests, WslTranscriptFsError } from './wsl-transcript-fs-gate' import { WSL_TRANSCRIPT_RUNNING_LEASE_MS } from './wsl-transcript-running-admission' diff --git a/src/main/native-chat/wsl-transcript-running-admission.ts b/src/main/native-chat/wsl-transcript-running-admission.ts index 3601a06e909..9a42f952e0d 100644 --- a/src/main/native-chat/wsl-transcript-running-admission.ts +++ b/src/main/native-chat/wsl-transcript-running-admission.ts @@ -1,4 +1,4 @@ -import { blockedWslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' import { wslTranscriptFsDistroNotRunningError } from './wsl-transcript-fs-error' /** diff --git a/src/main/native-chat/wsl-transcript-running-observer.test.ts b/src/main/native-chat/wsl-transcript-running-observer.test.ts index 2decd7eea07..cf41e18a083 100644 --- a/src/main/native-chat/wsl-transcript-running-observer.test.ts +++ b/src/main/native-chat/wsl-transcript-running-observer.test.ts @@ -2,7 +2,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' const mocks = vi.hoisted(() => ({ listRunning: vi.fn() })) -vi.mock('../wsl', () => ({ listRunningWslDistrosAsync: mocks.listRunning })) +vi.mock('../wsl/discovery/distro-catalog', () => ({ + listRunningWslDistrosAsync: mocks.listRunning +})) import { observeWslTranscriptRunningState, diff --git a/src/main/native-chat/wsl-transcript-running-observer.ts b/src/main/native-chat/wsl-transcript-running-observer.ts index 3b554accce7..f90fdeae789 100644 --- a/src/main/native-chat/wsl-transcript-running-observer.ts +++ b/src/main/native-chat/wsl-transcript-running-observer.ts @@ -1,5 +1,5 @@ -import { listRunningWslDistrosAsync } from '../wsl' -import { filterPathsToWslDistros } from '../wsl-running-path-filter' +import { listRunningWslDistrosAsync } from '../wsl/discovery/distro-catalog' +import { filterPathsToWslDistros } from '../wsl/filesystem/wsl-running-path-filter' /** Every watched WSL transcript shares one running-list read on this cadence, and reuses any * read another caller started within it, so watching never adds a `wsl.exe` per watcher. */ diff --git a/src/main/native-chat/wsl-transcript-watcher-running-guard.ts b/src/main/native-chat/wsl-transcript-watcher-running-guard.ts index 551580456e1..3a4a0dd1b8a 100644 --- a/src/main/native-chat/wsl-transcript-watcher-running-guard.ts +++ b/src/main/native-chat/wsl-transcript-watcher-running-guard.ts @@ -1,5 +1,5 @@ import { isWslUncPath } from '../../shared/wsl-paths' -import { filterPathsToRunningWslDistrosAsync } from '../wsl-running-path-filter' +import { filterPathsToRunningWslDistrosAsync } from '../wsl/filesystem/wsl-running-path-filter' import { createTranscriptNativeWatcher, type TranscriptNativeWatcher diff --git a/src/main/opencode/opencode-launch-capabilities.ts b/src/main/opencode/opencode-launch-capabilities.ts index 2f932e88b15..e879ded87ff 100644 --- a/src/main/opencode/opencode-launch-capabilities.ts +++ b/src/main/opencode/opencode-launch-capabilities.ts @@ -5,7 +5,7 @@ import { } from '../../shared/opencode-cli-version' import type { TuiAgent } from '../../shared/tui-agent' import { resolveCommandOnLocalPath } from '../ipc/command-path-resolver' -import { runWslProcess } from '../wsl/wsl-runner' +import { runWslProcess } from '../wsl/execution/wsl-runner' import { probeOpenCodeCliVersion } from './opencode-cli-version' import { getAgentLaunchCommandToken, diff --git a/src/main/opencode/opencode-wsl-probe-environment.test.ts b/src/main/opencode/opencode-wsl-probe-environment.test.ts index 1bb6fa03eb3..7fe9593dfd7 100644 --- a/src/main/opencode/opencode-wsl-probe-environment.test.ts +++ b/src/main/opencode/opencode-wsl-probe-environment.test.ts @@ -4,7 +4,9 @@ import { seedWslGuestEnvironmentForTests } from '../wsl/wsl-guest-environment' const run = vi.hoisted(() => vi.fn()) vi.mock('@orca/process-host', () => ({ runProcess: run })) -vi.mock('../wsl/wsl-executable-path', () => ({ resolveWslExecutablePath: () => 'wsl.exe' })) +vi.mock('../wsl/execution/wsl-executable-path', () => ({ + resolveWslExecutablePath: () => 'wsl.exe' +})) vi.mock('../agent-hooks/server', () => ({ agentHookServer: { endpointFilePath: null } })) beforeEach(() => { diff --git a/src/main/persistence/loading-store/repo-lifecycle-operations.ts b/src/main/persistence/loading-store/repo-lifecycle-operations.ts index faa17bbb222..6811ff0fae4 100644 --- a/src/main/persistence/loading-store/repo-lifecycle-operations.ts +++ b/src/main/persistence/loading-store/repo-lifecycle-operations.ts @@ -17,7 +17,7 @@ import { RepoOrderPersistenceOperations } from '../tracking-repos/repo-order-ope import { pruneWorktreeStateForRepo as pruneWorktreeStateForRepoOperation } from '../tracking-repos/repo-worktree-pruning' import { collectDeregisteredRepoIds } from '../tracking-repos/deregistered-repo-residue' import { retireLocalWorktreeMetadataPruneStateForRepo } from '../../workspaces/catalog/local-worktree-metadata-prune-gate' -import { releaseWslStoppedWorktreeRescan } from '../../wsl-stopped-worktree-rescan-registry' +import { releaseWslStoppedWorktreeRescan } from '../../wsl/discovery/wsl-stopped-worktree-rescan-registry' import { hydrateRepo as hydrateRepoOperation } from '../tracking-repos/repo-hydration' import { RepoUpdatePersistenceOperations } from '../tracking-repos/repo-update-operations' import { ProjectHostSetupPersistenceOperations } from '../tracking-repos/project-host-setup-update' @@ -33,7 +33,7 @@ import { pruneDeregisteredRepoUiResidue } from './repo-lifecycle-ui-residue' import { isWslMoveProjectSessionFrozen } from '../moving-wsl-projects/wsl-move-scope-guard' import { dropOrcadTerminalRestoreHintsForWorktrees } from '../migrating-orcad-catalog/orcad-terminal-restore-hint-store' import { getRepoIdFromWorktreeId } from '../../../shared/worktree/id' -import { applyNewWindowsDriveProjectDefault } from '../../wsl/wsl-drive-project-new-default' +import { applyNewWindowsDriveProjectDefault } from '../../wsl/filesystem/wsl-drive-project-new-default' // A paused WSL move keeps its local rows for a downgrade. function removeLocalRepoSession( diff --git a/src/main/persistence/moving-wsl-projects/wsl-move-fence.ts b/src/main/persistence/moving-wsl-projects/wsl-move-fence.ts index 458849bdcf6..b95f86de45d 100644 --- a/src/main/persistence/moving-wsl-projects/wsl-move-fence.ts +++ b/src/main/persistence/moving-wsl-projects/wsl-move-fence.ts @@ -7,7 +7,7 @@ import { wslMoveScopeRootPaths } from './wsl-move-scope-roots' import { listWslDriveUncConversions, type WslDriveUncConversion -} from '../../wsl/wsl-drive-unc-conversion-journal' +} from '../../wsl/filesystem/wsl-drive-unc-conversion-journal' export type WslMoveScopeIds = { repoIds: ReadonlySet diff --git a/src/main/persistence/moving-wsl-projects/wsl-move-host-readiness.ts b/src/main/persistence/moving-wsl-projects/wsl-move-host-readiness.ts index e5a7eea56c2..8f2fd5721dd 100644 --- a/src/main/persistence/moving-wsl-projects/wsl-move-host-readiness.ts +++ b/src/main/persistence/moving-wsl-projects/wsl-move-host-readiness.ts @@ -3,7 +3,7 @@ * only a distro the running-distro read confirms gets its host connected, or added for a bridge * user who never added one. A failed read proves nothing, so it never counts as stopped. */ -import type { WslRunningDistrosRead } from '../../wsl-background-distro-gate' +import type { WslRunningDistrosRead } from '../../wsl/discovery/wsl-background-distro-gate' import { wslMoveJournalKey } from '../../../shared/wsl-move/wsl-move-cutover' import type { WslHostAddResult } from '../../../shared/wsl-host-types' import type { WslMoveHostReadiness } from './wsl-move-orchestrator-ports' diff --git a/src/main/persistence/moving-wsl-projects/wsl-move-moved-distro-check.ts b/src/main/persistence/moving-wsl-projects/wsl-move-moved-distro-check.ts index 9a2d9f9859c..bc92ccc3daa 100644 --- a/src/main/persistence/moving-wsl-projects/wsl-move-moved-distro-check.ts +++ b/src/main/persistence/moving-wsl-projects/wsl-move-moved-distro-check.ts @@ -3,7 +3,7 @@ * same distro. A new GUID under the old name is either a reinstall or a re-import of the same * files, which the registry cannot tell apart. */ -import type { WslDistroRegistration } from '../../wsl/wsl-distro-registry-id' +import type { WslDistroRegistration } from '../../wsl/discovery/wsl-distro-registry-id' import type { WslMovedDistroVerdict } from './wsl-move-orchestrator-external-transitions' export function wslMovedDistroVerdict( diff --git a/src/main/persistence/moving-wsl-projects/wsl-move-scope-guard.ts b/src/main/persistence/moving-wsl-projects/wsl-move-scope-guard.ts index a6f933e1ab1..e3482b3362f 100644 --- a/src/main/persistence/moving-wsl-projects/wsl-move-scope-guard.ts +++ b/src/main/persistence/moving-wsl-projects/wsl-move-scope-guard.ts @@ -5,7 +5,7 @@ import { parseWorkspaceKey } from '../../../shared/workspace-scope' import { isWslUncPath } from '../../../shared/wsl-paths' import { getRepoExecutionHostId, LOCAL_EXECUTION_HOST_ID } from '../../../shared/execution-host' import { onWslMoveJournalChange } from './wsl-move-cutover-journal' -import { onWslDriveUncConversionJournalChange } from '../../wsl/wsl-drive-unc-conversion-journal' +import { onWslDriveUncConversionJournalChange } from '../../wsl/filesystem/wsl-drive-unc-conversion-journal' import { resolveWslMoveFence, type WslMoveFenceState } from './wsl-move-fence' import { comparableWslPath, isAtOrUnder } from './wsl-move-comparable-path' import { diff --git a/src/main/persistence/moving-wsl-projects/wsl-move-startup.ts b/src/main/persistence/moving-wsl-projects/wsl-move-startup.ts index 594ddc8eebd..29f7f07cbf5 100644 --- a/src/main/persistence/moving-wsl-projects/wsl-move-startup.ts +++ b/src/main/persistence/moving-wsl-projects/wsl-move-startup.ts @@ -4,7 +4,7 @@ */ import type { Store } from '../loading-store/store' import { recoverInterruptedWslMoves } from './wsl-move-reset' -import { isWslDistroRegistered } from '../../wsl/wsl-distro-registry-id' +import { isWslDistroRegistered } from '../../wsl/discovery/wsl-distro-registry-id' import { runWslMoveStartupRewrite } from './wsl-move-startup-rewrite' import { installWslMoveRetention } from './wsl-move-retention' import { registerWslMoveDesktopRewriteRegistry } from './wsl-move-desktop-rewrite-registry' diff --git a/src/main/persistence/tracking-repos/persistence-repo-lifecycle.test.ts b/src/main/persistence/tracking-repos/persistence-repo-lifecycle.test.ts index bb4df006160..1b460a03f61 100644 --- a/src/main/persistence/tracking-repos/persistence-repo-lifecycle.test.ts +++ b/src/main/persistence/tracking-repos/persistence-repo-lifecycle.test.ts @@ -32,7 +32,7 @@ import { hostWorktreeTarget } from '../../../shared/worktree/host-qualified-iden import { _pendingWslStoppedWorktreeRescanCount, holdWslStoppedWorktreeRescan -} from '../../wsl-stopped-worktree-rescan-registry' +} from '../../wsl/discovery/wsl-stopped-worktree-rescan-registry' import type { ExecutionHostId } from '../../../shared/execution-host' const at = (id: string, hostId: ExecutionHostId) => hostWorktreeTarget({ id, hostId }) diff --git a/src/main/ports/local-workspace-port-attribution-wsl-gate.test.ts b/src/main/ports/local-workspace-port-attribution-wsl-gate.test.ts index ff578adf2eb..dc0b636cedd 100644 --- a/src/main/ports/local-workspace-port-attribution-wsl-gate.test.ts +++ b/src/main/ports/local-workspace-port-attribution-wsl-gate.test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import type * as FsPromises from 'node:fs/promises' -import type * as WslUncAccessGate from '../wsl/wsl-unc-access-gate' +import type * as WslUncAccessGate from '../wsl/filesystem/wsl-unc-access-gate' const mocks = vi.hoisted(() => ({ realpath: vi.fn(async (path: string) => path), @@ -10,7 +10,7 @@ vi.mock('node:fs/promises', async (importOriginal) => ({ ...(await importOriginal()), realpath: mocks.realpath })) -vi.mock('../wsl/wsl-unc-access-gate', async (importOriginal) => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', async (importOriginal) => ({ ...(await importOriginal()), blockedWslDistroForPath: mocks.blocked })) diff --git a/src/main/ports/local-workspace-port-attribution.ts b/src/main/ports/local-workspace-port-attribution.ts index 56c6a94dd8f..d08481278bb 100644 --- a/src/main/ports/local-workspace-port-attribution.ts +++ b/src/main/ports/local-workspace-port-attribution.ts @@ -1,7 +1,7 @@ import path from 'node:path' import { realpath } from 'node:fs/promises' import { withTimeout } from '../../shared/promise-timeout-fallback' -import { blockedWslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' import { PrioritySemaphore } from '../../shared/priority-semaphore' import { mapWithConcurrency } from '../../shared/map-with-concurrency' import type { diff --git a/src/main/preflight/agent-detection.ts b/src/main/preflight/agent-detection.ts index ad73464a7a7..eda919c6b32 100644 --- a/src/main/preflight/agent-detection.ts +++ b/src/main/preflight/agent-detection.ts @@ -29,8 +29,8 @@ import { type RemoteWindowsTerminalCapabilities } from '../ipc/preflight-remote-windows-terminal-capabilities' import { invalidateWslGuestEnvironment } from '../wsl/wsl-guest-environment' -import { prunePreflightWslCache } from '../preflight-wsl-cache' -import { assertWslDistroRunningForExec } from '../wsl/wsl-background-exec-gate' +import { prunePreflightWslCache } from '../wsl/discovery/preflight-wsl-cache' +import { assertWslDistroRunningForExec } from '../wsl/discovery/wsl-background-exec-gate' import { detectInstalledAgents, type InstalledAgentDetectionOptions diff --git a/src/main/preflight/preflight-wsl-stopped-distro.test.ts b/src/main/preflight/preflight-wsl-stopped-distro.test.ts index 3f3e633eabd..0811f520547 100644 --- a/src/main/preflight/preflight-wsl-stopped-distro.test.ts +++ b/src/main/preflight/preflight-wsl-stopped-distro.test.ts @@ -7,14 +7,14 @@ vi.mock('@orca/process-host', async (importOriginal) => ({ ...(await importOriginal()), runProcess: mocks.runProcess })) -vi.mock('../wsl/wsl-runner', async (importOriginal) => ({ +vi.mock('../wsl/execution/wsl-runner', async (importOriginal) => ({ ...(await importOriginal()), runWslProcess: mocks.runWslProcess })) -import { _resetWslCachesForTests } from '../wsl' -import { _resetWslBackgroundDistroGateForTests } from '../wsl-background-distro-gate' -import { runAsWslExecUserAct } from '../wsl/wsl-background-exec-gate' +import { _resetWslCachesForTests } from '../wsl/discovery/distro-catalog' +import { _resetWslBackgroundDistroGateForTests } from '../wsl/discovery/wsl-background-distro-gate' +import { runAsWslExecUserAct } from '../wsl/discovery/wsl-background-exec-gate' import { _resetPreflightCache, runPreflightCheck } from './agent-detection' function runningList(...distros: string[]): ProcessResult { diff --git a/src/main/preflight/workspace-agent-detection.test.ts b/src/main/preflight/workspace-agent-detection.test.ts index 7b5ab6e29b1..0ff0bec6a78 100644 --- a/src/main/preflight/workspace-agent-detection.test.ts +++ b/src/main/preflight/workspace-agent-detection.test.ts @@ -20,7 +20,7 @@ import { detectProjectLaunchContext, type WorkspaceAgentDetectionStore } from './workspace-agent-detection' -import { _resetWslCachesForTests, _setWslCachesForTests } from '../wsl' +import { _resetWslCachesForTests, _setWslCachesForTests } from '../wsl/discovery/distro-catalog' const { detectInstalledMock, refreshMock } = vi.hoisted(() => ({ detectInstalledMock: vi.fn(), @@ -28,7 +28,7 @@ const { detectInstalledMock, refreshMock } = vi.hoisted(() => ({ })) // These cases cover a running distro; the E9 stopped-distro gate has its own suite. -vi.mock('../wsl/wsl-background-exec-gate', () => ({ +vi.mock('../wsl/discovery/wsl-background-exec-gate', () => ({ assertWslDistroRunningForExec: async () => {}, runAsWslExecUserAct: async (_distro: unknown, act: () => Promise) => act() })) diff --git a/src/main/preflight/workspace-agent-detection.ts b/src/main/preflight/workspace-agent-detection.ts index 2bab515be9b..94396a43b74 100644 --- a/src/main/preflight/workspace-agent-detection.ts +++ b/src/main/preflight/workspace-agent-detection.ts @@ -33,7 +33,7 @@ import { type RefreshAgentsResult } from './agent-detection' import type { InstalledAgentDetectionOptions } from './installed-agent-detection' -import { assertWslDistroRunningForExec } from '../wsl/wsl-background-exec-gate' +import { assertWslDistroRunningForExec } from '../wsl/discovery/wsl-background-exec-gate' export type AgentDetectionHost = | { kind: 'local'; context?: PreflightRuntimeContext } diff --git a/src/main/project-groups/folder-workspace-path-status.ts b/src/main/project-groups/folder-workspace-path-status.ts index a10f7b0a2cc..f68e3624a01 100644 --- a/src/main/project-groups/folder-workspace-path-status.ts +++ b/src/main/project-groups/folder-workspace-path-status.ts @@ -10,7 +10,7 @@ import { getProjectGroupSubtreeIds } from '../../shared/project-groups' import type { FolderWorkspace } from '../../shared/folder-workspace-types' import type { ProjectGroup } from '../../shared/project-group-types' import type { Repo } from '../../shared/repo-types' -import { blockedWslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' type FolderWorkspacePathStatusStore = { getRepos: () => Repo[] diff --git a/src/main/providers/local-filesystem-provider.ts b/src/main/providers/local-filesystem-provider.ts index d46dfb6f44b..5a8633e2e4c 100644 --- a/src/main/providers/local-filesystem-provider.ts +++ b/src/main/providers/local-filesystem-provider.ts @@ -24,7 +24,7 @@ import type { FileWriteResult } from '../../shared/file-write-disk-precondition' import { writeLocalTextFileWithDiskPrecondition } from '../ipc/filesystem/local-disk-write-precondition' -import { windowsFsPath } from '../wsl/wsl-unc-drive-fs-path' +import { windowsFsPath } from '../wsl/filesystem/wsl-unc-drive-fs-path' export type LocalFilesystemProviderOptions = { /** Read lazily so a call that fails earlier never touches the store. */ diff --git a/src/main/providers/local-pty/local-pty-executable-spawn.test.ts b/src/main/providers/local-pty/local-pty-executable-spawn.test.ts index 694d989adda..053e1196611 100644 --- a/src/main/providers/local-pty/local-pty-executable-spawn.test.ts +++ b/src/main/providers/local-pty/local-pty-executable-spawn.test.ts @@ -38,7 +38,7 @@ function dirStats(isDirectory: boolean): Stats { return { isDirectory: () => isDirectory } as Stats } -vi.mock('../../wsl', () => ({ +vi.mock('../../wsl/filesystem/unc-path-access', () => ({ wslUncDirectoryExistsAsync: wslUncDirectoryExistsAsyncMock })) diff --git a/src/main/providers/local-pty/local-pty-launch-context.ts b/src/main/providers/local-pty/local-pty-launch-context.ts index 1f3f2079c39..68f82ecbb59 100644 --- a/src/main/providers/local-pty/local-pty-launch-context.ts +++ b/src/main/providers/local-pty/local-pty-launch-context.ts @@ -1,6 +1,6 @@ import { basename, delimiter, win32 as pathWin32 } from 'node:path' import { splitWorktreeIdForFilesystem } from '../../../shared/worktree/id' -import { parseWslPath } from '../../wsl' +import { parseWslPath } from '../../wsl/filesystem/unc-path-access' import { resolvePathEnvKey } from '../../pty/environment/windows-path-segment-merge' import { expandWindowsEnvironmentVariables } from '../../../shared/windows-environment-expansion' import { resolveSafePtyDefaultCwd } from '../pty-default-cwd' diff --git a/src/main/providers/local-pty/local-pty-launch-plan.ts b/src/main/providers/local-pty/local-pty-launch-plan.ts index f03b50e3e43..9d1f91a84e4 100644 --- a/src/main/providers/local-pty/local-pty-launch-plan.ts +++ b/src/main/providers/local-pty/local-pty-launch-plan.ts @@ -3,7 +3,8 @@ import { recognizeAgentProcessFromCommandLine } from '../../../shared/agent-proc import { WINDOWS_GIT_BASH_SHELL } from '../../../shared/windows-terminal-shell' import { resolveWindowsGitBashShellPath } from '../../pty/shell-startup/git-bash' import { resolveUnixPaneShellPath } from '../../daemon/shell-ready' -import { getDefaultWslDistro, parseWslPath } from '../../wsl' +import { getDefaultWslDistro } from '../../wsl/discovery/distro-catalog' +import { parseWslPath } from '../../wsl/filesystem/unc-path-access' import { getDefaultCwd, getWslContextFromPreferredDistro, diff --git a/src/main/providers/local-pty/local-pty-provider-foreground-process.test.ts b/src/main/providers/local-pty/local-pty-provider-foreground-process.test.ts index 362c00b967d..898fad8f9ab 100644 --- a/src/main/providers/local-pty/local-pty-provider-foreground-process.test.ts +++ b/src/main/providers/local-pty/local-pty-provider-foreground-process.test.ts @@ -1,5 +1,5 @@ import type * as WslPathOwner from '../../../shared/wsl-paths' -import type * as WslAvailabilityTypes from '../../wsl-availability' +import type * as WslAvailabilityTypes from '../../wsl/discovery/wsl-availability' import { assert, beforeEach, describe, expect, it, vi } from 'vitest' import type * as MacosTccLoginShell from '../macos-tcc-login-shell' import type * as ForegroundProcess from '../agent-foreground-process' @@ -49,8 +49,9 @@ const { vi.mock('../../../shared/wsl-paths', async (importOriginal) => ({ ...(await importOriginal()), - toLinuxPath: (await vi.importMock>('../../wsl')) - .toLinuxPath + toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), + toWindowsWslPath: (path: string, distro: string) => + `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}` })) vi.mock('fs', () => ({ @@ -119,7 +120,7 @@ vi.mock('../windows-console-attached-processes', () => ({ readWindowsConsoleAttachedProcessIds: consoleMembers })) -vi.mock('../../wsl', () => ({ +vi.mock('../../wsl/filesystem/unc-path-access', () => ({ parseWslPath: (path: string) => { const match = path.match(/^\\\\wsl\.localhost\\([^\\]+)(.*)$/) if (!match) { @@ -130,16 +131,13 @@ vi.mock('../../wsl', () => ({ linuxPath: (match[2] || '').replace(/\\/g, '/') || '/' } }, - toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), - toWindowsWslPath: (path: string, distro: string) => - `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}`, - getDefaultWslDistro: () => 'Ubuntu', - isWslAvailableAsync: () => isWslAvailableAsyncMock(), - // Fixture WSL UNC directories exist; avoid launching wsl.exe to validate them. wslUncDirectoryExistsAsync: (...args: unknown[]) => wslUncDirectoryExistsAsyncMock(...args) })) +vi.mock('../../wsl/discovery/distro-catalog', () => ({ + getDefaultWslDistro: () => 'Ubuntu' +})) -vi.mock('../../wsl-availability', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-availability', async (importOriginal) => ({ ...(await importOriginal()), isWslAvailableAsync: () => isWslAvailableAsyncMock() })) diff --git a/src/main/providers/local-pty/local-pty-provider-io-events.test.ts b/src/main/providers/local-pty/local-pty-provider-io-events.test.ts index 769b4b96613..b4e7dfb409f 100644 --- a/src/main/providers/local-pty/local-pty-provider-io-events.test.ts +++ b/src/main/providers/local-pty/local-pty-provider-io-events.test.ts @@ -1,5 +1,5 @@ import type * as WslPathOwner from '../../../shared/wsl-paths' -import type * as WslAvailabilityTypes from '../../wsl-availability' +import type * as WslAvailabilityTypes from '../../wsl/discovery/wsl-availability' import { beforeEach, describe, expect, it, vi } from 'vitest' import type * as MacosTccLoginShell from '../macos-tcc-login-shell' @@ -35,8 +35,9 @@ const { vi.mock('../../../shared/wsl-paths', async (importOriginal) => ({ ...(await importOriginal()), - toLinuxPath: (await vi.importMock>('../../wsl')) - .toLinuxPath + toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), + toWindowsWslPath: (path: string, distro: string) => + `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}` })) vi.mock('fs', () => ({ @@ -94,7 +95,7 @@ vi.mock('../windows-pty-job-membership', () => ({ isWindowsPtyJobReadable: () => true })) -vi.mock('../../wsl', () => ({ +vi.mock('../../wsl/filesystem/unc-path-access', () => ({ parseWslPath: (path: string) => { const match = path.match(/^\\\\wsl\.localhost\\([^\\]+)(.*)$/) if (!match) { @@ -105,16 +106,13 @@ vi.mock('../../wsl', () => ({ linuxPath: (match[2] || '').replace(/\\/g, '/') || '/' } }, - toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), - toWindowsWslPath: (path: string, distro: string) => - `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}`, - getDefaultWslDistro: () => 'Ubuntu', - isWslAvailableAsync: () => isWslAvailableAsyncMock(), - // Fixture WSL UNC directories exist; avoid launching wsl.exe to validate them. wslUncDirectoryExistsAsync: (...args: unknown[]) => wslUncDirectoryExistsAsyncMock(...args) })) +vi.mock('../../wsl/discovery/distro-catalog', () => ({ + getDefaultWslDistro: () => 'Ubuntu' +})) -vi.mock('../../wsl-availability', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-availability', async (importOriginal) => ({ ...(await importOriginal()), isWslAvailableAsync: () => isWslAvailableAsyncMock() })) diff --git a/src/main/providers/local-pty/local-pty-provider-session-inventory.test.ts b/src/main/providers/local-pty/local-pty-provider-session-inventory.test.ts index 3b88301ddce..0778cacb967 100644 --- a/src/main/providers/local-pty/local-pty-provider-session-inventory.test.ts +++ b/src/main/providers/local-pty/local-pty-provider-session-inventory.test.ts @@ -1,5 +1,5 @@ import type * as WslPathOwner from '../../../shared/wsl-paths' -import type * as WslAvailabilityTypes from '../../wsl-availability' +import type * as WslAvailabilityTypes from '../../wsl/discovery/wsl-availability' import { beforeEach, describe, expect, it, vi } from 'vitest' import type * as MacosTccLoginShell from '../macos-tcc-login-shell' @@ -35,8 +35,9 @@ const { vi.mock('../../../shared/wsl-paths', async (importOriginal) => ({ ...(await importOriginal()), - toLinuxPath: (await vi.importMock>('../../wsl')) - .toLinuxPath + toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), + toWindowsWslPath: (path: string, distro: string) => + `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}` })) vi.mock('fs', () => ({ @@ -94,7 +95,7 @@ vi.mock('../windows-pty-job-membership', () => ({ isWindowsPtyJobReadable: () => true })) -vi.mock('../../wsl', () => ({ +vi.mock('../../wsl/filesystem/unc-path-access', () => ({ parseWslPath: (path: string) => { const match = path.match(/^\\\\wsl\.localhost\\([^\\]+)(.*)$/) if (!match) { @@ -105,16 +106,13 @@ vi.mock('../../wsl', () => ({ linuxPath: (match[2] || '').replace(/\\/g, '/') || '/' } }, - toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), - toWindowsWslPath: (path: string, distro: string) => - `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}`, - getDefaultWslDistro: () => 'Ubuntu', - isWslAvailableAsync: () => isWslAvailableAsyncMock(), - // Fixture WSL UNC directories exist; avoid launching wsl.exe to validate them. wslUncDirectoryExistsAsync: (...args: unknown[]) => wslUncDirectoryExistsAsyncMock(...args) })) +vi.mock('../../wsl/discovery/distro-catalog', () => ({ + getDefaultWslDistro: () => 'Ubuntu' +})) -vi.mock('../../wsl-availability', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-availability', async (importOriginal) => ({ ...(await importOriginal()), isWslAvailableAsync: () => isWslAvailableAsyncMock() })) diff --git a/src/main/providers/local-pty/local-pty-provider-shell-readiness.test.ts b/src/main/providers/local-pty/local-pty-provider-shell-readiness.test.ts index 728d69db802..04bdd5b7e7a 100644 --- a/src/main/providers/local-pty/local-pty-provider-shell-readiness.test.ts +++ b/src/main/providers/local-pty/local-pty-provider-shell-readiness.test.ts @@ -1,5 +1,5 @@ import type * as WslPathOwner from '../../../shared/wsl-paths' -import type * as WslAvailabilityTypes from '../../wsl-availability' +import type * as WslAvailabilityTypes from '../../wsl/discovery/wsl-availability' import { beforeEach, describe, expect, it, vi } from 'vitest' import type * as MacosTccLoginShell from '../macos-tcc-login-shell' @@ -35,8 +35,9 @@ const { vi.mock('../../../shared/wsl-paths', async (importOriginal) => ({ ...(await importOriginal()), - toLinuxPath: (await vi.importMock>('../../wsl')) - .toLinuxPath + toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), + toWindowsWslPath: (path: string, distro: string) => + `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}` })) vi.mock('fs', () => ({ @@ -94,7 +95,7 @@ vi.mock('../windows-pty-job-membership', () => ({ isWindowsPtyJobReadable: () => true })) -vi.mock('../../wsl', () => ({ +vi.mock('../../wsl/filesystem/unc-path-access', () => ({ parseWslPath: (path: string) => { const match = path.match(/^\\\\wsl\.localhost\\([^\\]+)(.*)$/) if (!match) { @@ -105,16 +106,13 @@ vi.mock('../../wsl', () => ({ linuxPath: (match[2] || '').replace(/\\/g, '/') || '/' } }, - toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), - toWindowsWslPath: (path: string, distro: string) => - `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}`, - getDefaultWslDistro: () => 'Ubuntu', - isWslAvailableAsync: () => isWslAvailableAsyncMock(), - // Fixture WSL UNC directories exist; avoid launching wsl.exe to validate them. wslUncDirectoryExistsAsync: (...args: unknown[]) => wslUncDirectoryExistsAsyncMock(...args) })) +vi.mock('../../wsl/discovery/distro-catalog', () => ({ + getDefaultWslDistro: () => 'Ubuntu' +})) -vi.mock('../../wsl-availability', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-availability', async (importOriginal) => ({ ...(await importOriginal()), isWslAvailableAsync: () => isWslAvailableAsyncMock() })) diff --git a/src/main/providers/local-pty/local-pty-provider-shutdown.test.ts b/src/main/providers/local-pty/local-pty-provider-shutdown.test.ts index 6b89f187782..71323618c2a 100644 --- a/src/main/providers/local-pty/local-pty-provider-shutdown.test.ts +++ b/src/main/providers/local-pty/local-pty-provider-shutdown.test.ts @@ -1,5 +1,5 @@ import type * as WslPathOwner from '../../../shared/wsl-paths' -import type * as WslAvailabilityTypes from '../../wsl-availability' +import type * as WslAvailabilityTypes from '../../wsl/discovery/wsl-availability' import { beforeEach, describe, expect, it, vi } from 'vitest' import type * as MacosTccLoginShell from '../macos-tcc-login-shell' import type * as PosixPtyProcessTable from '../../pty/process-retirement/posix-pty-process-table' @@ -38,8 +38,9 @@ const { vi.mock('../../../shared/wsl-paths', async (importOriginal) => ({ ...(await importOriginal()), - toLinuxPath: (await vi.importMock>('../../wsl')) - .toLinuxPath + toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), + toWindowsWslPath: (path: string, distro: string) => + `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}` })) vi.mock('fs', () => ({ @@ -104,7 +105,7 @@ vi.mock('../windows-pty-job-membership', () => ({ isWindowsPtyJobReadable: () => true })) -vi.mock('../../wsl', () => ({ +vi.mock('../../wsl/filesystem/unc-path-access', () => ({ parseWslPath: (path: string) => { const match = path.match(/^\\\\wsl\.localhost\\([^\\]+)(.*)$/) if (!match) { @@ -115,16 +116,13 @@ vi.mock('../../wsl', () => ({ linuxPath: (match[2] || '').replace(/\\/g, '/') || '/' } }, - toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), - toWindowsWslPath: (path: string, distro: string) => - `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}`, - getDefaultWslDistro: () => 'Ubuntu', - isWslAvailableAsync: () => isWslAvailableAsyncMock(), - // Fixture WSL UNC directories exist; avoid launching wsl.exe to validate them. wslUncDirectoryExistsAsync: (...args: unknown[]) => wslUncDirectoryExistsAsyncMock(...args) })) +vi.mock('../../wsl/discovery/distro-catalog', () => ({ + getDefaultWslDistro: () => 'Ubuntu' +})) -vi.mock('../../wsl-availability', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-availability', async (importOriginal) => ({ ...(await importOriginal()), isWslAvailableAsync: () => isWslAvailableAsyncMock() })) diff --git a/src/main/providers/local-pty/local-pty-provider-spawn-cwd-safety.test.ts b/src/main/providers/local-pty/local-pty-provider-spawn-cwd-safety.test.ts index 930dd288018..188eadba406 100644 --- a/src/main/providers/local-pty/local-pty-provider-spawn-cwd-safety.test.ts +++ b/src/main/providers/local-pty/local-pty-provider-spawn-cwd-safety.test.ts @@ -1,5 +1,5 @@ import type * as WslPathOwner from '../../../shared/wsl-paths' -import type * as WslAvailabilityTypes from '../../wsl-availability' +import type * as WslAvailabilityTypes from '../../wsl/discovery/wsl-availability' import { beforeEach, describe, expect, it, vi } from 'vitest' import type * as MacosTccLoginShell from '../macos-tcc-login-shell' @@ -35,8 +35,9 @@ const { vi.mock('../../../shared/wsl-paths', async (importOriginal) => ({ ...(await importOriginal()), - toLinuxPath: (await vi.importMock>('../../wsl')) - .toLinuxPath + toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), + toWindowsWslPath: (path: string, distro: string) => + `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}` })) vi.mock('fs', () => ({ @@ -94,7 +95,7 @@ vi.mock('../windows-pty-job-membership', () => ({ isWindowsPtyJobReadable: () => true })) -vi.mock('../../wsl', () => ({ +vi.mock('../../wsl/filesystem/unc-path-access', () => ({ parseWslPath: (path: string) => { const match = path.match(/^\\\\wsl\.localhost\\([^\\]+)(.*)$/) if (!match) { @@ -105,16 +106,13 @@ vi.mock('../../wsl', () => ({ linuxPath: (match[2] || '').replace(/\\/g, '/') || '/' } }, - toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), - toWindowsWslPath: (path: string, distro: string) => - `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}`, - getDefaultWslDistro: () => 'Ubuntu', - isWslAvailableAsync: () => isWslAvailableAsyncMock(), - // Fixture WSL UNC directories exist; avoid launching wsl.exe to validate them. wslUncDirectoryExistsAsync: (...args: unknown[]) => wslUncDirectoryExistsAsyncMock(...args) })) +vi.mock('../../wsl/discovery/distro-catalog', () => ({ + getDefaultWslDistro: () => 'Ubuntu' +})) -vi.mock('../../wsl-availability', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-availability', async (importOriginal) => ({ ...(await importOriginal()), isWslAvailableAsync: () => isWslAvailableAsyncMock() })) diff --git a/src/main/providers/local-pty/local-pty-provider-spawn-env.test.ts b/src/main/providers/local-pty/local-pty-provider-spawn-env.test.ts index 6ff41382fc2..e52decf8106 100644 --- a/src/main/providers/local-pty/local-pty-provider-spawn-env.test.ts +++ b/src/main/providers/local-pty/local-pty-provider-spawn-env.test.ts @@ -1,5 +1,5 @@ import type * as WslPathOwner from '../../../shared/wsl-paths' -import type * as WslAvailabilityTypes from '../../wsl-availability' +import type * as WslAvailabilityTypes from '../../wsl/discovery/wsl-availability' import { beforeEach, describe, expect, it, vi } from 'vitest' import { delimiter } from 'node:path' import type * as MacosTccLoginShell from '../macos-tcc-login-shell' @@ -37,8 +37,9 @@ const { vi.mock('../../../shared/wsl-paths', async (importOriginal) => ({ ...(await importOriginal()), - toLinuxPath: (await vi.importMock>('../../wsl')) - .toLinuxPath + toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), + toWindowsWslPath: (path: string, distro: string) => + `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}` })) vi.mock('fs', () => ({ @@ -96,7 +97,7 @@ vi.mock('../windows-pty-job-membership', () => ({ isWindowsPtyJobReadable: () => true })) -vi.mock('../../wsl', () => ({ +vi.mock('../../wsl/filesystem/unc-path-access', () => ({ parseWslPath: (path: string) => { const match = path.match(/^\\\\wsl\.localhost\\([^\\]+)(.*)$/) if (!match) { @@ -107,16 +108,13 @@ vi.mock('../../wsl', () => ({ linuxPath: (match[2] || '').replace(/\\/g, '/') || '/' } }, - toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), - toWindowsWslPath: (path: string, distro: string) => - `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}`, - getDefaultWslDistro: () => 'Ubuntu', - isWslAvailableAsync: () => isWslAvailableAsyncMock(), - // Fixture WSL UNC directories exist; avoid launching wsl.exe to validate them. wslUncDirectoryExistsAsync: (...args: unknown[]) => wslUncDirectoryExistsAsyncMock(...args) })) +vi.mock('../../wsl/discovery/distro-catalog', () => ({ + getDefaultWslDistro: () => 'Ubuntu' +})) -vi.mock('../../wsl-availability', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-availability', async (importOriginal) => ({ ...(await importOriginal()), isWslAvailableAsync: () => isWslAvailableAsyncMock() })) diff --git a/src/main/providers/local-pty/local-pty-provider-spawn-session.test.ts b/src/main/providers/local-pty/local-pty-provider-spawn-session.test.ts index 496db740e1d..60f0d176431 100644 --- a/src/main/providers/local-pty/local-pty-provider-spawn-session.test.ts +++ b/src/main/providers/local-pty/local-pty-provider-spawn-session.test.ts @@ -1,5 +1,5 @@ import type * as WslPathOwner from '../../../shared/wsl-paths' -import type * as WslAvailabilityTypes from '../../wsl-availability' +import type * as WslAvailabilityTypes from '../../wsl/discovery/wsl-availability' import { beforeEach, describe, expect, it, vi } from 'vitest' import type * as MacosTccLoginShell from '../macos-tcc-login-shell' import type { ShellSpawnParams } from './local-pty-executable-spawn' @@ -36,8 +36,9 @@ const { vi.mock('../../../shared/wsl-paths', async (importOriginal) => ({ ...(await importOriginal()), - toLinuxPath: (await vi.importMock>('../../wsl')) - .toLinuxPath + toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), + toWindowsWslPath: (path: string, distro: string) => + `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}` })) vi.mock('fs', () => ({ @@ -104,7 +105,7 @@ vi.mock('../windows-pty-job-membership', () => ({ isWindowsPtyJobReadable: () => true })) -vi.mock('../../wsl', () => ({ +vi.mock('../../wsl/filesystem/unc-path-access', () => ({ parseWslPath: (path: string) => { const match = path.match(/^\\\\wsl\.localhost\\([^\\]+)(.*)$/) if (!match) { @@ -115,16 +116,13 @@ vi.mock('../../wsl', () => ({ linuxPath: (match[2] || '').replace(/\\/g, '/') || '/' } }, - toLinuxPath: (path: string) => path.replace(/^C:\\/i, '/mnt/c/').replace(/\\/g, '/'), - toWindowsWslPath: (path: string, distro: string) => - `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}`, - getDefaultWslDistro: () => 'Ubuntu', - isWslAvailableAsync: () => isWslAvailableAsyncMock(), - // Fixture WSL UNC directories exist; avoid launching wsl.exe to validate them. wslUncDirectoryExistsAsync: (...args: unknown[]) => wslUncDirectoryExistsAsyncMock(...args) })) +vi.mock('../../wsl/discovery/distro-catalog', () => ({ + getDefaultWslDistro: () => 'Ubuntu' +})) -vi.mock('../../wsl-availability', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-availability', async (importOriginal) => ({ ...(await importOriginal()), isWslAvailableAsync: () => isWslAvailableAsyncMock() })) diff --git a/src/main/providers/local-pty/local-pty-provider-windows-shell-launch.test.ts b/src/main/providers/local-pty/local-pty-provider-windows-shell-launch.test.ts index 6c7c343e07d..be74f6be7fb 100644 --- a/src/main/providers/local-pty/local-pty-provider-windows-shell-launch.test.ts +++ b/src/main/providers/local-pty/local-pty-provider-windows-shell-launch.test.ts @@ -1,5 +1,5 @@ import type * as WslPathOwner from '../../../shared/wsl-paths' -import type * as WslAvailabilityTypes from '../../wsl-availability' +import type * as WslAvailabilityTypes from '../../wsl/discovery/wsl-availability' import { beforeEach, describe, expect, it, vi } from 'vitest' import type * as MacosTccLoginShell from '../macos-tcc-login-shell' @@ -41,7 +41,9 @@ const { vi.mock('../../../shared/wsl-paths', async (importOriginal) => ({ ...(await importOriginal()), - toLinuxPath: toLinuxPathMock + toLinuxPath: toLinuxPathMock, + toWindowsWslPath: (path: string, distro: string) => + `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}` })) vi.mock('fs', () => ({ @@ -100,24 +102,20 @@ vi.mock('../windows-pty-job-membership', () => ({ isWindowsPtyJobReadable: () => true })) -vi.mock('../../wsl', async () => ({ - // The real parser, so both UNC spellings (\\wsl.localhost and \\wsl$) reach the launch plan. +vi.mock('../../wsl/filesystem/unc-path-access', async () => ({ parseWslPath: (await import('../../../shared/wsl-paths')).parseWslUncPath, - toLinuxPath: toLinuxPathMock, - toWindowsWslPath: (path: string, distro: string) => - `\\\\wsl.localhost\\${distro}${path.replace(/\//g, '\\')}`, - getDefaultWslDistro: () => 'Ubuntu', - isWslAvailableAsync: () => isWslAvailableAsyncMock(), - // Fixture WSL UNC directories exist; avoid launching wsl.exe to validate them. wslUncDirectoryExistsAsync: (...args: unknown[]) => wslUncDirectoryExistsAsyncMock(...args) })) +vi.mock('../../wsl/discovery/distro-catalog', async () => ({ + getDefaultWslDistro: () => 'Ubuntu' +})) -vi.mock('../../wsl-availability', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-availability', async (importOriginal) => ({ ...(await importOriginal()), isWslAvailableAsync: () => isWslAvailableAsyncMock() })) -vi.mock('../../wsl-background-distro-gate', () => ({ +vi.mock('../../wsl/discovery/wsl-background-distro-gate', () => ({ readWslDistroRunningState: (...args: unknown[]) => readWslDistroRunningStateMock(...args) })) diff --git a/src/main/providers/local-pty/local-pty-session-operations.ts b/src/main/providers/local-pty/local-pty-session-operations.ts index 5b17273a1c6..02707eb8572 100644 --- a/src/main/providers/local-pty/local-pty-session-operations.ts +++ b/src/main/providers/local-pty/local-pty-session-operations.ts @@ -5,7 +5,7 @@ import { readPtsName } from '../../pty/process-retirement/node-pty-pts-name' import { readPtyForegroundGroup } from '../../pty/process-retirement/pty-master-foreground-observation' import { signalPosixPtyForegroundGroup } from '../../pty/process-retirement/posix-pty-foreground-group' import { ptyShellProcessId } from '../../windows/windows-pty-job' -import { isWslAvailableAsync } from '../../wsl-availability' +import { isWslAvailableAsync } from '../../wsl/discovery/wsl-availability' import { resolveGitBashPath } from '../../pty/shell-startup/git-bash' import { resolveProcessCwd } from '../process-cwd' import { diff --git a/src/main/providers/local-pty/local-pty-shell-ready-bash-rcfile.ts b/src/main/providers/local-pty/local-pty-shell-ready-bash-rcfile.ts index 083e6815dbd..3b0575c8b04 100644 --- a/src/main/providers/local-pty/local-pty-shell-ready-bash-rcfile.ts +++ b/src/main/providers/local-pty/local-pty-shell-ready-bash-rcfile.ts @@ -2,7 +2,7 @@ import { BASH_PROMPT_COMMAND_COMPOSITION_BLOCK } from '../../pty/shell-startup/bash-prompt-command-composition' import { ORCA_CLI_POSIX_PATH_RESTORE } from '../../../shared/orca-cli-shell-path' import { MANAGED_DATA_ACCOUNT_POSIX_RESTORE } from '../../../shared/managed-data-account-shell' -import { WSL_MANAGED_CLI_PATH_RESTORE } from '../../wsl-managed-cli-path-restore' +import { WSL_MANAGED_CLI_PATH_RESTORE } from '../../wsl/execution/wsl-managed-cli-path-restore' import { getPosixOmpShellWrapper } from '../../pty/shell-startup/omp-shell-wrapper' import { getPosixCodexShellLaunchPreflight } from '../../../shared/codex-shell-function' import { getPosixClaudeShellFunction } from '../../../shared/claude-shell-function' @@ -12,7 +12,7 @@ import { SHELL_STARTUP_IDENTITY_MARKER_BLOCK } from '../../pty/shell-startup/shell-templates' import { SHELL_READY_MARKER_ESCAPED } from './local-pty-shell-ready-marker' -import { BASH_WSL_CWD_REPORT_BLOCK } from '../../wsl-shell-cwd-report' +import { BASH_WSL_CWD_REPORT_BLOCK } from '../../wsl/filesystem/wsl-shell-cwd-report' export function getBashShellReadyRcfileContent(): string { return `# Orca bash shell-ready wrapper diff --git a/src/main/providers/local-pty/local-pty-shell-ready-wrapper-fileset.ts b/src/main/providers/local-pty/local-pty-shell-ready-wrapper-fileset.ts index b63022b047f..2214f8f08f7 100644 --- a/src/main/providers/local-pty/local-pty-shell-ready-wrapper-fileset.ts +++ b/src/main/providers/local-pty/local-pty-shell-ready-wrapper-fileset.ts @@ -13,7 +13,7 @@ import { type ZshStartupHookSpec } from '../../pty/shell-startup/zsh-startup-wrapper-builder' import { getBashShellReadyRcfileContent } from './local-pty-shell-ready-bash-rcfile' -import { SH_WSL_ENV_FILE } from '../../wsl-shell-cwd-report' +import { SH_WSL_ENV_FILE } from '../../wsl/filesystem/wsl-shell-cwd-report' import { SHELL_READY_MARKER_ESCAPED } from './local-pty-shell-ready-marker' /** Paths in the generated tree, kept separate so existence checks do not rebuild wrapper bytes. */ diff --git a/src/main/providers/local-pty/local-pty-spawn-environment-wsl-background.test.ts b/src/main/providers/local-pty/local-pty-spawn-environment-wsl-background.test.ts index be3c2f66b84..a30138b6e08 100644 --- a/src/main/providers/local-pty/local-pty-spawn-environment-wsl-background.test.ts +++ b/src/main/providers/local-pty/local-pty-spawn-environment-wsl-background.test.ts @@ -2,8 +2,8 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest' import { buildLocalPtySpawnEnvironment } from './local-pty-spawn-environment' import type { LocalPtyLaunchPlan } from './local-pty-launch-plan' import type { PtySpawnOptions } from '../pty-provider-contract' -import { runAsWslLaunchUserAct } from '../../wsl/wsl-background-exec-gate' -import { isWslUserActFor } from '../../wsl/wsl-user-act-scope' +import { runAsWslLaunchUserAct } from '../../wsl/discovery/wsl-background-exec-gate' +import { isWslUserActFor } from '../../wsl/discovery/wsl-user-act-scope' const plan: LocalPtyLaunchPlan = { startupAgentRecognition: null, diff --git a/src/main/providers/local-pty/local-pty-windows-spawn-environment.ts b/src/main/providers/local-pty/local-pty-windows-spawn-environment.ts index c596a9e61d4..59b183228e2 100644 --- a/src/main/providers/local-pty/local-pty-windows-spawn-environment.ts +++ b/src/main/providers/local-pty/local-pty-windows-spawn-environment.ts @@ -9,7 +9,7 @@ import { isWslCodexHomeForHost } from '../../pty/shell-startup/codex-home-wsl-env' import { addWslEnvKeys } from '../../../shared/wsl-env' -import { parseWslPath } from '../../wsl' +import { parseWslPath } from '../../wsl/filesystem/unc-path-access' import { isWindowsGitBashShellPath } from '../../pty/shell-startup/git-bash' import type { LocalPtyLaunchPlan } from './local-pty-launch-plan' import { diff --git a/src/main/providers/windows-shell-args.ts b/src/main/providers/windows-shell-args.ts index 2414c64a947..088181937ef 100644 --- a/src/main/providers/windows-shell-args.ts +++ b/src/main/providers/windows-shell-args.ts @@ -1,6 +1,7 @@ import { win32 as pathWin32 } from 'node:path' import { isWindowsGitBashShellPath } from '../pty/shell-startup/git-bash' -import { parseWslPath, toLinuxPath, toWindowsWslPath } from '../wsl' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' +import { toLinuxPath, toWindowsWslPath } from '../../shared/wsl-paths' import { buildWslExecArgs, buildWslInteractiveLoginShellCommand diff --git a/src/main/providers/working-directory-validation-retention.test.ts b/src/main/providers/working-directory-validation-retention.test.ts index 8cf6a5e24e2..d5e5933257d 100644 --- a/src/main/providers/working-directory-validation-retention.test.ts +++ b/src/main/providers/working-directory-validation-retention.test.ts @@ -5,7 +5,7 @@ const { stat } = vi.hoisted(() => ({ stat: vi.fn<() => Promise<{ isDirectory: () => boolean }>>() })) vi.mock('node:fs/promises', () => ({ stat })) -vi.mock('../wsl', () => ({ +vi.mock('../wsl/filesystem/unc-path-access', () => ({ wslUncDirectoryExistsAsync: () => { throw new Error('Unexpected WSL probe') } diff --git a/src/main/providers/working-directory-validation.test.ts b/src/main/providers/working-directory-validation.test.ts index 26eae6a1999..ee7fea9cbeb 100644 --- a/src/main/providers/working-directory-validation.test.ts +++ b/src/main/providers/working-directory-validation.test.ts @@ -5,7 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' const wslUncDirectoryExistsAsyncMock = vi.hoisted(() => vi.fn()) -vi.mock('../wsl', async (importOriginal) => { +vi.mock('../wsl/filesystem/unc-path-access', async (importOriginal) => { const actual = (await importOriginal()) as Record return { ...actual, wslUncDirectoryExistsAsync: wslUncDirectoryExistsAsyncMock } }) diff --git a/src/main/providers/working-directory-validation.ts b/src/main/providers/working-directory-validation.ts index 748cf5eb880..272f58ba8da 100644 --- a/src/main/providers/working-directory-validation.ts +++ b/src/main/providers/working-directory-validation.ts @@ -2,7 +2,7 @@ import { existsSync, statSync } from 'node:fs' import { stat } from 'node:fs/promises' import { release } from 'node:os' import { isWslUncPath, uncRouteKey } from '../../shared/wsl-paths' -import { wslUncDirectoryExistsAsync } from '../wsl' +import { wslUncDirectoryExistsAsync } from '../wsl/filesystem/unc-path-access' import { PrioritySemaphore } from '../../shared/priority-semaphore' const pendingWorkingDirectoryValidations = new Map>() diff --git a/src/main/pty/history/terminal-history-deletion.ts b/src/main/pty/history/terminal-history-deletion.ts index 9868dbac465..dc6976ce6bb 100644 --- a/src/main/pty/history/terminal-history-deletion.ts +++ b/src/main/pty/history/terminal-history-deletion.ts @@ -10,8 +10,8 @@ import { PENDING_DELETE_DIR_NAME } from './terminal-history-paths' import { hashWorktreeId } from './terminal-history-id' -import { deleteWslFishHistoryFile } from '../../wsl-fish-history-cleanup' -import { deferUntilWslDistroRunning } from '../../wsl-background-distro-gate' +import { deleteWslFishHistoryFile } from '../../wsl/history/wsl-fish-history-cleanup' +import { deferUntilWslDistroRunning } from '../../wsl/discovery/wsl-background-distro-gate' const pendingHistoryTreeRemovals = new Map>() export const MAX_PENDING_HISTORY_TREE_REMOVALS = 64 diff --git a/src/main/pty/history/terminal-history-tombstone-retry.test.ts b/src/main/pty/history/terminal-history-tombstone-retry.test.ts index 9ded5430be7..0ae70cf1ddd 100644 --- a/src/main/pty/history/terminal-history-tombstone-retry.test.ts +++ b/src/main/pty/history/terminal-history-tombstone-retry.test.ts @@ -15,7 +15,7 @@ vi.mock('../../filesystem/host-tree-removal', () => ({ removeHostTree: removeHostTreeMock })) -vi.mock('../../wsl-fish-history-cleanup', () => ({ +vi.mock('../../wsl/history/wsl-fish-history-cleanup', () => ({ deleteWslFishHistoryFile: deleteWslFishHistoryFileMock })) @@ -32,7 +32,7 @@ import { import { _resetWslBackgroundDistroGateForTests, noteWslDistrosRunning -} from '../../wsl-background-distro-gate' +} from '../../wsl/discovery/wsl-background-distro-gate' // Real filesystem reads need the actual event loop, even while timers are faked. const realSetImmediate = setImmediate diff --git a/src/main/pty/history/terminal-history.test.ts b/src/main/pty/history/terminal-history.test.ts index c9c1965501d..a79e6c49029 100644 --- a/src/main/pty/history/terminal-history.test.ts +++ b/src/main/pty/history/terminal-history.test.ts @@ -76,12 +76,11 @@ const { parseWslPathMock, toLinuxPathMock } = vi.hoisted(() => ({ toLinuxPathMock: vi.fn((p: string) => p) })) -vi.mock('../../wsl', () => ({ - parseWslPath: parseWslPathMock, - toLinuxPath: toLinuxPathMock +vi.mock('../../wsl/filesystem/unc-path-access', () => ({ + parseWslPath: parseWslPathMock })) -vi.mock('../../wsl-fish-history-cleanup', () => ({ +vi.mock('../../wsl/history/wsl-fish-history-cleanup', () => ({ deleteWslFishHistoryFile: deleteWslFishHistoryFileMock })) diff --git a/src/main/pty/history/terminal-history.ts b/src/main/pty/history/terminal-history.ts index 31674a0b8fe..9882c257c71 100644 --- a/src/main/pty/history/terminal-history.ts +++ b/src/main/pty/history/terminal-history.ts @@ -8,7 +8,7 @@ import { resolveFishHistoryDir } from './fish-history-session' import { dropInheritedOrcaHistFile } from './worktree-history-file-path' -import { parseWslPath } from '../../wsl' +import { parseWslPath } from '../../wsl/filesystem/unc-path-access' import { toLinuxPath } from '../../../shared/wsl-paths' import { getHistoryRoot, getHistoryRootWsl } from './terminal-history-paths' import { hashWorktreeId } from './terminal-history-id' diff --git a/src/main/pty/shell-startup/zsh-startup-wrapper-builder.ts b/src/main/pty/shell-startup/zsh-startup-wrapper-builder.ts index 49d8203ccaa..61b9218d2b8 100644 --- a/src/main/pty/shell-startup/zsh-startup-wrapper-builder.ts +++ b/src/main/pty/shell-startup/zsh-startup-wrapper-builder.ts @@ -2,7 +2,7 @@ import { ORCA_CLI_POSIX_PATH_RESTORE } from '../../../shared/orca-cli-shell-path import { MANAGED_DATA_ACCOUNT_POSIX_RESTORE } from '../../../shared/managed-data-account-shell' /** Restore ZDOTDIR before user startup; define functions first so .zshenv emulation cannot change their parsing. */ import { getPosixOmpShellWrapper } from './omp-shell-wrapper' -import { WSL_MANAGED_CLI_PATH_RESTORE } from '../../wsl-managed-cli-path-restore' +import { WSL_MANAGED_CLI_PATH_RESTORE } from '../../wsl/execution/wsl-managed-cli-path-restore' import { getPosixCodexShellLaunchPreflight } from '../../../shared/codex-shell-function' import { getPosixClaudeShellFunction } from '../../../shared/claude-shell-function' import { @@ -17,7 +17,7 @@ import { ZSH_USER_ZSHENV_SOURCE_BLOCK, ZSH_ZDOTDIR_HANDBACK_BLOCK } from './shell-templates' -import { ZSH_WSL_CWD_REPORT_BLOCK } from '../../wsl-shell-cwd-report' +import { ZSH_WSL_CWD_REPORT_BLOCK } from '../../wsl/filesystem/wsl-shell-cwd-report' export type ZshWrapperRestoreSpec = { /** Local-only PATH restore; inert outside WSL. */ diff --git a/src/main/rate-limits/claude-managed-account-usage.ts b/src/main/rate-limits/claude-managed-account-usage.ts index 15ee29f2c1e..f649fb460e8 100644 --- a/src/main/rate-limits/claude-managed-account-usage.ts +++ b/src/main/rate-limits/claude-managed-account-usage.ts @@ -7,7 +7,7 @@ import { toWindowsWslPath } from '../../shared/wsl-paths' import type { ClaudeManagedAccountUsageOptions } from './claude-usage-fetch-options' import { fetchActiveClaudeRateLimits } from './claude-active-usage-fetch' import { claudeUsageUnavailable, makeClaudeUsageResult } from './claude-usage-result' -import { blockedWslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' /** Derive host account folders from account ids, never stored paths. */ export type InactiveClaudeAccount = { diff --git a/src/main/rate-limits/claude-profile-usage.test.ts b/src/main/rate-limits/claude-profile-usage.test.ts index 2f0fa3ae3e3..2e70846e646 100644 --- a/src/main/rate-limits/claude-profile-usage.test.ts +++ b/src/main/rate-limits/claude-profile-usage.test.ts @@ -27,7 +27,7 @@ const runningDistros = vi.hoisted(() => ({ const settledGate = vi.hoisted(() => ({ override: vi.fn((): { distro: string; state: 'stopped' } | undefined => undefined) })) -vi.mock('../wsl/wsl-unc-access-gate', () => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', () => ({ blockedWslDistroForPath: async (path: string) => { const override = settledGate.override() if (override !== undefined) { diff --git a/src/main/rate-limits/codex-fetcher.test.ts b/src/main/rate-limits/codex-fetcher.test.ts index dc64fe5bffd..d2591ff25ee 100644 --- a/src/main/rate-limits/codex-fetcher.test.ts +++ b/src/main/rate-limits/codex-fetcher.test.ts @@ -46,7 +46,7 @@ vi.mock('../codex-cli/command', () => ({ resolveCodexCommand: resolveCodexCommandMock })) -vi.mock('../wsl-interop-spawn-directory', () => ({ +vi.mock('../wsl/execution/wsl-interop-spawn-directory', () => ({ resolveWslInteropSpawnCwd: () => 'C:\\Windows' })) vi.mock('node-pty', () => ({ diff --git a/src/main/rate-limits/codex-fetcher.ts b/src/main/rate-limits/codex-fetcher.ts index 70d604bcffc..36ea44e7a3c 100644 --- a/src/main/rate-limits/codex-fetcher.ts +++ b/src/main/rate-limits/codex-fetcher.ts @@ -33,7 +33,7 @@ import { import { readCodexRateLimitsViaRpc } from './codex-rpc-rate-limit-probe' import { getHiddenProbeWslCwdSetupCommands, resolveHiddenProbeCwd } from './hidden-probe-cwd' import { quotePosixShell } from '../../shared/shell-argument-quoting' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' +import { resolveWslInteropSpawnCwd } from '../wsl/execution/wsl-interop-spawn-directory' const RPC_TIMEOUT_MS = 10_000 const WSL_RPC_TIMEOUT_MS = 25_000 diff --git a/src/main/rate-limits/codex-rate-limit-wsl-home-gate.test.ts b/src/main/rate-limits/codex-rate-limit-wsl-home-gate.test.ts index 4074f0c7ebe..d1aba98de99 100644 --- a/src/main/rate-limits/codex-rate-limit-wsl-home-gate.test.ts +++ b/src/main/rate-limits/codex-rate-limit-wsl-home-gate.test.ts @@ -2,7 +2,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type { CodexAccountSelectionTarget } from '../../shared/codex-selection-lane' import type { CodexRateLimitHomeResolution } from '../codex-accounts/runtime-home-service-types' -vi.mock('../wsl/wsl-default-distro', () => ({ resolveWslDefaultDistro: vi.fn(async () => null) })) +vi.mock('../wsl/discovery/wsl-default-distro', () => ({ + resolveWslDefaultDistro: vi.fn(async () => null) +})) const { resolveCodexRateLimitHomeUnlessStopped } = await import('./codex-rate-limit-wsl-home-gate') diff --git a/src/main/rate-limits/codex-rate-limit-wsl-home-gate.ts b/src/main/rate-limits/codex-rate-limit-wsl-home-gate.ts index fe500de0a07..239e27e2060 100644 --- a/src/main/rate-limits/codex-rate-limit-wsl-home-gate.ts +++ b/src/main/rate-limits/codex-rate-limit-wsl-home-gate.ts @@ -1,8 +1,8 @@ import type { CodexAccountSelectionTarget } from '../../shared/codex-selection-lane' import { parseWslUncPath } from '../../shared/wsl-paths' import type { CodexRateLimitHomeResolution } from '../codex-accounts/runtime-home-service-types' -import { isWslDistroRunning } from '../wsl-background-distro-gate' -import { resolveWslDefaultDistro } from '../wsl/wsl-default-distro' +import { isWslDistroRunning } from '../wsl/discovery/wsl-background-distro-gate' +import { resolveWslDefaultDistro } from '../wsl/discovery/wsl-default-distro' type CodexRateLimitHomeSource = { prepareForRateLimitFetch: ( diff --git a/src/main/rate-limits/inactive-codex-home.ts b/src/main/rate-limits/inactive-codex-home.ts index 3311196fa29..b52b63b07c1 100644 --- a/src/main/rate-limits/inactive-codex-home.ts +++ b/src/main/rate-limits/inactive-codex-home.ts @@ -1,4 +1,4 @@ -import { blockedWslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' import type { InactiveCodexHome } from './service/service-types' /** A preview is no act on its distro: reading a stopped one's home would boot it (E9). */ diff --git a/src/main/ripgrep/bundled-ripgrep-text-search.ts b/src/main/ripgrep/bundled-ripgrep-text-search.ts index 59f1e828721..c2560be6845 100644 --- a/src/main/ripgrep/bundled-ripgrep-text-search.ts +++ b/src/main/ripgrep/bundled-ripgrep-text-search.ts @@ -20,7 +20,7 @@ import { isTransientRipgrepSpawnError, ripgrepMissingCwdError } from '../../shared/ripgrep-process-availability' -import { toWindowsWslPath } from '../wsl' +import { toWindowsWslPath } from '../../shared/wsl-paths' import { bundledRipgrepUnavailableError } from './bundled-ripgrep-path' import { spawnBundledRipgrep } from './bundled-ripgrep-spawn' import { stopBundledRipgrep } from './bundled-ripgrep-stop' diff --git a/src/main/ripgrep/bundled-ripgrep-wsl-routing.ts b/src/main/ripgrep/bundled-ripgrep-wsl-routing.ts index 75f40a50db2..9dc58b38422 100644 --- a/src/main/ripgrep/bundled-ripgrep-wsl-routing.ts +++ b/src/main/ripgrep/bundled-ripgrep-wsl-routing.ts @@ -1,4 +1,4 @@ -import { parseWslPath } from '../wsl' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' export type BundledRipgrepWslRouting = { /** Distro the spawn is routed into via wsl.exe; unset runs the host binary. */ diff --git a/src/main/runtime/agent-launch-scope-runtime.test.ts b/src/main/runtime/agent-launch-scope-runtime.test.ts index f75c6685719..7f466069097 100644 --- a/src/main/runtime/agent-launch-scope-runtime.test.ts +++ b/src/main/runtime/agent-launch-scope-runtime.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest' import type { Repo } from '../../shared/repo-types' import type { FolderWorkspace } from '../../shared/folder-workspace-types' -import { _resetWslCachesForTests, _setWslCachesForTests } from '../wsl' +import { _resetWslCachesForTests, _setWslCachesForTests } from '../wsl/discovery/distro-catalog' import { agentLaunchPlatformForScope, resolveAgentLaunchRuntime diff --git a/src/main/runtime/files/file-reads.ts b/src/main/runtime/files/file-reads.ts index ae180fe0835..433aca97a9a 100644 --- a/src/main/runtime/files/file-reads.ts +++ b/src/main/runtime/files/file-reads.ts @@ -24,8 +24,8 @@ import { previewableBinaryByteLimit } from './file-preview-budget' import { readLocalFileRange } from '../../ipc/filesystem/local-file-range-read' -import { windowsFsPath } from '../../wsl/wsl-unc-drive-fs-path' -import { guardWslUncPathAccess } from '../../wsl/wsl-unc-access-gate' +import { windowsFsPath } from '../../wsl/filesystem/wsl-unc-drive-fs-path' +import { guardWslUncPathAccess } from '../../wsl/filesystem/wsl-unc-access-gate' import { resolveLocalFileRequestPath } from '../../ipc/local-file-access-resolution' import type { LocalFileAccess } from '../../../shared/local-file-access' import { filePreviewForPath } from '../../../shared/file-preview-kind' diff --git a/src/main/runtime/opencode-wsl-folder-launch-host.test.ts b/src/main/runtime/opencode-wsl-folder-launch-host.test.ts index 40424d9f36b..f27c7671c44 100644 --- a/src/main/runtime/opencode-wsl-folder-launch-host.test.ts +++ b/src/main/runtime/opencode-wsl-folder-launch-host.test.ts @@ -3,7 +3,7 @@ import { afterEach, beforeEach, expect, it, vi } from 'vitest' import { OrcaRuntimeService } from './orca-runtime' import { RpcDispatcher } from './rpc/dispatcher' import { AGENT_SESSION_METHODS } from './rpc/methods/agent-session' -import { _resetWslCachesForTests, _setWslCachesForTests } from '../wsl' +import { _resetWslCachesForTests, _setWslCachesForTests } from '../wsl/discovery/distro-catalog' import { PROJECT_RUNTIME_REPAIR_REQUIRED_CODE } from '../../shared/project-runtime-repair-message' import { partialRuntimeStore, diff --git a/src/main/runtime/orca-runtime-create-base-prefetch.test.ts b/src/main/runtime/orca-runtime-create-base-prefetch.test.ts index ee8937ebc91..3d8b9048bd1 100644 --- a/src/main/runtime/orca-runtime-create-base-prefetch.test.ts +++ b/src/main/runtime/orca-runtime-create-base-prefetch.test.ts @@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type * as WorktreeCreatePreparation from '../workspaces/creation/preparation/worktree-create-preparation' import type { Project } from '../../shared/project-types' import type { Repo } from '../../shared/repo-types' -import { _resetWslCachesForTests, _setWslCachesForTests } from '../wsl' +import { _resetWslCachesForTests, _setWslCachesForTests } from '../wsl/discovery/distro-catalog' const mocks = vi.hoisted(() => ({ prefetchWorktreeCreateBase: vi.fn(), diff --git a/src/main/runtime/orca-runtime-test-mocks/setup.spec.ts b/src/main/runtime/orca-runtime-test-mocks/setup.spec.ts index bbf94e4e6f5..5b198234cd5 100644 --- a/src/main/runtime/orca-runtime-test-mocks/setup.spec.ts +++ b/src/main/runtime/orca-runtime-test-mocks/setup.spec.ts @@ -3,7 +3,7 @@ import { expect, vi } from 'vitest' import type { Mock } from 'vitest' import type * as GitUsernameModule from '../../git/git-username' import type * as GitRepoDefaultBaseRefModule from '../../git/repo-default-base-ref' -import type * as WslUncAccessGateModule from '../../wsl/wsl-unc-access-gate' +import type * as WslUncAccessGateModule from '../../wsl/filesystem/wsl-unc-access-gate' import type * as FilesystemPathContainmentModule from '../../ipc/filesystem/filesystem-path-containment' import { reviewHeadRemoteRefComponent } from '../../../shared/review-head-tracking-ref' @@ -310,7 +310,7 @@ vi.mock('../repo-worktree-resolution-scan', () => ({ })) // Fake-win32 runtime tests have no wsl.exe: treat every distro as running unless a test says otherwise. -vi.mock('../../wsl/wsl-unc-access-gate', async (importOriginal) => { +vi.mock('../../wsl/filesystem/wsl-unc-access-gate', async (importOriginal) => { const actual = await importOriginal() const blockedWslDistroForPath = vi.fn(async () => null) return { diff --git a/src/main/runtime/orca-runtime-tests/wsl-stopped-distro-worktree-scan.spec.ts b/src/main/runtime/orca-runtime-tests/wsl-stopped-distro-worktree-scan.spec.ts index 48170abf5b0..4f9c5541104 100644 --- a/src/main/runtime/orca-runtime-tests/wsl-stopped-distro-worktree-scan.spec.ts +++ b/src/main/runtime/orca-runtime-tests/wsl-stopped-distro-worktree-scan.spec.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from 'vitest' import * as repoWorktreeAdminFingerprint from '../repo-worktree-admin-fingerprint' -import * as wslUncAccessGate from '../../wsl/wsl-unc-access-gate' +import * as wslUncAccessGate from '../../wsl/filesystem/wsl-unc-access-gate' import { OrcaRuntimeService, listWorktrees } from '../orca-runtime-test-mocks.spec' import { makeWorktreeInfo, makeWorktreeMeta, store } from '../orca-runtime-test-fixtures.spec' diff --git a/src/main/runtime/rpc/methods/host-capabilities.ts b/src/main/runtime/rpc/methods/host-capabilities.ts index 12736aaad90..acb678b000f 100644 --- a/src/main/runtime/rpc/methods/host-capabilities.ts +++ b/src/main/runtime/rpc/methods/host-capabilities.ts @@ -1,6 +1,7 @@ import { defineMethod } from '../core' import { isPwshAvailableAsync } from '../../../pty/shell-startup/pwsh' -import { isWslAvailableAsync, listWslDistrosAsync } from '../../../wsl' +import { isWslAvailableAsync } from '../../../wsl/discovery/wsl-availability' +import { listWslDistrosAsync } from '../../../wsl/discovery/distro-catalog' import { isGitBashAvailable } from '../../../pty/shell-startup/git-bash' export const HOST_CAPABILITY_METHODS = [ diff --git a/src/main/runtime/rpc/methods/preflight-selected-target.test.ts b/src/main/runtime/rpc/methods/preflight-selected-target.test.ts index a7a2769de8b..c850884eaf0 100644 --- a/src/main/runtime/rpc/methods/preflight-selected-target.test.ts +++ b/src/main/runtime/rpc/methods/preflight-selected-target.test.ts @@ -33,7 +33,7 @@ const { refresh, deliver } = vi.hoisted(() => ({ })) vi.mock('./agent-launch-terminal-prompt', () => ({ deliverTerminalAgentLaunchPrompt: deliver })) // These ownership cases use a running distro; the stopped-distro contract is separate. -vi.mock('../../../wsl/wsl-background-exec-gate', () => ({ +vi.mock('../../../wsl/discovery/wsl-background-exec-gate', () => ({ assertWslDistroRunningForExec: async () => {}, runAsWslExecUserAct: async (_distro: unknown, act: () => Promise) => act() })) diff --git a/src/main/runtime/rpc/methods/preflight.test.ts b/src/main/runtime/rpc/methods/preflight.test.ts index 8db4fed8855..78a6731f363 100644 --- a/src/main/runtime/rpc/methods/preflight.test.ts +++ b/src/main/runtime/rpc/methods/preflight.test.ts @@ -28,7 +28,7 @@ vi.mock('../../../preflight/agent-detection', () => ({ })) // The running gate is real on Windows CI; each case states whether the distro runs. -vi.mock('../../../wsl/wsl-background-exec-gate', () => ({ +vi.mock('../../../wsl/discovery/wsl-background-exec-gate', () => ({ assertWslDistroRunningForExec: assertWslDistroRunningForExecMock })) diff --git a/src/main/runtime/rpc/methods/skills.test.ts b/src/main/runtime/rpc/methods/skills.test.ts index b5418c7ce54..240bcea5495 100644 --- a/src/main/runtime/rpc/methods/skills.test.ts +++ b/src/main/runtime/rpc/methods/skills.test.ts @@ -10,7 +10,7 @@ vi.mock('../../../skills/skill-discovery-target', () => ({ discoverSkillsOnTarget: vi.fn(async () => ({ skills: [], sources: [], scannedAt: 1 })) })) // Off Windows the real gate never sees a distro; stand in for its UNC parse. -vi.mock('../../../wsl/wsl-unc-access-gate', async (importOriginal) => ({ +vi.mock('../../../wsl/filesystem/wsl-unc-access-gate', async (importOriginal) => ({ ...(await importOriginal>()), wslDistroForPath: (path: string) => /^\\\\wsl\.localhost\\([^\\]+)/.exec(path)?.[1] ?? null })) diff --git a/src/main/runtime/rpc/methods/skills.ts b/src/main/runtime/rpc/methods/skills.ts index 09fb8111155..89e7e18ae7e 100644 --- a/src/main/runtime/rpc/methods/skills.ts +++ b/src/main/runtime/rpc/methods/skills.ts @@ -45,7 +45,7 @@ import { SkillsGetInstallProgressParams } from '../../../../shared/rpc-contract/skills-params' import { unavailableWhileWslDistroStopped } from '../../../skills/skill-discovery-stopped-wsl-roots' -import { runAsWslUserAct, wslDistroForPath } from '../../../wsl/wsl-unc-access-gate' +import { runAsWslUserAct, wslDistroForPath } from '../../../wsl/filesystem/wsl-unc-access-gate' // Use the same target resolution for discovery and delete-plan roots, including WSL. export function resolveDiscoveryTarget( diff --git a/src/main/runtime/runtime-agent-terminal-startup.test.ts b/src/main/runtime/runtime-agent-terminal-startup.test.ts index 4cf969a4b21..e25c4610a1a 100644 --- a/src/main/runtime/runtime-agent-terminal-startup.test.ts +++ b/src/main/runtime/runtime-agent-terminal-startup.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { detectAgentCommandsOnHost } from '../preflight/agent-detection' import { resolveAgentTerminalCreateOptions } from './runtime-agent-terminal-startup' -import { _resetWslCachesForTests, _setWslCachesForTests } from '../wsl' +import { _resetWslCachesForTests, _setWslCachesForTests } from '../wsl/discovery/distro-catalog' import { MIXED_FOLDER, MIXED_GROUP } from '../../shared/folder-workspace-host-routing.test-fixture' import { getDefaultWorkspaceSession } from '../../shared/constants' diff --git a/src/main/runtime/runtime-folder-workspace-wsl-failed-start-pane.test.ts b/src/main/runtime/runtime-folder-workspace-wsl-failed-start-pane.test.ts index 19d8ecc8ac6..2064195d38e 100644 --- a/src/main/runtime/runtime-folder-workspace-wsl-failed-start-pane.test.ts +++ b/src/main/runtime/runtime-folder-workspace-wsl-failed-start-pane.test.ts @@ -17,8 +17,8 @@ const { makeFolderWorkspace, TEST_FOLDER_WORKSPACE_KEY } = await import('./orca-runtime-test-fixtures.spec') -const { blockedWslDistroForPath } = await import('../wsl/wsl-unc-access-gate') -const { isWslUserActFor } = await import('../wsl/wsl-user-act-scope') +const { blockedWslDistroForPath } = await import('../wsl/filesystem/wsl-unc-access-gate') +const { isWslUserActFor } = await import('../wsl/discovery/wsl-user-act-scope') const PARENT = '\\\\wsl.localhost\\Ubuntu\\home\\me' const FOLDER = `${PARENT}\\notes` diff --git a/src/main/runtime/runtime-folder-workspace-wsl-launch-scope.test.ts b/src/main/runtime/runtime-folder-workspace-wsl-launch-scope.test.ts index 634ac3fd38a..4656a7ba696 100644 --- a/src/main/runtime/runtime-folder-workspace-wsl-launch-scope.test.ts +++ b/src/main/runtime/runtime-folder-workspace-wsl-launch-scope.test.ts @@ -16,8 +16,8 @@ const { makeFolderWorkspace, TEST_FOLDER_WORKSPACE_KEY } = await import('./orca-runtime-test-fixtures.spec') -const { blockedWslDistroForPath } = await import('../wsl/wsl-unc-access-gate') -const { isWslUserActFor } = await import('../wsl/wsl-user-act-scope') +const { blockedWslDistroForPath } = await import('../wsl/filesystem/wsl-unc-access-gate') +const { isWslUserActFor } = await import('../wsl/discovery/wsl-user-act-scope') const { wslDistroHoldMessage } = await import('../../shared/wsl-distro-stopped-hold') const { LOCAL_EXECUTION_HOST_ID } = await import('../../shared/execution-host') diff --git a/src/main/runtime/runtime-gitlab-worktree-base-wsl-gate.test.ts b/src/main/runtime/runtime-gitlab-worktree-base-wsl-gate.test.ts index 22860354afe..0817ea7e830 100644 --- a/src/main/runtime/runtime-gitlab-worktree-base-wsl-gate.test.ts +++ b/src/main/runtime/runtime-gitlab-worktree-base-wsl-gate.test.ts @@ -1,6 +1,6 @@ import './rpc/unused-default-rpc-methods.test-fixture' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as DistroGateModule from '../wsl-background-distro-gate' +import type * as DistroGateModule from '../wsl/discovery/wsl-background-distro-gate' import type { Repo } from '../../shared/repo-types' import type { RpcRequest } from './rpc/core' import type { OrcaRuntimeService } from './orca-runtime' @@ -14,7 +14,7 @@ const mocks = vi.hoisted(() => { }) } }) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: vi.fn(async () => mocks.state.distro) })) diff --git a/src/main/runtime/runtime-hosted-review-commands.ts b/src/main/runtime/runtime-hosted-review-commands.ts index 2335f22cb60..565a0dfac3f 100644 --- a/src/main/runtime/runtime-hosted-review-commands.ts +++ b/src/main/runtime/runtime-hosted-review-commands.ts @@ -31,7 +31,7 @@ import { } from '../source-control/hosted-review-creation' import type { HostedReviewExecutionOptions } from '../source-control/hosted-review-git-options' import { createStackedHostedReview } from '../source-control/stacked-hosted-review-creation' -import { guardWslUncPathAccess } from '../wsl/wsl-unc-access-gate' +import { guardWslUncPathAccess } from '../wsl/filesystem/wsl-unc-access-gate' type HostedReviewTargetArgs = { repoSelector: string; worktreeSelector?: string } diff --git a/src/main/runtime/runtime-repository-fork-backfill.ts b/src/main/runtime/runtime-repository-fork-backfill.ts index ef778121c57..377f5236699 100644 --- a/src/main/runtime/runtime-repository-fork-backfill.ts +++ b/src/main/runtime/runtime-repository-fork-backfill.ts @@ -9,7 +9,7 @@ import { getRepoUpstream } from '../github/client' import { detectGitHubAvatarIcon } from '../repository-icons/repo-icon-autodetect' import type { RuntimeStore } from './runtime-store-contract' import { isWslMoveRepoBlocked } from '../persistence/moving-wsl-projects/wsl-move-background-backoff' -import { blockedWslDistroForPath, wslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath, wslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' export class RuntimeRepositoryForkBackfill { private started = false diff --git a/src/main/runtime/runtime-repository-hooks-commands.test.ts b/src/main/runtime/runtime-repository-hooks-commands.test.ts index acd67bb8247..128aa5c0585 100644 --- a/src/main/runtime/runtime-repository-hooks-commands.test.ts +++ b/src/main/runtime/runtime-repository-hooks-commands.test.ts @@ -8,7 +8,7 @@ const mocks = vi.hoisted(() => ({ loadHooks: vi.fn((): OrcaHooks | null => null) })) -vi.mock('../wsl/wsl-unc-access-gate', () => ({ blockedWslDistroForPath: mocks.blocked })) +vi.mock('../wsl/filesystem/wsl-unc-access-gate', () => ({ blockedWslDistroForPath: mocks.blocked })) vi.mock('../workspace-hooks/hooks', async (importOriginal) => ({ ...(await importOriginal>()), hasHooksFile: mocks.hasHooksFile, diff --git a/src/main/runtime/runtime-repository-hooks-commands.ts b/src/main/runtime/runtime-repository-hooks-commands.ts index ba283a49d8f..7960212d921 100644 --- a/src/main/runtime/runtime-repository-hooks-commands.ts +++ b/src/main/runtime/runtime-repository-hooks-commands.ts @@ -1,6 +1,6 @@ import { getRepoDialableSshTargetId } from '../../shared/execution-host' import { createHash } from 'node:crypto' -import { windowsFsPath } from '../wsl/wsl-unc-drive-fs-path' +import { windowsFsPath } from '../wsl/filesystem/wsl-unc-drive-fs-path' import { readFile } from 'node:fs/promises' import type { Repo } from '../../shared/repo-types' import type { OrcaHooks } from '../../shared/orca-yaml-hook-types' @@ -17,7 +17,7 @@ import { isENOENT } from '../ipc/filesystem/filesystem-path-containment' import { isFolderRepo } from '../../shared/repo-kind' import { inspectSetupScriptImportCandidates } from '../../shared/setup-script-imports' import { joinWorktreeRelativePath } from './runtime-relative-paths' -import { blockedWslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' type RuntimeRepositoryHooksCommandsDeps = { resolveRepo: (selector: string) => Promise diff --git a/src/main/runtime/runtime-repository-ref-queries.ts b/src/main/runtime/runtime-repository-ref-queries.ts index fe0fe61a487..8267ce95a26 100644 --- a/src/main/runtime/runtime-repository-ref-queries.ts +++ b/src/main/runtime/runtime-repository-ref-queries.ts @@ -8,7 +8,7 @@ import { } from '../../shared/repo-search-limits' import { getBaseRefDefault, getRemoteCount, searchBaseRefDetails } from '../git/repo' import { getRepoRoutingConnectionId } from '../../shared/execution-host' -import { blockedWslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' type RuntimeRepositoryRefQueryDependencies = { resolveRepo: (selector: string) => Promise diff --git a/src/main/runtime/runtime-repository-registration-controller.ts b/src/main/runtime/runtime-repository-registration-controller.ts index 24f0da44250..7495d220289 100644 --- a/src/main/runtime/runtime-repository-registration-controller.ts +++ b/src/main/runtime/runtime-repository-registration-controller.ts @@ -23,9 +23,9 @@ import { WslHostWindowsDriveRefusalError, type WslHostWindowsDriveRefusal } from '../../shared/wsl-host-windows-drive-refusal' -import { describeWslUncAccessDenied } from '../wsl/wsl-unc-access-denied' +import { describeWslUncAccessDenied } from '../wsl/filesystem/wsl-unc-access-denied' import { getResolvedFolderWorkspacePathStatus } from '../project-groups/folder-workspace-path-status' -import { runAsWslUserAct, wslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { runAsWslUserAct, wslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' import { repoCreateFailure, type RepoCreateFailure } from '../../shared/repo-create-failure-copy' type RuntimeRepositoryRegistrationDependencies = { diff --git a/src/main/runtime/runtime-skill-install-authority.ts b/src/main/runtime/runtime-skill-install-authority.ts index f3e1bdb4235..070160dd3ee 100644 --- a/src/main/runtime/runtime-skill-install-authority.ts +++ b/src/main/runtime/runtime-skill-install-authority.ts @@ -1,5 +1,5 @@ import { homedir } from 'node:os' -import { getWslHome } from '../wsl' +import { getWslHome } from '../wsl/discovery/distro-catalog' import { parseWslUncPath } from '../../shared/wsl-paths' import { getConnectionExecutionHostId, diff --git a/src/main/runtime/runtime-skill-install-queries.ts b/src/main/runtime/runtime-skill-install-queries.ts index 3844f3e1093..e6174783037 100644 --- a/src/main/runtime/runtime-skill-install-queries.ts +++ b/src/main/runtime/runtime-skill-install-queries.ts @@ -9,7 +9,7 @@ import { previewSharedSkillInstall, removeSharedSkillInstall } from '../skills/skill-install-management-service' -import { toLinuxPath } from '../wsl' +import { toLinuxPath } from '../../shared/wsl-paths' import type { SkillBundleInstallPreviewRequest } from '../../shared/skill-bundle-install-contract' import type { SkillInstallPreviewRequest, diff --git a/src/main/runtime/runtime-wsl-background-read-gate.test.ts b/src/main/runtime/runtime-wsl-background-read-gate.test.ts index 32dc159ea18..cd6e907f74c 100644 --- a/src/main/runtime/runtime-wsl-background-read-gate.test.ts +++ b/src/main/runtime/runtime-wsl-background-read-gate.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' const readWslDistroRunningStateMock = vi.hoisted(() => vi.fn()) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: readWslDistroRunningStateMock })) @@ -13,7 +13,7 @@ import { RuntimeFileAccess } from './files/file-access' import { RuntimeFileReads } from './files/file-reads' import { RuntimeFileWatches } from './files/watch/file-watches' import type { RuntimeGitCommandHost, RuntimeGitTarget } from './runtime-git-command-target' -import { WslDistroStoppedError } from '../wsl/wsl-unc-access-gate' +import { WslDistroStoppedError } from '../wsl/filesystem/wsl-unc-access-gate' import { mapRuntimeError } from './rpc/errors' const UNC_ROOT = '\\\\wsl.localhost\\Ubuntu\\home\\me\\repo' diff --git a/src/main/runtime/runtime-wsl-background-read-gate.ts b/src/main/runtime/runtime-wsl-background-read-gate.ts index 48e512b4f38..f4e5c7a0b15 100644 --- a/src/main/runtime/runtime-wsl-background-read-gate.ts +++ b/src/main/runtime/runtime-wsl-background-read-gate.ts @@ -1,5 +1,5 @@ import { LOCAL_EXECUTION_HOST_ID, type ExecutionHostId } from '../../shared/execution-host' -import { assertWslUncPathRunning } from '../wsl/wsl-unc-access-gate' +import { assertWslUncPathRunning } from '../wsl/filesystem/wsl-unc-access-gate' /** * Paired phone, web and CLI clients poll Git followers no user is looking at; a stopped distro diff --git a/src/main/runtime/session-graph/session-graph-authority.ts b/src/main/runtime/session-graph/session-graph-authority.ts index 19b20975d11..733a8aaa4b2 100644 --- a/src/main/runtime/session-graph/session-graph-authority.ts +++ b/src/main/runtime/session-graph/session-graph-authority.ts @@ -21,7 +21,7 @@ import { blockedWslDistroForPath, runAsWslUserAct, wslDistroForPath -} from '../../wsl/wsl-unc-access-gate' +} from '../../wsl/filesystem/wsl-unc-access-gate' import { wslDistroHoldMessage } from '../../../shared/wsl-distro-stopped-hold' import type { TerminalWorkspaceLaunchScope } from '../runtime-legacy-worker-terminal-recovery-types' import { folderWorkspaceKey, parseWorkspaceKey } from '../../../shared/workspace-scope' diff --git a/src/main/runtime/terminal-kitty-temporary-roots.ts b/src/main/runtime/terminal-kitty-temporary-roots.ts index 2ec74e7dce5..02d82c2ca64 100644 --- a/src/main/runtime/terminal-kitty-temporary-roots.ts +++ b/src/main/runtime/terminal-kitty-temporary-roots.ts @@ -1,6 +1,7 @@ import { tmpdir } from 'node:os' import { realpath } from 'node:fs/promises' -import { parseWslPath, toWindowsWslPath } from '../wsl' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' +import { toWindowsWslPath } from '../../shared/wsl-paths' export async function kittyTemporaryRoots(worktreePath: string): Promise { const roots = new Set([tmpdir()]) diff --git a/src/main/runtime/terminal/terminal-file-path.ts b/src/main/runtime/terminal/terminal-file-path.ts index 1825ca4b703..41d4448adc7 100644 --- a/src/main/runtime/terminal/terminal-file-path.ts +++ b/src/main/runtime/terminal/terminal-file-path.ts @@ -3,7 +3,8 @@ import { isWindowsAbsolutePathLike, resolveRuntimePath } from '../../../shared/cross-platform-path' -import { parseWslPath, toWindowsWslPath } from '../../wsl' +import { parseWslPath } from '../../wsl/filesystem/unc-path-access' +import { toWindowsWslPath } from '../../../shared/wsl-paths' export function resolveTerminalAbsolutePath(args: { base: string diff --git a/src/main/runtime/terminal/terminal-path-resolver.ts b/src/main/runtime/terminal/terminal-path-resolver.ts index a5b00bf27aa..bec68896afd 100644 --- a/src/main/runtime/terminal/terminal-path-resolver.ts +++ b/src/main/runtime/terminal/terminal-path-resolver.ts @@ -2,7 +2,7 @@ import type { RuntimeNativeChatFileContext, RuntimeTerminalPathResolution } from '../../../shared/runtime-types' -import { parseWslPath } from '../../wsl' +import { parseWslPath } from '../../wsl/filesystem/unc-path-access' import { relativePathInsideRoot, resolveRuntimePath } from '../../../shared/cross-platform-path' import { homedir } from 'node:os' import { resolveTerminalAbsolutePath } from './terminal-file-path' diff --git a/src/main/runtime/workspaces/workspace-repo-scan-refresh.ts b/src/main/runtime/workspaces/workspace-repo-scan-refresh.ts index a913d0a4129..9dd0975e19f 100644 --- a/src/main/runtime/workspaces/workspace-repo-scan-refresh.ts +++ b/src/main/runtime/workspaces/workspace-repo-scan-refresh.ts @@ -17,7 +17,7 @@ import type { GitWorktreeInfo } from '../../../shared/worktree/types' import { listStoredWorktreeRowsForRepo } from '../repo-worktree-row-resolution' import type { ResolvedWorktree } from '../runtime-worktree-path-identity' import { getRepoExecutionHostId, getRepoSshConnectionId } from '../../../shared/execution-host' -import { blockedWslDistroForPath, wslDistroForPath } from '../../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath, wslDistroForPath } from '../../wsl/filesystem/wsl-unc-access-gate' const lastFingerprintUnknownWarnAt = new Map() diff --git a/src/main/skills/claude-plugin-skill-sources-wsl.ts b/src/main/skills/claude-plugin-skill-sources-wsl.ts index 1f7c10dc160..1303f2efd33 100644 --- a/src/main/skills/claude-plugin-skill-sources-wsl.ts +++ b/src/main/skills/claude-plugin-skill-sources-wsl.ts @@ -1,6 +1,6 @@ import { posix as pathPosix } from 'node:path' -import { quoteBashString } from '../wsl-bash-command' -import { runWslProcess } from '../wsl/wsl-runner' +import { quotePosixShell as quoteBashString } from '../../shared/shell-argument-quoting' +import { runWslProcess } from '../wsl/execution/wsl-runner' import { getClaudePluginMetadataPaths, resolveClaudePluginSkillSources, diff --git a/src/main/skills/discovery-wsl-stopped-distro.test.ts b/src/main/skills/discovery-wsl-stopped-distro.test.ts index d6ed889c12e..ee12ec5e9a2 100644 --- a/src/main/skills/discovery-wsl-stopped-distro.test.ts +++ b/src/main/skills/discovery-wsl-stopped-distro.test.ts @@ -4,7 +4,7 @@ import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type * as FsPromises from 'node:fs/promises' import type { Repo } from '../../shared/repo-types' -import type * as WslUncAccessGateModule from '../wsl/wsl-unc-access-gate' +import type * as WslUncAccessGateModule from '../wsl/filesystem/wsl-unc-access-gate' type GateState = 'stopped' | 'unverifiable' | 'running' @@ -31,7 +31,7 @@ vi.mock('node:fs/promises', async (importOriginal) => { open: record(actual.open) } }) -vi.mock('../wsl/wsl-unc-access-gate', async (importOriginal) => ({ +vi.mock('../wsl/filesystem/wsl-unc-access-gate', async (importOriginal) => ({ ...(await importOriginal()), // Off Windows no path maps to a distro; stand in for the WSL project's UNC root. wslDistroForPath: (path: string) => diff --git a/src/main/skills/discovery.ts b/src/main/skills/discovery.ts index 7f510cb40e6..e22110f1df2 100644 --- a/src/main/skills/discovery.ts +++ b/src/main/skills/discovery.ts @@ -28,7 +28,7 @@ import { unavailableSkillSource, type StoppedWslRootsReadScope } from './skill-discovery-stopped-wsl-roots' -import { wslDistroForPath } from '../wsl/wsl-unc-access-gate' +import { wslDistroForPath } from '../wsl/filesystem/wsl-unc-access-gate' import { buildRemoteRepoSkillSources } from './skill-remote-repo-sources' import { discoverClaudePluginSkillSources } from './claude-plugin-skill-sources' import { findSkillFiles } from './skill-root-file-walk' diff --git a/src/main/skills/skill-discovery-stopped-wsl-roots.ts b/src/main/skills/skill-discovery-stopped-wsl-roots.ts index fa7a25d13f1..b7f43760503 100644 --- a/src/main/skills/skill-discovery-stopped-wsl-roots.ts +++ b/src/main/skills/skill-discovery-stopped-wsl-roots.ts @@ -8,7 +8,7 @@ import { wslDistroForPath, WslDistroStoppedError, WslDistroUnverifiableError -} from '../wsl/wsl-unc-access-gate' +} from '../wsl/filesystem/wsl-unc-access-gate' import { stablePathId, type SkillScanRoot } from './skill-discovery-sources' const ALL_SOURCE_KINDS: readonly SkillSourceKind[] = ['home', 'repo', 'bundled', 'plugin'] diff --git a/src/main/skills/skill-discovery-target.ts b/src/main/skills/skill-discovery-target.ts index 5345607e631..7409f787bbb 100644 --- a/src/main/skills/skill-discovery-target.ts +++ b/src/main/skills/skill-discovery-target.ts @@ -4,7 +4,9 @@ import { } from './skill-discovery-wsl-observation' import type { Repo } from '../../shared/repo-types' import type { SkillDiscoveryResult, SkillDiscoveryTarget } from '../../shared/skills' -import { getDefaultWslDistro, getWslHomeAsync, parseWslPath, toLinuxPath } from '../wsl' +import { getDefaultWslDistro, getWslHomeAsync } from '../wsl/discovery/distro-catalog' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' +import { toLinuxPath } from '../../shared/wsl-paths' import { clearSkillRootScanCache, discoverSkills } from './discovery' import { discoverSkillObservationInWsl } from './skill-discovery-wsl' import type { SkillProviderRootOverrides } from './skill-provider-destinations' @@ -12,7 +14,7 @@ import { stablePathId } from './skill-discovery-sources' import { skillScanSourceKinds } from './skill-discovery-source-filter' import { getRepoExecutionHostId } from '../../shared/execution-host' import { isSkillRootUnavailableError, SkillScanCoalescer } from './skill-scan-coalescer' -import { assertWslUncPathRunning } from '../wsl/wsl-unc-access-gate' +import { assertWslUncPathRunning } from '../wsl/filesystem/wsl-unc-access-gate' import { stoppedWslRootsReadScopeKey, type StoppedWslRootsReadScope diff --git a/src/main/skills/skill-discovery-wsl-alias-sharing.test.ts b/src/main/skills/skill-discovery-wsl-alias-sharing.test.ts index 79a7b4e9b43..0278d85cb15 100644 --- a/src/main/skills/skill-discovery-wsl-alias-sharing.test.ts +++ b/src/main/skills/skill-discovery-wsl-alias-sharing.test.ts @@ -1,6 +1,6 @@ import { beforeEach, expect, it, vi } from 'vitest' const io = vi.hoisted(() => ({ run: vi.fn(), plugins: vi.fn(async () => []) })) -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess: io.run })) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: io.run })) vi.mock('./claude-plugin-skill-sources-wsl', () => ({ discoverClaudePluginSkillSourcesInWsl: io.plugins })) diff --git a/src/main/skills/skill-discovery-wsl-plugins.test.ts b/src/main/skills/skill-discovery-wsl-plugins.test.ts index 8f4d13cca66..3a02d283d35 100644 --- a/src/main/skills/skill-discovery-wsl-plugins.test.ts +++ b/src/main/skills/skill-discovery-wsl-plugins.test.ts @@ -1,10 +1,10 @@ -import type { WslResult } from '../wsl/wsl-runner' +import type { WslResult } from '../wsl/execution/wsl-runner' import { posix as pathPosix } from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' const runWslProcessMock = vi.hoisted(() => vi.fn()) -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) import { buildSkillDiscoverySources } from './skill-discovery-sources' import { rootMayContainSourceKind } from './skill-discovery-source-filter' diff --git a/src/main/skills/skill-discovery-wsl.ts b/src/main/skills/skill-discovery-wsl.ts index f7bf6f34583..ed9b3df4529 100644 --- a/src/main/skills/skill-discovery-wsl.ts +++ b/src/main/skills/skill-discovery-wsl.ts @@ -6,8 +6,8 @@ import { export { parseWslSkillDiscoveryOutput } from './skill-discovery-wsl-observation' import { posix as pathPosix } from 'node:path' import type { SkillDiscoveryResult, SkillSourceKind } from '../../shared/skills' -import { quoteBashString } from '../wsl-bash-command' -import { runWslProcess } from '../wsl/wsl-runner' +import { quotePosixShell as quoteBashString } from '../../shared/shell-argument-quoting' +import { runWslProcess } from '../wsl/execution/wsl-runner' import { buildSkillDiscoverySources, type SkillScanRoot } from './skill-discovery-sources' import { rootMayContainSourceKind } from './skill-discovery-source-filter' import { discoverClaudePluginSkillSourcesInWsl } from './claude-plugin-skill-sources-wsl' diff --git a/src/main/skills/skill-install-discovery-wsl.test.ts b/src/main/skills/skill-install-discovery-wsl.test.ts index f54a69b44dc..dfebf98de14 100644 --- a/src/main/skills/skill-install-discovery-wsl.test.ts +++ b/src/main/skills/skill-install-discovery-wsl.test.ts @@ -1,14 +1,14 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import type { SkillInstallResult } from '../../shared/skill-install-contract' import type { SkillDiscoveryResult } from '../../shared/skills' -import type { WslResult, WslSpec } from '../wsl/wsl-runner' +import type { WslResult, WslSpec } from '../wsl/execution/wsl-runner' import type { discoverSkills } from './discovery' const transport = vi.hoisted(() => ({ run: vi.fn<(spec: WslSpec) => Promise>(), native: vi.fn() })) -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess: transport.run })) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: transport.run })) vi.mock('./discovery', () => ({ discoverSkills: transport.native })) import { discoverSkillsInWsl } from './skill-discovery-wsl' diff --git a/src/main/skills/skill-provider-runtime-roots.ts b/src/main/skills/skill-provider-runtime-roots.ts index 4bf5c5f5226..0c0bae6d5d3 100644 --- a/src/main/skills/skill-provider-runtime-roots.ts +++ b/src/main/skills/skill-provider-runtime-roots.ts @@ -7,7 +7,7 @@ import { type DefaultHermesHomeInput, resolveDefaultHermesHome } from '../hermes/hermes-default-home' -import { runWslProcess } from '../wsl/wsl-runner' +import { runWslProcess } from '../wsl/execution/wsl-runner' import type { SkillProviderRootOverrides } from './skill-provider-destinations' const PROVIDER_ROOT_MAX_LENGTH = 32_768 diff --git a/src/main/skills/skill-wsl-delete.integration.test.ts b/src/main/skills/skill-wsl-delete.integration.test.ts index f0f4f5a5481..f92106fe84a 100644 --- a/src/main/skills/skill-wsl-delete.integration.test.ts +++ b/src/main/skills/skill-wsl-delete.integration.test.ts @@ -1,6 +1,6 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest' import { runProcess } from '@orca/process-host' -import { resolveWslExecutablePath } from '../wsl/wsl-executable-path' +import { resolveWslExecutablePath } from '../wsl/execution/wsl-executable-path' import { WslSkillInstallFilesystem } from './skill-wsl-install-filesystem' const DISTRO = process.env.ORCA_REAL_WSL_SKILL_DISTRO ?? 'Ubuntu-24.04' diff --git a/src/main/skills/skill-wsl-install-filesystem.test.ts b/src/main/skills/skill-wsl-install-filesystem.test.ts index 2b179501efe..97a4dccfbac 100644 --- a/src/main/skills/skill-wsl-install-filesystem.test.ts +++ b/src/main/skills/skill-wsl-install-filesystem.test.ts @@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' const { runWslProcessMock } = vi.hoisted(() => ({ runWslProcessMock: vi.fn() })) -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) import { WslSkillInstallFilesystem } from './skill-wsl-install-filesystem' diff --git a/src/main/skills/skill-wsl-install-filesystem.ts b/src/main/skills/skill-wsl-install-filesystem.ts index ee3939cd374..126c5968be6 100644 --- a/src/main/skills/skill-wsl-install-filesystem.ts +++ b/src/main/skills/skill-wsl-install-filesystem.ts @@ -20,7 +20,7 @@ import { } from './skill-delete/wsl-enumeration-protocol' import { SKILL_INSTALL_PROVIDERS } from '../../shared/skill-install-providers' import type { SkillProviderRootOverrides } from './skill-provider-destinations' -import { runWslProcess } from '../wsl/wsl-runner' +import { runWslProcess } from '../wsl/execution/wsl-runner' const BATCH_FILE_COUNT = 8 const GUEST_COMMAND_TIMEOUT_MS = 30_000 diff --git a/src/main/skills/skill-wsl-provider-detection.test.ts b/src/main/skills/skill-wsl-provider-detection.test.ts index 723d4d2cc6f..3f2fee1a681 100644 --- a/src/main/skills/skill-wsl-provider-detection.test.ts +++ b/src/main/skills/skill-wsl-provider-detection.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' const runWslProcessMock = vi.hoisted(() => vi.fn()) -vi.mock('../wsl/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) import { SKILL_INSTALL_PROVIDERS } from '../../shared/skill-install-providers' import { getTuiAgentDetectCommands, TUI_AGENT_CONFIG } from '../../shared/tui-agent-config' diff --git a/src/main/skills/skill-wsl-provider-detection.ts b/src/main/skills/skill-wsl-provider-detection.ts index 576abf88f32..d60b83e283b 100644 --- a/src/main/skills/skill-wsl-provider-detection.ts +++ b/src/main/skills/skill-wsl-provider-detection.ts @@ -5,7 +5,7 @@ import { resolveDetectedTuiAgentIds } from '../../shared/tui-agent-detection-commands' import { quotePosixShell } from '../../shared/shell-argument-quoting' -import { runWslProcess } from '../wsl/wsl-runner' +import { runWslProcess } from '../wsl/execution/wsl-runner' const PROVIDER_DETECTION_COMMANDS = KNOWN_TUI_AGENT_DETECTION_COMMANDS.filter((command) => isSkillInstallProviderId(command.id) diff --git a/src/main/ssh-expired-lease-pane-readoption.test.ts b/src/main/ssh/connection/ssh-expired-lease-pane-readoption.test.ts similarity index 87% rename from src/main/ssh-expired-lease-pane-readoption.test.ts rename to src/main/ssh/connection/ssh-expired-lease-pane-readoption.test.ts index 324d62acd6b..2e82188f0b0 100644 --- a/src/main/ssh-expired-lease-pane-readoption.test.ts +++ b/src/main/ssh/connection/ssh-expired-lease-pane-readoption.test.ts @@ -2,17 +2,17 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' import { rmSync, mkdtempSync } from 'node:fs' import { join } from 'node:path' import { tmpdir } from 'node:os' -import { makePaneKey } from '../shared/stable-pane-id' -import { resolvePersistedStablePaneOwner } from './ipc/pty/pane/stable-owner' -import { adoptStablePane } from './ipc/pty/pane/adopt-stable' -import { PtyHostNotDispatchableError } from './ipc/pty/provider/registry' +import { makePaneKey } from '../../../shared/stable-pane-id' +import { resolvePersistedStablePaneOwner } from '../../ipc/pty/pane/stable-owner' +import { adoptStablePane } from '../../ipc/pty/pane/adopt-stable' +import { PtyHostNotDispatchableError } from '../../ipc/pty/provider/registry' import { testState, createStoreWithSshRemotePtyLeases -} from './persistence/persistence-test-harness' -import { makeTerminalTab, TEST_LEAF_1 } from './persistence/persistence-session-fixtures' +} from '../../persistence/persistence-test-harness' +import { makeTerminalTab, TEST_LEAF_1 } from '../../persistence/persistence-session-fixtures' -import { PtyExitProof } from './pty/process-retirement/pty-exit-proof' +import { PtyExitProof } from '../../pty/process-retirement/pty-exit-proof' vi.mock('electron', () => ({ app: { getPath: () => testState.dir }, diff --git a/src/main/ssh-reattach-pane-cardinality.test.ts b/src/main/ssh/connection/ssh-reattach-pane-cardinality.test.ts similarity index 97% rename from src/main/ssh-reattach-pane-cardinality.test.ts rename to src/main/ssh/connection/ssh-reattach-pane-cardinality.test.ts index 9b88c371928..8423854f46f 100644 --- a/src/main/ssh-reattach-pane-cardinality.test.ts +++ b/src/main/ssh/connection/ssh-reattach-pane-cardinality.test.ts @@ -8,14 +8,14 @@ import { createStoreWithSshRemotePtyLeases, makeRepo, writeDataFile -} from './persistence/persistence-test-harness' +} from '../../persistence/persistence-test-harness' import { makeTerminalTab, TEST_LEAF_1, TEST_LEAF_2 -} from './persistence/persistence-session-fixtures' +} from '../../persistence/persistence-session-fixtures' -import { getDefaultPersistedState } from '../shared/constants' +import { getDefaultPersistedState } from '../../../shared/constants' vi.mock('electron', () => ({ app: { getPath: () => testState.dir }, diff --git a/src/main/startup/codex-launch-per-agent-hook-opt-out.test.ts b/src/main/startup/codex-launch-per-agent-hook-opt-out.test.ts index c14d628286c..22c5cc824c8 100644 --- a/src/main/startup/codex-launch-per-agent-hook-opt-out.test.ts +++ b/src/main/startup/codex-launch-per-agent-hook-opt-out.test.ts @@ -39,7 +39,7 @@ vi.mock( '../agent-hooks/managed-agent-hook-controls', async () => await import('../../shared/agent-status-hooks-setting') ) -vi.mock('../wsl', () => ({ getDefaultWslDistro: () => 'Ubuntu' })) +vi.mock('../wsl/discovery/distro-catalog', () => ({ getDefaultWslDistro: () => 'Ubuntu' })) vi.mock('../codex/codex-home-paths', () => ({ getSystemCodexHomePath: () => SYSTEM_HOME, getOrcaManagedCodexHomePath: () => '/managed/.codex' diff --git a/src/main/startup/main-process-quit.ts b/src/main/startup/main-process-quit.ts index 2d225172330..ecba79b70c0 100644 --- a/src/main/startup/main-process-quit.ts +++ b/src/main/startup/main-process-quit.ts @@ -1,4 +1,4 @@ -import { killWslChannelsInCloseGrace } from '../wsl/wsl-command-channel' +import { killWslChannelsInCloseGrace } from '../wsl/execution/wsl-command-channel' import { markHostShuttingDown } from './quit/host-shutdown-state' import { app, type Event } from 'electron' import { closeAllWatchers } from '../ipc/filesystem/watchers/filesystem-watcher-shutdown' diff --git a/src/main/startup/main-process-ready-foundation.ts b/src/main/startup/main-process-ready-foundation.ts index 046c8c4aa39..a1aa8ede6ff 100644 --- a/src/main/startup/main-process-ready-foundation.ts +++ b/src/main/startup/main-process-ready-foundation.ts @@ -15,7 +15,7 @@ import { getAppEnvironment } from '../../shared/app-environment' import { loadWslMoveFence } from '../persistence/moving-wsl-projects/wsl-move-scope-guard' import { startWslMoveStartup } from '../persistence/moving-wsl-projects/wsl-move-startup' import { startWslHostsPolicyLiveUpdates } from '../wsl/wsl-hosts-policy-live-update' -import { runPendingWslDriveUncConversions } from '../wsl/wsl-drive-unc-conversion-startup' +import { runPendingWslDriveUncConversions } from '../wsl/filesystem/wsl-drive-unc-conversion-startup' import { createProfileStateStoreForStartup } from '../persistence/profile-state/profile-state-startup-authority' import { getProfileUserDataPath } from '../orca-profiles/profile-storage-paths' import { initializeBrowserClientHostId } from '../browser/browser-client-host-id' diff --git a/src/main/startup/wsl-holder-uninstall-preflight.test.ts b/src/main/startup/wsl-holder-uninstall-preflight.test.ts index bd0bd329d75..cf9aa540406 100644 --- a/src/main/startup/wsl-holder-uninstall-preflight.test.ts +++ b/src/main/startup/wsl-holder-uninstall-preflight.test.ts @@ -11,13 +11,15 @@ vi.mock('electron', () => ({ app: { exit, getPath: () => 'C:\\Users\\u\\AppData\\Roaming\\orca' } })) vi.mock('./windows-app-data-path', () => ({ ensureWindowsAppDataPath: vi.fn() })) -vi.mock('../wsl/wsl-distro-holder', () => ({ createWslDistroHolder: () => ({ releaseAll }) })) +vi.mock('../wsl/discovery/wsl-distro-holder', () => ({ + createWslDistroHolder: () => ({ releaseAll }) +})) vi.mock('../wsl/wsl-host-uninstall-server-stop', () => ({ stopWslHostServersForUninstall: stopServers, wslHostUninstallStopDependencies: () => ({ distros: () => [], listRunning: async () => [] }) })) -import type { WslDistroHolder } from '../wsl/wsl-distro-holder' +import type { WslDistroHolder } from '../wsl/discovery/wsl-distro-holder-types' import type { WslHostUninstallStopDependencies } from '../wsl/wsl-host-uninstall-server-stop' import { releaseWslHoldersForUninstall, diff --git a/src/main/startup/wsl-holder-uninstall-preflight.ts b/src/main/startup/wsl-holder-uninstall-preflight.ts index fd1f0e65182..e4d5e794081 100644 --- a/src/main/startup/wsl-holder-uninstall-preflight.ts +++ b/src/main/startup/wsl-holder-uninstall-preflight.ts @@ -1,5 +1,6 @@ import { app } from 'electron' -import { createWslDistroHolder, type WslDistroHolder } from '../wsl/wsl-distro-holder' +import { createWslDistroHolder } from '../wsl/discovery/wsl-distro-holder' +import type { WslDistroHolder } from '../wsl/discovery/wsl-distro-holder-types' import { ensureWindowsAppDataPath } from './windows-app-data-path' import { stopWslHostServersForUninstall, diff --git a/src/main/telemetry/wsl-usage-reporter.ts b/src/main/telemetry/wsl-usage-reporter.ts index 57e9e42097a..148f4d5c215 100644 --- a/src/main/telemetry/wsl-usage-reporter.ts +++ b/src/main/telemetry/wsl-usage-reporter.ts @@ -7,13 +7,13 @@ import { getRepoExecutionHostId, parseExecutionHostId } from '../../shared/execu import { listEnvironments } from '../../shared/runtime-environment-store' import { isWslHostRuntimeEnvironment } from '../../shared/runtime-environments' import { resolveLocalWorkspaceRuntime } from '../workspaces/execution-host/local-project-runtime-resolution' -import { getCachedWslAvailability } from '../wsl-availability' -import { getCachedWslDistros } from '../wsl' -import { listConfirmedRunningWslDistros } from '../wsl-background-distro-gate' -import { filterUserWslDistros } from '../wsl-distro-list-output' -import { peekConfirmedRunningWslDistros } from '../wsl-running-distro-cache' +import { getCachedWslAvailability } from '../wsl/discovery/wsl-availability' +import { getCachedWslDistros } from '../wsl/discovery/distro-catalog' +import { listConfirmedRunningWslDistros } from '../wsl/discovery/wsl-background-distro-gate' +import { filterUserWslDistros } from '../wsl/discovery/wsl-distro-list-output' +import { peekConfirmedRunningWslDistros } from '../wsl/discovery/wsl-running-distro-cache' import { loadWindowsNativeRegistry, WINDOWS_REG_SZ } from '../windows/windows-native-registry' -import { readWslDistroRegistrations } from '../wsl/wsl-distro-registry-id' +import { readWslDistroRegistrations } from '../wsl/discovery/wsl-distro-registry-id' import { listWslHostDistros } from '../wsl/wsl-host-distro-list' import { wslHostsAppliedMovedProjects, diff --git a/src/main/text-generation/source-control-wsl-launch.test.ts b/src/main/text-generation/source-control-wsl-launch.test.ts index a7672edda41..bc63b8e1786 100644 --- a/src/main/text-generation/source-control-wsl-launch.test.ts +++ b/src/main/text-generation/source-control-wsl-launch.test.ts @@ -24,7 +24,7 @@ vi.mock('node:child_process', async (original) => { spawnMock.mockImplementation(actual.spawn) return { ...actual, spawn: spawnMock } }) -vi.mock('../wsl-background-distro-gate', () => ({ noteWslDistroLaunched: vi.fn() })) +vi.mock('../wsl/discovery/wsl-background-distro-gate', () => ({ noteWslDistroLaunched: vi.fn() })) const nativeSpawn = (await vi.importActual('node:child_process')).spawn afterEach(() => { spawnMock.mockReset().mockImplementation(nativeSpawn) diff --git a/src/main/text-generation/source-control-wsl-prompt.test.ts b/src/main/text-generation/source-control-wsl-prompt.test.ts index d1f81ba8952..7a614c92c03 100644 --- a/src/main/text-generation/source-control-wsl-prompt.test.ts +++ b/src/main/text-generation/source-control-wsl-prompt.test.ts @@ -28,7 +28,7 @@ vi.mock('../../shared/windows-transient-lock-removal', async (original) => ({ vi.mock('../pty/process-retirement/windows-process-tree-kill', () => ({ terminateWindowsProcessTree: vi.fn(async () => true) })) -vi.mock('../wsl-background-distro-gate', () => ({ noteWslDistroLaunched: vi.fn() })) +vi.mock('../wsl/discovery/wsl-background-distro-gate', () => ({ noteWslDistroLaunched: vi.fn() })) afterEach(() => { vi.useRealTimers() diff --git a/src/main/workspace-hooks/hook-runtime-target.ts b/src/main/workspace-hooks/hook-runtime-target.ts index ec270ab9739..ed02e0adb44 100644 --- a/src/main/workspace-hooks/hook-runtime-target.ts +++ b/src/main/workspace-hooks/hook-runtime-target.ts @@ -1,4 +1,4 @@ -import { parseWslPath } from '../wsl' +import { parseWslPath } from '../wsl/filesystem/unc-path-access' import { toLinuxPath } from '../../shared/wsl-paths' import type { ProjectExecutionRuntimeResolution } from '../../shared/project-execution-runtime' diff --git a/src/main/workspace-hooks/hooks.test.ts b/src/main/workspace-hooks/hooks.test.ts index 53bf554341d..95640f007c8 100644 --- a/src/main/workspace-hooks/hooks.test.ts +++ b/src/main/workspace-hooks/hooks.test.ts @@ -23,7 +23,7 @@ vi.mock('child_process', () => ({ execFileSync: vi.fn() })) -vi.mock('../wsl/wsl-runner', () => ({ +vi.mock('../wsl/execution/wsl-runner', () => ({ runWslProcess: runWslProcessMock })) diff --git a/src/main/workspace-hooks/hooks.ts b/src/main/workspace-hooks/hooks.ts index 1c0c140ebb4..fb451bf5c4f 100644 --- a/src/main/workspace-hooks/hooks.ts +++ b/src/main/workspace-hooks/hooks.ts @@ -9,8 +9,8 @@ import { iterateLfScriptLines } from './setup-runner-script-text' import { promptGuardShellEnv } from '../git/command-runner/git-process-env' import { dropIncoherentCondaActivationEnv } from '../pty/shell-startup/conda-activation-env' import { toLinuxPath } from '../../shared/wsl-paths' -import { runWslProcess } from '../wsl/wsl-runner' -import { windowsFsPath } from '../wsl/wsl-unc-drive-fs-path' +import { runWslProcess } from '../wsl/execution/wsl-runner' +import { windowsFsPath } from '../wsl/filesystem/wsl-unc-drive-fs-path' import type { HookRuntimeTarget } from './hook-runtime-target' import type { OrcaHooks } from '../../shared/orca-yaml-hook-types' import type { Repo } from '../../shared/repo-types' diff --git a/src/main/workspace-hooks/issue-command-file.ts b/src/main/workspace-hooks/issue-command-file.ts index aa4ade31f28..224e2e18e7f 100644 --- a/src/main/workspace-hooks/issue-command-file.ts +++ b/src/main/workspace-hooks/issue-command-file.ts @@ -8,7 +8,7 @@ import { guardWslUncPathAccess, WslDistroStoppedError, WslDistroUnverifiableError -} from '../wsl/wsl-unc-access-gate' +} from '../wsl/filesystem/wsl-unc-access-gate' type IssueCommandGitOptions = GitRuntimeOptions | (() => GitRuntimeOptions) diff --git a/src/main/workspace-hooks/issue-command-wsl-stopped-distro.test.ts b/src/main/workspace-hooks/issue-command-wsl-stopped-distro.test.ts index 8e48573518b..f4b67c768c4 100644 --- a/src/main/workspace-hooks/issue-command-wsl-stopped-distro.test.ts +++ b/src/main/workspace-hooks/issue-command-wsl-stopped-distro.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as BackgroundDistroGate from '../wsl-background-distro-gate' +import type * as BackgroundDistroGate from '../wsl/discovery/wsl-background-distro-gate' import type * as NodeFs from 'node:fs' const mocks = vi.hoisted(() => ({ @@ -12,7 +12,7 @@ const mocks = vi.hoisted(() => ({ loadHooks: vi.fn((_path: string) => null) })) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: mocks.readWslDistroRunningState })) diff --git a/src/main/workspace-hooks/worktree-runner-script.ts b/src/main/workspace-hooks/worktree-runner-script.ts index 26c98aa4e5b..59c77929026 100644 --- a/src/main/workspace-hooks/worktree-runner-script.ts +++ b/src/main/workspace-hooks/worktree-runner-script.ts @@ -9,8 +9,8 @@ import { gitExecFileSync } from '../git/command-runner/git-exec-file-sync' import { isLocalGitRuntimeRouterInstalled } from '../git/command-runner/local-git-runtime-route' import { readWorktreeGitPath } from '../git/worktree-git-path' import { resolveWslWorktreeGitPath } from '../git/wsl-worktree-git-path' -import { knownWslAutomountRoots } from '../wsl/wsl-automount-root' -import { isWslPath } from '../wsl' +import { knownWslAutomountRoots } from '../wsl/filesystem/wsl-automount-root' +import { isWslPath } from '../wsl/filesystem/unc-path-access' import { toWindowsWslPath, toLinuxPath } from '../../shared/wsl-paths' import { getHookRuntimeTarget, getHookWslContext } from './hook-runtime-target' import { SETUP_RUNNER_PATH_ENV_KEYS, getSetupRunnerEnvVars } from './setup-hook-env-vars' diff --git a/src/main/workspaces/catalog/repo-git-enrichment-wsl-stopped-distro.test.ts b/src/main/workspaces/catalog/repo-git-enrichment-wsl-stopped-distro.test.ts index a7eadc0781c..a689502721a 100644 --- a/src/main/workspaces/catalog/repo-git-enrichment-wsl-stopped-distro.test.ts +++ b/src/main/workspaces/catalog/repo-git-enrichment-wsl-stopped-distro.test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import type { Repo } from '../../../shared/repo-types' -import type * as WslUncAccessGateModule from '../../wsl/wsl-unc-access-gate' +import type * as WslUncAccessGateModule from '../../wsl/filesystem/wsl-unc-access-gate' const mocks = vi.hoisted(() => ({ stopped: true, @@ -15,7 +15,7 @@ vi.mock('./repo-git-remote-identity', () => ({ vi.mock('../../git/git-username', () => ({ resolveLocalGitUsernameDetailed: mocks.resolveLocalGitUsernameDetailed })) -vi.mock('../../wsl/wsl-unc-access-gate', async (importOriginal) => ({ +vi.mock('../../wsl/filesystem/wsl-unc-access-gate', async (importOriginal) => ({ ...(await importOriginal()), blockedWslDistroForPath: mocks.blockedWslDistroForPath, wslDistroForPath: mocks.wslDistroForPath diff --git a/src/main/workspaces/catalog/repo-git-remote-identity-enrichment.test.ts b/src/main/workspaces/catalog/repo-git-remote-identity-enrichment.test.ts index 678ecb1830e..eb5bda13961 100644 --- a/src/main/workspaces/catalog/repo-git-remote-identity-enrichment.test.ts +++ b/src/main/workspaces/catalog/repo-git-remote-identity-enrichment.test.ts @@ -6,8 +6,8 @@ import type { RepoHostTarget } from '../../../shared/repo-host-identity' import { repoTarget } from '../../persistence/repo-host-target-matcher.test-fixture' import { type GitRemoteIdentityProbe, probeGitRemoteIdentity } from './repo-git-remote-identity' import { WSL_HOSTS_INTERNAL_GATE_ENV } from '../../../shared/wsl-host-internal-gate' -import type * as DistroGate from '../../wsl-background-distro-gate' -import type { WslDistroRunningState } from '../../wsl-background-distro-gate' +import type * as DistroGate from '../../wsl/discovery/wsl-background-distro-gate' +import type { WslDistroRunningState } from '../../wsl/discovery/wsl-background-distro-gate' import { setLocalGitRuntimeRouter } from '../../git/command-runner/local-git-runtime-route' import { enrichMissingRepoGitRemoteIdentities, @@ -19,7 +19,7 @@ vi.mock('./repo-git-remote-identity', () => ({ probeGitRemoteIdentity: vi.fn() })) const distroGate = vi.hoisted((): { state: WslDistroRunningState } => ({ state: 'running' })) -vi.mock('../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: async () => distroGate.state })) diff --git a/src/main/workspaces/catalog/repo-git-remote-identity-enrichment.ts b/src/main/workspaces/catalog/repo-git-remote-identity-enrichment.ts index 91fcccd6179..684d98f4be6 100644 --- a/src/main/workspaces/catalog/repo-git-remote-identity-enrichment.ts +++ b/src/main/workspaces/catalog/repo-git-remote-identity-enrichment.ts @@ -15,7 +15,7 @@ import { getProjectRuntimeReadGitOptions } from '../execution-host/project-runti import { isLocalGitRuntimeRouterInstalled } from '../../git/command-runner/local-git-runtime-route' import type { ProjectRuntimeResolutionStore } from '../execution-host/local-project-runtime-resolution' import { isWslMoveRepoBlocked } from '../../persistence/moving-wsl-projects/wsl-move-background-backoff' -import { blockedWslDistroForPath, wslDistroForPath } from '../../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath, wslDistroForPath } from '../../wsl/filesystem/wsl-unc-access-gate' const NO_IDENTITY_RETRY_TTL_MS = 5 * 60 * 1000 // Refresh renamed/transferred projects without probing on every list call. diff --git a/src/main/workspaces/catalog/repo-git-username-enrichment-wsl-act.test.ts b/src/main/workspaces/catalog/repo-git-username-enrichment-wsl-act.test.ts index 5b3d2b700d9..5291a8e52d4 100644 --- a/src/main/workspaces/catalog/repo-git-username-enrichment-wsl-act.test.ts +++ b/src/main/workspaces/catalog/repo-git-username-enrichment-wsl-act.test.ts @@ -9,7 +9,7 @@ const mocks = vi.hoisted(() => ({ vi.mock('../../git/git-username', () => ({ resolveLocalGitUsernameDetailed: mocks.resolveLocalGitUsernameDetailed })) -vi.mock('../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: mocks.readWslDistroRunningState })) @@ -19,8 +19,8 @@ const { flushRepoGitUsernameEnrichmentForTests, resetRepoGitUsernameEnrichmentForTests } = await import('./repo-git-username-enrichment') -const { blockedWslDistroForPath } = await import('../../wsl/wsl-unc-access-gate') -const { runAsWslUserAct } = await import('../../wsl/wsl-user-act-scope') +const { blockedWslDistroForPath } = await import('../../wsl/filesystem/wsl-unc-access-gate') +const { runAsWslUserAct } = await import('../../wsl/discovery/wsl-user-act-scope') const repo: Repo = { id: 'r1', diff --git a/src/main/workspaces/catalog/repo-git-username-enrichment.ts b/src/main/workspaces/catalog/repo-git-username-enrichment.ts index 1d5be44238b..dbcf6063356 100644 --- a/src/main/workspaces/catalog/repo-git-username-enrichment.ts +++ b/src/main/workspaces/catalog/repo-git-username-enrichment.ts @@ -1,8 +1,8 @@ import { getRepoExecutionHostId } from '../../../shared/execution-host' import type { Repo } from '../../../shared/repo-types' import { resolveLocalGitUsernameDetailed } from '../../git/git-username' -import { blockedWslDistroForPath, wslDistroForPath } from '../../wsl/wsl-unc-access-gate' -import { outsideWslUserAct } from '../../wsl/wsl-user-act-scope' +import { blockedWslDistroForPath, wslDistroForPath } from '../../wsl/filesystem/wsl-unc-access-gate' +import { outsideWslUserAct } from '../../wsl/discovery/wsl-user-act-scope' type RepoUsernameStore = { getRepos(): Repo[] diff --git a/src/main/workspaces/creation/preparation/worktree-create-preparation-wsl-root.test.ts b/src/main/workspaces/creation/preparation/worktree-create-preparation-wsl-root.test.ts index 8fdf94ca66f..362703ac379 100644 --- a/src/main/workspaces/creation/preparation/worktree-create-preparation-wsl-root.test.ts +++ b/src/main/workspaces/creation/preparation/worktree-create-preparation-wsl-root.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as WslModule from '../../../wsl' +import type * as WslModule from '../../../wsl/discovery/distro-catalog' import type { Store } from '../../../persistence/loading-store/store' import type { Repo } from '../../../../shared/repo-types' @@ -37,7 +37,7 @@ vi.mock('../../execution-host/project-runtime-git-options', () => ({ getLocalProjectWorktreeGitOptions: mocks.getWorktreeOptions, getWorktreeMirrorDistro: mocks.getMirrorDistro })) -vi.mock('../../../wsl', async (importOriginal) => ({ +vi.mock('../../../wsl/discovery/distro-catalog', async (importOriginal) => ({ ...(await importOriginal()), getWslHome: mocks.getWslHome, getWslHomeAsync: mocks.getWslHomeAsync diff --git a/src/main/workspaces/creation/worktree-root-preparation.test.ts b/src/main/workspaces/creation/worktree-root-preparation.test.ts index 962a205440d..4e947eb0253 100644 --- a/src/main/workspaces/creation/worktree-root-preparation.test.ts +++ b/src/main/workspaces/creation/worktree-root-preparation.test.ts @@ -1,5 +1,5 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' -import type * as WslModule from '../../wsl' +import type * as WslModule from '../../wsl/discovery/distro-catalog' import type { Repo } from '../../../shared/repo-types' const { mkdirMock, getWslHomeMock, getWslHomeAsyncMock, runningStateMock } = vi.hoisted(() => ({ @@ -13,13 +13,13 @@ vi.mock('fs/promises', () => ({ mkdir: mkdirMock })) -vi.mock('../../wsl', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/distro-catalog', async (importOriginal) => ({ ...(await importOriginal()), getWslHome: getWslHomeMock, getWslHomeAsync: getWslHomeAsyncMock })) -vi.mock('../../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal>()), readWslDistroRunningState: runningStateMock })) diff --git a/src/main/workspaces/creation/worktree-root-preparation.ts b/src/main/workspaces/creation/worktree-root-preparation.ts index 70269601469..325b6d2a8bf 100644 --- a/src/main/workspaces/creation/worktree-root-preparation.ts +++ b/src/main/workspaces/creation/worktree-root-preparation.ts @@ -6,7 +6,7 @@ import { isFolderRepo } from '../../../shared/repo-kind' import { computeWorkspaceRootAsync, getWorktreePathSettings } from '../../ipc/worktree-logic' import { getWorktreeMirrorDistro } from '../execution-host/project-runtime-git-options' import type { ProjectRuntimeResolutionStore } from '../execution-host/local-project-runtime-resolution' -import { blockedWslDistroForPath } from '../../wsl/wsl-unc-access-gate' +import { blockedWslDistroForPath } from '../../wsl/filesystem/wsl-unc-access-gate' // Match create's mirror-distro resolution so root preparation cannot target a different directory. type WorktreeRootPreparationSettings = Pick & diff --git a/src/main/workspaces/execution-host/local-project-runtime-resolution.ts b/src/main/workspaces/execution-host/local-project-runtime-resolution.ts index db330423d5f..ea5b2ea4eaa 100644 --- a/src/main/workspaces/execution-host/local-project-runtime-resolution.ts +++ b/src/main/workspaces/execution-host/local-project-runtime-resolution.ts @@ -15,8 +15,11 @@ import { resolveProjectExecutionRuntime, type ProjectExecutionRuntimeResolution } from '../../../shared/project-execution-runtime' -import { getCachedWslAvailability, hasCachedWslAvailability } from '../../wsl-availability' -import { getCachedWslDistros, hasCachedWslDistros } from '../../wsl' +import { + getCachedWslAvailability, + hasCachedWslAvailability +} from '../../wsl/discovery/wsl-availability' +import { getCachedWslDistros, hasCachedWslDistros } from '../../wsl/discovery/distro-catalog' import { getRepoIdFromWorktreeId } from '../../../shared/worktree/id' import { projectMatchesRepo } from '../../../shared/project-repo-match' import type { LocalWindowsTerminalRuntimeOptions } from '../../../shared/local-windows-terminal-runtime' diff --git a/src/main/workspaces/execution-host/project-runtime-git-options.test.ts b/src/main/workspaces/execution-host/project-runtime-git-options.test.ts index 70b144f818c..23a18a7c113 100644 --- a/src/main/workspaces/execution-host/project-runtime-git-options.test.ts +++ b/src/main/workspaces/execution-host/project-runtime-git-options.test.ts @@ -8,7 +8,7 @@ import { getWorktreeMirrorDistro } from './project-runtime-git-options' import { resolveLocalProjectRuntimeForRepo } from './local-project-runtime-resolution' -import { _resetWslCachesForTests, _setWslCachesForTests } from '../../wsl' +import { _resetWslCachesForTests, _setWslCachesForTests } from '../../wsl/discovery/distro-catalog' function withPlatform(platform: NodeJS.Platform, run: () => T): T { const originalPlatform = process.platform diff --git a/src/main/workspaces/execution-host/project-runtime-git-router.ts b/src/main/workspaces/execution-host/project-runtime-git-router.ts index 0bfab4ab126..f7cc6432324 100644 --- a/src/main/workspaces/execution-host/project-runtime-git-router.ts +++ b/src/main/workspaces/execution-host/project-runtime-git-router.ts @@ -21,7 +21,7 @@ import { setLocalGitRuntimeRouter, type LocalGitRuntimeRouter } from '../../git/command-runner/local-git-runtime-route' -import { isWslDistroRunningForBackgroundWork } from '../../wsl-background-distro-gate' +import { isWslDistroRunningForBackgroundWork } from '../../wsl/discovery/wsl-background-distro-gate' import { onWslHostsNewWorkChanged, wslHostsGateOpen, @@ -32,7 +32,7 @@ import { knownWslAutomountRoots, onWslAutomountRootsChanged, wslDrivePathUnderRoots -} from '../../wsl/wsl-automount-root' +} from '../../wsl/filesystem/wsl-automount-root' export type ProjectRuntimeGitRouterStore = { getRepos: () => Repo[] diff --git a/src/main/workspaces/execution-host/project-runtime-read-git-options-opt-in.test.ts b/src/main/workspaces/execution-host/project-runtime-read-git-options-opt-in.test.ts index 9ce3074bff2..3cbfb7d2998 100644 --- a/src/main/workspaces/execution-host/project-runtime-read-git-options-opt-in.test.ts +++ b/src/main/workspaces/execution-host/project-runtime-read-git-options-opt-in.test.ts @@ -4,7 +4,7 @@ import type { Project } from '../../../shared/project-types' import type { Repo } from '../../../shared/repo-types' import { WSL_HOSTS_INTERNAL_GATE_ENV } from '../../../shared/wsl-host-internal-gate' import { getProjectRuntimeReadGitOptions } from './project-runtime-git-options' -import { _resetWslCachesForTests, _setWslCachesForTests } from '../../wsl' +import { _resetWslCachesForTests, _setWslCachesForTests } from '../../wsl/discovery/distro-catalog' const repo: Repo = { id: 'repo-1', diff --git a/src/main/workspaces/removal/local-worktree-filesystem.ts b/src/main/workspaces/removal/local-worktree-filesystem.ts index cc8f1ad7517..2d7432a9f4c 100644 --- a/src/main/workspaces/removal/local-worktree-filesystem.ts +++ b/src/main/workspaces/removal/local-worktree-filesystem.ts @@ -5,8 +5,8 @@ import { buildWslExecArgs } from '../../../shared/wsl-login-shell-command' import { quotePosixShell } from '../../../shared/shell-argument-quoting' import { removeHostTree } from '../../filesystem/host-tree-removal' import { toLinuxPath } from '../../../shared/wsl-paths' -import { resolveWslInteropSpawnCwd } from '../../wsl-interop-spawn-directory' -import { describeWslProcessFailure } from '../../wsl/wsl-process-failure' +import { resolveWslInteropSpawnCwd } from '../../wsl/execution/wsl-interop-spawn-directory' +import { describeWslProcessFailure } from '../../wsl/execution/wsl-process-failure' import type { WorktreeProofAccess } from './worktree-orphan-gitdir-proof' export type LocalWorktreeFilesystemOptions = { diff --git a/src/main/workspaces/removal/retirement/worktree-name-retirement.ts b/src/main/workspaces/removal/retirement/worktree-name-retirement.ts index 4231d4f57a3..beb3adcec2b 100644 --- a/src/main/workspaces/removal/retirement/worktree-name-retirement.ts +++ b/src/main/workspaces/removal/retirement/worktree-name-retirement.ts @@ -29,8 +29,8 @@ import { } from './worktree-retirement-namespace' import { discoverRetiredWorktreeNames } from './worktree-retirement-discovery' import { runRetirementBackfillScan } from './worktree-retirement-backfill-scan' -import { hasCachedWslHome } from '../../../wsl-home-cache' -import { parseWslPath } from '../../../wsl' +import { hasCachedWslHome } from '../../../wsl/discovery/wsl-home-cache' +import { parseWslPath } from '../../../wsl/filesystem/unc-path-access' import { getWorktreeMirrorDistro } from '../../execution-host/project-runtime-git-options' import type { ProjectRuntimeResolutionStore } from '../../execution-host/local-project-runtime-resolution' diff --git a/src/main/workspaces/removal/retirement/worktree-retirement-discovery-wsl.test.ts b/src/main/workspaces/removal/retirement/worktree-retirement-discovery-wsl.test.ts index 45e4403f949..f273f88949a 100644 --- a/src/main/workspaces/removal/retirement/worktree-retirement-discovery-wsl.test.ts +++ b/src/main/workspaces/removal/retirement/worktree-retirement-discovery-wsl.test.ts @@ -16,7 +16,7 @@ vi.mock('../../../native-chat/wsl-transcript-fs-gate', async (importOriginal) => })) // Keep parseWslPath and hasCachedWslHome real for the backfill path under test. -vi.mock('../../../wsl', async (importOriginal) => ({ +vi.mock('../../../wsl/discovery/distro-catalog', async (importOriginal) => ({ ...((await importOriginal()) as Record), getWslHomeAsync: getWslHomeAsyncMock })) diff --git a/src/main/workspaces/removal/retirement/worktree-retirement-discovery.ts b/src/main/workspaces/removal/retirement/worktree-retirement-discovery.ts index 77b0ad28278..a24b8b9d808 100644 --- a/src/main/workspaces/removal/retirement/worktree-retirement-discovery.ts +++ b/src/main/workspaces/removal/retirement/worktree-retirement-discovery.ts @@ -9,7 +9,7 @@ import { import { wslGatedReaddir, wslGatedStat } from '../../../native-chat/wsl-transcript-fs-access' import type { RetirementScanResult } from './worktree-retirement-backfill-scan' import { normalizeRetirableGeneratedName } from './worktree-name-retirement' -import { getWslHomeAsync } from '../../../wsl' +import { getWslHomeAsync } from '../../../wsl/discovery/distro-catalog' /** Prefer spending an extra name to reissuing a path whose agent history survives. */ export function collectRetiredNamesFromLeafNames(leafNames: Iterable): Set { diff --git a/src/main/workspaces/removal/worktree-background-removal.ts b/src/main/workspaces/removal/worktree-background-removal.ts index 5abc5a064ff..d7b65befb94 100644 --- a/src/main/workspaces/removal/worktree-background-removal.ts +++ b/src/main/workspaces/removal/worktree-background-removal.ts @@ -4,7 +4,7 @@ import type { GitWorktreeInfo } from '../../../shared/worktree/types' import { normalizeLocalBranchRef } from '../../git/worktree-operation-options' import { acquireWatcherRemovalGate, type WatcherRemovalGate } from '../../ipc/watcher-removal-gate' import { runWorktreeChangeInvalidators } from '../../ipc/worktree-change-invalidators' -import { parseWslPath } from '../../wsl' +import { parseWslPath } from '../../wsl/filesystem/unc-path-access' import { readWorktreeRemovalRecords, type WorktreeRemovalRecord } from './worktree-removal-records' import { failureLeftByGit } from './worktree-removal-failure' import { differentCheckoutAtPathError, isCheckoutRegistered } from './worktree-removal-leftover' diff --git a/src/main/workspaces/removal/worktree-trash.ts b/src/main/workspaces/removal/worktree-trash.ts index 120727685d8..88b9185bf69 100644 --- a/src/main/workspaces/removal/worktree-trash.ts +++ b/src/main/workspaces/removal/worktree-trash.ts @@ -7,7 +7,7 @@ import { isFolderRepo } from '../../../shared/repo-kind' import { computeWorkspaceRoot, getWorktreePathSettings } from '../../ipc/worktree-logic' import type { GlobalSettings } from '../../../shared/global-settings-types' import type { Repo } from '../../../shared/repo-types' -import { parseWslPath } from '../../wsl' +import { parseWslPath } from '../../wsl/filesystem/unc-path-access' import { getRepoRoutingConnectionId } from '../../../shared/execution-host' export const WORKTREE_TRASH_DIR_NAME = '.orca-worktree-trash' diff --git a/src/main/wsl-approved-root-race.wsl.test.ts b/src/main/wsl-approved-root-race.wsl.test.ts index 07d0e722752..c42b3a7d405 100644 --- a/src/main/wsl-approved-root-race.wsl.test.ts +++ b/src/main/wsl-approved-root-race.wsl.test.ts @@ -1,8 +1,8 @@ import { execFile } from 'node:child_process' import { promisify } from 'node:util' import { afterAll, beforeAll, describe, expect, it } from 'vitest' -import { containedDeleteCommand } from './wsl-contained-delete' -import { parseWslPath } from './wsl' +import { containedDeleteCommand } from './wsl/filesystem/wsl-contained-delete' +import { parseWslPath } from './wsl/filesystem/unc-path-access' const execFileAsync = promisify(execFile) const DISTRO = process.env.ORCA_WSL_TEST_DISTRO ?? 'Ubuntu-24.04' diff --git a/src/main/wsl-env.ts b/src/main/wsl-env.ts deleted file mode 100644 index c77d15ebf17..00000000000 --- a/src/main/wsl-env.ts +++ /dev/null @@ -1 +0,0 @@ -export { addWslEnvKeys } from '../shared/wsl-env' diff --git a/src/main/wsl.test.ts b/src/main/wsl/discovery/distro-catalog.test.ts similarity index 87% rename from src/main/wsl.test.ts rename to src/main/wsl/discovery/distro-catalog.test.ts index 7220739e6c1..1087aa799fa 100644 --- a/src/main/wsl.test.ts +++ b/src/main/wsl/discovery/distro-catalog.test.ts @@ -1,6 +1,21 @@ import { afterEach, describe, expect, it, vi } from 'vitest' import type { ProcessResult } from '@orca/process-host/process-spec' import { assertWslDistroAllowed } from '@orca/process-host/wsl-distro-allowlist' +import { + _resetWslCachesForTests, + _setWslCachesForTests, + getCachedWslDistros, + getWslHome, + getWslHomeAsync, + hasCachedWslDistros, + listWslDistros, + listWslDistrosAsync +} from './distro-catalog' +import { + getCachedWslAvailability, + hasCachedWslAvailability, + isWslAvailableAsync +} from './wsl-availability' const { runProcessMock, runProcessSyncMock } = vi.hoisted(() => ({ runProcessMock: vi.fn(), @@ -11,9 +26,11 @@ vi.mock('@orca/process-host', () => ({ runProcess: runProcessMock, runProcessSync: runProcessSyncMock })) -vi.mock('./wsl-interop-spawn-directory', () => ({ + +vi.mock('../execution/wsl-interop-spawn-directory', () => ({ resolveWslInteropSpawnCwd: () => 'C:\\Windows' })) + // These cases model hosts with no registered distro; the lost-output fallback has its own suite. vi.mock('./wsl-registered-distro-fallback', () => ({ listedOrRegisteredWslDistros: async (listed: string[]) => listed, @@ -39,24 +56,6 @@ function spawnError(code: string): Error { return Object.assign(new Error(`spawn wsl.exe ${code}`), { code }) } -import { - _resetWslCachesForTests, - _setWslCachesForTests, - getCachedWslAvailability, - getCachedWslDistros, - getWslHome, - getWslHomeAsync, - hasCachedWslAvailability, - hasCachedWslDistros, - isWslAvailableAsync, - listWslDistros, - listWslDistrosAsync, - parseWslPath, - toLinuxPath, - toWindowsWslPath, - wslUncDirectoryExistsAsync -} from './wsl' - function withPlatform(value: NodeJS.Platform, fn: () => T): T { const original = process.platform Object.defineProperty(process, 'platform', { configurable: true, value }) @@ -588,94 +587,3 @@ describe('WSL availability cache', () => { }) }) }) - -describe('wsl path helpers', () => { - it('parses WSL UNC paths on Windows', () => { - const originalPlatform = process.platform - Object.defineProperty(process, 'platform', { - configurable: true, - value: 'win32' - }) - - try { - expect(parseWslPath('\\\\wsl.localhost\\Ubuntu\\home\\jin\\repo')).toEqual({ - distro: 'Ubuntu', - linuxPath: '/home/jin/repo' - }) - } finally { - Object.defineProperty(process, 'platform', { - configurable: true, - value: originalPlatform - }) - } - }) - - it('converts Windows drive paths to /mnt paths for WSL commands', () => { - expect(toLinuxPath('C:\\Users\\jinwo\\git\\orca')).toBe('/mnt/c/Users/jinwo/git/orca') - }) - - it('converts /mnt drive paths back to native Windows form', () => { - expect(toWindowsWslPath('/mnt/c/Users/jinwo/git/orca', 'Ubuntu')).toBe( - 'C:\\Users\\jinwo\\git\\orca' - ) - }) -}) - -describe('wslUncDirectoryExistsAsync', () => { - afterEach(() => { - runProcessMock.mockReset() - }) - - it('returns true when the distro reports the directory exists', async () => { - runProcessMock.mockResolvedValue(exited('__ORCA_DIRECTORY_EXISTS__')) - - await expect( - withPlatformAsync('win32', () => - wslUncDirectoryExistsAsync('\\\\wsl.localhost\\Ubuntu\\home\\jin\\repo') - ) - ).resolves.toBe(true) - expect(runProcessMock).toHaveBeenCalledWith( - expect.objectContaining({ - program: 'wsl.exe', - timeoutMs: 5000, - args: [ - '-d', - 'Ubuntu', - '--exec', - 'sh', - '-c', - expect.stringContaining('__ORCA_DIRECTORY_EXISTS__'), - 'sh', - '/home/jin/repo' - ] - }) - ) - }) - - it('distinguishes a missing directory from an inconclusive probe', async () => { - runProcessMock - .mockResolvedValueOnce(exited('__ORCA_DIRECTORY_MISSING__')) - .mockResolvedValueOnce(exited('', 4294967295)) - - await withPlatformAsync('win32', async () => { - await expect( - wslUncDirectoryExistsAsync('\\\\wsl.localhost\\Ubuntu\\home\\jin\\missing') - ).resolves.toBe(false) - await expect( - wslUncDirectoryExistsAsync('\\\\wsl.localhost\\Ubuntu\\home\\jin\\repo') - ).resolves.toBeNull() - }) - }) - - it('returns null without spawning for paths outside WSL or off Windows', async () => { - await expect( - withPlatformAsync('win32', () => wslUncDirectoryExistsAsync('C:\\Users\\jin\\repo')) - ).resolves.toBeNull() - await expect( - withPlatformAsync('linux', () => - wslUncDirectoryExistsAsync('\\\\wsl.localhost\\Ubuntu\\home\\jin') - ) - ).resolves.toBeNull() - expect(runProcessMock).not.toHaveBeenCalled() - }) -}) diff --git a/src/main/wsl.ts b/src/main/wsl/discovery/distro-catalog.ts similarity index 80% rename from src/main/wsl.ts rename to src/main/wsl/discovery/distro-catalog.ts index c55e125a9ab..29b97a676f4 100644 --- a/src/main/wsl.ts +++ b/src/main/wsl/discovery/distro-catalog.ts @@ -1,6 +1,6 @@ -import { runProcess, runProcessSync } from '@orca/process-host' -import { buildWslExecArgs } from '../shared/wsl-login-shell-command' -import { parseWslUncPath, toWindowsWslPath } from '../shared/wsl-paths' +import { runProcessSync } from '@orca/process-host' +import { buildWslExecArgs } from '../../../shared/wsl-login-shell-command' +import { toWindowsWslPath } from '../../../shared/wsl-paths' import { filterUserWslDistros, parseWslDistros } from './wsl-distro-list-output' import { wslDistroListRetryDelayMs } from './wsl-distro-retry' import { @@ -8,7 +8,12 @@ import { _setWslAvailabilityCacheForTests, dropStaleWslAvailabilityFailure } from './wsl-availability' -import { wslExeProcessSpec, wslExeStdout } from './wsl-exe-process' +import { + WSL_PROBE_TIMEOUT_MS, + runWslExe, + wslExeProcessSpec, + wslExeStdout +} from '../execution/wsl-exe-process' import { isWslListOutputLost, listedOrRegisteredWslDistros, @@ -21,25 +26,8 @@ import { resolveRunningWslDistros, type RunningWslDistroReadOptions } from './wsl-running-distro-cache' -import { - getWslDirectoryProbeArgs, - parseWslDirectoryProbeOutput -} from './wsl-directory-probe-command' import { clearWslHomeCache, getCachedWslHome, rememberWslHome } from './wsl-home-cache' -export { hasCachedWslHome } from './wsl-home-cache' -// Relay path conversion must not import the distro-probing subprocess graph. -export { toLinuxPath, toWindowsWslPath } from '../shared/wsl-paths' -export { - getCachedWslAvailability, - hasCachedWslAvailability, - isWslAvailableAsync -} from './wsl-availability' -export type WslPathInfo = { - distro: string - linuxPath: string -} -const WSL_PROBE_TIMEOUT_MS = 5000 // Measured on a slow PC: a cold systemd distro takes 4-11 s to answer its first exec, and killing // wsl.exe mid-boot leaves the distro failing every call with Wsl/Service/E_UNEXPECTED for 14+ s. // An async probe blocks nothing, so it waits out the boot. @@ -49,39 +37,19 @@ function wslHomeProbeArgs(distro: string): string[] { return buildWslExecArgs(distro, ['bash', '-c', 'echo $HOME']) } -export function parseWslPath(windowsPath: string): WslPathInfo | null { - if (process.platform !== 'win32') { - return null - } - - return parseWslUncPath(windowsPath) -} - -export function isWslPath(path: string): boolean { - return parseWslPath(path) !== null -} - -/** Probe inside the guest because Win32 9P stat can falsely report ENOENT; no authoritative answer returns null. */ -export function wslUncDirectoryExistsAsync(uncPath: string): Promise { - if (process.platform !== 'win32') { - return Promise.resolve(null) - } - const info = parseWslUncPath(uncPath) - if (!info) { - return Promise.resolve(null) - } - return runProcess(wslExeProcessSpec(getWslDirectoryProbeArgs(info), WSL_PROBE_TIMEOUT_MS)) - .then((result) => parseWslDirectoryProbeOutput(result.stdout)) - .catch(() => null) -} - const wslHomeProbeCache = new Map>() + let wslDistroCache: string[] | null = null + let wslDistroListInFlight: Promise | null = null + // Empty and failed probes stay retryable, with capped backoff to avoid repeatedly spawning wsl.exe. let wslDistroListRetryAfterMs = 0 + let wslDistroListEmptyStreak = 0 + let wslDistroProbeSequence = 0 + let wslDistroCacheSequence = 0 function armWslDistroListRetry(): void { @@ -295,22 +263,6 @@ export async function getWslHomeAsync(distro: string): Promise { return probe } -/** Canonical guest path of a directory; Windows cannot follow guest symlinks over 9P. */ -export async function resolveWslGuestRealDirAsync( - distro: string, - guestDir: string -): Promise { - try { - // -m: a session's folder may not exist yet, but the profile symlink above it does. - const realDir = ( - await runWslExe(buildWslExecArgs(distro, ['realpath', '-m', '--', guestDir])) - ).trim() - return realDir.startsWith('/') ? realDir : null - } catch { - return null - } -} - /** UNC home roots for distros that are running at discovery time. */ export async function listRunningWslHomeDirsAsync(): Promise { const homes = await Promise.all( @@ -351,11 +303,3 @@ export function _setWslCachesForTests(args: { cacheWslDistroList(args.distros, ++wslDistroProbeSequence) } } - -async function runWslExe( - args: string[], - env?: NodeJS.ProcessEnv, - timeoutMs = WSL_PROBE_TIMEOUT_MS -): Promise { - return wslExeStdout(await runProcess(wslExeProcessSpec(args, timeoutMs, env))) -} diff --git a/src/main/preflight-wsl-cache.ts b/src/main/wsl/discovery/preflight-wsl-cache.ts similarity index 100% rename from src/main/preflight-wsl-cache.ts rename to src/main/wsl/discovery/preflight-wsl-cache.ts diff --git a/src/main/wsl-availability.ts b/src/main/wsl/discovery/wsl-availability.ts similarity index 97% rename from src/main/wsl-availability.ts rename to src/main/wsl/discovery/wsl-availability.ts index ede887e6c73..e370b0a62f8 100644 --- a/src/main/wsl-availability.ts +++ b/src/main/wsl/discovery/wsl-availability.ts @@ -1,7 +1,7 @@ import { runProcess } from '@orca/process-host' import type { ProcessResult, ProcessSpec } from '@orca/process-host/process-spec' -import { buildWslExecArgs } from '../shared/wsl-login-shell-command' -import { wslExeProcessSpec } from './wsl-exe-process' +import { buildWslExecArgs } from '../../../shared/wsl-login-shell-command' +import { wslExeProcessSpec } from '../execution/wsl-exe-process' type WslAvailabilityCache = | { available: true } diff --git a/src/main/wsl-background-distro-gate.test.ts b/src/main/wsl/discovery/wsl-background-distro-gate.test.ts similarity index 98% rename from src/main/wsl-background-distro-gate.test.ts rename to src/main/wsl/discovery/wsl-background-distro-gate.test.ts index 411b4496955..428a641495f 100644 --- a/src/main/wsl-background-distro-gate.test.ts +++ b/src/main/wsl/discovery/wsl-background-distro-gate.test.ts @@ -5,7 +5,7 @@ const wslMocks = vi.hoisted(() => ({ vi.fn<(options?: { requireConfirmed?: boolean }) => Promise>(), listWslDistrosAsync: vi.fn<() => Promise>() })) -vi.mock('./wsl', () => wslMocks) +vi.mock('./distro-catalog', () => wslMocks) import { _resetWslBackgroundDistroGateForTests, @@ -19,7 +19,7 @@ import { readSettledConfirmedRunningWslDistros, WSL_STOP_SETTLE_MS } from './wsl-background-distro-gate' -import { isWslUserActFor, runAsWslUserAct } from './wsl/wsl-user-act-scope' +import { isWslUserActFor, runAsWslUserAct } from './wsl-user-act-scope' import { _resetRunningWslDistroCacheForTests, resolveRunningWslDistros diff --git a/src/main/wsl-background-distro-gate.ts b/src/main/wsl/discovery/wsl-background-distro-gate.ts similarity index 99% rename from src/main/wsl-background-distro-gate.ts rename to src/main/wsl/discovery/wsl-background-distro-gate.ts index 6a87c52898a..75e5d31a836 100644 --- a/src/main/wsl-background-distro-gate.ts +++ b/src/main/wsl/discovery/wsl-background-distro-gate.ts @@ -1,5 +1,5 @@ -import { listRunningWslDistrosAsync, listWslDistrosAsync } from './wsl' -import { outsideWslUserAct } from './wsl/wsl-user-act-scope' +import { listRunningWslDistrosAsync, listWslDistrosAsync } from './distro-catalog' +import { outsideWslUserAct } from './wsl-user-act-scope' import { onConfirmedRunningWslDistros, onRunningWslDistrosStopped, diff --git a/src/main/wsl/wsl-background-exec-gate.test.ts b/src/main/wsl/discovery/wsl-background-exec-gate.test.ts similarity index 98% rename from src/main/wsl/wsl-background-exec-gate.test.ts rename to src/main/wsl/discovery/wsl-background-exec-gate.test.ts index 764ad967f86..fa93ff1f819 100644 --- a/src/main/wsl/wsl-background-exec-gate.test.ts +++ b/src/main/wsl/discovery/wsl-background-exec-gate.test.ts @@ -13,11 +13,11 @@ const { runProcess, readWslDistroRunningState, listWslDistrosAsync, cachedList } ) vi.mock('@orca/process-host', () => ({ runProcess })) -vi.mock('../wsl', () => ({ +vi.mock('./distro-catalog', () => ({ listWslDistrosAsync, getCachedWslDistros: () => cachedList.current })) -vi.mock('../wsl-background-distro-gate', () => ({ +vi.mock('./wsl-background-distro-gate', () => ({ readWslDistroRunningState, noteWslDistroWoken: vi.fn(), noteWslDistrosRunning: vi.fn(), diff --git a/src/main/wsl/wsl-background-exec-gate.ts b/src/main/wsl/discovery/wsl-background-exec-gate.ts similarity index 98% rename from src/main/wsl/wsl-background-exec-gate.ts rename to src/main/wsl/discovery/wsl-background-exec-gate.ts index b3b0f9e7eec..756774a6935 100644 --- a/src/main/wsl/wsl-background-exec-gate.ts +++ b/src/main/wsl/discovery/wsl-background-exec-gate.ts @@ -4,7 +4,7 @@ import { runAsWslUserAct, WslDistroUnverifiableError, type BlockedWslDistro -} from './wsl-unc-access-gate' +} from '../filesystem/wsl-unc-access-gate' import { isWslUserActFor, runAsWslUserAct as runScopedWslUserAct } from './wsl-user-act-scope' import { resolveWslDefaultDistro, diff --git a/src/main/wsl-console-running-distros.test.ts b/src/main/wsl/discovery/wsl-console-running-distros.test.ts similarity index 100% rename from src/main/wsl-console-running-distros.test.ts rename to src/main/wsl/discovery/wsl-console-running-distros.test.ts diff --git a/src/main/wsl-console-running-distros.ts b/src/main/wsl/discovery/wsl-console-running-distros.ts similarity index 96% rename from src/main/wsl-console-running-distros.ts rename to src/main/wsl/discovery/wsl-console-running-distros.ts index 83b0567505d..bee80fc0377 100644 --- a/src/main/wsl-console-running-distros.ts +++ b/src/main/wsl/discovery/wsl-console-running-distros.ts @@ -2,8 +2,8 @@ import { createRequire } from 'node:module' import type * as pty from 'node-pty' import { windowsSystem32Binary } from '@orca/process-host/windows-system-binary' -import { stripAnsiEscapeSequences } from '../shared/ansi-escape-sequences' -import { resolveWslInteropSpawnCwd } from './wsl-interop-spawn-directory' +import { stripAnsiEscapeSequences } from '../../../shared/ansi-escape-sequences' +import { resolveWslInteropSpawnCwd } from '../execution/wsl-interop-spawn-directory' const requireFromMain = createRequire(__filename) const MAX_OUTPUT_CHARS = 64 * 1024 diff --git a/src/main/wsl/wsl-default-distro.ts b/src/main/wsl/discovery/wsl-default-distro.ts similarity index 97% rename from src/main/wsl/wsl-default-distro.ts rename to src/main/wsl/discovery/wsl-default-distro.ts index b1a2ffd73c9..6e7a7b98684 100644 --- a/src/main/wsl/wsl-default-distro.ts +++ b/src/main/wsl/discovery/wsl-default-distro.ts @@ -4,7 +4,7 @@ */ import { AsyncLocalStorage } from 'node:async_hooks' import { runProcess } from '@orca/process-host' -import { getCachedWslDistros, listWslDistrosAsync } from '../wsl' +import { getCachedWslDistros, listWslDistrosAsync } from './distro-catalog' import { lxssRegQuerySpec, parseDefaultWslDistroId, diff --git a/src/main/wsl/wsl-distro-boot-id.ts b/src/main/wsl/discovery/wsl-distro-boot-id.ts similarity index 80% rename from src/main/wsl/wsl-distro-boot-id.ts rename to src/main/wsl/discovery/wsl-distro-boot-id.ts index 4851a5c7bae..6661d9a0415 100644 --- a/src/main/wsl/wsl-distro-boot-id.ts +++ b/src/main/wsl/discovery/wsl-distro-boot-id.ts @@ -1,7 +1,7 @@ import { runProcess } from '@orca/process-host' -import { buildWslExecArgs } from '../../shared/wsl-login-shell-command' -import { resolveWslExecutablePath } from './wsl-executable-path' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' +import { buildWslExecArgs } from '../../../shared/wsl-login-shell-command' +import { resolveWslExecutablePath } from '../execution/wsl-executable-path' +import { resolveWslInteropSpawnCwd } from '../execution/wsl-interop-spawn-directory' const BOOT_ID_TIMEOUT_MS = 5_000 const BOOT_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i diff --git a/src/main/wsl/wsl-distro-holder-command.ts b/src/main/wsl/discovery/wsl-distro-holder-command.ts similarity index 97% rename from src/main/wsl/wsl-distro-holder-command.ts rename to src/main/wsl/discovery/wsl-distro-holder-command.ts index 8660ec1b551..3bee3f128d3 100644 --- a/src/main/wsl/wsl-distro-holder-command.ts +++ b/src/main/wsl/discovery/wsl-distro-holder-command.ts @@ -1,8 +1,8 @@ import { ORCAD_WSL_HOLDER_BLOCKED_FILENAME, ORCAD_WSL_HOLDER_RELEASE_FILENAME -} from '../../shared/orcad-idle-exit' -import { buildWslExecArgs } from '../../shared/wsl-login-shell-command' +} from '../../../shared/orcad-idle-exit' +import { buildWslExecArgs } from '../../../shared/wsl-login-shell-command' /** `$0` of the holder's shell; the token that identifies our holder in a process command line. */ export const WSL_DISTRO_HOLDER_MARKER = 'orca-wsl-distro-holder' diff --git a/src/main/wsl/wsl-distro-holder-process-classification.ts b/src/main/wsl/discovery/wsl-distro-holder-process-classification.ts similarity index 93% rename from src/main/wsl/wsl-distro-holder-process-classification.ts rename to src/main/wsl/discovery/wsl-distro-holder-process-classification.ts index d0af3d20678..333af69a670 100644 --- a/src/main/wsl/wsl-distro-holder-process-classification.ts +++ b/src/main/wsl/discovery/wsl-distro-holder-process-classification.ts @@ -1,4 +1,4 @@ -import type { WindowsProcessEvidence } from '../daemon/daemon-incarnation-evidence-types' +import type { WindowsProcessEvidence } from '../../daemon/daemon-incarnation-evidence-types' import { isWslDistroHolderCommandLine } from './wsl-distro-holder-command' import type { WslDistroHolderRecord } from './wsl-distro-holder-record' import type { WslDistroHolderState } from './wsl-distro-holder-types' diff --git a/src/main/wsl/wsl-distro-holder-record.ts b/src/main/wsl/discovery/wsl-distro-holder-record.ts similarity index 97% rename from src/main/wsl/wsl-distro-holder-record.ts rename to src/main/wsl/discovery/wsl-distro-holder-record.ts index 86399d64a2e..ca5e47482a8 100644 --- a/src/main/wsl/wsl-distro-holder-record.ts +++ b/src/main/wsl/discovery/wsl-distro-holder-record.ts @@ -4,8 +4,8 @@ import { durableWriteTempPath, removeStaleDurableWriteTempFiles, writeFileDurable -} from '../filesystem/durable-file-write' -import { hasErrorCode } from '../daemon/daemon-process-inspection' +} from '../../filesystem/durable-file-write' +import { hasErrorCode } from '../../daemon/daemon-process-inspection' /** Per-distro record intentionally survives Orca quit so the next launch can re-adopt the surviving holder. */ export type WslDistroHolderRecord = { diff --git a/src/main/wsl/wsl-distro-holder-script.test.ts b/src/main/wsl/discovery/wsl-distro-holder-script.test.ts similarity index 99% rename from src/main/wsl/wsl-distro-holder-script.test.ts rename to src/main/wsl/discovery/wsl-distro-holder-script.test.ts index b5a4c6d3cba..4838a84cba0 100644 --- a/src/main/wsl/wsl-distro-holder-script.test.ts +++ b/src/main/wsl/discovery/wsl-distro-holder-script.test.ts @@ -14,7 +14,7 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest' import { ORCAD_WSL_HOLDER_BLOCKED_FILENAME, ORCAD_WSL_HOLDER_RELEASE_FILENAME -} from '../../shared/orcad-idle-exit' +} from '../../../shared/orcad-idle-exit' import { buildWslDistroHolderScript, WSL_DISTRO_HOLDER_BLOCKED_NAMES_MAX, diff --git a/src/main/wsl/wsl-distro-holder-types.ts b/src/main/wsl/discovery/wsl-distro-holder-types.ts similarity index 97% rename from src/main/wsl/wsl-distro-holder-types.ts rename to src/main/wsl/discovery/wsl-distro-holder-types.ts index 7e3d64903c7..4e49515e6a8 100644 --- a/src/main/wsl/wsl-distro-holder-types.ts +++ b/src/main/wsl/discovery/wsl-distro-holder-types.ts @@ -1,5 +1,5 @@ import type { EventEmitter } from 'node:events' -import type { WindowsProcessEvidence } from '../daemon/daemon-incarnation-evidence-types' +import type { WindowsProcessEvidence } from '../../daemon/daemon-incarnation-evidence-types' import type { WslDistroHolderRecord } from './wsl-distro-holder-record' /** Holder liveness, in the execution-host vocabulary: lookup failure is never `exited`. */ diff --git a/src/main/wsl/wsl-distro-holder.test.ts b/src/main/wsl/discovery/wsl-distro-holder.test.ts similarity index 98% rename from src/main/wsl/wsl-distro-holder.test.ts rename to src/main/wsl/discovery/wsl-distro-holder.test.ts index 579c1be199e..3d6cd406b21 100644 --- a/src/main/wsl/wsl-distro-holder.test.ts +++ b/src/main/wsl/discovery/wsl-distro-holder.test.ts @@ -3,7 +3,7 @@ import { mkdtemp, readdir, readFile, rm, writeFile, mkdir } from 'node:fs/promis import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type { WindowsProcessEvidence } from '../daemon/daemon-incarnation-evidence-types' +import type { WindowsProcessEvidence } from '../../daemon/daemon-incarnation-evidence-types' import { buildWslDistroHolderArgs, buildWslDistroHolderScript, @@ -12,10 +12,9 @@ import { } from './wsl-distro-holder-command' import { WSL_HOLDER_UNVERIFIABLE_REPLACE_AFTER_MS, - createWslDistroHolder, - type WslDistroHolderChild, - type WslDistroHolderDependencies + createWslDistroHolder } from './wsl-distro-holder' +import type { WslDistroHolderChild, WslDistroHolderDependencies } from './wsl-distro-holder-types' import { wslDistroHolderDirectory, type WslDistroHolderRecord } from './wsl-distro-holder-record' const HOLDER_COMMAND = (distro: string): string => diff --git a/src/main/wsl/wsl-distro-holder.ts b/src/main/wsl/discovery/wsl-distro-holder.ts similarity index 94% rename from src/main/wsl/wsl-distro-holder.ts rename to src/main/wsl/discovery/wsl-distro-holder.ts index 00722b6a6d0..cc0c3e50439 100644 --- a/src/main/wsl/wsl-distro-holder.ts +++ b/src/main/wsl/discovery/wsl-distro-holder.ts @@ -1,12 +1,12 @@ -import { runKeyedSerializedOperation } from '../cli/keyed-promise-queue' +import { runKeyedSerializedOperation } from '../../cli/keyed-promise-queue' import { spawnDetachedWithoutInheritance } from '@orca/process-host/isolated-detached-spawn' -import { queryWindowsProcess } from '../daemon/daemon-process-inspection' +import { queryWindowsProcess } from '../../daemon/daemon-process-inspection' import { listConfirmedRunningWslDistros, noteWslDistroMayHaveStopped -} from '../wsl-background-distro-gate' -import { WslDistroNotRunningError } from './wsl-orcad-connection-errors' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' +} from './wsl-background-distro-gate' +import { WslDistroNotRunningError } from '../wsl-orcad-connection-errors' +import { resolveWslInteropSpawnCwd } from '../execution/wsl-interop-spawn-directory' import { buildWslDistroHolderArgs } from './wsl-distro-holder-command' import { listWslDistroHolderRecordDistros, @@ -16,16 +16,8 @@ import { writeWslDistroHolderRecord, type WslDistroHolderRecord } from './wsl-distro-holder-record' -import { resolveWslExecutablePath } from './wsl-executable-path' +import { resolveWslExecutablePath } from '../execution/wsl-executable-path' -export type { - WslDistroHolder, - WslDistroHolderAdoption, - WslDistroHolderChild, - WslDistroHolderDependencies, - WslDistroHolderEnsureResult, - WslDistroHolderState -} from './wsl-distro-holder-types' import type { WslDistroHolder, WslDistroHolderChild, @@ -54,7 +46,6 @@ function spawnDetachedHolder(distro: string): WslDistroHolderChild { }) } -export { classifyWslDistroHolderProcess } from './wsl-distro-holder-process-classification' import { classifyWslDistroHolderProcess } from './wsl-distro-holder-process-classification' export function createWslDistroHolder(dependencies: WslDistroHolderDependencies): WslDistroHolder { diff --git a/src/main/wsl-distro-list-output.test.ts b/src/main/wsl/discovery/wsl-distro-list-output.test.ts similarity index 100% rename from src/main/wsl-distro-list-output.test.ts rename to src/main/wsl/discovery/wsl-distro-list-output.test.ts diff --git a/src/main/wsl-distro-list-output.ts b/src/main/wsl/discovery/wsl-distro-list-output.ts similarity index 100% rename from src/main/wsl-distro-list-output.ts rename to src/main/wsl/discovery/wsl-distro-list-output.ts diff --git a/src/main/wsl-distro-list-single-flight.test.ts b/src/main/wsl/discovery/wsl-distro-list-single-flight.test.ts similarity index 99% rename from src/main/wsl-distro-list-single-flight.test.ts rename to src/main/wsl/discovery/wsl-distro-list-single-flight.test.ts index 955186f8e1e..d91e95d7f0f 100644 --- a/src/main/wsl-distro-list-single-flight.test.ts +++ b/src/main/wsl/discovery/wsl-distro-list-single-flight.test.ts @@ -30,7 +30,7 @@ import { getCachedWslDistros, listWslDistros, listWslDistrosAsync -} from './wsl' +} from './distro-catalog' describe('WSL distro list single-flight', () => { const originalPlatform = process.platform diff --git a/src/main/wsl/wsl-distro-registry-id.test.ts b/src/main/wsl/discovery/wsl-distro-registry-id.test.ts similarity index 100% rename from src/main/wsl/wsl-distro-registry-id.test.ts rename to src/main/wsl/discovery/wsl-distro-registry-id.test.ts diff --git a/src/main/wsl/wsl-distro-registry-id.ts b/src/main/wsl/discovery/wsl-distro-registry-id.ts similarity index 100% rename from src/main/wsl/wsl-distro-registry-id.ts rename to src/main/wsl/discovery/wsl-distro-registry-id.ts diff --git a/src/main/wsl-distro-retry.ts b/src/main/wsl/discovery/wsl-distro-retry.ts similarity index 100% rename from src/main/wsl-distro-retry.ts rename to src/main/wsl/discovery/wsl-distro-retry.ts diff --git a/src/main/wsl/wsl-distro-unsupported.ts b/src/main/wsl/discovery/wsl-distro-unsupported.ts similarity index 86% rename from src/main/wsl/wsl-distro-unsupported.ts rename to src/main/wsl/discovery/wsl-distro-unsupported.ts index f936b05235a..1d5d867fd26 100644 --- a/src/main/wsl/wsl-distro-unsupported.ts +++ b/src/main/wsl/discovery/wsl-distro-unsupported.ts @@ -2,10 +2,10 @@ * Distros that can't host Orca's server, each refused with the step that fixes it. There is no * fallback once the WSL bridge is gone, so a refusal must say what to run, not only what failed. */ -import { OrcadHostUnsupportedError } from '../orcad/orcad-host-unavailable' -import { OrcadHostGlibcUnsupportedError } from '../managed-server/lifecycle/orcad-runtime-target' -import { RemoteNodeRuntimeSelfTestError } from '../ssh/orcad-remote-node-runtime-report' -import { wslHostAddRefusalText } from '../../shared/wsl-host-failure-copy' +import { OrcadHostUnsupportedError } from '../../orcad/orcad-host-unavailable' +import { OrcadHostGlibcUnsupportedError } from '../../managed-server/lifecycle/orcad-runtime-target' +import { RemoteNodeRuntimeSelfTestError } from '../../ssh/orcad-remote-node-runtime-report' +import { wslHostAddRefusalText } from '../../../shared/wsl-host-failure-copy' /** Keeps OrcadHostUnsupportedError's name, so callers that classify by name still see it. */ export class WslDistroVersion1Error extends OrcadHostUnsupportedError { diff --git a/src/main/wsl-home-cache.ts b/src/main/wsl/discovery/wsl-home-cache.ts similarity index 100% rename from src/main/wsl-home-cache.ts rename to src/main/wsl/discovery/wsl-home-cache.ts diff --git a/src/main/wsl/wsl-home-unless-stopped.ts b/src/main/wsl/discovery/wsl-home-unless-stopped.ts similarity index 84% rename from src/main/wsl/wsl-home-unless-stopped.ts rename to src/main/wsl/discovery/wsl-home-unless-stopped.ts index 0af8d519848..cf4c32a8097 100644 --- a/src/main/wsl/wsl-home-unless-stopped.ts +++ b/src/main/wsl/discovery/wsl-home-unless-stopped.ts @@ -1,7 +1,7 @@ -import { getWslHomeAsync, listRunningWslDistrosAsync } from '../wsl' -import { readConfirmedRunningWslDistros } from '../wsl-background-distro-gate' -import { getCachedWslHome } from '../wsl-home-cache' -import { blockedWslDistroForPath } from './wsl-unc-access-gate' +import { getWslHomeAsync, listRunningWslDistrosAsync } from './distro-catalog' +import { readConfirmedRunningWslDistros } from './wsl-background-distro-gate' +import { getCachedWslHome } from './wsl-home-cache' +import { blockedWslDistroForPath } from '../filesystem/wsl-unc-access-gate' /** The distro's home for authorization; an uncached home is only probed (wsl.exe) while it runs (E9). */ export async function wslHomeUnlessStopped(distro: string): Promise { diff --git a/src/main/wsl-last-seen-running-age.test.ts b/src/main/wsl/discovery/wsl-last-seen-running-age.test.ts similarity index 100% rename from src/main/wsl-last-seen-running-age.test.ts rename to src/main/wsl/discovery/wsl-last-seen-running-age.test.ts diff --git a/src/main/wsl-lost-list-output.test.ts b/src/main/wsl/discovery/wsl-lost-list-output.test.ts similarity index 99% rename from src/main/wsl-lost-list-output.test.ts rename to src/main/wsl/discovery/wsl-lost-list-output.test.ts index 28eb0d775d3..d6c01c0fcdc 100644 --- a/src/main/wsl-lost-list-output.test.ts +++ b/src/main/wsl/discovery/wsl-lost-list-output.test.ts @@ -20,7 +20,7 @@ import { listRunningWslDistrosAsync, listWslDistros, listWslDistrosAsync -} from './wsl' +} from './distro-catalog' // The reporter's capture of `wsl.exe --list --quiet` through process-host on WSL 3.0.3 (#35509). const LOST_LIST_OUTPUT: ProcessResult = { diff --git a/src/main/wsl-registered-distro-fallback.ts b/src/main/wsl/discovery/wsl-registered-distro-fallback.ts similarity index 98% rename from src/main/wsl-registered-distro-fallback.ts rename to src/main/wsl/discovery/wsl-registered-distro-fallback.ts index a3cb41f54f0..10fac1f0a74 100644 --- a/src/main/wsl-registered-distro-fallback.ts +++ b/src/main/wsl/discovery/wsl-registered-distro-fallback.ts @@ -7,7 +7,7 @@ import { lxssRegQuerySpec, parseDefaultWslDistroId, parseWslDistroRegistrations -} from './wsl/wsl-distro-registry-id' +} from './wsl-distro-registry-id' /** Registered user distros, default first as `wsl --list` orders them; empty when the registry is unreadable. */ export function registeredUserWslDistros(result: Pick): string[] { diff --git a/src/main/wsl-running-distro-cache.ts b/src/main/wsl/discovery/wsl-running-distro-cache.ts similarity index 100% rename from src/main/wsl-running-distro-cache.ts rename to src/main/wsl/discovery/wsl-running-distro-cache.ts diff --git a/src/main/wsl-running-distro-stop.test.ts b/src/main/wsl/discovery/wsl-running-distro-stop.test.ts similarity index 100% rename from src/main/wsl-running-distro-stop.test.ts rename to src/main/wsl/discovery/wsl-running-distro-stop.test.ts diff --git a/src/main/wsl-running-distros.test.ts b/src/main/wsl/discovery/wsl-running-distros.test.ts similarity index 97% rename from src/main/wsl-running-distros.test.ts rename to src/main/wsl/discovery/wsl-running-distros.test.ts index 3a320f0072d..1dcd3333b07 100644 --- a/src/main/wsl-running-distros.test.ts +++ b/src/main/wsl/discovery/wsl-running-distros.test.ts @@ -19,13 +19,13 @@ import { _setWslCachesForTests, listRunningWslDistrosAsync, listRunningWslHomeDirsAsync -} from './wsl' -import { filterPathsToRunningWslDistrosAsync } from './wsl-running-path-filter' -import { resetWslInteropSpawnDirectoryCache } from './wsl-interop-spawn-directory' +} from './distro-catalog' +import { filterPathsToRunningWslDistrosAsync } from '../filesystem/wsl-running-path-filter' +import { resetWslInteropSpawnDirectoryCache } from '../execution/wsl-interop-spawn-directory' import { observeWslTranscriptRunningState, resetWslTranscriptRunningObserverForTests -} from './native-chat/wsl-transcript-running-observer' +} from '../../native-chat/wsl-transcript-running-observer' function restoreEnv(key: string, value: string | undefined): void { if (value === undefined) { diff --git a/src/main/wsl-stopped-worktree-rescan-registry.ts b/src/main/wsl/discovery/wsl-stopped-worktree-rescan-registry.ts similarity index 100% rename from src/main/wsl-stopped-worktree-rescan-registry.ts rename to src/main/wsl/discovery/wsl-stopped-worktree-rescan-registry.ts diff --git a/src/main/wsl/wsl-user-act-scope.test.ts b/src/main/wsl/discovery/wsl-user-act-scope.test.ts similarity index 100% rename from src/main/wsl/wsl-user-act-scope.test.ts rename to src/main/wsl/discovery/wsl-user-act-scope.test.ts diff --git a/src/main/wsl/wsl-user-act-scope.ts b/src/main/wsl/discovery/wsl-user-act-scope.ts similarity index 100% rename from src/main/wsl/wsl-user-act-scope.ts rename to src/main/wsl/discovery/wsl-user-act-scope.ts diff --git a/src/main/wsl-bash-command.ts b/src/main/wsl/execution/wsl-bash-command.ts similarity index 73% rename from src/main/wsl-bash-command.ts rename to src/main/wsl/execution/wsl-bash-command.ts index 9434882231c..73b262dbe35 100644 --- a/src/main/wsl-bash-command.ts +++ b/src/main/wsl/execution/wsl-bash-command.ts @@ -1,6 +1,4 @@ -import { quotePosixShell } from '../shared/shell-argument-quoting' - -export { quotePosixShell as quoteBashString } +import { quotePosixShell } from '../../../shared/shell-argument-quoting' export function buildEncodedWslBashCommand(command: string): string { // Encode multiline payloads intact; --exec separately preserves the wsl.exe argument boundary. diff --git a/src/main/wsl/wsl-command-channel.test.ts b/src/main/wsl/execution/wsl-command-channel.test.ts similarity index 100% rename from src/main/wsl/wsl-command-channel.test.ts rename to src/main/wsl/execution/wsl-command-channel.test.ts diff --git a/src/main/wsl/wsl-command-channel.ts b/src/main/wsl/execution/wsl-command-channel.ts similarity index 97% rename from src/main/wsl/wsl-command-channel.ts rename to src/main/wsl/execution/wsl-command-channel.ts index 7e6e0dc3fc2..a677ca506ac 100644 --- a/src/main/wsl/wsl-command-channel.ts +++ b/src/main/wsl/execution/wsl-command-channel.ts @@ -1,6 +1,6 @@ import { Duplex } from 'node:stream' import type { PipedChildProcess } from '@orca/process-host/process-spec' -import type { RemoteCommandChannel } from '../managed-server/install/remote-install-transport' +import type { RemoteCommandChannel } from '../../managed-server/install/remote-install-transport' /** How long a closed channel's guest gets to exit on stdin EOF before wsl.exe is killed. */ export const WSL_CHANNEL_CLOSE_GRACE_MS = 2_000 diff --git a/src/main/wsl/wsl-command-loop-pool.ts b/src/main/wsl/execution/wsl-command-loop-pool.ts similarity index 95% rename from src/main/wsl/wsl-command-loop-pool.ts rename to src/main/wsl/execution/wsl-command-loop-pool.ts index f59fb24ed4b..68b67d17ffd 100644 --- a/src/main/wsl/wsl-command-loop-pool.ts +++ b/src/main/wsl/execution/wsl-command-loop-pool.ts @@ -1,6 +1,6 @@ import type { PipedChildProcess } from '@orca/process-host/process-spec' -import type { RemoteCommandChannel } from '../managed-server/install/remote-install-transport' -import { createSshOperationAbortError } from '../ssh/connection/ssh-exec-options' +import type { RemoteCommandChannel } from '../../managed-server/install/remote-install-transport' +import { createSshOperationAbortError } from '../../ssh/connection/ssh-exec-options' import { startWslCommandLoop, wslCommandLoopMarker, type WslCommandLoop } from './wsl-command-loop' export type WslCommandLoopPool = { diff --git a/src/main/wsl/wsl-command-loop.test.ts b/src/main/wsl/execution/wsl-command-loop.test.ts similarity index 98% rename from src/main/wsl/wsl-command-loop.test.ts rename to src/main/wsl/execution/wsl-command-loop.test.ts index c4972575d56..ae173ffb0b6 100644 --- a/src/main/wsl/wsl-command-loop.test.ts +++ b/src/main/wsl/execution/wsl-command-loop.test.ts @@ -4,7 +4,7 @@ import { join } from 'node:path' import { afterEach, describe, expect, it } from 'vitest' import { spawnProcess } from '@orca/process-host' import type { PipedChildProcess } from '@orca/process-host/process-spec' -import { execCommand } from '../ssh/remote-exec/remote-exec-command' +import { execCommand } from '../../ssh/remote-exec/remote-exec-command' import { WSL_COMMAND_LOOP_ARGV0, WSL_COMMAND_LOOP_SCRIPT } from './wsl-command-loop' import { createWslCommandLoopPool, type WslCommandLoopPool } from './wsl-command-loop-pool' diff --git a/src/main/wsl/wsl-command-loop.ts b/src/main/wsl/execution/wsl-command-loop.ts similarity index 98% rename from src/main/wsl/wsl-command-loop.ts rename to src/main/wsl/execution/wsl-command-loop.ts index a73940bac11..15c580b60ad 100644 --- a/src/main/wsl/wsl-command-loop.ts +++ b/src/main/wsl/execution/wsl-command-loop.ts @@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto' import { Duplex, PassThrough, Writable } from 'node:stream' import type { PipedChildProcess } from '@orca/process-host/process-spec' -import type { RemoteCommandChannel } from '../managed-server/install/remote-install-transport' +import type { RemoteCommandChannel } from '../../managed-server/install/remote-install-transport' // setsid preserves per-command process-group isolation. Fresh output files keep background writers attached to old inodes, never the next command. export const WSL_COMMAND_LOOP_SCRIPT = [ diff --git a/src/main/wsl-exe-process.ts b/src/main/wsl/execution/wsl-exe-process.ts similarity index 73% rename from src/main/wsl-exe-process.ts rename to src/main/wsl/execution/wsl-exe-process.ts index faa122b77e8..7e831eea563 100644 --- a/src/main/wsl-exe-process.ts +++ b/src/main/wsl/execution/wsl-exe-process.ts @@ -1,6 +1,17 @@ +import { runProcess } from '@orca/process-host' import type { ProcessResult, ProcessSpec } from '@orca/process-host/process-spec' import { resolveWslInteropSpawnCwd } from './wsl-interop-spawn-directory' +export const WSL_PROBE_TIMEOUT_MS = 5000 + +export async function runWslExe( + args: string[], + env?: NodeJS.ProcessEnv, + timeoutMs = WSL_PROBE_TIMEOUT_MS +): Promise { + return wslExeStdout(await runProcess(wslExeProcessSpec(args, timeoutMs, env))) +} + export function wslExeProcessSpec( args: readonly string[], timeoutMs: number, diff --git a/src/main/wsl/wsl-executable-path.ts b/src/main/wsl/execution/wsl-executable-path.ts similarity index 100% rename from src/main/wsl/wsl-executable-path.ts rename to src/main/wsl/execution/wsl-executable-path.ts diff --git a/src/main/wsl/wsl-executable-path.win32.test.ts b/src/main/wsl/execution/wsl-executable-path.win32.test.ts similarity index 100% rename from src/main/wsl/wsl-executable-path.win32.test.ts rename to src/main/wsl/execution/wsl-executable-path.win32.test.ts diff --git a/src/main/wsl/wsl-interop-health.test.ts b/src/main/wsl/execution/wsl-interop-health.test.ts similarity index 98% rename from src/main/wsl/wsl-interop-health.test.ts rename to src/main/wsl/execution/wsl-interop-health.test.ts index 6a9452daae1..dcfd6957b38 100644 --- a/src/main/wsl/wsl-interop-health.test.ts +++ b/src/main/wsl/execution/wsl-interop-health.test.ts @@ -1,9 +1,9 @@ import { describe, expect, it, vi } from 'vitest' -vi.mock('../wsl', () => ({ +vi.mock('../discovery/distro-catalog', () => ({ listWslDistrosAsync: vi.fn() })) -vi.mock('../wsl-background-distro-gate', () => ({ isWslDistroRunning: vi.fn() })) +vi.mock('../discovery/wsl-background-distro-gate', () => ({ isWslDistroRunning: vi.fn() })) vi.mock('./wsl-runner', () => ({ runWslProcess: vi.fn() })) import { diff --git a/src/main/wsl/wsl-interop-health.ts b/src/main/wsl/execution/wsl-interop-health.ts similarity index 96% rename from src/main/wsl/wsl-interop-health.ts rename to src/main/wsl/execution/wsl-interop-health.ts index 6b849a2173f..585e211ec17 100644 --- a/src/main/wsl/wsl-interop-health.ts +++ b/src/main/wsl/execution/wsl-interop-health.ts @@ -1,6 +1,6 @@ -import { listWslDistrosAsync } from '../wsl' -import { isWslDistroRunning } from '../wsl-background-distro-gate' -import { onRunningWslDistrosStopped } from '../wsl-running-distro-cache' +import { listWslDistrosAsync } from '../discovery/distro-catalog' +import { isWslDistroRunning } from '../discovery/wsl-background-distro-gate' +import { onRunningWslDistrosStopped } from '../discovery/wsl-running-distro-cache' import { runWslProcess } from './wsl-runner' import { parseWslInteropProbeOutput, diff --git a/src/main/wsl/wsl-interop-registration.test.ts b/src/main/wsl/execution/wsl-interop-registration.test.ts similarity index 100% rename from src/main/wsl/wsl-interop-registration.test.ts rename to src/main/wsl/execution/wsl-interop-registration.test.ts diff --git a/src/main/wsl/wsl-interop-registration.ts b/src/main/wsl/execution/wsl-interop-registration.ts similarity index 100% rename from src/main/wsl/wsl-interop-registration.ts rename to src/main/wsl/execution/wsl-interop-registration.ts diff --git a/src/main/wsl-interop-spawn-directory.test.ts b/src/main/wsl/execution/wsl-interop-spawn-directory.test.ts similarity index 100% rename from src/main/wsl-interop-spawn-directory.test.ts rename to src/main/wsl/execution/wsl-interop-spawn-directory.test.ts diff --git a/src/main/wsl-interop-spawn-directory.ts b/src/main/wsl/execution/wsl-interop-spawn-directory.ts similarity index 100% rename from src/main/wsl-interop-spawn-directory.ts rename to src/main/wsl/execution/wsl-interop-spawn-directory.ts diff --git a/src/main/wsl-managed-cli-path-restore.test.ts b/src/main/wsl/execution/wsl-managed-cli-path-restore.test.ts similarity index 100% rename from src/main/wsl-managed-cli-path-restore.test.ts rename to src/main/wsl/execution/wsl-managed-cli-path-restore.test.ts diff --git a/src/main/wsl-managed-cli-path-restore.ts b/src/main/wsl/execution/wsl-managed-cli-path-restore.ts similarity index 100% rename from src/main/wsl-managed-cli-path-restore.ts rename to src/main/wsl/execution/wsl-managed-cli-path-restore.ts diff --git a/src/main/wsl/wsl-node-runtime-download-budget.ts b/src/main/wsl/execution/wsl-node-runtime-download-budget.ts similarity index 86% rename from src/main/wsl/wsl-node-runtime-download-budget.ts rename to src/main/wsl/execution/wsl-node-runtime-download-budget.ts index 64d6fd69503..448c97b8a50 100644 --- a/src/main/wsl/wsl-node-runtime-download-budget.ts +++ b/src/main/wsl/execution/wsl-node-runtime-download-budget.ts @@ -1,4 +1,4 @@ -import type { NodeRuntimeDownloadBudget } from '../ssh/orcad-node-runtime-install-options' +import type { NodeRuntimeDownloadBudget } from '../../ssh/orcad-node-runtime-install-options' /** * A first WSL deploy fetches the pinned Node archive. Behind a firewall that drops packets the default diff --git a/src/main/wsl/wsl-node-runtime-prefetch.test.ts b/src/main/wsl/execution/wsl-node-runtime-prefetch.test.ts similarity index 97% rename from src/main/wsl/wsl-node-runtime-prefetch.test.ts rename to src/main/wsl/execution/wsl-node-runtime-prefetch.test.ts index 93da04c4388..f08dd1b8796 100644 --- a/src/main/wsl/wsl-node-runtime-prefetch.test.ts +++ b/src/main/wsl/execution/wsl-node-runtime-prefetch.test.ts @@ -2,7 +2,7 @@ import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises' import { tmpdir } from 'node:os' import { dirname, join } from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { orcadNodeRuntimeInstallOptions } from '../ssh/orcad-node-runtime-install-options' +import { orcadNodeRuntimeInstallOptions } from '../../ssh/orcad-node-runtime-install-options' import { prefetchWslNodeRuntime, resetWslNodeRuntimePrefetchForTests, diff --git a/src/main/wsl/wsl-node-runtime-prefetch.ts b/src/main/wsl/execution/wsl-node-runtime-prefetch.ts similarity index 91% rename from src/main/wsl/wsl-node-runtime-prefetch.ts rename to src/main/wsl/execution/wsl-node-runtime-prefetch.ts index f43672b1466..d84c55ec0c1 100644 --- a/src/main/wsl/wsl-node-runtime-prefetch.ts +++ b/src/main/wsl/execution/wsl-node-runtime-prefetch.ts @@ -1,13 +1,13 @@ import { existsSync } from 'node:fs' import { join } from 'node:path' -import type { NodeRuntimeTarget } from '../../shared/node-runtime-pin' -import type { GlobalSettings } from '../../shared/global-settings-types' -import { errorMessage } from '../../shared/error-message' +import type { NodeRuntimeTarget } from '../../../shared/node-runtime-pin' +import type { GlobalSettings } from '../../../shared/global-settings-types' +import { errorMessage } from '../../../shared/error-message' import { materializeNodeRuntimeArchive, nodeRuntimeArchiveCachePath -} from '../node-runtime/pinned-runtime-materializer' -import { wslHostsGateOpen } from './wsl-host-gate' +} from '../../node-runtime/pinned-runtime-materializer' +import { wslHostsGateOpen } from '../wsl-host-gate' /** Off the startup path; the archive is about 55 MB. */ const PREFETCH_DELAY_MS = 60_000 diff --git a/src/main/wsl/wsl-process-failure.ts b/src/main/wsl/execution/wsl-process-failure.ts similarity index 100% rename from src/main/wsl/wsl-process-failure.ts rename to src/main/wsl/execution/wsl-process-failure.ts diff --git a/src/main/wsl/wsl-runner.test.ts b/src/main/wsl/execution/wsl-runner.test.ts similarity index 99% rename from src/main/wsl/wsl-runner.test.ts rename to src/main/wsl/execution/wsl-runner.test.ts index 5090a4b10d9..f42505f3f04 100644 --- a/src/main/wsl/wsl-runner.test.ts +++ b/src/main/wsl/execution/wsl-runner.test.ts @@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' const runProcessMock = vi.hoisted(() => vi.fn()) vi.mock('@orca/process-host', () => ({ runProcess: runProcessMock })) -vi.mock('../wsl-interop-spawn-directory', () => ({ +vi.mock('./wsl-interop-spawn-directory', () => ({ resolveWslInteropSpawnCwd: () => 'C:\\Windows' })) vi.mock('./wsl-executable-path', () => ({ @@ -13,7 +13,7 @@ import { runWslProcess } from './wsl-runner' import { invalidateWslGuestEnvironment, seedWslGuestEnvironmentForTests -} from './wsl-guest-environment' +} from '../wsl-guest-environment' const ENVIRONMENT = { path: '/home/u/.nvm/bin:/usr/bin', diff --git a/src/main/wsl/wsl-runner.ts b/src/main/wsl/execution/wsl-runner.ts similarity index 95% rename from src/main/wsl/wsl-runner.ts rename to src/main/wsl/execution/wsl-runner.ts index ea7b42ea070..c002b7f9230 100644 --- a/src/main/wsl/wsl-runner.ts +++ b/src/main/wsl/execution/wsl-runner.ts @@ -1,9 +1,12 @@ -import { addWslEnvKeys } from '../../shared/wsl-env' -import { commandLineLength, MAX_COMMAND_LINE_CHARS } from '../../shared/windows-command-line-budget' +import { addWslEnvKeys } from '../../../shared/wsl-env' +import { + commandLineLength, + MAX_COMMAND_LINE_CHARS +} from '../../../shared/windows-command-line-budget' import { runProcess } from '@orca/process-host' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' -import { buildWslExecArgs } from '../../shared/wsl-login-shell-command' -import { getWslGuestEnvironment, type WslGuestEnvironment } from './wsl-guest-environment' +import { resolveWslInteropSpawnCwd } from './wsl-interop-spawn-directory' +import { buildWslExecArgs } from '../../../shared/wsl-login-shell-command' +import { getWslGuestEnvironment, type WslGuestEnvironment } from '../wsl-guest-environment' import { resolveWslExecutablePath } from './wsl-executable-path' /** Shared WSL argv/environment/payload rules; see docs/reference/wsl-command-execution.md. */ diff --git a/src/main/wsl/wsl-runner.wsl.test.ts b/src/main/wsl/execution/wsl-runner.wsl.test.ts similarity index 98% rename from src/main/wsl/wsl-runner.wsl.test.ts rename to src/main/wsl/execution/wsl-runner.wsl.test.ts index 416f8bd7a3b..e471032d679 100644 --- a/src/main/wsl/wsl-runner.wsl.test.ts +++ b/src/main/wsl/execution/wsl-runner.wsl.test.ts @@ -1,6 +1,6 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest' import { runWslProcess } from './wsl-runner' -import { invalidateWslGuestEnvironment } from './wsl-guest-environment' +import { invalidateWslGuestEnvironment } from '../wsl-guest-environment' import { runProcess } from '@orca/process-host' import { resolveWslExecutablePath } from './wsl-executable-path' diff --git a/src/main/wsl/filesystem/unc-path-access.test.ts b/src/main/wsl/filesystem/unc-path-access.test.ts new file mode 100644 index 00000000000..ea310358329 --- /dev/null +++ b/src/main/wsl/filesystem/unc-path-access.test.ts @@ -0,0 +1,132 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' +import type { ProcessResult } from '@orca/process-host/process-spec' +import { parseWslPath, wslUncDirectoryExistsAsync } from './unc-path-access' +import { toLinuxPath, toWindowsWslPath } from '../../../shared/wsl-paths' + +const { runProcessMock, runProcessSyncMock } = vi.hoisted(() => ({ + runProcessMock: vi.fn(), + runProcessSyncMock: vi.fn() +})) + +vi.mock('@orca/process-host', () => ({ + runProcess: runProcessMock, + runProcessSync: runProcessSyncMock +})) + +vi.mock('../execution/wsl-interop-spawn-directory', () => ({ + resolveWslInteropSpawnCwd: () => 'C:\\Windows' +})) + +// These cases model hosts with no registered distro; the lost-output fallback has its own suite. +vi.mock('../discovery/wsl-registered-distro-fallback', () => ({ + listedOrRegisteredWslDistros: async (listed: string[]) => listed, + readRegisteredWslDistrosLater: () => {}, + isWslListOutputLost: () => false, + resetWslListOutputLost: () => {}, + runningWhenListedNone: async () => [] +})) + +function exited(stdout: string, code: number | null = 0): ProcessResult { + return { code, signal: null, stdout, stderr: '', timedOut: false } +} + +async function withPlatformAsync(value: NodeJS.Platform, fn: () => Promise): Promise { + const original = process.platform + Object.defineProperty(process, 'platform', { configurable: true, value }) + try { + return await fn() + } finally { + Object.defineProperty(process, 'platform', { configurable: true, value: original }) + } +} + +describe('wsl path helpers', () => { + it('parses WSL UNC paths on Windows', () => { + const originalPlatform = process.platform + Object.defineProperty(process, 'platform', { + configurable: true, + value: 'win32' + }) + + try { + expect(parseWslPath('\\\\wsl.localhost\\Ubuntu\\home\\jin\\repo')).toEqual({ + distro: 'Ubuntu', + linuxPath: '/home/jin/repo' + }) + } finally { + Object.defineProperty(process, 'platform', { + configurable: true, + value: originalPlatform + }) + } + }) + + it('converts Windows drive paths to /mnt paths for WSL commands', () => { + expect(toLinuxPath('C:\\Users\\jinwo\\git\\orca')).toBe('/mnt/c/Users/jinwo/git/orca') + }) + + it('converts /mnt drive paths back to native Windows form', () => { + expect(toWindowsWslPath('/mnt/c/Users/jinwo/git/orca', 'Ubuntu')).toBe( + 'C:\\Users\\jinwo\\git\\orca' + ) + }) +}) + +describe('wslUncDirectoryExistsAsync', () => { + afterEach(() => { + runProcessMock.mockReset() + }) + + it('returns true when the distro reports the directory exists', async () => { + runProcessMock.mockResolvedValue(exited('__ORCA_DIRECTORY_EXISTS__')) + + await expect( + withPlatformAsync('win32', () => + wslUncDirectoryExistsAsync('\\\\wsl.localhost\\Ubuntu\\home\\jin\\repo') + ) + ).resolves.toBe(true) + expect(runProcessMock).toHaveBeenCalledWith( + expect.objectContaining({ + program: 'wsl.exe', + timeoutMs: 5000, + args: [ + '-d', + 'Ubuntu', + '--exec', + 'sh', + '-c', + expect.stringContaining('__ORCA_DIRECTORY_EXISTS__'), + 'sh', + '/home/jin/repo' + ] + }) + ) + }) + + it('distinguishes a missing directory from an inconclusive probe', async () => { + runProcessMock + .mockResolvedValueOnce(exited('__ORCA_DIRECTORY_MISSING__')) + .mockResolvedValueOnce(exited('', 4294967295)) + + await withPlatformAsync('win32', async () => { + await expect( + wslUncDirectoryExistsAsync('\\\\wsl.localhost\\Ubuntu\\home\\jin\\missing') + ).resolves.toBe(false) + await expect( + wslUncDirectoryExistsAsync('\\\\wsl.localhost\\Ubuntu\\home\\jin\\repo') + ).resolves.toBeNull() + }) + }) + + it('returns null without spawning for paths outside WSL or off Windows', async () => { + await expect( + withPlatformAsync('win32', () => wslUncDirectoryExistsAsync('C:\\Users\\jin\\repo')) + ).resolves.toBeNull() + await expect( + withPlatformAsync('linux', () => + wslUncDirectoryExistsAsync('\\\\wsl.localhost\\Ubuntu\\home\\jin') + ) + ).resolves.toBeNull() + expect(runProcessMock).not.toHaveBeenCalled() + }) +}) diff --git a/src/main/wsl/filesystem/unc-path-access.ts b/src/main/wsl/filesystem/unc-path-access.ts new file mode 100644 index 00000000000..c481e0e3770 --- /dev/null +++ b/src/main/wsl/filesystem/unc-path-access.ts @@ -0,0 +1,50 @@ +import { runProcess } from '@orca/process-host' +import { parseWslUncPath, type WslUncPathInfo as WslPathInfo } from '../../../shared/wsl-paths' +import { buildWslExecArgs } from '../../../shared/wsl-login-shell-command' +import { WSL_PROBE_TIMEOUT_MS, runWslExe, wslExeProcessSpec } from '../execution/wsl-exe-process' +import { + getWslDirectoryProbeArgs, + parseWslDirectoryProbeOutput +} from './wsl-directory-probe-command' + +export function parseWslPath(windowsPath: string): WslPathInfo | null { + if (process.platform !== 'win32') { + return null + } + + return parseWslUncPath(windowsPath) +} + +export function isWslPath(path: string): boolean { + return parseWslPath(path) !== null +} + +/** Probe inside the guest because Win32 9P stat can falsely report ENOENT; no authoritative answer returns null. */ +export function wslUncDirectoryExistsAsync(uncPath: string): Promise { + if (process.platform !== 'win32') { + return Promise.resolve(null) + } + const info = parseWslUncPath(uncPath) + if (!info) { + return Promise.resolve(null) + } + return runProcess(wslExeProcessSpec(getWslDirectoryProbeArgs(info), WSL_PROBE_TIMEOUT_MS)) + .then((result) => parseWslDirectoryProbeOutput(result.stdout)) + .catch(() => null) +} + +/** Canonical guest path of a directory; Windows cannot follow guest symlinks over 9P. */ +export async function resolveWslGuestRealDirAsync( + distro: string, + guestDir: string +): Promise { + try { + // -m: a session's folder may not exist yet, but the profile symlink above it does. + const realDir = ( + await runWslExe(buildWslExecArgs(distro, ['realpath', '-m', '--', guestDir])) + ).trim() + return realDir.startsWith('/') ? realDir : null + } catch { + return null + } +} diff --git a/src/main/wsl/wsl-automount-root.test.ts b/src/main/wsl/filesystem/wsl-automount-root.test.ts similarity index 96% rename from src/main/wsl/wsl-automount-root.test.ts rename to src/main/wsl/filesystem/wsl-automount-root.test.ts index 0e274eb9a3e..cfe03f728e9 100644 --- a/src/main/wsl/wsl-automount-root.test.ts +++ b/src/main/wsl/filesystem/wsl-automount-root.test.ts @@ -1,18 +1,21 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' // The gate's running reads go through wsl.exe; these tests feed the cache their own lists. -vi.mock('../wsl', () => ({ listRunningWslDistrosAsync: vi.fn(), listWslDistrosAsync: vi.fn() })) +vi.mock('../discovery/distro-catalog', () => ({ + listRunningWslDistrosAsync: vi.fn(), + listWslDistrosAsync: vi.fn() +})) import { _resetWslBackgroundDistroGateForTests, noteWslDistroMayHaveStopped, noteWslDistroWoken, WSL_STOP_SETTLE_MS -} from '../wsl-background-distro-gate' +} from '../discovery/wsl-background-distro-gate' import { _resetRunningWslDistroCacheForTests, resolveRunningWslDistros -} from '../wsl-running-distro-cache' +} from '../discovery/wsl-running-distro-cache' import { followWslAutomountRoots, knownWslAutomountRoots, diff --git a/src/main/wsl/wsl-automount-root.ts b/src/main/wsl/filesystem/wsl-automount-root.ts similarity index 94% rename from src/main/wsl/wsl-automount-root.ts rename to src/main/wsl/filesystem/wsl-automount-root.ts index c108bbcb4c1..fe8b231a9cd 100644 --- a/src/main/wsl/wsl-automount-root.ts +++ b/src/main/wsl/filesystem/wsl-automount-root.ts @@ -7,18 +7,18 @@ * outside Orca with no wake after it keeps the old root until the next noticed stop or wake. */ import { runProcess } from '@orca/process-host' -import { buildPosixStdoutFence } from '../../shared/posix-stdout-fence' -import { buildWslExecArgs } from '../../shared/wsl-login-shell-command' +import { buildPosixStdoutFence } from '../../../shared/posix-stdout-fence' +import { buildWslExecArgs } from '../../../shared/wsl-login-shell-command' import { onWslDistroGateNote, wasWslDistroLastSeenRunningSettled -} from '../wsl-background-distro-gate' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' +} from '../discovery/wsl-background-distro-gate' +import { resolveWslInteropSpawnCwd } from '../execution/wsl-interop-spawn-directory' import { onConfirmedRunningWslDistros, onRunningWslDistrosStopped -} from '../wsl-running-distro-cache' -import { resolveWslExecutablePath } from './wsl-executable-path' +} from '../discovery/wsl-running-distro-cache' +import { resolveWslExecutablePath } from '../execution/wsl-executable-path' export const DEFAULT_WSL_AUTOMOUNT_ROOT = '/mnt/' diff --git a/src/main/wsl-contained-delete.ts b/src/main/wsl/filesystem/wsl-contained-delete.ts similarity index 98% rename from src/main/wsl-contained-delete.ts rename to src/main/wsl/filesystem/wsl-contained-delete.ts index e0dddb2c7e4..f8a60275141 100644 --- a/src/main/wsl-contained-delete.ts +++ b/src/main/wsl/filesystem/wsl-contained-delete.ts @@ -1,5 +1,5 @@ import { posix } from 'node:path' -import type { WslPathInfo } from './wsl' +import type { WslUncPathInfo as WslPathInfo } from '../../../shared/wsl-paths' const REJECTION_PREFIX = 'ORCA_WSL_DELETE_REJECT:' diff --git a/src/main/wsl-directory-probe-command.ts b/src/main/wsl/filesystem/wsl-directory-probe-command.ts similarity index 93% rename from src/main/wsl-directory-probe-command.ts rename to src/main/wsl/filesystem/wsl-directory-probe-command.ts index dc6dabba814..298d722d8a5 100644 --- a/src/main/wsl-directory-probe-command.ts +++ b/src/main/wsl/filesystem/wsl-directory-probe-command.ts @@ -1,4 +1,4 @@ -import type { WslUncPathInfo } from '../shared/wsl-paths' +import type { WslUncPathInfo } from '../../../shared/wsl-paths' // Exit codes conflate host failures with guest results; only stdout markers prove the guest answered. const WSL_DIRECTORY_EXISTS_MARKER = '__ORCA_DIRECTORY_EXISTS__' diff --git a/src/main/wsl/wsl-directory-upload.test.ts b/src/main/wsl/filesystem/wsl-directory-upload.test.ts similarity index 98% rename from src/main/wsl/wsl-directory-upload.test.ts rename to src/main/wsl/filesystem/wsl-directory-upload.test.ts index f0e3401509a..80a7c795ff2 100644 --- a/src/main/wsl/wsl-directory-upload.test.ts +++ b/src/main/wsl/filesystem/wsl-directory-upload.test.ts @@ -16,7 +16,10 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest' import { spawnProcess } from '@orca/process-host' import type { PipedChildProcess } from '@orca/process-host/process-spec' import { uploadDirectoryIntoWsl, wslGuestSourcePath } from './wsl-directory-upload' -import { createWslOrcadHostTransport, type WslOrcadHostTransport } from './wsl-orcad-host-transport' +import { + createWslOrcadHostTransport, + type WslOrcadHostTransport +} from '../wsl-orcad-host-transport' function hasSha256sum(): boolean { try { diff --git a/src/main/wsl/wsl-directory-upload.ts b/src/main/wsl/filesystem/wsl-directory-upload.ts similarity index 92% rename from src/main/wsl/wsl-directory-upload.ts rename to src/main/wsl/filesystem/wsl-directory-upload.ts index 0983dbb91a3..598afba7f4c 100644 --- a/src/main/wsl/wsl-directory-upload.ts +++ b/src/main/wsl/filesystem/wsl-directory-upload.ts @@ -3,21 +3,21 @@ import { createHash, randomBytes } from 'node:crypto' import { constants } from 'node:fs' import { open } from 'node:fs/promises' import { Readable } from 'node:stream' -import { parseWslUncPath, toLinuxPath } from '../../shared/wsl-paths' -import type { RemoteInstallTransport } from '../managed-server/install/remote-install-transport' -import { quotePosixShell } from '../../shared/shell-argument-quoting' -import { execCommand } from '../ssh/remote-exec/remote-exec-command' -import { REMOTE_INSTALL_TIMEOUT_MS } from '../managed-server/install/remote-deploy-timing' -import { getRemoteHostPlatform } from '../ssh/ssh-remote-platform' +import { parseWslUncPath, toLinuxPath } from '../../../shared/wsl-paths' +import type { RemoteInstallTransport } from '../../managed-server/install/remote-install-transport' +import { quotePosixShell } from '../../../shared/shell-argument-quoting' +import { execCommand } from '../../ssh/remote-exec/remote-exec-command' +import { REMOTE_INSTALL_TIMEOUT_MS } from '../../managed-server/install/remote-deploy-timing' +import { getRemoteHostPlatform } from '../../ssh/ssh-remote-platform' import { collectLocalUploadPlan, type LocalUploadPlan -} from '../ssh/system-transport/system-ssh-file-transfer' +} from '../../ssh/system-transport/system-ssh-file-transfer' import { buildUstarEntryHeader, USTAR_BLOCK_BYTES, ustarPaddingBytes -} from '../archive/ustar-entry-header' +} from '../../archive/ustar-entry-header' export const WSL_GUEST_SOURCE_UNAVAILABLE = 'ORCA_WSL_GUEST_SOURCE_UNAVAILABLE' export const WSL_UPLOAD_PROMOTED = 'ORCA_WSL_UPLOAD_PROMOTED' diff --git a/src/main/wsl/wsl-drive-project-new-default.test.ts b/src/main/wsl/filesystem/wsl-drive-project-new-default.test.ts similarity index 97% rename from src/main/wsl/wsl-drive-project-new-default.test.ts rename to src/main/wsl/filesystem/wsl-drive-project-new-default.test.ts index 5f7a30e4fd0..3187810f5e8 100644 --- a/src/main/wsl/wsl-drive-project-new-default.test.ts +++ b/src/main/wsl/filesystem/wsl-drive-project-new-default.test.ts @@ -2,7 +2,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type { LocalWindowsRuntimePreference } from '../../shared/project-execution-runtime' +import type { LocalWindowsRuntimePreference } from '../../../shared/project-execution-runtime' import { applyNewWindowsDriveProjectDefault, newWindowsDriveProjectRuntimePreference, @@ -11,7 +11,7 @@ import { } from './wsl-drive-project-new-default' const gate = vi.hoisted(() => ({ open: true })) -vi.mock('./wsl-host-gate', () => ({ +vi.mock('../wsl-host-gate', () => ({ wslHostsGateOpen: () => gate.open, wslHostsOptedIn: (settings: { experimentalWslHosts?: boolean } | undefined) => gate.open && settings?.experimentalWslHosts === true diff --git a/src/main/wsl/wsl-drive-project-new-default.ts b/src/main/wsl/filesystem/wsl-drive-project-new-default.ts similarity index 89% rename from src/main/wsl/wsl-drive-project-new-default.ts rename to src/main/wsl/filesystem/wsl-drive-project-new-default.ts index 8948c38220c..1ed2193b167 100644 --- a/src/main/wsl/wsl-drive-project-new-default.ts +++ b/src/main/wsl/filesystem/wsl-drive-project-new-default.ts @@ -5,17 +5,17 @@ */ import { readdirSync, readFileSync, statSync } from 'node:fs' import { join } from 'node:path' -import { getRepoExecutionHostId, LOCAL_EXECUTION_HOST_ID } from '../../shared/execution-host' +import { getRepoExecutionHostId, LOCAL_EXECUTION_HOST_ID } from '../../../shared/execution-host' import { normalizeGlobalWindowsRuntimeDefault, type LocalWindowsRuntimePreference -} from '../../shared/project-execution-runtime' -import type { GlobalSettings } from '../../shared/global-settings-types' -import type { Project } from '../../shared/project-types' -import { isFolderRepo } from '../../shared/repo-kind' -import type { Repo } from '../../shared/repo-types' -import { isForeignLink } from '../git/worktree-prune-guard' -import { wslHostsOptedIn } from './wsl-host-gate' +} from '../../../shared/project-execution-runtime' +import type { GlobalSettings } from '../../../shared/global-settings-types' +import type { Project } from '../../../shared/project-types' +import { isFolderRepo } from '../../../shared/repo-kind' +import type { Repo } from '../../../shared/repo-types' +import { isForeignLink } from '../../git/worktree-prune-guard' +import { wslHostsOptedIn } from '../wsl-host-gate' export type NewWindowsDriveProjectDefaultArgs = { platform: string diff --git a/src/main/wsl/wsl-drive-project-windows-git.test.ts b/src/main/wsl/filesystem/wsl-drive-project-windows-git.test.ts similarity index 98% rename from src/main/wsl/wsl-drive-project-windows-git.test.ts rename to src/main/wsl/filesystem/wsl-drive-project-windows-git.test.ts index 6c94c7591f1..ac02aead88c 100644 --- a/src/main/wsl/wsl-drive-project-windows-git.test.ts +++ b/src/main/wsl/filesystem/wsl-drive-project-windows-git.test.ts @@ -2,9 +2,9 @@ import { describe, expect, it, vi } from 'vitest' import { resolveProjectExecutionRuntime, type LocalWindowsRuntimePreference -} from '../../shared/project-execution-runtime' -import type { Project } from '../../shared/project-types' -import type { Repo } from '../../shared/repo-types' +} from '../../../shared/project-execution-runtime' +import type { Project } from '../../../shared/project-types' +import type { Repo } from '../../../shared/repo-types' import { convertWslDriveProjectToWindowsGit, previewWslDriveProjectWindowsGit, diff --git a/src/main/wsl/wsl-drive-project-windows-git.ts b/src/main/wsl/filesystem/wsl-drive-project-windows-git.ts similarity index 92% rename from src/main/wsl/wsl-drive-project-windows-git.ts rename to src/main/wsl/filesystem/wsl-drive-project-windows-git.ts index 7d62f67621b..f28639e68ce 100644 --- a/src/main/wsl/wsl-drive-project-windows-git.ts +++ b/src/main/wsl/filesystem/wsl-drive-project-windows-git.ts @@ -4,17 +4,17 @@ * runs Git changes. Refused when Windows Git couldn't safely own the repo's worktrees. */ import { win32 } from 'node:path' -import { getRepoExecutionHostId, LOCAL_EXECUTION_HOST_ID } from '../../shared/execution-host' -import type { ProjectExecutionRuntimeResolution } from '../../shared/project-execution-runtime' -import type { Project } from '../../shared/project-types' -import type { Repo } from '../../shared/repo-types' -import { isFolderRepo } from '../../shared/repo-kind' -import { isWslUncPath } from '../../shared/wsl-paths' -import { isForeignLink } from '../git/worktree-prune-guard' +import { getRepoExecutionHostId, LOCAL_EXECUTION_HOST_ID } from '../../../shared/execution-host' +import type { ProjectExecutionRuntimeResolution } from '../../../shared/project-execution-runtime' +import type { Project } from '../../../shared/project-types' +import type { Repo } from '../../../shared/repo-types' +import { isFolderRepo } from '../../../shared/repo-kind' +import { isWslUncPath } from '../../../shared/wsl-paths' +import { isForeignLink } from '../../git/worktree-prune-guard' import type { WslDriveProjectConversionResult, WslDriveProjectPreview -} from '../../shared/wsl-drive-project-types' +} from '../../../shared/wsl-drive-project-types' /** Windows Git only: the runner never routes through WSL. */ export type WindowsGitRunner = (args: string[], cwd: string) => Promise diff --git a/src/main/wsl/wsl-drive-unc-conversion-journal.ts b/src/main/wsl/filesystem/wsl-drive-unc-conversion-journal.ts similarity index 95% rename from src/main/wsl/wsl-drive-unc-conversion-journal.ts rename to src/main/wsl/filesystem/wsl-drive-unc-conversion-journal.ts index a09d010c0b4..d3b2930c07d 100644 --- a/src/main/wsl/wsl-drive-unc-conversion-journal.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-conversion-journal.ts @@ -7,8 +7,8 @@ * - `prepared`: nothing outside the journal changed yet; a failed profile rewrite drops the record. * - `profile-rewritten`: the profile names the drive paths; the other stores only go forward. */ -import { isRecord } from '../../shared/orcad-migration/orcad-migration-manifest-fields' -import { createMigrationJournalDirectory } from '../persistence/migrating-orcad-catalog/migration-journal-directory' +import { isRecord } from '../../../shared/orcad-migration/orcad-migration-manifest-fields' +import { createMigrationJournalDirectory } from '../../persistence/migrating-orcad-catalog/migration-journal-directory' export const WSL_DRIVE_UNC_CONVERSION_PHASES = ['prepared', 'profile-rewritten'] as const export type WslDriveUncConversionPhase = (typeof WSL_DRIVE_UNC_CONVERSION_PHASES)[number] diff --git a/src/main/wsl/wsl-drive-unc-conversion-renderer.test.ts b/src/main/wsl/filesystem/wsl-drive-unc-conversion-renderer.test.ts similarity index 100% rename from src/main/wsl/wsl-drive-unc-conversion-renderer.test.ts rename to src/main/wsl/filesystem/wsl-drive-unc-conversion-renderer.test.ts diff --git a/src/main/wsl/wsl-drive-unc-conversion-renderer.ts b/src/main/wsl/filesystem/wsl-drive-unc-conversion-renderer.ts similarity index 94% rename from src/main/wsl/wsl-drive-unc-conversion-renderer.ts rename to src/main/wsl/filesystem/wsl-drive-unc-conversion-renderer.ts index e8ab13d62bf..6c48b275e8d 100644 --- a/src/main/wsl/wsl-drive-unc-conversion-renderer.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-conversion-renderer.ts @@ -6,8 +6,8 @@ import { WSL_DRIVE_UNC_RENDERER_STORE_IDS, type WslDriveUncPendingRendererRewrite -} from '../../shared/wsl-drive-unc-renderer-store-keys' -import type { WslMoveRecordStoreRewrittenResult } from '../../shared/wsl-move/wsl-move-renderer-rewrite-types' +} from '../../../shared/wsl-drive-unc-renderer-store-keys' +import type { WslMoveRecordStoreRewrittenResult } from '../../../shared/wsl-move/wsl-move-renderer-rewrite-types' import { listWslDriveUncConversions, removeWslDriveUncConversion, diff --git a/src/main/wsl/wsl-drive-unc-conversion-run.test.ts b/src/main/wsl/filesystem/wsl-drive-unc-conversion-run.test.ts similarity index 97% rename from src/main/wsl/wsl-drive-unc-conversion-run.test.ts rename to src/main/wsl/filesystem/wsl-drive-unc-conversion-run.test.ts index 5998bf73436..5b6e5d725a1 100644 --- a/src/main/wsl/wsl-drive-unc-conversion-run.test.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-conversion-run.test.ts @@ -2,13 +2,13 @@ import { mkdtempSync, rmSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { getDefaultPersistedState } from '../../shared/constants' -import type { PersistedState } from '../../shared/persisted-state-types' -import type { WslMoveBlocker } from '../../shared/wsl-move/wsl-move-driver-types' +import { getDefaultPersistedState } from '../../../shared/constants' +import type { PersistedState } from '../../../shared/persisted-state-types' +import type { WslMoveBlocker } from '../../../shared/wsl-move/wsl-move-driver-types' import { wslMoveFenceFromCutovers, withWslDriveUncConversions -} from '../persistence/moving-wsl-projects/wsl-move-fence' +} from '../../persistence/moving-wsl-projects/wsl-move-fence' import { listWslDriveUncConversions, writeWslDriveUncConversion diff --git a/src/main/wsl/wsl-drive-unc-conversion-run.ts b/src/main/wsl/filesystem/wsl-drive-unc-conversion-run.ts similarity index 92% rename from src/main/wsl/wsl-drive-unc-conversion-run.ts rename to src/main/wsl/filesystem/wsl-drive-unc-conversion-run.ts index aced1843d7b..aaee1fd4cd6 100644 --- a/src/main/wsl/wsl-drive-unc-conversion-run.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-conversion-run.ts @@ -4,16 +4,16 @@ * journal the conversion and restart. The next startup rewrites everything before the window * opens (wsl-drive-unc-conversion-startup.ts); the woken panes reattach to their renamed sessions. */ -import type { PersistedState } from '../../shared/persisted-state-types' -import { getRepoMainWorktreeId } from '../../shared/worktree/id' +import type { PersistedState } from '../../../shared/persisted-state-types' +import { getRepoMainWorktreeId } from '../../../shared/worktree/id' import type { WslDriveUncConversionBlocker, WslDriveUncConversionRequest, WslDriveUncConversionResult -} from '../../shared/wsl-drive-unc-conversion-types' -import type { WslMoveRefusal } from '../../shared/wsl-move/wsl-move-driver-types' -import type { WslMoveTerminalScope } from '../persistence/moving-wsl-projects/wsl-move-driver-ports' -import { wslMoveRepoPaths } from '../persistence/moving-wsl-projects/wsl-move-scope' +} from '../../../shared/wsl-drive-unc-conversion-types' +import type { WslMoveRefusal } from '../../../shared/wsl-move/wsl-move-driver-types' +import type { WslMoveTerminalScope } from '../../persistence/moving-wsl-projects/wsl-move-driver-ports' +import { wslMoveRepoPaths } from '../../persistence/moving-wsl-projects/wsl-move-scope' import { listWslDriveUncConversionsForProfile, writeWslDriveUncConversion @@ -27,11 +27,11 @@ import { WslDriveUncKeyCollisionError } from './wsl-drive-unc-identity-rewrite' import { collectWslDriveUncScope, withNestedWslDriveUncProjects, - wslDriveUncDuplicatesSplitBy, - wslUncDrivePathToWindows + wslDriveUncDuplicatesSplitBy } from './wsl-drive-unc-project-scope' +import { wslUncDrivePathToWindows } from '../../../shared/wsl-paths' import { rewriteWslDriveUncState, wslDriveUncRewriteRoots } from './wsl-drive-unc-state-rewrite' -import type { WindowsDriveMount } from '../runtime/wsl-guest-drive-mountinfo' +import type { WindowsDriveMount } from '../../runtime/wsl-guest-drive-mountinfo' export type WslDriveUncConversionRunDeps = Pick< WslDriveProjectDeps, diff --git a/src/main/wsl/wsl-drive-unc-conversion-startup.test.ts b/src/main/wsl/filesystem/wsl-drive-unc-conversion-startup.test.ts similarity index 92% rename from src/main/wsl/wsl-drive-unc-conversion-startup.test.ts rename to src/main/wsl/filesystem/wsl-drive-unc-conversion-startup.test.ts index 13dfed63f3e..405032338ca 100644 --- a/src/main/wsl/wsl-drive-unc-conversion-startup.test.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-conversion-startup.test.ts @@ -2,23 +2,23 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { getDefaultPersistedState } from '../../shared/constants' +import { getDefaultPersistedState } from '../../../shared/constants' import { agentSessionLeaseFixture, agentSessionRecordFixture -} from '../../shared/agent-session/lifecycle/agent-session-record.test-fixture' -import { encodeAgentSessionRecord } from '../../shared/agent-session/lifecycle/agent-session-record-stored-form' -import type { PersistedState } from '../../shared/persisted-state-types' -import { WSL_HOSTS_INTERNAL_GATE_ENV } from '../../shared/wsl-host-internal-gate' -import { getHistorySessionDirName } from '../daemon/history-paths' -import { readProfileProjectTransferState } from '../orca-profiles/profile-project-domain-state' -import { getOrcaProfileStateDatabaseFile } from '../orca-profiles/profile-storage-paths' -import { openProfileStateDatabase } from '../persistence/profile-state/profile-state-database' -import { importProfileStateJson } from '../persistence/profile-state/profile-state-documents' -import Database from '../sqlite/sync-database' -import { loadAgentSessionStoreRows } from '../runtime/agent-session/records/agent-session-record-rows' -import { getAgentSessionConversation } from '../runtime/agent-session/records/agent-session-store-state' -import { hashWorktreeId } from '../pty/history/terminal-history-id' +} from '../../../shared/agent-session/lifecycle/agent-session-record.test-fixture' +import { encodeAgentSessionRecord } from '../../../shared/agent-session/lifecycle/agent-session-record-stored-form' +import type { PersistedState } from '../../../shared/persisted-state-types' +import { WSL_HOSTS_INTERNAL_GATE_ENV } from '../../../shared/wsl-host-internal-gate' +import { getHistorySessionDirName } from '../../daemon/history-paths' +import { readProfileProjectTransferState } from '../../orca-profiles/profile-project-domain-state' +import { getOrcaProfileStateDatabaseFile } from '../../orca-profiles/profile-storage-paths' +import { openProfileStateDatabase } from '../../persistence/profile-state/profile-state-database' +import { importProfileStateJson } from '../../persistence/profile-state/profile-state-documents' +import Database from '../../sqlite/sync-database' +import { loadAgentSessionStoreRows } from '../../runtime/agent-session/records/agent-session-record-rows' +import { getAgentSessionConversation } from '../../runtime/agent-session/records/agent-session-store-state' +import { hashWorktreeId } from '../../pty/history/terminal-history-id' import type * as Journal from './wsl-drive-unc-conversion-journal' import { listWslDriveUncConversions, diff --git a/src/main/wsl/wsl-drive-unc-conversion-startup.ts b/src/main/wsl/filesystem/wsl-drive-unc-conversion-startup.ts similarity index 91% rename from src/main/wsl/wsl-drive-unc-conversion-startup.ts rename to src/main/wsl/filesystem/wsl-drive-unc-conversion-startup.ts index 7eba6587f1f..60c1aee269a 100644 --- a/src/main/wsl/wsl-drive-unc-conversion-startup.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-conversion-startup.ts @@ -7,12 +7,12 @@ import { prepareProfileProjectDomainChanges, type ProfileProjectDomainChanges -} from '../orca-profiles/profile-project-domain-changes' +} from '../../orca-profiles/profile-project-domain-changes' import { readProfileProjectTransferState, writeProfileProjectDomainChanges -} from '../orca-profiles/profile-project-domain-state' -import { migrateProfileProjectTransferParticipant } from '../orca-profiles/profile-project-transfer-migration' +} from '../../orca-profiles/profile-project-domain-state' +import { migrateProfileProjectTransferParticipant } from '../../orca-profiles/profile-project-transfer-migration' import { listWslDriveUncConversionsForProfile, removeWslDriveUncConversion, @@ -23,13 +23,13 @@ import { wslDriveUncConversionStores, type WslDriveUncConversionStore } from './wsl-drive-unc-conversion-stores' -import { wslHostsGateOpen } from './wsl-host-gate' +import { wslHostsGateOpen } from '../wsl-host-gate' import { isWslDriveUncConversionComplete } from './wsl-drive-unc-conversion-renderer' -import { getHistoryRoot, listWslHistoryRoots } from '../pty/history/terminal-history-paths' -import { orchestrationDbFile } from '../runtime/orchestration/db/orchestration-db-file' -import { journalDatabasePath } from '../native-chat/agent-session-journal/journal-host-database' +import { getHistoryRoot, listWslHistoryRoots } from '../../pty/history/terminal-history-paths' +import { orchestrationDbFile } from '../../runtime/orchestration/db/orchestration-db-file' +import { journalDatabasePath } from '../../native-chat/agent-session-journal/journal-host-database' import { rewriteWslDriveUncState } from './wsl-drive-unc-state-rewrite' -import { WSL_DRIVE_UNC_STATE_DISPOSITIONS } from '../../shared/wsl-drive-unc-state-dispositions' +import { WSL_DRIVE_UNC_STATE_DISPOSITIONS } from '../../../shared/wsl-drive-unc-state-dispositions' export type WslDriveUncConversionStartupDeps = { /** Where the journal lives. */ diff --git a/src/main/wsl/wsl-drive-unc-conversion-stores.ts b/src/main/wsl/filesystem/wsl-drive-unc-conversion-stores.ts similarity index 92% rename from src/main/wsl/wsl-drive-unc-conversion-stores.ts rename to src/main/wsl/filesystem/wsl-drive-unc-conversion-stores.ts index 662a843ed78..d3c79679d63 100644 --- a/src/main/wsl/wsl-drive-unc-conversion-stores.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-conversion-stores.ts @@ -5,17 +5,17 @@ */ import { existsSync, readdirSync, readFileSync, renameSync } from 'node:fs' import { join } from 'node:path' -import { PTY_SESSION_ID_SEPARATOR } from '../../shared/pty-session-id-format' -import { isRecord } from '../../shared/orcad-migration/orcad-migration-manifest-fields' -import { getHistorySessionDirName } from '../daemon/history-paths' +import { PTY_SESSION_ID_SEPARATOR } from '../../../shared/pty-session-id-format' +import { isRecord } from '../../../shared/orcad-migration/orcad-migration-manifest-fields' +import { getHistorySessionDirName } from '../../daemon/history-paths' import { durableWriteTempPath, syncDirectoryDurablySync, writeFileDurableSync -} from '../filesystem/durable-file-write' -import { rewriteWslMoveOrchestrationHistoryFile } from '../persistence/moving-wsl-projects/wsl-move-orchestration-history-rewrite' -import Database from '../sqlite/sync-database' -import { hashWorktreeId } from '../pty/history/terminal-history-id' +} from '../../filesystem/durable-file-write' +import { rewriteWslMoveOrchestrationHistoryFile } from '../../persistence/moving-wsl-projects/wsl-move-orchestration-history-rewrite' +import Database from '../../sqlite/sync-database' +import { hashWorktreeId } from '../../pty/history/terminal-history-id' export type WslDriveUncConversionStorePaths = { /** The daemon's `terminal-history`: one folder per terminal session, named by its id. */ diff --git a/src/main/wsl/wsl-drive-unc-discovery-shadows.ts b/src/main/wsl/filesystem/wsl-drive-unc-discovery-shadows.ts similarity index 86% rename from src/main/wsl/wsl-drive-unc-discovery-shadows.ts rename to src/main/wsl/filesystem/wsl-drive-unc-discovery-shadows.ts index 30791febe10..ce9e3c9d851 100644 --- a/src/main/wsl/wsl-drive-unc-discovery-shadows.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-discovery-shadows.ts @@ -4,11 +4,11 @@ * row holds only bookkeeping; dropping it, its identity aliases and its identity-keyed row lets the * converted row, which carries the user's data, take the key. */ -import { LOCAL_EXECUTION_HOST_ID } from '../../shared/execution-host' -import type { PersistedState } from '../../shared/persisted-state-types' -import { DEFAULT_WORKSPACE_STATUS_ID } from '../../shared/workspace-statuses' -import { composeWorktreeHostIdentity } from '../../shared/worktree/host-qualified-identity' -import type { WorktreeMeta } from '../../shared/worktree/meta-types' +import { LOCAL_EXECUTION_HOST_ID } from '../../../shared/execution-host' +import type { PersistedState } from '../../../shared/persisted-state-types' +import { DEFAULT_WORKSPACE_STATUS_ID } from '../../../shared/workspace-statuses' +import { composeWorktreeHostIdentity } from '../../../shared/worktree/host-qualified-identity' +import type { WorktreeMeta } from '../../../shared/worktree/meta-types' // What discovery writes on its own; any other field with a value is the user's. const DISCOVERY_FIELDS: ReadonlySet = new Set([ diff --git a/src/main/wsl/wsl-drive-unc-identity-rewrite.test.ts b/src/main/wsl/filesystem/wsl-drive-unc-identity-rewrite.test.ts similarity index 100% rename from src/main/wsl/wsl-drive-unc-identity-rewrite.test.ts rename to src/main/wsl/filesystem/wsl-drive-unc-identity-rewrite.test.ts diff --git a/src/main/wsl/wsl-drive-unc-identity-rewrite.ts b/src/main/wsl/filesystem/wsl-drive-unc-identity-rewrite.ts similarity index 93% rename from src/main/wsl/wsl-drive-unc-identity-rewrite.ts rename to src/main/wsl/filesystem/wsl-drive-unc-identity-rewrite.ts index efec217ed68..5aecf83188f 100644 --- a/src/main/wsl/wsl-drive-unc-identity-rewrite.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-identity-rewrite.ts @@ -5,20 +5,23 @@ * ids are rebuilt by the export's composite rewriters; user text is never touched. */ import { isDeepStrictEqual } from 'node:util' -import { normalizeRuntimePathForComparison } from '../../shared/cross-platform-path' -import { LOCAL_EXECUTION_HOST_ID, parseExecutionHostId } from '../../shared/execution-host' -import { PTY_SESSION_ID_SEPARATOR } from '../../shared/pty-session-id-format' -import { parseWorkspaceKey } from '../../shared/workspace-scope' -import { getRepoIdFromWorktreeId, WORKTREE_ID_SEPARATOR } from '../../shared/worktree/id' +import { normalizeRuntimePathForComparison } from '../../../shared/cross-platform-path' +import { LOCAL_EXECUTION_HOST_ID, parseExecutionHostId } from '../../../shared/execution-host' +import { + PTY_SESSION_ID_SEPARATOR, + WORKTREE_ID_SEPARATOR +} from '../../../shared/pty-session-id-format' +import { parseWorkspaceKey } from '../../../shared/workspace-scope' +import { getRepoIdFromWorktreeId } from '../../../shared/worktree/id' import { parseEditorFileId, WSL_MOVE_FREE_TEXT_KEYS -} from '../persistence/moving-wsl-projects/wsl-move-canonical-form' +} from '../../persistence/moving-wsl-projects/wsl-move-canonical-form' import { rewriteOrcadMigrationPathValue, type OrcadMigrationPathRewriter -} from '../ssh/orcad-migration-path-rewrite' -import { wslUncDrivePathToWindows } from './wsl-drive-unc-project-scope' +} from '../../ssh/orcad-migration-path-rewrite' +import { wslUncDrivePathToWindows } from '../../../shared/wsl-paths' export type WslDriveUncRewriteScope = { distro: string diff --git a/src/main/wsl/wsl-drive-unc-mounts.ts b/src/main/wsl/filesystem/wsl-drive-unc-mounts.ts similarity index 80% rename from src/main/wsl/wsl-drive-unc-mounts.ts rename to src/main/wsl/filesystem/wsl-drive-unc-mounts.ts index 13c6d8a2737..257a5fc8c74 100644 --- a/src/main/wsl/wsl-drive-unc-mounts.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-mounts.ts @@ -4,16 +4,16 @@ */ import { posix } from 'node:path' import { runProcess } from '@orca/process-host' -import { buildPosixStdoutFence } from '../../shared/posix-stdout-fence' -import { normalizeRuntimePathForComparison } from '../../shared/cross-platform-path' -import { buildWslExecArgs } from '../../shared/wsl-login-shell-command' -import { wslUncPathToLinux } from '../../shared/wsl-paths' +import { buildPosixStdoutFence } from '../../../shared/posix-stdout-fence' +import { normalizeRuntimePathForComparison } from '../../../shared/cross-platform-path' +import { buildWslExecArgs } from '../../../shared/wsl-login-shell-command' +import { wslUncPathToLinux } from '../../../shared/wsl-paths' import { parseWindowsDriveMountInfo, type WindowsDriveMount -} from '../runtime/wsl-guest-drive-mountinfo' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' -import { resolveWslExecutablePath } from './wsl-executable-path' +} from '../../runtime/wsl-guest-drive-mountinfo' +import { resolveWslInteropSpawnCwd } from '../execution/wsl-interop-spawn-directory' +import { resolveWslExecutablePath } from '../execution/wsl-executable-path' const READ_TIMEOUT_MS = 10_000 diff --git a/src/main/wsl/wsl-drive-unc-project-scope.test.ts b/src/main/wsl/filesystem/wsl-drive-unc-project-scope.test.ts similarity index 95% rename from src/main/wsl/wsl-drive-unc-project-scope.test.ts rename to src/main/wsl/filesystem/wsl-drive-unc-project-scope.test.ts index 915d6bf7169..336f08746b2 100644 --- a/src/main/wsl/wsl-drive-unc-project-scope.test.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-project-scope.test.ts @@ -1,12 +1,9 @@ import { describe, expect, it } from 'vitest' -import type { FolderWorkspace } from '../../shared/folder-workspace-types' -import type { Repo } from '../../shared/repo-types' -import type { WindowsDriveMount } from '../runtime/wsl-guest-drive-mountinfo' -import { - collectWslDriveUncScope, - wslDriveUncWorktreeId, - wslUncDrivePathToWindows -} from './wsl-drive-unc-project-scope' +import type { FolderWorkspace } from '../../../shared/folder-workspace-types' +import type { Repo } from '../../../shared/repo-types' +import type { WindowsDriveMount } from '../../runtime/wsl-guest-drive-mountinfo' +import { collectWslDriveUncScope, wslDriveUncWorktreeId } from './wsl-drive-unc-project-scope' +import { wslUncDrivePathToWindows } from '../../../shared/wsl-paths' function repo(id: string, path: string, extra: Partial = {}): Repo { return { id, displayName: id, path, badgeColor: '', addedAt: 0, ...extra } diff --git a/src/main/wsl/wsl-drive-unc-project-scope.ts b/src/main/wsl/filesystem/wsl-drive-unc-project-scope.ts similarity index 92% rename from src/main/wsl/wsl-drive-unc-project-scope.ts rename to src/main/wsl/filesystem/wsl-drive-unc-project-scope.ts index 9306b6f036a..e6414df072d 100644 --- a/src/main/wsl/wsl-drive-unc-project-scope.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-project-scope.ts @@ -3,18 +3,17 @@ * the mover refuses: D1c converts each in place to the same folder's drive path (`C:\x`) on this * computer. This is the scope and the path map; nothing here writes. */ -import { getRepoExecutionHostId, LOCAL_EXECUTION_HOST_ID } from '../../shared/execution-host' -import { resolveFolderWorkspaceHost } from '../../shared/folder-workspace-execution-host' -import type { FolderWorkspace } from '../../shared/folder-workspace-types' -import type { ProjectGroup } from '../../shared/project-group-types' -import type { Repo } from '../../shared/repo-types' -import { normalizeRuntimePathForComparison } from '../../shared/cross-platform-path' -import { rewriteWorktreeIdPath } from '../../shared/worktree/id' -import { wslUncDrivePathToWindows } from '../../shared/wsl-paths' +import { getRepoExecutionHostId, LOCAL_EXECUTION_HOST_ID } from '../../../shared/execution-host' +import { resolveFolderWorkspaceHost } from '../../../shared/folder-workspace-execution-host' +import type { FolderWorkspace } from '../../../shared/folder-workspace-types' +import type { ProjectGroup } from '../../../shared/project-group-types' +import type { Repo } from '../../../shared/repo-types' +import { normalizeRuntimePathForComparison } from '../../../shared/cross-platform-path' +import { rewriteWorktreeIdPath } from '../../../shared/worktree/id' +import { wslUncDrivePathToWindows } from '../../../shared/wsl-paths' -export { wslUncDrivePathToWindows } -import { wslMoveRepoPaths } from '../persistence/moving-wsl-projects/wsl-move-scope' -import type { WindowsDriveMount } from '../runtime/wsl-guest-drive-mountinfo' +import { wslMoveRepoPaths } from '../../persistence/moving-wsl-projects/wsl-move-scope' +import type { WindowsDriveMount } from '../../runtime/wsl-guest-drive-mountinfo' import { wslUncPathIsWindowsDriveFolder } from './wsl-drive-unc-mounts' export type WslDriveUncRefusal = diff --git a/src/main/wsl/wsl-drive-unc-state-rewrite.test.ts b/src/main/wsl/filesystem/wsl-drive-unc-state-rewrite.test.ts similarity index 95% rename from src/main/wsl/wsl-drive-unc-state-rewrite.test.ts rename to src/main/wsl/filesystem/wsl-drive-unc-state-rewrite.test.ts index e334971b0d8..c88baabf378 100644 --- a/src/main/wsl/wsl-drive-unc-state-rewrite.test.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-state-rewrite.test.ts @@ -1,15 +1,15 @@ import { describe, expect, it } from 'vitest' -import { getDefaultPersistedState } from '../../shared/constants' -import type { PersistedState } from '../../shared/persisted-state-types' -import { foldersAndAutomationsWslMoverProfile } from '../persistence/__fixtures__/wsl-mover/wsl-mover-folders-profile' -import { heavyWslMoverProfile } from '../persistence/__fixtures__/wsl-mover/wsl-mover-heavy-profile' +import { getDefaultPersistedState } from '../../../shared/constants' +import type { PersistedState } from '../../../shared/persisted-state-types' +import { foldersAndAutomationsWslMoverProfile } from '../../persistence/__fixtures__/wsl-mover/wsl-mover-folders-profile' +import { heavyWslMoverProfile } from '../../persistence/__fixtures__/wsl-mover/wsl-mover-heavy-profile' import { repo, terminalTab, WSL_MOVER_DISTRO, type WslMoverPaths -} from '../persistence/__fixtures__/wsl-mover/wsl-mover-profile-rows' -import type { WslMoveProjectionInput } from '../persistence/moving-wsl-projects/wsl-move-state-projection' +} from '../../persistence/__fixtures__/wsl-mover/wsl-mover-profile-rows' +import type { WslMoveProjectionInput } from '../../persistence/moving-wsl-projects/wsl-move-state-projection' import { WslDriveUncKeyCollisionError } from './wsl-drive-unc-identity-rewrite' import { rewriteWslDriveUncState } from './wsl-drive-unc-state-rewrite' diff --git a/src/main/wsl/wsl-drive-unc-state-rewrite.ts b/src/main/wsl/filesystem/wsl-drive-unc-state-rewrite.ts similarity index 89% rename from src/main/wsl/wsl-drive-unc-state-rewrite.ts rename to src/main/wsl/filesystem/wsl-drive-unc-state-rewrite.ts index 9f6f23d2721..536957462c5 100644 --- a/src/main/wsl/wsl-drive-unc-state-rewrite.ts +++ b/src/main/wsl/filesystem/wsl-drive-unc-state-rewrite.ts @@ -3,23 +3,23 @@ * that can name one is re-keyed by wsl-drive-unc-identity-rewrite.ts, and the projects switch to * Git for Windows with their terminals still in the distro. Pure; the caller writes the result. */ -import { composeWorktreeHostIdentity } from '../../shared/worktree/host-qualified-identity' -import { LOCAL_EXECUTION_HOST_ID } from '../../shared/execution-host' -import type { PersistedState } from '../../shared/persisted-state-types' -import type { LocalWindowsRuntimePreference } from '../../shared/project-execution-runtime' -import type { Project } from '../../shared/project-types' -import type { WorktreeMeta } from '../../shared/worktree/meta-types' +import { composeWorktreeHostIdentity } from '../../../shared/worktree/host-qualified-identity' +import { LOCAL_EXECUTION_HOST_ID } from '../../../shared/execution-host' +import type { PersistedState } from '../../../shared/persisted-state-types' +import type { LocalWindowsRuntimePreference } from '../../../shared/project-execution-runtime' +import type { Project } from '../../../shared/project-types' +import type { WorktreeMeta } from '../../../shared/worktree/meta-types' import { getRepoMainWorktreeId, splitWorktreeId, splitWorktreeIdForFilesystem -} from '../../shared/worktree/id' -import { PTY_SESSION_ID_SEPARATOR } from '../../shared/pty-session-id-format' -import { parseWorkspaceKey } from '../../shared/workspace-scope' -import { WSL_DRIVE_UNC_STATE_DISPOSITIONS } from '../../shared/wsl-drive-unc-state-dispositions' -import { wslMoveRepoPaths } from '../persistence/moving-wsl-projects/wsl-move-scope' +} from '../../../shared/worktree/id' +import { PTY_SESSION_ID_SEPARATOR } from '../../../shared/pty-session-id-format' +import { parseWorkspaceKey } from '../../../shared/workspace-scope' +import { WSL_DRIVE_UNC_STATE_DISPOSITIONS } from '../../../shared/wsl-drive-unc-state-dispositions' +import { wslMoveRepoPaths } from '../../persistence/moving-wsl-projects/wsl-move-scope' import { withoutDiscoveryShadows } from './wsl-drive-unc-discovery-shadows' -import { wslUncDrivePathToWindows } from './wsl-drive-unc-project-scope' +import { wslUncDrivePathToWindows } from '../../../shared/wsl-paths' import { createWslDriveUncRewriter, rewriteWslDriveUncValue, diff --git a/src/main/wsl-running-path-filter.test.ts b/src/main/wsl/filesystem/wsl-running-path-filter.test.ts similarity index 88% rename from src/main/wsl-running-path-filter.test.ts rename to src/main/wsl/filesystem/wsl-running-path-filter.test.ts index 2a82316c371..f6a3034a52d 100644 --- a/src/main/wsl-running-path-filter.test.ts +++ b/src/main/wsl/filesystem/wsl-running-path-filter.test.ts @@ -1,8 +1,8 @@ import { afterEach, describe, expect, it, vi } from 'vitest' import { filterPathsToRunningWslDistrosAsync } from './wsl-running-path-filter' -import { listRunningWslDistrosAsync } from './wsl' +import { listRunningWslDistrosAsync } from '../discovery/distro-catalog' -vi.mock('./wsl', () => ({ listRunningWslDistrosAsync: vi.fn() })) +vi.mock('../discovery/distro-catalog', () => ({ listRunningWslDistrosAsync: vi.fn() })) afterEach(() => { vi.restoreAllMocks() diff --git a/src/main/wsl-running-path-filter.ts b/src/main/wsl/filesystem/wsl-running-path-filter.ts similarity index 82% rename from src/main/wsl-running-path-filter.ts rename to src/main/wsl/filesystem/wsl-running-path-filter.ts index 62455fbf167..e400ce99a33 100644 --- a/src/main/wsl-running-path-filter.ts +++ b/src/main/wsl/filesystem/wsl-running-path-filter.ts @@ -1,5 +1,5 @@ -import { isWslUncPath, parseWslUncPath } from '../shared/wsl-paths' -import { listRunningWslDistrosAsync } from './wsl' +import { isWslUncPath, parseWslUncPath } from '../../../shared/wsl-paths' +import { listRunningWslDistrosAsync } from '../discovery/distro-catalog' export function filterPathsToWslDistros( paths: readonly string[], diff --git a/src/main/wsl-sh-cwd-report.node-pty.test.ts b/src/main/wsl/filesystem/wsl-sh-cwd-report.node-pty.test.ts similarity index 98% rename from src/main/wsl-sh-cwd-report.node-pty.test.ts rename to src/main/wsl/filesystem/wsl-sh-cwd-report.node-pty.test.ts index 7ab41d1ca72..be8252a22bf 100644 --- a/src/main/wsl-sh-cwd-report.node-pty.test.ts +++ b/src/main/wsl/filesystem/wsl-sh-cwd-report.node-pty.test.ts @@ -15,9 +15,9 @@ import { import { tmpdir } from 'node:os' import path from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { buildWslInteractiveLoginShellCommand } from '../shared/wsl-login-shell-command' +import { buildWslInteractiveLoginShellCommand } from '../../../shared/wsl-login-shell-command' import { SH_WSL_ENV_FILE } from './wsl-shell-cwd-report' -import { parseFileUriPath } from './daemon/osc7-file-uri' +import { parseFileUriPath } from '../../daemon/osc7-file-uri' function findOnPath(name: string): string | null { for (const dir of ['/bin', '/usr/bin', '/usr/local/bin', '/opt/homebrew/bin']) { diff --git a/src/main/wsl-shell-cwd-report.test.ts b/src/main/wsl/filesystem/wsl-shell-cwd-report.test.ts similarity index 90% rename from src/main/wsl-shell-cwd-report.test.ts rename to src/main/wsl/filesystem/wsl-shell-cwd-report.test.ts index 896512a6d70..e69bbd645f4 100644 --- a/src/main/wsl-shell-cwd-report.test.ts +++ b/src/main/wsl/filesystem/wsl-shell-cwd-report.test.ts @@ -3,10 +3,10 @@ import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'nod import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { getBashShellReadyRcfileContent } from './providers/local-pty/local-pty-shell-ready-bash-rcfile' -import { getLocalZshWrapperSpec } from './providers/local-pty/local-pty-shell-ready-wrapper-fileset' -import { buildZshStartupHook } from './pty/shell-startup/zsh-startup-wrapper-builder' -import { parseFileUriPath } from './daemon/osc7-file-uri' +import { getBashShellReadyRcfileContent } from '../../providers/local-pty/local-pty-shell-ready-bash-rcfile' +import { getLocalZshWrapperSpec } from '../../providers/local-pty/local-pty-shell-ready-wrapper-fileset' +import { buildZshStartupHook } from '../../pty/shell-startup/zsh-startup-wrapper-builder' +import { parseFileUriPath } from '../../daemon/osc7-file-uri' const hasShell = (shell: string) => process.platform !== 'win32' && spawnSync(shell, ['--version']).status === 0 diff --git a/src/main/wsl-shell-cwd-report.ts b/src/main/wsl/filesystem/wsl-shell-cwd-report.ts similarity index 100% rename from src/main/wsl-shell-cwd-report.ts rename to src/main/wsl/filesystem/wsl-shell-cwd-report.ts diff --git a/src/main/wsl/wsl-unc-access-denied.ts b/src/main/wsl/filesystem/wsl-unc-access-denied.ts similarity index 91% rename from src/main/wsl/wsl-unc-access-denied.ts rename to src/main/wsl/filesystem/wsl-unc-access-denied.ts index fb44421a7bf..af7333b045a 100644 --- a/src/main/wsl/wsl-unc-access-denied.ts +++ b/src/main/wsl/filesystem/wsl-unc-access-denied.ts @@ -4,8 +4,8 @@ * can list a distro's `\home` and `\mnt` but get EPERM inside `\mnt\`. */ import { readdir } from 'node:fs/promises' -import { parseWslUncPath } from '../../shared/wsl-paths' -import { wslHostsOptedIn } from './wsl-host-gate' +import { parseWslUncPath } from '../../../shared/wsl-paths' +import { wslHostsOptedIn } from '../wsl-host-gate' /** The message to show instead of "not a git repository"; null when access wasn't the problem. */ export async function describeWslUncAccessDenied( diff --git a/src/main/wsl/wsl-unc-access-gate-user-act.test.ts b/src/main/wsl/filesystem/wsl-unc-access-gate-user-act.test.ts similarity index 81% rename from src/main/wsl/wsl-unc-access-gate-user-act.test.ts rename to src/main/wsl/filesystem/wsl-unc-access-gate-user-act.test.ts index d15410837e6..9a6c9b5738b 100644 --- a/src/main/wsl/wsl-unc-access-gate-user-act.test.ts +++ b/src/main/wsl/filesystem/wsl-unc-access-gate-user-act.test.ts @@ -1,14 +1,14 @@ import { describe, expect, it, vi } from 'vitest' -import type * as BackgroundDistroGateModule from '../wsl-background-distro-gate' +import type * as BackgroundDistroGateModule from '../discovery/wsl-background-distro-gate' const mocks = vi.hoisted(() => ({ noteWslDistroWoken: vi.fn() })) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), noteWslDistroWoken: mocks.noteWslDistroWoken })) import { runAsWslUserAct } from './wsl-unc-access-gate' -import { isWslUserActFor } from './wsl-user-act-scope' +import { isWslUserActFor } from '../discovery/wsl-user-act-scope' describe('runAsWslUserAct marks the distro woken when the act settles', () => { it.each([ diff --git a/src/main/wsl/wsl-unc-access-gate.test.ts b/src/main/wsl/filesystem/wsl-unc-access-gate.test.ts similarity index 96% rename from src/main/wsl/wsl-unc-access-gate.test.ts rename to src/main/wsl/filesystem/wsl-unc-access-gate.test.ts index 702551c4b9e..f1abb9935a8 100644 --- a/src/main/wsl/wsl-unc-access-gate.test.ts +++ b/src/main/wsl/filesystem/wsl-unc-access-gate.test.ts @@ -5,13 +5,12 @@ const wslMocks = vi.hoisted(() => ({ vi.fn<(options?: { requireConfirmed?: boolean; startedAfter?: number }) => Promise>(), listWslDistrosAsync: vi.fn<() => Promise>() })) -vi.mock('../wsl', () => wslMocks) +vi.mock('../discovery/distro-catalog', () => wslMocks) import { assertWslUncPathRunning, guardWslUncPathAccess, runAsWslUserAct, - noteWslDistroMayHaveStopped, WSL_UNC_RUNNING_LEASE_MS, WslDistroStoppedError, WslDistroUnverifiableError @@ -20,16 +19,17 @@ import { _resetWslBackgroundDistroGateForTests, deferUntilWslDistroRunning, noteWslDistroLaunched, + noteWslDistroMayHaveStopped, noteWslDistrosRunning, WSL_STOP_SETTLE_MS -} from '../wsl-background-distro-gate' -import { EXIT_SETTLE_MS } from './wsl-orcad-liveness-evidence' -import { isWslUserActFor } from './wsl-user-act-scope' -import { isWslDistroNotRunningRefusal } from '../../shared/wsl-distro-not-running-refusal' +} from '../discovery/wsl-background-distro-gate' +import { EXIT_SETTLE_MS } from '../wsl-orcad-liveness-evidence' +import { isWslUserActFor } from '../discovery/wsl-user-act-scope' +import { isWslDistroNotRunningRefusal } from '../../../shared/wsl-distro-not-running-refusal' import { _resetRunningWslDistroCacheForTests, resolveRunningWslDistros -} from '../wsl-running-distro-cache' +} from '../discovery/wsl-running-distro-cache' const UNC = '\\\\wsl.localhost\\Ubuntu\\home\\me\\project' const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform') diff --git a/src/main/wsl/wsl-unc-access-gate.ts b/src/main/wsl/filesystem/wsl-unc-access-gate.ts similarity index 92% rename from src/main/wsl/wsl-unc-access-gate.ts rename to src/main/wsl/filesystem/wsl-unc-access-gate.ts index 72d838ef3fa..4144d79e350 100644 --- a/src/main/wsl/wsl-unc-access-gate.ts +++ b/src/main/wsl/filesystem/wsl-unc-access-gate.ts @@ -1,17 +1,18 @@ -import { parseWslUncPath } from '../../shared/wsl-paths' +import { parseWslUncPath } from '../../../shared/wsl-paths' import { wslDistroStoppedMessage, wslDistroUnverifiableMessage -} from '../../shared/wsl-distro-not-running-refusal' -import { isWslUserActFor, runAsWslUserAct as runScopedWslUserAct } from './wsl-user-act-scope' +} from '../../../shared/wsl-distro-not-running-refusal' +import { + isWslUserActFor, + runAsWslUserAct as runScopedWslUserAct +} from '../discovery/wsl-user-act-scope' import { noteWslDistroWoken, noteWslDistrosRunning, readWslDistroRunningState, type WslDistroRunningState -} from '../wsl-background-distro-gate' - -export { noteWslDistroMayHaveStopped } from '../wsl-background-distro-gate' +} from '../discovery/wsl-background-distro-gate' // Any 9P touch of `\\wsl.localhost\` boots a stopped distro, so background reads ask first. // Most stops are signalled (watcher or relay exit, or a read that saw it), but one with no Orca diff --git a/src/main/wsl-unc-delete.test.ts b/src/main/wsl/filesystem/wsl-unc-delete.test.ts similarity index 96% rename from src/main/wsl-unc-delete.test.ts rename to src/main/wsl/filesystem/wsl-unc-delete.test.ts index bd86ac2ce6f..17ec0552e26 100644 --- a/src/main/wsl-unc-delete.test.ts +++ b/src/main/wsl/filesystem/wsl-unc-delete.test.ts @@ -7,11 +7,11 @@ const { runProcessMock, wokenMock } = vi.hoisted(() => ({ })) vi.mock('@orca/process-host', () => ({ runProcess: runProcessMock })) -vi.mock('./wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), noteWslDistroWoken: wokenMock })) -vi.mock('./wsl-interop-spawn-directory', () => ({ +vi.mock('../execution/wsl-interop-spawn-directory', () => ({ resolveWslInteropSpawnCwd: () => 'C:\\Windows' })) @@ -20,7 +20,7 @@ function exited(code: number, stderr = ''): ProcessResult { } import { tryDeleteWslUncPath } from './wsl-unc-delete' -import { isWslUserActFor } from './wsl/wsl-user-act-scope' +import { isWslUserActFor } from '../discovery/wsl-user-act-scope' async function withPlatform(platform: NodeJS.Platform, run: () => Promise): Promise { const original = Object.getOwnPropertyDescriptor(process, 'platform') diff --git a/src/main/wsl-unc-delete.ts b/src/main/wsl/filesystem/wsl-unc-delete.ts similarity index 89% rename from src/main/wsl-unc-delete.ts rename to src/main/wsl/filesystem/wsl-unc-delete.ts index c39d3fea346..205c2c3b71a 100644 --- a/src/main/wsl-unc-delete.ts +++ b/src/main/wsl/filesystem/wsl-unc-delete.ts @@ -1,8 +1,8 @@ import { runProcess } from '@orca/process-host' -import { buildWslExecArgs } from '../shared/wsl-login-shell-command' -import { parseWslPath } from './wsl' -import { wslExeFailure, wslExeProcessSpec } from './wsl-exe-process' -import { runAsWslUserAct } from './wsl/wsl-unc-access-gate' +import { buildWslExecArgs } from '../../../shared/wsl-login-shell-command' +import { parseWslPath } from './unc-path-access' +import { wslExeFailure, wslExeProcessSpec } from '../execution/wsl-exe-process' +import { runAsWslUserAct } from './wsl-unc-access-gate' import { containedDeleteCommand, rejectionFromWslDeleteStderr, diff --git a/src/main/wsl-unc-delete.wsl.test.ts b/src/main/wsl/filesystem/wsl-unc-delete.wsl.test.ts similarity index 100% rename from src/main/wsl-unc-delete.wsl.test.ts rename to src/main/wsl/filesystem/wsl-unc-delete.wsl.test.ts diff --git a/src/main/wsl/wsl-unc-drive-file-content.test.ts b/src/main/wsl/filesystem/wsl-unc-drive-file-content.test.ts similarity index 90% rename from src/main/wsl/wsl-unc-drive-file-content.test.ts rename to src/main/wsl/filesystem/wsl-unc-drive-file-content.test.ts index 056f6c20f66..bf59ae778b8 100644 --- a/src/main/wsl/wsl-unc-drive-file-content.test.ts +++ b/src/main/wsl/filesystem/wsl-unc-drive-file-content.test.ts @@ -82,10 +82,10 @@ vi.mock('node:fs/promises', async (importOriginal) => ({ ...fsMock })) -import { readLocalFileContent } from '../ipc/filesystem/filesystem-file-content-inspection' -import { readLocalFileRange } from '../ipc/filesystem/local-file-range-read' -import { writeLocalTextFileWithDiskPrecondition } from '../ipc/filesystem/local-disk-write-precondition' -import { renameLocalPathSerializedByDestination } from '../filesystem/destination-serialized-local-rename' +import { readLocalFileContent } from '../../ipc/filesystem/filesystem-file-content-inspection' +import { readLocalFileRange } from '../../ipc/filesystem/local-file-range-read' +import { writeLocalTextFileWithDiskPrecondition } from '../../ipc/filesystem/local-disk-write-precondition' +import { renameLocalPathSerializedByDestination } from '../../filesystem/destination-serialized-local-rename' const UNC = String.raw`\\wsl.localhost\Ubuntu\mnt\c\src\app` const originalPlatform = process.platform diff --git a/src/main/wsl/wsl-unc-drive-fs-path.test.ts b/src/main/wsl/filesystem/wsl-unc-drive-fs-path.test.ts similarity index 100% rename from src/main/wsl/wsl-unc-drive-fs-path.test.ts rename to src/main/wsl/filesystem/wsl-unc-drive-fs-path.test.ts diff --git a/src/main/wsl/wsl-unc-drive-fs-path.ts b/src/main/wsl/filesystem/wsl-unc-drive-fs-path.ts similarity index 95% rename from src/main/wsl/wsl-unc-drive-fs-path.ts rename to src/main/wsl/filesystem/wsl-unc-drive-fs-path.ts index 35c492922fa..304d863ed6f 100644 --- a/src/main/wsl/wsl-unc-drive-fs-path.ts +++ b/src/main/wsl/filesystem/wsl-unc-drive-fs-path.ts @@ -3,7 +3,7 @@ * answers EPERM (WSL 2.7). The same folder opens through its drive path, `C:\x`. */ import { realpath as fsRealpath } from 'node:fs/promises' -import { parseWslUncPath, toWindowsWslDrivePath } from '../../shared/wsl-paths' +import { parseWslUncPath, toWindowsWslDrivePath } from '../../../shared/wsl-paths' const WSL_UNC_PREFIX = /^[\\/]{2}(?:wsl\.localhost|wsl\$)[\\/][^\\/]+/i const DRIVE_PATH = /^([A-Za-z]):(?:[\\/](.*))?$/ diff --git a/src/main/wsl-fish-history-cleanup.test.ts b/src/main/wsl/history/wsl-fish-history-cleanup.test.ts similarity index 100% rename from src/main/wsl-fish-history-cleanup.test.ts rename to src/main/wsl/history/wsl-fish-history-cleanup.test.ts diff --git a/src/main/wsl-fish-history-cleanup.ts b/src/main/wsl/history/wsl-fish-history-cleanup.ts similarity index 92% rename from src/main/wsl-fish-history-cleanup.ts rename to src/main/wsl/history/wsl-fish-history-cleanup.ts index 0aa37525274..923a28d6557 100644 --- a/src/main/wsl-fish-history-cleanup.ts +++ b/src/main/wsl/history/wsl-fish-history-cleanup.ts @@ -1,6 +1,6 @@ -import { runWslProcess } from './wsl/wsl-runner' -import { isSafeFishHistorySession } from './pty/history/fish-history-session' -import { isWslDistroRunning } from './wsl-background-distro-gate' +import { runWslProcess } from '../execution/wsl-runner' +import { isSafeFishHistorySession } from '../../pty/history/fish-history-session' +import { isWslDistroRunning } from '../discovery/wsl-background-distro-gate' /** Stopped distros must wait for a later cleanup; GC cannot boot them. */ export type WslFishHistoryCleanupOutcome = 'deleted' | 'skipped' | 'distro-stopped' diff --git a/src/main/wsl/wsl-guest-environment.test.ts b/src/main/wsl/wsl-guest-environment.test.ts index 96d51d568c6..182d7905eba 100644 --- a/src/main/wsl/wsl-guest-environment.test.ts +++ b/src/main/wsl/wsl-guest-environment.test.ts @@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' const runProcessMock = vi.hoisted(() => vi.fn()) vi.mock('@orca/process-host', () => ({ runProcess: runProcessMock })) -vi.mock('./wsl-executable-path', () => ({ resolveWslExecutablePath: () => 'wsl.exe' })) +vi.mock('./execution/wsl-executable-path', () => ({ resolveWslExecutablePath: () => 'wsl.exe' })) import { getWslGuestEnvironment, diff --git a/src/main/wsl/wsl-guest-environment.ts b/src/main/wsl/wsl-guest-environment.ts index 048387fdd65..70f107b15e6 100644 --- a/src/main/wsl/wsl-guest-environment.ts +++ b/src/main/wsl/wsl-guest-environment.ts @@ -3,8 +3,8 @@ import { buildWslCapturedLoginShellCommand, buildWslExecArgs } from '../../shared/wsl-login-shell-command' -import { resolveWslExecutablePath } from './wsl-executable-path' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' +import { resolveWslExecutablePath } from './execution/wsl-executable-path' +import { resolveWslInteropSpawnCwd } from './execution/wsl-interop-spawn-directory' /** Cache the distro login environment to retain user PATH without repeated blocking profile/login-shell probes (#14288/#9768). */ diff --git a/src/main/wsl/wsl-guest-pane-processes.test.ts b/src/main/wsl/wsl-guest-pane-processes.test.ts index 5b96d3251b9..20259288b31 100644 --- a/src/main/wsl/wsl-guest-pane-processes.test.ts +++ b/src/main/wsl/wsl-guest-pane-processes.test.ts @@ -1,5 +1,5 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' -import type { WslResult } from './wsl-runner' +import type { WslResult } from './execution/wsl-runner' const isWslDistroRunning = vi.hoisted(() => vi.fn(async (_distro: string) => true)) const runWslProcess = vi.hoisted(() => @@ -12,11 +12,11 @@ const runWslProcess = vi.hoisted(() => })) ) const wasWslDistroLastSeenRunningSettled = vi.hoisted(() => vi.fn((_distro: string) => false)) -vi.mock('../wsl-background-distro-gate', () => ({ +vi.mock('./discovery/wsl-background-distro-gate', () => ({ isWslDistroRunning, wasWslDistroLastSeenRunningSettled })) -vi.mock('./wsl-runner', () => ({ runWslProcess })) +vi.mock('./execution/wsl-runner', () => ({ runWslProcess })) const { parseWslGuestPaneProcesses, diff --git a/src/main/wsl/wsl-guest-pane-processes.ts b/src/main/wsl/wsl-guest-pane-processes.ts index d3d369253da..2f65163fce1 100644 --- a/src/main/wsl/wsl-guest-pane-processes.ts +++ b/src/main/wsl/wsl-guest-pane-processes.ts @@ -3,8 +3,8 @@ import { isShellProcess } from '../../shared/shell-process-detection' import { isWslDistroRunning, wasWslDistroLastSeenRunningSettled -} from '../wsl-background-distro-gate' -import { runWslProcess } from './wsl-runner' +} from './discovery/wsl-background-distro-gate' +import { runWslProcess } from './execution/wsl-runner' export type WslGuestProcessRow = { pid: number diff --git a/src/main/wsl/wsl-guest-process-table.test.ts b/src/main/wsl/wsl-guest-process-table.test.ts index 1f4e9302105..12624ddbd4f 100644 --- a/src/main/wsl/wsl-guest-process-table.test.ts +++ b/src/main/wsl/wsl-guest-process-table.test.ts @@ -1,18 +1,18 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as BackgroundDistroGate from '../wsl-background-distro-gate' +import type * as BackgroundDistroGate from './discovery/wsl-background-distro-gate' const mocks = vi.hoisted(() => ({ runWslProcess: vi.fn(), readWslDistroRunningState: vi.fn() })) -vi.mock('./wsl-runner', () => ({ runWslProcess: mocks.runWslProcess })) -vi.mock('../wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('./execution/wsl-runner', () => ({ runWslProcess: mocks.runWslProcess })) +vi.mock('./discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: mocks.readWslDistroRunningState })) import { readWslGuestProcessTable } from './wsl-guest-process-table' -import { runAsWslUserAct } from './wsl-unc-access-gate' +import { runAsWslUserAct } from './filesystem/wsl-unc-access-gate' describe('readWslGuestProcessTable never boots a stopped distro (E9)', () => { const originalPlatform = process.platform diff --git a/src/main/wsl/wsl-guest-process-table.ts b/src/main/wsl/wsl-guest-process-table.ts index 654d00f8146..04ff77a2140 100644 --- a/src/main/wsl/wsl-guest-process-table.ts +++ b/src/main/wsl/wsl-guest-process-table.ts @@ -7,8 +7,8 @@ import { WSL_GUEST_PANE_PROCESS_SCRIPT, type WslGuestProcessRow } from '../persistence/moving-wsl-projects/wsl-move-guest-foreground' -import { runWslProcess } from './wsl-runner' -import { blockedWslDistroForPath } from './wsl-unc-access-gate' +import { runWslProcess } from './execution/wsl-runner' +import { blockedWslDistroForPath } from './filesystem/wsl-unc-access-gate' const readsInFlight = new Map>() diff --git a/src/main/wsl/wsl-host-add-admission.ts b/src/main/wsl/wsl-host-add-admission.ts index bc5990759f0..bb558326547 100644 --- a/src/main/wsl/wsl-host-add-admission.ts +++ b/src/main/wsl/wsl-host-add-admission.ts @@ -7,7 +7,7 @@ import { type WslHostCopyParams } from '../../shared/wsl-host-failure-copy' import type { WslHostDistroCandidate } from './wsl-host-distro-list' -import { wslDistroHolderKey } from './wsl-distro-holder-record' +import { wslDistroHolderKey } from './discovery/wsl-distro-holder-record' export const WSL_HOSTS_DISABLED_MESSAGE = WSL_HOST_ADD_REFUSAL_COPY.turnedOff export const WSL_HOST_SERVER_FILES_MISSING_MESSAGE = WSL_HOST_ADD_REFUSAL_COPY.serverFilesMissing diff --git a/src/main/wsl/wsl-host-connector.test.ts b/src/main/wsl/wsl-host-connector.test.ts index d7c59bdbc66..3fcec7898a7 100644 --- a/src/main/wsl/wsl-host-connector.test.ts +++ b/src/main/wsl/wsl-host-connector.test.ts @@ -1,6 +1,6 @@ import { expect, it, vi } from 'vitest' import { createWslHostConnector } from './wsl-host-connector' -import type { WslRunningDistrosRead } from '../wsl-background-distro-gate' +import type { WslRunningDistrosRead } from './discovery/wsl-background-distro-gate' import type * as TunnelIdentity from '../managed-server/lifecycle/orcad-managed-tunnel-identity' const mocks = vi.hoisted(() => ({ @@ -22,7 +22,7 @@ vi.mock('./wsl-orcad-connection', async (importOriginal) => ({ isConnecting = mocks.managerIsConnecting } })) -vi.mock('../wsl-background-distro-gate', () => ({ +vi.mock('./discovery/wsl-background-distro-gate', () => ({ // Settled per distro: a list taken while it stops still names it (E9). readSettledConfirmedRunningWslDistros: mocks.readRunning, wasWslDistroLastSeenRunningSettled: mocks.lastSeenRunning, diff --git a/src/main/wsl/wsl-host-connector.ts b/src/main/wsl/wsl-host-connector.ts index 187ab2efa2a..df80f7a93d4 100644 --- a/src/main/wsl/wsl-host-connector.ts +++ b/src/main/wsl/wsl-host-connector.ts @@ -4,15 +4,16 @@ import { createWslOrcadPairingRecovery } from './wsl-orcad-pairing-repair' import { readSettledConfirmedRunningWslDistros, wasWslDistroLastSeenRunningSettled -} from '../wsl-background-distro-gate' +} from './discovery/wsl-background-distro-gate' import { parsePairingCode } from '../../shared/pairing' import { pairedRuntimeConnectionFromOffer } from '../../shared/paired-runtime-connection' import { verifyOrcadPairingIdentity } from '../managed-server/lifecycle/orcad-managed-tunnel-identity' import { resolveEnvironmentPairingOffer } from '../../shared/runtime-environment-store' import { findWslHostDeployment } from '../../shared/runtime-environment-wsl-host-store' -import { createWslDistroHolder, type WslDistroHolder } from './wsl-distro-holder' +import { createWslDistroHolder } from './discovery/wsl-distro-holder' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' import { listWslHostDistros } from './wsl-host-distro-list' -import { resolveWslDistroName } from './wsl-distro-registry-id' +import { resolveWslDistroName } from './discovery/wsl-distro-registry-id' import type { WslHostConnector, WslHostReachability } from './wsl-host-service' import { readWslDistroOrcadPublicKey } from './wsl-host-ssh-orcad-conflict' import { @@ -33,7 +34,7 @@ import { createWslOrcadLivenessSupervisor } from './wsl-orcad-liveness-wiring' import type { WslOrcadLivenessSupervisor } from './wsl-orcad-liveness-supervisor' import { confirmsRunning } from './wsl-orcad-liveness-evidence' import { requireConfirmedRunning } from './wsl-orcad-connection-errors' -import { wslDistroHolderKey } from './wsl-distro-holder-record' +import { wslDistroHolderKey } from './discovery/wsl-distro-holder-record' import { wslHostServerStopReason } from '../../shared/wsl-host-failure-copy' function targetFor(distro: string): WslOrcadHostTarget { diff --git a/src/main/wsl/wsl-host-distro-list.test.ts b/src/main/wsl/wsl-host-distro-list.test.ts index 4998dff2735..207ba25ca6e 100644 --- a/src/main/wsl/wsl-host-distro-list.test.ts +++ b/src/main/wsl/wsl-host-distro-list.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import type { WslDistroRegistration } from './wsl-distro-registry-id' +import type { WslDistroRegistration } from './discovery/wsl-distro-registry-id' import { admitWslHostDistro } from './wsl-host-add-admission' import { listWslHostDistros } from './wsl-host-distro-list' diff --git a/src/main/wsl/wsl-host-distro-list.ts b/src/main/wsl/wsl-host-distro-list.ts index bfedae3c42c..26ea52ace39 100644 --- a/src/main/wsl/wsl-host-distro-list.ts +++ b/src/main/wsl/wsl-host-distro-list.ts @@ -1,11 +1,14 @@ /** List user distros from Lxss (including WSL version), then probe running state without booting any. Exclude Docker internals. */ import type { WslHostDistro } from '../../shared/wsl-host-types' -import { filterUserWslDistros } from '../wsl-distro-list-output' +import { filterUserWslDistros } from './discovery/wsl-distro-list-output' import { readConfirmedRunningWslDistros, type WslRunningDistrosRead -} from '../wsl-background-distro-gate' -import { readWslDistroRegistrations, type WslDistroRegistration } from './wsl-distro-registry-id' +} from './discovery/wsl-background-distro-gate' +import { + readWslDistroRegistrations, + type WslDistroRegistration +} from './discovery/wsl-distro-registry-id' export type WslHostDistroListDependencies = { readRegistrations?: () => Promise diff --git a/src/main/wsl/wsl-host-first-connect.test.ts b/src/main/wsl/wsl-host-first-connect.test.ts index 1228f0ddb71..351c449485f 100644 --- a/src/main/wsl/wsl-host-first-connect.test.ts +++ b/src/main/wsl/wsl-host-first-connect.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it, vi } from 'vitest' -import { WslDistroVersion1Error } from './wsl-distro-unsupported' +import { WslDistroVersion1Error } from './discovery/wsl-distro-unsupported' import { connectForWslHostAdd } from './wsl-host-first-connect' describe('connectForWslHostAdd', () => { diff --git a/src/main/wsl/wsl-host-first-connect.ts b/src/main/wsl/wsl-host-first-connect.ts index 0f8c7b5b70a..2abcbbb77d5 100644 --- a/src/main/wsl/wsl-host-first-connect.ts +++ b/src/main/wsl/wsl-host-first-connect.ts @@ -8,7 +8,7 @@ import { WslDistroNotRegisteredError, WslDistroVersion1Error, wslUnsupportedDistroFixMessage -} from './wsl-distro-unsupported' +} from './discovery/wsl-distro-unsupported' import { wslHostAddRefusal } from './wsl-host-add-admission' import { RemoteNodeRuntimeSelfTestError } from '../ssh/orcad-remote-node-runtime-report' import type { WslOrcadConnection } from './wsl-orcad-connection' diff --git a/src/main/wsl/wsl-host-runtime-call.ts b/src/main/wsl/wsl-host-runtime-call.ts index 87cc3b57e67..f5db23d7c4a 100644 --- a/src/main/wsl/wsl-host-runtime-call.ts +++ b/src/main/wsl/wsl-host-runtime-call.ts @@ -1,7 +1,7 @@ /** E9 for runtime calls: a poll or fetch reaches a WSL host only without booting its distro. */ import { assertWslHostRunAllowed, wslHostRuntimeCallGuard } from './wsl-host-gate' import type { WslHostDeploymentRecord } from '../../shared/wsl-host-deployment-store' -import { deferUntilWslDistroRunning } from '../wsl-background-distro-gate' +import { deferUntilWslDistroRunning } from './discovery/wsl-background-distro-gate' import { rethrowRetryable, settlingConnectFailure } from './wsl-host-connect-failure' import type { WslHostConnector, WslHostServiceDependencies } from './wsl-host-connector-contract' import { wslHostNotConnectedMessage, wslHostStoppedMessage } from './wsl-host-add-admission' diff --git a/src/main/wsl/wsl-host-service.ts b/src/main/wsl/wsl-host-service.ts index a5fb671340d..fff8beb1096 100644 --- a/src/main/wsl/wsl-host-service.ts +++ b/src/main/wsl/wsl-host-service.ts @@ -15,7 +15,7 @@ import type { WslHostStatus } from '../../shared/wsl-host-types' import type { WslHostConnector, WslHostServiceDependencies } from './wsl-host-connector-contract' -import { wslDistroHolderKey } from './wsl-distro-holder-record' +import { wslDistroHolderKey } from './discovery/wsl-distro-holder-record' import { saveWslHostConnection, readWslHostRecordsQuietly, diff --git a/src/main/wsl/wsl-host-uninstall-server-stop.ts b/src/main/wsl/wsl-host-uninstall-server-stop.ts index 1a118a3d13d..c3cb3df8e65 100644 --- a/src/main/wsl/wsl-host-uninstall-server-stop.ts +++ b/src/main/wsl/wsl-host-uninstall-server-stop.ts @@ -5,7 +5,7 @@ import { errorMessage } from '../../shared/error-message' import { quotePosixShell } from '../../shared/shell-argument-quoting' import type { WslHostServerStop } from '../../shared/wsl-host-types' import { execCommand } from '../ssh/remote-exec/remote-exec-command' -import { listRunningWslDistrosAsync } from '../wsl' +import { listRunningWslDistrosAsync } from './discovery/distro-catalog' import { readWslHostRecordsQuietly } from './wsl-host-connection-record' import { decommissionWslHostOrcad, diff --git a/src/main/wsl/wsl-orcad-bridge-activity.ts b/src/main/wsl/wsl-orcad-bridge-activity.ts index bf44a922e50..e5890a31671 100644 --- a/src/main/wsl/wsl-orcad-bridge-activity.ts +++ b/src/main/wsl/wsl-orcad-bridge-activity.ts @@ -6,7 +6,7 @@ */ import type { RemoteCommandChannel } from '../managed-server/install/remote-install-transport' import type { WslOrcadWatch } from './wsl-orcad-watch' -import { noteWslDistroMayHaveStopped } from '../wsl-background-distro-gate' +import { noteWslDistroMayHaveStopped } from './discovery/wsl-background-distro-gate' export type WslOrcadBridgeChannelEvents = { opened(): void diff --git a/src/main/wsl/wsl-orcad-connect-stop-fence.test.ts b/src/main/wsl/wsl-orcad-connect-stop-fence.test.ts index 60a08f12a0d..c4c4515aea0 100644 --- a/src/main/wsl/wsl-orcad-connect-stop-fence.test.ts +++ b/src/main/wsl/wsl-orcad-connect-stop-fence.test.ts @@ -1,8 +1,11 @@ import { describe, expect, it, vi } from 'vitest' -import type { WslDistroGateNote } from '../wsl-background-distro-gate' -import { noteWslDistroMayHaveStopped, noteWslDistroWoken } from '../wsl-background-distro-gate' +import type { WslDistroGateNote } from './discovery/wsl-background-distro-gate' +import { + noteWslDistroMayHaveStopped, + noteWslDistroWoken +} from './discovery/wsl-background-distro-gate' import type { OrcadHostTransport } from '../ssh/orcad-host-transport' -import type { WslDistroHolder } from './wsl-distro-holder-types' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' import { ADOPTED_HOLDER_POLL_MS, fenceHolderOnStop, diff --git a/src/main/wsl/wsl-orcad-connect-stop-fence.ts b/src/main/wsl/wsl-orcad-connect-stop-fence.ts index d993118a479..df677f17d6e 100644 --- a/src/main/wsl/wsl-orcad-connect-stop-fence.ts +++ b/src/main/wsl/wsl-orcad-connect-stop-fence.ts @@ -3,10 +3,10 @@ * commands. A stop heard meanwhile (`wsl --terminate`, a holder exit) fences every later spawn, so * the connect fails instead of booting the distro again. */ -import { onWslDistroGateNote } from '../wsl-background-distro-gate' +import { onWslDistroGateNote } from './discovery/wsl-background-distro-gate' import type { OrcadHostTransport } from '../ssh/orcad-host-transport' -import { wslDistroHolderKey } from './wsl-distro-holder-record' -import type { WslDistroHolder } from './wsl-distro-holder-types' +import { wslDistroHolderKey } from './discovery/wsl-distro-holder-record' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' import { WslDistroNotRunningError } from './wsl-orcad-connection-errors' import type { WslOrcadDeployOptions } from './wsl-orcad-deploy' diff --git a/src/main/wsl/wsl-orcad-connection-errors.ts b/src/main/wsl/wsl-orcad-connection-errors.ts index e5accf7a4de..abca3ffbae4 100644 --- a/src/main/wsl/wsl-orcad-connection-errors.ts +++ b/src/main/wsl/wsl-orcad-connection-errors.ts @@ -1,5 +1,5 @@ -import type { WslRunningDistrosRead } from '../wsl-background-distro-gate' -import { wslDistroHolderKey } from './wsl-distro-holder-record' +import type { WslRunningDistrosRead } from './discovery/wsl-background-distro-gate' +import { wslDistroHolderKey } from './discovery/wsl-distro-holder-record' import type { WslOrcadLaunch } from './wsl-orcad-deploy' import { confirmsRunning } from './wsl-orcad-liveness-evidence' diff --git a/src/main/wsl/wsl-orcad-connection-types.ts b/src/main/wsl/wsl-orcad-connection-types.ts index 5de16051753..c6782bfceb3 100644 --- a/src/main/wsl/wsl-orcad-connection-types.ts +++ b/src/main/wsl/wsl-orcad-connection-types.ts @@ -3,7 +3,7 @@ import type { OrcadTunnelIdentity } from '../managed-server/lifecycle/orcad-mana import type { ServeReadiness } from '../server/serve-readiness' import type { OrcadHostTransport } from '../ssh/orcad-host-transport' import type { StartedPortForward } from '../ssh/port-forwarding/ssh-port-forward-provider' -import type { WslDistroHolder } from './wsl-distro-holder' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' import type { WslOrcadConnectionStatus } from './wsl-orcad-connection-status' import type { WslOrcadDeferredUpdate, diff --git a/src/main/wsl/wsl-orcad-connection.ts b/src/main/wsl/wsl-orcad-connection.ts index c86bab63440..f307e46bf57 100644 --- a/src/main/wsl/wsl-orcad-connection.ts +++ b/src/main/wsl/wsl-orcad-connection.ts @@ -18,7 +18,7 @@ import { wslConnectFailedStatus, type WslOrcadConnectionStatus } from './wsl-orcad-connection-status' -import { wslDistroHolderKey } from './wsl-distro-holder-record' +import { wslDistroHolderKey } from './discovery/wsl-distro-holder-record' import { defaultWslOrcadEnvironmentId, deployAndLaunchWslOrcad, diff --git a/src/main/wsl/wsl-orcad-deploy-app-update.test.ts b/src/main/wsl/wsl-orcad-deploy-app-update.test.ts index c692f4b70b6..8e0608802e0 100644 --- a/src/main/wsl/wsl-orcad-deploy-app-update.test.ts +++ b/src/main/wsl/wsl-orcad-deploy-app-update.test.ts @@ -9,7 +9,7 @@ import { type OrcadActivationRecord } from '../managed-server/activation/orcad-activation-record' import { getRemoteHostPlatform } from '../ssh/ssh-remote-platform' -import type { WslDistroHolder } from './wsl-distro-holder' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' import type { WslOrcadHostTarget } from './wsl-orcad-host-target' const mocks = vi.hoisted(() => ({ diff --git a/src/main/wsl/wsl-orcad-deploy.test.ts b/src/main/wsl/wsl-orcad-deploy.test.ts index e5d888cf194..b2a6b5258d2 100644 --- a/src/main/wsl/wsl-orcad-deploy.test.ts +++ b/src/main/wsl/wsl-orcad-deploy.test.ts @@ -7,7 +7,7 @@ import { emptyOrcadActivationRecord } from '../managed-server/activation/orcad-a import { getRemoteHostPlatform } from '../ssh/ssh-remote-platform' import { OrcadActiveReadinessError } from '../ssh/orcad-active-readiness' import { WslDistroNotRunningError } from './wsl-orcad-connection-errors' -import type { WslDistroHolder } from './wsl-distro-holder' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' import type { WslOrcadHostTarget } from './wsl-orcad-host-target' const mocks = vi.hoisted(() => ({ diff --git a/src/main/wsl/wsl-orcad-deploy.ts b/src/main/wsl/wsl-orcad-deploy.ts index b8e24039b98..aae1fa47c2f 100644 --- a/src/main/wsl/wsl-orcad-deploy.ts +++ b/src/main/wsl/wsl-orcad-deploy.ts @@ -28,9 +28,10 @@ import { WslDistroNotRunningError } from './wsl-orcad-connection-errors' import { deployOrcad, type OrcadDeployOptions } from '../ssh/orcad-remote-deploy' import { isWslMoveUnderwayOnHost } from '../persistence/moving-wsl-projects/wsl-move-running-moves' import { readLocalFullVersion } from '../managed-server/install/remote-versioned-install' -import { createWslDistroHolder, type WslDistroHolder } from './wsl-distro-holder' -import { wslDistroHolderKey } from './wsl-distro-holder-record' -import { readWslDistroRegistryIdShared } from './wsl-distro-registry-id' +import { createWslDistroHolder } from './discovery/wsl-distro-holder' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' +import { wslDistroHolderKey } from './discovery/wsl-distro-holder-record' +import { readWslDistroRegistryIdShared } from './discovery/wsl-distro-registry-id' import type { WslOrcadHostTarget } from './wsl-orcad-host-target' import { createWslOrcadHostTransport, type WslOrcadHostTransport } from './wsl-orcad-host-transport' import { holdWslDistroWithContext } from './wsl-orcad-held-context' @@ -48,7 +49,7 @@ import { wslOrcadDeferralFailure } from './wsl-orcad-update-admission' import { withOwnBuildLaunchEnv } from './wsl-orcad-own-build-launch-env' -import { WSL_NODE_RUNTIME_DOWNLOAD_BUDGET } from './wsl-node-runtime-download-budget' +import { WSL_NODE_RUNTIME_DOWNLOAD_BUDGET } from './execution/wsl-node-runtime-download-budget' /** An update this app carries that the host may not take yet; the incumbent keeps serving. */ export type WslOrcadDeferredUpdate = WslHostDeferredUpdate diff --git a/src/main/wsl/wsl-orcad-held-context.test.ts b/src/main/wsl/wsl-orcad-held-context.test.ts index 0f9df9e349d..478f924ca62 100644 --- a/src/main/wsl/wsl-orcad-held-context.test.ts +++ b/src/main/wsl/wsl-orcad-held-context.test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import type { OrcadHostTransport } from '../ssh/orcad-host-transport' -import type { WslDistroHolder } from './wsl-distro-holder' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' import type { WslOrcadHostTarget } from './wsl-orcad-host-target' const mocks = vi.hoisted(() => { diff --git a/src/main/wsl/wsl-orcad-held-context.ts b/src/main/wsl/wsl-orcad-held-context.ts index 1333452f8c7..b3887030b83 100644 --- a/src/main/wsl/wsl-orcad-held-context.ts +++ b/src/main/wsl/wsl-orcad-held-context.ts @@ -8,8 +8,8 @@ import { } from '../ssh/ssh-remote-platform-detection' import type { RemoteHostPlatform } from '../ssh/ssh-remote-platform' import { LINUX_LIBC_FIRST_PROBE } from '../node-runtime/linux-libc-probe' -import type { WslDistroHolder } from './wsl-distro-holder' -import { refuseMissingWslDistro, WslDistroVersion1Error } from './wsl-distro-unsupported' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' +import { refuseMissingWslDistro, WslDistroVersion1Error } from './discovery/wsl-distro-unsupported' import type { WslOrcadHostTarget } from './wsl-orcad-host-target' import { createWslOrcadConnectStateReader } from './wsl-orcad-connect-state-snapshot' diff --git a/src/main/wsl/wsl-orcad-host-transport.test.ts b/src/main/wsl/wsl-orcad-host-transport.test.ts index d6843a480b3..bb553530251 100644 --- a/src/main/wsl/wsl-orcad-host-transport.test.ts +++ b/src/main/wsl/wsl-orcad-host-transport.test.ts @@ -4,7 +4,7 @@ import { describe, expect, it, vi } from 'vitest' import type { PipedChildProcess, PipedProcessSpec } from '@orca/process-host/process-spec' import { execCommand } from '../ssh/remote-exec/remote-exec-command' -import { WSL_CHANNEL_CLOSE_GRACE_MS } from './wsl-command-channel' +import { WSL_CHANNEL_CLOSE_GRACE_MS } from './execution/wsl-command-channel' import { createWslOrcadHostTransport } from './wsl-orcad-host-transport' type FakeChild = EventEmitter & { diff --git a/src/main/wsl/wsl-orcad-host-transport.ts b/src/main/wsl/wsl-orcad-host-transport.ts index 7944faf1042..624ee7c80aa 100644 --- a/src/main/wsl/wsl-orcad-host-transport.ts +++ b/src/main/wsl/wsl-orcad-host-transport.ts @@ -10,14 +10,14 @@ import { type SshExecOptions } from '../ssh/connection/ssh-exec-options' import { writeStringViaExecStdin } from '../ssh/ssh-exec-stdin-file-transfer' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' -import { wrapWslCommandProcess } from './wsl-command-channel' -import { WSL_COMMAND_LOOP_ARGV0, WSL_COMMAND_LOOP_SCRIPT } from './wsl-command-loop' -import { createWslCommandLoopPool } from './wsl-command-loop-pool' -import { uploadDirectoryIntoWsl, wslGuestSourcePath } from './wsl-directory-upload' -import { resolveWslExecutablePath } from './wsl-executable-path' -import { noteWslDistroLaunched } from '../wsl-background-distro-gate' -import { readWslDistroRegistryIdShared } from './wsl-distro-registry-id' +import { resolveWslInteropSpawnCwd } from './execution/wsl-interop-spawn-directory' +import { wrapWslCommandProcess } from './execution/wsl-command-channel' +import { WSL_COMMAND_LOOP_ARGV0, WSL_COMMAND_LOOP_SCRIPT } from './execution/wsl-command-loop' +import { createWslCommandLoopPool } from './execution/wsl-command-loop-pool' +import { uploadDirectoryIntoWsl, wslGuestSourcePath } from './filesystem/wsl-directory-upload' +import { resolveWslExecutablePath } from './execution/wsl-executable-path' +import { noteWslDistroLaunched } from './discovery/wsl-background-distro-gate' +import { readWslDistroRegistryIdShared } from './discovery/wsl-distro-registry-id' import { ORCAD_WSL_DISTRO_GUID_ENV } from '../orcad/orcad-migration-wsl-destination' import { ORCAD_IDLE_TIMEOUT_ENV, diff --git a/src/main/wsl/wsl-orcad-liveness-evidence.ts b/src/main/wsl/wsl-orcad-liveness-evidence.ts index d40bb37bf65..ac5610f7685 100644 --- a/src/main/wsl/wsl-orcad-liveness-evidence.ts +++ b/src/main/wsl/wsl-orcad-liveness-evidence.ts @@ -1,5 +1,5 @@ -import type { WslRunningDistrosRead } from '../wsl-background-distro-gate' -import { wslDistroHolderKey } from './wsl-distro-holder-record' +import type { WslRunningDistrosRead } from './discovery/wsl-background-distro-gate' +import { wslDistroHolderKey } from './discovery/wsl-distro-holder-record' import type { WslGuestIdentity } from './wsl-guest-process-identity' import type { Trigger } from './wsl-orcad-liveness-state' import { nextWslLivenessProbe, type WslLivenessEvidence } from './wsl-orcad-liveness-verdict' diff --git a/src/main/wsl/wsl-orcad-liveness-recovery.ts b/src/main/wsl/wsl-orcad-liveness-recovery.ts index 35c7c27f535..07aa9a9d32b 100644 --- a/src/main/wsl/wsl-orcad-liveness-recovery.ts +++ b/src/main/wsl/wsl-orcad-liveness-recovery.ts @@ -1,8 +1,8 @@ /** C4 recovery uses bounded relaunch backoff, then census before publishing terminal verdicts. Recovery is never a user action, so it needs a confirmed-running distro and never boots one (E9). */ import type { OrcadTerminalCensus } from '../../shared/orcad-terminal-census' import { wslHostStatusDetailText } from '../../shared/wsl-host-failure-copy' -import type { WslRunningDistrosRead } from '../wsl-background-distro-gate' -import { wslDistroHolderKey } from './wsl-distro-holder-record' +import type { WslRunningDistrosRead } from './discovery/wsl-background-distro-gate' +import { wslDistroHolderKey } from './discovery/wsl-distro-holder-record' import type { WslOrcadConnection, WslOrcadConnectOptions } from './wsl-orcad-connection' import type { WslOrcadConnectionStatus } from './wsl-orcad-connection-status' import type { WslLivenessVerdict } from './wsl-orcad-liveness-verdict' diff --git a/src/main/wsl/wsl-orcad-liveness-state.ts b/src/main/wsl/wsl-orcad-liveness-state.ts index 59e8423dfcf..1374bc1a602 100644 --- a/src/main/wsl/wsl-orcad-liveness-state.ts +++ b/src/main/wsl/wsl-orcad-liveness-state.ts @@ -1,7 +1,7 @@ import { EXIT_SETTLE_MS } from './wsl-orcad-liveness-evidence' import type { OrcadTerminalCensus } from '../../shared/orcad-terminal-census' import type { SystemPowerLifecycleListener } from '../power/system-power-lifecycle' -import type { WslRunningDistrosRead } from '../wsl-background-distro-gate' +import type { WslRunningDistrosRead } from './discovery/wsl-background-distro-gate' import type { WslGuestIdentity } from './wsl-guest-process-identity' import type { WslOrcadConnection, WslOrcadConnectionManager } from './wsl-orcad-connection' import type { WslOrcadConnectionStatus } from './wsl-orcad-connection-status' diff --git a/src/main/wsl/wsl-orcad-liveness-stopping-poll.ts b/src/main/wsl/wsl-orcad-liveness-stopping-poll.ts index d53caf29e55..1d6147c6b38 100644 --- a/src/main/wsl/wsl-orcad-liveness-stopping-poll.ts +++ b/src/main/wsl/wsl-orcad-liveness-stopping-poll.ts @@ -1,4 +1,4 @@ -import type { WslRunningDistrosRead } from '../wsl-background-distro-gate' +import type { WslRunningDistrosRead } from './discovery/wsl-background-distro-gate' import { confirmsRunning, EXIT_SETTLE_MS } from './wsl-orcad-liveness-evidence' import type { Supervised, WslOrcadLivenessDependencies } from './wsl-orcad-liveness-state' diff --git a/src/main/wsl/wsl-orcad-liveness-supervisor.test.ts b/src/main/wsl/wsl-orcad-liveness-supervisor.test.ts index 60771edfd1f..c3d6f182b56 100644 --- a/src/main/wsl/wsl-orcad-liveness-supervisor.test.ts +++ b/src/main/wsl/wsl-orcad-liveness-supervisor.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from 'vitest' import type { OrcadTerminalCensus } from '../../shared/orcad-terminal-census' import type { SystemPowerLifecycleListener } from '../power/system-power-lifecycle' -import type { WslRunningDistrosRead } from '../wsl-background-distro-gate' +import type { WslRunningDistrosRead } from './discovery/wsl-background-distro-gate' import type { WslGuestIdentity } from './wsl-guest-process-identity' import type { WslOrcadConnection } from './wsl-orcad-connection' import type { WslOrcadConnectionStatus } from './wsl-orcad-connection-status' diff --git a/src/main/wsl/wsl-orcad-liveness-supervisor.ts b/src/main/wsl/wsl-orcad-liveness-supervisor.ts index 1a200e82da7..feecd0ebf0a 100644 --- a/src/main/wsl/wsl-orcad-liveness-supervisor.ts +++ b/src/main/wsl/wsl-orcad-liveness-supervisor.ts @@ -3,7 +3,7 @@ import type { WslOrcadConnection } from './wsl-orcad-connection' import { settleExitedDistroRunning } from './wsl-orcad-liveness-stopping-poll' import { isNoBootRefusal } from './wsl-orcad-connection-errors' import type { WslOrcadConnectIntent, WslOrcadConnectionStatus } from './wsl-orcad-connection-status' -import { wslDistroHolderKey } from './wsl-distro-holder-record' +import { wslDistroHolderKey } from './discovery/wsl-distro-holder-record' import { recoverWslOrcad, type WslOrcadRecoveryReason } from './wsl-orcad-liveness-recovery' import { confirmsRunning, gatherWslLivenessEvidence } from './wsl-orcad-liveness-evidence' import { diff --git a/src/main/wsl/wsl-orcad-liveness-wiring.ts b/src/main/wsl/wsl-orcad-liveness-wiring.ts index 5b03d2a4757..f1246d2179f 100644 --- a/src/main/wsl/wsl-orcad-liveness-wiring.ts +++ b/src/main/wsl/wsl-orcad-liveness-wiring.ts @@ -14,8 +14,8 @@ import { subscribeSystemPowerLifecycle } from '../power/system-power-lifecycle' import { deferUntilWslDistroRunning, readSettledConfirmedRunningWslDistros -} from '../wsl-background-distro-gate' -import type { WslDistroHolder } from './wsl-distro-holder' +} from './discovery/wsl-background-distro-gate' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' import { readWslGuestIdentity } from './wsl-guest-process-identity' import type { WslOrcadConnection, WslOrcadConnectionManager } from './wsl-orcad-connection' import { defaultWslOrcadEnvironmentId } from './wsl-orcad-deploy' diff --git a/src/main/wsl/wsl-orcad-midturn-stop-lane.ts b/src/main/wsl/wsl-orcad-midturn-stop-lane.ts index b2bc9ec1859..dee3e999bb1 100644 --- a/src/main/wsl/wsl-orcad-midturn-stop-lane.ts +++ b/src/main/wsl/wsl-orcad-midturn-stop-lane.ts @@ -19,7 +19,7 @@ import type { WslHostStatus } from '../../shared/wsl-host-types' import { claudeSessionIdForOrcaSession } from '../claude/structured/claude-structured-session-id' import { hasOrcadTemplate } from '../orcad/orcad-artifact-materializer' import { packagedClaudeChatScenario } from '../orcad/orcad-structured-chat-scenario' -import { wslDistroHolderKey } from './wsl-distro-holder-record' +import { wslDistroHolderKey } from './discovery/wsl-distro-holder-record' import { wslHostStoppedMessage } from './wsl-host-add-admission' import { wslHostConnectOptions } from './wsl-host-connect-request' import { createWslHostConnector } from './wsl-host-connector' diff --git a/src/main/wsl/wsl-orcad-real-distro-idle-release-lane.test.ts b/src/main/wsl/wsl-orcad-real-distro-idle-release-lane.test.ts index 14f2b6af42c..dbf9a3a489a 100644 --- a/src/main/wsl/wsl-orcad-real-distro-idle-release-lane.test.ts +++ b/src/main/wsl/wsl-orcad-real-distro-idle-release-lane.test.ts @@ -20,18 +20,19 @@ import { parsePairingCode } from '../../shared/pairing' import { sendRemoteRuntimeRequest } from '../../shared/remote-runtime/remote-runtime-client' import { RemoteRuntimeSharedControlConnection } from '../../shared/remote-runtime/control/remote-runtime-shared-control-connection' import { execCommand } from '../ssh/remote-exec/remote-exec-command' -import { readConfirmedRunningWslDistros } from '../wsl-background-distro-gate' +import { readConfirmedRunningWslDistros } from './discovery/wsl-background-distro-gate' import { readWindowsProcessTableFresh } from '../windows/windows-process-table' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' +import { resolveWslInteropSpawnCwd } from './execution/wsl-interop-spawn-directory' import { buildWslExecArgs, buildWslInteractiveLoginShellCommand, buildWslLoginShellCommand } from '../../shared/wsl-login-shell-command' -import { resolveWslExecutablePath } from './wsl-executable-path' -import { createWslDistroHolder, type WslDistroHolder } from './wsl-distro-holder' -import { WSL_DISTRO_HOLDER_POLL_SECONDS } from './wsl-distro-holder-command' -import { wslDistroHolderKey } from './wsl-distro-holder-record' +import { resolveWslExecutablePath } from './execution/wsl-executable-path' +import { createWslDistroHolder } from './discovery/wsl-distro-holder' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' +import { WSL_DISTRO_HOLDER_POLL_SECONDS } from './discovery/wsl-distro-holder-command' +import { wslDistroHolderKey } from './discovery/wsl-distro-holder-record' import { WslOrcadConnectionManager, type WslOrcadConnection } from './wsl-orcad-connection' import { defaultWslOrcadEnvironmentId, deployAndLaunchWslOrcad } from './wsl-orcad-deploy' import { diff --git a/src/main/wsl/wsl-orcad-real-distro-lane.test.ts b/src/main/wsl/wsl-orcad-real-distro-lane.test.ts index d4f3079f483..d4227978100 100644 --- a/src/main/wsl/wsl-orcad-real-distro-lane.test.ts +++ b/src/main/wsl/wsl-orcad-real-distro-lane.test.ts @@ -21,13 +21,14 @@ import { } from '../../shared/orcad-artifacts' import { requestOrcadTerminalCensus } from '../ssh/orcad-terminal-census-client' import { execCommand } from '../ssh/remote-exec/remote-exec-command' -import { readConfirmedRunningWslDistros } from '../wsl-background-distro-gate' +import { readConfirmedRunningWslDistros } from './discovery/wsl-background-distro-gate' import { readWindowsProcessTableFresh } from '../windows/windows-process-table' -import { resolveWslInteropSpawnCwd } from '../wsl-interop-spawn-directory' +import { resolveWslInteropSpawnCwd } from './execution/wsl-interop-spawn-directory' import { RemoteRuntimeSharedControlConnection } from '../../shared/remote-runtime/control/remote-runtime-shared-control-connection' import { WslOrcadBridgeActivity } from './wsl-orcad-bridge-activity' import { listenWslOrcadStdioBridge } from './wsl-orcad-stdio-bridge' -import { createWslDistroHolder, type WslDistroHolder } from './wsl-distro-holder' +import { createWslDistroHolder } from './discovery/wsl-distro-holder' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' import { proveWslStructuredChat } from './wsl-orcad-structured-chat-contract' import { createLaneWslHost, proveWslMidTurnStopAndContinue } from './wsl-orcad-midturn-stop-lane' import { reinstallWslGuestCli, WSL_CHAT_GUEST_BIN } from './wsl-orcad-chat-provider-fixture' @@ -36,9 +37,9 @@ import { WSL_CHAT_WINDOWS_DECOY_AGENTS, WSL_CHAT_WINDOWS_DECOY_DIR } from './wsl-orcad-chat-windows-decoy' -import { WSL_DISTRO_HOLDER_MARKER } from './wsl-distro-holder-command' -import { resolveWslExecutablePath } from './wsl-executable-path' -import { wslDistroHolderKey } from './wsl-distro-holder-record' +import { WSL_DISTRO_HOLDER_MARKER } from './discovery/wsl-distro-holder-command' +import { resolveWslExecutablePath } from './execution/wsl-executable-path' +import { wslDistroHolderKey } from './discovery/wsl-distro-holder-record' import { WslOrcadConnectionManager, type WslOrcadConnection } from './wsl-orcad-connection' import type { WslOrcadConnectionStatus } from './wsl-orcad-connection-status' import { defaultWslOrcadEnvironmentId, deployAndLaunchWslOrcad } from './wsl-orcad-deploy' diff --git a/src/main/wsl/wsl-orcad-stdio-bridge-e9.test.ts b/src/main/wsl/wsl-orcad-stdio-bridge-e9.test.ts index b06725267d6..afad020fac3 100644 --- a/src/main/wsl/wsl-orcad-stdio-bridge-e9.test.ts +++ b/src/main/wsl/wsl-orcad-stdio-bridge-e9.test.ts @@ -30,11 +30,11 @@ vi.mock('@orca/process-host', async (importOriginal) => { } }) -import { _resetWslCachesForTests } from '../wsl' +import { _resetWslCachesForTests } from './discovery/distro-catalog' import { _resetWslBackgroundDistroGateForTests, wasWslDistroLastSeenRunningSettled -} from '../wsl-background-distro-gate' +} from './discovery/wsl-background-distro-gate' import { WslOrcadBridgeActivity, wslHostBridgeEvents } from './wsl-orcad-bridge-activity' import { createWslOrcadHostTransport } from './wsl-orcad-host-transport' import { listenWslOrcadStdioBridge } from './wsl-orcad-stdio-bridge' diff --git a/src/main/wsl/wsl-orcad-stdio-bridge.ts b/src/main/wsl/wsl-orcad-stdio-bridge.ts index 9d7f589ae50..0d48e27e7e9 100644 --- a/src/main/wsl/wsl-orcad-stdio-bridge.ts +++ b/src/main/wsl/wsl-orcad-stdio-bridge.ts @@ -10,7 +10,7 @@ import { type OrcadStdioBridgeDependencies } from '../managed-server/lifecycle/orcad-stdio-bridge-provider' import type { StartedPortForward } from '../ssh/port-forwarding/ssh-port-forward-provider' -import { assertWslUncPathRunning } from './wsl-unc-access-gate' +import { assertWslUncPathRunning } from './filesystem/wsl-unc-access-gate' export type WslOrcadStdioBridgeOptions = { environmentId: string diff --git a/src/main/wsl/wsl-orcad-update-move-hold-driver.test.ts b/src/main/wsl/wsl-orcad-update-move-hold-driver.test.ts index 5bcecd8b2e3..9fa2b62f064 100644 --- a/src/main/wsl/wsl-orcad-update-move-hold-driver.test.ts +++ b/src/main/wsl/wsl-orcad-update-move-hold-driver.test.ts @@ -34,7 +34,7 @@ import { } from '../persistence/moving-wsl-projects/wsl-move-running-moves' import { getRemoteHostPlatform } from '../ssh/ssh-remote-platform' import type { OrcadHostTransport } from '../ssh/orcad-host-transport' -import type { WslDistroHolder } from './wsl-distro-holder' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' import type { WslOrcadHostTarget } from './wsl-orcad-host-target' vi.mock('electron', () => ({ diff --git a/src/main/wsl/wsl-orphan-holder-release.test.ts b/src/main/wsl/wsl-orphan-holder-release.test.ts index d86bbdaf737..d9261a35769 100644 --- a/src/main/wsl/wsl-orphan-holder-release.test.ts +++ b/src/main/wsl/wsl-orphan-holder-release.test.ts @@ -8,8 +8,8 @@ import { } from '../../shared/runtime-environment-wsl-host-store' import { encodePairingOffer } from '../../shared/pairing' import { getWslHostDeploymentStorePath } from '../../shared/wsl-host-deployment-store' -import type { WslDistroHolder } from './wsl-distro-holder' -import { wslDistroHolderDirectory } from './wsl-distro-holder-record' +import type { WslDistroHolder } from './discovery/wsl-distro-holder-types' +import { wslDistroHolderDirectory } from './discovery/wsl-distro-holder-record' import { releaseUnwantedWslHolders, wslHolderKeepPolicy } from './wsl-orphan-holder-release' const KEY = Buffer.alloc(32, 7).toString('base64') diff --git a/src/main/wsl/wsl-orphan-holder-release.ts b/src/main/wsl/wsl-orphan-holder-release.ts index 88df06b49c2..bb088543b6c 100644 --- a/src/main/wsl/wsl-orphan-holder-release.ts +++ b/src/main/wsl/wsl-orphan-holder-release.ts @@ -2,15 +2,12 @@ import { existsSync } from 'node:fs' import { readWslHostDeployments } from '../../shared/wsl-host-deployment-store' import { sameWslDistro } from './wsl-host-add-admission' -import { - createWslDistroHolder, - type WslDistroHolder, - type WslDistroHolderAdoption -} from './wsl-distro-holder' +import { createWslDistroHolder } from './discovery/wsl-distro-holder' +import type { WslDistroHolder, WslDistroHolderAdoption } from './discovery/wsl-distro-holder-types' import { listWslDistroHolderRecordDistros, wslDistroHolderDirectory -} from './wsl-distro-holder-record' +} from './discovery/wsl-distro-holder-record' /** * Which holders to keep: none when hosts are off (`keepHostHolders` false); else a host's, re-read per holder so an Add diff --git a/src/main/wsl/wsl-pinned-runtime.ts b/src/main/wsl/wsl-pinned-runtime.ts index b88c93dcfa1..5148369f59b 100644 --- a/src/main/wsl/wsl-pinned-runtime.ts +++ b/src/main/wsl/wsl-pinned-runtime.ts @@ -15,7 +15,7 @@ import { } from '../ssh/orcad-remote-node-runtime-report' import { getRemoteHostPlatform } from '../ssh/ssh-remote-platform' import { isGlibcBelow, PINNED_NODE_GLIBC_FLOOR } from '../ssh/pinned-runtime-host-target' -import type { WslSpec } from './wsl-runner' +import type { WslSpec } from './execution/wsl-runner' const downloads = new Map>() const DOWNLOAD_TIMEOUT_MS = 180_000 diff --git a/src/renderer/src/components/terminal-pane/pty-agent-pane-launch.test.ts b/src/renderer/src/components/terminal-pane/pty-agent-pane-launch.test.ts index 0af714f771c..e9105072542 100644 --- a/src/renderer/src/components/terminal-pane/pty-agent-pane-launch.test.ts +++ b/src/renderer/src/components/terminal-pane/pty-agent-pane-launch.test.ts @@ -104,7 +104,7 @@ vi.mock('../../../../main/pi/titlebar-extension-service', () => vi.mock('../../../../main/pty/shell-startup/pwsh', () => import('../../../../main/ipc/pty/pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../../../main/wsl', async (importOriginal) => +vi.mock('../../../../main/wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../../../../main/ipc/pty/pty-ipc-mock-registry')).wslModuleMock( await importOriginal() ) diff --git a/src/shared/wsl-drive-unc-state-dispositions.ts b/src/shared/wsl-drive-unc-state-dispositions.ts index 69d9b3f4936..0959ea34d7b 100644 --- a/src/shared/wsl-drive-unc-state-dispositions.ts +++ b/src/shared/wsl-drive-unc-state-dispositions.ts @@ -1,6 +1,6 @@ /** * What converting a UNC Windows-drive project to its drive path (D1c) does with each saved field; - * src/main/wsl/wsl-drive-unc-state-rewrite.ts applies it. + * src/main/wsl/filesystem/wsl-drive-unc-state-rewrite.ts applies it. */ import type { PersistedState } from './persisted-state-types' diff --git a/src/wsl-guest/preflight-handler.test.ts b/src/wsl-guest/preflight-handler.test.ts index 92d5524e31f..ff9cb202275 100644 --- a/src/wsl-guest/preflight-handler.test.ts +++ b/src/wsl-guest/preflight-handler.test.ts @@ -1,3 +1,4 @@ +import type * as WslAvailability from '../main/wsl/discovery/wsl-availability' import { beforeEach, describe, expect, it, vi } from 'vitest' import { buildPosixCommandPathLookupScript } from '../shared/posix-command-path-lookup' @@ -28,8 +29,13 @@ vi.mock('child_process', () => { vi.mock('../main/pty/shell-startup/pwsh', () => ({ isPwshAvailableAsync: isPwshAvailableAsyncMock })) -vi.mock('../main/wsl', () => ({ - isWslAvailableAsync: isWslAvailableAsyncMock, +vi.mock('../main/wsl/discovery/wsl-availability', async (importOriginal) => ({ + ...(await importOriginal()), + ...(await (() => ({ + isWslAvailableAsync: isWslAvailableAsyncMock + }))()) +})) +vi.mock('../main/wsl/discovery/distro-catalog', () => ({ listWslDistrosAsync: listWslDistrosAsyncMock })) vi.mock('../main/pty/shell-startup/git-bash', () => ({ diff --git a/src/wsl-guest/preflight-handler.ts b/src/wsl-guest/preflight-handler.ts index 19d7d628696..572deeba25a 100644 --- a/src/wsl-guest/preflight-handler.ts +++ b/src/wsl-guest/preflight-handler.ts @@ -5,7 +5,8 @@ import path, { win32 } from 'node:path' import type { RelayDispatcher } from './dispatcher' import { buildRelayCommandEnv } from './relay-command-env' import { isPwshAvailableAsync } from '../main/pty/shell-startup/pwsh' -import { isWslAvailableAsync, listWslDistrosAsync } from '../main/wsl' +import { isWslAvailableAsync } from '../main/wsl/discovery/wsl-availability' +import { listWslDistrosAsync } from '../main/wsl/discovery/distro-catalog' import { isGitBashAvailable } from '../main/pty/shell-startup/git-bash' import { buildPosixCommandPathLookupScript } from '../shared/posix-command-path-lookup' import { runProcess } from '@orca/process-host' diff --git a/tests/e2e/pty-folder-project-runtime-contract.unit.test.ts b/tests/e2e/pty-folder-project-runtime-contract.unit.test.ts index dda1fac39c5..74fab436d54 100644 --- a/tests/e2e/pty-folder-project-runtime-contract.unit.test.ts +++ b/tests/e2e/pty-folder-project-runtime-contract.unit.test.ts @@ -1,7 +1,7 @@ import { mockPanePtyArgs } from '../../src/renderer/src/components/terminal-pane/pty-connection-test-connect-mock-pane' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type * as React from 'react' -import type * as WslDistroGate from '../../src/main/wsl-background-distro-gate' +import type * as WslDistroGate from '../../src/main/wsl/discovery/wsl-background-distro-gate' import type { PtyApi } from '../../src/preload/api/pty-api' import type { RuntimePtyController } from '../../src/main/runtime/runtime-pty-controller-contract' import type { Project, ProjectHostSetup } from '../../src/shared/project-types' @@ -35,7 +35,10 @@ import { existsSyncMock, wslUncDirectoryExistsAsyncMock } from '../../src/main/ipc/pty/pty-ipc-mock-registry' -import { _setWslCachesForTests, _resetWslCachesForTests } from '../../src/main/wsl' +import { + _setWslCachesForTests, + _resetWslCachesForTests +} from '../../src/main/wsl/discovery/distro-catalog' import { createSessionWriteSubscriber, type WorkspaceSessionWrite @@ -75,7 +78,7 @@ vi.mock('@/components/terminal-pane/pty-transport', () => ({ })) // This runtime-selection fixture models a running distro; stopped/unverifiable holds have their own tests. -vi.mock('../../src/main/wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../src/main/wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: vi.fn(async (): Promise<'running'> => 'running') })) @@ -113,7 +116,7 @@ vi.mock('../../src/main/pi/titlebar-extension-service', () => vi.mock('../../src/main/pty/shell-startup/pwsh', () => import('../../src/main/ipc/pty/pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../src/main/wsl', async (importOriginal) => +vi.mock('../../src/main/wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../../src/main/ipc/pty/pty-ipc-mock-registry')).wslModuleMock( await importOriginal() ) diff --git a/tests/e2e/pty-spawn-cwd-folder-owner.unit.test.ts b/tests/e2e/pty-spawn-cwd-folder-owner.unit.test.ts index 523bf6c6c21..eebb69116d3 100644 --- a/tests/e2e/pty-spawn-cwd-folder-owner.unit.test.ts +++ b/tests/e2e/pty-spawn-cwd-folder-owner.unit.test.ts @@ -43,7 +43,7 @@ vi.mock('../../src/main/pi/titlebar-extension-service', () => vi.mock('../../src/main/pty/shell-startup/pwsh', () => import('../../src/main/ipc/pty/pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../src/main/wsl', async (importOriginal) => +vi.mock('../../src/main/wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../../src/main/ipc/pty/pty-ipc-mock-registry')).wslModuleMock( await importOriginal() ) diff --git a/tests/e2e/terminal-account-restart.unit.test.ts b/tests/e2e/terminal-account-restart.unit.test.ts index 4f2aea62cc6..864add28fda 100644 --- a/tests/e2e/terminal-account-restart.unit.test.ts +++ b/tests/e2e/terminal-account-restart.unit.test.ts @@ -44,7 +44,7 @@ vi.mock('../../src/main/pi/titlebar-extension-service', () => vi.mock('../../src/main/pty/shell-startup/pwsh', () => import('../../src/main/ipc/pty/pty-ipc-mock-registry').then((m) => m.pwshModuleMock()) ) -vi.mock('../../src/main/wsl', async (importOriginal) => +vi.mock('../../src/main/wsl/filesystem/unc-path-access', async (importOriginal) => (await import('../../src/main/ipc/pty/pty-ipc-mock-registry')).wslModuleMock( await importOriginal() ) diff --git a/tests/e2e/wsl-drive-unc-conversion.spec.ts b/tests/e2e/wsl-drive-unc-conversion.spec.ts index 953ce57b1da..cf0d5860098 100644 --- a/tests/e2e/wsl-drive-unc-conversion.spec.ts +++ b/tests/e2e/wsl-drive-unc-conversion.spec.ts @@ -20,7 +20,7 @@ import { getHistorySessionDirName } from '../../src/main/daemon/history-paths' import { listWslDriveUncConversions, writeWslDriveUncConversion -} from '../../src/main/wsl/wsl-drive-unc-conversion-journal' +} from '../../src/main/wsl/filesystem/wsl-drive-unc-conversion-journal' import { WSL_HOSTS_INTERNAL_GATE_ENV } from '../../src/shared/wsl-host-internal-gate' test.use({ seedTestRepo: false })