发布

  • [OPIK-2739] [FE] Add inline editing for user feedback column (#3716)

    frostbyte_neo 发布于 2025-10-20 10:48:55 +00:00

    • [OPIK-2739] [FE] Add inline editing for user feedback column

    This commit implements inline editing functionality for the user feedback column in data tables, allowing users to quickly update feedback scores without opening a separate dialog.

    Key changes:

    • Created FeedbackScoreEditDropdown component with hover-triggered edit button
    • Integrated dropdown with feedback definitions API to fetch categorical options
    • Added support for toggling feedback values (setting/unsetting)
    • Enhanced FeedbackScoreCellValue to conditionally render edit dropdown
    • Updated FeedbackScoreCell to pass down edit handler and user context

    The edit button appears on hover and presents feedback options from the User feedback definition, defaulting to 👍/👎 if the definition is not found.

    Implements OPIK-2739: Add inline editing user feedback column

    • Revision 2: Fix Tailwind CSS classname ordering

    • Revision 3: Restrict user feedback editing to TracesSpansTab only

    Use table meta to control which pages allow inline editing of user feedback.
    This ensures the edit functionality only appears on TracesSpansTab and not on
    other pages like ThreadsTab, annotation queues, or experiments.

    • Revision 4: Refactor FeedbackScoreEditDropdown to simplify feedback options handling
    • Updated feedback options logic to directly map categories from user feedback definition, ensuring fallback to an empty object if not available.
    • Added a check to prevent rendering the dropdown if no feedback options are present, improving user experience.
    • Revision 4: Make edit button visible on entire cell hover

    Move group class from inner div to CellWrapper so the edit button appears
    when hovering anywhere in the cell, not just over the cell content.

    • Revision 5: Fix dropdown anchor shift during close animation

    Add delayed visibility state to keep the edit button visible for 150ms after
    the dropdown closes. This prevents the dropdown from losing its anchor point
    and briefly flashing in the top-left corner during the close animation.

    • Revision 6: Use cn utility for conditional className

    Replace ternary operator with cn utility function for cleaner and more
    maintainable conditional class name application.

    • Revision 7: Refactor FeedbackScoreCellValue to follow DRY principle

    Extract common edit dropdown condition into shouldShowEditDropdown variable
    to avoid duplicating the conditional rendering logic. Also removed unnecessary
    non-null assertions where possible.

    • Add workspace name retrieval in FeedbackScoreEditDropdown component
    • Moved workspace name retrieval to the correct position in the component to ensure it is available for feedback definitions logic.
    • Removed duplicate declaration of workspace name to streamline the code and improve maintainability.
    • Update FeedbackScoreEditDropdown to use current user's feedback value
    • Added retrieval of the logged-in user's name to ensure the correct feedback value is displayed based on the author.
    • Updated the logic for obtaining the current feedback value to reference the user's specific feedback entry, enhancing accuracy in the dropdown component.
    • Refactor user name retrieval to use default for open source in SMEFlowContext and FeedbackScore components
    • Updated components to utilize useLoggedInUserNameOrOpenSourceDefaultUser for consistent user name handling.
    • Simplified logic to ensure "admin" is used as a fallback when no user is logged in, improving feedback score functionality.
    • Revision 8: Pass categoryName to feedback score mutation

    Include feedbackScore.category_name when calling setTraceFeedbackScore to
    ensure the category is properly persisted. Also removed debug console.log.

    • Refactor user name retrieval in AnnotateRow component

    Updated AnnotateRow to use useLoggedInUserNameOrOpenSourceDefaultUser for consistent user name handling, ensuring a default user is utilized when no user is logged in. This change aligns with recent updates for improved feedback score functionality.

    • Enhance FeedbackScoreEditDropdown to sort feedback options by value
    • Integrated lodash's sortBy function to sort feedback options based on their value before rendering.
    • This change improves the user experience by presenting feedback categories in a consistent order.
    下载附件