From 4ac94b2feb495ce575b9cd5aa072d50b24fb5fbd Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 29 Apr 2026 16:09:53 +0200 Subject: [PATCH] refactor(frontend): delete orphaned personMention.ts after Tiptap migration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The textarea-era detectPersonMention helper has no production callers since the suggestion plugin's char: '@' mechanism replaced it. Per "Dead code is deleted, not commented out", remove the source file and its spec — the spec was running but tested a function nobody calls. Felix #5615 blocker. Co-Authored-By: Claude Opus 4.7 --- frontend/src/lib/utils/personMention.spec.ts | 65 -------------------- frontend/src/lib/utils/personMention.ts | 23 ------- 2 files changed, 88 deletions(-) delete mode 100644 frontend/src/lib/utils/personMention.spec.ts delete mode 100644 frontend/src/lib/utils/personMention.ts diff --git a/frontend/src/lib/utils/personMention.spec.ts b/frontend/src/lib/utils/personMention.spec.ts deleted file mode 100644 index 7101c27c..00000000 --- a/frontend/src/lib/utils/personMention.spec.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { describe, it, expect } from 'vitest'; -import { detectPersonMention } from './personMention'; - -describe('detectPersonMention', () => { - it('returns null when text has no @', () => { - expect(detectPersonMention('hello world', 11)).toBeNull(); - }); - - it('returns null when @ is preceded by a non-whitespace character (email pattern)', () => { - expect(detectPersonMention('user@example', 12)).toBeNull(); - }); - - it('returns query for @ at the very start of string', () => { - expect(detectPersonMention('@Aug', 4)).toBe('Aug'); - }); - - it('returns empty string immediately after @', () => { - expect(detectPersonMention('@', 1)).toBe(''); - }); - - it('returns single-word query', () => { - expect(detectPersonMention('hi @Auguste', 11)).toBe('Auguste'); - }); - - it('keeps the trigger active when the query has a trailing space', () => { - expect(detectPersonMention('hi @Auguste ', 12)).toBe('Auguste '); - }); - - it('returns multi-word query (spaces allowed)', () => { - expect(detectPersonMention('hi @Auguste Raddatz', 19)).toBe('Auguste Raddatz'); - }); - - it('returns single-character query', () => { - expect(detectPersonMention('@M', 2)).toBe('M'); - }); - - it('returns null when the query crosses a newline', () => { - expect(detectPersonMention('@Aug\nfoo', 8)).toBeNull(); - }); - - it('returns null when a second @ appears in the query (next mention starts)', () => { - expect(detectPersonMention('@Aug@bar', 8)).toBeNull(); - }); - - it('uses the most recent @ when separated by whitespace', () => { - // '@Aug @Bert' with cursor at end — the second @ is the trigger. - expect(detectPersonMention('@Aug @Bert', 10)).toBe('Bert'); - }); - - it('returns the query when the cursor sits exactly at a newline boundary', () => { - // '@Aug\nfoo' with cursor at index 4 — right at the newline before it - // is consumed. The query is still 'Aug' because nothing past the cursor - // counts. - expect(detectPersonMention('@Aug\nfoo', 4)).toBe('Aug'); - }); - - it('returns null when cursor is before the @', () => { - expect(detectPersonMention('@Hans', 0)).toBeNull(); - }); - - it('uses the most recent @ in the text', () => { - // cursor is just after the second @ + a few chars - expect(detectPersonMention('hi @Anna and @Bert', 18)).toBe('Bert'); - }); -}); diff --git a/frontend/src/lib/utils/personMention.ts b/frontend/src/lib/utils/personMention.ts deleted file mode 100644 index 7611c89f..00000000 --- a/frontend/src/lib/utils/personMention.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Given the current textarea value and cursor position, returns the - * @-person-mention query being typed (the text after the last triggering @), - * or null if no person-mention is active. - * - * Rules — distinct from comment-mentions in `mention.ts`: - * - @ must be at the start of the string or preceded by whitespace - * - The query may contain spaces (historical persons commonly have multi-word - * display names — "Auguste Raddatz", "Maria von Müller-Schultz") - * - The query stops at a newline or at a second @ (the next mention starts) - */ -export function detectPersonMention(text: string, cursorPos: number): string | null { - const before = text.slice(0, cursorPos); - const atIndex = before.lastIndexOf('@'); - if (atIndex === -1) return null; - - if (atIndex > 0 && !/\s/.test(before[atIndex - 1])) return null; - - const query = before.slice(atIndex + 1); - if (query.includes('\n') || query.includes('@')) return null; - - return query; -}