moving
Some checks failed
Installer Smoke / installer-smoke (push) Has been cancelled

This commit is contained in:
Oleg Maslov
2026-09-02 10:10:29 +02:00
commit 0c3e2ead3b
3841 changed files with 970576 additions and 0 deletions

View File

@@ -0,0 +1,112 @@
import { useState, type ReactNode } from 'react';
import { motion, useReducedMotion } from 'framer-motion';
import { ChevronDown, Sparkles } from 'lucide-react';
import { cn } from '@/lib/utils';
import { SPRING } from '@/lib/motion/tokens';
import { DotLive } from './DotLive';
import { ProvenanceLine } from './ProvenanceLine';
import type { WarmTone } from './tones';
export interface ActivityStep {
tone?: WarmTone;
text: ReactNode;
/** Provenance for the step — rendered only when real source data exists. */
provenance?: { source: string; when?: string; onClick?: () => void };
/**
* Surprise-recall bloom (Pillar 3.2): when true, the step row blooms honey on
* mount — a SPRING.micro scale pop + a ~600ms honey glow that fades, drawing the
* eye to the "it remembered" moment. Set only for the memory-recall step of the
* ACTIVE turn; reduced-motion renders a plain row (no bloom).
*/
bloom?: boolean;
}
interface ActivityStreamProps {
/** e.g. "Worked across memory, web & files". */
summary: string;
durationMs?: number;
steps: ActivityStep[];
/** Default-open on the active turn; collapsed on prior turns. */
defaultOpen?: boolean;
className?: string;
}
/**
* The Chat "activity stream" — a collapsible card that reveals the agent's
* steps (each with a tone dot and optional provenance pill). The header shows a
* summary + step count + duration. Violet spark = intelligence/memory work.
*/
export function ActivityStream({
summary,
durationMs,
steps,
defaultOpen = false,
className,
}: ActivityStreamProps) {
const [open, setOpen] = useState(defaultOpen);
const reduce = useReducedMotion();
const seconds = durationMs != null ? `${Math.max(1, Math.round(durationMs / 1000))}s` : null;
const meta = [`${steps.length} step${steps.length === 1 ? '' : 's'}`, seconds].filter(Boolean).join(' · ');
return (
<div className={cn('rounded-[14px] border border-[var(--line-soft)] bg-[var(--bg-2)]', className)}>
<button
type="button"
onClick={() => setOpen((o) => !o)}
aria-expanded={open}
className="flex w-full items-center gap-2.5 px-3.5 py-2.5 text-left"
>
<Sparkles className="h-4 w-4 shrink-0 text-[var(--intel)]" strokeWidth={1.8} />
<span className="flex-1 text-[13px] text-[var(--text-2)]">
{summary}
{meta && <span className="text-[var(--text-dim)]"> · {meta}</span>}
</span>
<ChevronDown
className={cn(
'h-4 w-4 shrink-0 text-[var(--text-dim)] transition-transform motion-reduce:transition-none',
open && 'rotate-180',
)}
/>
</button>
{open && (
<ul className="space-y-2 border-t border-[var(--line-soft)] px-3.5 py-3">
{steps.map((s, i) => {
const rowContent = (
<>
<DotLive tone={s.tone ?? 'intel'} live={false} size={7} className="mt-1.5" />
<span className="min-w-0 flex-1">
{s.text}
{s.provenance && (
<span className="mt-1 block">
<ProvenanceLine {...s.provenance} />
</span>
)}
</span>
</>
);
// Surprise-recall bloom: honey glow (CSS keyframe) + SPRING.micro scale
// pop on mount. Skipped under reduced-motion → a plain row (no bloom).
if (s.bloom && !reduce) {
return (
<motion.li
key={i}
data-recall-bloom="true"
className="recall-bloom flex items-start gap-2.5 rounded-lg text-[13px] text-[var(--text-2)]"
initial={{ scale: 0.96 }}
animate={{ scale: 1 }}
transition={SPRING.micro}
>
{rowContent}
</motion.li>
);
}
return (
<li key={i} className="flex items-start gap-2.5 text-[13px] text-[var(--text-2)]">
{rowContent}
</li>
);
})}
</ul>
)}
</div>
);
}

View File

@@ -0,0 +1,48 @@
import { useReducedMotion } from 'framer-motion';
import { cn } from '@/lib/utils';
interface AmbientHiveGlowProps {
/**
* Home-only gate (Pillar 3.4): the whole ambient is behind this prop so it can
* never leak onto another surface. Renders nothing when false.
*/
active?: boolean;
className?: string;
}
/**
* AmbientHiveGlow — a slow honey "breath" behind the Home hero zone (Pillar 3.4,
* brand HIGH). A very-low-amplitude honey radial that swells and settles on a ~6s
* cycle so the surface feels alive WITHOUT competing with content — the brand's
* "respectful, no gratuitous movement" WIN must survive, so the amplitude stays
* below the attention threshold (a faint --honey-glow radial, opacity breath only,
* no travel, no color shift).
*
* Purely decorative: aria-hidden + pointer-events-none, painted behind everything
* via -z-10. Reduced-motion (REDUCED.ambient = 'off'): the loop stops — a single
* static faint radial remains (no movement). The breath keyframe is ALSO stilled
* in index.css's prefers-reduced-motion block as a backstop.
*/
export function AmbientHiveGlow({ active = true, className }: AmbientHiveGlowProps) {
const reduce = useReducedMotion();
if (!active) return null;
return (
<div
aria-hidden
data-testid="ambient-hive-glow"
data-reduced={reduce ? 'true' : 'false'}
className={cn(
'pointer-events-none absolute inset-x-0 top-0 -z-10 h-[440px] overflow-hidden',
className,
)}
>
<div
className={cn(
'absolute left-1/2 top-[-160px] h-[560px] w-[860px] -translate-x-1/2 rounded-full',
'bg-[radial-gradient(ellipse_at_center,var(--honey-glow),transparent_66%)]',
reduce ? 'opacity-50' : 'hive-ambient-breath',
)}
/>
</div>
);
}

View File

@@ -0,0 +1,109 @@
import { useState } from 'react';
import { Plus, ArrowUp, Search } from 'lucide-react';
import { cn } from '@/lib/utils';
import { cmdKLabel } from '@/lib/platform';
interface AskBarProps {
placeholder?: string;
onSubmit: (text: string) => void;
/** Optional "+" affordance — receives the current trimmed input (quick note);
* callers open the command palette when the input is empty (no dead button). */
onPlus?: (text: string) => void;
/** Optional keystroke tap — lets a host use the bar as a live filter too
* (Marketplace single smart input). Fires with '' when the bar clears. */
onChange?: (text: string) => void;
cmdkHint?: boolean;
/** Submit affordance intent. 'send' (default) is the Home composer up-arrow;
* 'search' swaps to a magnifier + "Search" label so a search bar doesn't read
* as a scroll-to-top control (R10 Lane C). */
submitVariant?: 'send' | 'search';
className?: string;
}
/**
* Full-width ask pill with a honey "+" affordance, a ⌘K hint, and a honey send
* button — the Home composer. Enter submits (Shift+Enter is a newline-safe
* no-op here since it's a single-line input).
*/
export function AskBar({
placeholder = 'Start something new — “draft the board update from this week’s work”…',
onSubmit,
onPlus,
onChange,
cmdkHint = true,
submitVariant = 'send',
className,
}: AskBarProps) {
const [value, setValue] = useState('');
const setAndTap = (next: string) => {
setValue(next);
onChange?.(next);
};
const submit = () => {
const text = value.trim();
if (!text) return;
onSubmit(text);
setAndTap('');
};
return (
<div
className={cn(
'flex items-center gap-2 rounded-full border border-[var(--line)] bg-[var(--surface)] px-2 py-2 transition-colors focus-within:border-[var(--honey-line)] focus-within:shadow-[var(--shadow-honey)]',
className,
)}
>
{onPlus && (
<button
type="button"
aria-label="Quick capture"
onClick={() => {
const text = value.trim();
onPlus(text);
if (text) setAndTap('');
}}
className="grid h-9 w-9 shrink-0 place-items-center rounded-full text-[var(--honey-text)] hover:bg-[var(--honey-wash)]"
>
<Plus className="h-5 w-5" />
</button>
)}
<input
name="ask-waggle"
autoComplete="off"
value={value}
onChange={(e) => setAndTap(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter') {
e.preventDefault();
submit();
}
}}
placeholder={placeholder}
aria-label="Ask Waggle"
className="min-w-0 flex-1 rounded-md bg-transparent px-2 text-[15px] text-[var(--text)] placeholder:text-[var(--text-dim)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--surface)]"
/>
{cmdkHint && <kbd className="kbd hidden sm:inline-block">{cmdKLabel}</kbd>}
{submitVariant === 'search' ? (
<button
type="button"
aria-label="Search"
onClick={submit}
disabled={!value.trim()}
className="flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-[var(--honey)] px-3.5 text-[13px] font-medium text-[#1a1407] transition-opacity disabled:opacity-40"
>
<Search className="h-4 w-4" />
<span className="hidden sm:inline">Search</span>
</button>
) : (
<button
type="button"
aria-label="Send"
onClick={submit}
disabled={!value.trim()}
className="grid h-9 w-9 shrink-0 place-items-center rounded-full bg-[var(--honey)] text-[#1a1407] transition-opacity disabled:opacity-40"
>
<ArrowUp className="h-5 w-5" />
</button>
)}
</div>
);
}

View File

@@ -0,0 +1,63 @@
import { cn } from '@/lib/utils';
interface ConfidenceRingProps {
/**
* 0–100 confidence. `undefined` means the substrate holds NO confidence for
* this memory (it is a harvest-only signal) — the ring renders a neutral "—",
* never a fabricated number (PR3 no-fabrication contract).
*/
value?: number;
className?: string;
}
/**
* Band color for a confidence value (screen-19 §5a `confColor`):
* ≥85 → healthy (sage) · ≥60 → attention (honey) · <60 → risk (terracotta)
*/
export function confidenceColor(c: number): string {
if (c >= 85) return 'var(--healthy)';
if (c >= 60) return 'var(--attention)';
return 'var(--risk)';
}
/**
* 38px confidence ring (Memory-Trust screen-19 §5a). The "NN%" value AND the
* 2px ring border are both colored by band. When `value` is undefined a quiet
* "unscored" text badge renders instead — the honest "no confidence stored"
* state (curated / agent / quick-capture frames carry no confidence; only
* harvest does). Never defaults a number, never an empty dial (Wave F fix 3a).
*/
export function ConfidenceRing({ value, className }: ConfidenceRingProps) {
if (typeof value !== 'number' || !Number.isFinite(value)) {
return (
<div className={cn('flex w-[42px] flex-none flex-col items-center', className)}>
<span
role="img"
aria-label="Confidence not scored"
className="w-full rounded-[7px] border border-[var(--line-soft)] bg-[var(--surface-2)] py-1 text-center font-mono text-[8.5px] text-[var(--text-dim)]"
>
unscored
</span>
<span className="mt-1 font-mono text-[9px] uppercase tracking-[0.06em] text-[var(--text-dim)]">
conf
</span>
</div>
);
}
const color = confidenceColor(value);
return (
<div className={cn('flex w-[42px] flex-none flex-col items-center', className)}>
<div
role="img"
className="grid h-[38px] w-[38px] place-items-center rounded-full font-mono text-[10px] font-semibold"
style={{ color, border: `2px solid ${color}` }}
aria-label={`Confidence ${Math.round(value)} percent (${value >= 85 ? 'high' : value >= 60 ? 'medium' : 'low'})`}
>
{Math.round(value)}%
</div>
<span className="mt-1 font-mono text-[9px] uppercase tracking-[0.06em] text-[var(--text-dim)]">
conf
</span>
</div>
);
}

View File

@@ -0,0 +1,29 @@
import { cn } from '@/lib/utils';
import { TONE_COLOR, type WarmTone } from './tones';
interface DotLiveProps {
tone?: WarmTone;
/** Breathing pulse for a live/active state (default). Off → static dot. */
live?: boolean;
size?: number;
className?: string;
}
/**
* A small status dot, optionally breathing (`.dot-live`) for live state.
* Color resolves from a warm semantic token; the pulse honors
* `prefers-reduced-motion` via `motion-reduce:animate-none`.
*/
export function DotLive({ tone = 'healthy', live = true, size = 8, className }: DotLiveProps) {
return (
<span
aria-hidden
style={{ width: size, height: size, backgroundColor: TONE_COLOR[tone] }}
className={cn(
'inline-block shrink-0 rounded-full',
live && 'dot-live motion-reduce:animate-none',
className,
)}
/>
);
}

View File

@@ -0,0 +1,104 @@
import { motion } from 'framer-motion';
import { cn } from '@/lib/utils';
import { SPRING } from '@/lib/motion/tokens';
interface HexAvatarProps {
/** Text to derive the single-initial glyph from (e.g. a workspace name). */
label: string;
/** Box size in px (the hex clip fits inside). Default 28. */
size?: number;
/** Warm gradient fill (default); false → flat surface tile. */
gradient?: boolean;
className?: string;
/**
* Hero shared-element morph (Lane HM). When set, the hex renders as a
* `motion.span` carrying this `layoutId`, so it animates position + size
* between a source (a workspace card) and a destination (the workspace
* header) that use the SAME id — the avatar grows into the surface. Omitted
* → a plain `<span>`, byte-identical to before, so every existing caller is
* untouched. Reduced-motion callers pass `undefined` (no shared-element
* travel — REDUCED.routeTransition = crossfade-only).
*/
layoutId?: string;
}
/**
* Round-6 fix 1a: 5 SATURATED warm brand-adjacent gradient tones (honey ·
* bright honey · deep honey · warm copper · terracotta), picked
* deterministically from the label so one workspace keeps its hue on every
* surface. The old moss/sand/clay trio read as murky off-ramp olives — every
* tone now stays on the honey→terracotta band so monograms read intentional
* on both themes. Honey stays the brand anchor (tone 0 uses the theme
* tokens); the dark #1a1407 ink reads on every tone. Decorative only
* (aria-hidden).
*/
const WARM_TONES: ReadonlyArray<readonly [string, string]> = [
['var(--honey-bright)', 'var(--honey-deep)'], // honey (brand default)
['#f6c45a', '#e9a52c'], // bright honey
['#e9a52c', '#c07e16'], // deep honey
['#d98a3d', '#b06a24'], // warm copper
['#db8068', '#c05f43'], // terracotta
];
function toneFor(label: string): readonly [string, string] {
const key = label.trim();
let h = 0;
for (let i = 0; i < key.length; i++) h = (h * 31 + key.charCodeAt(i)) >>> 0;
return WARM_TONES[h % WARM_TONES.length];
}
/**
* Wave S (Lane B): the deterministic accent for a label — the bright stop of its
* warm tone, picked by the SAME hash the avatar uses. Reused for the workspace
* card's 2px top band so a card's live signal shares one source of truth with
* its monogram hue (no drift, no fabrication).
*/
export function accentFor(label: string): string {
return toneFor(label)[0];
}
function firstInitial(label: string): string {
const ch = label.trim()[0];
return ch ? ch.toUpperCase() : 'W';
}
/**
* Hex-clipped avatar with a warm gradient + #1a1407 ink — the brand motif
* for workspaces / agents (extracted from the inline pattern in Sidebar.tsx).
* Decorative shape; the adjacent name carries the accessible identity, so the
* tile is aria-hidden.
*/
export function HexAvatar({ label, size = 28, gradient = true, className, layoutId }: HexAvatarProps) {
const [bright, deep] = toneFor(label);
const style = {
width: size,
height: size,
fontSize: Math.max(10, Math.round(size * 0.42)),
...(gradient ? { background: `linear-gradient(150deg, ${bright}, ${deep})` } : {}),
};
const classes = cn(
'hex grid shrink-0 place-items-center font-extrabold leading-none',
gradient
? 'text-[#1a1407]'
: 'border border-[var(--line)] bg-[var(--surface-3)] text-[var(--text-2)]',
className,
);
const glyph = firstInitial(label);
// Hero morph path (Lane HM): opt-in only. The hex itself is the layout
// element, so the same clip-path shape scales/translates cleanly between the
// card and the header (expressive tier — more travel, same settle DNA).
if (layoutId) {
return (
<motion.span aria-hidden layoutId={layoutId} transition={SPRING.expressive} style={style} className={classes}>
{glyph}
</motion.span>
);
}
return (
<span aria-hidden style={style} className={classes}>
{glyph}
</span>
);
}

View File

@@ -0,0 +1,26 @@
import { Check } from 'lucide-react';
import { cn } from '@/lib/utils';
import { TONE_COLOR, TONE_WASH, type WarmTone } from './tones';
interface HexCheckTileProps {
tone?: WarmTone;
size?: number;
className?: string;
}
/**
* Small hex-clipped tile with a check glyph — the leading marker on Workspace
* "What Waggle knows" fact rows.
*/
export function HexCheckTile({ tone = 'healthy', size = 26, className }: HexCheckTileProps) {
const glyph = Math.round(size * 0.5);
return (
<span
aria-hidden
style={{ width: size, height: size, backgroundColor: TONE_WASH[tone], color: TONE_COLOR[tone] }}
className={cn('hex grid shrink-0 place-items-center', className)}
>
<Check style={{ width: glyph, height: glyph }} strokeWidth={2.4} />
</span>
);
}

View File

@@ -0,0 +1,27 @@
import type { ElementType } from 'react';
import { cn } from '@/lib/utils';
import { TONE_COLOR, TONE_WASH, type WarmTone } from './tones';
interface IconTileProps {
icon: ElementType;
tone?: WarmTone;
size?: number;
className?: string;
}
/**
* Tinted rounded-square icon tile (`*-wash` bg + tone-colored glyph) — the
* leading affordance on "Waggle suggests" rows and recent-work artifact rows.
*/
export function IconTile({ icon: Icon, tone = 'honey', size = 38, className }: IconTileProps) {
const glyph = Math.round(size * 0.45);
return (
<span
aria-hidden
style={{ width: size, height: size, backgroundColor: TONE_WASH[tone], color: TONE_COLOR[tone] }}
className={cn('grid shrink-0 place-items-center rounded-[12px]', className)}
>
<Icon style={{ width: glyph, height: glyph }} strokeWidth={1.8} />
</span>
);
}

View File

@@ -0,0 +1,71 @@
import { AlertTriangle } from 'lucide-react';
import { cn } from '@/lib/utils';
import type { ApprovalRequest } from '@/components/ui/approval-modal';
import { RISK_LABELS, canAlwaysAllow } from '@/lib/risk-display';
interface InlineApprovalCardProps {
request: ApprovalRequest;
title?: string;
onApprove: () => void;
onDecline: () => void;
/** Offered only when the approval class permits it (A6 policy). */
onAlwaysAllow?: () => void;
approveLabel?: string;
className?: string;
}
/**
* Inline (in-thread) approval card — `--honey-wash` fill + attention border +
* warning icon. Shares the risk vocabulary with `ApprovalModal` via
* `risk-display.ts`; "Always allow" is gated by `canAlwaysAllow` so a
* CRITICAL/blocked action can never offer it.
*/
export function InlineApprovalCard({
request,
title = 'Approve before I leave your machine',
onApprove,
onDecline,
onAlwaysAllow,
approveLabel = 'Approve & continue',
className,
}: InlineApprovalCardProps) {
const showAlways = onAlwaysAllow && canAlwaysAllow(request.approvalClass);
const target = request.scope.length ? `${request.action} › ${request.scope.join(' · ')}` : request.action;
return (
<div className={cn('rounded-[14px] border border-[var(--honey-line)] bg-[var(--honey-wash)] p-4', className)}>
<div className="flex items-start gap-3">
<AlertTriangle className="mt-0.5 h-5 w-5 shrink-0 text-[var(--attention)]" strokeWidth={1.8} />
<div className="min-w-0 flex-1">
<p className="text-[14px] font-semibold text-[var(--text)]">{title}</p>
<p className="mt-1 break-words font-mono text-[12px] text-[var(--text-2)]">{target}</p>
<p className="mt-1 text-[11.5px] text-[var(--text-dim)]">{RISK_LABELS[request.riskLevel]} risk</p>
<div className="mt-3 flex flex-wrap gap-2">
<button
type="button"
onClick={onApprove}
className="rounded-[10px] bg-[var(--honey)] px-3.5 py-1.5 text-[13px] font-medium text-[#1a1407]"
>
{approveLabel}
</button>
<button
type="button"
onClick={onDecline}
className="rounded-[10px] border border-[var(--line-strong)] bg-[var(--surface)] px-3.5 py-1.5 text-[13px] text-[var(--text-2)] transition-colors hover:text-[var(--text)]"
>
Not now
</button>
{showAlways && (
<button
type="button"
onClick={onAlwaysAllow}
className="rounded-[10px] px-3.5 py-1.5 text-[13px] text-[var(--text-dim)] transition-colors hover:text-[var(--text-2)]"
>
Always allow
</button>
)}
</div>
</div>
</div>
</div>
);
}

View File

@@ -0,0 +1,48 @@
import { ChevronDown } from 'lucide-react';
import { cn } from '@/lib/utils';
import { DotLive } from './DotLive';
interface ModelPillProps {
/** Routing mode, e.g. "auto". Omit to show the model alone. */
mode?: string;
model: string;
onClick?: () => void;
title?: string;
className?: string;
}
/**
* "auto · Claude Sonnet" model pill with a healthy live dot — sits in the Chat
* context header. Becomes a button (with chevron) when `onClick` is supplied.
*/
export function ModelPill({ mode = 'auto', model, onClick, title, className }: ModelPillProps) {
const content = (
<>
<DotLive tone="healthy" size={7} />
<span className="font-mono text-[12px] text-[var(--text-2)]">
{mode ? <span className="text-[var(--text-dim)]">{mode} · </span> : null}
{model}
</span>
{onClick && <ChevronDown className="h-3.5 w-3.5 text-[var(--text-dim)]" />}
</>
);
const base =
'inline-flex items-center gap-1.5 rounded-full border border-[var(--line-soft)] bg-[var(--surface)] px-2.5 py-1';
if (onClick) {
return (
<button
type="button"
onClick={onClick}
title={title}
className={cn(base, 'transition-colors hover:border-[var(--honey-line)]', className)}
>
{content}
</button>
);
}
return (
<span title={title} className={cn(base, className)}>
{content}
</span>
);
}

View File

@@ -0,0 +1,58 @@
import type { ReactNode } from 'react';
import { cn } from '@/lib/utils';
import { DotLive } from './DotLive';
import { RunChip, type RunChipProps } from './RunChip';
interface OvernightHeroProps {
eyebrow?: string;
/** The "While you slept …" statement; embed honey spans for key numbers.
* The caller owns the empty-night fallback line — the statement always
* renders, whether or not chips accompany it (H2: single-clause stories
* pass no chips, since a lone chip would just repeat the sentence). */
statement: ReactNode;
runs?: RunChipProps[];
className?: string;
}
/**
* Home overnight "hero moment" — a gradient `--r-xl` card with a soft honey
* radial glow. Renders gracefully with no runs (the data is often empty / null;
* see PR3-BUILD-PLAN §5).
*/
export function OvernightHero({
eyebrow = 'While you slept',
statement,
runs = [],
className,
}: OvernightHeroProps) {
const hasRuns = runs.length > 0;
return (
<section
className={cn(
'relative overflow-hidden rounded-[var(--r-xl)] border border-[var(--line-soft)] bg-[linear-gradient(150deg,var(--surface),var(--surface-2))] p-7 shadow-[var(--shadow-elevated)]',
className,
)}
>
<span
aria-hidden
className="pointer-events-none absolute -right-16 -top-16 h-48 w-48 rounded-full bg-[radial-gradient(circle,var(--honey-glow),transparent_70%)]"
/>
<div className="relative">
<div className="mb-3 flex items-center gap-2 font-mono text-[11px] uppercase tracking-[0.1em] text-[var(--text-muted)]">
<DotLive tone="intel" size={7} />
{eyebrow}
</div>
<p className="max-w-[60ch] text-[clamp(19px,2.4vw,26px)] font-semibold leading-[1.4] text-[var(--text)]">
{statement}
</p>
{hasRuns && (
<div className="mt-5 flex flex-wrap gap-2">
{runs.map((r, i) => (
<RunChip key={i} {...r} />
))}
</div>
)}
</div>
</section>
);
}

View File

@@ -0,0 +1,34 @@
import { cn } from '@/lib/utils';
import { EvidenceChip } from '@/components/ui/evidence-chip';
interface ProvenanceLineProps {
/** Provenance source, e.g. "web · mem0.ai" or "Claude Code". */
source: string;
/** Optional relative time, e.g. "2h ago". */
when?: string;
/** PR3.5 trace hook — makes the pill clickable into the memory detail. */
onClick?: () => void;
className?: string;
}
/**
* "⬡ source · when" provenance pill in mono / `--intel` — the core trust
* pattern (README §6.6). Thin wrapper over `EvidenceChip` recolored to the
* intel (violet) semantic. Clickable when `onClick` is supplied.
*/
export function ProvenanceLine({ source, when, onClick, className }: ProvenanceLineProps) {
const label = `⬡ ${source}${when ? ` · ${when}` : ''}`;
return (
<EvidenceChip
label={label}
title={label}
onClick={onClick}
className={cn(
// 12px (overrides the chip's 11px base) — provenance is trust-critical
// micro-metadata and must not sit on the sub-12px decoration tier (a11y).
'font-mono text-[12px] text-[var(--intel)] border-[var(--intel-wash)] bg-transparent',
className,
)}
/>
);
}

View File

@@ -0,0 +1,27 @@
import { cn } from '@/lib/utils';
import { DotLive } from './DotLive';
import type { WarmTone } from './tones';
export interface RunChipProps {
label: string;
tone?: WarmTone;
className?: string;
}
/**
* A result chip (static status dot + label) for the overnight hero —
* e.g. "14 memories consolidated" (intel), "1 export failed" (risk).
*/
export function RunChip({ label, tone = 'healthy', className }: RunChipProps) {
return (
<span
className={cn(
'inline-flex items-center gap-2 rounded-full border border-[var(--line-soft)] bg-[var(--surface)]/60 px-3 py-1 text-[12.5px] text-[var(--text-2)]',
className,
)}
>
<DotLive tone={tone} live={false} size={7} />
{label}
</span>
);
}

View File

@@ -0,0 +1,28 @@
import type { ReactNode } from 'react';
import { cn } from '@/lib/utils';
interface SectionLabelProps {
children: ReactNode;
/** Append a trailing hairline rule filling the remaining width. */
rule?: boolean;
className?: string;
}
/**
* 11px mono, uppercase section header. Used to head every screen section.
* Wave X Lane C: was `--text-dim` at 0.14em tracking — a video judge read the
* eyebrows ("WHILE YOU SLEPT", "TRUST · INSPECT · CORRECT · FORGET") as garbled
* noise. `--text-dim` also fails 4.5:1 on the light canvas (#736958 on cream ≈
* 4.47:1). Raised to `--text-muted` (≈6.3:1 dark / 4.77:1 light — AA in both)
* and eased tracking to 0.10em so tiny uppercase stays legible.
*/
export function SectionLabel({ children, rule = false, className }: SectionLabelProps) {
return (
<div className={cn('flex items-center gap-3', className)}>
<span className="font-mono text-[11px] uppercase tracking-[0.1em] text-[var(--text-muted)]">
{children}
</span>
{rule && <span aria-hidden className="h-px flex-1 bg-[var(--line-soft)]" />}
</div>
);
}

View File

@@ -0,0 +1,26 @@
import { cn } from '@/lib/utils';
interface StreakChipProps {
days: number;
className?: string;
}
/**
* 🔥 N-day streak chip (honey-wash fill / honey-line border) for the Home
* greeting. The habit-loop mechanic lives on Home, not a standalone page
* (SCREENS §15). `days` is currently a mock value — no backend streak field
* exists yet (see PR3-BUILD-PLAN §5).
*/
export function StreakChip({ days, className }: StreakChipProps) {
return (
<span
className={cn(
'inline-flex items-center gap-1.5 rounded-full border border-[var(--honey-line)] bg-[var(--honey-wash)] px-3 py-1 text-[12.5px] font-medium text-[var(--text-2)]',
className,
)}
>
<span aria-hidden>🔥</span>
<span>{days}-day streak</span>
</span>
);
}

View File

@@ -0,0 +1,133 @@
import { useEffect, useRef } from 'react';
import { motion, useReducedMotion } from 'framer-motion';
import { SPRING, DUR, EASE_OUT } from '@/lib/motion/tokens';
import { cn } from '@/lib/utils';
/**
* WaggleSettle — the commissioned signature gesture (Phase-D Lane WS, brand
* blocking #1). A recognizably waggle-derived micro-choreography: the honey
* brand hex runs the bee's figure-eight waggle dance (a Gerono lemniscate — two
* lobes crossing at the origin — with a fast body-wobble overlay) and SETTLES at
* centre with a single-overshoot spring bloom (~400ms, DUR.settle +
* SPRING.expressive). It must read as "the waggle," not a generic scale-pop, so
* the translation path — not the scale — carries the identity.
*
* Prototype discipline: this is judged STANDALONE on /motion-spec first, and
* wired to exactly ONE product moment (memory saved) behind the SIGNATURE.full
* taxonomy gate (see waggle-settle-gate.ts). It is not propagated to any other
* moment in this phase.
*
* Purely decorative (aria-hidden + pointer-events-none) — it reinforces a state
* change the host has already announced, so it adds no second SR event. It
* mounts only while `play` is true and calls `onDone` when the gesture finishes,
* so the host clears state to re-arm.
*
* Reduced-motion (REDUCED.settle = 'instant-state-color-pulse'): the dancer is
* static at its settled state (no path, no transform) and a single honey colour
* pulse plays in place of the gesture — exactly the taxonomy's reduced mapping.
*/
/** Times for the 9-point figure-eight keyframe path (evenly spaced 0→1). */
export const WAGGLE_TIMES = [0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1] as const;
/**
* Gerono lemniscate (∞) sampled at t = k·π/4, normalised to [-1, 1]. Two lobes
* (left/right) crossing at the origin; starts and ends at 0 — the bee returns to
* where it began. This is the "figure-eight dance DNA."
*/
export const WAGGLE_FIG8_X = [0, 0.707, 1, 0.707, 0, -0.707, -1, -0.707, 0] as const;
export const WAGGLE_FIG8_Y = [0, 1, 0, -1, 0, 1, 0, -1, 0] as const;
/** Decaying body-wobble (degrees) synced to the run — the literal "waggle." */
export const WAGGLE_WOBBLE_DEG = [0, -12, 10, -10, 8, -8, 6, -5, 0] as const;
export interface WaggleSettleProps {
/** Fire the gesture while true. Set false again (via onDone) to re-arm. */
play: boolean;
/** Called once the gesture (or the reduced-motion pulse) has finished. */
onDone?: () => void;
/** Dancer size in px — drives the figure-eight reach. Default 40. */
size?: number;
/** Positioning/offset classes applied to the host anchor. */
className?: string;
/** Testid for the overlay root (default `waggle-settle`). */
'data-testid'?: string;
}
export function WaggleSettle({
play,
onDone,
size = 40,
className,
'data-testid': testId = 'waggle-settle',
}: WaggleSettleProps) {
const reduce = !!useReducedMotion();
// Keep onDone current without resetting the timer mid-gesture on every render.
const onDoneRef = useRef(onDone);
onDoneRef.current = onDone;
useEffect(() => {
if (!play) return;
// gesture length + a short tail so the spring has visually settled.
const ms = Math.round(DUR.settle * 1000) + 120;
const timer = setTimeout(() => onDoneRef.current?.(), ms);
return () => clearTimeout(timer);
}, [play]);
if (!play) return null;
const dancer = Math.round(size * 0.55);
const glow = Math.round(size * 1.5);
const ampX = size * 0.5;
const ampY = size * 0.3;
const fig8x = WAGGLE_FIG8_X.map((v) => v * ampX);
const fig8y = WAGGLE_FIG8_Y.map((v) => v * ampY);
const times = [...WAGGLE_TIMES];
return (
<span
aria-hidden
data-testid={testId}
data-reduced={reduce ? 'true' : 'false'}
className={cn('pointer-events-none absolute inset-0 grid place-items-center', className)}
>
{/* Settle bloom / reduced-motion colour pulse — honey energy release. */}
<motion.span
data-testid="waggle-settle-glow"
className="absolute rounded-full"
style={{
width: glow,
height: glow,
background: 'radial-gradient(circle, var(--honey-glow), transparent 70%)',
}}
initial={{ opacity: 0, scale: reduce ? 1 : 0.5 }}
animate={reduce ? { opacity: [0, 0.8, 0] } : { opacity: [0, 0.85, 0], scale: [0.5, 1.5] }}
transition={{ duration: DUR.settle, ease: EASE_OUT }}
/>
{/* The dancer — the honey brand hex running the figure-eight waggle → settle. */}
<motion.span
data-testid="waggle-settle-dancer"
className="hex block shadow-[var(--shadow-honey)]"
style={{ width: dancer, height: dancer, backgroundColor: 'var(--honey)' }}
initial={reduce ? { opacity: 0, scale: 1 } : { opacity: 0, scale: 0.7, x: 0, y: 0, rotate: 0 }}
animate={
reduce
? { opacity: 1 }
: { opacity: 1, scale: 1, x: fig8x, y: fig8y, rotate: [...WAGGLE_WOBBLE_DEG] }
}
transition={
reduce
? { duration: 0 }
: {
x: { duration: DUR.settle, times, ease: 'easeInOut' },
y: { duration: DUR.settle, times, ease: 'easeInOut' },
rotate: { duration: DUR.settle, times, ease: 'easeInOut' },
opacity: { duration: DUR.fast },
scale: SPRING.expressive,
}
}
/>
</span>
);
}

View File

@@ -0,0 +1,24 @@
/**
* Warm-Hive shared primitives (PR3 Phase 0). Opinionated, token-driven warm
* compositions consumed by the Home / Chat / Workspace screens. Generic,
* always-labeled primitives stay in `components/ui/` — these are the
* warm-Hive-specific atoms.
*/
export { HexAvatar } from './HexAvatar';
export { SectionLabel } from './SectionLabel';
export { DotLive } from './DotLive';
export { ProvenanceLine } from './ProvenanceLine';
export { RunChip, type RunChipProps } from './RunChip';
export { IconTile } from './IconTile';
export { HexCheckTile } from './HexCheckTile';
export { StreakChip } from './StreakChip';
export { ModelPill } from './ModelPill';
export { OvernightHero } from './OvernightHero';
export { AskBar } from './AskBar';
export { ActivityStream, type ActivityStep } from './ActivityStream';
export { AmbientHiveGlow } from './AmbientHiveGlow';
export { InlineApprovalCard } from './InlineApprovalCard';
export { ConfidenceRing, confidenceColor } from './ConfidenceRing';
export { WaggleSettle, type WaggleSettleProps } from './WaggleSettle';
export { claimFullSignature } from './waggle-settle-gate';
export { TONE_COLOR, TONE_WASH, type WarmTone } from './tones';

View File

@@ -0,0 +1,36 @@
/**
* Warm-Hive status tone vocabulary (PR3 shared primitives). Superset of
* `ui/status-badge.tsx`'s StatusTone, mapped to the DESATURATED warm semantic
* tokens (recon primitives.md §1). Status-only — never decoration. Light mode
* inherits because every value resolves from a `var(--token)`.
*/
export type WarmTone =
| 'work'
| 'intel'
| 'healthy'
| 'attention'
| 'risk'
| 'honey'
| 'neutral';
/** Foreground / dot color for a tone. */
export const TONE_COLOR: Record<WarmTone, string> = {
work: 'var(--work)',
intel: 'var(--intel)',
healthy: 'var(--healthy)',
attention: 'var(--attention)',
risk: 'var(--risk)',
honey: 'var(--honey)',
neutral: 'var(--text-muted)',
};
/** Tinted wash (background) for a tone. */
export const TONE_WASH: Record<WarmTone, string> = {
work: 'var(--work-wash)',
intel: 'var(--intel-wash)',
healthy: 'var(--healthy-wash)',
attention: 'var(--honey-wash)',
risk: 'var(--risk-wash)',
honey: 'var(--honey-wash)',
neutral: 'var(--surface-3)',
};

View File

@@ -0,0 +1,90 @@
/**
* SIGNATURE.full session gate for the waggle-settle (Phase-D Lane WS).
*
* The full-amplitude settle is a RARE flourish (Phase-0.7 taxonomy): it fires at
* most once per session for a given "first-of-session" moment, and never inside
* the global per-session cooldown that spaces ALL full flourishes apart. Pure
* decision + thin sessionStorage persistence — session-scoped ON PURPOSE (a
* fresh tab/session earns the flourish again; a reload within the session does
* not). Mirrors the import-reminder-state split: pure logic here, storage is the
* caller's edge.
*/
import { SIGNATURE } from '@/lib/motion/tokens';
export const SIGNATURE_FULL_STORAGE_KEY = 'waggle:signature-full-state';
export interface SignatureFullState {
/** Epoch ms of the last full flourish this session, or null if none yet. */
readonly lastFiredAt: number | null;
/** First-of-session moments already spent this session. */
readonly firedMoments: readonly string[];
}
export const EMPTY_SIGNATURE_STATE: SignatureFullState = { lastFiredAt: null, firedMoments: [] };
export interface CanFireInput {
readonly moment: string;
readonly state: SignatureFullState;
readonly now: number;
/** Override the taxonomy cooldown (tests). */
readonly cooldownMs?: number;
}
/** Pure: may a full-amplitude settle fire for `moment` at `now`? */
export function canFireFullSignature({ moment, state, now, cooldownMs }: CanFireInput): boolean {
const cd = cooldownMs ?? SIGNATURE.full.perSessionCooldownMs;
// Only recognised full-tier moments qualify for the flourish.
if (!(SIGNATURE.full.moments as readonly string[]).includes(moment)) return false;
// A first-of-session moment is spent once per session.
if (state.firedMoments.includes(moment)) return false;
// The global cooldown spaces every full flourish apart.
if (state.lastFiredAt !== null && now - state.lastFiredAt < cd) return false;
return true;
}
/** Immutable fold: record a fire of `moment` at `now`. */
export function recordFullSignature(state: SignatureFullState, moment: string, now: number): SignatureFullState {
return {
lastFiredAt: now,
firedMoments: state.firedMoments.includes(moment)
? state.firedMoments
: [...state.firedMoments, moment],
};
}
/** Read session-scoped gate state; empty when storage is unavailable/unset. */
export function readSignatureFullState(): SignatureFullState {
try {
const raw = window.sessionStorage.getItem(SIGNATURE_FULL_STORAGE_KEY);
if (!raw) return EMPTY_SIGNATURE_STATE;
const parsed = JSON.parse(raw) as Partial<SignatureFullState>;
return {
lastFiredAt: typeof parsed.lastFiredAt === 'number' ? parsed.lastFiredAt : null,
firedMoments: Array.isArray(parsed.firedMoments)
? parsed.firedMoments.filter((m): m is string => typeof m === 'string')
: [],
};
} catch {
return EMPTY_SIGNATURE_STATE;
}
}
/** Persist session-scoped gate state (no-op when storage disabled). */
export function writeSignatureFullState(state: SignatureFullState): void {
try {
window.sessionStorage.setItem(SIGNATURE_FULL_STORAGE_KEY, JSON.stringify(state));
} catch {
/* storage disabled — no-op */
}
}
/**
* Caller convenience: check the gate and, if the flourish may play, record the
* fire atomically. Returns true when the settle should play now.
*/
export function claimFullSignature(moment: string, now: number = Date.now()): boolean {
const state = readSignatureFullState();
if (!canFireFullSignature({ moment, state, now })) return false;
writeSignatureFullState(recordFullSignature(state, moment, now));
return true;
}