mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-03 02:11:48 +00:00
fix(tui): address code review feedback on model picker
- Reset keySaving on back() to prevent blocked key entry after Esc - Show '(needs setup)' for non-API-key auth providers instead of generic '(no key)' - Set is_current correctly for unauthenticated providers that happen to be the active session provider - Guard model.save_key with is_managed() check — return error on managed installs where .env is read-only
This commit is contained in:
parent
f4c761c6a0
commit
c8e506c383
2 changed files with 9 additions and 3 deletions
|
|
@ -4758,7 +4758,7 @@ def _(rid, params: dict) -> dict:
|
||||||
authenticated.append({
|
authenticated.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": False,
|
"is_current": entry.slug == current_provider,
|
||||||
"is_user_defined": False,
|
"is_user_defined": False,
|
||||||
"models": [],
|
"models": [],
|
||||||
"total_models": 0,
|
"total_models": 0,
|
||||||
|
|
@ -4794,7 +4794,7 @@ def _(rid, params: dict) -> dict:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
from hermes_cli.auth import PROVIDER_REGISTRY
|
from hermes_cli.auth import PROVIDER_REGISTRY
|
||||||
from hermes_cli.config import save_env_value
|
from hermes_cli.config import is_managed, save_env_value
|
||||||
from hermes_cli.model_switch import list_authenticated_providers
|
from hermes_cli.model_switch import list_authenticated_providers
|
||||||
|
|
||||||
slug = (params.get("slug") or "").strip()
|
slug = (params.get("slug") or "").strip()
|
||||||
|
|
@ -4802,6 +4802,9 @@ def _(rid, params: dict) -> dict:
|
||||||
if not slug or not api_key:
|
if not slug or not api_key:
|
||||||
return _err(rid, 4001, "slug and api_key are required")
|
return _err(rid, 4001, "slug and api_key are required")
|
||||||
|
|
||||||
|
if is_managed():
|
||||||
|
return _err(rid, 4006, "managed install — credentials are read-only")
|
||||||
|
|
||||||
pconfig = PROVIDER_REGISTRY.get(slug)
|
pconfig = PROVIDER_REGISTRY.get(slug)
|
||||||
if not pconfig:
|
if not pconfig:
|
||||||
return _err(rid, 4002, f"unknown provider: {slug}")
|
return _err(rid, 4002, f"unknown provider: {slug}")
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ export function ModelPicker({ gw, onCancel, onSelect, sessionId, t }: ModelPicke
|
||||||
setModelIdx(0)
|
setModelIdx(0)
|
||||||
setKeyInput('')
|
setKeyInput('')
|
||||||
setKeyError('')
|
setKeyError('')
|
||||||
|
setKeySaving(false)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -383,7 +384,9 @@ export function ModelPicker({ gw, onCancel, onSelect, sessionId, t }: ModelPicke
|
||||||
(p, i) => {
|
(p, i) => {
|
||||||
const authMark = p.authenticated === false ? '○' : p.is_current ? '*' : '●'
|
const authMark = p.authenticated === false ? '○' : p.is_current ? '*' : '●'
|
||||||
const modelCount = p.total_models ?? p.models?.length ?? 0
|
const modelCount = p.total_models ?? p.models?.length ?? 0
|
||||||
const suffix = p.authenticated === false ? '(no key)' : `${modelCount} models`
|
const suffix = p.authenticated === false
|
||||||
|
? (p.auth_type === 'api_key' ? '(no key)' : '(needs setup)')
|
||||||
|
: `${modelCount} models`
|
||||||
|
|
||||||
return `${authMark} ${names[i]} · ${suffix}`
|
return `${authMark} ${names[i]} · ${suffix}`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue