yangdx commited on
Commit
15c04d1
·
1 Parent(s): 4aa931e

Keep graph query label after 401 error for post-login data reload

Browse files
lightrag_webui/src/hooks/useLightragGraph.tsx CHANGED
@@ -342,15 +342,23 @@ const useLightrangeGraph = () => {
342
  // Still mark graph as empty for other logic
343
  state.setGraphIsEmpty(true);
344
 
345
- // Only clear current label if it's not already empty
346
- if (currentQueryLabel) {
 
 
 
 
347
  useSettingsStore.getState().setQueryLabel('');
348
  }
349
 
350
- // Clear last successful query label to ensure labels are fetched next time
351
- state.setLastSuccessfulQueryLabel('');
 
 
 
 
352
 
353
- console.log('Graph data is empty, created graph with empty graph node');
354
  } else {
355
  // Create and set new graph
356
  const newSigmaGraph = createSigmaGraph(data);
 
342
  // Still mark graph as empty for other logic
343
  state.setGraphIsEmpty(true);
344
 
345
+ // Check if the empty graph is due to 401 authentication error
346
+ const errorMessage = useBackendState.getState().message;
347
+ const isAuthError = errorMessage && errorMessage.includes('Authentication required');
348
+
349
+ // Only clear queryLabel if it's not an auth error and current label is not empty
350
+ if (!isAuthError && currentQueryLabel) {
351
  useSettingsStore.getState().setQueryLabel('');
352
  }
353
 
354
+ // Only clear last successful query label if it's not an auth error
355
+ if (!isAuthError) {
356
+ state.setLastSuccessfulQueryLabel('');
357
+ } else {
358
+ console.log('Keep queryLabel for post-login reload');
359
+ }
360
 
361
+ console.log(`Graph data is empty, created graph with empty graph node. Auth error: ${isAuthError}`);
362
  } else {
363
  // Create and set new graph
364
  const newSigmaGraph = createSigmaGraph(data);
lightrag_webui/src/services/navigation.ts CHANGED
@@ -32,7 +32,7 @@ class NavigationService {
32
  // Reset backend state
33
  useBackendState.getState().clear();
34
 
35
- // Reset retrieval history while preserving other user preferences
36
  useSettingsStore.getState().setRetrievalHistory([]);
37
 
38
  // Clear authentication state
 
32
  // Reset backend state
33
  useBackendState.getState().clear();
34
 
35
+ // Reset retrieval history message while preserving other user preferences
36
  useSettingsStore.getState().setRetrievalHistory([]);
37
 
38
  // Clear authentication state