codeant-ai-for-open-source[bot] commented on code in PR #43108:
URL: https://github.com/apache/superset/pull/43108#discussion_r3996245660


##########
superset-frontend/src/dashboard/containers/DashboardPage.tsx:
##########
@@ -81,6 +81,30 @@ import {
 
 type NativeFilterConfigEntry = Partial<Filter> & { id: string };
 
+const DASHBOARD_FILTERS_STORAGE_PREFIX = 'superset_dashboard_filters_';

Review Comment:
   Agreed. Guest/embedded sessions should not persist filter state because 
there is no stable identity to scope it to, and this matches `FilterBar`’s 
behavior.
   
   Skip both restoration and persistence when `userId` is unavailable:
   
   ```typescript
   // Before attempting localStorage restoration
   if (userId == null) {
     // Continue with URL/default state only
   } else {
     const savedFilters = getSavedDashboardFilters(id, userId);
     // existing validation and restoration logic
   }
   ```
   
   And in the persistence effect:
   
   ```typescript
   useEffect(() => {
     if (
       !id ||
       userId == null ||
       hydratedDashboardId !== id ||
       !isDashboardHydrated.current
     ) {
       return;
     }
   
     // existing persistence logic
   }, [id, hydratedDashboardId, fullDataMask, nativeFilters, userId]);
   ```
   
   Use `userId == null` rather than a truthiness check so a valid ID of `0` is 
not treated as anonymous. The existing authenticated-user key format then 
prevents cross-user reuse, while embedded/guest sessions neither read nor write 
dashboard filter state. Tests expecting anonymous localStorage restoration 
should be updated to use an authenticated `userId`; add a test confirming 
anonymous sessions skip both operations.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to