fix(ui-tui): harden TUI error handling, model validation, command UX parity, and gateway lifecycle

This commit is contained in:
Brooklyn Nicholson 2026-04-13 18:29:24 -05:00
parent 783c6b6ed6
commit aeb53131f3
15 changed files with 1303 additions and 309 deletions

View file

@ -2,7 +2,7 @@ import { startTransition, useEffect, useRef, useState } from 'react'
import type { GatewayClient } from '../gatewayClient.js'
const TAB_PATH_RE = /((?:\.\.?\/|~\/|\/|@)[^\s]*)$/
const TAB_PATH_RE = /((?:["']?(?:[A-Za-z]:[\\/]|\.{1,2}\/|~\/|\/|@|[^"'`\s]+\/))[^\s]*)$/
export function useCompletion(input: string, blocked: boolean, gw: GatewayClient) {
const [completions, setCompletions] = useState<{ text: string; display: string; meta: string }[]>([])
@ -59,7 +59,18 @@ export function useCompletion(input: string, blocked: boolean, gw: GatewayClient
setCompReplace(isSlash ? (r?.replace_from ?? 1) : input.length - (pathWord?.length ?? 0))
})
})
.catch(() => {})
.catch((e: unknown) => {
if (ref.current !== input) {
return
}
const meta = e instanceof Error && e.message ? e.message : 'unavailable'
startTransition(() => {
setCompletions([{ text: '', display: 'completion unavailable', meta }])
setCompIdx(0)
setCompReplace(isSlash ? 1 : input.length - (pathWord?.length ?? 0))
})
})
}, 60)
return () => clearTimeout(t)