Skip to content

Fix media mentions with punctuated filenames#187

Open
1jsjs wants to merge 2 commits into
trykimu:mainfrom
1jsjs:fix-video-mention-with-punctuated-filenames
Open

Fix media mentions with punctuated filenames#187
1jsjs wants to merge 2 commits into
trykimu:mainfrom
1jsjs:fix-video-mention-with-punctuated-filenames

Conversation

@1jsjs

@1jsjs 1jsjs commented Jun 11, 2026

Copy link
Copy Markdown

Summary

Fix media mentions in the chat box so selected video files keep being sent to the AI assistant when their filenames include punctuation or spaces.

Changes

  • Replaced the previous \w-based mention cleanup check with exact media-name matching.
  • Added mention boundary handling so names like clip-01.mp4 and my video.mov remain valid mentions without matching longer partial names.

Testing

  • pnpm exec eslint app/components/chat/ChatBox.tsx
  • pnpm exec prettier --check app/components/chat/ChatBox.tsx
  • Verified mention parsing with sample filenames containing ., -, and spaces.

Screenshots / Recordings (if UI)

N/A

Related Issues

Closes #29

Breaking Changes

None

Deployment Notes

None

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request improves the mention cleanup logic in ChatBox.tsx by replacing a restrictive regex with a new helper function, hasMentionToken, which supports media names containing punctuation (e.g., "clip-01.mp4"). It also includes minor formatting cleanups. The review feedback points out a potential issue where hasMentionToken could trigger false positives (such as matching email addresses) because it does not verify the character preceding the @ symbol, and provides a code suggestion to resolve this.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +85 to +99
function hasMentionToken(value: string, itemName: string): boolean {
const normalizedValue = value.toLowerCase();
const mention = `@${itemName.toLowerCase()}`;
let index = normalizedValue.indexOf(mention);

while (index !== -1) {
const nextChar = normalizedValue[index + mention.length];
if (nextChar === undefined || MENTION_TERMINATOR_PATTERN.test(nextChar)) {
return true;
}
index = normalizedValue.indexOf(mention, index + mention.length);
}

return false;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The hasMentionToken function currently matches any occurrence of @itemName regardless of what character precedes the @ symbol. This can lead to false positives, such as matching email addresses (e.g., user@domain.mp4 matching an asset named domain.mp4) or other random text containing @.

To prevent this, we should ensure that the character immediately preceding the @ symbol is either a whitespace character or that the @ is at the start of the string. This is also consistent with the mention trigger logic on line 419.

function hasMentionToken(value: string, itemName: string): boolean {
  const normalizedValue = value.toLowerCase();
  const mention = `@${itemName.toLowerCase()}`;
  let index = normalizedValue.indexOf(mention);

  while (index !== -1) {
    const prevChar = index > 0 ? normalizedValue[index - 1] : undefined;
    if (prevChar === undefined || /\s/.test(prevChar)) {
      const nextChar = normalizedValue[index + mention.length];
      if (nextChar === undefined || MENTION_TERMINATOR_PATTERN.test(nextChar)) {
        return true;
      }
    }
    index = normalizedValue.indexOf(mention, index + mention.length);
  }

  return false;
}

@codacy-production

codacy-production Bot commented Jun 11, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics -381 complexity · 0 duplication

Metric Results
Complexity -381
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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.

@video is not working

1 participant