From 16255dd8b6b8fea3fa8f4f59ee1619b2996294da Mon Sep 17 00:00:00 2001 From: Kit Langton <7587245+kitlangton@users.noreply.github.com> Date: Sun, 12 Jul 2026 23:12:41 +0000 Subject: [PATCH] feat(tui): add agent picker preview --- packages/tui/src/component/dialog-agent.tsx | 48 ++++++++++++++++++++- packages/tui/src/ui/dialog-select.tsx | 46 ++++++++++++++++---- 2 files changed, 83 insertions(+), 11 deletions(-) diff --git a/packages/tui/src/component/dialog-agent.tsx b/packages/tui/src/component/dialog-agent.tsx index f586cb0780..59968bc606 100644 --- a/packages/tui/src/component/dialog-agent.tsx +++ b/packages/tui/src/component/dialog-agent.tsx @@ -1,27 +1,71 @@ import { createMemo } from "solid-js" import { useLocal } from "../context/local" -import { DialogSelect } from "../ui/dialog-select" +import { DialogSelect, type DialogSelectOption } from "../ui/dialog-select" import { useDialog } from "../ui/dialog" +import { useTheme } from "../context/theme" +import { TextAttributes } from "@opentui/core" +import { DialogModel } from "./dialog-model" export function DialogAgent() { const local = useLocal() const dialog = useDialog() + const { theme } = useTheme() + + dialog.setSize("xlarge") const options = createMemo(() => local.agent.list().map((item) => { return { value: item.id, title: item.id, - description: item.description, + description: undefined, } }), ) + function Preview(props: { option: DialogSelectOption | undefined }) { + const agent = createMemo(() => local.agent.list().find((item) => item.id === props.option?.value)) + const model = createMemo(() => { + const value = agent()?.model + if (value) return `${value.providerID}/${value.id}` + return "Uses the current session model" + }) + + return ( + + + {agent()?.id} + + + DESCRIPTION + + {agent()?.description ?? "No description provided."} + + + + MODEL + {model()} + + + ) + } + return ( } + actions={[ + { + command: "model.list", + title: "Choose model", + onTrigger(option) { + local.agent.set(option.value) + dialog.replace(() => ) + }, + }, + ]} onSelect={(option) => { local.agent.set(option.value) dialog.clear() diff --git a/packages/tui/src/ui/dialog-select.tsx b/packages/tui/src/ui/dialog-select.tsx index ef13bc1d50..7ae5a2811a 100644 --- a/packages/tui/src/ui/dialog-select.tsx +++ b/packages/tui/src/ui/dialog-select.tsx @@ -49,6 +49,7 @@ export interface DialogSelectProps { label: string side?: "left" | "right" }[] + preview?: (option: DialogSelectOption | undefined) => JSX.Element bindings?: readonly Binding[] current?: T } @@ -557,17 +558,37 @@ export function DialogSelect(props: DialogSelectProps) { } return ( - - + + + + dialog.clear()}> + esc + + {props.preview?.(selected())} + + + {props.titleView ?? ( {props.title} )} - dialog.clear()}> - esc - + + dialog.clear()}> + esc + + @@ -597,7 +618,7 @@ export function DialogSelect(props: DialogSelectProps) { - + 0} fallback={ @@ -609,8 +630,8 @@ export function DialogSelect(props: DialogSelectProps) { } > (scroll = r)} @@ -721,7 +742,14 @@ export function DialogSelect(props: DialogSelectProps) { }> - + {props.footer} {(item) => }