Files
orca/src/shared/commit-message-host-key.ts
T
Brennan Benson 40ea4ece1a Track Claude models from the installed CLI per host (STA-3330) (#12369)
* feat(native-chat): track Claude models from the installed CLI per host (STA-3330)

The Claude seed no longer pins version labels to aliases that resolve
differently across CLI versions, and the catalog now defines listModels
backed by a one-shot list_models control request over --print stream-json.
Hosts whose CLI predates the request answer with a control error and keep
the seed. Discovery also feeds Source Control AI via the commit-message
spec, and the /model echo detector matches resolved model names.

* fix(native-chat): preserve discovered Claude capabilities

* fix(native-chat): tolerate malformed Claude model entries

* fix(native-chat): discover models in folder workspaces

* fix(native-chat): trust discovered Claude capabilities

* fix(native-chat): remove Claude model fallbacks

* fix(native-chat): keep the Claude model picker rendered

The Claude picker rendered nothing until the per-host `list_models` probe
returned, so it popped in ~1s after mount and never appeared at all when
the probe failed — an old CLI without `list_models`, no `claude` on PATH,
or an older remote runtime whose response omits `catalogOrigin`.

Restore the version-neutral family seed as the starting list; discovery
still replaces it wholesale on success, so a host with a real catalog
never shows an obsolete hardcoded row.

Separately, the tracked model could fall outside the active list: the
terminal header scrape yields family ids (`opus`) while a current CLI
lists `opus[1m]` and no plain `opus`. That blanked the picker trigger and
dropped the model's effort and fast-mode controls. Reconcile the tracked
id into the active list once, so the snapshot, the appliers, and typed
command recording all see a labelled, operable row for it.
2026-08-04 15:47:29 -07:00

35 lines
1.0 KiB
TypeScript

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)
}