Skip to content

Commit 6427916

Browse files
MuriloFPellipsis-dev[bot]daniel-lxs
authored
fix: resolve URL loading timeout issues in @ mentions (RooCodeInc#5160)
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: Daniel Riccio <[email protected]>
1 parent 8c493b3 commit 6427916

File tree

23 files changed

+643
-279
lines changed

23 files changed

+643
-279
lines changed

src/core/mentions/__tests__/index.spec.ts

Lines changed: 121 additions & 271 deletions
Large diffs are not rendered by default.

src/core/mentions/index.ts

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,32 @@ import { FileContextTracker } from "../context-tracking/FileContextTracker"
1919

2020
import { RooIgnoreController } from "../ignore/RooIgnoreController"
2121

22+
import { t } from "../../i18n"
23+
24+
function getUrlErrorMessage(error: unknown): string {
25+
const errorMessage = error instanceof Error ? error.message : String(error)
26+
27+
// Check for common error patterns and return appropriate message
28+
if (errorMessage.includes("timeout")) {
29+
return t("common:errors.url_timeout")
30+
}
31+
if (errorMessage.includes("net::ERR_NAME_NOT_RESOLVED")) {
32+
return t("common:errors.url_not_found")
33+
}
34+
if (errorMessage.includes("net::ERR_INTERNET_DISCONNECTED")) {
35+
return t("common:errors.no_internet")
36+
}
37+
if (errorMessage.includes("403") || errorMessage.includes("Forbidden")) {
38+
return t("common:errors.url_forbidden")
39+
}
40+
if (errorMessage.includes("404") || errorMessage.includes("Not Found")) {
41+
return t("common:errors.url_page_not_found")
42+
}
43+
44+
// Default error message
45+
return t("common:errors.url_fetch_failed", { error: errorMessage })
46+
}
47+
2248
export async function openMention(mention?: string): Promise<void> {
2349
if (!mention) {
2450
return
@@ -84,22 +110,37 @@ export async function parseMentions(
84110
await urlContentFetcher.launchBrowser()
85111
} catch (error) {
86112
launchBrowserError = error
87-
vscode.window.showErrorMessage(`Error fetching content for ${urlMention}: ${error.message}`)
113+
const errorMessage = error instanceof Error ? error.message : String(error)
114+
vscode.window.showErrorMessage(`Error fetching content for ${urlMention}: ${errorMessage}`)
88115
}
89116
}
90117

91118
for (const mention of mentions) {
92119
if (mention.startsWith("http")) {
93120
let result: string
94121
if (launchBrowserError) {
95-
result = `Error fetching content: ${launchBrowserError.message}`
122+
const errorMessage =
123+
launchBrowserError instanceof Error ? launchBrowserError.message : String(launchBrowserError)
124+
result = `Error fetching content: ${errorMessage}`
96125
} else {
97126
try {
98127
const markdown = await urlContentFetcher.urlToMarkdown(mention)
99128
result = markdown
100129
} catch (error) {
101-
vscode.window.showErrorMessage(`Error fetching content for ${mention}: ${error.message}`)
102-
result = `Error fetching content: ${error.message}`
130+
console.error(`Error fetching URL ${mention}:`, error)
131+
132+
// Get raw error message for AI
133+
const rawErrorMessage = error instanceof Error ? error.message : String(error)
134+
135+
// Get localized error message for UI notification
136+
const localizedErrorMessage = getUrlErrorMessage(error)
137+
138+
vscode.window.showErrorMessage(
139+
t("common:errors.url_fetch_error_with_url", { url: mention, error: localizedErrorMessage }),
140+
)
141+
142+
// Send raw error message to AI model
143+
result = `Error fetching content: ${rawErrorMessage}`
103144
}
104145
}
105146
parsedText += `\n\n<url_content url="${mention}">\n${result}\n</url_content>`

src/i18n/locales/ca/common.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@
6262
"condensed_recently": "El context s'ha condensat recentment; s'omet aquest intent",
6363
"condense_handler_invalid": "El gestor de l'API per condensar el context no és vàlid",
6464
"condense_context_grew": "La mida del context ha augmentat durant la condensació; s'omet aquest intent",
65+
"url_timeout": "El lloc web ha trigat massa a carregar (timeout). Això pot ser degut a una connexió lenta, un lloc web pesat o temporalment no disponible. Pots tornar-ho a provar més tard o comprovar si la URL és correcta.",
66+
"url_not_found": "No s'ha pogut trobar l'adreça del lloc web. Comprova si la URL és correcta i torna-ho a provar.",
67+
"no_internet": "No hi ha connexió a internet. Comprova la teva connexió de xarxa i torna-ho a provar.",
68+
"url_forbidden": "L'accés a aquest lloc web està prohibit. El lloc pot bloquejar l'accés automatitzat o requerir autenticació.",
69+
"url_page_not_found": "No s'ha trobat la pàgina. Comprova si la URL és correcta.",
70+
"url_fetch_failed": "Error en obtenir el contingut de la URL: {{error}}",
71+
"url_fetch_error_with_url": "Error en obtenir contingut per {{url}}: {{error}}",
6572
"share_task_failed": "Ha fallat compartir la tasca. Si us plau, torna-ho a provar.",
6673
"share_no_active_task": "No hi ha cap tasca activa per compartir",
6774
"share_auth_required": "Es requereix autenticació. Si us plau, inicia sessió per compartir tasques.",

src/i18n/locales/de/common.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
"condensed_recently": "Kontext wurde kürzlich verdichtet; dieser Versuch wird übersprungen",
5959
"condense_handler_invalid": "API-Handler zum Verdichten des Kontexts ist ungültig",
6060
"condense_context_grew": "Kontextgröße ist während der Verdichtung gewachsen; dieser Versuch wird übersprungen",
61+
"url_timeout": "Die Website hat zu lange zum Laden gebraucht (Timeout). Das könnte an einer langsamen Verbindung, einer schweren Website oder vorübergehender Nichtverfügbarkeit liegen. Du kannst es später nochmal versuchen oder prüfen, ob die URL korrekt ist.",
62+
"url_not_found": "Die Website-Adresse konnte nicht gefunden werden. Bitte prüfe, ob die URL korrekt ist und versuche es erneut.",
63+
"no_internet": "Keine Internetverbindung. Bitte prüfe deine Netzwerkverbindung und versuche es erneut.",
64+
"url_forbidden": "Zugriff auf diese Website ist verboten. Die Seite könnte automatisierten Zugriff blockieren oder eine Authentifizierung erfordern.",
65+
"url_page_not_found": "Die Seite wurde nicht gefunden. Bitte prüfe, ob die URL korrekt ist.",
66+
"url_fetch_failed": "Fehler beim Abrufen des URL-Inhalts: {{error}}",
67+
"url_fetch_error_with_url": "Fehler beim Abrufen des Inhalts für {{url}}: {{error}}",
6168
"share_task_failed": "Teilen der Aufgabe fehlgeschlagen. Bitte versuche es erneut.",
6269
"share_no_active_task": "Keine aktive Aufgabe zum Teilen",
6370
"share_auth_required": "Authentifizierung erforderlich. Bitte melde dich an, um Aufgaben zu teilen.",

src/i18n/locales/en/common.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
"condensed_recently": "Context was condensed recently; skipping this attempt",
5959
"condense_handler_invalid": "API handler for condensing context is invalid",
6060
"condense_context_grew": "Context size increased during condensing; skipping this attempt",
61+
"url_timeout": "The website took too long to load (timeout). This could be due to a slow connection, heavy website, or the site being temporarily unavailable. You can try again later or check if the URL is correct.",
62+
"url_not_found": "The website address could not be found. Please check if the URL is correct and try again.",
63+
"no_internet": "No internet connection. Please check your network connection and try again.",
64+
"url_forbidden": "Access to this website is forbidden. The site may block automated access or require authentication.",
65+
"url_page_not_found": "The page was not found. Please check if the URL is correct.",
66+
"url_fetch_failed": "Failed to fetch URL content: {{error}}",
67+
"url_fetch_error_with_url": "Error fetching content for {{url}}: {{error}}",
6168
"share_task_failed": "Failed to share task. Please try again.",
6269
"share_no_active_task": "No active task to share",
6370
"share_auth_required": "Authentication required. Please sign in to share tasks.",

src/i18n/locales/es/common.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
"condensed_recently": "El contexto se condensó recientemente; se omite este intento",
5959
"condense_handler_invalid": "El manejador de API para condensar el contexto no es válido",
6060
"condense_context_grew": "El tamaño del contexto aumentó durante la condensación; se omite este intento",
61+
"url_timeout": "El sitio web tardó demasiado en cargar (timeout). Esto podría deberse a una conexión lenta, un sitio web pesado o que esté temporalmente no disponible. Puedes intentarlo más tarde o verificar si la URL es correcta.",
62+
"url_not_found": "No se pudo encontrar la dirección del sitio web. Por favor verifica si la URL es correcta e inténtalo de nuevo.",
63+
"no_internet": "Sin conexión a internet. Por favor verifica tu conexión de red e inténtalo de nuevo.",
64+
"url_forbidden": "El acceso a este sitio web está prohibido. El sitio puede bloquear el acceso automatizado o requerir autenticación.",
65+
"url_page_not_found": "La página no fue encontrada. Por favor verifica si la URL es correcta.",
66+
"url_fetch_failed": "Error al obtener el contenido de la URL: {{error}}",
67+
"url_fetch_error_with_url": "Error al obtener contenido para {{url}}: {{error}}",
6168
"share_task_failed": "Error al compartir la tarea. Por favor, inténtalo de nuevo.",
6269
"share_no_active_task": "No hay tarea activa para compartir",
6370
"share_auth_required": "Se requiere autenticación. Por favor, inicia sesión para compartir tareas.",

src/i18n/locales/fr/common.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
"condensed_recently": "Le contexte a été condensé récemment ; cette tentative est ignorée",
5959
"condense_handler_invalid": "Le gestionnaire d'API pour condenser le contexte est invalide",
6060
"condense_context_grew": "La taille du contexte a augmenté pendant la condensation ; cette tentative est ignorée",
61+
"url_timeout": "Le site web a pris trop de temps à charger (timeout). Cela pourrait être dû à une connexion lente, un site web lourd ou temporairement indisponible. Tu peux réessayer plus tard ou vérifier si l'URL est correcte.",
62+
"url_not_found": "L'adresse du site web n'a pas pu être trouvée. Vérifie si l'URL est correcte et réessaie.",
63+
"no_internet": "Pas de connexion internet. Vérifie ta connexion réseau et réessaie.",
64+
"url_forbidden": "L'accès à ce site web est interdit. Le site peut bloquer l'accès automatisé ou nécessiter une authentification.",
65+
"url_page_not_found": "La page n'a pas été trouvée. Vérifie si l'URL est correcte.",
66+
"url_fetch_failed": "Échec de récupération du contenu de l'URL : {{error}}",
67+
"url_fetch_error_with_url": "Erreur lors de la récupération du contenu pour {{url}} : {{error}}",
6168
"share_task_failed": "Échec du partage de la tâche. Veuillez réessayer.",
6269
"share_no_active_task": "Aucune tâche active à partager",
6370
"share_auth_required": "Authentification requise. Veuillez vous connecter pour partager des tâches.",

src/i18n/locales/hi/common.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
"condensed_recently": "संदर्भ हाल ही में संक्षिप्त किया गया था; इस प्रयास को छोड़ा जा रहा है",
5959
"condense_handler_invalid": "संदर्भ को संक्षिप्त करने के लिए API हैंडलर अमान्य है",
6060
"condense_context_grew": "संक्षिप्तीकरण के दौरान संदर्भ का आकार बढ़ गया; इस प्रयास को छोड़ा जा रहा है",
61+
"url_timeout": "वेबसाइट लोड होने में बहुत समय लगा (टाइमआउट)। यह धीमे कनेक्शन, भारी वेबसाइट या अस्थायी रूप से अनुपलब्ध होने के कारण हो सकता है। आप बाद में फिर से कोशिश कर सकते हैं या जांच सकते हैं कि URL सही है या नहीं।",
62+
"url_not_found": "वेबसाइट का पता नहीं मिल सका। कृपया जांचें कि URL सही है और फिर से कोशिश करें।",
63+
"no_internet": "इंटरनेट कनेक्शन नहीं है। कृपया अपना नेटवर्क कनेक्शन जांचें और फिर से कोशिश करें।",
64+
"url_forbidden": "इस वेबसाइट तक पहुंच प्रतिबंधित है। साइट स्वचालित पहुंच को ब्लॉक कर सकती है या प्रमाणीकरण की आवश्यकता हो सकती है।",
65+
"url_page_not_found": "पेज नहीं मिला। कृपया जांचें कि URL सही है।",
66+
"url_fetch_failed": "URL सामग्री प्राप्त करने में त्रुटि: {{error}}",
67+
"url_fetch_error_with_url": "{{url}} के लिए सामग्री प्राप्त करने में त्रुटि: {{error}}",
6168
"share_task_failed": "कार्य साझा करने में विफल। कृपया पुनः प्रयास करें।",
6269
"share_no_active_task": "साझा करने के लिए कोई सक्रिय कार्य नहीं",
6370
"share_auth_required": "प्रमाणीकरण आवश्यक है। कार्य साझा करने के लिए कृपया साइन इन करें।",

src/i18n/locales/id/common.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
"condensed_recently": "Konteks baru saja dikompres; melewati percobaan ini",
5959
"condense_handler_invalid": "Handler API untuk mengompres konteks tidak valid",
6060
"condense_context_grew": "Ukuran konteks bertambah saat mengompres; melewati percobaan ini",
61+
"url_timeout": "Situs web membutuhkan waktu terlalu lama untuk dimuat (timeout). Ini bisa disebabkan oleh koneksi lambat, situs web berat, atau sementara tidak tersedia. Kamu bisa mencoba lagi nanti atau memeriksa apakah URL sudah benar.",
62+
"url_not_found": "Alamat situs web tidak dapat ditemukan. Silakan periksa apakah URL sudah benar dan coba lagi.",
63+
"no_internet": "Tidak ada koneksi internet. Silakan periksa koneksi jaringan kamu dan coba lagi.",
64+
"url_forbidden": "Akses ke situs web ini dilarang. Situs mungkin memblokir akses otomatis atau memerlukan autentikasi.",
65+
"url_page_not_found": "Halaman tidak ditemukan. Silakan periksa apakah URL sudah benar.",
66+
"url_fetch_failed": "Gagal mengambil konten URL: {{error}}",
67+
"url_fetch_error_with_url": "Error mengambil konten untuk {{url}}: {{error}}",
6168
"share_task_failed": "Gagal membagikan tugas. Silakan coba lagi.",
6269
"share_no_active_task": "Tidak ada tugas aktif untuk dibagikan",
6370
"share_auth_required": "Autentikasi diperlukan. Silakan masuk untuk berbagi tugas.",

src/i18n/locales/it/common.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
"condensed_recently": "Il contesto è stato condensato di recente; questo tentativo viene saltato",
5959
"condense_handler_invalid": "Il gestore API per condensare il contesto non è valido",
6060
"condense_context_grew": "La dimensione del contesto è aumentata durante la condensazione; questo tentativo viene saltato",
61+
"url_timeout": "Il sito web ha impiegato troppo tempo a caricarsi (timeout). Questo potrebbe essere dovuto a una connessione lenta, un sito web pesante o temporaneamente non disponibile. Puoi riprovare più tardi o verificare se l'URL è corretto.",
62+
"url_not_found": "L'indirizzo del sito web non è stato trovato. Verifica se l'URL è corretto e riprova.",
63+
"no_internet": "Nessuna connessione internet. Verifica la tua connessione di rete e riprova.",
64+
"url_forbidden": "L'accesso a questo sito web è vietato. Il sito potrebbe bloccare l'accesso automatizzato o richiedere autenticazione.",
65+
"url_page_not_found": "La pagina non è stata trovata. Verifica se l'URL è corretto.",
66+
"url_fetch_failed": "Errore nel recupero del contenuto URL: {{error}}",
67+
"url_fetch_error_with_url": "Errore nel recupero del contenuto per {{url}}: {{error}}",
6168
"share_task_failed": "Condivisione dell'attività fallita. Riprova.",
6269
"share_no_active_task": "Nessuna attività attiva da condividere",
6370
"share_auth_required": "Autenticazione richiesta. Accedi per condividere le attività.",

0 commit comments

Comments
 (0)