Skip to content

Commit 0a5cf46

Browse files
committed
fix: revert conditional display of command pattern selector
Per user feedback, the command pattern selector should always be displayed when patterns are available, regardless of whether command restrictions are configured.
1 parent 17dbda3 commit 0a5cf46

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
4747
const [isExpanded, setIsExpanded] = useState(terminalShellIntegrationDisabled)
4848
const [streamingOutput, setStreamingOutput] = useState("")
4949
const [status, setStatus] = useState<CommandExecutionStatus | null>(null)
50-
// Show suggestions when user has command restrictions enabled (has denied commands)
51-
// This provides a better UX by only showing the pattern selector when it's relevant
52-
const showCommandSuggestions = deniedCommands.length > 0 || allowedCommands.length > 0
5350

5451
// The command's output can either come from the text associated with the
5552
// task message (this is the case for completed commands) or from the
@@ -206,7 +203,7 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
206203
)}
207204
<OutputContainer isExpanded={isExpanded} output={output} />
208205
</div>
209-
{showCommandSuggestions && commandPatterns.length > 0 && (
206+
{commandPatterns.length > 0 && (
210207
<CommandPatternSelector
211208
patterns={commandPatterns}
212209
allowedCommands={allowedCommands}

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

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -253,35 +253,6 @@ Suggested patterns: npm, npm install, npm run`
253253
expect(screen.queryByTestId("command-pattern-selector")).not.toBeInTheDocument()
254254
})
255255

256-
it("should not show pattern selector when no command restrictions are configured", () => {
257-
const noRestrictionsState = {
258-
...mockExtensionState,
259-
allowedCommands: [],
260-
deniedCommands: [],
261-
}
262-
263-
render(
264-
<ExtensionStateContext.Provider value={noRestrictionsState as any}>
265-
<CommandExecution executionId="test-no-restrictions" text="npm install" />
266-
</ExtensionStateContext.Provider>,
267-
)
268-
269-
// Should not show pattern selector when no restrictions are configured
270-
expect(screen.queryByTestId("command-pattern-selector")).not.toBeInTheDocument()
271-
})
272-
273-
it("should show pattern selector when command restrictions are configured", () => {
274-
// Default mockExtensionState has allowedCommands: ["npm"] and deniedCommands: ["rm"]
275-
render(
276-
<ExtensionStateWrapper>
277-
<CommandExecution executionId="test-with-restrictions" text="npm install" />
278-
</ExtensionStateWrapper>,
279-
)
280-
281-
// Should show pattern selector when restrictions are configured
282-
expect(screen.getByTestId("command-pattern-selector")).toBeInTheDocument()
283-
})
284-
285256
it("should expand output when terminal shell integration is disabled", () => {
286257
const disabledState = {
287258
...mockExtensionState,
@@ -317,8 +288,8 @@ Output here`
317288
</ExtensionStateContext.Provider>,
318289
)
319290

320-
// When both are undefined (which defaults to empty arrays), pattern selector should not show
321-
expect(screen.queryByTestId("command-pattern-selector")).not.toBeInTheDocument()
291+
// Should show pattern selector when patterns are available
292+
expect(screen.getByTestId("command-pattern-selector")).toBeInTheDocument()
322293
})
323294

324295
it("should handle pattern change when moving from denied to allowed", () => {

0 commit comments

Comments
 (0)