-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[OPIK-2477] [FE] Add expand/collapse feedback score reasons toggle button #4127
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
Open
JetoPistola
wants to merge
36
commits into
main
Choose a base branch
from
danield/OPIK-2477-add-score-reason-optional-column
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+71
−28
Open
Changes from 26 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
85e33d8
[OPIK-2477] [FE] Add score reason as optional column in trace, thread…
JetoPistola c58d104
Revision 2: Refactor to use global toggle for score reason columns
JetoPistola aee575c
Revision 3: Relocate reasons toggle to Columns menu
JetoPistola 4b41460
Revision 2: Show score reasons inline when row height is Medium/Large
JetoPistola 1428bc2
Revision 3: Keep score and reason on same line, add to all resource p…
JetoPistola cc68af4
Revision 4: Align reason button with section title, match font size
JetoPistola 8a04ef2
Revision 5: Create reusable FeedbackScoreReasonToggle component (DRY)…
JetoPistola 4c401aa
Revision 6: Add self-start alignment to reasons toggle button
JetoPistola 99b4118
Revision 7: Move self-start alignment to wrapper div in ColumnsButton
JetoPistola d26b94d
Revision 8: Remove bold font, increase spacing, add margin to toggle
JetoPistola 92955e9
Revision 9: Stack title and toggle button vertically (separate lines)
JetoPistola d8ac5a6
Revision 9: Allow label and toggle to wrap naturally with flex-wrap
JetoPistola da2e9e2
Revision 10: Keep label and toggle on same line together with whitesp…
JetoPistola 252982f
Revision 11: Increase dropdown menu width to prevent horizontal scroll
JetoPistola 8c0edc0
Revision 12: Remove unused FeedbackScoreReasonCell component
JetoPistola ec61cdb
Revision 13: Remove obsolete comments from useExperimentsTableConfig
JetoPistola 16ea198
Revision 13: Remove obsolete comments and use cleaner arrow function …
JetoPistola 2ad424f
Revision 14: Restore original scoresColumnsData format with array spread
JetoPistola 7b549dc
Revision 14: Use TableMeta type and destructure meta properly
JetoPistola 7e50fd0
Revision 15: Use array includes for row height check
JetoPistola a1da3c0
Revision 16: Encapsulate visibility logic in FeedbackScoreReasonToggl…
JetoPistola 16fa908
Revision 17: Return columnSections directly from hook without useMemos
JetoPistola ccc95f2
Make showReasons and setShowReasons optional props with defaults in u…
JetoPistola b753f17
Make showReasons and setShowReasons optional props with defaults in u…
JetoPistola 289a9bd
Revision 18: Allow inline reasons to be multiline with proper truncation
JetoPistola f67a829
Revision 19: Prevent inline reasons from overflowing into cells below
JetoPistola 7d71e05
Revision 20: Add tooltip to show full reasons when truncated
JetoPistola ce2234e
Revision 21: Refactor to avoid duplicating tooltip wrapper
JetoPistola f48323d
Revision 22: Apply linter fixes to FeedbackScoreReasonToggle
JetoPistola fa8e73f
Apply suggestion from @JetoPistola
JetoPistola 8e990a2
Revision 23: Add expand reasons toggle to ExperimentItemsTab
JetoPistola 0b38cb7
Revision 24: Fix inline reasons display in CompareExperimentsFeedback…
JetoPistola 8df202e
Revision 26: Make row height the single source of truth for feedback …
JetoPistola a452951
Revision 28: Remove action support from ColumnsButton
JetoPistola c776e29
Update DataTableRowHeightSelector labels for clarity
JetoPistola 89099db
Refactor CompareExperimentsFeedbackScoreCell layout to conditionally …
JetoPistola File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import React from "react"; | ||
| import { CellContext } from "@tanstack/react-table"; | ||
| import { CellContext, TableMeta } from "@tanstack/react-table"; | ||
|
|
||
| import { ExperimentItem, ExperimentsCompare } from "@/types/datasets"; | ||
| import VerticallySplitCellWrapper, { | ||
|
|
@@ -16,6 +16,7 @@ import { FeedbackScoreCustomMeta } from "@/types/feedback-scores"; | |
| import useFeedbackScoreInlineEdit from "@/hooks/useFeedbackScoreInlineEdit"; | ||
| import { cn } from "@/lib/utils"; | ||
| import FeedbackScoreEditDropdown from "@/components/shared/DataTableCells/FeedbackScoreEditDropdown"; | ||
| import { ROW_HEIGHT } from "@/types/shared"; | ||
|
|
||
| const CompareExperimentsFeedbackScoreCell: React.FC< | ||
| CellContext<ExperimentsCompare, unknown> | ||
|
|
@@ -37,12 +38,17 @@ const CompareExperimentsFeedbackScoreCell: React.FC< | |
| feedbackScore, | ||
| }); | ||
|
|
||
| const enableUserFeedbackEditing = | ||
| const { | ||
| enableUserFeedbackEditing = false, | ||
| showReasons = false, | ||
| rowHeight = ROW_HEIGHT.small, | ||
| } = (context.table.options.meta ?? {}) as TableMeta<ExperimentsCompare>; | ||
|
|
||
| const isEditingEnabled = | ||
| experimentCompare.experiment_items.length === 1 && | ||
| (context.table.options.meta?.enableUserFeedbackEditing ?? false); | ||
| enableUserFeedbackEditing; | ||
| const isUserFeedbackColumn = | ||
| enableUserFeedbackEditing && | ||
| context.column.id === "feedback_scores_User feedback"; | ||
| isEditingEnabled && context.column.id === "feedback_scores_User feedback"; | ||
|
|
||
| const renderContent = (item: ExperimentItem | undefined) => { | ||
| const feedbackScore = item?.feedback_scores?.find( | ||
|
|
@@ -79,10 +85,15 @@ const CompareExperimentsFeedbackScoreCell: React.FC< | |
|
|
||
| const color = feedbackKey && colorMap ? colorMap[feedbackKey] : undefined; | ||
|
|
||
| const shouldShowInlineReasons = | ||
| showReasons && | ||
| [ROW_HEIGHT.medium, ROW_HEIGHT.large].includes(rowHeight) && | ||
| reasons.length > 0; | ||
|
|
||
| return ( | ||
| <div | ||
| className={cn( | ||
| "flex h-4 w-full items-center justify-end gap-1", | ||
| "flex h-4 w-full items-center justify-end gap-1 flex-wrap overflow-hidden", | ||
| isUserFeedbackColumn && "group", | ||
| )} | ||
| > | ||
|
|
@@ -92,10 +103,16 @@ const CompareExperimentsFeedbackScoreCell: React.FC< | |
| isUserFeedbackColumn={isUserFeedbackColumn} | ||
| onValueChange={handleValueChange} | ||
| /> | ||
| {reasons.length > 0 && ( | ||
| <FeedbackScoreReasonTooltip reasons={reasons}> | ||
| <MessageSquareMore className="size-3.5 shrink-0 text-light-slate" /> | ||
| </FeedbackScoreReasonTooltip> | ||
| {shouldShowInlineReasons ? ( | ||
| <span className="line-clamp-3 break-words text-xs text-muted-foreground"> | ||
| {reasons.map((r) => r.reason).join(", ")} | ||
| </span> | ||
| ) : ( | ||
|
||
| reasons.length > 0 && ( | ||
| <FeedbackScoreReasonTooltip reasons={reasons}> | ||
| <MessageSquareMore className="size-3.5 shrink-0 text-light-slate" /> | ||
| </FeedbackScoreReasonTooltip> | ||
| ) | ||
| )} | ||
| </div> | ||
| ); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Using
React.FCis discouraged in modern TypeScript/React. Use a standard function declaration with explicit props typing instead.