Skip to content

Conversation

@MuriloFP
Copy link
Contributor

@MuriloFP MuriloFP commented Jul 8, 2025

Related GitHub Issue

This PR addresses user experience improvements for the CodeIndexPopover component (no specific issue linked - internal enhancement)

Roo Code Task Context (Optional)

N/A - Internal development task

Description

This PR transforms the CodeIndexPopover component from a basic settings form into a robust, user-friendly configuration interface with comprehensive validation and state management.

Key Implementation Details:

  • Zod Validation Schema: Implemented provider-specific validation schemas that adapt based on the selected embedding provider (OpenAI, Ollama, OpenAI-compatible, Gemini)
  • Real-time Error Feedback: Added visual error indicators (red borders) and inline error messages that appear immediately when validation fails
  • Unsaved Changes Protection: Implemented change detection with a confirmation dialog to prevent accidental data loss
  • Internationalization: All validation messages now use i18n keys for proper localization support
  • State Management: Added comprehensive form state tracking for errors, unsaved changes, and dialog states

Design Choices:

  • Used Zod for validation to ensure type safety and consistent error handling
  • Implemented partial schema validation to handle secret fields with placeholder values
  • Added error clearing on user input for better UX
  • Used VSCode theme colors for consistent error styling

Areas for Review Focus:

  • Validation logic for different embedding providers
  • Unsaved changes detection and dialog flow
  • Error message internationalization implementation
  • Form state management and error clearing behavior

Test Procedure

Unit Tests:

  • Created comprehensive test suite: CodeIndexPopover.validation.spec.tsx
  • Tests cover all embedding providers (OpenAI, Ollama, OpenAI-compatible, Gemini)
  • Validates both Zod schema validation and manual validation logic
  • Tests internationalization by checking for i18n keys in error messages

Manual Testing Steps:

  1. Open CodeIndexPopover component
  2. Try different embedding providers and test validation:
    • Leave required fields empty and attempt to save
    • Enter invalid URLs and verify error messages
    • Test with valid data to ensure validation passes
  3. Test unsaved changes dialog:
    • Make changes to form fields
    • Attempt to close popover without saving
    • Verify confirmation dialog appears
  4. Test error clearing:
    • Trigger validation errors
    • Start typing in error fields
    • Verify errors clear on user input

Testing Environment:

  • Run tests: cd webview-ui && npx vitest src/components/chat/__tests__/CodeIndexPopover.validation.spec.tsx
  • All 6 validation tests should pass
  • Manual testing in VSCode extension environment

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Before: Basic form with no validation feedback
After: Enhanced form with:

  • Red border indicators on invalid fields
  • Inline error messages below each field
  • Confirmation dialog for unsaved changes
  • Proper error clearing on user input

Screenshots would be helpful here to show the visual improvements, but are not included in this text-based response.

Documentation Updates

  • No documentation updates are required.

Additional Notes

Translation Support:

  • Added 10 new validation message keys to webview-ui/src/i18n/locales/en/settings.json
  • All validation errors now use i18n keys for proper localization
  • English translations provided; other language files will need updates

Performance Considerations:

  • Validation only runs on save attempt, not on every keystroke
  • Error clearing is optimized to only update specific field errors
  • Dialog state management uses React hooks for efficient re-renders

Future Enhancements:

  • Could add real-time validation (on blur/change) if desired
  • Could extend validation to include more complex rules
  • Could add success states and animations

Get in Touch

@MuriloFP


Important

Enhances CodeIndexPopover with validation, state management, and i18n support, adding Zod schemas, real-time error feedback, and unsaved changes protection.

  • Behavior:
    • Transforms CodeIndexPopover into a user-friendly interface with validation and state management.
    • Implements provider-specific validation schemas using Zod for different embedding providers.
    • Adds real-time error feedback with visual indicators and inline messages.
    • Introduces unsaved changes protection with a confirmation dialog.
    • Supports internationalization for validation messages using i18n keys.
  • Testing:
    • Adds CodeIndexPopover.validation.spec.tsx for unit tests covering all embedding providers.
    • Manual testing includes validation checks, unsaved changes dialog, and error clearing.
  • Translations:
    • Updates translation files (settings.json) across multiple locales to include new validation messages.

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

@MuriloFP MuriloFP requested review from cte, jr and mrubens as code owners July 8, 2025 22:46
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. UI/UX UI/UX related or focused labels Jul 8, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 8, 2025
@MuriloFP MuriloFP marked this pull request as draft July 8, 2025 23:22
@daniel-lxs daniel-lxs marked this pull request as ready for review July 9, 2025 00:14
@dosubot dosubot bot added the enhancement New feature or request label Jul 9, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Jul 9, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 9, 2025
MuriloFP and others added 11 commits July 8, 2025 19:51
…X improvements

- Add comprehensive form validation with Zod schema for all providers
- Implement real-time validation feedback with error messages
- Add unsaved changes detection with confirmation dialog
- Internationalize all validation messages using i18n framework
- Add visual error indicators (red borders) for invalid fields
- Improve popover close handling with unsaved changes check
- Add form state management and error clearing on user input
- Create validation test suite for all provider configurations
- Enhance user experience with proper error messaging and confirmations
- Changed OpenAI Compatible provider to use generic codebaseIndexEmbedderModelDimension field
- Removed provider-specific codebaseIndexOpenAiCompatibleModelDimension field
- This ensures consistency with other providers and proper persistence of the dimension value
- All validation tests pass
- Update Zod schema to validate codebaseIndexEmbedderModelDimension instead of provider-specific field
- Fix manual validation logic to check the correct field name
- Update test to use the generic field name
- Ensures validation works consistently with UI field usage
- Replace hardcoded 'Invalid Ollama URL' and 'Invalid base URL' strings with i18n keys
- Add missing invalidOllamaUrl and invalidBaseUrl keys to all locale files
- Update tests to expect i18n keys instead of hardcoded strings
- Ensures consistent localization across all validation messages
- Remove redundant manual validation checks (lines 375-425)
- Simplify validateSettings() to rely solely on Zod schema
- Handle SECRET_PLACEHOLDER values as valid (backend secrets exist)
- Reduce code by ~80 lines while maintaining same functionality
- Single source of truth for validation rules
This reverts commit a7c78b80751d4125e70c3be87d4c0b7ba6206795.
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
@daniel-lxs daniel-lxs force-pushed the indexing-field-validation branch from cb47183 to a80e1e6 Compare July 9, 2025 00:54
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 9, 2025
@mrubens mrubens merged commit fa60a31 into RooCodeInc:main Jul 9, 2025
11 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 9, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jul 9, 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 lgtm This PR has been approved by a maintainer PR - Needs Review size:XXL This PR changes 1000+ 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.

4 participants