Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ const AnnotateRow: React.FunctionComponent<AnnotateRowProps> = ({
value: reasonValue,
onChange: onReasonChange,
onReset: onReasonReset,
resetValue,
resetValue: resetReasonValue,
setInputValue: setReasonValue,
} = useDebouncedValue({
initialValue: feedbackScore?.reason,
Copy link
Preview

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

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

The initialValue parameter is being passed but was removed from the useDebouncedValue hook parameters. This will be ignored and could lead to unexpected behavior.

Copilot uses AI. Check for mistakes.

onDebouncedChange: handleChangeReason,
Expand All @@ -104,12 +105,17 @@ const AnnotateRow: React.FunctionComponent<AnnotateRowProps> = ({
const deleteFeedbackScore = useCallback(() => {
onDeleteFeedbackScore(name);
setEditReason(false);
resetValue();
resetReasonValue();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [name, resetValue]);
}, [name, resetReasonValue]);

const handleCopyReasonClick = async (reasonValue: string) => {
await copy(reasonValue);
const toggleEditReasonHandler = useCallback(() => {
setEditReason(!editReason);
setReasonValue(feedbackScore?.reason);
}, [editReason, feedbackScore?.reason, setReasonValue]);

const handleCopyReasonClick = async (v: string) => {
await copy(v);

toast({
description: "Reason successfully copied to clipboard",
Expand Down Expand Up @@ -273,9 +279,9 @@ const AnnotateRow: React.FunctionComponent<AnnotateRowProps> = ({
editReason &&
"bg-toggle-outline-active active:bg-toggle-outline-active hover:bg-toggle-outline-active",
)}
onClick={() => setEditReason((v) => !v)}
onClick={toggleEditReasonHandler}
>
{!!reasonValue && (
{!!feedbackScore?.reason && (
<div
className={cn(
"absolute right-1 top-1 size-[8px] rounded-full border-2 border-white bg-primary group-hover/reason-btn:border-primary-foreground",
Expand Down Expand Up @@ -313,13 +319,13 @@ const AnnotateRow: React.FunctionComponent<AnnotateRowProps> = ({
updateTextAreaHeight(e, 32);
}}
/>
{reasonValue && (
{feedbackScore?.reason && (
<div className="absolute right-2 top-1 hidden gap-1 group-hover/reason-field:flex">
<TooltipWrapper content="Copy">
<Button
size="icon-2xs"
variant="outline"
onClick={() => handleCopyReasonClick(reasonValue)}
onClick={() => handleCopyReasonClick(feedbackScore.reason!)}
>
<Copy />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const TraceAnnotateViewer: React.FunctionComponent<
</div>
)}
<FeedbackScoresEditor
key={spanId ?? traceId}
key={`${spanId ?? "no-span-id"}-${traceId}`}
feedbackScores={data.feedback_scores || []}
onUpdateFeedbackScore={onUpdateFeedbackScore}
onDeleteFeedbackScore={onDeleteFeedbackScore}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const AddFeedbackScorePopover: React.FunctionComponent<
<PopoverContent side="top" align="end" className="p-0">
<div className="max-h-[70vh] max-w-[400px] overflow-auto px-0 py-4">
<FeedbackScoresEditor
key={spanId ?? traceId}
key={`${spanId ?? "no-span-id"}-${traceId}`}
feedbackScores={feedbackScores}
onUpdateFeedbackScore={onUpdateFeedbackScore}
onDeleteFeedbackScore={onDeleteFeedbackScore}
Expand Down
7 changes: 3 additions & 4 deletions apps/opik-frontend/src/hooks/useDebouncedValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ type UseDebouncedValueArgs = {
onDebouncedChange: (value: string) => void;
delay?: number;
onChange?: () => void;
setInputValue?: (value: string) => void;
Copy link
Preview

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

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

The setInputValue parameter name conflicts with the internal state setter. Consider renaming to onSetInputValue or externalSetInputValue to avoid confusion and clearly indicate it's a callback.

Suggested change
setInputValue?: (value: string) => void;
onSetInputValue?: (value: string) => void;

Copilot uses AI. Check for mistakes.

};
export const useDebouncedValue = ({
initialValue,
onDebouncedChange,
delay = 300,
onChange,
}: UseDebouncedValueArgs) => {
Comment on lines 10 to 14
Copy link
Preview

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

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

The setInputValue parameter is defined in the type but not destructured in the function parameters. This will cause the external setInputValue functionality to be unavailable.

Copilot uses AI. Check for mistakes.

const [inputValue, setInputValue] = useState<string | undefined>(
initialValue,
);
const [inputValue, setInputValue] = useState<string | undefined>();

const debouncedCallback = useMemo(
() => debounce(onDebouncedChange, delay),
Expand Down Expand Up @@ -44,6 +42,7 @@ export const useDebouncedValue = ({
return {
resetValue,
value: inputValue,
setInputValue,
onChange: handleInputChange,
onReset,
};
Expand Down