feat: use code block to display bash commands

This commit is contained in:
Henry Li
2026-01-19 21:59:23 +08:00
parent fb265f2b1f
commit b8f9678d07
2 changed files with 9 additions and 3 deletions

View File

@@ -109,12 +109,12 @@ export const CodeBlock = ({
>
<div className="relative size-full">
<div
className="[&>pre]:bg-background! [&>pre]:text-foreground! size-full overflow-auto dark:hidden [&_code]:font-mono [&_code]:text-sm [&>pre]:m-0 [&>pre]:p-4 [&>pre]:text-sm [&>pre]:whitespace-pre-wrap"
className="[&>pre]:bg-background! [&>pre]:text-foreground! size-full overflow-auto dark:hidden [&_code]:font-mono [&_code]:text-sm [&>pre]:m-0 [&>pre]:text-sm [&>pre]:whitespace-pre-wrap"
// biome-ignore lint/security/noDangerouslySetInnerHtml: "this is needed."
dangerouslySetInnerHTML={{ __html: html }}
/>
<div
className="[&>pre]:bg-background! [&>pre]:text-foreground! hidden size-full overflow-auto dark:block [&_code]:font-mono [&_code]:text-sm [&>pre]:m-0 [&>pre]:p-4 [&>pre]:text-sm [&>pre]:whitespace-pre-wrap"
className="[&>pre]:bg-background! [&>pre]:text-foreground! hidden size-full overflow-auto dark:block [&_code]:font-mono [&_code]:text-sm [&>pre]:m-0 [&>pre]:text-sm [&>pre]:whitespace-pre-wrap"
// biome-ignore lint/security/noDangerouslySetInnerHtml: "this is needed."
dangerouslySetInnerHTML={{ __html: darkHtml }}
/>

View File

@@ -33,6 +33,7 @@ import { cn } from "@/lib/utils";
import { useArtifacts } from "../artifacts";
import { FlipDisplay } from "../flip-display";
import { CodeBlock } from "@/components/ai-elements/code-block";
export function MessageGroup({
className,
@@ -300,7 +301,12 @@ function ToolCall({
icon={SquareTerminalIcon}
>
{command && (
<ChainOfThoughtSearchResult>{command}</ChainOfThoughtSearchResult>
<CodeBlock
className="mx-0 border-none px-0"
showLineNumbers={false}
language="bash"
code={command}
/>
)}
</ChainOfThoughtStep>
);