Files
archived-orca/src/shared/commit-message-host-key.ts
T
Brennan Benson 9779d6e91e Pick Model and Effort for Source Control text actions (#37205)
Use the shared agent picker for Source Control text actions, with Model and Effort choices while preserving Custom command, Arguments, inherited defaults and Save/Discard behavior.

Reviewed on bbdb46a369cc872ae6cbb7c4b65dc5968e21fcba; final CI passed and brennan-ready returned READY.
2026-11-03 10:50:20 -08:00

52 lines
1.6 KiB
TypeScript

import { getRepoExecutionHostId, parseRoutableExecutionHostId } from './execution-host'
export const LOCAL_COMMIT_MESSAGE_HOST_KEY = 'local'
export const UNKNOWN_COMMIT_MESSAGE_HOST_KEY = 'unknown'
export const RUNTIME_COMMIT_MESSAGE_HOST_KEY_PREFIX = 'runtime:'
export function getCommitMessageModelDiscoveryHostKeyForLocalRuntime(
wslDistro: string | null | undefined
): string {
const distro = wslDistro?.trim()
return distro ? `wsl:${distro}` : LOCAL_COMMIT_MESSAGE_HOST_KEY
}
export function getCommitMessageModelDiscoveryHostKey(
connectionId: string | null | undefined
): string {
if (connectionId === undefined) {
return UNKNOWN_COMMIT_MESSAGE_HOST_KEY
}
return connectionId ? `ssh:${connectionId}` : LOCAL_COMMIT_MESSAGE_HOST_KEY
}
export function getCommitMessageModelDiscoveryHostKeyForScope(
scope: string | null | undefined
): string {
if (scope === undefined) {
return UNKNOWN_COMMIT_MESSAGE_HOST_KEY
}
if (!scope) {
return LOCAL_COMMIT_MESSAGE_HOST_KEY
}
if (scope.startsWith(RUNTIME_COMMIT_MESSAGE_HOST_KEY_PREFIX)) {
return scope
}
return getCommitMessageModelDiscoveryHostKey(scope)
}
/** The text-model host key for the host a repository's commands run on. */
export function getRepoCommitMessageModelDiscoveryHostKey(repo: {
connectionId?: string | null
executionHostId?: string | null
}): string {
const host = parseRoutableExecutionHostId(getRepoExecutionHostId(repo))
return getCommitMessageModelDiscoveryHostKeyForScope(
host?.kind === 'ssh'
? host.targetId
: host?.kind === 'runtime'
? `${RUNTIME_COMMIT_MESSAGE_HOST_KEY_PREFIX}${host.environmentId}`
: null
)
}