Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

Enhance tutorial workflows for builder and agents pages

Muhammad Hamza Khand8929a6a5141
diff --git a/packages/app/src/builder-ui/tutorials/index.ts b/packages/app/src/builder-ui/tutorials/index.ts
index 9f7c4c2d..42a0de65 100644
--- a/packages/app/src/builder-ui/tutorials/index.ts
+++ b/packages/app/src/builder-ui/tutorials/index.ts
@@ -1,10 +1,11 @@
import { userSettingKeys } from '@shared/userSettingKeys';
import { getUserSettings, saveUserSettings } from '@src/react/shared/hooks/useUserSettings';
+import { Analytics } from '@src/shared/posthog/services/analytics';
export const builderPageTutorialWorkflow = async () => {
const tutorialSeen = await getUserSettings(userSettingKeys.SEEN_BUILDER_PAGE_TUTORIAL);
- if (tutorialSeen) return null;
+ if (tutorialSeen === 'true') return null;
const Tutorial = (window as any)?.Tutorial;
if (!Tutorial) return null;
@@ -18,6 +19,15 @@ export const builderPageTutorialWorkflow = async () => {
} (${tutorialWorkflow.currentStep + 1}/${tutorialWorkflow.getSteps().length})`;
}, 0);
},
+ onReset: () => {
+ // Called when overlay is about to be cleared
+ Analytics.track('builder_page_tutorial_completed', {
+ page_url: '/builder',
+ source: 'Tutorial completed on builder page onboarding',
+ });
+
+ saveUserSettings(userSettingKeys.SEEN_BUILDER_PAGE_TUTORIAL, 'true');
+ },
animate: true,
showButtons: true,
nextBtnText: 'Next',
@@ -74,7 +84,5 @@ export const builderPageTutorialWorkflow = async () => {
},
]);
- await saveUserSettings(userSettingKeys.SEEN_BUILDER_PAGE_TUTORIAL, 'true');
-
return tutorialWorkflow;
};
diff --git a/packages/app/src/react/features/agents/hooks/useAgentsPageTutorial.ts b/packages/app/src/react/features/agents/hooks/useAgentsPageTutorial.ts
index af04f846..47a54d07 100644
--- a/packages/app/src/react/features/agents/hooks/useAgentsPageTutorial.ts
+++ b/packages/app/src/react/features/agents/hooks/useAgentsPageTutorial.ts
@@ -1,36 +1,34 @@
-import { useAuthCtx } from '@react/shared/contexts/auth.context';
+import { useGetUserSettings, useStoreUserSettings } from '@react/shared/hooks/useUserSettings';
import { Analytics } from '@src/shared/posthog/services/analytics';
-import { useEffect } from 'react';
+import { userSettingKeys } from '@src/shared/userSettingKeys';
+import { useEffect, useRef } from 'react';
type UseAgentsPageTutorialOptions = {
enabled?: boolean;
- storageKeyPrefix?: string;
maxAttempts?: number;
intervalMs?: number;
};
/**
* Triggers the in-app tutorial on the Agents page for first-time visitors.
- * Uses a per-user localStorage key to ensure it shows only once per user.
+ * Uses user settings to ensure it shows only once per user.
*/
export function useAgentsPageTutorial(options: UseAgentsPageTutorialOptions = {}): void {
const {
enabled = true,
- storageKeyPrefix = 'agents_page_tutorial_seen',
maxAttempts = 30, // ~9s total at 300ms
intervalMs = 300,
} = options;
- const { userInfo } = useAuthCtx();
+ const { data: tutorialSeen } = useGetUserSettings(userSettingKeys.SEEN_AGENTS_PAGE_TUTORIAL);
+ const storeUserSettings = useStoreUserSettings(userSettingKeys.SEEN_AGENTS_PAGE_TUTORIAL);
+ const hasStartedRef = useRef(false);
useEffect(() => {
if (!enabled) return;
- const userId = userInfo?.user?.id || 'anon';
- const storageKey = `${storageKeyPrefix}:${userId}`;
-
- const hasSeen = typeof window !== 'undefined' && localStorage.getItem(storageKey) === 'true';
- if (hasSeen) return;
+ // Check if user has already seen the tutorial or if tutorial has already been started
+ if (tutorialSeen === 'true' || hasStartedRef.current) return;
let attempts = 0;
@@ -45,6 +43,9 @@ export function useAgentsPageTutorial(options: UseAgentsPageTutorialOptions = {}
const startTutorial = () => {
try {
+ // Mark as started to prevent multiple triggers
+ hasStartedRef.current = true;
+
const TutorialCtor = (window as any).Tutorial as any;
if (!TutorialCtor) return;
@@ -58,8 +59,11 @@ export function useAgentsPageTutorial(options: UseAgentsPageTutorialOptions = {}
// Called when overlay is about to be cleared
Analytics.track('home_page_tutorial_completed', {
page_url: '/agents',
- source: 'Tutorial completed on home page onboarding'
+ source: 'Tutorial completed on home page onboarding',
});
+
+ // Mark tutorial as completed in user settings
+ storeUserSettings.mutate('true');
},
animate: true,
showButtons: true,
@@ -107,7 +111,6 @@ export function useAgentsPageTutorial(options: UseAgentsPageTutorialOptions = {}
]);
home_page_onboarding.start();
- localStorage.setItem(storageKey, 'true');
} catch {
// swallow errors to avoid blocking the page
}
@@ -126,7 +129,5 @@ export function useAgentsPageTutorial(options: UseAgentsPageTutorialOptions = {}
return () => {
if (interval) window.clearInterval(interval);
};
- }, [enabled, storageKeyPrefix, maxAttempts, intervalMs, userInfo?.user?.id]);
+ }, [enabled, maxAttempts, intervalMs, tutorialSeen, storeUserSettings]);
}
-
-
diff --git a/packages/app/src/shared/userSettingKeys.ts b/packages/app/src/shared/userSettingKeys.ts
index de1f8e51..6e968629 100644
--- a/packages/app/src/shared/userSettingKeys.ts
+++ b/packages/app/src/shared/userSettingKeys.ts
@@ -3,4 +3,5 @@ export const userSettingKeys = {
USER_TEAM: 'userTeam',
DEFAULT_ROLE: 'DEFAULT_ROLE',
SEEN_BUILDER_PAGE_TUTORIAL: 'SEEN_BUILDER_PAGE_TUTORIAL',
+ SEEN_AGENTS_PAGE_TUTORIAL: 'SEEN_AGENTS_PAGE_TUTORIAL',
};