Fix delayed agent launches such as sleep 30 && claude (#28205)

* fix(terminal): preserve preparation and discovery for delayed agent launches

* refactor(agents): centralize launch intent recognition

* refactor(agents): keep launch intent in one module apart from process recognition

Move recognizeAgentLaunchCommand next to the sleep-prefix scanner so the strict
process-table matcher is untouched, name the module away from the agent-launch
funnel files, share one executable-name normalizer, and colocate the
preparation tests with their modules.
This commit is contained in:
Neil
2026-10-13 01:55:18 -07:00
committed by GitHub
parent acea005ed8
commit 7246a0e269
32 changed files with 746 additions and 187 deletions
@@ -1,8 +1,4 @@
import { parseWslUncPath, toLinuxPath } from '../../shared/wsl-paths'
import {
getFirstCommandToken,
getCommandTokenPathBasename
} from '../../shared/command-token-scanner'
import {
getOpenCodeCliCapabilities,
type OpenCodeCliCapabilities
@@ -11,15 +7,17 @@ import type { TuiAgent } from '../../shared/tui-agent'
import { resolveCommandOnLocalPath } from '../ipc/command-path-resolver'
import { runWslProcess } from '../wsl/wsl-runner'
import { probeOpenCodeCliVersion } from './opencode-cli-version'
import {
getAgentLaunchCommandToken,
getAgentLaunchExecutableName
} from '../../shared/agent-command-line-intent'
export function getOpenCodeLaunchExecutable(
command: string | undefined,
agent?: TuiAgent
): string | null {
const executable = getFirstCommandToken(command ?? '')
const name = getCommandTokenPathBasename(executable)
.toLowerCase()
.replace(/\.(?:exe|cmd|sh)$/, '')
const executable = getAgentLaunchCommandToken(command)
const name = getAgentLaunchExecutableName(command)
return agent === 'opencode' ||
agent === 'opencode2' ||
(!agent && (name === 'opencode' || name === 'opencode2'))
@@ -87,7 +85,10 @@ export async function probeOpenCodeLaunchCapabilities(options: {
}
const executablePath = options.resolveExecutable
? await options.resolveExecutable(executable)
: await resolveCommandOnLocalPath(executable, { env: options.env, cwd: options.cwd })
: await resolveCommandOnLocalPath(executable, {
env: options.env,
cwd: options.cwd
})
return executablePath
? probeOpenCodeCliVersion({
executablePath,