From a2330b114b6647da642f13130ab92ad37b9e8f7d Mon Sep 17 00:00:00 2001 From: Ryan Hopper-Lowe Date: Mon, 16 Dec 2024 13:31:42 -0600 Subject: [PATCH] feat: update chat bar to encapsulate thread actions and submit button --- ui/admin/app/components/chat/Chat.tsx | 7 +- ui/admin/app/components/chat/ChatHelpers.tsx | 10 +-- ui/admin/app/components/chat/Chatbar.tsx | 32 ++++--- ui/admin/app/components/ui/button.tsx | 5 +- ui/admin/app/components/ui/textarea.tsx | 92 ++++++++++++++++++-- 5 files changed, 113 insertions(+), 33 deletions(-) diff --git a/ui/admin/app/components/chat/Chat.tsx b/ui/admin/app/components/chat/Chat.tsx index 27a2810e6..8968f0963 100644 --- a/ui/admin/app/components/chat/Chat.tsx +++ b/ui/admin/app/components/chat/Chat.tsx @@ -3,7 +3,6 @@ import { useState } from "react"; import { cn } from "~/lib/utils"; import { useChat } from "~/components/chat/ChatContext"; -import { ChatHelpers } from "~/components/chat/ChatHelpers"; import { Chatbar } from "~/components/chat/Chatbar"; import { MessagePane } from "~/components/chat/MessagePane"; import { RunWorkflow } from "~/components/chat/RunWorkflow"; @@ -56,9 +55,7 @@ export function Chat({ className }: ChatProps) { setRunTriggered(true); invoke(params && JSON.stringify(params)); }} - className={cn({ - "w-full": threadId, - })} + className={cn({ "w-full": threadId })} popoverContentProps={{ className: cn({ "translate-y-[-50%]": !threadId }), }} @@ -69,8 +66,6 @@ export function Chat({ className }: ChatProps) { )} - - ); } diff --git a/ui/admin/app/components/chat/ChatHelpers.tsx b/ui/admin/app/components/chat/ChatHelpers.tsx index 1c596f44c..e524f7897 100644 --- a/ui/admin/app/components/chat/ChatHelpers.tsx +++ b/ui/admin/app/components/chat/ChatHelpers.tsx @@ -19,7 +19,7 @@ import { } from "~/components/ui/popover"; import { Switch } from "~/components/ui/switch"; -export function ChatHelpers() { +export function ChatHelpers({ className }: { className?: string }) { const { threadId } = useChat(); const { data: thread } = useSWR( @@ -39,10 +39,8 @@ export function ChatHelpers() { const tools = thread?.tools; - console.log(knowledge); - return ( -
+
+ + +
+ } />
- - ); } diff --git a/ui/admin/app/components/ui/button.tsx b/ui/admin/app/components/ui/button.tsx index 5d8b1354d..18a9ffbcf 100644 --- a/ui/admin/app/components/ui/button.tsx +++ b/ui/admin/app/components/ui/button.tsx @@ -11,11 +11,11 @@ const buttonVariants = cva( variants: { variant: { default: - "bg-primary text-primary-foreground shadow hover:bg-primary/80", + "bg-primary text-primary-foreground shadow hover:bg-primary/80 focus-visible:ring-foreground", destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/80", outline: - "border border-input bg-background shadow-sm hover:bg-muted/80", + "border border-input bg-transparent shadow-sm hover:bg-muted/80", secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80", ghost: "hover:bg-secondary hover:text-secondary-foreground", @@ -29,6 +29,7 @@ const buttonVariants = cva( sm: "h-8 px-3 text-xs", lg: "h-10 px-8", icon: "h-9 w-9 min-w-9 min-h-9 [&_svg]:size-[1.375rem]", + "icon-sm": "h-8 w-8 min-w-8 min-h-8 [&_svg]:size-[1.125rem]", }, shape: { none: "", diff --git a/ui/admin/app/components/ui/textarea.tsx b/ui/admin/app/components/ui/textarea.tsx index e6f7eb488..6b35c544a 100644 --- a/ui/admin/app/components/ui/textarea.tsx +++ b/ui/admin/app/components/ui/textarea.tsx @@ -1,16 +1,49 @@ +import { VariantProps, cva } from "class-variance-authority"; import * as React from "react"; -import { useImperativeHandle } from "react"; +import { forwardRef, useImperativeHandle } from "react"; import { cn } from "~/lib/utils"; -export type TextareaProps = React.TextareaHTMLAttributes; +const textareaVariants = cva( + "flex w-full rounded-md bg-transparent text-sm placeholder:text-muted-foreground has-[:focus-visible]:ring-1 has-[:focus-visible]:ring-ring group group-disabled:cursor-not-allowed group-disabled:bg-opacity-50", + { + variants: { + variant: { + outlined: "border border-input shadow-sm", + flat: "border-none shadow-none bg-muted", + }, + }, + defaultVariants: { + variant: "outlined", + }, + } +); -const Textarea = React.forwardRef( - ({ className, ...props }, ref) => { +type TextAreaWrapperProps = React.HTMLAttributes & + VariantProps; +const TextAreaWrapper = forwardRef( + ({ className, variant, ...props }, ref) => { + return ( +
+ ); + } +); +TextAreaWrapper.displayName = "TextAreaWrapper"; + +type TextAreaBaseProps = React.TextareaHTMLAttributes & + VariantProps; + +const TextAreaBase = forwardRef( + ({ className, variant, ...props }, ref) => { return (