From 03d7733f281020c5a0352ece882ebc61caf175a3 Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Thu, 10 Apr 2025 18:03:24 -0400 Subject: [PATCH] Better display of diff errors --- src/core/tools/applyDiffTool.ts | 2 +- src/exports/roo-code.d.ts | 2 + src/exports/types.ts | 2 + src/schemas/index.ts | 1 + webview-ui/src/components/chat/ChatRow.tsx | 95 +++++++++++++++++++++ webview-ui/src/i18n/locales/ca/chat.json | 3 + webview-ui/src/i18n/locales/de/chat.json | 3 + webview-ui/src/i18n/locales/en/chat.json | 3 + webview-ui/src/i18n/locales/es/chat.json | 3 + webview-ui/src/i18n/locales/fr/chat.json | 3 + webview-ui/src/i18n/locales/hi/chat.json | 3 + webview-ui/src/i18n/locales/it/chat.json | 3 + webview-ui/src/i18n/locales/ja/chat.json | 3 + webview-ui/src/i18n/locales/ko/chat.json | 3 + webview-ui/src/i18n/locales/pl/chat.json | 3 + webview-ui/src/i18n/locales/pt-BR/chat.json | 3 + webview-ui/src/i18n/locales/tr/chat.json | 3 + webview-ui/src/i18n/locales/vi/chat.json | 3 + webview-ui/src/i18n/locales/zh-CN/chat.json | 3 + webview-ui/src/i18n/locales/zh-TW/chat.json | 3 + 20 files changed, 146 insertions(+), 1 deletion(-) diff --git a/src/core/tools/applyDiffTool.ts b/src/core/tools/applyDiffTool.ts index d8ae9fa610d..c57a62c17d8 100644 --- a/src/core/tools/applyDiffTool.ts +++ b/src/core/tools/applyDiffTool.ts @@ -108,7 +108,7 @@ export async function applyDiffTool( } if (currentCount >= 2) { - await cline.say("error", formattedError) + await cline.say("diff_error", formattedError) } pushToolResult(formattedError) return diff --git a/src/exports/roo-code.d.ts b/src/exports/roo-code.d.ts index 40939e4e32a..0efc708928c 100644 --- a/src/exports/roo-code.d.ts +++ b/src/exports/roo-code.d.ts @@ -387,6 +387,7 @@ type ClineMessage = { | "subtask_result" | "checkpoint_saved" | "rooignore_error" + | "diff_error" ) | undefined text?: string | undefined @@ -467,6 +468,7 @@ type RooCodeEvents = { | "subtask_result" | "checkpoint_saved" | "rooignore_error" + | "diff_error" ) | undefined text?: string | undefined diff --git a/src/exports/types.ts b/src/exports/types.ts index 64a955554e9..f61be2e04f9 100644 --- a/src/exports/types.ts +++ b/src/exports/types.ts @@ -392,6 +392,7 @@ type ClineMessage = { | "subtask_result" | "checkpoint_saved" | "rooignore_error" + | "diff_error" ) | undefined text?: string | undefined @@ -476,6 +477,7 @@ type RooCodeEvents = { | "subtask_result" | "checkpoint_saved" | "rooignore_error" + | "diff_error" ) | undefined text?: string | undefined diff --git a/src/schemas/index.ts b/src/schemas/index.ts index 208c061b532..637aaeabe52 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -742,6 +742,7 @@ export const clineSays = [ "subtask_result", "checkpoint_saved", "rooignore_error", + "diff_error", ] as const export const clineSaySchema = z.enum(clineSays) diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index e73086e5dd8..aaa9f93e782 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -86,6 +86,9 @@ export const ChatRowContent = ({ const { t } = useTranslation() const { mcpServers, alwaysAllowMcp, currentCheckpoint } = useExtensionState() const [reasoningCollapsed, setReasoningCollapsed] = useState(true) + const [isDiffErrorExpanded, setIsDiffErrorExpanded] = useState(false) + const [showCopySuccess, setShowCopySuccess] = useState(false) + const { copyWithFeedback } = useCopyToClipboard() const [cost, apiReqCancelReason, apiReqStreamingFailedMessage] = useMemo(() => { if (message.text !== null && message.text !== undefined && message.say === "api_req_started") { @@ -602,6 +605,98 @@ export const ChatRowContent = ({ switch (message.type) { case "say": switch (message.say) { + case "diff_error": + return ( +
+
+
setIsDiffErrorExpanded(!isDiffErrorExpanded)}> +
+ + {t("chat:diffError.title")} +
+
+ { + e.stopPropagation() + + // Call copyWithFeedback and handle the Promise + copyWithFeedback(message.text || "").then((success) => { + if (success) { + // Show checkmark + setShowCopySuccess(true) + + // Reset after a brief delay + setTimeout(() => { + setShowCopySuccess(false) + }, 1000) + } + }) + }}> + + + +
+
+ {isDiffErrorExpanded && ( +
+ +
+ )} +
+
+ ) case "subtask_result": return (
diff --git a/webview-ui/src/i18n/locales/ca/chat.json b/webview-ui/src/i18n/locales/ca/chat.json index 87643da195f..6c913965d65 100644 --- a/webview-ui/src/i18n/locales/ca/chat.json +++ b/webview-ui/src/i18n/locales/ca/chat.json @@ -83,6 +83,9 @@ "edit": "Edita...", "forNextMode": "per al següent mode", "error": "Error", + "diffError": { + "title": "Edició fallida" + }, "troubleMessage": "Roo està tenint problemes...", "apiRequest": { "title": "Sol·licitud API", diff --git a/webview-ui/src/i18n/locales/de/chat.json b/webview-ui/src/i18n/locales/de/chat.json index 0b378f0db56..cb97b0bc842 100644 --- a/webview-ui/src/i18n/locales/de/chat.json +++ b/webview-ui/src/i18n/locales/de/chat.json @@ -83,6 +83,9 @@ "edit": "Bearbeiten...", "forNextMode": "für nächsten Modus", "error": "Fehler", + "diffError": { + "title": "Bearbeitung fehlgeschlagen" + }, "troubleMessage": "Roo hat Probleme...", "apiRequest": { "title": "API-Anfrage", diff --git a/webview-ui/src/i18n/locales/en/chat.json b/webview-ui/src/i18n/locales/en/chat.json index d29dbd6162b..f9f838356d8 100644 --- a/webview-ui/src/i18n/locales/en/chat.json +++ b/webview-ui/src/i18n/locales/en/chat.json @@ -154,6 +154,9 @@ }, "taskCompleted": "Task Completed", "error": "Error", + "diffError": { + "title": "Edit Unsuccessful" + }, "troubleMessage": "Roo is having trouble...", "shellIntegration": { "unavailable": "Shell Integration Unavailable", diff --git a/webview-ui/src/i18n/locales/es/chat.json b/webview-ui/src/i18n/locales/es/chat.json index 4d53776d24f..caa1b6048ce 100644 --- a/webview-ui/src/i18n/locales/es/chat.json +++ b/webview-ui/src/i18n/locales/es/chat.json @@ -83,6 +83,9 @@ "edit": "Editar...", "forNextMode": "para el siguiente modo", "error": "Error", + "diffError": { + "title": "Edición fallida" + }, "troubleMessage": "Roo está teniendo problemas...", "apiRequest": { "title": "Solicitud API", diff --git a/webview-ui/src/i18n/locales/fr/chat.json b/webview-ui/src/i18n/locales/fr/chat.json index c5771955b4d..28254ab1c82 100644 --- a/webview-ui/src/i18n/locales/fr/chat.json +++ b/webview-ui/src/i18n/locales/fr/chat.json @@ -83,6 +83,9 @@ "edit": "Éditer...", "forNextMode": "pour le prochain mode", "error": "Erreur", + "diffError": { + "title": "Modification échouée" + }, "troubleMessage": "Roo rencontre des difficultés...", "apiRequest": { "title": "Requête API", diff --git a/webview-ui/src/i18n/locales/hi/chat.json b/webview-ui/src/i18n/locales/hi/chat.json index a044bf7e21e..78904af0062 100644 --- a/webview-ui/src/i18n/locales/hi/chat.json +++ b/webview-ui/src/i18n/locales/hi/chat.json @@ -83,6 +83,9 @@ "edit": "संपादित करें...", "forNextMode": "अगले मोड के लिए", "error": "त्रुटि", + "diffError": { + "title": "संपादन असफल" + }, "troubleMessage": "Roo को समस्या हो रही है...", "apiRequest": { "title": "API अनुरोध", diff --git a/webview-ui/src/i18n/locales/it/chat.json b/webview-ui/src/i18n/locales/it/chat.json index 03c22b76431..cb1d5f6dc1a 100644 --- a/webview-ui/src/i18n/locales/it/chat.json +++ b/webview-ui/src/i18n/locales/it/chat.json @@ -86,6 +86,9 @@ "wantsToFetch": "Roo vuole recuperare istruzioni dettagliate per aiutare con l'attività corrente" }, "error": "Errore", + "diffError": { + "title": "Modifica non riuscita" + }, "troubleMessage": "Roo sta avendo problemi...", "apiRequest": { "title": "Richiesta API", diff --git a/webview-ui/src/i18n/locales/ja/chat.json b/webview-ui/src/i18n/locales/ja/chat.json index b817edfae78..4eb1aa52fe3 100644 --- a/webview-ui/src/i18n/locales/ja/chat.json +++ b/webview-ui/src/i18n/locales/ja/chat.json @@ -83,6 +83,9 @@ "edit": "編集...", "forNextMode": "次のモード用", "error": "エラー", + "diffError": { + "title": "編集に失敗しました" + }, "troubleMessage": "Rooに問題が発生しています...", "apiRequest": { "title": "APIリクエスト", diff --git a/webview-ui/src/i18n/locales/ko/chat.json b/webview-ui/src/i18n/locales/ko/chat.json index e7c26d0abc3..2f4bff5cd3a 100644 --- a/webview-ui/src/i18n/locales/ko/chat.json +++ b/webview-ui/src/i18n/locales/ko/chat.json @@ -83,6 +83,9 @@ "edit": "편집...", "forNextMode": "다음 모드용", "error": "오류", + "diffError": { + "title": "편집 실패" + }, "troubleMessage": "Roo에 문제가 발생했습니다...", "apiRequest": { "title": "API 요청", diff --git a/webview-ui/src/i18n/locales/pl/chat.json b/webview-ui/src/i18n/locales/pl/chat.json index cd12f58dca6..372b3479430 100644 --- a/webview-ui/src/i18n/locales/pl/chat.json +++ b/webview-ui/src/i18n/locales/pl/chat.json @@ -83,6 +83,9 @@ "edit": "Edytuj...", "forNextMode": "dla następnego trybu", "error": "Błąd", + "diffError": { + "title": "Edycja nieudana" + }, "troubleMessage": "Roo ma problemy...", "apiRequest": { "title": "Zapytanie API", diff --git a/webview-ui/src/i18n/locales/pt-BR/chat.json b/webview-ui/src/i18n/locales/pt-BR/chat.json index 250f32ce7e9..d5d7aefc565 100644 --- a/webview-ui/src/i18n/locales/pt-BR/chat.json +++ b/webview-ui/src/i18n/locales/pt-BR/chat.json @@ -83,6 +83,9 @@ "edit": "Editar...", "forNextMode": "para o próximo modo", "error": "Erro", + "diffError": { + "title": "Edição mal-sucedida" + }, "troubleMessage": "Roo está tendo problemas...", "apiRequest": { "title": "Requisição API", diff --git a/webview-ui/src/i18n/locales/tr/chat.json b/webview-ui/src/i18n/locales/tr/chat.json index 34fc5929909..3e4d68d6183 100644 --- a/webview-ui/src/i18n/locales/tr/chat.json +++ b/webview-ui/src/i18n/locales/tr/chat.json @@ -83,6 +83,9 @@ "edit": "Düzenle...", "forNextMode": "sonraki mod için", "error": "Hata", + "diffError": { + "title": "Düzenleme Başarısız" + }, "troubleMessage": "Roo sorun yaşıyor...", "apiRequest": { "title": "API İsteği", diff --git a/webview-ui/src/i18n/locales/vi/chat.json b/webview-ui/src/i18n/locales/vi/chat.json index 184b4447e74..7c417d54ef0 100644 --- a/webview-ui/src/i18n/locales/vi/chat.json +++ b/webview-ui/src/i18n/locales/vi/chat.json @@ -83,6 +83,9 @@ "edit": "Chỉnh sửa...", "forNextMode": "cho chế độ tiếp theo", "error": "Lỗi", + "diffError": { + "title": "Chỉnh sửa không thành công" + }, "troubleMessage": "Roo đang gặp sự cố...", "apiRequest": { "title": "Yêu cầu API", diff --git a/webview-ui/src/i18n/locales/zh-CN/chat.json b/webview-ui/src/i18n/locales/zh-CN/chat.json index d834fc81b82..a8c261642c1 100644 --- a/webview-ui/src/i18n/locales/zh-CN/chat.json +++ b/webview-ui/src/i18n/locales/zh-CN/chat.json @@ -83,6 +83,9 @@ "edit": "编辑...", "forNextMode": "用于下一个模式", "error": "错误", + "diffError": { + "title": "编辑失败" + }, "troubleMessage": "Roo遇到问题...", "apiRequest": { "title": "API请求", diff --git a/webview-ui/src/i18n/locales/zh-TW/chat.json b/webview-ui/src/i18n/locales/zh-TW/chat.json index e00a1b6f096..b232eea8898 100644 --- a/webview-ui/src/i18n/locales/zh-TW/chat.json +++ b/webview-ui/src/i18n/locales/zh-TW/chat.json @@ -83,6 +83,9 @@ "edit": "編輯...", "forNextMode": "用於下一個模式", "error": "錯誤", + "diffError": { + "title": "編輯失敗" + }, "troubleMessage": "Roo 遇到問題...", "apiRequest": { "title": "API 請求",