mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-07 02:51:50 +00:00
fix(tui): address remaining review feedback — ordering and digit shortcuts
- Emit providers in CANONICAL_PROVIDERS order (matching hermes model) with user-defined/custom providers appended after - Remove digit quick-select (1-9,0) handler — inconsistent with absolute row numbering and already removed from hint text - Remove unused windowOffset import
This commit is contained in:
parent
c8e506c383
commit
c23c7c994b
2 changed files with 36 additions and 46 deletions
|
|
@ -4736,18 +4736,23 @@ def _(rid, params: dict) -> dict:
|
||||||
max_models=50,
|
max_models=50,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Mark authenticated providers and build lookup
|
# Mark authenticated providers and build lookup by slug
|
||||||
authed_slugs = set()
|
authed_map: dict = {}
|
||||||
|
authed_extra: list = [] # user-defined/custom not in CANONICAL_PROVIDERS
|
||||||
|
canonical_slugs = {e.slug for e in CANONICAL_PROVIDERS}
|
||||||
for p in authenticated:
|
for p in authenticated:
|
||||||
p["authenticated"] = True
|
p["authenticated"] = True
|
||||||
authed_slugs.add(p["slug"])
|
authed_map[p["slug"]] = p
|
||||||
|
if p["slug"] not in canonical_slugs:
|
||||||
|
authed_extra.append(p)
|
||||||
|
|
||||||
# Add unauthenticated canonical providers so the picker shows all
|
# Build final list in CANONICAL_PROVIDERS order, merging auth data
|
||||||
# options (matching `hermes model` behaviour).
|
|
||||||
from hermes_cli.auth import PROVIDER_REGISTRY as _auth_reg
|
from hermes_cli.auth import PROVIDER_REGISTRY as _auth_reg
|
||||||
|
ordered: list = []
|
||||||
for entry in CANONICAL_PROVIDERS:
|
for entry in CANONICAL_PROVIDERS:
|
||||||
if entry.slug in authed_slugs:
|
if entry.slug in authed_map:
|
||||||
continue
|
ordered.append(authed_map[entry.slug])
|
||||||
|
else:
|
||||||
pconfig = _auth_reg.get(entry.slug)
|
pconfig = _auth_reg.get(entry.slug)
|
||||||
auth_type = pconfig.auth_type if pconfig else "api_key"
|
auth_type = pconfig.auth_type if pconfig else "api_key"
|
||||||
key_env = pconfig.api_key_env_vars[0] if (pconfig and pconfig.api_key_env_vars) else ""
|
key_env = pconfig.api_key_env_vars[0] if (pconfig and pconfig.api_key_env_vars) else ""
|
||||||
|
|
@ -4755,7 +4760,7 @@ def _(rid, params: dict) -> dict:
|
||||||
warning = f"paste {key_env} to activate"
|
warning = f"paste {key_env} to activate"
|
||||||
else:
|
else:
|
||||||
warning = f"run `hermes model` to configure ({auth_type})"
|
warning = f"run `hermes model` to configure ({auth_type})"
|
||||||
authenticated.append({
|
ordered.append({
|
||||||
"slug": entry.slug,
|
"slug": entry.slug,
|
||||||
"name": _PROVIDER_LABELS.get(entry.slug, entry.label),
|
"name": _PROVIDER_LABELS.get(entry.slug, entry.label),
|
||||||
"is_current": entry.slug == current_provider,
|
"is_current": entry.slug == current_provider,
|
||||||
|
|
@ -4769,10 +4774,13 @@ def _(rid, params: dict) -> dict:
|
||||||
"warning": warning,
|
"warning": warning,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Append user-defined/custom providers not in canonical list
|
||||||
|
ordered.extend(authed_extra)
|
||||||
|
|
||||||
return _ok(
|
return _ok(
|
||||||
rid,
|
rid,
|
||||||
{
|
{
|
||||||
"providers": authenticated,
|
"providers": ordered,
|
||||||
"model": current_model,
|
"model": current_model,
|
||||||
"provider": current_provider,
|
"provider": current_provider,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import type { ModelOptionProvider, ModelOptionsResponse } from '../gatewayTypes.
|
||||||
import { asRpcResult, rpcErrorMessage } from '../lib/rpc.js'
|
import { asRpcResult, rpcErrorMessage } from '../lib/rpc.js'
|
||||||
import type { Theme } from '../theme.js'
|
import type { Theme } from '../theme.js'
|
||||||
|
|
||||||
import { OverlayHint, useOverlayKeys, windowItems, windowOffset } from './overlayControls.js'
|
import { OverlayHint, useOverlayKeys, windowItems } from './overlayControls.js'
|
||||||
|
|
||||||
const VISIBLE = 12
|
const VISIBLE = 12
|
||||||
const MIN_WIDTH = 40
|
const MIN_WIDTH = 40
|
||||||
|
|
@ -264,24 +264,6 @@ export function ModelPicker({ gw, onCancel, onSelect, sessionId, t }: ModelPicke
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const n = ch === '0' ? 10 : parseInt(ch, 10)
|
|
||||||
|
|
||||||
if (!Number.isNaN(n) && n >= 1 && n <= Math.min(10, count)) {
|
|
||||||
const offset = windowOffset(count, sel, VISIBLE)
|
|
||||||
|
|
||||||
if (stage === 'provider') {
|
|
||||||
const next = offset + n - 1
|
|
||||||
|
|
||||||
if (providers[next]) {
|
|
||||||
setProviderIdx(next)
|
|
||||||
}
|
|
||||||
} else if (provider && models[offset + n - 1]) {
|
|
||||||
onSelect(
|
|
||||||
`${models[offset + n - 1]} --provider ${provider.slug}${persistGlobal ? ' --global' : ` ${TUI_SESSION_MODEL_FLAG}`}`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue