refactor: organize workspace cleanup by concrete owners (#41887)

This commit is contained in:
Neil
2026-11-12 23:54:23 -08:00
committed by GitHub
parent 66db0a6a50
commit bd3d62d3d5
82 changed files with 278 additions and 369 deletions
+1 -1
View File
@@ -526,7 +526,7 @@
2 test-no-wall-clock:src/renderer/src/components/terminal-pane/pty-connection/emulation/fish-color-scheme-child-stdin.node-pty.test.ts
2 test-no-wall-clock:src/renderer/src/components/terminal-pane/snapshots/remote-snapshot-alt-screen-host-chain.test.ts
1 test-no-wall-clock:src/renderer/src/components/terminal/initial-terminal-structured-launch.test.tsx
2 test-no-wall-clock:src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-removal.agent-stop.test.tsx
2 test-no-wall-clock:src/renderer/src/components/workspace-cleanup/removal/use-workspace-cleanup-removal.agent-stop.test.tsx
1 test-no-wall-clock:src/renderer/src/components/worktree-jump/WorktreeJumpPalette.recent-tabs.behavior.test.tsx
2 test-no-wall-clock:src/renderer/src/hooks/ipc-events/agent-status-terminal-title-tab-write.test.ts
1 test-no-wall-clock:src/renderer/src/lib/workspace/activation/worktree-activation-emptied-workspace-reseed.test.ts
+3 -3
View File
@@ -668,9 +668,9 @@
1 src/renderer/src/components/use-terminal-window-lifecycle.ts
1 src/renderer/src/components/use-terminal-workspace-foundation.ts
1 src/renderer/src/components/virtualized-list.tsx
1 src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-facet-rows.ts
2 src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-git-evidence.ts
1 src/renderer/src/components/workspace-cleanup/workspace-cleanup-candidate-list.tsx
1 src/renderer/src/components/workspace-cleanup/browse/use-workspace-cleanup-facet-rows.ts
2 src/renderer/src/components/workspace-cleanup/candidate-evidence/use-workspace-cleanup-git-evidence.ts
1 src/renderer/src/components/workspace-cleanup/candidate-list/workspace-cleanup-candidate-list.tsx
2 src/renderer/src/components/workspace-emoji/useWorkspaceEmojiShortcodeInput.ts
1 src/renderer/src/components/worktree-jump/use-worktree-jump-palette-list-entries.ts
1 src/renderer/src/components/worktree-jump/use-worktree-jump-palette-local-state.ts
@@ -5388,19 +5388,19 @@
"src/renderer/src/components/use-terminal-window-lifecycle.frame-flush.test.tsx": 2164,
"src/renderer/src/components/virtualized-list.test.tsx": 446,
"src/renderer/src/components/window-close-request-coordinator.test.ts": 361,
"src/renderer/src/components/workspace-cleanup/WorkspaceCleanupDialog.stale-while-revalidate.test.tsx": 3269,
"src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.test.tsx": 248,
"src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-git-evidence.test.tsx": 539,
"src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-removal.agent-stop.test.tsx": 2285,
"src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-row-order.test.ts": 242,
"src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal-late-settlement.test.ts": 1880,
"src/renderer/src/components/workspace-cleanup/workspace-cleanup-background-removal.test.ts": 283,
"src/renderer/src/components/workspace-cleanup/workspace-cleanup-facet-filter.test.ts": 341,
"src/renderer/src/components/workspace-cleanup/workspace-cleanup-facet-sort.test.ts": 264,
"src/renderer/src/components/workspace-cleanup/workspace-cleanup-flat-list.test.tsx": 2594,
"src/renderer/src/components/workspace-cleanup/workspace-cleanup-removal-candidates.test.ts": 206,
"src/renderer/src/components/workspace-cleanup/workspace-cleanup-removal-settlement.test.ts": 203,
"src/renderer/src/components/workspace-cleanup/workspace-cleanup-removal-timeout-recovery.test.ts": 1817,
"src/renderer/src/components/workspace-cleanup/dialog/WorkspaceCleanupDialog.stale-while-revalidate.test.tsx": 3269,
"src/renderer/src/components/workspace-cleanup/browse/use-workspace-cleanup-browse-state.test.tsx": 248,
"src/renderer/src/components/workspace-cleanup/candidate-evidence/use-workspace-cleanup-git-evidence.test.tsx": 539,
"src/renderer/src/components/workspace-cleanup/removal/use-workspace-cleanup-removal.agent-stop.test.tsx": 2285,
"src/renderer/src/components/workspace-cleanup/candidate-list/use-workspace-cleanup-row-order.test.ts": 242,
"src/renderer/src/components/workspace-cleanup/removal/settlement/workspace-cleanup-background-removal-late-settlement.test.ts": 1880,
"src/renderer/src/components/workspace-cleanup/removal/settlement/workspace-cleanup-background-removal.test.ts": 283,
"src/renderer/src/components/workspace-cleanup/candidate-evidence/workspace-cleanup-host-index.test.ts": 341,
"src/renderer/src/components/workspace-cleanup/query/workspace-cleanup-facet-sort.test.ts": 264,
"src/renderer/src/components/workspace-cleanup/candidate-list/workspace-cleanup-flat-list.test.tsx": 2594,
"src/renderer/src/components/workspace-cleanup/removal/workspace-cleanup-removal-candidates.test.ts": 206,
"src/renderer/src/components/workspace-cleanup/removal/settlement/workspace-cleanup-removal-settlement.test.ts": 203,
"src/renderer/src/components/workspace-cleanup/removal/settlement/workspace-cleanup-removal-timeout-recovery.test.ts": 1817,
"src/renderer/src/components/workspace-emoji/WorkspaceEmojiPickerButton.test.tsx": 1086,
"src/renderer/src/components/workspace-emoji/WorkspaceEmojiPickerPanel.test.tsx": 763,
"src/renderer/src/components/workspace-emoji/useWorkspaceEmojiShortcodeInput.test.tsx": 365,
@@ -25,6 +25,7 @@ const DESTRUCTIVE_CONTROL_RE = /variant=["']destructive["']|variant:\s*["']destr
const CONFIRMATION_DIALOG_RE = /<(?:Alert)?Dialog(?:Content|Footer)\b/
const NATIVE_MESSAGE_BOX_RE = /\bshowMessageBox(?:Sync)?\(/
const PROTECTED_COPY_PRAGMA_RE = /^\s*\/\/ @protected-copy\b/m
const PROTECTED_COPY_FILE_SCOPE_RE = /^\s*\/\/ @protected-copy scope=file\s*$/m
const RELATIVE_IMPORT_RE = /(?:^|\n)\s*(?:import|export)\s[^'"]*?from\s+['"](\.\/[^'"]+)['"]/g
const PLURAL_SUFFIX_RE = /_(?:zero|one|two|few|many|other)$/
const RESOLVE_EXTENSIONS = ['', '.ts', '.tsx', '/index.ts', '/index.tsx']
@@ -75,6 +76,9 @@ export function collectProtectedCopyKeys(sources, englishPaths) {
const marked = [...sources.keys()].filter((file) => protectedCopyMarker(sources.get(file)))
const files = new Set(marked)
for (const file of marked) {
if (PROTECTED_COPY_FILE_SCOPE_RE.test(sources.get(file))) {
continue
}
for (const imported of siblingImports(file, sources.get(file))) {
if (sources.has(imported)) {
files.add(imported)
@@ -15,37 +15,37 @@ import {
getWorkspaceCleanupCandidateIdentity,
resolveWorkspaceCleanupRemovalHostId
} from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { WorkspaceCleanupBrowseToolbar } from './workspace-cleanup-browse-toolbar'
import { WorkspaceCleanupConfirmRemove } from './workspace-cleanup-confirm-remove'
import { WorkspaceCleanupConfirmStopAgents } from './workspace-cleanup-confirm-stop-agents'
import { WorkspaceCleanupDialogHeader } from './workspace-cleanup-dialog-header'
import { WorkspaceCleanupBrowseToolbar } from './browse/workspace-cleanup-browse-toolbar'
import { WorkspaceCleanupConfirmRemove } from './removal/workspace-cleanup-confirm-remove'
import { WorkspaceCleanupConfirmStopAgents } from './removal/agent-consent/workspace-cleanup-confirm-stop-agents'
import { WorkspaceCleanupDialogHeader } from './dialog/workspace-cleanup-dialog-header'
import {
getWorkspaceCleanupDeletionPhaseByIdentity,
selectWorkspaceCleanupDeletionPhases
} from './workspace-cleanup-deletion-phases'
} from './removal/workspace-cleanup-deletion-phases'
import {
WorkspaceCleanupInitialScanBanner,
WorkspaceCleanupNotice,
WorkspaceCleanupSkeletonRows
} from './workspace-cleanup-dialog-notices'
import { WorkspaceCleanupRowList } from './workspace-cleanup-row-list'
import { formatWorkspaceCleanupScanNotice } from './workspace-cleanup-scan-notice'
import { applyWorkspaceCleanupGitEvidence } from './workspace-cleanup-git-evidence'
import { useWorkspaceCleanupBrowseState } from './use-workspace-cleanup-browse-state'
} from './dialog/workspace-cleanup-dialog-notices'
import { WorkspaceCleanupRowList } from './candidate-list/workspace-cleanup-row-list'
import { formatWorkspaceCleanupScanNotice } from './scanning/workspace-cleanup-scan-notice'
import { applyWorkspaceCleanupGitEvidence } from './candidate-evidence/workspace-cleanup-git-evidence'
import { useWorkspaceCleanupBrowseState } from './browse/use-workspace-cleanup-browse-state'
import {
useWorkspaceCleanupDialogLifecycle,
type WorkspaceCleanupDialogLifecycle
} from './use-workspace-cleanup-dialog-lifecycle'
import { useWorkspaceCleanupFacetRows } from './use-workspace-cleanup-facet-rows'
import { useWorkspaceCleanupGitEvidence } from './use-workspace-cleanup-git-evidence'
import { useWorkspaceCleanupIgnore } from './use-workspace-cleanup-ignore'
import { useWorkspaceCleanupRowOrder } from './use-workspace-cleanup-row-order'
import { openWorkspaceCleanupForgetLocally } from './workspace-cleanup-forget-locally-button'
} from './dialog/use-workspace-cleanup-dialog-lifecycle'
import { useWorkspaceCleanupFacetRows } from './browse/use-workspace-cleanup-facet-rows'
import { useWorkspaceCleanupGitEvidence } from './candidate-evidence/use-workspace-cleanup-git-evidence'
import { useWorkspaceCleanupIgnore } from './browse/use-workspace-cleanup-ignore'
import { useWorkspaceCleanupRowOrder } from './candidate-list/use-workspace-cleanup-row-order'
import { openWorkspaceCleanupForgetLocally } from './removal/workspace-cleanup-forget-locally-button'
import {
formatVanishedSelectionNotice,
formatWithheldSelectionNotice,
toggleSetMember
} from './workspace-cleanup-selection-model'
} from './browse/workspace-cleanup-selection-model'
export default function WorkspaceCleanupDialog(): React.JSX.Element | null {
const lifecycle = useWorkspaceCleanupDialogLifecycle()
@@ -8,7 +8,7 @@ import {
createWorkspaceCleanupBrowseSlice,
resetWorkspaceCleanupBrowsePersistTimer
} from '@/store/slices/workspace-cleanup/workspace-cleanup-browse'
import { createDefaultWorkspaceCleanupBrowseState } from '../../../../shared/workspace-cleanup/workspace-cleanup-browse-state'
import { createDefaultWorkspaceCleanupBrowseState } from '../../../../../shared/workspace-cleanup/workspace-cleanup-browse-state'
import {
useWorkspaceCleanupBrowseState,
@@ -5,7 +5,7 @@ import {
type WorkspaceCleanupFilterState,
type WorkspaceCleanupSortField,
type WorkspaceCleanupSortState
} from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
export type WorkspaceCleanupBrowseController = {
filters: WorkspaceCleanupFilterState
@@ -3,25 +3,25 @@ import { useShallow } from 'zustand/react/shallow'
import { useAppStore } from '@/store/index'
import { getLiveAgentStatusByWorktreeId } from '@/lib/workspace/activity/worktree-activity-state'
import { translateWorkspaceBoardStatusLabel } from '@/components/sidebar/workspace-board-status-label'
import type { HostedReviewProvider } from '../../../../shared/source-control/hosted-review/hosted-review-contracts'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { HostedReviewProvider } from '../../../../../shared/source-control/hosted-review/hosted-review-contracts'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import type {
WorkspaceCleanupFilterState,
WorkspaceCleanupSortState
} from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import {
countWorkspaceCleanupMeasuredRows,
type WorkspaceCleanupFacets
} from './workspace-cleanup-facets'
} from '../query/workspace-cleanup-facets'
import {
countWorkspaceCleanupFacetMatches,
filterWorkspaceCleanupFacets,
runWorkspaceCleanupQuery
} from './workspace-cleanup-query'
} from '../query/workspace-cleanup-query'
import {
buildWorkspaceCleanupReviewLookup,
type WorkspaceCleanupReviewInfo
} from './workspace-cleanup-presentation'
} from '../candidate-evidence/workspace-cleanup-review-lookup'
import type {
WorkspaceCleanupFacetCounts,
WorkspaceCleanupFacetOptions
@@ -30,13 +30,13 @@ import {
buildWorkspaceCleanupSizeIndex,
buildWorkspaceCleanupWorktreeIndex,
countWorkspaceCleanupCandidateIds
} from './workspace-cleanup-host-identity'
} from '../candidate-evidence/workspace-cleanup-host-indexes'
import {
computeWorkspaceCleanupFacetList,
computeWorkspaceCleanupReviewInfoIndex,
createWorkspaceCleanupFacetListCache,
createWorkspaceCleanupReviewInfoCache
} from './workspace-cleanup-facet-row-caches'
} from '../query/workspace-cleanup-facet-row-caches'
import { selectWorktreesByRepo } from '@/store/workspaces/catalog/workspace-record-fields'
import { useUiLanguageRevision } from '@/i18n/use-ui-language-revision'
@@ -3,8 +3,8 @@ import { toast } from 'sonner'
import { useMountedRef } from '@/hooks/useMountedRef'
import { useAppStore } from '@/store'
import { translate } from '@/i18n/i18n'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { getWorkspaceCleanupCandidateIdentity } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { getWorkspaceCleanupCandidateIdentity } from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
function describeError(err: unknown): string {
return err instanceof Error ? err.message : String(err)
@@ -1,7 +1,7 @@
import {
createDefaultWorkspaceCleanupFilterState,
type WorkspaceCleanupFilterState
} from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
export type WorkspaceCleanupFacetGroupKey = keyof Omit<WorkspaceCleanupFilterState, 'query'>
@@ -8,8 +8,8 @@ import { toMegabytes } from './workspace-cleanup-facet-panel-model'
import {
type WorkspaceCleanupAppliedFilter,
listAppliedWorkspaceCleanupFilters
} from '../../../../shared/workspace-cleanup/workspace-cleanup-applied-filters'
import type { WorkspaceCleanupFilterState } from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-applied-filters'
import type { WorkspaceCleanupFilterState } from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
// Show narrowing filters outside the panel; derive labels per render so language changes cannot reuse stale translations.
// Why not memoized: the labels are translated at build time, so caching them on
@@ -3,10 +3,10 @@ import { useTranslate } from '@/i18n/use-translate'
import type { WorkspaceCleanupBrowseController } from './use-workspace-cleanup-browse-state'
import type { WorkspaceCleanupFacetRows } from './use-workspace-cleanup-facet-rows'
import { listActiveWorkspaceCleanupFacetGroups } from './workspace-cleanup-active-facets'
import { WorkspaceCleanupEmptyState } from './workspace-cleanup-dialog-notices'
import { WorkspaceCleanupEmptyState } from '../dialog/workspace-cleanup-dialog-notices'
import { WorkspaceCleanupFilterBar } from './workspace-cleanup-filter-bar'
import { WorkspaceCleanupSortHeader } from './workspace-cleanup-sort-header'
import type { WorkspaceSpaceScanProgress } from '../../../../shared/workspace-disk-space/workspace-space-types'
import type { WorkspaceSpaceScanProgress } from '../../../../../shared/workspace-disk-space/workspace-space-types'
export function WorkspaceCleanupBrowseToolbar({
browse,
@@ -1,6 +1,6 @@
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import type { HostedReviewProvider } from '../../../../shared/source-control/hosted-review/hosted-review-contracts'
import type { HostedReviewProvider } from '../../../../../shared/source-control/hosted-review/hosted-review-contracts'
import type {
WorkspaceCleanupAgentState,
WorkspaceCleanupBlockerMode,
@@ -11,7 +11,7 @@ import type {
WorkspaceCleanupSortField,
WorkspaceCleanupTicketSource,
WorkspaceCleanupTriState
} from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
export function getWorkspaceCleanupSortFieldLabel(
field: WorkspaceCleanupSortField,
@@ -1,6 +1,6 @@
import type { ExecutionHostId } from '../../../../shared/execution-host'
import type { HostedReviewProvider } from '../../../../shared/source-control/hosted-review/hosted-review-contracts'
import type { WorkspaceCleanupFilterState } from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import type { ExecutionHostId } from '../../../../../shared/execution-host'
import type { HostedReviewProvider } from '../../../../../shared/source-control/hosted-review/hosted-review-contracts'
import type { WorkspaceCleanupFilterState } from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
export type WorkspaceCleanupFacetCounts = Record<
keyof Omit<WorkspaceCleanupFilterState, 'query'>,
@@ -11,7 +11,7 @@ import {
useAppliedWorkspaceCleanupFilters,
WorkspaceCleanupAppliedFilterChips
} from './workspace-cleanup-applied-filter-chips'
import type { WorkspaceCleanupAppliedFilter } from '../../../../shared/workspace-cleanup/workspace-cleanup-applied-filters'
import type { WorkspaceCleanupAppliedFilter } from '../../../../../shared/workspace-cleanup/workspace-cleanup-applied-filters'
import { WorkspaceCleanupGitReviewFacets } from './workspace-cleanup-git-review-facets'
import { WorkspaceCleanupLifecycleFacets } from './workspace-cleanup-lifecycle-facets'
import type { WorkspaceCleanupFacetGroupProps } from './workspace-cleanup-facet-panel-model'
@@ -1,6 +1,6 @@
import React from 'react'
import { useTranslate } from '@/i18n/use-translate'
import { getTranslatedExecutionHostLabel } from '../sidebar/execution-host-label'
import { getTranslatedExecutionHostLabel } from '../../sidebar/execution-host-label'
import {
WORKSPACE_CLEANUP_BLOCKER_MODE_VALUES,
WORKSPACE_CLEANUP_BLOCKER_VALUES,
@@ -9,8 +9,8 @@ import {
WORKSPACE_CLEANUP_REVIEW_STATE_VALUES,
WORKSPACE_CLEANUP_TICKET_SOURCE_VALUES,
WORKSPACE_CLEANUP_TRI_STATE_VALUES
} from '../../../../shared/workspace-cleanup/workspace-cleanup-facet-rankings'
import { getWorkspaceCleanupBlockerLabel } from './workspace-cleanup-candidate-labels'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-facet-rankings'
import { getWorkspaceCleanupBlockerLabel } from '../candidate-list/workspace-cleanup-candidate-labels'
import {
FacetChoice,
FacetNumberField,
@@ -5,7 +5,7 @@ import {
WORKSPACE_CLEANUP_IDLE_SIGNAL_VALUES,
WORKSPACE_CLEANUP_PRESENCE_VALUES,
WORKSPACE_CLEANUP_TRI_STATE_VALUES
} from '../../../../shared/workspace-cleanup/workspace-cleanup-facet-rankings'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-facet-rankings'
import {
FacetCheckbox,
FacetChoice,
@@ -10,11 +10,11 @@ import {
DropdownMenuTrigger
} from '@/components/ui/dropdown-menu'
import { useTranslate } from '@/i18n/use-translate'
import { WORKSPACE_CLEANUP_SORT_FIELD_VALUES } from '../../../../shared/workspace-cleanup/workspace-cleanup-facet-rankings'
import { WORKSPACE_CLEANUP_SORT_FIELD_VALUES } from '../../../../../shared/workspace-cleanup/workspace-cleanup-facet-rankings'
import type {
WorkspaceCleanupSortField,
WorkspaceCleanupSortState
} from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import { getWorkspaceCleanupSortFieldLabel } from './workspace-cleanup-facet-labels'
export function WorkspaceCleanupSortHeader({
@@ -5,8 +5,8 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import type {
WorkspaceCleanupScanProgress,
WorkspaceCleanupScanResult
} from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { makeFacetCandidate } from './workspace-cleanup-facet.test.fixture'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { makeFacetCandidate } from '../query/workspace-cleanup-facet.test.fixture'
import { useWorkspaceCleanupGitEvidence } from './use-workspace-cleanup-git-evidence'
const holders = vi.hoisted(() => ({ cancelScan: vi.fn(), scan: vi.fn() }))
@@ -102,38 +102,6 @@ describe('useWorkspaceCleanupGitEvidence', () => {
expect(view.result.current.pendingWorktreeIds.size).toBe(5)
})
it('chunks dispatches at the shared target batch limit so no queued id is dropped', async () => {
const first = Array.from({ length: 300 }, (_, i) => deferredCandidate(`a${i}`))
const grown = [...first, ...Array.from({ length: 600 }, (_, i) => deferredCandidate(`b${i}`))]
const view = renderHook(
({ candidates }: { candidates: ReturnType<typeof deferredCandidate>[] }) =>
useWorkspaceCleanupGitEvidence({ enabled: true, candidates, scannedAt: 1 }),
{ initialProps: { candidates: first } }
)
await waitFor(() => expect(holders.scan).toHaveBeenCalledTimes(1))
expect(pending[0]?.worktreeIds).toHaveLength(300)
view.rerender({ candidates: grown })
await waitFor(() => expect(view.result.current.totalCount).toBe(900))
expect(holders.scan).toHaveBeenCalledTimes(1)
await act(async () => {
pending[0]?.resolve({ scannedAt: 1, candidates: [], errors: [] })
})
await waitFor(() => expect(holders.scan).toHaveBeenCalledTimes(2))
expect(pending[1]?.worktreeIds).toHaveLength(500)
await act(async () => {
pending[1]?.resolve({ scannedAt: 1, candidates: [], errors: [] })
})
await waitFor(() => expect(holders.scan).toHaveBeenCalledTimes(3))
expect(pending[2]?.worktreeIds).toHaveLength(100)
const dispatched = pending.flatMap((request) => request.worktreeIds)
expect(new Set(dispatched).size).toBe(900)
})
it('restarts evidence collection when the settled scan snapshot changes', async () => {
const candidates = [deferredCandidate('a')]
const view = renderHook(
@@ -1,13 +1,13 @@
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
import { useMountedRef } from '@/hooks/useMountedRef'
import { getWorkspaceCleanupCandidateIdentity } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { getWorkspaceCleanupCandidateIdentity } from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { selectWorkspaceCleanupGitEvidenceTargets } from './workspace-cleanup-git-evidence'
import {
type WorkspaceCleanupCandidate,
WORKSPACE_CLEANUP_TARGET_BATCH_LIMIT as WORKSPACE_CLEANUP_GIT_EVIDENCE_MAX_TARGETS
} from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { createNonSecureContextUuid as createBrowserUuid } from '../../../../shared/non-secure-context-uuid'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { createNonSecureContextUuid as createBrowserUuid } from '../../../../../shared/non-secure-context-uuid'
import { useAppStore } from '@/store'
import {
cancelWorkspaceCleanupHostScan,
@@ -3,13 +3,13 @@ import {
type WorkspaceCleanupCandidate,
type WorkspaceCleanupReason,
WORKSPACE_CLEANUP_TARGET_BATCH_LIMIT as WORKSPACE_CLEANUP_GIT_EVIDENCE_MAX_TARGETS
} from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { getWorkspaceCleanupCandidateIdentity } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { getWorkspaceCleanupCandidateIdentity } from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import type {
WorkspaceCleanupFilterState,
WorkspaceCleanupSortField,
WorkspaceCleanupSortState
} from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
/** Broad scans may defer Git reads; resolve unknown rows on demand before trusting Git-based filtering or sorting. */
export function hasWorkspaceCleanupGitEvidence(candidate: WorkspaceCleanupCandidate): boolean {
@@ -2,9 +2,9 @@ import { describe, expect, it } from 'vitest'
import {
buildWorkspaceCleanupSizeIndex,
buildWorkspaceCleanupWorktreeIndex
} from './workspace-cleanup-host-identity'
import { getWorkspaceCleanupHostIdentity } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { makeFacetCandidate } from './workspace-cleanup-facet.test.fixture'
} from './workspace-cleanup-host-indexes'
import { getWorkspaceCleanupHostIdentity } from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { makeFacetCandidate } from '../query/workspace-cleanup-facet.test.fixture'
describe('facet building', () => {
it('keeps same-id worktrees and sizes isolated by host', () => {
@@ -2,15 +2,15 @@ import {
getRepoExecutionHostId,
normalizeExecutionHostId,
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 type {
WorkspaceSpaceWorktree,
WorkspaceSpaceWorktreeMeasurement
} from '../../../../shared/workspace-disk-space/workspace-space-types'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { getWorkspaceCleanupHostIdentity } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
} from '../../../../../shared/workspace-disk-space/workspace-space-types'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { getWorkspaceCleanupHostIdentity } from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
/** Structural subset of `Worktree` kept in sync with the persisted source. */
export type WorkspaceCleanupWorktreeFacts = Pick<Worktree, 'id'> &
@@ -1,40 +1,21 @@
// @protected-copy scope=file
import { getHostedReviewCacheKey } from '@/store/slices/hosted-review/hosted-review-cache-identity'
import type { AppState } from '@/store/types'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import { getRepoExecutionHostId } from '../../../../shared/execution-host'
import { getRepoExecutionHostId } from '../../../../../shared/execution-host'
import type {
HostedReviewInfo,
HostedReviewProvider
} from '../../../../shared/source-control/hosted-review/hosted-review-contracts'
import type { Repo } from '../../../../shared/repo-types'
import type { Worktree } from '../../../../shared/worktree/types'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { isGitHubPRSuppressed } from '../../../../shared/worktree/github-pr-suppression'
import './workspace-cleanup-host-identity'
import { getWorkspaceCleanupCandidateHostId } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
} from '../../../../../shared/source-control/hosted-review/hosted-review-contracts'
import type { Repo } from '../../../../../shared/repo-types'
import type { Worktree } from '../../../../../shared/worktree/types'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { isGitHubPRSuppressed } from '../../../../../shared/worktree/github-pr-suppression'
import './workspace-cleanup-host-indexes'
import { getWorkspaceCleanupCandidateHostId } from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { selectWorktreesByRepo } from '@/store/workspaces/catalog/workspace-record-fields'
export type WorkspaceCleanupSortKey = 'activity' | 'name' | 'repo' | 'review' | 'git'
export type WorkspaceCleanupSortDirection = 'asc' | 'desc'
export type WorkspaceCleanupTimeFilter = 'all' | '30d' | '90d' | 'archived'
export type WorkspaceCleanupReviewFilter =
| 'all'
| 'no-review'
| 'has-review'
| 'open-review'
| 'closed-review'
export type WorkspaceCleanupGitFilter = 'all' | 'clean' | 'dirty' | 'unpushed' | 'unknown'
export type WorkspaceCleanupContextFilter = 'all' | 'has-context' | 'no-context'
export type WorkspaceCleanupFilters = {
query: string
time: WorkspaceCleanupTimeFilter
review: WorkspaceCleanupReviewFilter
git: WorkspaceCleanupGitFilter
context: WorkspaceCleanupContextFilter
}
export type WorkspaceCleanupReviewInfo = {
hasReview: boolean
label: string | null
@@ -53,14 +34,6 @@ export type WorkspaceCleanupReviewLookup = {
worktreesByRepoAndId: ReadonlyMap<string, readonly Worktree[]>
}
export {
filterWorkspaceCleanupCandidates,
getWorkspaceCleanupGitState,
getWorkspaceCleanupSearchText,
hasWorkspaceCleanupLocalContext,
sortWorkspaceCleanupCandidates
} from './workspace-cleanup-filter-sort'
export function getWorkspaceCleanupReviewInfo(
candidate: WorkspaceCleanupCandidate,
state: WorkspaceCleanupRendererStateInputs,
@@ -3,7 +3,7 @@
import { renderHook } from '@testing-library/react'
import { describe, expect, it } from 'vitest'
import { useWorkspaceCleanupRowOrder } from './use-workspace-cleanup-row-order'
import type { WorkspaceCleanupSortState } from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import type { WorkspaceCleanupSortState } from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
type Row = { worktreeId: string }
@@ -1,5 +1,5 @@
import { useEffect, useEffectEvent, useMemo, useRef, useState } from 'react'
import type { WorkspaceCleanupSortState } from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import type { WorkspaceCleanupSortState } from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
type OrderedRow = { worktreeId: string }
@@ -1,8 +1,8 @@
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import type { WorkspaceCleanupBlocker } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupGitState } from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import type { WorktreeAtRiskLocalFiles } from '../../../../shared/worktree/at-risk-local-files'
import type { WorkspaceCleanupBlocker } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupGitState } from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import type { WorktreeAtRiskLocalFiles } from '../../../../../shared/worktree/at-risk-local-files'
import { formatAtRiskLocalFileNames } from '@/lib/workspace/display/at-risk-local-files-label'
type ContextDetailKind = 'terminal' | 'editor' | 'browser' | 'diff' | 'agent'
@@ -1,11 +1,12 @@
// @protected-copy scope=file
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import {
isWorkspaceCleanupHeadLanded,
type WorkspaceCleanupBlocker,
type WorkspaceCleanupCandidate
} from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { getWorkspaceCleanupGitState } from './workspace-cleanup-presentation'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { getWorkspaceCleanupGitState } from '../query/workspace-cleanup-candidate-filter-sort'
import {
formatUnpushedCommitCount,
formatWorkspaceCleanupContextDetail,
@@ -2,9 +2,9 @@ import React from 'react'
import { cn } from '@/lib/class-names'
import { useTranslate, type Translate } from '@/i18n/use-translate'
import { CopyButton } from '@/components/right-sidebar/checks-panel/comments/comment-controls'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { formatGitStatus } from './workspace-cleanup-candidate-row-data'
import { getWorkspaceCleanupGitState } from './workspace-cleanup-presentation'
import { getWorkspaceCleanupGitState } from '../query/workspace-cleanup-candidate-filter-sort'
type CandidateRowDetailsProps = {
/** Non-git flags; git safety already reads in the Git line. */
@@ -4,8 +4,8 @@ import { Button } from '@/components/ui/button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { cn } from '@/lib/class-names'
import { useTranslate } from '@/i18n/use-translate'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { WorkspaceCleanupForgetLocallyButton } from './workspace-cleanup-forget-locally-button'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { WorkspaceCleanupForgetLocallyButton } from '../removal/workspace-cleanup-forget-locally-button'
import { getWorkspaceCleanupCandidateAccessibleName } from './workspace-cleanup-host-label'
type CandidateRowTrailingProps = {
@@ -1,11 +1,11 @@
import { defineFixture } from '../../component-fixtures/component-fixture'
import { REPO_COLORS } from '../../../../shared/repo-badge-color'
import type { ExecutionHostId } from '../../../../shared/execution-host'
import type { Repo } from '../../../../shared/repo-types'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { defineFixture } from '../../../component-fixtures/component-fixture'
import { REPO_COLORS } from '../../../../../shared/repo-badge-color'
import type { ExecutionHostId } from '../../../../../shared/execution-host'
import type { Repo } from '../../../../../shared/repo-types'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupFailure } from '@/store/slices/workspace-cleanup/workspace-cleanup-removal'
import { CandidateRow, type WorkspaceCleanupDeletionPhase } from './workspace-cleanup-candidate-row'
import type { WorkspaceCleanupReviewInfo } from './workspace-cleanup-presentation'
import type { WorkspaceCleanupReviewInfo } from '../candidate-evidence/workspace-cleanup-review-lookup'
const NOW = 1_700_000_000_000
const LOCAL: ExecutionHostId = 'local'
@@ -17,8 +17,8 @@ import { useUiLanguageRevision } from '@/i18n/use-ui-language-revision'
import {
canQueueWorkspaceCleanupCandidate,
type WorkspaceCleanupCandidate
} from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupReviewInfo } from './workspace-cleanup-presentation'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupReviewInfo } from '../candidate-evidence/workspace-cleanup-review-lookup'
import { CandidateRowDetails } from './workspace-cleanup-candidate-row-details'
import {
formatBranchSafetyDetails,
@@ -39,13 +39,13 @@ import {
} from './workspace-cleanup-metadata-chip'
import { RepoIconGlyph } from '@/components/repo/repo-icon'
import { resolveRepoHeaderColor } from '@/components/sidebar/worktree-list/rows/project-header-color'
import type { Repo } from '../../../../shared/repo-types'
import type { Repo } from '../../../../../shared/repo-types'
import { CandidateRowTrailing } from './workspace-cleanup-candidate-row-trailing'
import {
getWorkspaceCleanupCandidateAccessibleName,
getWorkspaceCleanupCandidateHostLabel
} from './workspace-cleanup-host-label'
import { getReviewTooltip } from './workspace-cleanup-row-labels'
import { getReviewTooltip } from './workspace-cleanup-review-labels'
import type { WorkspaceCleanupFailure } from '@/store/slices/workspace-cleanup/workspace-cleanup-removal'
export type WorkspaceCleanupDeletionPhase = 'deleting' | 'queued'
@@ -5,9 +5,9 @@ import { createRoot, type Root } from 'react-dom/client'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { CandidateRow } from './workspace-cleanup-candidate-row'
import { WorkspaceCleanupCandidateList } from './workspace-cleanup-candidate-list'
import { makeNamedFacets } from './workspace-cleanup-facet.test.fixture'
import { makeNamedFacets } from '../query/workspace-cleanup-facet.test.fixture'
import type { WorkspaceCleanupFacets } from './workspace-cleanup-facets'
import type { WorkspaceCleanupFacets } from '../query/workspace-cleanup-facets'
vi.mock('@/components/ui/tooltip', () => ({
Tooltip: ({ children }: { children: ReactNode }) => <>{children}</>,
@@ -1,9 +1,10 @@
// @protected-copy scope=file
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import { getTranslatedExecutionHostLabel } from '../sidebar/execution-host-label'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import './workspace-cleanup-host-identity'
import { resolveWorkspaceCleanupRemovalHostId } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { getTranslatedExecutionHostLabel } from '../../sidebar/execution-host-label'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import '../candidate-evidence/workspace-cleanup-host-indexes'
import { resolveWorkspaceCleanupRemovalHostId } from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
export function getWorkspaceCleanupCandidateHostLabel(
candidate: WorkspaceCleanupCandidate,
@@ -1,3 +1,4 @@
// @protected-copy scope=file
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
@@ -1,5 +1,5 @@
import type { WorkspaceCleanupReviewInfo } from './workspace-cleanup-presentation'
import { getWorkspaceCleanupReviewStateLabel } from './workspace-cleanup-facet-labels'
import type { WorkspaceCleanupReviewInfo } from '../candidate-evidence/workspace-cleanup-review-lookup'
import { getWorkspaceCleanupReviewStateLabel } from '../browse/workspace-cleanup-facet-labels'
export function getReviewTooltip(reviewInfo: WorkspaceCleanupReviewInfo): string {
return [reviewInfo.label, getReviewStateSrText(reviewInfo)].filter(Boolean).join(' · ')
@@ -1,19 +1,19 @@
import React, { useMemo } from 'react'
import { useAppStore } from '@/store'
import { useTranslate } from '@/i18n/use-translate'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { formatBytes } from '../../../../shared/format-bytes'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { formatBytes } from '../../../../../shared/format-bytes'
import { CandidateRow, type WorkspaceCleanupDeletionPhase } from './workspace-cleanup-candidate-row'
import { WorkspaceCleanupCandidateList } from './workspace-cleanup-candidate-list'
import { WorkspaceCleanupEmptyState } from './workspace-cleanup-dialog-notices'
import type { WorkspaceCleanupFacets } from './workspace-cleanup-facets'
import { WorkspaceCleanupEmptyState } from '../dialog/workspace-cleanup-dialog-notices'
import type { WorkspaceCleanupFacets } from '../query/workspace-cleanup-facets'
import { formatWorkspaceCleanupRelativeTime } from './workspace-cleanup-relative-time'
import type { WorkspaceCleanupFailure } from '@/store/slices/workspace-cleanup/workspace-cleanup-removal'
import {
findWorkspaceCleanupCandidateRepo,
groupWorkspaceCleanupReposById
} from './workspace-cleanup-presentation'
import { getWorkspaceCleanupCandidateHostId } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
} from '../candidate-evidence/workspace-cleanup-review-lookup'
import { getWorkspaceCleanupCandidateHostId } from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
export type WorkspaceCleanupRowListState = {
rows: readonly WorkspaceCleanupFacets[]
@@ -7,15 +7,15 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type {
WorkspaceCleanupScanProgress,
WorkspaceCleanupScanResult
} from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupBrowseState } from '../../../../shared/workspace-cleanup/workspace-cleanup-browse-state'
import { createTestStore, seedStore } from '../../store/testing/app-store-test-fixture'
import { resetWorkspaceCleanupBrowsePersistTimer } from '../../store/slices/workspace-cleanup/workspace-cleanup-browse'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupBrowseState } from '../../../../../shared/workspace-cleanup/workspace-cleanup-browse-state'
import { createTestStore, seedStore } from '../../../store/testing/app-store-test-fixture'
import { resetWorkspaceCleanupBrowsePersistTimer } from '../../../store/slices/workspace-cleanup/workspace-cleanup-browse'
import {
NOW,
makeCandidate
} from '../../store/slices/workspace-cleanup/workspace-cleanup-slice-test-harness'
import WorkspaceCleanupDialog from './WorkspaceCleanupDialog'
} from '../../../store/slices/workspace-cleanup/workspace-cleanup-slice-test-harness'
import WorkspaceCleanupDialog from '../WorkspaceCleanupDialog'
const holders = vi.hoisted(() => ({
store: null as unknown as { (selector: (s: unknown) => unknown): unknown } & {
@@ -3,8 +3,8 @@ import { useAppStore } from '@/store'
import {
useWorkspaceCleanupRemoval,
type WorkspaceCleanupRemovalController
} from './use-workspace-cleanup-removal'
import { useWorkspaceCleanupScanLifecycle } from './use-workspace-cleanup-scan-lifecycle'
} from '../removal/use-workspace-cleanup-removal'
import { useWorkspaceCleanupScanLifecycle } from '../scanning/use-workspace-cleanup-scan-lifecycle'
const WORKSPACE_CLEANUP_CLOSE_LINGER_MS = 300
@@ -1,14 +1,14 @@
import { defineFixture } from '../../component-fixtures/component-fixture'
import { defineFixture } from '../../../component-fixtures/component-fixture'
import { Dialog } from '@/components/ui/dialog'
import type { WorkspaceCleanupScanProgress } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupScanProgress } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import {
createDefaultWorkspaceCleanupFilterState,
DEFAULT_WORKSPACE_CLEANUP_SORT
} from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import { WorkspaceCleanupDialogHeader } from './workspace-cleanup-dialog-header'
import { WorkspaceCleanupFilterBar } from './workspace-cleanup-filter-bar'
import type { WorkspaceCleanupFacetCounts } from './workspace-cleanup-facet-panel-model'
import { WorkspaceCleanupSortHeader } from './workspace-cleanup-sort-header'
import { WorkspaceCleanupFilterBar } from '../browse/workspace-cleanup-filter-bar'
import type { WorkspaceCleanupFacetCounts } from '../browse/workspace-cleanup-facet-panel-model'
import { WorkspaceCleanupSortHeader } from '../browse/workspace-cleanup-sort-header'
const NOW = Date.now()
const COUNTS: WorkspaceCleanupFacetCounts = {
@@ -5,7 +5,7 @@ import { DialogHeader, DialogTitle } from '@/components/ui/dialog'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { cn } from '@/lib/class-names'
import { useTranslate } from '@/i18n/use-translate'
import type { WorkspaceCleanupScanProgress } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupScanProgress } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { WorkspaceCleanupFreshness } from './workspace-cleanup-freshness'
export function WorkspaceCleanupDialogHeader({
@@ -2,7 +2,7 @@ import React from 'react'
import { AlertTriangle, Loader2 } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { useTranslate } from '@/i18n/use-translate'
import type { WorkspaceCleanupScanProgress } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupScanProgress } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
export function WorkspaceCleanupInitialScanBanner({
progress
@@ -3,8 +3,8 @@ import { useNow } from '@/hooks/use-now'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { translate } from '@/i18n/i18n'
import { useTranslate, type Translate } from '@/i18n/use-translate'
import type { WorkspaceCleanupScanProgress } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { formatWorkspaceCleanupRelativeTime } from './workspace-cleanup-relative-time'
import type { WorkspaceCleanupScanProgress } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { formatWorkspaceCleanupRelativeTime } from '../candidate-list/workspace-cleanup-relative-time'
/** Show the displayed snapshot’s age while a nonblocking rescan indicator streams updates. */
export function WorkspaceCleanupFreshness({
@@ -2,19 +2,35 @@ import { compareDisplayName } from '@/lib/workspace/display/worktree-display-nam
import {
isWorkspaceCleanupHeadLanded,
type WorkspaceCleanupCandidate
} from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupGitState } from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import { getWorkspaceCleanupGitChipLabel } from './workspace-cleanup-candidate-labels'
import type {
WorkspaceCleanupContextFilter,
WorkspaceCleanupFilters,
WorkspaceCleanupGitFilter,
WorkspaceCleanupReviewFilter,
WorkspaceCleanupReviewInfo,
WorkspaceCleanupSortDirection,
WorkspaceCleanupSortKey,
WorkspaceCleanupTimeFilter
} from './workspace-cleanup-presentation'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupGitState } from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import { getWorkspaceCleanupGitChipLabel } from '../candidate-list/workspace-cleanup-candidate-labels'
import type { WorkspaceCleanupReviewInfo } from '../candidate-evidence/workspace-cleanup-review-lookup'
export type WorkspaceCleanupSortKey = 'activity' | 'name' | 'repo' | 'review' | 'git'
export type WorkspaceCleanupSortDirection = 'asc' | 'desc'
export type WorkspaceCleanupTimeFilter = 'all' | '30d' | '90d' | 'archived'
export type WorkspaceCleanupReviewFilter =
| 'all'
| 'no-review'
| 'has-review'
| 'open-review'
| 'closed-review'
export type WorkspaceCleanupGitFilter = 'all' | 'clean' | 'dirty' | 'unpushed' | 'unknown'
export type WorkspaceCleanupContextFilter = 'all' | 'has-context' | 'no-context'
export type WorkspaceCleanupFilters = {
query: string
time: WorkspaceCleanupTimeFilter
review: WorkspaceCleanupReviewFilter
git: WorkspaceCleanupGitFilter
context: WorkspaceCleanupContextFilter
}
const DAY_MS = 24 * 60 * 60 * 1000
@@ -1,10 +1,10 @@
import type { AppState } from '@/store/types'
import { translate } from '@/i18n/i18n'
import type { HostedReviewInfo } from '../../../../shared/source-control/hosted-review/hosted-review-contracts'
import type { Repo } from '../../../../shared/repo-types'
import type { Worktree } from '../../../../shared/worktree/types'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupFilters } from './workspace-cleanup-presentation'
import type { HostedReviewInfo } from '../../../../../shared/source-control/hosted-review/hosted-review-contracts'
import type { Repo } from '../../../../../shared/repo-types'
import type { Worktree } from '../../../../../shared/worktree/types'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupFilters } from './workspace-cleanup-candidate-filter-sort'
export const NOW = 1_700_000_000_000
@@ -12,7 +12,7 @@ import type {
WorkspaceCleanupStatusFilter,
WorkspaceCleanupTicketFilter,
WorkspaceCleanupTriState
} from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
export const WORKSPACE_CLEANUP_DAY_MS = 24 * 60 * 60 * 1000
@@ -1,6 +1,6 @@
import type { LiveAgentWorktreeStatus } from '../../../../shared/sidebar-list/workspace-activity-facts'
import type { WorkspaceStatusDefinition } from '../../../../shared/worktree/types'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { LiveAgentWorktreeStatus } from '../../../../../shared/sidebar-list/workspace-activity-facts'
import type { WorkspaceStatusDefinition } from '../../../../../shared/worktree/types'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import {
buildWorkspaceCleanupFacets,
type WorkspaceCleanupFacetSources,
@@ -11,13 +11,13 @@ import {
type WorkspaceCleanupRendererStateInputs,
type WorkspaceCleanupReviewInfo,
type WorkspaceCleanupReviewLookup
} from './workspace-cleanup-presentation'
import './workspace-cleanup-host-identity'
} from '../candidate-evidence/workspace-cleanup-review-lookup'
import '../candidate-evidence/workspace-cleanup-host-indexes'
import {
getWorkspaceCleanupCandidateHostId,
getWorkspaceCleanupCandidateIdentity,
getWorkspaceCleanupHostIdentity
} from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { getWorktreeVisitTimestamp } from '@/lib/workspace/activation/worktree-visit-recency'
import type { Translate } from '@/i18n/use-translate'
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'
import { makeNamedFacets } from './workspace-cleanup-facet.test.fixture'
import { sortWorkspaceCleanupFacets } from './workspace-cleanup-facet-sort'
import type { WorkspaceCleanupSortField } from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import type { WorkspaceCleanupSortField } from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
function names(
rows: ReturnType<typeof makeNamedFacets>[],
@@ -4,11 +4,11 @@ import {
getWorkspaceCleanupBlockerSeverity,
getWorkspaceCleanupGitRank,
getWorkspaceCleanupReviewRank
} from '../../../../shared/workspace-cleanup/workspace-cleanup-facet-rankings'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-facet-rankings'
import type {
WorkspaceCleanupSortField,
WorkspaceCleanupSortState
} from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
/** Missing signals sort last in either direction; flipping reverses only rows with evidence. */
const ABSENT_LAST_FIELDS: ReadonlySet<WorkspaceCleanupSortField> = new Set([
@@ -1,14 +1,14 @@
import type { LiveAgentWorktreeStatus } from '../../../../shared/sidebar-list/workspace-activity-facts'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { cloneDefaultWorkspaceStatuses } from '../../../../shared/workspace-statuses'
import { getWorkspaceCleanupCandidateIdentity } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import type { LiveAgentWorktreeStatus } from '../../../../../shared/sidebar-list/workspace-activity-facts'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { cloneDefaultWorkspaceStatuses } from '../../../../../shared/workspace-statuses'
import { getWorkspaceCleanupCandidateIdentity } from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import {
buildWorkspaceCleanupFacets,
type WorkspaceCleanupFacetSources,
type WorkspaceCleanupFacets,
type WorkspaceCleanupWorktreeFacts
type WorkspaceCleanupFacets
} from './workspace-cleanup-facets'
import type { WorkspaceCleanupReviewInfo } from './workspace-cleanup-presentation'
import type { WorkspaceCleanupWorktreeFacts } from '../candidate-evidence/workspace-cleanup-host-indexes'
import type { WorkspaceCleanupReviewInfo } from '../candidate-evidence/workspace-cleanup-review-lookup'
export const FACET_NOW = 1_700_000_000_000
export const DAY = 24 * 60 * 60 * 1000
@@ -1,32 +1,31 @@
import type { LiveAgentWorktreeStatus } from '../../../../shared/sidebar-list/workspace-activity-facts'
import type { ExecutionHostId } from '../../../../shared/execution-host'
import type { WorkspaceStatusDefinition } from '../../../../shared/worktree/types'
import type { LiveAgentWorktreeStatus } from '../../../../../shared/sidebar-list/workspace-activity-facts'
import type { ExecutionHostId } from '../../../../../shared/execution-host'
import type { WorkspaceStatusDefinition } from '../../../../../shared/worktree/types'
import {
getWorkspaceCleanupCandidateIdentity,
getWorkspaceCleanupCandidateHostId,
getWorkspaceCleanupHostIdentity
} from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { getWorkspaceStatus } from '../../../../shared/workspace-statuses'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { getWorkspaceStatus } from '../../../../../shared/workspace-statuses'
import {
canQueueWorkspaceCleanupCandidate,
WORKSPACE_CLEANUP_BULK_SELECT_EXCLUSIONS,
type WorkspaceCleanupBlocker,
type WorkspaceCleanupCandidate
} from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { getWorkspaceCleanupGitState } from './workspace-cleanup-filter-sort'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { getWorkspaceCleanupGitState } from './workspace-cleanup-candidate-filter-sort'
import type {
WorkspaceCleanupAgentState,
WorkspaceCleanupGitState,
WorkspaceCleanupReviewState,
WorkspaceCleanupTicketSource
} from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import type { WorkspaceCleanupReviewInfo } from './workspace-cleanup-presentation'
import type { WorkspaceCleanupWorktreeFacts } from './workspace-cleanup-host-identity'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import type { WorkspaceCleanupReviewInfo } from '../candidate-evidence/workspace-cleanup-review-lookup'
import type { WorkspaceCleanupWorktreeFacts } from '../candidate-evidence/workspace-cleanup-host-indexes'
import { getWorktreeVisitTimestamp } from '@/lib/workspace/activation/worktree-visit-recency'
import { getWorkspaceCleanupGitChipLabel } from './workspace-cleanup-candidate-labels'
import { getWorkspaceCleanupGitChipLabel } from '../candidate-list/workspace-cleanup-candidate-labels'
import type { Translate } from '@/i18n/use-translate'
export type { WorkspaceCleanupWorktreeFacts } from './workspace-cleanup-host-identity'
export type WorkspaceCleanupFacetSources = {
worktreeById?: ReadonlyMap<string, WorkspaceCleanupWorktreeFacts>
@@ -1,5 +1,5 @@
import { expect, it } from 'vitest'
import { createDefaultWorkspaceCleanupFilterState } from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import { createDefaultWorkspaceCleanupFilterState } from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
import { makeFacetCandidate } from './workspace-cleanup-facet.test.fixture'
import { queryWorkspaceCleanupCandidates } from './workspace-cleanup-query'
@@ -1,4 +1,4 @@
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import {
buildWorkspaceCleanupFacetList,
type WorkspaceCleanupFacetSources,
@@ -20,7 +20,7 @@ import { sortWorkspaceCleanupFacets } from './workspace-cleanup-facet-sort'
import type {
WorkspaceCleanupFilterState,
WorkspaceCleanupSortState
} from '../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-filter-model'
export type WorkspaceCleanupQuery = {
filters: WorkspaceCleanupFilterState
@@ -1,7 +1,7 @@
import { useCallback, useState } from 'react'
import { useAppStore } from '@/store'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { getWorkspaceCleanupCandidateIdentity } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import type { WorkspaceCleanupCandidate } from '../../../../../../shared/workspace-cleanup/workspace-cleanup'
import { getWorkspaceCleanupCandidateIdentity } from '../../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { getWorkspaceCleanupAgentEvidence } from '@/store/slices/workspace-cleanup/workspace-cleanup-agent-evidence'
import { withWorkspaceCleanupAgentStopApproval } from './workspace-cleanup-agent-stop-approval'
@@ -1,4 +1,4 @@
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupCandidate } from '../../../../../../shared/workspace-cleanup/workspace-cleanup'
/** Stamp explicit agent-stop consent; scan live-agent labels alone are not approval and must be rewritten before final dispatch. */
export function withWorkspaceCleanupAgentStopApproval(
@@ -5,14 +5,14 @@ import { DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/co
import { ScrollArea } from '@/components/ui/scroll-area'
import { cn } from '@/lib/class-names'
import { useTranslate } from '@/i18n/use-translate'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import './workspace-cleanup-host-identity'
import { getWorkspaceCleanupCandidateIdentity } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import type { WorkspaceCleanupCandidate } from '../../../../../../shared/workspace-cleanup/workspace-cleanup'
import '../../candidate-evidence/workspace-cleanup-host-indexes'
import { getWorkspaceCleanupCandidateIdentity } from '../../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import {
getWorkspaceCleanupCandidateAccessibleName,
getWorkspaceCleanupCandidateHostLabel
} from './workspace-cleanup-host-label'
import { WorkspaceCleanupMetadataChip } from './workspace-cleanup-metadata-chip'
} from '../../candidate-list/workspace-cleanup-host-label'
import { WorkspaceCleanupMetadataChip } from '../../candidate-list/workspace-cleanup-metadata-chip'
export function WorkspaceCleanupConfirmStopAgents({
candidates,
@@ -1,11 +1,11 @@
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupCandidate } from '../../../../../../shared/workspace-cleanup/workspace-cleanup'
import {
isPathInsideOrEqual,
normalizeRuntimePathForComparison
} from '../../../../shared/cross-platform-path'
} from '../../../../../../shared/cross-platform-path'
import type { WorkspaceCleanupFailure } from '@/store/slices/workspace-cleanup/workspace-cleanup-removal'
import { translate } from '@/i18n/i18n'
import { getWorkspaceCleanupCandidateHostId } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { getWorkspaceCleanupCandidateHostId } from '../../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
// Ancestor skips remain provisional while blockers remove; authoritative settlement hardens or lifts them.
export type SkippedWorkspaceCleanupAncestor = {
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { toast } from 'sonner'
import type { WorkspaceCleanupRemoveResult } from '@/store/slices/workspace-cleanup/workspace-cleanup-removal'
import { startWorkspaceCleanupBackgroundRemoval } from './workspace-cleanup-background-removal'
import { makeCandidate } from './workspace-cleanup-presentation-fixtures'
import { makeCandidate } from '../../query/workspace-cleanup-candidate-state.test-fixture'
vi.mock('sonner', () => ({
toast: {
@@ -1,7 +1,6 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { startWorkspaceCleanupBackgroundRemoval } from './workspace-cleanup-background-removal'
import { makeCandidate } from './workspace-cleanup-presentation-fixtures'
import { getWorkspaceCleanupHostIdentity } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { makeCandidate } from '../../query/workspace-cleanup-candidate-state.test-fixture'
vi.mock('sonner', () => ({
toast: {
@@ -11,7 +10,7 @@ vi.mock('sonner', () => ({
}
}))
vi.mock('../sidebar/workspace-actions/deletion/preserved-branch-batch-toast', () => ({
vi.mock('../../../sidebar/workspace-actions/deletion/preserved-branch-batch-toast', () => ({
showPreservedBranchBatchToast: vi.fn()
}))
@@ -149,58 +148,4 @@ describe('startWorkspaceCleanupBackgroundRemoval', () => {
]
})
})
it('does not skip a paired-runtime ancestor after another runtime child fails', async () => {
const failedChild = makeCandidate({
worktreeId: 'repo-1::/repo/parent/child',
displayName: 'child',
branch: 'child',
path: '/repo/parent/child',
executionHostId: 'runtime:hub-a'
})
const unrelatedParent = makeCandidate({
worktreeId: 'repo-2::/repo/parent',
repoId: 'repo-2',
repoName: 'Repo 2',
displayName: 'parent',
branch: 'parent',
path: '/repo/parent',
executionHostId: 'runtime:hub-b'
})
const removeCandidates = vi
.fn()
.mockResolvedValueOnce({
removedIds: [],
removedIdentities: [],
failures: [
{
worktreeId: failedChild.worktreeId,
executionHostId: failedChild.executionHostId,
displayName: failedChild.displayName,
message: 'busy'
}
]
})
.mockResolvedValueOnce({
removedIds: [unrelatedParent.worktreeId],
removedIdentities: [
getWorkspaceCleanupHostIdentity('runtime:hub-b', unrelatedParent.worktreeId)
],
failures: []
})
startWorkspaceCleanupBackgroundRemoval({
candidates: [unrelatedParent, failedChild],
removeCandidates,
onProgress: vi.fn()
})
await settleBackgroundRemoval()
expect(removeCandidates).toHaveBeenNthCalledWith(1, [failedChild.worktreeId], {
approvedCandidates: [failedChild]
})
expect(removeCandidates).toHaveBeenNthCalledWith(2, [unrelatedParent.worktreeId], {
approvedCandidates: [unrelatedParent]
})
})
})
@@ -1,12 +1,13 @@
// @protected-copy scope=file
import { toast } from 'sonner'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupCandidate } from '../../../../../../shared/workspace-cleanup/workspace-cleanup'
import type {
WorkspaceCleanupFailure,
WorkspaceCleanupRemoveOptions,
WorkspaceCleanupRemoveResult
} from '@/store/slices/workspace-cleanup/workspace-cleanup-removal'
import { translate } from '@/i18n/i18n'
import { getWorkspaceCleanupCandidateHostId } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { getWorkspaceCleanupCandidateHostId } from '../../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import {
getSkippedAncestorMessage,
isStrictWorkspaceCleanupDescendant,
@@ -1,4 +1,4 @@
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupCandidate } from '../../../../../../shared/workspace-cleanup/workspace-cleanup'
import type {
WorkspaceCleanupFailure,
WorkspaceCleanupRemoveOptions,
@@ -20,7 +20,7 @@ import { reclassifySkippedWorkspaceCleanupAncestors } from './workspace-cleanup-
import {
getWorkspaceCleanupCandidateHostId,
getWorkspaceCleanupCandidateIdentity
} from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
} from '../../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
type WorkspaceCleanupRemoveCandidates = (
worktreeIds: readonly string[],
@@ -3,7 +3,7 @@ import {
trackWorkspaceCleanupLateSettlement,
type WorkspaceCleanupRemovalSettlement
} from './workspace-cleanup-removal-settlement'
import { makeCandidate } from './workspace-cleanup-presentation-fixtures'
import { makeCandidate } from '../../query/workspace-cleanup-candidate-state.test-fixture'
describe('workspace cleanup late settlement tracking', () => {
it('detaches the batch callback and reports with a compact candidate identity', async () => {
@@ -1,10 +1,10 @@
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupCandidate } from '../../../../../../shared/workspace-cleanup/workspace-cleanup'
import type {
WorkspaceCleanupFailure,
WorkspaceCleanupRemoveResult
} from '@/store/slices/workspace-cleanup/workspace-cleanup-removal'
import { translate } from '@/i18n/i18n'
import { getWorkspaceCleanupCandidateHostId } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { getWorkspaceCleanupCandidateHostId } from '../../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
export type WorkspaceCleanupRemovalSettlement =
| { status: 'fulfilled'; result: WorkspaceCleanupRemoveResult }
@@ -4,7 +4,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { toast } from 'sonner'
import type { WorkspaceCleanupRemoveResult } from '@/store/slices/workspace-cleanup/workspace-cleanup-removal'
import { startWorkspaceCleanupBackgroundRemoval } from './workspace-cleanup-background-removal'
import { makeCandidate } from './workspace-cleanup-presentation-fixtures'
import { makeCandidate } from '../../query/workspace-cleanup-candidate-state.test-fixture'
vi.mock('sonner', () => ({
toast: {
@@ -4,7 +4,7 @@ import type {
WorkspaceCleanupRemoveResult
} from '@/store/slices/workspace-cleanup/workspace-cleanup-removal'
import { translate } from '@/i18n/i18n'
import { showPreservedBranchBatchToast } from '../sidebar/workspace-actions/deletion/preserved-branch-batch-toast'
import { showPreservedBranchBatchToast } from '../../../sidebar/workspace-actions/deletion/preserved-branch-batch-toast'
export function showWorkspaceCleanupRemovalResultToasts(
result: WorkspaceCleanupRemoveResult,
@@ -1,4 +1,4 @@
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupCandidate } from '../../../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupFailure } from '@/store/slices/workspace-cleanup/workspace-cleanup-removal'
import {
getSkippedAncestorMessage,
@@ -2,9 +2,9 @@
import { act, renderHook } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { AgentStatusEntry } from '../../../../shared/agent-status/contracts/agent-status-types'
import { makePaneKey } from '../../../../shared/workspace-layout/stable-pane-id'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { AgentStatusEntry } from '../../../../../shared/agent-status/contracts/agent-status-types'
import { makePaneKey } from '../../../../../shared/workspace-layout/stable-pane-id'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import type {
WorkspaceCleanupRemoveOptions,
WorkspaceCleanupRemoveResult
@@ -16,9 +16,9 @@ vi.mock('sonner', () => ({
import { useAppStore } from '@/store'
import { makeTab } from '@/store/terminals/terminal-tab.test-fixture'
import { makeCandidate } from './workspace-cleanup-presentation-fixtures'
import { makeCandidate } from '../query/workspace-cleanup-candidate-state.test-fixture'
import { useWorkspaceCleanupRemoval } from './use-workspace-cleanup-removal'
import { useWorkspaceCleanupDialogLifecycle } from './use-workspace-cleanup-dialog-lifecycle'
import { useWorkspaceCleanupDialogLifecycle } from '../dialog/use-workspace-cleanup-dialog-lifecycle'
const initialState = useAppStore.getInitialState()
const LEAF_ID = '11111111-1111-4111-8111-111111111111'
@@ -1,25 +1,25 @@
import { useCallback, useRef, useState } from 'react'
import { useAppStore } from '@/store'
import { useMountedRef } from '@/hooks/useMountedRef'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import {
getWorkspaceCleanupCandidateIdentity,
getWorkspaceCleanupHostIdentity,
resolveWorkspaceCleanupRemovalHostId
} from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { getWorktreeDeleteStateKey } from '@/store/slices/worktrees/teardown/worktree-delete-state'
import type { WorkspaceCleanupFailure } from '@/store/slices/workspace-cleanup/workspace-cleanup-removal'
import {
startWorkspaceCleanupBackgroundRemoval,
type WorkspaceCleanupRemovalProgress
} from './workspace-cleanup-background-removal'
} from './settlement/workspace-cleanup-background-removal'
import { filterWorkspaceCleanupRemovalCandidates } from './workspace-cleanup-removal-candidates'
import { createWorkspaceCleanupSnapshotPruneBatch } from './workspace-cleanup-snapshot-prune-batch'
import { useWorkspaceCleanupUnverifiedRemoval } from './use-workspace-cleanup-unverified-removal'
import {
useWorkspaceCleanupAgentStopGate,
type WorkspaceCleanupAgentStopRequest
} from './use-workspace-cleanup-agent-stop-gate'
} from './agent-consent/use-workspace-cleanup-agent-stop-gate'
export type WorkspaceCleanupRemovalController = {
confirming: boolean
@@ -1,18 +1,18 @@
import { useCallback, type Dispatch, type SetStateAction } from 'react'
import { useMountedRef } from '@/hooks/useMountedRef'
import { useAppStore } from '@/store'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import {
getWorkspaceCleanupCandidateIdentity,
getWorkspaceCleanupHostIdentity,
resolveWorkspaceCleanupRemovalHostId
} from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import type {
WorkspaceCleanupFailure,
WorkspaceCleanupRemoveResult
} from '@/store/slices/workspace-cleanup/workspace-cleanup-removal'
import { startWorkspaceCleanupBackgroundRemoval } from './workspace-cleanup-background-removal'
import type { WorkspaceCleanupDeletionPhase } from './workspace-cleanup-candidate-row'
import { startWorkspaceCleanupBackgroundRemoval } from './settlement/workspace-cleanup-background-removal'
import type { WorkspaceCleanupDeletionPhase } from '../candidate-list/workspace-cleanup-candidate-row'
import { createWorkspaceCleanupSnapshotPruneBatch } from './workspace-cleanup-snapshot-prune-batch'
type UnverifiedRemovalArgs = {
@@ -10,31 +10,31 @@ import { useTranslate, type Translate } from '@/i18n/use-translate'
import {
needsWorkspaceCleanupRemovalApproval,
type WorkspaceCleanupCandidate
} from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupRemovalProgress } from './workspace-cleanup-background-removal'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupRemovalProgress } from './settlement/workspace-cleanup-background-removal'
import {
getCandidateFactStatuses,
formatContextDetailLabels,
getDirtyGitLabel,
shouldShowGitMetadataChip
} from './workspace-cleanup-candidate-row-data'
import type { WorkspaceCleanupReviewInfo } from './workspace-cleanup-presentation'
import { formatWorkspaceCleanupRelativeTime } from './workspace-cleanup-relative-time'
} from '../candidate-list/workspace-cleanup-candidate-row-data'
import type { WorkspaceCleanupReviewInfo } from '../candidate-evidence/workspace-cleanup-review-lookup'
import { formatWorkspaceCleanupRelativeTime } from '../candidate-list/workspace-cleanup-relative-time'
import { getReviewStateTone } from '@/components/github/review-state-presentation'
import { getReviewStateSrText } from './workspace-cleanup-row-labels'
import { StatusPill } from './workspace-cleanup-status-pill'
import { WorkspaceCleanupCandidateList } from './workspace-cleanup-candidate-list'
import './workspace-cleanup-host-identity'
import { getReviewStateSrText } from '../candidate-list/workspace-cleanup-review-labels'
import { StatusPill } from '../candidate-list/workspace-cleanup-status-pill'
import { WorkspaceCleanupCandidateList } from '../candidate-list/workspace-cleanup-candidate-list'
import '../candidate-evidence/workspace-cleanup-host-indexes'
import {
getWorkspaceCleanupCandidateHostId,
getWorkspaceCleanupCandidateIdentity,
getWorkspaceCleanupHostIdentity
} from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import {
getWorkspaceCleanupCandidateAccessibleName,
getWorkspaceCleanupCandidateHostLabel
} from './workspace-cleanup-host-label'
import { WorkspaceCleanupMetadataText } from './workspace-cleanup-metadata-chip'
} from '../candidate-list/workspace-cleanup-host-label'
import { WorkspaceCleanupMetadataText } from '../candidate-list/workspace-cleanup-metadata-chip'
const CONFIRM_REMOVE_ROW_ESTIMATE_PX = 76
@@ -1,12 +1,12 @@
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorktreeDeleteState } from '@/store/slices/worktrees/teardown/worktree-delete-state-types'
import {
getWorkspaceCleanupCandidateIdentity,
getWorkspaceCleanupIdentityWorktreeId,
resolveWorkspaceCleanupRemovalHostId
} from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { composeWorktreeHostIdentity } from '../../../../shared/worktree/host-qualified-identity'
import type { WorkspaceCleanupDeletionPhase } from './workspace-cleanup-candidate-row'
} from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { composeWorktreeHostIdentity } from '../../../../../shared/worktree/host-qualified-identity'
import type { WorkspaceCleanupDeletionPhase } from '../candidate-list/workspace-cleanup-candidate-row'
export function getWorkspaceCleanupDeletionPhaseByIdentity(
candidates: readonly WorkspaceCleanupCandidate[],
@@ -2,8 +2,8 @@ import { Trash2 } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { useTranslate } from '@/i18n/use-translate'
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import { resolveWorkspaceCleanupRemovalHostId } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import { resolveWorkspaceCleanupRemovalHostId } from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { runWorktreeDelete } from '@/components/sidebar/workspace-actions/deletion/delete-worktree-flow'
export function openWorkspaceCleanupForgetLocally(candidate: WorkspaceCleanupCandidate): void {
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'
import { makeCandidate } from './workspace-cleanup-presentation-fixtures'
import { makeCandidate } from '../query/workspace-cleanup-candidate-state.test-fixture'
import { filterWorkspaceCleanupRemovalCandidates } from './workspace-cleanup-removal-candidates'
import { composeWorktreeHostIdentity } from '../../../../shared/worktree/host-qualified-identity'
import { composeWorktreeHostIdentity } from '../../../../../shared/worktree/host-qualified-identity'
describe('workspace cleanup removal candidates', () => {
it('keeps a same-id sibling on another host removable', () => {
@@ -1,7 +1,7 @@
import type { WorkspaceCleanupCandidate } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupCandidate } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorktreeDeleteState } from '@/store/slices/worktrees/teardown/worktree-delete-state-types'
import { composeWorktreeHostIdentity } from '../../../../shared/worktree/host-qualified-identity'
import { resolveWorkspaceCleanupRemovalHostId } from '../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
import { composeWorktreeHostIdentity } from '../../../../../shared/worktree/host-qualified-identity'
import { resolveWorkspaceCleanupRemovalHostId } from '../../../../../shared/workspace-cleanup/workspace-cleanup-host-identity'
type DeletionFlagState = Pick<WorktreeDeleteState, 'isDeleting' | 'executionHostId'>
@@ -1,5 +1,5 @@
import type { WorkspaceCleanupBackgroundRemovalArgs } from './workspace-cleanup-background-removal'
import { createNonSecureContextUuid as createBrowserUuid } from '../../../../shared/non-secure-context-uuid'
import type { WorkspaceCleanupBackgroundRemovalArgs } from './settlement/workspace-cleanup-background-removal'
import { createNonSecureContextUuid as createBrowserUuid } from '../../../../../shared/non-secure-context-uuid'
export function createWorkspaceCleanupSnapshotPruneBatch():
| WorkspaceCleanupBackgroundRemovalArgs['snapshotPruneBatch']
@@ -1,6 +1,6 @@
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import type { WorkspaceCleanupScanError } from '../../../../shared/workspace-cleanup/workspace-cleanup'
import type { WorkspaceCleanupScanError } from '../../../../../shared/workspace-cleanup/workspace-cleanup'
function isDisconnectedRemoteScanError(message: string): boolean {
return (