diff --git a/ui/desktop/src/components/GooseMessage.tsx b/ui/desktop/src/components/GooseMessage.tsx
index 0c0255292..289d6ee2e 100644
--- a/ui/desktop/src/components/GooseMessage.tsx
+++ b/ui/desktop/src/components/GooseMessage.tsx
@@ -13,23 +13,20 @@ interface GooseMessageProps {
}
export default function GooseMessage({ message, metadata, messages, append }: GooseMessageProps) {
- // Find the preceding user message
+ // Extract URLs under a few conditions
+ // 1. The message is purely text
+ // 2. The link wasn't also present in the previous message
+ // 3. The message contains the explicit http:// or https:// protocol at the beginning
const messageIndex = messages?.findIndex(msg => msg.id === message.id);
const previousMessage = messageIndex > 0 ? messages[messageIndex - 1] : null;
-
- // Get URLs from previous user message (if it exists)
- const previousUrls = previousMessage
- ? extractUrls(previousMessage.content)
- : [];
-
- // Extract URLs from current message, excluding those from the previous user message
- const urls = extractUrls(message.content, previousUrls);
+ const previousUrls = previousMessage ? extractUrls(previousMessage.content) : [];
+ const urls = !message.toolInvocations ? extractUrls(message.content, previousUrls) : [];
return (
-
+
-
- {message.toolInvocations ? (
+ {message.toolInvocations && (
+
{message.toolInvocations.map((toolInvocation) => (
))}
- ) : (
- metadata ? (
-
- ) : (
-
{message.content}
- )
- )}
-
+
+ )}
+
+ {message.content && (
+
+ {message.content}
+
+ )}
{urls.length > 0 && (
@@ -58,6 +51,16 @@ export default function GooseMessage({ message, metadata, messages, append }: Go
))}
)}
+
+ {false && metadata && (
+
+
+
+ )}
);
diff --git a/ui/desktop/src/components/UserMessage.tsx b/ui/desktop/src/components/UserMessage.tsx
index 4724f0b92..226ca325a 100644
--- a/ui/desktop/src/components/UserMessage.tsx
+++ b/ui/desktop/src/components/UserMessage.tsx
@@ -4,9 +4,8 @@ import LinkPreview from './LinkPreview'
import { extractUrls } from '../utils/urlUtils'
export default function UserMessage({ message }) {
- // Extract URLs from current message
- const urls = extractUrls(message.content, []); // No previous URLs to check against
- console.log('User message URLs:', urls);
+ // Extract URLs which explicitly contain the http:// or https:// protocol
+ const urls = extractUrls(message.content, []);
return (
diff --git a/ui/desktop/src/utils/urlUtils.ts b/ui/desktop/src/utils/urlUtils.ts
index 3e3219bde..d4f2a066c 100644
--- a/ui/desktop/src/utils/urlUtils.ts
+++ b/ui/desktop/src/utils/urlUtils.ts
@@ -1,5 +1,3 @@
-import * as linkify from 'linkifyjs';
-
// Helper to normalize URLs for comparison
function normalizeUrl(url: string): string {
try {
@@ -13,21 +11,18 @@ function normalizeUrl(url: string): string {
}
export function extractUrls(content: string, previousUrls: string[] = []): string[] {
- // First extract markdown-style links using regex
- const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
+ // Modified regex to only match markdown links with http:// or https://
+ const markdownLinkRegex = /\[([^\]]+)\]\((https?:\/\/[^)]+)\)/g;
const markdownMatches = Array.from(content.matchAll(markdownLinkRegex));
const markdownUrls = markdownMatches.map(match => match[2]);
- // Then use linkifyjs to find regular URLs
- const links = linkify.find(content);
-
- // Get URLs from current content
- const linkifyUrls = links
- .filter(link => link.type === 'url')
- .map(link => link.href);
+ // Modified regex for standalone URLs with http:// or https://
+ const urlRegex = /(https?:\/\/[^\s<>"']+)/g;
+ const urlMatches = Array.from(content.matchAll(urlRegex));
+ const standardUrls = urlMatches.map(match => match[1]);
- // Combine markdown URLs with linkify URLs
- const currentUrls = [...new Set([...markdownUrls, ...linkifyUrls])];
+ // Combine markdown URLs with standard URLs
+ const currentUrls = [...new Set([...markdownUrls, ...standardUrls])];
// Normalize all URLs for comparison
const normalizedPreviousUrls = previousUrls.map(normalizeUrl);