From 92a8a6a7270b63a5adc2636b27d0a0159874dee0 Mon Sep 17 00:00:00 2001 From: Jannis Braun <151788261+TheZwiss@users.noreply.github.com> Date: Sat, 25 Apr 2026 19:34:29 +0200 Subject: [PATCH] chore(friends): tighten Direct-Add gate consistency Per code-review: directAddDisplay now reads directAt === -1 instead of re-deriving includes('@'); add a one-line comment on showDirectAdd so the predicate's intent is obvious at first read. --- packages/web/src/components/chat/FriendsPage.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/web/src/components/chat/FriendsPage.tsx b/packages/web/src/components/chat/FriendsPage.tsx index 0007c198..a1978597 100644 --- a/packages/web/src/components/chat/FriendsPage.tsx +++ b/packages/web/src/components/chat/FriendsPage.tsx @@ -464,13 +464,14 @@ function AddFriendTab({ const trimmedQuery = query.trim(); const directAt = trimmedQuery.lastIndexOf('@'); + // Allow bare handle (no @) or @ at non-edge position; hide @, @bob, bob@. const showDirectAdd = trimmedQuery.length > 0 && (directAt === -1 || (directAt > 0 && directAt < trimmedQuery.length - 1)); // Bare handle gets the home host appended for display only — submission // still uses the raw trimmed query. - const directAddDisplay = trimmedQuery.includes('@') - ? trimmedQuery - : `${trimmedQuery}@${window.location.host}`; + const directAddDisplay = directAt === -1 + ? `${trimmedQuery}@${window.location.host}` + : trimmedQuery; // Direct Add handler const handleDirectAdd = async () => {