Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
101 changes: 101 additions & 0 deletions src/main/runtime/orca-runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12734,6 +12734,107 @@ describe('OrcaRuntimeService', () => {
expect(spawnCall?.env?.ORCA_AGENT_LAUNCH_TOKEN).toBeUndefined()
})

it('resolves bare agent ids whose launch binary differs from the id', async () => {
const spawn = vi.fn().mockResolvedValue({ id: 'pty-bg' })
const runtimeStore = {
...store,
getSettings: () => ({
...store.getSettings(),
disabledTuiAgents: [],
agentCmdOverrides: {},
agentDefaultArgs: { antigravity: '--dangerously-skip-permissions' },
agentDefaultEnv: {}
})
}
const runtime = new OrcaRuntimeService(runtimeStore)
runtime.setPtyController({
spawn,
write: () => true,
kill: () => true,
getForegroundProcess: async () => null
})

// Why: orchestration worker-start passes command: <agent id>; antigravity's
// binary is `agy`, so matching only launchCmd left this path as a raw shell
// string without launchAgent / launch token.
Comment on lines +12757 to +12759

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Reduce this comment to one line.

Keep only the non-obvious reason for the test. The three-line explanation exceeds the TypeScript comment guideline.

As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.

Source: Coding guidelines

await runtime.createTerminal(`path:${TEST_WORKTREE_PATH}`, {
command: 'antigravity',
title: 'worker'
})

const spawnCall = spawn.mock.calls[0]?.[0] as
| { command?: string; env?: Record<string, string>; launchAgent?: string }
| undefined
expect(spawnCall?.command).toBe("agy '--dangerously-skip-permissions'")
expect(spawnCall?.launchAgent).toBe('antigravity')
expect(spawnCall?.env?.ORCA_AGENT_LAUNCH_TOKEN).toMatch(UUID_RE)
})

it('resolves bare cursor agent ids to the cursor-agent launch binary', async () => {
const spawn = vi.fn().mockResolvedValue({ id: 'pty-bg' })
const runtimeStore = {
...store,
getSettings: () => ({
...store.getSettings(),
disabledTuiAgents: [],
agentCmdOverrides: {},
agentDefaultArgs: { cursor: '--yolo' },
agentDefaultEnv: {}
})
}
const runtime = new OrcaRuntimeService(runtimeStore)
runtime.setPtyController({
spawn,
write: () => true,
kill: () => true,
getForegroundProcess: async () => null
})

await runtime.createTerminal(`path:${TEST_WORKTREE_PATH}`, {
command: 'cursor',
title: 'worker'
})

const spawnCall = spawn.mock.calls[0]?.[0] as
| { command?: string; launchAgent?: string; env?: Record<string, string> }
| undefined
expect(spawnCall?.command).toBe("cursor-agent '--yolo'")
expect(spawnCall?.launchAgent).toBe('cursor')
expect(spawnCall?.env?.ORCA_AGENT_LAUNCH_TOKEN).toMatch(UUID_RE)
})

it('keeps disabled bare agent id terminal creates unchanged', async () => {
const spawn = vi.fn().mockResolvedValue({ id: 'pty-bg' })
const runtimeStore = {
...store,
getSettings: () => ({
...store.getSettings(),
disabledTuiAgents: ['antigravity' as const],
agentCmdOverrides: {},
agentDefaultArgs: { antigravity: '--dangerously-skip-permissions' },
agentDefaultEnv: {}
})
}
const runtime = new OrcaRuntimeService(runtimeStore)
runtime.setPtyController({
spawn,
write: () => true,
kill: () => true,
getForegroundProcess: async () => null
})

await runtime.createTerminal(`path:${TEST_WORKTREE_PATH}`, {
command: 'antigravity'
})

const spawnCall = spawn.mock.calls[0]?.[0] as
| { command?: string; env?: Record<string, string>; launchAgent?: string }
| undefined
expect(spawnCall?.command).toBe('antigravity')
expect(spawnCall?.launchAgent).toBeUndefined()
expect(spawnCall?.env?.ORCA_AGENT_LAUNCH_TOKEN).toBeUndefined()
})

it('sends Settings agent defaults through renderer-backed bare agent terminal creates', async () => {
const runtimeStore = {
...store,
Comment on lines 12734 to 12840

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 No test for multi-token launchCmd agents resolved via bare ID

The fix unblocks several agents beyond antigravity and cursor — notably kiro (launchCmd: 'kiro-cli chat --tui'), aug (auggie), and command-code (command-code --trust). These are the cases where the old binary-match loop was most broken (multi-token launchCmd made it even harder to accidentally pass the right string via worker-start). A test confirming that command: 'kiro' produces kiro-cli chat --tui ... would close the obvious regression vector for those agents and document the intended behaviour for reviewers of future kiro/aug config changes.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Expand Down
8 changes: 8 additions & 0 deletions src/main/runtime/orca-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,14 @@ function resolveBareAgentLaunchCommand(args: {
return null
}

// Why: worker-start / federation pass the agent id (`antigravity`, `cursor`) as
// createTerminal `command`, while UI launches use the real binary (`agy`,
// `cursor-agent`). Accept the bare id so Settings defaults, launchAgent, and
// ORCA_AGENT_LAUNCH_TOKEN attach the same way as a picker launch.
if (isTuiAgent(command) && isTuiAgentEnabled(command, args.settings.disabledTuiAgents)) {
return command
}
Comment on lines +1381 to +1383

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Early-return bypasses cmdOverride-as-command matching

The new isTuiAgent check runs before the existing loop that also compares command against each agent's agentCmdOverrides entry. If an operator has ever set agentCmdOverrides['someAgent'] = 'antigravity' (using another agent's bare ID as a custom launch path for that agent), command = 'antigravity' would previously resolve to 'someAgent' via the override branch, but now resolves to 'antigravity' via this early return. In practice this configuration pattern is unlikely (and arguably nonsensical), but the priority shift is undocumented and could surprise anyone who relied on it.


const cmdOverrides = args.settings.agentCmdOverrides ?? {}
for (const agent of Object.keys(TUI_AGENT_CONFIG) as TuiAgent[]) {
if (!isTuiAgentEnabled(agent, args.settings.disabledTuiAgents)) {
Expand Down
Loading