mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
fix(orchestration): worker worktrees follow the project's setup setting
worker-start defaulted --setup to run, so new worker worktrees ran the setup script even when the project had setup turned off. Without an explicit --setup, a worker now skips setup when the project skips it by default; run-by-default and ask keep running it as before. Remote workers resolve this on the host that owns the project.
This commit is contained in:
@@ -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.",
|
||||
|
||||
+6
-2
@@ -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,
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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<SetupDecision, 'run' | 'skip'> {
|
||||
if (requested === 'run' || requested === 'skip') {
|
||||
return requested
|
||||
}
|
||||
return getEffectiveSetupRunPolicy(repo) === 'skip-by-default' ? 'skip' : 'run'
|
||||
}
|
||||
|
||||
export function getDefaultTabsLaunch(
|
||||
hooks: OrcaHooks | null,
|
||||
repo: Repo,
|
||||
|
||||
Reference in New Issue
Block a user