|
|
@@ -22,6 +22,9 @@ import { TuiEvent } from "../../event"
|
|
|
import { iife } from "@/util/iife"
|
|
|
import { Locale } from "@/util/locale"
|
|
|
import { createColors, createFrames } from "../../ui/spinner.ts"
|
|
|
+import { useDialog } from "@tui/ui/dialog"
|
|
|
+import { DialogProvider as DialogProviderConnect } from "../dialog-provider"
|
|
|
+import { useToast } from "../../ui/toast"
|
|
|
|
|
|
export type PromptProps = {
|
|
|
sessionID?: string
|
|
|
@@ -50,12 +53,25 @@ export function Prompt(props: PromptProps) {
|
|
|
const sdk = useSDK()
|
|
|
const route = useRoute()
|
|
|
const sync = useSync()
|
|
|
+ const dialog = useDialog()
|
|
|
+ const toast = useToast()
|
|
|
const status = createMemo(() => sync.data.session_status[props.sessionID ?? ""] ?? { type: "idle" })
|
|
|
const history = usePromptHistory()
|
|
|
const command = useCommandDialog()
|
|
|
const renderer = useRenderer()
|
|
|
const { theme, syntax } = useTheme()
|
|
|
|
|
|
+ function promptModelWarning() {
|
|
|
+ toast.show({
|
|
|
+ variant: "warning",
|
|
|
+ message: "Connect a provider to send prompts",
|
|
|
+ duration: 3000,
|
|
|
+ })
|
|
|
+ if (sync.data.provider.length === 0) {
|
|
|
+ dialog.replace(() => <DialogProviderConnect />)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
const textareaKeybindings = createMemo(() => {
|
|
|
const newlineBindings = keybind.all.input_newline || []
|
|
|
const submitBindings = keybind.all.input_submit || []
|
|
|
@@ -388,6 +404,11 @@ export function Prompt(props: PromptProps) {
|
|
|
if (props.disabled) return
|
|
|
if (autocomplete.visible) return
|
|
|
if (!store.prompt.input) return
|
|
|
+ const selectedModel = local.model.current()
|
|
|
+ if (!selectedModel) {
|
|
|
+ promptModelWarning()
|
|
|
+ return
|
|
|
+ }
|
|
|
const sessionID = props.sessionID
|
|
|
? props.sessionID
|
|
|
: await (async () => {
|
|
|
@@ -424,8 +445,8 @@ export function Prompt(props: PromptProps) {
|
|
|
body: {
|
|
|
agent: local.agent.current().name,
|
|
|
model: {
|
|
|
- providerID: local.model.current().providerID,
|
|
|
- modelID: local.model.current().modelID,
|
|
|
+ providerID: selectedModel.providerID,
|
|
|
+ modelID: selectedModel.modelID,
|
|
|
},
|
|
|
command: inputText,
|
|
|
},
|
|
|
@@ -448,7 +469,7 @@ export function Prompt(props: PromptProps) {
|
|
|
command: command.slice(1),
|
|
|
arguments: args.join(" "),
|
|
|
agent: local.agent.current().name,
|
|
|
- model: `${local.model.current().providerID}/${local.model.current().modelID}`,
|
|
|
+ model: `${selectedModel.providerID}/${selectedModel.modelID}`,
|
|
|
messageID,
|
|
|
},
|
|
|
})
|
|
|
@@ -458,10 +479,10 @@ export function Prompt(props: PromptProps) {
|
|
|
id: sessionID,
|
|
|
},
|
|
|
body: {
|
|
|
- ...local.model.current(),
|
|
|
+ ...selectedModel,
|
|
|
messageID,
|
|
|
agent: local.agent.current().name,
|
|
|
- model: local.model.current(),
|
|
|
+ model: selectedModel,
|
|
|
parts: [
|
|
|
{
|
|
|
id: Identifier.ascending("part"),
|