Repository navigation
fix(orchestration): resolve bare agent ids when launch binary differs #12177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The fix unblocks several agents beyond 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! |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new |
||
|
|
||
| const cmdOverrides = args.settings.agentCmdOverrides ?? {} | ||
| for (const agent of Object.keys(TUI_AGENT_CONFIG) as TuiAgent[]) { | ||
| if (!isTuiAgentEnabled(agent, args.settings.disabledTuiAgents)) { | ||
|
|
||
There was a problem hiding this comment.
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