Skip to content

Conversation

@MuriloFP
Copy link
Contributor

@MuriloFP MuriloFP commented Jul 31, 2025

Add mode display indicators on task cards

Fixes #6493

Summary

This PR adds mode display indicators to task cards in both the main chat view and history view, allowing users to easily see which mode was used for each task. The implementation includes a new reusable ModeBadge component that displays mode names with proper styling and handles edge cases gracefully.

Changes Made

New Component

  • ModeBadge.tsx: Created a reusable component that:
    • Displays mode names using the existing findModeBySlug function
    • Falls back to showing the mode slug if a custom mode is deleted
    • Truncates long mode names (max 120px) with full name shown in tooltip
    • Uses VSCode theme variables for consistent styling
    • Returns null when no mode is provided (graceful degradation)

Updated Components

  • TaskItemHeader.tsx (History View):

    • Added ModeBadge import and integration
    • Badge appears next to the date when a task has a mode
    • No visual changes for tasks without modes
  • TaskHeader.tsx (Main Chat View):

    • Added ModeBadge import and integration
    • Badge appears next to "Task:" label in the header
    • Works correctly in both collapsed and expanded states
    • Fixed critical test mock issue that was causing test instability

Testing

Unit Tests Added

  • ModeBadge Component (5 tests):

    • ✅ Renders mode name when mode exists
    • ✅ Falls back to slug when mode not found
    • ✅ Returns null when no mode slug provided
    • ✅ Truncates long mode names with proper CSS classes
    • ✅ Shows full name in tooltip (basic verification)
  • TaskItemHeader (2 new tests):

    • ✅ Shows mode badge when item has mode
    • ✅ Does not show mode badge when item has no mode
  • TaskHeader (2 new tests):

    • ✅ Displays mode badge when currentTaskItem has mode
    • ✅ Does not display mode badge when currentTaskItem has no mode

Total: 19 tests passing

Manual Testing Completed

  • Mode badges appear correctly in history view
  • Mode badges appear correctly in main chat view
  • Tasks without modes show no badge
  • Custom modes display properly
  • Long mode names truncate with ellipsis
  • Tooltips show full mode names on hover
  • Deleted custom modes show slug as fallback
  • No visual regressions in existing UI

Screenshots

Note: Manual testing confirmed all visual requirements are met. Mode badges integrate seamlessly with the existing UI using VSCode theme colors.

Technical Notes

  1. No Translation Changes: The implementation only displays mode names which are already defined in the mode configurations. No new user-facing strings were added.

  2. CSS Variables: Uses existing VSCode badge CSS variables (--vscode-badge-background and --vscode-badge-foreground) that were already defined in the codebase.

  3. Performance: Minimal impact - the component is lightweight and only renders when a mode is present.

  4. Accessibility: The badges inherit text color and background from VSCode theme, ensuring proper contrast. Tooltips provide additional context for truncated names.

Review Notes

During internal review, a critical test mock issue was identified and fixed in TaskHeader.spec.tsx. The mock variable was improperly scoped, which could have caused test instability. This has been resolved using proper Vitest mocking patterns with vi.hoisted().

Checklist

  • Code follows project style guidelines
  • Tests have been added/updated
  • All tests pass
  • No console logs or debug statements
  • Changes are scoped to the issue requirements only
  • Manual testing completed
  • No breaking changes

Important

Adds ModeBadge component to display mode indicators on task cards in chat and history views, with unit tests for new functionality.

  • Behavior:
    • Adds ModeBadge component in ModeBadge.tsx to display mode names on task cards.
    • Integrates ModeBadge in TaskHeader.tsx and TaskItemHeader.tsx to show mode indicators.
    • Handles cases where mode is missing by showing slug or nothing.
    • Truncates long mode names with a tooltip for full name.
  • Testing:
    • Adds unit tests for ModeBadge in ModeBadge.spec.tsx.
    • Updates tests in TaskHeader.spec.tsx and TaskItemHeader.spec.tsx to verify mode badge display.
  • Misc:
    • Uses VSCode theme variables for consistent styling in ModeBadge.

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

MuriloFP and others added 30 commits July 3, 2025 15:26
@MuriloFP MuriloFP requested review from cte, jr and mrubens as code owners July 31, 2025 17:25
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. UI/UX UI/UX related or focused labels Jul 31, 2025
Copy link
Contributor

@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.

Thank you for implementing the mode display indicators! This is a well-structured implementation that addresses the issue requirements. I've identified a couple of critical issues that need to be fixed before this can be merged, along with some suggestions for improvement.


// Get all modes (built-in + custom)
const allModes = getAllModes(customModes)
const mode = findModeBySlug(modeSlug, allModes)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be using getModeBySlug() instead of findModeBySlug()? Looking at the modes file, getModeBySlug() checks custom modes first then built-in modes, which seems more appropriate for this use case. findModeBySlug() only searches within the provided modes array.

<StandardTooltip content={displayName}>
<span
className={cn(
"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the items-center class necessary when using truncate? The truncate behavior might not need vertical centering. Could we simplify this to just the essential classes?

}))

// Mock the ExtensionStateContext
const { mockGetCurrentTaskItem, mockSetCurrentTaskItem } = vi.hoisted(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The mock setup here seems quite complex for the test needs. Could we simplify this mock to improve maintainability? The hoisted pattern is good, but the getter/setter functions might be overkill for these tests.

expect(badge).toHaveClass("max-w-[120px]")
})

it("shows full name in tooltip", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test has a placeholder comment but doesn't actually verify tooltip behavior. Could we either implement proper tooltip testing (with user interactions) or remove this incomplete test to avoid confusion?

@MuriloFP MuriloFP marked this pull request as draft July 31, 2025 17:31
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 31, 2025
- Changed from findModeBySlug to getModeBySlug for better mode resolution
- Removed unnecessary 'items-center' CSS class from ModeBadge
- Simplified mock setup in TaskHeader.spec.tsx for better maintainability
- Improved tooltip test clarity in ModeBadge.spec.tsx
- All tests passing successfully
@daniel-lxs daniel-lxs moved this from Triage to PR [Draft / In Progress] in Roo Code Roadmap Aug 1, 2025
@hannesrudolph hannesrudolph added PR - Draft / In Progress and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Aug 1, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 22, 2025
@github-project-automation github-project-automation bot moved this from PR [Draft / In Progress] to Done in Roo Code Roadmap Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR - Draft / In Progress size:L This PR changes 100-499 lines, ignoring generated files. UI/UX UI/UX related or focused

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Add mode display indicators on task cards (main screen and history)

2 participants