fix: cleanup console error and warning render FE (#5253)
* fix: console error render FE * chore: cleanup error and warning console
This commit is contained in:
parent
82736c96b1
commit
57ad0894ab
@ -47,13 +47,15 @@ function DialogOverlay({
|
|||||||
type DialogContentProps = React.ComponentProps<
|
type DialogContentProps = React.ComponentProps<
|
||||||
typeof DialogPrimitive.Content
|
typeof DialogPrimitive.Content
|
||||||
> & {
|
> & {
|
||||||
showCloseButton?: boolean
|
'showCloseButton'?: boolean
|
||||||
|
'aria-describedby'?: string | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
function DialogContent({
|
function DialogContent({
|
||||||
showCloseButton = true,
|
showCloseButton = true,
|
||||||
className,
|
className,
|
||||||
children,
|
children,
|
||||||
|
'aria-describedby': ariaDescribedBy,
|
||||||
...props
|
...props
|
||||||
}: DialogContentProps) {
|
}: DialogContentProps) {
|
||||||
return (
|
return (
|
||||||
@ -61,6 +63,7 @@ function DialogContent({
|
|||||||
<DialogOverlay />
|
<DialogOverlay />
|
||||||
<DialogPrimitive.Content
|
<DialogPrimitive.Content
|
||||||
data-slot="dialog-content"
|
data-slot="dialog-content"
|
||||||
|
aria-describedby={ariaDescribedBy}
|
||||||
className={cn(
|
className={cn(
|
||||||
'bg-main-view max-h-[calc(100%-48px)] overflow-auto border-main-view-fg/10 text-main-view-fg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg',
|
'bg-main-view max-h-[calc(100%-48px)] overflow-auto border-main-view-fg/10 text-main-view-fg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg',
|
||||||
className
|
className
|
||||||
|
|||||||
@ -142,6 +142,12 @@ const ChatInput = ({
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (tooltipToolsAvailable && dropdownToolsAvailable) {
|
||||||
|
setTooltipToolsAvailable(false)
|
||||||
|
}
|
||||||
|
}, [dropdownToolsAvailable, tooltipToolsAvailable])
|
||||||
|
|
||||||
// Focus when thread changes
|
// Focus when thread changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (textareaRef.current) {
|
if (textareaRef.current) {
|
||||||
@ -479,12 +485,12 @@ const ChatInput = ({
|
|||||||
>
|
>
|
||||||
<DropdownToolsAvailable
|
<DropdownToolsAvailable
|
||||||
initialMessage={initialMessage}
|
initialMessage={initialMessage}
|
||||||
|
onOpenChange={(isOpen) => {
|
||||||
|
setDropdownToolsAvailable(isOpen)
|
||||||
|
setTooltipToolsAvailable(false)
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{(isOpen, toolsCount) => {
|
{(isOpen, toolsCount) => {
|
||||||
setDropdownToolsAvailable(isOpen)
|
|
||||||
if (tooltipToolsAvailable && isOpen) {
|
|
||||||
setTooltipToolsAvailable(false)
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
|
|||||||
@ -18,14 +18,21 @@ import { useAppState } from '@/hooks/useAppState'
|
|||||||
interface DropdownToolsAvailableProps {
|
interface DropdownToolsAvailableProps {
|
||||||
children: (isOpen: boolean, toolsCount: number) => React.ReactNode
|
children: (isOpen: boolean, toolsCount: number) => React.ReactNode
|
||||||
initialMessage?: boolean
|
initialMessage?: boolean
|
||||||
|
onOpenChange?: (isOpen: boolean) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function DropdownToolsAvailable({
|
export default function DropdownToolsAvailable({
|
||||||
children,
|
children,
|
||||||
initialMessage = false,
|
initialMessage = false,
|
||||||
|
onOpenChange,
|
||||||
}: DropdownToolsAvailableProps) {
|
}: DropdownToolsAvailableProps) {
|
||||||
const { tools } = useAppState()
|
const { tools } = useAppState()
|
||||||
const [isOpen, setIsOpen] = useState(false)
|
const [isOpen, setIsOpen] = useState(false)
|
||||||
|
|
||||||
|
const handleOpenChange = (open: boolean) => {
|
||||||
|
setIsOpen(open)
|
||||||
|
onOpenChange?.(open)
|
||||||
|
}
|
||||||
const { getCurrentThread } = useThreads()
|
const { getCurrentThread } = useThreads()
|
||||||
const {
|
const {
|
||||||
isToolDisabled,
|
isToolDisabled,
|
||||||
@ -86,7 +93,7 @@ export default function DropdownToolsAvailable({
|
|||||||
|
|
||||||
if (tools.length === 0) {
|
if (tools.length === 0) {
|
||||||
return (
|
return (
|
||||||
<DropdownMenu onOpenChange={setIsOpen}>
|
<DropdownMenu onOpenChange={handleOpenChange}>
|
||||||
<DropdownMenuTrigger asChild>{renderTrigger()}</DropdownMenuTrigger>
|
<DropdownMenuTrigger asChild>{renderTrigger()}</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent align="start" className="max-w-64">
|
<DropdownMenuContent align="start" className="max-w-64">
|
||||||
<DropdownMenuItem disabled>No tools available</DropdownMenuItem>
|
<DropdownMenuItem disabled>No tools available</DropdownMenuItem>
|
||||||
@ -96,7 +103,7 @@ export default function DropdownToolsAvailable({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenu onOpenChange={setIsOpen}>
|
<DropdownMenu onOpenChange={handleOpenChange}>
|
||||||
<DropdownMenuTrigger asChild>{renderTrigger()}</DropdownMenuTrigger>
|
<DropdownMenuTrigger asChild>{renderTrigger()}</DropdownMenuTrigger>
|
||||||
|
|
||||||
<DropdownMenuContent
|
<DropdownMenuContent
|
||||||
|
|||||||
@ -184,7 +184,7 @@ export const ThreadContent = memo(
|
|||||||
| undefined
|
| undefined
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment key={item.id}>
|
||||||
{item.content?.[0]?.text && item.role === 'user' && (
|
{item.content?.[0]?.text && item.role === 'user' && (
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<div className="flex justify-end w-full h-full text-start break-words whitespace-normal">
|
<div className="flex justify-end w-full h-full text-start break-words whitespace-normal">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user