diff --git a/webview-ui/src/components/chat/CommandExecution.tsx b/webview-ui/src/components/chat/CommandExecution.tsx index 38caaa62aa..ad024a378e 100644 --- a/webview-ui/src/components/chat/CommandExecution.tsx +++ b/webview-ui/src/components/chat/CommandExecution.tsx @@ -16,7 +16,7 @@ import { CommandPatternSelector } from "./CommandPatternSelector" import { extractCommandPatterns, getPatternDescription, - parseCommandAndOutput as parseCommandAndOutputUtil, + parseCommandAndOutput, CommandPattern, } from "../../utils/commandPatterns" @@ -42,7 +42,7 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec suggestions, } = useMemo(() => { // Use the enhanced parser from commandPatterns - return parseCommandAndOutputUtil(text || "") + return parseCommandAndOutput(text || "") }, [text]) // If we aren't opening the VSCode terminal for this command then we default @@ -64,7 +64,7 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec // Use AI suggestions if available if (suggestions.length > 0) { - suggestions.forEach((suggestion) => { + suggestions.forEach((suggestion: string) => { patterns.push({ pattern: suggestion, description: getPatternDescription(suggestion), diff --git a/webview-ui/src/components/chat/__tests__/CommandExecution.spec.tsx b/webview-ui/src/components/chat/__tests__/CommandExecution.spec.tsx index 6448457cbd..3312434ab2 100644 --- a/webview-ui/src/components/chat/__tests__/CommandExecution.spec.tsx +++ b/webview-ui/src/components/chat/__tests__/CommandExecution.spec.tsx @@ -463,5 +463,29 @@ Without any command prefix` expect(codeBlock.textContent).toContain("Multiple lines of output") expect(codeBlock.textContent).toContain("Without any command prefix") }) + + it("should handle fallback case where parsed command equals original text", () => { + // This tests the case where parseCommandAndOutput returns command === text + // which happens when there's no output separator or command prefix + const plainCommand = "docker build ." + + render( + + + , + ) + + // Should render the command + expect(screen.getByTestId("code-block")).toHaveTextContent("docker build .") + + // Should show pattern selector with extracted patterns + expect(screen.getByTestId("command-pattern-selector")).toBeInTheDocument() + expect(screen.getByText("docker")).toBeInTheDocument() + expect(screen.getByText("docker build")).toBeInTheDocument() + + // Verify no output is shown (since command === text means no output) + const codeBlocks = screen.getAllByTestId("code-block") + expect(codeBlocks).toHaveLength(1) // Only the command block, no output block + }) }) })