feat: support guest session (#919)

This commit is contained in:
Jeremy 2025-04-25 23:40:15 -07:00 committed by GitHub
parent 24cb2ce19b
commit 9279135355
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 741 additions and 288 deletions

View file

@ -12,9 +12,10 @@ import { MultimodalInput } from './multimodal-input';
import { Messages } from './messages';
import type { VisibilityType } from './visibility-selector';
import { useArtifactSelector } from '@/hooks/use-artifact';
import { toast } from 'sonner';
import { unstable_serialize } from 'swr/infinite';
import { getChatHistoryPaginationKey } from './sidebar-history';
import { toast } from './toast';
import type { Session } from 'next-auth';
export function Chat({
id,
@ -22,12 +23,14 @@ export function Chat({
selectedChatModel,
selectedVisibilityType,
isReadonly,
session,
}: {
id: string;
initialMessages: Array<UIMessage>;
selectedChatModel: string;
selectedVisibilityType: VisibilityType;
isReadonly: boolean;
session: Session;
}) {
const { mutate } = useSWRConfig();
@ -51,8 +54,11 @@ export function Chat({
onFinish: () => {
mutate(unstable_serialize(getChatHistoryPaginationKey));
},
onError: () => {
toast.error('An error occurred, please try again!');
onError: (error) => {
toast({
type: 'error',
description: error.message,
});
},
});
@ -72,6 +78,7 @@ export function Chat({
selectedModelId={selectedChatModel}
selectedVisibilityType={selectedVisibilityType}
isReadonly={isReadonly}
session={session}
/>
<Messages