Skip to content

The agent that grows with you

fix(desktop): a first-run start that outlasts the boot budget offers to continue without setup

alt-glitch5a1700e8b0f9
diff --git a/apps/desktop/src/app/contrib/onboarding-kickoff-machine.ts b/apps/desktop/src/app/contrib/onboarding-kickoff-machine.ts
index d8aca182e07..6a6224f6894 100644
--- a/apps/desktop/src/app/contrib/onboarding-kickoff-machine.ts
+++ b/apps/desktop/src/app/contrib/onboarding-kickoff-machine.ts
@@ -9,7 +9,8 @@ import { $gatewayState } from '@/store/session'
* (the backend process is alive, the gateway is open or reconnecting, a call is in flight) it waits with no
* wall-clock deadline: a cold first boot answers late, but it answers (51 s to listen on a Windows ARM64
* first boot, then a busy backend behind the first calls). It fails only on what waiting cannot fix: an
- * RPC error response, the backend process exiting, or a result it does not expect.
+ * RPC error response, the backend process exiting, a result it does not expect, or `stop` (the person chose
+ * to go on without setup once the wait outlasted the boot budget).
*/
export type KickoffState = 'waiting-backend' | 'preparing' | 'opening' | 'started' | 'off' | 'failed'
@@ -19,6 +20,9 @@ export const NO_DEADLINE = 0
/** A failure no amount of waiting fixes. */
export class KickoffFailure extends Error {}
+/** The person chose to go on without setup while the start was still waiting. */
+export class KickoffSkipped extends KickoffFailure {}
+
type FailureKind = 'fatal' | 'starting' | 'transient'
function failureKind(error: unknown): FailureKind {
@@ -55,12 +59,39 @@ export interface KickoffMachine {
* dropped connection runs it again once. Anything else, or the backend exiting, rejects. */
attempt<T>(state: KickoffState, step: () => Promise<T>): Promise<T>
dispose(): void
+ /** Aborts every call that carries `signal` and fails the kickoff with `reason`. */
+ stop(reason: KickoffFailure): void
+ /** Passed to every kickoff RPC, so `stop` rejects the ones still in flight. */
+ signal: AbortSignal
+ /** `work`, or `stop`'s reason if that comes first: for steps that take no signal. */
+ until<T>(work: Promise<T>): Promise<T>
}
export function createKickoffMachine(): KickoffMachine {
let state: KickoffState | 'begin' = 'begin'
let exitFailure: KickoffFailure | null = null
const exitWaiters = new Set<(error: KickoffFailure) => void>()
+ const stopper = new AbortController()
+ let stopReason: KickoffFailure | null = null
+
+ const stop = (reason: KickoffFailure) => {
+ stopReason = reason
+ stopper.abort(reason)
+
+ for (const reject of exitWaiters) {
+ reject(reason)
+ }
+ }
+
+ const until = <T>(work: Promise<T>): Promise<T> =>
+ stopReason
+ ? Promise.reject(stopReason)
+ : Promise.race([
+ work,
+ new Promise<never>((_, reject) =>
+ stopper.signal.addEventListener('abort', () => reject(stopReason), { once: true })
+ )
+ ])
const enter = (next: KickoffState, detail?: string) => {
log(`${state} -> ${next}${detail ? ` (${detail})` : ''}`)
@@ -83,6 +114,10 @@ export function createKickoffMachine(): KickoffMachine {
})
const gatewayOpen = (): Promise<void> => {
+ if (stopReason) {
+ return Promise.reject(stopReason)
+ }
+
if (exitFailure) {
return Promise.reject(exitFailure)
}
@@ -128,6 +163,10 @@ export function createKickoffMachine(): KickoffMachine {
} catch (error) {
const kind = failureKind(error)
+ if (stopReason) {
+ throw stopReason
+ }
+
if (exitFailure) {
throw exitFailure
}
@@ -142,5 +181,5 @@ export function createKickoffMachine(): KickoffMachine {
}
}
- return { attempt, dispose: () => offExit?.(), enter }
+ return { attempt, dispose: () => offExit?.(), enter, signal: stopper.signal, stop, until }
}
diff --git a/apps/desktop/src/app/contrib/onboarding-kickoff.ts b/apps/desktop/src/app/contrib/onboarding-kickoff.ts
index 0096df6a4b1..0b641a04daa 100644
--- a/apps/desktop/src/app/contrib/onboarding-kickoff.ts
+++ b/apps/desktop/src/app/contrib/onboarding-kickoff.ts
@@ -7,10 +7,12 @@ import { $introTurnSent, openIntro, rememberLaunchSource } from '@/components/on
import { $setupSession, guideSourceConnectionId } from '@/components/onboarding-chat/setup-profile'
import type { ChatMessagePart } from '@/lib/chat-messages'
import { isOnboardingEnabled } from '@/lib/onboarding-enabled'
+import { BACKEND_BOOT_WAIT_TIMEOUT_MS } from '@/lib/with-timeout'
import { prefetchConnectorCatalog } from '@/store/connector-catalog'
import { activeGatewayConnectionId, requestGatewayForProfile } from '@/store/gateway'
import { notify } from '@/store/notifications'
import { $setupProfileName, type GuideKickoffResult } from '@/store/onboarding-gate'
+import { $introStartExit } from '@/store/onboarding-intro'
import { prefetchOnboardingPlugins } from '@/store/onboarding-plugins'
import {
$activeGatewayProfile,
@@ -22,7 +24,7 @@ import {
import { $activeSessionId, $selectedStoredSessionId } from '@/store/session'
import { $sessionStates } from '@/store/session-states'
-import { createKickoffMachine, KickoffFailure, NO_DEADLINE } from './onboarding-kickoff-machine'
+import { createKickoffMachine, KickoffFailure, KickoffSkipped, NO_DEADLINE } from './onboarding-kickoff-machine'
import type { AmbientGatewayRequest } from './session-rpc-dispatcher'
function prefetchGuideCatalogs(storedId: null | string): void {
@@ -131,6 +133,15 @@ export function useOnboardingKickoff({ requestGateway, resumeSession, runSlashCo
const machine = createKickoffMachine()
let swapped = false
+ // Past the boot budget the start keeps waiting, and the starting screen offers a way out.
+ const offerExit = window.setTimeout(
+ () =>
+ $introStartExit.set(() =>
+ machine.stop(new KickoffSkipped('Setup was skipped while Hermes was still starting.'))
+ ),
+ BACKEND_BOOT_WAIT_TIMEOUT_MS
+ )
+
try {
// Every call here is idempotent, so a retry repeats the whole step. The calls carry no deadline: a cold
// first boot answers them late, and the machine fails on the signals that mean it never will.
@@ -138,7 +149,8 @@ export function useOnboardingKickoff({ requestGateway, resumeSession, runSlashCo
const { name: setupProfile } = await requestGateway<OnboardingEnsureSetupProfileResult>(
'onboarding.ensure_setup_profile',
{},
- NO_DEADLINE
+ NO_DEADLINE,
+ machine.signal
)
$setupProfileName.set(setupProfile)
@@ -150,7 +162,7 @@ export function useOnboardingKickoff({ requestGateway, resumeSession, runSlashCo
'setup.status',
{},
NO_DEADLINE,
- undefined,
+ machine.signal,
{ spawnPriority: 'foreground' }
)
@@ -171,13 +183,14 @@ export function useOnboardingKickoff({ requestGateway, resumeSession, runSlashCo
$newChatProfile.set(setupProfile)
}
- await ensureGatewayProfile(setupProfile)
+ await machine.until(ensureGatewayProfile(setupProfile))
// Finds the setup chat by title or creates it; `empty` is true only before its first turn.
const setupChat = await requestGateway<OnboardingEnsureSetupSessionResult>(
'onboarding.ensure_setup_session',
{},
- NO_DEADLINE
+ NO_DEADLINE,
+ machine.signal
)
return { record, setupChat, setupProfile }
@@ -196,12 +209,8 @@ export function useOnboardingKickoff({ requestGateway, resumeSession, runSlashCo
const guideRequest: AmbientGatewayRequest = (method, params, timeout) =>
requestGatewayForProfile(setupProfile, method, params, timeout)
- const runtimeId = await adoptGuideSession(
- setupProfile,
- setupChat.session_id,
- record.free_tier_route,
- resumeSession,
- guideRequest
+ const runtimeId = await machine.until(
+ adoptGuideSession(setupProfile, setupChat.session_id, record.free_tier_route, resumeSession, guideRequest)
)
// A relaunch reopens the same setup chat; one whose opening was cut off is sent the command again.
@@ -238,15 +247,20 @@ export function useOnboardingKickoff({ requestGateway, resumeSession, runSlashCo
})
}
- console.error('[setup] welcome chat could not start', error)
- notify({
- kind: 'error',
- title: 'Welcome chat needs attention',
- message: error instanceof Error ? error.message : 'The welcome chat could not start.'
- })
+ // Going on without setup is the person's choice, not an error to report.
+ if (!(error instanceof KickoffSkipped)) {
+ console.error('[setup] welcome chat could not start', error)
+ notify({
+ kind: 'error',
+ title: 'Welcome chat needs attention',
+ message: error instanceof Error ? error.message : 'The welcome chat could not start.'
+ })
+ }
return 'failed'
} finally {
+ window.clearTimeout(offerExit)
+ $introStartExit.set(null)
machine.dispose()
}
}, [requestGateway, resumeSession, runSlashCommand])
diff --git a/apps/desktop/src/components/gateway-connecting-overlay.tsx b/apps/desktop/src/components/gateway-connecting-overlay.tsx
index b2bab64b3ad..255f178c87c 100644
--- a/apps/desktop/src/components/gateway-connecting-overlay.tsx
+++ b/apps/desktop/src/components/gateway-connecting-overlay.tsx
@@ -2,14 +2,16 @@ 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 { $introView } from '@/store/onboarding-intro'
+import { $introStartExit, $introView } from '@/store/onboarding-intro'
import { $gatewayState } from '@/store/session'
import { isMainWindow } from '@/store/windows'
@@ -59,10 +61,26 @@ function isInitialConnect(
interface ConnectingOverlayViewProps {
decoding: boolean
+ onExit: (() => void) | null
phase: Phase
}
-function ConnectingOverlayView({ decoding, phase }: ConnectingOverlayViewProps) {
+/** 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) {
const leaving = phase !== 'live'
const overlayHidden = phase === 'overlay-out' || phase === 'gone'
@@ -77,17 +95,21 @@ function ConnectingOverlayView({ decoding, phase }: ConnectingOverlayViewProps)
// in styles.css.
data-glass-opaque=""
>
- <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}
- />
+ {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}
+ />
+ )}
</div>
)
}
@@ -98,6 +120,7 @@ export function GatewayConnectingOverlay() {
const gatewaySwitching = useStore($gatewaySwitching)
const onboardingStateRead = useStore($onboardingStateRead)
const introView = useStore($introView)
+ const introStartExit = useStore($introStartExit)
const [previewing] = useState(forcedPreview)
const reduce = prefersReducedMotion()
// Under reduced motion, skip the multi-phase exit choreography (text-out →
@@ -187,5 +210,11 @@ export function GatewayConnectingOverlay() {
return null
}
- return <ConnectingOverlayView decoding={phase === 'live' && (previewing || connecting)} phase={phase} />
+ return (
+ <ConnectingOverlayView
+ decoding={phase === 'live' && (previewing || connecting)}
+ onExit={introHolds ? introStartExit : null}
+ phase={phase}
+ />
+ )
}
diff --git a/apps/desktop/src/i18n/en_onboarding.ts b/apps/desktop/src/i18n/en_onboarding.ts
index 85edcbd83f1..49acf80a9c9 100644
--- a/apps/desktop/src/i18n/en_onboarding.ts
+++ b/apps/desktop/src/i18n/en_onboarding.ts
@@ -5,6 +5,9 @@ export const enOnboarding: Translations['onboarding'] = {
headerDesc: 'Connect a model provider to start chatting. Most options take one click.',
preparingInstall: 'Hermes is finishing install. This usually takes under a minute on first run.',
starting: 'Starting Hermes…',
+ setupSlowTitle: 'Setup is taking longer than usual.',
+ setupSlowBody: 'Hermes is still starting in the background.',
+ continueWithoutSetup: 'Continue without setup',
lookingUpProviders: 'Looking up providers...',
collapse: 'Collapse',
otherProviders: 'Other providers',
diff --git a/apps/desktop/src/i18n/types_onboarding.ts b/apps/desktop/src/i18n/types_onboarding.ts
index 93eeabf6994..610c6e09b13 100644
--- a/apps/desktop/src/i18n/types_onboarding.ts
+++ b/apps/desktop/src/i18n/types_onboarding.ts
@@ -3,6 +3,9 @@ export interface OnboardingTranslations {
headerDesc: string
preparingInstall: string
starting: string
+ setupSlowTitle: string
+ setupSlowBody: string
+ continueWithoutSetup: string
lookingUpProviders: string
collapse: string
otherProviders: string
diff --git a/apps/desktop/src/store/onboarding-intro.ts b/apps/desktop/src/store/onboarding-intro.ts
index 508c15e1473..ffe855783be 100644
--- a/apps/desktop/src/store/onboarding-intro.ts
+++ b/apps/desktop/src/store/onboarding-intro.ts
@@ -12,6 +12,10 @@ export type IntroView = 'off' | 'starting' | 'intro' | 'ended'
export const $introView = atom<IntroView>('off')
+/** Set once the setup chat's start has outlasted the boot budget: the starting screen keeps waiting and offers
+ * this way out, which ends the start through the kickoff's failed path. Null otherwise. */
+export const $introStartExit = atom<(() => void) | null>(null)
+
/** The demo layout is on screen: the chat alone, narrower, minimal composer, no status bar. Kept here,
* free of layout imports, so the shell can read it; onboarding-chat/assembly.ts owns the switch. */
export const $chatOnboardingSolo = atom(false)
diff --git a/locales/_keys.desktop.json b/locales/_keys.desktop.json
index b647609279b..2cd49cba759 100644
--- a/locales/_keys.desktop.json
+++ b/locales/_keys.desktop.json
@@ -2083,6 +2083,7 @@
"onboarding.connectedPicking",
"onboarding.connectedProvider",
"onboarding.connecting",
+ "onboarding.continueWithoutSetup",
"onboarding.copy",
"onboarding.copyAuthCode",
"onboarding.couldNotSave",
@@ -2121,6 +2122,8 @@
"onboarding.reopenSignInPage",
"onboarding.reopenVerification",
"onboarding.replaceCurrent",
+ "onboarding.setupSlowBody",
+ "onboarding.setupSlowTitle",
"onboarding.signInDidNotFinish",
"onboarding.signInExpired",
"onboarding.signInFailed",