This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/** PR5 Phase C2 — the terminal First-task step (seed the first message, open the workspace). */
|
||||
import { describe, it, expect, vi, afterEach } from 'vitest';
|
||||
import { render, screen, fireEvent, cleanup } from '@testing-library/react';
|
||||
import FirstTaskStep from './FirstTaskStep';
|
||||
|
||||
const base = {
|
||||
message: 'Do a thing',
|
||||
onMessageChange: vi.fn(),
|
||||
suggestions: ['Suggestion A', 'Suggestion B'],
|
||||
onPickSuggestion: vi.fn(),
|
||||
onLetsGo: vi.fn(),
|
||||
createError: null,
|
||||
};
|
||||
|
||||
afterEach(() => cleanup());
|
||||
|
||||
describe('FirstTaskStep', () => {
|
||||
it('shows the seeded first message and edits it', () => {
|
||||
const onMessageChange = vi.fn();
|
||||
render(<FirstTaskStep {...base} onMessageChange={onMessageChange} />);
|
||||
const ta = screen.getByLabelText(/first task/i);
|
||||
expect(ta).toHaveValue('Do a thing');
|
||||
expect(ta).toHaveAttribute('name', 'onboardingFirstTask');
|
||||
expect(ta).toHaveAttribute('autocomplete', 'off');
|
||||
fireEvent.change(ta, { target: { value: 'New task' } });
|
||||
expect(onMessageChange).toHaveBeenCalledWith('New task');
|
||||
});
|
||||
|
||||
it('picks a suggested prompt', () => {
|
||||
const onPickSuggestion = vi.fn();
|
||||
render(<FirstTaskStep {...base} onPickSuggestion={onPickSuggestion} />);
|
||||
const suggestion = screen.getByRole('button', { name: /suggestion a/i });
|
||||
expect(suggestion).toHaveClass('text-foreground/80');
|
||||
fireEvent.click(suggestion);
|
||||
expect(onPickSuggestion).toHaveBeenCalledWith('Suggestion A');
|
||||
});
|
||||
|
||||
it('opens the workspace on "Let\'s go"', () => {
|
||||
const onLetsGo = vi.fn();
|
||||
render(<FirstTaskStep {...base} onLetsGo={onLetsGo} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: /let's go/i }));
|
||||
expect(onLetsGo).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
import { motion } from 'framer-motion';
|
||||
import { fadeSlide } from './constants';
|
||||
import type { FirstTaskStepProps } from './types';
|
||||
|
||||
/**
|
||||
* Onboarding terminal step (PR5) — end inside the work. The workspace already exists
|
||||
* (created on the Template step); here the user gives the agent its first task, seeded
|
||||
* with the chosen template's hint and a few suggested prompts. "Let's go" opens the
|
||||
* workspace with that first message (an empty box falls back to a default greeting in
|
||||
* the wizard, so this never dead-ends).
|
||||
*/
|
||||
const FirstTaskStep = ({ message, onMessageChange, suggestions, onPickSuggestion, onLetsGo, createError }: FirstTaskStepProps) => (
|
||||
<motion.div key="step-first-task" {...fadeSlide}>
|
||||
<div className="text-center mb-5">
|
||||
<h2 className="text-2xl font-display font-bold text-foreground mb-2">What's first?</h2>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Your workspace is ready. Give your agent its first task — or pick a suggestion.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{createError && <p className="text-xs text-muted-foreground mb-3 text-center">{createError}</p>}
|
||||
|
||||
<textarea
|
||||
name="onboardingFirstTask"
|
||||
autoComplete="off"
|
||||
value={message}
|
||||
onChange={(e) => onMessageChange(e.target.value)}
|
||||
rows={3}
|
||||
placeholder="Ask your agent to do something…"
|
||||
aria-label="First task"
|
||||
className="w-full bg-muted/50 border border-border/50 rounded-lg px-3 py-2.5 text-sm text-foreground resize-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background mb-3"
|
||||
/>
|
||||
|
||||
{suggestions.length > 0 && (
|
||||
<div className="flex flex-wrap gap-2 mb-6">
|
||||
{suggestions.map((s) => (
|
||||
<button
|
||||
key={s}
|
||||
type="button"
|
||||
onClick={() => onPickSuggestion(s)}
|
||||
className="rounded-full border border-border bg-card px-3 py-1.5 text-left text-xs text-foreground/80 hover:text-foreground hover:border-primary/40 transition-colors focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
>
|
||||
{s}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex justify-end">
|
||||
<button
|
||||
onClick={onLetsGo}
|
||||
className="inline-flex items-center gap-2 px-8 py-3 rounded-xl bg-primary text-primary-foreground font-display text-sm font-semibold hover:bg-primary/80 transition-colors glow-primary focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
>
|
||||
🐝 Let's go!
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
|
||||
export default FirstTaskStep;
|
||||
228
apps/web/src/components/os/overlays/onboarding/ImportStep.tsx
Normal file
228
apps/web/src/components/os/overlays/onboarding/ImportStep.tsx
Normal file
@@ -0,0 +1,228 @@
|
||||
import { motion } from 'framer-motion';
|
||||
import { Brain, Upload, Loader2, Check, Zap, ExternalLink, Info } from 'lucide-react';
|
||||
import { fadeSlide } from './constants';
|
||||
import { ConfidenceBadge } from '@/components/ui/confidence-badge';
|
||||
import { memoryKindLabel } from '@/lib/harvest-kind-map';
|
||||
import type { ImportStepProps } from './types';
|
||||
|
||||
/**
|
||||
* S15 / C33 — Memory Import. Surfaces the classified `items[]` from
|
||||
* `POST /api/harvest/preview` (per-item `kind` + `confidence`, Phase 2B.3) so
|
||||
* the user sees what is being imported, then commits ALL items as
|
||||
* `status:'unreviewed'` server-side (C33 commit-all default). Review happens
|
||||
* later in Memory → Needs review (the S16 surface), pointed to below — there is
|
||||
* no per-item selection UI in this cut.
|
||||
*
|
||||
* Source tiles map to `UniversalAdapter`-supported sources. Per C34, tools
|
||||
* without an export adapter (Hermes / Codex / Cursor) route to the generic
|
||||
* "Other" upload tile rather than a dedicated tile, and the long tail lives in
|
||||
* Memory → Harvest after setup.
|
||||
*/
|
||||
const SOURCE_TILES: ReadonlyArray<{
|
||||
id: string;
|
||||
name: string;
|
||||
desc: string;
|
||||
/** One-line how-to: where in the source product the export file comes from. */
|
||||
hint: string;
|
||||
glyph: string;
|
||||
accent: string;
|
||||
}> = [
|
||||
{ id: 'chatgpt', name: 'ChatGPT', desc: 'OpenAI export (.json)', hint: 'In ChatGPT: Settings → Data controls → Export data. You\'ll get an email with the file.', glyph: '✦', accent: 'text-emerald-400 bg-emerald-500/10 ring-emerald-500/30' },
|
||||
{ id: 'claude', name: 'Claude', desc: 'Anthropic export (.json)', hint: 'In Claude: Settings → Privacy → Export data.', glyph: '✧', accent: 'text-orange-400 bg-orange-500/10 ring-orange-500/30' },
|
||||
{ id: 'gemini', name: 'Gemini', desc: 'Google Takeout (.json)', hint: 'Go to takeout.google.com, select Gemini, download.', glyph: '✦', accent: 'text-sky-400 bg-sky-500/10 ring-sky-500/30' },
|
||||
{ id: 'perplexity', name: 'Perplexity', desc: 'Threads export', hint: 'In Perplexity: Settings → Account → Export.', glyph: '◆', accent: 'text-teal-400 bg-teal-500/10 ring-teal-500/30' },
|
||||
// C34: Cursor / Codex / Hermes have no export adapter yet — fold them into
|
||||
// the generic "Other" file picker rather than a dedicated tile.
|
||||
{ id: 'unknown', name: 'Other', desc: 'Cursor, Codex, any text/JSON', hint: 'Any .txt, .md or .json conversation file works.', glyph: '·', accent: 'text-muted-foreground bg-muted/30 ring-border/40' },
|
||||
];
|
||||
|
||||
const LARGE_AUTO_IMPORT_THRESHOLD = 1000;
|
||||
const formatImportCount = (count: number): string => new Intl.NumberFormat('en-US').format(count);
|
||||
|
||||
const ImportStep = ({
|
||||
importSource,
|
||||
importItems,
|
||||
importDone,
|
||||
importing,
|
||||
onFileImport,
|
||||
onImportCommit,
|
||||
claudeCodeDetected,
|
||||
onClaudeCodeHarvest,
|
||||
onContinue,
|
||||
}: ImportStepProps) => {
|
||||
const detectedItemCount = claudeCodeDetected?.itemCount ?? 0;
|
||||
const detectedItemCountLabel = formatImportCount(detectedItemCount);
|
||||
const largeDetectedHistory = detectedItemCount >= LARGE_AUTO_IMPORT_THRESHOLD;
|
||||
|
||||
return (
|
||||
<motion.div key="step-memory-import" {...fadeSlide}>
|
||||
<div className="text-center mb-6">
|
||||
<Brain className="w-10 h-10 text-honey mx-auto mb-3" />
|
||||
<h2 className="text-2xl font-display font-bold text-foreground mb-2">
|
||||
Where do you use AI today?
|
||||
</h2>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Bring your existing conversations — Waggle extracts decisions, preferences, and knowledge into your persistent memory.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Claude Code auto-detect banner — only when the sidecar found local files. */}
|
||||
{!importDone && claudeCodeDetected?.found && (
|
||||
<div className={`mb-5 p-3 rounded-xl border ${largeDetectedHistory ? 'bg-honey/10 border-honey/30' : 'bg-primary/10 border-primary/30'}`}>
|
||||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<Zap className="w-4 h-4 text-honey shrink-0" />
|
||||
<div className="min-w-0">
|
||||
<p className="text-xs font-display font-medium text-foreground">Claude Code detected</p>
|
||||
<p className="text-[11px] text-muted-foreground truncate" title={claudeCodeDetected.path}>
|
||||
Found {detectedItemCountLabel} items from Claude Code
|
||||
</p>
|
||||
{largeDetectedHistory && (
|
||||
<p className="text-[11px] text-muted-foreground/80 mt-1 max-w-md">
|
||||
That is a lot of memory to absorb at setup. Review it after your workspace is ready,
|
||||
or import now if you are ready to curate Needs review.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{onClaudeCodeHarvest && (
|
||||
largeDetectedHistory ? (
|
||||
<div className="flex flex-col sm:flex-row gap-2 sm:items-center shrink-0">
|
||||
<button
|
||||
onClick={onContinue}
|
||||
disabled={importing}
|
||||
className="px-3 py-1.5 rounded-lg bg-primary text-primary-foreground text-xs font-display font-semibold hover:bg-primary/90 transition-colors disabled:opacity-50"
|
||||
>
|
||||
Review after setup
|
||||
</button>
|
||||
<button
|
||||
onClick={onClaudeCodeHarvest}
|
||||
disabled={importing}
|
||||
aria-busy={importing}
|
||||
className="px-3 py-1.5 rounded-lg border border-border/70 bg-background/40 text-xs font-display font-semibold text-foreground hover:bg-muted/60 transition-colors disabled:opacity-50"
|
||||
>
|
||||
{importing ? <Loader2 aria-label="Importing" className="w-3 h-3 animate-spin" /> : `Import ${detectedItemCountLabel} now`}
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<button
|
||||
onClick={onClaudeCodeHarvest}
|
||||
disabled={importing}
|
||||
aria-busy={importing}
|
||||
className="px-3 py-1.5 rounded-lg bg-primary text-primary-foreground text-xs font-display font-semibold hover:bg-primary/90 transition-colors disabled:opacity-50 shrink-0"
|
||||
>
|
||||
{importing ? <Loader2 aria-label="Importing" className="w-3 h-3 animate-spin" /> : 'Import my history'}
|
||||
</button>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!importSource && !importDone && (
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 gap-2.5 mb-6">
|
||||
{SOURCE_TILES.map((src) => (
|
||||
<label
|
||||
key={src.id}
|
||||
className="glass-strong rounded-xl p-3.5 cursor-pointer hover:border-primary/40 focus-within:ring-2 focus-within:ring-primary transition-colors text-left group flex flex-col gap-1"
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={`inline-flex items-center justify-center w-7 h-7 rounded-lg ring-1 mb-0.5 text-base font-bold ${src.accent}`}
|
||||
>
|
||||
{src.glyph}
|
||||
</span>
|
||||
<h3 className="text-xs font-display font-semibold text-foreground">{src.name}</h3>
|
||||
<p className="text-[11px] text-muted-foreground">{src.desc}</p>
|
||||
<p className="text-[10px] text-muted-foreground/70">{src.hint}</p>
|
||||
<div className="flex items-center gap-1 text-[11px] text-honey group-hover:text-honey/80 mt-0.5">
|
||||
<Upload className="w-3 h-3" /> Choose file
|
||||
</div>
|
||||
<input
|
||||
type="file"
|
||||
accept=".json,.txt,.md,.csv"
|
||||
aria-label={`Import ${src.name} export file`}
|
||||
className="sr-only"
|
||||
onChange={(e) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (file) onFileImport(file, src.id);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* C33: surface the classified items (kind + confidence) before commit. The
|
||||
commit lands every item as `status:'unreviewed'`; no per-item selection. */}
|
||||
{importItems.length > 0 && !importDone && (
|
||||
<div className="glass-strong rounded-xl p-4 mb-4">
|
||||
<h3 className="text-sm font-display font-semibold text-foreground mb-2">
|
||||
Preview — {importItems.length} {importItems.length === 1 ? 'item' : 'items'} found
|
||||
</h3>
|
||||
<div className="max-h-40 overflow-y-auto space-y-1.5 mb-3">
|
||||
{importItems.slice(0, 10).map((item, i) => (
|
||||
<div key={item.id ?? i} className="flex items-center gap-2 text-xs">
|
||||
<span className="inline-flex items-center rounded-md bg-muted/60 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0">
|
||||
{memoryKindLabel(item.kind)}
|
||||
</span>
|
||||
<span className="text-muted-foreground truncate flex-1 min-w-0">{item.title}</span>
|
||||
<ConfidenceBadge value={item.confidence} compact className="shrink-0" />
|
||||
</div>
|
||||
))}
|
||||
{importItems.length > 10 && (
|
||||
<div className="text-xs text-muted-foreground/60">
|
||||
…and {importItems.length - 10} more
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
onClick={onImportCommit}
|
||||
disabled={importing}
|
||||
aria-busy={importing}
|
||||
className="inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-primary text-primary-foreground text-xs font-display font-semibold hover:bg-primary/80 disabled:opacity-50 transition-colors focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
>
|
||||
{importing ? <Loader2 aria-hidden="true" className="w-3 h-3 animate-spin" /> : <Check aria-hidden="true" className="w-3 h-3" />}
|
||||
Import {importItems.length} {importItems.length === 1 ? 'item' : 'items'}
|
||||
</button>
|
||||
{/* C33: review-later pointer. */}
|
||||
<p className="flex items-start gap-1.5 text-[11px] text-muted-foreground/80 mt-2.5">
|
||||
<Info className="w-3 h-3 mt-0.5 shrink-0" />
|
||||
Everything imports as <span className="text-foreground/70">Needs review</span> — you can review,
|
||||
edit, or remove these anytime in Memory → Needs review.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{importDone && (
|
||||
<div className="glass-strong rounded-xl p-4 mb-4 text-center">
|
||||
<Check className="w-6 h-6 text-honey mx-auto mb-2" />
|
||||
<p className="text-sm text-foreground font-display">Memories imported!</p>
|
||||
<p className="text-[11px] text-muted-foreground mt-1">
|
||||
Find them under Memory → Needs review to curate.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Long-tail pointer for sources without a primary tile. */}
|
||||
{!importSource && !importDone && (
|
||||
<div className="mb-4 text-center">
|
||||
<p className="text-[11px] text-muted-foreground">
|
||||
Have history elsewhere? <span className="text-foreground/70">Open Memory → Harvest after setup for 14+ more sources <ExternalLink className="w-2.5 h-2.5 inline-block ml-0.5" /></span>
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex items-center justify-end gap-4">
|
||||
<button
|
||||
onClick={onContinue}
|
||||
className="text-xs text-muted-foreground hover:text-foreground transition-colors rounded-md px-1 focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
>
|
||||
{importDone ? 'Continue →' : 'Skip this step →'}
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ImportStep;
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* PR5 Phase C — the onboarding hard model gate. Continue is disabled until a
|
||||
* working model exists; "I'll do this later" is the single soft escape (→ Home).
|
||||
*/
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { render, screen, fireEvent, cleanup } from '@testing-library/react';
|
||||
|
||||
const mocks = vi.hoisted(() => ({ useHasWorkingModel: vi.fn() }));
|
||||
vi.mock('@/hooks/useHasWorkingModel', () => ({ useHasWorkingModel: mocks.useHasWorkingModel }));
|
||||
vi.mock('@/components/os/model-gate/ModelGate', () => ({ ModelGate: () => <div data-testid="model-gate" /> }));
|
||||
|
||||
import ModelGateStep from './ModelGateStep';
|
||||
|
||||
const state = (over: Record<string, unknown> = {}) => ({
|
||||
hasWorkingModel: false, cloudReady: false, localReady: false, loading: false, refresh: vi.fn(), ...over,
|
||||
});
|
||||
const props = () => ({ onContinue: vi.fn(), onLater: vi.fn() });
|
||||
|
||||
beforeEach(() => mocks.useHasWorkingModel.mockReturnValue(state()));
|
||||
afterEach(() => { cleanup(); vi.clearAllMocks(); });
|
||||
|
||||
describe('ModelGateStep — the hard model gate', () => {
|
||||
it('embeds the shared ModelGate', () => {
|
||||
render(<ModelGateStep {...props()} />);
|
||||
expect(screen.getByTestId('model-gate')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('disables Continue until a working model exists', () => {
|
||||
const p = props();
|
||||
render(<ModelGateStep {...p} />);
|
||||
const cont = screen.getByRole('button', { name: /continue/i });
|
||||
expect(cont).toBeDisabled();
|
||||
fireEvent.click(cont);
|
||||
expect(p.onContinue).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('enables Continue and advances once a model is working', () => {
|
||||
mocks.useHasWorkingModel.mockReturnValue(state({ hasWorkingModel: true }));
|
||||
const p = props();
|
||||
render(<ModelGateStep {...p} />);
|
||||
const cont = screen.getByRole('button', { name: /continue/i });
|
||||
expect(cont).toBeEnabled();
|
||||
fireEvent.click(cont);
|
||||
expect(p.onContinue).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('shows a local-ready state while keeping the setup gate available for another provider', () => {
|
||||
mocks.useHasWorkingModel.mockReturnValue(state({ hasWorkingModel: true, localReady: true, loading: true }));
|
||||
render(<ModelGateStep {...props()} />);
|
||||
|
||||
expect(screen.getByTestId('model-gate')).toBeInTheDocument();
|
||||
expect(screen.getByRole('status')).toHaveTextContent(/model ready/i);
|
||||
});
|
||||
|
||||
it('keeps cloud readiness owned by the shared gate so rejected keys remain visible', () => {
|
||||
mocks.useHasWorkingModel.mockReturnValue(state({ hasWorkingModel: true, cloudReady: true, loading: true }));
|
||||
render(<ModelGateStep {...props()} />);
|
||||
|
||||
expect(screen.getByTestId('model-gate')).toBeInTheDocument();
|
||||
expect(screen.queryByText(/model ready/i)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('"I\'ll do this later" escapes even with no model (dismiss to Home)', () => {
|
||||
const p = props();
|
||||
render(<ModelGateStep {...p} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: /do this later/i }));
|
||||
expect(p.onLater).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
import { motion } from 'framer-motion';
|
||||
import { Cpu, ArrowRight, Loader2, Check } from 'lucide-react';
|
||||
import { fadeSlide } from './constants';
|
||||
import { ModelGate } from '@/components/os/model-gate/ModelGate';
|
||||
import { useHasWorkingModel } from '@/hooks/useHasWorkingModel';
|
||||
import type { ModelGateStepProps } from './types';
|
||||
|
||||
/**
|
||||
* Onboarding step 3 — the HARD model gate (PR5 D2). Continue stays disabled until
|
||||
* ≥1 working model exists (a cloud key live-validated → Vault, OR a detected/pulled
|
||||
* local model). One soft escape — "I'll do this later" — dismisses onboarding to
|
||||
* Home, where the NoModelBanner persists until a model is set up. A zero-model first
|
||||
* task instantly errors; the gate prevents that cold-start dead-end (DESIGN_POV §2).
|
||||
*
|
||||
* Reuses the shared ModelGate (same component as Settings → Models) so the gate and
|
||||
* the permanent home of model setup can never drift.
|
||||
*/
|
||||
const ModelGateStep = ({ onContinue, onLater }: ModelGateStepProps) => {
|
||||
const { hasWorkingModel, cloudReady, localReady, loading, refresh } = useHasWorkingModel();
|
||||
return (
|
||||
<motion.div key="step-model-gate" {...fadeSlide}>
|
||||
<div className="text-center mb-5">
|
||||
<Cpu className="w-10 h-10 text-honey mx-auto mb-3" />
|
||||
<h2 className="text-2xl font-display font-bold text-foreground mb-2">Connect a model</h2>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Waggle needs one model to think with. Bring your own provider key — stored encrypted
|
||||
in your Vault — or run a model locally. Nothing leaves your machine without your key.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{hasWorkingModel && localReady && !cloudReady ? (
|
||||
<div role="status" className="flex items-start gap-3 rounded-xl border border-primary/30 bg-primary/10 px-4 py-3 text-left">
|
||||
<Check className="mt-0.5 h-5 w-5 shrink-0 text-honey" aria-hidden />
|
||||
<div>
|
||||
<p className="text-sm font-display font-semibold text-foreground">Model ready</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{cloudReady
|
||||
? 'Your provider key is in Vault. You can tune models later in Settings.'
|
||||
: localReady
|
||||
? 'A local model is available. You can tune models later in Settings.'
|
||||
: 'A model is available. You can tune models later in Settings.'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<ModelGate
|
||||
variant="onboarding"
|
||||
onModelReady={refresh}
|
||||
suppressReadinessBanner={hasWorkingModel && localReady && !cloudReady}
|
||||
/>
|
||||
|
||||
<div className="flex items-center justify-end gap-4 mt-6">
|
||||
<div className="flex items-center gap-3">
|
||||
<button
|
||||
onClick={onLater}
|
||||
className="text-sm text-muted-foreground hover:text-foreground transition-colors font-display rounded-md px-2 py-1 focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
>
|
||||
I'll do this later
|
||||
</button>
|
||||
<button
|
||||
onClick={onContinue}
|
||||
disabled={!hasWorkingModel}
|
||||
aria-disabled={!hasWorkingModel}
|
||||
title={hasWorkingModel ? undefined : 'Add a working model to continue'}
|
||||
className="inline-flex items-center gap-2 px-5 py-2.5 rounded-xl bg-primary text-primary-foreground font-display text-sm font-semibold hover:bg-primary/80 disabled:opacity-50 transition-colors focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
>
|
||||
{loading && !hasWorkingModel ? <Loader2 aria-hidden className="w-4 h-4 animate-spin" /> : null}
|
||||
Continue <ArrowRight className="w-4 h-4" aria-hidden />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelGateStep;
|
||||
@@ -0,0 +1,14 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import ReadyStep from './ReadyStep';
|
||||
|
||||
describe('ReadyStep', () => {
|
||||
it('renders the Waggle logo with stable intrinsic dimensions', () => {
|
||||
render(<ReadyStep createError={null} onLetsGo={vi.fn()} />);
|
||||
|
||||
const logo = screen.getByAltText('Waggle');
|
||||
expect(logo).toHaveAttribute('width', '80');
|
||||
expect(logo).toHaveAttribute('height', '80');
|
||||
});
|
||||
});
|
||||
48
apps/web/src/components/os/overlays/onboarding/ReadyStep.tsx
Normal file
48
apps/web/src/components/os/overlays/onboarding/ReadyStep.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
import { motion } from 'framer-motion';
|
||||
import waggleLogoDark from '@/assets/waggle-logo.jpeg';
|
||||
import waggleLogoLight from '@/assets/waggle-logo.png';
|
||||
import { useIsLightTheme } from '@/hooks/useIsLightTheme';
|
||||
import { fadeSlide } from './constants';
|
||||
import type { ReadyStepProps } from './types';
|
||||
|
||||
const ReadyStep = ({ createError, onLetsGo }: ReadyStepProps) => {
|
||||
const isLight = useIsLightTheme();
|
||||
const waggleLogo = isLight ? waggleLogoLight : waggleLogoDark;
|
||||
return (
|
||||
<motion.div key="step-7" {...fadeSlide} className="text-center">
|
||||
<motion.div
|
||||
initial={{ scale: 0.8, opacity: 0 }}
|
||||
animate={{ scale: 1, opacity: 1 }}
|
||||
transition={{ type: 'spring', damping: 12 }}
|
||||
>
|
||||
<div className="relative w-20 h-20 mx-auto mb-5">
|
||||
<img
|
||||
src={waggleLogo}
|
||||
alt="Waggle"
|
||||
width={80}
|
||||
height={80}
|
||||
className="w-20 h-20 rounded-2xl"
|
||||
style={{ boxShadow: '0 0 60px hsl(var(--primary) / 0.4)' }}
|
||||
/>
|
||||
</div>
|
||||
{createError && (
|
||||
<p className="text-xs text-amber-400 mb-3 text-center">{createError}</p>
|
||||
)}
|
||||
<h2 className="text-3xl font-display font-bold text-foreground mb-2">
|
||||
Your hive is ready ⬡
|
||||
</h2>
|
||||
<p className="text-sm text-muted-foreground mb-6">
|
||||
Your workspace is ready. Let's get to work.
|
||||
</p>
|
||||
<button
|
||||
onClick={onLetsGo}
|
||||
className="inline-flex items-center gap-2 px-8 py-3 rounded-xl bg-primary text-primary-foreground font-display text-sm font-semibold hover:bg-primary/80 transition-colors glow-primary"
|
||||
>
|
||||
🐝 Let's go!
|
||||
</button>
|
||||
</motion.div>
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ReadyStep;
|
||||
@@ -0,0 +1,48 @@
|
||||
/** PR5 Phase C2 — the Template step (curated 6; selecting creates the workspace). */
|
||||
import { describe, it, expect, vi, afterEach } from 'vitest';
|
||||
import { render, screen, fireEvent, cleanup } from '@testing-library/react';
|
||||
import { Microscope } from 'lucide-react';
|
||||
import TemplateStep from './TemplateStep';
|
||||
|
||||
const templates = [
|
||||
{ id: 'research-project', name: 'Research Hub', icon: Microscope, hint: 'Design a literature review', desc: 'Deep dive' },
|
||||
{ id: 'blank', name: 'Blank Workspace', icon: Microscope, hint: 'Hello!', desc: 'From scratch' },
|
||||
];
|
||||
|
||||
afterEach(() => cleanup());
|
||||
|
||||
describe('TemplateStep', () => {
|
||||
it('renders the curated templates and selects one by id', () => {
|
||||
const onSelect = vi.fn();
|
||||
render(<TemplateStep templates={templates} onSelect={onSelect} creating={false} creatingId={null} createError={null} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: /research hub/i }));
|
||||
expect(onSelect).toHaveBeenCalledWith('research-project');
|
||||
});
|
||||
|
||||
it('disables the cards while creating and marks the chosen one busy', () => {
|
||||
render(<TemplateStep templates={templates} onSelect={vi.fn()} creating creatingId="blank" createError={null} />);
|
||||
expect(screen.getByRole('button', { name: /research hub/i })).toBeDisabled();
|
||||
expect(screen.getByRole('button', { name: /blank workspace/i })).toHaveAttribute('aria-busy', 'true');
|
||||
});
|
||||
|
||||
it('shows a soft create error', () => {
|
||||
render(<TemplateStep templates={templates} onSelect={vi.fn()} creating={false} creatingId={null} createError="created locally" />);
|
||||
expect(screen.getByText(/created locally/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows no Recommended badge and keeps input order when recommendedId is null', () => {
|
||||
render(<TemplateStep templates={templates} onSelect={vi.fn()} creating={false} creatingId={null} createError={null} recommendedId={null} />);
|
||||
expect(screen.queryByText(/recommended/i)).not.toBeInTheDocument();
|
||||
const cards = screen.getAllByRole('button');
|
||||
expect(cards[0]).toHaveTextContent(/research hub/i);
|
||||
});
|
||||
|
||||
it('badges the recommended template and floats it first', () => {
|
||||
// blank is second in the input list; recommending it must move it to the front.
|
||||
render(<TemplateStep templates={templates} onSelect={vi.fn()} creating={false} creatingId={null} createError={null} recommendedId="blank" />);
|
||||
expect(screen.getByText(/recommended/i)).toBeInTheDocument();
|
||||
const cards = screen.getAllByRole('button');
|
||||
expect(cards[0]).toHaveTextContent(/blank workspace/i);
|
||||
expect(cards[0]).toHaveTextContent(/recommended/i);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
import { motion } from 'framer-motion';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
import { fadeSlide } from './constants';
|
||||
import type { TemplateStepProps } from './types';
|
||||
|
||||
/**
|
||||
* Onboarding Template step (PR5 D4/D5). Folds the old workspace-create step: picking
|
||||
* one of the curated 6 starting points creates the first workspace with a matching
|
||||
* specialist persona + the template id, then advances to the first task. Calm/fast —
|
||||
* no type picker, no name field (the template names it; renameable later).
|
||||
*/
|
||||
const TemplateStep = ({ templates, onSelect, creating, creatingId, createError, recommendedId }: TemplateStepProps) => {
|
||||
// Recommended card first (immutable reorder); leave order untouched when the
|
||||
// recommendation isn't one of the shown templates.
|
||||
const ordered =
|
||||
recommendedId && templates.some((t) => t.id === recommendedId)
|
||||
? [
|
||||
...templates.filter((t) => t.id === recommendedId),
|
||||
...templates.filter((t) => t.id !== recommendedId),
|
||||
]
|
||||
: templates;
|
||||
|
||||
return (
|
||||
<motion.div key="step-template" {...fadeSlide}>
|
||||
<div className="text-center mb-6">
|
||||
<h2 className="text-2xl font-display font-bold text-foreground mb-2">Pick a starting point</h2>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
We'll set up your first workspace — its own brain, with a matching specialist. Add more anytime.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-2.5 mb-5">
|
||||
{ordered.map((t) => {
|
||||
const Icon = t.icon;
|
||||
const isCreating = creating && creatingId === t.id;
|
||||
const isRecommended = t.id === recommendedId;
|
||||
return (
|
||||
<button
|
||||
key={t.id}
|
||||
type="button"
|
||||
onClick={() => onSelect(t.id)}
|
||||
disabled={creating}
|
||||
aria-busy={isCreating}
|
||||
className="glass-strong rounded-xl p-3.5 text-left transition-colors flex flex-col gap-1 hover:border-primary/40 disabled:opacity-60 focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
>
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
{isCreating ? (
|
||||
<Loader2 className="w-5 h-5 mb-0.5 text-honey animate-spin" aria-hidden />
|
||||
) : (
|
||||
<Icon className="w-5 h-5 mb-0.5 text-muted-foreground" aria-hidden />
|
||||
)}
|
||||
{isRecommended && (
|
||||
<span className="text-[10px] font-display font-semibold uppercase tracking-wide text-honey bg-primary/10 rounded-full px-2 py-0.5">
|
||||
Recommended
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<h3 className="text-sm font-display font-semibold text-foreground">{t.name}</h3>
|
||||
<p className="text-[11px] text-muted-foreground">{t.desc}</p>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{createError && <p className="text-xs text-muted-foreground mb-3">{createError}</p>}
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TemplateStep;
|
||||
106
apps/web/src/components/os/overlays/onboarding/WelcomeStep.tsx
Normal file
106
apps/web/src/components/os/overlays/onboarding/WelcomeStep.tsx
Normal file
@@ -0,0 +1,106 @@
|
||||
import { motion, useReducedMotion } from 'framer-motion';
|
||||
import { ShieldCheck, Lock, Globe } from 'lucide-react';
|
||||
import beeMascot from '@/assets/personas/general-purpose.png';
|
||||
import { fadeSlide } from './constants';
|
||||
import type { WelcomeStepProps } from './types';
|
||||
|
||||
/**
|
||||
* S12 — First Launch. Manual "Continue" only (C29: the 3s auto-advance was
|
||||
* dropped). Carries a static disabled `English (US)` chip (C28 — no i18n exists
|
||||
* yet, so the selector is a non-interactive placeholder) and a one-line
|
||||
* local-first / privacy note so the user sees the trust signal up front. When
|
||||
* the sidecar is unreachable an "offline-ready" note reassures that setup still
|
||||
* works locally.
|
||||
*/
|
||||
const WelcomeStep = ({ onClickAnywhere, offline }: WelcomeStepProps) => {
|
||||
const reduceMotion = useReducedMotion();
|
||||
return (
|
||||
<motion.div
|
||||
key="step-first-launch"
|
||||
{...fadeSlide}
|
||||
className="text-center"
|
||||
>
|
||||
<div className="relative w-24 h-24 mx-auto mb-6">
|
||||
{/* Wave R Lane E — brand moment: the canonical flat-geometric hex-bee
|
||||
mascot (the same set the persona picker + landing use) opens
|
||||
onboarding, a warm greeting instead of a generic app-icon tile. The
|
||||
transparent mascot reads on both themes.
|
||||
Wave S Lane E — kill the square tile seam: the old `glow-breathe`
|
||||
class animated a `box-shadow`, which hugs the element's RECTANGLE (so
|
||||
the amber glow read as a square tile against light ivory). Drive the
|
||||
pulse through the `filter: drop-shadow` instead — it follows the bee's
|
||||
alpha silhouette, so the halo is bee-shaped, not a tile. Reduced-motion
|
||||
holds a single static drop-shadow (no pulse).
|
||||
Wave W Lane E fix 2: amplify the breathing so the hero moment has a
|
||||
living pulse on video — a faster ~3s cycle with a visibly larger
|
||||
radius/opacity swing (24→58px, 0.20→0.58) instead of the barely-there
|
||||
28→46px / 0.26→0.46. Still tasteful; reduced-motion stays static. */}
|
||||
<motion.img
|
||||
src={beeMascot}
|
||||
alt="Waggle"
|
||||
className="w-24 h-24"
|
||||
animate={
|
||||
reduceMotion
|
||||
? { filter: 'drop-shadow(0 0 38px hsl(var(--primary) / 0.36))' }
|
||||
: {
|
||||
filter: [
|
||||
'drop-shadow(0 0 24px hsl(var(--primary) / 0.20))',
|
||||
'drop-shadow(0 0 58px hsl(var(--primary) / 0.58))',
|
||||
'drop-shadow(0 0 24px hsl(var(--primary) / 0.20))',
|
||||
],
|
||||
}
|
||||
}
|
||||
transition={
|
||||
reduceMotion
|
||||
? { duration: 0 }
|
||||
: { duration: 3, repeat: Infinity, ease: 'easeInOut' }
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<span className="inline-block text-xs font-display font-semibold tracking-[0.3em] uppercase text-honey mb-4">
|
||||
Personal AI Workspace
|
||||
</span>
|
||||
<h1 className="text-4xl font-display font-bold text-foreground mb-3">
|
||||
Your AI should know how you work
|
||||
</h1>
|
||||
<p className="text-muted-foreground text-sm max-w-md mx-auto mb-6">
|
||||
Waggle remembers you, knows your projects, evolves with each decision, and guides the next step.
|
||||
</p>
|
||||
|
||||
{/* C28: static language badge — no i18n exists yet, so this is a
|
||||
non-interactive marker of the (sole) current language, not a control. */}
|
||||
<div className="mb-5">
|
||||
<span
|
||||
title="More languages coming soon"
|
||||
className="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full border border-border/50 bg-muted/30 text-xs font-display text-muted-foreground"
|
||||
>
|
||||
<Globe className="w-3 h-3" aria-hidden /> English (US)
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); onClickAnywhere(); }}
|
||||
autoFocus
|
||||
className="inline-flex items-center gap-2 px-6 py-3 rounded-xl bg-primary text-primary-foreground font-display text-sm font-semibold hover:bg-primary/80 transition-colors focus-visible:outline-none focus-visible:shadow-[0_0_0_3px_var(--focus-ring)]"
|
||||
>
|
||||
Continue →
|
||||
</button>
|
||||
|
||||
{/* Local-first / privacy note (C28 companion). Lane T: was
|
||||
text-muted-foreground/70 — the /70 composited to ~2.9:1 (light) / 3.8:1
|
||||
(dark) over the scrim (sub-AA). Full-opacity --text-tertiary → 5.4/7.0:1. */}
|
||||
<p className="flex items-center justify-center gap-1.5 text-xs text-[var(--text-tertiary)] mt-5 max-w-md mx-auto">
|
||||
<ShieldCheck className="w-3.5 h-3.5 text-honey/70 shrink-0" />
|
||||
Your memory and data stay on your device. Nothing leaves unless you say so.
|
||||
</p>
|
||||
{offline && (
|
||||
<p className="flex items-center justify-center gap-1.5 text-[11px] text-[var(--text-tertiary)] mt-2">
|
||||
<Lock className="w-3 h-3 shrink-0" />
|
||||
Offline-ready — setup works locally even without a connection.
|
||||
</p>
|
||||
)}
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
export default WelcomeStep;
|
||||
@@ -0,0 +1,53 @@
|
||||
import { cleanup, render, screen } from '@testing-library/react';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import WhoAreYouStep from './WhoAreYouStep';
|
||||
import type { OnboardingProfileFields } from './types';
|
||||
|
||||
const profile: OnboardingProfileFields = {
|
||||
name: 'Mara',
|
||||
role: 'Operations Lead',
|
||||
industry: 'Technology',
|
||||
workType: 'operations',
|
||||
teamSize: 'small',
|
||||
goals: ['remember'],
|
||||
};
|
||||
|
||||
afterEach(() => cleanup());
|
||||
|
||||
describe('WhoAreYouStep', () => {
|
||||
it('a11y: identity fields expose stable form metadata', () => {
|
||||
render(
|
||||
<WhoAreYouStep
|
||||
profile={profile}
|
||||
onChange={vi.fn()}
|
||||
onContinue={vi.fn()}
|
||||
saving={false}
|
||||
/>,
|
||||
);
|
||||
|
||||
const name = screen.getByRole('textbox', { name: 'Name' });
|
||||
expect(name).toHaveAttribute('name', 'onboardingName');
|
||||
expect(name).toHaveAttribute('autocomplete', 'name');
|
||||
|
||||
const role = screen.getByRole('textbox', { name: 'Role' });
|
||||
expect(role).toHaveAttribute('name', 'onboardingRole');
|
||||
expect(role).toHaveAttribute('autocomplete', 'organization-title');
|
||||
});
|
||||
|
||||
it('keeps unselected profile chips readable instead of looking disabled', () => {
|
||||
render(
|
||||
<WhoAreYouStep
|
||||
profile={{ ...profile, workType: '', teamSize: '', goals: [] }}
|
||||
onChange={vi.fn()}
|
||||
onContinue={vi.fn()}
|
||||
saving={false}
|
||||
/>,
|
||||
);
|
||||
|
||||
for (const name of ['Engineering', 'Just me', 'Remember everything I work on']) {
|
||||
const chip = screen.getByRole('button', { name });
|
||||
expect(chip).toHaveClass('text-[var(--text-tertiary)]');
|
||||
expect(chip).toHaveClass('border-[var(--line-affordance)]');
|
||||
}
|
||||
});
|
||||
});
|
||||
192
apps/web/src/components/os/overlays/onboarding/WhoAreYouStep.tsx
Normal file
192
apps/web/src/components/os/overlays/onboarding/WhoAreYouStep.tsx
Normal file
@@ -0,0 +1,192 @@
|
||||
import { motion } from 'framer-motion';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
import { fadeSlide } from './constants';
|
||||
import { WORK_TYPES, TEAM_SIZES, GOALS, buildProfilePreview } from '@/lib/onboarding-profile';
|
||||
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@/components/ui/select';
|
||||
import type { WhoAreYouStepProps } from './types';
|
||||
|
||||
/** Industry options — copied from UserProfileApp's Identity tab (reuse pattern). */
|
||||
const INDUSTRIES = [
|
||||
'Technology', 'Financial Services', 'Consulting', 'Healthcare',
|
||||
'Education', 'Manufacturing', 'Retail', 'Media', 'Legal',
|
||||
'Real Estate', 'Energy', 'Government', 'Non-profit', 'Other',
|
||||
] as const;
|
||||
|
||||
const profileChipClass = (selected: boolean): string => selected
|
||||
? 'border border-primary/40 bg-primary text-primary-foreground'
|
||||
: 'border border-[var(--line-affordance)] bg-muted/50 text-[var(--text-tertiary)] hover:border-[var(--focus-ring)] hover:text-foreground';
|
||||
|
||||
/**
|
||||
* S13 / B8 — "Who Are You". Captures the day-0 identity + personalization
|
||||
* signals and renders a live one-line preview. On Continue the wizard performs
|
||||
* the dual write (`PUT /api/profile` AND `POST /api/identity`) so the Home
|
||||
* cockpit greets the user by name (B8). This component is presentational: it
|
||||
* lifts every field through `onChange` and delegates the save to `onContinue`.
|
||||
*/
|
||||
const WhoAreYouStep = ({ profile, onChange, onContinue, saving }: WhoAreYouStepProps) => {
|
||||
const goals = profile.goals ?? [];
|
||||
const toggleGoal = (id: string) => {
|
||||
const next = goals.includes(id) ? goals.filter(g => g !== id) : [...goals, id];
|
||||
onChange({ goals: next });
|
||||
};
|
||||
|
||||
const preview = buildProfilePreview({
|
||||
name: profile.name,
|
||||
role: profile.role,
|
||||
industry: profile.industry,
|
||||
workType: profile.workType,
|
||||
teamSize: profile.teamSize,
|
||||
goals,
|
||||
});
|
||||
|
||||
return (
|
||||
<motion.div key="step-who-are-you" {...fadeSlide} className="w-full min-w-0">
|
||||
{/* Wave V Lane F item 3 (mascot carry): the generic UserRound glyph that
|
||||
used to head this step is gone — the wizard shell now carries the
|
||||
persistent breathing hex-bee across every step, so the brand mascot is
|
||||
the header instead of a per-step icon swap. */}
|
||||
<div className="text-center mb-3 sm:mb-6">
|
||||
<h2 className="text-xl sm:text-2xl font-display font-bold text-foreground mb-1.5 sm:mb-2">
|
||||
Tell us who you are
|
||||
</h2>
|
||||
<p className="text-[13px] sm:text-sm text-muted-foreground leading-snug sm:leading-normal">
|
||||
Waggle uses this to greet you by name and tailor how it helps. You can change it anytime in My Profile.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3 sm:space-y-5">
|
||||
{/* Name / Role / Industry */}
|
||||
<div className="grid grid-cols-1 sm:grid-cols-3 gap-2 sm:gap-3">
|
||||
<div>
|
||||
<label className="text-xs text-muted-foreground block mb-1" htmlFor="who-name">Name</label>
|
||||
<input
|
||||
id="who-name"
|
||||
name="onboardingName"
|
||||
autoComplete="name"
|
||||
value={profile.name ?? ''}
|
||||
onChange={e => onChange({ name: e.target.value })}
|
||||
placeholder="Marko Markovic"
|
||||
className="w-full bg-muted/50 border border-border/50 rounded-lg px-3 py-1.5 text-[13px] sm:text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-xs text-muted-foreground block mb-1" htmlFor="who-role">Role</label>
|
||||
<input
|
||||
id="who-role"
|
||||
name="onboardingRole"
|
||||
autoComplete="organization-title"
|
||||
value={profile.role ?? ''}
|
||||
onChange={e => onChange({ role: e.target.value })}
|
||||
placeholder="Strategy Consultant"
|
||||
className="w-full bg-muted/50 border border-border/50 rounded-lg px-3 py-1.5 text-[13px] sm:text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-xs text-muted-foreground block mb-1" htmlFor="who-industry">Industry</label>
|
||||
{/* Wave V Lane F item 3: the native OS <select> rendered its options
|
||||
list in un-themed browser chrome (a white popup in dark mode).
|
||||
The app's themed Select primitive (Radix) renders a token-driven
|
||||
dropdown that matches both themes; the trigger inherits the same
|
||||
bg-muted/50 + border-border/50 grammar as the Name/Role inputs. */}
|
||||
<Select
|
||||
value={profile.industry || undefined}
|
||||
onValueChange={(v) => onChange({ industry: v })}
|
||||
>
|
||||
<SelectTrigger
|
||||
id="who-industry"
|
||||
aria-label="Industry"
|
||||
className="w-full h-auto bg-muted/50 border-border/50 rounded-lg px-3 py-1.5 text-[13px] sm:text-sm text-foreground"
|
||||
>
|
||||
<SelectValue placeholder="Select…" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{INDUSTRIES.map(i => (
|
||||
<SelectItem key={i} value={i}>{i}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Work type (C30 — distinct personalization signal from the template) */}
|
||||
<div>
|
||||
<label className="text-xs text-muted-foreground block mb-1.5 sm:mb-2">What kind of work do you do?</label>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{WORK_TYPES.map(w => (
|
||||
<button
|
||||
key={w.id}
|
||||
type="button"
|
||||
aria-pressed={profile.workType === w.id}
|
||||
onClick={() => onChange({ workType: profile.workType === w.id ? '' : w.id })}
|
||||
className={`px-2.5 py-1 sm:px-3 sm:py-1.5 rounded-lg text-xs font-display transition-colors ${profileChipClass(profile.workType === w.id)}`}
|
||||
>
|
||||
{w.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Team size */}
|
||||
<div>
|
||||
<label className="text-xs text-muted-foreground block mb-1.5 sm:mb-2">How big is your team?</label>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{TEAM_SIZES.map(t => (
|
||||
<button
|
||||
key={t.id}
|
||||
type="button"
|
||||
aria-pressed={profile.teamSize === t.id}
|
||||
onClick={() => onChange({ teamSize: profile.teamSize === t.id ? '' : t.id })}
|
||||
className={`px-2.5 py-1 sm:px-3 sm:py-1.5 rounded-lg text-xs font-display transition-colors ${profileChipClass(profile.teamSize === t.id)}`}
|
||||
>
|
||||
{t.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Goals (multi-select chips) */}
|
||||
<div>
|
||||
<label className="text-xs text-muted-foreground block mb-1.5 sm:mb-2">What do you want Waggle to help with?</label>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{GOALS.map(g => {
|
||||
const on = goals.includes(g.id);
|
||||
return (
|
||||
<button
|
||||
key={g.id}
|
||||
type="button"
|
||||
aria-pressed={on}
|
||||
onClick={() => toggleGoal(g.id)}
|
||||
className={`px-2.5 py-1 sm:px-3 sm:py-1.5 rounded-lg text-xs font-display transition-colors ${profileChipClass(on)}`}
|
||||
>
|
||||
{g.label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Live preview */}
|
||||
<div className="p-2.5 sm:p-3 rounded-xl bg-secondary/30 border border-border/30">
|
||||
{/* Lane T: was text-muted-foreground/70 (~2.9:1 light over the tinted
|
||||
preview panel — sub-AA). Full-opacity --text-tertiary → ≥5.2:1. */}
|
||||
<p className="text-[11px] uppercase tracking-wide text-[var(--text-tertiary)] mb-1 font-display">Preview</p>
|
||||
<p className="text-sm text-foreground">{preview}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-end gap-4 mt-4 sm:mt-6">
|
||||
<button
|
||||
onClick={onContinue}
|
||||
disabled={saving}
|
||||
aria-busy={saving}
|
||||
className="inline-flex items-center gap-2 px-5 py-2 sm:py-2.5 rounded-xl bg-primary text-primary-foreground font-display text-sm font-semibold hover:bg-primary/80 disabled:opacity-50 transition-colors focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
>
|
||||
{saving ? <Loader2 aria-hidden="true" className="w-4 h-4 animate-spin" /> : null}
|
||||
{saving ? 'Saving…' : 'Continue →'}
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
export default WhoAreYouStep;
|
||||
@@ -0,0 +1,26 @@
|
||||
import { cleanup, render, screen } from '@testing-library/react';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import WorkspaceCreateStep from './WorkspaceCreateStep';
|
||||
|
||||
afterEach(() => cleanup());
|
||||
|
||||
describe('WorkspaceCreateStep', () => {
|
||||
it('a11y: workspace name exposes stable form metadata', () => {
|
||||
render(
|
||||
<WorkspaceCreateStep
|
||||
workspaceType="project"
|
||||
workspaceName="Launch"
|
||||
onSelectType={vi.fn()}
|
||||
onNameChange={vi.fn()}
|
||||
onCreate={vi.fn()}
|
||||
onBack={vi.fn()}
|
||||
creating={false}
|
||||
createError={null}
|
||||
/>,
|
||||
);
|
||||
|
||||
const name = screen.getByRole('textbox', { name: /workspace name/i });
|
||||
expect(name).toHaveAttribute('name', 'onboardingWorkspaceName');
|
||||
expect(name).toHaveAttribute('autocomplete', 'off');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,111 @@
|
||||
import { motion } from 'framer-motion';
|
||||
import { FolderPlus, Briefcase, Users2, Microscope, User, Loader2 } from 'lucide-react';
|
||||
import type { ElementType } from 'react';
|
||||
import { fadeSlide } from './constants';
|
||||
import type { WorkspaceCreateStepProps, OnboardingWorkspaceType } from './types';
|
||||
|
||||
/**
|
||||
* S17 (thin / onboarding-embedded) — Workspace Creation. A trimmed type-picker
|
||||
* (C6: `project | client | research | personal`) + a name field, routed through
|
||||
* the SAME existing create path (`handleFinish` → `adapter.createWorkspace`).
|
||||
* The full stepped S17 wizard (suggested skills/agents/connectors panels) is a
|
||||
* separate standalone card; per C35 no installs/OAuth run here. The full
|
||||
* 6-type `WorkspaceType` reserves `team`/`organization` — onboarding offers the
|
||||
* 4 personal-scope types only.
|
||||
*/
|
||||
const WORKSPACE_TYPES: ReadonlyArray<{
|
||||
id: OnboardingWorkspaceType;
|
||||
name: string;
|
||||
desc: string;
|
||||
icon: ElementType;
|
||||
}> = [
|
||||
{ id: 'project', name: 'Project', desc: 'A focused piece of work', icon: Briefcase },
|
||||
{ id: 'client', name: 'Client', desc: 'Work for a specific client', icon: Users2 },
|
||||
{ id: 'research', name: 'Research', desc: 'Explore a topic or question', icon: Microscope },
|
||||
{ id: 'personal', name: 'Personal', desc: 'Your own space', icon: User },
|
||||
];
|
||||
|
||||
const WorkspaceCreateStep = ({
|
||||
workspaceType,
|
||||
workspaceName,
|
||||
onSelectType,
|
||||
onNameChange,
|
||||
onCreate,
|
||||
onBack,
|
||||
creating,
|
||||
createError,
|
||||
}: WorkspaceCreateStepProps) => (
|
||||
<motion.div key="step-workspace-create" {...fadeSlide}>
|
||||
<div className="text-center mb-6">
|
||||
<FolderPlus className="w-10 h-10 text-honey mx-auto mb-3" />
|
||||
<h2 className="text-2xl font-display font-bold text-foreground mb-2">
|
||||
Create your first workspace
|
||||
</h2>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Each workspace is its own brain — memory, files, and agents stay isolated.
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground/70 mt-1.5">
|
||||
Your agent learns each workspace's patterns and can propose new skills — you approve every change.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-2.5 mb-5">
|
||||
{WORKSPACE_TYPES.map((t) => {
|
||||
const Icon = t.icon;
|
||||
const selected = workspaceType === t.id;
|
||||
return (
|
||||
<button
|
||||
key={t.id}
|
||||
type="button"
|
||||
onClick={() => onSelectType(t.id)}
|
||||
aria-pressed={selected}
|
||||
className={`glass-strong rounded-xl p-3.5 text-left transition-colors flex flex-col gap-1 ${
|
||||
selected ? 'ring-2 ring-primary border-primary/40' : 'hover:border-primary/40'
|
||||
}`}
|
||||
>
|
||||
<Icon className={`w-5 h-5 mb-0.5 ${selected ? 'text-honey' : 'text-muted-foreground'}`} />
|
||||
<h3 className="text-sm font-display font-semibold text-foreground">{t.name}</h3>
|
||||
<p className="text-[11px] text-muted-foreground">{t.desc}</p>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="mb-5">
|
||||
<label className="text-xs text-muted-foreground block mb-1" htmlFor="ws-name">Workspace name</label>
|
||||
<input
|
||||
id="ws-name"
|
||||
name="onboardingWorkspaceName"
|
||||
autoComplete="off"
|
||||
value={workspaceName}
|
||||
onChange={e => onNameChange(e.target.value)}
|
||||
placeholder="My Workspace"
|
||||
className="w-full bg-muted/50 border border-border/50 rounded-lg px-3 py-2 text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{createError && (
|
||||
<p className="text-xs text-[var(--sem-risk,theme(colors.red.400))] mb-3">{createError}</p>
|
||||
)}
|
||||
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<button
|
||||
onClick={onBack}
|
||||
className="text-sm text-muted-foreground hover:text-foreground transition-colors font-display rounded-md px-1 focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
>
|
||||
Back
|
||||
</button>
|
||||
<button
|
||||
onClick={onCreate}
|
||||
disabled={creating || !workspaceName.trim()}
|
||||
aria-busy={creating}
|
||||
className="inline-flex items-center gap-2 px-5 py-2.5 rounded-xl bg-primary text-primary-foreground font-display text-sm font-semibold hover:bg-primary/80 disabled:opacity-50 transition-colors focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
||||
>
|
||||
{creating ? <Loader2 aria-hidden="true" className="w-4 h-4 animate-spin" /> : null}
|
||||
{creating ? 'Creating…' : 'Create workspace →'}
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
|
||||
export default WorkspaceCreateStep;
|
||||
187
apps/web/src/components/os/overlays/onboarding/constants.ts
Normal file
187
apps/web/src/components/os/overlays/onboarding/constants.ts
Normal file
@@ -0,0 +1,187 @@
|
||||
import {
|
||||
Brain, Layers, Wrench, Target, Microscope, Laptop, Megaphone, Rocket,
|
||||
Scale, Building, Plus, PenLine, BarChart3, Code, ClipboardList, Mail,
|
||||
Hexagon, Zap, Crown, HeadphonesIcon, Settings, Database, Users,
|
||||
Palette, DollarSign, Briefcase,
|
||||
} from 'lucide-react';
|
||||
import { DUR } from '@/lib/motion/tokens';
|
||||
import type { OnboardingTemplate, OnboardingPersona, ValueProp, TierOption } from './types';
|
||||
import type { UserTier } from '@/lib/dock-tiers';
|
||||
|
||||
export const TEMPLATES: readonly OnboardingTemplate[] = [
|
||||
{ id: 'sales-pipeline', name: 'Sales Pipeline', icon: Target, hint: 'Research the top 5 competitors in my industry', desc: 'Track deals and prospects' },
|
||||
{ id: 'research-project', name: 'Research Hub', icon: Microscope, hint: 'Help me design a literature review on my topic', desc: 'Deep dive into any subject' },
|
||||
{ id: 'code-review', name: 'Engineering', icon: Laptop, hint: 'Read my project and tell me what you see', desc: 'Code, review, and ship' },
|
||||
{ id: 'marketing-campaign', name: 'Marketing & Content', icon: Megaphone, hint: 'Draft a campaign brief for my product launch', desc: 'Campaigns, copy, and SEO' },
|
||||
{ id: 'product-launch', name: 'Product Management', icon: Rocket, hint: 'Help me write a PRD for my next feature', desc: 'Specs, roadmaps, and launches' },
|
||||
{ id: 'legal-review', name: 'Legal & Compliance', icon: Scale, hint: 'Draft a standard NDA template', desc: 'Contracts, compliance, and risk' },
|
||||
{ id: 'agency-consulting', name: 'Consulting', icon: Building, hint: 'Set up client workspaces for my biggest accounts', desc: 'Client delivery and strategy' },
|
||||
{ id: 'customer-support', name: 'Customer Support', icon: HeadphonesIcon, hint: 'Help me draft a response to this customer issue', desc: 'Tickets, KB, and escalation' },
|
||||
{ id: 'finance-accounting', name: 'Finance', icon: DollarSign, hint: 'Prepare a variance analysis for this month', desc: 'Budgets, reports, and close' },
|
||||
{ id: 'hr-people', name: 'HR & People', icon: Users, hint: 'Draft a job description for a senior engineer', desc: 'Hiring, policy, and onboarding' },
|
||||
{ id: 'operations-center', name: 'Operations', icon: Settings, hint: 'Create an SOP for our onboarding process', desc: 'Processes, SOPs, and vendors' },
|
||||
{ id: 'data-analytics', name: 'Data & Analytics', icon: Database, hint: 'Write a SQL query to find our top customers', desc: 'SQL, dashboards, and insights' },
|
||||
{ id: 'recruiting-pipeline', name: 'Recruiting', icon: Briefcase, hint: 'Write a job description and screening scorecard', desc: 'Source, screen, and hire' },
|
||||
{ id: 'design-studio', name: 'Design Studio', icon: Palette, hint: 'Write a creative brief for our rebrand', desc: 'Briefs, feedback, and brand' },
|
||||
{ id: 'blank', name: 'Blank Workspace', icon: Plus, hint: 'Hello! What can you help me with?', desc: 'Start from scratch' },
|
||||
] as const;
|
||||
|
||||
export const TEMPLATE_PERSONA: Readonly<Record<string, string>> = {
|
||||
'sales-pipeline': 'sales-rep',
|
||||
'research-project': 'researcher',
|
||||
'code-review': 'coder',
|
||||
'marketing-campaign': 'marketer',
|
||||
'product-launch': 'product-manager-senior',
|
||||
'legal-review': 'legal-professional',
|
||||
'agency-consulting': 'consultant',
|
||||
'customer-support': 'support-agent',
|
||||
'finance-accounting': 'finance-owner',
|
||||
'hr-people': 'hr-manager',
|
||||
'operations-center': 'ops-manager',
|
||||
'data-analytics': 'data-engineer',
|
||||
'recruiting-pipeline': 'recruiter',
|
||||
'design-studio': 'creative-director',
|
||||
'blank': 'general-purpose',
|
||||
};
|
||||
|
||||
/**
|
||||
* PR5 D5 — the curated 6 onboarding starting points for the ≤2-min flow. The full
|
||||
* 15 (and more specialists) live in the workspace gallery later. These map to existing
|
||||
* TEMPLATES ids + TEMPLATE_PERSONA — curation, not new data.
|
||||
*/
|
||||
export const CURATED_ONBOARDING_TEMPLATE_IDS = [
|
||||
'research-project', 'code-review', 'sales-pipeline',
|
||||
'marketing-campaign', 'product-launch', 'blank',
|
||||
] as const;
|
||||
|
||||
export const CURATED_ONBOARDING_TEMPLATES: readonly OnboardingTemplate[] =
|
||||
CURATED_ONBOARDING_TEMPLATE_IDS
|
||||
.map((id) => TEMPLATES.find((t) => t.id === id))
|
||||
.filter((t): t is OnboardingTemplate => Boolean(t));
|
||||
|
||||
/**
|
||||
* First-task suggestion chips per curated template. The single `hint` on each
|
||||
* TEMPLATE seeds the textarea; this gives the terminal step 2-3 tailored prompts
|
||||
* to pick from instead of the same 6 generic hints for everyone. Keyed by curated
|
||||
* template id; the wizard falls back to the curated hints when the chosen id has
|
||||
* no group. Each group leads with the template's own `hint` for continuity.
|
||||
*/
|
||||
export const TEMPLATE_SUGGESTIONS: Readonly<Record<string, readonly string[]>> = {
|
||||
'research-project': [
|
||||
'Help me design a literature review on my topic',
|
||||
'Summarize the key debates in my field',
|
||||
'Find the strongest sources for my argument',
|
||||
],
|
||||
'code-review': [
|
||||
'Read my project and tell me what you see',
|
||||
'Review this file for bugs and edge cases',
|
||||
'Explain how this codebase is structured',
|
||||
],
|
||||
'sales-pipeline': [
|
||||
'Research the top 5 competitors in my industry',
|
||||
'Draft a cold outreach email for a new prospect',
|
||||
'Help me prep for an upcoming sales call',
|
||||
],
|
||||
'marketing-campaign': [
|
||||
'Draft a campaign brief for my product launch',
|
||||
'Write three headline options for this landing page',
|
||||
'Outline a content calendar for next month',
|
||||
],
|
||||
'product-launch': [
|
||||
'Help me write a PRD for my next feature',
|
||||
'Draft a roadmap for the next quarter',
|
||||
'Turn this idea into user stories',
|
||||
],
|
||||
'blank': [
|
||||
'Hello! What can you help me with?',
|
||||
'Summarize a document I paste here',
|
||||
'Help me plan my week',
|
||||
],
|
||||
};
|
||||
|
||||
export const ALL_ONBOARDING_PERSONAS: readonly OnboardingPersona[] = [
|
||||
{ id: 'general-purpose', name: 'General Purpose', icon: Brain, desc: 'Adapts to any task', tier: 'universal' as const },
|
||||
{ id: 'researcher', name: 'Researcher', icon: Microscope, desc: 'Deep research & synthesis', tier: 'knowledge' as const },
|
||||
{ id: 'writer', name: 'Writer', icon: PenLine, desc: 'Drafting & editing', tier: 'knowledge' as const },
|
||||
{ id: 'analyst', name: 'Analyst', icon: BarChart3, desc: 'Data analysis & decisions', tier: 'knowledge' as const },
|
||||
{ id: 'coder', name: 'Coder', icon: Code, desc: 'Code & architecture', tier: 'knowledge' as const },
|
||||
{ id: 'project-manager', name: 'Project Manager', icon: ClipboardList, desc: 'Planning & coordination', tier: 'domain' as const },
|
||||
{ id: 'executive-assistant', name: 'Exec Assistant', icon: Mail, desc: 'Email & scheduling', tier: 'domain' as const },
|
||||
{ id: 'sales-rep', name: 'Sales Rep', icon: Target, desc: 'Prospecting & outreach', tier: 'domain' as const },
|
||||
{ id: 'marketer', name: 'Marketer', icon: Megaphone, desc: 'Campaigns & copy', tier: 'domain' as const },
|
||||
{ id: 'product-manager-senior', name: 'Senior PM', icon: Rocket, desc: 'PRDs & roadmaps', tier: 'domain' as const },
|
||||
{ id: 'hr-manager', name: 'HR Manager', icon: Users, desc: 'Policy & compliance', tier: 'domain' as const },
|
||||
{ id: 'legal-professional', name: 'Legal Counsel', icon: Scale, desc: 'Contracts & compliance', tier: 'domain' as const },
|
||||
{ id: 'finance-owner', name: 'Business Finance', icon: DollarSign, desc: 'Budgets & reporting', tier: 'domain' as const },
|
||||
{ id: 'consultant', name: 'Consultant', icon: Building, desc: 'Strategy & deliverables', tier: 'domain' as const },
|
||||
{ id: 'support-agent', name: 'Support Agent', icon: HeadphonesIcon, desc: 'Tickets & KB articles', tier: 'domain' as const },
|
||||
{ id: 'ops-manager', name: 'Ops Manager', icon: Settings, desc: 'SOPs & processes', tier: 'domain' as const },
|
||||
{ id: 'data-engineer', name: 'Data Engineer', icon: Database, desc: 'SQL & dashboards', tier: 'domain' as const },
|
||||
{ id: 'recruiter', name: 'Recruiter', icon: Briefcase, desc: 'Sourcing & hiring', tier: 'domain' as const },
|
||||
{ id: 'creative-director', name: 'Creative Director', icon: Palette, desc: 'Briefs & brand', tier: 'domain' as const },
|
||||
] as const;
|
||||
|
||||
/** Get personas relevant to the selected template — recommended first, then others */
|
||||
export function getPersonasForTemplate(templateId: string): readonly OnboardingPersona[] {
|
||||
const recommended = TEMPLATE_PERSONA[templateId];
|
||||
const universal = ALL_ONBOARDING_PERSONAS.filter(p => p.tier === 'universal');
|
||||
const knowledge = ALL_ONBOARDING_PERSONAS.filter(p => p.tier === 'knowledge');
|
||||
const domain = ALL_ONBOARDING_PERSONAS.filter(p => p.tier === 'domain');
|
||||
return [
|
||||
...domain.filter(p => p.id === recommended),
|
||||
...universal,
|
||||
...knowledge,
|
||||
...domain.filter(p => p.id !== recommended),
|
||||
];
|
||||
}
|
||||
|
||||
// QW-5: display labels renamed to avoid collision with billing tiers
|
||||
// (billing uses "Pro $19/mo", "Teams $49/seat"). Dock tiers describe how
|
||||
// many icons appear — they are UI layout, not billing. Internal enum
|
||||
// values ('simple' / 'professional' / 'power') stay the same so stored
|
||||
// user preferences keep working without migration.
|
||||
export const TIER_OPTIONS: readonly TierOption[] = [
|
||||
{
|
||||
id: 'simple' as UserTier,
|
||||
name: 'Essential',
|
||||
icon: Hexagon,
|
||||
color: 'text-sky-400',
|
||||
desc: 'Clean and focused. Just the essentials — chat, files, and home.',
|
||||
},
|
||||
{
|
||||
id: 'professional' as UserTier,
|
||||
name: 'Standard',
|
||||
icon: Zap,
|
||||
color: 'text-amber-400',
|
||||
desc: 'Agents, memory, and workspace tools. The full knowledge-worker kit.',
|
||||
},
|
||||
{
|
||||
id: 'power' as UserTier,
|
||||
name: 'Everything',
|
||||
icon: Crown,
|
||||
color: 'text-violet-400',
|
||||
desc: 'All apps visible. Ops console, scheduled jobs, marketplace.',
|
||||
},
|
||||
] as const;
|
||||
|
||||
export const VALUE_PROPS: readonly ValueProp[] = [
|
||||
{ icon: Brain, title: 'Remembers everything', desc: 'Persistent memory across all sessions' },
|
||||
{ icon: Layers, title: 'Workspace-native', desc: 'One brain per project, fully isolated' },
|
||||
{ icon: Wrench, title: 'Real tools', desc: 'Search, draft, code, plan — not just chat' },
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Shared framer-motion transition for step content.
|
||||
* Wave W Lane E fix 2: directional (horizontal) slide instead of the old
|
||||
* vertical nudge — the incoming step enters from the right (x:24) as the
|
||||
* outgoing one exits left (x:-24), so welcome→step-1 (and every later step)
|
||||
* reads as forward spatial motion rather than a fade-in-place. ~200ms.
|
||||
* Motion-safe: the wizard wraps steps in <MotionConfig reducedMotion="user">,
|
||||
* which drops the x transform to a pure opacity fade for reduced-motion users.
|
||||
*/
|
||||
export const fadeSlide = {
|
||||
initial: { opacity: 0, x: 24 },
|
||||
animate: { opacity: 1, x: 0 },
|
||||
exit: { opacity: 0, x: -24 },
|
||||
transition: { duration: DUR.base },
|
||||
} as const;
|
||||
@@ -0,0 +1,36 @@
|
||||
/** PR5 D5 — the curated 6 onboarding templates resolve to real data + personas. */
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
CURATED_ONBOARDING_TEMPLATES,
|
||||
CURATED_ONBOARDING_TEMPLATE_IDS,
|
||||
TEMPLATE_PERSONA,
|
||||
TEMPLATE_SUGGESTIONS,
|
||||
} from './constants';
|
||||
|
||||
describe('curated onboarding templates (PR5 D5)', () => {
|
||||
it('resolves all 6 curated ids to real templates (no silent drops)', () => {
|
||||
expect(CURATED_ONBOARDING_TEMPLATE_IDS).toHaveLength(6);
|
||||
expect(CURATED_ONBOARDING_TEMPLATES).toHaveLength(CURATED_ONBOARDING_TEMPLATE_IDS.length);
|
||||
});
|
||||
|
||||
it('maps every curated template to a specialist persona', () => {
|
||||
for (const t of CURATED_ONBOARDING_TEMPLATES) {
|
||||
expect(TEMPLATE_PERSONA[t.id]).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
it('gives every curated template a non-empty hint for the first-task seed', () => {
|
||||
for (const t of CURATED_ONBOARDING_TEMPLATES) {
|
||||
expect(t.hint.length).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
|
||||
it('gives every curated template a non-empty first-task suggestion group', () => {
|
||||
for (const t of CURATED_ONBOARDING_TEMPLATES) {
|
||||
const group = TEMPLATE_SUGGESTIONS[t.id];
|
||||
expect(group).toBeDefined();
|
||||
expect(group.length).toBeGreaterThan(0);
|
||||
expect(group.every(s => s.length > 0)).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
21
apps/web/src/components/os/overlays/onboarding/index.ts
Normal file
21
apps/web/src/components/os/overlays/onboarding/index.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
export { default as WelcomeStep } from './WelcomeStep';
|
||||
export { default as WhoAreYouStep } from './WhoAreYouStep';
|
||||
export { default as ModelGateStep } from './ModelGateStep';
|
||||
export { default as ImportStep } from './ImportStep';
|
||||
export { default as TemplateStep } from './TemplateStep';
|
||||
export { default as FirstTaskStep } from './FirstTaskStep';
|
||||
export { default as WorkspaceCreateStep } from './WorkspaceCreateStep';
|
||||
export { default as ReadyStep } from './ReadyStep';
|
||||
|
||||
export type {
|
||||
WelcomeStepProps,
|
||||
WhoAreYouStepProps,
|
||||
ModelGateStepProps,
|
||||
ImportStepProps,
|
||||
TemplateStepProps,
|
||||
FirstTaskStepProps,
|
||||
WorkspaceCreateStepProps,
|
||||
ReadyStepProps,
|
||||
OnboardingProfileFields,
|
||||
OnboardingWorkspaceType,
|
||||
} from './types';
|
||||
@@ -0,0 +1,50 @@
|
||||
/** Who-are-you → curated template recommendation (badge + first ordering). */
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { recommendTemplateId } from './recommend-template';
|
||||
import { CURATED_ONBOARDING_TEMPLATE_IDS } from './constants';
|
||||
|
||||
describe('recommendTemplateId', () => {
|
||||
it('maps each supported work type to a curated template id', () => {
|
||||
expect(recommendTemplateId('engineering')).toBe('code-review');
|
||||
expect(recommendTemplateId('product')).toBe('product-launch');
|
||||
expect(recommendTemplateId('research')).toBe('research-project');
|
||||
expect(recommendTemplateId('sales')).toBe('sales-pipeline');
|
||||
expect(recommendTemplateId('marketing')).toBe('marketing-campaign');
|
||||
// Consulting has no curated card — Research Hub is the proxy.
|
||||
expect(recommendTemplateId('consulting')).toBe('research-project');
|
||||
});
|
||||
|
||||
it('only ever recommends a curated id', () => {
|
||||
const curated = new Set<string>(CURATED_ONBOARDING_TEMPLATE_IDS);
|
||||
for (const wt of ['engineering', 'product', 'research', 'sales', 'marketing', 'consulting']) {
|
||||
const id = recommendTemplateId(wt);
|
||||
expect(id).not.toBeNull();
|
||||
expect(curated.has(id as string)).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('returns null for work types without a curated match', () => {
|
||||
for (const wt of ['operations', 'finance', 'legal', 'design', 'leadership', 'other']) {
|
||||
expect(recommendTemplateId(wt)).toBeNull();
|
||||
}
|
||||
});
|
||||
|
||||
it('falls back to keyword-matching the free-text role when work type is empty', () => {
|
||||
expect(recommendTemplateId('', 'Senior Software Engineer')).toBe('code-review');
|
||||
expect(recommendTemplateId(undefined, 'Strategy Consultant')).toBe('research-project');
|
||||
expect(recommendTemplateId('', 'Head of Sales')).toBe('sales-pipeline');
|
||||
expect(recommendTemplateId('', 'Growth Marketer')).toBe('marketing-campaign');
|
||||
expect(recommendTemplateId('', 'Product Manager')).toBe('product-launch');
|
||||
expect(recommendTemplateId('', 'Research Scientist')).toBe('research-project');
|
||||
});
|
||||
|
||||
it('prefers the explicit work type over the role text', () => {
|
||||
expect(recommendTemplateId('sales', 'Software Engineer')).toBe('sales-pipeline');
|
||||
});
|
||||
|
||||
it('returns null when neither signal matches', () => {
|
||||
expect(recommendTemplateId()).toBeNull();
|
||||
expect(recommendTemplateId('', '')).toBeNull();
|
||||
expect(recommendTemplateId('', 'Operations Lead')).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
// Pure mapping: who-are-you signals (workType / role) → a curated onboarding
|
||||
// template id, used to badge + float the "Recommended" starting point on the
|
||||
// Template step. Returns null when no confident match exists (no badge, list
|
||||
// keeps its default order). Kept out of the component so the table is unit-
|
||||
// testable without mounting the tree.
|
||||
|
||||
/** Curated-6 template ids (mirrors CURATED_ONBOARDING_TEMPLATE_IDS in constants.ts). */
|
||||
type CuratedTemplateId =
|
||||
| 'code-review'
|
||||
| 'product-launch'
|
||||
| 'research-project'
|
||||
| 'sales-pipeline'
|
||||
| 'marketing-campaign';
|
||||
|
||||
/** WORK_TYPES id → curated template id. Only work types with a curated match
|
||||
* appear; everything else (operations/finance/legal/design/leadership/other)
|
||||
* falls through to null. Consulting has no curated card — Research Hub is the
|
||||
* plan-mandated proxy. */
|
||||
const WORK_TYPE_TO_TEMPLATE: Readonly<Record<string, CuratedTemplateId>> = {
|
||||
engineering: 'code-review',
|
||||
product: 'product-launch',
|
||||
research: 'research-project',
|
||||
sales: 'sales-pipeline',
|
||||
marketing: 'marketing-campaign',
|
||||
consulting: 'research-project',
|
||||
};
|
||||
|
||||
/** Free-text role keyword fallback (ordered — first match wins). */
|
||||
const ROLE_PATTERNS: ReadonlyArray<readonly [RegExp, CuratedTemplateId]> = [
|
||||
[/consult/i, 'research-project'],
|
||||
[/engineer|develop/i, 'code-review'],
|
||||
[/sales/i, 'sales-pipeline'],
|
||||
[/market/i, 'marketing-campaign'],
|
||||
[/product/i, 'product-launch'],
|
||||
[/research/i, 'research-project'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Recommend a curated template id from the day-0 signals. Prefers the explicit
|
||||
* work-type chip; falls back to keyword-matching the free-text role. Returns
|
||||
* null when neither yields a confident match.
|
||||
*/
|
||||
export function recommendTemplateId(workType?: string, role?: string): string | null {
|
||||
const byWorkType = workType ? WORK_TYPE_TO_TEMPLATE[workType] : undefined;
|
||||
if (byWorkType) return byWorkType;
|
||||
|
||||
const r = role?.trim();
|
||||
if (r) {
|
||||
for (const [pattern, id] of ROLE_PATTERNS) {
|
||||
if (pattern.test(r)) return id;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
135
apps/web/src/components/os/overlays/onboarding/types.ts
Normal file
135
apps/web/src/components/os/overlays/onboarding/types.ts
Normal file
@@ -0,0 +1,135 @@
|
||||
import type { ElementType } from 'react';
|
||||
import type { UserTier } from '@/lib/dock-tiers';
|
||||
import type { UserProfile, ClassifiedHarvestItem } from '@/lib/types';
|
||||
import type { WorkspaceType } from '@waggle/shared';
|
||||
|
||||
/* ─── Shared step prop base ─── */
|
||||
export interface StepNavigation {
|
||||
readonly goToStep: (step: number) => void;
|
||||
}
|
||||
|
||||
/* ─── WelcomeStep (S12 — first-launch) ─── */
|
||||
export interface WelcomeStepProps {
|
||||
/** Advance to the next step (manual Continue; no auto-advance — C29). */
|
||||
readonly onClickAnywhere: () => void;
|
||||
/** Sidecar reachability — surfaces an offline-ready note (C28 companion). */
|
||||
readonly offline?: boolean;
|
||||
}
|
||||
|
||||
/* ─── WhoAreYouStep (S13 / B8) ─── */
|
||||
/** The profile slice the Who-Are-You step edits. */
|
||||
export type OnboardingProfileFields = Pick<
|
||||
UserProfile,
|
||||
'name' | 'role' | 'industry' | 'workType' | 'teamSize' | 'goals'
|
||||
>;
|
||||
|
||||
export interface WhoAreYouStepProps {
|
||||
readonly profile: OnboardingProfileFields;
|
||||
readonly onChange: (patch: Partial<OnboardingProfileFields>) => void;
|
||||
/** Performs the dual write (profile + identity seed) then advances. */
|
||||
readonly onContinue: () => void;
|
||||
readonly saving: boolean;
|
||||
}
|
||||
|
||||
/* ─── ImportStep (S15 / C33) ─── */
|
||||
export interface ImportStepProps {
|
||||
readonly importSource: string | null;
|
||||
/** Classified preview items (kind + confidence) from harvest/preview (C33). */
|
||||
readonly importItems: readonly ClassifiedHarvestItem[];
|
||||
readonly importDone: boolean;
|
||||
readonly importing: boolean;
|
||||
readonly onFileImport: (file: File, source: string) => void;
|
||||
readonly onImportCommit: () => void;
|
||||
/** Claude Code auto-detect status; when found, renders a one-click harvest. */
|
||||
readonly claudeCodeDetected?: { found: boolean; itemCount: number; path: string } | null;
|
||||
readonly onClaudeCodeHarvest?: () => void;
|
||||
readonly onContinue: () => void;
|
||||
}
|
||||
|
||||
/* ─── WorkspaceCreateStep (S17 thin / C6 / C35) ─── */
|
||||
/** Onboarding-scoped workspace types — the personal-scope subset of WorkspaceType
|
||||
* (`team`/`organization` are reserved for the team flow, not day-0 onboarding). */
|
||||
export type OnboardingWorkspaceType = Extract<
|
||||
WorkspaceType,
|
||||
'project' | 'client' | 'research' | 'personal'
|
||||
>;
|
||||
|
||||
export interface WorkspaceCreateStepProps {
|
||||
readonly workspaceType: OnboardingWorkspaceType;
|
||||
readonly workspaceName: string;
|
||||
readonly onSelectType: (type: OnboardingWorkspaceType) => void;
|
||||
readonly onNameChange: (name: string) => void;
|
||||
readonly onCreate: () => void;
|
||||
readonly onBack: () => void;
|
||||
readonly creating: boolean;
|
||||
readonly createError: string | null;
|
||||
}
|
||||
|
||||
/* ─── ModelGateStep (PR5 D2 — the hard model gate) ─── */
|
||||
export interface ModelGateStepProps {
|
||||
/** Advance to Import — only reachable once a working model exists (hard gate). */
|
||||
readonly onContinue: () => void;
|
||||
/** Soft escape: dismiss onboarding to Home (the NoModelBanner persists there). */
|
||||
readonly onLater: () => void;
|
||||
}
|
||||
|
||||
/* ─── TemplateStep (PR5 D4/D5 — curated 6; selecting one creates the workspace) ─── */
|
||||
export interface TemplateStepProps {
|
||||
readonly templates: readonly OnboardingTemplate[];
|
||||
/** Create the workspace from this template (persona + templateId), then advance. */
|
||||
readonly onSelect: (templateId: string) => void;
|
||||
readonly creating: boolean;
|
||||
/** The template id currently being created (for a per-card spinner). */
|
||||
readonly creatingId: string | null;
|
||||
readonly createError: string | null;
|
||||
/** Curated id recommended from the who-are-you answers (badge + first ordering); null = none. */
|
||||
readonly recommendedId?: string | null;
|
||||
}
|
||||
|
||||
/* ─── FirstTaskStep (PR5 — terminal: seed the first message, open the workspace) ─── */
|
||||
export interface FirstTaskStepProps {
|
||||
readonly message: string;
|
||||
readonly onMessageChange: (message: string) => void;
|
||||
/** Suggested first prompts (the curated templates' hints). */
|
||||
readonly suggestions: readonly string[];
|
||||
readonly onPickSuggestion: (suggestion: string) => void;
|
||||
readonly onLetsGo: () => void;
|
||||
readonly createError: string | null;
|
||||
}
|
||||
|
||||
/* ─── ReadyStep (superseded by FirstTaskStep; kept for any standalone reuse) ─── */
|
||||
export interface ReadyStepProps {
|
||||
readonly createError: string | null;
|
||||
readonly onLetsGo: () => void;
|
||||
}
|
||||
|
||||
/* ─── Shared data types (still consumed by constants.ts + onboarding-tier-filter.ts) ─── */
|
||||
export interface OnboardingTemplate {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly icon: ElementType;
|
||||
readonly hint: string;
|
||||
readonly desc: string;
|
||||
}
|
||||
|
||||
export interface OnboardingPersona {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly icon: ElementType;
|
||||
readonly desc: string;
|
||||
readonly tier: 'universal' | 'knowledge' | 'domain';
|
||||
}
|
||||
|
||||
export interface ValueProp {
|
||||
readonly icon: ElementType;
|
||||
readonly title: string;
|
||||
readonly desc: string;
|
||||
}
|
||||
|
||||
export interface TierOption {
|
||||
readonly id: UserTier;
|
||||
readonly name: string;
|
||||
readonly icon: ElementType;
|
||||
readonly color: string;
|
||||
readonly desc: string;
|
||||
}
|
||||
Reference in New Issue
Block a user