Skip to content

Commit

Permalink
chore(weave): add annotation spec name to feedback grid (#3331)
Browse files Browse the repository at this point in the history
  • Loading branch information
gtarpenning authored Jan 7, 2025
1 parent 5a61b84 commit 2880ba8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export const FeedbackGrid = ({
return getTsClient().registerOnFeedbackListener(weaveRef, query.refetch);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const hasAnnotationFeedback = query.result?.some(f =>
f.feedback_type.startsWith(ANNOTATION_PREFIX)
);

// Group by feedback on this object vs. descendent objects
const grouped = useMemo(() => {
Expand Down Expand Up @@ -127,6 +130,7 @@ export const FeedbackGrid = ({
<FeedbackGridInner
feedback={grouped[path]}
currentViewerId={currentViewerId}
showAnnotationName={hasAnnotationFeedback}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import {GridColDef, GridRowHeightParams} from '@mui/x-data-grid-pro';
import {
GridColDef,
GridRenderCellParams,
GridRowHeightParams,
} from '@mui/x-data-grid-pro';
import React from 'react';

import {Timestamp} from '../../../../Timestamp';
Expand All @@ -9,16 +13,21 @@ import {Feedback} from '../pages/wfReactInterface/traceServerClientTypes';
import {StyledDataGrid} from '../StyledDataGrid';
import {FeedbackGridActions} from './FeedbackGridActions';
import {FeedbackTypeChip} from './FeedbackTypeChip';
import {isHumanAnnotationType} from './StructuredFeedback/humanAnnotationTypes';
import {
getHumanAnnotationNameFromFeedbackType,
isHumanAnnotationType,
} from './StructuredFeedback/humanAnnotationTypes';

type FeedbackGridInnerProps = {
feedback: Feedback[];
currentViewerId: string | null;
showAnnotationName?: boolean;
};

export const FeedbackGridInner = ({
feedback,
currentViewerId,
showAnnotationName,
}: FeedbackGridInnerProps) => {
const columns: GridColDef[] = [
{
Expand All @@ -31,6 +40,25 @@ export const FeedbackGridInner = ({
</div>
),
},
...(showAnnotationName
? [
{
field: 'annotation_name',
headerName: 'Name',
flex: 1,
renderCell: (params: GridRenderCellParams) => {
const feedbackType = params.row.feedback_type;
const annotationName = isHumanAnnotationType(feedbackType)
? getHumanAnnotationNameFromFeedbackType(feedbackType)
: null;
if (!annotationName) {
return null;
}
return <CellValueString value={annotationName} />;
},
},
]
: []),
{
field: 'payload',
headerName: 'Feedback',
Expand Down Expand Up @@ -61,16 +89,17 @@ export const FeedbackGridInner = ({
{
field: 'created_at',
headerName: 'Timestamp',
minWidth: 120,
width: 120,
minWidth: 105,
width: 105,
renderCell: params => (
<Timestamp value={params.row.created_at} format="relative" />
),
},
{
field: 'id',
headerName: 'ID',
width: 50,
width: 48,
minWidth: 48,
display: 'flex',
renderCell: params => <CopyableId id={params.row.id} type="Feedback" />,
},
Expand Down Expand Up @@ -98,7 +127,8 @@ export const FeedbackGridInner = ({
{
field: 'actions',
headerName: '',
width: 50,
width: 36,
minWidth: 36,
filterable: false,
sortable: false,
resizable: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ export type HumanAnnotation = Feedback & {};

export const isHumanAnnotationType = (feedbackType: string) =>
feedbackType.startsWith(HUMAN_ANNOTATION_BASE_TYPE);

export const getHumanAnnotationNameFromFeedbackType = (feedbackType: string) =>
feedbackType.split('.').pop();

0 comments on commit 2880ba8

Please sign in to comment.