feat: just more cleaning

This commit is contained in:
Brooklyn Nicholson 2026-04-15 14:14:01 -05:00
parent 46cef4b7fa
commit 4b4b4d47bc
24 changed files with 2852 additions and 829 deletions

View file

@ -2,18 +2,10 @@ import { Box, Text, useInput } from '@hermes/ink'
import { useEffect, useState } from 'react'
import type { GatewayClient } from '../gatewayClient.js'
import type { ModelOptionProvider, ModelOptionsResponse } from '../gatewayTypes.js'
import { asRpcResult, rpcErrorMessage } from '../lib/rpc.js'
import type { Theme } from '../theme.js'
interface ProviderItem {
is_current?: boolean
models?: string[]
name: string
slug: string
total_models?: number
warning?: string
}
const VISIBLE = 12
const pageOffset = (count: number, sel: number) => Math.max(0, Math.min(sel - Math.floor(VISIBLE / 2), count - VISIBLE))
@ -31,7 +23,7 @@ export function ModelPicker({
sessionId: string | null
t: Theme
}) {
const [providers, setProviders] = useState<ProviderItem[]>([])
const [providers, setProviders] = useState<ModelOptionProvider[]>([])
const [currentModel, setCurrentModel] = useState('')
const [err, setErr] = useState('')
const [loading, setLoading] = useState(true)
@ -41,9 +33,9 @@ export function ModelPicker({
const [stage, setStage] = useState<'model' | 'provider'>('provider')
useEffect(() => {
gw.request('model.options', sessionId ? { session_id: sessionId } : {})
.then((raw: any) => {
const r = asRpcResult(raw)
gw.request<ModelOptionsResponse>('model.options', sessionId ? { session_id: sessionId } : {})
.then(raw => {
const r = asRpcResult<ModelOptionsResponse>(raw)
if (!r) {
setErr('invalid response: model.options')
@ -52,7 +44,7 @@ export function ModelPicker({
return
}
const next = (r.providers ?? []) as ProviderItem[]
const next = r.providers ?? []
setProviders(next)
setCurrentModel(String(r.model ?? ''))
setProviderIdx(