Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

fix: restrict @-mention parsing to line-start or whitespace boundaries - #7876

Merged
mrubens merged 1 commit into
mainfrom
fix/restrict-mention-parsing-boundaries
Sep 11, 2025
Merged

mrubens merged 1 commit into
mainfrom
fix/restrict-mention-parsing-boundaries

Conversation

@ghost

@ghost ghost commented Sep 11, 2025 •

Copy link
Copy Markdown

Summary

This PR fixes issue #7875 by restricting @-mention parsing to only work at line-start or after whitespace, preventing accidental loading of URLs/files from pasted logs.

Problem

When users paste logs containing patterns like @https://... or @/path mid-line (e.g., Error loading resource@https://api.example.com), the chat incorrectly treats them as mentions and attempts to load the content.

Solution

  • Updated the mentionRegex pattern to require the @ symbol to be either:
    • At the start of a line (^)
    • Preceded by whitespace ((?<=\s))
  • This prevents mentions from being recognized when they appear mid-word or after non-whitespace characters

Changes

  • Modified src/shared/context-mentions.ts to update the regex pattern
  • Added comprehensive test cases in src/shared/__tests__/context-mentions.spec.ts to verify:
    • Valid mentions still work (at line-start and after whitespace)
    • Invalid mentions are rejected (mid-word, after punctuation without space)
    • Pasted log scenarios are handled correctly

Screenshots:

Before:
image

After:
image

Testing

  • ✅ All existing tests pass (71 tests total)
  • ✅ Added new test cases specifically for boundary restrictions
  • ✅ Verified backward compatibility - all valid use cases continue to work
  • ✅ Linting and type checks pass

Backward Compatibility

This change maintains full backward compatibility:

  • All valid mentions (at line-start or after whitespace) continue to work
  • The escape mechanism (\@) is preserved
  • No breaking changes to existing functionality

Fixes #7875


Important

Restricts @-mention parsing to line-start or after whitespace to prevent incorrect parsing in pasted logs.

  • Behavior:
    • Restricts @-mention parsing to line-start or after whitespace in mentionRegex in context-mentions.ts.
    • Prevents incorrect parsing of URLs/files in pasted logs.
  • Testing:
    • Adds test cases in context-mentions.spec.ts for valid mentions (line-start, after whitespace) and invalid mentions (mid-word, after punctuation without space).
    • Verifies handling of pasted log scenarios.
  • Backward Compatibility:
    • Maintains existing functionality for valid mentions.
    • No breaking changes introduced.

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

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

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

Mentions: restrict “@” parsing to line-start or whitespace to avoid loading from pasted logs

4 participants