diff --git a/gui/src/components/markdown/CodeBlockToolbar.tsx b/gui/src/components/markdown/CodeBlockToolbar.tsx index a7a1e53e1..f0512163d 100644 --- a/gui/src/components/markdown/CodeBlockToolbar.tsx +++ b/gui/src/components/markdown/CodeBlockToolbar.tsx @@ -40,6 +40,30 @@ interface CodeBlockToolBarProps { } const terminalLanguages = ["bash", "sh"]; +const commonTerminalCommands = [ + "npm", + "pnpm", + "yarn", + "bun", + "deno", + "npx", + "cd", + "ls", + "pwd", + "pip", + "python", + "node", + "git", + "curl", + "wget", +]; +function isTerminalCodeBlock(language: string | undefined, text: string) { + return ( + terminalLanguages.includes(language) || + (text.trim().split("\n").length === 1 && + commonTerminalCommands.some((c) => text.trim().startsWith(c))) + ); +} function CodeBlockToolBar(props: CodeBlockToolBarProps) { const [copied, setCopied] = useState(false); @@ -52,7 +76,7 @@ function CodeBlockToolBar(props: CodeBlockToolBarProps) { <>