Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9a37baa
Let automations run in Chat or Terminal through the shared agent laun…
brennanb2025 Oct 27, 2026
e8b0992
Preserve automation targets and complete owned terminal lifecycles
brennanb2025 Oct 27, 2026
9446867
Keep stale prompt projection available when recomputing
brennanb2025 Oct 27, 2026
cf9d32c
Count repeated desktop lifecycle resource cleanup
brennanb2025 Oct 27, 2026
62ca316
Preserve automation targets and observe committed chat work
brennanb2025 Oct 27, 2026
161d88e
Scope automation observation and reconciliation work to each operation
brennanb2025 Oct 27, 2026
e1a175d
Restore automation server composition and process import boundaries
brennanb2025 Oct 27, 2026
56f4d6e
Merge main into automation chat runs
brennanb2025 Oct 27, 2026
008d661
fix(automations): preserve busy chat reuse and runtime boundaries
brennanb2025 Oct 28, 2026
dc6677e
Merge main and preserve complete overlapping terminal shutdown
brennanb2025 Oct 28, 2026
d7aa11a
Merge main and preserve automation destination refusal proof
brennanb2025 Oct 28, 2026
e5112e6
Correct shutdown test acquisition and exported measurement types
brennanb2025 Oct 28, 2026
f4cec2b
Correct automation fixture contracts and duplicate imports
brennanb2025 Oct 28, 2026
50a7318
Keep Chat automations separate from Terminal execution
brennanb2025 Oct 28, 2026
7b51df3
Preserve Chat automation intent while support loads
brennanb2025 Oct 29, 2026
008efc7
Merge main into Chat automations and preserve integration proofs
brennanb2025 Oct 29, 2026
9c4c175
Resolve automation Chat validation diagnostics
brennanb2025 Oct 29, 2026
3575b4e
Merge main into automation Chat runs
brennanb2025 Oct 29, 2026
ace256e
Remove unused automation style directives
brennanb2025 Oct 29, 2026
2d391e4
Make automation surface classes statically inspectable
brennanb2025 Oct 29, 2026
1224cf6
Move automation surface styling into a toggle group variant
brennanb2025 Oct 29, 2026
c59dbcd
Correct automation launch test receipt and output fixtures
brennanb2025 Oct 29, 2026
02f496b
Merge main into automation Chat runs
brennanb2025 Oct 29, 2026
9a4ac5b
Account for pane and prompt journal reads in delivery test
brennanb2025 Oct 29, 2026
cad4344
Preserve admitted automation surface across save effects
brennanb2025 Oct 29, 2026
cb6f08b
Separate automation page test actions from their lifecycle owner
brennanb2025 Oct 29, 2026
f28e7c1
Merge main into automation chat runs
brennanb2025 Oct 29, 2026
2ea2e05
Complete automation route test fixture input
brennanb2025 Oct 29, 2026
973de2b
Merge main after upstream editor validation repair
brennanb2025 Oct 29, 2026
c5f3c94
Reopen saved automation chats through the existing record owner
brennanb2025 Oct 30, 2026
72fe71a
test: isolate session action fixtures and complete tab groups
brennanb2025 Oct 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/scripts/ci-shard-timings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,7 @@
"src/main/automations/external-manager-scoped.test.ts": 256,
"src/main/automations/external-manager.test.ts": 207,
"src/main/automations/headless-automation-agent-launch.test.ts": 1100,
"tests/e2e/headless-automation-agent-launch.unit.test.ts": 1100,
"src/main/automations/headless-dispatch-durability.test.ts": 401,
"src/main/automations/headless-run-terminal-retention.test.ts": 115,
"src/main/automations/headless-workspace-create.test.ts": 34,
Expand Down
12 changes: 11 additions & 1 deletion config/scripts/orcad-entry-build.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,25 @@ import { runProcessSync } from '@orca/process-host'

const directory = mkdtempSync(join(tmpdir(), 'orca-structured-provider-build-'))
const bundle = join(directory, 'orcad-server.js')
let serverMetafile

beforeAll(async () => {
await buildOrcadEntry(bundle)
serverMetafile = (await buildOrcadEntry(bundle)).metafile
}, 60_000)

afterAll(() => {
rmSync(directory, { recursive: true, force: true })
})

it('ships no runtime Electron imports in the actual server graph', () => {
const electronImporters = Object.entries(serverMetafile.inputs)
.filter(([, input]) =>
input.imports.some(({ path }) => path === 'electron' || path.startsWith('electron/'))
)
.map(([path]) => path)
expect(electronImporters).toEqual([])
})

it('loads the structured Claude SDK through the packaged server under plain Node', () => {
const loaded = runProcessSync({
program: process.execPath,
Expand Down
1 change: 1 addition & 0 deletions config/tsconfig.tc.web.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"../src/shared/**/*",
"../src/packages/process-host/src/__fixtures__/**/*",
"../src/main/gitlab/mappers.ts",
"../src/main/persistence/profile-state-cutover-fixture.ts",
"../src/main/runtime/sidebar-inputs/sidebar-clock.ts",
"../src/main/runtime/sidebar-inputs/sidebar-retention-owner.ts",
"../src/main/runtime/sidebar-inputs/producer-revision.ts",
Expand Down
93 changes: 93 additions & 0 deletions src/main/automations/automation-agent-run-result.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import type { AgentLaunchResult } from '../../shared/agent-launch-intent'
import type { OrcaRuntimeService } from '../runtime/orca-runtime'
import type { AutomationRun } from '../../shared/automations-types'
import type { AutomationChatAgentLaunch } from './automation-chat-agent-launch'
import { tuiAgentDisplayName } from '../../shared/tui-agent-display-names'
import { parsePaneKey } from '../../shared/stable-pane-id'
import { readAutomationRunReceipt } from './automation-run-receipt'
import { AutomationRunLaunchError } from './headless-dispatch'

export function publishedLaunchTarget(
runtime: Pick<OrcaRuntimeService, 'getTerminalPaneKey' | 'getTerminalPtyIdForHandle'>,
result: Pick<AgentLaunchResult, 'worktreeId' | 'outcome'>
): AutomationChatAgentLaunch {
let paneKey = result.outcome.kind === 'terminal' ? (result.outcome.paneKey ?? null) : null
let ptyId: string | null = null
if (result.outcome.kind === 'terminal') {
try {
paneKey ??= runtime.getTerminalPaneKey(result.outcome.handle)
} catch {
/* Keep publication identity. */
}
try {
ptyId = runtime.getTerminalPtyIdForHandle(result.outcome.handle)
} catch {
/* Process evidence is optional for opening. */
}
}
return {
workspaceId: result.worktreeId,
workspaceDisplayName: null,
sessionKind: result.outcome.kind === 'structured' ? 'chat' : 'terminal',
chatSessionId: result.outcome.kind === 'structured' ? result.outcome.sessionId : null,
terminalHandle: result.outcome.kind === 'terminal' ? result.outcome.handle : null,
terminalSessionId: parsePaneKey(paneKey ?? '')?.tabId ?? null,
terminalPaneKey: paneKey,
terminalPtyId: ptyId
}
}

export async function enrichAutomationRunTarget(
runtime: OrcaRuntimeService,
target: AutomationChatAgentLaunch
): Promise<AutomationChatAgentLaunch> {
try {
const shown = await runtime.showManagedWorktree(`id:${target.workspaceId}`)
target.workspaceDisplayName = shown.displayName ?? null
} catch {
// Publication already owns the target; optional display metadata cannot erase it.
}
if (target.terminalHandle && !target.terminalSessionId) {
try {
target.terminalSessionId = (await runtime.showTerminal(target.terminalHandle)).tabId ?? null
} catch {
// Keep the published pane and process identity when its presentation is unavailable.
}
}
return target
}

/** A lost reply is not proof of no effect; recovery reads the ordinary operation receipt. */
export async function automationRunAcceptedTarget(
runtime: OrcaRuntimeService,
run: Pick<AutomationRun, 'id' | 'createdAt'>,
target: AutomationChatAgentLaunch | undefined,
error: unknown,
agent: string
): Promise<AutomationChatAgentLaunch> {
const receipt = await runtime
.openAgentSessionRecordStore()
.then((store) => readAutomationRunReceipt(store, run))
.catch(() => null)
if (receipt?.accepted) {
return receipt.kind === 'terminal'
? publishedLaunchTarget(runtime, receipt.launch)
: {
workspaceId: receipt.workspaceId,
workspaceDisplayName: null,
sessionKind: 'chat',
chatSessionId: receipt.sessionId,
terminalHandle: null,
terminalSessionId: null,
terminalPaneKey: null,
terminalPtyId: null
}
}
if (target) {
throw new AutomationRunLaunchError(
`${tuiAgentDisplayName(agent)} could not confirm this run's prompt. Open the run before trying again.`,
target
)
}
throw error
}
116 changes: 116 additions & 0 deletions src/main/automations/automation-chat-agent-launch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import type { Automation, AutomationRun } from '../../shared/automations-types'
import type { OrcaRuntimeService } from '../runtime/orca-runtime'
import { launchAgentOnHost } from '../runtime/rpc/methods/agent-launch'
import { reuseAutomationChat } from './automation-chat-session-reuse'
import { buildHeadlessAutomationWorkspaceName } from './headless-workspace-create'
import type { AutomationRunTargetResult } from './run-target-resolution'
import {
AutomationRunLaunchError,
type HeadlessAutomationDispatchLaunch
} from './headless-dispatch'
import {
publishedLaunchTarget,
enrichAutomationRunTarget,
automationRunAcceptedTarget
} from './automation-agent-run-result'
import { automationRunOperationId, AUTOMATION_AGENT_CALLER } from './automation-run-operation'
import { createAutomationDispatchToken } from './dispatch-tokens'
import { tuiAgentDisplayName } from '../../shared/tui-agent-display-names'

export type AutomationChatAgentLaunch = HeadlessAutomationDispatchLaunch & {
terminalHandle: string | null
}

export type AutomationChatLaunchRequest = {
automation: Automation
run: Pick<AutomationRun, 'id' | 'title' | 'scheduledFor' | 'createdAt'>
target: Extract<AutomationRunTargetResult, { ok: true }>
runs: readonly AutomationRun[]
}

export async function launchAutomationChatAgent(
runtime: OrcaRuntimeService,
request: AutomationChatLaunchRequest
): Promise<AutomationChatAgentLaunch> {
try {
return await enrichAutomationRunTarget(runtime, await launchChat(runtime, request))
} catch (error) {
if (error instanceof AutomationRunLaunchError) {
throw error
}
console.error('[automations] chat launch failed:', error)
throw new Error(
`${tuiAgentDisplayName(request.automation.agentId) ?? 'The agent'} could not confirm this run's prompt. Open its workspace before running again.`
)
}
}

async function launchChat(
runtime: OrcaRuntimeService,
request: AutomationChatLaunchRequest
): Promise<AutomationChatAgentLaunch> {
const { automation, run, target } = request
let published: AutomationChatAgentLaunch | undefined
if (automation.reuseSession && automation.workspaceId) {
const reused = await reuseAutomationChat(runtime, request)
if (reused) {
return reused
}
}
const operationId = automationRunOperationId(run, 'fresh-launch')
try {
const result = await launchAgentOnHost(
{
agent: automation.agentId,
operationId,
surface: 'chat',
presentation: 'background',
prompt: { text: automation.prompt, delivery: 'submit' },
target:
automation.workspaceMode === 'existing'
? { kind: 'existing', worktree: `id:${automation.workspaceId}` }
: {
kind: 'create-worktree',
create: {
repo: `id:${target.repo.id}`,
name: buildHeadlessAutomationWorkspaceName(run.title, run.scheduledFor),
...(automation.baseBranch ? { baseBranch: automation.baseBranch } : {}),
setupDecision: automation.setupDecision ?? 'skip',
activate: false,
automationProvenanceRequest: {
automationId: automation.id,
automationRunId: run.id,
dispatchToken: createAutomationDispatchToken(automation.id, run.id),
createRequestId: operationId
}
}
}
},
{ runtime, caller: AUTOMATION_AGENT_CALLER },
{
onSurfacePublished: (surface) => {
published = publishedLaunchTarget(runtime, surface)
}
}
)
if (result.prompt?.outcome !== 'journaled' && result.prompt?.outcome !== 'handed-to-terminal') {
throw new AutomationRunLaunchError(
`${tuiAgentDisplayName(automation.agentId)} started, but Orca could not confirm this run's prompt. Open the run before trying again.`,
published ?? publishedLaunchTarget(runtime, result)
)
}
return publishedLaunchTarget(runtime, result)
} catch (error) {
if (
error instanceof Error &&
('code' in error
? error.code === 'agent_session_operation_expired'
: error.message.includes('agent_session_operation_expired'))
) {
throw new AutomationRunLaunchError(
`${tuiAgentDisplayName(automation.agentId)} could not start because this run waited too long. Run the automation again.`
)
}
return automationRunAcceptedTarget(runtime, run, published, error, automation.agentId)
}
}
Loading
Loading