| 1 | import { getMarkdownLanguageTagForFile } from "core/util"; |
| 2 | import StyledMarkdownPreview from "../../../components/StyledMarkdownPreview"; |
| 3 | |
| 4 | type EditToolCallProps = { |
| 5 | relativeFilePath: string; |
| 6 | changes: string; |
| 7 | historyIndex: number; |
| 8 | toolCallId?: string; |
| 9 | expandCodeblocks?: boolean; |
| 10 | }; |
| 11 | |
| 12 | export function EditFile(props: EditToolCallProps) { |
| 13 | if (!props.relativeFilePath || !props.changes) { |
| 14 | return null; |
| 15 | } |
| 16 | |
| 17 | const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilePath ?? "test.txt")} ${props.relativeFilePath}\n${props.changes}\n\`\`\``; |
| 18 | |
| 19 | return ( |
| 20 | <StyledMarkdownPreview |
| 21 | expandCodeblocks={false} |
| 22 | isRenderingInStepContainer |
| 23 | disableManualApply |
| 24 | source={src} |
| 25 | toolCallId={props.toolCallId} |
| 26 | itemIndex={props.historyIndex} |
| 27 | collapsible={true} |
| 28 | /> |
| 29 | ); |
| 30 | } |