Skip to content

feat: highlight denied commands in command execution code block#12297

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
feature/highlight-denied-commands-in-codeblock
Draft

feat: highlight denied commands in command execution code block#12297
roomote-v0[bot] wants to merge 1 commit intomainfrom
feature/highlight-denied-commands-in-codeblock

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 Bot commented May 8, 2026

Related GitHub Issue

Closes: #12292

Description

This PR attempts to address the request in Issue #12292 (comment by @PlanBernhard) to visually highlight which specific command(s) triggered a denial when a command block is presented for approval. Feedback and guidance are welcome.

Changes:

  • New utility (webview-ui/src/utils/command-denied.ts): getDeniedSubcommands() parses a command string into sub-commands using parseCommand, then checks each against the denied/allowed command lists using the same longest-prefix-match logic as the backend.

  • New UI component (DeniedCommandsBanner in CommandExecution.tsx): When denied sub-commands are detected, a yellow warning banner appears below the code block showing exactly which commands triggered the block. Uses VSCode warning theme colors for consistent styling.

  • i18n: Added deniedCommandDetected string to the English locale.

Test Procedure

  • 12 unit tests for getDeniedSubcommands utility covering: empty inputs, single denied commands, chained commands, longest-prefix-match resolution, case-insensitivity, and mixed allowed/denied chains.
  • 4 integration tests for DeniedCommandsBanner rendering in CommandExecution.spec.tsx covering: banner visibility for denied commands, hidden when allowed, chained command detection, and empty deny list.

All 45 tests pass (12 utility + 33 component tests including 29 pre-existing).

Run tests:

cd webview-ui && npx vitest run src/utils/__tests__/command-denied.spec.ts
cd webview-ui && npx vitest run src/components/chat/__tests__/CommandExecution.spec.tsx

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: No documentation updates needed for this UI enhancement.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A (running in headless environment). The banner uses VSCode warning theme variables (--vscode-inputValidation-warningBackground, --vscode-inputValidation-warningBorder) for a yellow warning appearance, with a shield icon and denied commands displayed in highlighted code tags.

Documentation Updates

No documentation updates needed.

Interactively review PR in Roo Code Cloud

When a command is blocked by the denied commands list, a yellow warning
banner now appears below the code block showing which specific
sub-commands triggered the denial. This helps users understand why a
command is asking for approval when all other commands in the block
appear to be allowed.

- Add getDeniedSubcommands utility to identify denied sub-commands
- Add DeniedCommandsBanner component with yellow warning styling
- Add i18n string for denied command detection message
- Add tests for utility and component integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] [CRITICAL] Auto Approve: Denied commands did not work

1 participant