Fix Windows agent launch readiness matching (#2404)
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { isRecognizedAgentType, recognizeAgentProcess } from './agent-process-recognition'
|
||||
import {
|
||||
isExpectedAgentProcess,
|
||||
isRecognizedAgentType,
|
||||
recognizeAgentProcess
|
||||
} from './agent-process-recognition'
|
||||
|
||||
describe('agent process recognition', () => {
|
||||
it('recognizes packaged Codex foreground process names', () => {
|
||||
@@ -9,4 +13,12 @@ describe('agent process recognition', () => {
|
||||
})
|
||||
expect(isRecognizedAgentType('codex-aarch64-ap')).toBe(true)
|
||||
})
|
||||
|
||||
it('matches expected agents from platform-specific foreground process paths', () => {
|
||||
expect(
|
||||
isExpectedAgentProcess(String.raw`C:\Users\dev\AppData\Roaming\npm\claude.exe`, 'claude')
|
||||
).toBe(true)
|
||||
expect(isExpectedAgentProcess('/usr/local/bin/claude', 'claude')).toBe(true)
|
||||
expect(isExpectedAgentProcess('powershell.exe', 'claude')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -55,6 +55,21 @@ function agentForNormalizedProcess(normalized: string): TuiAgent | undefined {
|
||||
return undefined
|
||||
}
|
||||
|
||||
export function isExpectedAgentProcess(
|
||||
processName: string | null | undefined,
|
||||
expectedProcess: string
|
||||
): boolean {
|
||||
const normalizedProcess = normalizeProcessName(processName)
|
||||
const normalizedExpected = normalizeProcessName(expectedProcess)
|
||||
if (!normalizedProcess || !normalizedExpected) {
|
||||
return false
|
||||
}
|
||||
return (
|
||||
normalizedProcess === normalizedExpected ||
|
||||
normalizedProcess.startsWith(`${normalizedExpected}.`)
|
||||
)
|
||||
}
|
||||
|
||||
export function recognizeAgentProcess(
|
||||
processName: string | null | undefined
|
||||
): RecognizedAgentProcess | null {
|
||||
|
||||
Reference in New Issue
Block a user