diff --git a/config/scripts/ci-shard-timings.json b/config/scripts/ci-shard-timings.json index e6f313dd663c..9f29e9654182 100644 --- a/config/scripts/ci-shard-timings.json +++ b/config/scripts/ci-shard-timings.json @@ -1175,7 +1175,6 @@ "src/main/ai-vault/scanners/zcode/session-scanner-zcode.test.ts": 515, "src/main/ai-vault/session-scanner.test.ts": 731, "src/main/ai-vault/session-scope-real-paths.test.ts": 62, - "src/main/ai-vault/parse-cache/session-sidecar-stat.test.ts": 59, "src/main/ai-vault/session-titles/session-title-file-reader-wsl-stall.test.ts": 284, "src/main/ai-vault/session-titles/session-title-file-reader.test.ts": 173, "src/main/ai-vault/transcripts/session-transcript-consumers.test.ts": 562, @@ -1467,7 +1466,6 @@ "src/main/browser/cookies/sources/browser-cookie-source-partition.test.ts": 85, "src/main/browser/desktop-browser-bridge/desktop-browser-bridge-executor.test.ts": 163, "src/main/browser/desktop-browser-bridge/desktop-browser-bridge-manager.test.ts": 1258, - "src/main/browser/desktop-browser-bridge/remote-cli-driven-workspaces.test.ts": 241, "src/main/browser/doc-preview-download-block-notice.test.ts": 67, "src/main/browser/doc-preview-failure-notice.test.ts": 45, "src/main/browser/doc-preview-file-reader.test.ts": 4476, @@ -1798,7 +1796,6 @@ "src/main/cli/windows-user-path-registry.test.ts": 49, "src/main/cli/workspace-choice-argv-boundary.test.ts": 293, "src/main/cli/wsl-cli-installer.test.ts": 309, - "src/main/cli/wsl-cli-login-path.test.ts": 231, "src/main/cli/wsl-cli-powershell-boundary.test.ts": 104, "src/main/cli/wsl-cli-registration-operation.test.ts": 96, "src/main/cli/wsl-cli-registration-reconciliation.test.ts": 386, @@ -2541,7 +2538,6 @@ "src/main/git/base-ref-search-selector.test.ts": 257, "src/main/git/branch-rename.test.ts": 66, "src/main/git/canonical-repo-key.test.ts": 221, - "src/main/git/source-control/check-ignored-paths.test.ts": 52, "src/main/git/checkout-branch-identity-real-git.test.ts": 378, "src/main/git/remotes/coalesced-probe.test.ts": 43, "src/main/git/command-runner/exec-file-capture-bytes.test.ts": 4698, @@ -2723,7 +2719,6 @@ "src/main/git/worktrees/content-paths/worktree-shared-directories.test.ts": 1045, "src/main/git/worktrees/sparse-checkout/worktree-sparse-checkout-cache.test.ts": 283, "src/main/git/worktrees/sparse-checkout/worktree-sparse-checkout.test.ts": 851, - "src/main/git/worktrees/sparse-checkout/worktree-sparse-state-host-paths.test.ts": 321, "src/main/git/worktrees/content-paths/worktree-symlink-detection.test.ts": 51, "src/main/git/wsl-direct-git-read-commands.test.ts": 74, "src/main/git/command-runner/wsl-linked-worktree-git-route-invalidation.test.ts": 48, @@ -3060,7 +3055,6 @@ "src/main/ipc/hooks/worktree-hook-inspection-unc-drive.test.ts": 73, "src/main/ipc/hosted-review.test.ts": 743, "src/main/ipc/jira/cancellable-requests.test.ts": 47, - "src/main/ipc/jira/ipc-params.test.ts": 65, "src/main/ipc/jira/issue-summary-generation.test.ts": 127, "src/main/ipc/linear/register-handlers.test.ts": 113, "src/main/ipc/local-file-access-resolution-network-path.test.ts": 284, @@ -3150,7 +3144,6 @@ "src/main/ipc/pty/ipc/codex-shared-server.test.ts": 89, "src/main/ipc/pty/ipc/spawn-commit-run-facts.test.ts": 1661, "src/main/ipc/pty/ipc/spawn-options-codex-isolation.test.ts": 1115, - "src/main/ipc/pty/ipc/spawn-options-spawn-intent.test.ts": 1063, "src/main/ipc/pty/ipc/spawn-push-target-materialization-real-git.test.ts": 1316, "src/main/ipc/pty/ipc/spawn-reattach-size-cache.test.ts": 1459, "src/main/ipc/pty/ipc/terminal-view-attributes-ipc.test.ts": 516, @@ -3494,7 +3487,6 @@ "src/main/kimi/hook-service-mode-read-failure.test.ts": 97, "src/main/kimi/hook-service.test.ts": 113, "src/main/kimi/kimi-hook-config-toml.test.ts": 99, - "src/main/kimi/kimi-runtime-home.test.ts": 69, "src/main/kiro/hook-service.test.ts": 192, "src/main/kiro/standalone-hooks-remote.test.ts": 90, "src/main/kiro/standalone-hooks.test.ts": 121, @@ -4761,7 +4753,6 @@ "src/main/plugins/plugin-uninstall-ordering.test.ts": 4404, "src/main/plugins/plugin-vm-recipe-identities.test.ts": 232, "src/main/plugins/plugin-vm-recipe-registry.test.ts": 349, - "src/main/plugins/view/plugin-host-renderer-actions.test.ts": 58, "src/main/plugins/view/plugin-view-capture.test.ts": 59, "src/main/plugins/view/plugin-view-chrome-shot.test.ts": 156, "src/main/plugins/view/plugin-view-desktop.test.ts": 305, @@ -4793,7 +4784,6 @@ "src/main/ports/darwin-netstat-listeners.test.ts": 89, "src/main/ports/darwin-port-scan-lifetime.test.ts": 63, "src/main/ports/darwin-process-metadata.test.ts": 404, - "src/main/ports/local-workspace-port-attribution-wsl-gate.test.ts": 70, "src/main/ports/local-workspace-port-scanner.test.ts": 328, "src/main/ports/port-scan-command-client.test.ts": 1715, "src/main/ports/port-scan-command-execution.test.ts": 5290, @@ -4803,7 +4793,6 @@ "src/main/ports/workspace-port-page-probe.test.ts": 131, "src/main/pty/shell-startup/powershell-osc133-bootstrap-windows-clm.test.ts": 126, "src/main/preflight/agent-command-detection.test.ts": 188, - "src/main/preflight/codex-cli-installation.test.ts": 83, "src/main/preflight/codex-workspace-relative-path.test.ts": 1493, "src/main/preflight/preflight-wsl-stopped-distro.test.ts": 467, "src/main/preflight/workspace-agent-detection.test.ts": 936, @@ -4817,7 +4806,6 @@ "src/main/workspaces/execution-host/project-runtime-git-options.test.ts": 172, "src/main/workspaces/execution-host/project-runtime-git-router-store.test.ts": 1818, "src/main/workspaces/execution-host/project-runtime-git-router.test.ts": 192, - "src/main/workspaces/execution-host/project-runtime-read-git-options-opt-in.test.ts": 137, "src/main/credentials/protected-secret-persistence-concurrency.test.ts": 68, "src/main/credentials/protected-secret-persistence.test.ts": 53, "src/main/provider-process/managed-provider-process-fallback-tree.test.ts": 150, @@ -4918,7 +4906,6 @@ "src/main/pty/process-retirement/pty-master-foreground-observation.test.ts": 120, "src/main/pty/shell-startup/shell-startup-env.test.ts": 116, "src/main/pty/environment/windows-environment-path.test.ts": 116, - "src/main/pty/environment/windows-path-registry-fallback.test.ts": 49, "src/main/pty/environment/windows-path-registry-reader.test.ts": 44, "src/main/pty/shell-startup/wsl-orca-env.test.ts": 104, "src/main/pty/shell-startup/pwsh.test.ts": 69, @@ -5034,7 +5021,6 @@ "src/main/runtime/agent-session/agent-session-conversation-clear-commit.test.ts": 957, "src/main/runtime/agent-session/agent-session-death-evidence-persistence.test.ts": 1113, "src/main/runtime/agent-session/agent-session-launch-directory.test.ts": 926, - "src/main/runtime/agent-session/agent-session-replaced-runtime.test.ts": 138, "src/main/runtime/agent-session/agent-session-runtime-attribution.test.ts": 1015, "src/main/runtime/agent-session/agent-session-tab-layout.test.ts": 275, "src/main/runtime/agent-session/agent-session-unsaved-creation-supersession.test.ts": 726, @@ -5141,7 +5127,6 @@ "src/main/runtime/browser-screencast-subscription-id.test.ts": 43, "src/main/runtime/browser-session-tab-selection-snapshot.test.ts": 45, "src/main/runtime/browser-tab-create-caller-navigation.test.ts": 4491, - "src/main/runtime/browser-tab-create-folder-workspace.test.ts": 602, "src/main/runtime/browser-tab-create-publication.test.ts": 588, "src/main/runtime/browser/browser-profiles-client-placement.test.ts": 278, "src/main/runtime/browser/browser-screencasts.test.ts": 632, @@ -5687,7 +5672,6 @@ "src/main/runtime/rpc/methods/linear-agent-access.test.ts": 4648, "src/main/runtime/rpc/methods/linear.test.ts": 812, "src/main/runtime/rpc/methods/managed-runtime-install.test.ts": 1315, - "src/main/runtime/rpc/methods/mobile-relay-hosts.test.ts": 614, "src/main/runtime/rpc/methods/mobile-web-bundle-range.test.ts": 3372, "src/main/runtime/rpc/methods/mobile-web-bundle-read-concurrency.test.ts": 837, "src/main/runtime/rpc/methods/mobile-web-bundle-window-refusals.test.ts": 857, @@ -5883,7 +5867,6 @@ "src/main/runtime/rpc/methods/workspace-layout-paired-desktop.test.ts": 27666, "src/main/runtime/rpc/methods/workspace-layout.test.ts": 3391, "src/main/runtime/rpc/methods/worktree-catalog-snapshot-method.test.ts": 1590, - "src/main/runtime/rpc/methods/worktree-create-args.test.ts": 293, "src/main/runtime/rpc/methods/worktree-create-foreign-automation-provenance.test.ts": 1528, "src/main/runtime/rpc/methods/worktree-create-navigation.test.ts": 1652, "src/main/runtime/rpc/methods/worktree-runtime-routing.test.ts": 1735, @@ -6124,7 +6107,6 @@ "src/main/runtime/runtime-search-line-fragments.test.ts": 624, "src/main/runtime/runtime-secondary-visibility-host.test.ts": 3990, "src/main/runtime/runtime-server-environment-commands.test.ts": 262, - "src/main/runtime/runtime-skill-install-authority.test.ts": 102, "src/main/runtime/runtime-skill-install-commands.test.ts": 720, "src/main/runtime/runtime-socket-sweep.test.ts": 47, "src/main/runtime/runtime-sort-order-scan-cache.test.ts": 3537, @@ -6349,7 +6331,6 @@ "src/main/runtime/terminal/stop/exact-terminal-stop-liveness.test.ts": 4321, "src/main/runtime/terminal/stop/hook-status-resume-records.test.ts": 271, "src/main/runtime/terminal/stop/terminal-update-admission.test.ts": 48, - "src/main/runtime/terminal/stop/worktree-sleep-resume-records.test.ts": 45, "src/main/runtime/terminal/surface/closed-pane-exit-cleanup-main.test.ts": 4281, "src/main/runtime/terminal/surface/main-default-pane-acquisition.test.ts": 5812, "src/main/runtime/terminal/surface/main-terminal-acquisition.test.ts": 4330, @@ -6797,7 +6778,6 @@ "src/main/startup/os-opened-document-resolution.test.ts": 74, "src/main/startup/os-opened-documents.test.ts": 67, "src/main/startup/plugin-install-link-state.test.ts": 210, - "src/main/startup/plugin-worktree-lifecycle.test.ts": 1512, "src/main/startup/profile-state-recovery-preflight.test.ts": 696, "src/main/startup/profile-state-save-delay.test.ts": 45, "src/main/startup/profile-state-write-failure.test.ts": 487, @@ -6841,7 +6821,6 @@ "src/main/telemetry/client-deferred-start.test.ts": 8659, "src/main/telemetry/client-lifecycle.test.ts": 206, "src/main/telemetry/client.test.ts": 213, - "src/main/telemetry/cohort-classifier.test.ts": 43, "src/main/telemetry/consent.test.ts": 48, "src/main/telemetry/onboarding-cohort-classifier.test.ts": 51, "src/main/telemetry/onboarding-feature-setup-validator.test.ts": 182, @@ -6861,7 +6840,6 @@ "src/main/text-generation/agent-failure-output.test.ts": 49, "src/main/text-generation/antigravity-generation-stream.test.ts": 479, "src/main/text-generation/command-environment-process.test.ts": 1044, - "src/main/text-generation/command-environment-wsl.test.ts": 219, "src/main/text-generation/commit-message-agent-environment.test.ts": 95, "src/main/text-generation/commit-message-text-generation-branch-name.test.ts": 496, "src/main/text-generation/commit-message-text-generation-cancellation.test.ts": 1171, @@ -7104,13 +7082,10 @@ "src/main/wsl/execution/wsl-guest-process-identity.test.ts": 54, "src/main/wsl/execution/wsl-guest-process-table.test.ts": 146, "src/main/wsl/host-lifecycle/wsl-host-automation-wake.test.ts": 288, - "src/main/wsl/host-lifecycle/wsl-host-connection-record.test.ts": 162, "src/main/wsl/host-lifecycle/wsl-host-connector.test.ts": 826, - "src/main/wsl/host-lifecycle/wsl-host-distro-list.test.ts": 142, "src/main/wsl/host-lifecycle/wsl-host-gate-startup.test.ts": 540, "src/main/wsl/host-lifecycle/wsl-host-gate.test.ts": 156, "src/main/wsl/host-lifecycle/wsl-host-kept-for-peers.test.ts": 159, - "src/main/wsl/host-lifecycle/wsl-host-peer-desktops.test.ts": 103, "src/main/wsl/host-lifecycle/wsl-host-pending-removal.test.ts": 955, "src/main/wsl/host-lifecycle/wsl-host-phone-reach.test.ts": 113, "src/main/wsl/host-lifecycle/wsl-host-server-stop.test.ts": 407, @@ -7140,10 +7115,8 @@ "src/main/wsl/orcad/wsl-orcad-liveness-building-blocks.test.ts": 132, "src/main/wsl/orcad/wsl-orcad-liveness-supervisor.test.ts": 249, "src/main/wsl/orcad/wsl-orcad-liveness-verdict.test.ts": 45, - "src/main/wsl/orcad/wsl-orcad-own-build-launch-env.test.ts": 45, "src/main/wsl/orcad/wsl-orcad-real-distro-idle-release-lane.test.ts": 636, "src/main/wsl/orcad/wsl-orcad-real-distro-lane.test.ts": 1061, - "src/main/wsl/orcad/wsl-orcad-reconnect-backoff.test.ts": 51, "src/main/wsl/orcad/wsl-orcad-stdio-bridge-e9.test.ts": 1203, "src/main/wsl/orcad/wsl-orcad-stdio-bridge.test.ts": 471, "src/main/wsl/orcad/wsl-orcad-update-admission-move-hold.test.ts": 630, @@ -8569,7 +8542,6 @@ "src/renderer/src/components/plugins/presentation/plugin-status-presentation.test.ts": 182, "src/renderer/src/components/plugins/state/plugin-preview-cache.test.ts": 201, "src/renderer/src/components/plugins/state/plugin-theme-apply.test.ts": 2037, - "src/renderer/src/components/plugins/state/plugin-try-action.test.ts": 1697, "src/renderer/src/components/plugins/state/use-plugin-contribution-source.test.tsx": 1935, "src/renderer/src/components/plugins/state/use-plugin-hover-prefetch.test.tsx": 262, "src/renderer/src/components/plugins/state/use-plugin-install-action.test.tsx": 2404, diff --git a/src/main/ai-vault/parse-cache/session-sidecar-stat.test.ts b/src/main/ai-vault/parse-cache/session-sidecar-stat.test.ts deleted file mode 100644 index e93ca2348e40..000000000000 --- a/src/main/ai-vault/parse-cache/session-sidecar-stat.test.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { sidecarUnchanged, type SessionSidecarObservation } from './session-sidecar-stat' - -const META = { path: '/chats/a/meta.json', mtimeMs: 100, sizeBytes: 20 } as const -const OTHER = { path: '/chats/a/meta.json', mtimeMs: 101, sizeBytes: 20 } as const - -type Named = [label: string, value: SessionSidecarObservation | undefined] - -const ENTRIES: Named[] = [ - ['undefined', undefined], - ["'none'", 'none'], - ["'unknown'", 'unknown'], - ['object', { ...META }] -] -const OBSERVED: Named[] = [ - ['undefined', undefined], - ["'none'", 'none'], - ["'unknown'", 'unknown'], - ['same object', { ...META }], - ['different object', { ...OTHER }], - ['different path', { ...META, path: '/chats/b/meta.json' }], - ['different size', { ...META, sizeBytes: 21 }] -] - -// entry (row) x observed (column). A `true` cell is a cache hit. -const TRUTH_TABLE: Record> = { - undefined: { - undefined: true, - "'none'": true, - "'unknown'": false, - 'same object': false, - 'different object': false, - 'different path': false, - 'different size': false - }, - "'none'": { - undefined: true, - "'none'": true, - "'unknown'": false, - 'same object': false, - 'different object': false, - 'different path': false, - 'different size': false - }, - "'unknown'": { - undefined: false, - "'none'": false, - "'unknown'": false, - 'same object': false, - 'different object': false, - 'different path': false, - 'different size': false - }, - object: { - undefined: false, - "'none'": false, - "'unknown'": false, - 'same object': true, - 'different object': false, - 'different path': false, - 'different size': false - } -} - -describe.each(ENTRIES)('cached %s', (entryLabel, entry) => { - it.each(OBSERVED)(`vs observed %s`, (observedLabel, observed) => { - expect(sidecarUnchanged(entry, observed)).toBe(TRUTH_TABLE[entryLabel][observedLabel]) - }) -}) diff --git a/src/main/ai-vault/transcripts/remote-session-content-lines.test.ts b/src/main/ai-vault/transcripts/remote-session-content-lines.test.ts index 68f3ec630d80..a2257cf68575 100644 --- a/src/main/ai-vault/transcripts/remote-session-content-lines.test.ts +++ b/src/main/ai-vault/transcripts/remote-session-content-lines.test.ts @@ -12,25 +12,6 @@ async function collect(content: string, signal: AbortSignal): Promise } describe('remote session content lines', () => { - it.each([ - ['', ['']], - ['\n', ['', '']], - ['one\r\ntwo\n', ['one', 'two', '']], - ['one\rtwo\r', ['one\rtwo']], - ['x'.repeat(300_000), ['x'.repeat(300_000)]], - [`${'x'.repeat(YIELD_CHAR_COUNT + 1)}\ny`, ['x'.repeat(YIELD_CHAR_COUNT + 1), 'y']], - [`${'x'.repeat(YIELD_CHAR_COUNT)}\r\ny`, ['x'.repeat(YIELD_CHAR_COUNT), 'y']], - [`${'x'.repeat(YIELD_CHAR_COUNT * 2)}\ny`, ['x'.repeat(YIELD_CHAR_COUNT * 2), 'y']] - ])('preserves line boundaries for input %#', async (content, expected) => { - expect(await collect(content as string, new AbortController().signal)).toEqual(expected) - }) - - it('rejects an already cancelled scan even for empty content', async () => { - const controller = new AbortController() - controller.abort() - await expect(collect('', controller.signal)).rejects.toThrow() - }) - it.each(['\n'.repeat(400), `${'x'.repeat(300_000)}\nlast`])( 'observes cancellation at an event-loop yield for input %#', async (content) => { diff --git a/src/main/browser/desktop-browser-bridge/remote-cli-driven-workspaces.test.ts b/src/main/browser/desktop-browser-bridge/remote-cli-driven-workspaces.test.ts deleted file mode 100644 index f4f867248e1f..000000000000 --- a/src/main/browser/desktop-browser-bridge/remote-cli-driven-workspaces.test.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { afterEach, describe, expect, it, vi } from 'vitest' - -const owners = vi.hoisted(() => ({ - tabByGuest: new Map(), - worktreeByTab: new Map(), - urlByContents: new Map() -})) - -vi.mock('electron', () => ({ - webContents: { - fromId: (id: number) => { - const url = owners.urlByContents.get(id) - return url === undefined ? undefined : { isDestroyed: () => false, getURL: () => url } - } - } -})) - -vi.mock('../browser-manager', () => ({ - browserManager: { - getOwningTabIdForGuestWebContentsId: (id: number) => owners.tabByGuest.get(id) ?? null, - getWorktreeIdForTab: (tab: string) => owners.worktreeByTab.get(tab) - } -})) - -import { - isRemoteCliDrivenGuest, - markRemoteCliDrivenWorkspace, - resetRemoteCliDrivenWorkspacesForTests -} from './remote-cli-driven-workspaces' - -afterEach(() => { - resetRemoteCliDrivenWorkspacesForTests() - owners.tabByGuest.clear() - owners.worktreeByTab.clear() - owners.urlByContents.clear() -}) - -describe('isRemoteCliDrivenGuest', () => { - it('covers a driven page and the popups it opened, not other workspaces', () => { - owners.tabByGuest.set(1, 'host-page') - owners.tabByGuest.set(2, 'host-page') - owners.tabByGuest.set(3, 'local-page') - owners.worktreeByTab.set('host-page', 'repo-host::/srv/app') - owners.worktreeByTab.set('local-page', 'repo-local::/Users/me/app') - markRemoteCliDrivenWorkspace('repo-host::/srv/app') - - expect(isRemoteCliDrivenGuest(1)).toBe(true) - expect(isRemoteCliDrivenGuest(2)).toBe(true) - expect(isRemoteCliDrivenGuest(3)).toBe(false) - }) - - it('fails closed for a guest whose owning page is unknown once a host drives pages', () => { - markRemoteCliDrivenWorkspace('repo-host::/srv/app') - - expect(isRemoteCliDrivenGuest(99)).toBe(true) - }) - - it("keeps clipboard read for an unowned extension page, which runs only the extension's code", () => { - owners.urlByContents.set(7, `chrome-extension://${'a'.repeat(32)}/offscreen.html`) - owners.urlByContents.set(8, 'https://example.com/') - markRemoteCliDrivenWorkspace('repo-host::/srv/app') - - expect(isRemoteCliDrivenGuest(7)).toBe(false) - expect(isRemoteCliDrivenGuest(8)).toBe(true) - }) -}) diff --git a/src/main/cli/wsl-cli-login-path.test.ts b/src/main/cli/wsl-cli-login-path.test.ts deleted file mode 100644 index e5d3481e9f3f..000000000000 --- a/src/main/cli/wsl-cli-login-path.test.ts +++ /dev/null @@ -1,66 +0,0 @@ -import type { CliInstallStatus } from '../../shared/cli-install-types' -import { beforeEach, describe, expect, it, vi } from 'vitest' - -const runWslProcessMock = vi.hoisted(() => vi.fn()) - -vi.mock('../wsl/execution/wsl-runner', () => ({ - runWslProcess: runWslProcessMock -})) - -import { WslCliInstaller, _internals } from './wsl-cli-installer' - -const launcherPath = 'C:\\Users\\me\\AppData\\Local\\Programs\\Orca\\resources\\bin\\orca.exe' - -function makeHostStatus(): CliInstallStatus { - return { - platform: 'win32', - commandName: 'orca', - commandPath: launcherPath, - pathDirectory: 'C:\\Users\\me\\AppData\\Local\\Programs\\Orca\\resources\\bin', - pathConfigured: true, - launcherPath, - installMethod: 'wrapper', - supported: true, - state: 'installed', - currentTarget: launcherPath, - unsupportedReason: null, - detail: null - } -} - -describe('WslCliInstaller login-PATH lanes', () => { - beforeEach(() => { - runWslProcessMock.mockReset() - }) - - it('reports PATH unknown rather than "not on PATH" without the login PATH', async () => { - const launcher = _internals.buildWslLauncher( - launcherPath, - '/home/alice/.local/share/orca/orca-wsl-bridge.ps1' - ) - runWslProcessMock.mockImplementation(async (spec: { script: string; loginPath: string }) => ({ - environmentResolved: spec.loginPath !== 'preferred', - code: 0, - stdout: spec.script.includes('$HOME') - ? '/home/alice' - : spec.script.includes(':$PATH:') - ? 'no' - : spec.script.includes('wslpath') - ? 'yes' - : spec.script.includes('orca-wsl-bridge.ps1') - ? _internals.buildWslBridgeScript() - : launcher, - stderr: '', - timedOut: false - })) - const installer = new WslCliInstaller({ - platform: 'win32', - distro: 'Ubuntu', - hostInstaller: { getStatus: async () => makeHostStatus() } - }) - - const status = await installer.getStatus() - expect(status).toMatchObject({ state: 'installed', pathConfigured: null }) - expect(status.detail).toContain('login PATH could not be read') - }) -}) diff --git a/src/main/git/source-control/check-ignored-paths.test.ts b/src/main/git/source-control/check-ignored-paths.test.ts deleted file mode 100644 index 0e6ab900ea75..000000000000 --- a/src/main/git/source-control/check-ignored-paths.test.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { beforeEach, describe, expect, it, vi } from 'vitest' -import { checkIgnoredPaths } from './check-ignored-paths' -import { gitExecFileAsync } from '../command-runner/git-exec-file' -import { GIT_CHECK_IGNORE_TIMEOUT_MS } from '../../../shared/git-check-ignore-stdio' - -vi.mock('../command-runner/git-exec-file', async (importOriginal) => ({ - ...(await importOriginal>()), - gitExecFileAsync: vi.fn() -})) - -const gitExecFileAsyncMock = vi.mocked(gitExecFileAsync) - -describe('checkIgnoredPaths', () => { - beforeEach(() => { - gitExecFileAsyncMock.mockReset() - }) - - it('returns ignored paths from git check-ignore output', async () => { - gitExecFileAsyncMock.mockResolvedValue({ stdout: 'dist/bundle.js\0.env\0', stderr: '' }) - - await expect( - checkIgnoredPaths('/repo', ['dist/bundle.js', 'src/index.ts', '.env']) - ).resolves.toEqual(['dist/bundle.js', '.env']) - - expect(gitExecFileAsyncMock).toHaveBeenCalledWith( - ['-c', 'core.quotePath=false', 'check-ignore', '-z', '--stdin'], - { - cwd: '/repo', - stdin: 'dist/bundle.js\0src/index.ts\0.env\0', - timeout: GIT_CHECK_IGNORE_TIMEOUT_MS - } - ) - }) - - it('checks ten thousand paths with one bounded subprocess', async () => { - gitExecFileAsyncMock.mockResolvedValue({ stdout: '', stderr: '' }) - const paths = Array.from({ length: 10_000 }, (_, index) => `generated/file-${index}.js`) - - await expect(checkIgnoredPaths('/repo', paths)).resolves.toEqual([]) - - expect(gitExecFileAsyncMock).toHaveBeenCalledTimes(1) - expect(gitExecFileAsyncMock.mock.calls[0]?.[1]).toMatchObject({ - timeout: GIT_CHECK_IGNORE_TIMEOUT_MS - }) - expect(gitExecFileAsyncMock.mock.calls[0]?.[1].stdin?.split('\0')).toHaveLength(10_001) - }) - - it('treats exit code 1 as no ignored paths', async () => { - gitExecFileAsyncMock.mockRejectedValue(Object.assign(new Error('no matches'), { code: 1 })) - - await expect(checkIgnoredPaths('/repo', ['src/index.ts'])).resolves.toEqual([]) - }) - - it('skips the subprocess for an empty path list', async () => { - await expect(checkIgnoredPaths('/repo', [])).resolves.toEqual([]) - expect(gitExecFileAsyncMock).not.toHaveBeenCalled() - }) -}) diff --git a/src/main/git/worktrees/sparse-checkout/worktree-sparse-state-host-paths.test.ts b/src/main/git/worktrees/sparse-checkout/worktree-sparse-state-host-paths.test.ts deleted file mode 100644 index d3fc16a36829..000000000000 --- a/src/main/git/worktrees/sparse-checkout/worktree-sparse-state-host-paths.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { beforeEach, describe, expect, it, vi } from 'vitest' - -const { readFileMock, statMock } = vi.hoisted(() => ({ - readFileMock: vi.fn(), - statMock: vi.fn() -})) - -vi.mock('node:fs/promises', () => ({ readFile: readFileMock, stat: statMock })) - -import { detectSparseCheckout } from './worktree-sparse-state' - -const slashed = (value: unknown): string => String(value).replaceAll('\\', '/') -const missing = () => Object.assign(new Error('ENOENT'), { code: 'ENOENT' }) - -// A drive-spelled checkout needs the caller's distro to resolve its non-drvfs gitdir pointer. -const HOST_WORKTREE = 'C:/wt/x' -const GUEST_GIT_DIR = '/home/me/repo/.git/worktrees/x' -const HOST_GIT_DIR = '//wsl.localhost/Ubuntu/home/me/repo/.git/worktrees/x' - -describe('detectSparseCheckout on a drvfs-spelled WSL worktree', () => { - beforeEach(() => { - readFileMock.mockReset() - statMock.mockReset() - readFileMock.mockImplementation(async (target: string) => { - const value = slashed(target) - if (value === `${HOST_WORKTREE}/.git`) { - return `gitdir: ${GUEST_GIT_DIR}\n` - } - // Omit commondir to isolate gitdir-pointer resolution. - if (value === `${HOST_GIT_DIR}/config`) { - return '[core]\n\tsparseCheckout = true\n' - } - throw missing() - }) - statMock.mockImplementation(async (target: string) => - slashed(target) === `${HOST_GIT_DIR}/info/sparse-checkout` - ? { isFile: () => true, size: 12 } - : Promise.reject(missing()) - ) - }) - - it('reads the pattern file through the caller-named distro', async () => { - const platformSpy = vi.spyOn(process, 'platform', 'get').mockReturnValue('win32') - - try { - await expect(detectSparseCheckout('/mnt/c/wt/x', { wslDistro: 'Ubuntu' })).resolves.toBe(true) - expect(statMock.mock.calls.map(([target]) => slashed(target))).toContain( - `${HOST_GIT_DIR}/info/sparse-checkout` - ) - } finally { - platformSpy.mockRestore() - } - }) -}) diff --git a/src/main/ipc/jira/ipc-params.test.ts b/src/main/ipc/jira/ipc-params.test.ts deleted file mode 100644 index d43980405383..000000000000 --- a/src/main/ipc/jira/ipc-params.test.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { - clampJiraIssueLimit, - normalizeJiraIssueUpdate, - normalizeJiraSiteId, - normalizeJiraSiteSelection -} from './ipc-params' - -describe('Jira IPC parameters', () => { - it('preserves normalized sites and all-sites selection', () => { - expect(normalizeJiraSiteId(' site-1 ')).toBe('site-1') - expect(normalizeJiraSiteSelection(' all ')).toBe('all') - for (const value of [undefined, null, 1, {}, '', ' ']) { - expect(normalizeJiraSiteSelection(value)).toBeUndefined() - } - }) - - it('bounds issue reads and rejects nonfinite limits', () => { - expect(clampJiraIssueLimit(0)).toBe(1) - expect(clampJiraIssueLimit(1_000_000)).toBe(100) - expect(clampJiraIssueLimit(50)).toBe(50) - for (const value of [undefined, '100', Number.NaN, Infinity, -Infinity]) { - expect(clampJiraIssueLimit(value)).toBe(30) - } - }) - - it('preserves supported issue edits including clears and transition fields', () => { - const updates = { - title: '', - labels: [], - assigneeAccountId: null, - priorityId: null, - transitionId: '31', - transitionFields: { resolution: { id: '1' } }, - transitionComment: 'Verified' - } - expect(normalizeJiraIssueUpdate(updates)).toEqual(updates) - expect( - normalizeJiraIssueUpdate({ labelOperations: { add: ['new'], remove: ['old'] } }) - ).toEqual({ labelOperations: { add: ['new'], remove: ['old'] } }) - expect(normalizeJiraIssueUpdate({})).toEqual({}) - }) - - it.each([ - null, - [], - 'title', - { title: 1 }, - { labels: 'label' }, - { labels: ['label', 1] }, - { assigneeAccountId: {} }, - { priorityId: false }, - { transitionId: null }, - { transitionFields: [] }, - { transitionFields: null }, - { transitionComment: 1 }, - { labelOperations: null }, - { labelOperations: [] }, - { labelOperations: 1 }, - { labelOperations: { add: 'label' } }, - { labelOperations: { remove: [1] } } - ])('rejects malformed edits before they reach Jira: %j', (value) => { - expect(normalizeJiraIssueUpdate(value)).toBeNull() - }) -}) diff --git a/src/main/ipc/pty/ipc/spawn-options-spawn-intent.test.ts b/src/main/ipc/pty/ipc/spawn-options-spawn-intent.test.ts deleted file mode 100644 index 6dd0b11ad163..000000000000 --- a/src/main/ipc/pty/ipc/spawn-options-spawn-intent.test.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { describe, expect, it, vi } from 'vitest' -import { getDefaultSettings } from '../../../../shared/constants' -import { buildPtyIpcSpawnOptions } from './spawn-options' -import { createPtyIpcSpawnState } from './spawn-state' -import type { PtySpawnIpcArgs, PtySpawnIpcDeps } from './spawn-types' - -async function resolveSpawnOptions(args: PtySpawnIpcArgs) { - // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: buildPtyIpcSpawnOptions only reads the members stubbed here; the rest belong to later spawn stages this test never runs. - const deps = { - transitionSpawnHiddenRendererPtyDeliveryState: vi.fn(), - syncPtyBackgroundedDelivery: vi.fn(), - sendPtySpawnedToRenderer: vi.fn(), - getSettings: () => getDefaultSettings('/tmp'), - runtime: { registerPreAllocatedHandleForPty: vi.fn() } - } as unknown as PtySpawnIpcDeps - const ctx = createPtyIpcSpawnState(deps, args) - ctx.env = {} - await buildPtyIpcSpawnOptions(ctx) - return ctx.spawnOptions -} - -async function resolveSpawnIntent(args: PtySpawnIpcArgs): Promise { - return (await resolveSpawnOptions(args)).spawnIntent -} - -const PANE = { cols: 80, rows: 24 } - -describe('renderer pty spawn: declared spawn intent', () => { - it('treats a missing or unknown intent as undeclared', async () => { - await expect(resolveSpawnIntent(PANE)).resolves.toBeUndefined() - await expect(resolveSpawnIntent({ ...PANE, spawnIntent: 'urgent' })).resolves.toBeUndefined() - await expect( - resolveSpawnIntent({ ...PANE, spawnIntent: 'interactive' }) - ).resolves.toBeUndefined() - }) -}) - -describe('renderer pty spawn: a passive restore', () => { - it('forwards only an exact true, which lets the WSL host hold a stopped distro', async () => { - expect( - (await resolveSpawnOptions({ ...PANE, wslPassiveRestore: true })).wslPassiveRestore - ).toBe(true) - expect( - (await resolveSpawnOptions({ ...PANE, wslPassiveRestore: 'yes' })).wslPassiveRestore - ).toBeUndefined() - expect((await resolveSpawnOptions(PANE)).wslPassiveRestore).toBeUndefined() - }) -}) diff --git a/src/main/ipc/wsl-move-reloadable-window.test.ts b/src/main/ipc/wsl-move-reloadable-window.test.ts index 937301471c51..f65531ef13bf 100644 --- a/src/main/ipc/wsl-move-reloadable-window.test.ts +++ b/src/main/ipc/wsl-move-reloadable-window.test.ts @@ -48,13 +48,4 @@ describe('WSL move window reload landing', () => { const relaunched = await openStore() expect(relaunched.getUI().activeView).toBe('terminal') }) - - it('keeps any other view the reload started from', async () => { - const store = await openStore() - store.updateUI({ activeView: 'tasks' }) - - leaveSettingsForWslMoveReload(store) - - expect(store.getUI().activeView).toBe('tasks') - }) }) diff --git a/src/main/kimi/kimi-runtime-home.test.ts b/src/main/kimi/kimi-runtime-home.test.ts deleted file mode 100644 index 5c9fe4050a18..000000000000 --- a/src/main/kimi/kimi-runtime-home.test.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' - -const wslMocks = vi.hoisted(() => ({ - listWslDistrosAsync: vi.fn<() => Promise>(), - listRunningWslDistrosAsync: vi.fn<() => Promise>(), - getWslHomeAsync: vi.fn<(distro: string) => Promise>() -})) - -vi.mock('../wsl/discovery/distro-catalog', () => wslMocks) -vi.mock('node:os', () => ({ homedir: () => 'C:\\Users\\neil' })) - -import { getHostKimiHome, resolveKimiHome } from './kimi-runtime-home' - -describe('resolveKimiHome', () => { - const originalKimiCodeHome = process.env.KIMI_CODE_HOME - - beforeEach(() => { - delete process.env.KIMI_CODE_HOME - wslMocks.listWslDistrosAsync.mockReset().mockResolvedValue(['Ubuntu']) - wslMocks.listRunningWslDistrosAsync.mockReset().mockResolvedValue(['Ubuntu']) - wslMocks.getWslHomeAsync.mockReset().mockResolvedValue('\\\\wsl.localhost\\Ubuntu\\home\\neil') - }) - - afterEach(() => { - if (originalKimiCodeHome === undefined) { - delete process.env.KIMI_CODE_HOME - } else { - process.env.KIMI_CODE_HOME = originalKimiCodeHome - } - }) - - it('ignores the host KIMI_CODE_HOME when reading a WSL home', async () => { - process.env.KIMI_CODE_HOME = 'D:\\kimi-home' - expect((await resolveKimiHome({ runtime: 'wsl', wslDistro: 'Ubuntu' }, 'win32')).path).toBe( - '\\\\wsl.localhost\\Ubuntu\\home\\neil\\.kimi-code' - ) - }) - - it('reports no path without probing the home while the distro is stopped', async () => { - wslMocks.listRunningWslDistrosAsync.mockResolvedValue([]) - expect(await resolveKimiHome({ runtime: 'wsl', wslDistro: 'Ubuntu' }, 'win32')).toEqual({ - runtime: 'wsl', - wslDistro: 'Ubuntu', - path: null - }) - expect(wslMocks.getWslHomeAsync).not.toHaveBeenCalled() - }) - - it('never probes WSL off Windows', async () => { - expect(await resolveKimiHome({ runtime: 'wsl', wslDistro: 'Ubuntu' }, 'darwin')).toEqual({ - runtime: 'host', - wslDistro: null, - path: getHostKimiHome() - }) - expect(wslMocks.listWslDistrosAsync).not.toHaveBeenCalled() - expect(wslMocks.getWslHomeAsync).not.toHaveBeenCalled() - }) -}) diff --git a/src/main/plugins/plugin-runtime-rpc-dispatch.test.ts b/src/main/plugins/plugin-runtime-rpc-dispatch.test.ts index 04958678de38..4e3147abed08 100644 --- a/src/main/plugins/plugin-runtime-rpc-dispatch.test.ts +++ b/src/main/plugins/plugin-runtime-rpc-dispatch.test.ts @@ -27,14 +27,6 @@ function harness() { } describe('pluginRuntimeRpc', () => { - it('runs the CLI method and answers its result', async () => { - const { rpc, ran } = harness() - await expect(rpc('terminal.create', { command: 'ls' })).resolves.toEqual({ - terminal: { handle: 'h' } - }) - expect(ran).toEqual([{ command: 'ls' }]) - }) - it('refuses with the revocation itself when the plugin lost approval before the effect', async () => { const { rpc, ran } = harness() await expect( @@ -58,9 +50,4 @@ describe('pluginRuntimeRpc', () => { await expect(rpc('terminal.create', {}, { signal: cancel.signal })).rejects.toThrow() expect(ran).toEqual([]) }) - - it('carries the runtime error code', async () => { - const { rpc } = harness() - await expect(rpc('terminal.nope', {})).rejects.toMatchObject({ code: expect.any(String) }) - }) }) diff --git a/src/main/plugins/view/plugin-host-renderer-actions.test.ts b/src/main/plugins/view/plugin-host-renderer-actions.test.ts deleted file mode 100644 index 1eeca8009fed..000000000000 --- a/src/main/plugins/view/plugin-host-renderer-actions.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { afterEach, describe, expect, it, vi } from 'vitest' -import { - getPluginHostRendererActions, - setPluginHostRendererRequest -} from './plugin-host-renderer-actions' - -afterEach(() => setPluginHostRendererRequest(null)) - -describe('plugin host renderer actions', () => { - it('are absent in headless serve, and unavailable with no window', async () => { - expect(getPluginHostRendererActions()).toBeNull() - setPluginHostRendererRequest(() => null) - await expect(getPluginHostRendererActions()?.runAction('view.tasks')).rejects.toMatchObject({ - code: 'unavailable' - }) - }) - - it('send open-file and run-action, and map the window refusals', async () => { - const request = vi - .fn() - .mockResolvedValueOnce({ requestId: 'a', ok: true }) - .mockResolvedValueOnce({ requestId: 'b', ok: false, code: 'no_workspace', message: 'none' }) - .mockResolvedValueOnce({ requestId: 'c', ok: false, code: 'renderer_error', message: 'boom' }) - .mockRejectedValueOnce(new Error('renderer_unavailable')) - setPluginHostRendererRequest(request) - const actions = getPluginHostRendererActions()! - await expect(actions.openFile('app', 'src/a.ts')).resolves.toBeUndefined() - expect(request).toHaveBeenCalledWith({ - kind: 'open-file', - worktreeId: 'app', - relativePath: 'src/a.ts' - }) - await expect(actions.runAction('view.tasks')).rejects.toMatchObject({ code: 'unavailable' }) - await expect(actions.runAction('view.tasks')).rejects.toMatchObject({ code: 'action_failed' }) - await expect(actions.runAction('view.tasks')).rejects.toMatchObject({ code: 'unavailable' }) - expect(request).toHaveBeenLastCalledWith({ kind: 'run-action', action: 'view.tasks' }) - request.mockResolvedValueOnce({ requestId: 'd', ok: true }) - await actions.openFolderWorkspace('f1') - expect(request).toHaveBeenLastCalledWith({ - kind: 'open-folder-workspace', - folderWorkspaceId: 'f1' - }) - }) -}) 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 deleted file mode 100644 index dc0b636cedd4..000000000000 --- a/src/main/ports/local-workspace-port-attribution-wsl-gate.test.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { beforeEach, describe, expect, it, vi } from 'vitest' -import type * as FsPromises from 'node:fs/promises' -import type * as WslUncAccessGate from '../wsl/filesystem/wsl-unc-access-gate' - -const mocks = vi.hoisted(() => ({ - realpath: vi.fn(async (path: string) => path), - blocked: vi.fn(async () => null) -})) -vi.mock('node:fs/promises', async (importOriginal) => ({ - ...(await importOriginal()), - realpath: mocks.realpath -})) -vi.mock('../wsl/filesystem/wsl-unc-access-gate', async (importOriginal) => ({ - ...(await importOriginal()), - blockedWslDistroForPath: mocks.blocked -})) - -import { resolveWorkspacePortProbes } from './local-workspace-port-attribution' -import type { WorkspacePortProbe } from '../../shared/workspace-ports' - -function probe(path: string): WorkspacePortProbe { - return { id: `wt:${path}`, repoId: 'repo-1', displayName: 'repo', path } -} - -describe('port attribution for a stopped WSL distro (E9)', () => { - beforeEach(() => { - mocks.realpath.mockClear() - mocks.blocked.mockReset().mockResolvedValue(null) - }) - - it("never realpaths a stopped distro's workspace root, leaving its alias unknown", async () => { - const root = '\\\\wsl.localhost\\Ubuntu\\home\\me\\repo' - mocks.blocked.mockResolvedValue({ distro: 'Ubuntu', state: 'stopped' }) - - const result = await resolveWorkspacePortProbes([probe(root)], true) - - expect(mocks.blocked).toHaveBeenCalledWith(root) - expect(mocks.realpath).not.toHaveBeenCalled() - expect(result.complete).toBe(false) - }) - - it('resolves roots whose distro runs, and host roots, as before', async () => { - const root = '\\\\wsl.localhost\\Ubuntu\\home\\me\\other' - - const result = await resolveWorkspacePortProbes([probe(root), probe('C:\\src\\repo')], true) - - expect(mocks.realpath).toHaveBeenCalledWith(root) - expect(mocks.realpath).toHaveBeenCalledWith('C:\\src\\repo') - expect(result.complete).toBe(true) - }) -}) diff --git a/src/main/preflight/codex-cli-installation.test.ts b/src/main/preflight/codex-cli-installation.test.ts deleted file mode 100644 index 8af72fe55568..000000000000 --- a/src/main/preflight/codex-cli-installation.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { afterEach, describe, expect, it, vi } from 'vitest' -import { CODEX_MINIMUM_SUPPORTED_VERSION } from '../../shared/codex-cli-installation' -import { checkAgentCliVersion } from '../agent-launch/preflight/agent-cli-version-probe' -import { readCodexCliVersion } from '../codex/codex-cli-installation-error' - -const { runProcess } = vi.hoisted(() => ({ runProcess: vi.fn() })) -vi.mock('@orca/process-host', async (original) => ({ - ...(await original()), - runProcess -})) - -const checkCodex = (input: Parameters[0]) => - checkAgentCliVersion(input, [CODEX_MINIMUM_SUPPORTED_VERSION], readCodexCliVersion) - -function prints(stdout: string, timedOut = false): void { - runProcess.mockResolvedValue({ code: 0, stdout, stderr: '', timedOut }) -} -afterEach(() => { - vi.restoreAllMocks() - vi.useRealTimers() - runProcess.mockReset() -}) - -describe('Codex installation version probes', () => { - it('probes every read and sees changes behind an unchanged launcher', async () => { - const program = '/fake/codex' - const input = { program, env: { PATH: '/launch/path' } } - for (const version of ['0.135.0', '0.136.0', '0.135.0']) { - prints(`company-wrapper 0.1.0\ncodex-cli ${version}`) - expect((await readCodexCliVersion(input)).version).toBe(version) - } - expect(runProcess).toHaveBeenCalledTimes(3) - expect(runProcess).toHaveBeenCalledWith( - expect.objectContaining({ - program, - env: input.env, - args: ['--version'], - timeoutMs: 5_000, - maxOutputBytes: 4_096 - }) - ) - }) - - it('allows a timeout and reads the next version without waiting', async () => { - const program = '/fake/codex' - prints('codex-cli 0.135.0', true) - expect((await checkCodex({ program })).status).toBe('unknown') - prints('codex-cli 0.136.0') - expect((await checkCodex({ program })).status).toBe('ready') - expect(runProcess).toHaveBeenCalledTimes(2) - }) -}) diff --git a/src/main/pty/environment/windows-path-registry-fallback.test.ts b/src/main/pty/environment/windows-path-registry-fallback.test.ts deleted file mode 100644 index a7db74af3105..000000000000 --- a/src/main/pty/environment/windows-path-registry-fallback.test.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { WindowsPathRegistryFallback } from './windows-path-registry-fallback' - -const success = (segments: string[]) => ({ failed: false, segments }) -const failure = () => ({ failed: true, segments: [] }) - -describe('WindowsPathRegistryFallback', () => { - it('withholds an incomplete snapshot until every source has succeeded', () => { - const fallback = new WindowsPathRegistryFallback(2) - - expect(fallback.commitReads([success(['C:\\Machine']), failure()])).toBeUndefined() - expect(fallback.commitReads([failure(), success(['C:\\User'])])).toEqual([ - 'C:\\Machine', - 'C:\\User' - ]) - }) - - it('uses each source independently when a later read fails', () => { - const fallback = new WindowsPathRegistryFallback(2) - fallback.commitReads([success(['C:\\OldMachine']), success(['C:\\OldUser'])]) - - expect(fallback.commitReads([success(['C:\\NewMachine']), failure()])).toEqual([ - 'C:\\NewMachine', - 'C:\\OldUser' - ]) - }) - - it('treats a successful empty source as authoritative', () => { - const fallback = new WindowsPathRegistryFallback(2) - fallback.commitReads([success(['C:\\Machine']), success(['C:\\User'])]) - - expect(fallback.commitReads([failure(), success([])])).toEqual(['C:\\Machine']) - expect(fallback.commitReads([failure(), failure()])).toEqual(['C:\\Machine']) - }) - - it('clears retained sources on reset', () => { - const fallback = new WindowsPathRegistryFallback(2) - fallback.commitReads([success(['C:\\Machine']), success(['C:\\User'])]) - - fallback.reset() - - expect(fallback.commitReads([failure(), failure()])).toBeUndefined() - }) - - it('does not expose retained arrays to callers', () => { - const fallback = new WindowsPathRegistryFallback(2) - const machine = ['C:\\Machine'] - const first = fallback.commitReads([success(machine), success(['C:\\User'])])! - - machine[0] = 'C:\\MutatedInput' - first[0] = 'C:\\MutatedOutput' - - expect(fallback.commitReads([failure(), failure()])).toEqual(['C:\\Machine', 'C:\\User']) - }) -}) diff --git a/src/main/runtime/agent-session/agent-session-replaced-runtime.test.ts b/src/main/runtime/agent-session/agent-session-replaced-runtime.test.ts deleted file mode 100644 index 3d5941312e66..000000000000 --- a/src/main/runtime/agent-session/agent-session-replaced-runtime.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { describe, expect, it } from 'vitest' -import type { AgentSessionLease } from '../../../shared/agent-session/lifecycle/agent-session-record' -import { - agentSessionLeaseFixture, - agentSessionRecordFixture -} from '../../../shared/agent-session/lifecycle/agent-session-record.test-fixture' -import { agentSessionReplacedRuntimes } from './agent-session-replaced-runtime' -import type { AgentSessionStoreState } from './records/agent-session-store-state' - -const SESSION = 'session-alpha-1' -const OWNER = { hostId: 'local', pid: 4242, processStartTimeMs: 1, spawnToken: 'spawn-owner' } - -function loaded(lease: Partial, runtimeEnd?: 'crash'): AgentSessionStoreState { - const record = agentSessionRecordFixture( - agentSessionLeaseFixture({ unreconciled: true, ...lease }) - ) - return { - records: new Map([[SESSION, record]]), - operations: new Map(), - retiredClaimKeys: [], - unreadableRecords: new Map(), - sessionTabs: null, - runtimeEnds: runtimeEnd ? new Map([['earlier', runtimeEnd]]) : new Map() - } -} - -function replacedFor(state: AgentSessionStoreState) { - return agentSessionReplacedRuntimes(state, { - hostId: 'local', - incarnation: 'this-runtime' - }).get(SESSION) -} - -describe('the runtimes a new server replaced, as it loads their records', () => { - it('names every fence an earlier runtime granted, its owner renewal, and how it ended', () => { - expect( - replacedFor(loaded({ ownerProcess: { ...OWNER, runtime: 'earlier' } }, 'crash')) - ).toEqual({ fence: 7, lastProvenAliveAt: 30_000, runtimeEnd: 'crash' }) - }) - - it('covers a chat an earlier runtime released, which no owner holds now', () => { - expect( - replacedFor(loaded({ ownerProcess: null, reservedSpawnToken: null, claimStatus: 'released' })) - ).toEqual({ fence: 7 }) - }) - - it.each([ - ['an owner this runtime recorded', { ownerProcess: { ...OWNER, runtime: 'this-runtime' } }], - ['an owner on another host', { ownerProcess: { ...OWNER, hostId: 'remote' } }], - ['a terminal agent an older build recorded', { claimStatus: 'conflicted' as const }] - ])('replaces nothing for %s', (_label, lease) => { - expect(replacedFor(loaded(lease))).toBeUndefined() - }) -}) diff --git a/src/main/runtime/browser-tab-create-folder-workspace.test.ts b/src/main/runtime/browser-tab-create-folder-workspace.test.ts deleted file mode 100644 index 6aeb427f3e44..000000000000 --- a/src/main/runtime/browser-tab-create-folder-workspace.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -// #21353: server-hosted tabs must resolve folder selectors too. -import { describe, expect, it, vi } from 'vitest' -import type { RuntimeBrowserCommandHost } from './browser/browser-command-contracts' - -vi.mock('electron', () => ({ - ipcMain: { on: vi.fn(), removeListener: vi.fn() }, - webContents: { fromId: vi.fn() } -})) - -vi.mock('../ipc/browser-tab-registration-wait', () => ({ - waitForTabRegistration: vi.fn(), - waitForWorktreeTabRegistration: vi.fn() -})) - -vi.mock('../browser/browser-session-registry', () => ({ - browserSessionRegistry: { - getDefaultProfile: () => ({ id: 'default', partition: 'persist:orca-browser' }), - getProfile: () => ({ id: 'default', partition: 'persist:orca-browser' }), - resolveKnownPartition: () => 'persist:orca-browser' - } -})) - -const FOLDER = 'folder:folder-1' - -function createHost(overrides: Record): RuntimeBrowserCommandHost { - // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: test host implements only the members browserTabCreate reads. - return { - resolveWorkspaceSelector: vi.fn(async () => { - throw new Error('selector_not_found') - }), - resolveBrowserWorkspace: vi.fn(async () => ({ id: FOLDER })), - getAgentBrowserBridge: () => null, - getAvailableAuthoritativeWindow: vi.fn(() => null), - ...overrides - } as unknown as RuntimeBrowserCommandHost -} - -describe('browser.tabCreate on a folder workspace', () => { - it('creates a server-hosted page for the folder workspace', async () => { - const { RuntimeBrowserCommands } = await import('./browser/browser-commands') - const createTab = vi.fn(async () => ({ browserPageId: 'page-folder' })) - const host = createHost({ - getOffscreenBrowserBackend: vi.fn(() => ({ createTab })) - }) - - await expect( - new RuntimeBrowserCommands(host).browserTabCreate( - { worktree: `id:${FOLDER}`, url: 'about:blank' }, - { pairedDeviceId: 'device-a', clientKind: 'runtime' } - ) - ).resolves.toEqual({ browserPageId: 'page-folder' }) - - expect(host.resolveBrowserWorkspace).toHaveBeenCalledWith(`id:${FOLDER}`) - expect(createTab).toHaveBeenCalledWith(expect.objectContaining({ worktreeId: FOLDER })) - }) -}) diff --git a/src/main/runtime/rpc/methods/mobile-relay-hosts.test.ts b/src/main/runtime/rpc/methods/mobile-relay-hosts.test.ts deleted file mode 100644 index 2c654f17e464..000000000000 --- a/src/main/runtime/rpc/methods/mobile-relay-hosts.test.ts +++ /dev/null @@ -1,50 +0,0 @@ -import '../unused-default-rpc-methods.test-fixture' -import { describe, expect, it, vi } from 'vitest' -import type { OrcaRuntimeService } from '../../orca-runtime' -import { RpcDispatcher } from '../dispatcher' -import { MOBILE_RELAY_HOSTS_METHODS } from './mobile-relay-hosts' -import type { z } from 'zod' -import type { - MobileRelayHostWorktreesParamsSchema, - MobileRelayServerWorktreeRow -} from '../../../../shared/mobile-relay-hosts-contract' - -const row = (worktreeId: string, displayName = worktreeId): MobileRelayServerWorktreeRow => ({ - hostId: 'runtime:env-1', - worktreeId, - displayName -}) - -function relay(...served: (MobileRelayServerWorktreeRow[] | null)[]) { - const worktrees = vi.fn(async () => ({ worktrees: served.shift() ?? null })) - // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the dispatcher reads only the runtime id; these methods read none. - const runtime = { getRuntimeId: () => 'desktop' } as unknown as OrcaRuntimeService - const dispatcher = new RpcDispatcher({ runtime, methods: MOBILE_RELAY_HOSTS_METHODS }) - return async ( - params: Omit, 'hostId'> - ): Promise> => { - let result: Record = {} - await dispatcher.dispatchStreaming( - { - id: 'r', - authToken: 'token', - method: 'mobileRelay.hosts.worktrees', - params: { hostId: 'runtime:env-1', ...params } - }, - (reply) => { - result = JSON.parse(reply).result - }, - { mobileRelayHosts: { list: () => ({ hosts: [] }), worktrees } } - ) - return result - } -} - -describe('mobileRelay.hosts.worktrees snapshots', () => { - it('answers callers that send no snapshot fields exactly as before', async () => { - const read = relay([row('a')], null) - - expect(await read({})).toEqual({ worktrees: [row('a')] }) - expect(await read({})).toEqual({ worktrees: null }) - }) -}) diff --git a/src/main/runtime/rpc/methods/worktree-create-args.test.ts b/src/main/runtime/rpc/methods/worktree-create-args.test.ts deleted file mode 100644 index ef48a048239c..000000000000 --- a/src/main/runtime/rpc/methods/worktree-create-args.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { buildManagedWorktreeCreateArgs } from './worktree-create-args' -import { AgentLaunch, AgentLaunchReplay } from '../../../../shared/rpc-contract/agent-launch-params' -import { WorktreeCreate } from '../../../../shared/rpc-contract/worktree-create-params' - -const PROVENANCE = { - automationProvenance: undefined, - cliProvenance: undefined, - creatorProvenance: { kind: 'host' as const } -} - -const build = (params: Record) => - buildManagedWorktreeCreateArgs(WorktreeCreate.parse(params), PROVENANCE) - -describe('buildManagedWorktreeCreateArgs', () => { - it('carries one transient cwd-choice field through plain, startup and both modern launch schemas', () => { - const choices = ['id:repo::/checkout', 'id:repo::/checkout::workspace:sibling'] - const create = { - repo: 'id:repo', - name: 'child', - cwdParentWorktree: choices[0], - cwdParentAmbiguous: true, - callerTerminalHandle: 'term_R' - } - for (const schema of [AgentLaunch, AgentLaunchReplay]) { - const request = schema.parse({ - agent: 'codex', - operationId: '1760000000000-0123456789abcdef0123456789abcdef', - target: { kind: 'create-worktree', create } - }) - expect(request.target.kind).toBe('create-worktree') - if (request.target.kind !== 'create-worktree') { - throw new Error('wrong launch target') - } - expect(build(request.target.create).lineage).toMatchObject({ - cwdParentAmbiguous: true, - cwdParentWorktree: choices[0], - callerTerminalHandle: 'term_R' - }) - } - for (const payload of [create, { ...create, startupAgent: 'codex', startupPrompt: 'review' }]) { - expect(build(payload).lineage).toMatchObject({ - cwdParentAmbiguous: true, - cwdParentWorktree: choices[0], - callerTerminalHandle: 'term_R' - }) - } - expect( - build({ repo: 'id:repo', name: 'legacy', cwdParentWorktree: choices[0] }).lineage - ).not.toHaveProperty('cwdParentAmbiguous') - }) -}) diff --git a/src/main/runtime/runtime-rpc/runtime-rpc-long-poll.test.ts b/src/main/runtime/runtime-rpc/runtime-rpc-long-poll.test.ts deleted file mode 100644 index b982786d8297..000000000000 --- a/src/main/runtime/runtime-rpc/runtime-rpc-long-poll.test.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { classifyRuntimeLongPoll } from './runtime-rpc-long-poll' - -describe('OrcaRuntimeRpcServer', () => { - it('classifies worker-start as a keepalive-backed long poll', () => { - expect( - classifyRuntimeLongPoll({ - id: 'req_worker_start', - authToken: 'token', - method: 'orchestration.workerStart', - params: { task: 'task_1', timeoutMs: 60_000 } - }) - ).toBe('wait') - }) - - it.each(['agent.launch', 'agent.launchReplay'])( - 'keeps a prompted %s alive while it waits for the agent to be ready', - (method) => { - const prompt = { text: 'fix the build', delivery: 'submit' } - expect( - classifyRuntimeLongPoll({ - id: 'req_launch', - authToken: 'token', - method, - params: { prompt } - }) - ).toBe('wait') - // An existing workspace without a prompt remains a short call. - expect( - classifyRuntimeLongPoll({ id: 'req_launch', authToken: 'token', method, params: {} }) - ).toBeNull() - } - ) - - it.each(['agent.launch', 'agent.launchReplay'])( - 'keeps unprompted %s workspace setup alive', - (method) => { - expect( - classifyRuntimeLongPoll({ - id: 'req_setup', - authToken: 'token', - method, - params: { - target: { kind: 'create-worktree', create: { repo: 'id:repo-1', name: 'task' } } - } - }) - ).toBe('wait') - expect( - classifyRuntimeLongPoll({ - id: 'req_existing', - authToken: 'token', - method, - params: { target: { kind: 'existing', worktree: 'id:wt-7' } } - }) - ).toBeNull() - } - ) - - it('keeps agent-prompt submission sockets alive during verification', () => { - expect( - classifyRuntimeLongPoll({ - id: 'req_prompt', - authToken: 'token', - method: 'terminal.send', - params: { agentPrompt: true } - }) - ).toBe('wait') - expect( - classifyRuntimeLongPoll({ - id: 'req_direct', - authToken: 'token', - method: 'terminal.send', - params: { agentPrompt: false } - }) - ).toBeNull() - }) -}) diff --git a/src/main/runtime/runtime-skill-install-authority.test.ts b/src/main/runtime/runtime-skill-install-authority.test.ts deleted file mode 100644 index 262a4a36f9ad..000000000000 --- a/src/main/runtime/runtime-skill-install-authority.test.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { describe, expect, it } from 'vitest' -import type { RuntimeSkillCommandHost } from './runtime-skill-command-contract' -import { createSkillInstallAuthority } from './runtime-skill-install-authority' - -const WORKTREE_ID = 'repo-1::/workspace/app' - -function createHost(overrides: Partial = {}): RuntimeSkillCommandHost { - return { - getRuntimeId: () => 'runtime-1', - getUserDataPath: () => '/tmp/orca-skill-authority-test', - isPackaged: () => true, - getSettings: () => ({}), - listRepos: () => [{ id: 'repo-1', path: '/workspace/app' }], - listFolderWorkspaces: () => [], - listResolvedWorktrees: async () => [], - showManagedWorktree: async () => ({ id: WORKTREE_ID, path: '/workspace/app' }), - skillTransactionRecovery: Promise.resolve(), - ...overrides - } as RuntimeSkillCommandHost -} - -describe('createSkillInstallAuthority', () => { - // Preserve thrown Git/I/O errors; converting to missing workspace loses actionable cause. - it('surfaces a worktree lookup failure instead of reporting it as not found', async () => { - const authority = createSkillInstallAuthority( - createHost({ - showManagedWorktree: async () => { - throw new Error('git-index-locked') - } - }) - ) - - await expect(authority.resolveWorktree(WORKTREE_ID)).rejects.toThrow('git-index-locked') - }) - - it('returns null when the lookup resolves a different worktree', async () => { - const authority = createSkillInstallAuthority( - createHost({ showManagedWorktree: async () => ({ id: 'repo-1::/other', path: '/other' }) }) - ) - - await expect(authority.resolveWorktree(WORKTREE_ID)).resolves.toBeNull() - }) - - it('never resolves a folder workspace as a worktree, where only repo rows fence the host', async () => { - const authority = createSkillInstallAuthority( - createHost({ - showManagedWorktree: async () => ({ id: 'folder:remote-folder', path: '/srv/remote' }) - }) - ) - - await expect(authority.resolveWorktree('folder:remote-folder')).resolves.toBeNull() - }) -}) diff --git a/src/main/runtime/terminal/stop/worktree-sleep-resume-records.test.ts b/src/main/runtime/terminal/stop/worktree-sleep-resume-records.test.ts deleted file mode 100644 index 356fba328fcb..000000000000 --- a/src/main/runtime/terminal/stop/worktree-sleep-resume-records.test.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { describe, expect, it } from 'vitest' -import type { SleepingAgentSessionRecord } from '../../../../shared/agent-session/lifecycle/agent-session-resume' -import type { WorkspaceSessionState } from '../../../../shared/workspace-session-state-types' -import { dropStrandedSleepRecord } from './worktree-sleep-resume-records' - -const slept: SleepingAgentSessionRecord = { - paneKey: 'tab-1:leaf-1', - tabId: 'tab-1', - worktreeId: 'wt-1', - agent: 'claude', - providerSession: { key: 'session_id', id: 'sess-1' }, - prompt: '', - state: 'done', - capturedAt: 1, - updatedAt: 1, - origin: 'worktree-sleep', - restoreOnTabOpenOnly: true -} - -function session( - tabIds: string[], - record: SleepingAgentSessionRecord = slept -): WorkspaceSessionState { - const tab = (id: string) => ({ - id, - ptyId: null, - worktreeId: 'wt-1', - title: 'Terminal', - customTitle: null, - color: null, - sortOrder: 0, - createdAt: 1 - }) - return { - activeRepoId: null, - activeWorktreeId: null, - activeTabId: null, - tabsByWorktree: { 'wt-1': tabIds.map(tab) }, - terminalLayoutsByTabId: {}, - sleepingAgentSessionsByPaneKey: { [record.paneKey]: record } - } -} - -describe('dropStrandedSleepRecord', () => { - it("drops a workspace sleep's record once no tab holds its pane", () => { - expect( - dropStrandedSleepRecord(session([]), 'wt-1', slept.paneKey)?.sleepingAgentSessionsByPaneKey - ).toEqual({}) - }) - - // A window must not discard a record main still resumes when its tab opens. - it("keeps a listed tab's record, window-owned records, and another worktree's record", () => { - expect(dropStrandedSleepRecord(session(['tab-1']), 'wt-1', slept.paneKey)).toBeNull() - const quit = { ...slept, origin: 'quit' as const } - expect(dropStrandedSleepRecord(session([], quit), 'wt-1', quit.paneKey)).toBeNull() - expect(dropStrandedSleepRecord(session([]), 'wt-2', slept.paneKey)).toBeNull() - }) -}) diff --git a/src/main/startup/plugin-worktree-lifecycle.test.ts b/src/main/startup/plugin-worktree-lifecycle.test.ts deleted file mode 100644 index 5b77e35a1a6a..000000000000 --- a/src/main/startup/plugin-worktree-lifecycle.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { afterEach, describe, expect, it, vi } from 'vitest' -import { workspaceRemovedPayloadSchema } from '../../shared/plugins/events/plugin-events' -import type { PluginService } from '../plugins/plugin-service' -import { emitPluginWorktreeLifecycle } from './main-process-pty-startup' -import { mainProcessState } from './main-process-state' -import { setPluginHookRunner } from '../plugins/hooks/plugin-hook-dispatch' - -describe('emitPluginWorktreeLifecycle', () => { - afterEach(() => { - mainProcessState.pluginService = null - setPluginHookRunner(null) - }) - - it('runs workspace.create.after for folders too, while workspace.created stays Git-only', () => { - const emitEvent = vi.fn() - // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the emitter only calls emitEvent. - mainProcessState.pluginService = { emitEvent } as unknown as PluginService - const run = vi.fn(async (_event: string, payload: unknown) => ({ - kind: 'continue' as const, - payload - })) - setPluginHookRunner({ wants: () => true, run }) - emitPluginWorktreeLifecycle({ - kind: 'created', - worktreeId: 'folder:ws-1', - path: '/ws', - branch: '' - }) - expect(emitEvent).not.toHaveBeenCalled() - expect(run).toHaveBeenCalledWith('workspace.create.after', { - workspaceId: 'folder:ws-1', - kind: 'folder', - path: '/ws', - branch: '' - }) - }) - - it('keeps folder removals internal and publishes Git worktree removals', () => { - const emitEvent = vi.fn() - // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the emitter only calls emitEvent. - mainProcessState.pluginService = { emitEvent } as unknown as PluginService - emitPluginWorktreeLifecycle({ kind: 'removed', worktreeId: 'folder:ws-1', path: '/tmp/ws' }) - expect(emitEvent).not.toHaveBeenCalled() - emitPluginWorktreeLifecycle({ kind: 'removed', worktreeId: 'repo::/tmp/ws', path: '/tmp/ws' }) - expect(emitEvent).toHaveBeenCalledWith('workspace.removed', { - workspaceId: 'repo::/tmp/ws', - kind: 'worktree', - path: '/tmp/ws' - }) - expect(workspaceRemovedPayloadSchema.safeParse(emitEvent.mock.calls[0]?.[1]).success).toBe(true) - }) -}) diff --git a/src/main/telemetry/cohort-classifier.test.ts b/src/main/telemetry/cohort-classifier.test.ts deleted file mode 100644 index bcc5867f69ba..000000000000 --- a/src/main/telemetry/cohort-classifier.test.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type { Repo } from '../../shared/repo-types' -import type { Store } from '../persistence/loading-store/store' -import { - _resetSessionWarnFlagForTests, - _setStoreForTests, - getCohortAtEmit, - initCohortClassifier -} from './cohort-classifier' - -function makeFakeStore(getRepos: () => Repo[]): Store { - // Both fake accessors share one repo source so changes/failures stay consistent. - return { - getRepos: vi.fn(getRepos), - getRepoCount: vi.fn(() => getRepos().length) - } as unknown as Store -} - -describe('cohort-classifier', () => { - beforeEach(() => { - vi.spyOn(console, 'warn').mockImplementation(() => {}) - _setStoreForTests(null) - _resetSessionWarnFlagForTests() - }) - afterEach(() => { - vi.restoreAllMocks() - _setStoreForTests(null) - }) - - it('returns undefined and never throws when getRepos throws', () => { - initCohortClassifier( - makeFakeStore(() => { - throw new Error('disk fault') - }) - ) - expect(() => getCohortAtEmit()).not.toThrow() - expect(getCohortAtEmit()).toEqual({ nth_repo_added: undefined }) - }) - - // Warn once on degraded reads so missing cohort data is diagnosable without flooding logs. - it('warns at most once per session even across many degraded calls', () => { - initCohortClassifier( - makeFakeStore(() => { - throw new Error('disk fault') - }) - ) - const warnSpy = console.warn as unknown as ReturnType - for (let i = 0; i < 50; i++) { - getCohortAtEmit() - } - expect(warnSpy).toHaveBeenCalledTimes(1) - }) - - it('resets the warn flag when reinitialized', () => { - initCohortClassifier( - makeFakeStore(() => { - throw new Error('first') - }) - ) - getCohortAtEmit() - initCohortClassifier( - makeFakeStore(() => { - throw new Error('second') - }) - ) - getCohortAtEmit() - const warnSpy = console.warn as unknown as ReturnType - expect(warnSpy).toHaveBeenCalledTimes(2) - }) -}) diff --git a/src/main/text-generation/command-environment-wsl.test.ts b/src/main/text-generation/command-environment-wsl.test.ts deleted file mode 100644 index 3f971ccd7f8a..000000000000 --- a/src/main/text-generation/command-environment-wsl.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { afterEach, describe, expect, it, vi } from 'vitest' -import { wslAwareSpawn } from '../git/runner' -import { spawnSourceControlAgent } from './source-control-agent-launch' -import { withPlatform } from './commit-message-text-generation-test-harness' -import { resolveCodexHomeProcessLockKeyForSpawnEnv } from '../codex-cli/codex-home-process-lock' - -vi.mock('../git/command-runner/wsl-aware-spawn', async (importOriginal) => ({ - ...(await importOriginal>()), - wslAwareSpawn: vi.fn() -})) -afterEach(() => vi.unstubAllEnvs()) - -describe('command environment on WSL', () => { - it('applies literal assignments in the guest after the login shell, without changing launcher PATH', () => { - withPlatform('win32', () => { - spawnSourceControlAgent({ - binary: 'claude', - args: ['-p'], - cwd: '\\\\wsl$\\Ubuntu\\repo', - wslDistro: 'Ubuntu', - env: undefined, - commandEnv: { PATH: '/guest/bin', VALUE: '$HOME;$(echo unsafe)' }, - stdinMode: 'pipe', - useCwdForNative: true - }) - }) - expect(wslAwareSpawn).toHaveBeenCalledWith( - '/usr/bin/env', - ['PATH=/guest/bin', 'VALUE=$HOME;$(echo unsafe)', 'claude', '-p'], - expect.objectContaining({ wslDistro: 'Ubuntu', windowsHide: true, useWslLoginShell: true }) - ) - const options = vi.mocked(wslAwareSpawn).mock.calls[0][2] - expect(options.env?.PATH).not.toBe('/guest/bin') - expect(options.env?.VALUE).toBeUndefined() - }) - - it('locks an explicitly assigned guest Codex home even when it matches the host value', () => { - vi.stubEnv('CODEX_HOME', '/same/home') - const explicit = resolveCodexHomeProcessLockKeyForSpawnEnv( - { CODEX_HOME: '/same/home' }, - 'Ubuntu', - { CODEX_HOME: '/same/home' } - ) - const managed = resolveCodexHomeProcessLockKeyForSpawnEnv( - { CODEX_HOME: '/other/home' }, - 'Ubuntu' - ) - expect(explicit).toContain('/same/home') - expect(explicit).not.toContain('.orca-default-codex-home') - expect(explicit).not.toBe(managed) - }) -}) diff --git a/src/main/text-generation/copilot-unavailable-model-retry.test.ts b/src/main/text-generation/copilot-unavailable-model-retry.test.ts deleted file mode 100644 index c5eeb0e5af4f..000000000000 --- a/src/main/text-generation/copilot-unavailable-model-retry.test.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { describe, expect, it } from 'vitest' -import type { CommitMessagePlan } from '../../shared/commit-message-plan' -import { copilotUnavailableModelRetryPlan } from './copilot-unavailable-model-retry' - -const rejection = 'Error: Model "gpt-5.4" from --model flag is not available.\n' -const plan: CommitMessagePlan = { - binary: 'copilot', - // The prompt quotes the rejection text and must survive argv editing. - args: ['--prompt', rejection, '--silent', '--model', 'gpt-5.4', '--effort', 'low'], - stdinPayload: null, - label: 'GitHub Copilot' -} - -function failure(overrides: { exitCode?: number | null; stdout?: string; stderr?: string }) { - return { label: 'GitHub Copilot', exitCode: 1, stdout: '', stderr: rejection, ...overrides } -} - -describe('copilotUnavailableModelRetryPlan', () => { - it('drops the rejected model and its effort level', () => { - expect(copilotUnavailableModelRetryPlan(plan, failure({}))?.args).toEqual([ - '--prompt', - rejection, - '--silent' - ]) - }) - - it('accepts the rejection line among other stderr lines', () => { - const stderr = `Update available\r\n${rejection.replace('\n', '\r\n')}` - expect(copilotUnavailableModelRetryPlan(plan, failure({ stderr }))).not.toBeNull() - }) - - it.each([ - ['no failure output', undefined], - ['exit code 0', failure({ exitCode: 0 })], - ['unknown exit code', failure({ exitCode: null })], - ['model output before the failure', failure({ stdout: 'fix-login\n' })], - ['a quoted rejection', failure({ stderr: `agent said: ${rejection}` })], - [ - 'a rejection of another model', - failure({ stderr: 'Error: Model "gpt-5.5" from --model flag is not available.\n' }) - ] - ])('does not retry with %s', (_name, output) => { - expect(copilotUnavailableModelRetryPlan(plan, output)).toBeNull() - }) - - it('does not retry when the plan passes no model', () => { - expect( - copilotUnavailableModelRetryPlan({ ...plan, args: plan.args.slice(0, 3) }, failure({})) - ).toBeNull() - }) -}) 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 deleted file mode 100644 index 3cbfb7d2998a..000000000000 --- a/src/main/workspaces/execution-host/project-runtime-read-git-options-opt-in.test.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type { Store } from '../../persistence/loading-store/store' -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/discovery/distro-catalog' - -const repo: Repo = { - id: 'repo-1', - displayName: 'Repo', - path: String.raw`C:\repo`, - badgeColor: '#000000', - addedAt: 0 -} -const project: Project = { - id: 'project-1', - displayName: 'Project', - badgeColor: '#000000', - sourceRepoIds: ['repo-1'], - createdAt: 0, - updatedAt: 0, - localWindowsRuntimePreference: { kind: 'wsl', distro: 'Ubuntu' } -} - -function store(experimentalWslHosts: boolean): Store { - // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: runtime resolution reads only getProjects and getSettings. - return { - getProjects: () => [project], - getSettings: () => ({ - localWindowsRuntimeDefault: { kind: 'windows-host' }, - experimentalWslHosts - }) - } as unknown as Store -} - -// Stage 1 is opt-in: base-ref and remote-identity reads follow the runtime only with the setting on. -describe('base-ref and remote-identity reads of a WSL-runtime project', () => { - const platform = process.platform - beforeEach(() => { - vi.stubEnv(WSL_HOSTS_INTERNAL_GATE_ENV, '1') - Object.defineProperty(process, 'platform', { configurable: true, value: 'win32' }) - _setWslCachesForTests({ available: true, distros: ['Ubuntu'] }) - }) - afterEach(() => { - vi.unstubAllEnvs() - Object.defineProperty(process, 'platform', { configurable: true, value: platform }) - _resetWslCachesForTests() - }) - - it('run with host Git as before while the WSL hosts setting is off', () => { - expect(getProjectRuntimeReadGitOptions(store(false), repo)).toEqual({}) - }) - - it("follow the project's distro once the user turns WSL hosts on", () => { - expect(getProjectRuntimeReadGitOptions(store(true), repo)).toEqual({ wslDistro: 'Ubuntu' }) - }) -}) diff --git a/src/main/wsl/execution/wsl-guest-process-identity.test.ts b/src/main/wsl/execution/wsl-guest-process-identity.test.ts index 778fbb2cb7c8..786d625dcb91 100644 --- a/src/main/wsl/execution/wsl-guest-process-identity.test.ts +++ b/src/main/wsl/execution/wsl-guest-process-identity.test.ts @@ -1,9 +1,5 @@ import { describe, expect, it } from 'vitest' -import { - parseWslGuestIdentity, - procStatStartTicks, - wslGuestIdentityCommand -} from './wsl-guest-process-identity' +import { parseWslGuestIdentity, procStatStartTicks } from './wsl-guest-process-identity' const BOOT_ID = '6a0c4b1e-2f3d-4e5f-8a9b-0c1d2e3f4a5b' // Fields 3..22 after the name; field 22 (start ticks) is the last one here. @@ -47,13 +43,3 @@ describe('parseWslGuestIdentity', () => { expect(parseWslGuestIdentity(['not-a-boot-id', '1 (init) x', '', ''].join(SEP))).toBeNull() }) }) - -describe('wslGuestIdentityCommand', () => { - it('only interpolates a validated pid', () => { - expect(wslGuestIdentityCommand(4321)).toContain('/proc/4321/stat') - expect(wslGuestIdentityCommand(null)).not.toContain('/proc/null') - expect(wslGuestIdentityCommand(-1)).not.toContain('/proc/-1') - // Nothing time-of-day based: identity must survive a guest clock jump. - expect(wslGuestIdentityCommand(4321)).not.toMatch(/date|uptime|btime/) - }) -}) diff --git a/src/main/wsl/host-lifecycle/wsl-host-connection-record.test.ts b/src/main/wsl/host-lifecycle/wsl-host-connection-record.test.ts deleted file mode 100644 index d0e3b0925491..000000000000 --- a/src/main/wsl/host-lifecycle/wsl-host-connection-record.test.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { describe, expect, it } from 'vitest' -import type { WslHostDeploymentRecord } from '../../../shared/wsl-host-deployment-store' -import { toWslHostStatus } from './wsl-host-connection-record' - -const record: WslHostDeploymentRecord = { - kind: 'wsl', - distro: 'Ubuntu', - localPort: 41_000, - remotePort: 6_768, - environmentId: 'wsl:ubuntu', - createdAt: 1 -} -const deferredUpdate = { - candidateVersion: '1.5.0+ab', - code: 'orcad_activation_policy_refused', - reason: 'rolled back', - forceable: true -} - -describe('toWslHostStatus', () => { - it('keeps the deferral of a connect that deferred, so Update and Force stay offered', () => { - expect( - toWslHostStatus(record, { - state: 'failed', - reason: 'rolled back', - terminals: 'unverifiable', - deferredUpdate - }).deferredUpdate - ).toEqual(deferredUpdate) - expect( - toWslHostStatus(record, { state: 'failed', reason: 'x', terminals: 'unverifiable' }) - .deferredUpdate - ).toBeNull() - expect(toWslHostStatus(record, { state: 'connecting' }).deferredUpdate).toBeNull() - }) - - it('codes an unverifiable reason as a sentence, and keeps verbatim connect errors uncoded', () => { - expect( - toWslHostStatus(record, { - state: 'unverifiable', - reason: 'guest-unanswered', - terminals: 'unverifiable' - }) - ).toMatchObject({ - detail: 'The distro is running but didn’t answer Orca’s check.', - detailCode: 'guestUnanswered' - }) - const failed = toWslHostStatus(record, { - state: 'failed', - reason: 'bridge refused', - terminals: 'unverifiable' - }) - expect(failed.detail).toBe('bridge refused') - expect(failed).not.toHaveProperty('detailCode') - const pendingStop = { - since: 1, - reason: 'The WSL service did not confirm whether the distro runs.', - reasonCode: 'serviceUnconfirmed', - verdict: 'unverifiable' as const - } - expect(toWslHostStatus({ ...record, pendingStop }, { state: 'closed' })).toMatchObject({ - detail: pendingStop.reason, - detailCode: 'serviceUnconfirmed', - removalPending: true - }) - }) -}) diff --git a/src/main/wsl/host-lifecycle/wsl-host-distro-list.test.ts b/src/main/wsl/host-lifecycle/wsl-host-distro-list.test.ts deleted file mode 100644 index b742d1a513d7..000000000000 --- a/src/main/wsl/host-lifecycle/wsl-host-distro-list.test.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { describe, expect, it } from 'vitest' -import type { WslDistroRegistration } from '../discovery/wsl-distro-registry-id' -import { admitWslHostDistro } from './wsl-host-add-admission' -import { listWslHostDistros } from './wsl-host-distro-list' - -const registrations: WslDistroRegistration[] = [ - { id: 'a', distro: 'Ubuntu', version: 2 }, - { id: 'b', distro: 'Debian', version: 2 }, - { id: 'c', distro: 'docker-desktop', version: 2 } -] -const readRegistrations = async () => registrations - -describe('listWslHostDistros', () => { - it('marks each user distro running or stopped from a confirmed read', async () => { - const distros = await listWslHostDistros({ - readRegistrations, - readRunning: async () => ({ status: 'confirmed', distros: ['ubuntu'] }) - }) - expect(distros.map(({ name, state }) => [name, state])).toEqual([ - ['Debian', 'stopped'], - ['Ubuntu', 'running'] - ]) - }) - - it('says unverifiable, never stopped, when the running list cannot be read', async () => { - for (const readRunning of [ - async () => ({ status: 'unavailable' }) as const, - async () => { - throw new Error('wsl.exe timed out') - } - ]) { - const distros = await listWslHostDistros({ readRegistrations, readRunning }) - expect(distros.map(({ state }) => state)).toEqual(['unverifiable', 'unverifiable']) - } - }) -}) - -describe('admitWslHostDistro', () => { - const candidate = { id: 'a', name: 'Ubuntu', version: 2 as const, state: 'unverifiable' as const } - - it('needs the user’s explicit start for a distro WSL could not vouch for', () => { - const refused = admitWslHostDistro({ - requested: 'Ubuntu', - candidates: [candidate], - alreadyAdded: () => false, - startIfStopped: false - }) - expect(refused).toMatchObject({ ok: false, kind: 'failed', errorCode: 'distroUnverifiable' }) - expect( - admitWslHostDistro({ - requested: 'Ubuntu', - candidates: [candidate], - alreadyAdded: () => false, - startIfStopped: true - }) - ).toEqual({ distro: candidate }) - }) -}) diff --git a/src/main/wsl/host-lifecycle/wsl-host-peer-desktops.test.ts b/src/main/wsl/host-lifecycle/wsl-host-peer-desktops.test.ts deleted file mode 100644 index 4e22634e9888..000000000000 --- a/src/main/wsl/host-lifecycle/wsl-host-peer-desktops.test.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { describe, expect, it, vi } from 'vitest' -import { ORCAD_PEER_DESKTOPS_RUNTIME_CAPABILITY } from '../../../shared/orcad-runtime-capabilities' -import { ORCAD_PEER_DESKTOPS_METHOD } from '../../../shared/orcad-peer-desktops-contract' -import { readWslHostPeerDesktops } from './wsl-host-peer-desktops' - -function server(peers: unknown, capabilities = [ORCAD_PEER_DESKTOPS_RUNTIME_CAPABILITY]) { - return vi.fn(async (method: string) => { - if (method === 'status.get') { - return { runtimeId: 'r', capabilities } - } - if (method === ORCAD_PEER_DESKTOPS_METHOD) { - return { peers } - } - throw new Error(`unexpected ${method}`) - }) -} - -describe('readWslHostPeerDesktops', () => { - it('names the other Orcas connected now, asking as this installation', async () => { - const call = server([{ name: 'Orca Dev' }]) - await expect(readWslHostPeerDesktops(call, 'this-installation')).resolves.toEqual({ - kind: 'shared', - names: ['Orca Dev'] - }) - expect(call).toHaveBeenCalledWith(ORCAD_PEER_DESKTOPS_METHOD, { - clientInstanceId: 'this-installation' - }) - }) - - it('lets the teardown proceed when no other Orca is connected', async () => { - await expect(readWslHostPeerDesktops(server([]), 'this-installation')).resolves.toEqual({ - kind: 'none' - }) - }) - - it('reports an older server without asking it a method it lacks', async () => { - const call = server([], []) - await expect(readWslHostPeerDesktops(call, 'this-installation')).resolves.toEqual({ - kind: 'unsupported' - }) - expect(call).toHaveBeenCalledTimes(1) - }) - - it('throws on an answer it cannot read, so the teardown is refused', async () => { - await expect(readWslHostPeerDesktops(server('nope'), 'this-installation')).rejects.toThrow() - const failing = vi.fn(async () => { - throw new Error('timeout') - }) - await expect(readWslHostPeerDesktops(failing, 'this-installation')).rejects.toThrow('timeout') - }) -}) diff --git a/src/main/wsl/orcad/wsl-orcad-own-build-launch-env.test.ts b/src/main/wsl/orcad/wsl-orcad-own-build-launch-env.test.ts deleted file mode 100644 index aff538da7ecf..000000000000 --- a/src/main/wsl/orcad/wsl-orcad-own-build-launch-env.test.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { hostMallocTunablesLaunchEnv } from '../../memory/host-malloc-tunables' -import type { OrcadHostTransport } from '../../ssh/orcad-host-transport' -import { withOwnBuildLaunchEnv } from './wsl-orcad-own-build-launch-env' - -function transport(): OrcadHostTransport { - // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the wrapper reads only orcadLaunchEnv. - return { - orcadLaunchEnv: async () => [['ORCA_WSL_DISTRO_GUID', 'g']] - } as unknown as OrcadHostTransport -} - -describe('withOwnBuildLaunchEnv', () => { - it('adds the malloc tunables when the launched slot is this build', async () => { - const conn = withOwnBuildLaunchEnv(transport(), () => '0.1.0+own') - await expect(conn.orcadLaunchEnv?.({ fullVersion: '0.1.0+own' })).resolves.toEqual([ - ['ORCA_WSL_DISTRO_GUID', 'g'], - ...hostMallocTunablesLaunchEnv() - ]) - }) - - it('withholds them from an older slot, which would leak them to user shells', async () => { - const conn = withOwnBuildLaunchEnv(transport(), () => '0.1.0+own') - await expect(conn.orcadLaunchEnv?.({ fullVersion: '0.1.0+older' })).resolves.toEqual([ - ['ORCA_WSL_DISTRO_GUID', 'g'] - ]) - }) - - it('withholds them before this build’s version is known', async () => { - const conn = withOwnBuildLaunchEnv(transport(), () => null) - await expect(conn.orcadLaunchEnv?.({ fullVersion: '0.1.0+own' })).resolves.toEqual([ - ['ORCA_WSL_DISTRO_GUID', 'g'] - ]) - }) - - it('keeps a class-based transport’s prototype methods', async () => { - class ClassTransport { - readonly prefix = 'ran:' - describe(command: string): string { - return `${this.prefix}${command}` - } - } - // The wrapper only reads orcadLaunchEnv; a bare instance stands in for the full transport. - const transport: OrcadHostTransport & ClassTransport = Object.create(new ClassTransport()) - const conn = withOwnBuildLaunchEnv(transport, () => null) - expect(conn.describe('true')).toBe('ran:true') - await expect(conn.orcadLaunchEnv?.({ fullVersion: '0.1.0+own' })).resolves.toEqual([]) - }) -}) diff --git a/src/main/wsl/orcad/wsl-orcad-reconnect-backoff.test.ts b/src/main/wsl/orcad/wsl-orcad-reconnect-backoff.test.ts deleted file mode 100644 index f16b4ed215a1..000000000000 --- a/src/main/wsl/orcad/wsl-orcad-reconnect-backoff.test.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { - WSL_ORCAD_RECONNECT_DELAYS_MS, - WSL_ORCAD_STABLE_MS, - WSL_ORCAD_VERIFY_RETRY_CAP_MS, - WslOrcadReconnectBackoff, - wslOrcadVerifyRetryDelayMs -} from './wsl-orcad-reconnect-backoff' - -describe('WslOrcadReconnectBackoff', () => { - it('walks the ladder within its jitter bounds, then gives up', () => { - const backoff = new WslOrcadReconnectBackoff(() => 0.999) - for (const [index, floor] of WSL_ORCAD_RECONNECT_DELAYS_MS.entries()) { - const decision = backoff.next(0) - expect(decision.kind).toBe('retry') - if (decision.kind === 'retry') { - expect(decision.attempt).toBe(index + 1) - expect(decision.delayMs).toBeGreaterThanOrEqual(floor) - expect(decision.delayMs).toBeLessThanOrEqual(floor * 1.2) - } - } - expect(backoff.next(0)).toEqual({ - kind: 'give-up', - attempts: WSL_ORCAD_RECONNECT_DELAYS_MS.length - }) - }) - - it('restarts the ladder only after a stable stretch of monotonic time', () => { - const backoff = new WslOrcadReconnectBackoff(() => 0) - backoff.next(0) - backoff.next(0) - backoff.noteReady(1_000) - expect(backoff.next(1_000 + WSL_ORCAD_STABLE_MS - 1)).toMatchObject({ attempt: 3 }) - backoff.noteReady(5_000) - expect(backoff.next(5_000 + WSL_ORCAD_STABLE_MS)).toMatchObject({ attempt: 1 }) - }) - - it('is driven only by the monotonic time it is given, so a wall-clock jump changes nothing', () => { - const backoff = new WslOrcadReconnectBackoff(() => 0) - backoff.noteReady(10) - const realNow = Date.now - Date.now = () => realNow() + 365 * 24 * 3_600_000 - try { - backoff.next(20) - backoff.noteReady(30) - expect(backoff.next(40)).toMatchObject({ attempt: 2 }) - } finally { - Date.now = realNow - } - }) -}) - -describe('wslOrcadVerifyRetryDelayMs', () => { - it('doubles from a second and caps without ever giving up', () => { - expect(wslOrcadVerifyRetryDelayMs(0)).toBe(1_000) - expect(wslOrcadVerifyRetryDelayMs(1)).toBe(2_000) - expect(wslOrcadVerifyRetryDelayMs(50)).toBe(WSL_ORCAD_VERIFY_RETRY_CAP_MS) - }) -}) diff --git a/src/renderer/src/components/plugins/state/plugin-try-action.test.ts b/src/renderer/src/components/plugins/state/plugin-try-action.test.ts deleted file mode 100644 index 4f86cb64b957..000000000000 --- a/src/renderer/src/components/plugins/state/plugin-try-action.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { firstSyntaxExtension } from './plugin-try-action' - -describe('firstSyntaxExtension', () => { - it('takes the first extension any grammar declares', () => { - expect( - firstSyntaxExtension([ - { extensions: [] }, - { extensions: ['.vhd', '.vhdl'] }, - { extensions: ['.v'] } - ]) - ).toBe('.vhd') - }) - - it('is null when grammars only match file names', () => { - expect(firstSyntaxExtension([{ extensions: [] }])).toBeNull() - expect(firstSyntaxExtension([])).toBeNull() - }) -})