| 1 | import { getMarkdownLanguageTagForFile } from "core/util"; |
| 2 | import StyledMarkdownPreview from "../../../components/StyledMarkdownPreview"; |
| 3 | |
| 4 | interface CreateFileToolCallProps { |
| 5 | relativeFilepath: string; |
| 6 | fileContents: string; |
| 7 | historyIndex: number; |
| 8 | } |
| 9 | |
| 10 | export function CreateFile(props: CreateFileToolCallProps) { |
| 11 | if (!props.fileContents) { |
| 12 | return null; |
| 13 | } |
| 14 | |
| 15 | const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilepath ?? "output.txt")} ${props.relativeFilepath}\n${props.fileContents ?? ""}\n\`\`\``; |
| 16 | |
| 17 | return props.relativeFilepath ? ( |
| 18 | <StyledMarkdownPreview |
| 19 | isRenderingInStepContainer |
| 20 | disableManualApply |
| 21 | source={src} |
| 22 | itemIndex={props.historyIndex} |
| 23 | /> |
| 24 | ) : null; |
| 25 | } |