tui: hide favorite keybind in model dialog when disconnected to prevent errors

This commit is contained in:
Dax Raad 2025-11-27 13:42:26 -05:00
parent ea52ed41be
commit a0b689c140
2 changed files with 6 additions and 3 deletions

View file

@ -21,7 +21,7 @@ export function DialogModel() {
const options = createMemo(() => {
const query = ref()?.filter
const favorites = local.model.favorite()
const favorites = connected() ? local.model.favorite() : []
const recents = local.model.recent()
const currentModel = local.model.current()
@ -67,7 +67,7 @@ export function DialogModel() {
modelID: model.id,
},
title: model.name ?? item.modelID,
description: `${provider.name}`,
description: provider.name,
category: "Favorites",
disabled: provider.id === "opencode" && model.id.includes("-nano"),
footer: model.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
@ -204,6 +204,7 @@ export function DialogModel() {
{
keybind: Keybind.parse("ctrl+f")[0],
title: "Favorite",
disabled: !connected(),
onTrigger: (option) => {
local.model.toggleFavorite(option.value as { providerID: string; modelID: string })
},

View file

@ -21,6 +21,7 @@ export interface DialogSelectProps<T> {
keybind?: {
keybind: Keybind.Info
title: string
disabled?: boolean
onTrigger: (option: DialogSelectOption<T>) => void
}[]
current?: T
@ -150,6 +151,7 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
}
for (const item of props.keybind ?? []) {
if (item.disabled) continue
if (Keybind.match(item.keybind, keybind.parse(evt))) {
const s = selected()
if (s) {
@ -254,7 +256,7 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
</For>
</scrollbox>
<box paddingRight={2} paddingLeft={4} flexDirection="row" paddingBottom={1} gap={2}>
<For each={props.keybind ?? []}>
<For each={(props.keybind ?? []).filter((x) => !x.disabled)}>
{(item) => (
<text>
<span style={{ fg: theme.text }}>