Skip to content

The agent that grows with you

fix(desktop): a relaunch after leaving the intro skips the demo layout

alt-glitchc2f06a8abbd7
diff --git a/apps/desktop/src/components/onboarding/first-run/kickoff.test.ts b/apps/desktop/src/components/onboarding/first-run/kickoff.test.ts
index e0fe906ff4a..a38a147b4e7 100644
--- a/apps/desktop/src/components/onboarding/first-run/kickoff.test.ts
+++ b/apps/desktop/src/components/onboarding/first-run/kickoff.test.ts
@@ -32,6 +32,7 @@ beforeEach(() => {
$connection.set({ mode: 'local' } as never)
$onboardingPhase.set('idle')
$introView.set('off')
+ $chatOnboardingSolo.set(false)
$selectedStoredSessionId.set(null)
size.mockClear()
})
@@ -54,6 +55,15 @@ describe('first-run kickoff', () => {
expect($introCopy.get()).toBe('playing')
})
+ it('reopens the chat without the demo layout once the user left the intro on an earlier launch', async () => {
+ const opened = await startOnboarding(request, adopt, { ensureProfile, intro: firstRunIntro(), introSeen: true })
+
+ expect(opened).toBe(true)
+ expect(size).not.toHaveBeenCalled()
+ expect($chatOnboardingSolo.get()).toBe(false)
+ expect($introView.get()).toBe('ended')
+ })
+
it('waits on a slow start with no deadline, and the way out fails it', async () => {
vi.useFakeTimers()
const deadlines: (number | undefined)[] = []
diff --git a/apps/desktop/src/components/onboarding/first-run/kickoff.ts b/apps/desktop/src/components/onboarding/first-run/kickoff.ts
index 4144f9a1751..5d655819e19 100644
--- a/apps/desktop/src/components/onboarding/first-run/kickoff.ts
+++ b/apps/desktop/src/components/onboarding/first-run/kickoff.ts
@@ -2,7 +2,7 @@ import type { OnboardingStartResult } from '@hermes/shared'
import { chatMessageText } from '@/lib/chat-messages'
import { BACKEND_BOOT_WAIT_TIMEOUT_MS } from '@/lib/with-timeout'
-import { $introStartExit } from '@/store/onboarding-intro'
+import { $introStartExit, $introView } from '@/store/onboarding-intro'
import { $onboardingEnded, type OnboardingIntroHooks } from '@/store/onboarding-run'
import { $activeSessionId } from '@/store/session'
import { $sessionStates } from '@/store/session-states'
@@ -25,6 +25,8 @@ function hasAssistantWords(runtimeId: null | string): boolean {
*/
export function firstRunIntro(): OnboardingIntroHooks {
let offerExit: ReturnType<typeof setTimeout> | undefined
+ // The user left this run's intro on an earlier launch: the chat reopens as a normal chat, no demo.
+ let left = false
const clearExit = () => {
clearTimeout(offerExit)
@@ -32,14 +34,18 @@ export function firstRunIntro(): OnboardingIntroHooks {
}
return {
- starting: abandon => {
+ starting: (abandon, seen) => {
+ left = seen
startIntro()
$introTurnSent.set(false)
offerExit = setTimeout(() => $introStartExit.set(abandon), BACKEND_BOOT_WAIT_TIMEOUT_MS)
},
started: () => {
clearExit()
- openDemoLayout()
+
+ if (!left) {
+ openDemoLayout()
+ }
},
opened: (started: OnboardingStartResult) => {
const runtimeId = $activeSessionId.get()
@@ -49,7 +55,12 @@ export function firstRunIntro(): OnboardingIntroHooks {
])
// onboarding.start has already submitted the opening turn.
$introTurnSent.set(true)
- openIntro(!hasAssistantWords(runtimeId))
+
+ if (left) {
+ $introView.set('ended')
+ } else {
+ openIntro(!hasAssistantWords(runtimeId))
+ }
},
failed: () => {
clearExit()
diff --git a/apps/desktop/src/store/onboarding-run.test.ts b/apps/desktop/src/store/onboarding-run.test.ts
index a02f0b9d894..525985dd69a 100644
--- a/apps/desktop/src/store/onboarding-run.test.ts
+++ b/apps/desktop/src/store/onboarding-run.test.ts
@@ -1,5 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { $introView } from './onboarding-intro'
import { $onboardingPhase } from './onboarding-phase'
import { $onboardingDecided, $onboardingSurfaceClear } from './onboarding-presence'
import {
@@ -125,6 +126,17 @@ describe('onboarding run', () => {
expect(calls).toContain('free_tier.ack_notice')
})
+ it('records the intro as seen when the user first leaves it mid-run', async () => {
+ const { calls, request } = backend({ eligible: true, run: true })
+ const intro = { failed: vi.fn(), opened: () => $introView.set('intro'), started: vi.fn(), starting: vi.fn() }
+
+ await startOnboarding(request, resume, { ensureProfile, intro })
+ $introView.set('ended')
+ $introView.set('off')
+
+ expect(calls.filter(method => method === 'onboarding.mark_seen')).toHaveLength(1)
+ })
+
it('keeps the run when the backend refuses the skip', async () => {
const { request } = backend({ eligible: true, run: true })
await startOnboarding(request, resume, { ensureProfile })
diff --git a/apps/desktop/src/store/onboarding-run.ts b/apps/desktop/src/store/onboarding-run.ts
index 48f2cf18609..1e07e0eebd1 100644
--- a/apps/desktop/src/store/onboarding-run.ts
+++ b/apps/desktop/src/store/onboarding-run.ts
@@ -8,7 +8,12 @@
* (`onboarding.state`) and writes the install-level flag when a run ends.
*/
-import type { MachineFactsResult, OnboardingRunStateResult, OnboardingStartResult } from '@hermes/shared'
+import type {
+ MachineFactsResult,
+ OnboardingRunStateResult,
+ OnboardingStartResult,
+ OnboardingStateResult
+} from '@hermes/shared'
import { atom, computed } from 'nanostores'
import { getRuntimeI18nLocale } from '@/i18n/runtime'
@@ -17,6 +22,7 @@ import type { GatewayRequester } from '@/lib/yolo-session'
import { ackFreeTierNotice } from './free-tier'
import { activeGatewayConnectionId } from './gateway'
import { clearFreeTierIntro } from './onboarding'
+import { $introView } from './onboarding-intro'
import { $onboardingPhase } from './onboarding-phase'
import { markOnboardingDecided, setOnboardingSurfaceActive } from './onboarding-presence'
import { $activeGatewayProfile, ensureGatewayAgent, ensureGatewayProfile, newSessionInProfile } from './profile'
@@ -112,8 +118,8 @@ async function factsSource(request: OnboardingRequest): Promise<'local' | 'remot
/** The first-run intro around a start (`components/onboarding/first-run/kickoff.ts`). */
export interface OnboardingIntroHooks {
/** Before `onboarding.start`: the boot overlay holds. `abandon`: the user went on without setup; the
- * start fails and the chat stays closed. */
- starting: (abandon: () => void) => void
+ * start fails and the chat stays closed. `seen`: the user left this run's intro on an earlier launch. */
+ starting: (abandon: () => void, seen: boolean) => void
/** The start answered, the chat not open yet. */
started: (started: OnboardingStartResult) => void
/** The chat is the one on screen. */
@@ -125,6 +131,8 @@ interface StartOptions {
/** Points the window's gateway at the profile onboarding runs in (`store/profile.ts::ensureGatewayProfile`). */
ensureProfile?: (profile: string) => Promise<void>
intro?: OnboardingIntroHooks
+ /** The user left the intro on an earlier launch (`onboarding.mark_seen`). */
+ introSeen?: boolean
rerun?: boolean
}
@@ -132,14 +140,14 @@ interface StartOptions {
export async function startOnboarding(
request: OnboardingRequest,
resume: OnboardingResume,
- { ensureProfile = ensureGatewayProfile, intro, rerun = false }: StartOptions = {}
+ { ensureProfile = ensureGatewayProfile, intro, introSeen = false, rerun = false }: StartOptions = {}
): Promise<boolean> {
$onboardingPhase.set('shown')
$onboardingEnded.set(null)
$onboardingChatSeen.set(false)
const abandon = new AbortController()
- intro?.starting(() => abandon.abort())
+ intro?.starting(() => abandon.abort(), introSeen)
launch = { connectionId: activeGatewayConnectionId(), profile: $activeGatewayProfile.get() }
try {
@@ -161,6 +169,7 @@ export async function startOnboarding(
if (intro) {
intro.opened(started)
ackFreeTierIntro(request)
+ markSeenOnLeave(request)
}
return true
@@ -189,6 +198,21 @@ function ackFreeTierIntro(request: OnboardingRequest): void {
})
}
+// Main's rule: once the user leaves the intro mid-run, a relaunch reopens the chat without the demo.
+function markSeenOnLeave(request: OnboardingRequest): void {
+ if ($introView.get() !== 'intro') {
+ return
+ }
+
+ const stop = $introView.listen(view => {
+ stop()
+
+ if (view === 'ended' && $onboardingPhase.get() === 'shown') {
+ void request('onboarding.mark_seen').catch(error => console.warn('[onboarding] mark_seen failed', error))
+ }
+ })
+}
+
// Like main's failed kickoff: the window goes back to where it was before the switch.
async function returnToLaunchProfile(ensureProfile: (profile: string) => Promise<void>): Promise<void> {
if (!launch) {
@@ -223,10 +247,12 @@ export function decideOnboarding(
async function readAndStart(request: OnboardingRequest, resume: OnboardingResume, options?: StartOptions): Promise<void> {
try {
- const state = await request<OnboardingRunStateResult>('onboarding.state')
+ const state = await request<OnboardingRunStateResult & Partial<Pick<OnboardingStateResult, 'intro'>>>(
+ 'onboarding.state'
+ )
if (state.run && state.eligible) {
- await startOnboarding(request, resume, options)
+ await startOnboarding(request, resume, { ...options, introSeen: state.intro === 'seen' })
}
} catch (error) {
console.warn('[onboarding] state could not be read', error)