Skip to content
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

chore: added/removed evals reflected in URL state #2665

Merged
merged 6 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions weave-js/src/components/PagePanelComponents/Home/Browse3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -921,16 +921,27 @@ const OpPageBinding = () => {
};

const CompareEvaluationsBinding = () => {
const history = useHistory();
const location = useLocation();
const {entity, project} = useParamsDecoded<Browse3TabParams>();
const query = useURLSearchParamsDict();
const evaluationCallIds = useMemo(() => {
return JSON.parse(query.evaluationCallIds);
}, [query.evaluationCallIds]);
const onEvaluationCallIdsUpdate = useCallback(
(newEvaluationCallIds: string[]) => {
const newQuery = new URLSearchParams(location.search);
newQuery.set('evaluationCallIds', JSON.stringify(newEvaluationCallIds));
history.push({search: newQuery.toString()});
},
[history, location.search]
);
return (
<CompareEvaluationsPage
entity={entity}
project={project}
evaluationCallIds={evaluationCallIds}
onEvaluationCallIdsUpdate={onEvaluationCallIdsUpdate}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ const useCallTabs = (call: CallSchema) => {
entity={call.entity}
project={call.project}
evaluationCallIds={[call.callId]}
// Dont persist changes to evaluationCallIds in the URL
onEvaluationCallIdsUpdate={() => {}}
/>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type CompareEvaluationsPageProps = {
entity: string;
project: string;
evaluationCallIds: string[];
onEvaluationCallIdsUpdate: (newEvaluationCallIds: string[]) => void;
};

export const CompareEvaluationsPage: React.FC<
Expand All @@ -55,6 +56,7 @@ export const CompareEvaluationsPage: React.FC<
entity={props.entity}
project={props.project}
evaluationCallIds={props.evaluationCallIds}
onEvaluationCallIdsUpdate={props.onEvaluationCallIdsUpdate}
/>
),
},
Expand Down Expand Up @@ -113,6 +115,7 @@ export const CompareEvaluationsPageContent: React.FC<
initialEvaluationCallIds={props.evaluationCallIds}
baselineEvaluationCallId={baselineEvaluationCallId ?? undefined}
comparisonDimensions={comparisonDimensions ?? undefined}
onEvaluationCallIdsUpdate={props.onEvaluationCallIdsUpdate}
setBaselineEvaluationCallId={setBaselineEvaluationCallId}
setComparisonDimensions={setComparisonDimensionsAndClearInputDigest}
selectedInputDigest={selectedInputDigest ?? undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const CompareEvaluationsProvider: React.FC<{
entity: string;
project: string;
initialEvaluationCallIds: string[];
onEvaluationCallIdsUpdate: (newEvaluationCallIds: string[]) => void;
setBaselineEvaluationCallId: React.Dispatch<
React.SetStateAction<string | null>
>;
Expand All @@ -46,6 +47,7 @@ export const CompareEvaluationsProvider: React.FC<{
entity,
project,
initialEvaluationCallIds,
onEvaluationCallIdsUpdate,
setBaselineEvaluationCallId,
setComparisonDimensions,

Expand Down Expand Up @@ -78,15 +80,23 @@ export const CompareEvaluationsProvider: React.FC<{
setComparisonDimensions,
setSelectedInputDigest,
addEvaluationCall: (newCallId: string) => {
setEvaluationCallIds(prev => [...prev, newCallId]);
const newEvaluationCallIds = [...evaluationCallIds, newCallId];
setEvaluationCallIds(newEvaluationCallIds);
onEvaluationCallIdsUpdate(newEvaluationCallIds);
},
removeEvaluationCall: (callId: string) => {
setEvaluationCallIds(prev => prev.filter(id => id !== callId));
const newEvaluationCallIds = evaluationCallIds.filter(
id => id !== callId
);
setEvaluationCallIds(newEvaluationCallIds);
onEvaluationCallIdsUpdate(newEvaluationCallIds);
},
};
}, [
initialState.loading,
initialState.result,
evaluationCallIds,
onEvaluationCallIdsUpdate,
setEvaluationCallIds,
setBaselineEvaluationCallId,
setComparisonDimensions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,20 @@ export const EvaluationDefinition: React.FC<{
{props.callId === props.state.baselineEvaluationCallId && (
<Pill label="Baseline" color="teal" />
)}
<PopupDropdown
sections={[menuOptions]}
trigger={
<Button
className="rotate-90"
icon="overflow-horizontal"
size="small"
variant="ghost"
style={{marginLeft: '4px'}}
/>
}
/>
<div style={{marginLeft: '-14px'}}>
<PopupDropdown
sections={[menuOptions]}
trigger={
<Button
className="rotate-90"
icon="overflow-horizontal"
size="small"
variant="ghost"
style={{marginLeft: '4px'}}
/>
}
/>
</div>
</HorizontalBox>
);
};
Expand Down
Loading