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.
This commit is contained in:
hannesrudolph 2025-07-23 13:26:06 -06:00
parent 17dbda3d4d
commit 0a5cf463a1
2 changed files with 3 additions and 35 deletions

View file

@ -47,9 +47,6 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
const [isExpanded, setIsExpanded] = useState(terminalShellIntegrationDisabled)
const [streamingOutput, setStreamingOutput] = useState("")
const [status, setStatus] = useState<CommandExecutionStatus | null>(null)
// Show suggestions when user has command restrictions enabled (has denied commands)
// This provides a better UX by only showing the pattern selector when it's relevant
const showCommandSuggestions = deniedCommands.length > 0 || allowedCommands.length > 0
// The command's output can either come from the text associated with the
// task message (this is the case for completed commands) or from the
@ -206,7 +203,7 @@ export const CommandExecution = ({ executionId, text, icon, title }: CommandExec
)}
<OutputContainer isExpanded={isExpanded} output={output} />
</div>
{showCommandSuggestions && commandPatterns.length > 0 && (
{commandPatterns.length > 0 && (
<CommandPatternSelector
patterns={commandPatterns}
allowedCommands={allowedCommands}

View file

@ -253,35 +253,6 @@ Suggested patterns: npm, npm install, npm run`
expect(screen.queryByTestId("command-pattern-selector")).not.toBeInTheDocument()
})
it("should not show pattern selector when no command restrictions are configured", () => {
const noRestrictionsState = {
...mockExtensionState,
allowedCommands: [],
deniedCommands: [],
}
render(
<ExtensionStateContext.Provider value={noRestrictionsState as any}>
<CommandExecution executionId="test-no-restrictions" text="npm install" />
</ExtensionStateContext.Provider>,
)
// Should not show pattern selector when no restrictions are configured
expect(screen.queryByTestId("command-pattern-selector")).not.toBeInTheDocument()
})
it("should show pattern selector when command restrictions are configured", () => {
// Default mockExtensionState has allowedCommands: ["npm"] and deniedCommands: ["rm"]
render(
<ExtensionStateWrapper>
<CommandExecution executionId="test-with-restrictions" text="npm install" />
</ExtensionStateWrapper>,
)
// Should show pattern selector when restrictions are configured
expect(screen.getByTestId("command-pattern-selector")).toBeInTheDocument()
})
it("should expand output when terminal shell integration is disabled", () => {
const disabledState = {
...mockExtensionState,
@ -317,8 +288,8 @@ Output here`
</ExtensionStateContext.Provider>,
)
// When both are undefined (which defaults to empty arrays), pattern selector should not show
expect(screen.queryByTestId("command-pattern-selector")).not.toBeInTheDocument()
// Should show pattern selector when patterns are available
expect(screen.getByTestId("command-pattern-selector")).toBeInTheDocument()
})
it("should handle pattern change when moving from denied to allowed", () => {