88 lines
2.3 KiB
TypeScript
88 lines
2.3 KiB
TypeScript
"use client"
|
|
|
|
import { useTranslations } from "next-intl"
|
|
import type {
|
|
ConnectionStatus,
|
|
PromptCapabilitiesInfo,
|
|
PromptDraft,
|
|
SessionConfigOptionInfo,
|
|
SessionModeInfo,
|
|
AvailableCommandInfo,
|
|
} from "@/lib/types"
|
|
import { MessageInput } from "@/components/chat/message-input"
|
|
|
|
interface ChatInputProps {
|
|
status: ConnectionStatus | null
|
|
promptCapabilities: PromptCapabilitiesInfo
|
|
defaultPath?: string
|
|
onFocus?: () => void
|
|
onSend: (draft: PromptDraft, modeId?: string | null) => void
|
|
onCancel: () => void
|
|
modes?: SessionModeInfo[]
|
|
configOptions?: SessionConfigOptionInfo[]
|
|
modeLoading?: boolean
|
|
configOptionsLoading?: boolean
|
|
selectedModeId?: string | null
|
|
onModeChange?: (modeId: string) => void
|
|
onConfigOptionChange?: (configId: string, valueId: string) => void
|
|
availableCommands?: AvailableCommandInfo[] | null
|
|
attachmentTabId?: string | null
|
|
draftStorageKey?: string | null
|
|
}
|
|
|
|
export function ChatInput({
|
|
status,
|
|
promptCapabilities,
|
|
defaultPath,
|
|
onFocus,
|
|
onSend,
|
|
onCancel,
|
|
modes,
|
|
configOptions,
|
|
modeLoading = false,
|
|
configOptionsLoading = false,
|
|
selectedModeId,
|
|
onModeChange,
|
|
onConfigOptionChange,
|
|
availableCommands,
|
|
attachmentTabId,
|
|
draftStorageKey,
|
|
}: ChatInputProps) {
|
|
const t = useTranslations("Folder.chat.chatInput")
|
|
const isConnected = status === "connected"
|
|
const isPrompting = status === "prompting"
|
|
const isConnecting = status === "connecting" || status === "downloading"
|
|
|
|
return (
|
|
<div className="p-4 pt-0">
|
|
<MessageInput
|
|
onSend={onSend}
|
|
promptCapabilities={promptCapabilities}
|
|
onFocus={onFocus}
|
|
defaultPath={defaultPath}
|
|
disabled={!isConnected}
|
|
isPrompting={isPrompting}
|
|
onCancel={onCancel}
|
|
modes={modes}
|
|
configOptions={configOptions}
|
|
modeLoading={modeLoading}
|
|
configOptionsLoading={configOptionsLoading}
|
|
selectedModeId={selectedModeId}
|
|
onModeChange={onModeChange}
|
|
onConfigOptionChange={onConfigOptionChange}
|
|
availableCommands={availableCommands}
|
|
attachmentTabId={attachmentTabId}
|
|
draftStorageKey={draftStorageKey}
|
|
placeholder={
|
|
isConnecting
|
|
? t("connecting")
|
|
: isPrompting
|
|
? t("agentResponding")
|
|
: t("sendMessage")
|
|
}
|
|
className="min-h-28 max-h-60"
|
|
/>
|
|
</div>
|
|
)
|
|
}
|