Skip to content

Commit 03d7733

Browse files
committed
Better display of diff errors
1 parent 77daf85 commit 03d7733

File tree

20 files changed

+146
-1
lines changed

20 files changed

+146
-1
lines changed

src/core/tools/applyDiffTool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export async function applyDiffTool(
108108
}
109109

110110
if (currentCount >= 2) {
111-
await cline.say("error", formattedError)
111+
await cline.say("diff_error", formattedError)
112112
}
113113
pushToolResult(formattedError)
114114
return

src/exports/roo-code.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ type ClineMessage = {
387387
| "subtask_result"
388388
| "checkpoint_saved"
389389
| "rooignore_error"
390+
| "diff_error"
390391
)
391392
| undefined
392393
text?: string | undefined
@@ -467,6 +468,7 @@ type RooCodeEvents = {
467468
| "subtask_result"
468469
| "checkpoint_saved"
469470
| "rooignore_error"
471+
| "diff_error"
470472
)
471473
| undefined
472474
text?: string | undefined

src/exports/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ type ClineMessage = {
392392
| "subtask_result"
393393
| "checkpoint_saved"
394394
| "rooignore_error"
395+
| "diff_error"
395396
)
396397
| undefined
397398
text?: string | undefined
@@ -476,6 +477,7 @@ type RooCodeEvents = {
476477
| "subtask_result"
477478
| "checkpoint_saved"
478479
| "rooignore_error"
480+
| "diff_error"
479481
)
480482
| undefined
481483
text?: string | undefined

src/schemas/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ export const clineSays = [
742742
"subtask_result",
743743
"checkpoint_saved",
744744
"rooignore_error",
745+
"diff_error",
745746
] as const
746747

747748
export const clineSaySchema = z.enum(clineSays)

webview-ui/src/components/chat/ChatRow.tsx

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ export const ChatRowContent = ({
8686
const { t } = useTranslation()
8787
const { mcpServers, alwaysAllowMcp, currentCheckpoint } = useExtensionState()
8888
const [reasoningCollapsed, setReasoningCollapsed] = useState(true)
89+
const [isDiffErrorExpanded, setIsDiffErrorExpanded] = useState(false)
90+
const [showCopySuccess, setShowCopySuccess] = useState(false)
91+
const { copyWithFeedback } = useCopyToClipboard()
8992

9093
const [cost, apiReqCancelReason, apiReqStreamingFailedMessage] = useMemo(() => {
9194
if (message.text !== null && message.text !== undefined && message.say === "api_req_started") {
@@ -602,6 +605,98 @@ export const ChatRowContent = ({
602605
switch (message.type) {
603606
case "say":
604607
switch (message.say) {
608+
case "diff_error":
609+
return (
610+
<div>
611+
<div
612+
style={{
613+
marginTop: "0px",
614+
overflow: "hidden",
615+
marginBottom: "8px",
616+
}}>
617+
<div
618+
style={{
619+
borderBottom: isDiffErrorExpanded
620+
? "1px solid var(--vscode-editorGroup-border)"
621+
: "none",
622+
fontWeight: "normal",
623+
fontSize: "var(--vscode-font-size)",
624+
color: "var(--vscode-editor-foreground)",
625+
display: "flex",
626+
alignItems: "center",
627+
justifyContent: "space-between",
628+
cursor: "pointer",
629+
}}
630+
onClick={() => setIsDiffErrorExpanded(!isDiffErrorExpanded)}>
631+
<div
632+
style={{
633+
display: "flex",
634+
alignItems: "center",
635+
gap: "10px",
636+
flexGrow: 1,
637+
}}>
638+
<span
639+
className="codicon codicon-warning"
640+
style={{
641+
color: "var(--vscode-editorWarning-foreground)",
642+
opacity: 0.8,
643+
fontSize: 16,
644+
marginBottom: "-1.5px",
645+
}}></span>
646+
<span style={{ fontWeight: "bold" }}>{t("chat:diffError.title")}</span>
647+
</div>
648+
<div style={{ display: "flex", alignItems: "center" }}>
649+
<VSCodeButton
650+
appearance="icon"
651+
style={{
652+
padding: "3px",
653+
height: "24px",
654+
marginRight: "4px",
655+
color: "var(--vscode-editor-foreground)",
656+
display: "flex",
657+
alignItems: "center",
658+
justifyContent: "center",
659+
background: "transparent",
660+
}}
661+
onClick={(e) => {
662+
e.stopPropagation()
663+
664+
// Call copyWithFeedback and handle the Promise
665+
copyWithFeedback(message.text || "").then((success) => {
666+
if (success) {
667+
// Show checkmark
668+
setShowCopySuccess(true)
669+
670+
// Reset after a brief delay
671+
setTimeout(() => {
672+
setShowCopySuccess(false)
673+
}, 1000)
674+
}
675+
})
676+
}}>
677+
<span
678+
className={`codicon codicon-${showCopySuccess ? "check" : "copy"}`}></span>
679+
</VSCodeButton>
680+
<span
681+
className={`codicon codicon-chevron-${isDiffErrorExpanded ? "up" : "down"}`}></span>
682+
</div>
683+
</div>
684+
{isDiffErrorExpanded && (
685+
<div
686+
style={{
687+
padding: "8px",
688+
backgroundColor: "var(--vscode-editor-background)",
689+
borderTop: "none",
690+
}}>
691+
<CodeBlock
692+
source={`${"```"}plaintext\n${message.text || ""}\n${"```"}`}
693+
forceWrap={true}
694+
/>
695+
</div>
696+
)}
697+
</div>
698+
</div>
699+
)
605700
case "subtask_result":
606701
return (
607702
<div>

webview-ui/src/i18n/locales/ca/chat.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@
8383
"edit": "Edita...",
8484
"forNextMode": "per al següent mode",
8585
"error": "Error",
86+
"diffError": {
87+
"title": "Edició fallida"
88+
},
8689
"troubleMessage": "Roo està tenint problemes...",
8790
"apiRequest": {
8891
"title": "Sol·licitud API",

webview-ui/src/i18n/locales/de/chat.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@
8383
"edit": "Bearbeiten...",
8484
"forNextMode": "für nächsten Modus",
8585
"error": "Fehler",
86+
"diffError": {
87+
"title": "Bearbeitung fehlgeschlagen"
88+
},
8689
"troubleMessage": "Roo hat Probleme...",
8790
"apiRequest": {
8891
"title": "API-Anfrage",

webview-ui/src/i18n/locales/en/chat.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@
154154
},
155155
"taskCompleted": "Task Completed",
156156
"error": "Error",
157+
"diffError": {
158+
"title": "Edit Unsuccessful"
159+
},
157160
"troubleMessage": "Roo is having trouble...",
158161
"shellIntegration": {
159162
"unavailable": "Shell Integration Unavailable",

webview-ui/src/i18n/locales/es/chat.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@
8383
"edit": "Editar...",
8484
"forNextMode": "para el siguiente modo",
8585
"error": "Error",
86+
"diffError": {
87+
"title": "Edición fallida"
88+
},
8689
"troubleMessage": "Roo está teniendo problemas...",
8790
"apiRequest": {
8891
"title": "Solicitud API",

webview-ui/src/i18n/locales/fr/chat.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@
8383
"edit": "Éditer...",
8484
"forNextMode": "pour le prochain mode",
8585
"error": "Erreur",
86+
"diffError": {
87+
"title": "Modification échouée"
88+
},
8689
"troubleMessage": "Roo rencontre des difficultés...",
8790
"apiRequest": {
8891
"title": "Requête API",

0 commit comments

Comments
 (0)