Skip to content
Open
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
12,318 changes: 4,382 additions & 7,936 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test": "vitest run",
"test:ci": "vitest run --coverage",
"lint": "eslint --fix",
"format": "prettier --write",
"format": "prettier --write .",
"format:check": "prettier --check . && eslint .",
"storybook": "storybook dev -p 6006",
"build-storybook": "npm ci && storybook build"
Expand Down Expand Up @@ -44,9 +44,8 @@
"openai": "^4.103.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-markdown": "^10.1.0",
"remark-gfm": "^4.0.1",
"sonner": "^2.0.6",
"streamdown": "^2.1.0",
"tailwind-merge": "^3.0.2",
"tailwindcss": "^4.0.6",
"tailwindcss-animate": "^1.0.7",
Expand Down
19 changes: 19 additions & 0 deletions src/components/BotMessage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -466,4 +466,23 @@ describe('BotMessage', () => {
expect(mockExecCommand).toHaveBeenCalledWith('copy')
}
})

it('passes isStreaming prop to MarkdownContent for animation control', () => {
const message: Message = {
id: 'msg-1',
content: 'Streaming message content...',
timestamp: '2025-07-06T12:00:00Z',
status: 'sent',
}

const { container } = render(
<BotMessage message={message} isStreaming={true} />,
)

const markdownContainer = container.querySelector('[data-raw-markdown]')
expect(markdownContainer).toBeInTheDocument()
expect(markdownContainer?.getAttribute('data-raw-markdown')).toBe(
'Streaming message content...',
)
})
})
9 changes: 7 additions & 2 deletions src/components/BotMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ export interface Message extends Omit<AssistantStreamEvent, 'type'> {
export interface BotMessageProps {
message: Message
fileAnnotations?: Array<AnnotatedFile>
isStreaming?: boolean
}

export function BotMessage({ message, fileAnnotations = [] }: BotMessageProps) {
export function BotMessage({
message,
fileAnnotations = [],
isStreaming = false,
}: BotMessageProps) {
const [imageErrors, setImageErrors] = useState<Set<string>>(new Set())
const processedContent = replaceSandboxUrls(message.content, fileAnnotations)

Expand Down Expand Up @@ -71,7 +76,7 @@ export function BotMessage({ message, fileAnnotations = [] }: BotMessageProps) {
<div data-raw-markdown={processedContent}>
<MarkdownContent
content={processedContent}
fileAnnotations={fileAnnotations}
isAnimating={isStreaming}
/>
</div>

Expand Down
5 changes: 5 additions & 0 deletions src/components/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export function Chat() {
status: 'sent',
}}
fileAnnotations={[event.annotation]}
isStreaming={false}
/>
)
} else if ('type' in event && event.type === 'error') {
Expand All @@ -332,6 +333,7 @@ export function Chat() {
status: 'sent',
}}
fileAnnotations={event.fileAnnotations || []}
isStreaming={streaming && idx === renderEvents.length - 1}
/>
)
} else if ('type' in event && event.type === 'user') {
Expand Down Expand Up @@ -369,6 +371,9 @@ export function Chat() {
timestamp: getTimestamp(),
status: 'sent',
}}
isStreaming={
streaming && idx === renderEvents.length - 1
}
/>
)
} else {
Expand Down
26 changes: 14 additions & 12 deletions src/components/MarkdownContent.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import ReactMarkdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import { Streamdown } from 'streamdown'
import { toast } from 'sonner'
import type { AnnotatedFile } from '@/lib/utils/code-interpreter'
import type { ComponentProps } from 'react'
import { CodeBlock } from '@/components/CodeBlock'

type MarkdownContentProps = {
content: string
fileAnnotations?: Array<AnnotatedFile>
isAnimating?: boolean
}

export function MarkdownContent({ content }: MarkdownContentProps) {
export function MarkdownContent({
content,
isAnimating = false,
}: MarkdownContentProps) {
const handleCopySuccess = () => {
toast.success('Copied code snippet to clipboard')
}
Expand All @@ -20,10 +22,10 @@ export function MarkdownContent({ content }: MarkdownContentProps) {

return (
<div className="prose prose-sm dark:prose-invert max-w-none break-words">
<ReactMarkdown
remarkPlugins={[remarkGfm]}
<Streamdown
isAnimating={isAnimating}
components={{
pre: ({ children, ...props }) => (
pre: ({ children, ...props }: ComponentProps<'pre'>) => (
<CodeBlock
onCopySuccess={handleCopySuccess}
onCopyError={handleCopyError}
Expand All @@ -32,15 +34,15 @@ export function MarkdownContent({ content }: MarkdownContentProps) {
{children}
</CodeBlock>
),
code: ({ ...props }) => (
code: ({ ...props }: ComponentProps<'code'>) => (
<code className="break-words whitespace-pre-wrap" {...props} />
),
table: ({ ...props }) => (
table: ({ ...props }: ComponentProps<'table'>) => (
<div className="overflow-x-auto my-4">
<table {...props} />
</div>
),
a: ({ href, children, ...props }) => (
a: ({ href, children, ...props }: ComponentProps<'a'>) => (
<a
href={href}
className="break-words"
Expand All @@ -54,7 +56,7 @@ export function MarkdownContent({ content }: MarkdownContentProps) {
}}
>
{content}
</ReactMarkdown>
</Streamdown>
</div>
)
}
Loading
Loading