diff --git a/packages/web/src/components/chat/messageMenuItems.tsx b/packages/web/src/components/chat/messageMenuItems.tsx index 675fbd91..61b7ed49 100644 --- a/packages/web/src/components/chat/messageMenuItems.tsx +++ b/packages/web/src/components/chat/messageMenuItems.tsx @@ -2,6 +2,7 @@ import React from 'react'; import type { ContextMenuItem } from '../../stores/contextMenuStore'; import type { MessageWithUser } from '@backspace/shared'; import { saveImage, copyImageToClipboard } from '../../utils/imageActions'; +import { useUIStore } from '../../stores/uiStore'; const QUICK_EMOJIS = ['👍', '❤️', '😂', '😮']; @@ -21,6 +22,7 @@ interface MessageMenuParams { onOpenEmojiPicker: () => void; onMarkUnread: (messageId: string) => void; imageUrl?: string | null; + sourceUrl?: string | null; } export function buildMessageMenuItems(params: MessageMenuParams): ContextMenuItem[] { @@ -40,6 +42,7 @@ export function buildMessageMenuItems(params: MessageMenuParams): ContextMenuIte onOpenEmojiPicker, onMarkUnread, imageUrl, + sourceUrl, } = params; const items: ContextMenuItem[] = []; @@ -86,6 +89,38 @@ export function buildMessageMenuItems(params: MessageMenuParams): ContextMenuIte items.push({ key: 'image-sep', type: 'separator' }); } + // ── Link Actions (when URL text is suppressed) ────────────────────── + if (sourceUrl) { + items.push({ + key: 'copy-link', + type: 'action', + label: 'Copy Link', + icon: ( + + + + ), + onClick: () => { + navigator.clipboard.writeText(sourceUrl); + useUIStore.getState().addToast('Copied link', 'success', 3000); + }, + }); + items.push({ + key: 'open-link', + type: 'action', + label: 'Open Link', + icon: ( + + + + ), + onClick: () => { + window.open(sourceUrl, '_blank', 'noopener'); + }, + }); + items.push({ key: 'link-sep', type: 'separator' }); + } + // ── Quick Reaction Row ────────────────────────────────────────────────── if (canAddReactions) { items.push({ @@ -160,7 +195,7 @@ export function buildMessageMenuItems(params: MessageMenuParams): ContextMenuIte key: 'copy-text', type: 'action', label: 'Copy Text', - hidden: !message.content, + hidden: !message.content || !!sourceUrl, icon: (