Skip to content

Commit acc9fe3

Browse files
committed
fix: Use isSuccess guard for onboarding preferences fallback
Default to false (show dialog) when the query has successfully loaded but data is missing, instead of silently defaulting to true (hide). Only hide during the loading state to prevent flash. Signed-off-by: Krishna Mohan <krishanmohank974@gmail.com>
1 parent da7372b commit acc9fe3

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

frontend/src/components/layout/AppLayout.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,16 @@ export function AppLayout({ children }: AppLayoutProps) {
9595
const openCommandPalette = useCommandPaletteStore((state) => state.open);
9696

9797
// Onboarding tutorial state (persisted in DB via API)
98-
const { data: userPreferences, isLoading: prefsLoading } = useUserPreferences();
98+
const {
99+
data: userPreferences,
100+
isLoading: prefsLoading,
101+
isSuccess: prefsLoaded,
102+
} = useUserPreferences();
99103
const updatePreferences = useUpdateUserPreferences();
100-
const hasCompletedOnboarding = prefsLoading
101-
? true
102-
: (userPreferences?.hasCompletedOnboarding ?? true);
104+
// While loading: hide dialog (true). After loaded: use server value, default false for new users.
105+
const hasCompletedOnboarding = prefsLoaded
106+
? (userPreferences?.hasCompletedOnboarding ?? false)
107+
: true;
103108
const onboardingStep = useOnboardingStore((state) => state.currentStep);
104109
const setOnboardingStep = useOnboardingStore((state) => state.setCurrentStep);
105110
const completeOnboarding = () => updatePreferences.mutate({ hasCompletedOnboarding: true });

frontend/src/features/workflow-builder/WorkflowBuilder.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,11 @@ function WorkflowBuilderContent() {
168168
const isMobile = useIsMobile();
169169

170170
// Builder tour state (completion persisted in DB, step tracking is session-only)
171-
const { data: userPreferences } = useUserPreferences();
171+
const { data: userPreferences, isSuccess: prefsLoaded } = useUserPreferences();
172172
const updatePreferencesForTour = useUpdateUserPreferences();
173-
const hasCompletedBuilderTour = userPreferences?.hasCompletedBuilderTour ?? true;
173+
const hasCompletedBuilderTour = prefsLoaded
174+
? (userPreferences?.hasCompletedBuilderTour ?? false)
175+
: true;
174176
const builderTourStep = useOnboardingStore((s) => s.builderTourStep);
175177
const setBuilderTourStep = useOnboardingStore((s) => s.setBuilderTourStep);
176178
const completeBuilderTour = () =>

0 commit comments

Comments
 (0)