From c563f68df97aea1fa9592eefdb0106d6bf649b9c Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Mon, 2 Nov 2026 14:16:06 -0800 Subject: [PATCH] refactor: group workspace cleanup and space diagnostics (#37558) * refactor: organize workspace diagnostics and cleanup owners * test: target concrete cleanup and cancellation owners --- .../build-plugins/main-build-entry-points.ts | 4 ++- config/flaky-test-pattern-baseline.txt | 2 +- config/knip.json | 2 +- config/repo-host-read-baseline.txt | 6 ++-- config/scripts/ci-shard-timings.json | 30 +++++++++---------- config/worktree-id-composer-baseline.txt | 4 +-- src/main/ipc/localhost-worktree-labels.ts | 2 +- .../register-core-handlers.test.ts | 4 +-- .../register-core-handlers.ts | 4 +-- .../workspace-cleanup-activity.test.ts | 2 +- .../workspace-cleanup-activity.ts | 6 ++-- .../workspace-cleanup-broad-scan.test.ts | 24 +++++++-------- .../workspace-cleanup-candidate.ts | 10 +++---- .../workspace-cleanup-disconnected-ssh.ts | 19 +++++++----- ...orkspace-cleanup-document-lifetime.test.ts | 20 +++++++------ ...ace-cleanup-execution-host-routing.test.ts | 18 ++++++----- .../workspace-cleanup-folder-workspaces.ts | 16 +++++----- .../workspace-cleanup-git-evidence.ts | 14 ++++----- .../workspace-cleanup-git-route.ts | 8 ++--- .../workspace-cleanup-progress-emitter.ts | 2 +- .../workspace-cleanup-scan-eligibility.ts | 4 +-- .../workspace-cleanup-scan-primitives.ts | 6 ++-- .../workspace-cleanup-scan-targets.ts | 4 +-- .../workspace-cleanup-scan.ts | 16 +++++----- .../workspace-cleanup-snapshot-ipc.test.ts | 6 ++-- .../workspace-cleanup-worktree-listing.ts | 14 ++++----- .../workspace-cleanup.test.ts | 28 ++++++++--------- .../workspace-cleanup.ts | 16 +++++----- .../workspace-space-window.ts | 14 ++++----- .../workspace-space.test.ts | 13 ++++---- .../{ => workspace-space}/workspace-space.ts | 12 ++++---- ...thoritative-local-metadata-pruning.test.ts | 6 ++-- ...ktrees-automation-create-terminals.test.ts | 6 ++-- .../ipc/worktrees-background-removal.test.ts | 6 ++-- .../ipc/worktrees-create-event-timing.test.ts | 6 ++-- ...trees-create-label-only-first-work.test.ts | 6 ++-- ...ktrees-create-metadata-persistence.test.ts | 6 ++-- .../ipc/worktrees-create-registry.test.ts | 6 ++-- .../ipc/worktrees-delete-pty-teardown.test.ts | 6 ++-- .../ipc/worktrees-detected-scan-cache.test.ts | 6 ++-- ...ktrees-discovery-metadata-backfill.test.ts | 6 ++-- ...worktrees-existing-branch-checkout.test.ts | 6 ++-- src/main/ipc/worktrees-failed-removal.test.ts | 6 ++-- src/main/ipc/worktrees-forget-local.test.ts | 6 ++-- .../worktrees-issue-command-overrides.test.ts | 6 ++-- .../ipc/worktrees-lineage-hydration.test.ts | 6 ++-- .../worktrees-listing-fallback-rows.test.ts | 6 ++-- ...orktrees-local-base-ref-resolution.test.ts | 6 ++-- .../ipc/worktrees-local-create-flow.test.ts | 6 ++-- .../worktrees-local-create-path-claim.test.ts | 6 ++-- ...ees-mutation-scan-generation-order.test.ts | 6 ++-- ...worktrees-orphan-directory-cleanup.test.ts | 6 ++-- .../ipc/worktrees-removal-recovery.test.ts | 6 ++-- .../worktrees-remove-archive-hooks.test.ts | 6 ++-- .../ipc/worktrees-remove-preflight.test.ts | 6 ++-- ...trees-setup-launch-sparse-checkout.test.ts | 6 ++-- .../ipc/worktrees-ssh-pr-head-fetch.test.ts | 6 ++-- ...orktrees-ssh-repo-owner-resolution.test.ts | 6 ++-- .../ipc/worktrees-wsl-runtime-routing.test.ts | 6 ++-- ...itative-local-worktree-metadata-pruning.ts | 4 +-- .../listing/register-host-catalog-handlers.ts | 4 +-- .../localhost-worktree-label-proxy.test.ts | 0 .../localhost-worktree-label-proxy.ts | 4 +-- .../attach-main-window-services.test.ts | 4 +-- .../window/attach-main-window-services.ts | 2 +- ...ace-cleanup-removal-snapshot-prune.test.ts | 2 +- ...orkspace-cleanup-removal-snapshot-prune.ts | 4 +-- .../workspace-cleanup-scan-snapshot.test.ts | 4 +-- .../workspace-cleanup-scan-snapshot.ts | 6 ++-- .../workspace-snapshot-prune-index.ts | 2 +- .../workspace-space-analysis-capacity.test.ts | 12 ++++---- ...orkspace-space-analysis-du-timeout.test.ts | 8 ++--- .../workspace-space-analysis-snapshot.test.ts | 4 +-- .../workspace-space-analysis-snapshot.ts | 8 ++--- .../workspace-space-analysis.test.ts | 13 ++++---- .../workspace-space-analysis.ts | 10 +++---- .../workspace-space-local-scan.ts | 20 ++++++------- .../workspace-space-repo-scan.ts | 26 ++++++++-------- .../workspace-space-scan-control.test.ts | 0 .../workspace-space-scan-control.ts | 4 +-- .../workspace-space-scan-worker-client.ts | 13 ++++---- .../workspace-space-scan-worker-entry.ts | 0 .../workspace-space-scan-worker-protocol.ts | 6 ++-- .../workspace-space-worktree-row.ts | 10 +++---- src/main/worktree-removal-process-cleanup.ts | 8 ++--- 85 files changed, 342 insertions(+), 334 deletions(-) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-activity.test.ts (99%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-activity.ts (96%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-broad-scan.test.ts (96%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-candidate.ts (95%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-disconnected-ssh.ts (88%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-document-lifetime.test.ts (89%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-execution-host-routing.test.ts (91%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-folder-workspaces.ts (66%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-git-evidence.ts (89%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-git-route.ts (90%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-progress-emitter.ts (98%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-scan-eligibility.ts (84%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-scan-primitives.ts (94%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-scan-targets.ts (89%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-scan.ts (95%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-snapshot-ipc.test.ts (98%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup-worktree-listing.ts (81%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup.test.ts (96%) rename src/main/ipc/{ => workspace-cleanup}/workspace-cleanup.ts (93%) rename src/main/ipc/{ => workspace-space}/workspace-space-window.ts (86%) rename src/main/ipc/{ => workspace-space}/workspace-space.test.ts (94%) rename src/main/ipc/{ => workspace-space}/workspace-space.ts (91%) rename src/main/{ => ports/workspace-labels}/localhost-worktree-label-proxy.test.ts (100%) rename src/main/{ => ports/workspace-labels}/localhost-worktree-label-proxy.ts (98%) rename src/main/{ => workspaces/cleanup}/workspace-cleanup-removal-snapshot-prune.test.ts (98%) rename src/main/{ => workspaces/cleanup}/workspace-cleanup-removal-snapshot-prune.ts (97%) rename src/main/{ => workspaces/cleanup}/workspace-cleanup-scan-snapshot.test.ts (99%) rename src/main/{ => workspaces/cleanup}/workspace-cleanup-scan-snapshot.ts (98%) rename src/main/{ => workspaces/cleanup}/workspace-snapshot-prune-index.ts (95%) rename src/main/{ => workspaces/space-analysis}/workspace-space-analysis-capacity.test.ts (87%) rename src/main/{ => workspaces/space-analysis}/workspace-space-analysis-du-timeout.test.ts (95%) rename src/main/{ => workspaces/space-analysis}/workspace-space-analysis-snapshot.test.ts (99%) rename src/main/{ => workspaces/space-analysis}/workspace-space-analysis-snapshot.ts (98%) rename src/main/{ => workspaces/space-analysis}/workspace-space-analysis.test.ts (96%) rename src/main/{ => workspaces/space-analysis}/workspace-space-analysis.ts (93%) rename src/main/{ => workspaces/space-analysis}/workspace-space-local-scan.ts (91%) rename src/main/{ => workspaces/space-analysis}/workspace-space-repo-scan.ts (91%) rename src/main/{ => workspaces/space-analysis}/workspace-space-scan-control.test.ts (100%) rename src/main/{ => workspaces/space-analysis}/workspace-space-scan-control.ts (93%) rename src/main/{ => workspaces/space-analysis}/workspace-space-scan-worker-client.ts (83%) rename src/main/{ => workspaces/space-analysis}/workspace-space-scan-worker-entry.ts (100%) rename src/main/{ => workspaces/space-analysis}/workspace-space-scan-worker-protocol.ts (59%) rename src/main/{ => workspaces/space-analysis}/workspace-space-worktree-row.ts (88%) diff --git a/config/build-plugins/main-build-entry-points.ts b/config/build-plugins/main-build-entry-points.ts index 1e9252af09c..38447ba9063 100644 --- a/config/build-plugins/main-build-entry-points.ts +++ b/config/build-plugins/main-build-entry-points.ts @@ -39,7 +39,9 @@ export const MAIN_BUILD_ENTRY_POINTS: Record = { ), // Usage scans synchronously walk histories/SQLite; keep them off the main loop. 'usage-scan-worker-entry': resolve('src/main/usage/usage-scan-worker-entry.ts'), - 'workspace-space-scan-worker-entry': resolve('src/main/workspace-space-scan-worker-entry.ts'), + 'workspace-space-scan-worker-entry': resolve( + 'src/main/workspaces/space-analysis/workspace-space-scan-worker-entry.ts' + ), // Why: a first account setup can merge a large history tree with sync fs calls. 'claude-profile-setup-worker-entry': resolve( 'src/main/claude-accounts/claude-profile-setup-worker-entry.ts' diff --git a/config/flaky-test-pattern-baseline.txt b/config/flaky-test-pattern-baseline.txt index e5ee26a189c..05274cf79d4 100644 --- a/config/flaky-test-pattern-baseline.txt +++ b/config/flaky-test-pattern-baseline.txt @@ -326,7 +326,7 @@ 1 test-no-real-time-wait:src/main/ipc/rebinding-file-watch.test.ts 3 test-no-real-time-wait:src/main/ipc/runtime-environments/runtime-environment-preference.test.ts 5 test-no-real-time-wait:src/main/ipc/runtime-environments/runtime-environment-request-connections.test.ts -2 test-no-real-time-wait:src/main/ipc/workspace-cleanup-snapshot-ipc.test.ts +2 test-no-real-time-wait:src/main/ipc/workspace-cleanup/workspace-cleanup-snapshot-ipc.test.ts 1 test-no-real-time-wait:src/main/ipc/worktree-base-directory-poller-marker-fanout.test.ts 14 test-no-real-time-wait:src/main/ipc/worktree-base-directory-poller.test.ts 6 test-no-real-time-wait:src/main/ipc/worktree-git-common-polling.test.ts diff --git a/config/knip.json b/config/knip.json index 1995f10aac6..38409c4ba8f 100644 --- a/config/knip.json +++ b/config/knip.json @@ -42,7 +42,7 @@ "src/main/ai-vault/session-scanner-service-entry.ts", "src/main/native-chat/wsl-transcript-fs-process-entry.ts", "src/main/usage/usage-scan-worker-entry.ts", - "src/main/workspace-space-scan-worker-entry.ts", + "src/main/workspaces/space-analysis/workspace-space-scan-worker-entry.ts", "src/main/claude-accounts/claude-profile-setup-worker-entry.ts", "src/main/persistence/profile-state/profile-state-backup-worker-entry.ts", "src/main/persistence/profile-state/profile-state-writer-worker-entry.ts", diff --git a/config/repo-host-read-baseline.txt b/config/repo-host-read-baseline.txt index ea7ad72eb17..dbc73b8a062 100644 --- a/config/repo-host-read-baseline.txt +++ b/config/repo-host-read-baseline.txt @@ -15,8 +15,8 @@ 1 src/main/ipc/registered-worktree-root-owner.ts 4 src/main/ipc/repos/local-repo-registration.ts 1 src/main/ipc/repos/nested-repo-import-handler.ts -2 src/main/ipc/workspace-cleanup-candidate.ts -1 src/main/ipc/workspace-cleanup-disconnected-ssh.ts +2 src/main/ipc/workspace-cleanup/workspace-cleanup-candidate.ts +1 src/main/ipc/workspace-cleanup/workspace-cleanup-disconnected-ssh.ts 1 src/main/ipc/worktrees-test-metadata-pruning-store.ts 1 src/main/ipc/worktrees/listing/authoritative-local-worktree-metadata-pruning.ts 1 src/main/ipc/worktrees/listing/register-host-catalog-handlers.ts @@ -43,7 +43,7 @@ 3 src/main/runtime/runtime-reference-agents.ts 1 src/main/runtime/runtime-worktree-selection.ts 1 src/main/ssh/targets/ssh-target-orcad-claims.ts -1 src/main/workspace-space-worktree-row.ts +1 src/main/workspaces/space-analysis/workspace-space-worktree-row.ts 1 src/main/worktree-create-base-prefetch.ts 2 src/main/worktree-name-retirement.ts 1 src/shared/endpoint-catalog-adoption.ts diff --git a/config/scripts/ci-shard-timings.json b/config/scripts/ci-shard-timings.json index 58c2dfdf7a2..89e294953f2 100644 --- a/config/scripts/ci-shard-timings.json +++ b/config/scripts/ci-shard-timings.json @@ -3382,14 +3382,14 @@ "src/main/ipc/usage-provider-handlers-readiness.test.ts": 506, "src/main/ipc/watcher-event-root-path-rewrite.test.ts": 48, "src/main/ipc/watcher-removal-gate.test.ts": 384, - "src/main/ipc/workspace-cleanup-activity.test.ts": 76, - "src/main/ipc/workspace-cleanup-broad-scan.test.ts": 785, - "src/main/ipc/workspace-cleanup-document-lifetime.test.ts": 1130, - "src/main/ipc/workspace-cleanup-execution-host-routing.test.ts": 641, - "src/main/ipc/workspace-cleanup-snapshot-ipc.test.ts": 102, - "src/main/ipc/workspace-cleanup.test.ts": 2580, + "src/main/ipc/workspace-cleanup/workspace-cleanup-activity.test.ts": 76, + "src/main/ipc/workspace-cleanup/workspace-cleanup-broad-scan.test.ts": 785, + "src/main/ipc/workspace-cleanup/workspace-cleanup-document-lifetime.test.ts": 1130, + "src/main/ipc/workspace-cleanup/workspace-cleanup-execution-host-routing.test.ts": 641, + "src/main/ipc/workspace-cleanup/workspace-cleanup-snapshot-ipc.test.ts": 102, + "src/main/ipc/workspace-cleanup/workspace-cleanup.test.ts": 2580, "src/main/ipc/workspace-ports.test.ts": 101, - "src/main/ipc/workspace-space.test.ts": 60, + "src/main/ipc/workspace-space/workspace-space.test.ts": 60, "src/main/ipc/worktree-base-directory-event-filter.test.ts": 58, "src/main/ipc/worktree-base-directory-notifications.test.ts": 65, "src/main/ipc/worktree-base-directory-poller-marker-fanout.test.ts": 193, @@ -3576,7 +3576,7 @@ "src/main/local-worktree-path-presence.test.ts": 52, "src/main/local-worktree-removal-recovery-live.test.ts": 465, "src/main/local-worktree-removal-recovery.test.ts": 351, - "src/main/localhost-worktree-label-proxy.test.ts": 120, + "src/main/ports/workspace-labels/localhost-worktree-label-proxy.test.ts": 120, "src/main/macos-full-disk-access-status.test.ts": 42, "src/main/macos-press-and-hold-default.defaults-domain.test.ts": 76, "src/main/macos-press-and-hold-default.test.ts": 109, @@ -7082,14 +7082,14 @@ "src/main/worker-thread-child-process/worker-thread-child-output-flow.test.ts": 158, "src/main/worker-thread-child-process/worker-thread-child-process.test.ts": 602, "src/main/worker-thread-request-queue.test.ts": 83, - "src/main/workspace-cleanup-removal-snapshot-prune.test.ts": 60, - "src/main/workspace-cleanup-scan-snapshot.test.ts": 160, + "src/main/workspaces/cleanup/workspace-cleanup-removal-snapshot-prune.test.ts": 60, + "src/main/workspaces/cleanup/workspace-cleanup-scan-snapshot.test.ts": 160, "src/main/workspace-create-event-fields.test.ts": 265, - "src/main/workspace-space-analysis-capacity.test.ts": 711, - "src/main/workspace-space-analysis-du-timeout.test.ts": 899, - "src/main/workspace-space-analysis-snapshot.test.ts": 151, - "src/main/workspace-space-analysis.test.ts": 592, - "src/main/workspace-space-scan-control.test.ts": 56, + "src/main/workspaces/space-analysis/workspace-space-analysis-capacity.test.ts": 711, + "src/main/workspaces/space-analysis/workspace-space-analysis-du-timeout.test.ts": 899, + "src/main/workspaces/space-analysis/workspace-space-analysis-snapshot.test.ts": 151, + "src/main/workspaces/space-analysis/workspace-space-analysis.test.ts": 592, + "src/main/workspaces/space-analysis/workspace-space-scan-control.test.ts": 56, "src/main/worktree-background-removal-records.test.ts": 575, "src/main/worktree-background-removal.test.ts": 400, "src/main/worktree-create-base-prefetch.test.ts": 284, diff --git a/config/worktree-id-composer-baseline.txt b/config/worktree-id-composer-baseline.txt index e1811efef57..a9cebd82a1a 100644 --- a/config/worktree-id-composer-baseline.txt +++ b/config/worktree-id-composer-baseline.txt @@ -1,7 +1,7 @@ # Hand-built worktree ids (`${repoId}::${path}`) per file, outside src/shared/worktree/id.ts. # This is a RATCHET: counts may only go DOWN. Compose ids with composeWorktreeId or # getRepoMainWorktreeId instead. Prune after a fix: pnpm check:worktree-id-composer-ratchet --prune -1 src/main/ipc/workspace-cleanup-scan.ts +1 src/main/ipc/workspace-cleanup/workspace-cleanup-scan.ts 1 src/main/ipc/worktree-folder-rename-target.ts 1 src/main/ipc/worktree-metadata-merge.ts 1 src/main/ipc/worktree-push-target-reconciliation.ts @@ -14,6 +14,6 @@ 1 src/main/runtime/runtime-local-worktree-materialization.ts 1 src/main/runtime/runtime-managed-worktree-queries.ts 1 src/main/runtime/runtime-provisioned-root-adoption.ts -1 src/main/workspace-space-repo-scan.ts +1 src/main/workspaces/space-analysis/workspace-space-repo-scan.ts 1 src/main/worktree-lineage-pruning.ts 1 src/renderer/src/components/sidebar/DeleteNestedWorktreesDialog.tsx diff --git a/src/main/ipc/localhost-worktree-labels.ts b/src/main/ipc/localhost-worktree-labels.ts index 78fd7727b53..06df95a4f62 100644 --- a/src/main/ipc/localhost-worktree-labels.ts +++ b/src/main/ipc/localhost-worktree-labels.ts @@ -7,7 +7,7 @@ import { type LocalhostWorktreeLabelRoute } from '../../shared/localhost-worktree-labels' import type { Store } from '../persistence/loading-store/store' -import { localhostWorktreeLabelProxy } from '../localhost-worktree-label-proxy' +import { localhostWorktreeLabelProxy } from '../ports/workspace-labels/localhost-worktree-label-proxy' import { getStoreWorkspacePortProbes, scanWorkspacePortProbes diff --git a/src/main/ipc/register-core-handlers/register-core-handlers.test.ts b/src/main/ipc/register-core-handlers/register-core-handlers.test.ts index c48f796b2fa..cf9e83bb3a4 100644 --- a/src/main/ipc/register-core-handlers/register-core-handlers.test.ts +++ b/src/main/ipc/register-core-handlers/register-core-handlers.test.ts @@ -174,7 +174,7 @@ vi.mock('../dashboard-popout', () => ({ registerDashboardPopoutHandlers: registerDashboardPopoutHandlersMock })) -vi.mock('../workspace-space-window', () => ({ +vi.mock('../workspace-space/workspace-space-window', () => ({ registerWorkspaceSpaceWindowHandlers: registerWorkspaceSpaceWindowHandlersMock })) @@ -250,7 +250,7 @@ vi.mock('../skill-delete/handlers', () => ({ registerSkillDeleteIpcHandlers: registerSkillDeleteIpcHandlersMock })) -vi.mock('../workspace-space', () => ({ +vi.mock('../workspace-space/workspace-space', () => ({ registerWorkspaceSpaceHandlers: registerWorkspaceSpaceHandlersMock })) diff --git a/src/main/ipc/register-core-handlers/register-core-handlers.ts b/src/main/ipc/register-core-handlers/register-core-handlers.ts index ca5f9c16654..09f64060351 100644 --- a/src/main/ipc/register-core-handlers/register-core-handlers.ts +++ b/src/main/ipc/register-core-handlers/register-core-handlers.ts @@ -40,7 +40,7 @@ import { registerNotificationHandlers } from '../notifications' import { registerNotebookHandlers } from '../notebook' import { registerOnboardingHandlers } from '../onboarding' import { registerDashboardPopoutHandlers } from '../dashboard-popout' -import { registerWorkspaceSpaceWindowHandlers } from '../workspace-space-window' +import { registerWorkspaceSpaceWindowHandlers } from '../workspace-space/workspace-space-window' import { registerTerminalPreviewHandlers } from '../terminal-preview' import { registerDeveloperPermissionHandlers } from '../developer-permissions' import { registerComputerUsePermissionHandlers } from '../computer-use-permissions' @@ -51,7 +51,7 @@ import { registerSettingsHandlers } from '../settings' import { registerDiagnosticsHandlers } from '../diagnostics' import { registerSkillsHandlers } from '../skills' import { registerSkillDeleteIpcHandlers } from '../skill-delete/handlers' -import { registerWorkspaceSpaceHandlers } from '../workspace-space' +import { registerWorkspaceSpaceHandlers } from '../workspace-space/workspace-space' import { registerWorkspacePortHandlers } from '../workspace-ports' import { registerLinkPreviewHandlers } from '../link-preview' import { registerLocalhostWorktreeLabelHandlers } from '../localhost-worktree-labels' diff --git a/src/main/ipc/workspace-cleanup-activity.test.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-activity.test.ts similarity index 99% rename from src/main/ipc/workspace-cleanup-activity.test.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-activity.test.ts index 3a27ee87a4a..0689d98008d 100644 --- a/src/main/ipc/workspace-cleanup-activity.test.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-activity.test.ts @@ -2,7 +2,7 @@ import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import { describe, expect, it, vi } from 'vitest' -import type { Worktree } from '../../shared/worktree/types' +import type { Worktree } from '../../../shared/worktree/types' import { resolveWorkspaceCleanupActivityWorktree } from './workspace-cleanup-activity' import type { WorkspaceCleanupGitRoute } from './workspace-cleanup-git-route' diff --git a/src/main/ipc/workspace-cleanup-activity.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-activity.ts similarity index 96% rename from src/main/ipc/workspace-cleanup-activity.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-activity.ts index 83d68abf073..39abd5e245c 100644 --- a/src/main/ipc/workspace-cleanup-activity.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-activity.ts @@ -1,8 +1,8 @@ import { lstat, open, readFile } from 'node:fs/promises' import path from 'node:path' -import type { Worktree } from '../../shared/worktree/types' -import { resolveGitMetadataPath } from '../../shared/git-metadata-path' -import { getPersistedWorkspaceCleanupActivityAt } from '../../shared/workspace-cleanup' +import type { Worktree } from '../../../shared/worktree/types' +import { resolveGitMetadataPath } from '../../../shared/git-metadata-path' +import { getPersistedWorkspaceCleanupActivityAt } from '../../../shared/workspace-cleanup' import type { WorkspaceCleanupGitRoute } from './workspace-cleanup-git-route' type StatPath = (targetPath: string) => Promise<{ mtimeMs: number }> diff --git a/src/main/ipc/workspace-cleanup-broad-scan.test.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-broad-scan.test.ts similarity index 96% rename from src/main/ipc/workspace-cleanup-broad-scan.test.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-broad-scan.test.ts index 721ca593383..7b0f78bbd6d 100644 --- a/src/main/ipc/workspace-cleanup-broad-scan.test.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-broad-scan.test.ts @@ -1,12 +1,12 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import path from 'node:path' -import type { Store } from '../persistence/loading-store/store' -import type * as RepoWorktreesModule from '../repo-worktrees' -import type { GitStatusResult } from '../../shared/git-status-types' -import type { Repo } from '../../shared/repo-types' -import type { GitWorktreeInfo } from '../../shared/worktree/types' -import type { WorktreeMeta } from '../../shared/worktree/meta-types' -import { WORKSPACE_CLEANUP_TARGET_BATCH_LIMIT } from '../../shared/workspace-cleanup' +import type { Store } from '../../persistence/loading-store/store' +import type * as RepoWorktreesModule from '../../repo-worktrees' +import type { GitStatusResult } from '../../../shared/git-status-types' +import type { Repo } from '../../../shared/repo-types' +import type { GitWorktreeInfo } from '../../../shared/worktree/types' +import type { WorktreeMeta } from '../../../shared/worktree/meta-types' +import { WORKSPACE_CLEANUP_TARGET_BATCH_LIMIT } from '../../../shared/workspace-cleanup' const { lstatMock, @@ -29,23 +29,23 @@ vi.mock('node:fs/promises', () => ({ readFile: readFileMock })) -vi.mock('../repo-worktrees', async () => { - const actual = await vi.importActual('../repo-worktrees') +vi.mock('../../repo-worktrees', async () => { + const actual = await vi.importActual('../../repo-worktrees') return { listRepoWorktrees: listRepoWorktreesMock, createFolderWorktree: actual.createFolderWorktree } }) -vi.mock('../git/status', () => ({ +vi.mock('../../git/source-control/status-read', () => ({ getStatus: getStatusMock })) -vi.mock('../git/runner', () => ({ +vi.mock('../../git/command-runner/git-exec-file', () => ({ gitExecFileAsync: gitExecFileAsyncMock })) -vi.mock('../project-runtime-git-options', () => ({ +vi.mock('../../project-runtime-git-options', () => ({ getLocalProjectWorktreeGitOptions: getLocalProjectWorktreeGitOptionsMock })) diff --git a/src/main/ipc/workspace-cleanup-candidate.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-candidate.ts similarity index 95% rename from src/main/ipc/workspace-cleanup-candidate.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-candidate.ts index bcfc3afeda6..e35698f98f1 100644 --- a/src/main/ipc/workspace-cleanup-candidate.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-candidate.ts @@ -1,7 +1,7 @@ -import { isFolderRepo } from '../../shared/repo-kind' -import type { Repo } from '../../shared/repo-types' -import type { Worktree } from '../../shared/worktree/types' -import { getWorktreeExecutionHostId } from '../../shared/execution-host' +import { isFolderRepo } from '../../../shared/repo-kind' +import type { Repo } from '../../../shared/repo-types' +import type { Worktree } from '../../../shared/worktree/types' +import { getWorktreeExecutionHostId } from '../../../shared/execution-host' import { applyWorkspaceCleanupPolicy, createWorkspaceCleanupFingerprint, @@ -10,7 +10,7 @@ import { type WorkspaceCleanupBlocker, type WorkspaceCleanupCandidate, type WorkspaceCleanupReason -} from '../../shared/workspace-cleanup' +} from '../../../shared/workspace-cleanup' import { createEmptyWorkspaceCleanupGitEvidence, readWorkspaceCleanupGitEvidence diff --git a/src/main/ipc/workspace-cleanup-disconnected-ssh.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-disconnected-ssh.ts similarity index 88% rename from src/main/ipc/workspace-cleanup-disconnected-ssh.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-disconnected-ssh.ts index c6dd14b4311..644d65f0a58 100644 --- a/src/main/ipc/workspace-cleanup-disconnected-ssh.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-disconnected-ssh.ts @@ -1,24 +1,27 @@ import { basename } from 'node:path' -import { getRepoExecutionHostId, normalizeExecutionHostId } from '../../shared/execution-host' -import type { Store } from '../persistence/loading-store/store' -import type { Repo } from '../../shared/repo-types' -import type { WorktreeMeta } from '../../shared/worktree/meta-types' +import { getRepoExecutionHostId, normalizeExecutionHostId } from '../../../shared/execution-host' +import type { Store } from '../../persistence/loading-store/store' +import type { Repo } from '../../../shared/repo-types' +import type { WorktreeMeta } from '../../../shared/worktree/meta-types' import { applyWorkspaceCleanupPolicy, createWorkspaceCleanupFingerprint, type WorkspaceCleanupCandidate -} from '../../shared/workspace-cleanup' -import { splitWorktreeIdForFilesystem } from '../../shared/worktree/id' +} from '../../../shared/workspace-cleanup' +import { splitWorktreeIdForFilesystem } from '../../../shared/worktree/id' import { getNewestWorkspaceCleanupDiffCommentAt, getWorkspaceCleanupInactivityReasonsForWorkspace, isWorkspaceInactiveForCleanup } from './workspace-cleanup-candidate' -import { getRepoOwnedWorktreeMeta, isWorktreeMetaOwnedByRepo } from '../worktree-metadata-ownership' +import { + getRepoOwnedWorktreeMeta, + isWorktreeMetaOwnedByRepo +} from '../../worktree-metadata-ownership' import { readAllWorktreeMetaForHost, readWorktreeMetaForHost -} from '../persistence/host-qualified-worktree-meta' +} from '../../persistence/host-qualified-worktree-meta' export function synthesizeDisconnectedSshCleanupCandidates( store: Store, diff --git a/src/main/ipc/workspace-cleanup-document-lifetime.test.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-document-lifetime.test.ts similarity index 89% rename from src/main/ipc/workspace-cleanup-document-lifetime.test.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-document-lifetime.test.ts index aee7d26a0a6..96a49a4904e 100644 --- a/src/main/ipc/workspace-cleanup-document-lifetime.test.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-document-lifetime.test.ts @@ -1,8 +1,8 @@ import { EventEmitter } from 'node:events' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type { GitStatusResult } from '../../shared/git-status-types' -import type { GitWorktreeInfo } from '../../shared/worktree/types' -import type * as RepoWorktrees from '../repo-worktrees' +import type { GitStatusResult } from '../../../shared/git-status-types' +import type { GitWorktreeInfo } from '../../../shared/worktree/types' +import type * as RepoWorktrees from '../../repo-worktrees' const boundary = vi.hoisted(() => ({ handlers: new Map unknown>(), @@ -23,20 +23,22 @@ vi.mock('node:fs/promises', () => ({ throw new Error('no gitdir pointer') }) })) -vi.mock('../repo-worktrees', async (importOriginal) => ({ +vi.mock('../../repo-worktrees', async (importOriginal) => ({ ...(await importOriginal()), listRepoWorktrees: boundary.list })) -vi.mock('../git/status', () => ({ getStatus: boundary.status })) -vi.mock('../git/runner', () => ({ +vi.mock('../../git/source-control/status-read', () => ({ getStatus: boundary.status })) +vi.mock('../../git/command-runner/git-exec-file', () => ({ gitExecFileAsync: vi.fn(async () => ({ stdout: '0\n', stderr: '' })) })) -vi.mock('../project-runtime-git-options', () => ({ getLocalProjectWorktreeGitOptions: () => ({}) })) -vi.mock('../workspace-cleanup-scan-snapshot', () => ({ +vi.mock('../../project-runtime-git-options', () => ({ + getLocalProjectWorktreeGitOptions: () => ({}) +})) +vi.mock('../../workspaces/cleanup/workspace-cleanup-scan-snapshot', () => ({ persistWorkspaceCleanupScanResult: boundary.persist, readWorkspaceCleanupScanSnapshot: vi.fn() })) -vi.mock('../workspace-cleanup-removal-snapshot-prune', () => ({ +vi.mock('../../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', () => ({ beginWorkspaceCleanupRemovalSnapshotPruneBatch: vi.fn(), finishWorkspaceCleanupRemovalSnapshotPruneBatch: vi.fn(), recordWorkspaceCleanupRemovalSnapshotPrune: vi.fn() diff --git a/src/main/ipc/workspace-cleanup-execution-host-routing.test.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-execution-host-routing.test.ts similarity index 91% rename from src/main/ipc/workspace-cleanup-execution-host-routing.test.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-execution-host-routing.test.ts index 162d07bfc5d..c7794c37b04 100644 --- a/src/main/ipc/workspace-cleanup-execution-host-routing.test.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-execution-host-routing.test.ts @@ -1,8 +1,8 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type { Store } from '../persistence/loading-store/store' -import type { GitStatusResult } from '../../shared/git-status-types' -import type { Repo } from '../../shared/repo-types' -import type { WorktreeMeta } from '../../shared/worktree/meta-types' +import type { Store } from '../../persistence/loading-store/store' +import type { GitStatusResult } from '../../../shared/git-status-types' +import type { Repo } from '../../../shared/repo-types' +import type { WorktreeMeta } from '../../../shared/worktree/meta-types' const { lstatMock, @@ -28,15 +28,17 @@ vi.mock('node:fs/promises', () => ({ open: openMock })) -vi.mock('../repo-worktrees', () => ({ +vi.mock('../../repo-worktrees', () => ({ listRepoWorktrees: listRepoWorktreesMock, createFolderWorktree: vi.fn() })) -vi.mock('../git/status', () => ({ getStatus: getStatusMock })) -vi.mock('../git/runner', () => ({ gitExecFileAsync: gitExecFileAsyncMock })) +vi.mock('../../git/source-control/status-read', () => ({ getStatus: getStatusMock })) +vi.mock('../../git/command-runner/git-exec-file', () => ({ + gitExecFileAsync: gitExecFileAsyncMock +})) -vi.mock('../project-runtime-git-options', () => ({ +vi.mock('../../project-runtime-git-options', () => ({ getLocalProjectWorktreeGitOptions: getLocalProjectWorktreeGitOptionsMock })) diff --git a/src/main/ipc/workspace-cleanup-folder-workspaces.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-folder-workspaces.ts similarity index 66% rename from src/main/ipc/workspace-cleanup-folder-workspaces.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-folder-workspaces.ts index 79cff68b351..a9016487866 100644 --- a/src/main/ipc/workspace-cleanup-folder-workspaces.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-folder-workspaces.ts @@ -1,14 +1,14 @@ -import type { Store } from '../persistence/loading-store/store' -import { createFolderWorktree } from '../repo-worktrees' -import type { Repo } from '../../shared/repo-types' -import type { Worktree } from '../../shared/worktree/types' -import type { WorktreeMeta } from '../../shared/worktree/meta-types' +import type { Store } from '../../persistence/loading-store/store' +import { createFolderWorktree } from '../../repo-worktrees' +import type { Repo } from '../../../shared/repo-types' +import type { Worktree } from '../../../shared/worktree/types' +import type { WorktreeMeta } from '../../../shared/worktree/meta-types' import { FOLDER_WORKSPACE_INSTANCE_SEPARATOR, getRepoMainWorktreeId -} from '../../shared/worktree/id' -import { mergeWorktree } from './worktree-metadata-merge' -import { getRepoOwnedWorktreeMeta } from '../worktree-metadata-ownership' +} from '../../../shared/worktree/id' +import { mergeWorktree } from '../worktree-metadata-merge' +import { getRepoOwnedWorktreeMeta } from '../../worktree-metadata-ownership' export function listWorkspaceCleanupFolderWorkspaces( store: Store, diff --git a/src/main/ipc/workspace-cleanup-git-evidence.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-git-evidence.ts similarity index 89% rename from src/main/ipc/workspace-cleanup-git-evidence.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-git-evidence.ts index 128332424d5..476abaaad09 100644 --- a/src/main/ipc/workspace-cleanup-git-evidence.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-git-evidence.ts @@ -1,15 +1,15 @@ -import { getStatus } from '../git/status' -import { gitExecFileAsync } from '../git/runner' -import type { GitStatusResult } from '../../shared/git-status-types' -import type { Repo } from '../../shared/repo-types' -import type { Worktree } from '../../shared/worktree/types' -import type { WorkspaceCleanupBlocker } from '../../shared/workspace-cleanup' +import { getStatus } from '../../git/source-control/status-read' +import { gitExecFileAsync } from '../../git/command-runner/git-exec-file' +import type { GitStatusResult } from '../../../shared/git-status-types' +import type { Repo } from '../../../shared/repo-types' +import type { Worktree } from '../../../shared/worktree/types' +import type { WorkspaceCleanupBlocker } from '../../../shared/workspace-cleanup' import { WORKSPACE_CLEANUP_GIT_READ_TIMEOUT_MS, WorkspaceCleanupScanCancelledError, withWorkspaceCleanupTimeout } from './workspace-cleanup-scan-primitives' -import { getWorktreeSharedLinkPaths } from '../git/worktree-shared-directories' +import { getWorktreeSharedLinkPaths } from '../../git/worktree-shared-directories' import { resolveWorkspaceCleanupWorktreeGitRoute, type WorkspaceCleanupGitRoute diff --git a/src/main/ipc/workspace-cleanup-git-route.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-git-route.ts similarity index 90% rename from src/main/ipc/workspace-cleanup-git-route.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-git-route.ts index cadbc7b2b32..019c6ea7fd5 100644 --- a/src/main/ipc/workspace-cleanup-git-route.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-git-route.ts @@ -6,13 +6,13 @@ import { getWorktreeExecutionHostId, LOCAL_EXECUTION_HOST_ID, type ExecutionHostId -} from '../../shared/execution-host' -import type { Repo } from '../../shared/repo-types' -import type { Worktree } from '../../shared/worktree/types' +} from '../../../shared/execution-host' +import type { Repo } from '../../../shared/repo-types' +import type { Worktree } from '../../../shared/worktree/types' import { ExecutionHostNotDispatchableError, resolveGitRouteForHost -} from '../providers/execution-host-provider-dispatch' +} from '../../providers/execution-host-provider-dispatch' export type WorkspaceCleanupGitRoute = | { kind: 'local'; hostId: typeof LOCAL_EXECUTION_HOST_ID } diff --git a/src/main/ipc/workspace-cleanup-progress-emitter.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-progress-emitter.ts similarity index 98% rename from src/main/ipc/workspace-cleanup-progress-emitter.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-progress-emitter.ts index 7a2a5394963..9d106b25439 100644 --- a/src/main/ipc/workspace-cleanup-progress-emitter.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-progress-emitter.ts @@ -2,7 +2,7 @@ import type { WorkspaceCleanupCandidate, WorkspaceCleanupScanError, WorkspaceCleanupScanProgress -} from '../../shared/workspace-cleanup' +} from '../../../shared/workspace-cleanup' import { appendWorkspaceCleanupItems } from './workspace-cleanup-scan-primitives' const WORKSPACE_CLEANUP_PROGRESS_EMIT_INTERVAL_MS = 100 diff --git a/src/main/ipc/workspace-cleanup-scan-eligibility.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-scan-eligibility.ts similarity index 84% rename from src/main/ipc/workspace-cleanup-scan-eligibility.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-scan-eligibility.ts index efbaf2a4d81..72472526eb6 100644 --- a/src/main/ipc/workspace-cleanup-scan-eligibility.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-scan-eligibility.ts @@ -1,5 +1,5 @@ -import type { Worktree } from '../../shared/worktree/types' -import { getPersistedWorkspaceCleanupActivityAt } from '../../shared/workspace-cleanup' +import type { Worktree } from '../../../shared/worktree/types' +import { getPersistedWorkspaceCleanupActivityAt } from '../../../shared/workspace-cleanup' import { isWorkspaceInactiveForCleanup } from './workspace-cleanup-candidate' /** Preserve suggestion-only broad scans for older clients; full-list coverage requires explicit opt-in. */ diff --git a/src/main/ipc/workspace-cleanup-scan-primitives.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-scan-primitives.ts similarity index 94% rename from src/main/ipc/workspace-cleanup-scan-primitives.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-scan-primitives.ts index 21b8f0a90d9..6366386fe2c 100644 --- a/src/main/ipc/workspace-cleanup-scan-primitives.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-scan-primitives.ts @@ -1,7 +1,7 @@ import { basename } from 'node:path' -import { getRepoExecutionHostId } from '../../shared/execution-host' -import type { Repo } from '../../shared/repo-types' -import type { WorkspaceCleanupScanError } from '../../shared/workspace-cleanup' +import { getRepoExecutionHostId } from '../../../shared/execution-host' +import type { Repo } from '../../../shared/repo-types' +import type { WorkspaceCleanupScanError } from '../../../shared/workspace-cleanup' export const WORKSPACE_CLEANUP_GIT_READ_TIMEOUT_MS = 8_000 diff --git a/src/main/ipc/workspace-cleanup-scan-targets.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-scan-targets.ts similarity index 89% rename from src/main/ipc/workspace-cleanup-scan-targets.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-scan-targets.ts index b437c13736e..bc3a48c1ffa 100644 --- a/src/main/ipc/workspace-cleanup-scan-targets.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-scan-targets.ts @@ -1,8 +1,8 @@ -import { splitWorktreeId } from '../../shared/worktree/id' +import { splitWorktreeId } from '../../../shared/worktree/id' import { WORKSPACE_CLEANUP_TARGET_BATCH_LIMIT, type WorkspaceCleanupScanArgs -} from '../../shared/workspace-cleanup' +} from '../../../shared/workspace-cleanup' export function hasTargetedWorkspaceCleanupScan(args: WorkspaceCleanupScanArgs): boolean { return typeof args.worktreeId === 'string' || Array.isArray(args.worktreeIds) diff --git a/src/main/ipc/workspace-cleanup-scan.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-scan.ts similarity index 95% rename from src/main/ipc/workspace-cleanup-scan.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-scan.ts index f91e4aef9c1..406343c62ac 100644 --- a/src/main/ipc/workspace-cleanup-scan.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-scan.ts @@ -1,15 +1,15 @@ -import type { Store } from '../persistence/loading-store/store' -import { isFolderRepo } from '../../shared/repo-kind' -import { readWorktreeMetaForHost } from '../persistence/host-qualified-worktree-meta' -import type { Repo } from '../../shared/repo-types' -import type { GitWorktreeInfo, Worktree } from '../../shared/worktree/types' -import { mergeWorktree } from './worktree-metadata-merge' +import type { Store } from '../../persistence/loading-store/store' +import { isFolderRepo } from '../../../shared/repo-kind' +import { readWorktreeMetaForHost } from '../../persistence/host-qualified-worktree-meta' +import type { Repo } from '../../../shared/repo-types' +import type { GitWorktreeInfo, Worktree } from '../../../shared/worktree/types' +import { mergeWorktree } from '../worktree-metadata-merge' import type { WorkspaceCleanupCandidate, WorkspaceCleanupScanArgs, WorkspaceCleanupScanError, WorkspaceCleanupScanResult -} from '../../shared/workspace-cleanup' +} from '../../../shared/workspace-cleanup' import { handleRepoWorktreeListError, listCleanupGitWorktrees @@ -44,7 +44,7 @@ import { getTargetWorktreeIdsByRepo, hasTargetedWorkspaceCleanupScan } from './workspace-cleanup-scan-targets' -import { isWorktreeMetaOwnedByRepo } from '../worktree-metadata-ownership' +import { isWorktreeMetaOwnedByRepo } from '../../worktree-metadata-ownership' const WORKTREE_SCAN_CONCURRENCY = 3 // Overlap repo scans to avoid summing SSH listing round-trip latency. diff --git a/src/main/ipc/workspace-cleanup-snapshot-ipc.test.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-snapshot-ipc.test.ts similarity index 98% rename from src/main/ipc/workspace-cleanup-snapshot-ipc.test.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-snapshot-ipc.test.ts index 3e617cb9b1d..b17d4f1c954 100644 --- a/src/main/ipc/workspace-cleanup-snapshot-ipc.test.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-snapshot-ipc.test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import { ipcMain } from 'electron' -import type { Store } from '../persistence/loading-store/store' +import type { Store } from '../../persistence/loading-store/store' const { persistScanResultMock, readScanSnapshotMock, scanWorkspaceCleanupMock } = vi.hoisted( () => ({ @@ -23,7 +23,7 @@ vi.mock('electron', () => ({ } })) -vi.mock('../workspace-cleanup-scan-snapshot', () => ({ +vi.mock('../../workspaces/cleanup/workspace-cleanup-scan-snapshot', () => ({ persistWorkspaceCleanupScanResult: persistScanResultMock, readWorkspaceCleanupScanSnapshot: readScanSnapshotMock })) @@ -32,7 +32,7 @@ vi.mock('./workspace-cleanup-scan', () => ({ scanWorkspaceCleanup: scanWorkspaceCleanupMock })) -vi.mock('../workspace-cleanup-removal-snapshot-prune', () => ({ +vi.mock('../../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', () => ({ beginWorkspaceCleanupRemovalSnapshotPruneBatch: beginPruneBatchMock, finishWorkspaceCleanupRemovalSnapshotPruneBatch: finishPruneBatchMock, recordWorkspaceCleanupRemovalSnapshotPrune: recordPruneMock diff --git a/src/main/ipc/workspace-cleanup-worktree-listing.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup-worktree-listing.ts similarity index 81% rename from src/main/ipc/workspace-cleanup-worktree-listing.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup-worktree-listing.ts index 81016c69603..51d162c9aca 100644 --- a/src/main/ipc/workspace-cleanup-worktree-listing.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup-worktree-listing.ts @@ -1,24 +1,24 @@ -import type { Store } from '../persistence/loading-store/store' -import { listRepoWorktrees, createFolderWorktree } from '../repo-worktrees' -import type { Repo } from '../../shared/repo-types' -import type { GitWorktreeInfo } from '../../shared/worktree/types' +import type { Store } from '../../persistence/loading-store/store' +import { listRepoWorktrees, createFolderWorktree } from '../../repo-worktrees' +import type { Repo } from '../../../shared/repo-types' +import type { GitWorktreeInfo } from '../../../shared/worktree/types' import type { WorkspaceCleanupScanError, WorkspaceCleanupScanResult -} from '../../shared/workspace-cleanup' +} from '../../../shared/workspace-cleanup' import { WORKSPACE_CLEANUP_GIT_READ_TIMEOUT_MS, createWorkspaceCleanupScanError, toSafeWorkspaceCleanupRepoScanError, withWorkspaceCleanupTimeout } from './workspace-cleanup-scan-primitives' -import { ExecutionHostNotDispatchableError } from '../providers/execution-host-provider-dispatch' +import { ExecutionHostNotDispatchableError } from '../../providers/execution-host-provider-dispatch' import { isRemoteWorkspaceCleanupHost, resolveWorkspaceCleanupRepoGitRoute, type WorkspaceCleanupGitRoute } from './workspace-cleanup-git-route' -import { getLocalProjectWorktreeGitOptions } from '../project-runtime-git-options' +import { getLocalProjectWorktreeGitOptions } from '../../project-runtime-git-options' export async function listCleanupGitWorktrees( store: Store, diff --git a/src/main/ipc/workspace-cleanup.test.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup.test.ts similarity index 96% rename from src/main/ipc/workspace-cleanup.test.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup.test.ts index 73148581cbb..1f99653ae39 100644 --- a/src/main/ipc/workspace-cleanup.test.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup.test.ts @@ -1,13 +1,13 @@ import path from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { ipcMain } from 'electron' -import type { Store } from '../persistence/loading-store/store' -import type { DiffComment } from '../../shared/diff-comment-types' -import type { GitStatusResult } from '../../shared/git-status-types' -import type { Repo } from '../../shared/repo-types' -import type { WorktreeMeta } from '../../shared/worktree/meta-types' -import type { GitWorktreeInfo } from '../../shared/worktree/types' -import type { WorkspaceCleanupScanProgress } from '../../shared/workspace-cleanup' +import type { Store } from '../../persistence/loading-store/store' +import type { DiffComment } from '../../../shared/diff-comment-types' +import type { GitStatusResult } from '../../../shared/git-status-types' +import type { Repo } from '../../../shared/repo-types' +import type { WorktreeMeta } from '../../../shared/worktree/meta-types' +import type { GitWorktreeInfo } from '../../../shared/worktree/types' +import type { WorkspaceCleanupScanProgress } from '../../../shared/workspace-cleanup' const { lstatMock, @@ -39,34 +39,34 @@ vi.mock('electron', () => ({ } })) -vi.mock('../repo-worktrees', () => ({ +vi.mock('../../repo-worktrees', () => ({ listRepoWorktrees: listRepoWorktreesMock, createFolderWorktree: vi.fn() })) -vi.mock('../git/status', () => ({ +vi.mock('../../git/source-control/status-read', () => ({ getStatus: getStatusMock })) -vi.mock('../git/runner', () => ({ +vi.mock('../../git/command-runner/git-exec-file', () => ({ gitExecFileAsync: gitExecFileAsyncMock })) -vi.mock('../project-runtime-git-options', () => ({ +vi.mock('../../project-runtime-git-options', () => ({ getLocalProjectWorktreeGitOptions: getLocalProjectWorktreeGitOptionsMock })) -vi.mock('../memory/pty-registry', () => ({ +vi.mock('../../memory/pty-registry', () => ({ listRegisteredPtys: listRegisteredPtysMock })) // Real snapshot persistence is covered in workspace-cleanup-snapshot-ipc.test.ts. -vi.mock('../workspace-cleanup-scan-snapshot', () => ({ +vi.mock('../../workspaces/cleanup/workspace-cleanup-scan-snapshot', () => ({ persistWorkspaceCleanupScanResult: vi.fn(async () => undefined), readWorkspaceCleanupScanSnapshot: vi.fn(async () => null) })) -import { scanWorkspaceCleanup } from './workspace-cleanup' +import { scanWorkspaceCleanup } from './workspace-cleanup-scan' const NOW = 1_700_000_000_000 const REPO: Repo = { diff --git a/src/main/ipc/workspace-cleanup.ts b/src/main/ipc/workspace-cleanup/workspace-cleanup.ts similarity index 93% rename from src/main/ipc/workspace-cleanup.ts rename to src/main/ipc/workspace-cleanup/workspace-cleanup.ts index aaadaab4f11..3f6fca66cec 100644 --- a/src/main/ipc/workspace-cleanup.ts +++ b/src/main/ipc/workspace-cleanup/workspace-cleanup.ts @@ -1,5 +1,5 @@ import { ipcMain } from 'electron' -import type { Store } from '../persistence/loading-store/store' +import type { Store } from '../../persistence/loading-store/store' import { WORKSPACE_CLEANUP_CLASSIFIER_VERSION, type WorkspaceCleanupDismissArgs, @@ -7,23 +7,21 @@ import { type WorkspaceCleanupScanResult, type WorkspaceCleanupSnapshotPruneBatchArgs, type WorkspaceCleanupSnapshotPruneRecordArgs -} from '../../shared/workspace-cleanup' -import { parseExecutionHostId } from '../../shared/execution-host' -import { getWorkspaceCleanupHostIdentity } from '../../shared/workspace-cleanup-host-identity' +} from '../../../shared/workspace-cleanup' +import { parseExecutionHostId } from '../../../shared/execution-host' +import { getWorkspaceCleanupHostIdentity } from '../../../shared/workspace-cleanup-host-identity' import { scanWorkspaceCleanup } from './workspace-cleanup-scan' -import { abortWhenRendererGone } from './renderer-lifetime-abort' +import { abortWhenRendererGone } from '../renderer-lifetime-abort' import { hasTargetedWorkspaceCleanupScan } from './workspace-cleanup-scan-targets' import { persistWorkspaceCleanupScanResult, readWorkspaceCleanupScanSnapshot -} from '../workspace-cleanup-scan-snapshot' +} from '../../workspaces/cleanup/workspace-cleanup-scan-snapshot' import { beginWorkspaceCleanupRemovalSnapshotPruneBatch, finishWorkspaceCleanupRemovalSnapshotPruneBatch, recordWorkspaceCleanupRemovalSnapshotPrune -} from '../workspace-cleanup-removal-snapshot-prune' - -export { scanWorkspaceCleanup } +} from '../../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune' // Module scope preserves old-window scan cancellation across handler re-registration. const activeScans = new Map() diff --git a/src/main/ipc/workspace-space-window.ts b/src/main/ipc/workspace-space/workspace-space-window.ts similarity index 86% rename from src/main/ipc/workspace-space-window.ts rename to src/main/ipc/workspace-space/workspace-space-window.ts index 9b86fde7ef4..eafab75ca8d 100644 --- a/src/main/ipc/workspace-space-window.ts +++ b/src/main/ipc/workspace-space/workspace-space-window.ts @@ -1,15 +1,15 @@ import { BrowserWindow, ipcMain } from 'electron' -import { getTrustedUIRendererWebContents, isTrustedUIRenderer } from './ui' +import { getTrustedUIRendererWebContents, isTrustedUIRenderer } from '../ui' import { createOrFocusWorkspaceSpaceWindow, getWorkspaceSpaceWindow, isWorkspaceSpaceWindowRenderer -} from '../window/workspace-space-window' -import { safelyRevealWindow } from '../window/focus-existing-window' -import { isBackgroundLaunch } from '../window/foreground-activation-policy' -import { normalizeExecutionHostId } from '../../shared/execution-host' -import { isWorkspaceSpaceChange } from '../../shared/workspace-space-change' -import type { Store } from '../persistence/loading-store/store' +} from '../../window/workspace-space-window' +import { safelyRevealWindow } from '../../window/focus-existing-window' +import { isBackgroundLaunch } from '../../window/foreground-activation-policy' +import { normalizeExecutionHostId } from '../../../shared/execution-host' +import { isWorkspaceSpaceChange } from '../../../shared/workspace-space-change' +import type { Store } from '../../persistence/loading-store/store' export function registerWorkspaceSpaceWindowHandlers(store: Store): void { for (const channel of [ diff --git a/src/main/ipc/workspace-space.test.ts b/src/main/ipc/workspace-space/workspace-space.test.ts similarity index 94% rename from src/main/ipc/workspace-space.test.ts rename to src/main/ipc/workspace-space/workspace-space.test.ts index edd288d6dba..65f62243a46 100644 --- a/src/main/ipc/workspace-space.test.ts +++ b/src/main/ipc/workspace-space/workspace-space.test.ts @@ -3,8 +3,8 @@ import type { WorkspaceSpaceAnalysis, WorkspaceSpaceAnalyzeResult, WorkspaceSpaceScanProgress -} from '../../shared/workspace-space-types' -import type { Store } from '../persistence/loading-store/store' +} from '../../../shared/workspace-space-types' +import type { Store } from '../../persistence/loading-store/store' const { handlers, @@ -36,12 +36,15 @@ vi.mock('electron', () => ({ } })) -vi.mock('../workspace-space-analysis', () => ({ - WorkspaceSpaceScanCancelledError: WorkspaceSpaceScanCancelledErrorMock, +vi.mock('../../workspaces/space-analysis/workspace-space-analysis', () => ({ analyzeWorkspaceSpace: analyzeWorkspaceSpaceMock })) -vi.mock('../workspace-space-analysis-snapshot', () => ({ +vi.mock('../../workspaces/space-analysis/workspace-space-scan-control', () => ({ + WorkspaceSpaceScanCancelledError: WorkspaceSpaceScanCancelledErrorMock +})) + +vi.mock('../../workspaces/space-analysis/workspace-space-analysis-snapshot', () => ({ persistWorkspaceSpaceAnalysisSnapshot: persistAnalysisSnapshotMock, readWorkspaceSpaceAnalysisSnapshot: readAnalysisSnapshotMock })) diff --git a/src/main/ipc/workspace-space.ts b/src/main/ipc/workspace-space/workspace-space.ts similarity index 91% rename from src/main/ipc/workspace-space.ts rename to src/main/ipc/workspace-space/workspace-space.ts index b5b77ae1ea0..1b1550e1acd 100644 --- a/src/main/ipc/workspace-space.ts +++ b/src/main/ipc/workspace-space/workspace-space.ts @@ -1,19 +1,17 @@ import { ipcMain } from 'electron' -import type { Store } from '../persistence/loading-store/store' +import type { Store } from '../../persistence/loading-store/store' import type { WorkspaceSpaceAnalysis, WorkspaceSpaceAnalyzeResult, WorkspaceSpaceScanProgress, WorkspaceSpaceWorktreeMeasurement -} from '../../shared/workspace-space-types' -import { - analyzeWorkspaceSpace, - WorkspaceSpaceScanCancelledError -} from '../workspace-space-analysis' +} from '../../../shared/workspace-space-types' +import { analyzeWorkspaceSpace } from '../../workspaces/space-analysis/workspace-space-analysis' +import { WorkspaceSpaceScanCancelledError } from '../../workspaces/space-analysis/workspace-space-scan-control' import { persistWorkspaceSpaceAnalysisSnapshot, readWorkspaceSpaceAnalysisSnapshot -} from '../workspace-space-analysis-snapshot' +} from '../../workspaces/space-analysis/workspace-space-analysis-snapshot' const PROGRESS_EMIT_INTERVAL_MS = 100 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 5cd1250939f..23272149d49 100644 --- a/src/main/ipc/worktrees-authoritative-local-metadata-pruning.test.ts +++ b/src/main/ipc/worktrees-authoritative-local-metadata-pruning.test.ts @@ -85,13 +85,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../local-worktree-path-presence', async (importOriginal) => ({ diff --git a/src/main/ipc/worktrees-automation-create-terminals.test.ts b/src/main/ipc/worktrees-automation-create-terminals.test.ts index ccdb1dbfc96..c4fe1f2e1b9 100644 --- a/src/main/ipc/worktrees-automation-create-terminals.test.ts +++ b/src/main/ipc/worktrees-automation-create-terminals.test.ts @@ -67,13 +67,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-background-removal.test.ts b/src/main/ipc/worktrees-background-removal.test.ts index c210f0b36b1..b33431c3939 100644 --- a/src/main/ipc/worktrees-background-removal.test.ts +++ b/src/main/ipc/worktrees-background-removal.test.ts @@ -73,13 +73,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-create-event-timing.test.ts b/src/main/ipc/worktrees-create-event-timing.test.ts index 20440c7acc8..66c6928c761 100644 --- a/src/main/ipc/worktrees-create-event-timing.test.ts +++ b/src/main/ipc/worktrees-create-event-timing.test.ts @@ -73,13 +73,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-create-label-only-first-work.test.ts b/src/main/ipc/worktrees-create-label-only-first-work.test.ts index 44073da396b..fb863ed9b64 100644 --- a/src/main/ipc/worktrees-create-label-only-first-work.test.ts +++ b/src/main/ipc/worktrees-create-label-only-first-work.test.ts @@ -78,13 +78,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-create-metadata-persistence.test.ts b/src/main/ipc/worktrees-create-metadata-persistence.test.ts index ca8f820ab3d..ab0b052af75 100644 --- a/src/main/ipc/worktrees-create-metadata-persistence.test.ts +++ b/src/main/ipc/worktrees-create-metadata-persistence.test.ts @@ -122,13 +122,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-create-registry.test.ts b/src/main/ipc/worktrees-create-registry.test.ts index 6f9ba164306..9760e2c3a19 100644 --- a/src/main/ipc/worktrees-create-registry.test.ts +++ b/src/main/ipc/worktrees-create-registry.test.ts @@ -62,13 +62,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-delete-pty-teardown.test.ts b/src/main/ipc/worktrees-delete-pty-teardown.test.ts index 4e48b107286..d6b87711aa2 100644 --- a/src/main/ipc/worktrees-delete-pty-teardown.test.ts +++ b/src/main/ipc/worktrees-delete-pty-teardown.test.ts @@ -72,13 +72,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-detected-scan-cache.test.ts b/src/main/ipc/worktrees-detected-scan-cache.test.ts index c3c91a76dcf..d811ee5ff82 100644 --- a/src/main/ipc/worktrees-detected-scan-cache.test.ts +++ b/src/main/ipc/worktrees-detected-scan-cache.test.ts @@ -71,13 +71,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-discovery-metadata-backfill.test.ts b/src/main/ipc/worktrees-discovery-metadata-backfill.test.ts index bd608554edb..ca0ede2a290 100644 --- a/src/main/ipc/worktrees-discovery-metadata-backfill.test.ts +++ b/src/main/ipc/worktrees-discovery-metadata-backfill.test.ts @@ -62,13 +62,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-existing-branch-checkout.test.ts b/src/main/ipc/worktrees-existing-branch-checkout.test.ts index 82ffab891b0..d310968f087 100644 --- a/src/main/ipc/worktrees-existing-branch-checkout.test.ts +++ b/src/main/ipc/worktrees-existing-branch-checkout.test.ts @@ -67,13 +67,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-failed-removal.test.ts b/src/main/ipc/worktrees-failed-removal.test.ts index c1536fae308..40bc4f053a6 100644 --- a/src/main/ipc/worktrees-failed-removal.test.ts +++ b/src/main/ipc/worktrees-failed-removal.test.ts @@ -83,13 +83,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-forget-local.test.ts b/src/main/ipc/worktrees-forget-local.test.ts index 9b3ee4cbe88..c5e46fdae96 100644 --- a/src/main/ipc/worktrees-forget-local.test.ts +++ b/src/main/ipc/worktrees-forget-local.test.ts @@ -77,13 +77,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-issue-command-overrides.test.ts b/src/main/ipc/worktrees-issue-command-overrides.test.ts index 66cf9f6468a..74a5509e63a 100644 --- a/src/main/ipc/worktrees-issue-command-overrides.test.ts +++ b/src/main/ipc/worktrees-issue-command-overrides.test.ts @@ -66,13 +66,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-lineage-hydration.test.ts b/src/main/ipc/worktrees-lineage-hydration.test.ts index 54f18ac43f7..976bcec758b 100644 --- a/src/main/ipc/worktrees-lineage-hydration.test.ts +++ b/src/main/ipc/worktrees-lineage-hydration.test.ts @@ -66,13 +66,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-listing-fallback-rows.test.ts b/src/main/ipc/worktrees-listing-fallback-rows.test.ts index b1126ff9fe6..d9f3cecdf58 100644 --- a/src/main/ipc/worktrees-listing-fallback-rows.test.ts +++ b/src/main/ipc/worktrees-listing-fallback-rows.test.ts @@ -65,13 +65,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-local-base-ref-resolution.test.ts b/src/main/ipc/worktrees-local-base-ref-resolution.test.ts index 0d22a816ed3..746b1e94403 100644 --- a/src/main/ipc/worktrees-local-base-ref-resolution.test.ts +++ b/src/main/ipc/worktrees-local-base-ref-resolution.test.ts @@ -70,13 +70,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-local-create-flow.test.ts b/src/main/ipc/worktrees-local-create-flow.test.ts index c27c02270dd..232e5a07239 100644 --- a/src/main/ipc/worktrees-local-create-flow.test.ts +++ b/src/main/ipc/worktrees-local-create-flow.test.ts @@ -87,13 +87,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-local-create-path-claim.test.ts b/src/main/ipc/worktrees-local-create-path-claim.test.ts index f2a052743d7..68b6646447e 100644 --- a/src/main/ipc/worktrees-local-create-path-claim.test.ts +++ b/src/main/ipc/worktrees-local-create-path-claim.test.ts @@ -65,13 +65,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-mutation-scan-generation-order.test.ts b/src/main/ipc/worktrees-mutation-scan-generation-order.test.ts index 5c1a69f435a..9abdf6739b2 100644 --- a/src/main/ipc/worktrees-mutation-scan-generation-order.test.ts +++ b/src/main/ipc/worktrees-mutation-scan-generation-order.test.ts @@ -69,13 +69,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-orphan-directory-cleanup.test.ts b/src/main/ipc/worktrees-orphan-directory-cleanup.test.ts index 89786d667d7..0a0b8d3f6ec 100644 --- a/src/main/ipc/worktrees-orphan-directory-cleanup.test.ts +++ b/src/main/ipc/worktrees-orphan-directory-cleanup.test.ts @@ -73,13 +73,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-removal-recovery.test.ts b/src/main/ipc/worktrees-removal-recovery.test.ts index 3c3a4f7e6b1..45fcd245894 100644 --- a/src/main/ipc/worktrees-removal-recovery.test.ts +++ b/src/main/ipc/worktrees-removal-recovery.test.ts @@ -102,13 +102,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-remove-archive-hooks.test.ts b/src/main/ipc/worktrees-remove-archive-hooks.test.ts index 288d4589507..56b7148b2f3 100644 --- a/src/main/ipc/worktrees-remove-archive-hooks.test.ts +++ b/src/main/ipc/worktrees-remove-archive-hooks.test.ts @@ -78,13 +78,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-remove-preflight.test.ts b/src/main/ipc/worktrees-remove-preflight.test.ts index 9046249c125..b75c47edba8 100644 --- a/src/main/ipc/worktrees-remove-preflight.test.ts +++ b/src/main/ipc/worktrees-remove-preflight.test.ts @@ -73,13 +73,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-setup-launch-sparse-checkout.test.ts b/src/main/ipc/worktrees-setup-launch-sparse-checkout.test.ts index 2934fc3a433..96a9d276aa7 100644 --- a/src/main/ipc/worktrees-setup-launch-sparse-checkout.test.ts +++ b/src/main/ipc/worktrees-setup-launch-sparse-checkout.test.ts @@ -70,13 +70,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-ssh-pr-head-fetch.test.ts b/src/main/ipc/worktrees-ssh-pr-head-fetch.test.ts index 8d4be2a08f2..34f0f98735e 100644 --- a/src/main/ipc/worktrees-ssh-pr-head-fetch.test.ts +++ b/src/main/ipc/worktrees-ssh-pr-head-fetch.test.ts @@ -63,13 +63,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-ssh-repo-owner-resolution.test.ts b/src/main/ipc/worktrees-ssh-repo-owner-resolution.test.ts index 54d9d0af331..50e4f6cacbd 100644 --- a/src/main/ipc/worktrees-ssh-repo-owner-resolution.test.ts +++ b/src/main/ipc/worktrees-ssh-repo-owner-resolution.test.ts @@ -77,13 +77,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees-wsl-runtime-routing.test.ts b/src/main/ipc/worktrees-wsl-runtime-routing.test.ts index 7ea73262430..782d1d0e552 100644 --- a/src/main/ipc/worktrees-wsl-runtime-routing.test.ts +++ b/src/main/ipc/worktrees-wsl-runtime-routing.test.ts @@ -93,13 +93,13 @@ vi.mock('../terminal-history-deletion', async () => vi.mock('../ports/advertised-url-watcher', async () => (await import('./worktrees-test-module-mocks')).advertisedUrlWatcherModuleMock() ) -vi.mock('../workspace-cleanup-scan-snapshot', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-scan-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupScanSnapshotModuleMock() ) -vi.mock('../workspace-space-analysis-snapshot', async () => +vi.mock('../workspaces/space-analysis/workspace-space-analysis-snapshot', async () => (await import('./worktrees-test-module-mocks')).workspaceSpaceAnalysisSnapshotModuleMock() ) -vi.mock('../workspace-cleanup-removal-snapshot-prune', async () => +vi.mock('../workspaces/cleanup/workspace-cleanup-removal-snapshot-prune', async () => (await import('./worktrees-test-module-mocks')).workspaceCleanupRemovalSnapshotPruneModuleMock() ) vi.mock('../runtime/worktree-teardown', async () => diff --git a/src/main/ipc/worktrees/listing/authoritative-local-worktree-metadata-pruning.ts b/src/main/ipc/worktrees/listing/authoritative-local-worktree-metadata-pruning.ts index 2dd588b0f6e..7825ca09eed 100644 --- a/src/main/ipc/worktrees/listing/authoritative-local-worktree-metadata-pruning.ts +++ b/src/main/ipc/worktrees/listing/authoritative-local-worktree-metadata-pruning.ts @@ -11,8 +11,8 @@ import { isWslUncPath } from '../../../../shared/wsl-paths' import { agentHookServer } from '../../../agent-hooks/server' import type { Store } from '../../../persistence/loading-store/store' import type { NativeLocalWorktreeMetadataScanExpectation } from '../../../persistence/tracking-repos/missing-local-worktree-metadata-pruning' -import { pruneWorkspaceCleanupScanSnapshots } from '../../../workspace-cleanup-scan-snapshot' -import { pruneWorkspaceSpaceAnalysisSnapshots } from '../../../workspace-space-analysis-snapshot' +import { pruneWorkspaceCleanupScanSnapshots } from '../../../workspaces/cleanup/workspace-cleanup-scan-snapshot' +import { pruneWorkspaceSpaceAnalysisSnapshots } from '../../../workspaces/space-analysis/workspace-space-analysis-snapshot' import { isLocalWorktreeScanGenerationCurrent } from '../../../local-worktree-scan-generation' import { localWorktreePathsExistOrAreUnverifiable } from '../../../local-worktree-path-presence' import { worktreeRetentionPathComparisonKey } from '../../../worktree-retention-path-comparison' diff --git a/src/main/ipc/worktrees/listing/register-host-catalog-handlers.ts b/src/main/ipc/worktrees/listing/register-host-catalog-handlers.ts index 0f4646a8bdb..0cd46124774 100644 --- a/src/main/ipc/worktrees/listing/register-host-catalog-handlers.ts +++ b/src/main/ipc/worktrees/listing/register-host-catalog-handlers.ts @@ -11,8 +11,8 @@ import { isFolderRepo } from '../../../../shared/repo-kind' import { projectWorktreeLineageWithHostPeers } from '../../../worktree-lineage-host-peers' import { getRepoIdFromWorktreeId } from '../../../../shared/worktree/id' import { agentHookServer } from '../../../agent-hooks/server' -import { pruneWorkspaceCleanupScanSnapshots } from '../../../workspace-cleanup-scan-snapshot' -import { pruneWorkspaceSpaceAnalysisSnapshots } from '../../../workspace-space-analysis-snapshot' +import { pruneWorkspaceCleanupScanSnapshots } from '../../../workspaces/cleanup/workspace-cleanup-scan-snapshot' +import { pruneWorkspaceSpaceAnalysisSnapshots } from '../../../workspaces/space-analysis/workspace-space-analysis-snapshot' import { findExactRepoOwner, hasConflictingStoredWorktreeOwner } from './worktree-host-ownership' import { buildDisconnectedDetectedWorktrees, diff --git a/src/main/localhost-worktree-label-proxy.test.ts b/src/main/ports/workspace-labels/localhost-worktree-label-proxy.test.ts similarity index 100% rename from src/main/localhost-worktree-label-proxy.test.ts rename to src/main/ports/workspace-labels/localhost-worktree-label-proxy.test.ts diff --git a/src/main/localhost-worktree-label-proxy.ts b/src/main/ports/workspace-labels/localhost-worktree-label-proxy.ts similarity index 98% rename from src/main/localhost-worktree-label-proxy.ts rename to src/main/ports/workspace-labels/localhost-worktree-label-proxy.ts index 27801b65566..4f3b82a4259 100644 --- a/src/main/localhost-worktree-label-proxy.ts +++ b/src/main/ports/workspace-labels/localhost-worktree-label-proxy.ts @@ -6,12 +6,12 @@ import { URL } from 'node:url' import type { LocalhostWorktreeLabelResult, LocalhostWorktreeLabelRoute -} from '../shared/localhost-worktree-labels' +} from '../../../shared/localhost-worktree-labels' import { connectableLoopbackHost, getLocalhostWorktreeHostLabel, getLocalhostWorktreeRouteKey -} from '../shared/localhost-worktree-labels' +} from '../../../shared/localhost-worktree-labels' type RegisteredRoute = LocalhostWorktreeLabelRoute & { label: string diff --git a/src/main/window/attach-main-window-services.test.ts b/src/main/window/attach-main-window-services.test.ts index 5f89501fa0e..66a98e7d704 100644 --- a/src/main/window/attach-main-window-services.test.ts +++ b/src/main/window/attach-main-window-services.test.ts @@ -3,7 +3,7 @@ import type { Store } from '../persistence/loading-store/store' import { cancelHistoryGc } from '../terminal-history-gc' import type { registerSshHandlers } from '../ipc/ssh/ssh' import type { registerDaemonManagementHandlers } from '../ipc/pty/pty-management' -import type { registerWorkspaceCleanupHandlers } from '../ipc/workspace-cleanup' +import type { registerWorkspaceCleanupHandlers } from '../ipc/workspace-cleanup/workspace-cleanup' import type { startFolderRepoGitUpgradeWatch } from '../ipc/folder-repo-git-upgrade' import { createMainWindowServiceStub, @@ -119,7 +119,7 @@ vi.mock('../ipc/ssh/ssh', () => ({ registerSshHandlers: registerSshHandlersMock vi.mock('../ipc/pty/pty-management', () => ({ registerDaemonManagementHandlers: registerDaemonManagementHandlersMock })) -vi.mock('../ipc/workspace-cleanup', () => ({ +vi.mock('../ipc/workspace-cleanup/workspace-cleanup', () => ({ registerWorkspaceCleanupHandlers: registerWorkspaceCleanupHandlersMock })) vi.mock('../ipc/folder-repo-git-upgrade', () => ({ diff --git a/src/main/window/attach-main-window-services.ts b/src/main/window/attach-main-window-services.ts index 7094a4fe340..ded1321dfd7 100644 --- a/src/main/window/attach-main-window-services.ts +++ b/src/main/window/attach-main-window-services.ts @@ -11,7 +11,7 @@ import { registerRepoHandlers } from '../ipc/repos' import { setRepoRemoteClientNotifier } from '../ipc/repos/repos-changed-notification' import { setWorktreeCatalogRemoteClientNotifier } from '../ipc/watched-worktree-catalog-notification' import { registerWorktreeHandlers } from '../ipc/worktrees' -import { registerWorkspaceCleanupHandlers } from '../ipc/workspace-cleanup' +import { registerWorkspaceCleanupHandlers } from '../ipc/workspace-cleanup/workspace-cleanup' import { registerPtyHandlers } from '../ipc/pty/register-handlers' import type { CodexHomePtySpawnedLifecycleArgs, diff --git a/src/main/workspace-cleanup-removal-snapshot-prune.test.ts b/src/main/workspaces/cleanup/workspace-cleanup-removal-snapshot-prune.test.ts similarity index 98% rename from src/main/workspace-cleanup-removal-snapshot-prune.test.ts rename to src/main/workspaces/cleanup/workspace-cleanup-removal-snapshot-prune.test.ts index 466476b10c3..92c13be3417 100644 --- a/src/main/workspace-cleanup-removal-snapshot-prune.test.ts +++ b/src/main/workspaces/cleanup/workspace-cleanup-removal-snapshot-prune.test.ts @@ -22,7 +22,7 @@ vi.mock('./workspace-cleanup-scan-snapshot', () => ({ registerWorkspaceCleanupScanSnapshotPruneTombstones: registerCleanupTombstonesMock })) -vi.mock('./workspace-space-analysis-snapshot', () => ({ +vi.mock('../space-analysis/workspace-space-analysis-snapshot', () => ({ finalizeWorkspaceSpaceAnalysisSnapshotPrunes: finalizeSpaceSnapshotsMock, pruneWorkspaceSpaceAnalysisSnapshots: pruneSpaceSnapshotsMock, registerWorkspaceSpaceAnalysisSnapshotPruneTombstones: registerSpaceTombstonesMock diff --git a/src/main/workspace-cleanup-removal-snapshot-prune.ts b/src/main/workspaces/cleanup/workspace-cleanup-removal-snapshot-prune.ts similarity index 97% rename from src/main/workspace-cleanup-removal-snapshot-prune.ts rename to src/main/workspaces/cleanup/workspace-cleanup-removal-snapshot-prune.ts index 9b4244400c6..7bcf44aecfc 100644 --- a/src/main/workspace-cleanup-removal-snapshot-prune.ts +++ b/src/main/workspaces/cleanup/workspace-cleanup-removal-snapshot-prune.ts @@ -1,7 +1,7 @@ import type { WorkspaceCleanupSnapshotPruneBatchArgs, WorkspaceCleanupSnapshotPruneRecordArgs -} from '../shared/workspace-cleanup' +} from '../../../shared/workspace-cleanup' import { finalizeWorkspaceCleanupScanSnapshotPrunes, pruneWorkspaceCleanupScanSnapshots, @@ -11,7 +11,7 @@ import { finalizeWorkspaceSpaceAnalysisSnapshotPrunes, pruneWorkspaceSpaceAnalysisSnapshots, registerWorkspaceSpaceAnalysisSnapshotPruneTombstones -} from './workspace-space-analysis-snapshot' +} from '../space-analysis/workspace-space-analysis-snapshot' type SnapshotPruneTarget = Omit diff --git a/src/main/workspace-cleanup-scan-snapshot.test.ts b/src/main/workspaces/cleanup/workspace-cleanup-scan-snapshot.test.ts similarity index 99% rename from src/main/workspace-cleanup-scan-snapshot.test.ts rename to src/main/workspaces/cleanup/workspace-cleanup-scan-snapshot.test.ts index ce4e5b36e35..dce2ebd319c 100644 --- a/src/main/workspace-cleanup-scan-snapshot.test.ts +++ b/src/main/workspaces/cleanup/workspace-cleanup-scan-snapshot.test.ts @@ -5,14 +5,14 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type { WorkspaceCleanupCandidate, WorkspaceCleanupScanResult -} from '../shared/workspace-cleanup' +} from '../../../shared/workspace-cleanup' const { snapshotWriteSpy, userDataDirHolder } = vi.hoisted(() => ({ snapshotWriteSpy: vi.fn(), userDataDirHolder: { dir: '' } })) -vi.mock('./sidecar-snapshot-file', async (importOriginal) => { +vi.mock('../../sidecar-snapshot-file', async (importOriginal) => { const actual = await importOriginal>() const writeSidecarSnapshot = actual.writeSidecarSnapshot as ( file: string, diff --git a/src/main/workspace-cleanup-scan-snapshot.ts b/src/main/workspaces/cleanup/workspace-cleanup-scan-snapshot.ts similarity index 98% rename from src/main/workspace-cleanup-scan-snapshot.ts rename to src/main/workspaces/cleanup/workspace-cleanup-scan-snapshot.ts index 1b1296156fd..6e54bd68164 100644 --- a/src/main/workspace-cleanup-scan-snapshot.ts +++ b/src/main/workspaces/cleanup/workspace-cleanup-scan-snapshot.ts @@ -3,14 +3,14 @@ import { type WorkspaceCleanupCandidate, type WorkspaceCleanupScanArgs, type WorkspaceCleanupScanResult -} from '../shared/workspace-cleanup' +} from '../../../shared/workspace-cleanup' import { readSidecarSnapshot, sidecarSnapshotFile, withSidecarSnapshotQueue, writeSidecarSnapshot -} from './sidecar-snapshot-file' -import type { ExecutionHostId } from '../shared/execution-host' +} from '../../sidecar-snapshot-file' +import type { ExecutionHostId } from '../../../shared/execution-host' import { activeWorkspaceSnapshotPruneKeys, registerWorkspaceSnapshotPrunesForFile, diff --git a/src/main/workspace-snapshot-prune-index.ts b/src/main/workspaces/cleanup/workspace-snapshot-prune-index.ts similarity index 95% rename from src/main/workspace-snapshot-prune-index.ts rename to src/main/workspaces/cleanup/workspace-snapshot-prune-index.ts index 56b4289335b..2d9f49901b4 100644 --- a/src/main/workspace-snapshot-prune-index.ts +++ b/src/main/workspaces/cleanup/workspace-snapshot-prune-index.ts @@ -1,4 +1,4 @@ -import type { ExecutionHostId } from '../shared/execution-host' +import type { ExecutionHostId } from '../../../shared/execution-host' export type WorkspaceSnapshotPruneTarget = { worktreeId: string diff --git a/src/main/workspace-space-analysis-capacity.test.ts b/src/main/workspaces/space-analysis/workspace-space-analysis-capacity.test.ts similarity index 87% rename from src/main/workspace-space-analysis-capacity.test.ts rename to src/main/workspaces/space-analysis/workspace-space-analysis-capacity.test.ts index a57b79f8e67..a7ce18fca93 100644 --- a/src/main/workspace-space-analysis-capacity.test.ts +++ b/src/main/workspaces/space-analysis/workspace-space-analysis-capacity.test.ts @@ -3,9 +3,9 @@ import { tmpdir } from 'node:os' import { join } from 'node:path' import type * as NodeProcess from 'node:process' import { afterEach, describe, expect, it, vi } from 'vitest' -import type { Repo } from '../shared/repo-types' -import type * as WorkspaceSpaceScanBudgetModule from '../shared/workspace-space-scan-budget' -import type { Store } from './persistence/loading-store/store' +import type { Repo } from '../../../shared/repo-types' +import type * as WorkspaceSpaceScanBudgetModule from '../../../shared/workspace-space-scan-budget' +import type { Store } from '../../persistence/loading-store/store' const { listRepoWorktreesMock } = vi.hoisted(() => ({ listRepoWorktreesMock: vi.fn() @@ -16,9 +16,9 @@ vi.mock('node:process', async () => { return { ...actual, platform: 'win32' } }) -vi.mock('../shared/workspace-space-scan-budget', async () => { +vi.mock('../../../shared/workspace-space-scan-budget', async () => { const actual = await vi.importActual( - '../shared/workspace-space-scan-budget' + '../../../shared/workspace-space-scan-budget' ) return { ...actual, @@ -26,7 +26,7 @@ vi.mock('../shared/workspace-space-scan-budget', async () => { } }) -vi.mock('./repo-worktrees', () => ({ +vi.mock('../../repo-worktrees', () => ({ createFolderWorktree: (repo: Repo) => ({ path: repo.path, head: '', diff --git a/src/main/workspace-space-analysis-du-timeout.test.ts b/src/main/workspaces/space-analysis/workspace-space-analysis-du-timeout.test.ts similarity index 95% rename from src/main/workspace-space-analysis-du-timeout.test.ts rename to src/main/workspaces/space-analysis/workspace-space-analysis-du-timeout.test.ts index ddc60648380..9d1f015405c 100644 --- a/src/main/workspace-space-analysis-du-timeout.test.ts +++ b/src/main/workspaces/space-analysis/workspace-space-analysis-du-timeout.test.ts @@ -4,15 +4,15 @@ import { join } from 'node:path' import { EventEmitter } from 'node:events' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type * as NodeProcess from 'node:process' -import type { Repo } from '../shared/repo-types' -import type { Store } from './persistence/loading-store/store' +import type { Repo } from '../../../shared/repo-types' +import type { Store } from '../../persistence/loading-store/store' const { spawnProcessMock, listRepoWorktreesMock } = vi.hoisted(() => ({ spawnProcessMock: vi.fn(), listRepoWorktreesMock: vi.fn() })) -vi.mock('./worker-thread-child-process/worker-thread-child-process', () => ({ +vi.mock('../../worker-thread-child-process/worker-thread-child-process', () => ({ spawnProcessOnWorkerThread: spawnProcessMock })) @@ -21,7 +21,7 @@ vi.mock('node:process', async () => { return { ...actual, platform: 'darwin' } }) -vi.mock('./repo-worktrees', () => ({ +vi.mock('../../repo-worktrees', () => ({ createFolderWorktree: (repo: Repo) => ({ path: repo.path, head: '', diff --git a/src/main/workspace-space-analysis-snapshot.test.ts b/src/main/workspaces/space-analysis/workspace-space-analysis-snapshot.test.ts similarity index 99% rename from src/main/workspace-space-analysis-snapshot.test.ts rename to src/main/workspaces/space-analysis/workspace-space-analysis-snapshot.test.ts index b19560a7c50..9fcd07b7b2a 100644 --- a/src/main/workspace-space-analysis-snapshot.test.ts +++ b/src/main/workspaces/space-analysis/workspace-space-analysis-snapshot.test.ts @@ -5,14 +5,14 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type { WorkspaceSpaceAnalysis, WorkspaceSpaceWorktree -} from '../shared/workspace-space-types' +} from '../../../shared/workspace-space-types' const { snapshotWriteSpy, userDataDirHolder } = vi.hoisted(() => ({ snapshotWriteSpy: vi.fn(), userDataDirHolder: { dir: '' } })) -vi.mock('./sidecar-snapshot-file', async (importOriginal) => { +vi.mock('../../sidecar-snapshot-file', async (importOriginal) => { const actual = await importOriginal>() const writeSidecarSnapshot = actual.writeSidecarSnapshot as ( file: string, diff --git a/src/main/workspace-space-analysis-snapshot.ts b/src/main/workspaces/space-analysis/workspace-space-analysis-snapshot.ts similarity index 98% rename from src/main/workspace-space-analysis-snapshot.ts rename to src/main/workspaces/space-analysis/workspace-space-analysis-snapshot.ts index e404767330b..f87a8d8bdd0 100644 --- a/src/main/workspace-space-analysis-snapshot.ts +++ b/src/main/workspaces/space-analysis/workspace-space-analysis-snapshot.ts @@ -1,14 +1,14 @@ import type { WorkspaceSpaceAnalysis, WorkspaceSpaceWorktree -} from '../shared/workspace-space-types' +} from '../../../shared/workspace-space-types' import { readSidecarSnapshot, sidecarSnapshotFile, withSidecarSnapshotQueue, writeSidecarSnapshot -} from './sidecar-snapshot-file' -import type { ExecutionHostId } from '../shared/execution-host' +} from '../../sidecar-snapshot-file' +import type { ExecutionHostId } from '../../../shared/execution-host' import { activeWorkspaceSnapshotPruneKeys, registerWorkspaceSnapshotPrunesForFile, @@ -16,7 +16,7 @@ import { workspaceSnapshotPruneTargetKeys, type WorkspaceSnapshotPruneTarget, type WorkspaceSnapshotPruneTombstone -} from './workspace-snapshot-prune-index' +} from '../cleanup/workspace-snapshot-prune-index' const SNAPSHOT_FILE_NAME = 'orca-workspace-space-analysis.json' const SNAPSHOT_VERSION = 2 diff --git a/src/main/workspace-space-analysis.test.ts b/src/main/workspaces/space-analysis/workspace-space-analysis.test.ts similarity index 96% rename from src/main/workspace-space-analysis.test.ts rename to src/main/workspaces/space-analysis/workspace-space-analysis.test.ts index 36811558551..9a04861e2af 100644 --- a/src/main/workspace-space-analysis.test.ts +++ b/src/main/workspaces/space-analysis/workspace-space-analysis.test.ts @@ -2,8 +2,8 @@ import { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' 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 type { Repo } from '../../../shared/repo-types' +import type { Store } from '../../persistence/loading-store/store' const { listRepoWorktreesMock, getLocalProjectWorktreeGitOptionsMock, workerState } = vi.hoisted( () => ({ @@ -13,7 +13,7 @@ const { listRepoWorktreesMock, getLocalProjectWorktreeGitOptionsMock, workerStat }) ) -vi.mock('./repo-worktrees', () => ({ +vi.mock('../../repo-worktrees', () => ({ createFolderWorktree: (repo: Repo) => ({ path: repo.path, head: '', @@ -24,11 +24,11 @@ vi.mock('./repo-worktrees', () => ({ listRepoWorktrees: listRepoWorktreesMock })) -vi.mock('./project-runtime-git-options', () => ({ +vi.mock('../../project-runtime-git-options', () => ({ getLocalProjectWorktreeGitOptions: getLocalProjectWorktreeGitOptionsMock })) -vi.mock('./worker-thread-child-process/worker-thread-child-process', () => ({ +vi.mock('../../worker-thread-child-process/worker-thread-child-process', () => ({ spawnProcessOnWorkerThread: () => { throw new Error('Use portable traversal in this test') } @@ -48,7 +48,8 @@ vi.mock('./workspace-space-scan-worker-client', async () => { } }) -import { analyzeWorkspaceSpace, WorkspaceSpaceScanCancelledError } from './workspace-space-analysis' +import { analyzeWorkspaceSpace } from './workspace-space-analysis' +import { WorkspaceSpaceScanCancelledError } from './workspace-space-scan-control' function createStore(repos: Repo[], worktreeHostId?: `runtime:${string}`): Store { return { diff --git a/src/main/workspace-space-analysis.ts b/src/main/workspaces/space-analysis/workspace-space-analysis.ts similarity index 93% rename from src/main/workspace-space-analysis.ts rename to src/main/workspaces/space-analysis/workspace-space-analysis.ts index f9c31516177..d289c6c1a31 100644 --- a/src/main/workspace-space-analysis.ts +++ b/src/main/workspaces/space-analysis/workspace-space-analysis.ts @@ -1,10 +1,10 @@ -import type { Store } from './persistence/loading-store/store' -import { spawnProcessOnWorkerThread } from './worker-thread-child-process/worker-thread-child-process' +import type { Store } from '../../persistence/loading-store/store' +import { spawnProcessOnWorkerThread } from '../../worker-thread-child-process/worker-thread-child-process' import type { WorkspaceSpaceAnalysis, WorkspaceSpaceScanProgress -} from '../shared/workspace-space-types' -import { mapWithConcurrency } from '../shared/map-with-concurrency' +} from '../../../shared/workspace-space-types' +import { mapWithConcurrency } from '../../../shared/map-with-concurrency' import { WorkspaceSpaceScanCancelledError, createWorkspaceSpaceScanLimiter, @@ -22,8 +22,6 @@ const LOCAL_WORKTREE_SCAN_CONCURRENCY = 1 const DU_TIMEOUT_MS = 120_000 const DU_MAX_BUFFER_BYTES = 16 * 1024 * 1024 -export { WorkspaceSpaceScanCancelledError } - async function readLocalDuDepthOne(rootPath: string, signal?: AbortSignal): Promise { return new Promise((resolve, reject) => { let settled = false diff --git a/src/main/workspace-space-local-scan.ts b/src/main/workspaces/space-analysis/workspace-space-local-scan.ts similarity index 91% rename from src/main/workspace-space-local-scan.ts rename to src/main/workspaces/space-analysis/workspace-space-local-scan.ts index 31a561c121a..ef7882a82c2 100644 --- a/src/main/workspace-space-local-scan.ts +++ b/src/main/workspaces/space-analysis/workspace-space-local-scan.ts @@ -1,21 +1,19 @@ import { lstat, opendir } from 'node:fs/promises' import { platform } from 'node:process' import type { Dirent } from 'node:fs' -import type { Repo } from '../shared/repo-types' -import type { Worktree } from '../shared/worktree/types' -import type { WorkspaceSpaceWorktree } from '../shared/workspace-space-types' -import { compactWorkspaceSpaceItems } from '../shared/workspace-space-compaction' -import { escapeRegex } from '../shared/string-utils' -import { mapWithConcurrency } from '../shared/map-with-concurrency' -import { - scanWorkspaceSpaceEntryTree, - type WorkspaceSpaceEntryScan -} from '../shared/workspace-space-entry-traversal' +import type { Repo } from '../../../shared/repo-types' +import type { Worktree } from '../../../shared/worktree/types' +import type { WorkspaceSpaceWorktree } from '../../../shared/workspace-space-types' +import { compactWorkspaceSpaceItems } from '../../../shared/workspace-space-compaction' +import { escapeRegex } from '../../../shared/string-utils' +import { mapWithConcurrency } from '../../../shared/map-with-concurrency' +import { scanWorkspaceSpaceEntryTree } from '../../../shared/workspace-space-entry-traversal' +import type { WorkspaceSpaceEntryScan } from '../../../shared/workspace-space-directory-frame' import { collectWorkspaceSpaceDirectoryEntries, createWorkspaceSpaceScanBudget, WorkspaceSpaceScanCapacityError -} from '../shared/workspace-space-scan-budget' +} from '../../../shared/workspace-space-scan-budget' import { WorkspaceSpaceScanCancelledError, classifyWorkspaceSpaceError, diff --git a/src/main/workspace-space-repo-scan.ts b/src/main/workspaces/space-analysis/workspace-space-repo-scan.ts similarity index 91% rename from src/main/workspace-space-repo-scan.ts rename to src/main/workspaces/space-analysis/workspace-space-repo-scan.ts index 8fd48580389..e0334ac9ffb 100644 --- a/src/main/workspace-space-repo-scan.ts +++ b/src/main/workspaces/space-analysis/workspace-space-repo-scan.ts @@ -1,25 +1,25 @@ -import type { Store } from './persistence/loading-store/store' +import type { Store } from '../../persistence/loading-store/store' import { platform } from 'node:process' -import { isFolderRepo } from '../shared/repo-kind' -import type { Repo } from '../shared/repo-types' -import type { GitWorktreeInfo, Worktree } from '../shared/worktree/types' +import { isFolderRepo } from '../../../shared/repo-kind' +import type { Repo } from '../../../shared/repo-types' +import type { GitWorktreeInfo, Worktree } from '../../../shared/worktree/types' import type { WorkspaceSpaceRepoSummary, WorkspaceSpaceScanProgress, WorkspaceSpaceScanStatus, WorkspaceSpaceWorktree -} from '../shared/workspace-space-types' -import { mapWithConcurrency } from '../shared/map-with-concurrency' -import { getRepoExecutionHostId, LOCAL_EXECUTION_HOST_ID } from '../shared/execution-host' -import { readWorktreeMetaForHost } from './persistence/host-qualified-worktree-meta' -import { getRepoOwnedWorktreeMeta } from './worktree-metadata-ownership' +} from '../../../shared/workspace-space-types' +import { mapWithConcurrency } from '../../../shared/map-with-concurrency' +import { getRepoExecutionHostId, LOCAL_EXECUTION_HOST_ID } from '../../../shared/execution-host' +import { readWorktreeMetaForHost } from '../../persistence/host-qualified-worktree-meta' +import { getRepoOwnedWorktreeMeta } from '../../worktree-metadata-ownership' import { resolveFilesystemRouteForHost, resolveGitRouteForHost -} from './providers/execution-host-provider-dispatch' -import { createFolderWorktree, listRepoWorktrees } from './repo-worktrees' -import { mergeWorktree } from './ipc/worktree-metadata-merge' -import { getLocalProjectWorktreeGitOptions } from './project-runtime-git-options' +} from '../../providers/execution-host-provider-dispatch' +import { createFolderWorktree, listRepoWorktrees } from '../../repo-worktrees' +import { mergeWorktree } from '../../ipc/worktree-metadata-merge' +import { getLocalProjectWorktreeGitOptions } from '../../project-runtime-git-options' import { WorkspaceSpaceScanCancelledError, classifyWorkspaceSpaceError, diff --git a/src/main/workspace-space-scan-control.test.ts b/src/main/workspaces/space-analysis/workspace-space-scan-control.test.ts similarity index 100% rename from src/main/workspace-space-scan-control.test.ts rename to src/main/workspaces/space-analysis/workspace-space-scan-control.test.ts diff --git a/src/main/workspace-space-scan-control.ts b/src/main/workspaces/space-analysis/workspace-space-scan-control.ts similarity index 93% rename from src/main/workspace-space-scan-control.ts rename to src/main/workspaces/space-analysis/workspace-space-scan-control.ts index a13cb952c33..5e31ac31b20 100644 --- a/src/main/workspace-space-scan-control.ts +++ b/src/main/workspaces/space-analysis/workspace-space-scan-control.ts @@ -1,5 +1,5 @@ -import type { WorkspaceSpaceScanStatus } from '../shared/workspace-space-types' -import { WorkspaceSpaceScanCapacityError } from '../shared/workspace-space-scan-budget' +import type { WorkspaceSpaceScanStatus } from '../../../shared/workspace-space-types' +import { WorkspaceSpaceScanCapacityError } from '../../../shared/workspace-space-scan-budget' export type AsyncLimiter = (task: () => Promise) => Promise diff --git a/src/main/workspace-space-scan-worker-client.ts b/src/main/workspaces/space-analysis/workspace-space-scan-worker-client.ts similarity index 83% rename from src/main/workspace-space-scan-worker-client.ts rename to src/main/workspaces/space-analysis/workspace-space-scan-worker-client.ts index f5ee30ec546..4f52b7ea3e7 100644 --- a/src/main/workspace-space-scan-worker-client.ts +++ b/src/main/workspaces/space-analysis/workspace-space-scan-worker-client.ts @@ -1,10 +1,13 @@ import { existsSync } from 'node:fs' import { Worker } from 'node:worker_threads' -import type { Repo } from '../shared/repo-types' -import type { Worktree } from '../shared/worktree/types' -import type { WorkspaceSpaceWorktree } from '../shared/workspace-space-types' -import { WorkerThreadRequestQueue } from './worker-thread-request-queue' -import { currentWorkerEntryLayout, resolveWorkerThreadEntryPath } from './worker-thread-entry-path' +import type { Repo } from '../../../shared/repo-types' +import type { Worktree } from '../../../shared/worktree/types' +import type { WorkspaceSpaceWorktree } from '../../../shared/workspace-space-types' +import { WorkerThreadRequestQueue } from '../../worker-thread-request-queue' +import { + currentWorkerEntryLayout, + resolveWorkerThreadEntryPath +} from '../../worker-thread-entry-path' import type { WorkspaceSpaceScanWorkerRequest, WorkspaceSpaceScanWorkerResponse diff --git a/src/main/workspace-space-scan-worker-entry.ts b/src/main/workspaces/space-analysis/workspace-space-scan-worker-entry.ts similarity index 100% rename from src/main/workspace-space-scan-worker-entry.ts rename to src/main/workspaces/space-analysis/workspace-space-scan-worker-entry.ts diff --git a/src/main/workspace-space-scan-worker-protocol.ts b/src/main/workspaces/space-analysis/workspace-space-scan-worker-protocol.ts similarity index 59% rename from src/main/workspace-space-scan-worker-protocol.ts rename to src/main/workspaces/space-analysis/workspace-space-scan-worker-protocol.ts index 48ff9fab3bf..10da1ef3aa4 100644 --- a/src/main/workspace-space-scan-worker-protocol.ts +++ b/src/main/workspaces/space-analysis/workspace-space-scan-worker-protocol.ts @@ -1,6 +1,6 @@ -import type { Repo } from '../shared/repo-types' -import type { Worktree } from '../shared/worktree/types' -import type { WorkspaceSpaceWorktree } from '../shared/workspace-space-types' +import type { Repo } from '../../../shared/repo-types' +import type { Worktree } from '../../../shared/worktree/types' +import type { WorkspaceSpaceWorktree } from '../../../shared/workspace-space-types' export type WorkspaceSpaceScanWorkerRequest = { id: number diff --git a/src/main/workspace-space-worktree-row.ts b/src/main/workspaces/space-analysis/workspace-space-worktree-row.ts similarity index 88% rename from src/main/workspace-space-worktree-row.ts rename to src/main/workspaces/space-analysis/workspace-space-worktree-row.ts index e94c755e17e..e1318b4d778 100644 --- a/src/main/workspace-space-worktree-row.ts +++ b/src/main/workspaces/space-analysis/workspace-space-worktree-row.ts @@ -1,14 +1,14 @@ import { posix, win32 } from 'node:path' -import type { Repo } from '../shared/repo-types' -import type { Worktree } from '../shared/worktree/types' +import type { Repo } from '../../../shared/repo-types' +import type { Worktree } from '../../../shared/worktree/types' import type { WorkspaceSpaceDirectoryScanResult, WorkspaceSpaceItem, WorkspaceSpaceScanStatus, WorkspaceSpaceWorktree -} from '../shared/workspace-space-types' -import type { WorkspaceSpaceEntryScan } from '../shared/workspace-space-entry-traversal' -import { getWorktreeExecutionHostId } from '../shared/execution-host' +} from '../../../shared/workspace-space-types' +import type { WorkspaceSpaceEntryScan } from '../../../shared/workspace-space-directory-frame' +import { getWorktreeExecutionHostId } from '../../../shared/execution-host' export function basenameWorkspaceFilesystemPath(pathValue: string): string { return looksLikeWindowsPath(pathValue) ? win32.basename(pathValue) : posix.basename(pathValue) diff --git a/src/main/worktree-removal-process-cleanup.ts b/src/main/worktree-removal-process-cleanup.ts index ce235fe2d09..eb8cc740868 100644 --- a/src/main/worktree-removal-process-cleanup.ts +++ b/src/main/worktree-removal-process-cleanup.ts @@ -1,10 +1,10 @@ import type { ExecutionHostId } from '../shared/execution-host' import { advertisedUrlWatcher } from './ports/advertised-url-watcher' -import { localhostWorktreeLabelProxy } from './localhost-worktree-label-proxy' +import { localhostWorktreeLabelProxy } from './ports/workspace-labels/localhost-worktree-label-proxy' import { deleteWorktreeHistoryDir } from './terminal-history-deletion' -import { recordWorkspaceCleanupRemovalSnapshotPrune } from './workspace-cleanup-removal-snapshot-prune' -import { pruneWorkspaceCleanupScanSnapshot } from './workspace-cleanup-scan-snapshot' -import { pruneWorkspaceSpaceAnalysisSnapshot } from './workspace-space-analysis-snapshot' +import { recordWorkspaceCleanupRemovalSnapshotPrune } from './workspaces/cleanup/workspace-cleanup-removal-snapshot-prune' +import { pruneWorkspaceCleanupScanSnapshot } from './workspaces/cleanup/workspace-cleanup-scan-snapshot' +import { pruneWorkspaceSpaceAnalysisSnapshot } from './workspaces/space-analysis/workspace-space-analysis-snapshot' /** Drop host-blind process state only when no same-ID workspace survives on another host. */ export function dropRemovedWorktreeProcessState(worktreeId: string): void {