fix: multiple chat creation bug (#88)
Co-authored-by: Eduardo <eduardo.verona@decode.pt>
This commit is contained in:
parent
ee5934dff8
commit
1b5811df53
1 changed files with 14 additions and 9 deletions
|
|
@ -1,17 +1,17 @@
|
||||||
import * as React from 'react'
|
|
||||||
import Link from 'next/link'
|
|
||||||
import Textarea from 'react-textarea-autosize'
|
|
||||||
import { UseChatHelpers } from 'ai/react'
|
import { UseChatHelpers } from 'ai/react'
|
||||||
|
import * as React from 'react'
|
||||||
|
import Textarea from 'react-textarea-autosize'
|
||||||
|
|
||||||
import { useEnterSubmit } from '@/lib/hooks/use-enter-submit'
|
|
||||||
import { cn } from '@/lib/utils'
|
|
||||||
import { Button, buttonVariants } from '@/components/ui/button'
|
import { Button, buttonVariants } from '@/components/ui/button'
|
||||||
|
import { IconArrowElbow, IconPlus } from '@/components/ui/icons'
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
TooltipTrigger
|
TooltipTrigger
|
||||||
} from '@/components/ui/tooltip'
|
} from '@/components/ui/tooltip'
|
||||||
import { IconArrowElbow, IconPlus } from '@/components/ui/icons'
|
import { useEnterSubmit } from '@/lib/hooks/use-enter-submit'
|
||||||
|
import { cn } from '@/lib/utils'
|
||||||
|
import { useRouter } from 'next/navigation'
|
||||||
|
|
||||||
export interface PromptProps
|
export interface PromptProps
|
||||||
extends Pick<UseChatHelpers, 'input' | 'setInput'> {
|
extends Pick<UseChatHelpers, 'input' | 'setInput'> {
|
||||||
|
|
@ -27,6 +27,7 @@ export function PromptForm({
|
||||||
}: PromptProps) {
|
}: PromptProps) {
|
||||||
const { formRef, onKeyDown } = useEnterSubmit()
|
const { formRef, onKeyDown } = useEnterSubmit()
|
||||||
const inputRef = React.useRef<HTMLTextAreaElement>(null)
|
const inputRef = React.useRef<HTMLTextAreaElement>(null)
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (inputRef.current) {
|
if (inputRef.current) {
|
||||||
|
|
@ -49,8 +50,12 @@ export function PromptForm({
|
||||||
<div className="relative flex max-h-60 w-full grow flex-col overflow-hidden bg-background px-8 sm:rounded-md sm:border sm:px-12">
|
<div className="relative flex max-h-60 w-full grow flex-col overflow-hidden bg-background px-8 sm:rounded-md sm:border sm:px-12">
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<Link
|
<button
|
||||||
href="/"
|
onClick={e => {
|
||||||
|
e.preventDefault()
|
||||||
|
router.refresh()
|
||||||
|
router.push('/')
|
||||||
|
}}
|
||||||
className={cn(
|
className={cn(
|
||||||
buttonVariants({ size: 'sm', variant: 'outline' }),
|
buttonVariants({ size: 'sm', variant: 'outline' }),
|
||||||
'absolute left-0 top-4 h-8 w-8 rounded-full bg-background p-0 sm:left-4'
|
'absolute left-0 top-4 h-8 w-8 rounded-full bg-background p-0 sm:left-4'
|
||||||
|
|
@ -58,7 +63,7 @@ export function PromptForm({
|
||||||
>
|
>
|
||||||
<IconPlus />
|
<IconPlus />
|
||||||
<span className="sr-only">New Chat</span>
|
<span className="sr-only">New Chat</span>
|
||||||
</Link>
|
</button>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent>New Chat</TooltipContent>
|
<TooltipContent>New Chat</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue