feat: paginate chat history (#903)

This commit is contained in:
Jeremy 2025-04-03 00:28:36 -07:00 committed by GitHub
parent 235b0edb91
commit a07a3aad5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 346 additions and 212 deletions

View file

@ -10,9 +10,11 @@ import { fetcher, generateUUID } from '@/lib/utils';
import { Artifact } from './artifact';
import { MultimodalInput } from './multimodal-input';
import { Messages } from './messages';
import { VisibilityType } from './visibility-selector';
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';
export function Chat({
id,
@ -47,7 +49,7 @@ export function Chat({
sendExtraMessageFields: true,
generateId: generateUUID,
onFinish: () => {
mutate('/api/history');
mutate(unstable_serialize(getChatHistoryPaginationKey));
},
onError: () => {
toast.error('An error occured, please try again!');