Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.1 KB
Raw Blame
import { IconBrain } from '@posthog/icons'

import { inStorybookTestRunner } from 'lib/utils/dom'

import { TaskExecutionStatus as ExecutionStatus } from '~/queries/schema/schema-assistant-messages'

import { Activity } from '../components/ActivityPrimitives'
import { MarkdownMessage } from './MarkdownMessage'

export interface ReasoningAnswerProps {
    content: string
    completed: boolean
    id: string
    showCompletionIcon?: boolean
    animate?: boolean
}

export function ReasoningAnswer({
    content,
    completed,
    id,
    showCompletionIcon = true,
    animate = false,
}: ReasoningAnswerProps): JSX.Element {
    return (
        <Activity
            id={id}
            title={<MarkdownMessage id={id} content={completed ? 'Thought' : content} />}
            substeps={completed ? [content] : []}
            status={completed ? ExecutionStatus.Completed : ExecutionStatus.InProgress}
            icon={<IconBrain />}
            animate={!inStorybookTestRunner() && animate} // Avoiding flaky snapshots in Storybook
            showCompletionIcon={showCompletionIcon}
        />
    )
}