Files
orca/src/main/ipc/preflight.ts
T
d3e3b173e6 fix(agents): one host-routed agent-detection entry point (#27054)
* fix(agents): one host-routed agent-detection entry point

preflight.detectAgents / refreshAgents take an optional { worktreeId } and the
host resolves that workspace's project runtime (WSL included) or SSH target.
Gated by preflight.workspace-scoped.v1; old peers keep the host default.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(agents): route detection by the worktree's own host record

A repo id shared by local and SSH rows made the first row pick the detection
host. Resolve the worktree from the host's list and apply the shared
execution-host routing rule; ambiguous rows refuse. Dashboard falls back to the
host-default list until a workspace's own list loads.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(agents): refuse an ambiguous workspace instead of probing the host

Only selector_not_found keeps the host default; selector_ambiguous now fails
closed. Adds runtime-level coverage of the lookup.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(agents): refuse an ambiguously owned folder workspace

Co-Authored-By: Claude <noreply@anthropic.com>

* test(agents): quick-launch runtime target carries the workspace

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: m4air <m4air@m4airs-MacBook-Air.local>
Co-authored-by: Claude <noreply@anthropic.com>
2026-10-09 18:39:13 -07:00

57 lines
2.0 KiB
TypeScript

import { ipcMain } from 'electron'
import {
detectRemoteWindowsTerminalCapabilities,
runPreflightCheck
} from '../preflight/agent-detection'
import { detectAgentsOnHost, refreshAgentsOnHost } from '../preflight/workspace-agent-detection'
import type {
PreflightRuntimeContext,
PreflightStatus,
RemoteWindowsTerminalCapabilities
} from '../preflight/agent-detection'
// Why this file is thin: everything above the handler layer moved to
// ../preflight/agent-detection so the runtime can call it without ipcMain.
// Re-exported here so existing importers of `ipc/preflight` keep working.
export * from '../preflight/agent-detection'
import { readZCodeInteractiveCapability } from '../zcode/interactive-capability'
export function registerPreflightHandlers(): void {
ipcMain.handle(
'preflight:check',
async (
_event,
args?: PreflightRuntimeContext & { force?: boolean }
): Promise<PreflightStatus> => {
return runPreflightCheck(args?.force, args)
}
)
ipcMain.handle('preflight:detectAgents', async (_event, args?: PreflightRuntimeContext) =>
detectAgentsOnHost({ kind: 'local', context: args })
)
// Why here: this is the one place that already answers "what can the installed agent CLIs
// do", and the probe is cached, so a repeat launch costs nothing.
ipcMain.handle('preflight:zcodeInteractiveCapability', async () =>
readZCodeInteractiveCapability()
)
ipcMain.handle('preflight:refreshAgents', async (_event, args?: PreflightRuntimeContext) => {
return refreshAgentsOnHost({ kind: 'local', context: args })
})
ipcMain.handle(
'preflight:detectRemoteAgents',
async (_event, args: { connectionId: string }): Promise<string[]> =>
detectAgentsOnHost({ kind: 'ssh', connectionId: args.connectionId })
)
ipcMain.handle(
'preflight:detectRemoteWindowsTerminalCapabilities',
async (_event, args: { connectionId: string }): Promise<RemoteWindowsTerminalCapabilities> => {
return detectRemoteWindowsTerminalCapabilities(args)
}
)
}