diff --git a/app/packages/operators/src/CustomPanel.tsx b/app/packages/operators/src/CustomPanel.tsx index ccbe779406..fce41ede1e 100644 --- a/app/packages/operators/src/CustomPanel.tsx +++ b/app/packages/operators/src/CustomPanel.tsx @@ -119,6 +119,7 @@ export function defineCustomPanel({ on_change_selected_labels, on_change_extended_selection, on_change_group_slice, + on_change_query_performance, on_change_spaces, panel_name, panel_label, @@ -139,6 +140,7 @@ export function defineCustomPanel({ onChangeSelectedLabels={on_change_selected_labels} onChangeExtendedSelection={on_change_extended_selection} onChangeGroupSlice={on_change_group_slice} + on_change_query_performance={on_change_query_performance} onChangeSpaces={on_change_spaces} dimensions={dimensions} panelName={panel_name} diff --git a/app/packages/operators/src/state.ts b/app/packages/operators/src/state.ts index 726ab14a1f..dc8e9b333a 100644 --- a/app/packages/operators/src/state.ts +++ b/app/packages/operators/src/state.ts @@ -94,7 +94,7 @@ const globalContextSelector = selector({ const viewName = get(fos.viewName); const extendedSelection = get(fos.extendedSelection); const groupSlice = get(fos.groupSlice); - const queryPerformance = typeof get(fos.queryPerformance) === "number"; + const queryPerformance = get(fos.queryPerformance); const spaces = get(fos.sessionSpaces); const workspaceName = spaces?._name; diff --git a/app/packages/operators/src/useCustomPanelHooks.ts b/app/packages/operators/src/useCustomPanelHooks.ts index 85d08e7a58..7363234138 100644 --- a/app/packages/operators/src/useCustomPanelHooks.ts +++ b/app/packages/operators/src/useCustomPanelHooks.ts @@ -26,6 +26,7 @@ export interface CustomPanelProps { onChangeSelectedLabels?: string; onChangeExtendedSelection?: string; onChangeGroupSlice?: string; + onChangeQueryPerformance?: boolean; onChangeSpaces?: string; onChangeWorkspace?: string; dimensions: DimensionsType | null; @@ -139,6 +140,12 @@ export function useCustomPanelHooks(props: CustomPanelProps): CustomPanelHooks { ctx.groupSlice, props.onChangeGroupSlice ); + useCtxChangePanelEvent( + isLoaded, + panelId, + ctx.queryPerformance, + props.onChangeQueryPerformance + ); useCtxChangePanelEvent(isLoaded, panelId, ctx.spaces, props.onChangeSpaces); useCtxChangePanelEvent( isLoaded, diff --git a/app/packages/state/src/recoil/queryPerformance.ts b/app/packages/state/src/recoil/queryPerformance.ts index 956d3da1b6..8392074e29 100644 --- a/app/packages/state/src/recoil/queryPerformance.ts +++ b/app/packages/state/src/recoil/queryPerformance.ts @@ -207,7 +207,7 @@ const queryPerformanceStore = atomFamily({ ], }); -export const queryPerformance = selector({ +export const queryPerformance = selector({ key: "queryPerformance", get: ({ get }) => { if (get(view).length) { diff --git a/fiftyone/operators/operations.py b/fiftyone/operators/operations.py index 3eea25a31a..f10c0a00f4 100644 --- a/fiftyone/operators/operations.py +++ b/fiftyone/operators/operations.py @@ -321,6 +321,7 @@ def register_panel( on_change_selected_labels=None, on_change_extended_selection=None, on_change_group_slice=None, + on_change_query_performance=None, allow_duplicates=False, priority=None, _builtin=False, @@ -364,6 +365,8 @@ def register_panel( current extended selection changes on_change_group_slice (None): an operator to invoke when the group slice changes + on_change_query_performance (None): an operator to invoke when the + query performance changes allow_duplicates (False): whether to allow multiple instances of the panel to the opened priority (None): the priority of the panel, used for sort order @@ -392,6 +395,7 @@ def register_panel( "on_change_selected_labels": on_change_selected_labels, "on_change_extended_selection": on_change_extended_selection, "on_change_group_slice": on_change_group_slice, + "on_change_query_performance": on_change_query_performance, "allow_duplicates": allow_duplicates, "priority": priority, "_builtin": _builtin, diff --git a/fiftyone/operators/panel.py b/fiftyone/operators/panel.py index 2a909101bd..787ee77401 100644 --- a/fiftyone/operators/panel.py +++ b/fiftyone/operators/panel.py @@ -139,6 +139,7 @@ def on_startup(self, ctx): "on_change_selected_labels", "on_change_extended_selection", "on_change_group_slice", + "on_change_query_performance", ] for method in methods + ctx_change_events: if hasattr(self, method) and callable(getattr(self, method)):