Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 7 additions & 42 deletions components/message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,21 @@

import type { ChatRequestOptions, Message } from 'ai';
import cx from 'classnames';
import equal from 'fast-deep-equal';
import { AnimatePresence, motion } from 'framer-motion';
import { memo, useMemo, useState } from 'react';
import { memo, useState } from 'react';

import type { Vote } from '@/lib/db/schema';
import { cn } from '@/lib/utils';

import { DocumentToolCall, DocumentToolResult } from './document';
import {
ChevronDownIcon,
LoaderIcon,
PencilEditIcon,
SparklesIcon,
} from './icons';
import { DocumentPreview } from './document-preview';
import { SparklesIcon } from './icons';
import { Markdown } from './markdown';
import { MessageActions } from './message-actions';
import { PreviewAttachment } from './preview-attachment';
import { Weather } from './weather';
import equal from 'fast-deep-equal';
import { cn } from '@/lib/utils';
import { Button } from './ui/button';
import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip';
import { MessageEditor } from './message-editor';
import { DocumentPreview } from './document-preview';
import { MessageReasoning } from './message-reasoning';
import { PreviewAttachment } from './preview-attachment';
import { Weather } from './weather';

const PurePreviewMessage = ({
chatId,
Expand Down Expand Up @@ -95,23 +87,6 @@ const PurePreviewMessage = ({

{(message.content || message.reasoning) && mode === 'view' && (
<div className="flex flex-row gap-2 items-start">
{message.role === 'user' && !isReadonly && (
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="ghost"
className="px-2 h-fit rounded-full text-muted-foreground opacity-0 group-hover/message:opacity-100"
onClick={() => {
setMode('edit');
}}
>
<PencilEditIcon />
</Button>
</TooltipTrigger>
<TooltipContent>Edit message</TooltipContent>
</Tooltip>
)}

<div
className={cn('flex flex-col gap-4', {
'bg-primary text-primary-foreground px-3 py-2 rounded-xl':
Expand Down Expand Up @@ -201,16 +176,6 @@ const PurePreviewMessage = ({
})}
</div>
)}

{!isReadonly && (
<MessageActions
key={`action-${message.id}`}
chatId={chatId}
message={message}
vote={vote}
isLoading={isLoading}
/>
)}
</div>
</div>
</motion.div>
Expand Down
8 changes: 2 additions & 6 deletions components/multimodal-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
Message,
} from 'ai';
import cx from 'classnames';
import equal from 'fast-deep-equal';
import type React from 'react';
import {
useRef,
Expand All @@ -25,10 +26,9 @@ import { sanitizeUIMessages } from '@/lib/utils';

import { ArrowUpIcon, PaperclipIcon, StopIcon } from './icons';
import { PreviewAttachment } from './preview-attachment';
import { SuggestedActions } from './suggested-actions';
import { Button } from './ui/button';
import { Textarea } from './ui/textarea';
import { SuggestedActions } from './suggested-actions';
import equal from 'fast-deep-equal';

function PureMultimodalInput({
chatId,
Expand Down Expand Up @@ -254,10 +254,6 @@ function PureMultimodalInput({
}}
/>

<div className="absolute bottom-0 p-2 w-fit flex flex-row justify-start">
<AttachmentsButton fileInputRef={fileInputRef} isLoading={isLoading} />
</div>

<div className="absolute bottom-0 right-0 p-2 w-fit flex flex-row justify-end">
{isLoading ? (
<StopButton stop={stop} setMessages={setMessages} />
Expand Down
62 changes: 9 additions & 53 deletions components/sidebar-history.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
'use client';

import { isToday, isYesterday, subMonths, subWeeks } from 'date-fns';
import type { User } from 'next-auth';
import Link from 'next/link';
import { useParams, usePathname, useRouter } from 'next/navigation';
import type { User } from 'next-auth';
import { memo, useEffect, useState } from 'react';
import { toast } from 'sonner';
import useSWR from 'swr';

import {
CheckCircleFillIcon,
GlobeIcon,
LockIcon,
MoreHorizontalIcon,
ShareIcon,
TrashIcon,
} from '@/components/icons';
import {
Expand All @@ -30,25 +25,18 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuPortal,
DropdownMenuSeparator,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
import {
SidebarGroup,
SidebarGroupContent,
SidebarMenu,
SidebarMenuAction,
SidebarMenuButton,
SidebarMenuItem,
useSidebar,
} from '@/components/ui/sidebar';
import { useChatVisibility } from '@/hooks/use-chat-visibility';
import type { Chat } from '@/lib/db/schema';
import { fetcher } from '@/lib/utils';
import { useChatVisibility } from '@/hooks/use-chat-visibility';

type GroupedChats = {
today: Chat[];
Expand Down Expand Up @@ -83,54 +71,22 @@ const PureChatItem = ({
</SidebarMenuButton>

<DropdownMenu modal={true}>
<DropdownMenuTrigger asChild>
{/*
TODO: Re-enable when conversation deletion is implemented

https://github.com/pattern-tech/pattern-app/issues/33
*/}
{/* <DropdownMenuTrigger asChild>
<SidebarMenuAction
className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground mr-0.5"
showOnHover={!isActive}
>
<MoreHorizontalIcon />
<span className="sr-only">More</span>
</SidebarMenuAction>
</DropdownMenuTrigger>
</DropdownMenuTrigger> */}

<DropdownMenuContent side="bottom" align="end">
<DropdownMenuSub>
<DropdownMenuSubTrigger className="cursor-pointer">
<ShareIcon />
<span>Share</span>
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
<DropdownMenuItem
className="cursor-pointer flex-row justify-between"
onClick={() => {
setVisibilityType('private');
}}
>
<div className="flex flex-row gap-2 items-center">
<LockIcon size={12} />
<span>Private</span>
</div>
{visibilityType === 'private' ? (
<CheckCircleFillIcon />
) : null}
</DropdownMenuItem>
<DropdownMenuItem
className="cursor-pointer flex-row justify-between"
onClick={() => {
setVisibilityType('public');
}}
>
<div className="flex flex-row gap-2 items-center">
<GlobeIcon />
<span>Public</span>
</div>
{visibilityType === 'public' ? <CheckCircleFillIcon /> : null}
</DropdownMenuItem>
</DropdownMenuSubContent>
</DropdownMenuPortal>
</DropdownMenuSub>

<DropdownMenuItem
className="cursor-pointer text-destructive focus:bg-destructive/15 focus:text-destructive dark:text-red-500"
onSelect={() => onDelete(chat.id)}
Expand Down
9 changes: 4 additions & 5 deletions lib/ai/pattern-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ export class PatternModel implements LanguageModelV1 {
textDelta: event.data,
});
} else if (event.type === 'tool_start') {
const text = this.getToolStartReasoningText(event);
controller.enqueue({
type: 'reasoning',
textDelta: text,
});
/**
* TODO: Re-enable reasoning when backend supports it
* https://github.com/pattern-tech/pattern-app/issues/27
*/
} else {
controller.enqueue({
type: 'error',
Expand Down