Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Nov 5, 2025

Fixes the issue where multi-line git commit messages were being incorrectly split into separate commands, causing cluttered UI in the auto-approved commands list.

Problem

Multi-line commands with quoted strings (like git commit messages) were being split at newline boundaries, even when those newlines were inside quotes. This caused:

  1. Incorrect command validation: Multi-line git commits were split into separate validation commands
  2. Cluttered UI: The command pattern selector showed unwieldy full commit message text instead of clean patterns like 'git' and 'git commit'

Solution

Combined two fixes for a robust solution:

1. Root Cause Fix in parseCommand

  • Modified parseCommand to protect quoted strings before splitting on newlines
  • Multi-line strings like git commit messages now stay as single commands instead of being incorrectly split across lines
  • Uses placeholder substitution to preserve quoted content during parsing

2. UI Display Fix in CommandExecution

  • Added filtering to exclude patterns containing newlines from the command pattern selector
  • UI now shows clean, useful patterns like 'git' and 'git commit' instead of entire multi-line commit messages
  • Users can still see the full command in the code block, but only get actionable patterns in the selector

Key Changes

  • webview-ui/src/utils/command-validation.ts: Enhanced parseCommand to handle quoted multi-line strings correctly
  • webview-ui/src/components/chat/CommandExecution.tsx: Filter multi-line patterns from UI display
  • Tests: Updated test expectations to match correct behavior using regex patterns instead of exact string matches

Screenshots

Before:
2025-11-05_17-20-01
After:
2025-11-05_17-19-08

Result

✅ Multi-line commands are properly validated (no incorrect splitting)
✅ UI shows clean, useful patterns (no unwieldy multi-line text)
✅ All existing functionality preserved
✅ All tests pass


Important

Fixes multi-line command parsing and UI display for quoted strings, enhancing parseCommand and filtering multi-line patterns in CommandExecution.tsx.

  • Behavior:
    • Fixes multi-line command parsing in parseCommand to handle quoted strings correctly, preventing incorrect splitting.
    • Filters out multi-line patterns from the command pattern selector in CommandExecution.tsx.
  • Tests:
    • Updates tests in CommandExecution.spec.tsx and command-validation.spec.ts to cover new parsing logic and UI behavior.
  • Misc:
    • Improves placeholder substitution logic in command-validation.ts to preserve quoted content during parsing.

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

- Fix parseCommand to preserve newlines within quoted strings instead of incorrectly splitting them
- Add UI filtering to exclude multi-line patterns from command pattern selector
- Multi-line git commit messages now work correctly for auto-approval validation
- UI shows clean patterns like 'git' and 'git commit' instead of unwieldy full commit text
- Add comprehensive tests for multi-line command handling
- Much simpler approach than placeholder substitution in PR #8792

Fixes the issue where multi-line git commit messages were being split into
separate commands and causing cluttered UI in the auto-approved commands list.
The previous test expectations were using escaped \n strings, but template
literals preserve actual whitespace. Updated tests to use regex patterns
to verify the correct multi-line behavior while being flexible about
exact whitespace formatting.
@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners November 5, 2025 23:06
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Nov 5, 2025
@roomote
Copy link

roomote bot commented Nov 5, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The PR correctly fixes multi-line command parsing by protecting quoted strings before splitting on newlines, and filters multi-line patterns from the UI selector. The implementation is sound, tests are comprehensive, and no bugs were identified.

Mention @roomote in a comment to trigger your PR Fixer agent and make changes to this pull request.

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Nov 5, 2025
})

// Protect single-quoted strings (including multi-line) - simpler regex
protectedCommand = protectedCommand.replace(/'[^']*'/gs, (match) => {

Choose a reason for hiding this comment

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

these regexes do not have any escape support, so when you have a commit message with quotes in it you will again get garbled commands in the auto-allow list, for instance, take this git commit

git commit -m "refactor: \"In the garden of configuration, where validation blooms twice\"

Like Borges' labyrinth of forking paths, we've discovered that environment
validation had wandered into duplicate territories. The drizzle.ts file now
bears witness to this repetition—a mirror reflecting its own constraints,
where POSTGRES_URL and its companions are validated not once, but twice,
creating an echo chamber of certainty.

Meanwhile, in email.ts, the OrganizationInviteEmailData type has become
a palimpsest, its definition inscribed twice upon the parchment of code,
separated by empty lines that whisper of copy-paste's gentle touch.

As Hemingway might say: \"The code was good. Then it wasn't. Then it was
the same code twice.\" We've added statement_timeout to the pool config—
a temporal guardian standing watch over queries that might otherwise
wander too long in database dreams.

This commit captures a moment of duplication, a snapshot of code's
tendency toward repetition, like Gertrude Stein's \"a rose is a rose
is a rose\"—except here, it's validation that validates the validation."

We get

CleanShot 2025-11-06 at 09 18 47@2x

@markijbema
Copy link

I really like the visual changes! I do think that the sanitation itself is more limited than my version, and think this still show the problematic behaviour in commits with quotes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: PR [Needs Review]

Development

Successfully merging this pull request may close these issues.

4 participants