mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
refactor(renderer): group workspace creation and launch owners
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'
|
||||
|
||||
+1
-1
@@ -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'
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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' }))
|
||||
}))
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+2
-2
@@ -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[] = [
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}) => (
|
||||
<div>
|
||||
<button type="button" data-test-close-popover onClick={() => onOpenChange?.(false)} />
|
||||
{children}
|
||||
</div>
|
||||
),
|
||||
PopoverAnchor: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
PopoverContent: ({ children }: { children: React.ReactNode }) => <div>{children}</div>
|
||||
}))
|
||||
|
||||
vi.mock('./use-recent-project-ids', () => ({ useRecentProjectIds: () => [] }))
|
||||
|
||||
let container: HTMLDivElement
|
||||
let root: Root
|
||||
|
||||
function renderField(element: React.ReactNode): void {
|
||||
root.render(<TooltipProvider>{element}</TooltipProvider>)
|
||||
}
|
||||
|
||||
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<HTMLInputElement>(
|
||||
'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(
|
||||
<ProjectCombobox
|
||||
options={projects}
|
||||
value={null}
|
||||
onValueChange={onValueChange}
|
||||
onAddProject={onAddProject}
|
||||
/>
|
||||
)
|
||||
})
|
||||
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(
|
||||
<ProjectCombobox options={sectionedOptions} value={null} onValueChange={onValueChange} />
|
||||
)
|
||||
})
|
||||
act(() => {
|
||||
container
|
||||
.querySelector<HTMLElement>('[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')
|
||||
})
|
||||
})
|
||||
@@ -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,
|
||||
|
||||
@@ -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(<MatchedText text={option.displayName} hits={match!.nameHits} />)
|
||||
})
|
||||
|
||||
expect(markedText()).toBe('orca')
|
||||
})
|
||||
})
|
||||
@@ -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. */
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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(
|
||||
<SetProjectLocationDialog
|
||||
option={option}
|
||||
projectName="orca"
|
||||
projectKind="git"
|
||||
defaultCloneUrl="https://github.com/stablyai/orca.git"
|
||||
onClose={onClose}
|
||||
onReady={onReady}
|
||||
/>
|
||||
)
|
||||
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(
|
||||
<SetProjectLocationDialog
|
||||
option={null}
|
||||
projectName="orca"
|
||||
projectKind="git"
|
||||
defaultCloneUrl="https://github.com/stablyai/orca.git"
|
||||
onClose={onClose}
|
||||
onReady={onReady}
|
||||
/>
|
||||
)
|
||||
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(
|
||||
<StrictMode>
|
||||
<SetProjectLocationDialog
|
||||
option={option}
|
||||
projectName="orca"
|
||||
projectKind="git"
|
||||
defaultCloneUrl="git@github.com:stablyai/orca.git"
|
||||
onClose={vi.fn()}
|
||||
onReady={onReady}
|
||||
/>
|
||||
</StrictMode>
|
||||
)
|
||||
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']))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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?: {
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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[] {
|
||||
|
||||
+6
-6
@@ -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'
|
||||
|
||||
+11
-10
@@ -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
|
||||
+1
-1
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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<GlobalSettings>) => {
|
||||
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<void>
|
||||
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<void>
|
||||
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<void>()
|
||||
const detected = Promise.withResolvers<string[]>()
|
||||
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<void>
|
||||
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()
|
||||
})
|
||||
})
|
||||
@@ -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 {
|
||||
|
||||
+1
-1
@@ -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,
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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<AppState, 'settings'> & WorktreeAgentInventoryState
|
||||
|
||||
-68
@@ -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' })
|
||||
)
|
||||
})
|
||||
+2
-2
@@ -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'
|
||||
|
||||
+5
-2
@@ -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<typeof sourceControlLaunchWorkspace>[0]
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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<string | null>('chat')
|
||||
const pendingScrollTargetRef = useRef<string | null>(targetSection)
|
||||
const contentScrollRef = useRef<HTMLDivElement>(null)
|
||||
const pendingScrollTargetWatchRef = useRef(null)
|
||||
const pendingSubsectionScrollFrameRef = useRef<number | null>(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<SettingsTerminalModel, 'neededRepos'> = { 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 (
|
||||
<TooltipProvider>
|
||||
<ActiveSettingsSectionProvider value={activeSectionId}>
|
||||
<output aria-label="Selected settings page">{activeSectionId}</output>
|
||||
<ChatSettingsSection
|
||||
settings={settings}
|
||||
updateSettings={vi.fn()}
|
||||
writeSourceControlAiSettings={async () => {}}
|
||||
searchEntries={[
|
||||
...getChatAppearanceSearchEntries(),
|
||||
getChatNamingSearchEntry(),
|
||||
getChatInlineVisualsSearchEntry()
|
||||
]}
|
||||
showDesktopOnlySettings
|
||||
isMounted
|
||||
/>
|
||||
</ActiveSettingsSectionProvider>
|
||||
</TooltipProvider>
|
||||
)
|
||||
}
|
||||
|
||||
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(
|
||||
<NavigationHarness initialSection="appearance" targetSection="chat-inline-visuals" />
|
||||
)
|
||||
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))
|
||||
})
|
||||
})
|
||||
@@ -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()
|
||||
|
||||
+1
-1
@@ -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 = {
|
||||
|
||||
+4
-1
@@ -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'
|
||||
|
||||
@@ -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<typeof window.api.ephemeralVm.listRecipeCatalog>
|
||||
|
||||
+1
-1
@@ -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'
|
||||
|
||||
|
||||
+1
-1
@@ -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'
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
+1
-1
@@ -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 = {
|
||||
|
||||
+1
-1
@@ -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,
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
+3
-2
@@ -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
|
||||
)
|
||||
|
||||
+1
-1
@@ -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'
|
||||
|
||||
|
||||
+1
-1
@@ -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'
|
||||
|
||||
+1
-1
@@ -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'
|
||||
|
||||
+2
-54
@@ -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<typeof NewWorkspaceModule>()
|
||||
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)
|
||||
})
|
||||
|
||||
+5
-4
@@ -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)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import type { LinkedWorkItemSummary } from '@/lib/new-workspace'
|
||||
import type { LinkedWorkItemSummary } from '@/lib/workspace/creation/new-workspace'
|
||||
import {
|
||||
buildWorkspaceSourceSelection,
|
||||
getWorkspaceSourceName,
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<string> = new Set()
|
||||
|
||||
|
||||
+4
-3
@@ -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) }
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
-221
@@ -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<typeof vi.fn>,
|
||||
ptyId = 'pty-1',
|
||||
sendInputAccepted?: ReturnType<typeof vi.fn>
|
||||
) {
|
||||
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()
|
||||
})
|
||||
})
|
||||
+1
-1
@@ -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'
|
||||
}))
|
||||
|
||||
|
||||
+1
-1
@@ -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'
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
+1
-1
@@ -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 => {
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user