The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): first-run surfaces wait on onboarding presence, not the guided gate
alt-glitch1197e43d0126
diff --git a/apps/desktop/src/app/contrib/hooks/desktop-onboarding-metrics.ts b/apps/desktop/src/app/contrib/hooks/desktop-onboarding-metrics.tsindex 3117c6a1afc..8fbbe568cd8 100644--- a/apps/desktop/src/app/contrib/hooks/desktop-onboarding-metrics.ts+++ b/apps/desktop/src/app/contrib/hooks/desktop-onboarding-metrics.ts@@ -1,7 +1,7 @@/*** First-run funnel telemetry (hermes.desktop.onboarding). Observes the- * onboarding stores' own transitions — the provider picker, the guided intro,- * free-tier sign-in — and maps them onto the closed step set; nothing here+ * onboarding stores' own transitions — the provider picker, first-run+ * onboarding, free-tier sign-in — and maps them onto the closed step set; nothing here* changes onboarding behavior. Manual (Settings "add provider") flows are not* first run and are ignored.*/@@ -9,7 +9,7 @@import { closeOnboardingStep, recordDislike, recordOnboarding } from '@/store/desktop-metrics'import { $freeTierSignIn, type FreeTierSignInState } from '@/store/free-tier-sign-in'import { $desktopOnboarding, type DesktopOnboardingState } from '@/store/onboarding'-import { $onboardingGate, type OnboardingPhase } from '@/store/onboarding-gate'+import { $onboardingPhase, type OnboardingPhase } from '@/store/onboarding-phase'const OAUTH_PENDING = new Set(['awaiting_user', 'error', 'external_pending', 'polling', 'starting', 'submitting'])@@ -85,18 +85,21 @@ export function onboardingTransition(prev: DesktopOnboardingState, next: Desktop}}+/** D10: `guide` is reached when onboarding shows and completed when it finishes. */export function guidePhaseTransition(prev: OnboardingPhase, next: OnboardingPhase): void {if (prev === next) {return}- if (next === 'guided') {+ if (next === 'shown') {recordOnboarding('guide', 'reached')} else if (next === 'skipped') {recordOnboarding('guide_skip', 'completed')closeOnboardingStep('guide')} else if (next === 'done') {recordOnboarding('guide', 'completed')+ } else if (next === 'failed') {+ closeOnboardingStep('guide')}}@@ -124,7 +127,7 @@ export function signInTransition(prev: FreeTierSignInState, next: FreeTierSignIn/** Subscribe the three first-run stores; returns the unsubscribe. */export function observeOnboardingMetrics(): () => void {let onboarding = $desktopOnboarding.get()- let phase = $onboardingGate.get().phase+ let phase = $onboardingPhase.get()let signIn = $freeTierSignIn.get()const stops = [@@ -134,11 +137,11 @@ export function observeOnboardingMetrics(): () => void {onboarding = nextonboardingTransition(prev, next)}),- $onboardingGate.listen(next => {+ $onboardingPhase.listen(next => {const prev = phase- phase = next.phase- guidePhaseTransition(prev, next.phase)+ phase = next+ guidePhaseTransition(prev, next)}),$freeTierSignIn.listen(next => {const prev = signIndiff --git a/apps/desktop/src/app/contrib/surfaces.tsx b/apps/desktop/src/app/contrib/surfaces.tsxindex ed2258a7f30..e96c7435838 100644--- a/apps/desktop/src/app/contrib/surfaces.tsx+++ b/apps/desktop/src/app/contrib/surfaces.tsx@@ -15,8 +15,6 @@ import { ContribBoundary, ContribRender } from '@/contrib/react/boundary'import { useContributions } from '@/contrib/react/use-contributions'import { $activeConnectionId } from '@/store/connections'import { $gateway } from '@/store/gateway'-import { $guideOpening } from '@/store/onboarding-gate'-import { $chatOnboardingSolo } from '@/store/onboarding-intro'import { $activeGatewayProfile } from '@/store/profile'import { $freshDraftReady, $gatewayState } from '@/store/session'@@ -84,8 +82,6 @@ export const StatusbarSurface = memo(function StatusbarSurface({const activeConnectionId = useStore($activeConnectionId)const activeGatewayProfile = useStore($activeGatewayProfile)const gatewayState = useStore($gatewayState)- const guideOpening = useStore($guideOpening)- const demoLayout = useStore($chatOnboardingSolo)const freshDraftReady = useStore($freshDraftReady)const gatewayScope = `${activeConnectionId ?? ''}\0${activeGatewayProfile}`const { inferenceStatus, statusSnapshot } = useStatusSnapshot(gatewayState, actions.requestGateway, gatewayScope)@@ -109,8 +105,7 @@ export const StatusbarSurface = memo(function StatusbarSurface({toggleCommandCenter: actions.toggleCommandCenter})- // The demo layout (first-run intro) has no status bar.- return guideOpening || demoLayout ? null : <StatusbarControls items={statusbarItems} leftItems={leftStatusbarItems} />+ return <StatusbarControls items={statusbarItems} leftItems={leftStatusbarItems} />})/** The workspace pane: the real route table (chat + full-page views + plugindiff --git a/apps/desktop/src/app/contrib/wiring.tsx b/apps/desktop/src/app/contrib/wiring.tsxindex 9f5655f491f..0178e7ad70e 100644--- a/apps/desktop/src/app/contrib/wiring.tsx+++ b/apps/desktop/src/app/contrib/wiring.tsx@@ -23,7 +23,6 @@ import { FreeTierSignInDialog } from '@/components/free-tier/sign-in-dialog'import { GatewayConnectingOverlay } from '@/components/gateway-connecting-overlay'import { NotificationStack } from '@/components/notifications'import { DesktopOnboardingOverlay } from '@/components/onboarding'-import { OnboardingChatGate } from '@/components/onboarding-chat/gate'import { $newSessionTabAction, registerPaneCloser } from '@/components/pane-shell/tree/store'import {$workspaceMode,@@ -52,6 +51,7 @@ import { reconnectGateway } from '@/store/gateway-reconnect'import { $interfaceMode, shownInMode } from '@/store/interface-mode'import { $pinnedSessionIds, pinSession, restoreWorktree, unpinSession } from '@/store/layout'import { notifyError } from '@/store/notifications'+import { markOnboardingDecided } from '@/store/onboarding-presence'import { $poolLimitsSettingsRequest } from '@/store/pool-limits'import { $previewTarget } from '@/store/preview'import {@@ -90,7 +90,7 @@ import { reportPendingUpdateRun } from '@/store/shared-metrics'import { $archivedSessions } from '@/store/sidebar-archive'import { $titlebarAppActionsSide, titlebarAppActionsClusterCounts } from '@/store/titlebar-app-actions'import { armWakeWord, stopClientCapture } from '@/store/wake-word'-import { isAuxiliaryWindow, isBrowserWindow, isHudWindow, isMainWindow } from '@/store/windows'+import { isAuxiliaryWindow, isBrowserWindow, isHudWindow } from '@/store/windows'import { useSkinCommand } from '@/themes/use-skin-command'import type { SessionInfo } from '@/types/hermes'@@ -166,7 +166,6 @@ import { usePetBridge } from './hooks/use-pet-bridge'import { useQuickEntryBridge } from './hooks/use-quick-entry-bridge'import { useSessionTileDelegate } from './hooks/use-session-tile-delegate'import { McpInstallDeepLinkDialog } from './mcp-install-deeplink-dialog'-import { type KickoffSlashCommand, useOnboardingKickoff } from './onboarding-kickoff'import { useTitlebarToolContributions } from './panes'import { type AmbientGatewayRequest, createSessionRpcDispatcher } from './session-rpc-dispatcher'import { ChatRoutesSurface, SidebarSurface, StatusbarSurface, TerminalSurface } from './surfaces'@@ -599,24 +598,8 @@ export function ContribWiring({ children }: { children: ReactNode }) {}}, [startSessionInWorkspace, startWorkSessionRequest])- const adoptSessionRoute = useCallback(- async (storedSessionId: string) => {- creatingSessionRef.current = true-- try {- await resumeSession(storedSessionId, true)-- if ($selectedStoredSessionId.get() === storedSessionId) {- navigate(sessionRoute(storedSessionId), { replace: true })- }- } finally {- window.setTimeout(() => {- creatingSessionRef.current = false- }, 0)- }- },- [navigate, resumeSession]- )+ // Nothing decides whether first-run onboarding runs yet, so first-run surfaces are free at boot.+ useEffect(() => markOnboardingDecided(), [])// "New project" DRAG completion: the dialog created a project that was// dropped onto a chat zone (tab-strip slot / pane edge / pane center). Open@@ -692,17 +675,6 @@ export function ContribWiring({ children }: { children: ReactNode }) {updateSessionState})- const runKickoffSlash = useCallback<KickoffSlashCommand>(- (command, options) => executeSlashCommand(command, { ...options, typed: false }),- [executeSlashCommand]- )-- const kickoffFirstChat = useOnboardingKickoff({- requestGateway: ambientRequestGateway,- resumeSession: adoptSessionRoute,- runSlashCommand: runKickoffSlash- })-// Runs outside the selected ChatBar so queues belonging to background// sessions continue once those sessions are idle. The session dispatcher// routes each send to its owner; a disconnected foreground is not a global gate.@@ -1282,14 +1254,6 @@ export function ContribWiring({ children }: { children: ReactNode }) {{/* The full real overlay set (mirrors DesktopController's `overlays`). */}<RemoteDisplayBanner />{!isAuxiliaryWindow() && <DesktopInstallOverlay />}- {!isAuxiliaryWindow() && (- <OnboardingChatGate- enabled={gatewayState === 'open'}- onKickoff={kickoffFirstChat}- requestGateway={ambientRequestGateway}- runsIntro={isMainWindow()}- />- )}{!isAuxiliaryWindow() && (<DesktopOnboardingOverlayenabled={gatewayState === 'open'}diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/credential-warning-onboarding.test.ts b/apps/desktop/src/app/session/hooks/use-session-actions/credential-warning-onboarding.test.tsnew file mode 100644index 00000000000..fce168cec89--- /dev/null+++ b/apps/desktop/src/app/session/hooks/use-session-actions/credential-warning-onboarding.test.ts@@ -0,0 +1,30 @@+import { afterEach, beforeEach, describe, expect, it } from 'vitest'++import { $desktopOnboarding, consumePendingCredentialWarning } from '@/store/onboarding'+import { setOnboardingSurfaceActive } from '@/store/onboarding-presence'++import { applyRuntimeInfo } from './utils'++const initialOnboardingState = $desktopOnboarding.get()++describe('applyRuntimeInfo credential warning while onboarding is open', () => {+ beforeEach(() => {+ consumePendingCredentialWarning()+ $desktopOnboarding.set({ ...initialOnboardingState, reason: null, requested: false })+ })++ afterEach(() => {+ setOnboardingSurfaceActive('onboarding', false)+ consumePendingCredentialWarning()+ $desktopOnboarding.set(initialOnboardingState)+ })++ it('drops the warning: onboarding owns the first run', () => {+ setOnboardingSurfaceActive('onboarding', true)+ applyRuntimeInfo({+ credential_warning: "No API key configured for provider 'openrouter'. First message will fail."+ })++ expect(consumePendingCredentialWarning()).toBeNull()+ })+})diff --git a/apps/desktop/src/app/settings/config-settings.tsx b/apps/desktop/src/app/settings/config-settings.tsxindex 34e05aca3c4..a35a087650d 100644--- a/apps/desktop/src/app/settings/config-settings.tsx+++ b/apps/desktop/src/app/settings/config-settings.tsx@@ -37,7 +37,6 @@ import { PanelEmpty } from '../overlays/panel'import { ConfigField } from './config-field'import { configSubpageForField } from './config-subpages'-import { DeveloperSettings } from './developer-settings'import {clearsEnabledToolsets,diffConfig,@@ -486,7 +485,6 @@ function ConfigSettingsInner({/><PoolLimitsSetting /><QuickEntrySettings />- <DeveloperSettings /></>)}{/* Device-local attach/preview byte cap (main-process IPC guard). Chat isdiff --git a/apps/desktop/src/app/settings/developer-settings.tsx b/apps/desktop/src/app/settings/developer-settings.tsxdeleted file mode 100644index 97167aea042..00000000000--- a/apps/desktop/src/app/settings/developer-settings.tsx+++ /dev/null@@ -1,50 +0,0 @@-import { useState } from 'react'--import { useGatewayRequest } from '@/app/gateway/hooks/use-gateway-request'-import { Button } from '@/components/ui/button'-import { useI18n } from '@/i18n'-import { Wrench } from '@/lib/icons'-import { isOnboardingEnabled } from '@/lib/onboarding-enabled'-import { notifyError } from '@/store/notifications'-import { resetOnboarding } from '@/store/onboarding-gate'--import { ListRow, SettingsSection } from './primitives'--/** Advanced → Developer. Only builds with the guided first run have anything here. */-export function DeveloperSettings() {- const { t } = useI18n()- const c = t.settings.config- const [resetting, setResetting] = useState(false)- const { requestGateway } = useGatewayRequest()-- if (!isOnboardingEnabled()) {- return null- }-- const reset = async () => {- setResetting(true)-- try {- await resetOnboarding(requestGateway)- // A fresh window runs the first run from zero, starting screen included.- window.location.reload()- } catch (error) {- notifyError(error, c.resetOnboardingFailed)- setResetting(false)- }- }-- return (- <SettingsSection icon={Wrench} title={c.developerTitle}>- <ListRow- action={- <Button disabled={resetting} onClick={() => void reset()} size="sm" variant="outline">- {c.resetOnboardingAction}- </Button>- }- description={c.resetOnboardingDesc}- title={c.resetOnboardingTitle}- />- </SettingsSection>- )-}diff --git a/apps/desktop/src/app/shell/hooks/use-statusbar-items.test.tsx b/apps/desktop/src/app/shell/hooks/use-statusbar-items.test.tsxindex 429df95a7af..c094fb8fdd6 100644--- a/apps/desktop/src/app/shell/hooks/use-statusbar-items.test.tsx+++ b/apps/desktop/src/app/shell/hooks/use-statusbar-items.test.tsx@@ -2,7 +2,7 @@ import { act, renderHook } from '@testing-library/react'import type { WritableAtom } from 'nanostores'import { isValidElement, type ReactNode } from 'react'import { MemoryRouter } from 'react-router'-import { afterEach, describe, expect, it, vi } from 'vitest'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { group } from '@/components/pane-shell/tree/model'import { $layoutTree, noteActiveTreeGroup } from '@/components/pane-shell/tree/store'@@ -11,7 +11,7 @@ import { createClientSessionState } from '@/lib/chat-runtime'import type * as DesktopFs from '@/lib/desktop-fs'import { $freeTierStatus } from '@/store/free-tier'import { INTERFACE_MODES, setInterfaceMode } from '@/store/interface-mode'-import { $onboardingGate } from '@/store/onboarding-gate'+import { markOnboardingDecided, setOnboardingSurfaceActive } from '@/store/onboarding-presence'import {$connection,$currentCwd,@@ -399,8 +399,6 @@ describe('free-tier Sign in in every interface mode', () => {notice_pending: false})- const desktopBridge = window.hermesDesktop-function signInChipVisible(): boolean {const { leftStatusbarItems, statusbarItems } = renderStatusbarItems()const chip = [...leftStatusbarItems, ...statusbarItems].find(item => item.id === 'free-tier')@@ -408,10 +406,11 @@ describe('free-tier Sign in in every interface mode', () => {return $statusbarVisible.get() && chip !== undefined && !chip.hidden}+ beforeEach(() => markOnboardingDecided())+afterEach(() => {$freeTierStatus.set(null)- $onboardingGate.set({ ...$onboardingGate.get(), phase: 'idle' })- window.hermesDesktop = desktopBridge+ setOnboardingSurfaceActive('onboarding', false)setInterfaceMode('advanced')})@@ -431,13 +430,12 @@ describe('free-tier Sign in in every interface mode', () => {expect($statusbarVisible.get()).toBe(false)})- it('holds the chip while a guided setup is running and brings it back after', () => {- window.hermesDesktop = { ...desktopBridge, guestOnboardingEnabled: true } as typeof desktopBridge+ it('holds the chip while onboarding is open and brings it back after', () => {$freeTierStatus.set(freeTier(true))- $onboardingGate.set({ ...$onboardingGate.get(), phase: 'guided' })+ setOnboardingSurfaceActive('onboarding', true)expect(signInChipVisible()).toBe(false)- $onboardingGate.set({ ...$onboardingGate.get(), phase: 'done' })+ setOnboardingSurfaceActive('onboarding', false)expect(signInChipVisible()).toBe(true)})})diff --git a/apps/desktop/src/components/free-tier/sign-in-dialog.test.tsx b/apps/desktop/src/components/free-tier/sign-in-dialog.test.tsxindex e171cd88d47..009a4562b97 100644--- a/apps/desktop/src/components/free-tier/sign-in-dialog.test.tsx+++ b/apps/desktop/src/components/free-tier/sign-in-dialog.test.tsx@@ -5,7 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import type * as HermesApi from '@/hermes'import { $freeTierStatus } from '@/store/free-tier'import { $freeTierSignIn, noteFreeTierTurnComplete, openFreeTierSignIn } from '@/store/free-tier-sign-in'-import { $onboardingGate } from '@/store/onboarding-gate'+import { markOnboardingDecided, setOnboardingSurfaceActive } from '@/store/onboarding-presence'import type { FreeTierStatus } from '@/types/hermes'const pollOAuthSession = vi.fn()@@ -36,14 +36,14 @@ vi.mock('@/app/gateway/hooks/use-gateway-request', () => ({beforeEach(() => {vi.spyOn(window, 'open').mockReturnValue(null)+ markOnboardingDecided()})afterEach(() => {cleanup()$freeTierSignIn.set({ status: 'closed' })$freeTierStatus.set(null)- $onboardingGate.set({ guideKickoff: 'idle', guideQueued: false, phase: 'idle' })- Reflect.deleteProperty(window, 'hermesDesktop')+ setOnboardingSurfaceActive('onboarding', false)vi.restoreAllMocks()vi.clearAllMocks()vi.useRealTimers()@@ -106,9 +106,8 @@ describe('FreeTierSignInDialog', () => {)})- it('waits for guided onboarding to leave the screen, then offers sign-in', async () => {- Object.assign(window, { hermesDesktop: { guestOnboardingEnabled: true } })- $onboardingGate.set({ guideKickoff: 'started', guideQueued: false, phase: 'guided' })+ it('waits for onboarding to leave the screen, then offers sign-in', async () => {+ setOnboardingSurfaceActive('onboarding', true)await renderDialog()await act(async () => {@@ -118,7 +117,7 @@ describe('FreeTierSignInDialog', () => {expect(requestGateway).not.toHaveBeenCalledWith('free_tier.claim_nudge')await act(async () => {- $onboardingGate.set({ guideKickoff: 'started', guideQueued: false, phase: 'done' })+ setOnboardingSurfaceActive('onboarding', false)})await waitFor(() => expect(screen.getByText('Keep going with Hermes')).toBeTruthy())diff --git a/apps/desktop/src/components/free-tier/sign-in-dialog.tsx b/apps/desktop/src/components/free-tier/sign-in-dialog.tsxindex 288f4ade819..2e0b19a1889 100644--- a/apps/desktop/src/components/free-tier/sign-in-dialog.tsx+++ b/apps/desktop/src/components/free-tier/sign-in-dialog.tsx@@ -41,8 +41,7 @@ import {syncFreeTierOffer} from '@/store/free-tier-sign-in'import { refreshOnboardingProviders } from '@/store/onboarding'-import { $onboardingGate } from '@/store/onboarding-gate'-import { $onboardingSurfaces } from '@/store/onboarding-presence'+import { $onboardingSurfaceClear } from '@/store/onboarding-presence'import { $currentModel, setModelPickerOpen } from '@/store/session'interface FreeTierSignInDialogProps {@@ -84,7 +83,7 @@ export function FreeTierSignInDialog({ onSelectModel }: FreeTierSignInDialogProp}}, [owned, requestGateway, state.status])- // The sign-in offer rides every status read, and retries once guided+ // The sign-in offer rides every status read, and retries once the first-run// onboarding leaves the screen. A completed free-tier turn re-reads the// status, since that is when the backend arms the next offer. Only the// owner (main windows) times it.@@ -97,8 +96,7 @@ export function FreeTierSignInDialog({ onSelectModel }: FreeTierSignInDialogPropconst stops = [$freeTierStatus.listen(sync),- $onboardingGate.listen(sync),- $onboardingSurfaces.listen(sync),+ $onboardingSurfaceClear.listen(sync),$freeTierTurnCompleted.listen(() => void refreshFreeTierStatus(requestGateway, sameGatewayRoute()))]diff --git a/apps/desktop/src/components/gateway-connecting-overlay.tsx b/apps/desktop/src/components/gateway-connecting-overlay.tsxindex 255f178c87c..b43e18c78f8 100644--- a/apps/desktop/src/components/gateway-connecting-overlay.tsx+++ b/apps/desktop/src/components/gateway-connecting-overlay.tsx@@ -2,16 +2,12 @@ import type { ConnectionState } from '@hermes/shared'import { useStore } from '@nanostores/react'import { useEffect, useRef, useState } from 'react'-import { Button } from '@/components/ui/button'import { DecodeText } from '@/components/ui/decode-text'import { prefersReducedMotion } from '@/hooks/use-media-query'-import { useI18n } from '@/i18n'-import { isOnboardingEnabled } from '@/lib/onboarding-enabled'import { cn } from '@/lib/utils'import { $desktopBoot, type DesktopBootState } from '@/store/boot'import { $gatewaySwitching } from '@/store/gateway-switch'-import { $onboardingStateRead } from '@/store/onboarding-gate'-import { $introStartExit, $introView } from '@/store/onboarding-intro'+import { $onboardingDecided, ONBOARDING_DECIDE_DEADLINE_MS } from '@/store/onboarding-presence'import { $gatewayState } from '@/store/session'import { isMainWindow } from '@/store/windows'@@ -61,26 +57,10 @@ function isInitialConnect(interface ConnectingOverlayViewProps {decoding: boolean- onExit: (() => void) | nullphase: Phase}-/** The first-run start outlasted the boot budget: it keeps waiting, and the person may go on without setup. */-function SlowSetupStart({ onExit }: { onExit: () => void }) {- const { t } = useI18n()-- return (- <div className="grid max-w-xs justify-items-center gap-3 text-center" role="status">- <div className="text-sm font-medium text-foreground">{t.onboarding.setupSlowTitle}</div>- <div className="text-xs text-muted-foreground">{t.onboarding.setupSlowBody}</div>- <Button onClick={onExit} size="sm" type="button" variant="secondary">- {t.onboarding.continueWithoutSetup}- </Button>- </div>- )-}--function ConnectingOverlayView({ decoding, onExit, phase }: ConnectingOverlayViewProps) {+function ConnectingOverlayView({ decoding, phase }: ConnectingOverlayViewProps) {const leaving = phase !== 'live'const overlayHidden = phase === 'overlay-out' || phase === 'gone'@@ -95,21 +75,17 @@ function ConnectingOverlayView({ decoding, onExit, phase }: ConnectingOverlayVie// in styles.css.data-glass-opaque="">- {onExit ? (- <SlowSetupStart onExit={onExit} />- ) : (- <DecodeText- active={decoding}- className={cn(- 'pl-[0.4em] text-(--theme-primary) transition duration-300 ease-out',- leaving ? 'translate-y-2 opacity-0 saturate-0' : 'translate-y-0 opacity-100 saturate-100'- )}- cursor- loop- prefix={4}- text={TEXT}- />- )}+ <DecodeText+ active={decoding}+ className={cn(+ 'pl-[0.4em] text-(--theme-primary) transition duration-300 ease-out',+ leaving ? 'translate-y-2 opacity-0 saturate-0' : 'translate-y-0 opacity-100 saturate-100'+ )}+ cursor+ loop+ prefix={4}+ text={TEXT}+ /></div>)}@@ -118,9 +94,8 @@ export function GatewayConnectingOverlay() {const gatewayState = useStore($gatewayState)const boot = useStore($desktopBoot)const gatewaySwitching = useStore($gatewaySwitching)- const onboardingStateRead = useStore($onboardingStateRead)- const introView = useStore($introView)- const introStartExit = useStore($introStartExit)+ const onboardingDecided = useStore($onboardingDecided)+ const [decideExpired, setDecideExpired] = useState(false)const [previewing] = useState(forcedPreview)const reduce = prefersReducedMotion()// Under reduced motion, skip the multi-phase exit choreography (text-out →@@ -147,10 +122,19 @@ export function GatewayConnectingOverlay() {shownRef.current = true}- // The first-run intro's `starting` screen is this overlay: it stays up until the backend says- // whether the intro runs and, if it does, until the setup chat is open.- const introHolds =- !previewing && isMainWindow() && isOnboardingEnabled() && (!onboardingStateRead || introView === 'starting')+ // Held until the app knows whether onboarding runs, so the chat never flashes before it.+ // A short deadline, never the free account: onboarding does not wait for the mint.+ const onboardingHolds = !previewing && isMainWindow() && !onboardingDecided && !decideExpired++ useEffect(() => {+ if (gatewayState !== 'open' || onboardingDecided) {+ return+ }++ const id = window.setTimeout(() => setDecideExpired(true), ONBOARDING_DECIDE_DEADLINE_MS)++ return () => window.clearTimeout(id)+ }, [gatewayState, onboardingDecided])// Kick off the exit when connected: real connect, or a faked timer in preview.useEffect(() => {@@ -164,14 +148,14 @@ export function GatewayConnectingOverlay() {return () => window.clearTimeout(id)}- if (gatewayState === 'open' && shownRef.current && !introHolds) {+ if (gatewayState === 'open' && shownRef.current && !onboardingHolds) {// Under reduced motion, skip the multi-phase exit choreography// (text-out → hold → overlay fade) and jump straight to gone so the// overlay unmounts the instant the gateway opens. E2E screenshots// rely on this to avoid catching the overlay mid-fade.setPhase(reduce ? 'gone' : 'text-out')}- }, [phase, previewing, gatewayState, introHolds, reduce])+ }, [phase, previewing, gatewayState, onboardingHolds, reduce])// Advance the exit choreography: text-out -> overlay-out -> gone.useEffect(() => {@@ -213,7 +197,6 @@ export function GatewayConnectingOverlay() {return (<ConnectingOverlayViewdecoding={phase === 'live' && (previewing || connecting)}- onExit={introHolds ? introStartExit : null}phase={phase}/>)diff --git a/apps/desktop/src/components/shared-metrics/consent-dialog.test.tsx b/apps/desktop/src/components/shared-metrics/consent-dialog.test.tsxindex 66542a23520..bee7669e932 100644--- a/apps/desktop/src/components/shared-metrics/consent-dialog.test.tsx+++ b/apps/desktop/src/components/shared-metrics/consent-dialog.test.tsx@@ -3,6 +3,7 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest'import { en } from '@/i18n/en'import { $desktopOnboarding } from '@/store/onboarding'+import { markOnboardingDecided } from '@/store/onboarding-presence'import {$sharedMetricsConsent,$sharedMetricsDetailsOpen,@@ -12,6 +13,9 @@ import {import { SharedMetricsConsentDialog } from './consent-dialog'+// Onboarding's due check answered "not due": first-run surfaces are free to show.+markOnboardingDecided()+const copy = en.sharedMetricsfunction backend(initial: SharedMetricsConsent) {diff --git a/apps/desktop/src/components/shared-metrics/consent-dialog.tsx b/apps/desktop/src/components/shared-metrics/consent-dialog.tsxindex eeba992bd5f..6c0f98f599d 100644--- a/apps/desktop/src/components/shared-metrics/consent-dialog.tsx+++ b/apps/desktop/src/components/shared-metrics/consent-dialog.tsx@@ -17,9 +17,7 @@ import { $tourActive } from '@/lib/tour/tour-active'import { cn } from '@/lib/utils'import { notifyError } from '@/store/notifications'import { $desktopOnboarding } from '@/store/onboarding'-import { $guidedOnboardingSettled, $setupProfileName } from '@/store/onboarding-gate'-import { $onboardingSurfaces } from '@/store/onboarding-presence'-import { normalizeProfileKey } from '@/store/profile'+import { $onboardingSurfaceClear } from '@/store/onboarding-presence'import {$sharedMetricsConsent,$sharedMetricsDetailsOpen,@@ -57,10 +55,8 @@ export function SharedMetricsConsentDialog({ enabled, profile, requestGateway }:const { t } = useI18n()const copy = t.sharedMetricsconst onboarding = useStore($desktopOnboarding)- const surfaces = useStore($onboardingSurfaces)- const guidedSettled = useStore($guidedOnboardingSettled)+ const surfaceClear = useStore($onboardingSurfaceClear)const tourActive = useStore($tourActive)- const setupProfile = useStore($setupProfileName)const detailsId = useId()const consent = useStore($sharedMetricsConsent)const detailsOpen = useStore($sharedMetricsDetailsOpen)@@ -69,20 +65,16 @@ export function SharedMetricsConsentDialog({ enabled, profile, requestGateway }:const scopedRequest = useMemo(() => sharedMetricsProfileRequester(requestGateway, profile), [profile, requestGateway])- // Never over the provider picker, the free-tier welcome, the guided chat or a tour on screen:+ // Never over the provider picker, the free-tier welcome, onboarding or a tour on screen:// the question belongs to the moment after setup.const onboardingSettled =(onboarding.configured === true || onboarding.firstRunSkipped) &&!onboarding.manual &&!onboarding.freeTierReady &&- surfaces.size === 0 &&- guidedSettled &&+ surfaceClear &&!tourActive- // The setup profile only hosts the welcome chat; its answer would count for nobody.- const inSetupProfile = setupProfile !== null && normalizeProfileKey(setupProfile) === normalizeProfileKey(profile)-- const ready = enabled && onboardingSettled && !inSetupProfile+ const ready = enabled && onboardingSettleduseEffect(() => {$sharedMetricsConsent.set(null)diff --git a/apps/desktop/src/components/tips/use-tip-rotation.test.tsx b/apps/desktop/src/components/tips/use-tip-rotation.test.tsxindex 906e90e9093..505769755c2 100644--- a/apps/desktop/src/components/tips/use-tip-rotation.test.tsx+++ b/apps/desktop/src/components/tips/use-tip-rotation.test.tsx@@ -4,11 +4,15 @@ import { afterEach, beforeEach, expect, it, vi } from 'vitest'import { en } from '@/i18n/en'import { $localModelsEnabled } from '@/store/local-models-flag'+import { markOnboardingDecided } from '@/store/onboarding-presence'import { $awaitingResponse, $busy, $connection } from '@/store/session'import { $activeTip, $nextTipAt, $retiredTips, $tipsEnabled, $tipShownAt } from '@/store/tips'import { useTipRotation } from './use-tip-rotation'+// Onboarding's due check answered "not due": first-run surfaces are free to show.+markOnboardingDecided()+vi.mock('@/store/tutorial-lifetime', () => ({ checkTutorialLifetime: vi.fn() }))const reply = async (request: { path: string }) =>diff --git a/apps/desktop/src/components/tips/use-tip-rotation.ts b/apps/desktop/src/components/tips/use-tip-rotation.tsindex 2cba843488c..4fac3ceef43 100644--- a/apps/desktop/src/components/tips/use-tip-rotation.ts+++ b/apps/desktop/src/components/tips/use-tip-rotation.ts@@ -56,7 +56,7 @@ function appIsQuiet(lastTypedAt: number): boolean {return false}- // The first-run intro is never a quiet moment.+ // First-run onboarding is never a quiet moment.if ($busy.get() || $awaitingResponse.get() || onboardingSurfaceActive()) {return false}diff --git a/apps/desktop/src/store/free-tier-offer.test.ts b/apps/desktop/src/store/free-tier-offer.test.tsindex 613a3f28318..3e8a6f8aba6 100644--- a/apps/desktop/src/store/free-tier-offer.test.ts+++ b/apps/desktop/src/store/free-tier-offer.test.ts@@ -3,7 +3,11 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { $freeTierStatus, type FreeTierRequester } from '@/store/free-tier'import { $freeTierSignIn, closeFreeTierSignIn, stopFreeTierOffer, syncFreeTierOffer } from '@/store/free-tier-sign-in'import { activeGatewayProfileKey, ensureGatewayForProfile } from '@/store/gateway'-import { $onboardingGate } from '@/store/onboarding-gate'+import {+ $onboardingDecided,+ markOnboardingDecided,+ setOnboardingSurfaceActive+} from '@/store/onboarding-presence'import type { FreeTierStatus } from '@/types/hermes'const status = (nudge_due_in: null | number, available = true): FreeTierStatus => ({@@ -52,6 +56,8 @@ function own(requestGateway: FreeTierRequester) {beforeEach(() => {vi.useFakeTimers()+ // Onboarding's due check answered "not due": nothing first-run owns the screen.+ markOnboardingDecided()})afterEach(() => {@@ -60,8 +66,7 @@ afterEach(() => {stopFreeTierOffer()closeFreeTierSignIn()$freeTierStatus.set(null)- $onboardingGate.set({ guideKickoff: 'idle', guideQueued: false, phase: 'idle' })- Reflect.deleteProperty(window, 'hermesDesktop')+ setOnboardingSurfaceActive('onboarding', false)vi.useRealTimers()})@@ -103,14 +108,23 @@ describe('sign-in offer after a finished task', () => {expect($freeTierSignIn.get()).toEqual({ status: 'closed' })})- it('does not claim while guided onboarding is on screen, the dialog is open, or off the free tier', async () => {+ it('does not claim before the due check answers', async () => {const requestGateway = gateway({ statuses: [status(0)] })- Object.assign(window, { hermesDesktop: { guestOnboardingEnabled: true } })- $onboardingGate.set({ guideKickoff: 'started', guideQueued: false, phase: 'guided' })+ $onboardingDecided.set(false)syncFreeTierOffer(status(0), requestGateway)await vi.advanceTimersByTimeAsync(0)- $onboardingGate.set({ guideKickoff: 'started', guideQueued: false, phase: 'done' })++ expect(claims(requestGateway)).toBe(0)+ })++ it('does not claim while onboarding is on screen, the dialog is open, or off the free tier', async () => {+ const requestGateway = gateway({ statuses: [status(0)] })++ setOnboardingSurfaceActive('onboarding', true)+ syncFreeTierOffer(status(0), requestGateway)+ await vi.advanceTimersByTimeAsync(0)+ setOnboardingSurfaceActive('onboarding', false)$freeTierSignIn.set({ status: 'requested' })syncFreeTierOffer(status(0), requestGateway)diff --git a/apps/desktop/src/store/free-tier-sign-in.ts b/apps/desktop/src/store/free-tier-sign-in.tsindex c9c364cf0d5..795d6fa8975 100644--- a/apps/desktop/src/store/free-tier-sign-in.ts+++ b/apps/desktop/src/store/free-tier-sign-in.ts@@ -6,7 +6,6 @@ import { gatewayActivationEpoch } from '@/store/gateway'import type { FreeTierStatus } from '@/types/hermes'import { $freeTierStatus, type FreeTierRequester, NOUS_PROVIDER_ID, refreshFreeTierStatus } from './free-tier'-import { guidedOnboardingActive } from './onboarding-gate'import { onboardingSurfaceActive } from './onboarding-presence'const POLL_MS = 2000@@ -188,7 +187,7 @@ export function syncFreeTierOffer(status: FreeTierStatus | null, requestGateway:}const offerBlocked = () =>- offerClaiming || guidedOnboardingActive() || onboardingSurfaceActive() || $freeTierSignIn.get().status !== 'closed'+ offerClaiming || onboardingSurfaceActive() || $freeTierSignIn.get().status !== 'closed'async function claimFreeTierOffer(requestGateway: FreeTierRequester) {if (offerBlocked()) {diff --git a/apps/desktop/src/store/free-tier.ts b/apps/desktop/src/store/free-tier.tsindex 96d089f7ba4..6ee7d17f2e5 100644--- a/apps/desktop/src/store/free-tier.ts+++ b/apps/desktop/src/store/free-tier.ts@@ -2,8 +2,7 @@ import { atom, computed } from 'nanostores'import { runFreeTierChallenge } from '@/store/free-tier-challenge'import { setModeContext } from '@/store/interface-mode'-import { $onboardingGate, guidedOnboardingActive } from '@/store/onboarding-gate'-import { onboardingSurfaceActive } from '@/store/onboarding-presence'+import { $onboardingSurfaceClear, onboardingSurfaceActive } from '@/store/onboarding-presence'import type { FreeTierStatus } from '@/types/hermes'/** The model the free-tier route runs on. Used to recognise a session that is@@ -28,12 +27,12 @@ export const $freeTierStatus = atom<FreeTierStatus | null>(null)/*** A signed-out free-tier user who should see the standing Sign in: the tier is* on with an identity (`available`; a sign-in replaces that identity, so it- * reads false afterwards) and no guided setup owns the moment. The statusbar- * chip shows on it, and Simple mode keeps the statusbar up on it.+ * reads false afterwards) and first-run onboarding does not own the+ * moment. The statusbar chip shows on it, and Simple mode keeps the statusbar up on it.*/export const $freeTierSignInOpen = computed(- [$freeTierStatus, $onboardingGate],- status => Boolean(status?.available) && !guidedOnboardingActive()+ [$freeTierStatus, $onboardingSurfaceClear],+ (status, clear) => Boolean(status?.available) && clear)// Fed here, beside the atom, so every importer of this store gets the same link.diff --git a/apps/desktop/src/store/interface-mode.ts b/apps/desktop/src/store/interface-mode.tsindex e66930f37d8..b0a164b40cc 100644--- a/apps/desktop/src/store/interface-mode.ts+++ b/apps/desktop/src/store/interface-mode.ts@@ -80,6 +80,8 @@ export interface ModeContext {/** A signed-out free-tier user with no setup in progress: the statusbar's* Sign in chip is their standing way to sign in. */freeTierSignInOpen: boolean+ /** The first-run onboarding is open; its account and download progress live in the statusbar. */+ onboardingOpen: booleanprofileCount: number}@@ -115,8 +117,8 @@ const SIMPLE_POLICY: PolicyTable = {// What was said and when — cost, tokens, PR and profile chips are readouts.sidebarRowMeta: ['preview', 'updated'],// The bar carries the free tier's Sign in chip, the one standing way in to a- // sign-in. It rests hidden for everyone else and goes away once they sign in.- statusbarVisible: context => context.freeTierSignInOpen,+ // sign-in, and onboarding's account progress. It rests hidden otherwise.+ statusbarVisible: context => context.freeTierSignInOpen || context.onboardingOpen,terminalOpen: false,// Product summaries; the technical payload view is the instrumentation itself.toolViewMode: 'product'@@ -138,6 +140,7 @@ const shadows = (key: ModePolicyKey, mode: InterfaceMode) => key in POLICY[mode]export const $modeContext = atom<ModeContext>({connectionCount: 1,freeTierSignInOpen: false,+ onboardingOpen: false,profileCount: 1})diff --git a/apps/desktop/src/store/onboarding-phase.ts b/apps/desktop/src/store/onboarding-phase.tsnew file mode 100644index 00000000000..8e5ca14f961--- /dev/null+++ b/apps/desktop/src/store/onboarding-phase.ts@@ -0,0 +1,6 @@+import { atom } from 'nanostores'++/** Where first-run onboarding is: `shown` while it runs, then how it ended. Funnel telemetry reads it. */+export type OnboardingPhase = 'done' | 'failed' | 'idle' | 'shown' | 'skipped'++export const $onboardingPhase = atom<OnboardingPhase>('idle')diff --git a/apps/desktop/src/store/onboarding-presence.ts b/apps/desktop/src/store/onboarding-presence.tsindex 73a5ed09cf8..55572ddf214 100644--- a/apps/desktop/src/store/onboarding-presence.ts+++ b/apps/desktop/src/store/onboarding-presence.ts@@ -1,11 +1,26 @@-import { atom } from 'nanostores'+import { atom, computed } from 'nanostores'-type OnboardingSurface = 'intro'+import { setModeContext } from '@/store/interface-mode'++type OnboardingSurface = 'onboarding'const EMPTY: ReadonlySet<OnboardingSurface> = new Set()export const $onboardingSurfaces = atom<ReadonlySet<OnboardingSurface>>(EMPTY)+/**+ * First-run onboarding's due check has answered (or timed out, or does not apply in this+ * window). Until it has, every "not during setup" surface waits: onboarding may still open.+ */+export const $onboardingDecided = atom(false)++/** How long anything waits on the due check before treating onboarding as not due. */+export const ONBOARDING_DECIDE_DEADLINE_MS = 4_000++export function markOnboardingDecided(): void {+ $onboardingDecided.set(true)+}+export function setOnboardingSurfaceActive(surface: OnboardingSurface, active: boolean): void {const current = $onboardingSurfaces.get()@@ -24,6 +39,37 @@ export function setOnboardingSurfaceActive(surface: OnboardingSurface, active: b$onboardingSurfaces.set(next.size === 0 ? EMPTY : next)}+/** Nothing first-run owns the screen: the due check answered and no onboarding surface is open. */+export const $onboardingSurfaceClear = computed(+ [$onboardingDecided, $onboardingSurfaces],+ (decided, surfaces) => decided && surfaces.size === 0+)++/** A first-run surface is open, or may still open. */export function onboardingSurfaceActive(): boolean {+ return !$onboardingSurfaceClear.get()+}++/** A first-run surface is open now; an undecided due check does not count. */+export function onboardingSurfaceOpen(): boolean {return $onboardingSurfaces.get().size > 0}++/** Run once nothing first-run owns the screen (now, when it already doesn't). */+export function afterOnboardingSurfaceClear(run: () => void): void {+ if ($onboardingSurfaceClear.get()) {+ run()++ return+ }++ const stop = $onboardingSurfaceClear.listen(clear => {+ if (clear) {+ stop()+ run()+ }+ })+}++// Simple mode keeps the status bar up while onboarding is open: account and download progress live there.+$onboardingSurfaces.subscribe(surfaces => setModeContext({ onboardingOpen: surfaces.size > 0 }))diff --git a/apps/desktop/src/store/onboarding.test.ts b/apps/desktop/src/store/onboarding.test.tsindex f95c28b0386..d33117fd94b 100644--- a/apps/desktop/src/store/onboarding.test.ts+++ b/apps/desktop/src/store/onboarding.test.ts@@ -2,6 +2,7 @@ import { act } from 'react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import * as notifications from '@/store/notifications'+import { markOnboardingDecided } from '@/store/onboarding-presence'import { makeOAuthProvider } from '@/test/oauth-provider'import type { OAuthProvider } from '@/types/hermes'@@ -19,6 +20,9 @@ import {submitOnboardingCode} from './onboarding'+// Onboarding's due check answered "not due": first-run surfaces are free to show.+markOnboardingDecided()+function baseState(overrides: Partial<DesktopOnboardingState> = {}): DesktopOnboardingState {return {configured: false,diff --git a/apps/desktop/src/store/onboarding.ts b/apps/desktop/src/store/onboarding.tsindex 9f1551fad45..43e149b87f7 100644--- a/apps/desktop/src/store/onboarding.ts+++ b/apps/desktop/src/store/onboarding.ts@@ -16,11 +16,17 @@ import {import { translateNow } from '@/i18n'import { isProviderSetupErrorMessage } from '@/lib/provider-setup-errors'import { evaluateRuntimeReadiness, type RuntimeReadinessResult } from '@/lib/runtime-readiness'-import { ackFreeTierNotice, freeTierReadyPending, refreshFreeTierStatus, setFreeTierRoute } from '@/store/free-tier'+import {+ $freeTierStatus,+ ackFreeTierNotice,+ freeTierReadyPending,+ refreshFreeTierStatus,+ setFreeTierRoute+} from '@/store/free-tier'import { $gatewayBootGeneration } from '@/store/live-sync'import { setMainModelAssignment } from '@/store/model-assignment'import { dismissNotification, notify, notifyError } from '@/store/notifications'-import { afterOnboardingStateRead, guidedOnboardingActive } from '@/store/onboarding-gate'+import { afterOnboardingSurfaceClear, onboardingSurfaceOpen } from '@/store/onboarding-presence'import { captureOnboardingScope, type OnboardingScope } from '@/store/onboarding-scope'import type { OAuthProvider, OAuthStartResponse } from '@/types/hermes'@@ -570,18 +576,13 @@ async function refreshProviders() {}export function requestDesktopOnboarding(reason = DEFAULT_ONBOARDING_REASON) {- // Not during the guided first launch. The free tier carries inference- // there, and a credential probe that fires anyway (a free-tier token mid- // refresh, a setup-profile session before its runtime settles) would drop- // the provider picker over the guide the user is in the middle of. Sign-in- // is offered where the guide chooses to, on its own ready screen.- afterOnboardingStateRead(() => {- if (guidedOnboardingActive()) {- return- }-+ // Not over first-run onboarding. The free account may still be in+ // the making, and a credential probe that fires meanwhile would drop the+ // provider picker over it; onboarding hands over to the picker+ // itself when the account fails.+ afterOnboardingSurfaceClear(() =>patch({ reason: reason.trim() || DEFAULT_ONBOARDING_REASON, requested: true })- })+ )}/** Credential warning delivered passively (session create/activate/resume@@ -598,7 +599,8 @@ let pendingCredentialWarning: null | string = nullexport function requestDesktopOnboardingForCredentialWarning(reason: null | string | undefined) {const warning = reason?.trim()- if (!warning || !isProviderSetupErrorMessage(warning) || guidedOnboardingActive()) {+ // Stash while the due check is still undecided: submit consumes it later. Drop only under an open onboarding.+ if (!warning || !isProviderSetupErrorMessage(warning) || onboardingSurfaceOpen()) {pendingCredentialWarning = nullreturn@@ -854,18 +856,13 @@ export async function refreshOnboarding(ctx: OnboardingContext, stillWanted?: ()*/async function applyFreeTierIntro(ctx: OnboardingContext, runtime: RuntimeReadinessResult) {setFreeTierRoute(runtime.freeTier)- const status = await refreshFreeTierStatus(ctx.requestGateway)-- // The guided first launch IS the introduction. Raising the ready screen on- // top of it (a readiness round fires when the layout pick assembles the- // window) covered the guide mid-conversation, and dismissing it remounted- // the card the user had just answered.- afterOnboardingStateRead(() => {- if (guidedOnboardingActive()) {- return- }+ await refreshFreeTierStatus(ctx.requestGateway)- if (freeTierReadyPending(status, runtime.freeTier ?? null)) {+ // Onboarding's Start IS the introduction and acks the notice; a+ // Skip leaves it owed. Read the status when the overlay is free, not now,+ // so an ack made meanwhile is honoured.+ afterOnboardingSurfaceClear(() => {+ if (freeTierReadyPending($freeTierStatus.get(), runtime.freeTier ?? null)) {patch({ freeTierReady: true })}})