diff --git a/src/cli/specs/orchestration-worker-specs.ts b/src/cli/specs/orchestration-worker-specs.ts index b4f7dfc12f5..c6426789fd7 100644 --- a/src/cli/specs/orchestration-worker-specs.ts +++ b/src/cli/specs/orchestration-worker-specs.ts @@ -43,7 +43,7 @@ export const ORCHESTRATION_WORKER_COMMAND_SPECS: CommandSpec[] = [ '--agent takes an Orca agent id enabled on the worker server, such as claude, codex, cursor, antigravity, muse, zcode, opencode, or opencode2.', '--model supports Claude, Codex, Cursor, Antigravity, Grok, and Muse opaque provider model ids; --effort requires --model. OMP also takes its model roles and selectors (such as @worker or provider/model:level), with --effort as its thinking level. Neither can combine with --terminal. OpenCode model selection requires an existing worktree, a verified execution-host CLI, and an available model; effort is unsupported. Other agents, including zcode, launch with the model from their own config.', 'Finished workers close on their own unless started with --keep-open; a worker started in a new worktree (new-child or new-top-level) is kept open, so release it when no one will use its chat.', - 'New worktrees use agent-first creation and default --setup to run. Repository start-immediately runs setup beside the agent; wait-for-setup gates agent readiness and task input.', + 'New worktrees use agent-first creation; without --setup, setup runs unless the project turns it off. Repository start-immediately runs setup beside the agent; wait-for-setup gates agent readiness and task input.', 'New worktrees without --name get the name Orca gives an unnamed workspace; the receipt names it. Servers older than this change still require --name.', 'Creation flags (--name, --repo, --base-branch, --display-name, --comment, --setup) are rejected for current/existing worktrees. Use exact --repo on the selected server; project/host convenience routing remains on worktree create.', "How the worker runs follows the user's own setting for new agent tabs; there is no flag for it and no caller needs to ask. A dispatch the setting cannot apply to still starts, so the placement, agent, and launch options passed here are always the ones honoured.", diff --git a/src/main/runtime/rpc/methods/orchestration/federation/federated-worker-agent-launch.ts b/src/main/runtime/rpc/methods/orchestration/federation/federated-worker-agent-launch.ts index 0a3b9d07f9f..060cb204d08 100644 --- a/src/main/runtime/rpc/methods/orchestration/federation/federated-worker-agent-launch.ts +++ b/src/main/runtime/rpc/methods/orchestration/federation/federated-worker-agent-launch.ts @@ -6,6 +6,7 @@ import type { TuiAgent } from '../../../../../../shared/agent-launch/catalog/tui import { executeAgentLaunch } from '../../../../../agent-launch/agent-launch-executor' import type { OrcaRuntimeService } from '../../../../orca-runtime' import type { OrchestrationDb } from '../../../../orchestration/db/orchestration-db' +import { resolveUnattendedSetupDecision } from '../../../../../workspace-hooks/effective-hook-config' import { WORKER_START_VOCABULARY } from '../structured-workers/orchestration-worker-start-mode' import type { WorkerSetupReceipt } from '../worker/worker-topology' import { resolveWorkerWorktreeName } from '../worker/worker-worktree-creation' @@ -78,7 +79,10 @@ export async function launchFederatedWorkerAgent(args: { dispatchId: params.dispatchId, stage: 'worktree_creating' }) - const setupDecision = params.setup ?? 'run' + const setupDecision = resolveUnattendedSetupDecision( + await runtime.showRepo(repo), + params.setup + ) const result = await runtime.createManagedWorktree({ onStartupTerminalCreated: (terminal) => { terminalCreation = terminal @@ -119,7 +123,7 @@ export async function launchFederatedWorkerAgent(args: { name: result.worktree.displayName }) const setup: WorkerSetupReceipt = { - requested: setupDecision, + requested: params.setup ?? 'inherit', effective: setupDecision, source: args.setupSource, hookFound: result.setupReceipt?.hookFound ?? false, diff --git a/src/main/runtime/rpc/methods/orchestration/federation/federated-worker-start.ts b/src/main/runtime/rpc/methods/orchestration/federation/federated-worker-start.ts index 1cb692c1d60..2d97909ae01 100644 --- a/src/main/runtime/rpc/methods/orchestration/federation/federated-worker-start.ts +++ b/src/main/runtime/rpc/methods/orchestration/federation/federated-worker-start.ts @@ -122,7 +122,7 @@ export async function startFederatedWorker(args: FederatedWorkerStartRequest): P ? ORCHESTRATION_FEDERATION_CONTROL_MAIL_PROTOCOL_VERSION : 1 - const setupDecision = createsWorktree ? (params.setup ?? 'run') : 'not_applicable' + const setupDecision = createsWorktree ? (params.setup ?? 'inherit') : 'not_applicable' const runId = args.bindRunId() const started = db.createStartingWorkerDispatch({ creator: resolveDispatchCreator(runtime, params.from, args.callerSession), @@ -195,7 +195,7 @@ export async function startFederatedWorker(args: FederatedWorkerStartRequest): P displayName: params.displayName, ...(params.displayName !== undefined ? { displayNameKind: 'user' as const } : {}), comment: params.comment, - setup: createsWorktree ? (params.setup ?? 'run') : undefined, + setup: createsWorktree ? params.setup : undefined, setupSource: createsWorktree ? params.setup ? 'explicit_request' diff --git a/src/main/runtime/rpc/methods/orchestration/worker/worker-worktree-creation.ts b/src/main/runtime/rpc/methods/orchestration/worker/worker-worktree-creation.ts index 225e552e7d5..8f74380878e 100644 --- a/src/main/runtime/rpc/methods/orchestration/worker/worker-worktree-creation.ts +++ b/src/main/runtime/rpc/methods/orchestration/worker/worker-worktree-creation.ts @@ -6,6 +6,7 @@ import type { TuiAgent } from '../../../../../../shared/agent-launch/catalog/tui import { suggestCreatureNameForPaths } from '../../../../../../shared/worktree-name-suggestion' import type { OrcaRuntimeService } from '../../../../orca-runtime' import type { OrchestrationDb } from '../../../../orchestration/db/orchestration-db' +import { resolveUnattendedSetupDecision } from '../../../../../workspace-hooks/effective-hook-config' import { OrchestrationError } from '../../../../orchestration/orchestration-error' import { parseWorkspaceKey } from '../../../../../../shared/workspace-scope' import type { WorkerEffect, WorkerSetupReceipt } from './worker-topology' @@ -121,7 +122,10 @@ export async function createWorkerWorktree(args: { setupReceipt: WorkerSetupReceipt }> { const { runtime, db, dispatchId, requestedWorktree, target, params, effects } = args - const setupDecision = params.setup ?? 'run' + const setupDecision = resolveUnattendedSetupDecision( + await runtime.showRepo(target.repoSelector), + params.setup + ) let terminalCreation: RuntimeTerminalCreate | undefined db.recordWorkerStage({ dispatchId, stage: 'worktree_creating', effects }) const created = await runtime.createManagedWorktree({ @@ -173,7 +177,7 @@ export async function createWorkerWorktree(args: { residualResources: effects }) const setupReceipt = { - requested: setupDecision, + requested: params.setup ?? 'inherit', effective: setupDecision, source: params.setup ? 'explicit_request' : 'orchestration_default', hookFound: created.setupReceipt?.hookFound ?? false, diff --git a/src/main/runtime/rpc/methods/orchestration/worker/workers-new-worktree.test.ts b/src/main/runtime/rpc/methods/orchestration/worker/workers-new-worktree.test.ts index 3dc1ec37a2b..8ecf24d3652 100644 --- a/src/main/runtime/rpc/methods/orchestration/worker/workers-new-worktree.test.ts +++ b/src/main/runtime/rpc/methods/orchestration/worker/workers-new-worktree.test.ts @@ -137,6 +137,29 @@ describe('orchestration new-worktree workers', () => { } } + it("skips setup when the project's setup is off and the coordinator did not ask for it", async () => { + vi.mocked(runtime.showRepo).mockResolvedValue({ + id: 'repo', + path: '/repo', + displayName: 'repo', + badgeColor: 'gray', + addedAt: 1, + kind: 'git', + hookSettings: { + mode: 'auto', + setupRunPolicy: 'skip-by-default', + scripts: { setup: '', archive: '' } + } + }) + mockCreatedWorktree({ state: 'skipped' }) + + await startWorker() + + expect(runtime.createManagedWorktree).toHaveBeenCalledWith( + expect.objectContaining({ setupDecision: 'skip' }) + ) + }) + // Composer and idle readiness paths must both record setup evidence; the composer path previously dropped it. it('does not inject task input when the gated setup terminal fails to start', async () => { diff --git a/src/main/workspace-hooks/effective-hook-config.ts b/src/main/workspace-hooks/effective-hook-config.ts index f5b00df705e..5391d59ee80 100644 --- a/src/main/workspace-hooks/effective-hook-config.ts +++ b/src/main/workspace-hooks/effective-hook-config.ts @@ -77,6 +77,17 @@ export function shouldRunSetupForCreate(repo: Repo, decision: SetupDecision = 'i return policy === 'run-by-default' } +/** Unattended creates (orchestration workers) cannot ask, so only an explicit project skip turns setup off. */ +export function resolveUnattendedSetupDecision( + repo: Repo, + requested?: SetupDecision +): Extract { + if (requested === 'run' || requested === 'skip') { + return requested + } + return getEffectiveSetupRunPolicy(repo) === 'skip-by-default' ? 'skip' : 'run' +} + export function getDefaultTabsLaunch( hooks: OrcaHooks | null, repo: Repo,