Clean up editor code and reorganize contents (#478)

This commit is contained in:
Jeremy 2024-11-01 15:31:54 +05:30 committed by GitHub
parent b3aa3cb18a
commit 5190b109c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 475 additions and 444 deletions

View file

@ -4,8 +4,8 @@ import { Attachment, Message } from 'ai';
import { useChat } from 'ai/react';
import { AnimatePresence } from 'framer-motion';
import { useState } from 'react';
import { useWindowSize } from 'usehooks-ts';
import { Model } from '@/ai/models';
import { ChatHeader } from '@/components/custom/chat-header';
import { Message as PreviewMessage } from '@/components/custom/message';
import { useScrollToBottom } from '@/components/custom/use-scroll-to-bottom';
@ -42,7 +42,22 @@ export function Chat({
},
});
const [canvas, setCanvas] = useState<UICanvas | null>(null);
const { width: windowWidth = 1920, height: windowHeight = 1080 } =
useWindowSize();
const [canvas, setCanvas] = useState<UICanvas>({
documentId: 'init',
content: '',
title: '',
status: 'idle',
isVisible: false,
boundingBox: {
top: windowHeight / 4,
left: windowWidth / 4,
width: 250,
height: 50,
},
});
const [messagesContainerRef, messagesEndRef] =
useScrollToBottom<HTMLDivElement>();