Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(desktop): extract dev skip onboarding logic into a custom hook

Steven Enamakel02926c89440a
diff --git a/app/src/App.tsx b/app/src/App.tsx
index 138317345c..ee33842a23 100644
--- a/app/src/App.tsx
+++ b/app/src/App.tsx
@@ -31,6 +31,7 @@ import PersistRehydrationScreen from './components/PersistRehydrationScreen';
import PttHotkeyManager from './components/PttHotkeyManager';
import SecurityBanner from './components/SecurityBanner';
import AppWalkthrough from './components/walkthrough/AppWalkthrough';
+import { useDevSkipOnboarding } from './hooks/useDevSkipOnboarding';
import { useNotchBootSync } from './hooks/useNotchBootSync';
import { I18nProvider } from './lib/i18n/I18nContext';
import {
@@ -186,24 +187,12 @@ export function AppShellDesktop() {
!!snapshot.sessionToken &&
(DEV_FORCE_ONBOARDING || (!snapshot.onboardingCompleted && !DEV_SKIP_ONBOARDING));
- // Dev-only auto-skip (`VITE_DEV_SKIP_ONBOARDING`): record completion in the
- // core once per shell mount rather than just hiding the stepper, so state
- // that keys off the core flag agrees with what the UI shows.
- const devSkipRequestedRef = useRef(false);
- useEffect(() => {
- if (!DEV_SKIP_ONBOARDING || devSkipRequestedRef.current) return;
- if (isBootstrapping || !snapshot.sessionToken || snapshot.onboardingCompleted) return;
- devSkipRequestedRef.current = true;
- console.debug('[onboarding-gate] dev skip: marking onboarding complete');
- void setOnboardingCompletedFlag(true).catch(err =>
- console.warn('[onboarding-gate] dev skip: could not mark onboarding complete', err)
- );
- }, [
+ useDevSkipOnboarding({
isBootstrapping,
- snapshot.sessionToken,
- snapshot.onboardingCompleted,
+ sessionToken: snapshot.sessionToken,
+ onboardingCompleted: snapshot.onboardingCompleted,
setOnboardingCompletedFlag,
- ]);
+ });
// Onboarding gate: while `onboarding_completed=false`, force any non-
// onboarding route back to `/onboarding`. Once completed, bounce the
diff --git a/app/src/hooks/useDevSkipOnboarding.ts b/app/src/hooks/useDevSkipOnboarding.ts
new file mode 100644
index 0000000000..91f76cd44d
--- /dev/null
+++ b/app/src/hooks/useDevSkipOnboarding.ts
@@ -0,0 +1,32 @@
+import { useEffect, useRef } from 'react';
+
+import { DEV_SKIP_ONBOARDING } from '../utils/config';
+
+interface DevSkipOnboardingInput {
+ isBootstrapping: boolean;
+ sessionToken: string | null | undefined;
+ onboardingCompleted: boolean | undefined;
+ setOnboardingCompletedFlag: (value: boolean) => Promise<void>;
+}
+
+/**
+ * Dev-only auto-skip (`VITE_DEV_SKIP_ONBOARDING`, set by
+ * `scripts/run-dev-web.sh`): once a signed-in user's core reports onboarding
+ * incomplete, record completion in the core — once per mount — rather than
+ * only hiding the stepper, so state keyed off the core flag agrees with the UI.
+ */
+export function useDevSkipOnboarding(
+ { isBootstrapping, sessionToken, onboardingCompleted, setOnboardingCompletedFlag }: DevSkipOnboardingInput,
+ enabled: boolean = DEV_SKIP_ONBOARDING
+): void {
+ const requestedRef = useRef(false);
+ useEffect(() => {
+ if (!enabled || requestedRef.current) return;
+ if (isBootstrapping || !sessionToken || onboardingCompleted) return;
+ requestedRef.current = true;
+ console.debug('[onboarding-gate] dev skip: marking onboarding complete');
+ void setOnboardingCompletedFlag(true).catch(err =>
+ console.warn('[onboarding-gate] dev skip: could not mark onboarding complete', err)
+ );
+ }, [enabled, isBootstrapping, sessionToken, onboardingCompleted, setOnboardingCompletedFlag]);
+}