Skip to content

The agent that grows with you

fix(desktop): show the guide greeting before its backend is ready

alt-glitcha8bc09e9e625
diff --git a/apps/desktop/DESIGN.md b/apps/desktop/DESIGN.md
index aaa3de141b3..05bc7f5d4df 100644
--- a/apps/desktop/DESIGN.md
+++ b/apps/desktop/DESIGN.md
@@ -283,6 +283,12 @@ so glass and message-bubble transparency do not reveal scrolling text.
- Install, onboarding, connecting, boot failure, and reauthentication are
distinct states with shared visual primitives. Preserve their recovery
semantics when unifying appearance.
+- Guide arrival shows the locally known greeting in the transcript position,
+ revealed at 18 graphemes per second with the existing markdown cursor. No
+ status copy or spinner. Composer, Skip setup, and statusbar stay unmounted
+ until the seeded session has been adopted; then controls fade in over 100ms.
+ Reduced motion shows the complete greeting immediately. Never invent a new
+ greeting on a resumed guide or delay backend readiness for the animation.
- Respect `AppShell` overlay ownership. Persistent terminal/content layers,
route overlays, dialogs, and boot surfaces must not compete through ad-hoc
z-index literals. Pick a rung of the ladder in `styles.css` instead —
diff --git a/apps/desktop/src/app/chat/index.tsx b/apps/desktop/src/app/chat/index.tsx
index 899596a3a60..94a81320e1f 100644
--- a/apps/desktop/src/app/chat/index.tsx
+++ b/apps/desktop/src/app/chat/index.tsx
@@ -13,6 +13,7 @@ import { Thread } from '@/components/assistant-ui/thread'
import { TranscriptWindowProvider } from '@/components/assistant-ui/thread/transcript-window'
import { Backdrop } from '@/components/Backdrop'
import { COMPOSER_HEART_CONFIG, HeartField } from '@/components/chat/vibe-hearts'
+import { GuideGreetingPreview } from '@/components/onboarding-chat/greeting-preview'
import { usePaneVisible } from '@/components/pane-shell/pane-visibility'
import { $sessionTileDragging, $sessionTileEdgeHover } from '@/components/pane-shell/tree/store'
import { PromptOverlays } from '@/components/prompt-overlays'
@@ -31,6 +32,7 @@ import { migrateSessionDraft } from '@/store/composer'
import { migrateQueuedPrompts, parkQueuedPrompts } from '@/store/composer-queue'
import { $introSplash } from '@/store/intro-splash'
import { $pinnedSessionIds } from '@/store/layout'
+import { $guideOpening, $onboardingGate } from '@/store/onboarding-gate'
import { $petActive } from '@/store/pet'
import { $petOverlayActive } from '@/store/pet-overlay'
import { $activeGatewayProfile, $gatewaySwapTarget, $hydrationSyncProfile, $profiles } from '@/store/profile'
@@ -419,6 +421,8 @@ const ChatViewContent = memo(function ChatViewContent({
const composerScope = useComposerScope()
const composerSurfaceId = useComposerSurfaceId()
const isPrimary = view.kind === 'primary'
+ const guideOpening = useStore($guideOpening) && isPrimary
+ const guideStarted = useStoreSelector($onboardingGate, gate => gate.guideKickoff === 'started')
const activeSessionId = useStore(view.$runtimeId)
const transcriptStoredSessionId = useStoreSelector($sessionStates, states =>
@@ -573,7 +577,7 @@ const ChatViewContent = memo(function ChatViewContent({
// Hide the composer in the exhausted error state too: there's no live runtime
// to send to until a retry rebinds one. Watch windows are pure spectators of a
// subagent run driven elsewhere — no composer, transcript is read-only.
- const showChatBar = !loadingSession && !resumeExhausted && !isWatchWindow()
+ const showChatBar = !guideOpening && !loadingSession && !resumeExhausted && !isWatchWindow()
const threadKey = selectedSessionId || activeSessionId || (isRoutedSessionView ? location.pathname : 'new')
const modelOptionsQuery = useQuery<ModelOptionsResult>({
@@ -683,6 +687,7 @@ const ChatViewContent = memo(function ChatViewContent({
data-chat-unfocused={surfaceFocused ? undefined : ''}
data-composer-surface-id={composerSurfaceId}
data-composer-target={composerScope.target}
+ data-guide-arrived={isPrimary && guideStarted ? '' : undefined}
data-session-anchor={sessionAnchor}
>
<Backdrop />
@@ -716,19 +721,23 @@ const ChatViewContent = memo(function ChatViewContent({
data-slot="composer-bounds"
{...dropHandlers}
>
- <Thread
- clampToComposer={showChatBar}
- cwd={currentCwd}
- gateway={gateway}
- intro={showIntro ? { personality: introPersonality, seed: introSeed } : undefined}
- loading={threadLoading}
- onBranchInNewChat={onBranchInNewChat}
- onCancel={haltRun}
- onDismissError={onDismissError}
- onRestoreToMessage={onRestoreToMessage}
- sessionId={activeSessionId}
- sessionKey={threadKey}
- />
+ {guideOpening ? (
+ <GuideGreetingPreview />
+ ) : (
+ <Thread
+ clampToComposer={showChatBar}
+ cwd={currentCwd}
+ gateway={gateway}
+ intro={showIntro ? { personality: introPersonality, seed: introSeed } : undefined}
+ loading={threadLoading}
+ onBranchInNewChat={onBranchInNewChat}
+ onCancel={haltRun}
+ onDismissError={onDismissError}
+ onRestoreToMessage={onRestoreToMessage}
+ sessionId={activeSessionId}
+ sessionKey={threadKey}
+ />
+ )}
{resumeExhausted && routedSessionId && (
<div className="absolute inset-0 z-10 grid place-items-center bg-(--ui-chat-surface-background) px-8 py-10">
<ErrorState
diff --git a/apps/desktop/src/app/contrib/onboarding-kickoff.ts b/apps/desktop/src/app/contrib/onboarding-kickoff.ts
index ddce7e40efd..eb013b9a8d6 100644
--- a/apps/desktop/src/app/contrib/onboarding-kickoff.ts
+++ b/apps/desktop/src/app/contrib/onboarding-kickoff.ts
@@ -166,7 +166,10 @@ export function useOnboardingKickoff({
// Set the title explicitly so the backend does not name the session after the hidden runbook message.
await guideRequest('session.title', { session_id: runtimeId, title: SETUP_CHAT_TITLE }).catch(() => undefined)
- // session.create has already persisted both seed rows, so the caller may advance the phase.
+ // Creation persists the seed but resets the renderer's transcript. Adopt
+ // it before removing the local greeting, so the handoff has no blank frame.
+ await resumeSession(storedId ?? runtimeId, true)
+
return true
} catch (error) {
$newChatProfile.set(previousNewChatProfile)
diff --git a/apps/desktop/src/app/contrib/surfaces.tsx b/apps/desktop/src/app/contrib/surfaces.tsx
index 5bc3e493073..c89187c44c9 100644
--- a/apps/desktop/src/app/contrib/surfaces.tsx
+++ b/apps/desktop/src/app/contrib/surfaces.tsx
@@ -15,6 +15,7 @@ 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 { $activeGatewayProfile } from '@/store/profile'
import { $freshDraftReady, $gatewayState } from '@/store/session'
@@ -82,6 +83,7 @@ export const StatusbarSurface = memo(function StatusbarSurface({
const activeConnectionId = useStore($activeConnectionId)
const activeGatewayProfile = useStore($activeGatewayProfile)
const gatewayState = useStore($gatewayState)
+ const guideOpening = useStore($guideOpening)
const freshDraftReady = useStore($freshDraftReady)
const gatewayScope = `${activeConnectionId ?? ''}\0${activeGatewayProfile}`
const { inferenceStatus, statusSnapshot } = useStatusSnapshot(gatewayState, actions.requestGateway, gatewayScope)
@@ -104,7 +106,7 @@ export const StatusbarSurface = memo(function StatusbarSurface({
toggleCommandCenter: actions.toggleCommandCenter
})
- return <StatusbarControls items={statusbarItems} leftItems={leftStatusbarItems} />
+ return guideOpening ? null : <StatusbarControls items={statusbarItems} leftItems={leftStatusbarItems} />
})
/** The workspace pane: the real route table (chat + full-page views + plugin
diff --git a/apps/desktop/src/components/assistant-ui/markdown-text.tsx b/apps/desktop/src/components/assistant-ui/markdown-text.tsx
index d0e04ca3f48..8e70a0bad5d 100644
--- a/apps/desktop/src/components/assistant-ui/markdown-text.tsx
+++ b/apps/desktop/src/components/assistant-ui/markdown-text.tsx
@@ -448,6 +448,7 @@ function MarkdownImageContent({ className, src, alt, ...props }: ComponentProps<
}
interface MarkdownTextSurfaceProps {
+ caret?: ComponentProps<typeof StreamdownTextPrimitive>['caret']
containerClassName?: string
containerProps?: ComponentProps<'div'>
defer?: boolean
@@ -575,6 +576,7 @@ function MarkdownParagraph({
}
function MarkdownTextSurface({
+ caret,
containerClassName,
containerProps,
defer,
@@ -726,6 +728,7 @@ function MarkdownTextSurface({
label="markdown-render"
>
<StreamdownTextPrimitive
+ caret={caret}
components={components}
containerClassName={cn(MARKDOWN_CONTAINER_CLASS_NAME, containerClassName)}
containerProps={containerProps}
diff --git a/apps/desktop/src/components/onboarding-chat/gate.tsx b/apps/desktop/src/components/onboarding-chat/gate.tsx
index 6987c6da4e8..ccbcba8214c 100644
--- a/apps/desktop/src/components/onboarding-chat/gate.tsx
+++ b/apps/desktop/src/components/onboarding-chat/gate.tsx
@@ -1,12 +1,12 @@
import { useStore } from '@nanostores/react'
import { useEffect } from 'react'
-import { takeGuideShape } from '@/components/onboarding-chat/assembly'
+import { endChatOnboardingSolo, takeGuideShape } from '@/components/onboarding-chat/assembly'
import { isOnboardingEnabled } from '@/lib/onboarding-enabled'
import { ackFreeTierNotice, type FreeTierRequester } from '@/store/free-tier'
import { $introReveal } from '@/store/intro-reveal'
import { clearFreeTierIntro } from '@/store/onboarding'
-import { $onboardingGate, runGuideKickoff } from '@/store/onboarding-gate'
+import { $onboardingGate, runGuideKickoff, skipGuide } from '@/store/onboarding-gate'
interface OnboardingChatGateProps {
enabled: boolean
@@ -69,7 +69,16 @@ export function OnboardingChatGate({ enabled, onKickoff, requestGateway }: Onboa
useEffect(() => {
if (enabled && gate.guideQueued && intro.phase === 'hidden') {
- void runGuideKickoff(onKickoff)
+ const recover = () => {
+ endChatOnboardingSolo()
+ skipGuide()
+ }
+
+ void runGuideKickoff(onKickoff).then(started => {
+ if (!started) {
+ recover()
+ }
+ }, recover)
}
}, [enabled, gate.guideQueued, intro.phase, onKickoff])
diff --git a/apps/desktop/src/components/onboarding-chat/greeting-preview.css b/apps/desktop/src/components/onboarding-chat/greeting-preview.css
new file mode 100644
index 00000000000..826edf14d77
--- /dev/null
+++ b/apps/desktop/src/components/onboarding-chat/greeting-preview.css
@@ -0,0 +1,14 @@
+@keyframes guide-controls-arrive {
+ from { opacity: 0; }
+ to { opacity: 1; }
+}
+
+[data-guide-arrived] [data-slot='composer-dock'] {
+ animation: guide-controls-arrive 100ms ease-out;
+}
+
+@media (prefers-reduced-motion: reduce) {
+ [data-guide-arrived] [data-slot='composer-dock'] {
+ animation: none;
+ }
+}
diff --git a/apps/desktop/src/components/onboarding-chat/greeting-preview.test.tsx b/apps/desktop/src/components/onboarding-chat/greeting-preview.test.tsx
new file mode 100644
index 00000000000..e450ae8838f
--- /dev/null
+++ b/apps/desktop/src/components/onboarding-chat/greeting-preview.test.tsx
@@ -0,0 +1,41 @@
+import { act, cleanup, render } from '@testing-library/react'
+import { afterEach, expect, it, vi } from 'vitest'
+
+import { I18nProvider } from '@/i18n'
+
+import { GreetingPreviewText, greetingRevealFrames } from './greeting-preview'
+
+afterEach(() => {
+ cleanup()
+ vi.unstubAllGlobals()
+})
+
+it('reveals the exact greeting in graphemes and cancels its pending frame on unmount', () => {
+ const text = 'Hi 👩🏽‍💻.\n\n你好'
+ const frames = greetingRevealFrames(text)
+ const boundary = frames.find(frame => text.slice(0, frame.end).endsWith('👩🏽‍💻'))
+ expect(boundary).toBeDefined()
+ expect(frames.at(-1)?.end).toBe(text.length)
+ expect(frames.every((frame, index) => index === 0 || frame.at > frames[index - 1].at)).toBe(true)
+
+ let next: FrameRequestCallback | undefined
+ const cancel = vi.fn()
+ vi.stubGlobal('requestAnimationFrame', (callback: FrameRequestCallback) => {
+ next = callback
+
+ return 1
+ })
+ vi.stubGlobal('cancelAnimationFrame', cancel)
+
+ const { container, unmount } = render(
+ <I18nProvider>
+ <GreetingPreviewText text={text} />
+ </I18nProvider>
+ )
+
+ expect(container.querySelector('.sr-only')?.textContent).toBe(text)
+ act(() => next?.(performance.now() + 200))
+ expect(container.querySelector('[aria-hidden]')?.textContent).not.toContain('你好')
+ unmount()
+ expect(cancel).toHaveBeenCalled()
+})
diff --git a/apps/desktop/src/components/onboarding-chat/greeting-preview.tsx b/apps/desktop/src/components/onboarding-chat/greeting-preview.tsx
new file mode 100644
index 00000000000..66a76ebc533
--- /dev/null
+++ b/apps/desktop/src/components/onboarding-chat/greeting-preview.tsx
@@ -0,0 +1,89 @@
+import './greeting-preview.css'
+
+import { useStore } from '@nanostores/react'
+import { useReducedMotion } from 'motion/react'
+import { useEffect, useMemo, useState } from 'react'
+
+import { MarkdownTextContent } from '@/components/assistant-ui/markdown-text'
+import { $onboardingGreeting } from '@/components/onboarding-chat/assembly'
+import { $onboardingGate } from '@/store/onboarding-gate'
+
+/** Grapheme boundaries keep translated greetings and combined characters intact. */
+export function greetingRevealFrames(text: string): { end: number; at: number }[] {
+ const frames = []
+ let at = 0
+
+ for (const { index, segment } of new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment(text)) {
+ frames.push({ end: index + segment.length, at })
+ at += 1000 / 18
+
+ if (/[.!?。!?]$/u.test(segment)) {
+ at += 220
+ } else if (segment === '\n' && text[index - 1] === '\n') {
+ at += 650
+ }
+ }
+
+ return frames
+}
+
+export function GreetingPreviewText({ text }: { text: string }) {
+ const reducedMotion = useReducedMotion()
+ const frames = useMemo(() => greetingRevealFrames(text), [text])
+ const [end, setEnd] = useState(0)
+
+ useEffect(() => {
+ if (reducedMotion || !frames.length) {
+ return
+ }
+
+ let frame = 0
+ let index = 0
+ const start = performance.now()
+
+ const reveal = (now: number) => {
+ while (index < frames.length && frames[index].at <= now - start) {
+ index += 1
+ }
+
+ setEnd(index ? frames[index - 1].end : 0)
+
+ if (index < frames.length) {
+ frame = requestAnimationFrame(reveal)
+ }
+ }
+
+ frame = requestAnimationFrame(reveal)
+
+ return () => cancelAnimationFrame(frame)
+ }, [frames, reducedMotion])
+
+ const visible = reducedMotion ? text : text.slice(0, end)
+
+ return (
+ <div data-role="assistant" data-slot="guide-greeting-preview">
+ <span className="sr-only">{text}</span>
+ <div
+ aria-hidden
+ className="wrap-anywhere min-w-0 max-w-full overflow-hidden text-pretty text-[length:var(--conversation-text-font-size)] leading-(--dt-line-height) text-foreground"
+ data-slot="aui_assistant-message-content"
+ >
+ <MarkdownTextContent caret={reducedMotion ? undefined : 'block'} isRunning={visible !== text} text={visible} />
+ </div>
+ </div>
+ )
+}
+
+/** A local presentation of the exact greeting later persisted by session.create. */
+export function GuideGreetingPreview() {
+ const greeting = useStore($onboardingGreeting)
+ const gate = useStore($onboardingGate)
+
+ return (
+ <div className="h-full overflow-y-auto" data-slot="guide-opening">
+ <div className="mx-auto w-full max-w-(--composer-width) min-w-0 px-6 pt-[calc(var(--titlebar-height)-0.5rem)]">
+ {gate.phase === 'cinematic' && greeting && <GreetingPreviewText key={greeting} text={greeting} />}
+ </div>
+ </div>
+ )
+}
diff --git a/apps/desktop/src/store/guide-opening.test.ts b/apps/desktop/src/store/guide-opening.test.ts
new file mode 100644
index 00000000000..de4139c3729
--- /dev/null
+++ b/apps/desktop/src/store/guide-opening.test.ts
@@ -0,0 +1,30 @@
+import { expect, it, vi } from 'vitest'
+
+it('keeps the opening visible through a shared kickoff and settles only after the seed is durable', async () => {
+ vi.stubGlobal('hermesDesktop', { guestOnboardingEnabled: true })
+ const { $guideOpening, $onboardingGate, runGuideKickoff, skipGuide } = await import('./onboarding-gate')
+ $onboardingGate.set({ phase: 'cinematic', guideQueued: true, guideKickoff: 'idle' })
+
+ let finishSeed: (ready: boolean) => void = () => {}
+
+ const seed = new Promise<boolean>(resolve => {
+ finishSeed = resolve
+ })
+
+ const kickoff = vi.fn(() => seed)
+ expect($guideOpening.get()).toBe(true)
+
+ const first = runGuideKickoff(kickoff)
+ const second = runGuideKickoff(kickoff)
+ expect(first).toBe(second)
+ expect($onboardingGate.get().guideKickoff).toBe('starting')
+ expect($guideOpening.get()).toBe(true)
+ finishSeed(true)
+ await first
+ expect(kickoff).toHaveBeenCalledOnce()
+ expect($guideOpening.get()).toBe(false)
+ expect($onboardingGate.get().phase).toBe('guided')
+ skipGuide()
+ expect($guideOpening.get()).toBe(false)
+ vi.unstubAllGlobals()
+})
diff --git a/apps/desktop/src/store/onboarding-gate.test.ts b/apps/desktop/src/store/onboarding-gate.test.ts
index 9ad83bb01d1..1c9d0485cef 100644
--- a/apps/desktop/src/store/onboarding-gate.test.ts
+++ b/apps/desktop/src/store/onboarding-gate.test.ts
@@ -44,7 +44,7 @@ it('a skipped intro still queues the guided flow, and never replays the film', a
beginOnboardingFlowWithoutIntro(false)
const { $onboardingGate } = await import('./onboarding-gate')
- expect($onboardingGate.get()).toEqual({ phase: 'cinematic', guideQueued: true })
+ expect($onboardingGate.get()).toEqual({ phase: 'cinematic', guideQueued: true, guideKickoff: 'idle' })
// The film is recorded as watched: a later launch without HERMES_SKIP_INTRO
// must adopt the persisted guide, not play the film over it.
expect(hasSeenIntroReveal()).toBe(true)
diff --git a/apps/desktop/src/store/onboarding-gate.ts b/apps/desktop/src/store/onboarding-gate.ts
index f90d655bec9..de7a1d78f02 100644
--- a/apps/desktop/src/store/onboarding-gate.ts
+++ b/apps/desktop/src/store/onboarding-gate.ts
@@ -1,9 +1,9 @@
-import { atom } from 'nanostores'
+import { atom, computed } from 'nanostores'
import { isOnboardingEnabled } from '@/lib/onboarding-enabled'
import { readKey, writeKey } from '@/lib/storage'
-import { hasSeenIntroReveal, markIntroRevealSeen } from './intro-reveal'
+import { $introReveal, hasSeenIntroReveal, markIntroRevealSeen } from './intro-reveal'
import { DEFAULT_ANSWERS, setOnboardingAnswers } from './onboarding-answers'
const PHASE_KEY = 'hermes-onboarding-phase-v1'
@@ -19,6 +19,7 @@ function isOnboardingPhase(value: string | null): value is OnboardingPhase {
export interface OnboardingGateState {
phase: OnboardingPhase
guideQueued: boolean
+ guideKickoff: 'idle' | 'starting' | 'started'
}
type GuideKickoff = { status: 'idle' } | { status: 'starting'; promise: Promise<boolean> } | { status: 'started' }
@@ -34,16 +35,30 @@ function loadGate(): OnboardingGateState {
// connected splash, the stock composer and model picker, a small window
// whose sidebars cannot open) while the gate still says the guide is on.
// The kickoff adopts the existing guide chat by title, so nothing is lost.
- return { phase, guideQueued: (phase === 'cinematic' && hasSeenIntroReveal()) || phase === 'guided' }
+ return {
+ phase,
+ guideQueued: (phase === 'cinematic' && hasSeenIntroReveal()) || phase === 'guided',
+ guideKickoff: 'idle'
+ }
}
export const $onboardingGate = atom<OnboardingGateState>(loadGate())
let guideKickoff: GuideKickoff = { status: 'idle' }
+export const $guideOpening = computed(
+ [$onboardingGate, $introReveal],
+ (gate, intro) =>
+ isOnboardingEnabled() && gate.guideQueued && intro.phase === 'hidden' && gate.guideKickoff !== 'started'
+)
+
+function setGuideKickoff(state: GuideKickoff): void {
+ guideKickoff = state
+ $onboardingGate.set({ ...$onboardingGate.get(), guideKickoff: state.status })
+}
function setPhase(phase: OnboardingPhase): void {
writeKey(PHASE_KEY, phase === 'idle' ? null : phase)
- $onboardingGate.set({ phase, guideQueued: false })
+ $onboardingGate.set({ ...$onboardingGate.get(), phase, guideQueued: false })
}
/** The guided first launch is on screen or mid-handoff. Ambient chrome that
@@ -116,7 +131,7 @@ export function runGuideKickoff(kickoff: () => Promise<boolean>): Promise<boolea
.then(kickoff)
.then(
started => {
- guideKickoff = { status: started ? 'started' : 'idle' }
+ setGuideKickoff({ status: started ? 'started' : 'idle' })
if (started && $onboardingGate.get().phase === 'cinematic') {
setPhase('guided')
@@ -125,13 +140,13 @@ export function runGuideKickoff(kickoff: () => Promise<boolean>): Promise<boolea
return started
},
error => {
- guideKickoff = { status: 'idle' }
+ setGuideKickoff({ status: 'idle' })
throw error
}
)
- guideKickoff = { status: 'starting', promise }
+ setGuideKickoff({ status: 'starting', promise })
return promise
}
@@ -164,7 +179,7 @@ export function devResetOnboardingFlow(): void {
return
}
- guideKickoff = { status: 'idle' }
+ setGuideKickoff({ status: 'idle' })
setPhase('idle')
setOnboardingAnswers({ ...DEFAULT_ANSWERS, connectors: [...DEFAULT_ANSWERS.connectors] })
}