"use client" /** * The Ask Leo launcher — the chip that opens Leo from the shell's utility bar. * * Every element the launcher's stylesheet targets is created here: * `data-ask-leo-utility-glow-wrap` and its `data-intro`, the glow layer, the * wash, the star wrapper, and the label. That is the whole reason this component * exists rather than the five consumer files it replaces. The arrival is a CSS * animation shipped in the package's `globals.css`, and a stylesheet that * selects markup it does not own is a release that lands inert: consumers took * the new CSS, kept their own older chip, and saw nothing change. * * Leo's own state stays with the consumer. `open`, `busy`, and `onToggle` are * props because which thread is open — and whether it is mid-answer — is the * app's model, and the package cannot ship the provider that holds it. The * arrival, the greeting, and the chrome are the package's, so they are not * props. * * `showLabel` is the density decision, not a style: at `false` the chip is * icon-only and the arrival's opening beat has nothing to open, which is what * the compact bar wants. The label's box animating from zero is what takes the * comfortable chip from icon to icon-and-name on load. */ import * as React from "react" import { Button } from "../ui/button" import { LeoIcon, type LeoIconSize } from "../ui/leo-icon" import { Tooltip, TooltipContent, TooltipTrigger, } from "../ui/tooltip" import { useOneShotIntro } from "../../hooks/use-one-shot-intro" import { useStagedGreeting } from "../../hooks/use-staged-greeting" import { cn } from "../../lib/utils" import { AskLeoLauncherWash } from "./ask-leo-launcher-wash" import { askLeoLauncherChipClass, utilityBarActionButtonClass, } from "./utility-bar-chrome" type LauncherSize = "sm" | "lg" const BUTTON_SIZE_BY_KEY = { "label-sm": "sm", "label-lg": "default", "icon-sm": "icon-sm", "icon-lg": "icon", } as const function launcherButtonSize(showLabel: boolean, size: LauncherSize) { return BUTTON_SIZE_BY_KEY[`${showLabel ? "label" : "icon"}-${size}`] } function launcherButtonClass( showLabel: boolean, size: LauncherSize, disabled: boolean, buttonClassName?: string, ) { const labelled = showLabel ? LABELLED_CLASS[size] : undefined return cn( "relative z-[1] items-center overflow-visible", utilityBarActionButtonClass, askLeoLauncherChipClass, labelled, disabled && "cursor-not-allowed text-muted-foreground opacity-60", buttonClassName, ) } const LABELLED_CLASS: Record = { sm: "h-8 gap-1.5 px-2", lg: "gap-1.5", } const FALLBACK_STAR_TEXT: Record = { lg: "text-sm", sm: "text-xs", } function motionIsActive( disabled: boolean, busy: boolean, hovered: boolean, greeting: boolean, ) { return !disabled && !busy && (hovered || greeting) } function LauncherStar({ animatedStar, busy, disabled, hovered, greeting, size, starSize, iconClassName, }: { animatedStar: boolean busy: boolean disabled: boolean hovered: boolean greeting: boolean size: LauncherSize starSize: LeoIconSize iconClassName?: string }) { if (animatedStar) { return ( ) } return (