Skip to content

Commit 2f5a7aa

Browse files
committed
Fix duplicate Welcome graph creation
- Add check for existing shared/system Welcome graph before creating new one - Frontend now detects server-created shared Welcome graph - Prevents duplicate Welcome graphs when user logs in - Maintains fallback creation if no Welcome graph exists at all
1 parent c3dc529 commit 2f5a7aa

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

packages/web/src/contexts/GraphContext.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,20 @@ export function GraphProvider({ children }: GraphProviderProps) {
149149
}
150150
}
151151
} else if (!isLoading && !graphsError && currentUser && !isCreatingWelcomeGraph) {
152-
console.log('🎉 No graphs found for user:', currentUser.id, '- Triggering Welcome graph creation');
153-
// No graphs available - automatically create Welcome graph for new users
154-
setAvailableGraphs([]);
155-
setCurrentGraph(null);
156-
setIsCreatingWelcomeGraph(true);
152+
// Check if shared Welcome graph exists (created by server onboarding service)
153+
const hasWelcomeGraph = [...(graphsData?.systemGraphs || []), ...(graphsData?.sharedGraphs || [])]
154+
.some(g => g.name === 'Welcome');
155+
156+
if (!hasWelcomeGraph) {
157+
console.log('🎉 No graphs found for user:', currentUser.id, '- Triggering Welcome graph creation');
158+
// No graphs available - automatically create Welcome graph for new users
159+
setAvailableGraphs([]);
160+
setCurrentGraph(null);
161+
setIsCreatingWelcomeGraph(true);
162+
} else {
163+
console.log('✅ Shared Welcome graph already exists, skipping creation');
164+
return;
165+
}
157166

158167
// Create Welcome graph automatically with tutorial content
159168
const createWelcomeGraphWithTutorial = async () => {

0 commit comments

Comments
 (0)