Skip to content

Commit f884d83

Browse files
committed
fix(chat): only treat a period as a mention boundary when no name continues after it
1 parent b7c2dc5 commit f884d83

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎apps/sim/app/workspace/[workspaceId]/home/components/user-message-content/utils.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ describe('computeMentionRanges', () => {
1717
expect(spans('(see @Workflow)', [workflow])).toEqual(['@Workflow'])
1818
})
1919

20+
it('treats a period as a boundary only when no name continues after it', () => {
21+
expect(spans('see @Workflow.', [workflow])).toEqual(['@Workflow'])
22+
expect(spans('open @report.pdf', [{ kind: 'file', label: 'report' }])).toEqual([])
23+
})
24+
2025
it('matches every repeat of a mention separated by one space', () => {
2126
expect(spans('@Workflow @Workflow', [workflow])).toEqual(['@Workflow', '@Workflow'])
2227
})

‎apps/sim/app/workspace/[workspaceId]/home/components/user-message-content/utils.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ export function computeMentionRanges(text: string, contexts: ChatMessageContext[
3131
const prefix =
3232
ctx.kind === 'skill' || ctx.kind === 'mcp' || ctx.kind === 'slash_command' ? '/' : '@'
3333
const token = `${prefix}${ctx.label}`
34-
const pattern = new RegExp(`(^|\\s)(${escapeRegExp(token)})(?=[\\s.,;:!?)\\]]|$)`, 'g')
34+
const pattern = new RegExp(
35+
`(^|\\s)(${escapeRegExp(token)})(?=[\\s,;:!?)\\]]|\\.(?![\\w-])|$)`,
36+
'g'
37+
)
3538
let match: RegExpExecArray | null
3639
while ((match = pattern.exec(text)) !== null) {
3740
const leadingSpace = match[1]

0 commit comments

Comments
 (0)