Fix slow onboarding when the agent thinking state blocks new users too long
Summary
Fix slow onboarding for new users where the app stays on "Your agent is thinking..." for too long.
Problem
During onboarding, new users are blocked on a long loading/thinking state. This makes first-time setup feel slow and unresponsive.
Observed Behavior
- New user enters onboarding/chat flow.
- Screen stays on "Your agent is thinking..." for an extended time.
- User cannot progress quickly.
Expected Behavior
- Onboarding should feel fast and responsive.
- Agent response should appear quickly or use a clear fallback/template.
- User should not be blocked indefinitely by slow agent generation.
Scope
- Identify what causes long thinking time during onboarding.
- Add timeout/fallback response for slow welcome/onboarding agent generation.
- Preload or cache required onboarding context where possible.
- Ensure onboarding can continue even if agent generation is delayed.
- Improve loading UI with clearer progress or next action.
- Add telemetry for onboarding wait time and agent-generation latency.
Acceptance Criteria
- New users are not stuck waiting on "Your agent is thinking...".
- Onboarding agent responds within an acceptable time or uses fallback.
- User can continue onboarding even if agent generation is slow.
- No repeated/stalled thinking states during first-time onboarding.
- Tests cover slow-agent and fallback onboarding paths.
Closing as completed — the user-visible problem here was resolved by an alternate mechanism. PR #1180 (closes #1123) replaced the entire welcome-agent onboarding path with a `react-joyride` walkthrough, which structurally removes the "agent thinking" wait that this issue was about.
Verification on current `main` (e945390d)
Confirmed the welcome-agent dispatch path is dead end-to-end on `tinyhumansai/openhuman:main`:
- `app/src/pages/Conversations.tsx:99-123` — `WelcomeThinkingTypewriter` (the "Your agent is thinking..." loader) is fully commented out with `[#1123]` markers; the only remaining grep hits for the string are inside those comments.
- `app/src/pages/Conversations.tsx:840-848` — `composerInteractionBlocked` is now hardcoded to `welcomePending: false`; the lockout that this issue was hitting can no longer fire.
- `app/src/pages/Conversations.tsx:1400-1416` — the welcome-thread JSX branch is commented; the empty-thread render is just `
No messages yet
`. - `app/src/pages/onboarding/OnboardingLayout.tsx:62-149` — `completeAndExit` no longer creates a welcome thread, no longer fires `chatSend(WELCOME_TRIGGER_MESSAGE, ...)`, and no longer touches `setWelcomeThreadId`. It now calls `setOnboardingCompletedFlag(true)` -> `setWalkthroughPending()` -> `navigate('/home')`. All `chat_send` / `thread_create_new` welcome paths are commented.
- `app/src/components/walkthrough/AppWalkthrough.tsx` — the replacement is purely localStorage flags + `react-joyride`. No socket subscriptions, no provider calls, no agent runs.
- `app/src/App.tsx:181-183` — `
` mounts unconditionally outside routes (gated only by `!isBootstrapping && !onOnboardingRoute`); no `welcomeLocked` route guard remains live. - `app/src/lib/coreState/store.ts:104-113` — `isWelcomeLocked()` now hard-returns `false`; old call sites are kept only to avoid import churn.
- Greps `WelcomeThinkingTypewriter`, `welcomePending: true`, `chat_send.*welcome|welcome_trigger`, "Your agent is thinking" return zero non-commented hits in `app/src` (the only `welcomePending: true` matches are in two test files asserting the legacy blocker logic, which is fine).
Tests
- `pnpm test:unit walkthrough onboarding` -> 55/55 passing across 7 files (covers `AppWalkthrough`, `OnboardingLayout`, `WelcomeStep`, `LocalAIStep`, `ContextGatheringStep`, `SkillsPage`).
- `cargo test -p openhuman --lib agent::agents::welcome` -> 4/4 passing. (These exercise the still-present Rust `welcome` prompt builder, which is now unreachable but harmless.)
Why this resolves #989
#989 was triggered by the welcome agent's "thinking..." state blocking the composer for too long after wizard exit. With the welcome-agent path gone:
- there is no thread auto-created at wizard exit,
- there is no synthetic `WELCOME_TRIGGER_MESSAGE` `chat_send`,
- there is no `welcomePending`-driven composer lockout,
- the post-wizard UX is a Joyride overlay over a normally-functional `/home`, with the composer fully interactive immediately.
Follow-up (separate cleanup, not blocking close)
Tracking dead-code rip-out as a separate housekeeping task: remove the commented welcome agent (`src/openhuman/agent/agents/welcome/*`), the `chat_onboarding_completed` flag, the `welcomePending` parameter on `isComposerInteractionBlocked`, the `welcomeThreadId` state on `threadSlice`, and the always-false `isWelcomeLocked` helper. Will file as its own issue.
Closing as completed — user-visible problem resolved by alternate mechanism (Joyride walkthrough). Tracking dead-code rip-out (welcome agent, `chat_onboarding_completed` flag, `welcomePending` param) as separate cleanup follow-up.
Closing #989 — symptom obviated by PR #1180 / #1123 (Joyride walkthrough replaced welcome-agent onboarding).
Verified on main (synced with upstream/main):
app/src/pages/Conversations.tsx:99-123—WelcomeThinkingTypewriterfully commented out; render branch atConversations.tsx:1400-1413is dead.app/src/pages/Conversations.tsx:844-848—composerInteractionBlockednow passeswelcomePending: falseunconditionally; the slow-thinking lockout cannot fire.app/src/pages/onboarding/OnboardingLayout.tsx:62-149—completeAndExitno longer creates a welcome thread or fires theWELCOME_TRIGGER_MESSAGEchat_send; it just callssetWalkthroughPending()andnavigate('/home').app/src/components/walkthrough/AppWalkthrough.tsx:78-117— Joyride mounts on/homepost-onboarding, gated byisWalkthroughPending(onboarded), with no chat round-trip.app/src/App.tsx:181-183—<AppWalkthrough>mounted outside routes so it persists across tabs.app/src/store/threadSlice.ts:295-300—setWelcomeThreadIdis now an explicit no-op stub;welcomeThreadIdis never mutated, so the prior fallback inproviders/ChatRuntimeProvider.tsx:145always falls through.- Greps (
grep -rn "WelcomeThinkingTypewriter\|welcomePending: true\|chat_send.*welcome\|welcome_trigger\|Your agent is thinking" app/src) return only commented references and test-only lines — no live call sites. - Tests on current
main:pnpm debug unit walkthrough(28/28),pnpm debug unit onboarding(27/27),pnpm debug unit Conversations.welcomeLock(4/4),cargo test -p openhuman --lib agent::agents::welcome(4/4) — all pass.
Tracking dead-code rip-out (welcome agent + chat_onboarding_completed flag + welcomePending plumbing + setWelcomeThreadId no-op) as a separate cleanup follow-up.