Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 23, 2025

Summary

This PR addresses Issue #7358 by unifying error display patterns in the chat view to use a consistent, less jarring banner approach.

Problem

Error messages in the chat view were visually jarring and inconsistent. The generic error path rendered a bold red header and paragraph, which demanded attention even for routine or recoverable issues.

Solution

Created a reusable ErrorBanner component that provides:

  • A subtle, collapsible banner with appropriate icons (warning/error/info)
  • Optional copy-to-clipboard functionality
  • Expandable details section with syntax highlighting support
  • Consistent visual pattern matching the existing diff_error implementation

Changes

  • ✨ Created new ErrorBanner component in webview-ui/src/components/common/ErrorBanner.tsx
  • ♻️ Refactored ChatRow.tsx to use ErrorBanner for both generic errors and diff_error cases
  • 🧪 Added comprehensive test suite with 14 test cases
  • 🔥 Removed 104 lines of redundant error handling code

Testing

  • All 14 ErrorBanner component tests passing
  • Linting and type checking pass
  • Manual testing confirms error banners are collapsible and less visually intrusive

Impact

  • ✅ Reduces visual noise and stress in the Chat UI
  • ✅ Maintains clarity with on-demand access to error details
  • ✅ Establishes consistent error presentation across all scenarios
  • ✅ Improves code maintainability with a single reusable component

Screenshots

The new error presentation follows the same subtle pattern as diff_error, with a collapsible banner that doesn't overwhelm the interface.

Fixes #7358


Important

Introduces ErrorBanner component for consistent error display in chat view, replacing redundant error handling code and adding comprehensive tests.

  • Behavior:
    • Introduces ErrorBanner component in ErrorBanner.tsx for consistent error display.
    • Replaces existing error handling in ChatRow.tsx with ErrorBanner for diff_error and error cases.
    • ErrorBanner supports warning, error, and info variants, with optional copy-to-clipboard and expandable details.
  • Testing:
    • Adds 14 test cases in ErrorBanner.spec.tsx to verify ErrorBanner functionality.
    • Tests cover rendering, icon display, expand/collapse behavior, copy functionality, and variant-specific styling.
  • Misc:
    • Removes 104 lines of redundant error handling code in ChatRow.tsx.

This description was created by Ellipsis for 82520b9. You can customize this summary. It will automatically update as commits are pushed.

- Create ErrorBanner component for consistent error/warning display
- Replace generic error rendering with ErrorBanner in ChatRow
- Replace diff_error implementation with ErrorBanner
- Add comprehensive tests for ErrorBanner component
- Provides collapsible, less jarring error presentation with copy functionality

Fixes #7358
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 23, 2025 21:14
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Aug 23, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 23, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing my own code is like debugging in a mirror - everything looks backwards but somehow still broken.

justifyContent: "space-between",
cursor: details ? "pointer" : "default",
}}
onClick={details ? handleToggleExpand : undefined}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we enhance accessibility here? Consider adding:

  • aria-expanded={isExpanded} to the clickable div
  • role="button" and tabIndex={0} for keyboard navigation
  • Keyboard event handlers (onKeyDown for Enter/Space)
  • aria-live="polite" for the copy success feedback

This would make the component more accessible to screen reader users.


const handleToggleExpand = useCallback(() => {
setIsExpanded(!isExpanded)
}, [isExpanded])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance optimization opportunity: Instead of including isExpanded in the dependency array, could we use the functional update pattern?

Suggested change
}, [isExpanded])
const handleToggleExpand = useCallback(() => {
setIsExpanded(prev => !prev)
}, [])

This removes the dependency and prevents unnecessary re-creation of the callback.

defaultExpanded = false,
onCopy,
actions,
detailsLanguage = "xml",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is xml always a valid language for the CodeBlock component? Consider validating that the detailsLanguage prop value is supported, or documenting the valid options in the prop interface.

icon = document.querySelector(".codicon-info")
expect(icon).toHaveStyle({ color: "var(--vscode-charts-blue)" })
})
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great test coverage! Consider adding a few more test cases:

  • Keyboard navigation (Enter/Space to expand/collapse)
  • Different detailsLanguage values
  • Very long error messages to ensure proper text wrapping
  • Edge cases like empty details or special characters

/** Optional callback when copy button is clicked */
onCopy?: () => void
/** Optional additional actions to display on the right side */
actions?: React.ReactNode
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actions prop type is quite broad. If we know the specific use cases, could we define a more specific type? For example:

actions?: React.ReactElement<ButtonProps> | React.ReactElement<ButtonProps>[]

@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 25, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Chat: Unify error display to match diff_error banner (less jarring, dynamic, and robust)

3 participants