Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 3, 2025

This PR fixes an issue in the CommandPatternSelector component where the full command was being suggested as a pattern even when it contained command separators (&&, ||, ;, |, &).

Problem

When a command like npm install && npm test was executed, the manage command permissions UI would suggest the entire command string as a pattern that could be allowed/denied. This was problematic because:

  • It would allow/deny the entire chain of commands at once
  • It goes against the principle of managing individual commands separately
  • The command validation system already splits commands by separators for individual validation

Solution

Modified the CommandPatternSelector component to check if the command contains separators before adding it as the first pattern. If separators are detected, only the extracted individual command patterns are shown.

Changes

  • Updated CommandPatternSelector.tsx to add separator detection logic
  • Added comprehensive tests to verify the behavior with various separator types
  • Existing functionality for commands without separators remains unchanged

Testing

  • All existing tests pass
  • Added new test cases specifically for commands with separators
  • Verified linting and type checking pass

Important

CommandPatternSelector now skips suggesting full commands with separators as patterns, showing only individual commands instead.

  • Behavior:
    • CommandPatternSelector now skips suggesting full commands with separators (&&, ||, ;, |, &) as patterns.
    • Only individual command patterns are shown if separators are present.
  • Code Changes:
    • Updated CommandPatternSelector.tsx to include separator detection logic.
    • Adjusted logic to only add full command if no separators are present.
  • Testing:
    • Added tests in CommandPatternSelector.spec.tsx for commands with and without separators.
    • Verified behavior with various separator types.

This description was created by Ellipsis for c2082fd. You can customize this summary. It will automatically update as commits are pushed.

@roomote roomote bot requested review from cte, jr and mrubens as code owners August 3, 2025 05:38
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Aug 3, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed my own code and found it surprisingly coherent. Must be a bug in the review system.

const fullCommandPattern: CommandPattern = { pattern: trimmedCommand }

// Check if command contains separators (&&, ||, ;, |, &)
const containsSeparators = /(?:&&|\|\||;|\||&)/.test(trimmedCommand)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this regex pattern robust enough? It might miss edge cases with whitespace variations like npm install &&npm test (no space before operator). The command-validation module might handle these cases differently.

Also, since command separators are used in multiple places (I see similar patterns in command-validation.ts), would it make sense to extract this as a shared constant to ensure consistency?

const trimmedCommand = command.trim()
const fullCommandPattern: CommandPattern = { pattern: trimmedCommand }

// Check if command contains separators (&&, ||, ;, |, &)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider enhancing this comment to explicitly list all the separators being checked: &&, ||, ;, |, &. This would make it immediately clear what patterns trigger the separator detection.

expect(screen.getByText("npm")).toBeInTheDocument()
})

it("should handle various separator types correctly", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great test coverage for the main scenarios! Consider adding a few edge case tests:

  • Commands with separators but no extracted patterns
  • Commands with multiple consecutive separators (e.g., cmd1 && || cmd2)
  • Commands with separators at the beginning or end (e.g., && cmd or cmd &&)

These edge cases might not be common, but they could help ensure the component behaves predictably in all situations.

@mrubens mrubens closed this Aug 3, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 3, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 3, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants