Skip to content

Commit

Permalink
chore: sync live with main branch (#646)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyphilemon authored Dec 20, 2024
1 parent 091cbe3 commit f3e2aea
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 208 deletions.
5 changes: 3 additions & 2 deletions app/(chat)/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export async function POST(request: Request) {
},
},
createDocument: {
description: 'Create a document for a writing activity.',
description:
'Create a document for a writing activity. This tool will call other functions that will generate the contents of the document based on the title and kind.',
parameters: z.object({
title: z.string(),
kind: z.enum(['text', 'code']),
Expand Down Expand Up @@ -249,7 +250,7 @@ export async function POST(request: Request) {
},
},
updateDocument: {
description: 'Update a document with the given description',
description: 'Update a document with the given description.',
parameters: z.object({
id: z.string().describe('The ID of the document to update'),
description: z
Expand Down
20 changes: 12 additions & 8 deletions app/(chat)/chat/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Chat } from '@/components/chat';
import { DEFAULT_MODEL_NAME, models } from '@/lib/ai/models';
import { getChatById, getMessagesByChatId } from '@/lib/db/queries';
import { convertToUIMessages } from '@/lib/utils';
import { DataStreamHandler } from '@/components/data-stream-handler';

export default async function Page(props: { params: Promise<{ id: string }> }) {
const params = await props.params;
Expand Down Expand Up @@ -48,13 +49,16 @@ export default async function Page(props: { params: Promise<{ id: string }> }) {
}

return (
<Chat
id={chat.id}
initialMessages={convertToUIMessages(messagesFromDb)}
selectedModelId={selectedModelId}
user={session?.user}
selectedVisibilityType={chat.visibility}
isReadonly={session?.user?.id !== chat.userId}
/>
<>
<Chat
id={chat.id}
initialMessages={convertToUIMessages(messagesFromDb)}
selectedModelId={selectedModelId}
user={session?.user}
selectedVisibilityType={chat.visibility}
isReadonly={session?.user?.id !== chat.userId}
/>
<DataStreamHandler id={id} />
</>
);
}
1 change: 0 additions & 1 deletion components/block-actions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { cn, generateUUID } from '@/lib/utils';
import { ClockRewind, CopyIcon, PlayIcon, RedoIcon, UndoIcon } from './icons';

import { Button } from './ui/button';
import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip';
import { useCopyToClipboard } from 'usehooks-ts';
Expand Down
43 changes: 0 additions & 43 deletions components/block-stream-handler.tsx

This file was deleted.

12 changes: 8 additions & 4 deletions components/document-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,13 @@ const PureHitboxLayer = ({
onClick={handleClick}
role="presentation"
aria-hidden="true"
/>
>
<div className="w-full p-4 flex justify-end items-center">
<div className="absolute right-[9px] top-[13px] p-2 hover:dark:bg-zinc-700 rounded-md hover:bg-zinc-100">
<FullscreenIcon />
</div>
</div>
</div>
);
};

Expand Down Expand Up @@ -196,9 +202,7 @@ const PureDocumentHeader = ({
</div>
<div className="-translate-y-1 sm:translate-y-0 font-medium">{title}</div>
</div>
<div>
<FullscreenIcon />
</div>
<div className="w-8" />
</div>
);

Expand Down
4 changes: 3 additions & 1 deletion components/message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ const PurePreviewMessage = ({
>
{message.role === 'assistant' && (
<div className="size-8 flex items-center rounded-full justify-center ring-1 shrink-0 ring-border bg-background">
<SparklesIcon size={14} />
<div className="translate-y-px">
<SparklesIcon size={14} />
</div>
</div>
)}

Expand Down
10 changes: 5 additions & 5 deletions components/multimodal-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ export const MultimodalInput = memo(
if (prevProps.input !== nextProps.input) return false;
if (prevProps.isLoading !== nextProps.isLoading) return false;
if (!equal(prevProps.attachments, nextProps.attachments)) return false;
if (prevProps.messages.length !== nextProps.messages.length) return false;

return true;
},
Expand All @@ -302,7 +301,7 @@ function PureAttachmentsButton({
disabled={isLoading}
variant="ghost"
>
<ImageIcon size={14} />
<PaperclipIcon size={14} />
</Button>
);
}
Expand All @@ -318,7 +317,7 @@ function PureStopButton({
}) {
return (
<Button
className="rounded-full p-1.5 h-fit absolute bottom-2 right-2 m-0.5 border dark:border-zinc-600"
className="rounded-full p-1.5 h-fit border dark:border-zinc-600"
onClick={(event) => {
event.preventDefault();
stop();
Expand All @@ -343,7 +342,7 @@ function PureSendButton({
}) {
return (
<Button
className="rounded-full p-1.5 h-fit absolute bottom-2 right-2 m-0.5 border dark:border-zinc-600"
className="rounded-full p-1.5 h-fit border dark:border-zinc-600"
onClick={(event) => {
event.preventDefault();
submitForm();
Expand All @@ -358,6 +357,7 @@ function PureSendButton({
const SendButton = memo(PureSendButton, (prevProps, nextProps) => {
if (prevProps.uploadQueue.length !== nextProps.uploadQueue.length)
return false;
if (!prevProps.input !== !nextProps.input) return false;
if (prevProps.input !== nextProps.input) return false;

return true;
});
10 changes: 4 additions & 6 deletions components/sidebar-history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ export function SidebarHistory({ user }: { user: User | undefined }) {
return (
<SidebarGroup>
<SidebarGroupContent>
<div className="text-zinc-500 w-full flex flex-row justify-center items-center text-sm gap-2">
<div>Login to save and revisit previous chats!</div>
<div className="px-2 text-zinc-500 w-full flex flex-row justify-center items-center text-sm gap-2">
Login to save and revisit previous chats!
</div>
</SidebarGroupContent>
</SidebarGroup>
Expand Down Expand Up @@ -238,10 +238,8 @@ export function SidebarHistory({ user }: { user: User | undefined }) {
return (
<SidebarGroup>
<SidebarGroupContent>
<div className="text-zinc-500 w-full flex flex-row justify-center items-center text-sm gap-2">
<div>
Your conversations will appear here once you start chatting!
</div>
<div className="px-2 text-zinc-500 w-full flex flex-row justify-center items-center text-sm gap-2">
Your conversations will appear here once you start chatting!
</div>
</SidebarGroupContent>
</SidebarGroup>
Expand Down
9 changes: 5 additions & 4 deletions components/suggested-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ function PureSuggestedActions({ chatId, append, user }: SuggestedActionsProps) {
},
{
title: 'Write code that',
label: `demonstrates djikstra's algorithm!`,
action: `Write code that demonstrates djikstra's algorithm!`,
label: `demonstrates djikstra's algorithm`,
action: `Write code that demonstrates djikstra's algorithm`,
},
{
title: 'Help me write an essay',
label: `about silicon valley!`,
action: `Help me write an essay about silicon valley!`,
label: `about silicon valley`,
action: `Help me write an essay about silicon valley`,
},
{
title: 'What is the weather',
Expand All @@ -54,6 +54,7 @@ function PureSuggestedActions({ chatId, append, user }: SuggestedActionsProps) {
variant="ghost"
onClick={async (event) => {
event.preventDefault();

if (user) {
window.history.replaceState({}, '', `/chat/${chatId}`);
}
Expand Down
4 changes: 2 additions & 2 deletions components/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export const Tools = ({

return (
<motion.div
className="flex flex-col"
className="flex flex-col gap-1.5"
initial={{ opacity: 0, scale: 0.95 }}
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.95 }}
Expand Down Expand Up @@ -467,7 +467,7 @@ const PureToolbar = ({
: {
opacity: 1,
y: 0,
height: toolsByBlockKind[blockKind].length * 47,
height: toolsByBlockKind[blockKind].length * 50,
transition: { delay: 0 },
scale: 1,
}
Expand Down
132 changes: 0 additions & 132 deletions components/use-block-stream.tsx

This file was deleted.

Loading

0 comments on commit f3e2aea

Please sign in to comment.