mirror of
https://github.com/stablyai/orca.git
synced 2026-10-08 08:02:32 +00:00
Respect disabled OpenCode variants and refresh WSL settings safely (#23328)
Respect disabled OpenCode variants, preserve explicit config ownership, and refresh WSL guest settings safely across reconnects. Based on Harshul Rathod proposal #22805. Co-authored-by: Harshul Rathod <harshulrathod1640@gmail.com>
This commit is contained in:
@@ -1,8 +1,31 @@
|
||||
import { getCommandTokenPathBasename, getFirstCommandToken } from './command-token-scanner'
|
||||
import type { TuiAgent } from './tui-agent'
|
||||
|
||||
export function isOpenCode2LaunchCommand(launchCommand: string | undefined): boolean {
|
||||
function openCodeCommandAgent(launchCommand: string | undefined): 'opencode' | 'opencode2' | null {
|
||||
const binary = getCommandTokenPathBasename(getFirstCommandToken(launchCommand ?? ''))
|
||||
.toLowerCase()
|
||||
.replace(/\.(?:cmd|exe|sh)$/, '')
|
||||
return binary === 'opencode2'
|
||||
return binary === 'opencode' || binary === 'opencode2' ? binary : null
|
||||
}
|
||||
|
||||
export function isOpenCode2LaunchCommand(launchCommand: string | undefined): boolean {
|
||||
return openCodeCommandAgent(launchCommand) === 'opencode2'
|
||||
}
|
||||
|
||||
export function selectOpenCodeHookAgent(
|
||||
launchAgent: TuiAgent | undefined,
|
||||
launchCommand: string | undefined,
|
||||
isEnabled: (agent: 'opencode' | 'opencode2') => boolean
|
||||
): 'opencode' | 'opencode2' | null {
|
||||
const explicit =
|
||||
launchAgent === 'opencode' || launchAgent === 'opencode2'
|
||||
? launchAgent
|
||||
: launchAgent === undefined
|
||||
? openCodeCommandAgent(launchCommand)
|
||||
: null
|
||||
// An explicit version selects its own integration; disabling it never substitutes the other.
|
||||
if (explicit) {
|
||||
return isEnabled(explicit) ? explicit : null
|
||||
}
|
||||
return isEnabled('opencode') ? 'opencode' : isEnabled('opencode2') ? 'opencode2' : null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user