Skip to content

Commit bce10d6

Browse files
committed
remove auto approve commands from command window
1 parent 5fac683 commit bce10d6

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ interface CommandExecutionProps {
4242
export const CommandExecution = ({ executionId, text, icon, title, isDenied = false }: CommandExecutionProps) => {
4343
const {
4444
terminalShellIntegrationDisabled = false,
45+
destructiveCommandGuardEnabled = false,
4546
allowedCommands = [],
4647
deniedCommands = [],
4748
setAllowedCommands,
@@ -246,7 +247,7 @@ export const CommandExecution = ({ executionId, text, icon, title, isDenied = fa
246247
<CodeBlock source={command} language="shell" />
247248
<OutputContainer isExpanded={isExpanded} output={output} />
248249
</div>
249-
{command && command.trim() && !isDenied && (
250+
{command && command.trim() && !destructiveCommandGuardEnabled && !isDenied && (
250251
<CommandPatternSelector
251252
patterns={commandPatterns}
252253
allowedCommands={allowedCommands}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ vi.mock("../CommandPatternSelector", () => ({
4444
// Mock ExtensionStateContext
4545
const mockExtensionState = {
4646
terminalShellIntegrationDisabled: false,
47+
destructiveCommandGuardEnabled: false,
4748
allowedCommands: ["npm"],
4849
deniedCommands: ["rm"],
4950
setAllowedCommands: vi.fn(),
@@ -110,6 +111,22 @@ describe("CommandExecution", () => {
110111
expect(selector).toHaveTextContent("npm install express")
111112
})
112113

114+
it("should hide the command pattern selector while destructive command guard is enabled", () => {
115+
const state = {
116+
...mockExtensionState,
117+
destructiveCommandGuardEnabled: true,
118+
}
119+
120+
render(
121+
<ExtensionStateContext.Provider value={state as any}>
122+
<CommandExecution executionId="test-1" text="npm install express" />
123+
</ExtensionStateContext.Provider>,
124+
)
125+
126+
expect(screen.getByTestId("code-block")).toHaveTextContent("npm install express")
127+
expect(screen.queryByTestId("command-pattern-selector")).not.toBeInTheDocument()
128+
})
129+
113130
it("should hide the command pattern selector for a denied command", () => {
114131
render(
115132
<ExtensionStateWrapper>

0 commit comments

Comments
 (0)