diff --git a/config/flaky-test-pattern-baseline.txt b/config/flaky-test-pattern-baseline.txt
index 764a84020c1..b984f4ad50b 100644
--- a/config/flaky-test-pattern-baseline.txt
+++ b/config/flaky-test-pattern-baseline.txt
@@ -272,7 +272,6 @@
1 test-no-real-time-wait:src/renderer/src/components/terminal-pane/viewport/terminal-fit-restore.test.ts
1 test-no-real-time-wait:src/renderer/src/hooks/runtime-project-refresh-scheduler.test.ts
1 test-no-real-time-wait:src/renderer/src/lib/agent-session/resume/cli-fork/native-chat-cli-fork-preparation.test.ts
-1 test-no-real-time-wait:src/renderer/src/lib/orca-yaml-trust-prompt-slot-eviction.test.ts
2 test-no-real-time-wait:src/renderer/src/store/slices/workspace-cleanup/workspace-cleanup-removal-preflight.test.ts
2 test-no-real-time-wait:src/shared/__tests__/process-host/windows-tree-kill-late-taskkill.win32.test.ts
1 test-no-real-time-wait:src/shared/darwin-process-table-capture.test.ts
diff --git a/config/react-compiler-bailout-baseline.txt b/config/react-compiler-bailout-baseline.txt
index d5333975431..3dae37fc31e 100644
--- a/config/react-compiler-bailout-baseline.txt
+++ b/config/react-compiler-bailout-baseline.txt
@@ -705,7 +705,7 @@
4 src/renderer/src/hooks/skills/freshness/useSkillFreshness.ts
1 src/renderer/src/hooks/useTaskPageGitHubWorkItemMutation.ts
6 src/renderer/src/hooks/useVirtualizedScrollAnchor.ts
-1 src/renderer/src/lib/host-chat-program-acquisition.ts
+1 src/renderer/src/lib/agent-session/launch/inventory/host-chat-program-acquisition.ts
1 src/renderer/src/lib/quick-open-file-history.ts
2 src/renderer/src/lib/worker-auto-close.ts
1 src/renderer/src/runtime/native-chat/naming/structured-chat-name-observation.ts
diff --git a/config/scripts/ci/sharding/ci-shard-timings.json b/config/scripts/ci/sharding/ci-shard-timings.json
index aaa18a61795..78ecb4e14e3 100644
--- a/config/scripts/ci/sharding/ci-shard-timings.json
+++ b/config/scripts/ci/sharding/ci-shard-timings.json
@@ -5318,8 +5318,6 @@
"src/renderer/src/components/new-workspace/DirectWorkItemSetupDialog.test.tsx": 5296,
"src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.test.tsx": 2493,
"src/renderer/src/components/new-workspace/ProjectCombobox.dialog-handoff.test.tsx": 1043,
- "src/renderer/src/components/new-workspace/ProjectCombobox.test.tsx": 848,
- "src/renderer/src/components/new-workspace/ProjectComboboxRow.test.tsx": 415,
"src/renderer/src/components/new-workspace/RunTargetCombobox.host-identity.test.tsx": 856,
"src/renderer/src/components/new-workspace/SetProjectLocationDialog.host-identity.test.tsx": 1094,
"src/renderer/src/components/new-workspace/SetProjectLocationDialog.test.tsx": 1387,
@@ -5482,7 +5480,6 @@
"src/renderer/src/components/settings/browser/BrowserUserAgentSetting.test.tsx": 2325,
"src/renderer/src/components/settings/chat/ChatNamingSetting.test.tsx": 2454,
"src/renderer/src/components/settings/chat/ChatPermissionSetting.test.tsx": 834,
- "src/renderer/src/components/settings/chat/ChatSettingsSection.navigation.test.tsx": 2540,
"src/renderer/src/components/settings/chat/ChatSettingsSection.test.tsx": 2718,
"src/renderer/src/lib/skills/runtime/skill-runtime-command.test.ts": 1670,
"src/renderer/src/components/settings/virtual-machines/recipes/EphemeralVmsPane.test.tsx": 1025,
@@ -5524,7 +5521,6 @@
"src/renderer/src/components/settings/developer-permissions/developer-permissions-search.test.ts": 308,
"src/renderer/src/components/settings/shortcuts/keybinding-diagnostic-text.test.ts": 522,
"src/renderer/src/components/settings/shortcuts/keybinding-title-copy.test.ts": 227,
- "src/renderer/src/lib/agent-session/launch/native-chat-provider-choice.test.tsx": 3738,
"src/renderer/src/components/settings/notifications/notification-host-pending-save.test.tsx": 2029,
"src/renderer/src/components/settings/repository/RepositoryJiraProjectSection.test.tsx": 463,
"src/renderer/src/components/settings/repository/RepositoryPaneDraftInput.test.tsx": 314,
@@ -5957,7 +5953,6 @@
"src/renderer/src/components/terminal-pane/emulation/terminal-capability-replies.test.ts": 131,
"src/renderer/src/components/terminal-pane/clipboard/terminal-clipboard-paste.test.ts": 76,
"src/renderer/src/components/terminal-pane/parking/retention/terminal-cold-park-timer-rearm.test.tsx": 701,
- "src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-handler.test.ts": 638,
"src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-image-path.test.ts": 61,
"src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-internal-handler.test.ts": 800,
"src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-path-writer.test.ts": 245,
@@ -6342,7 +6337,7 @@
"src/renderer/src/lib/browser/documents/doc-preview-grants.test.ts": 2094,
"src/renderer/src/lib/editor/file-operations/editor-file-operation-owner.test.ts": 2848,
"src/renderer/src/lib/emulator-error-copy.test.ts": 415,
- "src/renderer/src/lib/ensure-hooks-confirmed.test.ts": 799,
+ "src/renderer/src/runtime/repo-hooks/ensure-hooks-confirmed.test.ts": 799,
"src/renderer/src/lib/simulator/tabs/ensure-simulator-tab-behavior.test.ts": 3601,
"src/renderer/src/runtime/hosts/platform/execution-host-facts.test.ts": 1796,
"src/renderer/src/lib/feature-education-telemetry.test.ts": 52,
@@ -6353,8 +6348,6 @@
"src/renderer/src/lib/focus-terminal-tab-surface.split-focus.test.ts": 331,
"src/renderer/src/lib/foreground-terminal-tabs.test.ts": 55,
"src/renderer/src/lib/work-items/github/github-source-runtime-context.test.ts": 62,
- "src/renderer/src/lib/hook-command-delayed-delivery.test.ts": 1904,
- "src/renderer/src/lib/host-chat-program.test.ts": 2419,
"src/renderer/src/lib/host-mirror-handle-gap-drain.test.ts": 1706,
"src/renderer/src/lib/host-mirror-handle-gap-resume.test.ts": 1811,
"src/renderer/src/lib/host-mirrored-pane-resume-replay.test.ts": 1814,
@@ -6399,12 +6392,8 @@
"src/renderer/src/lib/monaco-languages/textmate-token-provider.test.ts": 245,
"src/renderer/src/lib/monaco-languages/zig-highlighting.test.ts": 7984,
"src/renderer/src/lib/agent-session/resume/cli-fork/native-chat-cli-fork-preparation.test.ts": 2773,
- "src/renderer/src/lib/new-workspace.test.ts": 4534,
- "src/renderer/src/lib/non-secure-context-crypto.repro.test.ts": 1691,
- "src/renderer/src/lib/onboarding-folder-cancellation.test.ts": 2486,
"src/renderer/src/lib/open-agent-message-sender.test.ts": 1497,
"src/renderer/src/lib/simulator/launch/open-mobile-emulator-tab.test.ts": 545,
- "src/renderer/src/lib/orca-yaml-trust-prompt-slot-eviction.test.ts": 884,
"src/renderer/src/lib/order-empty-query-worktrees.test.ts": 62,
"src/renderer/src/lib/os-file-drop-cancellation-guard.test.ts": 204,
"src/renderer/src/lib/os-file-drop-preload-integration.test.tsx": 353,
@@ -6476,9 +6465,9 @@
"src/renderer/src/lib/plugin-monaco-token-rules.test.ts": 51,
"src/renderer/src/lib/source-control/review/pr-bot-author-overrides.test.ts": 349,
"src/renderer/src/lib/source-control/review/comments/pr-comment-thread-resolution.test.ts": 48,
- "src/renderer/src/lib/project-clone-url-prefill.test.ts": 61,
- "src/renderer/src/lib/project-host-workspace-target.jira-mapping.test.ts": 76,
- "src/renderer/src/lib/project-host-workspace-target.test.ts": 92,
+ "src/renderer/src/lib/workspace/creation/project-clone-url-prefill.test.ts": 61,
+ "src/renderer/src/lib/workspace/creation/project-host-workspace-target.jira-mapping.test.ts": 76,
+ "src/renderer/src/lib/workspace/creation/project-host-workspace-target.test.ts": 92,
"src/renderer/src/lib/react-commit-cascade-observer.react185.test.tsx": 285,
"src/renderer/src/lib/react-commit-cascade-observer.test.ts": 189,
"src/renderer/src/lib/react-commit-cascade-telemetry.test.ts": 159,
@@ -6519,7 +6508,6 @@
"src/renderer/src/lib/simulator/tabs/simulator-pane-shutdown-scheduler.test.ts": 1679,
"src/renderer/src/lib/simulator/tabs/simulator-tab-layout-owner.test.ts": 2398,
"src/renderer/src/lib/simulator/tabs/simulator-tab-palette-activation.test.ts": 1903,
- "src/renderer/src/lib/sleeping-agent-session-launch-windows-quoting.test.ts": 547,
"src/renderer/src/lib/source-control/remote/source-control-remote-error.test.ts": 340,
"src/renderer/src/lib/ssh-config-passive-sync.test.ts": 1513,
"src/renderer/src/lib/state-collection-byte-estimate.test.ts": 86,
@@ -8045,7 +8033,6 @@
"tests/e2e/sustained-agent-typing-load-scripts.unit.test.ts": 2169,
"tests/e2e/task-page-linear-refresh-authority.unit.test.ts": 5548,
"tests/e2e/task-page-linear-refresh-transport.unit.test.ts": 2019,
- "tests/e2e/terminal-agent-fork-draft-ownership.unit.test.ts": 30195,
"tests/e2e/terminal-binding-crash-hydration.unit.test.ts": 1769,
"tests/e2e/terminal-foreground-confirmation.unit.test.ts": 644,
"tests/e2e/terminal-perf-presentation.unit.test.ts": 60,
diff --git a/config/scripts/test-runtime/execution-policy/vitest-shared-worker-setup-runner.mjs b/config/scripts/test-runtime/execution-policy/vitest-shared-worker-setup-runner.mjs
new file mode 100644
index 00000000000..1b41d2349cc
--- /dev/null
+++ b/config/scripts/test-runtime/execution-policy/vitest-shared-worker-setup-runner.mjs
@@ -0,0 +1,16 @@
+import { TestRunner } from 'vitest'
+
+export default class SharedWorkerSetupRunner extends TestRunner {
+ importFile(filepath, source) {
+ if (source === 'setup') {
+ // Warm transforms can key setup roots by a different URL than Vitest invalidates.
+ const modules = this.moduleRunner.evaluatedModules
+ for (const node of modules.getModulesByFile(filepath) ?? []) {
+ if (node.evaluated) {
+ modules.invalidateModule(node)
+ }
+ }
+ }
+ return super.importFile(filepath, source)
+ }
+}
diff --git a/config/tsconfig.node.json b/config/tsconfig.node.json
index 563748d8a33..5702c01cc47 100644
--- a/config/tsconfig.node.json
+++ b/config/tsconfig.node.json
@@ -23,7 +23,7 @@
"../src/cli/runtime/runtime-access-denied.ts",
"../src/cli/runtime/runtime-pid-liveness.ts",
"../src/renderer/src/store/slices/worktrees/create/worktree-create-payload.ts",
- "../src/renderer/src/lib/orca-hook-trust.ts",
+ "../src/renderer/src/runtime/repo-hooks/orca-hook-trust.ts",
"../src/renderer/src/lib/sha256.ts",
"../src/renderer/src/components/native-chat/native-chat-resolution-receipt.ts",
"../src/renderer/src/components/native-chat/structured-agent-question-projection.ts",
diff --git a/config/vitest.config.ts b/config/vitest.config.ts
index eab54372357..bfed0dadfdd 100644
--- a/config/vitest.config.ts
+++ b/config/vitest.config.ts
@@ -153,6 +153,9 @@ const sharedProjects =
name: `${runtimeProject.test.name}-shared`,
include: sharedWorkerFiles,
isolate: false,
+ runner: resolve(
+ 'config/scripts/test-runtime/execution-policy/vitest-shared-worker-setup-runner.mjs'
+ ),
setupFiles: [
...runtimeProject.test.setupFiles,
resolve('config/scripts/test-runtime/environment/vitest-shared-worker-file-reset.mjs')
diff --git a/src/main/workspace-hooks/created-worktree-setup-trust-parity.test.ts b/src/main/workspace-hooks/created-worktree-setup-trust-parity.test.ts
index 8a52338b972..5be81369820 100644
--- a/src/main/workspace-hooks/created-worktree-setup-trust-parity.test.ts
+++ b/src/main/workspace-hooks/created-worktree-setup-trust-parity.test.ts
@@ -4,7 +4,7 @@ import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { getSetupTrustContent } from '../../shared/orca-hook-setup-config'
-import '../../renderer/src/lib/orca-hook-trust'
+import '../../renderer/src/runtime/repo-hooks/orca-hook-trust'
import '../runtime/repositories/runtime-repository-hooks-commands'
import { loadHooks } from './hooks'
import { hashOrcaHookTrustContent } from './created-worktree-setup-trust'
diff --git a/src/renderer/src/components/NewWorkspaceComposerCard.tsx b/src/renderer/src/components/NewWorkspaceComposerCard.tsx
index 514a3b90408..3a898de67f3 100644
--- a/src/renderer/src/components/NewWorkspaceComposerCard.tsx
+++ b/src/renderer/src/components/NewWorkspaceComposerCard.tsx
@@ -5,7 +5,7 @@ import { useAppStore } from '@/store'
import { cn } from '@/lib/utils'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import { getScreenSubmitModifierLabel } from '@/lib/screen-submit-shortcut'
-import { resolveProjectCloneUrlPrefill } from '@/lib/project-clone-url-prefill'
+import { resolveProjectCloneUrlPrefill } from '@/lib/workspace/creation/project-clone-url-prefill'
import { useContextualTour } from '@/components/contextual-tours/use-contextual-tour'
import {
AddRemoteHostDialog,
diff --git a/src/renderer/src/components/NewWorkspaceComposerModal.tsx b/src/renderer/src/components/NewWorkspaceComposerModal.tsx
index 1c0169e1b1b..c0a27c4122c 100644
--- a/src/renderer/src/components/NewWorkspaceComposerModal.tsx
+++ b/src/renderer/src/components/NewWorkspaceComposerModal.tsx
@@ -3,13 +3,13 @@ import { toast } from 'sonner'
import {
formatWorkspaceCreateError,
getWorkspaceCreateErrorToastMessage
-} from '@/lib/workspace-create-error-format'
+} from '@/lib/workspace/creation/workspace-create-error-format'
import type {
AgentPickerDraft,
AgentPickerEntry
} from '../../../shared/agent-launch/picker/agent-launch-picker'
import { DirectWorkItemSetupDialog } from './new-workspace/DirectWorkItemSetupDialog'
-import { agentChoicePending } from '@/lib/host-chat-program'
+import { agentChoicePending } from '@/lib/agent-session/launch/inventory/host-chat-program'
import type { AgentLaunchSurface } from '@/lib/agent-session/launch/routing/agent-session-launch-plan'
import React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useAppStore } from '@/store/index'
@@ -32,14 +32,14 @@ import {
quickWorkspacePickerInputs,
pickQuickWorkspaceAgent,
resolveQuickWorkspaceAgentSelection
-} from '@/lib/quick-workspace-agent-selection'
-import { useAgentsOfferedForLaunch } from '@/lib/host-chat-program-acquisition'
-import { shouldAllowComposerEnterSubmitTarget } from '@/lib/new-workspace-enter-guard'
+} from '@/lib/workspace/creation/quick-workspace-agent-selection'
+import { useAgentsOfferedForLaunch } from '@/lib/agent-session/launch/inventory/host-chat-program-acquisition'
+import { shouldAllowComposerEnterSubmitTarget } from '@/lib/workspace/creation/new-workspace-enter-guard'
import { isScreenSubmitShortcut } from '@/lib/screen-submit-shortcut'
import type { TuiAgent } from '../../../shared/agent-launch/catalog/tui-agent'
import { translate } from '@/i18n/i18n'
import { useTranslate } from '@/i18n/use-translate'
-import { getWorkspaceComposerInitialFocusTarget } from '@/lib/workspace-composer-initial-focus'
+import { getWorkspaceComposerInitialFocusTarget } from '@/lib/workspace/creation/workspace-composer-initial-focus'
import '@/components/sidebar/workspace-creation/folder/folder-workspace-source-repos'
import { getFolderWorkspacePrimaryActionLabel } from '@/components/sidebar/workspace-creation/folder/folder-workspace-source-selection'
import { useAgentMenuObservation } from '@/components/tab-bar/use-new-tab-agent-menu-rows'
diff --git a/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx b/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx
index 73eae33015f..8af089829b8 100644
--- a/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx
+++ b/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx
@@ -1,5 +1,5 @@
import { useAgentPickerDraftScope } from '../agent/AgentLaunchSetupButton'
-import { agentsOfferedForLaunch } from '@/lib/host-chat-program'
+import { agentsOfferedForLaunch } from '@/lib/agent-session/launch/inventory/host-chat-program'
import { worktreeLaunchWorkspace } from '@/lib/agent-session/launch/routing/agent-launch-route-input'
import { useEffect, useRef, useState } from 'react'
import { Loader2, MessageSquarePlus } from 'lucide-react'
diff --git a/src/renderer/src/components/automations/authoring/AutomationEditorDialog.tsx b/src/renderer/src/components/automations/authoring/AutomationEditorDialog.tsx
index 55e3087582b..45e34130a12 100644
--- a/src/renderer/src/components/automations/authoring/AutomationEditorDialog.tsx
+++ b/src/renderer/src/components/automations/authoring/AutomationEditorDialog.tsx
@@ -2,7 +2,7 @@ import type { AutomationAuthorityRef } from '../../../../../shared/automations/o
import React from 'react'
import { useAppStore } from '@/store/index'
import { selectAgentLaunchRouteView } from '@/lib/agent-session/launch/routing/agent-launch-route-input'
-import { useChatProgramFacts } from '@/lib/host-chat-program-acquisition'
+import { useChatProgramFacts } from '@/lib/agent-session/launch/inventory/host-chat-program-acquisition'
import {
automationChatSupport,
automationDraftSurface,
diff --git a/src/renderer/src/components/automations/authoring/automation-orca-save.ts b/src/renderer/src/components/automations/authoring/automation-orca-save.ts
index eb6de9e658b..e2dd43ee641 100644
--- a/src/renderer/src/components/automations/authoring/automation-orca-save.ts
+++ b/src/renderer/src/components/automations/authoring/automation-orca-save.ts
@@ -17,7 +17,7 @@ import type {
AutomationUpdateInput
} from '../../../../../shared/automations/automation-definition'
import { getRepoExecutionHostId } from '../../../../../shared/execution-host'
-import { ensureHooksApproved } from '@/lib/ensure-hooks-confirmed'
+import { ensureHooksApproved } from '@/runtime/repo-hooks/ensure-hooks-confirmed'
import { translate } from '@/i18n/i18n'
import { useAppStore } from '@/store/index'
import { listAutomationsForTarget } from '../hosts/automation-host-client'
diff --git a/src/renderer/src/components/automations/authoring/automation-setup-review.ts b/src/renderer/src/components/automations/authoring/automation-setup-review.ts
index f93f37175cb..280510157b4 100644
--- a/src/renderer/src/components/automations/authoring/automation-setup-review.ts
+++ b/src/renderer/src/components/automations/authoring/automation-setup-review.ts
@@ -5,7 +5,7 @@ import {
confirmCreatedWorktreeSetupContent,
ensureHooksApproved,
type HookTrustApproval
-} from '@/lib/ensure-hooks-confirmed'
+} from '@/runtime/repo-hooks/ensure-hooks-confirmed'
import type { AutomationSaveContext } from './automation-save-context'
import type { Automation } from '../../../../../shared/automations/automation-definition'
import type { AutomationUsageSummary } from '../../../../../shared/automations/history/automation-usage-summary'
diff --git a/src/renderer/src/components/automations/automations-page-test-harness.tsx b/src/renderer/src/components/automations/automations-page-test-harness.tsx
index 309adc4fed9..cab3577d27c 100644
--- a/src/renderer/src/components/automations/automations-page-test-harness.tsx
+++ b/src/renderer/src/components/automations/automations-page-test-harness.tsx
@@ -113,7 +113,7 @@ vi.mock('@/runtime/repo-hooks/runtime-hooks-client', () => ({
checkRuntimeHooks: vi.fn(async () => ({ hooks: null, ok: true }))
}))
-vi.mock('@/lib/ensure-hooks-confirmed', () => ({
+vi.mock('@/runtime/repo-hooks/ensure-hooks-confirmed', () => ({
ensureHooksConfirmed: vi.fn(async () => 'inherit'),
ensureHooksApproved: vi.fn(async () => ({ decision: 'run' }))
}))
diff --git a/src/renderer/src/components/cmd-j/task-search-activation.ts b/src/renderer/src/components/cmd-j/task-search-activation.ts
index 2b7989e3d56..09b8445c942 100644
--- a/src/renderer/src/components/cmd-j/task-search-activation.ts
+++ b/src/renderer/src/components/cmd-j/task-search-activation.ts
@@ -6,11 +6,12 @@ import {
parseWorkspaceReferenceUrl
} from '../../../../shared/workspace-attachments/workspace-reference-identity'
import { getLinearIssueWorkspaceName } from '../../../../shared/workspace-name'
+import '@/lib/workspace/creation/new-workspace'
import {
getLinkedWorkItemWorkspaceName,
- getLinkedWorkItemSuggestedName,
- type LinkedWorkItemSummary
-} from '@/lib/new-workspace'
+ getLinkedWorkItemSuggestedName
+} from '../../../../shared/workspace-name'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import { buildLinearIssueLinkedWorkItem } from '@/lib/work-items/linear/linear-linked-work-item'
import type { Worktree } from '../../../../shared/worktree/types'
import {
diff --git a/src/renderer/src/components/dashboard/dashboard-chat-program-acquisition.ts b/src/renderer/src/components/dashboard/dashboard-chat-program-acquisition.ts
index b3f8308d39c..a6f29976a82 100644
--- a/src/renderer/src/components/dashboard/dashboard-chat-program-acquisition.ts
+++ b/src/renderer/src/components/dashboard/dashboard-chat-program-acquisition.ts
@@ -1,6 +1,6 @@
import type { AppState } from '@/store/types'
-import { holdChatProgramFacts } from '@/lib/host-chat-program-acquisition'
-import { resolveChatProgramContext } from '@/lib/host-chat-program'
+import { holdChatProgramFacts } from '@/lib/agent-session/launch/inventory/host-chat-program-acquisition'
+import { resolveChatProgramContext } from '@/lib/agent-session/launch/inventory/host-chat-program'
import {
selectAgentLaunchRouteView,
worktreeLaunchWorkspace
diff --git a/src/renderer/src/components/dashboard/dashboard-worktree-launch-options.ts b/src/renderer/src/components/dashboard/dashboard-worktree-launch-options.ts
index 76eaa73c76e..7e6e7dab48b 100644
--- a/src/renderer/src/components/dashboard/dashboard-worktree-launch-options.ts
+++ b/src/renderer/src/components/dashboard/dashboard-worktree-launch-options.ts
@@ -17,7 +17,7 @@ import {
worktreeLaunchWorkspace,
type AgentLaunchRouteView
} from '@/lib/agent-session/launch/routing/agent-launch-route-input'
-import { agentsOfferedForLaunch } from '@/lib/host-chat-program'
+import { agentsOfferedForLaunch } from '@/lib/agent-session/launch/inventory/host-chat-program'
import { selectWorktreesByRepo } from '@/store/workspaces/catalog/workspace-record-fields'
export type DashboardLaunchDetectionState = Pick<
diff --git a/src/renderer/src/components/dashboard/useDashboardPopoutBridge.ts b/src/renderer/src/components/dashboard/useDashboardPopoutBridge.ts
index 17247a60c28..73539bed721 100644
--- a/src/renderer/src/components/dashboard/useDashboardPopoutBridge.ts
+++ b/src/renderer/src/components/dashboard/useDashboardPopoutBridge.ts
@@ -6,7 +6,7 @@ import {
subscribeStructuredChatTabNames,
getStructuredChatTabNames
} from '@/runtime/native-chat/naming/structured-chat-name-observation'
-import { subscribeChatProgramFacts } from '@/lib/host-chat-program'
+import { subscribeChatProgramFacts } from '@/lib/agent-session/launch/inventory/host-chat-program'
import {
type AgentLaunchRouteView,
agentLaunchRouteInputsChanged,
diff --git a/src/renderer/src/components/dashboard/useLiveDashboardSnapshot.ts b/src/renderer/src/components/dashboard/useLiveDashboardSnapshot.ts
index bb2225f0e39..548b3ed1f8a 100644
--- a/src/renderer/src/components/dashboard/useLiveDashboardSnapshot.ts
+++ b/src/renderer/src/components/dashboard/useLiveDashboardSnapshot.ts
@@ -5,7 +5,7 @@ import { useAppStore } from '@/store'
import { useStructuredChatTabNames } from '@/runtime/native-chat/naming/structured-chat-name-observation'
import type { DashboardSnapshot } from '../../../../shared/dashboard-snapshot'
import { buildDashboardSnapshot } from './build-dashboard-snapshot'
-import { useChatProgramFactsVersion } from '@/lib/host-chat-program-acquisition'
+import { useChatProgramFactsVersion } from '@/lib/agent-session/launch/inventory/host-chat-program-acquisition'
import { createWorktreeAgentRowsCache } from './worktree-agent-rows-cache'
import { selectAgentLaunchRouteView } from '@/lib/agent-session/launch/routing/agent-launch-route-input'
import {
diff --git a/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.fixture.tsx b/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.fixture.tsx
index b4b91dc4cd5..66ba61079d7 100644
--- a/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.fixture.tsx
+++ b/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.fixture.tsx
@@ -1,10 +1,10 @@
import { useState } from 'react'
import { defineFixture } from '../../component-fixtures/component-fixture'
-import type { NewWorkspaceProjectOption } from '@/lib/new-workspace-project-options'
+import type { NewWorkspaceProjectOption } from '@/lib/workspace/creation/new-workspace-project-options'
import {
getProjectHostSetupSelectionKey,
type ProjectHostSetupOption
-} from '@/lib/project-host-setup-options'
+} from '@/lib/workspace/creation/project-host-setup-options'
import { NewWorkspaceComposerProjectSection } from './NewWorkspaceComposerProjectSection'
const projects: NewWorkspaceProjectOption[] = [
diff --git a/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx b/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx
index 66053fe642a..b4896ecbffe 100644
--- a/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx
+++ b/src/renderer/src/components/new-workspace/NewWorkspaceComposerProjectSection.tsx
@@ -6,7 +6,7 @@ import ProjectCombobox from '@/components/new-workspace/ProjectCombobox'
import RunTargetCombobox from '@/components/new-workspace/RunTargetCombobox'
import { useTranslate } from '@/i18n/use-translate'
import { cn } from '@/lib/utils'
-import { getSelectedNewWorkspaceProjectOptionId } from '@/lib/new-workspace-project-options'
+import { getSelectedNewWorkspaceProjectOptionId } from '@/lib/workspace/creation/new-workspace-project-options'
import type {
EphemeralVmRecipeOption,
NeedsProjectHostOption,
diff --git a/src/renderer/src/components/new-workspace/ProjectCombobox.test.tsx b/src/renderer/src/components/new-workspace/ProjectCombobox.test.tsx
deleted file mode 100644
index 80833845fcd..00000000000
--- a/src/renderer/src/components/new-workspace/ProjectCombobox.test.tsx
+++ /dev/null
@@ -1,171 +0,0 @@
-// @vitest-environment happy-dom
-
-import React, { act } from 'react'
-import { createRoot, type Root } from 'react-dom/client'
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import type { NewWorkspaceProjectOption } from '@/lib/new-workspace-project-options'
-import ProjectCombobox from './ProjectCombobox'
-import { TooltipProvider } from '@/components/ui/tooltip'
-
-// Render inline and expose Radix-style close independently of the component key handler.
-vi.mock('@/components/ui/popover', () => ({
- Popover: ({
- children,
- onOpenChange
- }: {
- children: React.ReactNode
- onOpenChange?: (open: boolean) => void
- }) => (
-
-
- ),
- PopoverAnchor: ({ children }: { children: React.ReactNode }) => <>{children}>,
- PopoverContent: ({ children }: { children: React.ReactNode }) => {children}
-}))
-
-vi.mock('./use-recent-project-ids', () => ({ useRecentProjectIds: () => [] }))
-
-let container: HTMLDivElement
-let root: Root
-
-function renderField(element: React.ReactNode): void {
- root.render({element})
-}
-
-const projects: NewWorkspaceProjectOption[] = [
- {
- kind: 'project',
- id: 'github:stablyai/orca',
- projectId: 'github:stablyai/orca',
- displayName: 'orca',
- badgeColor: '#111111',
- detail: 'stablyai/orca'
- },
- {
- kind: 'project',
- id: 'github:stablyai/noqa',
- projectId: 'github:stablyai/noqa',
- displayName: 'noqa',
- badgeColor: '#222222',
- detail: 'stablyai/noqa'
- },
- {
- kind: 'project-group',
- id: 'project-group:folder-group',
- projectGroupId: 'folder-group',
- displayName: 'Platform',
- badgeColor: '#333333',
- detail: '/tmp/platform',
- parentPath: '/tmp/platform',
- connectionId: null
- }
-]
-
-function field(): HTMLInputElement {
- const node = container.querySelector(
- 'input[data-project-combobox-root="true"][role="combobox"]'
- )
- if (!node) {
- throw new Error('project combobox field not found')
- }
- return node
-}
-
-function openList(): void {
- act(() => {
- field().focus()
- })
-}
-
-function type(value: string): void {
- const input = field()
- act(() => {
- const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')?.set
- setter?.call(input, value)
- input.dispatchEvent(new Event('input', { bubbles: true }))
- })
-}
-
-beforeEach(() => {
- container = document.createElement('div')
- document.body.appendChild(container)
- root = createRoot(container)
-})
-
-afterEach(() => {
- act(() => {
- root.unmount()
- })
- container.remove()
-})
-
-describe('ProjectCombobox', () => {
- it('arms "Add project" when a query matches nothing, so Enter is never a wrong guess', () => {
- const onAddProject = vi.fn()
- const onValueChange = vi.fn()
-
- act(() => {
- renderField(
-
- )
- })
- openList()
- type('zzzznomatch')
- act(() => {
- field().dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }))
- })
-
- expect(onAddProject).toHaveBeenCalledTimes(1)
- expect(onValueChange).not.toHaveBeenCalled()
- })
-
- // Sectioning sinks folders below projects; raw rank would arm the bottom row and Enter would choose the wrong project.
- const sectionedOptions: NewWorkspaceProjectOption[] = [
- ...Array.from({ length: 5 }, (_, index) => ({
- kind: 'project' as const,
- id: `project-${index}`,
- projectId: `project-${index}`,
- displayName: `svc-${index}`,
- badgeColor: '#111111',
- detail: `stablyai/svc-${index}`
- })),
- {
- kind: 'project-group',
- id: 'project-group:apps',
- projectGroupId: 'apps',
- displayName: 'Apps',
- badgeColor: '#333333',
- detail: '/tmp/apps',
- parentPath: '/tmp/apps',
- connectionId: null
- }
- ]
-
- it('commits the top row on Enter rather than the folder group sectioned to the bottom', () => {
- const onValueChange = vi.fn()
-
- act(() => {
- renderField(
-
- )
- })
- act(() => {
- container
- .querySelector('[data-project-combobox-root="true"]')
- ?.dispatchEvent(new MouseEvent('click', { bubbles: true }))
- })
- act(() => {
- field().dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }))
- })
-
- expect(onValueChange).toHaveBeenCalledWith('project-0')
- expect(onValueChange).not.toHaveBeenCalledWith('project-group:apps')
- })
-})
diff --git a/src/renderer/src/components/new-workspace/ProjectCombobox.tsx b/src/renderer/src/components/new-workspace/ProjectCombobox.tsx
index f89e9096d50..43a1272ac13 100644
--- a/src/renderer/src/components/new-workspace/ProjectCombobox.tsx
+++ b/src/renderer/src/components/new-workspace/ProjectCombobox.tsx
@@ -4,7 +4,7 @@ import { ChevronDown, FolderPlus } from 'lucide-react'
import { Popover, PopoverAnchor, PopoverContent } from '@/components/ui/popover'
import { cn } from '@/lib/utils'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
-import type { NewWorkspaceProjectOption } from '@/lib/new-workspace-project-options'
+import type { NewWorkspaceProjectOption } from '@/lib/workspace/creation/new-workspace-project-options'
import { useTranslate } from '@/i18n/use-translate'
import {
getAmbiguousProjectOptionIds,
diff --git a/src/renderer/src/components/new-workspace/ProjectComboboxRow.test.tsx b/src/renderer/src/components/new-workspace/ProjectComboboxRow.test.tsx
deleted file mode 100644
index 7b3850dce98..00000000000
--- a/src/renderer/src/components/new-workspace/ProjectComboboxRow.test.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-// @vitest-environment happy-dom
-
-import { act } from 'react'
-import { createRoot, type Root } from 'react-dom/client'
-import { afterEach, beforeEach, describe, expect, it } from 'vitest'
-import { MatchedText } from './ProjectComboboxRow'
-import { rankProjectOptions } from './project-combobox-matching'
-import type { NewWorkspaceProjectOption } from '@/lib/new-workspace-project-options'
-
-let container: HTMLDivElement
-let root: Root
-
-beforeEach(() => {
- container = document.createElement('div')
- document.body.appendChild(container)
- root = createRoot(container)
-})
-
-afterEach(() => {
- act(() => {
- root.unmount()
- })
- container.remove()
-})
-
-function markedText(): string {
- return Array.from(container.querySelectorAll('mark'))
- .map((mark) => mark.textContent ?? '')
- .join('')
-}
-
-describe('MatchedText', () => {
- // UTF-16 hit offsets and code-point rendering differ for emoji; marks must stay on the matched glyphs.
- it('aligns marks with the query when the name starts with an emoji', () => {
- const option: NewWorkspaceProjectOption = {
- kind: 'project',
- id: 'p1',
- projectId: 'p1',
- displayName: '🚀 orca',
- badgeColor: '#111111',
- detail: '~/dev/orca'
- }
- const [match] = rankProjectOptions([option], 'orca', [])
- expect(match).toBeDefined()
-
- act(() => {
- root.render()
- })
-
- expect(markedText()).toBe('orca')
- })
-})
diff --git a/src/renderer/src/components/new-workspace/ProjectComboboxRow.tsx b/src/renderer/src/components/new-workspace/ProjectComboboxRow.tsx
index 9cf579f7669..07f084687f7 100644
--- a/src/renderer/src/components/new-workspace/ProjectComboboxRow.tsx
+++ b/src/renderer/src/components/new-workspace/ProjectComboboxRow.tsx
@@ -2,7 +2,7 @@ import React from 'react'
import { FolderOpen } from 'lucide-react'
import { RepoBadgeMark } from '@/components/repo/RepoBadgeLabel'
import { cn } from '@/lib/utils'
-import type { NewWorkspaceProjectOption } from '@/lib/new-workspace-project-options'
+import type { NewWorkspaceProjectOption } from '@/lib/workspace/creation/new-workspace-project-options'
import { splitPathHeadForElision } from '@/lib/path-head-elision'
/** Identity mark shared by the field and every row, so a project reads the same in both. */
diff --git a/src/renderer/src/components/new-workspace/RunTargetCombobox.fixture.tsx b/src/renderer/src/components/new-workspace/RunTargetCombobox.fixture.tsx
index 9dc75e7c7d9..84fd7478975 100644
--- a/src/renderer/src/components/new-workspace/RunTargetCombobox.fixture.tsx
+++ b/src/renderer/src/components/new-workspace/RunTargetCombobox.fixture.tsx
@@ -1,5 +1,5 @@
import { defineFixture } from '../../component-fixtures/component-fixture'
-import type { ProjectHostSetupOption } from '@/lib/project-host-setup-options'
+import type { ProjectHostSetupOption } from '@/lib/workspace/creation/project-host-setup-options'
import RunTargetCombobox from './RunTargetCombobox'
// Shape produced by buildProjectHostSetupOptions with local + ephemeral VM setups and SSH hosts:
diff --git a/src/renderer/src/components/new-workspace/RunTargetCombobox.tsx b/src/renderer/src/components/new-workspace/RunTargetCombobox.tsx
index a655c4c9e1f..3703c5253dc 100644
--- a/src/renderer/src/components/new-workspace/RunTargetCombobox.tsx
+++ b/src/renderer/src/components/new-workspace/RunTargetCombobox.tsx
@@ -7,7 +7,7 @@ import {
type NeedsSetupProjectHostOption,
type ProjectHostSetupOption,
type ReadyProjectHostSetupOption
-} from '@/lib/project-host-setup-options'
+} from '@/lib/workspace/creation/project-host-setup-options'
import type { ExecutionHostId } from '../../../../shared/execution-host'
import { isWithinComboboxRoot, useTypeAheadCombobox } from './use-type-ahead-combobox'
import { COMBOBOX_POPOVER_SURFACE } from './type-ahead-combobox-styles'
diff --git a/src/renderer/src/components/new-workspace/RunTargetRowList.tsx b/src/renderer/src/components/new-workspace/RunTargetRowList.tsx
index 355fd0439cc..b2b7d7d4195 100644
--- a/src/renderer/src/components/new-workspace/RunTargetRowList.tsx
+++ b/src/renderer/src/components/new-workspace/RunTargetRowList.tsx
@@ -2,7 +2,7 @@ import React from 'react'
import type {
NeedsSetupProjectHostOption,
ReadyProjectHostSetupOption
-} from '@/lib/project-host-setup-options'
+} from '@/lib/workspace/creation/project-host-setup-options'
import { HostRowIcon, RunTargetRow } from './RunTargetComboboxRow'
import { ConnectHostButton, NeedsSetupHostIcon, SetLocationButton } from './RunTargetRowActions'
import { RecipesSubmenuRow } from './RunTargetSubmenus'
diff --git a/src/renderer/src/components/new-workspace/SetProjectLocationDialog.test.tsx b/src/renderer/src/components/new-workspace/SetProjectLocationDialog.test.tsx
index e9b7564e596..b0f0c919da5 100644
--- a/src/renderer/src/components/new-workspace/SetProjectLocationDialog.test.tsx
+++ b/src/renderer/src/components/new-workspace/SetProjectLocationDialog.test.tsx
@@ -1,10 +1,10 @@
// @vitest-environment happy-dom
-import { act, cleanup, render, screen } from '@testing-library/react'
+import { cleanup, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
-import { StrictMode, type ComponentProps } from 'react'
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import type { NeedsSetupProjectHostOption } from '@/lib/project-host-setup-options'
+import type { ComponentProps } from 'react'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import type { NeedsSetupProjectHostOption } from '@/lib/workspace/creation/project-host-setup-options'
const storeMocks = vi.hoisted(() => ({
setupProjectExistingFolder: vi.fn(),
@@ -68,17 +68,6 @@ function renderDialog(
return user
}
-beforeEach(() => {
- storeMocks.setupProjectExistingFolder.mockReset()
- storeMocks.setupProjectClone.mockReset()
- storeMocks.setupProjectExistingFolder.mockResolvedValue({
- setup: { id: 'setup-openclaw' }
- })
- storeMocks.setupProjectClone.mockResolvedValue({
- setup: { id: 'setup-openclaw-clone' }
- })
-})
-
afterEach(() => {
cleanup()
})
@@ -101,70 +90,4 @@ describe('SetProjectLocationDialog', () => {
await user.keyboard('{Escape}')
expect(onClose).toHaveBeenCalled()
})
-
- it('does not retarget the composer when a slow clone lands after dismissal', async () => {
- // An SSH clone is unbounded and the dialog stays dismissable while it runs.
- let finishClone: (result: { setup: { id: string } }) => void = () => {}
- storeMocks.setupProjectClone.mockReturnValue(
- new Promise((resolve) => {
- finishClone = resolve
- })
- )
- const onReady = vi.fn()
- const onClose = vi.fn()
- const { rerender } = render(
-
- )
- const user = userEvent.setup()
-
- await user.click(screen.getByRole('button', { name: /Clone from URL/ }))
- await user.type(screen.getByPlaceholderText('/destination/on/host'), '/remote/orca')
- await user.click(screen.getByRole('button', { name: 'Clone' }))
-
- rerender(
-
- )
- await act(async () => {
- finishClone({ setup: { id: 'setup-openclaw-clone' } })
- })
-
- expect(onReady).not.toHaveBeenCalled()
- })
-
- it('still reports success under StrictMode double-invoked effects', async () => {
- const onReady = vi.fn()
- render(
-
-
-
- )
- const user = userEvent.setup()
-
- await user.click(screen.getByRole('button', { name: /Browse folder/ }))
- await user.type(screen.getByPlaceholderText('/path/to/project/on/host'), '/remote/orca')
- await user.click(screen.getByRole('button', { name: 'Set location' }))
-
- expect(onReady).toHaveBeenCalledWith(JSON.stringify(['setup-openclaw', 'ssh:openclaw']))
- })
})
diff --git a/src/renderer/src/components/new-workspace/SetProjectLocationDialog.tsx b/src/renderer/src/components/new-workspace/SetProjectLocationDialog.tsx
index 1fc7424bee0..34567bbe71a 100644
--- a/src/renderer/src/components/new-workspace/SetProjectLocationDialog.tsx
+++ b/src/renderer/src/components/new-workspace/SetProjectLocationDialog.tsx
@@ -15,7 +15,7 @@ import { CreateProjectParentBrowser } from '@/components/sidebar/project-admissi
import {
getProjectHostSetupSelectionKey,
type NeedsSetupProjectHostOption
-} from '@/lib/project-host-setup-options'
+} from '@/lib/workspace/creation/project-host-setup-options'
import { parseExecutionHostId } from '../../../../shared/execution-host'
import type { RepoKind } from '../../../../shared/repo-types'
import { pickLocalProjectLocationFolder } from './pick-local-project-folder'
diff --git a/src/renderer/src/components/new-workspace/composer-modal-data.ts b/src/renderer/src/components/new-workspace/composer-modal-data.ts
index 482ac94c762..f81fdbf4d6b 100644
--- a/src/renderer/src/components/new-workspace/composer-modal-data.ts
+++ b/src/renderer/src/components/new-workspace/composer-modal-data.ts
@@ -4,13 +4,13 @@ import type {
} from '../../../../shared/agent-launch/picker/agent-launch-picker'
import type { AgentLaunchSurface } from '@/lib/agent-session/launch/routing/agent-session-launch-plan'
import type { DirectWorkItemSetupRequest } from '@/lib/workspace/creation/work-item/direct-work-item-setup'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import type { GitHubWorkItem } from '../../../../shared/github/work-item-types'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
import type { WorkspaceSource as WorkspaceCreateTelemetrySource } from '../../../../shared/workspace-source'
import type { WorkspaceStatus } from '../../../../shared/worktree/types'
import type { TaskSourceContext } from '../../../../shared/work-items/task-source-context'
-import type { WorkspaceCreationTargetHint } from '@/lib/project-host-workspace-target'
+import type { WorkspaceCreationTargetHint } from '@/lib/workspace/creation/project-host-workspace-target'
export type ComposerModalData = {
recovery?: {
diff --git a/src/renderer/src/components/new-workspace/new-workspace-composer-card-props.ts b/src/renderer/src/components/new-workspace/new-workspace-composer-card-props.ts
index e0224f81fa8..303035685fd 100644
--- a/src/renderer/src/components/new-workspace/new-workspace-composer-card-props.ts
+++ b/src/renderer/src/components/new-workspace/new-workspace-composer-card-props.ts
@@ -5,13 +5,13 @@ import type {
import type { AgentComboboxSurfaceRows } from '@/components/agent/agent-combobox-surface-items'
import type { ComposerAgentRows } from '@/hooks/composer-state/composer-agent-rows-target'
import type RepoCombobox from '@/components/repo/RepoCombobox'
-import type { NewWorkspaceProjectOption } from '@/lib/new-workspace-project-options'
+import type { NewWorkspaceProjectOption } from '@/lib/workspace/creation/new-workspace-project-options'
import type {
NeedsSetupProjectHostOption,
ProjectHostSetupOption
-} from '@/lib/project-host-setup-options'
+} from '@/lib/workspace/creation/project-host-setup-options'
import type { SetupConfig } from '../../../../shared/orca-hook-setup-config'
-import type { WorkspaceCreateErrorDisplay } from '@/lib/workspace-create-error-format'
+import type { WorkspaceCreateErrorDisplay } from '@/lib/workspace/creation/workspace-create-error-format'
import type { SmartNameMode } from '../../../../shared/new-workspace/smart-workspace-source-results'
import type SmartWorkspaceNameField from './SmartWorkspaceNameField'
import type { SmartWorkspaceNameSelection } from '@/components/new-workspace/smart-workspace-name-field-model'
diff --git a/src/renderer/src/components/new-workspace/project-combobox-matching.ts b/src/renderer/src/components/new-workspace/project-combobox-matching.ts
index 4d50f15f0fb..5fe4974610f 100644
--- a/src/renderer/src/components/new-workspace/project-combobox-matching.ts
+++ b/src/renderer/src/components/new-workspace/project-combobox-matching.ts
@@ -1,5 +1,5 @@
-import type { NewWorkspaceProjectOption } from '@/lib/new-workspace-project-options'
-import { isNewWorkspaceProjectOptionQueryTooLarge } from '@/lib/new-workspace-project-options'
+import type { NewWorkspaceProjectOption } from '@/lib/workspace/creation/new-workspace-project-options'
+import { isNewWorkspaceProjectOptionQueryTooLarge } from '@/lib/workspace/creation/new-workspace-project-options'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
diff --git a/src/renderer/src/components/new-workspace/run-target-options.ts b/src/renderer/src/components/new-workspace/run-target-options.ts
index 47a65e5f79d..620b0da9f32 100644
--- a/src/renderer/src/components/new-workspace/run-target-options.ts
+++ b/src/renderer/src/components/new-workspace/run-target-options.ts
@@ -4,7 +4,7 @@ import {
type NeedsSetupProjectHostOption,
type ProjectHostSetupOption,
type ReadyProjectHostSetupOption
-} from '@/lib/project-host-setup-options'
+} from '@/lib/workspace/creation/project-host-setup-options'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import { boundHostList } from '@/components/host-picker/bounded-host-list'
diff --git a/src/renderer/src/components/new-workspace/use-recent-project-ids.ts b/src/renderer/src/components/new-workspace/use-recent-project-ids.ts
index fd282fe17c9..b444193e79a 100644
--- a/src/renderer/src/components/new-workspace/use-recent-project-ids.ts
+++ b/src/renderer/src/components/new-workspace/use-recent-project-ids.ts
@@ -1,7 +1,7 @@
import { useMemo } from 'react'
import type { Worktree } from '../../../../shared/worktree/types'
import { useAllWorktrees } from '@/store/slices/worktrees/listing/use-worktree-catalog'
-import { NEW_WORKSPACE_PROJECT_GROUP_OPTION_PREFIX } from '@/lib/new-workspace-project-options'
+import { NEW_WORKSPACE_PROJECT_GROUP_OPTION_PREFIX } from '@/lib/workspace/creation/new-workspace-project-options'
/** Use each project’s newest workspace creation as recency; it matches this picker’s action without separate persisted state. */
export function orderProjectIdsByRecency(worktrees: readonly Worktree[]): string[] {
diff --git a/src/renderer/src/lib/onboarding-folder-agent-launch.ts b/src/renderer/src/components/onboarding/onboarding-folder-agent-launch.ts
similarity index 91%
rename from src/renderer/src/lib/onboarding-folder-agent-launch.ts
rename to src/renderer/src/components/onboarding/onboarding-folder-agent-launch.ts
index d3a58472c16..de29bc59a32 100644
--- a/src/renderer/src/lib/onboarding-folder-agent-launch.ts
+++ b/src/renderer/src/components/onboarding/onboarding-folder-agent-launch.ts
@@ -1,13 +1,13 @@
import { ensureAgentLaunchPreferences } from '@/runtime/agent-launch-settings/use-host-agent-launch-preferences'
import type { AgentLaunchPreferences } from '@/runtime/agent-launch-settings/host-agent-launch-preferences-resource'
-import type { ExecutionHostId } from '../../../shared/execution-host'
-import type { OnboardingState } from '../../../shared/onboarding-state-types'
-import type { TuiAgent } from '../../../shared/agent-launch/catalog/tui-agent'
-import type { useAppStore } from '@/store'
+import type { ExecutionHostId } from '../../../../shared/execution-host'
+import type { OnboardingState } from '../../../../shared/onboarding-state-types'
+import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
+import type { useAppStore } from '@/store/index'
import {
notifyAgentLaunchFailure,
agentLaunchRecoveryMessage
-} from './agent-session/launch/failure/agent-launch-failure'
+} from '../../lib/agent-session/launch/failure/agent-launch-failure'
import { resolveAgentLaunchExecutionContext } from '@/lib/agent-session/launch/new-tab/launch-agent-execution-context'
import {
planAgentSessionLaunch,
@@ -19,7 +19,7 @@ import {
onboardingFolderDefaultAgent,
shouldSeedFolderAgentAfterDismissedOnboarding,
type OnboardingFolderAgentStartup
-} from '@/lib/onboarding-folder-agent-startup'
+} from '@/components/onboarding/onboarding-folder-agent-startup'
import { activateAndRevealWorktree } from '@/lib/workspace/activation/worktree-activation'
import { beginStructuredAgentSessionProvisionalLaunch } from '@/lib/agent-session/structured-agent-session-provisional-tab'
diff --git a/src/renderer/src/lib/onboarding-folder-agent-startup.ts b/src/renderer/src/components/onboarding/onboarding-folder-agent-startup.ts
similarity index 66%
rename from src/renderer/src/lib/onboarding-folder-agent-startup.ts
rename to src/renderer/src/components/onboarding/onboarding-folder-agent-startup.ts
index b2190f61b99..daadfacd053 100644
--- a/src/renderer/src/lib/onboarding-folder-agent-startup.ts
+++ b/src/renderer/src/components/onboarding/onboarding-folder-agent-startup.ts
@@ -1,14 +1,15 @@
-import { buildAgentStartupPlan } from '../../../shared/agent-launch/startup/tui-agent-startup'
-import { tuiAgentToAgentKind } from '@/lib/telemetry'
-import { isTuiAgentEnabled } from '../../../shared/agent-launch/catalog/tui-agent-selection'
-import { resolveAgentStartupPlanInputs } from '../../../shared/agent-launch/startup/agent-startup-plan-inputs'
+import { buildAgentStartupPlan } from '../../../../shared/agent-launch/startup/tui-agent-startup'
+import '@/lib/telemetry'
+import { tuiAgentToAgentKind } from '../../../../shared/agent-kind'
+import { isTuiAgentEnabled } from '../../../../shared/agent-launch/catalog/tui-agent-selection'
+import { resolveAgentStartupPlanInputs } from '../../../../shared/agent-launch/startup/agent-startup-plan-inputs'
import type { AgentStartedTelemetry } from '@/lib/workspace/creation/worktree-startup-payload'
-import type { StartupCommandDelivery } from '../../../shared/agent-launch/startup/codex-startup-delivery'
-import type { SleepingAgentLaunchConfig } from '../../../shared/agent-session/lifecycle/agent-session-resume'
-import type { GlobalSettings } from '../../../shared/global-settings-types'
-import type { OnboardingState } from '../../../shared/onboarding-state-types'
-import type { AgentStartupShell } from '../../../shared/agent-launch/startup/tui-agent-startup-shell'
-import type { TuiAgent } from '../../../shared/agent-launch/catalog/tui-agent'
+import type { StartupCommandDelivery } from '../../../../shared/agent-launch/startup/codex-startup-delivery'
+import type { SleepingAgentLaunchConfig } from '../../../../shared/agent-session/lifecycle/agent-session-resume'
+import type { GlobalSettings } from '../../../../shared/global-settings-types'
+import type { OnboardingState } from '../../../../shared/onboarding-state-types'
+import type { AgentStartupShell } from '../../../../shared/agent-launch/startup/tui-agent-startup-shell'
+import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
export type OnboardingFolderAgentStartup = {
command: string
diff --git a/src/renderer/src/lib/onboarding-project-checklist.ts b/src/renderer/src/components/onboarding/onboarding-project-checklist.ts
similarity index 91%
rename from src/renderer/src/lib/onboarding-project-checklist.ts
rename to src/renderer/src/components/onboarding/onboarding-project-checklist.ts
index 07cbfa72acc..db7ee5bf2f7 100644
--- a/src/renderer/src/lib/onboarding-project-checklist.ts
+++ b/src/renderer/src/components/onboarding/onboarding-project-checklist.ts
@@ -1,5 +1,5 @@
import { track } from '@/lib/telemetry'
-import type { OnboardingState } from '../../../shared/onboarding-state-types'
+import type { OnboardingState } from '../../../../shared/onboarding-state-types'
export type OnboardingProjectChecklistItem = 'addedRepo' | 'addedFolder'
diff --git a/src/renderer/src/components/onboarding/use-onboarding-agent-surface.ts b/src/renderer/src/components/onboarding/use-onboarding-agent-surface.ts
index a7058d3b74f..d0fd8d00ae7 100644
--- a/src/renderer/src/components/onboarding/use-onboarding-agent-surface.ts
+++ b/src/renderer/src/components/onboarding/use-onboarding-agent-surface.ts
@@ -9,8 +9,11 @@ import {
} from '@/runtime/native-chat/agent-catalogs/chat-provider-agents'
import { recomputeOn } from '@/lib/recompute-on'
import type { ProspectiveWorkspace } from '@/lib/agent-session/launch/routing/agent-launch-route-input'
-import { readChatProgram, resolveChatProgramContext } from '@/lib/host-chat-program'
-import { useChatProgramFacts } from '@/lib/host-chat-program-acquisition'
+import {
+ readChatProgram,
+ resolveChatProgramContext
+} from '@/lib/agent-session/launch/inventory/host-chat-program'
+import { useChatProgramFacts } from '@/lib/agent-session/launch/inventory/host-chat-program-acquisition'
import { relearnHostStructuredAgents } from '@/runtime/native-chat/agent-catalogs/host-structured-agents'
import { useAppStore } from '@/store'
import { readNativeDetectedAgents } from '@/store/slices/agent-inventory/local-detected-agent-store-state'
diff --git a/src/renderer/src/components/onboarding/use-onboarding-flow-actions.test.tsx b/src/renderer/src/components/onboarding/use-onboarding-flow-actions.test.tsx
deleted file mode 100644
index b72da1b96bd..00000000000
--- a/src/renderer/src/components/onboarding/use-onboarding-flow-actions.test.tsx
+++ /dev/null
@@ -1,306 +0,0 @@
-// @vitest-environment happy-dom
-import { act, cleanup, renderHook } from '@testing-library/react'
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import type { GlobalSettings } from '../../../../shared/global-settings-types'
-import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
-import { getDefaultSettings } from '../../../../shared/constants'
-import { useOnboardingFlowActions } from './use-onboarding-flow-actions'
-import { useCloseWith } from './use-onboarding-flow-persistence'
-import { getDefaultOnboardingState } from '../../../../shared/onboarding-defaults'
-import { STEPS } from './use-onboarding-flow-types'
-import type { WorkspaceActivationOutcome } from '@/lib/workspace/activation/worktree-activation-outcome'
-
-const {
- track,
- launch,
- reveal,
- state,
- toastError,
- focusIntent,
- detect,
- acquireChoices,
- preferences
-} = vi.hoisted(() => {
- const state: { activeWorkspaceExecutionHostId: string; settings: GlobalSettings | null } = {
- activeWorkspaceExecutionHostId: 'runtime:chosen',
- settings: null
- }
- return {
- track: vi.fn(),
- launch: vi.fn(),
- reveal: vi.fn<(...args: unknown[]) => WorkspaceActivationOutcome>(() => ({
- opened: { primaryTabId: null }
- })),
- state,
- detect: vi.fn(),
- acquireChoices: vi.fn(),
- preferences: vi.fn(),
- toastError: vi.fn(),
- focusIntent: { cancel: vi.fn() }
- }
-})
-vi.mock('sonner', () => ({ toast: { error: toastError } }))
-vi.mock('@/store', () => ({ useAppStore: { getState: () => state } }))
-vi.mock('@/lib/workspace/ownership/worktree-runtime-owner', () => ({
- getExecutionHostIdForWorktree: () => state.activeWorkspaceExecutionHostId
-}))
-vi.mock('@/lib/agent-session/launch/new-tab/launch-agent-in-new-tab', () => ({
- launchAgentInNewTabWithOutcome: launch
-}))
-vi.mock('@/lib/workspace/activation/worktree-activation', () => ({
- activateAndRevealWorkspaceWithOutcome: reveal
-}))
-vi.mock('@/components/agent-tab-launch-context', () => ({
- captureAgentTabLaunchContext: () => ({ groupId: 'group', focusIntent })
-}))
-vi.mock('@/lib/telemetry', () => ({ track }))
-vi.mock('@/lib/agent-session/launch/inventory/agent-detection-target-inventory', () => ({
- loadDetectedAgentsForWorktree: detect
-}))
-vi.mock('@/lib/host-chat-program-acquisition', () => ({
- acquireAgentLaunchChoices: acquireChoices
-}))
-vi.mock('@/runtime/agent-launch-settings/use-host-agent-launch-preferences', () => ({
- ensureAgentLaunchPreferences: preferences
-}))
-beforeEach(() => {
- state.settings = getDefaultSettings('/tmp')
- detect.mockResolvedValue(['claude', 'codex'])
- preferences.mockImplementation(async (store) => store.settings)
- acquireChoices.mockImplementation(async (_workspace, load) => ({ detected: await load() }))
-})
-
-afterEach(() => {
- cleanup()
- vi.clearAllMocks()
- state.activeWorkspaceExecutionHostId = 'runtime:chosen'
-})
-
-function renderActions(
- hasSelectedWorkspace: boolean,
- stepIndex = STEPS.length - 1,
- selectedAgent: TuiAgent | null = 'codex',
- options: { surface?: 'chat' | 'terminal'; defaultAgent?: GlobalSettings['defaultTuiAgent'] } = {}
-) {
- const openModal = vi.fn()
- const update = vi.fn().mockResolvedValue({
- ...getDefaultOnboardingState(),
- outcome: 'completed',
- closedAt: 1
- })
- Object.defineProperty(window, 'api', {
- configurable: true,
- value: {
- onboarding: { update },
- starNag: { onboardingCompleted: vi.fn() }
- }
- })
- const onOnboardingChange = vi.fn()
- const persistCurrentStep = vi.fn().mockResolvedValue({ ok: true })
- state.settings = {
- ...getDefaultSettings('/tmp'),
- defaultTuiAgent: options.defaultAgent ?? null
- }
- const updateSettings = vi.fn(async (updates: Partial) => {
- state.settings = { ...state.settings!, ...updates }
- })
- const { result } = renderHook(() => {
- const closeWith = useCloseWith({
- onOnboardingChange,
- startTimeRef: { current: 1 },
- setError: vi.fn()
- })
- return useOnboardingFlowActions({
- busyLabel: null,
- setBusyLabel: vi.fn(),
- setError: vi.fn(),
- currentStep: STEPS[stepIndex],
- consumeStepDurationMs: () => 10,
- trackTaskSourcesSnapshot: vi.fn(),
- settings: state.settings,
- persistCurrentStep,
- selectedWorkspaceId: hasSelectedWorkspace ? 'folder:home' : null,
- closeWith,
- openModal,
- getNextStepIndex: (index) => index + 1,
- onOnboardingChange,
- stepIndex,
- setStepIndex: vi.fn(),
- selectedAgent,
- agentSurface: options.surface ?? 'terminal',
- themeLookBaseline: null,
- setTheme: vi.fn(),
- updateSettings,
- skipOptions: { skipIntegrations: true, skipWindowsTerminal: true }
- })
- })
- return { result, openModal, update, persistCurrentStep, onOnboardingChange, updateSettings }
-}
-
-describe('onboarding completion destination', () => {
- it('reports a captured workspace disappearing while completion is saved, without opening a surface', async () => {
- const { result, persistCurrentStep } = renderActions(true, STEPS.length - 1, 'claude')
- const saved = Promise.withResolvers<{ ok: boolean }>()
- persistCurrentStep.mockReturnValueOnce(saved.promise)
- let finishing: Promise
- act(() => {
- finishing = result.current.next()
- })
- expect(launch).not.toHaveBeenCalled()
- reveal.mockReturnValueOnce({ refused: { reason: 'workspace-missing', failureNotified: false } })
- await act(async () => {
- saved.resolve({ ok: true })
- await finishing
- })
- const createSurface = vi.fn()
- if (launch.mock.calls[0][0].beforeSurfaceOpen()) {
- createSurface()
- }
- expect(createSurface).not.toHaveBeenCalled()
- expect(toastError).toHaveBeenCalledOnce()
- })
-
- it('keeps onboarding open for retry when setting up later cannot save completion', async () => {
- const { result, update, onOnboardingChange, openModal } = renderActions(
- true,
- STEPS.findIndex((step) => step.id === 'agent')
- )
- update.mockRejectedValueOnce(new Error('save failed'))
- await act(() => result.current.setUpLater())
- expect(onOnboardingChange).not.toHaveBeenCalled()
- expect(openModal).not.toHaveBeenCalled()
- expect(launch).not.toHaveBeenCalled()
- await act(() => result.current.setUpLater())
- expect(openModal).not.toHaveBeenCalled()
- expect(launch).toHaveBeenCalledWith(expect.objectContaining({ agent: 'codex' }))
- })
-
- it('does not leave onboarding when the skipped agent preference cannot be saved', async () => {
- const { result, updateSettings, update, onOnboardingChange, openModal } = renderActions(
- true,
- STEPS.findIndex((step) => step.id === 'agent')
- )
- updateSettings.mockRejectedValueOnce(new Error('settings save failed'))
- await act(() => result.current.setUpLater())
- expect(update).not.toHaveBeenCalled()
- expect(onOnboardingChange).not.toHaveBeenCalled()
- expect(openModal).not.toHaveBeenCalled()
- expect(launch).not.toHaveBeenCalled()
- await act(() => result.current.setUpLater())
- expect(launch).toHaveBeenCalledWith(expect.objectContaining({ agent: 'codex' }))
- })
-
- it('keeps onboarding open when completion cannot be saved', async () => {
- const { result, openModal, update, onOnboardingChange } = renderActions(true)
- update.mockRejectedValueOnce(new Error('save failed'))
- await act(() => result.current.next())
- expect(openModal).not.toHaveBeenCalled()
- expect(onOnboardingChange).not.toHaveBeenCalled()
- expect(launch).not.toHaveBeenCalled()
- expect(track).not.toHaveBeenCalledWith('onboarding_completed', expect.anything())
- await act(() => result.current.next())
- expect(launch).toHaveBeenCalledWith(expect.objectContaining({ agent: 'codex' }))
- })
- it('keeps the captured target and owner through saving, dispatching once after unmount', async () => {
- const { result, persistCurrentStep } = renderActions(true)
- const saved = Promise.withResolvers<{ ok: boolean }>()
- persistCurrentStep.mockReturnValueOnce(saved.promise)
- let finishing: Promise
- act(() => {
- finishing = result.current.next()
- })
- await act(() => result.current.next())
- state.activeWorkspaceExecutionHostId = 'runtime:other'
- cleanup()
- await act(async () => {
- saved.resolve({ ok: true })
- await finishing
- })
- expect(launch).toHaveBeenCalledExactlyOnceWith(
- expect.objectContaining({
- worktreeId: 'folder:home',
- workspaceExecutionHostId: 'runtime:chosen'
- })
- )
- })
-
- it('retains the clicked workspace owner through deferred save and post-close discovery', async () => {
- const { result, updateSettings, onOnboardingChange } = renderActions(true, 0, 'claude', {
- surface: 'chat',
- defaultAgent: 'codex'
- })
- const saved = Promise.withResolvers()
- const detected = Promise.withResolvers()
- updateSettings.mockImplementationOnce(async (updates) => {
- await saved.promise
- state.settings = { ...state.settings!, ...updates }
- })
- detect.mockReturnValueOnce(detected.promise)
- const owners: string[] = []
- acquireChoices.mockImplementationOnce(
- async (_workspace, load, _signal, _deadline, getState) => {
- owners.push(getState().activeWorkspaceExecutionHostId)
- const ids = await load()
- owners.push(getState().activeWorkspaceExecutionHostId)
- return { detected: ids }
- }
- )
- let finishing: Promise
- act(() => {
- finishing = result.current.setUpLater()
- })
- await act(() => result.current.next())
- await act(() => result.current.setUpLater())
- state.activeWorkspaceExecutionHostId = 'runtime:other'
- await act(async () => {
- saved.resolve()
- await saved.promise
- })
- expect(onOnboardingChange).toHaveBeenCalled()
- expect(launch).not.toHaveBeenCalled()
- cleanup()
- await act(async () => {
- detected.resolve(['codex'])
- await finishing
- })
- expect(owners).toEqual(['runtime:chosen', 'runtime:chosen'])
- expect(preferences).toHaveBeenCalledWith(
- expect.objectContaining({ activeWorkspaceExecutionHostId: 'runtime:chosen' }),
- expect.anything()
- )
- expect(launch).toHaveBeenCalledExactlyOnceWith(
- expect.objectContaining({
- agent: 'codex',
- worktreeId: 'folder:home',
- workspaceExecutionHostId: 'runtime:chosen'
- })
- )
- })
-
- it('settles a failed default lookup after closing without launching or reporting twice', async () => {
- const { result, onOnboardingChange } = renderActions(true, 0, 'claude')
- detect.mockRejectedValueOnce(new Error('owner retired'))
- await act(() => result.current.setUpLater())
- expect(onOnboardingChange).toHaveBeenCalledWith(
- expect.objectContaining({ outcome: 'completed' })
- )
- expect(launch).not.toHaveBeenCalled()
- expect(toastError).not.toHaveBeenCalled()
- })
-
- it('does not launch for an unselected agent, dismissal or failed step persistence', async () => {
- const blank = renderActions(true, STEPS.length - 1, null)
- await act(() => blank.result.current.next())
- expect(launch).not.toHaveBeenCalled()
- cleanup()
- const dismissed = renderActions(true)
- await act(() => dismissed.result.current.dismissOnboarding())
- expect(launch).not.toHaveBeenCalled()
- cleanup()
- const failed = renderActions(true)
- failed.persistCurrentStep.mockResolvedValueOnce({ ok: false })
- await act(() => failed.result.current.next())
- expect(failed.update).not.toHaveBeenCalled()
- expect(launch).not.toHaveBeenCalled()
- })
-})
diff --git a/src/renderer/src/components/pull-request-page/checks/tab.tsx b/src/renderer/src/components/pull-request-page/checks/tab.tsx
index 6b87113606e..b87c3675e4d 100644
--- a/src/renderer/src/components/pull-request-page/checks/tab.tsx
+++ b/src/renderer/src/components/pull-request-page/checks/tab.tsx
@@ -27,7 +27,7 @@ import {
getGitHubSourceRuntimeHost
} from '@/lib/work-items/github/github-source-runtime-context'
import { getLocalRepoProjectExecutionRuntimeContext } from '@/lib/local-preflight-context'
-import { CLIENT_PLATFORM } from '@/lib/new-workspace'
+import { CLIENT_PLATFORM } from '@/lib/workspace/creation/new-workspace'
import { resolveRepoExecutionHostPlatform } from '@/runtime/hosts/platform/execution-host-facts'
import { resolveSourceControlActionRecipe } from '../../../../../shared/source-control/ai/source-control-ai-operation-policy'
import type {
diff --git a/src/renderer/src/components/right-sidebar/ai-vault/session-actions/use-ai-vault-panel-session-resume.ts b/src/renderer/src/components/right-sidebar/ai-vault/session-actions/use-ai-vault-panel-session-resume.ts
index eff01a998ea..455792578ae 100644
--- a/src/renderer/src/components/right-sidebar/ai-vault/session-actions/use-ai-vault-panel-session-resume.ts
+++ b/src/renderer/src/components/right-sidebar/ai-vault/session-actions/use-ai-vault-panel-session-resume.ts
@@ -4,7 +4,7 @@ import type { Repo } from '../../../../../../shared/repo-types'
import type { Worktree } from '../../../../../../shared/worktree/types'
import { useAppStore } from '@/store/index'
import { selectAgentLaunchRouteView } from '@/lib/agent-session/launch/routing/agent-launch-route-input'
-import { useChatProgramFactsVersion } from '@/lib/host-chat-program-acquisition'
+import { useChatProgramFactsVersion } from '@/lib/agent-session/launch/inventory/host-chat-program-acquisition'
import { recomputeOn } from '@/lib/recompute-on'
import {
resolveAiVaultHistorySessionResumeState,
diff --git a/src/renderer/src/components/right-sidebar/folder-workspace-repo-worktree-create.ts b/src/renderer/src/components/right-sidebar/folder-workspace-repo-worktree-create.ts
index c73bfbaea85..ca9ded39707 100644
--- a/src/renderer/src/components/right-sidebar/folder-workspace-repo-worktree-create.ts
+++ b/src/renderer/src/components/right-sidebar/folder-workspace-repo-worktree-create.ts
@@ -1,7 +1,7 @@
import { toast } from 'sonner'
import { translate } from '@/i18n/i18n'
import { readIpcErrorDetail } from '@/lib/ipc-error'
-import { getRepoWorkspaceCreationTargetHint } from '@/lib/project-host-workspace-target'
+import { getRepoWorkspaceCreationTargetHint } from '@/lib/workspace/creation/project-host-workspace-target'
import { runtimeTargetSupportsCapability } from '@/runtime/rpc/compatibility/runtime-target-capability'
import { runtimeRpcTargetForAuthorityKey } from '@/runtime/rpc/targets/runtime-client-target'
import { useAppStore } from '@/store'
diff --git a/src/renderer/src/components/right-sidebar/source-control/ai/recovery-launch.ts b/src/renderer/src/components/right-sidebar/source-control/ai/recovery-launch.ts
index 1fbb3965fc6..f5521649691 100644
--- a/src/renderer/src/components/right-sidebar/source-control/ai/recovery-launch.ts
+++ b/src/renderer/src/components/right-sidebar/source-control/ai/recovery-launch.ts
@@ -8,7 +8,7 @@ import { ensureAgentLaunchPreferences } from '@/runtime/agent-launch-settings/us
import {
AgentLaunchChoiceCancelled,
acquireAgentLaunchChoices
-} from '@/lib/host-chat-program-acquisition'
+} from '@/lib/agent-session/launch/inventory/host-chat-program-acquisition'
import { toast } from 'sonner'
import { useAppStore } from '@/store'
import type { AppState } from '@/store/types'
@@ -35,7 +35,7 @@ import {
import type { SourceControlLaunchActionId } from '../../../../../../shared/source-control/ai/recipes/source-control-ai-actions'
import { buildSourceControlRecoveryAgentCommandInput } from '../../../../../../shared/source-control/recovery/source-control-recovery-agent-command'
import { translate } from '@/i18n/i18n'
-import { agentChoiceMayOpenAsChat } from '@/lib/host-chat-program'
+import { agentChoiceMayOpenAsChat } from '@/lib/agent-session/launch/inventory/host-chat-program'
import { worktreeLaunchWorkspace } from '@/lib/agent-session/launch/routing/agent-launch-route-input'
type SourceControlAiLaunchStoreSnapshot = Pick & WorktreeAgentInventoryState
diff --git a/src/renderer/src/components/right-sidebar/source-control/ai/use-saved-source-control-action-start.test.tsx b/src/renderer/src/components/right-sidebar/source-control/ai/use-saved-source-control-action-start.test.tsx
deleted file mode 100644
index ea8fd2fce47..00000000000
--- a/src/renderer/src/components/right-sidebar/source-control/ai/use-saved-source-control-action-start.test.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-// @vitest-environment happy-dom
-import { act, cleanup, renderHook } from '@testing-library/react'
-import { afterEach, expect, it, vi } from 'vitest'
-import { useAppStore } from '@/store'
-import { getDefaultSettings } from '../../../../../../shared/constants'
-import { canonicalSourceControlActionSelection } from '../../../../../../shared/source-control/ai/recipes/source-control-action-selection'
-import { makeWorktree } from '@/store/slices/worktrees/worktree.test-fixture'
-import { TEST_REPO } from '@/store/repos/repo.test-fixture'
-import { useSavedSourceControlActionStart } from './use-saved-source-control-action-start'
-
-const { launch } = vi.hoisted(() => ({ launch: vi.fn() }))
-vi.mock('@/lib/agent-session/launch/new-tab/launch-agent-in-new-tab', () => ({
- launchAgentInNewTab: launch
-}))
-vi.mock('@/lib/focus-terminal-tab-surface', () => ({ focusTerminalTabSurface: vi.fn() }))
-vi.mock('@/lib/host-chat-program-acquisition', () => ({
- AgentLaunchChoiceCancelled: class extends Error {},
- acquireAgentLaunchChoices: async () => ({ detected: ['claude'] })
-}))
-vi.mock('@/runtime/agent-launch-settings/use-host-agent-launch-preferences', () => ({
- ensureAgentLaunchPreferences: async () => undefined
-}))
-const initial = useAppStore.getState()
-afterEach(() => {
- cleanup()
- useAppStore.setState(initial, true)
-})
-
-it('uses the current Claude permission default when a saved action launches after render', async () => {
- const settings = { ...getDefaultSettings('/tmp'), agentPermissionDefault: 'full-access' as const }
- useAppStore.setState({
- settings,
- repos: [TEST_REPO],
- worktreesByRepo: { [TEST_REPO.id]: [makeWorktree({ id: 'child', repoId: TEST_REPO.id })] }
- })
- launch.mockReturnValue({ surface: { kind: 'local-terminal', tabId: 'agent' } })
- const { result } = renderHook(() => {
- const saved = useSavedSourceControlActionStart()
- return () =>
- saved.start({
- selection: canonicalSourceControlActionSelection({
- agentId: 'claude',
- surface: 'terminal',
- agentArgs: '--model opus'
- }),
- basePrompt: 'Fix the failed commit',
- actionId: 'fixCommitFailure',
- repo: TEST_REPO,
- repoId: TEST_REPO.id,
- worktreeId: 'child',
- connectionId: null,
- promptDelivery: 'auto-submit',
- launchPlatform: 'linux',
- launchSource: 'source_control_recovery',
- onClose: () => {},
- onFallback: () => {
- throw new Error('Unexpected fallback')
- }
- })
- })
- useAppStore.setState({ settings: { ...settings, agentPermissionDefault: 'ask' } })
- await act(async () => {
- await result.current()
- })
- expect(launch).toHaveBeenCalledWith(
- expect.objectContaining({ agentArgs: '--permission-mode default --model opus' })
- )
-})
diff --git a/src/renderer/src/components/right-sidebar/source-control/ai/use-saved-source-control-action-start.ts b/src/renderer/src/components/right-sidebar/source-control/ai/use-saved-source-control-action-start.ts
index 12ce5c77466..264cbf7028f 100644
--- a/src/renderer/src/components/right-sidebar/source-control/ai/use-saved-source-control-action-start.ts
+++ b/src/renderer/src/components/right-sidebar/source-control/ai/use-saved-source-control-action-start.ts
@@ -5,8 +5,8 @@ import {
import {
AgentLaunchChoiceCancelled,
acquireAgentLaunchChoices
-} from '@/lib/host-chat-program-acquisition'
-import { agentsOfferedForLaunch } from '@/lib/host-chat-program'
+} from '@/lib/agent-session/launch/inventory/host-chat-program-acquisition'
+import { agentsOfferedForLaunch } from '@/lib/agent-session/launch/inventory/host-chat-program'
import { ensureAgentLaunchPreferences } from '@/runtime/agent-launch-settings/use-host-agent-launch-preferences'
import { buildAgentLaunchRouteInput } from '@/lib/agent-session/launch/routing/agent-launch-route-input'
import { workspaceKindForWorktreeId } from '../../../../../../shared/agent-launch/contracts/workspace-launch-kind'
diff --git a/src/renderer/src/components/right-sidebar/source-control/ai/use-source-control-launchable-agents.ts b/src/renderer/src/components/right-sidebar/source-control/ai/use-source-control-launchable-agents.ts
index c845afccedd..cf6b3d81307 100644
--- a/src/renderer/src/components/right-sidebar/source-control/ai/use-source-control-launchable-agents.ts
+++ b/src/renderer/src/components/right-sidebar/source-control/ai/use-source-control-launchable-agents.ts
@@ -8,8 +8,11 @@ import {
} from '@/lib/agent-session/launch/inventory/agent-detection-target-inventory'
import type { TuiAgent } from '../../../../../../shared/agent-launch/catalog/tui-agent'
import { sourceControlLaunchWorkspace } from './source-control-launch-agent-args-applicability'
-import { acquireAgentLaunchChoices, useChatProgramFacts } from '@/lib/host-chat-program-acquisition'
-import { agentsOfferedForLaunch } from '@/lib/host-chat-program'
+import {
+ acquireAgentLaunchChoices,
+ useChatProgramFacts
+} from '@/lib/agent-session/launch/inventory/host-chat-program-acquisition'
+import { agentsOfferedForLaunch } from '@/lib/agent-session/launch/inventory/host-chat-program'
type LaunchTarget = Parameters[0]
diff --git a/src/renderer/src/components/settings/agents/launch/AgentLaunchSettingsCatalog.tsx b/src/renderer/src/components/settings/agents/launch/AgentLaunchSettingsCatalog.tsx
index 334809388b3..2b47b17351d 100644
--- a/src/renderer/src/components/settings/agents/launch/AgentLaunchSettingsCatalog.tsx
+++ b/src/renderer/src/components/settings/agents/launch/AgentLaunchSettingsCatalog.tsx
@@ -2,7 +2,7 @@ import { useAppStateValue } from '@/store/retained-views/app-state-view'
import { AgentLaunchChoiceEditor } from '@/components/agent/launch-settings/AgentLaunchChoiceEditor'
import { agentChatPermissionModes } from '../../../../../../shared/agent-launch/permissions/agent-chat-permission-support'
import { savedChatPermissionMode } from '../../../../../../shared/agent-launch/permissions/agent-chat-permission-mode'
-import { useChatProgramFacts } from '@/lib/host-chat-program-acquisition'
+import { useChatProgramFacts } from '@/lib/agent-session/launch/inventory/host-chat-program-acquisition'
import { useMemo } from 'react'
import { recomputeOn } from '@/lib/recompute-on'
import { toast } from 'sonner'
@@ -43,7 +43,7 @@ import {
agentChoiceOpensAsChat,
readChatProgram,
resolveChatProgramContext
-} from '@/lib/host-chat-program'
+} from '@/lib/agent-session/launch/inventory/host-chat-program'
import { readNativeDetectedAgents } from '@/store/slices/agent-inventory/local-detected-agent-store-state'
import { useDetectedAgents, type AgentDetectionTarget } from '@/hooks/useDetectedAgents'
import { AgentDefaultSetting } from '@/components/settings/agents/launch/AgentDefaultSetting'
diff --git a/src/renderer/src/components/settings/chat/ChatAgentLaunchSettings.tsx b/src/renderer/src/components/settings/chat/ChatAgentLaunchSettings.tsx
index 328ae92d705..b5d8bd49a51 100644
--- a/src/renderer/src/components/settings/chat/ChatAgentLaunchSettings.tsx
+++ b/src/renderer/src/components/settings/chat/ChatAgentLaunchSettings.tsx
@@ -8,8 +8,11 @@ import {
useHostStructuredAgentsVersion
} from '@/runtime/native-chat/agent-catalogs/chat-provider-agents'
import { recomputeOn } from '@/lib/recompute-on'
-import { readChatProgram, resolveChatProgramContext } from '@/lib/host-chat-program'
-import { useChatProgramFacts } from '@/lib/host-chat-program-acquisition'
+import {
+ readChatProgram,
+ resolveChatProgramContext
+} from '@/lib/agent-session/launch/inventory/host-chat-program'
+import { useChatProgramFacts } from '@/lib/agent-session/launch/inventory/host-chat-program-acquisition'
import { useAppStore } from '@/store/index'
import { readNativeDetectedAgents } from '@/store/slices/agent-inventory/local-detected-agent-store-state'
import { Card, CardContent } from '../../ui/card'
diff --git a/src/renderer/src/components/settings/chat/ChatSettingsSection.navigation.test.tsx b/src/renderer/src/components/settings/chat/ChatSettingsSection.navigation.test.tsx
deleted file mode 100644
index 33c97355d59..00000000000
--- a/src/renderer/src/components/settings/chat/ChatSettingsSection.navigation.test.tsx
+++ /dev/null
@@ -1,133 +0,0 @@
-// @vitest-environment happy-dom
-// @vitest-environment happy-dom
-import { useRef, useState } from 'react'
-import { cleanup, render, screen, waitFor } from '@testing-library/react'
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import { getDefaultSettings } from '../../../../../shared/constants'
-import { buildSettingsNavigationMetadata } from '@/hooks/useSettingsNavigationMetadata'
-import { ChatSettingsSection } from './ChatSettingsSection'
-import { TooltipProvider } from '../../ui/tooltip'
-import { ActiveSettingsSectionProvider } from '../section-layout/SettingsSection'
-import { getChatAppearanceSearchEntries } from '../appearance/chat/chat-appearance-search'
-import { getChatNamingSearchEntry } from './chat-naming-search'
-import { getChatInlineVisualsSearchEntry } from './chat-inline-visuals-search'
-import { useSettingsRepoScrollEffects } from '../navigation/use-settings-repo-scroll-effects'
-import type { SettingsStoreModel } from '../page/use-settings-store-model'
-import type { SettingsInteractionController } from '../page/use-settings-interaction-controller'
-import type { SettingsNavigationModel } from '../navigation/use-settings-navigation-model'
-import type { SettingsTerminalModel } from '../page/use-settings-terminal-model'
-import { useAppStore } from '@/store/index'
-
-vi.mock('@/lib/host-chat-program-acquisition', () => ({ useChatProgramFacts: () => {} }))
-beforeEach(() => {
- useAppStore.setState(useAppStore.getInitialState(), true)
- useAppStore.setState({ ensureNativeDetectedAgents: vi.fn(async () => []) })
-})
-
-afterEach(() => {
- cleanup()
- vi.restoreAllMocks()
-})
-
-function NavigationHarness({
- initialSection,
- targetSection = 'chat-code-text-size'
-}: {
- initialSection: string
- targetSection?: string
-}) {
- const [activeSectionId, setActiveSectionId] = useState(initialSection)
- const settings = getDefaultSettings('/tmp')
- const sections = buildSettingsNavigationMetadata({
- isMac: false,
- isWindows: false,
- isWebClient: false,
- repos: []
- })
- const pendingNavSectionRef = useRef('chat')
- const pendingScrollTargetRef = useRef(targetSection)
- const contentScrollRef = useRef(null)
- const pendingScrollTargetWatchRef = useRef(null)
- const pendingSubsectionScrollFrameRef = useRef(null)
- const repoHooksRequestSeqRef = useRef(0)
- const model: Pick<
- SettingsStoreModel,
- | 'activeSectionId'
- | 'setActiveSectionId'
- | 'pendingNavRequestTick'
- | 'setPendingNavRequestTick'
- | 'repos'
- | 'setRepoHooksMap'
- | 'settingsSearchQuery'
- | 'setSettingsSearchQuery'
- > = {
- activeSectionId,
- setActiveSectionId,
- pendingNavRequestTick: 0,
- setPendingNavRequestTick: vi.fn(),
- repos: [],
- setRepoHooksMap: vi.fn(),
- settingsSearchQuery: '',
- setSettingsSearchQuery: vi.fn()
- }
- const interactions = {
- contentScrollRef,
- pendingNavSectionRef,
- pendingScrollTargetRef,
- pendingScrollTargetWatchRef,
- pendingSubsectionScrollFrameRef,
- repoHooksRequestSeqRef
- }
- const terminal: Pick = { neededRepos: [] }
- useSettingsRepoScrollEffects(
- // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: Supplies every model field read by this hook; no repos need loading.
- model as SettingsStoreModel,
- // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: Supplies every interaction ref read by this hook.
- interactions as SettingsInteractionController,
- // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: This hook only reads the visible navigation sections and IDs.
- {
- visibleNavSections: sections,
- visibleSectionIds: new Set(sections.map((s) => s.id))
- } as SettingsNavigationModel,
- // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: This hook only reads neededRepos; an empty list skips remote loading.
- terminal as SettingsTerminalModel
- )
- return (
-
-
-
- {}}
- searchEntries={[
- ...getChatAppearanceSearchEntries(),
- getChatNamingSearchEntry(),
- getChatInlineVisualsSearchEntry()
- ]}
- showDesktopOnlySettings
- isMounted
- />
-
-
- )
-}
-
-describe('Chat settings deep links', () => {
- it('activates Chat and scrolls to Inline visuals from another settings page', async () => {
- const scrollIntoView = vi.spyOn(HTMLElement.prototype, 'scrollIntoView')
- const { container } = render(
-
- )
- await waitFor(() => {
- expect(screen.getByRole('status', { name: 'Selected settings page' }).textContent).toBe(
- 'chat'
- )
- })
- const visuals = container.querySelector('#chat-inline-visuals')
- expect(visuals?.querySelector('[role="switch"]')).toBe(
- screen.getByRole('switch', { name: 'Toggle inline visuals' })
- )
- await waitFor(() => expect(scrollIntoView.mock.contexts).toContain(visuals))
- })
-})
diff --git a/src/renderer/src/components/settings/chat/ChatSettingsSection.test.tsx b/src/renderer/src/components/settings/chat/ChatSettingsSection.test.tsx
index 07a2539eaa2..cfce100e9eb 100644
--- a/src/renderer/src/components/settings/chat/ChatSettingsSection.test.tsx
+++ b/src/renderer/src/components/settings/chat/ChatSettingsSection.test.tsx
@@ -18,7 +18,9 @@ import { i18n } from '@/i18n/i18n'
import { useAppStore } from '@/store/index'
import { getChatLaunchSearchEntries } from './chat-launch-search'
-vi.mock('@/lib/host-chat-program-acquisition', () => ({ useChatProgramFacts: () => {} }))
+vi.mock('@/lib/agent-session/launch/inventory/host-chat-program-acquisition', () => ({
+ useChatProgramFacts: () => {}
+}))
afterEach(async () => {
cleanup()
diff --git a/src/renderer/src/components/settings/repository/hosts/repository-host-setup-options.ts b/src/renderer/src/components/settings/repository/hosts/repository-host-setup-options.ts
index 86f138791cb..55c3b8a2721 100644
--- a/src/renderer/src/components/settings/repository/hosts/repository-host-setup-options.ts
+++ b/src/renderer/src/components/settings/repository/hosts/repository-host-setup-options.ts
@@ -9,7 +9,7 @@ import type {
} from '../../../../../../shared/project-types'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
-import { getHostSetupUnavailableDetail } from '@/lib/project-host-setup-options'
+import { getHostSetupUnavailableDetail } from '@/lib/workspace/creation/project-host-setup-options'
import { pickerExecutionHosts } from '../../../../../../shared/execution-host/managed-orcad-execution-host'
export type SetupHostOption = {
diff --git a/src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.tsx b/src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.tsx
index fdc7ecc46fb..4eb92f07ca1 100644
--- a/src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.tsx
+++ b/src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.tsx
@@ -2,7 +2,10 @@ import { useEffect, useRef, useState } from 'react'
import { Plus, RefreshCcw } from 'lucide-react'
import type { SparsePreset } from '../../../../../../shared/worktree/create-types'
import { useAppStore } from '../../../../store/index'
-import { parseSparsePresetDirectories, validateSparsePresetName } from '@/lib/sparse-preset-draft'
+import {
+ parseSparsePresetDirectories,
+ validateSparsePresetName
+} from '@/components/sparse/sparse-preset-draft'
import { useMountedRef } from '@/hooks/useMountedRef'
import { Button } from '../../../ui/button'
import { getSparsePresetOperationErrorMessage } from './sparse-preset-operation-error'
diff --git a/src/renderer/src/components/settings/virtual-machines/recipes/EphemeralVmsPane.tsx b/src/renderer/src/components/settings/virtual-machines/recipes/EphemeralVmsPane.tsx
index e7145d8b0c0..9e670dff931 100644
--- a/src/renderer/src/components/settings/virtual-machines/recipes/EphemeralVmsPane.tsx
+++ b/src/renderer/src/components/settings/virtual-machines/recipes/EphemeralVmsPane.tsx
@@ -18,7 +18,7 @@ import { useActiveProjectSkillRuntime } from '@/hooks/skills/runtime/useActivePr
import {
launchEnvironmentSetupAgent,
pickEnvironmentSetupRepo
-} from '@/lib/environment-setup-agent-launch'
+} from '@/lib/agent-session/launch/environment-setup-agent-launch'
type RecipeCatalogEntry = Awaited<
ReturnType
diff --git a/src/renderer/src/components/settings/virtual-machines/runtimes/EphemeralVmRuntimeRow.tsx b/src/renderer/src/components/settings/virtual-machines/runtimes/EphemeralVmRuntimeRow.tsx
index f2887f5ab4d..90d21d77094 100644
--- a/src/renderer/src/components/settings/virtual-machines/runtimes/EphemeralVmRuntimeRow.tsx
+++ b/src/renderer/src/components/settings/virtual-machines/runtimes/EphemeralVmRuntimeRow.tsx
@@ -2,7 +2,7 @@ import { AlertTriangle, Copy, Loader2, Square, Trash2, X } from 'lucide-react'
import type { EphemeralVmRuntimeRecord } from '../../../../../../shared/ephemeral-vm-runtimes'
import { getEphemeralVmRecipeResultProjectRoot } from '../../../../../../shared/ephemeral-vm-recipes'
import { useTranslate } from '@/i18n/use-translate'
-import { ephemeralVmCleanupErrorText } from '@/lib/ephemeral-vm-error-copy'
+import { ephemeralVmCleanupErrorText } from '@/runtime/ephemeral-vm/ephemeral-vm-error-copy'
import { cn } from '@/lib/utils'
import { Button } from '../../../ui/button'
diff --git a/src/renderer/src/components/settings/virtual-machines/runtimes/EphemeralVmRuntimesSection.tsx b/src/renderer/src/components/settings/virtual-machines/runtimes/EphemeralVmRuntimesSection.tsx
index e31cd055e30..5ebef221cb7 100644
--- a/src/renderer/src/components/settings/virtual-machines/runtimes/EphemeralVmRuntimesSection.tsx
+++ b/src/renderer/src/components/settings/virtual-machines/runtimes/EphemeralVmRuntimesSection.tsx
@@ -7,7 +7,7 @@ import { EPHEMERAL_VM_CLEANUP_STOPPED_ERROR } from '../../../../../../shared/eph
import { useMountedRef } from '@/hooks/useMountedRef'
import { translate } from '@/i18n/i18n'
import { useTranslate, type Translate } from '@/i18n/use-translate'
-import { ephemeralVmCleanupErrorText } from '@/lib/ephemeral-vm-error-copy'
+import { ephemeralVmCleanupErrorText } from '@/runtime/ephemeral-vm/ephemeral-vm-error-copy'
import { Button } from '../../../ui/button'
import { Tooltip, TooltipContent, TooltipTrigger } from '../../../ui/tooltip'
import { EphemeralVmCleanupStopDialog } from './EphemeralVmCleanupStopDialog'
diff --git a/src/renderer/src/components/setup-guide/use-setup-guide-progress.ts b/src/renderer/src/components/setup-guide/use-setup-guide-progress.ts
index 6922a1fb708..d1d61a59c13 100644
--- a/src/renderer/src/components/setup-guide/use-setup-guide-progress.ts
+++ b/src/renderer/src/components/setup-guide/use-setup-guide-progress.ts
@@ -4,7 +4,7 @@ import { isGitRepoKind } from '../../../../shared/repo-kind'
import { getRepoExecutionHostId } from '../../../../shared/execution-host'
import { checkRuntimeHooks } from '@/runtime/repo-hooks/runtime-hooks-client'
import { getLocalPreflightContext, localPreflightContextKey } from '@/lib/local-preflight-context'
-import { hasEffectiveSetupCommand } from '@/lib/setup-script-status'
+import { hasEffectiveSetupCommand } from '@/runtime/repo-hooks/setup-script-status'
import { getProviderRuntimeContextKey } from '@/runtime/hosts/observations/provider-runtime-context'
import {
COMPUTER_USE_SKILL_NAME,
diff --git a/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.test.tsx b/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.test.tsx
index 43fe3448683..12ab2fe29f0 100644
--- a/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.test.tsx
+++ b/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.test.tsx
@@ -9,7 +9,7 @@ import {
__resetTrustPromptChainForTests,
confirmCreatedWorktreeSetupContent,
ensureHooksConfirmed
-} from '@/lib/ensure-hooks-confirmed'
+} from '@/runtime/repo-hooks/ensure-hooks-confirmed'
import type { Repo } from '../../../../shared/repo-types'
const hooksCheck = vi.fn()
diff --git a/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.tsx b/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.tsx
index 33d0be38c36..6648d6eea73 100644
--- a/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.tsx
+++ b/src/renderer/src/components/sidebar/OrcaYamlTrustDialog.tsx
@@ -9,13 +9,13 @@ import {
} from '@/components/ui/dialog'
import { Button } from '@/components/ui/button'
import { useAppStore } from '@/store'
-import type { OrcaHookScriptKind } from '@/lib/orca-hook-trust'
+import type { OrcaHookTrustKind } from '../../../../shared/orca-hook-trust-entries'
import { Trans } from 'react-i18next'
import { i18n, translate } from '@/i18n/i18n'
import { useTranslate, type Translate } from '@/i18n/use-translate'
import { useUiLanguageRevision } from '@/i18n/use-ui-language-revision'
-type ScriptKind = OrcaHookScriptKind
+type ScriptKind = OrcaHookTrustKind
type SkippedSetupReviewCopy = {
title: string
diff --git a/src/renderer/src/components/sidebar/RemoveFolderDialog.tsx b/src/renderer/src/components/sidebar/RemoveFolderDialog.tsx
index 71ef5ed4f99..8db72accfcc 100644
--- a/src/renderer/src/components/sidebar/RemoveFolderDialog.tsx
+++ b/src/renderer/src/components/sidebar/RemoveFolderDialog.tsx
@@ -17,7 +17,7 @@ import {
normalizeExecutionHostId
} from '../../../../shared/execution-host'
import { countOpenRepoTerminalTabs } from '@/store/repos/repo-removal'
-import { getRecipeVmSshTargetForHost } from '@/lib/recipe-vm-managed-host'
+import { getRecipeVmSshTargetForHost } from '@/runtime/ephemeral-vm/recipe-vm-managed-host'
import { RemovalUnsavedFilesNotice } from './workspace-actions/deletion/RemovalUnsavedFilesNotice'
import { confirmUnsavedDiscard } from '@/store/slices/worktrees/teardown/removed-workspace-unsaved-files'
import { projectRemovalTargets } from './workspace-actions/deletion/removal-unsaved-files'
diff --git a/src/renderer/src/components/sidebar/SetupScriptPromptCard.tsx b/src/renderer/src/components/sidebar/SetupScriptPromptCard.tsx
index 841eac011d4..19fc4b7b786 100644
--- a/src/renderer/src/components/sidebar/SetupScriptPromptCard.tsx
+++ b/src/renderer/src/components/sidebar/SetupScriptPromptCard.tsx
@@ -10,7 +10,7 @@ import {
getDetectedSetupPreviewContent,
isSetupScriptPromptDismissed,
isSilentSetupScriptPromptState
-} from '@/lib/setup-script-prompt'
+} from '@/runtime/repo-hooks/setup-script-prompt'
import { isGitRepoKind } from '../../../../shared/repo-kind'
import type { SetupScriptImportCandidate } from '../../../../shared/workspace-setup/setup-script-imports'
import { buildSetupScriptPromptActionTelemetry } from '../../../../shared/workspace-setup/setup-script-telemetry'
diff --git a/src/renderer/src/components/sidebar/SetupScriptPromptCardShell.tsx b/src/renderer/src/components/sidebar/SetupScriptPromptCardShell.tsx
index dbedf0b4257..440145e5bfd 100644
--- a/src/renderer/src/components/sidebar/SetupScriptPromptCardShell.tsx
+++ b/src/renderer/src/components/sidebar/SetupScriptPromptCardShell.tsx
@@ -11,7 +11,7 @@ import {
} from './SetupScriptPromptCardViews'
import { SetupScriptReviewDialog } from './SetupScriptReviewDialog'
import { useTranslate } from '@/i18n/use-translate'
-import type { DetectedSetupPreviewContent } from '@/lib/setup-script-prompt'
+import type { DetectedSetupPreviewContent } from '@/runtime/repo-hooks/setup-script-prompt'
type SetupScriptPromptCardShellProps = {
repoBadgeColor: string
diff --git a/src/renderer/src/components/sidebar/project-admission/completion/project-added-default-checkout.ts b/src/renderer/src/components/sidebar/project-admission/completion/project-added-default-checkout.ts
index fcdbe6e13d3..984e63cb288 100644
--- a/src/renderer/src/components/sidebar/project-admission/completion/project-added-default-checkout.ts
+++ b/src/renderer/src/components/sidebar/project-admission/completion/project-added-default-checkout.ts
@@ -7,7 +7,7 @@ import type {
} from '../../../../../../shared/telemetry-events'
import type { DetectedWorktreeListResult, Worktree } from '../../../../../../shared/worktree/types'
import { relativePathInsideRoot } from '../../../../../../shared/cross-platform-path'
-import { markOnboardingProjectAdded } from '@/lib/onboarding-project-checklist'
+import { markOnboardingProjectAdded } from '@/components/onboarding/onboarding-project-checklist'
import { finalizeImportedRepoAfterSkip } from './add-repo-skip-finalization'
import { parseExecutionHostId, type ExecutionHostId } from '../../../../../../shared/execution-host'
import {
diff --git a/src/renderer/src/components/sidebar/project-admission/create/useCreateRepo.ts b/src/renderer/src/components/sidebar/project-admission/create/useCreateRepo.ts
index 529a5956626..e575494ede5 100644
--- a/src/renderer/src/components/sidebar/project-admission/create/useCreateRepo.ts
+++ b/src/renderer/src/components/sidebar/project-admission/create/useCreateRepo.ts
@@ -3,7 +3,7 @@ import { toast } from 'sonner'
import { useAppStore } from '@/store/index'
import { useMountedRef } from '@/hooks/useMountedRef'
import { activateAndRevealWorktree } from '@/lib/workspace/activation/worktree-activation'
-import { markOnboardingProjectAdded } from '@/lib/onboarding-project-checklist'
+import { markOnboardingProjectAdded } from '@/components/onboarding/onboarding-project-checklist'
import { callRuntimeRpc } from '@/runtime/rpc/calls/runtime-rpc-call'
import { isGitRepoKind } from '../../../../../../shared/repo-kind'
import type { Repo } from '../../../../../../shared/repo-types'
diff --git a/src/renderer/src/components/sidebar/project-admission/dialog/NonGitFolderDialog.tsx b/src/renderer/src/components/sidebar/project-admission/dialog/NonGitFolderDialog.tsx
index 5e2e2b72444..8cd46c46d83 100644
--- a/src/renderer/src/components/sidebar/project-admission/dialog/NonGitFolderDialog.tsx
+++ b/src/renderer/src/components/sidebar/project-admission/dialog/NonGitFolderDialog.tsx
@@ -13,8 +13,8 @@ import { useAppStore } from '@/store/index'
import {
resolveDismissedOnboardingFolderAgentLaunch,
revealOnboardingFolderWithAgentLaunch
-} from '@/lib/onboarding-folder-agent-launch'
-import { markOnboardingProjectAdded } from '@/lib/onboarding-project-checklist'
+} from '@/components/onboarding/onboarding-folder-agent-launch'
+import { markOnboardingProjectAdded } from '@/components/onboarding/onboarding-project-checklist'
import { translate } from '@/i18n/i18n'
import { useTranslate } from '@/i18n/use-translate'
import { useUiLanguageRevision } from '@/i18n/use-ui-language-revision'
diff --git a/src/renderer/src/components/sidebar/project-admission/host-selection/use-add-repo-hosted-controller.ts b/src/renderer/src/components/sidebar/project-admission/host-selection/use-add-repo-hosted-controller.ts
index 6118a160278..4b89ec8e330 100644
--- a/src/renderer/src/components/sidebar/project-admission/host-selection/use-add-repo-hosted-controller.ts
+++ b/src/renderer/src/components/sidebar/project-admission/host-selection/use-add-repo-hosted-controller.ts
@@ -1,7 +1,7 @@
import type { CompleteGitRepoAdd } from '../completion/use-complete-git-repo-add'
import { useMemo } from 'react'
import { useAppStore } from '@/store/index'
-import { markOnboardingProjectAdded } from '@/lib/onboarding-project-checklist'
+import { markOnboardingProjectAdded } from '@/components/onboarding/onboarding-project-checklist'
/** Nest Add Project in a host surface rather than replacing the store modal. */
export type AddRepoDialogHostedController = {
diff --git a/src/renderer/src/components/sidebar/project-admission/nested-import/useAddRepoNestedImportFlow.ts b/src/renderer/src/components/sidebar/project-admission/nested-import/useAddRepoNestedImportFlow.ts
index f3215824d22..77a15dae9e0 100644
--- a/src/renderer/src/components/sidebar/project-admission/nested-import/useAddRepoNestedImportFlow.ts
+++ b/src/renderer/src/components/sidebar/project-admission/nested-import/useAddRepoNestedImportFlow.ts
@@ -2,7 +2,7 @@ import { useCallback, useRef } from 'react'
import { toast } from 'sonner'
import { track } from '@/lib/telemetry'
import { useAppStore } from '@/store/index'
-import { getSelectedNestedRepoPathsInScanOrder } from '@/lib/nested-repo-selected-paths'
+import { getSelectedNestedRepoPathsInScanOrder } from '@/lib/workspace/creation/nested-repo-selected-paths'
import {
buildNestedRepoImportActionTelemetry,
buildNestedRepoImportResultTelemetry,
diff --git a/src/renderer/src/components/sidebar/setup-script-prompt-render-state.ts b/src/renderer/src/components/sidebar/setup-script-prompt-render-state.ts
index b5bf06e18a5..2756c0a7f4b 100644
--- a/src/renderer/src/components/sidebar/setup-script-prompt-render-state.ts
+++ b/src/renderer/src/components/sidebar/setup-script-prompt-render-state.ts
@@ -4,7 +4,7 @@ import type { Worktree } from '../../../../shared/worktree/types'
import {
ignoresSharedSetupScripts,
type SetupScriptPromptInspection
-} from '@/lib/setup-script-prompt'
+} from '@/runtime/repo-hooks/setup-script-prompt'
import { findRepoForHost } from '@/store/repos/repo-host-identity'
import { toRuntimeExecutionHostId } from '../../../../shared/execution-host'
diff --git a/src/renderer/src/components/sidebar/useRenderedSetupScriptPromptState.ts b/src/renderer/src/components/sidebar/useRenderedSetupScriptPromptState.ts
index a6d96dd860a..9621f15b16f 100644
--- a/src/renderer/src/components/sidebar/useRenderedSetupScriptPromptState.ts
+++ b/src/renderer/src/components/sidebar/useRenderedSetupScriptPromptState.ts
@@ -1,5 +1,5 @@
import { useEffect, useRef } from 'react'
-import { isSilentSetupScriptPromptState } from '@/lib/setup-script-prompt'
+import { isSilentSetupScriptPromptState } from '@/runtime/repo-hooks/setup-script-prompt'
import {
getRenderedSetupScriptPromptState,
type LastVisibleSetupScriptPrompt,
diff --git a/src/renderer/src/components/sidebar/useSetupScriptPromptInspection.ts b/src/renderer/src/components/sidebar/useSetupScriptPromptInspection.ts
index e9e8cec5706..92616d9a787 100644
--- a/src/renderer/src/components/sidebar/useSetupScriptPromptInspection.ts
+++ b/src/renderer/src/components/sidebar/useSetupScriptPromptInspection.ts
@@ -1,5 +1,5 @@
import { useEffect } from 'react'
-import { inspectSetupScriptPromptState } from '@/lib/setup-script-prompt'
+import { inspectSetupScriptPromptState } from '@/runtime/repo-hooks/setup-script-prompt'
import {
checkRuntimeHooks,
inspectRuntimeSetupScriptImports
diff --git a/src/renderer/src/components/sidebar/workspace-actions/context-menu/use-worktree-context-menu-commands.ts b/src/renderer/src/components/sidebar/workspace-actions/context-menu/use-worktree-context-menu-commands.ts
index 440a0ba4ceb..32f8ab9f3a3 100644
--- a/src/renderer/src/components/sidebar/workspace-actions/context-menu/use-worktree-context-menu-commands.ts
+++ b/src/renderer/src/components/sidebar/workspace-actions/context-menu/use-worktree-context-menu-commands.ts
@@ -5,7 +5,7 @@ import {
getRepoExecutionHostId,
LOCAL_EXECUTION_HOST_ID
} from '../../../../../../shared/execution-host'
-import { getRepoWorkspaceCreationTargetHint } from '@/lib/project-host-workspace-target'
+import { getRepoWorkspaceCreationTargetHint } from '@/lib/workspace/creation/project-host-workspace-target'
import { resolveReviewRepository } from '@/lib/review-owner'
import type { WorkspaceStatusDefinition, Worktree } from '../../../../../../shared/worktree/types'
import {
diff --git a/src/renderer/src/components/sidebar/workspace-actions/context-menu/worktree-context-menu-policy.ts b/src/renderer/src/components/sidebar/workspace-actions/context-menu/worktree-context-menu-policy.ts
index ec748d32d3c..17fef0348bc 100644
--- a/src/renderer/src/components/sidebar/workspace-actions/context-menu/worktree-context-menu-policy.ts
+++ b/src/renderer/src/components/sidebar/workspace-actions/context-menu/worktree-context-menu-policy.ts
@@ -1,7 +1,8 @@
import type { AppState } from '@/store/types'
import type { Repo } from '../../../../../../shared/repo-types'
import { isGitRepoKind } from '../../../../../../shared/repo-kind'
-import { getComposerEligibleRepos } from '@/lib/new-workspace-composer-repo'
+import '@/lib/workspace/creation/new-workspace-composer-repo'
+import { getNewWorkspaceDialogEligibleRepos } from '../../../../../../shared/new-workspace-dialog-repo'
import type {
WorkspaceStatus,
WorkspaceStatusDefinition,
@@ -132,7 +133,7 @@ export function canCreateChildWorktree(args: {
return (
args.repo != null &&
isGitRepoKind(args.repo) &&
- getComposerEligibleRepos([args.repo]).length > 0 &&
+ getNewWorkspaceDialogEligibleRepos([args.repo]).length > 0 &&
!args.folderWorkspaceId &&
!args.worktree.isArchived
)
diff --git a/src/renderer/src/components/sidebar/workspace-card/surface/WorktreeCardVmStateBadge.tsx b/src/renderer/src/components/sidebar/workspace-card/surface/WorktreeCardVmStateBadge.tsx
index 3689e4918bf..949c7629780 100644
--- a/src/renderer/src/components/sidebar/workspace-card/surface/WorktreeCardVmStateBadge.tsx
+++ b/src/renderer/src/components/sidebar/workspace-card/surface/WorktreeCardVmStateBadge.tsx
@@ -4,7 +4,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip
import { translate } from '@/i18n/i18n'
import { useTranslate, type Translate } from '@/i18n/use-translate'
import { cn } from '@/lib/utils'
-import { ephemeralVmErrorText } from '@/lib/ephemeral-vm-error-copy'
+import { ephemeralVmErrorText } from '@/runtime/ephemeral-vm/ephemeral-vm-error-copy'
import type { EphemeralVmFailure } from '../../../../../../shared/ephemeral-vm-failure-copy'
import type { ExecutionHostVmState } from '../../../../../../shared/execution-host/execution-host-health'
diff --git a/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-agent-startup.ts b/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-agent-startup.ts
index a7263c7bb24..421a873b375 100644
--- a/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-agent-startup.ts
+++ b/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-agent-startup.ts
@@ -2,7 +2,7 @@ import {
resolveAgentStartupPlanInputs,
type AgentStartupSettings
} from '../../../../../../shared/agent-launch/startup/agent-startup-plan-inputs'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import { resolveRepoExecutionHostPlatform } from '@/runtime/hosts/platform/execution-host-facts'
import type { ExecutionHostPlatformFact } from '@/runtime/hosts/platform/execution-host-platform-fact'
import type { AppState } from '@/store/types'
diff --git a/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit-input.ts b/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit-input.ts
index c7d59a529ed..005776440d8 100644
--- a/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit-input.ts
+++ b/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit-input.ts
@@ -1,5 +1,5 @@
import type { AgentLaunchChoice } from '@/lib/agent-session/launch/routing/agent-menu-selection'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import type { AgentStartupSettings } from '../../../../../../shared/agent-launch/startup/agent-startup-plan-inputs'
import type { AgentLaunchInputViews } from '../../../../../../shared/agent-launch/choices/agent-launch-choices'
import type { FolderWorkspace } from '../../../../../../shared/folder-workspaces/folder-workspace-types'
diff --git a/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit.test.ts b/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit.test.ts
index c476b341e00..adb913d8f80 100644
--- a/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit.test.ts
+++ b/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit.test.ts
@@ -3,7 +3,7 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { makeProjectGroup, makeFolderWorkspace } from './folder-workspace-composer-submit-fixtures'
-import type * as NewWorkspaceModule from '@/lib/new-workspace'
+import type * as NewWorkspaceModule from '@/lib/workspace/creation/new-workspace'
const mocks = vi.hoisted(() => ({
activateAndRevealFolderWorkspace: vi.fn(),
@@ -15,7 +15,7 @@ vi.mock('@/lib/workspace/activation/worktree-activation', async (importOriginal)
return { ...actual, activateAndRevealFolderWorkspace: mocks.activateAndRevealFolderWorkspace }
})
-vi.mock('@/lib/new-workspace', async (importOriginal) => {
+vi.mock('@/lib/workspace/creation/new-workspace', async (importOriginal) => {
const actual = await importOriginal()
return {
...actual,
@@ -91,55 +91,3 @@ describe('submitFolderWorkspaceCreate native-chat launch draft', () => {
expect(seededDraftFor('tab-1')?.text).toBe(ISSUE_URL)
})
})
-
-it('keeps the folder legacy Arguments projection while carrying the entire non-native draft to the paired pane', async () => {
- mocks.activateAndRevealFolderWorkspace.mockReturnValue({ primaryTabId: 'folder-agent' })
- await submitFolderWorkspaceCreate({
- projectGroup: makeProjectGroup(),
- name: 'folder',
- lastAutoName: '',
- linkedWorkItem: linkedIssue,
- note: 'keep this note',
- quickAgent: 'codex',
- autoRenameBranchFromWork: false,
- agentCmdOverrides: {},
- launchInputs: { sessionOptions: { model: 'gpt-picked' } },
- legacyLaunchInputs: {
- agentArgs: '--add-dir /host/shared',
- sessionOptions: { model: 'gpt-picked' }
- },
- createFolderWorkspace: vi.fn(async () => makeFolderWorkspace()),
- onOpenChange: vi.fn()
- })
- const startup = mocks.activateAndRevealFolderWorkspace.mock.calls.at(-1)?.[1].startup
- expect(startup.command).toContain("'/host/shared'")
- expect(startup.freshAgentLaunch.agentArgs).toBeUndefined()
- expect(startup.freshAgentLaunch.prompt).toContain(ISSUE_URL)
- expect(startup.freshAgentLaunch.prompt).toContain('keep this note')
- expect(startup.freshAgentLaunch.legacy()).toMatchObject({
- pasteDraftAfterLaunch: expect.stringContaining('keep this note'),
- submitPastedPrompt: false
- })
-})
-
-it('delivers an old-host Aider folder note using the plan whose bare command executes', async () => {
- mocks.activateAndRevealFolderWorkspace.mockReturnValue({ primaryTabId: 'folder-aider' })
- await submitFolderWorkspaceCreate({
- projectGroup: makeProjectGroup(),
- name: 'folder',
- lastAutoName: '',
- linkedWorkItem: null,
- note: 'fix the folder',
- quickAgent: 'aider',
- autoRenameBranchFromWork: false,
- agentCmdOverrides: {},
- createFolderWorkspace: vi.fn(async () => makeFolderWorkspace()),
- onOpenChange: vi.fn()
- })
- const startup = mocks.activateAndRevealFolderWorkspace.mock.lastCall?.[1].startup
- expect(startup.command).toBe('aider')
- const compatibility = startup.freshAgentLaunch.legacy()
- expect(compatibility.startupPlan.launchCommand).toBe('aider')
- expect(compatibility.pasteDraftAfterLaunch).toBe('fix the folder')
- expect(compatibility.submitPastedPrompt).toBe(true)
-})
diff --git a/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit.ts b/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit.ts
index 5df1d7f3bfa..2324c10248d 100644
--- a/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit.ts
+++ b/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit.ts
@@ -1,6 +1,6 @@
import { ensureAgentLaunchPreferences } from '@/runtime/agent-launch-settings/use-host-agent-launch-preferences'
import { resolveAgentStartupPlanInputs } from '../../../../../../shared/agent-launch/startup/agent-startup-plan-inputs'
-import { ensureAgentStartupInTerminal } from '@/lib/new-workspace'
+import { ensureAgentStartupInTerminal } from '@/lib/workspace/creation/new-workspace'
import { seedNativeChatLaunchDraftForAgentTab } from '@/lib/agent-session/launch/prompt/agent-launch-prompt-delivery'
import { createNonSecureContextUuid as createBrowserUuid } from '../../../../../../shared/non-secure-context-uuid'
import { buildAgentStartupPlan } from '../../../../../../shared/agent-launch/startup/tui-agent-startup'
@@ -19,7 +19,8 @@ import {
} from '@/lib/agent-session/launch/routing/agent-session-launch-plan'
import { newAgentLaunchRequestId } from '@/lib/agent-session/launch/routing/agent-launch-request-id'
import { beginStructuredAgentSessionProvisionalLaunch } from '@/lib/agent-session/structured-agent-session-provisional-tab'
-import { getNewWorkspaceProjectGroupHostId } from '@/lib/new-workspace-project-options'
+import '@/lib/workspace/creation/new-workspace-project-options'
+import { getRepoExecutionHostId } from '../../../../../../shared/execution-host'
import { useAppStore } from '@/store/index'
import { resolveExecutionHostAgentStartupShell } from '@/runtime/hosts/platform/execution-host-facts'
import {
@@ -91,7 +92,7 @@ export async function submitFolderWorkspaceCreate({
? await ensureAgentLaunchPreferences(useAppStore.getState(), {
kind: 'folder',
runtimeEnvironmentId,
- executionHostId: getNewWorkspaceProjectGroupHostId(projectGroup)
+ executionHostId: getRepoExecutionHostId(projectGroup)
})
: undefined
const effectiveSettings = settings
@@ -145,7 +146,7 @@ export async function submitFolderWorkspaceCreate({
workspace: {
kind: 'folder' as const,
runtimeEnvironmentId,
- executionHostId: getNewWorkspaceProjectGroupHostId(projectGroup)
+ executionHostId: getRepoExecutionHostId(projectGroup)
},
prompt: launchDraftPrompt ?? note,
promptDelivery: launchDraftPrompt ? ('draft' as const) : ('auto-submit' as const)
diff --git a/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-source-selection.ts b/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-source-selection.ts
index 21d14333ce0..c694d72f11f 100644
--- a/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-source-selection.ts
+++ b/src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-source-selection.ts
@@ -1,4 +1,4 @@
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import {
buildWorkspaceSourceSelection,
getWorkspaceSourceName,
diff --git a/src/renderer/src/components/sidebar/worktree-list/listing/use-main-list-model.ts b/src/renderer/src/components/sidebar/worktree-list/listing/use-main-list-model.ts
index 6c9fbe9abd5..3c3a7c7d9cd 100644
--- a/src/renderer/src/components/sidebar/worktree-list/listing/use-main-list-model.ts
+++ b/src/renderer/src/components/sidebar/worktree-list/listing/use-main-list-model.ts
@@ -13,7 +13,7 @@ import {
readHiddenVmCheckouts,
subscribeHiddenVmCheckouts,
withoutHiddenVmCheckouts
-} from '@/lib/vm-create-hidden-checkouts'
+} from '@/runtime/ephemeral-vm/vm-create-hidden-checkouts'
import '../../../../../../shared/folder-workspaces/folder-workspace-execution-host'
import { getFolderWorkspaceHostId } from '../../../../../../shared/folder-workspaces/folder-workspace-host-id'
import type { FolderWorkspace } from '../../../../../../shared/folder-workspaces/folder-workspace-types'
diff --git a/src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts b/src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts
index 954b9acaafd..b24d500c95b 100644
--- a/src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts
+++ b/src/renderer/src/components/sidebar/worktree-list/listing/use-section-rows.ts
@@ -19,7 +19,10 @@ import { useEffectiveCollapsedGroups } from './use-collapsed-groups'
import type { Row } from '../../../../../../shared/sidebar-list/row-types'
import type { SectionRowsArgs } from './sidebar-list-model'
import { getLogicalRepoOrderRankById } from '../../../../../../shared/project-section-order'
-import { readHiddenVmCheckouts, subscribeHiddenVmCheckouts } from '@/lib/vm-create-hidden-checkouts'
+import {
+ readHiddenVmCheckouts,
+ subscribeHiddenVmCheckouts
+} from '@/runtime/ephemeral-vm/vm-create-hidden-checkouts'
import { getEmptyProjectPlaceholderRepoIds } from '../../../../../../shared/sidebar-list/empty-project-placeholder-repos'
import {
deferHostSectionCollapse,
diff --git a/src/renderer/src/components/sidebar/worktree-list/listing/use-visible-worktrees.ts b/src/renderer/src/components/sidebar/worktree-list/listing/use-visible-worktrees.ts
index 9a83fe32d62..68a2647bc88 100644
--- a/src/renderer/src/components/sidebar/worktree-list/listing/use-visible-worktrees.ts
+++ b/src/renderer/src/components/sidebar/worktree-list/listing/use-visible-worktrees.ts
@@ -28,7 +28,7 @@ import {
readHiddenVmCheckouts,
subscribeHiddenVmCheckouts,
withoutHiddenVmWorktrees
-} from '@/lib/vm-create-hidden-checkouts'
+} from '@/runtime/ephemeral-vm/vm-create-hidden-checkouts'
const EMPTY_WORKTREE_ID_SET: ReadonlySet = new Set()
diff --git a/src/renderer/src/components/sidebar/worktree-list/rows/header-create-workspace-target.ts b/src/renderer/src/components/sidebar/worktree-list/rows/header-create-workspace-target.ts
index 891e991da69..7a687b40e05 100644
--- a/src/renderer/src/components/sidebar/worktree-list/rows/header-create-workspace-target.ts
+++ b/src/renderer/src/components/sidebar/worktree-list/rows/header-create-workspace-target.ts
@@ -4,12 +4,13 @@ import {
getRepoHostIdentity,
getRepoRegistrationHostIds
} from '../../../../../../shared/repo-host-identity'
-import { getComposerEligibleRepos } from '@/lib/new-workspace-composer-repo'
+import '@/lib/workspace/creation/new-workspace-composer-repo'
+import { getNewWorkspaceDialogEligibleRepos } from '../../../../../../shared/new-workspace-dialog-repo'
import { useAppStore } from '@/store'
import {
getRepoWorkspaceCreationTargetHint,
type WorkspaceCreationTargetHint
-} from '@/lib/project-host-workspace-target'
+} from '@/lib/workspace/creation/project-host-workspace-target'
/** A single-host project header's create target, when its repo id alone can't pick the host. */
export function getHeaderCreateWorkspaceTarget(
@@ -23,7 +24,7 @@ export function getHeaderCreateWorkspaceTarget(
}
const identity = getRepoHostIdentity(repo)
// Plumbing repos the composer can't target keep the id path, which maps them to an eligible sibling.
- return getComposerEligibleRepos(repos).some(
+ return getNewWorkspaceDialogEligibleRepos(repos).some(
(candidate) => getRepoHostIdentity(candidate) === identity
)
? { initialWorkspaceTarget: getRepoWorkspaceCreationTargetHint(repo, projectHostSetups) }
diff --git a/src/renderer/src/components/sidebar/worktree-list/rows/repo-header-create-state.ts b/src/renderer/src/components/sidebar/worktree-list/rows/repo-header-create-state.ts
index a579c4fa333..c76c05984b4 100644
--- a/src/renderer/src/components/sidebar/worktree-list/rows/repo-header-create-state.ts
+++ b/src/renderer/src/components/sidebar/worktree-list/rows/repo-header-create-state.ts
@@ -1,7 +1,7 @@
import type { SshConnectionStatus } from '../../../../../../shared/ssh-types'
import type { Repo } from '../../../../../../shared/repo-types'
import { isGitRepoKind } from '../../../../../../shared/repo-kind'
-import { getSelectedRepoSshGate } from '../../../../lib/new-workspace-ssh-gate'
+import { getSelectedRepoSshGate } from '../../../../lib/workspace/creation/new-workspace-ssh-gate'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
diff --git a/src/renderer/src/components/sparse/SparseCheckoutPresetDraftForm.tsx b/src/renderer/src/components/sparse/SparseCheckoutPresetDraftForm.tsx
index c783e7453d7..70af94523ba 100644
--- a/src/renderer/src/components/sparse/SparseCheckoutPresetDraftForm.tsx
+++ b/src/renderer/src/components/sparse/SparseCheckoutPresetDraftForm.tsx
@@ -8,7 +8,7 @@ import { SparseSelectedDirectoryList } from './SparseSelectedDirectoryList'
import { addSparseDirectoryEntries } from './sparse-directory-entry-input'
import { useTranslate } from '@/i18n/use-translate'
import { normalizeSparseDirectoryLines } from '@/lib/sparse-paths'
-import type { SparsePresetDirectoryParseResult } from '@/lib/sparse-preset-draft'
+import type { SparsePresetDirectoryParseResult } from '@/components/sparse/sparse-preset-draft'
export type SparsePresetDraft = {
mode: 'new' | 'edit'
diff --git a/src/renderer/src/components/sparse/SparseCheckoutPresetSelect.tsx b/src/renderer/src/components/sparse/SparseCheckoutPresetSelect.tsx
index e10cdf6c722..70085deca83 100644
--- a/src/renderer/src/components/sparse/SparseCheckoutPresetSelect.tsx
+++ b/src/renderer/src/components/sparse/SparseCheckoutPresetSelect.tsx
@@ -4,7 +4,10 @@ import { Button } from '@/components/ui/button'
import { SparsePresetChooser } from './SparsePresetChooser'
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
import { useAppStore } from '@/store'
-import { parseSparsePresetDirectories, validateSparsePresetName } from '@/lib/sparse-preset-draft'
+import {
+ parseSparsePresetDirectories,
+ validateSparsePresetName
+} from '@/components/sparse/sparse-preset-draft'
import { useMountedRef } from '@/hooks/useMountedRef'
import type { SparsePreset } from '../../../../shared/worktree/create-types'
import { translate } from '@/i18n/i18n'
diff --git a/src/renderer/src/lib/sparse-preset-draft.ts b/src/renderer/src/components/sparse/sparse-preset-draft.ts
similarity index 100%
rename from src/renderer/src/lib/sparse-preset-draft.ts
rename to src/renderer/src/components/sparse/sparse-preset-draft.ts
diff --git a/src/renderer/src/components/tab-bar/QuickLaunchButton.tsx b/src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
index a99202ec1f2..71398dcd243 100644
--- a/src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
+++ b/src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
@@ -13,7 +13,10 @@ import { toast } from 'sonner'
import { launchAgentInNewTab } from '@/lib/agent-session/launch/new-tab/launch-agent-in-new-tab'
import { newAgentLaunchRequestId } from '@/lib/agent-session/launch/routing/agent-launch-request-id'
import { captureNativeChatComposerFocusIntent } from '@/components/native-chat/composer/focus/native-chat-composer-focus-intent'
-import { agentLaunchPromptOwnership, newAgentPromptOutcome } from '@/lib/new-agent-prompt-outcome'
+import {
+ agentLaunchPromptOwnership,
+ newAgentPromptOutcome
+} from '@/lib/agent-session/launch/prompt/new-agent-prompt-outcome'
import { activeAgentNotesSendFailureMessage } from '@/lib/agent-session/messaging/terminal/active-agent-note-send-result'
import { AgentSettingsMenuItem } from '@/components/agent/AgentSettingsMenuItem'
import { TabAgentSurfaceChoiceRow } from './TabAgentSurfaceChoiceRow'
diff --git a/src/renderer/src/components/tab-bar/use-new-tab-agent-menu-rows.ts b/src/renderer/src/components/tab-bar/use-new-tab-agent-menu-rows.ts
index f129bb84594..beac6031dbf 100644
--- a/src/renderer/src/components/tab-bar/use-new-tab-agent-menu-rows.ts
+++ b/src/renderer/src/components/tab-bar/use-new-tab-agent-menu-rows.ts
@@ -37,8 +37,8 @@ import {
} from '@/runtime/hosts/capabilities/local-runtime-capabilities'
import { useDetectedAgents, type AgentDetectionTarget } from '@/hooks/useDetectedAgents'
import { readDetectedAgentsForTarget } from '@/lib/agent-session/launch/inventory/agent-detection-target-inventory'
-import { useChatProgramFacts } from '@/lib/host-chat-program-acquisition'
-import { readChatProgram } from '@/lib/host-chat-program'
+import { useChatProgramFacts } from '@/lib/agent-session/launch/inventory/host-chat-program-acquisition'
+import { readChatProgram } from '@/lib/agent-session/launch/inventory/host-chat-program'
import { resolveAgentMenuSelection } from '@/lib/agent-session/launch/routing/agent-menu-selection'
import { useHostAgentMenuSettings } from '@/runtime/agent-launch-settings/use-host-agent-launch-preferences'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
diff --git a/src/renderer/src/components/task-page/jira/Filters.tsx b/src/renderer/src/components/task-page/jira/Filters.tsx
index 30bcaae445c..774acae850a 100644
--- a/src/renderer/src/components/task-page/jira/Filters.tsx
+++ b/src/renderer/src/components/task-page/jira/Filters.tsx
@@ -10,7 +10,7 @@ import { getJiraProjectSelectionKey } from '@/components/task-page/jira/task-pag
import { useTranslate } from '@/i18n/use-translate'
import { LoaderCircle, Plus, RefreshCw, Search, X } from 'lucide-react'
import { Input } from '@/components/ui/input'
-import { shouldSuppressEnterSubmit } from '@/lib/new-workspace-enter-guard'
+import { shouldSuppressEnterSubmit } from '@/lib/workspace/creation/new-workspace-enter-guard'
import { JiraProjectPicker } from '@/components/jira-project-picker'
import { matchesJiraProject } from '../../../../../shared/jira/jira-project-reference'
export function TaskPageJiraFilters({
diff --git a/src/renderer/src/components/task-page/linear/Filters.tsx b/src/renderer/src/components/task-page/linear/Filters.tsx
index 2477efea984..0985ba41f49 100644
--- a/src/renderer/src/components/task-page/linear/Filters.tsx
+++ b/src/renderer/src/components/task-page/linear/Filters.tsx
@@ -7,7 +7,7 @@ import { useAppStore } from '@/store'
import { Plus, LoaderCircle, RefreshCw, Search, X } from 'lucide-react'
import LinearIssueAttributeFilterDropdowns from '@/components/linear-issue-attribute-filter-dropdowns'
import { Input } from '@/components/ui/input'
-import { shouldSuppressEnterSubmit } from '@/lib/new-workspace-enter-guard'
+import { shouldSuppressEnterSubmit } from '@/lib/workspace/creation/new-workspace-enter-guard'
import { defaultScopeSource } from '@/runtime/hosts/selection/default-creation-host'
export function TaskPageLinearFilters({
model
diff --git a/src/renderer/src/components/task-page/use-task-page-composer-actions.ts b/src/renderer/src/components/task-page/use-task-page-composer-actions.ts
index 1cc1e63e0c3..254f0452a54 100644
--- a/src/renderer/src/components/task-page/use-task-page-composer-actions.ts
+++ b/src/renderer/src/components/task-page/use-task-page-composer-actions.ts
@@ -10,11 +10,11 @@ import { openLinearIssueWorkspaceOrStart } from '@/lib/work-items/linear/linear-
import { toast } from 'sonner'
import { translate } from '@/i18n/i18n'
import { bindTaskPageJiraItemSourceContext } from './jira/task-page-jira-item-source-context'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import { shouldHideTaskPageListChrome } from './task-page-list-chrome-visibility'
import { getJiraIssueWorkspaceSeed } from './task-page-source-context'
import { findJiraIssueDefaultRepo } from '../../../../shared/jira/jira-project-reference'
-import { getRepoWorkspaceCreationTargetHint } from '@/lib/project-host-workspace-target'
+import { getRepoWorkspaceCreationTargetHint } from '@/lib/workspace/creation/project-host-workspace-target'
export function useTaskPageComposerActions(model: TaskPageJiraListEffectsModel) {
const {
setTaskResumeState,
diff --git a/src/renderer/src/components/task-page/use-task-page-search-actions.ts b/src/renderer/src/components/task-page/use-task-page-search-actions.ts
index e029d804be1..ab1cc14a3df 100644
--- a/src/renderer/src/components/task-page/use-task-page-search-actions.ts
+++ b/src/renderer/src/components/task-page/use-task-page-search-actions.ts
@@ -11,7 +11,7 @@ import { toast } from 'sonner'
import { translate } from '@/i18n/i18n'
import type { GitHubTaskKind } from '@/components/task-page/task-page-localized-options'
import { getTaskPresetQuery } from '../../../../shared/work-items/task-preset-query'
-import { shouldSuppressEnterSubmit } from '@/lib/new-workspace-enter-guard'
+import { shouldSuppressEnterSubmit } from '@/lib/workspace/creation/new-workspace-enter-guard'
import { addAppKeyListener, removeAppKeyListener } from '@/lib/keyboard/app-keyboard-router'
export function useTaskPageSearchActions(model: TaskPageGitHubQuietRefreshModel) {
const {
diff --git a/src/renderer/src/components/task-page/use-task-page-workspace-actions.ts b/src/renderer/src/components/task-page/use-task-page-workspace-actions.ts
index 859366393d8..90b24da2c30 100644
--- a/src/renderer/src/components/task-page/use-task-page-workspace-actions.ts
+++ b/src/renderer/src/components/task-page/use-task-page-workspace-actions.ts
@@ -2,7 +2,7 @@ import type { TaskPageSearchActionsModel } from './use-task-page-search-actions'
import { useCallback } from 'react'
import type { GitHubWorkItem } from '../../../../shared/github/work-item-types'
import type { GitLabWorkItem } from '../../../../shared/gitlab-types'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import { useAppStore } from '@/store'
import { getWorkItemRepo } from '@/lib/work-items/work-item-repo-row'
import { findGithubWorkItemWorkspaceAttachment } from '@/lib/work-items/github/github-work-item-workspace-attachment'
diff --git a/src/renderer/src/components/terminal-agent-tab-shortcut.ts b/src/renderer/src/components/terminal-agent-tab-shortcut.ts
index cd63dc8e7ec..73baaa50bcd 100644
--- a/src/renderer/src/components/terminal-agent-tab-shortcut.ts
+++ b/src/renderer/src/components/terminal-agent-tab-shortcut.ts
@@ -9,7 +9,7 @@ import {
resolveDefaultAgentForNewTab,
resolveDefaultAgentForWorktreeNewTab
} from '@/lib/agent-session/launch/shortcuts/agent-tab-shortcuts'
-import { chosenAgentChatUnlearned } from '@/lib/host-chat-program'
+import { chosenAgentChatUnlearned } from '@/lib/agent-session/launch/inventory/host-chat-program'
import { worktreeLaunchWorkspace } from '@/lib/agent-session/launch/routing/agent-launch-route-input'
export type TerminalAgentTabShortcut = {
diff --git a/src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-handler.test.ts b/src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-handler.test.ts
deleted file mode 100644
index 71cd9f1d8b9..00000000000
--- a/src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-handler.test.ts
+++ /dev/null
@@ -1,221 +0,0 @@
-import { parseExecutionHostId } from '../../../../../../shared/execution-host'
-import { beforeEach, describe, expect, it, vi } from 'vitest'
-
-const mocks = vi.hoisted(() => {
- const worktreesByRepo: Record<
- string,
- { id: string; repoId: string; path: string; hostId?: string | null }[]
- > = {
- repo1: [{ id: 'wt-1', repoId: 'repo1', path: '/remote/repo', hostId: 'runtime:env-1' }]
- }
- const projects: {
- id: string
- localWindowsRuntimePreference:
- | { kind: 'inherit-global' }
- | { kind: 'windows-host' }
- | { kind: 'wsl'; distro: string | null }
- }[] = [
- {
- id: 'repo1',
- localWindowsRuntimePreference: { kind: 'inherit-global' as const }
- }
- ]
-
- return {
- toastLoading: vi.fn(() => 'toast-1'),
- toastDismiss: vi.fn(),
- toastError: vi.fn(),
- importExternalPathsToRuntime: vi.fn(),
- resolveDroppedPathsForAgent: vi.fn(),
- recordTerminalUserInputForLeaf: vi.fn(),
- storeState: {
- activeRepoId: 'repo1',
- activeWorktreeId: 'wt-1',
- settings: { activeRuntimeEnvironmentId: 'env-1' as string | null },
- projects,
- repos: [
- {
- id: 'repo1',
- connectionId: null as string | null,
- path: '/remote/repo',
- executionHostId: 'runtime:env-1' as string | null
- }
- ],
- worktreesByRepo,
- sshConnectionStates: new Map<
- string,
- { remotePlatform?: NodeJS.Platform; connectionGeneration?: number }
- >()
- }
- }
-})
-
-vi.mock('sonner', () => ({
- toast: {
- loading: mocks.toastLoading,
- dismiss: mocks.toastDismiss,
- error: mocks.toastError,
- message: vi.fn()
- }
-}))
-
-vi.mock('@/store/index', () => ({
- useAppStore: {
- getState: () => mocks.storeState
- }
-}))
-
-vi.mock('@/runtime/files/imports/runtime-file-import-client', () => ({
- importExternalPathsToRuntime: mocks.importExternalPathsToRuntime
-}))
-
-vi.mock('@/lib/new-workspace', () => ({
- CLIENT_PLATFORM: 'win32'
-}))
-
-vi.mock('../terminal-input-activity', () => ({
- recordTerminalUserInputForLeaf: mocks.recordTerminalUserInputForLeaf
-}))
-
-import './terminal-drop-handler'
-import { handleNativeTerminalFileDrop as handleTerminalFileDrop } from './terminal-native-file-drop-destination'
-import '../paste/terminal-bracketed-paste'
-
-function createTerminalTransport(
- sendInput: ReturnType,
- ptyId = 'pty-1',
- sendInputAccepted?: ReturnType
-) {
- const host = parseExecutionHostId(mocks.storeState.repos[0]?.executionHostId)
- return {
- sendInput,
- ...(sendInputAccepted ? { sendInputAccepted } : {}),
- getPtyId: vi.fn(() => ptyId),
- isConnected: vi.fn(() => true),
- getExecutionHostId: () => (host?.kind === 'runtime' ? 'local' : (host?.id ?? 'local')),
- getRuntimeEnvironmentId: () => (host?.kind === 'runtime' ? host.environmentId : null)
- }
-}
-
-describe('handleTerminalFileDrop', () => {
- beforeEach(() => {
- vi.clearAllMocks()
- mocks.storeState.activeRepoId = 'repo1'
- mocks.storeState.activeWorktreeId = 'wt-1'
- vi.stubGlobal('window', {
- api: {
- fs: {
- resolveDroppedPathsForAgent: mocks.resolveDroppedPathsForAgent
- }
- }
- })
- mocks.storeState.settings = { activeRuntimeEnvironmentId: 'env-1' }
- mocks.storeState.projects = [
- {
- id: 'repo1',
- localWindowsRuntimePreference: { kind: 'inherit-global' }
- }
- ]
- mocks.storeState.repos = [
- { id: 'repo1', connectionId: null, path: '/remote/repo', executionHostId: 'runtime:env-1' }
- ]
- mocks.storeState.worktreesByRepo = {
- repo1: [
- {
- id: 'wt-1',
- repoId: 'repo1',
- path: '/remote/repo',
- hostId: parseExecutionHostId(mocks.storeState.repos[0]?.executionHostId)?.id ?? 'local'
- }
- ]
- }
- mocks.storeState.sshConnectionStates = new Map()
- })
-
- it('does not paste runtime-uploaded paths when the target PTY changed', async () => {
- let ptyId = 'pty-1'
- mocks.importExternalPathsToRuntime.mockImplementation(async () => {
- ptyId = 'pty-2'
- return {
- results: [
- {
- sourcePath: '/Users/me/logo.png',
- status: 'imported',
- destPath: '/remote/repo/.orca/drops/logo.png',
- kind: 'file',
- renamed: false
- }
- ]
- }
- })
- const sendInput = vi.fn(() => true)
- const focus = vi.fn()
- const pane = { id: 1, leafId: 'leaf-1', terminal: { focus } }
- const manager = { getActivePane: () => pane, getPanes: () => [pane] }
- const transport = createTerminalTransport(sendInput)
- transport.getPtyId.mockImplementation(() => ptyId)
-
- await handleTerminalFileDrop({
- manager: manager as never,
- paneTransports: new Map([[1, transport]]) as never,
- worktreeId: 'wt-1',
- tabId: 'tab-1',
- cwd: undefined,
- pane,
- paths: ['/Users/me/logo.png']
- })
-
- expect(sendInput).not.toHaveBeenCalled()
- expect(focus).not.toHaveBeenCalled()
- expect(mocks.recordTerminalUserInputForLeaf).not.toHaveBeenCalled()
- expect(mocks.toastDismiss).toHaveBeenCalledWith('toast-1')
- })
-
- it('does not paste local WSL resolved paths when the target PTY changed', async () => {
- mocks.storeState.settings = { activeRuntimeEnvironmentId: 'focused-runtime' }
- mocks.storeState.repos = [
- { id: 'repo1', connectionId: null, path: '/repo', executionHostId: 'local' }
- ]
- mocks.storeState.worktreesByRepo = {
- repo1: [
- {
- id: 'wt-1',
- repoId: 'repo1',
- path: '\\\\wsl.localhost\\Ubuntu-24.04\\home\\user\\repo'
- }
- ]
- }
- let ptyId = 'pty-1'
- mocks.resolveDroppedPathsForAgent.mockImplementation(async () => {
- ptyId = 'pty-2'
- return {
- failed: [],
- resolvedPaths: ['/mnt/c/Users/Name/My Project/file.txt'],
- skipped: []
- }
- })
- const sendInput = vi.fn(() => true)
- const focus = vi.fn()
- const pane = { id: 1, leafId: 'leaf-1', terminal: { focus } }
- const manager = {
- getActivePane: () => pane,
- getPanes: () => [pane]
- }
- const transport = createTerminalTransport(sendInput)
- transport.getPtyId.mockImplementation(() => ptyId)
-
- await handleTerminalFileDrop({
- manager: manager as never,
- paneTransports: new Map([[1, transport]]) as never,
- worktreeId: 'wt-1',
- tabId: 'tab-1',
- cwd: undefined,
- pane,
- paths: ['C:\\Users\\Name\\My Project\\file.txt']
- })
-
- expect(sendInput).not.toHaveBeenCalled()
- expect(focus).not.toHaveBeenCalled()
- expect(mocks.recordTerminalUserInputForLeaf).not.toHaveBeenCalled()
- })
-})
diff --git a/src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-internal-handler.test.ts b/src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-internal-handler.test.ts
index 440d8864e34..3858b5482db 100644
--- a/src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-internal-handler.test.ts
+++ b/src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-internal-handler.test.ts
@@ -65,7 +65,7 @@ vi.mock('@/runtime/files/imports/runtime-file-import-client', () => ({
importExternalPathsToRuntime: mocks.importExternalPathsToRuntime
}))
-vi.mock('@/lib/new-workspace', () => ({
+vi.mock('@/lib/workspace/creation/new-workspace', () => ({
CLIENT_PLATFORM: 'win32'
}))
diff --git a/src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-local-wsl.ts b/src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-local-wsl.ts
index 16941accf74..82323057e72 100644
--- a/src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-local-wsl.ts
+++ b/src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-local-wsl.ts
@@ -1,5 +1,5 @@
import { getLocalProjectExecutionRuntimeContext } from '@/lib/local-preflight-context'
-import { CLIENT_PLATFORM } from '@/lib/new-workspace'
+import { CLIENT_PLATFORM } from '@/lib/workspace/creation/new-workspace'
import type { useAppStore } from '@/store/index'
import { isWindowsAbsolutePathLike } from '../../../../../../shared/cross-platform-path'
import { parseWslUncPath } from '../../../../../../shared/wsl-paths'
diff --git a/src/renderer/src/components/terminal-pane/parking/output-watchers/parked-terminal-command-status.ts b/src/renderer/src/components/terminal-pane/parking/output-watchers/parked-terminal-command-status.ts
index 1e38c1ef0fc..3c8dd072f58 100644
--- a/src/renderer/src/components/terminal-pane/parking/output-watchers/parked-terminal-command-status.ts
+++ b/src/renderer/src/components/terminal-pane/parking/output-watchers/parked-terminal-command-status.ts
@@ -6,7 +6,7 @@ import { isShellProcess } from '../../../../../../shared/agent-status/process/sh
import { dispatchTerminalCommandFinishedEvent } from '@/hooks/terminal-command-finished-event'
import { resolveLiveAgentStatusConnectionRouting } from '@/lib/agent-status/ownership/agent-status-connection-ownership'
import { getConnectionIdFromState } from '@/lib/workspace/ownership/connection-owner-resolution'
-import { rendererAgentStatusObservations } from '@/lib/renderer-agent-status-observations'
+import { rendererAgentStatusObservations } from '@/lib/agent-status/evidence/renderer-agent-status-observations'
import { isRetainedProgramResult } from '@/lib/program-status/row'
import { useAppStore } from '@/store/index'
import {
diff --git a/src/renderer/src/components/terminal-pane/pty-connection/agent-identity/command-code-pane-status.ts b/src/renderer/src/components/terminal-pane/pty-connection/agent-identity/command-code-pane-status.ts
index 065c9384ce0..fe4b8141520 100644
--- a/src/renderer/src/components/terminal-pane/pty-connection/agent-identity/command-code-pane-status.ts
+++ b/src/renderer/src/components/terminal-pane/pty-connection/agent-identity/command-code-pane-status.ts
@@ -6,7 +6,7 @@ import {
setCommandCodeDoneSettleExecutor
} from '../../agent-completion/command-code/command-code-done-settle'
import { canCommandCodeOutputOwnPane } from '../../agent-completion/command-code/command-code-output-ownership'
-import { rendererAgentStatusObservations } from '@/lib/renderer-agent-status-observations'
+import { rendererAgentStatusObservations } from '@/lib/agent-status/evidence/renderer-agent-status-observations'
export function bindCommandCodeOutputStatus(session: ConnectPanePtySession): void {
session.canApplyCommandCodeOutputStatus = (): boolean => {
diff --git a/src/renderer/src/components/terminal-pane/pty-connection/agent-identity/renderer-owned-pane-status.ts b/src/renderer/src/components/terminal-pane/pty-connection/agent-identity/renderer-owned-pane-status.ts
index 45411a1398c..f606d0df661 100644
--- a/src/renderer/src/components/terminal-pane/pty-connection/agent-identity/renderer-owned-pane-status.ts
+++ b/src/renderer/src/components/terminal-pane/pty-connection/agent-identity/renderer-owned-pane-status.ts
@@ -9,7 +9,7 @@ import {
registerRendererOwnedAgentStatusPane,
resolveRendererOwnedAgentStatusTiming
} from '../../agent-status/renderer-owned-agent-status-registry'
-import { rendererAgentStatusObservations } from '@/lib/renderer-agent-status-observations'
+import { rendererAgentStatusObservations } from '@/lib/agent-status/evidence/renderer-agent-status-observations'
import type { ConnectPanePtySession } from '../connect-pane-pty-session'
export function installRendererOwnedPaneStatus(session: ConnectPanePtySession): void {
diff --git a/src/renderer/src/components/terminal-pane/pty-connection/deferred-cold-restore-and-snapshot.ts b/src/renderer/src/components/terminal-pane/pty-connection/deferred-cold-restore-and-snapshot.ts
index 0c22d59bde5..57e4ffc393c 100644
--- a/src/renderer/src/components/terminal-pane/pty-connection/deferred-cold-restore-and-snapshot.ts
+++ b/src/renderer/src/components/terminal-pane/pty-connection/deferred-cold-restore-and-snapshot.ts
@@ -5,7 +5,7 @@ import { INITIAL_MODE_2031_REPLY_SCAN_STATE } from '../../../../../shared/termin
import { waitForTerminalOutputParsed } from '@/lib/pane-manager/pane-terminal-output-scheduler'
import { executeTerminalStartupCommandPaste } from '../input/paste/terminal-startup-command-paste'
import { resolveTerminalPasteRuntime } from '../input/paste/terminal-paste-runtime'
-import { CLIENT_PLATFORM } from '@/lib/new-workspace'
+import { CLIENT_PLATFORM } from '@/lib/workspace/creation/new-workspace'
import { recordPaneWakeThroughLayoutOwner } from '@/store/terminals/terminal-sleep-layout-owner'
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../../../shared/layout-owner-switch'
diff --git a/src/renderer/src/components/terminal-pane/pty-connection/emulation/native-windows-pane-policy.ts b/src/renderer/src/components/terminal-pane/pty-connection/emulation/native-windows-pane-policy.ts
index 5f8e2de582d..b7d81be037a 100644
--- a/src/renderer/src/components/terminal-pane/pty-connection/emulation/native-windows-pane-policy.ts
+++ b/src/renderer/src/components/terminal-pane/pty-connection/emulation/native-windows-pane-policy.ts
@@ -3,7 +3,7 @@ import {
isLocalNativeWindowsConpty,
resolveWindowsShellOverride
} from '@/lib/pane-manager/windows-pty-compatibility'
-import { CLIENT_PLATFORM } from '@/lib/new-workspace'
+import { CLIENT_PLATFORM } from '@/lib/workspace/creation/new-workspace'
import { resolveLatestAgentDoneStartedAt } from '../notifications/agent-done-started-at'
import type { ConnectPanePtySession } from '../connect-pane-pty-session'
diff --git a/src/renderer/src/components/terminal-pane/pty-connection/output/write-pty-output-to-xterm.ts b/src/renderer/src/components/terminal-pane/pty-connection/output/write-pty-output-to-xterm.ts
index d422d9382bb..b4a3bade7b4 100644
--- a/src/renderer/src/components/terminal-pane/pty-connection/output/write-pty-output-to-xterm.ts
+++ b/src/renderer/src/components/terminal-pane/pty-connection/output/write-pty-output-to-xterm.ts
@@ -4,7 +4,7 @@ import { takeCurrentTerminalDeliveryCredit } from '@/lib/pane-manager/terminal-d
import { nativeWindowsRewriteNeedsFollowupRenderRefresh } from '@/lib/pane-manager/terminal-complex-script'
import { writeTerminalOutput } from '@/lib/pane-manager/pane-terminal-output-scheduler'
import { forceFullViewportPresent } from '@/lib/pane-manager/terminal-render-pause-release'
-import { CLIENT_PLATFORM } from '@/lib/new-workspace'
+import { CLIENT_PLATFORM } from '@/lib/workspace/creation/new-workspace'
import { FOREGROUND_SYNCHRONIZED_FRAME_INTERACTIVE_WINDOW_MS } from './foreground-output-budgets'
import { scanSynchronizedOutput } from '../../../../../../shared/terminal/protocol/escape/terminal-synchronized-output-scan'
diff --git a/src/renderer/src/components/terminal-pane/pty-connection/startup/initial-agent-status.ts b/src/renderer/src/components/terminal-pane/pty-connection/startup/initial-agent-status.ts
index 91fac7a8b19..c13b70f83ad 100644
--- a/src/renderer/src/components/terminal-pane/pty-connection/startup/initial-agent-status.ts
+++ b/src/renderer/src/components/terminal-pane/pty-connection/startup/initial-agent-status.ts
@@ -1,6 +1,6 @@
import { useAppStore } from '@/store'
import { resolveCompatibleAgentTypeForOwner } from '../../../../../../shared/agent-status/title/agent-title-owner'
-import { rendererAgentStatusObservations } from '@/lib/renderer-agent-status-observations'
+import { rendererAgentStatusObservations } from '@/lib/agent-status/evidence/renderer-agent-status-observations'
import type { ConnectPanePtySession } from '../connect-pane-pty-session'
export function bindInitialAgentStatus(session: ConnectPanePtySession): void {
diff --git a/src/renderer/src/components/terminal-pane/pty-connection/test-fixtures/pty-connection-test-environment.ts b/src/renderer/src/components/terminal-pane/pty-connection/test-fixtures/pty-connection-test-environment.ts
index 2d53abce03a..9a9dae38d5f 100644
--- a/src/renderer/src/components/terminal-pane/pty-connection/test-fixtures/pty-connection-test-environment.ts
+++ b/src/renderer/src/components/terminal-pane/pty-connection/test-fixtures/pty-connection-test-environment.ts
@@ -192,7 +192,7 @@ async function resetSharedTerminalModuleState(): Promise {
import('@/lib/pane-manager/pane-terminal-output-queue-registry'),
import('@/lib/agent-session/launch/startup/agent-startup-delayed-delivery'),
import('@/lib/agent-session/launch/startup/agent-startup-delivery-guards'),
- import('@/lib/hook-command-delayed-delivery'),
+ import('@/lib/workspace/creation/setup/hook-command-delayed-delivery'),
import('../../agent-completion/agent-completion-identity-store'),
import('../../agent-completion/command-code/command-code-done-settle'),
import('../../agent-completion/process-inspection/agent-process-inspection-queue'),
diff --git a/src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/remote-runtime-pty-transport.ts b/src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/remote-runtime-pty-transport.ts
index 84ff3ef267c..faefc6be092 100644
--- a/src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/remote-runtime-pty-transport.ts
+++ b/src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/remote-runtime-pty-transport.ts
@@ -1,7 +1,7 @@
import type { TerminalOutputCadence } from '../../../../../../shared/terminal/stream/terminal-multiplex-flow-control'
import { lastVerifiedRuntimeStatus } from '../../../../../../shared/remote-runtime/host-status/runtime-host-status'
import { webTerminalPlacementParentTabId } from '@/runtime/hosted-terminals/placement/web-session-terminal-placement'
-import { pairedAgentLaunchInputs } from '@/lib/paired-agent-launch-inputs'
+import { pairedAgentLaunchInputs } from '@/lib/agent-session/launch/routing/paired-agent-launch-inputs'
import {
agentSessionCreateCapabilities,
agentSessionCreateRequest,
@@ -3942,7 +3942,7 @@ export function createRemoteRuntimePtyTransport(
.catch(() => false)
.then(async (promptDelivered) => {
const { completeWebHostAgentLaunch } =
- await import('@/lib/web-host-agent-launch-completion')
+ await import('@/lib/agent-session/launch/new-tab/web-host-agent-launch-completion')
completeWebHostAgentLaunch({
agent: launchAgentToSend,
worktreeId,
diff --git a/src/renderer/src/components/terminal-pane/session-fork/terminal-agent-session-fork.ts b/src/renderer/src/components/terminal-pane/session-fork/terminal-agent-session-fork.ts
index fb1282278bc..df5d16cfe1c 100644
--- a/src/renderer/src/components/terminal-pane/session-fork/terminal-agent-session-fork.ts
+++ b/src/renderer/src/components/terminal-pane/session-fork/terminal-agent-session-fork.ts
@@ -2,7 +2,7 @@ import { toast } from 'sonner'
import type { ManagedPane } from '@/lib/pane-manager/pane-manager-types'
import { launchAgentInNewTab } from '@/lib/agent-session/launch/new-tab/launch-agent-in-new-tab'
import { settleAgentTabLaunch } from '@/lib/agent-session/launch/new-tab/launch-agent-in-new-tab-host-agents'
-import { newAgentPromptOutcome } from '@/lib/new-agent-prompt-outcome'
+import { newAgentPromptOutcome } from '@/lib/agent-session/launch/prompt/new-agent-prompt-outcome'
import { buildAgentSessionForkPrompt } from '@/lib/agent-session/context/agent-session-fork-context'
import { activateAndRevealWorktree } from '@/lib/workspace/activation/worktree-activation'
import { resolveOwner } from '@/lib/workspace/ownership/resolve-owner'
diff --git a/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx b/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx
index 7c9f79b5e7d..38d8aecbe46 100644
--- a/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx
+++ b/src/renderer/src/components/worktree-creation/VmBuildSheet.tsx
@@ -2,7 +2,7 @@ import React from 'react'
import { AlertTriangle, Loader2 } from 'lucide-react'
import { cn } from '@/lib/utils'
import { useTranslate, type Translate } from '@/i18n/use-translate'
-import { resolveVmEnvironmentCheckDecision } from '@/lib/ephemeral-vm-environment-check-decision'
+import { resolveVmEnvironmentCheckDecision } from '@/runtime/ephemeral-vm/ephemeral-vm-environment-check-decision'
import type { PendingWorktreeCreation } from '@/lib/workspace/creation/pending-worktree-creation'
import { toast } from 'sonner'
import type { EnvironmentSetupFailureContext } from '../../../../shared/environment-setup-agent-prompt'
@@ -45,7 +45,7 @@ function startFixWithAgent(args: {
recipeId: string
failure: EnvironmentSetupFailureContext
}): void {
- void import('@/lib/environment-setup-agent-launch')
+ void import('@/lib/agent-session/launch/environment-setup-agent-launch')
.then(({ launchEnvironmentSetupAgent }) => launchEnvironmentSetupAgent(args))
.catch((launchError: unknown) => {
toast.error(launchError instanceof Error ? launchError.message : String(launchError))
diff --git a/src/renderer/src/components/worktree-jump/WorktreeJumpPalette.linear-url.test.tsx b/src/renderer/src/components/worktree-jump/WorktreeJumpPalette.linear-url.test.tsx
index df237706840..99bf66b8035 100644
--- a/src/renderer/src/components/worktree-jump/WorktreeJumpPalette.linear-url.test.tsx
+++ b/src/renderer/src/components/worktree-jump/WorktreeJumpPalette.linear-url.test.tsx
@@ -2,7 +2,7 @@ import { linearIssueReadFixture } from '@/store/slices/linear/linear-slice-test-
// @vitest-environment happy-dom
import { act } from 'react'
-import { flushSync } from 'react-dom'
+
import { createRoot, type Root } from 'react-dom/client'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type * as ReactI18Next from 'react-i18next'
@@ -10,9 +10,6 @@ import { useAppStore } from '@/store/index'
import type { AppState } from '@/store/types'
import type { LinearIssue } from '../../../../shared/linear/issue-types'
-import type { Repo } from '../../../../shared/repo-types'
-import { projectHostSetupProjectionFromRepos } from '../../../../shared/project-host-setup-projection'
-import { resolveWorkspaceCreationTarget } from '@/lib/project-host-workspace-target'
import WorktreeJumpPalette from './WorktreeJumpPalette'
import { makeRecentTabState, makeRepo } from './worktree-jump-palette-test-fixtures'
@@ -211,12 +208,6 @@ async function renderPalette(overrides: Partial): Promise {
await flushEffects()
}
-function getCommandValue(): string {
- return (
- testContainer.querySelector('[data-command-dialog]')?.dataset.commandValue ?? ''
- )
-}
-
describe('WorktreeJumpPalette Linear URL intent', () => {
beforeEach(() => {
globalThis.IS_REACT_ACT_ENVIRONMENT = true
@@ -283,71 +274,6 @@ describe('WorktreeJumpPalette Linear URL intent', () => {
})
})
- it('keeps runtime folder projects as the Linear lookup and composer owner', async () => {
- const folderRepo: Repo = {
- ...makeRepo(),
- id: 'folder-repo',
- kind: 'folder' as const,
- executionHostId: 'runtime:folder-env'
- }
- const fetchLinearIssue = vi.fn(() =>
- linearIssueReadFixture(async () => makeLinearIssue())
- )
- const prefetchWorktreeCreateBase = vi.fn(async () => {})
- await renderPalette({
- activeRepoId: folderRepo.id,
- repos: [folderRepo],
- fetchLinearIssue,
- prefetchWorktreeCreateBase
- })
- await act(async () => setCommandQuery?.(LINEAR_URL))
- await flushEffects()
-
- expect(fetchLinearIssue).toHaveBeenCalledWith(
- 'STA-4084',
- 'linear-workspace-1',
- expect.objectContaining({
- sourceContext: expect.objectContaining({
- provider: 'linear',
- projectId: 'repo:folder-repo',
- projectHostSetupId: 'folder-repo',
- repoId: 'folder-repo',
- hostId: 'runtime:folder-env'
- })
- })
- )
-
- await act(async () => {
- testContainer.querySelector('[data-command-item="__create_worktree__"]')?.click()
- await Promise.resolve()
- })
- await flushEffects()
-
- expect(useAppStore.getState().modalData).toMatchObject({
- initialRepoId: 'folder-repo',
- taskSourceContext: {
- provider: 'linear',
- projectId: 'repo:folder-repo',
- projectHostSetupId: 'folder-repo',
- repoId: 'folder-repo',
- hostId: 'runtime:folder-env'
- }
- })
- const projection = projectHostSetupProjectionFromRepos([folderRepo])
- expect(
- resolveWorkspaceCreationTarget({
- eligibleRepos: [folderRepo],
- projects: projection.projects,
- projectHostSetups: projection.setups,
- initialRepoId: 'folder-repo',
- projectId: 'repo:folder-repo',
- hostId: 'runtime:folder-env',
- projectHostSetupId: 'folder-repo'
- })
- ).toMatchObject({ status: 'ready', target: { repoId: 'folder-repo' } })
- expect(prefetchWorktreeCreateBase).not.toHaveBeenCalled()
- })
-
it('does not open the composer after the palette closes during lookup', async () => {
const issueLookup = deferredValue()
await renderPalette({
@@ -409,63 +335,4 @@ describe('WorktreeJumpPalette Linear URL intent', () => {
linkedWorkItem: { linearIdentifier: 'STA-4099', title: 'Current second issue' }
})
})
-
- it('does not let a stale lookup replace a newer URL preview', async () => {
- const firstLookup = deferredValue()
- const secondLookup = deferredValue()
- await renderPalette({
- fetchLinearIssue: vi.fn((identifier: string) =>
- linearIssueReadFixture(() =>
- identifier === 'STA-4084' ? firstLookup.promise : secondLookup.promise
- )
- )
- })
-
- vi.useFakeTimers()
- await act(async () => setCommandQuery?.('https://linear.app/stably/issue/STA-4084/first'))
- await flushEffects()
- await act(async () => {
- await vi.advanceTimersByTimeAsync(200)
- })
- expect(testContainer.textContent).toContain('Loading Linear issue…')
-
- await act(async () => {
- flushSync(() => setCommandQuery?.('https://linear.app/stably/issue/STA-4099/second'))
- const currentPendingRow = testContainer.querySelector(
- '[data-cmd-j-linear-issue-preview="true"]'
- )
- expect(currentPendingRow?.getAttribute('aria-label')).toBe(
- 'Create worktree from Linear issue STA-4099'
- )
- expect(currentPendingRow?.textContent).toContain('Create worktree from Linear issue')
- expect(currentPendingRow?.textContent).not.toContain('Loading Linear issue…')
- })
- await flushEffects()
-
- await act(async () => {
- firstLookup.resolve(makeLinearIssue({ title: 'Stale first issue' }))
- await firstLookup.promise
- })
- await flushEffects()
-
- expect(testContainer.textContent).toContain('STA-4099')
- expect(testContainer.textContent).not.toContain('Stale first issue')
-
- await act(async () => {
- secondLookup.resolve(
- makeLinearIssue({
- id: 'issue-sta-4099',
- identifier: 'STA-4099',
- title: 'Current second issue',
- url: 'https://linear.app/stably/issue/STA-4099/current-second-issue'
- })
- )
- await secondLookup.promise
- })
- await flushEffects()
-
- expect(testContainer.textContent).toContain('Current second issue')
- expect(testContainer.textContent).not.toContain('Stale first issue')
- expect(getCommandValue()).toBe('__create_worktree__')
- })
})
diff --git a/src/renderer/src/components/worktree-jump/use-worktree-jump-palette-quick-actions.ts b/src/renderer/src/components/worktree-jump/use-worktree-jump-palette-quick-actions.ts
index 74641f3c290..d0ee8be3a8c 100644
--- a/src/renderer/src/components/worktree-jump/use-worktree-jump-palette-quick-actions.ts
+++ b/src/renderer/src/components/worktree-jump/use-worktree-jump-palette-quick-actions.ts
@@ -13,10 +13,10 @@ import { buildCmdJBrowserNavigationAction } from '@/components/cmd-j/browser-nav
import { openWorkspaceBrowserTab } from '@/lib/browser/workspace/workspace-browser-tab-open'
import { findGroupAndWorktree } from '@/store/slices/tabs/tab-group-state'
import {
- getComposerEligibleRepos,
- resolveComposerActiveRepoId,
- resolveComposerGitRepoId
-} from '@/lib/new-workspace-composer-repo'
+ getNewWorkspaceDialogEligibleRepos,
+ resolveNewWorkspaceDialogGitRepoId
+} from '../../../../shared/new-workspace-dialog-repo'
+import { resolveComposerActiveRepoId } from '@/lib/workspace/creation/new-workspace-composer-repo'
import type { QuickActionPaletteItem, SettingsPaletteItem } from './worktree-jump-palette-model'
import type { WorktreeJumpPaletteLocalState } from './use-worktree-jump-palette-local-state'
import type { WorktreeJumpPaletteOpenTabs } from './use-worktree-jump-palette-open-tabs'
@@ -30,8 +30,8 @@ function getComposerPrefetchRepoId(
state: ReturnType,
initialRepoId?: string
): string | null {
- const eligibleRepos = getComposerEligibleRepos(state.repos)
- return resolveComposerGitRepoId({
+ const eligibleRepos = getNewWorkspaceDialogEligibleRepos(state.repos)
+ return resolveNewWorkspaceDialogGitRepoId({
eligibleRepos,
initialRepoId,
activeRepoId: resolveComposerActiveRepoId(
diff --git a/src/renderer/src/components/worktree-jump/use-worktree-jump-palette-store-state.ts b/src/renderer/src/components/worktree-jump/use-worktree-jump-palette-store-state.ts
index fb5113b520b..1e46542fe57 100644
--- a/src/renderer/src/components/worktree-jump/use-worktree-jump-palette-store-state.ts
+++ b/src/renderer/src/components/worktree-jump/use-worktree-jump-palette-store-state.ts
@@ -10,7 +10,7 @@ import {
readHiddenVmCheckouts,
subscribeHiddenVmCheckouts,
withoutHiddenVmWorktreesByRepo
-} from '@/lib/vm-create-hidden-checkouts'
+} from '@/runtime/ephemeral-vm/vm-create-hidden-checkouts'
import {
selectPaletteIndexStatusSnapshot,
selectPaletteStatusInputs
diff --git a/src/renderer/src/components/worktree-jump/use-worktree-jump-palette-task-url.ts b/src/renderer/src/components/worktree-jump/use-worktree-jump-palette-task-url.ts
index 871fd719a28..ea8cb1c2b14 100644
--- a/src/renderer/src/components/worktree-jump/use-worktree-jump-palette-task-url.ts
+++ b/src/renderer/src/components/worktree-jump/use-worktree-jump-palette-task-url.ts
@@ -7,11 +7,9 @@ import {
} from '@/store/slices/linear/linear-issue-read-lifecycle'
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
import { useAppStore } from '@/store/index'
-import {
- getComposerEligibleRepos,
- resolveComposerActiveRepoId
-} from '@/lib/new-workspace-composer-repo'
-import { resolveWorkspaceCreationTarget } from '@/lib/project-host-workspace-target'
+import { getNewWorkspaceDialogEligibleRepos } from '../../../../shared/new-workspace-dialog-repo'
+import { resolveComposerActiveRepoId } from '@/lib/workspace/creation/new-workspace-composer-repo'
+import { resolveWorkspaceCreationTarget } from '@/lib/workspace/creation/project-host-workspace-target'
import { lookupCmdJGitHubUrlWorkItem } from '@/lib/cmd-j-github-url-lookup'
import { lookupLinearIssueUrl } from '@/lib/work-items/linear/linear-issue-url-lookup'
import {
@@ -43,7 +41,7 @@ export type CmdJGitHubWorkItemPreview = {
/** The target New workspace would default to, used to scope task-link lookups to the same checkout. */
function getComposerDefaultWorkspaceTarget(state: ReturnType) {
- const eligibleRepos = getComposerEligibleRepos(state.repos)
+ const eligibleRepos = getNewWorkspaceDialogEligibleRepos(state.repos)
const activeRepoId = resolveComposerActiveRepoId(
state.repos,
eligibleRepos,
diff --git a/src/renderer/src/components/worktree-jump/worktree-jump-palette-create-worktree.ts b/src/renderer/src/components/worktree-jump/worktree-jump-palette-create-worktree.ts
index b6ac24150d0..8bbe8c86e3c 100644
--- a/src/renderer/src/components/worktree-jump/worktree-jump-palette-create-worktree.ts
+++ b/src/renderer/src/components/worktree-jump/worktree-jump-palette-create-worktree.ts
@@ -9,7 +9,7 @@ import {
getLinkedWorkItemSuggestedName,
getLinkedWorkItemWorkspaceName
} from '../../../../shared/workspace-name'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import type { WorktreeJumpPaletteCreateWorktreeInput } from './worktree-jump-palette-create-worktree-input'
import { lookupGitHubWorkItemForSource } from '@/lib/work-items/github/github-work-item-source-lookup'
import { activateAndRevealWorkspace } from '@/lib/workspace/activation/worktree-activation'
diff --git a/src/renderer/src/hooks/composer-state/async-composer-state.ts b/src/renderer/src/hooks/composer-state/async-composer-state.ts
index 6f0a3a7b735..e2b6ecf958d 100644
--- a/src/renderer/src/hooks/composer-state/async-composer-state.ts
+++ b/src/renderer/src/hooks/composer-state/async-composer-state.ts
@@ -25,7 +25,7 @@ type ComposerAsyncStateInput = Pick<
import { useState, useRef, useEffect, useCallback } from 'react'
import type { OrcaHooks, SetupAgentStartupPolicy } from '../../../../shared/orca-yaml-hook-types'
import type { IssueCommandReadResult } from '@/runtime/repo-hooks/runtime-hooks-client'
-import type { WorkspaceCreateErrorDisplay } from '@/lib/workspace-create-error-format'
+import type { WorkspaceCreateErrorDisplay } from '@/lib/workspace/creation/workspace-create-error-format'
import type { GitHubWorkItem } from '../../../../shared/github/work-item-types'
import { CONTEXTUAL_TOUR_ENABLE_AUTO_WORKSPACE_NAME_EVENT } from '@/components/contextual-tours/contextual-tour-composer-events'
import type { GitHubRepositoryIdentity } from '../../../../shared/github/pull-request-types'
diff --git a/src/renderer/src/hooks/composer-state/async-model.ts b/src/renderer/src/hooks/composer-state/async-model.ts
index 5cab5e84ad9..46dadb1a029 100644
--- a/src/renderer/src/hooks/composer-state/async-model.ts
+++ b/src/renderer/src/hooks/composer-state/async-model.ts
@@ -3,7 +3,7 @@ import type { RefObject } from 'react'
import type { GitHubWorkItem } from '../../../../shared/github/work-item-types'
import type { OrcaHooks, SetupAgentStartupPolicy } from '../../../../shared/orca-yaml-hook-types'
import type { GitHubRepositoryIdentity } from '../../../../shared/github/pull-request-types'
-import type { WorkspaceCreateErrorDisplay } from '@/lib/workspace-create-error-format'
+import type { WorkspaceCreateErrorDisplay } from '@/lib/workspace/creation/workspace-create-error-format'
import type { IssueCommandReadResult } from '@/runtime/repo-hooks/runtime-hooks-client'
import type { SmartSourceSelection } from './source-selection-decisions'
diff --git a/src/renderer/src/hooks/composer-state/composer-agent-rows-target.ts b/src/renderer/src/hooks/composer-state/composer-agent-rows-target.ts
index a91bd7e7f47..32d98ece516 100644
--- a/src/renderer/src/hooks/composer-state/composer-agent-rows-target.ts
+++ b/src/renderer/src/hooks/composer-state/composer-agent-rows-target.ts
@@ -1,4 +1,5 @@
-import { getNewWorkspaceProjectGroupHostId } from '@/lib/new-workspace-project-options'
+import '@/lib/workspace/creation/new-workspace-project-options'
+import { getRepoExecutionHostId } from '../../../../shared/execution-host'
import type { AgentDetectionTarget } from '@/hooks/useDetectedAgents'
import type { AgentMenuRowsTarget } from '@/components/tab-bar/use-new-tab-agent-menu-rows'
import type { ComposerModel } from './composer-model'
@@ -18,7 +19,7 @@ export function resolveComposerAgentRows(state: ComposerModel): ComposerAgentRow
workspace: {
kind: 'folder',
runtimeEnvironmentId: state.folderTargetRuntimeEnvironmentId,
- executionHostId: getNewWorkspaceProjectGroupHostId(group)
+ executionHostId: getRepoExecutionHostId(group)
}
},
detectionTarget: state.folderTargetAgentDetectionTarget
diff --git a/src/renderer/src/hooks/composer-state/composer-card-props.ts b/src/renderer/src/hooks/composer-state/composer-card-props.ts
index 4ee1c9bb6d2..61a47093169 100644
--- a/src/renderer/src/hooks/composer-state/composer-card-props.ts
+++ b/src/renderer/src/hooks/composer-state/composer-card-props.ts
@@ -1,6 +1,6 @@
import { resolveComposerAttachmentTarget } from './composer-attachment-target'
-import { getAttachmentLabel } from '@/lib/new-workspace'
-import { getQuickComposerCreateDisabled } from '@/lib/new-workspace-create-gates'
+import { getAttachmentLabel } from '@/lib/workspace/creation/new-workspace'
+import { getQuickComposerCreateDisabled } from '@/lib/workspace/creation/new-workspace-create-gates'
import type { ComposerModel } from './composer-model'
import { resolveComposerAgentRows } from './composer-agent-rows-target'
import type { ComposerCardActionProps, ComposerCardSourceProps } from './composer-card-contract'
diff --git a/src/renderer/src/hooks/composer-state/composer-decisions.ts b/src/renderer/src/hooks/composer-state/composer-decisions.ts
index 22a77290216..8074d655cd3 100644
--- a/src/renderer/src/hooks/composer-state/composer-decisions.ts
+++ b/src/renderer/src/hooks/composer-state/composer-decisions.ts
@@ -14,9 +14,9 @@ import type { GitHubWorkItem } from '../../../../shared/github/work-item-types'
import type { TaskSourceContext } from '../../../../shared/work-items/task-source-context'
import type { JiraIssueKeyCasing } from '../../../../shared/ui-chrome-types'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
-import type { WorkspaceCreationTargetHint } from '@/lib/project-host-workspace-target'
+import type { WorkspaceCreationTargetHint } from '@/lib/workspace/creation/project-host-workspace-target'
export type ComposerDecisions = {
canResolveFolderSmartGitHubSubmit: (input: { hasFolderSourceRepos: boolean }) => boolean
diff --git a/src/renderer/src/hooks/composer-state/composer-submit-model.ts b/src/renderer/src/hooks/composer-state/composer-submit-model.ts
index 4d699d85f81..3f33a40b973 100644
--- a/src/renderer/src/hooks/composer-state/composer-submit-model.ts
+++ b/src/renderer/src/hooks/composer-state/composer-submit-model.ts
@@ -3,9 +3,9 @@ import type { QuickSubmitOptions } from './quick-creation-request'
import type { GitPushTarget } from '../../../../shared/worktree/types'
import type { SetupDecision } from '../../../../shared/worktree/create-types'
import type { WorkspaceIntentName } from '../../../../shared/workspace-name'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import type { WorktreeCreationRequest } from '@/lib/workspace/creation/pending-worktree-creation'
-import type { ComposerCreateHandoff } from '@/lib/composer-create-handoff'
+import type { ComposerCreateHandoff } from '@/lib/workspace/creation/composer-create-handoff'
import type { PendingSmartGitHubSubmitResolution } from './source-selection-decisions'
type SmartCreateNames = {
diff --git a/src/renderer/src/hooks/composer-state/composer-target-store.ts b/src/renderer/src/hooks/composer-state/composer-target-store.ts
index 7379256e081..18e96c7eca6 100644
--- a/src/renderer/src/hooks/composer-state/composer-target-store.ts
+++ b/src/renderer/src/hooks/composer-state/composer-target-store.ts
@@ -1,19 +1,17 @@
import { useMemo } from 'react'
import { useAppStore } from '@/store'
import { useShallow } from 'zustand/react/shallow'
-import {
- getComposerEligibleRepos,
- resolveComposerActiveRepoId
-} from '@/lib/new-workspace-composer-repo'
+import { getNewWorkspaceDialogEligibleRepos } from '../../../../shared/new-workspace-dialog-repo'
+import { resolveComposerActiveRepoId } from '@/lib/workspace/creation/new-workspace-composer-repo'
import { buildExecutionHostRegistry } from '../../../../shared/execution-host/execution-host-registry'
import { getHostDisplayLabelOverrides } from '../../../../shared/host-setting-overrides'
import type { GitHubWorkItem } from '../../../../shared/github/work-item-types'
import type { TaskSourceContext } from '../../../../shared/work-items/task-source-context'
import type { WorkspaceStatus } from '../../../../shared/worktree/types'
import type { WorkspaceSource as WorkspaceCreateTelemetrySource } from '../../../../shared/workspace-source'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import type { ComposerDecisions } from './composer-decisions'
-import type { WorkspaceCreationTargetHint } from '@/lib/project-host-workspace-target'
+import type { WorkspaceCreationTargetHint } from '@/lib/workspace/creation/project-host-workspace-target'
import { selectWorktreesByRepo } from '@/store/workspaces/catalog/workspace-record-fields'
import { selectAllKnownWorkspaceStatuses } from '@/store/workspaces/status/host-workspace-status-columns'
@@ -129,7 +127,7 @@ export function useComposerTargetStore(options: ComposerStateInput, decisions: C
const workspaceHostScope = useAppStore((s) => s.workspaceHostScope)
- const eligibleRepos = useMemo(() => getComposerEligibleRepos(repos), [repos])
+ const eligibleRepos = useMemo(() => getNewWorkspaceDialogEligibleRepos(repos), [repos])
const hostOptions = useMemo(
() =>
diff --git a/src/renderer/src/hooks/composer-state/derived-composer-state.ts b/src/renderer/src/hooks/composer-state/derived-composer-state.ts
index 1cc8bfba767..fb090a8bb25 100644
--- a/src/renderer/src/hooks/composer-state/derived-composer-state.ts
+++ b/src/renderer/src/hooks/composer-state/derived-composer-state.ts
@@ -14,7 +14,7 @@ import {
getWorkspaceSeedName,
DEFAULT_ISSUE_COMMAND_TEMPLATE,
renderIssueCommandTemplate
-} from '@/lib/new-workspace'
+} from '@/lib/workspace/creation/new-workspace'
import { getSetupConfig } from '../../../../shared/orca-hook-setup-config'
import { deriveWorkspaceSetupState } from '@/lib/workspace/creation/setup/workspace-setup-preparation'
import type { SparsePreset } from '../../../../shared/worktree/create-types'
diff --git a/src/renderer/src/hooks/composer-state/folder-submit-orchestration.ts b/src/renderer/src/hooks/composer-state/folder-submit-orchestration.ts
index 67f16e1d570..6d04c1357c0 100644
--- a/src/renderer/src/hooks/composer-state/folder-submit-orchestration.ts
+++ b/src/renderer/src/hooks/composer-state/folder-submit-orchestration.ts
@@ -29,14 +29,14 @@ type FolderSubmitOrchestrationInput = Pick<
import { useCallback } from 'react'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
-import { settleComposerSubmit } from '@/lib/composer-submit-cancellation'
+import { settleComposerSubmit } from '@/lib/workspace/creation/composer-submit-cancellation'
import { isTuiAgentEnabled } from '../../../../shared/agent-launch/catalog/tui-agent-selection'
import { submitFolderWorkspaceCreate } from '@/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit'
import { translate } from '@/i18n/i18n'
import {
formatWorkspaceCreateError,
getWorkspaceCreateErrorToastMessage
-} from '@/lib/workspace-create-error-format'
+} from '@/lib/workspace/creation/workspace-create-error-format'
import { toast } from 'sonner'
export function useFolderSubmitOrchestration(input: FolderSubmitOrchestrationInput) {
diff --git a/src/renderer/src/hooks/composer-state/github-source-application.ts b/src/renderer/src/hooks/composer-state/github-source-application.ts
index 5466ae958a8..0036ab809f0 100644
--- a/src/renderer/src/hooks/composer-state/github-source-application.ts
+++ b/src/renderer/src/hooks/composer-state/github-source-application.ts
@@ -21,7 +21,11 @@ type GitHubSourceApplicationInput = Pick<
import { useCallback } from 'react'
import type { GitHubWorkItem } from '../../../../shared/github/work-item-types'
import { resolveGitHubWorkItemIdentity } from '../../../../shared/new-workspace/github-work-item-identity'
-import { getLinkedWorkItemWorkspaceName, getLinkedWorkItemSuggestedName } from '@/lib/new-workspace'
+import '@/lib/workspace/creation/new-workspace'
+import {
+ getLinkedWorkItemWorkspaceName,
+ getLinkedWorkItemSuggestedName
+} from '../../../../shared/workspace-name'
import { shouldApplyWorkspaceSourceAutoName } from '../../../../shared/new-workspace/workspace-source'
export function useGitHubSourceApplication(input: GitHubSourceApplicationInput) {
diff --git a/src/renderer/src/hooks/composer-state/host-runtime-effects.ts b/src/renderer/src/hooks/composer-state/host-runtime-effects.ts
index 43c74065ecc..725d9e02ede 100644
--- a/src/renderer/src/hooks/composer-state/host-runtime-effects.ts
+++ b/src/renderer/src/hooks/composer-state/host-runtime-effects.ts
@@ -37,7 +37,8 @@ import {
} from '../../../../shared/agent-launch/catalog/tui-agent-selection'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import { useAppStore } from '@/store'
-import { isSshConnectInProgress } from '@/lib/new-workspace-ssh-gate'
+import '@/lib/workspace/creation/new-workspace-ssh-gate'
+import { isConnectingSshStatus } from '@/ssh/ssh-connection-recoverability'
import {
connectRepoSshConnection,
getRepoSshConnection,
@@ -160,7 +161,7 @@ export function useHostRuntimeEffects(input: HostRuntimeEffectsInput) {
return
}
const liveStatus = selectRepoSshGateInput(liveState, liveRepo).status
- if (liveStatus === 'connected' || isSshConnectInProgress(liveStatus)) {
+ if (liveStatus === 'connected' || isConnectingSshStatus(liveStatus)) {
return
}
@@ -182,7 +183,7 @@ export function useHostRuntimeEffects(input: HostRuntimeEffectsInput) {
const liveStatus = useAppStore
.getState()
.sshConnectionStates.get(folderTargetConnectionId)?.status
- if (liveStatus === 'connected' || isSshConnectInProgress(liveStatus ?? null)) {
+ if (liveStatus === 'connected' || isConnectingSshStatus(liveStatus ?? null)) {
return
}
try {
diff --git a/src/renderer/src/hooks/composer-state/initial-target-model.ts b/src/renderer/src/hooks/composer-state/initial-target-model.ts
index 880e583608d..03cf354d843 100644
--- a/src/renderer/src/hooks/composer-state/initial-target-model.ts
+++ b/src/renderer/src/hooks/composer-state/initial-target-model.ts
@@ -3,7 +3,7 @@ import type { RefObject } from 'react'
import type { ExecutionHostId } from '../../../../shared/execution-host'
import type { ProjectGroup } from '../../../../shared/project-group-types'
import type { WorkspaceStatus } from '../../../../shared/worktree/types'
-import type { WorkspaceCreationTargetResolution } from '@/lib/project-host-workspace-target'
+import type { WorkspaceCreationTargetResolution } from '@/lib/workspace/creation/project-host-workspace-target'
export type ComposerInitialTargetModel = {
draftRepoId: string | null
diff --git a/src/renderer/src/hooks/composer-state/initial-target-state.ts b/src/renderer/src/hooks/composer-state/initial-target-state.ts
index 38eeb80d51e..889ddd33f53 100644
--- a/src/renderer/src/hooks/composer-state/initial-target-state.ts
+++ b/src/renderer/src/hooks/composer-state/initial-target-state.ts
@@ -24,8 +24,8 @@ type ComposerInitialTargetStateInput = Pick<
import { useEffect, useMemo, useRef, useState } from 'react'
import { isWorkspaceStatusId } from '../../../../shared/workspace-statuses'
-import { resolveWorkspaceCreationTarget } from '@/lib/project-host-workspace-target'
-import { findActionableFolderProjectGroup } from '@/lib/new-workspace-project-options'
+import { resolveWorkspaceCreationTarget } from '@/lib/workspace/creation/project-host-workspace-target'
+import { findActionableFolderProjectGroup } from '@/lib/workspace/creation/new-workspace-project-options'
import type { ProjectGroup } from '../../../../shared/project-group-types'
export function useComposerInitialTargetState(input: ComposerInitialTargetStateInput) {
diff --git a/src/renderer/src/hooks/composer-state/issue-source-actions.ts b/src/renderer/src/hooks/composer-state/issue-source-actions.ts
index 184b457bcfd..073656a6438 100644
--- a/src/renderer/src/hooks/composer-state/issue-source-actions.ts
+++ b/src/renderer/src/hooks/composer-state/issue-source-actions.ts
@@ -51,11 +51,12 @@ import {
} from '@/lib/work-items/linear/linear-linked-work-item'
import { getLinearIssueWorkspaceName } from '../../../../shared/workspace-name'
import { getJiraIssueKeyCasingSeedOptions } from '@/lib/work-items/jira/jira-issue-key-casing'
+import '@/lib/workspace/creation/new-workspace'
import {
getLinkedWorkItemSuggestedName,
- getLinkedWorkItemWorkspaceName,
- type LinkedWorkItemSummary
-} from '@/lib/new-workspace'
+ getLinkedWorkItemWorkspaceName
+} from '../../../../shared/workspace-name'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import type { SmartWorkspaceNameSelection } from '@/components/new-workspace/smart-workspace-name-field-model'
import type { TaskSourceContext } from '../../../../shared/work-items/task-source-context'
diff --git a/src/renderer/src/hooks/composer-state/linked-item-lookup-effects.ts b/src/renderer/src/hooks/composer-state/linked-item-lookup-effects.ts
index 09193a23314..c398def2c2c 100644
--- a/src/renderer/src/hooks/composer-state/linked-item-lookup-effects.ts
+++ b/src/renderer/src/hooks/composer-state/linked-item-lookup-effects.ts
@@ -26,7 +26,7 @@ type LinkedItemLookupEffectsInput = Pick<
| 'sshConnectedGeneration'
>
-import { canUseRepoBackedComposerSources } from '@/lib/new-workspace-ssh-gate'
+import { canUseRepoBackedComposerSources } from '@/lib/workspace/creation/new-workspace-ssh-gate'
import { useEffect } from 'react'
import { PER_REPO_FETCH_LIMIT } from '../../../../shared/work-items/work-item-pagination'
import { getDefaultSetupDecision } from '../../../../shared/orca-hook-setup-config'
diff --git a/src/renderer/src/hooks/composer-state/project-target-actions.ts b/src/renderer/src/hooks/composer-state/project-target-actions.ts
index c76f9e9aa41..4e47479087c 100644
--- a/src/renderer/src/hooks/composer-state/project-target-actions.ts
+++ b/src/renderer/src/hooks/composer-state/project-target-actions.ts
@@ -49,10 +49,10 @@ import {
getProjectGroupIdFromNewWorkspaceOptionId,
getProjectRowHostSetups,
findActionableFolderProjectGroup
-} from '@/lib/new-workspace-project-options'
+} from '@/lib/workspace/creation/new-workspace-project-options'
import { translate } from '@/i18n/i18n'
import { getFolderSourceRepos } from '@/components/sidebar/workspace-creation/folder/folder-workspace-source-repos'
-import { resolveWorkspaceCreationRepoId } from '@/lib/project-host-workspace-target'
+import { resolveWorkspaceCreationRepoId } from '@/lib/workspace/creation/project-host-workspace-target'
export function useProjectTargetActions(input: ProjectTargetActionsInput) {
const {
diff --git a/src/renderer/src/hooks/composer-state/quick-creation-execution.ts b/src/renderer/src/hooks/composer-state/quick-creation-execution.ts
index e1bf359ae58..b752a058156 100644
--- a/src/renderer/src/hooks/composer-state/quick-creation-execution.ts
+++ b/src/renderer/src/hooks/composer-state/quick-creation-execution.ts
@@ -6,9 +6,9 @@ import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent
import type { WorktreeCreationRequest } from '@/lib/workspace/creation/pending-worktree-creation'
import { useAppStore } from '@/store'
import { isWorkspaceStatusAllowedOnHost } from '@/store/workspaces/status/host-workspace-status-columns'
-import { settleComposerSubmit } from '@/lib/composer-submit-cancellation'
+import { settleComposerSubmit } from '@/lib/workspace/creation/composer-submit-cancellation'
import { runBackgroundWorktreeCreation } from '@/lib/workspace/creation/worktree-creation-flow'
-import type { ComposerCreateHandoff } from '@/lib/composer-create-handoff'
+import type { ComposerCreateHandoff } from '@/lib/workspace/creation/composer-create-handoff'
import { translate } from '@/i18n/i18n'
import { prepareQuickComposerStartup } from './quick-startup-plan'
import { buildQuickCreationRequest, type QuickSubmitOptions } from './quick-creation-request'
diff --git a/src/renderer/src/hooks/composer-state/quick-creation-request.ts b/src/renderer/src/hooks/composer-state/quick-creation-request.ts
index dbd6c3abfef..6d765c8d668 100644
--- a/src/renderer/src/hooks/composer-state/quick-creation-request.ts
+++ b/src/renderer/src/hooks/composer-state/quick-creation-request.ts
@@ -1,7 +1,7 @@
import type { AgentStartedTelemetry } from '@/lib/workspace/creation/worktree-startup-payload'
import type { WorktreeCreationRequest } from '@/lib/workspace/creation/pending-worktree-creation'
import type { AgentStartupPlan } from '../../../../shared/agent-launch/startup/tui-agent-startup'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import type { TaskSourceContext } from '../../../../shared/work-items/task-source-context'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
import type { AgentLaunchChoice } from '@/lib/agent-session/launch/routing/agent-menu-selection'
diff --git a/src/renderer/src/hooks/composer-state/quick-submit-action.ts b/src/renderer/src/hooks/composer-state/quick-submit-action.ts
index caa4eb26537..de1f8b57fec 100644
--- a/src/renderer/src/hooks/composer-state/quick-submit-action.ts
+++ b/src/renderer/src/hooks/composer-state/quick-submit-action.ts
@@ -4,14 +4,14 @@ import type { WorktreeCreationRequest } from '@/lib/workspace/creation/pending-w
import type { QuickSubmitOptions } from './quick-creation-request'
import { findPendingLinkedWorkItemCreationId } from '@/lib/workspace/creation/pending-worktree-creation'
import { useAppStore } from '@/store'
-import { getWorkspaceSeedName } from '@/lib/new-workspace'
-import { settleComposerSubmit } from '@/lib/composer-submit-cancellation'
+import { getWorkspaceSeedName } from '@/lib/workspace/creation/new-workspace'
+import { settleComposerSubmit } from '@/lib/workspace/creation/composer-submit-cancellation'
import {
formatWorkspaceCreateError,
getWorkspaceCreateErrorToastMessage
-} from '@/lib/workspace-create-error-format'
+} from '@/lib/workspace/creation/workspace-create-error-format'
import { toast } from 'sonner'
-import { scheduleComposerCreateHandoff } from '@/lib/composer-create-handoff'
+import { scheduleComposerCreateHandoff } from '@/lib/workspace/creation/composer-create-handoff'
import type { ComposerModel } from './composer-model'
diff --git a/src/renderer/src/hooks/composer-state/quick-submit-preparation.ts b/src/renderer/src/hooks/composer-state/quick-submit-preparation.ts
index 36d9bebbade..c9aaaf2b635 100644
--- a/src/renderer/src/hooks/composer-state/quick-submit-preparation.ts
+++ b/src/renderer/src/hooks/composer-state/quick-submit-preparation.ts
@@ -1,9 +1,9 @@
import type { QuickSubmitPreparationInput } from './quick-submit-input-contract'
import { useCallback } from 'react'
-import { settleComposerSubmit } from '@/lib/composer-submit-cancellation'
+import { settleComposerSubmit } from '@/lib/workspace/creation/composer-submit-cancellation'
import { getWorkspaceSourceProvider } from '../../../../shared/new-workspace/workspace-source'
-import { canUseIssueCommandForLinkedItemProvider } from '@/lib/new-workspace'
+import { canUseIssueCommandForLinkedItemProvider } from '@/lib/workspace/creation/new-workspace'
import { getSetupConfig } from '../../../../shared/orca-hook-setup-config'
import {
deriveWorkspaceSetupState,
diff --git a/src/renderer/src/hooks/composer-state/quick-submit-source-preparation.ts b/src/renderer/src/hooks/composer-state/quick-submit-source-preparation.ts
index eba8701beb6..549e7eb2f9b 100644
--- a/src/renderer/src/hooks/composer-state/quick-submit-source-preparation.ts
+++ b/src/renderer/src/hooks/composer-state/quick-submit-source-preparation.ts
@@ -19,7 +19,8 @@ type QuickSubmitSourcePreparationInput = Pick<
import { useCallback } from 'react'
import { isTuiAgentEnabled } from '../../../../shared/agent-launch/catalog/tui-agent-selection'
-import { getLinkedWorkItemWorkspaceName } from '@/lib/new-workspace'
+import '@/lib/workspace/creation/new-workspace'
+import { getLinkedWorkItemWorkspaceName } from '../../../../shared/workspace-name'
import { getJiraIssueKeyCasingSeedOptions } from '@/lib/work-items/jira/jira-issue-key-casing'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
import type { PendingSmartGitHubSubmitResolution } from './source-selection-decisions'
diff --git a/src/renderer/src/hooks/composer-state/runtime-target-model.ts b/src/renderer/src/hooks/composer-state/runtime-target-model.ts
index e6a7f51b8b3..28c02dbed08 100644
--- a/src/renderer/src/hooks/composer-state/runtime-target-model.ts
+++ b/src/renderer/src/hooks/composer-state/runtime-target-model.ts
@@ -7,9 +7,9 @@ import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent
import type { OrcaVmRecipe } from '../../../../shared/orca-yaml-hook-types'
import type { AgentStartupShell } from '../../../../shared/agent-launch/startup/tui-agent-startup-shell'
import type { ExecutionHostPlatformFact } from '@/runtime/hosts/platform/execution-host-platform-fact'
-import type { NewWorkspaceProjectOption } from '@/lib/new-workspace-project-options'
-import type { ProjectHostSetupOption } from '@/lib/project-host-setup-options'
-import type { WorkspaceCreationTargetResolution } from '@/lib/project-host-workspace-target'
+import type { NewWorkspaceProjectOption } from '@/lib/workspace/creation/new-workspace-project-options'
+import type { ProjectHostSetupOption } from '@/lib/workspace/creation/project-host-setup-options'
+import type { WorkspaceCreationTargetResolution } from '@/lib/workspace/creation/project-host-workspace-target'
export type ComposerRuntimeTargetModel = {
isProjectGroupTarget: boolean
diff --git a/src/renderer/src/hooks/composer-state/runtime-target-selection.ts b/src/renderer/src/hooks/composer-state/runtime-target-selection.ts
index c2fa25817ac..b7416acee21 100644
--- a/src/renderer/src/hooks/composer-state/runtime-target-selection.ts
+++ b/src/renderer/src/hooks/composer-state/runtime-target-selection.ts
@@ -4,14 +4,14 @@ import type { ComposerRuntimeTargetSelectionInput } from './composer-target-inpu
import { useEffect, useMemo, useRef } from 'react'
import { getFolderSourceRepos } from '@/components/sidebar/workspace-creation/folder/folder-workspace-source-repos'
import { parseExecutionHostId, getRepoExecutionHostId } from '../../../../shared/execution-host'
-import { getSelectedRepoSshGate } from '@/lib/new-workspace-ssh-gate'
+import { getSelectedRepoSshGate } from '@/lib/workspace/creation/new-workspace-ssh-gate'
import { selectRepoSshGateInput } from '@/lib/repo-ssh-connection'
import { useFolderWorkspaceComposerPathStatus } from '@/components/sidebar/workspace-creation/folder/folder-workspace-composer-path-status'
import { useDetectedAgents } from '@/hooks/useDetectedAgents'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
-import { resolveWorkspaceCreationTarget } from '@/lib/project-host-workspace-target'
+import { resolveWorkspaceCreationTarget } from '@/lib/workspace/creation/project-host-workspace-target'
import { isGitRepoKind } from '../../../../shared/repo-kind'
-import { CLIENT_PLATFORM } from '@/lib/new-workspace'
+import { CLIENT_PLATFORM } from '@/lib/workspace/creation/new-workspace'
import { getLocalRepoProjectExecutionRuntimeContext } from '@/lib/local-preflight-context'
import {
resolveExecutionHostAgentStartupShell,
@@ -20,8 +20,8 @@ import {
import type { ExecutionHostPlatformFact } from '@/runtime/hosts/platform/execution-host-platform-fact'
import { useAppStore } from '@/store'
import { repoIsRemote } from '../../../../shared/agent-launch/startup/agent-launch-remote'
-import { buildProjectHostSetupOptions } from '@/lib/project-host-setup-options'
-import { buildNewWorkspaceCreateTargetOptions } from '@/lib/new-workspace-project-options'
+import { buildProjectHostSetupOptions } from '@/lib/workspace/creation/project-host-setup-options'
+import { buildNewWorkspaceCreateTargetOptions } from '@/lib/workspace/creation/new-workspace-project-options'
import { getRuntimeEnvironmentIdForRepo } from '@/lib/workspace/ownership/repo-runtime-owner'
import { useEphemeralVmRecipeOptions } from '@/hooks/useEphemeralVmRecipeOptions'
diff --git a/src/renderer/src/hooks/composer-state/source-context-model.ts b/src/renderer/src/hooks/composer-state/source-context-model.ts
index 97a7b9219c0..04aea6f26cb 100644
--- a/src/renderer/src/hooks/composer-state/source-context-model.ts
+++ b/src/renderer/src/hooks/composer-state/source-context-model.ts
@@ -1,7 +1,7 @@
import type * as React from 'react'
import type { TaskSourceContext } from '../../../../shared/work-items/task-source-context'
import type { GitHubWorkItemIdentity } from '../../../../shared/new-workspace/github-work-item-identity'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
export type ComposerSourceContextModel = {
setRepoId: (value: string) => void
diff --git a/src/renderer/src/hooks/composer-state/source-context-state.ts b/src/renderer/src/hooks/composer-state/source-context-state.ts
index 2bb03cfe719..17e34a84374 100644
--- a/src/renderer/src/hooks/composer-state/source-context-state.ts
+++ b/src/renderer/src/hooks/composer-state/source-context-state.ts
@@ -27,7 +27,7 @@ type ComposerSourceContextStateInput = Pick<
import { useCallback, useMemo, useState } from 'react'
import { getWorkspaceSourceProvider } from '../../../../shared/new-workspace/workspace-source'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import { getLinearLinkedWorkItemBranchName } from '@/lib/work-items/linear/linear-linked-work-item'
import {
type TaskSourceContext,
diff --git a/src/renderer/src/hooks/composer-state/source-identity-actions.ts b/src/renderer/src/hooks/composer-state/source-identity-actions.ts
index 5fe6f36db0c..ecfc2b44209 100644
--- a/src/renderer/src/hooks/composer-state/source-identity-actions.ts
+++ b/src/renderer/src/hooks/composer-state/source-identity-actions.ts
@@ -35,7 +35,11 @@ type SourceIdentityActionsInput = Pick<
import { useCallback } from 'react'
import type { GitLabWorkItem } from '../../../../shared/gitlab-types'
-import { getLinkedWorkItemSuggestedName, getLinkedWorkItemWorkspaceName } from '@/lib/new-workspace'
+import '@/lib/workspace/creation/new-workspace'
+import {
+ getLinkedWorkItemSuggestedName,
+ getLinkedWorkItemWorkspaceName
+} from '../../../../shared/workspace-name'
import type { GitHubWorkItem } from '../../../../shared/github/work-item-types'
import { shouldApplyWorkspaceSourceAutoName } from '../../../../shared/new-workspace/workspace-source'
import { isLinearLinkedWorkItem } from '@/lib/work-items/linear/linear-linked-work-item'
diff --git a/src/renderer/src/hooks/composer-state/source-selection-decisions.ts b/src/renderer/src/hooks/composer-state/source-selection-decisions.ts
index fbec826ed11..ee5e4bf8f0e 100644
--- a/src/renderer/src/hooks/composer-state/source-selection-decisions.ts
+++ b/src/renderer/src/hooks/composer-state/source-selection-decisions.ts
@@ -2,7 +2,7 @@ import type { GitHubPrStartPoint, GitPushTarget } from '../../../../shared/workt
import type { GitHubWorkItem } from '../../../../shared/github/work-item-types'
import type { GitLabWorkItem } from '../../../../shared/gitlab-types'
import { getWorkspaceSourceProvider } from '../../../../shared/new-workspace/workspace-source'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import type { SmartGitHubSubmitResolution } from '@/lib/work-items/github/smart-github-submit'
import {
resolveGitHubWorkItemIdentity,
diff --git a/src/renderer/src/hooks/composer-state/target-change-actions.ts b/src/renderer/src/hooks/composer-state/target-change-actions.ts
index c0ff8fcb83c..65db2bf7c45 100644
--- a/src/renderer/src/hooks/composer-state/target-change-actions.ts
+++ b/src/renderer/src/hooks/composer-state/target-change-actions.ts
@@ -47,9 +47,10 @@ import {
getProjectHostSetupSelectionKey,
type ProjectHostSetupOption,
type ReadyProjectHostSetupOption
-} from '@/lib/project-host-setup-options'
+} from '@/lib/workspace/creation/project-host-setup-options'
import { useAppStore } from '@/store'
-import { getComposerEligibleRepos } from '@/lib/new-workspace-composer-repo'
+import '@/lib/workspace/creation/new-workspace-composer-repo'
+import { getNewWorkspaceDialogEligibleRepos } from '../../../../shared/new-workspace-dialog-repo'
export function useTargetChangeActions(input: TargetChangeActionsInput) {
const {
@@ -246,7 +247,7 @@ export function useTargetChangeActions(input: TargetChangeActionsInput) {
: buildProjectHostSetupOptions({
projectId: selectedRepoProjectId,
projectHostSetups: useAppStore.getState().projectHostSetups,
- eligibleRepos: getComposerEligibleRepos(useAppStore.getState().repos),
+ eligibleRepos: getNewWorkspaceDialogEligibleRepos(useAppStore.getState().repos),
hosts: hostOptions
}).find(
(candidate): candidate is ReadyProjectHostSetupOption =>
diff --git a/src/renderer/src/hooks/composer-state/target-store-model.ts b/src/renderer/src/hooks/composer-state/target-store-model.ts
index 0fe30658078..233b75fab9d 100644
--- a/src/renderer/src/hooks/composer-state/target-store-model.ts
+++ b/src/renderer/src/hooks/composer-state/target-store-model.ts
@@ -11,7 +11,7 @@ import type {
Worktree
} from '../../../../shared/worktree/types'
import type { ExecutionHostRegistryEntry } from '../../../../shared/execution-host/execution-host-registry-entry'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import type { ComposerDecisions } from './composer-decisions'
import type { ComposerStoreActions } from './composer-store-actions'
import type { SparsePreset } from '../../../../shared/worktree/create-types'
@@ -21,7 +21,7 @@ import type { RuntimeEnvironmentStatus } from '../../../../shared/remote-runtime
import type { GlobalSettings } from '../../../../shared/global-settings-types'
import type { WorkspaceHostScope } from '../../../../shared/ui-chrome-types'
import type { WorkspaceSource as WorkspaceCreateTelemetrySource } from '../../../../shared/workspace-source'
-import type { WorkspaceCreationTargetHint } from '@/lib/project-host-workspace-target'
+import type { WorkspaceCreationTargetHint } from '@/lib/workspace/creation/project-host-workspace-target'
export type ComposerTargetStoreModel = {
initialRepoId: string | undefined
diff --git a/src/renderer/src/hooks/ipc-events/new-workspace-command.ts b/src/renderer/src/hooks/ipc-events/new-workspace-command.ts
index 0059b95bf18..a8d7f03b60b 100644
--- a/src/renderer/src/hooks/ipc-events/new-workspace-command.ts
+++ b/src/renderer/src/hooks/ipc-events/new-workspace-command.ts
@@ -1,5 +1,5 @@
import { buildLinearIssueLinkedWorkItem } from '@/lib/work-items/linear/linear-linked-work-item'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import { getLinearIssueWorkspaceName } from '../../../../shared/workspace-name'
import type { AppState } from '../../store/types'
diff --git a/src/renderer/src/hooks/useComposerState.ts b/src/renderer/src/hooks/useComposerState.ts
index d806d47ab01..2ac5e320549 100644
--- a/src/renderer/src/hooks/useComposerState.ts
+++ b/src/renderer/src/hooks/useComposerState.ts
@@ -1,13 +1,13 @@
import type { RefObject } from 'react'
-import '@/lib/new-workspace'
-import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
+import '@/lib/workspace/creation/new-workspace'
+import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
import type { GitHubWorkItem } from '../../../shared/github/work-item-types'
import type { TuiAgent } from '../../../shared/agent-launch/catalog/tui-agent'
import type { QuickSubmitOptions } from './composer-state/quick-creation-request'
import type { TaskSourceContext } from '../../../shared/work-items/task-source-context'
import type { WorkspaceSource as WorkspaceCreateTelemetrySource } from '../../../shared/workspace-source'
import type { WorkspaceStatus } from '../../../shared/worktree/types'
-import type { WorkspaceCreationTargetHint } from '@/lib/project-host-workspace-target'
+import type { WorkspaceCreationTargetHint } from '@/lib/workspace/creation/project-host-workspace-target'
import { buildComposerCardProps } from './composer-state/composer-card-props'
import {
canResolveFolderSmartGitHubSubmit,
diff --git a/src/renderer/src/hooks/useEphemeralVmRecipeOptions.ts b/src/renderer/src/hooks/useEphemeralVmRecipeOptions.ts
index 97750798d9e..19626d6edd7 100644
--- a/src/renderer/src/hooks/useEphemeralVmRecipeOptions.ts
+++ b/src/renderer/src/hooks/useEphemeralVmRecipeOptions.ts
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
import { LOCAL_EXECUTION_HOST_ID, type ExecutionHostId } from '../../../shared/execution-host'
import type { OrcaVmRecipe } from '../../../shared/orca-yaml-hook-types'
import type { EphemeralVmFailure } from '../../../shared/ephemeral-vm-failure-copy'
-import { ephemeralVmErrorText } from '@/lib/ephemeral-vm-error-copy'
+import { ephemeralVmErrorText } from '@/runtime/ephemeral-vm/ephemeral-vm-error-copy'
import { useUiLanguageRevision } from '@/i18n/use-ui-language-revision'
type EphemeralVmRecipeOptionsArgs = {
diff --git a/src/renderer/src/lib/agent-session/launch/continuation/launch-agent-session-continuation-toast.test.tsx b/src/renderer/src/lib/agent-session/launch/continuation/launch-agent-session-continuation-toast.test.tsx
index 474baef3eaf..42c27fb6e70 100644
--- a/src/renderer/src/lib/agent-session/launch/continuation/launch-agent-session-continuation-toast.test.tsx
+++ b/src/renderer/src/lib/agent-session/launch/continuation/launch-agent-session-continuation-toast.test.tsx
@@ -24,7 +24,7 @@ vi.mock('@/runtime/rpc/calls/runtime-rpc-call', async (importOriginal) =>
await import('@/runtime/workspace-layout/testing/layout-apply-test-transport.test-fixture')
).runtimeRpcClientWithLayoutApply(await importOriginal())
)
-vi.mock('../../../host-chat-program-acquisition', () => ({
+vi.mock('../inventory/host-chat-program-acquisition', () => ({
acquireAgentLaunchChoices: async () => ({ detected: ['codex'], offered: ['codex'] })
}))
diff --git a/src/renderer/src/lib/agent-session/launch/continuation/launch-agent-session-continuation.ts b/src/renderer/src/lib/agent-session/launch/continuation/launch-agent-session-continuation.ts
index 86cfa89a60c..c75fa94a685 100644
--- a/src/renderer/src/lib/agent-session/launch/continuation/launch-agent-session-continuation.ts
+++ b/src/renderer/src/lib/agent-session/launch/continuation/launch-agent-session-continuation.ts
@@ -7,8 +7,8 @@ import { useAppStore } from '@/store/index'
import {
acquireAgentLaunchChoices,
AgentLaunchChoiceCancelled
-} from '../../../host-chat-program-acquisition'
-import { agentChoicePending } from '../../../host-chat-program'
+} from '../inventory/host-chat-program-acquisition'
+import { agentChoicePending } from '../inventory/host-chat-program'
import { worktreeLaunchWorkspace } from '../routing/agent-launch-route-input'
import { isTuiAgentEnabled } from '../../../../../../shared/agent-launch/catalog/tui-agent-selection'
import type { LaunchSource } from '../../../../../../shared/telemetry-property-schemas'
diff --git a/src/renderer/src/lib/environment-setup-agent-launch.ts b/src/renderer/src/lib/agent-session/launch/environment-setup-agent-launch.ts
similarity index 92%
rename from src/renderer/src/lib/environment-setup-agent-launch.ts
rename to src/renderer/src/lib/agent-session/launch/environment-setup-agent-launch.ts
index 1cf1d1acba4..395533bc5bd 100644
--- a/src/renderer/src/lib/environment-setup-agent-launch.ts
+++ b/src/renderer/src/lib/agent-session/launch/environment-setup-agent-launch.ts
@@ -1,5 +1,5 @@
import { toast } from 'sonner'
-import { useAppStore } from '@/store'
+import { useAppStore } from '@/store/index'
import { translate } from '@/i18n/i18n'
import { resolveDefaultAgentForWorktree } from '@/lib/agent-session/launch/shortcuts/agent-tab-shortcuts'
import { launchAgentInNewTabWithOutcome } from '@/lib/agent-session/launch/new-tab/launch-agent-in-new-tab'
@@ -8,13 +8,13 @@ import { captureAgentTabLaunchContext } from '@/components/agent-tab-launch-cont
import { activateAndRevealWorktreeWithOutcome } from '@/lib/workspace/activation/worktree-activation'
import { reportAgentWorkspaceActivation } from '@/lib/workspace/activation/worktree-activation-outcome'
import { focusTerminalTabSurface } from '@/lib/focus-terminal-tab-surface'
-import { isGitRepoKind } from '../../../shared/repo-kind'
-import type { Repo } from '../../../shared/repo-types'
-import type { Worktree } from '../../../shared/worktree/types'
+import { isGitRepoKind } from '../../../../../shared/repo-kind'
+import type { Repo } from '../../../../../shared/repo-types'
+import type { Worktree } from '../../../../../shared/worktree/types'
import {
buildEnvironmentSetupAgentPrompt,
type EnvironmentSetupFailureContext
-} from '../../../shared/environment-setup-agent-prompt'
+} from '../../../../../shared/environment-setup-agent-prompt'
/** The Git project an environment-setup agent should work on: the active one, else the first. */
export function pickEnvironmentSetupRepo(
diff --git a/src/renderer/src/lib/host-chat-program-acquisition.ts b/src/renderer/src/lib/agent-session/launch/inventory/host-chat-program-acquisition.ts
similarity index 93%
rename from src/renderer/src/lib/host-chat-program-acquisition.ts
rename to src/renderer/src/lib/agent-session/launch/inventory/host-chat-program-acquisition.ts
index abe59f741be..ee4fdcf05d1 100644
--- a/src/renderer/src/lib/host-chat-program-acquisition.ts
+++ b/src/renderer/src/lib/agent-session/launch/inventory/host-chat-program-acquisition.ts
@@ -4,8 +4,8 @@ import {
useAppStateValue
} from '@/store/retained-views/app-state-view'
import { useEffect, useMemo } from 'react'
-import { useAppStore } from '@/store'
-import type { ProspectiveWorkspace } from './agent-session/launch/routing/agent-launch-route-input'
+import { useAppStore } from '@/store/index'
+import type { ProspectiveWorkspace } from '../routing/agent-launch-route-input'
import {
agentsOfferedForLaunch,
resolveChatProgramContext,
@@ -19,14 +19,14 @@ import {
firstHostStructuredAgentAvailability
} from '@/runtime/native-chat/agent-catalogs/host-structured-agent-availability'
import { onRuntimeEnvironmentsRetired } from '@/runtime/rpc/environment-revisions/runtime-environment-revision'
-import { STRUCTURED_AGENT_SESSION_AVAILABILITY_RUNTIME_CAPABILITY as AVAILABILITY } from '../../../shared/agent-session/structured-agent-session-surface-capabilities'
-import type { TuiAgent } from '../../../shared/agent-launch/catalog/tui-agent'
+import { STRUCTURED_AGENT_SESSION_AVAILABILITY_RUNTIME_CAPABILITY as AVAILABILITY } from '../../../../../../shared/agent-session/structured-agent-session-surface-capabilities'
+import type { TuiAgent } from '../../../../../../shared/agent-launch/catalog/tui-agent'
import type { AppState } from '@/store/types'
-import { isTuiAgent } from '../../../shared/agent-launch/catalog/tui-agent-config'
+import { isTuiAgent } from '../../../../../../shared/agent-launch/catalog/tui-agent-config'
import {
getDetectionTargetIdentityForWorktree,
readAgentInventoryForWorktree
-} from './agent-session/launch/inventory/agent-detection-target-inventory'
+} from './agent-detection-target-inventory'
export const useChatProgramFactsVersion = (): number =>
useAppViewExternalStore(
diff --git a/src/renderer/src/lib/host-chat-program.ts b/src/renderer/src/lib/agent-session/launch/inventory/host-chat-program.ts
similarity index 89%
rename from src/renderer/src/lib/host-chat-program.ts
rename to src/renderer/src/lib/agent-session/launch/inventory/host-chat-program.ts
index 52c2440b6b1..beda9993fe5 100644
--- a/src/renderer/src/lib/host-chat-program.ts
+++ b/src/renderer/src/lib/agent-session/launch/inventory/host-chat-program.ts
@@ -1,24 +1,24 @@
-import { nativeChatPreferenceFor } from '../../../shared/structured-native-chat-launch-route'
-import { parseExecutionHostId } from '../../../shared/execution-host'
-import { MANAGED_RUNTIME_INSTALL_RUNTIME_CAPABILITY as INSTALL } from '../../../shared/managed-runtime-install'
+import { nativeChatPreferenceFor } from '../../../../../../shared/structured-native-chat-launch-route'
+import { parseExecutionHostId } from '../../../../../../shared/execution-host'
+import { MANAGED_RUNTIME_INSTALL_RUNTIME_CAPABILITY as INSTALL } from '../../../../../../shared/managed-runtime-install'
import {
STRUCTURED_AGENT_SESSION_REGISTERED_AGENTS_RUNTIME_CAPABILITY as CATALOG,
STRUCTURED_AGENT_SESSION_AVAILABILITY_RUNTIME_CAPABILITY as AVAILABILITY
-} from '../../../shared/agent-session/structured-agent-session-surface-capabilities'
-import { lastVerifiedRuntimeStatus } from '../../../shared/remote-runtime/host-status/runtime-host-status'
-import type { TuiAgent } from '../../../shared/agent-launch/catalog/tui-agent'
-import type { AgentSessionChatProgram } from '../../../shared/agent-session/agent-session-agent-availability'
-import { chatProviderAgents } from '../runtime/native-chat/agent-catalogs/chat-provider-agents'
+} from '../../../../../../shared/agent-session/structured-agent-session-surface-capabilities'
+import { lastVerifiedRuntimeStatus } from '../../../../../../shared/remote-runtime/host-status/runtime-host-status'
+import type { TuiAgent } from '../../../../../../shared/agent-launch/catalog/tui-agent'
+import type { AgentSessionChatProgram } from '../../../../../../shared/agent-session/agent-session-agent-availability'
+import { chatProviderAgents } from '../../../../runtime/native-chat/agent-catalogs/chat-provider-agents'
import {
resolveAgentLaunchRoute,
structuredAgentLaunchSupport
-} from './agent-session/launch/routing/agent-launch-routing'
+} from '../routing/agent-launch-routing'
import {
buildAgentLaunchRouteInput,
resolveAgentLaunchHost,
type AgentLaunchRouteStore,
type ProspectiveWorkspace
-} from './agent-session/launch/routing/agent-launch-route-input'
+} from '../routing/agent-launch-route-input'
import {
readHostStructuredAgentAvailability,
subscribeHostStructuredAgentAvailability
@@ -35,7 +35,7 @@ import {
onRuntimeEnvironmentsRetired
} from '@/runtime/rpc/environment-revisions/runtime-environment-revision'
import { structuredAgentSessionTargetForHost } from '@/runtime/native-chat/session-ownership/structured-agent-session-owner'
-import { getResolvedExecutionHostIdForWorktree } from './resolved-worktree-execution-host'
+import { getResolvedExecutionHostIdForWorktree } from '../../../resolved-worktree-execution-host'
export type ChatProgramObservation = AgentSessionChatProgram | 'unlearned'
type HostFactsStore = Pick
diff --git a/src/renderer/src/lib/agent-session/launch/native-chat-provider-choice.test.tsx b/src/renderer/src/lib/agent-session/launch/native-chat-provider-choice.test.tsx
deleted file mode 100644
index 353a8a3d079..00000000000
--- a/src/renderer/src/lib/agent-session/launch/native-chat-provider-choice.test.tsx
+++ /dev/null
@@ -1,189 +0,0 @@
-// @vitest-environment happy-dom
-import userEvent from '@testing-library/user-event'
-import { cleanup, fireEvent, render, screen, within } from '@testing-library/react'
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import { projectAgentLaunchSettings } from '../../../../../shared/agent-launch/choices/agent-launch-settings'
-import { createGlobalSettingsFixture } from '../../../../../shared/global-settings-test-fixture'
-import type { GlobalSettings } from '../../../../../shared/global-settings-types'
-import type { TuiAgent } from '../../../../../shared/agent-launch/catalog/tui-agent'
-import type { ManagedRuntimeInstallObservation } from '@/runtime/hosts/installation/use-managed-runtime-install'
-import type * as HostChatProgramModule from '@/lib/host-chat-program'
-import type * as ManagedRuntimeInstallModule from '@/runtime/hosts/installation/managed-runtime-install-status'
-import type * as SignInAreaModule from '../../../components/provider-accounts/AntigravityProviderSignInArea'
-import { TooltipProvider } from '../../../components/ui/tooltip'
-import { AgentLaunchSettingsCatalog } from '../../../components/settings/agents/launch/AgentLaunchSettingsCatalog'
-
-const store = vi.hoisted(
- (): { settings: unknown; localDetectedAgentIdsByContext: { host: TuiAgent[] | null } } => ({
- settings: null,
- localDetectedAgentIdsByContext: { host: ['claude'] }
- })
-)
-const inventory = vi.hoisted(
- (): {
- detected: TuiAgent[] | null
- failed: boolean
- chatAvailable: boolean
- nativePrograms: TuiAgent[]
- } => ({
- detected: ['claude'],
- failed: false,
- chatAvailable: true,
- nativePrograms: []
- })
-)
-const runtime = vi.hoisted((): { current: ManagedRuntimeInstallObservation } => ({
- current: { kind: 'pending' }
-}))
-vi.mock('../../../store/index', () => ({
- useAppStore: Object.assign((selector: (value: unknown) => unknown) => selector(store), {
- getState: () => store
- })
-}))
-vi.mock('@/runtime/native-chat/agent-catalogs/chat-provider-agents', () => ({
- chatProviderAgents: () => ['claude', 'codex', 'antigravity'],
- useHostStructuredAgentsVersion: () => 0
-}))
-vi.mock('@/hooks/useDetectedAgents', () => ({
- useDetectedAgents: () => ({
- detectedIds: inventory.detected,
- detectionFailed: inventory.failed,
- isRefreshing: false,
- refresh: vi.fn()
- })
-}))
-vi.mock('@/lib/host-chat-program-acquisition', () => ({ useChatProgramFacts: () => {} }))
-vi.mock('@/lib/host-chat-program', async (importOriginal) => ({
- ...(await importOriginal()),
- agentChoiceOpensAsChat: () => false,
- resolveChatProgramContext: (_state: unknown, workspace: { runtimeEnvironmentId?: string }) => ({
- executionHostId: workspace.runtimeEnvironmentId
- ? `runtime:${workspace.runtimeEnvironmentId}`
- : 'local',
- hostCapabilities: [],
- runtimeId: null
- }),
- // The host publishes Antigravity's downloaded chat program; its agy CLI is not installed.
- readChatProgram: (_store: unknown, agent: TuiAgent) =>
- (agent === 'antigravity' && inventory.chatAvailable) || inventory.nativePrograms.includes(agent)
- ? 'available'
- : 'missing'
-}))
-vi.mock('@/runtime/native-chat/agent-catalogs/host-structured-agents', () => ({
- readHostStructuredAgents: () => [{ agent: 'antigravity', managedRuntime: true }]
-}))
-vi.mock('@/runtime/hosts/installation/managed-runtime-install-status', async (importOriginal) => ({
- ...(await importOriginal()),
- installManagedRuntime: vi.fn(async () => {})
-}))
-vi.mock('@/runtime/hosts/installation/use-managed-runtime-install', () => ({
- useManagedRuntimeInstall: () => runtime.current
-}))
-vi.mock('../../../components/provider-accounts/use-antigravity-chat-sign-in', () => ({
- useAntigravityChatSignIn: () => ({ flow: null })
-}))
-vi.mock(
- '../../../components/provider-accounts/AntigravityProviderSignInArea',
- async (importOriginal) => ({
- ...(await importOriginal()),
- AntigravityProviderSignInArea: () => Antigravity account
- })
-)
-beforeEach(() => {
- inventory.detected = ['claude']
- inventory.failed = false
- inventory.chatAvailable = true
- inventory.nativePrograms = []
- store.localDetectedAgentIdsByContext.host = ['claude']
- runtime.current = { kind: 'pending' }
- vi.stubGlobal('api', { platform: { get: () => ({ platform: 'darwin' }) } })
-})
-afterEach(() => {
- cleanup()
- vi.unstubAllGlobals()
-})
-
-describe('agent row chat or CLI', () => {
- it('serializes choices from different rows while an inventory update arrives during the save', async () => {
- const settings = createGlobalSettingsFixture({ agentDefaultSurface: 'chat' })
- store.settings = settings
- const save = Promise.withResolvers()
- const updateSettings = vi.fn(async (updates: Partial) => {
- await save.promise
- Object.assign(settings, updates)
- })
- const element = () => (
- {})}
- detectionTarget={{ kind: 'local' }}
- hostName={null}
- renderPermissions={() => null}
- local={{ settings, updateSettings, saveEnvironment: vi.fn(async () => {}) }}
- />
- )
- const view = render(element(), { wrapper: TooltipProvider })
- const cli = (label: string) =>
- within(screen.getByRole('radiogroup', { name: `Open ${label} as` })).getByRole('radio', {
- name: 'CLI'
- })
- fireEvent.click(cli('Claude'))
- await vi.waitFor(() => expect(updateSettings).toHaveBeenCalledOnce())
- fireEvent.click(cli('Codex'))
- inventory.detected = []
- view.rerender(element())
- expect(updateSettings).toHaveBeenCalledOnce()
- save.resolve()
- await vi.waitFor(() => expect(updateSettings).toHaveBeenCalledTimes(2))
- expect(settings.nativeChatProviders).toEqual({ claude: false, codex: false })
- })
-})
-
-it('offers the selected paired native-only program editor and writes effort without CLI controls', async () => {
- inventory.detected = []
- store.localDetectedAgentIdsByContext.host = ['claude', 'antigravity']
- const settings = createGlobalSettingsFixture({
- agentLaunchChoices: {},
- agentPermissionDefault: 'own'
- })
- store.settings = settings
- const mutate = vi.fn(async () => {})
- const element = () => (
- null}
- />
- )
- const view = render(element(), { wrapper: TooltipProvider })
- const label = screen.getByText('Antigravity')
- const row = label.closest('.py-3')
- if (!(row instanceof HTMLElement)) {
- throw new Error('Missing paired native-only row')
- }
- fireEvent.click(within(row).getByRole('button', { name: 'Expand agent settings' }))
- expect(within(row).getByText('Model')).toBeTruthy()
- expect(within(row).queryByRole('textbox', { name: 'Arguments' })).toBeNull()
- expect(within(row).queryByRole('textbox', { name: 'Command' })).toBeNull()
- expect(screen.queryByRole('radiogroup', { name: 'Open Antigravity as' })).toBeNull()
- const effort = within(row).getByRole('button', { name: 'Reasoning effort: Default' })
- await userEvent.click(effort)
- const option = screen.getAllByRole('menuitemradio').find((item) => item.textContent === 'High')
- if (!option) {
- throw new Error('Missing paired effort option')
- }
- fireEvent.click(option)
- await vi.waitFor(() => expect(mutate).toHaveBeenCalledOnce())
- expect(mutate.mock.calls[0]).toEqual([
- expect.objectContaining({
- type: 'launch-choices',
- agent: 'antigravity',
- patch: { options: { effort: 'high' } }
- })
- ])
- inventory.chatAvailable = false
- view.rerender(element())
- expect(within(row).queryByText('Model')).toBeNull()
-})
diff --git a/src/renderer/src/lib/agent-session/launch/new-tab/agent-launch-caller-prompt-transport.test.ts b/src/renderer/src/lib/agent-session/launch/new-tab/agent-launch-caller-prompt-transport.test.ts
index 5132d1280e1..2b925a4e7e1 100644
--- a/src/renderer/src/lib/agent-session/launch/new-tab/agent-launch-caller-prompt-transport.test.ts
+++ b/src/renderer/src/lib/agent-session/launch/new-tab/agent-launch-caller-prompt-transport.test.ts
@@ -11,7 +11,7 @@ const mockPasteDraftWhenAgentReady = vi.fn<(request: Record) =>
)
vi.mock('@/store/index', () => ({ useAppStore: { getState: () => store } }))
-vi.mock('@/lib/new-workspace', () => ({ CLIENT_PLATFORM: 'darwin' }))
+vi.mock('@/lib/workspace/creation/new-workspace', () => ({ CLIENT_PLATFORM: 'darwin' }))
vi.mock('@/lib/workspace/ownership/connection-context', () => ({
getConnectionIdFromState: mockLaunchConnectionId
}))
diff --git a/src/renderer/src/lib/agent-session/launch/new-tab/agent-launch-caller-routing.test.ts b/src/renderer/src/lib/agent-session/launch/new-tab/agent-launch-caller-routing.test.ts
index ac27d959f1e..dd0fc84fbc2 100644
--- a/src/renderer/src/lib/agent-session/launch/new-tab/agent-launch-caller-routing.test.ts
+++ b/src/renderer/src/lib/agent-session/launch/new-tab/agent-launch-caller-routing.test.ts
@@ -21,7 +21,7 @@ const mockHostCapabilities = vi.fn<() => readonly string[] | null>(() => [])
const mockExecutionHostId = vi.fn(() => 'local')
vi.mock('@/store/index', () => ({ useAppStore: { getState: () => store } }))
-vi.mock('@/lib/new-workspace', () => ({ CLIENT_PLATFORM: 'darwin' }))
+vi.mock('@/lib/workspace/creation/new-workspace', () => ({ CLIENT_PLATFORM: 'darwin' }))
vi.mock('@/lib/workspace/ownership/connection-context', () => ({
getConnectionIdFromState: mockLaunchConnectionId
}))
diff --git a/src/renderer/src/lib/agent-session/launch/new-tab/launch-agent-in-new-tab-main-surface.test.ts b/src/renderer/src/lib/agent-session/launch/new-tab/launch-agent-in-new-tab-main-surface.test.ts
index c558d5dff24..8ef96c3b93f 100644
--- a/src/renderer/src/lib/agent-session/launch/new-tab/launch-agent-in-new-tab-main-surface.test.ts
+++ b/src/renderer/src/lib/agent-session/launch/new-tab/launch-agent-in-new-tab-main-surface.test.ts
@@ -29,7 +29,7 @@ vi.mock('@/store/index', () => ({
}
}))
-vi.mock('@/lib/host-chat-program-acquisition', async (original) => ({
+vi.mock('@/lib/agent-session/launch/inventory/host-chat-program-acquisition', async (original) => ({
...(await original