ov.setShowGlobalSearch(true)} onNotificationClick={ov.toggleNotifications} />
{/* Below sm the bottom bar (MobileNav, 56px plus the safe-area inset)
replaces the rail, so the canvas stops above it. */}
{/* Warm-Hive calm spine (ia.html) — five places + workspace pill +
⌘K tile + user row; all remaining depth lives in ⌘K. */}
ov.setShowGlobalSearch(true)}
onSpawnAgent={() => ov.setShowSpawnAgent(true)}
userName={userName}
/>
{/* Single canvas (§2.1 rule 1). Route wrappers bring their own
AppErrorBoundary, mirroring Desktop.tsx:556-558. */}
{/* §4.2 keep-alive: ChatHost portals one live ChatWindowInstance per
visited workspace, so navigation can't kill in-flight SSE
streams. It renders no layout DOM of its own. NOTE: it stays a
SIBLING of RouteTransition (never wrapped) so the crossfade can
never remount it and kill an in-flight stream. */}
{deferredShellElement()}
{/* Pillar 1.1 · Lane RT: the default fade-through crossfade + persistent
chrome for top-level route changes. Wraps ONLY the Outlet; the
sidebar + StatusBar above are outside this subtree, so they persist.
Feature-flagged + reduced-motion-aware; focus/AT ships inside it. */}
ov.setShowGlobalSearch(true)} />
{/* Overlays — Desktop.tsx:569-663 relocated; handlers retarget to
navigate() per §1.2 / §2.2. */}
{/* P7/D15 B3: the Win+K overlay sits outside the SurfaceBoundary-wrapped
Outlet, so an un-caught render throw here blanks the whole shell. Wrap
it in the same AppErrorBoundary the routes use; onClose dismisses it. */}
{ov.showGlobalSearch && deferredShellElement(
ov.setShowGlobalSearch(false)}>
ov.setShowGlobalSearch(false)}
onNavigate={handleSearchNavigate}
onExecute={() => { /* post-success hook — overlay closes itself; refresh feeds lazily */ }}
workspaceId={effectiveActiveWorkspaceId ?? undefined}
catalog={commandCatalog}
onCatalogSelect={handleCatalogSelect}
/>
)}
{ov.showCreateWorkspace && deferredShellElement(
ov.setShowCreateWorkspace(false)} onCreate={createWorkspace} />
)}
{/* §1.2/§4.2: PersonaSwitcher acts on the active workspace's chat widget
(widget state, NOT the workspace record — acceptance check 7); the
workspace-record patch survives as the no-real-workspace fallback. */}
{ov.showPersonaSwitcher && deferredShellElement(
ov.setShowPersonaSwitcher(false)}
currentPersona={(hasRealActiveWorkspace ? activeChatEntry.personaId : undefined) ?? effectiveActiveWorkspace?.persona}
currentGroupId={effectiveActiveWorkspace?.agentGroupId}
currentTemplateId={effectiveActiveWorkspace?.templateId}
onSelect={(personaId) => {
if (hasRealActiveWorkspace) {
setActiveChatPersona(personaId);
} else if (effectiveActiveWorkspaceId) {
patchWorkspace(effectiveActiveWorkspaceId, { persona: personaId, agentGroupId: undefined });
}
}}
onSelectGroup={(groupId) => { if (effectiveActiveWorkspaceId) patchWorkspace(effectiveActiveWorkspaceId, { agentGroupId: groupId, persona: undefined }); }} />
)}
{ov.showWorkspaceSwitcher && deferredShellElement(
ov.setShowWorkspaceSwitcher(false)}
workspaces={workspaces} activeWorkspaceId={effectiveActiveWorkspaceId}
error={workspacesError} onRetry={() => { void refreshWorkspaces(); }}
onCreateNew={() => ov.setShowCreateWorkspace(true)}
onViewAll={() => { ov.setShowWorkspaceSwitcher(false); navigate('/workspaces'); }}
onSelect={(id) => { selectWorkspace(id); ov.setShowWorkspaceSwitcher(false); navigate(`/workspaces/${id}`); }} />
)}
{ov.showNotifications && deferredShellElement(
ov.setShowNotifications(false)} notifications={notifications} onMarkRead={markRead} onMarkAllRead={markAllRead} />
)}
{ov.showKeyboardHelp && deferredShellElement(
ov.setShowKeyboardHelp(false)} />
)}
{ov.showSpawnAgent && deferredShellElement(
ov.setShowSpawnAgent(false)}
workspaces={workspaces} activeWorkspaceId={effectiveActiveWorkspaceId} onWorkspaceCreated={(ws) => selectWorkspace(ws.id)}
onSpawned={({ roomId, runId }) => {
ov.setShowSpawnAgent(false);
navigate(`/room?room=${encodeURIComponent(roomId)}&run=${encodeURIComponent(runId)}`);
}} />
)}
{shouldShowCoachMarks({
completed: onboardingState.completed,
tooltipsDismissed: !!onboardingState.tooltipsDismissed,
completedAt: onboardingState.completedAt ?? null,
completedThisSession: readOnboardedThisSession(),
forceTour: readForceTour(),
}) && deferredShellElement(
{ clearForceTour(); updateOnboarding({ tooltipsDismissed: true }); }}
suppressed={anyModalOpen}
/>
)}
{/* FR #45: one post-onboarding overlay at a time — Tour first, then the
briefing once Tour is dismissed (gating relocated from Desktop.tsx:621-637).
Home-only: the greeting belongs to the cockpit — overlaying Memory or
Skills hides the very surfaces that prove the product's claims.
Wave Q Lane A (item 2 — one problem, one voice): when the sidecar is
unreachable the SAME root cause already surfaces as Home's own error
state + the NoModelBanner, so suppress the briefing entirely rather than
stack a third symptom on top. The connection problem is announced once.
Wave U Lane B (item 1 — interruption discipline): gate on briefingLanding
('armed' = Home was the session's landing surface AND we haven't left it),
NOT the live pathname alone — so a mid-session Settings→Home never re-pops
it. The trailing pathname check absorbs the one-frame effect lag.
Lane H item 4: additionally require a ≥7-day absence — otherwise the home
hero's recall strip is the catch-up, and this modal stays closed. */}
{onboardingState.completed && onboardingState.tooltipsDismissed && ov.showLoginBriefing
&& !askAnalyticsConsent && briefingLanding === 'armed' && location.pathname.startsWith('/home') && !offline
&& briefingAwayDays >= BRIEFING_ABSENCE_DAYS && (
deferredShellElement(
{
if (permanent) writeLoginBriefingDismissed(true);
writeLoginBriefingLastDismissedAt();
ov.setShowLoginBriefing(false);
}}
onOpenWorkspace={(wsId) => { writeLoginBriefingLastDismissedAt(); selectWorkspace(wsId); navigate(routeFor('chat', { activeWorkspaceId: wsId })); ov.setShowLoginBriefing(false); }}
/>
)
)}
{/* Phase C.1: Context Rail (owned by the shell; surfaces feed it via
onContextRail props — §1.2 last row). */}
{contextRailTarget && deferredShellElement(
setContextRailTarget(null)} />
)}
{analyticsConsentDialog}
);
};
/**
* Boot gate (FR #23, ported from pages/Index.tsx:14-36): the boot signal is
* split into "boot finished" (gates BootScreen exit animation) and "show
* shell" (gates the layout + its overlays) so the exit transition finishes
* BEFORE the shell mounts. ShellProvider mounts inside the gate so its hooks
* start fetching post-boot, exactly when Desktop's hooks start today.
*/
const AppShell = () => {
// §3.3: one-shot `waggle-window-state-v1` migration, run on the first shell
// render — BEFORE the first canvas render (the Outlet only mounts inside
// ShellLayout below). The salvage side effects (chat-state merge + key
// removal) run on every entry path; the salvaged initialRoute is applied
// only via IndexRedirect when the app ENTERED on '/' (a typed deep link
// always wins — acceptance check 2).
useState(() => bootWindowStateMigration(window.location.pathname));
// Wave T Lane A (item 2): warm the LoginBriefing payload cache while the boot
// sequence runs (~4s), so the briefing greets with content instead of opening
// as a bare spinner. Skipped when the user turned the briefing off. Fire-and-
// forget; the adapter's connect gate defers the requests until the sidecar is
// reachable, and prefetchBriefing swallows its own rejection.
useEffect(() => {
if (!readLoginBriefingDismissed() && !readSkipBriefingParam()) prefetchBriefing();
}, []);
const [initialBooted] = useState(() => {
const params = new URLSearchParams(window.location.search);
const shouldSkipBoot = params.get('skipOnboarding') === 'true' || params.get('skipBoot') === 'true';
if (shouldSkipBoot) {
localStorage.setItem(BOOT_KEY, 'true');
return true;
}
return localStorage.getItem(BOOT_KEY) !== null;
});
// Wave T Lane A (item 1): the onboarding wizard flashes for ~1s for a
// server-onboarded user whose webview localStorage is fresh — the P4
// /api/onboarding/status probe only resolves AFTER the shell mounts, so the
// wizard paints before the auto-complete lands. Hold boot until the decision
// is KNOWN: sync when localStorage already settles it, else probe the server
// (capped so a dead endpoint can't brick boot — 3s, inside the boot screen's
// own 3-4s runtime, because a 1.5s cap still let the wizard flash on a cold
// dev server where the status roundtrip runs long). resolveReturningUser-
// Onboarding persists the completed flag so useOnboarding reads it
// synchronously and never renders the wizard for an onboarded user.
const [onboardingResolved, setOnboardingResolved] = useState(isOnboardingStatusKnownSync);
useEffect(() => {
if (onboardingResolved) return;
let settled = false;
const finish = () => { if (!settled) { settled = true; setOnboardingResolved(true); } };
void resolveReturningUserOnboarding().finally(finish);
const cap = window.setTimeout(finish, 3000);
return () => window.clearTimeout(cap);
}, [onboardingResolved]);
const [booted, setBooted] = useState(initialBooted);
const [showShell, setShowShell] = useState(() => initialBooted && isOnboardingStatusKnownSync());
// Lane H item 5: a warm session (returning user WITH a cache-first Home payload
// to paint behind the boot screen) shortens the brand flash to ≤500ms. A cold /
// day-0 launch (nothing cached to paint) keeps the full brand moment.
const [warmBoot] = useState(() => initialBooted && homeCacheExists());
// Fast path with no BootScreen to animate out (already booted this session):
// reveal the shell once onboarding resolves, since onExitComplete never fires.
useEffect(() => {
if (initialBooted && onboardingResolved) setShowShell(true);
}, [initialBooted, onboardingResolved]);
const handleBootComplete = () => {
localStorage.setItem(BOOT_KEY, 'true');
setBooted(true);
};
// Hold the BootScreen until BOTH the boot sequence finished AND onboarding
// status is known (item 1) — only then may it animate out and the shell mount.
const bootComplete = booted && onboardingResolved;
return (
<>
{/* Wave U Lane D: `ready` shortens the boot floor. The boot screen shows
its brand moment then exits the instant the shell's deps resolve —
onboarding resolution is the one genuinely-slow pre-boot dependency (a
server probe capped at 3s above). The briefing prefetch is fire-and-
forget on mount, and the workspace store warms inside ShellProvider
(post-boot), so neither can gate the floor. While onboarding is
unresolved the boot holds past the floor rather than flash the wizard. */}