Skip to content

refactor: streamline Chat component and introduce useStreamingChat hook #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 14, 2025
Merged
16 changes: 7 additions & 9 deletions src/components/BotMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Bot, Copy, Download } from 'lucide-react'
import { toast } from 'sonner'
import { useState } from 'react'
import { cn } from '@/lib/utils'
import type { Message } from '@/mcp/client'
import type { AssistantStreamEvent } from '@/hooks/useStreamingChat'
import { formatTimestamp } from '@/lib/utils'
import { MarkdownContent } from '@/components/MarkdownContent'
import { copyToClipboard } from '@/lib/utils/clipboard'
Expand All @@ -12,14 +12,14 @@ import {
createAnnotatedFileUrl,
} from '@/lib/utils/code-interpreter'

interface Message extends Omit<AssistantStreamEvent, 'type'> {
timestamp: string
status: string
}

export interface BotMessageProps {
message: Message
fileAnnotations?: Array<{
type: string
container_id: string
file_id: string
filename: string
}>
fileAnnotations?: AssistantStreamEvent['fileAnnotations']
}

export function BotMessage({ message, fileAnnotations = [] }: BotMessageProps) {
Expand Down Expand Up @@ -75,7 +75,6 @@ export function BotMessage({ message, fileAnnotations = [] }: BotMessageProps) {
<MarkdownContent content={message.content} />
</div>

{/* Image Gallery */}
{imageFiles.length > 0 && (
<div className="mt-4 space-y-3">
{imageFiles.map((annotation) => {
Expand Down Expand Up @@ -130,7 +129,6 @@ export function BotMessage({ message, fileAnnotations = [] }: BotMessageProps) {
</div>
)}

{/* Other Files */}
{otherFiles.length > 0 && (
<div className="mt-4 space-y-2">
<p className="text-xs text-gray-500 dark:text-gray-400 font-medium">
Expand Down
Loading
Loading