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.

Add tutorial hook for Agents page to guide first-time users

Muhammad Hamza Khan21c155499c3d
diff --git a/packages/app/src/react/features/agents/hooks/useAgentsPageTutorial.ts b/packages/app/src/react/features/agents/hooks/useAgentsPageTutorial.ts
new file mode 100644
index 00000000..1d14805d
--- /dev/null
+++ b/packages/app/src/react/features/agents/hooks/useAgentsPageTutorial.ts
@@ -0,0 +1,124 @@
+import { useAuthCtx } from '@react/shared/contexts/auth.context';
+import { useEffect } 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.
+ */
+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();
+
+ 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;
+
+ let attempts = 0;
+
+ const isReady = () => {
+ const TutorialCtor = (window as any)?.Tutorial;
+ if (!TutorialCtor) return false;
+ const main = document.querySelector('main');
+ const sidebar = document.querySelector('div[data-qa="navigation-sidebar"]');
+ const createBtn = document.querySelector('button[data-qa="create-agent-button"]');
+ return Boolean(main && sidebar && createBtn);
+ };
+
+ const startTutorial = () => {
+ try {
+ const TutorialCtor = (window as any).Tutorial as any;
+ if (!TutorialCtor) return;
+
+ const home_page_onboarding = new TutorialCtor({
+ onPopoverRender: (popoverElements: any) => {
+ setTimeout(() => {
+ popoverElements.popoverTitle.innerText = `${popoverElements.popoverTitle.innerText} (${home_page_onboarding.currentStep + 1}/${home_page_onboarding.getSteps().length})`;
+ }, 0);
+ },
+ animate: true,
+ showButtons: true,
+ nextBtnText: 'Next',
+ prevBtnText: 'Previous',
+ closeBtnText: 'Close',
+ padding: 10,
+ overlayOpacity: 0.7,
+ });
+
+ home_page_onboarding.defineSteps([
+ {
+ element: 'main',
+ popover: {
+ title: '<strong>Welcome to SmythOS</strong>',
+ description:
+ 'This is your team dashboard where you can manage AI agents, access templates, and organize your work.',
+ position: 'center',
+ align: 'center',
+ highlight: true,
+ },
+ },
+ {
+ element: 'div[data-qa="navigation-sidebar"]',
+ popover: {
+ title: '<strong>Main Navigation</strong>',
+ description:
+ 'Use this sidebar to navigate between different sections of SmythOS including Home, Templates, Data Pool, Analytics, Vault, and more.',
+ position: 'right',
+ align: 'start',
+ highlight: true,
+ },
+ },
+ {
+ element: 'button[data-qa="create-agent-button"]',
+ popover: {
+ title: '<strong>Create New Agent</strong>',
+ description:
+ 'Click here to start building a new AI agent from scratch using our visual workflow builder.',
+ position: 'bottom',
+ align: 'center',
+ highlight: true,
+ },
+ },
+ ]);
+
+ home_page_onboarding.start();
+ localStorage.setItem(storageKey, 'true');
+ } catch {
+ // swallow errors to avoid blocking the page
+ }
+ };
+
+ const interval = window.setInterval(() => {
+ attempts += 1;
+ if (isReady()) {
+ window.clearInterval(interval);
+ startTutorial();
+ } else if (attempts >= maxAttempts) {
+ window.clearInterval(interval);
+ }
+ }, intervalMs);
+
+ return () => {
+ if (interval) window.clearInterval(interval);
+ };
+ }, [enabled, storageKeyPrefix, maxAttempts, intervalMs, userInfo?.user?.id]);
+}
+
+
diff --git a/packages/app/src/react/features/agents/pages/AgentsPage.tsx b/packages/app/src/react/features/agents/pages/AgentsPage.tsx
index b90b1f66..92847939 100644
--- a/packages/app/src/react/features/agents/pages/AgentsPage.tsx
+++ b/packages/app/src/react/features/agents/pages/AgentsPage.tsx
@@ -7,6 +7,7 @@ import {
import ModelAgentsSection from '@react/features/agents/components/model-agents-section';
import { useOnboarding } from '@react/features/agents/contexts/OnboardingContext';
import { useAgentsData } from '@react/features/agents/hooks/useAgentsData';
+import { useAgentsPageTutorial } from '@react/features/agents/hooks/useAgentsPageTutorial';
import {
Learn,
OnboardingTasks,
@@ -80,6 +81,9 @@ function AgentsPage() {
},
});
+ // Trigger first-visit tutorial
+ useAgentsPageTutorial();
+
// Templates processing
useEffect(() => {
if (!!templatesData && !!userSettings) {