Skip to content

Commit c18e56a

Browse files
committed
Reuse command parsing on the frontend
1 parent 721cc59 commit c18e56a

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { cn } from "@src/lib/utils"
1515
import { Button } from "@src/components/ui"
1616
import CodeBlock from "../common/CodeBlock"
1717
import { CommandPatternSelector } from "./CommandPatternSelector"
18+
import { parseCommand } from "../../utils/command-validation"
1819
import { extractPatternsFromCommand } from "../../utils/command-parser"
1920

2021
interface CommandPattern {
@@ -53,8 +54,26 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
5354

5455
// Extract command patterns from the actual command that was executed
5556
const commandPatterns = useMemo<CommandPattern[]>(() => {
56-
const extractedPatterns = extractPatternsFromCommand(command)
57-
return extractedPatterns.map((pattern) => ({
57+
// First get all individual commands (including subshell commands) using parseCommand
58+
const allCommands = parseCommand(command)
59+
60+
// Then extract patterns from each command using the existing pattern extraction logic
61+
const allPatterns = new Set<string>()
62+
63+
// Add all individual commands first
64+
allCommands.forEach((cmd) => {
65+
if (cmd.trim()) {
66+
allPatterns.add(cmd.trim())
67+
}
68+
})
69+
70+
// Then add extracted patterns for each command
71+
allCommands.forEach((cmd) => {
72+
const patterns = extractPatternsFromCommand(cmd)
73+
patterns.forEach((pattern) => allPatterns.add(pattern))
74+
})
75+
76+
return Array.from(allPatterns).map((pattern) => ({
5877
pattern,
5978
}))
6079
}, [command])

0 commit comments

Comments
 (0)