diff --git a/packages/frontend-2/components/automate/viewer/panel/FunctionRunRowObjectResult.vue b/packages/frontend-2/components/automate/viewer/panel/FunctionRunRowObjectResult.vue index 8363e7c1d..d0eb12ddd 100644 --- a/packages/frontend-2/components/automate/viewer/panel/FunctionRunRowObjectResult.vue +++ b/packages/frontend-2/components/automate/viewer/panel/FunctionRunRowObjectResult.vue @@ -59,17 +59,12 @@ const { } } = useInjectedViewerState() -const { isolateObjects, resetFilters, addActiveFilter, filters } = useFilterUtilities() +const { isolateObjects, unIsolateObjects, resetFilters, addActiveFilter, filters } = + useFilterUtilities() const { setColorFilter, removeColorFilter } = useFilterColoringHelpers() -const logger = useLogger() const hasMetadataGradient = computed(() => { const hasGradient = !!props.result.metadata?.gradient - logger.debug('[FunctionRunRowObjectResult] hasMetadataGradient computed', { - hasMetadata: !!props.result.metadata, - hasGradient, - gradientValue: props.result.metadata?.gradient - }) return hasGradient }) @@ -77,10 +72,6 @@ const isIsolated = computed(() => { // Gradient results show active via metadataGradientIsSet if (hasMetadataGradient.value) { const isolated = metadataGradientIsSet.value - logger.debug('[FunctionRunRowObjectResult] isIsolated (gradient path)', { - metadataGradientIsSet: metadataGradientIsSet.value, - isolated - }) return isolated } @@ -89,14 +80,6 @@ const isIsolated = computed(() => { const ids = resultObjectIds.value const isolated = isolatedIds?.length ? containsAll(ids, isolatedIds) : false - logger.debug('[FunctionRunRowObjectResult] isIsolated (non-gradient path)', { - isolatedIds, - resultIds: ids, - isolatedIdsLength: isolatedIds?.length || 0, - resultIdsLength: ids.length, - isolated - }) - return isolated }) @@ -106,90 +89,26 @@ const resultObjectIds = computed(() => { ? props.result.objectIds : Object.keys(props.result.objectAppIds) - logger.debug('[FunctionRunRowObjectResult] resultObjectIds computed', { - hasObjectIds: 'objectIds' in props.result, - hasObjectAppIds: 'objectAppIds' in props.result, - idsCount: ids.length, - firstFewIds: ids.slice(0, 3) - }) - return ids }) const handleClick = () => { - try { - logger.debug('[FunctionRunRowObjectResult] handleClick triggered', { - functionId: props.functionId, - resultCategory: props.result.category, - resultLevel: props.result.level, - hasMetadataGradient: hasMetadataGradient.value, - metadataGradientIsSet: metadataGradientIsSet.value, - isIsolated: isIsolated.value, - resultObjectIds: resultObjectIds.value, - resultMetadata: props.result.metadata - }) - - if (hasMetadataGradient.value) { - logger.debug('[FunctionRunRowObjectResult] Taking gradient path') - setOrUnsetGradient() - return - } - - logger.debug('[FunctionRunRowObjectResult] Taking isolation path') - isolateOrUnisolateObjects() - } catch (error) { - logger.error('[FunctionRunRowObjectResult] Error in handleClick:', error) + if (hasMetadataGradient.value) { + setOrUnsetGradient() + return } + + isolateOrUnisolateObjects() } const isolateOrUnisolateObjects = () => { - try { - const ids = resultObjectIds.value - const currentIsolatedIds = filters.isolatedObjectIds.value || [] - const wasIsolated = containsAll(ids, currentIsolatedIds) + const ids = resultObjectIds.value + if (ids.length === 0) return - logger.debug('[FunctionRunRowObjectResult] isolateOrUnisolateObjects', { - objectIds: ids, - currentIsolatedIds, - wasIsolated, - idsLength: ids.length, - currentIsolatedLength: currentIsolatedIds.length - }) - - logger.debug('[FunctionRunRowObjectResult] Calling resetFilters()') - resetFilters() - - logger.debug('[FunctionRunRowObjectResult] Calling removeColorFilter()') - removeColorFilter() - - logger.debug('[FunctionRunRowObjectResult] Setting metadataGradientIsSet to false') - metadataGradientIsSet.value = false - - // Clear isolated objects first to ensure watcher fires - filters.isolatedObjectIds.value = [] - - if (!wasIsolated) { - logger.debug( - '[FunctionRunRowObjectResult] Objects were not isolated, calling isolateObjects with ids:', - ids - ) - isolateObjects(ids) - - // Check if the state was actually updated - logger.debug( - '[FunctionRunRowObjectResult] After isolateObjects call - isolatedObjectIds length:', - filters.isolatedObjectIds.value.length - ) - } else { - logger.debug( - '[FunctionRunRowObjectResult] Objects were already isolated, not calling isolateObjects' - ) - } - } catch (error) { - logger.error( - '[FunctionRunRowObjectResult] Error in isolateOrUnisolateObjects:', - error - ) + if (!isIsolated.value) { + isolateObjects(ids) + } else { + unIsolateObjects(ids) } } @@ -240,72 +159,35 @@ const computedFilterData = computed((): NumericFilterData | undefined => { }) const setOrUnsetGradient = () => { - logger.debug('[FunctionRunRowObjectResult] setOrUnsetGradient called', { - metadataGradientIsSet: metadataGradientIsSet.value, - hasResultMetadata: !!props.result.metadata, - computedPropInfo: computedPropInfo.value, - functionId: props.functionId, - gradientValues: props.result.metadata?.gradientValues - }) - if (metadataGradientIsSet.value) { - logger.debug('[FunctionRunRowObjectResult] Gradient is set, unsetting it') - logger.debug( - '[FunctionRunRowObjectResult] Calling resetFilters() from gradient unset' - ) resetFilters() - logger.debug( - '[FunctionRunRowObjectResult] Calling removeColorFilter() from gradient unset' - ) removeColorFilter() - logger.debug( - '[FunctionRunRowObjectResult] Setting metadataGradientIsSet to false from gradient unset' - ) metadataGradientIsSet.value = false return } - logger.debug('[FunctionRunRowObjectResult] Setting gradient, calling resetFilters()') resetFilters() if (!props.result.metadata) { - logger.debug('[FunctionRunRowObjectResult] No result metadata, returning early') return } if (!computedPropInfo.value) { - logger.debug('[FunctionRunRowObjectResult] No computedPropInfo, returning early') return } if (!props.functionId) { - logger.debug('[FunctionRunRowObjectResult] No functionId, returning early') return } const gradientValues = props.result.metadata?.gradientValues || {} - logger.debug('[FunctionRunRowObjectResult] Injecting gradient data into data store', { - functionId: props.functionId, - gradientValuesKeys: Object.keys(gradientValues), - gradientValuesCount: Object.keys(gradientValues).length - }) injectGradientDataIntoDataStore(filteringDataStore, props.functionId, gradientValues) - logger.debug('[FunctionRunRowObjectResult] Setting metadataGradientIsSet to true') metadataGradientIsSet.value = true - logger.debug( - '[FunctionRunRowObjectResult] Adding active filter with propInfo:', - computedPropInfo.value - ) const filterId = addActiveFilter(computedPropInfo.value) - logger.debug('[FunctionRunRowObjectResult] Got filterId:', filterId) - logger.debug( - '[FunctionRunRowObjectResult] Setting color filter with filterId:', - filterId - ) setColorFilter(filterId) } diff --git a/packages/frontend-2/lib/viewer/composables/setup/filters.ts b/packages/frontend-2/lib/viewer/composables/setup/filters.ts index 0532d0d3a..f1225db70 100644 --- a/packages/frontend-2/lib/viewer/composables/setup/filters.ts +++ b/packages/frontend-2/lib/viewer/composables/setup/filters.ts @@ -59,7 +59,6 @@ export const useManualFilteringPostSetup = () => { ui: { filters }, viewer: { instance } } = useInjectedViewerState() - const logger = useLogger() const filteringExtension = () => instance.getExtension(FilteringExtension) @@ -78,11 +77,6 @@ export const useManualFilteringPostSetup = () => { const highlightedObjects = highlightExtension?.getSelectedObjects().map((obj) => obj.id as string) || [] - logger.debug('[FilterSetup] preserveSelectionHighlightFilter - saving state', { - selectedObjectsCount: selectedObjects.length, - highlightedObjectsCount: highlightedObjects.length - }) - // 2. CLEAR viewer extensions directly if (selectedObjects.length) selectionExtension.clearSelection() if (highlightedObjects.length && highlightExtension) { @@ -90,25 +84,13 @@ export const useManualFilteringPostSetup = () => { } // 3. EXECUTE the filtering operation - logger.debug( - '[FilterSetup] preserveSelectionHighlightFilter - executing filter function' - ) const result = filterFn() - logger.debug( - '[FilterSetup] preserveSelectionHighlightFilter - filter function completed' - ) // 4. RESTORE to viewer extensions directly if (selectedObjects.length) { - logger.debug( - '[FilterSetup] preserveSelectionHighlightFilter - restoring selection' - ) selectionExtension.selectObjects(selectedObjects) } if (highlightedObjects.length && highlightExtension) { - logger.debug( - '[FilterSetup] preserveSelectionHighlightFilter - restoring highlights' - ) highlightExtension.selectObjects(highlightedObjects) } @@ -121,39 +103,20 @@ export const useManualFilteringPostSetup = () => { const { trigger: triggerIsolationWatch } = watchTriggerable( filters.isolatedObjectIds, (newIds, oldIds) => { - logger.debug('[FilterSetup] isolatedObjectIds watcher triggered', { - newIdsLength: newIds?.length || 0, - oldIdsLength: oldIds?.length || 0, - newIds: newIds?.slice(0, 3), - oldIds: oldIds?.slice(0, 3) - }) - if (!newIds || !oldIds) { - logger.debug('[FilterSetup] Early return - missing newIds or oldIds') return } preserveSelectionHighlightFilter(() => { const extension = filteringExtension() - logger.debug('[FilterSetup] Got filtering extension:', !!extension) const toIsolate = newIds.filter((id) => !oldIds.includes(id)) if (toIsolate.length > 0) { - logger.debug( - '[FilterSetup] Calling extension.isolateObjects with', - toIsolate.length, - 'objects' - ) extension.isolateObjects(toIsolate, 'manual-isolation', true, true) } const toUnIsolate = oldIds.filter((id) => !newIds.includes(id)) if (toUnIsolate.length > 0) { - logger.debug( - '[FilterSetup] Calling extension.unIsolateObjects with', - toUnIsolate.length, - 'objects' - ) extension.unIsolateObjects(toUnIsolate, 'manual-isolation', true, true) } })