Skip to content

Commit 860631c

Browse files
roomotehannesrudolph
authored andcommitted
fix: address code review feedback
- Replace unused showSuggestions state with SHOW_SUGGESTIONS constant - Fix parseCommandAndOutput import name consistency - Add test coverage for fallback case where command equals text
1 parent b24400b commit 860631c

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

webview-ui/src/components/chat/CommandExecution.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { CommandPatternSelector } from "./CommandPatternSelector"
1616
import {
1717
extractCommandPatterns,
1818
getPatternDescription,
19-
parseCommandAndOutput as parseCommandAndOutputUtil,
19+
parseCommandAndOutput,
2020
CommandPattern,
2121
} from "../../utils/commandPatterns"
2222

@@ -42,7 +42,7 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
4242
suggestions,
4343
} = useMemo(() => {
4444
// Use the enhanced parser from commandPatterns
45-
return parseCommandAndOutputUtil(text || "")
45+
return parseCommandAndOutput(text || "")
4646
}, [text])
4747

4848
// 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
6464

6565
// Use AI suggestions if available
6666
if (suggestions.length > 0) {
67-
suggestions.forEach((suggestion) => {
67+
suggestions.forEach((suggestion: string) => {
6868
patterns.push({
6969
pattern: suggestion,
7070
description: getPatternDescription(suggestion),

webview-ui/src/components/chat/__tests__/CommandExecution.spec.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,5 +463,29 @@ Without any command prefix`
463463
expect(codeBlock.textContent).toContain("Multiple lines of output")
464464
expect(codeBlock.textContent).toContain("Without any command prefix")
465465
})
466+
467+
it("should handle fallback case where parsed command equals original text", () => {
468+
// This tests the case where parseCommandAndOutput returns command === text
469+
// which happens when there's no output separator or command prefix
470+
const plainCommand = "docker build ."
471+
472+
render(
473+
<ExtensionStateWrapper>
474+
<CommandExecution executionId="test-15" text={plainCommand} />
475+
</ExtensionStateWrapper>,
476+
)
477+
478+
// Should render the command
479+
expect(screen.getByTestId("code-block")).toHaveTextContent("docker build .")
480+
481+
// Should show pattern selector with extracted patterns
482+
expect(screen.getByTestId("command-pattern-selector")).toBeInTheDocument()
483+
expect(screen.getByText("docker")).toBeInTheDocument()
484+
expect(screen.getByText("docker build")).toBeInTheDocument()
485+
486+
// Verify no output is shown (since command === text means no output)
487+
const codeBlocks = screen.getAllByTestId("code-block")
488+
expect(codeBlocks).toHaveLength(1) // Only the command block, no output block
489+
})
466490
})
467491
})

0 commit comments

Comments
 (0)