-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: make error display less jarring by matching diff_error style #6782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
ae8e4d8
eb4bd66
d303138
0f47482
aeb1ea6
8fcd218
a3b3446
001d38c
55f7053
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,7 +4,7 @@ import { McpExecution } from "./McpExecution" | |||||
| import { useSize } from "react-use" | ||||||
| import { useTranslation, Trans } from "react-i18next" | ||||||
| import deepEqual from "fast-deep-equal" | ||||||
| import { VSCodeBadge, VSCodeButton } from "@vscode/webview-ui-toolkit/react" | ||||||
| import { VSCodeBadge } from "@vscode/webview-ui-toolkit/react" | ||||||
|
|
||||||
| import type { ClineMessage } from "@roo-code/types" | ||||||
| import { Mode } from "@roo/modes" | ||||||
|
|
@@ -33,6 +33,7 @@ import MarkdownBlock from "../common/MarkdownBlock" | |||||
| import { ReasoningBlock } from "./ReasoningBlock" | ||||||
| import Thumbnails from "../common/Thumbnails" | ||||||
| import McpResourceRow from "../mcp/McpResourceRow" | ||||||
| import { IconButton } from "./IconButton" | ||||||
|
|
||||||
| import { Mention } from "./Mention" | ||||||
| import { CheckpointSaved } from "./checkpoints/CheckpointSaved" | ||||||
|
|
@@ -118,6 +119,8 @@ export const ChatRowContent = ({ | |||||
| const [reasoningCollapsed, setReasoningCollapsed] = useState(true) | ||||||
| const [isDiffErrorExpanded, setIsDiffErrorExpanded] = useState(false) | ||||||
| const [showCopySuccess, setShowCopySuccess] = useState(false) | ||||||
| const [isErrorExpanded, setIsErrorExpanded] = useState(false) | ||||||
| const [showErrorCopySuccess, setShowErrorCopySuccess] = useState(false) | ||||||
| const [isEditing, setIsEditing] = useState(false) | ||||||
| const [editedContent, setEditedContent] = useState("") | ||||||
| const [editMode, setEditMode] = useState<Mode>(mode || "code") | ||||||
|
|
@@ -893,37 +896,22 @@ export const ChatRowContent = ({ | |||||
| <span style={{ fontWeight: "bold" }}>{t("chat:diffError.title")}</span> | ||||||
| </div> | ||||||
| <div style={{ display: "flex", alignItems: "center" }}> | ||||||
| <VSCodeButton | ||||||
| appearance="icon" | ||||||
| style={{ | ||||||
| padding: "3px", | ||||||
| height: "24px", | ||||||
| marginRight: "4px", | ||||||
| color: "var(--vscode-editor-foreground)", | ||||||
| display: "flex", | ||||||
| alignItems: "center", | ||||||
| justifyContent: "center", | ||||||
| background: "transparent", | ||||||
| }} | ||||||
| onClick={(e) => { | ||||||
| <IconButton | ||||||
| iconClass={showCopySuccess ? "codicon-check" : "codicon-copy"} | ||||||
| title={t("chat:codeblock.tooltips.copy_code")} | ||||||
| onClick={(e: React.MouseEvent) => { | ||||||
| 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) | ||||||
|
||||||
| setShowCopySuccess(false) | |
| setShowErrorCopySuccess(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice there's significant code duplication between the error and diff_error implementations. Both share nearly identical structure for the collapsible UI, copy functionality, and expand/collapse behavior. Could we consider extracting a reusable component like to reduce this duplication and make future maintenance easier?
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clickable div lacks accessibility attributes. Consider adding:
This would improve keyboard navigation and screen reader support.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding accessibility attributes (e.g. role="button" and tabIndex) to the clickable error header div to improve keyboard navigation and screen reader support.
| onClick={() => setIsErrorExpanded(!isErrorExpanded)}> | |
| onClick={() => setIsErrorExpanded(!isErrorExpanded)} role="button" tabIndex={0}> |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional that the "Error" label uses color while the diff_error "Diff Error" label uses the default color? This creates a visual inconsistency between the two similar components. If this is meant to indicate severity (errors being more critical than diff errors), that's fine, but wanted to confirm this was deliberate.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The copy button’s onClick handler in the error block duplicates logic found in the diff_error block. Consider abstracting this copy-with-feedback functionality into a reusable component or helper to reduce duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The copy feedback logic for the diff error and the new error display is duplicated. Consider extracting this into a reusable function to reduce code duplication.