refactor(automations): group authoring, host catalog, listing and run owners

This commit is contained in:
Neil
2026-11-09 18:56:29 -08:00
parent e6308fb35c
commit c8f88ad6b1
232 changed files with 876 additions and 2559 deletions
+2 -2
View File
@@ -19,10 +19,10 @@
1 src/renderer/src/components/activity/use-agent-pane-thread-store-data.ts
1 src/renderer/src/components/activity/use-agent-pane-threads.ts
4 src/renderer/src/components/agent/AgentSettingsDialog.tsx
1 src/renderer/src/components/automations/automation-host-client.ts
1 src/renderer/src/components/automations/hosts/automation-host-client.ts
1 src/renderer/src/components/automations/automations-page-fixtures.ts
1 src/renderer/src/components/automations/use-automations-page-controller.ts
1 src/renderer/src/components/automations/use-automations-page-destination-form.ts
1 src/renderer/src/components/automations/authoring/use-automations-page-destination-form.ts
1 src/renderer/src/components/browser-pane/ReopenBrowserPageOnServerButton.tsx
1 src/renderer/src/components/browser-pane/browser-reopen-on-server.ts
1 src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-stream.ts
+1 -1
View File
@@ -1,7 +1,7 @@
# JSX mapped straight over a host collection, per file, outside components/host-picker.
# This is a RATCHET: counts may only go DOWN. Draw host lists with HostCombobox or
# useBoundedHostRows. Prune after a fix: pnpm check:host-list-render-ratchet --prune
1 src/renderer/src/components/automations/AutomationRunsDashboard.tsx
1 src/renderer/src/components/automations/runs/AutomationRunsDashboard.tsx
1 src/renderer/src/components/right-sidebar/ai-vault/panel/AiVaultPanelControls.tsx
1 src/renderer/src/components/right-sidebar/source-control/ai/SourceControlAgentActionDialogForm.tsx
1 src/renderer/src/components/settings/browser/profiles/BrowserSessionCookiesSection.tsx
+17 -17
View File
@@ -28,27 +28,27 @@
1 src/renderer/src/components/artifacts/ArtifactPublishButton.tsx
2 src/renderer/src/components/artifacts/ArtifactsPage.tsx
2 src/renderer/src/components/artifacts/useArtifactPagination.ts
2 src/renderer/src/components/automations/AutomationEditorPromptEditor.tsx
1 src/renderer/src/components/automations/AutomationHostFilterNotice.tsx
1 src/renderer/src/components/automations/AutomationProjectCombobox.tsx
1 src/renderer/src/components/automations/AutomationRunHistory.tsx
1 src/renderer/src/components/automations/AutomationRunsDashboard.tsx
1 src/renderer/src/components/automations/AutomationRunsTable.tsx
2 src/renderer/src/components/automations/authoring/AutomationEditorPromptEditor.tsx
1 src/renderer/src/components/automations/hosts/AutomationHostFilterNotice.tsx
1 src/renderer/src/components/automations/authoring/AutomationProjectCombobox.tsx
1 src/renderer/src/components/automations/runs/AutomationRunHistory.tsx
1 src/renderer/src/components/automations/runs/AutomationRunsDashboard.tsx
1 src/renderer/src/components/automations/runs/AutomationRunsTable.tsx
1 src/renderer/src/components/automations/AutomationsPageSurface.tsx
1 src/renderer/src/components/automations/use-automation-agent-picker-entries.ts
2 src/renderer/src/components/automations/use-automation-create-destination.ts
4 src/renderer/src/components/automations/use-automation-host-catalog.ts
4 src/renderer/src/components/automations/use-automation-list-search.ts
2 src/renderer/src/components/automations/use-automation-migrate-action.ts
1 src/renderer/src/components/automations/use-automation-runs-dashboard.ts
1 src/renderer/src/components/automations/use-automations-page-list-state.ts
1 src/renderer/src/components/automations/authoring/use-automation-agent-picker-entries.ts
2 src/renderer/src/components/automations/authoring/use-automation-create-destination.ts
4 src/renderer/src/components/automations/hosts/use-automation-host-catalog.ts
4 src/renderer/src/components/automations/listing/use-automation-list-search.ts
2 src/renderer/src/components/automations/authoring/use-automation-migrate-action.ts
1 src/renderer/src/components/automations/runs/use-automation-runs-dashboard.ts
1 src/renderer/src/components/automations/listing/use-automations-page-list-state.ts
1 src/renderer/src/components/automations/use-automations-page-local-state.ts
1 src/renderer/src/components/automations/use-automations-page-refresh.ts
1 src/renderer/src/components/automations/use-automations-page-setup-state.ts
1 src/renderer/src/components/automations/authoring/use-automations-page-setup-state.ts
1 src/renderer/src/components/automations/use-automations-page-store-state.ts
1 src/renderer/src/components/automations/use-external-automation-scope-retention.ts
2 src/renderer/src/components/automations/use-scoped-external-automations.ts
16 src/renderer/src/components/automations/use-selected-automation-run-history.ts
1 src/renderer/src/components/automations/external/use-external-automation-scope-retention.ts
2 src/renderer/src/components/automations/external/use-scoped-external-automations.ts
16 src/renderer/src/components/automations/runs/use-selected-automation-run-history.ts
7 src/renderer/src/components/browser-extension-install-dialog.tsx
1 src/renderer/src/components/browser-pane/ClientHostedBrowserPagePane.tsx
2 src/renderer/src/components/browser-pane/annotate/MarkupOverlay.tsx
+1 -1
View File
@@ -2,7 +2,7 @@
# This is a RATCHET: counts may only go DOWN. Use useTranslate()/useIntlLocale() from
# @/i18n/use-translate. Prune after a fix: pnpm check:render-path-translate-ratchet --prune
2 src/renderer/src/components/agent/AgentLaunchPromptComposer.tsx
5 src/renderer/src/components/automations/use-external-automation-actions.ts
5 src/renderer/src/components/automations/external/use-external-automation-actions.ts
1 src/renderer/src/components/diff-comments/useDiffCommentDecorator.tsx
2 src/renderer/src/components/editor/markdown-preview/render-tree/use-markdown-preview-components.tsx
1 src/renderer/src/components/tab-group/useTabGroupCreationCommands.ts
@@ -4675,53 +4675,52 @@
"src/renderer/src/components/artifacts/ArtifactPublishButton.test.tsx": 706,
"src/renderer/src/components/artifacts/ArtifactsPage.test.tsx": 2052,
"src/renderer/src/components/artifacts/artifact-publish-flow.test.ts": 114,
"src/renderer/src/components/automations/AutomationEditorPromptEditor.test.tsx": 396,
"src/renderer/src/components/automations/authoring/AutomationEditorPromptEditor.test.tsx": 396,
"src/renderer/src/components/automations/AutomationPromptDisclosure.test.tsx": 893,
"src/renderer/src/components/automations/AutomationRunsTable.test.tsx": 668,
"src/renderer/src/components/automations/AutomationSchedulePicker.test.ts": 431,
"src/renderer/src/components/automations/AutomationTimeField.test.tsx": 654,
"src/renderer/src/components/automations/authoring/AutomationSchedulePicker.test.ts": 431,
"src/renderer/src/components/automations/AutomationsPage.behavior.test.tsx": 3389,
"src/renderer/src/components/automations/AutomationsPage.edit-destination.test.tsx": 2932,
"src/renderer/src/components/automations/AutomationsPage.run-navigation.test.tsx": 3056,
"src/renderer/src/components/automations/ExternalAutomationManagers.test.tsx": 852,
"src/renderer/src/components/automations/automation-captured-owner.test.ts": 379,
"src/renderer/src/components/automations/automation-create-projects.test.ts": 42,
"src/renderer/src/components/automations/hosts/automation-captured-owner.test.ts": 379,
"src/renderer/src/components/automations/authoring/automation-create-projects.test.ts": 42,
"src/renderer/src/components/automations/automation-host-cache-controller.test.ts": 411,
"src/renderer/src/components/automations/automation-host-cache-error.test.ts": 391,
"src/renderer/src/components/automations/automation-host-cache-health.test.ts": 52,
"src/renderer/src/components/automations/automation-host-cache.test.ts": 79,
"src/renderer/src/components/automations/automation-host-catalog-generation.test.ts": 258,
"src/renderer/src/components/automations/automation-host-client.test.ts": 374,
"src/renderer/src/components/automations/hosts/automation-host-cache-error.test.ts": 391,
"src/renderer/src/components/automations/hosts/automation-host-cache-health.test.ts": 52,
"src/renderer/src/components/automations/hosts/automation-host-cache.test.ts": 79,
"src/renderer/src/components/automations/hosts/automation-host-client.test.ts": 374,
"src/renderer/src/components/automations/automation-host-diagnostics.test.ts": 460,
"src/renderer/src/components/automations/automation-host-filter-resolution.test.ts": 256,
"src/renderer/src/components/automations/automation-host-health.test.ts": 47,
"src/renderer/src/components/automations/hosts/automation-host-health.test.ts": 47,
"src/renderer/src/components/automations/automation-host-invalidation-window-events.test.ts": 83,
"src/renderer/src/components/automations/automation-host-invalidation.test.ts": 85,
"src/renderer/src/components/automations/automation-host-list-rows.test.ts": 419,
"src/renderer/src/components/automations/automation-host-recovery.test.ts": 51,
"src/renderer/src/components/automations/hosts/automation-host-list-rows.test.ts": 419,
"src/renderer/src/components/automations/hosts/automation-host-recovery.test.ts": 51,
"src/renderer/src/components/automations/automation-host-scale-gates.test.ts": 638,
"src/renderer/src/components/automations/automation-host-scheduler.test.ts": 439,
"src/renderer/src/components/automations/automation-legacy-schedule-editing.test.ts": 449,
"src/renderer/src/components/automations/automation-list-focus-recovery.test.ts": 48,
"src/renderer/src/components/automations/automation-list-row-identity.test.ts": 626,
"src/renderer/src/components/automations/automation-list-search.test.ts": 75,
"src/renderer/src/components/automations/hosts/automation-host-scheduler.test.ts": 439,
"src/renderer/src/components/automations/authoring/automation-legacy-schedule-editing.test.ts": 449,
"src/renderer/src/components/automations/listing/automation-list-focus-recovery.test.ts": 48,
"src/renderer/src/components/automations/automation-list-view.test.ts": 257,
"src/renderer/src/components/automations/automation-run-context.test.ts": 58,
"src/renderer/src/components/automations/automation-run-history-keyboard-navigation.test.ts": 434,
"src/renderer/src/components/automations/automation-run-open-target.test.ts": 442,
"src/renderer/src/components/automations/authoring/automation-run-context.test.ts": 58,
"src/renderer/src/components/automations/runs/automation-run-history-keyboard-navigation.test.ts": 434,
"src/renderer/src/components/automations/runs/automation-run-open-target.test.ts": 442,
"src/renderer/src/components/automations/automation-run-output-snapshot-equivalence.test.ts": 158,
"src/renderer/src/components/automations/automation-run-output-snapshot.test.ts": 96,
"src/renderer/src/components/automations/automation-setup-decision.test.ts": 58,
"src/renderer/src/components/automations/authoring/automation-setup-decision.test.ts": 58,
"src/renderer/src/components/automations/automation-usage-model.test.ts": 200,
"src/renderer/src/components/automations/external-automation-list-entries.test.ts": 57,
"src/renderer/src/components/automations/external-automation-scope-gating.test.ts": 67,
"src/renderer/src/components/automations/external/external-automation-scope-gating.test.ts": 67,
"src/renderer/src/components/automations/external-automation-scope-keys.test.ts": 53,
"src/renderer/src/components/automations/use-automation-host-catalog-readoption.test.tsx": 802,
"src/renderer/src/components/automations/use-automation-host-catalog.test.tsx": 920,
"src/renderer/src/components/automations/use-automation-list-focus-recovery.test.tsx": 229,
"src/renderer/src/components/automations/use-automation-list-search.test.tsx": 679,
"src/renderer/src/components/automations/use-automation-runs-dashboard-payload.test.tsx": 6692,
"src/renderer/src/components/automations/use-automation-runs-dashboard.test.tsx": 854,
"src/renderer/src/components/automations/hosts/use-automation-host-catalog-readoption.test.tsx": 802,
"src/renderer/src/components/automations/hosts/use-automation-host-catalog.test.tsx": 920,
"src/renderer/src/components/automations/listing/use-automation-list-search.test.tsx": 679,
"src/renderer/src/components/automations/runs/use-automation-runs-dashboard-payload.test.tsx": 6692,
"src/renderer/src/components/automations/runs/use-automation-runs-dashboard.test.tsx": 854,
"src/renderer/src/components/automations/use-selected-automation-run-history.test.tsx": 2104,
"src/renderer/src/components/browser-favicon.test.tsx": 333,
"src/renderer/src/components/browser-pane/ClientHostedBrowserPagePane.dead-guest.test.tsx": 6219,
@@ -7989,7 +7988,7 @@
"tests/e2e/ai-vault-account-stream.unit.test.ts": 4506,
"tests/e2e/ai-vault-manual-name-clear.unit.test.ts": 21206,
"tests/e2e/automation-chat-reopen.unit.test.ts": 6262,
"tests/e2e/automation-save-fallback.unit.test.ts": 9065,
"tests/e2e/claude-agent-row-view.unit.test.ts": 1491,
"tests/e2e/codex-child-approval-activity-row.unit.test.ts": 14886,
"tests/e2e/completed-worker-retirement-resume.unit.test.ts": 38857,
@@ -18,7 +18,7 @@ const { sortJiraIssues } = await jiti.import(
'../../../../src/renderer/src/components/jira-issue-sorter.ts'
)
const { sortAutomationListViewItems } = await jiti.import(
'../../../../src/renderer/src/components/automations/automation-list-view.ts'
'../../../../src/renderer/src/components/automations/listing/automation-list-view.ts'
)
const automationLocale = 'en-US'
@@ -137,7 +137,7 @@ const NODE_RUNTIME_INCLUDE = [
'src/main/gitlab/gitlab-known-host-retirement.test.ts',
'src/main/window/main-window-updater-deferred-setup.test.ts',
'src/renderer/src/components/terminal-pane/host-state/terminal-pane-host-state-memo.test.ts',
'src/renderer/src/components/automations/use-automation-runs-dashboard-payload.test.tsx',
'src/renderer/src/components/automations/runs/use-automation-runs-dashboard-payload.test.tsx',
'src/main/native-chat/agent-session-journal/**/*.test.ts',
'src/main/native-chat/agent-session-wire/host/testing/structured-agent-session-terminal-writer-acquire.test.ts',
'src/main/runtime/agent-session/records/agent-session-conversation-name-store.test.ts',
@@ -1,186 +0,0 @@
// @vitest-environment happy-dom
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import { useState } from 'react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { AGENT_CATALOG } from '@/lib/agent-catalog/agent-catalog'
import { TooltipProvider } from '@/components/ui/tooltip'
import { useAppStore } from '@/store'
import { setLocalRuntimeCapabilitiesForTests } from '@/runtime/hosts/capabilities/local-runtime-capabilities'
import { AUTOMATION_RUNTIME_CAPABILITIES } from '../../../../shared/automations/automation-runtime-capabilities'
import { clearNativeChatComposerDraftsForTests } from '../native-chat/drafts/native-chat-draft-reset'
import type { AutomationAuthorityRef } from '../../../../shared/automations/ownership/automation-owner-ref'
import type { AutomationHostCatalogEntry } from './automation-host-catalog-types'
import type { AutomationCreateDestinationControl } from './use-automation-create-destination'
import type { AutomationDraft } from './AutomationEditorDialog'
import { AutomationEditorSettingsSidebar } from './AutomationEditorSettingsSidebar'
// Why: only the Agent field is under test; the sibling fields own their own coverage.
vi.mock('./AutomationProjectCombobox', () => ({ default: () => null }))
vi.mock('./AutomationWorkspaceField', () => ({ AutomationWorkspaceField: () => null }))
vi.mock('./AutomationSessionField', () => ({ AutomationSessionField: () => null }))
vi.mock('./AutomationSchedulePicker', () => ({ AutomationSchedulePicker: () => null }))
vi.mock('./AutomationMissedRunGraceField', () => ({ AutomationMissedRunGraceField: () => null }))
vi.mock('./AutomationPrecheckFields', () => ({ AutomationPrecheckFields: () => null }))
vi.mock('./AutomationSetupDecisionField', () => ({ AutomationSetupDecisionField: () => null }))
vi.mock('./AutomationDestinationField', () => ({ AutomationDestinationField: () => null }))
vi.mock('@/hooks/useShortcutLabel', () => ({ useOptionalShortcutLabel: () => null }))
vi.mock('../tab-bar/use-new-tab-agent-menu-rows', () => ({
useAgentMenuObservation: () => ({
model: { state: 'loading' },
contextKey: 'automation-test',
detection: {
detectedIds: [],
isLoading: false,
isRefreshing: false,
detectionFailed: false,
needsServerUpdate: false,
refresh: async () => []
}
})
}))
vi.mock('../agent/use-agent-launch-picker-inventory', () => ({
useAgentLaunchPickerInventory: (_id: unknown, model: { rows: { agent: string }[] }) =>
model.rows.map((row) => ({
agent: row.agent,
label: row.agent,
rows: [row],
ownerKey: `automation-${row.agent}`,
surfaces: ['terminal'],
defaultSurface: 'terminal',
terminal: { model: 'gpt-5.4', permissionMode: 'ask' },
structured: {},
arguments: '--base',
catalog: {
origin: 'probe',
fetchedAt: 1,
models: [
{ id: 'gpt-5.4', label: 'Model A', isDefault: true, efforts: [] },
{ id: 'gpt-5.5', label: 'Model B', isDefault: false, efforts: [] }
]
}
}))
}))
const DRAFT: AutomationDraft = {
name: '',
prompt: '',
agentId: 'codex',
extraAgentArgs: '',
projectId: '',
workspaceMode: 'existing',
workspaceId: '',
baseBranch: '',
reuseSession: false,
precheckCommand: '',
precheckTimeoutSeconds: '30',
preset: 'weekly',
time: '09:15',
dayOfWeek: '5',
customSchedule: '',
missedRunGraceMinutes: '720',
savedSchedule: null,
scheduleWarning: null
}
function destinationControl(
authority: AutomationAuthorityRef | null
): AutomationCreateDestinationControl {
if (!authority) {
return {
entries: [],
projects: [],
onSelect: vi.fn(),
resolution: { status: 'choice-required', reason: 'unselected' }
}
}
const entry: AutomationHostCatalogEntry = {
stableRef: { authority, selector: { kind: 'self' } },
owner: { authority, selector: { kind: 'self' } },
stableKey: 'test-host',
label: 'Test host',
authorityLabel: 'Test host',
kind: 'self',
catalogState: 'authoritative',
authorityHealth: 'fresh',
executionHealth: 'connected',
querySupport: 'scoped'
}
return {
entries: [entry],
projects: [],
onSelect: vi.fn(),
resolution: { status: 'ready', authority, destination: { selector: { kind: 'self' } }, entry }
}
}
function renderSidebar(
onDraftChange: (updater: (d: AutomationDraft) => AutomationDraft) => void,
initial = DRAFT,
authority: AutomationAuthorityRef | null = { kind: 'desktop' },
destination = destinationControl(authority)
) {
function Form() {
const [draft, setDraft] = useState(initial)
return (
<TooltipProvider>
<AutomationEditorSettingsSidebar
destination={destination}
launchAuthority={authority ?? undefined}
surface={draft.surface ?? 'terminal'}
chatSupported={false}
repos={[]}
projectHostSetups={[]}
automationYamlHooksByRepoKey={{}}
getAutomationHooksCacheKey={(repoId) => repoId}
repoMap={new Map()}
worktrees={[]}
settings={null}
draft={draft}
visibleAgents={AGENT_CATALOG}
pickerTriggerClassName=""
onProjectChange={vi.fn()}
onDraftChange={(updater) => {
onDraftChange(updater)
setDraft(updater)
}}
onSetupDecisionTouched={vi.fn()}
/>
</TooltipProvider>
)
}
return render(<Form />)
}
beforeEach(() => {
clearNativeChatComposerDraftsForTests()
setLocalRuntimeCapabilitiesForTests(AUTOMATION_RUNTIME_CAPABILITIES)
})
afterEach(() => {
cleanup()
vi.restoreAllMocks()
setLocalRuntimeCapabilitiesForTests(null)
useAppStore.setState({ runtimeStatusByEnvironmentId: new Map() })
})
function openPicker() {
fireEvent.pointerDown(screen.getByRole('button', { name: 'Select agent' }), { button: 0 })
}
describe('AutomationEditorSettingsSidebar agent picker', () => {
it('discards an unaccepted setup when the editor owner closes', () => {
const onDraftChange = vi.fn()
const form = renderSidebar(onDraftChange)
openPicker()
fireEvent.click(screen.getByRole('button', { name: 'Configure Codex' }))
fireEvent.change(document.querySelector('textarea')!, { target: { value: '--unaccepted' } })
form.unmount()
renderSidebar(onDraftChange)
openPicker()
fireEvent.click(screen.getByRole('button', { name: 'Configure Codex' }))
expect(document.querySelector('textarea')).toHaveProperty('value', '--base')
expect(onDraftChange).not.toHaveBeenCalled()
})
})
@@ -1,80 +0,0 @@
// @vitest-environment happy-dom
import '@testing-library/jest-dom/vitest'
import React from 'react'
import { cleanup, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { AutomationTimeField } from './AutomationTimeField'
afterEach(() => {
cleanup()
})
function ControlledTimeField({
initialTime = '09:15',
mode = 'time',
onTimeChange
}: {
initialTime?: string
mode?: 'time' | 'minute'
onTimeChange?: (time: string) => void
}): React.JSX.Element {
const [time, setTime] = React.useState(initialTime)
return (
<AutomationTimeField
time={time}
mode={mode}
onTimeChange={(next) => {
setTime(next)
onTimeChange?.(next)
}}
/>
)
}
describe('AutomationTimeField interactions', () => {
it('commits typed hour/minute and toggles AM/PM into 24h storage', async () => {
const user = userEvent.setup()
const onTimeChange = vi.fn()
render(<ControlledTimeField onTimeChange={onTimeChange} />)
const hour = screen.getByLabelText('Hour')
await user.clear(hour)
await user.type(hour, '11')
expect(onTimeChange).toHaveBeenLastCalledWith('11:15')
onTimeChange.mockClear()
const minute = screen.getByLabelText('Minute')
await user.clear(minute)
await user.type(minute, '05')
expect(onTimeChange).toHaveBeenLastCalledWith('11:05')
onTimeChange.mockClear()
await user.click(screen.getByRole('button', { name: /^AM or PM:/ }))
expect(onTimeChange).toHaveBeenLastCalledWith('23:05')
expect(screen.getByRole('button', { name: /^AM or PM:/ })).toHaveTextContent('PM')
})
it('treats empty blur as min and does not re-fire after 2-digit auto-commit', async () => {
const user = userEvent.setup()
const onTimeChange = vi.fn()
render(<ControlledTimeField onTimeChange={onTimeChange} />)
const minute = screen.getByLabelText('Minute')
await user.clear(minute)
await user.tab()
expect(onTimeChange).toHaveBeenLastCalledWith('09:00')
expect(minute).toHaveValue('00')
onTimeChange.mockClear()
await user.click(minute)
await user.clear(minute)
await user.type(minute, '30')
// 2-digit entry auto-commits once; blur must not emit a second identical update.
const callsAfterType = onTimeChange.mock.calls.length
expect(onTimeChange).toHaveBeenLastCalledWith('09:30')
await user.tab()
expect(onTimeChange.mock.calls.length).toBe(callsAfterType)
})
})
@@ -43,21 +43,6 @@ function runtimeAutomationCalls(): string[] {
describe('AutomationsPage row actions under a colliding automation id', () => {
installAutomationsPageHarness()
it('names the selected row’s own host, not the desktop that listed it', async () => {
await collidingHosts()
await renderPage()
await settleHostQueries()
const remote = listedRows().find((candidate) => candidate.automation.name === 'Remote nightly')
await act(async () => {
mocks.listPanel?.selectAutomationRow(remote?.key ?? '')
})
// The record’s local target means local to its server; the catalog entry supplies the displayed host.
expect(mocks.detailPane?.selected?.name).toBe('Remote nightly')
expect(mocks.detailPane?.selectedHostEntry?.authorityLabel).toBe('GPU box')
})
it('runs the selected desktop row on the desktop, not on the runtime holding the same id', async () => {
await collidingHosts()
const { container } = await renderPage()
@@ -17,11 +17,7 @@ import {
settleHostQueries
} from './automations-page-test-harness'
import { listedRows } from './automations-page-listed-items'
import { makeAutomation, makeRun, WORKSPACE_ID } from './automations-page-fixtures'
import {
AUTOMATIONS_CHANGED_EVENT,
emitAutomationsChangedWindowEvent
} from '@/lib/automations-changed-window-event'
import { makeAutomation, makeRun } from './automations-page-fixtures'
async function openAutomationRow(container: HTMLElement, name: string): Promise<void> {
const row = [
@@ -32,267 +28,9 @@ async function openAutomationRow(container: HTMLElement, name: string): Promise<
await settleHostQueries()
}
describe('AutomationsPage refresh', () => {
installAutomationsPageHarness()
it.each(['desktop', 'runtime'] as const)(
'refreshes count and exact saved output on successive %s completion events without re-entry',
async (authority) => {
const automation = makeAutomation({ name: 'Selected nightly' })
scopedList(authority === 'desktop' ? [automation] : [])
api.automations.list.mockResolvedValue(authority === 'desktop' ? [automation] : [])
if (authority === 'runtime') {
runtimeHost([automation], [])
mocks.state.automationHostFilter = RUNTIME_SELF_FILTER
}
const { container } = await renderPage()
await openAutomationRow(container, automation.name)
const count = container.querySelector('[data-testid="detail-run-count"]')
expect(count?.textContent).toBe('0')
const reads = (): unknown[][] =>
mocks.callRuntimeRpc.mock.calls.filter(([, method]) => method === 'automation.runs')
const beforeEvents = reads().length
for (const unrelated of [
{
environmentId: authority === 'desktop' ? 'gpu' : null,
selector: { kind: 'self' as const }
},
{
environmentId: authority === 'runtime' ? 'gpu' : null,
selector: { kind: 'ssh' as const, targetId: 'elsewhere' }
}
]) {
await act(async () => emitAutomationsChangedWindowEvent({ ...unrelated, reason: 'run' }))
await settleHostQueries()
expect(reads()).toHaveLength(beforeEvents)
expect(container.querySelector('[data-testid="detail-run-count"]')).toBe(count)
}
const event = {
...(authority === 'runtime' ? { environmentId: 'gpu' } : {}),
selector: { kind: 'self' as const },
reason: 'run' as const
}
const first = makeRun({
id: 'first-completed',
outputSnapshot: {
format: 'plain_text',
content: 'First exact reply',
capturedAt: 1,
truncated: false
}
})
const answer = (runs: (typeof first)[]): void => {
api.automations.listRuns.mockResolvedValue(runs)
if (authority === 'runtime') {
mocks.state.runtimeAnswers = { automations: [automation], runs }
}
}
answer([first])
await act(async () => emitAutomationsChangedWindowEvent(event))
await settleHostQueries()
expect(count?.textContent).toBe('1')
expect(mocks.detailPane?.selectedRuns).toEqual([first])
expect(reads()).toHaveLength(beforeEvents + 1)
await act(async () => mocks.detailPane?.openAutomationRunPage(first))
expect(container.textContent).toContain('First exact reply')
const revised = {
...first,
outputSnapshot: { ...first.outputSnapshot!, content: 'Settled first exact reply' }
}
const second = makeRun({ id: 'second-completed' })
answer([second, revised])
await act(async () => emitAutomationsChangedWindowEvent(event))
await settleHostQueries()
expect(container.textContent).toContain('Settled first exact reply')
expect(reads()).toHaveLength(beforeEvents + 2)
await act(async () =>
container.querySelector<HTMLButtonElement>('[aria-label="Back to runs"]')?.click()
)
expect(container.querySelector('[data-testid="detail-run-count"]')?.textContent).toBe('2')
expect(mocks.detailPane?.selectedRuns.map((run) => run.id)).toEqual([
'second-completed',
'first-completed'
])
for (const [target, , params, options] of reads().slice(beforeEvents)) {
expect(target).toEqual(
authority === 'runtime'
? { kind: 'environment', environmentId: 'gpu' }
: { kind: 'local' }
)
expect(params).toEqual({
automationId: automation.id,
expectedOwner: SELF_PRECONDITION,
preview: true
})
if (authority === 'runtime') {
expect(options).toMatchObject({ expectedEnvironmentPairingRevision: 4 })
}
}
await settleHostQueries()
expect(reads()).toHaveLength(beforeEvents + 2)
}
)
})
describe('AutomationsPage selection', () => {
installAutomationsPageHarness()
it('keeps an acquired exact run through definition removal, failed history settlement and Back', async () => {
const automation = makeAutomation({ id: 'a-1', name: 'Nightly' })
const leafId = '11111111-1111-4111-8111-111111111111'
const run = makeRun({
id: 'old-run',
automationId: automation.id,
workspaceId: WORKSPACE_ID,
workspaceDisplayName: 'Original workspace',
terminalSessionId: 'recorded-tab',
terminalPaneKey: `recorded-tab:${leafId}`,
terminalPtyId: 'recorded-pty',
outputSnapshot: {
format: 'plain_text',
content: 'Saved exact historical output',
capturedAt: 1,
truncated: false
}
})
scopedList([automation])
api.automations.list.mockResolvedValue([automation])
api.automations.listRuns.mockResolvedValue([run])
mocks.state.selectedAutomationId = automation.id
mocks.state.setSelectedAutomationId = (id: string | null) => {
mocks.state.selectedAutomationId = id
}
mocks.state.tabsByWorktree = {}
mocks.state.folderWorkspaces = []
mocks.state.projectGroups = []
mocks.state.unifiedTabsByWorktree = {
[WORKSPACE_ID]: [
{
id: 'recorded-tab',
entityId: 'recorded-tab',
worktreeId: WORKSPACE_ID,
contentType: 'terminal',
executionHostId: 'local'
}
]
}
mocks.state.terminalLayoutsByTabId = {
'recorded-tab': {
root: { type: 'leaf', leafId },
activeLeafId: leafId,
ptyIdsByLeafId: { [leafId]: 'recorded-pty' }
}
}
mocks.state.ptyIdsByTabId = { 'recorded-tab': ['recorded-pty'] }
const { container, rerender } = await renderPage()
await openAutomationRow(container, 'Nightly')
const retryHistory = mocks.detailPane?.recoverSelectedRuns
await act(async () => mocks.detailPane?.openAutomationRunPage(run))
expect(container.textContent).toContain('Saved exact historical output')
expect(
[...container.querySelectorAll('button')].some((button) => button.textContent === 'View run')
).toBe(true)
scopedList([])
api.automations.list.mockResolvedValue([])
api.automations.listRuns.mockRejectedValue(new Error('History temporarily unavailable'))
const readsBeforeFailure = api.automations.listRuns.mock.calls.length
await act(async () =>
emitAutomationsChangedWindowEvent({ selector: { kind: 'self' }, reason: 'run' })
)
await settleHostQueries()
expect(api.automations.listRuns.mock.calls.length).toBe(readsBeforeFailure + 1)
expect(container.textContent).toContain('Saved exact historical output')
await rerender()
const readsBeforeRetry = api.automations.listRuns.mock.calls.length
await act(async () => retryHistory?.('retry'))
await settleHostQueries()
expect(api.automations.listRuns.mock.calls.length).toBeGreaterThan(readsBeforeRetry)
expect(container.textContent).toContain('Saved exact historical output')
expect(container.querySelector('[aria-label="Back to runs"]')).not.toBeNull()
expect(
[...container.querySelectorAll('button')].some((button) => button.textContent === 'View run')
).toBe(true)
await act(async () =>
container.querySelector<HTMLButtonElement>('[aria-label="Back to runs"]')?.click()
)
expect(container.querySelector('[data-testid="list-panel"]')).not.toBeNull()
expect(mocks.toastMessage).not.toHaveBeenCalledWith('Run history no longer available.')
})
it('reacquires a same-row SSH incarnation only after explicit selection, retaining old output through Retry and Back', async () => {
const automation = makeAutomation({ id: 'ssh-a', name: 'Captured SSH' })
mocks.state.selectedAutomationId = automation.id
mocks.state.setSelectedAutomationId = (id: string | null) => {
mocks.state.selectedAutomationId = id
}
const run = makeRun({
id: 'older-ssh-run',
automationId: automation.id,
outputSnapshot: {
format: 'plain_text',
content: 'Captured old output',
capturedAt: 1,
truncated: false
}
})
mocks.state.folderWorkspaces = []
mocks.state.projectGroups = []
let generation = 7
mocks.state.sshTargetLabels = new Map([['box', 'Box']])
mocks.state.sshTargetGenerations = new Map([['box', generation]])
mocks.state.sshConnectionStates = new Map([['box', { status: 'connected' }]])
api.automations.listScoped.mockImplementation(async (args) => ({
automations: args?.selector?.kind === 'ssh' ? [automation] : [],
items:
args?.selector?.kind === 'ssh'
? [
{
automationId: automation.id,
selector: { kind: 'ssh', targetId: 'box', targetGeneration: generation }
}
]
: [],
orphanCount: 0
}))
api.automations.listRuns.mockResolvedValue([run])
const { container, rerender } = await renderPage()
await openAutomationRow(container, 'Captured SSH')
await act(async () => mocks.detailPane?.openAutomationRunPage(run))
expect(container.textContent).toContain('Captured old output')
generation = 9
mocks.state.sshTargetGenerations = new Map([['box', generation]])
await rerender()
await act(async () => window.dispatchEvent(new Event(AUTOMATIONS_CHANGED_EVENT)))
await settleHostQueries()
expect(container.textContent).toContain('Captured old output')
const back = container.querySelector<HTMLButtonElement>('[aria-label="Back to runs"]')
expect(back).not.toBeNull()
await act(async () => back?.click())
expect(container.querySelector('[data-testid="detail-pane"]')).not.toBeNull()
const beforeRetry = api.automations.listRuns.mock.calls.length
await act(async () => mocks.detailPane?.recoverSelectedRuns('retry'))
await settleHostQueries()
expect(api.automations.listRuns.mock.calls.length).toBeGreaterThan(beforeRetry)
expect(
api.automations.listRuns.mock.calls
.slice(beforeRetry)
.every(([args]) => args?.expectedOwner?.selector?.targetGeneration !== 9)
).toBe(true)
expect(mocks.detailPane?.selectedRuns).toEqual([run])
const automations = [...container.querySelectorAll<HTMLButtonElement>('nav button')].find(
(button) => button.textContent === 'Automations'
)
expect(automations).toBeTruthy()
await act(async () => automations?.click())
const beforeReselect = api.automations.listRuns.mock.calls.length
await openAutomationRow(container, 'Captured SSH')
expect(
api.automations.listRuns.mock.calls
.slice(beforeReselect)
.some(([args]) => args?.expectedOwner?.selector?.targetGeneration === 9)
).toBe(true)
})
it('fetches the newly selected automation runs when the selection changes', async () => {
scopedList([
makeAutomation({ id: 'a-1', name: 'Nightly' }),
@@ -1,113 +0,0 @@
// @vitest-environment happy-dom
import { act } from 'react'
import { within } from '@testing-library/react'
import { describe, expect, it, vi } from 'vitest'
import type { AutomationRun } from '../../../../shared/automations/history/automation-run'
import {
api,
installAutomationsPageHarness,
mocks,
renderPage,
scopedList,
settleHostQueries
} from './automations-page-test-harness'
import { makeAutomation, makeRun } from './automations-page-fixtures'
vi.mock('@tanstack/react-virtual', async () => {
const { createVirtualizerStub } = await import('./virtualizer-test-stub')
return { useVirtualizer: createVirtualizerStub() }
})
installAutomationsPageHarness()
async function loadCachedHistory() {
const automation = makeAutomation()
const oldRun = makeRun({ id: 'run-26', runNumber: 26 })
api.automations.list.mockResolvedValue([automation])
scopedList([automation])
api.automations.listRuns.mockResolvedValue([oldRun])
mocks.state.selectedAutomationId = automation.id
mocks.state.setPendingAutomationRunNavigation = mocks.setPendingRunNavigation
mocks.setPendingRunNavigation.mockImplementation((navigation) => {
mocks.state.pendingAutomationRunNavigation = navigation
})
const page = await renderPage()
await settleHostQueries()
return { ...page, automation, oldRun }
}
async function openDashboardRun(
container: HTMLElement,
newRun: AutomationRun,
oldRun: AutomationRun
) {
const fresh = Promise.withResolvers<AutomationRun[]>()
api.automations.listRuns.mockImplementation((args?: { limit?: number }) =>
args?.limit ? Promise.resolve([newRun, oldRun]) : fresh.promise
)
await act(async () => within(container).getByRole('button', { name: 'Runs' }).click())
await act(async () => {
within(container)
.getByRole('button', { name: new RegExp(newRun.title) })
.click()
})
return fresh
}
describe('AutomationsPage run navigation', () => {
it('keeps the runs dashboard open when the user backs out of a pending read', async () => {
const { container, oldRun } = await loadCachedHistory()
const newRun = makeRun({ id: 'run-27', title: 'Nightly run 27' })
const fresh = await openDashboardRun(container, newRun, oldRun)
const breadcrumb = within(container).getByRole('navigation', {
name: 'Automations breadcrumb'
})
await act(async () => within(breadcrumb).getByRole('button', { name: 'Runs' }).click())
await act(async () => fresh.resolve([newRun, oldRun]))
expect(mocks.state.pendingAutomationRunNavigation).toBeNull()
expect(within(container).getByRole('textbox', { name: 'Search runs…' })).toBeTruthy()
expect(container.querySelector('[aria-label="Run context"]')).toBeNull()
expect(mocks.toastMessage).not.toHaveBeenCalled()
})
it('returns to automation details when cancelling a workspace run link from there', async () => {
const { container, rerender, automation, oldRun } = await loadCachedHistory()
await act(async () => within(container).getByRole('button', { name: 'Nightly' }).click())
const fresh = Promise.withResolvers<AutomationRun[]>()
api.automations.listRuns.mockReturnValue(fresh.promise)
mocks.state.pendingAutomationRunNavigation = {
automationId: automation.id,
runId: oldRun.id
}
await rerender()
expect(within(container).getByRole('status')).toBeTruthy()
await act(async () => {
window.dispatchEvent(
new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true })
)
})
expect(mocks.state.pendingAutomationRunNavigation).toBeNull()
await act(async () => fresh.resolve([oldRun]))
expect(within(container).getByTestId('detail-pane')).toBeTruthy()
expect(container.querySelector('[aria-label="Run context"]')).toBeNull()
expect(mocks.toastMessage).not.toHaveBeenCalled()
})
it('shows the history error when opening a run from the dashboard fails', async () => {
const { container, oldRun } = await loadCachedHistory()
const newRun = makeRun({ id: 'run-27', title: 'Nightly run 27' })
const fresh = await openDashboardRun(container, newRun, oldRun)
await act(async () => fresh.reject(new Error('Host disconnected')))
expect(mocks.state.pendingAutomationRunNavigation).toBeNull()
expect(mocks.toastMessage).not.toHaveBeenCalled()
expect(container.querySelector('[data-testid="detail-pane"]')).not.toBeNull()
expect(mocks.detailPane?.selectedRunsNotice?.message).toContain('Host disconnected')
})
})
@@ -1,5 +1,8 @@
import React from 'react'
import { AutomationDeleteDialog, ExternalAutomationDeleteDialog } from './AutomationDeleteDialogs'
import {
AutomationDeleteDialog,
ExternalAutomationDeleteDialog
} from './authoring/AutomationDeleteDialogs'
type Props = {
deleteTarget: React.ComponentProps<typeof AutomationDeleteDialog>['deleteTarget']
@@ -1,7 +1,7 @@
import React from 'react'
import type { AutomationsPageController } from './use-automations-page-controller'
import { AutomationsListPanel } from './AutomationsListPanel'
import { nextAutomationListSort } from './automation-list-view'
import { AutomationsListPanel } from './listing/AutomationsListPanel'
import { nextAutomationListSort } from './listing/automation-list-view'
export function AutomationsPageListPanel({
controller,
@@ -1,6 +1,6 @@
import React from 'react'
import { cn } from '@/lib/utils'
import { AUTOMATIONS_TABLE_GRID_CLASS } from './automations-table-layout'
import { AUTOMATIONS_TABLE_GRID_CLASS } from './listing/automations-table-layout'
import {
LIST_TABLE_CONTAINER_CLASS,
LIST_TABLE_HEADER_CLASS,
@@ -1,16 +1,19 @@
import React from 'react'
import { useTranslate } from '@/i18n/use-translate'
import { LoadingSpinner } from '@/components/LoadingSpinner'
import { AutomationEditorDialog } from './AutomationEditorDialog'
import { AutomationsDetailPane } from './AutomationsDetailPane'
import { AutomationEditorDialog } from './authoring/AutomationEditorDialog'
import { AutomationsDetailPane } from './details/AutomationsDetailPane'
import { AutomationsPageSkeleton } from './AutomationsPageSkeleton'
import { getAutomationAuthorityTarget } from './automation-host-client'
import { automationProjectName, type AutomationListRow } from './automation-list-row-identity'
import type { AutomationHostRecoveryAction } from './automation-host-status-descriptors'
import { getAutomationAuthorityTarget } from './hosts/automation-host-client'
import {
automationProjectName,
type AutomationListRow
} from './listing/automation-list-row-identity'
import type { AutomationHostRecoveryAction } from './hosts/automation-host-status-descriptors'
import { AutomationsPageTopBar } from './AutomationsPageTopBar'
import type { AutomationsPageController } from './use-automations-page-controller'
import { AutomationRunsDashboardSurface } from './AutomationRunsDashboardSurface'
import { AutomationRunDetailsPage } from './AutomationRunDetailsPage'
import { AutomationRunsDashboardSurface } from './runs/AutomationRunsDashboardSurface'
import { AutomationRunDetailsPage } from './runs/AutomationRunDetailsPage'
import { AutomationsPageDeleteDialogs } from './AutomationsPageDeleteDialogs'
import { AutomationsPageListPanel } from './AutomationsPageListPanel'
export function AutomationsPageSurface({
@@ -1,9 +1,9 @@
import React from 'react'
import { useTranslate } from '@/i18n/use-translate'
import { AutomationOwnerConflictNotice } from './AutomationOwnerConflictNotice'
import { AutomationOwnerConflictNotice } from './hosts/AutomationOwnerConflictNotice'
import { AutomationsPageBreadcrumb } from './AutomationsPageBreadcrumb'
import type { AutomationHostRecoveryAction } from './automation-host-status-descriptors'
import type { AutomationActionNotice } from './automation-row-action-dispatch'
import type { AutomationHostRecoveryAction } from './hosts/automation-host-status-descriptors'
import type { AutomationActionNotice } from './hosts/automation-row-action-dispatch'
export function AutomationsPageTopBar({
pageView,
@@ -1,7 +1,7 @@
import { useCallback, useMemo, useState, type ComponentProps } from 'react'
import { useAppStore } from '@/store'
import { useAppStore } from '@/store/index'
import { AgentLaunchPicker } from '@/components/agent/AgentLaunchPicker'
import { useAgentPickerDraftScope } from '@/components/agent/AgentLaunchSetupButton'
import { useAgentPickerDraftScope } from '@/components/agent/agent-launch-picker-drafts'
import { useAgentLaunchPickerInventory } from '@/components/agent/use-agent-launch-picker-inventory'
import { useAgentMenuObservation } from '@/components/tab-bar/use-new-tab-agent-menu-rows'
import {
@@ -11,15 +11,15 @@ import {
type ProspectiveWorkspace
} from '@/lib/agent-session/launch/routing/agent-launch-route-input'
import type { AgentCatalogEntry } from '@/lib/agent-catalog/agent-catalog'
import { parseExecutionHostId } from '../../../../shared/execution-host'
import { AUTOMATION_LAUNCH_SETUP_RUNTIME_CAPABILITY } from '../../../../shared/automations/automation-runtime-capabilities'
import { automationLegacyArguments } from '../../../../shared/automations/launch/automation-legacy-arguments'
import type { AutomationAuthorityRef } from '../../../../shared/automations/ownership/automation-owner-ref'
import { parseExecutionHostId } from '../../../../../shared/execution-host'
import { AUTOMATION_LAUNCH_SETUP_RUNTIME_CAPABILITY } from '../../../../../shared/automations/automation-runtime-capabilities'
import { automationLegacyArguments } from '../../../../../shared/automations/launch/automation-legacy-arguments'
import type { AutomationAuthorityRef } from '../../../../../shared/automations/ownership/automation-owner-ref'
import { Button } from '@/components/ui/button'
import { useTranslate } from '@/i18n/use-translate'
import { draftExtraAgentArgsNeedFreshSession } from './automation-draft-model'
import type { AgentDetectionTarget } from '@/hooks/useDetectedAgents'
import type { AgentPickerEntry } from '../../../../shared/agent-launch/picker/agent-launch-picker'
import type { AgentPickerEntry } from '../../../../../shared/agent-launch/picker/agent-launch-picker'
import type { NewTabAgentMenuModel } from '@/components/tab-bar/new-tab-agent-menu-model'
import { useAutomationAgentPickerEntries } from './use-automation-agent-picker-entries'
import { AutomationExtraAgentArgsField } from './AutomationExtraAgentArgsField'
@@ -30,7 +30,7 @@ import {
editAutomationLegacyDraft,
editsSupplementalArguments
} from './automation-launch-draft'
import type { GlobalSettings } from '../../../../shared/global-settings-types'
import type { GlobalSettings } from '../../../../../shared/global-settings-types'
function legacyArgumentsDraft(draft: AutomationDraft): AutomationDraft {
return {
@@ -2,11 +2,11 @@ import React from 'react'
import { CheckCircle2, CircleAlert } from 'lucide-react'
import { Input } from '@/components/ui/input'
import { cn } from '@/lib/utils'
import { describeAutomationSchedule } from '../../../../shared/automations/scheduling/automation-schedules'
import { getAutomationCronExpressionFields } from '../../../../shared/automations/scheduling/automation-schedule-parsing'
import { formatUiAutomationScheduleDescriptor } from './automation-schedule-label'
import { describeAutomationSchedule } from '../../../../../shared/automations/scheduling/automation-schedules'
import { getAutomationCronExpressionFields } from '../../../../../shared/automations/scheduling/automation-schedule-parsing'
import { formatUiAutomationScheduleDescriptor } from '../details/automation-schedule-label'
import type { AutomationDraft } from './AutomationEditorDialog'
import { Field } from './automation-page-parts'
import { Field } from '../automation-page-parts'
import { translate } from '@/i18n/i18n'
import { useIntlLocale, useTranslate, type Translate } from '@/i18n/use-translate'
@@ -9,13 +9,13 @@ import {
DialogHeader,
DialogTitle
} from '@/components/ui/dialog'
import type { Automation } from '../../../../shared/automations/automation-definition'
import type { Automation } from '../../../../../shared/automations/automation-definition'
import type {
ExternalAutomationJob,
ExternalAutomationManager
} from '../../../../shared/automations/external/external-automation'
import { getExternalAutomationScheduleDisplay } from './external-automation-schedule-display'
import { getExternalProviderLabel } from './external-automation-display'
} from '../../../../../shared/automations/external/external-automation'
import { getExternalAutomationScheduleDisplay } from '../external/external-automation-schedule-display'
import { getExternalProviderLabel } from '../external/external-automation-display'
import { Trans } from 'react-i18next'
import { i18n } from '@/i18n/i18n'
import { useIntlLocale, useTranslate } from '@/i18n/use-translate'
@@ -1,14 +1,14 @@
import React from 'react'
import { HostCombobox } from '@/components/host-picker/HostCombobox'
import { useTranslate } from '@/i18n/use-translate'
import { AutomationHostLabel, AutomationHostStatusBadges } from './AutomationHostBadges'
import { Field } from './automation-page-parts'
import { AutomationHostLabel, AutomationHostStatusBadges } from '../hosts/AutomationHostBadges'
import { Field } from '../automation-page-parts'
import {
automationCreateHostEligible,
automationCreateHostOffered,
automationCreateUpdateRequiredAuthorityLabels
} from './automation-create-destination'
import { groupAutomationHostEntriesByAuthority } from './automation-host-picker-groups'
import { groupAutomationHostEntriesByAuthority } from '../hosts/automation-host-picker-groups'
import type { AutomationCreateDestinationControl } from './use-automation-create-destination'
// This host stores/schedules the automation and may differ from workspace execution; saving an existing record elsewhere moves it.
@@ -1,6 +1,6 @@
import type { AutomationAuthorityRef } from '../../../../shared/automations/ownership/automation-owner-ref'
import type { AutomationAuthorityRef } from '../../../../../shared/automations/ownership/automation-owner-ref'
import React from 'react'
import { useAppStore } from '@/store'
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 {
@@ -10,26 +10,26 @@ import {
} from './automation-launch-surface'
import { Dialog, DialogContent } from '@/components/ui/dialog'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import { filterEnabledTuiAgents } from '../../../../shared/agent-launch/catalog/tui-agent-selection'
import { filterEnabledTuiAgents } from '../../../../../shared/agent-launch/catalog/tui-agent-selection'
import type {
AutomationLaunchPreferences,
AutomationLaunchSetupPatch
} from '../../../../shared/automations/launch/automation-launch-types'
} from '../../../../../shared/automations/launch/automation-launch-types'
import type {
AutomationSchedulePreset,
AutomationWorkspaceMode
} from '../../../../shared/automations/automation-definition'
import type { GlobalSettings } from '../../../../shared/global-settings-types'
import type { OrcaHooks } from '../../../../shared/orca-yaml-hook-types'
import type { ProjectHostSetup } from '../../../../shared/project-types'
import type { Repo } from '../../../../shared/repo-types'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
import type { SetupDecision } from '../../../../shared/worktree/create-types'
import type { Worktree } from '../../../../shared/worktree/types'
} from '../../../../../shared/automations/automation-definition'
import type { GlobalSettings } from '../../../../../shared/global-settings-types'
import type { OrcaHooks } from '../../../../../shared/orca-yaml-hook-types'
import type { ProjectHostSetup } from '../../../../../shared/project-types'
import type { Repo } from '../../../../../shared/repo-types'
import type { TuiAgent } from '../../../../../shared/agent-launch/catalog/tui-agent'
import type { SetupDecision } from '../../../../../shared/worktree/create-types'
import type { Worktree } from '../../../../../shared/worktree/types'
import { closeUnfocusedMonacoFindOrPreventDialogDismiss } from '@/components/editor/monaco-find-widget'
import { AutomationOwnerConflictNotice } from './AutomationOwnerConflictNotice'
import type { AutomationActionNotice } from './automation-row-action-dispatch'
import type { AutomationHostRecoveryAction } from './automation-host-status-descriptors'
import { AutomationOwnerConflictNotice } from '../hosts/AutomationOwnerConflictNotice'
import type { AutomationActionNotice } from '../hosts/automation-row-action-dispatch'
import type { AutomationHostRecoveryAction } from '../hosts/automation-host-status-descriptors'
import type { AutomationCreateDestinationControl } from './use-automation-create-destination'
import { AutomationEditorDialogFooter } from './AutomationEditorDialogFooter'
import { AutomationEditorDialogHeader } from './AutomationEditorDialogHeader'
@@ -15,7 +15,7 @@ vi.mock('@monaco-editor/react', () => ({
loader: { config: vi.fn() }
}))
vi.mock('@/lib/editor/monaco/monaco-setup', () => ({ monaco: {} }))
vi.mock('@/store', () => ({
vi.mock('@/store/index', () => ({
useAppStore: (selector: (state: Record<string, unknown>) => unknown) =>
selector({
settings: { theme: 'dark', terminalFontSize: 13, terminalFontFamily: 'monospace' },
@@ -30,12 +30,7 @@ vi.mock('@/components/editor/monaco-content-sync', () => ({
syncContentUpdate
}))
import { closeUnfocusedMonacoFindOrPreventDialogDismiss } from '@/components/editor/monaco-find-widget'
import {
AUTOMATION_PROMPT_EDITOR_SLOT,
AutomationEditorPromptEditor,
getAutomationPromptEditorRoot
} from './AutomationEditorPromptEditor'
import { AutomationEditorPromptEditor } from './AutomationEditorPromptEditor'
afterEach(() => {
cleanup()
@@ -75,37 +70,4 @@ describe('AutomationEditorPromptEditor', () => {
editorDom.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
expect(onDismiss).toHaveBeenCalledTimes(1)
})
it('scopes find-widget lookups to the prompt editor slot, not the document', () => {
const dialog = document.createElement('div')
const editorRoot = document.createElement('div')
editorRoot.setAttribute('data-slot', AUTOMATION_PROMPT_EDITOR_SLOT)
const nameField = document.createElement('input')
const background = document.createElement('div')
const backgroundFind = document.createElement('div')
backgroundFind.className = 'find-widget'
const closeButton = document.createElement('button')
closeButton.className = 'button codicon-widget-close'
const onBackgroundClose = vi.fn()
closeButton.addEventListener('click', onBackgroundClose)
backgroundFind.append(closeButton)
background.append(backgroundFind)
dialog.append(editorRoot, nameField)
document.body.append(dialog, background)
expect(getAutomationPromptEditorRoot(dialog)).toBe(editorRoot)
// Radix Escape fires on document; document-wide lookup could find editors behind the dialog.
expect(getAutomationPromptEditorRoot(document)).toBeNull()
expect(getAutomationPromptEditorRoot(null)).toBeNull()
expect(
closeUnfocusedMonacoFindOrPreventDialogDismiss({
root: getAutomationPromptEditorRoot(dialog),
eventTarget: nameField
})
).toBe(false)
expect(onBackgroundClose).not.toHaveBeenCalled()
dialog.remove()
background.remove()
})
})
@@ -1,15 +1,15 @@
import type { AutomationAuthorityRef } from '../../../../shared/automations/ownership/automation-owner-ref'
import type { AutomationAuthorityRef } from '../../../../../shared/automations/ownership/automation-owner-ref'
import { AutomationAgentLaunchPicker } from './AutomationAgentLaunchPicker'
import type { ProspectiveWorkspace } from '@/lib/agent-session/launch/routing/agent-launch-route-input'
import { useTranslate } from '@/i18n/use-translate'
import { isValidAutomationSchedule } from '../../../../shared/automations/scheduling/automation-schedule-parsing'
import type { GlobalSettings } from '../../../../shared/global-settings-types'
import type { OrcaHooks } from '../../../../shared/orca-yaml-hook-types'
import type { ProjectHostSetup } from '../../../../shared/project-types'
import type { Repo } from '../../../../shared/repo-types'
import type { Worktree } from '../../../../shared/worktree/types'
import { isValidAutomationSchedule } from '../../../../../shared/automations/scheduling/automation-schedule-parsing'
import type { GlobalSettings } from '../../../../../shared/global-settings-types'
import type { OrcaHooks } from '../../../../../shared/orca-yaml-hook-types'
import type { ProjectHostSetup } from '../../../../../shared/project-types'
import type { Repo } from '../../../../../shared/repo-types'
import type { Worktree } from '../../../../../shared/worktree/types'
import type { AgentCatalogEntry } from '@/lib/agent-catalog/agent-catalog'
import { AUTOMATION_EDITOR_SECTION_LABEL_CLASS, Field } from './automation-page-parts'
import { AUTOMATION_EDITOR_SECTION_LABEL_CLASS, Field } from '../automation-page-parts'
import { AutomationMissedRunGraceField } from './AutomationMissedRunGraceField'
import { AutomationPrecheckFields } from './AutomationPrecheckFields'
import AutomationProjectCombobox from './AutomationProjectCombobox'
@@ -6,8 +6,8 @@ import {
getExtraAgentArgsPlaceholder,
hasExtraAgentArgs,
supportsExtraAgentArgs
} from '../../../../shared/agent-launch/startup/automation-extra-agent-args'
import { AUTOMATION_EDITOR_SECTION_LABEL_CLASS } from './automation-page-parts'
} from '../../../../../shared/agent-launch/startup/automation-extra-agent-args'
import { AUTOMATION_EDITOR_SECTION_LABEL_CLASS } from '../automation-page-parts'
import {
draftExtraAgentArgsNeedFreshSession,
getDraftExtraAgentArgsError
@@ -7,7 +7,7 @@ import {
SelectValue
} from '@/components/ui/select'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { AUTOMATION_EDITOR_SECTION_LABEL_CLASS, Field } from './automation-page-parts'
import { AUTOMATION_EDITOR_SECTION_LABEL_CLASS, Field } from '../automation-page-parts'
import type { AutomationDraft } from './AutomationEditorDialog'
import { useTranslate } from '@/i18n/use-translate'
@@ -5,7 +5,7 @@ import {
SelectTrigger,
SelectValue
} from '@/components/ui/select'
import { AUTOMATION_EDITOR_SECTION_LABEL_CLASS, Field } from './automation-page-parts'
import { AUTOMATION_EDITOR_SECTION_LABEL_CLASS, Field } from '../automation-page-parts'
import type { AutomationDraft } from './AutomationEditorDialog'
import { useTranslate } from '@/i18n/use-translate'
@@ -4,15 +4,15 @@ import { Button } from '@/components/ui/button'
import { Command, CommandInput, CommandList } from '@/components/ui/command'
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
import RepoBadgeLabel from '@/components/repo/RepoBadgeLabel'
import { useAppStore } from '@/store'
import { isGitRepoKind } from '../../../../shared/repo-kind'
import { getRepoExecutionHostId } from '../../../../shared/execution-host'
import { useAppStore } from '@/store/index'
import { isGitRepoKind } from '../../../../../shared/repo-kind'
import { getRepoExecutionHostId } from '../../../../../shared/execution-host'
import { isRepoSearchQueryTooLarge, searchRepos } from '@/lib/repo-search'
import { cn } from '@/lib/utils'
import { useMountedRef } from '@/hooks/useMountedRef'
import { useTranslate } from '@/i18n/use-translate'
import { projectHostCountLabel } from '@/components/project-host-count-label'
import type { Repo } from '../../../../shared/repo-types'
import type { Repo } from '../../../../../shared/repo-types'
import {
getAutomationProjectGroupForRepo,
getAutomationProjectGroups,
@@ -6,14 +6,14 @@ import {
SelectTrigger,
SelectValue
} from '@/components/ui/select'
import type { AutomationSchedulePreset } from '../../../../shared/automations/automation-definition'
import { buildAutomationCronSchedule } from '../../../../shared/automations/scheduling/automation-schedule-occurrences'
import { isValidAutomationSchedule } from '../../../../shared/automations/scheduling/automation-schedule-parsing'
import type { AutomationSchedulePreset } from '../../../../../shared/automations/automation-definition'
import { buildAutomationCronSchedule } from '../../../../../shared/automations/scheduling/automation-schedule-occurrences'
import { isValidAutomationSchedule } from '../../../../../shared/automations/scheduling/automation-schedule-parsing'
import type { AutomationDraft } from './AutomationEditorDialog'
import { AutomationCustomCronPanel } from './AutomationCustomCronPanel'
import { acceptsAutomationDraftSchedule } from '../../../../shared/automations/scheduling/automation-schedule-input-gate'
import { acceptsAutomationDraftSchedule } from '../../../../../shared/automations/scheduling/automation-schedule-input-gate'
import { AutomationTimeField, parseAutomationTime } from './AutomationTimeField'
import { Field } from './automation-page-parts'
import { Field } from '../automation-page-parts'
import { translate } from '@/i18n/i18n'
import { useIntlLocale, useTranslate, type Translate } from '@/i18n/use-translate'
import { getUiWeekdayNames } from '@/i18n/weekday-names'
@@ -1,7 +1,7 @@
import { Info } from 'lucide-react'
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { AUTOMATION_EDITOR_SECTION_LABEL_CLASS, Field } from './automation-page-parts'
import { AUTOMATION_EDITOR_SECTION_LABEL_CLASS, Field } from '../automation-page-parts'
import type { AutomationDraft } from './AutomationEditorDialog'
import { useTranslate } from '@/i18n/use-translate'
@@ -5,9 +5,9 @@ import { cn } from '@/lib/utils'
import { useTranslate } from '@/i18n/use-translate'
import { getVisibleAutomationSetupDecision } from './automation-setup-decision'
import type { AutomationDraft } from './AutomationEditorDialog'
import type { OrcaHooks } from '../../../../shared/orca-yaml-hook-types'
import type { ProjectHostSetup } from '../../../../shared/project-types'
import type { Repo } from '../../../../shared/repo-types'
import type { OrcaHooks } from '../../../../../shared/orca-yaml-hook-types'
import type { ProjectHostSetup } from '../../../../../shared/project-types'
import type { Repo } from '../../../../../shared/repo-types'
type AutomationSetupDecisionFieldProps = {
draft: AutomationDraft
@@ -1,8 +1,8 @@
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'
import { useTranslate } from '@/i18n/use-translate'
import { nativeChatPreferenceFor } from '../../../../shared/structured-native-chat-launch-route'
import type { GlobalSettings } from '../../../../shared/global-settings-types'
import { Field, AUTOMATION_EDITOR_SECTION_LABEL_CLASS } from './automation-page-parts'
import { nativeChatPreferenceFor } from '../../../../../shared/structured-native-chat-launch-route'
import type { GlobalSettings } from '../../../../../shared/global-settings-types'
import { Field, AUTOMATION_EDITOR_SECTION_LABEL_CLASS } from '../automation-page-parts'
import { automationDraftSurface } from './automation-launch-surface'
import type { AutomationDraft } from './AutomationEditorDialog'
@@ -3,10 +3,10 @@ import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { CreateFromPicker } from '@/components/repo/CreateFromPicker'
import { useTranslate } from '@/i18n/use-translate'
import type { AutomationWorkspaceMode } from '../../../../shared/automations/automation-definition'
import type { Repo } from '../../../../shared/repo-types'
import type { Worktree } from '../../../../shared/worktree/types'
import { AUTOMATION_EDITOR_SECTION_LABEL_CLASS, Field } from './automation-page-parts'
import type { AutomationWorkspaceMode } from '../../../../../shared/automations/automation-definition'
import type { Repo } from '../../../../../shared/repo-types'
import type { Worktree } from '../../../../../shared/worktree/types'
import { AUTOMATION_EDITOR_SECTION_LABEL_CLASS, Field } from '../automation-page-parts'
import { WorkspaceCombobox } from './WorkspaceCombobox'
import type { AutomationDraft } from './AutomationEditorDialog'
@@ -10,7 +10,7 @@ import {
} from '@/components/ui/command'
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
import { cn } from '@/lib/utils'
import type { Worktree } from '../../../../shared/worktree/types'
import type { Worktree } from '../../../../../shared/worktree/types'
import { useTranslate } from '@/i18n/use-translate'
export function WorkspaceCombobox({
@@ -3,24 +3,24 @@
import type {
AutomationAuthorityRef,
AutomationOwnerRef
} from '../../../../shared/automations/ownership/automation-owner-ref'
import type { AutomationDestination } from '../../../../shared/automations/ownership/automation-owner-precondition'
} from '../../../../../shared/automations/ownership/automation-owner-ref'
import type { AutomationDestination } from '../../../../../shared/automations/ownership/automation-owner-precondition'
import {
hostStableKey,
isSameAutomationOwner
} from '../../../../shared/automations/ownership/automation-owner-key'
import { getRepoSshConnectionId, parseExecutionHostId } from '../../../../shared/execution-host'
import type { Repo } from '../../../../shared/repo-types'
} from '../../../../../shared/automations/ownership/automation-owner-key'
import { getRepoSshConnectionId, parseExecutionHostId } from '../../../../../shared/execution-host'
import type { Repo } from '../../../../../shared/repo-types'
import type {
AutomationCatalogHydrationEvidence,
AutomationHostCatalogEntry
} from './automation-host-catalog-types'
import { automationAuthorityCatalogKey } from './automation-host-catalog-types'
} from '../hosts/automation-host-catalog-types'
import { automationAuthorityCatalogKey } from '../hosts/automation-host-catalog-types'
import {
repoConnectionIdIn,
type AutomationAuthorityRepoTables
} from './automation-authority-identity'
import { automationHostRecoveryActions } from './automation-host-status-descriptors'
} from '../hosts/automation-authority-identity'
import { automationHostRecoveryActions } from '../hosts/automation-host-status-descriptors'
export type AutomationCreateDestinationChoiceReason =
/** No host is selected and nothing may be assumed. */
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import type { Repo } from '../../../../shared/repo-types'
import type { Repo } from '../../../../../shared/repo-types'
import { getAutomationCreateRepos } from './automation-create-projects'
function repo(id: string, executionHostId: Repo['executionHostId']): Repo {
@@ -2,9 +2,9 @@ import {
getRepoExecutionHostId,
parseExecutionHostId,
toRuntimeExecutionHostId
} from '../../../../shared/execution-host'
import type { Repo } from '../../../../shared/repo-types'
import type { AutomationHostTarget } from './automation-host-client'
} from '../../../../../shared/execution-host'
import type { Repo } from '../../../../../shared/repo-types'
import type { AutomationHostTarget } from '../hosts/automation-host-client'
/** Runtime creation uses that host’s repo catalog; desktop storage retains its SSH-capable catalog. */
export function getAutomationCreateRepos(
@@ -1,12 +1,12 @@
import { buildAutomationRrule } from '../../../../shared/automations/scheduling/automation-schedule-occurrences'
import { automationLaunchInputs } from '../../../../shared/automations/launch/automation-launch-choices'
import { buildAutomationRrule } from '../../../../../shared/automations/scheduling/automation-schedule-occurrences'
import { automationLaunchInputs } from '../../../../../shared/automations/launch/automation-launch-choices'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import type { AutomationPrecheck } from '../../../../shared/automations/automation-definition'
import type { Worktree } from '../../../../shared/worktree/types'
import type { AutomationPrecheck } from '../../../../../shared/automations/automation-definition'
import type { Worktree } from '../../../../../shared/worktree/types'
import {
hasExtraAgentArgs,
parseExtraAgentArgs
} from '../../../../shared/agent-launch/startup/automation-extra-agent-args'
} from '../../../../../shared/agent-launch/startup/automation-extra-agent-args'
import type { AutomationDraft } from './AutomationEditorDialog'
import { extraAgentArgsErrorText } from './automation-extra-agent-args-error-copy'
@@ -1,11 +1,11 @@
import { automationCanonicalLaunchSetup } from '../../../../shared/automations/launch/automation-canonical-launch-setup'
import type { Automation } from '../../../../shared/automations/automation-definition'
import { automationCanonicalLaunchSetup } from '../../../../../shared/automations/launch/automation-canonical-launch-setup'
import type { Automation } from '../../../../../shared/automations/automation-definition'
import { translate } from '@/i18n/i18n'
import { getAutomationRunRepoId } from '../../../../shared/automations/history/automation-run-identity'
import { getAutomationRunRepoId } from '../../../../../shared/automations/history/automation-run-identity'
import {
isRunnableAutomationSchedule,
tryParseAutomationRrule
} from '../../../../shared/automations/scheduling/automation-schedule-parsing'
} from '../../../../../shared/automations/scheduling/automation-schedule-parsing'
import type { AutomationDraft } from './AutomationEditorDialog'
import { AUTOMATION_DEFAULT_TIME, formatTimeInput } from './automation-draft-model'
import { getAutomationSetupDecisionDraftValue } from './automation-setup-decision'
@@ -3,7 +3,7 @@ import {
EXTRA_AGENT_ARGS_FAILURE_COPY as EN,
type ExtraAgentArgsFailure,
type ExtraAgentArgsFailureCode
} from '../../../../shared/agent-launch/startup/automation-extra-agent-args'
} from '../../../../../shared/agent-launch/startup/automation-extra-agent-args'
const COPY: Record<ExtraAgentArgsFailureCode, (params: Record<string, string>) => string> = {
unsupportedAgent: () =>
@@ -1,13 +1,13 @@
import { automationLegacyArguments } from '../../../../shared/automations/launch/automation-legacy-arguments'
import { automationCanonicalLaunchSetup } from '../../../../shared/automations/launch/automation-canonical-launch-setup'
import { hasModernAutomationLaunchSetup } from '../../../../shared/automations/launch/automation-launch-setup'
import { automationLegacyArguments } from '../../../../../shared/automations/launch/automation-legacy-arguments'
import { automationCanonicalLaunchSetup } from '../../../../../shared/automations/launch/automation-canonical-launch-setup'
import { hasModernAutomationLaunchSetup } from '../../../../../shared/automations/launch/automation-launch-setup'
import {
foldAutomationSourceEdit,
type AutomationLaunchEdit
} from '../../../../shared/automations/launch/automation-launch-source-edits'
import { parseExtraAgentArgs } from '../../../../shared/agent-launch/startup/automation-extra-agent-args'
import type { AgentPickerDraft } from '../../../../shared/agent-launch/picker/agent-launch-picker'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
} from '../../../../../shared/automations/launch/automation-launch-source-edits'
import { parseExtraAgentArgs } from '../../../../../shared/agent-launch/startup/automation-extra-agent-args'
import type { AgentPickerDraft } from '../../../../../shared/agent-launch/picker/agent-launch-picker'
import type { TuiAgent } from '../../../../../shared/agent-launch/catalog/tui-agent'
import type { AutomationDraft } from './AutomationEditorDialog'
export function editsSupplementalArguments(draft: AutomationDraft, modern: boolean): boolean {
@@ -1,22 +1,22 @@
import { encodeAutomationLaunchEdit } from '../../../../shared/automations/launch/automation-launch-source-edits'
import { encodeAutomationLaunchEdit } from '../../../../../shared/automations/launch/automation-launch-source-edits'
import {
applyAutomationLaunchSetupPatch,
hasModernAutomationLaunchSetup
} from '../../../../shared/automations/launch/automation-launch-setup'
import { automationCanonicalLaunchSetup } from '../../../../shared/automations/launch/automation-canonical-launch-setup'
} from '../../../../../shared/automations/launch/automation-launch-setup'
import { automationCanonicalLaunchSetup } from '../../../../../shared/automations/launch/automation-canonical-launch-setup'
import type {
Automation,
AutomationUpdateInput,
AutomationCreateInput
} from '../../../../shared/automations/automation-definition'
import type { GlobalSettings } from '../../../../shared/global-settings-types'
import { AUTOMATION_SURFACE_RUNTIME_CAPABILITY } from '../../../../shared/automations/automation-runtime-capabilities'
} from '../../../../../shared/automations/automation-definition'
import type { GlobalSettings } from '../../../../../shared/global-settings-types'
import { AUTOMATION_SURFACE_RUNTIME_CAPABILITY } from '../../../../../shared/automations/automation-runtime-capabilities'
import {
STRUCTURED_AGENT_SESSION_RUNTIME_CAPABILITY,
STRUCTURED_AGENT_SESSION_CLIENT_LAUNCH_MODE_CAPABILITY
} from '../../../../shared/agent-session/agent-session-runtime-capabilities'
import { STRUCTURED_AGENT_SESSION_REGISTERED_AGENTS_RUNTIME_CAPABILITY } from '../../../../shared/agent-session/structured-agent-session-surface-capabilities'
import { nativeChatPreferenceFor } from '../../../../shared/structured-native-chat-launch-route'
} from '../../../../../shared/agent-session/agent-session-runtime-capabilities'
import { STRUCTURED_AGENT_SESSION_REGISTERED_AGENTS_RUNTIME_CAPABILITY } from '../../../../../shared/agent-session/structured-agent-session-surface-capabilities'
import { nativeChatPreferenceFor } from '../../../../../shared/structured-native-chat-launch-route'
import {
buildAgentLaunchRouteInput,
type AgentLaunchRouteStore,
@@ -1,10 +1,10 @@
import { describe, expect, it } from 'vitest'
import type { Automation } from '../../../../shared/automations/automation-definition'
import { isValidAutomationSchedule } from '../../../../shared/automations/scheduling/automation-schedule-parsing'
import type { Automation } from '../../../../../shared/automations/automation-definition'
import { isValidAutomationSchedule } from '../../../../../shared/automations/scheduling/automation-schedule-parsing'
import { buildAutomationEditDraft } from './automation-edit-draft'
import { acceptsAutomationDraftSchedule } from '../../../../shared/automations/scheduling/automation-schedule-input-gate'
import { acceptsAutomationDraftSchedule } from '../../../../../shared/automations/scheduling/automation-schedule-input-gate'
// `*/90` on minutes was accepted before the oversized-step refusal (#15895) and still runs,
// firing at :00. Only a row persisted by an older build can hold it.
@@ -70,9 +70,4 @@ describe('editing an automation whose saved schedule predates the input gate', (
})
// Only oversized steps receive legacy leniency; unparseable schedules still need warnings.
it('keeps warning about a saved schedule that cannot be parsed', () => {
const draft = buildAutomationEditDraft(makeAutomation({ rrule: '0 9 32 * *' }))
expect(draft.customSchedule).toBe('')
expect(draft.scheduleWarning).toBeTruthy()
})
})
@@ -1,13 +1,16 @@
import { deleteAutomationForTarget, updateAutomationForTarget } from './automation-host-client'
import type { AutomationUpdateInput } from '../../../../shared/automations/automation-definition'
import {
deleteAutomationForTarget,
updateAutomationForTarget
} from '../hosts/automation-host-client'
import type { AutomationUpdateInput } from '../../../../../shared/automations/automation-definition'
import {
dispatchAutomationDelete,
dispatchAutomationUpdate
} from './automation-row-action-dispatch'
} from '../hosts/automation-row-action-dispatch'
import { persistSkipDeleteAutomationConfirm } from './automation-delete-confirm-preference'
import type { AutomationListRow } from './automation-list-row-identity'
import type { AutomationsPageActionContext } from './automations-page-action-context'
import type { SetupTrustMismatch } from '../../../../shared/worktree/create-types'
import type { AutomationListRow } from '../listing/automation-list-row-identity'
import type { AutomationsPageActionContext } from '../automations-page-action-context'
import type { SetupTrustMismatch } from '../../../../../shared/worktree/create-types'
import { reviewAutomationSkippedSetup } from './automation-setup-review'
/** Fenced toggle/delete handlers and the confirmation preference flow. */
@@ -3,20 +3,20 @@ import type {
Automation,
AutomationCreateInput,
AutomationUpdateInput
} from '../../../../shared/automations/automation-definition'
} from '../../../../../shared/automations/automation-definition'
import type {
AutomationAuthorityRef,
StableAutomationCatalogRef
} from '../../../../shared/automations/ownership/automation-owner-ref'
import type { AutomationDestination } from '../../../../shared/automations/ownership/automation-owner-precondition'
} from '../../../../../shared/automations/ownership/automation-owner-ref'
import type { AutomationDestination } from '../../../../../shared/automations/ownership/automation-owner-precondition'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import {
deleteAutomationForTarget,
listAutomationsForTarget,
updateAutomationForTarget
} from './automation-host-client'
import { createAutomationAtDestination } from './automation-owner-action-runner'
} from '../hosts/automation-host-client'
import { createAutomationAtDestination } from '../hosts/automation-owner-action-runner'
import {
dispatchAutomationDelete,
dispatchAutomationReread,
@@ -25,16 +25,16 @@ import {
type AutomationActionNotice,
type AutomationDispatchContext,
type AutomationDispatchResult
} from './automation-row-action-dispatch'
} from '../hosts/automation-row-action-dispatch'
import {
revalidateAutomationCreateDestination,
type AutomationCreateDestination
} from './automation-create-destination'
import type { AutomationHostTarget } from './automation-host-client'
import type { AutomationAuthorityChangeReason } from './automation-host-invalidation'
import type { AutomationHostTarget } from '../hosts/automation-host-client'
import type { AutomationAuthorityChangeReason } from '../hosts/automation-host-invalidation'
import type { AutomationSaveContext } from './automation-save-context'
import { automationAuthorityCatalogKey } from './automation-host-catalog-types'
import { createNonSecureContextUuid as createBrowserUuid } from '../../../../shared/non-secure-context-uuid'
import { automationAuthorityCatalogKey } from '../hosts/automation-host-catalog-types'
import { createNonSecureContextUuid as createBrowserUuid } from '../../../../../shared/non-secure-context-uuid'
export type AutomationMoveOperationContext = {
automationDispatchContext: AutomationDispatchContext
@@ -3,7 +3,7 @@ import {
recordedAutomationRunContext,
isSameAutomationWorkspace
} from './automation-recorded-target'
import { capturedAutomationOwner } from './automation-captured-owner'
import { capturedAutomationOwner } from '../hosts/automation-captured-owner'
import {
automationChatSupport,
automationDraftLaunchSetup,
@@ -15,16 +15,16 @@ import type {
Automation,
AutomationCreateInput,
AutomationUpdateInput
} from '../../../../shared/automations/automation-definition'
import { getRepoExecutionHostId } from '../../../../shared/execution-host'
} from '../../../../../shared/automations/automation-definition'
import { getRepoExecutionHostId } from '../../../../../shared/execution-host'
import { ensureHooksApproved } from '@/lib/ensure-hooks-confirmed'
import { translate } from '@/i18n/i18n'
import { useAppStore } from '@/store'
import { listAutomationsForTarget } from './automation-host-client'
import { useAppStore } from '@/store/index'
import { listAutomationsForTarget } from '../hosts/automation-host-client'
import {
dispatchAutomationReread,
type AutomationDispatchResult
} from './automation-row-action-dispatch'
} from '../hosts/automation-row-action-dispatch'
import { buildDraftPrecheck, buildDraftSchedule } from './automation-draft-model'
import { buildAutomationRunContextForRepo } from './automation-run-context'
import { resolveAutomationSetupDecisionForSave } from './automation-setup-decision'
@@ -1,6 +1,9 @@
import { getRepoExecutionHostId, LOCAL_EXECUTION_HOST_ID } from '../../../../shared/execution-host'
import { getProjectIdentityKey } from '../../../../shared/project-host-setup-projection'
import type { Repo } from '../../../../shared/repo-types'
import {
getRepoExecutionHostId,
LOCAL_EXECUTION_HOST_ID
} from '../../../../../shared/execution-host'
import { getProjectIdentityKey } from '../../../../../shared/project-host-setup-projection'
import type { Repo } from '../../../../../shared/repo-types'
export type AutomationProjectGroup = {
projectKey: string
@@ -1,8 +1,8 @@
import type { Automation } from '../../../../shared/automations/automation-definition'
import { AUTOMATION_ORPHAN_ISSUES } from '../../../../shared/automations/ownership/automation-list-scope'
import { parseExecutionHostId } from '../../../../shared/execution-host'
import { automationAuthorityCatalogKey } from './automation-host-catalog-types'
import type { AutomationCapturedOwner } from './automation-captured-owner'
import type { Automation } from '../../../../../shared/automations/automation-definition'
import { AUTOMATION_ORPHAN_ISSUES } from '../../../../../shared/automations/ownership/automation-list-scope'
import { parseExecutionHostId } from '../../../../../shared/execution-host'
import { automationAuthorityCatalogKey } from '../hosts/automation-host-catalog-types'
import type { AutomationCapturedOwner } from '../hosts/automation-captured-owner'
import type { AutomationCreateDestination } from './automation-create-destination'
export function isSameAutomationWorkspace(
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import type { ProjectHostSetup } from '../../../../shared/project-types'
import type { Repo } from '../../../../shared/repo-types'
import type { ProjectHostSetup } from '../../../../../shared/project-types'
import type { Repo } from '../../../../../shared/repo-types'
import { buildAutomationRunContextForRepo } from './automation-run-context'
function repo(id: string, path = `/repos/${id}`, executionHostId?: Repo['executionHostId']): Repo {
@@ -1,10 +1,10 @@
import {
buildWorkspaceRunContext,
type WorkspaceRunContext
} from '../../../../shared/work-items/task-source-context'
import type { ProjectHostSetup } from '../../../../shared/project-types'
import type { Repo } from '../../../../shared/repo-types'
import { getRepoExecutionHostId } from '../../../../shared/execution-host'
} from '../../../../../shared/work-items/task-source-context'
import type { ProjectHostSetup } from '../../../../../shared/project-types'
import type { Repo } from '../../../../../shared/repo-types'
import { getRepoExecutionHostId } from '../../../../../shared/execution-host'
export function buildAutomationRunContextForRepo(args: {
repoId: string
@@ -1,14 +1,14 @@
import { useAppStore } from '@/store'
import { useAppStore } from '@/store/index'
import {
automationChatSupport,
automationDraftSurface,
automationLaunchWorkspace
} from './automation-launch-surface'
import { toast } from 'sonner'
import { isTuiAgentEnabled } from '../../../../shared/agent-launch/catalog/tui-agent-selection'
import { isValidAutomationSchedule } from '../../../../shared/automations/scheduling/automation-schedule-parsing'
import { isTuiAgentEnabled } from '../../../../../shared/agent-launch/catalog/tui-agent-selection'
import { isValidAutomationSchedule } from '../../../../../shared/automations/scheduling/automation-schedule-parsing'
import { translate } from '@/i18n/i18n'
import { acceptsAutomationDraftSchedule } from '../../../../shared/automations/scheduling/automation-schedule-input-gate'
import { acceptsAutomationDraftSchedule } from '../../../../../shared/automations/scheduling/automation-schedule-input-gate'
import {
draftExtraAgentArgsNeedFreshSession,
getDraftExtraAgentArgsError,
@@ -1,5 +1,5 @@
import type { Automation } from '../../../../shared/automations/automation-definition'
import { useAppStore } from '@/store'
import type { Automation } from '../../../../../shared/automations/automation-definition'
import { useAppStore } from '@/store/index'
import type { AutomationCreateDestination } from './automation-create-destination'
import type { AutomationSaveContext } from './automation-save-context'
import { showAutomationSavedToast } from './automation-orca-save-operations'
@@ -1,8 +1,8 @@
import type { AutomationsPageListState } from './use-automations-page-list-state'
import type { AutomationsPageLocalState } from './use-automations-page-local-state'
import type { AutomationsPageRefresh } from './use-automations-page-refresh'
import type { AutomationsPageListState } from '../listing/use-automations-page-list-state'
import type { AutomationsPageLocalState } from '../use-automations-page-local-state'
import type { AutomationsPageRefresh } from '../use-automations-page-refresh'
import type { AutomationsPageSetupState } from './use-automations-page-setup-state'
import type { AutomationsPageStoreState } from './use-automations-page-store-state'
import type { AutomationsPageStoreState } from '../use-automations-page-store-state'
import type { AutomationsPageDestinationState } from './use-automations-page-destination-state'
import type { AutomationsPageDestinationFormState } from './use-automations-page-destination-form'
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import type { ProjectHostSetup } from '../../../../shared/project-types'
import type { Repo } from '../../../../shared/repo-types'
import type { ProjectHostSetup } from '../../../../../shared/project-types'
import type { Repo } from '../../../../../shared/repo-types'
import {
getVisibleAutomationSetupDecision,
resolveAutomationSetupDecisionForSave
@@ -1,13 +1,13 @@
import { getAutomationSetupDefaultDecision } from '../../../../shared/automations/launch/automation-setup-decision'
import { getAutomationSetupDefaultDecision } from '../../../../../shared/automations/launch/automation-setup-decision'
import type { AutomationWorkspaceMode } from '../../../../shared/automations/automation-definition'
import type { OrcaHooks, SetupRunPolicy } from '../../../../shared/orca-yaml-hook-types'
import type { ProjectHostSetup } from '../../../../shared/project-types'
import type { Repo } from '../../../../shared/repo-types'
import type { SetupDecision } from '../../../../shared/worktree/create-types'
import { findAutomationRepo } from '../../../../shared/automations/ownership/automation-repo-target'
import { getRepoExecutionHostId } from '../../../../shared/execution-host'
import { getSetupConfig } from '../../../../shared/orca-hook-setup-config'
import type { AutomationWorkspaceMode } from '../../../../../shared/automations/automation-definition'
import type { OrcaHooks, SetupRunPolicy } from '../../../../../shared/orca-yaml-hook-types'
import type { ProjectHostSetup } from '../../../../../shared/project-types'
import type { Repo } from '../../../../../shared/repo-types'
import type { SetupDecision } from '../../../../../shared/worktree/create-types'
import { findAutomationRepo } from '../../../../../shared/automations/ownership/automation-repo-target'
import { getRepoExecutionHostId } from '../../../../../shared/execution-host'
import { getSetupConfig } from '../../../../../shared/orca-hook-setup-config'
type AutomationSetupSource = {
setupScript: string
@@ -1,17 +1,17 @@
import { toast } from 'sonner'
import { translate } from '@/i18n/i18n'
import { useAppStore } from '@/store'
import { useAppStore } from '@/store/index'
import {
confirmCreatedWorktreeSetupContent,
ensureHooksApproved,
type HookTrustApproval
} from '@/lib/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'
import { getAutomationRunRepoId } from '../../../../shared/automations/history/automation-run-identity'
import type { SetupDecision, SetupTrustMismatch } from '../../../../shared/worktree/create-types'
import type { ExecutionHostId } from '../../../../shared/execution-host'
import type { Automation } from '../../../../../shared/automations/automation-definition'
import type { AutomationUsageSummary } from '../../../../../shared/automations/history/automation-usage-summary'
import { getAutomationRunRepoId } from '../../../../../shared/automations/history/automation-run-identity'
import type { SetupDecision, SetupTrustMismatch } from '../../../../../shared/worktree/create-types'
import type { ExecutionHostId } from '../../../../../shared/execution-host'
/** A skipped setup still waiting for approval; null once the automation approves that content. */
export type PendingAutomationSetupReview = { content: SetupTrustMismatch | null }
@@ -1,5 +1,5 @@
import type { AutomationSchedulePreset } from '../../../../shared/automations/automation-definition'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
import type { AutomationSchedulePreset } from '../../../../../shared/automations/automation-definition'
import type { TuiAgent } from '../../../../../shared/agent-launch/catalog/tui-agent'
import { translate } from '@/i18n/i18n'
import { createLocalizedCatalog } from '@/i18n/localized-catalog'
@@ -9,9 +9,9 @@ import {
agentPickerDraft,
type AgentPickerDraft,
type AgentPickerEntry
} from '../../../../shared/agent-launch/picker/agent-launch-picker'
import { automationLaunchChoices } from '../../../../shared/automations/launch/automation-launch-choices'
import { mergeExtraAgentArgs } from '../../../../shared/agent-launch/startup/automation-extra-agent-args'
} from '../../../../../shared/agent-launch/picker/agent-launch-picker'
import { automationLaunchChoices } from '../../../../../shared/automations/launch/automation-launch-choices'
import { mergeExtraAgentArgs } from '../../../../../shared/agent-launch/startup/automation-extra-agent-args'
import type { AutomationDraft } from './AutomationEditorDialog'
import { automationChatSupport } from './automation-launch-surface'
@@ -2,12 +2,12 @@
import { useCallback, useMemo, useRef, useState } from 'react'
import { translate } from '@/i18n/i18n'
import type { Repo } from '../../../../shared/repo-types'
import type { Repo } from '../../../../../shared/repo-types'
import type {
AutomationHostCatalog,
AutomationHostCatalogEntry
} from './automation-host-catalog-types'
import type { AutomationAuthorityRepoTables } from './automation-authority-identity'
} from '../hosts/automation-host-catalog-types'
import type { AutomationAuthorityRepoTables } from '../hosts/automation-authority-identity'
import {
automationCreateEligibleProjects,
automationCreateProjectMismatch,
@@ -19,7 +19,7 @@ import {
type AutomationCreateDestinationChoiceReason,
type AutomationCreateDestinationResolution
} from './automation-create-destination'
import type { AutomationActionNotice } from './automation-row-action-dispatch'
import type { AutomationActionNotice } from '../hosts/automation-row-action-dispatch'
export type AutomationCreateDestinationControl = {
entries: readonly AutomationHostCatalogEntry[]
@@ -1,11 +1,11 @@
import { useCallback, useEffect } from 'react'
import type { AutomationTemplate } from './automation-templates'
import { getDefaultWorktree } from './automation-draft-model'
import { hasModernAutomationLaunchSetup } from '../../../../shared/automations/launch/automation-launch-setup'
import { hasModernAutomationLaunchSetup } from '../../../../../shared/automations/launch/automation-launch-setup'
import type { AutomationsPageDestinationState } from './use-automations-page-destination-state'
import type { AutomationsPageDestinationFormState } from './use-automations-page-destination-form'
import type { AutomationsPageLocalState } from './use-automations-page-local-state'
import type { AutomationsPageRefresh } from './use-automations-page-refresh'
import type { AutomationsPageLocalState } from '../use-automations-page-local-state'
import type { AutomationsPageRefresh } from '../use-automations-page-refresh'
import type { AutomationsPageSetupState } from './use-automations-page-setup-state'
/** Synchronizes draft defaults, setup policy, and templates. */
@@ -1,18 +1,18 @@
import { useCallback } from 'react'
import { toRuntimeExecutionHostId } from '../../../../shared/execution-host'
import { useAppStore } from '@/store'
import { toRuntimeExecutionHostId } from '../../../../../shared/execution-host'
import { useAppStore } from '@/store/index'
import { buildAutomationEditDraft } from './automation-edit-draft'
import { AUTOMATION_DEFAULT_TIME, getDefaultWorktree } from './automation-draft-model'
import type { AutomationTemplate } from './automation-templates'
import { dispatchAutomationReread } from './automation-row-action-dispatch'
import { listAutomationsForTarget } from './automation-host-client'
import { dispatchAutomationReread } from '../hosts/automation-row-action-dispatch'
import { listAutomationsForTarget } from '../hosts/automation-host-client'
import { automationCreateHostFor } from './automation-create-destination'
import type { AutomationDraft } from './AutomationEditorDialog'
import type { AutomationListRow } from './automation-list-row-identity'
import type { AutomationListRow } from '../listing/automation-list-row-identity'
import type { AutomationsPageDestinationState } from './use-automations-page-destination-state'
import type { AutomationsPageDestinationFormState } from './use-automations-page-destination-form'
import type { AutomationsPageLocalState } from './use-automations-page-local-state'
import type { AutomationsPageStoreState } from './use-automations-page-store-state'
import type { AutomationsPageLocalState } from '../use-automations-page-local-state'
import type { AutomationsPageStoreState } from '../use-automations-page-store-state'
import { selectWorktreesByRepo } from '@/store/workspaces/catalog/workspace-record-fields'
/** Dialog open/edit actions, including host-captured re-reads and project changes. */
@@ -3,7 +3,7 @@ import { toast } from 'sonner'
import { resolveAutomationCreateDestination } from './automation-create-destination'
import { createAutomationSaveAction } from './automation-save-action'
import type { AutomationSaveContext } from './automation-save-context'
import type { AutomationListRow } from './automation-list-row-identity'
import type { AutomationListRow } from '../listing/automation-list-row-identity'
import type { AutomationEditorActions } from './use-automation-editor-actions'
/** Migrate: the editor's own move-to-server save, run without opening the dialog. */
@@ -1,13 +1,13 @@
import { resolveAutomationEditDestination } from './automation-orca-save-operations'
import { AUTOMATION_ORPHAN_ISSUES } from '../../../../shared/automations/ownership/automation-list-scope'
import { AUTOMATION_ORPHAN_ISSUES } from '../../../../../shared/automations/ownership/automation-list-scope'
import {
recordedAutomationRunContext,
isSameAutomationWorkspace
} from './automation-recorded-target'
import { useCallback, useEffect, useMemo } from 'react'
import { toRuntimeExecutionHostId } from '../../../../shared/execution-host'
import { toRuntimeExecutionHostId } from '../../../../../shared/execution-host'
import { useTranslate } from '@/i18n/use-translate'
import { automationWorktreesForRepo } from './automation-list-row-identity'
import { automationWorktreesForRepo } from '../listing/automation-list-row-identity'
import { getAutomationCreateRepos } from './automation-create-projects'
import {
automationCreateEligibleProjects,
@@ -23,15 +23,18 @@ import {
getAutomationOwnerTarget,
getAutomationTargetFromHostId,
type AutomationHostTarget
} from './automation-host-client'
import { automationAuthorityCatalogKey } from './automation-host-catalog-types'
import { capturedAutomationOwner, type AutomationCapturedOwner } from './automation-captured-owner'
} from '../hosts/automation-host-client'
import { automationAuthorityCatalogKey } from '../hosts/automation-host-catalog-types'
import {
capturedAutomationOwner,
type AutomationCapturedOwner
} from '../hosts/automation-captured-owner'
import { buildAutomationRunContextForRepo } from './automation-run-context'
import type { AutomationCreateDestinationControl } from './use-automation-create-destination'
import type { AutomationsPageDestinationState } from './use-automations-page-destination-state'
import type { AutomationsPageListState } from './use-automations-page-list-state'
import type { AutomationsPageLocalState } from './use-automations-page-local-state'
import type { AutomationsPageStoreState } from './use-automations-page-store-state'
import type { AutomationsPageListState } from '../listing/use-automations-page-list-state'
import type { AutomationsPageLocalState } from '../use-automations-page-local-state'
import type { AutomationsPageStoreState } from '../use-automations-page-store-state'
/** Editor project/workspace projections for the captured create or edit host. */
export function useAutomationsPageDestinationForm({
@@ -2,49 +2,52 @@ import { useCallback, useEffect, useMemo } from 'react'
import type {
AutomationAuthorityRef,
StableAutomationCatalogRef
} from '../../../../shared/automations/ownership/automation-owner-ref'
} from '../../../../../shared/automations/ownership/automation-owner-ref'
import {
getRepoExecutionHostId,
normalizeExecutionHostId,
toSshExecutionHostId,
toRuntimeExecutionHostId
} from '../../../../shared/execution-host'
} from '../../../../../shared/execution-host'
import {
automationCreateHostOffered,
automationCreateHostStableKey
} from './automation-create-destination'
import { getAutomationHostTargetFromKey, type AutomationHostTarget } from './automation-host-client'
import {
getAutomationHostTargetFromKey,
type AutomationHostTarget
} from '../hosts/automation-host-client'
import {
capturedAutomationOwner,
isAutomationActionEnabled,
type AutomationRowAction
} from './automation-captured-owner'
} from '../hosts/automation-captured-owner'
import {
automationRowCatalogRef,
automationWriteChangeEvent
} from './automation-write-invalidation'
import { automationRowRecoveryHost } from './automation-notice-recovery-host'
} from '../hosts/automation-write-invalidation'
import { automationRowRecoveryHost } from '../hosts/automation-notice-recovery-host'
import type {
AutomationActionNotice,
AutomationDispatchContext
} from './automation-row-action-dispatch'
} from '../hosts/automation-row-action-dispatch'
import {
automationRuntimePairingRevision,
groupReposByAutomationAuthority
} from './automation-authority-identity'
} from '../hosts/automation-authority-identity'
import { resolveIndexedWorktreeOwner } from '@/lib/workspace/ownership/worktree-runtime-owner-index'
import {
createRepoRowExecutionHostLookup,
resolveWorktreeExecutionHost
} from '../../../../shared/execution-host/worktree-execution-host-resolution'
import { automationWorktreesForRepo } from './automation-list-row-identity'
} from '../../../../../shared/execution-host/worktree-execution-host-resolution'
import { automationWorktreesForRepo } from '../listing/automation-list-row-identity'
import { getDefaultWorktree } from './automation-draft-model'
import type { AutomationsPageListState } from './use-automations-page-list-state'
import type { AutomationsPageLocalState } from './use-automations-page-local-state'
import type { AutomationsPageStoreState } from './use-automations-page-store-state'
import type { AutomationsPageListState } from '../listing/use-automations-page-list-state'
import type { AutomationsPageLocalState } from '../use-automations-page-local-state'
import type { AutomationsPageStoreState } from '../use-automations-page-store-state'
import { useAutomationCreateDestination } from './use-automation-create-destination'
import type { AutomationHostCatalogEntry } from './automation-host-catalog-types'
import type { AutomationAuthorityChangeReason } from './automation-host-invalidation'
import type { AutomationHostCatalogEntry } from '../hosts/automation-host-catalog-types'
import type { AutomationAuthorityChangeReason } from '../hosts/automation-host-invalidation'
/** Host destination, owner fencing, and authority-scoped project/workspace choices. */
export function useAutomationsPageDestinationState({
@@ -1,14 +1,17 @@
import { useCallback, useMemo } from 'react'
import type { OrcaHooks } from '../../../../shared/orca-yaml-hook-types'
import type { OrcaHooks } from '../../../../../shared/orca-yaml-hook-types'
import { checkRuntimeHooks } from '@/runtime/repo-hooks/runtime-hooks-client'
import type { AutomationDraft } from './AutomationEditorDialog'
import { getAutomationHostTargetFromKey, type AutomationHostTarget } from './automation-host-client'
import { getRepoExecutionHostId, type ExecutionHostId } from '../../../../shared/execution-host'
import { findAutomationRepo } from '../../../../shared/automations/ownership/automation-repo-target'
import {
getAutomationHostTargetFromKey,
type AutomationHostTarget
} from '../hosts/automation-host-client'
import { getRepoExecutionHostId, type ExecutionHostId } from '../../../../../shared/execution-host'
import { findAutomationRepo } from '../../../../../shared/automations/ownership/automation-repo-target'
import { getVisibleAutomationSetupDecision } from './automation-setup-decision'
import type { AutomationsPageListState } from './use-automations-page-list-state'
import type { AutomationsPageLocalState } from './use-automations-page-local-state'
import type { AutomationsPageStoreState } from './use-automations-page-store-state'
import type { AutomationsPageListState } from '../listing/use-automations-page-list-state'
import type { AutomationsPageLocalState } from '../use-automations-page-local-state'
import type { AutomationsPageStoreState } from '../use-automations-page-store-state'
/** Draft setup policy, selected history, and the page's legacy host target. */
export function useAutomationsPageSetupState({
@@ -1,48 +0,0 @@
import { describe, expect, it } from 'vitest'
import { buildAutomationHostCatalog } from './automation-host-catalog'
import type { AutomationCatalogSshMirrorInput } from './automation-host-catalog-types'
import {
automationCreateHostOffered,
preselectAutomationCreateHost
} from './automation-create-destination'
function mirror(
targets: AutomationCatalogSshMirrorInput['targets']
): AutomationCatalogSshMirrorInput {
return {
targetsHydrated: true,
targets,
removedTargetLabels: new Map(),
connectionStatusByTargetId: new Map()
}
}
describe('create destination on a managed SSH host', () => {
it("lists only the host's server and lands its desktop SSH key there", () => {
const { entries } = buildAutomationHostCatalog({
desktop: {
label: 'Local Mac',
ssh: mirror([{ targetId: 'box', label: 'Build box', generation: 2 }])
},
runtimes: [
{
environmentId: 'env-1',
label: 'Build box',
pairingRevision: 3,
authorityHealth: 'fresh',
querySupport: 'scoped',
ssh: mirror([]),
managedSshTargetId: 'box'
}
],
runtimeCatalogSettled: true
})
const desktopSshKey = 'host:desktop:ssh:box'
const desktopSsh = entries.find((entry) => entry.stableKey === desktopSshKey)
expect(desktopSsh && automationCreateHostOffered(desktopSsh)).toBe(false)
expect(preselectAutomationCreateHost(entries, desktopSshKey, null)?.stableKey).toBe(
'host:runtime:env-1:self'
)
})
})
@@ -1,166 +0,0 @@
import { beforeEach, describe, expect, it } from 'vitest'
import type { StableAutomationAuthorityRef } from '../../../../shared/automations/ownership/automation-owner-ref'
import { buildAutomationHostCatalog } from './automation-host-catalog'
import { createAutomationCatalogGenerationRegistry } from './automation-host-catalog-generation'
import type {
AutomationCatalogSshMirrorInput,
AutomationHostCatalogInput,
AutomationRuntimeAuthorityInput
} from './automation-host-catalog-types'
const DESKTOP: StableAutomationAuthorityRef = { kind: 'desktop' }
const ENV_A: StableAutomationAuthorityRef = { kind: 'runtime', environmentId: 'env-a' }
const ENV_B: StableAutomationAuthorityRef = { kind: 'runtime', environmentId: 'env-b' }
function mirror(
overrides: Partial<AutomationCatalogSshMirrorInput> = {}
): AutomationCatalogSshMirrorInput {
return {
targetsHydrated: true,
targets: [],
removedTargetLabels: new Map(),
connectionStatusByTargetId: new Map(),
...overrides
}
}
function runtime(
environmentId: string,
overrides: Partial<AutomationRuntimeAuthorityInput> = {}
): AutomationRuntimeAuthorityInput {
return {
environmentId,
label: environmentId,
pairingRevision: 1,
authorityHealth: 'fresh',
querySupport: 'scoped',
ssh: mirror(),
...overrides
}
}
function input(overrides: Partial<AutomationHostCatalogInput> = {}): AutomationHostCatalogInput {
return {
desktop: { label: 'Local Mac', ssh: mirror() },
runtimes: [runtime('env-a'), runtime('env-b')],
runtimeCatalogSettled: true,
...overrides
}
}
describe('automation catalog generation', () => {
let registry = createAutomationCatalogGenerationRegistry()
beforeEach(() => {
registry = createAutomationCatalogGenerationRegistry()
})
it('advances only the authority whose target bucket hydrated', () => {
registry.sync(
buildAutomationHostCatalog(
input({
runtimes: [
runtime('env-a', { ssh: mirror({ targetsHydrated: false }) }),
runtime('env-b')
]
})
)
)
const before = {
desktop: registry.get(DESKTOP),
a: registry.get(ENV_A),
b: registry.get(ENV_B)
}
const advanced = registry.sync(
buildAutomationHostCatalog(
input({
runtimes: [
runtime('env-a', {
ssh: mirror({ targets: [{ targetId: 't', label: 'T', generation: 2 }] })
}),
runtime('env-b')
]
})
)
)
expect(advanced.advancedAuthorityKeys).toEqual(['authority:runtime:env-a'])
expect(registry.get(ENV_A)).toBeGreaterThan(before.a)
expect(registry.get(ENV_B)).toBe(before.b)
expect(registry.get(DESKTOP)).toBe(before.desktop)
})
it('does not advance on runtime or SSH connection status changes', () => {
const targets = [{ targetId: 't', label: 'T', generation: 2 }]
registry.sync(
buildAutomationHostCatalog(
input({
runtimes: [
runtime('env-a', {
ssh: mirror({ targets, connectionStatusByTargetId: new Map([['t', 'connected']]) })
}),
runtime('env-b')
]
})
)
)
const before = registry.get(ENV_A)
const advanced = registry.sync(
buildAutomationHostCatalog(
input({
runtimes: [
runtime('env-a', {
authorityHealth: 'stale-error',
ssh: mirror({ targets, connectionStatusByTargetId: new Map([['t', 'reconnecting']]) })
}),
runtime('env-b')
]
})
)
)
expect(advanced.advancedAuthorityKeys).toEqual([])
expect(registry.get(ENV_A)).toBe(before)
})
// doc:321 — the entry a same-id re-adoption produces is byte-identical apart
// from this, so the caller has no other way to know its rows are obsolete.
it('reports a same-id SSH re-adoption as a reincarnated host', () => {
const desktopAt = (generation: number, label = 'Box'): AutomationHostCatalogInput =>
input({
desktop: {
label: 'Local Mac',
ssh: mirror({ targets: [{ targetId: 'ssh-1', label, generation }] })
}
})
const first = registry.sync(buildAutomationHostCatalog(desktopAt(4)))
expect(first.reincarnatedStableKeys).toEqual([])
const renamed = registry.sync(buildAutomationHostCatalog(desktopAt(4, 'Renamed')))
expect(renamed.reincarnatedStableKeys).toEqual([])
const readopted = registry.sync(buildAutomationHostCatalog(desktopAt(5)))
expect(readopted.reincarnatedStableKeys).toEqual(['host:desktop:ssh:ssh-1'])
expect(readopted.advancedAuthorityKeys).toEqual(['authority:desktop'])
})
// The generation file's own warning: an offline authority reported as
// legacy-unscoped loses its owner refs, which must not read as a re-adoption.
it('does not report a host whose owner merely went absent', () => {
const withSupport = (querySupport: 'scoped' | 'legacy-unscoped'): AutomationHostCatalogInput =>
input({
runtimes: [
runtime('env-a', {
querySupport,
// An SSH entry is where the owner ref actually disappears with the support level.
ssh: mirror({ targets: [{ targetId: 't', label: 'T', generation: 3 }] })
})
]
})
registry.sync(buildAutomationHostCatalog(withSupport('scoped')))
const degraded = registry.sync(buildAutomationHostCatalog(withSupport('legacy-unscoped')))
expect(degraded.reincarnatedStableKeys).toEqual([])
const restored = registry.sync(buildAutomationHostCatalog(withSupport('scoped')))
expect(restored.reincarnatedStableKeys).toEqual([])
})
})
@@ -1,223 +0,0 @@
import { describe, expect, it } from 'vitest'
import type { AutomationHostFilter } from '../../../../shared/automations/ownership/automation-host-filter'
import { hostStableKey } from '../../../../shared/automations/ownership/automation-owner-key'
import type { StableAutomationCatalogRef } from '../../../../shared/automations/ownership/automation-owner-ref'
import { buildAutomationHostCatalog } from './automation-host-catalog'
import type {
AutomationCatalogSshMirrorInput,
AutomationHostCatalogInput,
AutomationRuntimeAuthorityInput
} from './automation-host-catalog-types'
import { resolveAutomationHostFilter } from './automation-host-filter-resolution'
function mirror(
overrides: Partial<AutomationCatalogSshMirrorInput> = {}
): AutomationCatalogSshMirrorInput {
return {
targetsHydrated: true,
targets: [],
removedTargetLabels: new Map(),
connectionStatusByTargetId: new Map(),
...overrides
}
}
function runtime(
overrides: Partial<AutomationRuntimeAuthorityInput> = {}
): AutomationRuntimeAuthorityInput {
return {
environmentId: 'env-1',
label: 'Build server',
pairingRevision: 3,
authorityHealth: 'fresh',
querySupport: 'scoped',
ssh: mirror(),
...overrides
}
}
function catalogOf(overrides: Partial<AutomationHostCatalogInput> = {}) {
return buildAutomationHostCatalog({
desktop: { label: 'Local Mac', ssh: mirror() },
runtimes: [],
runtimeCatalogSettled: true,
...overrides
})
}
function filterFor(host: StableAutomationCatalogRef): AutomationHostFilter {
return { kind: 'host', host }
}
const desktopSsh = (targetId: string): StableAutomationCatalogRef => ({
authority: { kind: 'desktop' },
selector: { kind: 'ssh', targetId }
})
const runtimeSelf: StableAutomationCatalogRef = {
authority: { kind: 'runtime', environmentId: 'env-1' },
selector: { kind: 'self' }
}
const runtimeSsh: StableAutomationCatalogRef = {
authority: { kind: 'runtime', environmentId: 'env-1' },
selector: { kind: 'ssh', targetId: 'nested' }
}
const desktopOrphan: StableAutomationCatalogRef = {
authority: { kind: 'desktop' },
selector: { kind: 'orphan' }
}
describe('resolveAutomationHostFilter', () => {
it('retains a desktop SSH selection until the target list hydrates', () => {
const filter = filterFor(desktopSsh('pending'))
const resolution = resolveAutomationHostFilter({
filter,
catalog: catalogOf({
desktop: { label: 'Local Mac', ssh: mirror({ targetsHydrated: false }) }
})
})
expect(resolution).toMatchObject({ status: 'loading', announceFallback: false })
expect(resolution.effective).toBe(filter)
})
it('falls back and announces once desktop SSH absence is authoritative', () => {
const resolution = resolveAutomationHostFilter({
filter: filterFor(desktopSsh('gone')),
catalog: catalogOf()
})
expect(resolution).toEqual({
effective: { kind: 'all' },
entry: null,
status: 'removed',
announceFallback: true
})
})
it('keeps a removed host as a ghost while automations still reference it', () => {
const host = desktopSsh('gone')
const key = hostStableKey(host)
const resolution = resolveAutomationHostFilter({
filter: filterFor(host),
catalog: catalogOf({
desktop: {
label: 'Local Mac',
ssh: mirror({ removedTargetLabels: new Map([['gone', 'Old box']]) })
},
referencedStableKeys: [key]
}),
referencedStableKeys: new Set([key])
})
expect(resolution.status).toBe('ghost')
expect(resolution.announceFallback).toBe(false)
expect(resolution.entry?.label).toBe('Old box')
})
it('retains a Runtime Self selection until the saved runtime catalog settles', () => {
const filter = filterFor(runtimeSelf)
expect(
resolveAutomationHostFilter({ filter, catalog: catalogOf({ runtimeCatalogSettled: false }) })
.status
).toBe('loading')
expect(resolveAutomationHostFilter({ filter, catalog: catalogOf() })).toMatchObject({
status: 'removed',
announceFallback: true
})
})
it('retains a Runtime SSH selection until that runtime bucket hydrates', () => {
const filter = filterFor(runtimeSsh)
expect(
resolveAutomationHostFilter({
filter,
catalog: catalogOf({ runtimes: [runtime({ ssh: mirror({ targetsHydrated: false }) })] })
}).status
).toBe('loading')
expect(
resolveAutomationHostFilter({ filter, catalog: catalogOf({ runtimes: [runtime()] }) })
).toMatchObject({ status: 'removed', announceFallback: true })
})
it('accepts a removal tombstone as positive evidence for a nested target', () => {
const resolution = resolveAutomationHostFilter({
filter: filterFor(runtimeSsh),
catalog: catalogOf({
runtimes: [
runtime({
ssh: mirror({
targetsHydrated: false,
removedTargetLabels: new Map([['nested', 'Nested box']])
})
})
]
})
})
expect(resolution.status).toBe('removed')
expect(resolution.announceFallback).toBe(true)
})
it('never claims removal while the owning authority is offline', () => {
const offline = catalogOf({
runtimes: [
runtime({
authorityHealth: 'unavailable',
ssh: mirror({ removedTargetLabels: new Map([['nested', 'Nested box']]) })
})
]
})
expect(
resolveAutomationHostFilter({ filter: filterFor(runtimeSsh), catalog: offline })
).toMatchObject({ status: 'unavailable', announceFallback: false })
expect(
resolveAutomationHostFilter({
filter: filterFor({
authority: { kind: 'runtime', environmentId: 'env-1' },
selector: { kind: 'ssh', targetId: 'never-seen' }
}),
catalog: offline
})
).toMatchObject({ status: 'unavailable', announceFallback: false })
})
it('settles an orphan selection only on an authoritative orphan count', () => {
const filter = filterFor(desktopOrphan)
expect(resolveAutomationHostFilter({ filter, catalog: catalogOf() }).status).toBe('loading')
expect(
resolveAutomationHostFilter({
filter,
catalog: catalogOf({ desktop: { label: 'Local Mac', ssh: mirror(), orphanCount: 2 } })
}).status
).toBe('ready')
expect(
resolveAutomationHostFilter({
filter,
catalog: catalogOf({ desktop: { label: 'Local Mac', ssh: mirror(), orphanCount: 0 } })
})
).toMatchObject({ status: 'removed', announceFallback: true })
})
it('retains an orphan selection as unavailable while its authority is offline', () => {
const resolution = resolveAutomationHostFilter({
filter: filterFor({
authority: { kind: 'runtime', environmentId: 'env-1' },
selector: { kind: 'orphan' }
}),
catalog: catalogOf({ runtimes: [runtime({ authorityHealth: 'unavailable' })] })
})
expect(resolution).toMatchObject({ status: 'unavailable', announceFallback: false })
})
it('retains the display selection through a same-id re-pair', () => {
const filter = filterFor(runtimeSelf)
const before = resolveAutomationHostFilter({
filter,
catalog: catalogOf({ runtimes: [runtime({ pairingRevision: 3 })] })
})
const after = resolveAutomationHostFilter({
filter,
catalog: catalogOf({ runtimes: [runtime({ pairingRevision: 4 })] })
})
expect(after.status).toBe('ready')
expect(after.entry?.stableKey).toBe(before.entry?.stableKey)
// The display slot survives; the captured incarnation does not.
expect(after.entry?.owner).not.toEqual(before.entry?.owner)
})
})
@@ -1,167 +0,0 @@
/** Follow colliding authority-local IDs from host cache through list/search joins so the last host cannot overwrite another’s row. */
import { describe, expect, it } from 'vitest'
import type { Automation } from '../../../../shared/automations/automation-definition'
import type { AutomationHostCacheEntry, AutomationHostRow } from './automation-host-cache-types'
import type {
AutomationHostCatalog,
AutomationHostCatalogEntry
} from './automation-host-catalog-types'
import type { AutomationHostFilterResolution } from './automation-host-filter-resolution'
import type { Repo } from '../../../../shared/repo-types'
import type { Worktree } from '../../../../shared/worktree/types'
import { resolveAutomationHostListRows } from './automation-host-list-rows'
import { REPO_ID } from './automations-page-fixtures'
import { makeFolderWorkspace } from '../sidebar/workspace-creation/folder/folder-workspace-composer-submit-fixtures'
import {
automationFolderWorktreeForRow,
automationRepoForRow,
automationWorktreeForRow
} from './automation-list-row-identity'
const repoMap = new Map([
[REPO_ID, { id: REPO_ID, displayName: 'orca', path: '/src/orca' } as Repo]
])
const DESKTOP_SELF: AutomationHostCatalogEntry = {
stableRef: { authority: { kind: 'desktop' }, selector: { kind: 'self' } },
owner: { authority: { kind: 'desktop' }, selector: { kind: 'self' } },
stableKey: 'host:desktop:self',
label: 'This computer',
authorityLabel: 'This computer',
kind: 'self',
catalogState: 'authoritative',
authorityHealth: 'fresh',
executionHealth: 'connected',
querySupport: 'scoped'
}
const RUNTIME_SSH: AutomationHostCatalogEntry = {
...DESKTOP_SELF,
stableRef: {
authority: { kind: 'runtime', environmentId: 'gpu' },
selector: { kind: 'ssh', targetId: 'web-01' }
},
owner: {
authority: { kind: 'runtime', environmentId: 'gpu', pairingRevision: 4 },
selector: { kind: 'ssh', targetId: 'web-01', targetGeneration: 2 }
},
stableKey: 'host:runtime:gpu:ssh:web-01',
label: 'web-01',
authorityLabel: 'GPU box',
kind: 'ssh'
}
const ALL_HOSTS: AutomationHostFilterResolution = {
effective: { kind: 'all' },
entry: null,
status: 'all',
announceFallback: false
}
function cached(rows: AutomationHostRow[]): AutomationHostCacheEntry {
return {
data: rows,
fetchedAt: 1,
attempt: 0,
requestGeneration: 0,
catalogGeneration: 0,
request: null,
error: null,
orphanCount: null
}
}
function hostRow(entry: AutomationHostCatalogEntry, name: string): AutomationHostRow {
return {
automation: {
id: 'a-1',
name,
prompt: 'sweep',
projectId: REPO_ID,
workspaceMode: 'new_per_run',
baseBranch: null,
agentId: 'claude'
} as Automation,
owner: entry.owner,
selector: { kind: 'self' },
usageSummary: null,
usageKnown: true
}
}
/** The desktop and a runtime SSH host each holding a record called `a-1`. */
function collidedListRows(): ReturnType<typeof resolveAutomationHostListRows> {
const entries = [DESKTOP_SELF, RUNTIME_SSH]
const catalog: AutomationHostCatalog = {
entries,
byStableKey: new Map(entries.map((entry) => [entry.stableKey, entry])),
hydration: {
runtimeCatalogSettled: true,
desktopSshHydrated: true,
runtimeSshHydratedByEnvironmentId: new Map(),
savedRuntimeEnvironmentIds: new Set(),
orphanSettledAuthorityKeys: new Set(),
unavailableAuthorityKeys: new Set()
}
}
return resolveAutomationHostListRows({
catalog,
resolution: ALL_HOSTS,
entry: (stableKey) =>
cached([
stableKey === DESKTOP_SELF.stableKey
? hostRow(DESKTOP_SELF, 'Nightly desktop')
: hostRow(RUNTIME_SSH, 'Nightly web-01')
])
})
}
describe('automation list row identity across hosts', () => {
it('resolves colliding projects and worktrees inside each row authority', () => {
const rows = collidedListRows().rows
const repos = [
{ ...repoMap.get(REPO_ID)!, displayName: 'Desktop repo', executionHostId: 'local' as const },
{
...repoMap.get(REPO_ID)!,
displayName: 'Runtime repo',
executionHostId: 'runtime:gpu' as const
}
]
const worktrees = [
{ id: 'ws-1', repoId: REPO_ID, hostId: 'local', displayName: 'Desktop workspace' },
{
id: 'ws-1',
repoId: REPO_ID,
hostId: 'runtime:gpu',
displayName: 'Runtime workspace'
}
] as Worktree[]
expect(rows.map((row) => automationRepoForRow(row, repos)?.displayName)).toEqual([
'Desktop repo',
'Runtime repo'
])
expect(
rows.map((row) => {
const repo = automationRepoForRow(row, repos)
return automationWorktreeForRow(row, { [REPO_ID]: worktrees }, repo, repos, 'ws-1')
?.displayName
})
).toEqual(['Desktop workspace', 'Runtime workspace'])
})
it('resolves a folder workspace target inside each row authority', () => {
const rows = collidedListRows().rows
const folders = [
makeFolderWorkspace({ id: 'fw-1', name: 'Desktop folder' }),
makeFolderWorkspace({ id: 'fw-1', name: 'Runtime folder', executionHostId: 'runtime:gpu' })
]
expect(
rows.map((row) => automationFolderWorktreeForRow(row, folders, 'folder:fw-1')?.displayName)
).toEqual(['Desktop folder', 'Runtime folder'])
expect(automationFolderWorktreeForRow(rows[0], folders, 'ws-1')).toBeUndefined()
})
})
@@ -1,48 +0,0 @@
import { describe, expect, it } from 'vitest'
import {
AUTOMATION_LIST_SEARCH_PROMPT_MAX_CODE_UNITS,
AUTOMATION_LIST_SEARCH_QUERY_MAX_BYTES,
automationListSearchIndexMatches,
buildAutomationListSearchIndex,
clampAutomationListSearchQueryInput,
isAutomationListSearchQueryTooLarge,
resolveAutomationListSearchQuery,
truncateAutomationListSearchField
} from './automation-list-search'
describe('automation-list-search', () => {
it('rejects queries over the byte limit but under the code-unit limit', () => {
// 3 UTF-8 bytes per character, so half the cap in code units is over it in bytes.
const multiByte = '한'.repeat(AUTOMATION_LIST_SEARCH_QUERY_MAX_BYTES / 2)
expect(multiByte.length).toBeLessThanOrEqual(AUTOMATION_LIST_SEARCH_QUERY_MAX_BYTES)
expect(isAutomationListSearchQueryTooLarge(multiByte)).toBe(true)
expect(resolveAutomationListSearchQuery(multiByte)).toEqual({ status: 'too_large' })
})
it('clamps stored query input so multi-MB pastes are discarded', () => {
const hugePaste = 'a'.repeat(AUTOMATION_LIST_SEARCH_QUERY_MAX_BYTES * 100)
const clamped = clampAutomationListSearchQueryInput(hugePaste)
expect(clamped.length).toBe(AUTOMATION_LIST_SEARCH_QUERY_MAX_BYTES + 1)
expect(isAutomationListSearchQueryTooLarge(clamped)).toBe(true)
expect(clampAutomationListSearchQueryInput('auto pr')).toBe('auto pr')
})
it('caps indexed field length so huge prompts stay bounded', () => {
const prompt = `${'x'.repeat(AUTOMATION_LIST_SEARCH_PROMPT_MAX_CODE_UNITS)}unique-tail-token`
const index = buildAutomationListSearchIndex({
name: 'Nightly',
project: 'mobile',
prompt
})
expect(index.prompt.length).toBe(AUTOMATION_LIST_SEARCH_PROMPT_MAX_CODE_UNITS)
expect(automationListSearchIndexMatches(index, 'unique-tail-token')).toBe(false)
expect(automationListSearchIndexMatches(index, 'xxxx')).toBe(true)
})
it('does not split surrogate pairs when truncating', () => {
const emoji = '😀'
const value = `${'a'.repeat(7)}${emoji}`
expect(truncateAutomationListSearchField(value, 8)).toBe('a'.repeat(7))
expect(truncateAutomationListSearchField(value, 9)).toBe(value)
})
})
@@ -3,7 +3,7 @@ import type { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'
import type { AutomationRun } from '../../../../shared/automations/history/automation-run'
import type { PendingAutomationSetupReview } from './automation-setup-review'
import type { PendingAutomationSetupReview } from './authoring/automation-setup-review'
import { translate } from '@/i18n/i18n'
import { useTranslate, type Translate } from '@/i18n/use-translate'
import { formatUiNarrowRelativeTime } from '@/i18n/relative-time-format'
@@ -1,179 +0,0 @@
import { describe, expect, it } from 'vitest'
import type { AutomationRun } from '../../../../shared/automations/history/automation-run'
import {
buildAutomationRunOpenLayout,
resolveAutomationRunOpenTarget
} from './automation-run-open-target'
const leafId = '11111111-1111-4111-8111-111111111111'
const otherLeafId = '22222222-2222-4222-8222-222222222222'
const paneKey = `tab-1:${leafId}`
const runLeafLayout = {
root: { type: 'leaf' as const, leafId },
activeLeafId: leafId,
expandedLeafId: null
}
const livePtyIds = ['pty-run']
const canOpen = (args: Parameters<typeof resolveAutomationRunOpenTarget>[0]): boolean =>
resolveAutomationRunOpenTarget(args) !== null
function run(overrides: Partial<AutomationRun> = {}): AutomationRun {
return {
id: 'run-1',
automationId: 'automation-1',
title: 'Run 1',
scheduledFor: 1,
status: 'completed',
trigger: 'manual',
workspaceId: 'wt-1',
workspaceDisplayName: 'Workspace',
sessionKind: 'terminal',
chatSessionId: null,
terminalSessionId: 'tab-1',
terminalPaneKey: paneKey,
terminalPtyId: 'pty-run',
outputSnapshot: null,
precheckResult: null,
usage: null,
error: null,
startedAt: 1,
dispatchedAt: 1,
createdAt: 1,
...overrides
}
}
describe('automation run open target', () => {
it('rejects a layout whose run leaf is bound to another PTY', () => {
expect(
resolveAutomationRunOpenTarget({
run: run(),
terminalTabExists: true,
currentLayout: {
...runLeafLayout,
ptyIdsByLeafId: { [leafId]: 'pty-other' }
},
livePtyIds
})
).toBeNull()
})
it('targets the pane a successful run slept in place, before and after it wakes', () => {
// Why: hibernation drops only the run's PTY id; the pane key still names the run's own pane.
const sleptRun = run({ terminalPtyId: null })
const asleepLayout = { ...runLeafLayout, ptyIdsByLeafId: { [leafId]: 'pty-run' } }
const asleep = resolveAutomationRunOpenTarget({
run: sleptRun,
terminalTabExists: true,
currentLayout: asleepLayout,
livePtyIds: []
})
expect(asleep).toEqual({ tabId: 'tab-1', paneKey, leafId, ptyId: null })
if (!asleep) {
throw new Error('Expected target.')
}
expect(
buildAutomationRunOpenLayout({ target: asleep, currentLayout: asleepLayout }).ptyIdsByLeafId
).toBe(asleepLayout.ptyIdsByLeafId)
expect(
resolveAutomationRunOpenTarget({
run: sleptRun,
terminalTabExists: true,
currentLayout: { ...runLeafLayout, ptyIdsByLeafId: { [leafId]: 'pty-resumed' } },
livePtyIds: ['pty-resumed']
})
).toEqual({ tabId: 'tab-1', paneKey, leafId, ptyId: 'pty-resumed' })
expect(
canOpen({
run: sleptRun,
terminalTabExists: false,
currentLayout: asleepLayout,
livePtyIds: []
})
).toBe(false)
})
it('opens an existing run leaf when the layout has no PTY mapping yet', () => {
const target = resolveAutomationRunOpenTarget({
run: run(),
terminalTabExists: true,
currentLayout: runLeafLayout,
livePtyIds
})
expect(target).not.toBeNull()
if (!target) {
throw new Error('Expected target.')
}
expect(buildAutomationRunOpenLayout({ target, currentLayout: runLeafLayout })).toMatchObject({
root: { type: 'leaf', leafId },
activeLeafId: leafId,
ptyIdsByLeafId: { [leafId]: 'pty-run' }
})
})
it('does not rebuild a layout that is missing the run pane', () => {
expect(
resolveAutomationRunOpenTarget({
run: run(),
terminalTabExists: true,
currentLayout: {
root: { type: 'leaf', leafId: otherLeafId },
activeLeafId: otherLeafId,
expandedLeafId: null,
ptyIdsByLeafId: { [otherLeafId]: 'pty-empty-shell' }
},
livePtyIds
})
).toBeNull()
})
it('does not open when the current tab layout is unavailable', () => {
expect(
resolveAutomationRunOpenTarget({
run: run(),
terminalTabExists: true,
currentLayout: null,
livePtyIds
})
).toBeNull()
})
it('keeps an existing split layout when the run leaf is still present', () => {
const currentLayout = {
root: {
type: 'split' as const,
direction: 'horizontal' as const,
first: { type: 'leaf' as const, leafId },
second: { type: 'leaf' as const, leafId: otherLeafId }
},
activeLeafId: otherLeafId,
expandedLeafId: otherLeafId,
ptyIdsByLeafId: { [leafId]: 'pty-run', [otherLeafId]: 'pty-other' }
}
const target = resolveAutomationRunOpenTarget({
run: run(),
terminalTabExists: true,
currentLayout,
livePtyIds
})
expect(target).not.toBeNull()
if (!target) {
throw new Error('Expected target.')
}
const layout = buildAutomationRunOpenLayout({
target,
currentLayout
})
expect(layout).toMatchObject({
root: expect.objectContaining({ type: 'split' }),
activeLeafId: leafId,
expandedLeafId: null,
ptyIdsByLeafId: { [leafId]: 'pty-run', [otherLeafId]: 'pty-other' }
})
})
})
@@ -1,11 +1,11 @@
import type { AutomationsPageListState } from './use-automations-page-list-state'
import type { AutomationsPageListState } from './listing/use-automations-page-list-state'
import type { AutomationsPageLocalState } from './use-automations-page-local-state'
import type { AutomationsPagePresentationState } from './use-automations-page-presentation-state'
import type { AutomationsPageRefresh } from './use-automations-page-refresh'
import type { AutomationsPageSetupState } from './use-automations-page-setup-state'
import type { AutomationsPageSetupState } from './authoring/use-automations-page-setup-state'
import type { AutomationsPageStoreState } from './use-automations-page-store-state'
import type { AutomationsPageDestinationState } from './use-automations-page-destination-state'
import type { AutomationsPageDestinationFormState } from './use-automations-page-destination-form'
import type { AutomationsPageDestinationState } from './authoring/use-automations-page-destination-state'
import type { AutomationsPageDestinationFormState } from './authoring/use-automations-page-destination-form'
export type AutomationsPageActionContext = {
store: AutomationsPageStoreState
@@ -17,7 +17,7 @@ import { checkRuntimeHooks, type HookCheckResult } from '@/runtime/repo-hooks/ru
import { loadHostStructuredAgents } from '@/runtime/native-chat/agent-catalogs/host-structured-agents'
import { getDefaultSettings } from '../../../../shared/constants'
import type { Automation } from '../../../../shared/automations/automation-definition'
import type { AutomationDraft } from './AutomationEditorDialog'
import type { AutomationDraft } from './authoring/AutomationEditorDialog'
import {
AUTOMATION_LIST_HOST_SCOPE_RUNTIME_CAPABILITY as LIST_HOST_SCOPE,
AUTOMATION_OWNER_FENCING_RUNTIME_CAPABILITY as OWNER_FENCING,
@@ -1,12 +1,12 @@
import type { AutomationAuthorityRef } from '../../../../shared/automations/ownership/automation-owner-ref'
import type { Automation } from '../../../../shared/automations/automation-definition'
import type { Worktree } from '../../../../shared/worktree/types'
import type { AutomationHostCatalogView } from './use-automation-host-catalog'
import type { AutomationCreateDestinationControl } from './use-automation-create-destination'
import type { ExternalAutomationListEntry } from './external-automation-list-entries'
import type { AutomationListRow } from './automation-list-row-identity'
import type { AutomationListViewItem } from './automation-list-view'
import type { AutomationTemplate } from './automation-templates'
import type { AutomationHostCatalogView } from './hosts/use-automation-host-catalog'
import type { AutomationCreateDestinationControl } from './authoring/use-automation-create-destination'
import type { ExternalAutomationListEntry } from './external/external-automation-list-entries'
import type { AutomationListRow } from './listing/automation-list-row-identity'
import type { AutomationListViewItem } from './listing/automation-list-view'
import type { AutomationTemplate } from './authoring/automation-templates'
export type ListPanelProps = {
sortedListItems: readonly AutomationListViewItem[]
@@ -7,15 +7,18 @@ import type {
} from '../../../../shared/automations/history/automation-run'
import type { ExternalAutomationManager } from '../../../../shared/automations/external/external-automation'
import type { ProjectHostSetup } from '../../../../shared/project-types'
import type { AutomationHostCatalogEntry } from './automation-host-catalog-types'
import type { AutomationHostCatalogEntry } from './hosts/automation-host-catalog-types'
import type { AppState } from '@/store/types'
import type { Repo } from '../../../../shared/repo-types'
import type { Worktree } from '../../../../shared/worktree/types'
import type {
ExternalAutomationScope,
ScopedExternalAutomationManager
} from './external-automation-scope-client'
import { automationListRowKey, type AutomationListRow } from './automation-list-row-identity'
} from './external/external-automation-scope-client'
import {
automationListRowKey,
type AutomationListRow
} from './listing/automation-list-row-identity'
import { ALL_AUTOMATION_HOSTS_FILTER } from '../../../../shared/automations/ownership/automation-host-filter'
import { getDefaultSettings } from '../../../../shared/constants'
@@ -1,7 +1,7 @@
/** Read authority-qualified row keys and render order from the mocked list panel, matching real clicks rather than synthesizing identity. */
import type { AutomationListRow } from './automation-list-row-identity'
import type { ExternalAutomationListEntry } from './external-automation-list-entries'
import type { AutomationListRow } from './listing/automation-list-row-identity'
import type { ExternalAutomationListEntry } from './external/external-automation-list-entries'
import { mocks } from './automations-page-test-harness'
function listedItems() {
@@ -21,10 +21,10 @@ import {
} from '../../../../shared/automations/automation-runtime-capabilities'
import type { AppState } from '@/store/types'
import { AutomationDestinationField } from './AutomationDestinationField'
import { AutomationDestinationField } from './authoring/AutomationDestinationField'
import { TooltipProvider } from '@/components/ui/tooltip'
import { resetAutomationCapabilityProbes } from './automation-scoped-list-client'
import { resetAutomationCapabilityProbes } from './hosts/automation-capability-probe'
import {
addRuntimeProject as addRuntimeProjectFixture,
selfScopedList
@@ -65,7 +65,7 @@ export const mocks: AutomationsPageMocks = {
setPendingRunNavigation: vi.fn()
}
vi.mock('@/store', () => {
vi.mock('@/store/index', () => {
const useAppStore = (selector: (state: Partial<AppState>) => unknown): unknown =>
selector(mocks.state as Partial<AppState>)
useAppStore.getState = (): Partial<AppState> => mocks.state as Partial<AppState>
@@ -122,7 +122,7 @@ vi.mock('@/lib/workspace/activation/worktree-activation', () => ({
activateAndRevealWorktree: vi.fn()
}))
vi.mock('./AutomationsListPanel', () => ({
vi.mock('./listing/AutomationsListPanel', () => ({
AutomationsListPanel: (props: ListPanelProps) => {
const selectAutomationRow = (rowKey: string | null): void => {
props.selectAutomationRow(rowKey)
@@ -164,7 +164,7 @@ vi.mock('./AutomationsListPanel', () => ({
}
}))
vi.mock('./AutomationsDetailPane', () => ({
vi.mock('./details/AutomationsDetailPane', () => ({
AutomationsDetailPane: (props: DetailPaneProps) => {
mocks.detailPane = props
return (
@@ -176,7 +176,7 @@ vi.mock('./AutomationsDetailPane', () => ({
}
}))
vi.mock('./AutomationEditorDialog', () => ({
vi.mock('./authoring/AutomationEditorDialog', () => ({
AutomationEditorDialog: (props: EditorDialogProps) => {
mocks.editorDialog = props
return (
@@ -195,7 +195,7 @@ vi.mock('./AutomationEditorDialog', () => ({
}
}))
vi.mock('./AutomationDeleteDialogs', () => ({
vi.mock('./authoring/AutomationDeleteDialogs', () => ({
AutomationDeleteDialog: (props: DeleteDialogProps) => {
mocks.deleteDialog = props
return null
@@ -5,25 +5,25 @@ import { Badge } from '@/components/ui/badge'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import type { Automation } from '../../../../shared/automations/automation-definition'
import type { AutomationRun } from '../../../../shared/automations/history/automation-run'
import type { Automation } from '../../../../../shared/automations/automation-definition'
import type { AutomationRun } from '../../../../../shared/automations/history/automation-run'
import { formatUiAutomationSchedule } from './automation-schedule-label'
import { formatUiNarrowDuration } from '@/i18n/relative-time-format'
import {
AutomationRunErrorNotice,
formatAutomationDateTimeWithRelative
} from './automation-page-parts'
import { indexLatestAutomationRuns } from './automation-list-last-run'
import { formatAutomationCost, formatAutomationTokens } from './automation-usage-model'
import { summarizeAutomationRunUsage } from '../../../../shared/automations/history/automation-usage-summary'
import type { AutomationTargetAvailability } from './automation-target-availability'
import type { AutomationHostCatalogEntry } from './automation-host-catalog-types'
import { getAutomationHostDetailDisplay } from './automation-host-detail-display'
} from '../automation-page-parts'
import { indexLatestAutomationRuns } from '../listing/automation-list-last-run'
import { formatAutomationCost, formatAutomationTokens } from '../runs/automation-usage-model'
import { summarizeAutomationRunUsage } from '../../../../../shared/automations/history/automation-usage-summary'
import type { AutomationTargetAvailability } from '../hosts/automation-target-availability-types'
import type { AutomationHostCatalogEntry } from '../hosts/automation-host-catalog-types'
import { getAutomationHostDetailDisplay } from '../hosts/automation-host-detail-display'
import { getAutomationSourceDisplay } from './automation-source-display'
import { translate } from '@/i18n/i18n'
import { useIntlLocale, useTranslate, type Translate } from '@/i18n/use-translate'
import { AutomationPromptDisclosure } from './AutomationPromptDisclosure'
import { automationRunErrorText } from './automation-run-error-copy'
import { automationRunErrorText } from '../runs/automation-run-error-copy'
type AutomationDetailProps = {
automation: Automation | null
@@ -2,24 +2,24 @@ import React from 'react'
import { ArrowLeft } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
import type { Automation } from '../../../../shared/automations/automation-definition'
import type { Automation } from '../../../../../shared/automations/automation-definition'
import type {
ExternalAutomationAction,
ExternalAutomationJob,
ExternalAutomationManager
} from '../../../../shared/automations/external/external-automation'
import type { AutomationRun } from '../../../../shared/automations/history/automation-run'
import type { Worktree } from '../../../../shared/worktree/types'
} from '../../../../../shared/automations/external/external-automation'
import type { AutomationRun } from '../../../../../shared/automations/history/automation-run'
import type { Worktree } from '../../../../../shared/worktree/types'
import { AutomationDetail } from './AutomationDetail'
import { AutomationRunHistory } from './AutomationRunHistory'
import { ExternalAutomationManagers } from './ExternalAutomationManagers'
import type { ExternalAutomationListEntry } from './external-automation-list-entries'
import type { ExternalAutomationScope } from './external-automation-scope-client'
import type { AutomationActionNotice } from './automation-row-action-dispatch'
import type { AutomationHostRecoveryAction } from './automation-host-status-descriptors'
import type { AutomationHostCatalogEntry } from './automation-host-catalog-types'
import type { AutomationTargetAvailability } from './automation-target-availability'
import type { AutomationPaneTab } from './automation-page-state'
import { AutomationRunHistory } from '../runs/AutomationRunHistory'
import { ExternalAutomationManagers } from '../external/ExternalAutomationManagers'
import type { ExternalAutomationListEntry } from '../external/external-automation-list-entries'
import type { ExternalAutomationScope } from '../external/external-automation-scope-client'
import type { AutomationActionNotice } from '../hosts/automation-row-action-dispatch'
import type { AutomationHostRecoveryAction } from '../hosts/automation-host-status-descriptors'
import type { AutomationHostCatalogEntry } from '../hosts/automation-host-catalog-types'
import type { AutomationTargetAvailability } from '../hosts/automation-target-availability-types'
import type { AutomationPaneTab } from '../automation-page-state'
import {
getAutomationDetailNextTab,
shouldHandleAutomationDetailEscapeKey,
@@ -1,4 +1,4 @@
import type { AutomationPaneTab } from './automation-page-state'
import type { AutomationPaneTab } from '../automation-page-state'
export type AutomationDetailTabArrowKey = 'ArrowLeft' | 'ArrowRight'
@@ -2,7 +2,7 @@ import {
describeAutomationSchedule,
formatAutomationScheduleTime,
type AutomationScheduleDescriptor
} from '../../../../shared/automations/scheduling/automation-schedules'
} from '../../../../../shared/automations/scheduling/automation-schedules'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import { getUiWeekdayNames } from '@/i18n/weekday-names'
@@ -1,7 +1,7 @@
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import { getExecutionHostLabel } from '../../../../shared/execution-host'
import type { TaskSourceContext } from '../../../../shared/work-items/task-source-context'
import { getExecutionHostLabel } from '../../../../../shared/execution-host'
import type { TaskSourceContext } from '../../../../../shared/work-items/task-source-context'
export type AutomationSourceDisplay = {
label: string
@@ -8,7 +8,7 @@ import type {
ExternalAutomationAction,
ExternalAutomationJob,
ExternalAutomationManager
} from '../../../../shared/automations/external/external-automation'
} from '../../../../../shared/automations/external/external-automation'
import type {
ExternalAutomationScope,
ScopedExternalAutomationManager
@@ -1,10 +1,10 @@
import type { ExternalAutomationManager } from '../../../../shared/automations/external/external-automation'
import type { ExternalAutomationManager } from '../../../../../shared/automations/external/external-automation'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
import {
formatAutomationDateTime,
formatAutomationDateTimeWithRelative
} from './automation-page-parts'
} from '../automation-page-parts'
export function formatExternalDate(
value: string | null,
@@ -1,7 +1,7 @@
import type {
ExternalAutomationJob,
ExternalAutomationManager
} from '../../../../shared/automations/external/external-automation'
} from '../../../../../shared/automations/external/external-automation'
import type {
ExternalAutomationScope,
ScopedExternalAutomationManager
@@ -1,9 +1,9 @@
import type {
ExternalAutomationJob,
ExternalAutomationManager
} from '../../../../shared/automations/external/external-automation'
import { isRunnableAutomationCronSchedule } from '../../../../shared/automations/scheduling/automation-schedule-parsing'
import { formatUiAutomationSchedule } from './automation-schedule-label'
} from '../../../../../shared/automations/external/external-automation'
import { isRunnableAutomationCronSchedule } from '../../../../../shared/automations/scheduling/automation-schedule-parsing'
import { formatUiAutomationSchedule } from '../details/automation-schedule-label'
import { translate } from '@/i18n/i18n'
import type { Translate } from '@/i18n/use-translate'
@@ -4,10 +4,10 @@ import type {
ExternalAutomationAction,
ExternalAutomationManager,
ExternalAutomationProvider
} from '../../../../shared/automations/external/external-automation'
import type { AutomationOwnerRef } from '../../../../shared/automations/ownership/automation-owner-ref'
import { EXTERNAL_AUTOMATION_PROVIDERS } from '../../../../shared/external-automation-scope'
import type { AutomationHostCatalogEntry } from './automation-host-catalog-types'
} from '../../../../../shared/automations/external/external-automation'
import type { AutomationOwnerRef } from '../../../../../shared/automations/ownership/automation-owner-ref'
import { EXTERNAL_AUTOMATION_PROVIDERS } from '../../../../../shared/external-automation-scope'
import type { AutomationHostCatalogEntry } from '../hosts/automation-host-catalog-types'
import { resolveExternalAutomationScopeGate } from './external-automation-scope-gating'
export type ExternalAutomationScope = {
@@ -1,9 +1,6 @@
import { describe, expect, it } from 'vitest'
import {
EXTERNAL_AUTOMATION_SCOPE_CODES,
ExternalAutomationScopeError
} from '../../../../shared/external-automation-scope'
import type { AutomationHostCatalogEntry } from './automation-host-catalog-types'
import type { AutomationHostCatalogEntry } from '../hosts/automation-host-catalog-types'
import {
externalAutomationProbeOwners,
externalAutomationScopeGateFromError,
@@ -46,19 +43,6 @@ describe('external automation scope gating', () => {
})
describe('engine scope errors', () => {
it('reads the code the engine appends to its message', () => {
const hidden = new ExternalAutomationScopeError(EXTERNAL_AUTOMATION_SCOPE_CODES.targetHidden)
expect(parseExternalAutomationScopeCode(hidden)).toBe(
EXTERNAL_AUTOMATION_SCOPE_CODES.targetHidden
)
// Electron rewraps the message; the trailing token still terminates it.
expect(
parseExternalAutomationScopeCode(
new Error(`Error invoking remote method 'x': ${hidden.message}`)
)
).toBe(EXTERNAL_AUTOMATION_SCOPE_CODES.targetHidden)
})
it('leaves unrelated failures alone so they are not relabelled as scope limits', () => {
expect(externalAutomationScopeGateFromError(new Error('socket hang up'))).toBeNull()
expect(parseExternalAutomationScopeCode(null)).toBeNull()
@@ -3,10 +3,10 @@
import {
EXTERNAL_AUTOMATION_SCOPE_CODES,
type ExternalAutomationScopeCode
} from '../../../../shared/external-automation-scope'
import type { AutomationOwnerRef } from '../../../../shared/automations/ownership/automation-owner-ref'
import type { AutomationHostCatalogEntry } from './automation-host-catalog-types'
import type { AutomationHostFilterResolution } from './automation-host-filter-resolution'
} from '../../../../../shared/external-automation-scope'
import type { AutomationOwnerRef } from '../../../../../shared/automations/ownership/automation-owner-ref'
import type { AutomationHostCatalogEntry } from '../hosts/automation-host-catalog-types'
import type { AutomationHostFilterResolution } from '../hosts/automation-host-filter-resolution'
export type ExternalAutomationScopeStatus = 'listed' | 'not-listed' | 'unknown'

Some files were not shown because too many files have changed in this diff Show More