Open source CapCut alternative.
TypeScript
feat(site): welcome new Cut accounts with a five-slide sequence
David Le7bc40d273319
diff --git a/site/src/app/cut/app/(home)/settings/profile/page.tsx b/site/src/app/cut/app/(home)/settings/profile/page.tsxindex ee29df0b..62cd8f56 100644--- a/site/src/app/cut/app/(home)/settings/profile/page.tsx+++ b/site/src/app/cut/app/(home)/settings/profile/page.tsx@@ -8,6 +8,7 @@ import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";import { Label } from "@/components/ui/label";import { UserAvatar } from "@/cut/components/UserAvatar";+import { openOnboarding } from "@/cut/lib/onboarding";import {useAccountProfile,useUpdateDisplayName,@@ -97,6 +98,20 @@ export default function CutProfilePage() {</div></div>+ {/* The welcome sequence is a full-window overlay mounted in the app+ shell, so this row asks for it rather than rendering it. */}+ <div className="flex items-center justify-between gap-4 rounded-xl border bg-card p-5">+ <div className="min-w-0">+ <div className="text-sm font-medium">Welcome tour</div>+ <p className="mt-1 text-sm text-muted-foreground">+ The short intro to Donkey Cut you saw when you signed up.+ </p>+ </div>+ <Button variant="outline" onClick={openOnboarding}>+ Replay+ </Button>+ </div>+<AvatarDialogopen={editingAvatar}onOpenChange={setEditingAvatar}diff --git a/site/src/app/cut/app/layout.tsx b/site/src/app/cut/app/layout.tsxindex eed70299..b87d22ab 100644--- a/site/src/app/cut/app/layout.tsx+++ b/site/src/app/cut/app/layout.tsx@@ -3,6 +3,7 @@ import type { ReactNode } from "react";import { AppSurfaceBackground } from "@/app/app/_components/AppSurfaceBackground";import { ConnectGate } from "@/cut/components/ConnectGate";import { ExportsDock } from "@/cut/components/ExportsDock";+import { CutOnboarding } from "@/cut/components/onboarding/CutOnboarding";import { RequireSession } from "@/cut/components/RequireSession";// The Cut app (projects home, library, editor) renders on the same white@@ -14,7 +15,8 @@ import { RequireSession } from "@/cut/components/RequireSession";// sign-in with their target URL as the callback. ConnectGate picks the backend// the app runs on — the engine on this Mac when it answers without raising the// browser's local-network prompt, the cloud otherwise — and owns the banner-// that reports an engine this browser can no longer reach.+// that reports an engine this browser can no longer reach. CutOnboarding is the+// welcome sequence a new account sees before any of it.export default function CutAppLayout({ children }: { children: ReactNode }) {return (<div className="min-h-screen bg-white font-system text-foreground antialiased">@@ -25,6 +27,9 @@ export default function CutAppLayout({ children }: { children: ReactNode }) {{/* App-wide: exports keep showing as you move between projects. */}<ExportsDock /></ConnectGate>+ {/* Outside the gate so a first run covers the whole window, gate and+ all, and hands over to it when the last slide closes. */}+ <CutOnboarding /></RequireSession></div>);diff --git a/site/src/cut/components/onboarding/CutOnboarding.tsx b/site/src/cut/components/onboarding/CutOnboarding.tsxnew file mode 100644index 00000000..ab5cce44--- /dev/null+++ b/site/src/cut/components/onboarding/CutOnboarding.tsx@@ -0,0 +1,174 @@+"use client";++import { useCallback, useEffect, useRef, useState } from "react";+import { ArrowLeft, ArrowRight } from "lucide-react";++import { Button } from "@/components/ui/button";+import { AiChatSlide } from "@/cut/components/onboarding/slides/AiChat";+import { CreditsSlide } from "@/cut/components/onboarding/slides/Credits";+import { ModesSlide } from "@/cut/components/onboarding/slides/Modes";+import { ReferralSlide } from "@/cut/components/onboarding/slides/Referral";+import { WelcomeSlide } from "@/cut/components/onboarding/slides/Welcome";+import { onOpenOnboarding } from "@/cut/lib/onboarding";+import { track } from "@/lib/analytics";+import type { OnboardingRun, ReferralSource } from "@/lib/onboarding/sequence";+import { cn } from "@/lib/utils";+import {+ needsOnboarding,+ useOnboardingState,+ useSaveOnboarding,+} from "@/queries/onboarding";++const SLIDE_COUNT = 5;++// The welcome sequence: five slides over the whole window, shown once to a new+// account and again whenever settings asks to replay it. Mounted in the Cut app+// shell, above the connect gate, so a first run is the first thing an account+// sees and the gate is waiting underneath when it ends.+//+// The sequence reads state, it doesn't create it. Credits were granted at+// signup (src/lib/onboarding/signup-grants.ts) and the backend is picked by the+// connect gate; nothing here grants, switches, or configures anything. The one+// thing it writes is what it asks for: where the account heard about us.+export function CutOnboarding() {+ const { data: state } = useOnboardingState();+ const save = useSaveOnboarding();+ const [run, setRun] = useState<OnboardingRun | null>(null);+ const [step, setStep] = useState(0);+ const [referral, setReferral] = useState<ReferralSource | null>(null);+ // A first run opens once per page load, and only for an account that hasn't+ // finished this sequence.+ const autoOpened = useRef(false);+ const answerTimer = useRef<number | null>(null);++ const clearAnswerTimer = () => {+ if (answerTimer.current !== null) window.clearTimeout(answerTimer.current);+ answerTimer.current = null;+ };+ useEffect(() => clearAnswerTimer, []);++ const start = useCallback((source: OnboardingRun) => {+ setRun(source);+ setStep(0);+ setReferral(null);+ track("onboarding_started", { source });+ }, []);++ useEffect(() => {+ if (autoOpened.current || !needsOnboarding(state)) return;+ autoOpened.current = true;+ start("first_run");+ }, [state, start]);++ useEffect(() => onOpenOnboarding(() => start("replay")), [start]);++ const finish = useCallback(+ (skipped: boolean) => {+ if (!run) return;+ clearAnswerTimer();+ track("onboarding_completed", { source: run, skipped, step });+ save.mutate({ completed: true, skipped });+ setRun(null);+ },+ [run, save, step],+ );++ const back = useCallback(() => setStep((s) => Math.max(0, s - 1)), []);+ // Past the last slide is the end of the sequence, so one call covers both the+ // Next button and Get started.+ const advance = useCallback(() => {+ if (step >= SLIDE_COUNT - 1) finish(false);+ else setStep(step + 1);+ }, [step, finish]);++ useEffect(() => {+ if (!run) return;+ const onKey = (event: KeyboardEvent) => {+ if (event.key === "Escape") return finish(true);+ if (event.key === "ArrowLeft") return back();+ if (event.key === "ArrowRight" || event.key === "Enter") return advance();+ };+ window.addEventListener("keydown", onKey);+ return () => window.removeEventListener("keydown", onKey);+ }, [run, back, advance, finish]);++ if (!run) return null;++ // The answer saves on the click; the sequence moves on a beat later, so the+ // row gets to show it landed rather than vanishing under the next slide.+ // Tied to the click, not to the slide, so coming back to change an answer+ // doesn't bounce forward again.+ const selectReferral = (source: ReferralSource) => {+ setReferral(source);+ track("onboarding_referral_selected", { referralSource: source });+ save.mutate({ referralSource: source });+ clearAnswerTimer();+ answerTimer.current = window.setTimeout(advance, 220);+ };++ const last = step === SLIDE_COUNT - 1;++ return (+ <div+ role="dialog"+ aria-modal="true"+ aria-label="Welcome to Donkey Cut"+ className="fixed inset-0 z-[80] flex flex-col bg-cream font-system text-ink antialiased"+ >+ <div className="flex shrink-0 items-center justify-between px-6 py-5 md:px-10">+ <span className="text-[15px] font-semibold tracking-[-0.01em]">Donkey Cut</span>+ <button+ type="button"+ onClick={() => finish(true)}+ className="rounded-full px-3 py-1.5 text-[14px] text-[#454545] transition-colors hover:bg-ink/5"+ >+ Skip+ </button>+ </div>++ {/* Auto margins rather than items-center: a slide taller than the window+ scrolls from its top instead of having it clipped away. */}+ <div className="flex min-h-0 flex-1 overflow-y-auto px-6 py-4 md:px-10">+ <div className="m-auto w-full max-w-[1100px]">+ {step === 0 && <WelcomeSlide />}+ {step === 1 && (+ <ReferralSlide selected={referral} onSelect={selectReferral} />+ )}+ {step === 2 && <ModesSlide />}+ {step === 3 && <CreditsSlide run={run} />}+ {step === 4 && <AiChatSlide />}+ </div>+ </div>++ <div className="flex shrink-0 items-center justify-between gap-4 px-6 py-5 md:px-10">+ <Button+ variant="ghost"+ onClick={back}+ className={cn("gap-1.5 text-[#454545]", step === 0 && "invisible")}+ >+ <ArrowLeft className="size-4" /> Back+ </Button>++ <div className="flex items-center gap-1.5">+ {Array.from({ length: SLIDE_COUNT }, (_, i) => (+ <span+ key={i}+ className={cn(+ "size-1.5 rounded-full transition-colors",+ i === step ? "bg-coral" : "bg-ink/20",+ )}+ />+ ))}+ </div>++ <Button+ onClick={advance}+ className="gap-1.5 rounded-full bg-ink px-5 text-white hover:bg-ink/90"+ >+ {last ? "Get started" : "Next"}+ {!last && <ArrowRight className="size-4" />}+ </Button>+ </div>+ </div>+ );+}diff --git a/site/src/cut/components/onboarding/confetti.ts b/site/src/cut/components/onboarding/confetti.tsnew file mode 100644index 00000000..7b6fe27e--- /dev/null+++ b/site/src/cut/components/onboarding/confetti.ts@@ -0,0 +1,94 @@+// A confetti burst for the credits slide, drawn on a canvas the slide owns.+// Small enough to keep in the app rather than take a dependency for one moment+// of the product.++const COLORS = ["#ec7868", "#f2b544", "#4f9d69", "#0f0e0d", "#ffffff"];+const GRAVITY = 0.12;+const DRAG = 0.995;++type Piece = {+ x: number;+ y: number;+ vx: number;+ vy: number;+ w: number;+ h: number;+ rotation: number;+ spin: number;+ color: string;+ life: number;+};++/** Fire one burst from the canvas's upper middle. Returns a stop function for+ * the caller's cleanup; a burst also stops on its own once every piece has+ * fallen past the bottom. No-op under prefers-reduced-motion, where a screenful+ * of moving paper is the last thing anyone wants. */+export function burstConfetti(canvas: HTMLCanvasElement, count = 130): () => void {+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {+ return () => {};+ }+ const context = canvas.getContext("2d");+ if (!context) return () => {};++ const { width, height } = canvas.getBoundingClientRect();+ const ratio = window.devicePixelRatio || 1;+ canvas.width = Math.round(width * ratio);+ canvas.height = Math.round(height * ratio);+ context.scale(ratio, ratio);++ const originX = width / 2;+ const originY = height * 0.38;+ const pieces: Piece[] = Array.from({ length: count }, (_, i) => {+ // Spread the launch angles evenly and jitter each one, so the burst reads+ // as a ring rather than a stripe.+ const angle = (i / count) * Math.PI * 2 + Math.random() * 0.4;+ const speed = 3 + Math.random() * 5;+ return {+ x: originX,+ y: originY,+ vx: Math.cos(angle) * speed,+ vy: Math.sin(angle) * speed - 3,+ w: 5 + Math.random() * 5,+ h: 8 + Math.random() * 6,+ rotation: Math.random() * Math.PI,+ spin: (Math.random() - 0.5) * 0.3,+ color: COLORS[i % COLORS.length],+ life: 0,+ };+ });++ let frame = 0;+ let previous = performance.now();++ const draw = (now: number) => {+ // Step in 60fps units so the burst runs at the same speed on any display.+ const step = Math.min(32, now - previous) / 16.67;+ previous = now;+ context.clearRect(0, 0, width, height);++ let alive = 0;+ for (const piece of pieces) {+ piece.vx *= DRAG;+ piece.vy = piece.vy * DRAG + GRAVITY * step;+ piece.x += piece.vx * step;+ piece.y += piece.vy * step;+ piece.rotation += piece.spin * step;+ piece.life += step;+ if (piece.y - piece.h > height) continue;+ alive += 1;++ context.save();+ context.translate(piece.x, piece.y);+ context.rotate(piece.rotation);+ context.globalAlpha = Math.max(0, 1 - piece.life / 220);+ context.fillStyle = piece.color;+ context.fillRect(-piece.w / 2, -piece.h / 2, piece.w, piece.h);+ context.restore();+ }++ if (alive > 0) frame = requestAnimationFrame(draw);+ };++ frame = requestAnimationFrame(draw);+ return () => cancelAnimationFrame(frame);+}diff --git a/site/src/cut/components/onboarding/slides/AiChat.tsx b/site/src/cut/components/onboarding/slides/AiChat.tsxnew file mode 100644index 00000000..3d7b7859--- /dev/null+++ b/site/src/cut/components/onboarding/slides/AiChat.tsx@@ -0,0 +1,28 @@+"use client";++import { EditorMock } from "@/cut/components/editor-mock/EditorMock";++export function AiChatSlide() {+ return (+ <div className="mx-auto grid w-full max-w-[900px] items-center gap-10 md:grid-cols-[minmax(0,1fr)_auto]">+ <div>+ <h2 className="text-[clamp(26px,3.4vw,36px)] leading-[1.1] font-semibold tracking-[-0.02em]">+ Tell it what to change+ </h2>+ <p className="mt-4 text-[16.5px] leading-[1.55] text-[#454545]">+ The chat sits inside the editor with full access to your project. It+ can cut clips, generate the shot you're missing, write and read+ subtitles, add voiceover, and render the export — and you can ask it+ about your footage instead.+ </p>+ <p className="mt-4 text-[16.5px] leading-[1.55] text-[#454545]">+ It runs on Gemini Flash out of the box, or on your own Claude or Codex+ subscription if you already pay for one.+ </p>+ </div>+ <div className="h-[min(52vh,420px)]">+ <EditorMock view="ai" fit="height" showSwitcher={false} />+ </div>+ </div>+ );+}diff --git a/site/src/cut/components/onboarding/slides/Credits.tsx b/site/src/cut/components/onboarding/slides/Credits.tsxnew file mode 100644index 00000000..4b6e7699--- /dev/null+++ b/site/src/cut/components/onboarding/slides/Credits.tsx@@ -0,0 +1,54 @@+"use client";++import { useEffect, useRef } from "react";++import { burstConfetti } from "@/cut/components/onboarding/confetti";+import { formatUsd } from "@/lib/credits/format-usd";+import { signupAppCredits, type OnboardingRun } from "@/lib/onboarding/sequence";+import { useCreditBalance } from "@/queries/credits";++// The signup grant already landed when the account was created, so this slide+// never grants anything — it shows what is there. A first run celebrates it; a+// replay is a balance check, without the confetti or the news framing.+export function CreditsSlide({ run }: { run: OnboardingRun }) {+ const canvasRef = useRef<HTMLCanvasElement>(null);+ const { data: balance } = useCreditBalance();+ const firstRun = run === "first_run";++ useEffect(() => {+ const canvas = canvasRef.current;+ if (!canvas || !firstRun) return;+ return burstConfetti(canvas);+ }, [firstRun]);++ return (+ <div className="relative flex flex-col items-center text-center">+ {/* Fixed to the window: the burst covers the whole overlay and, being out+ of flow, can't stretch the slide's scroll area. */}+ {firstRun && (+ <canvas ref={canvasRef} aria-hidden className="pointer-events-none fixed inset-0" />+ )}+ <div className="relative max-w-[560px]">+ <div className="text-[clamp(56px,9vw,96px)] leading-none font-semibold tracking-[-0.03em] text-coral tabular-nums">+ {formatUsd(signupAppCredits)}+ </div>+ <h2 className="mt-5 text-[clamp(24px,3.2vw,34px)] leading-[1.1] font-semibold tracking-[-0.02em]">+ {firstRun ? "In AI credits, on the house" : "Your AI credits"}+ </h2>+ <p className="mt-4 text-[16px] leading-[1.55] text-[#454545]">+ {firstRun+ ? "Already in your account — nothing to claim. Spend it on generated images, video, voiceover, and music, right inside the timeline."+ : "Credits pay for generated images, video, voiceover, and music. Top up any time from Settings → Billing."}+ </p>+ {balance?.balance && (+ <p className="mt-6 text-[14px] text-[#454545]">+ Balance today:{" "}+ <span className="font-medium text-ink tabular-nums">+ {formatUsd(balance.balance)}+ </span>+ </p>+ )}+ </div>+ </div>+ );+}diff --git a/site/src/cut/components/onboarding/slides/Modes.tsx b/site/src/cut/components/onboarding/slides/Modes.tsxnew file mode 100644index 00000000..cbeb32c0--- /dev/null+++ b/site/src/cut/components/onboarding/slides/Modes.tsx@@ -0,0 +1,76 @@+"use client";++import { Cloud, Laptop } from "lucide-react";++export function ModesSlide() {+ return (+ <div className="mx-auto w-full max-w-[880px]">+ <h2 className="text-center text-[clamp(26px,3.4vw,36px)] leading-[1.1] font-semibold tracking-[-0.02em]">+ Two places to work+ </h2>+ <p className="mx-auto mt-3 max-w-[560px] text-center text-[16px] leading-[1.5] text-[#454545]">+ Donkey Cut edits in the cloud or on your own machine, and the editor is+ the same either way.+ </p>++ <div className="mt-9 grid gap-4 md:grid-cols-2">+ <Mode+ icon={<Cloud className="size-5" />}+ title="In the cloud"+ points={[+ "Any browser, any OS, nothing to install",+ "Projects and media stored for you",+ "Exports rendered by our workers",+ ]}+ />+ <Mode+ icon={<Laptop className="size-5" />}+ title="On your Mac"+ points={[+ "The Donkey app, macOS only",+ "Footage stays in your own file system",+ "Free on-device speech-to-text, and exports on your hardware",+ ]}+ />+ </div>++ <p className="mx-auto mt-7 max-w-[560px] text-center text-[15px] leading-[1.5] text-[#454545]">+ Nothing to choose now. Donkey Cut works locally whenever the Mac app is+ running and in the cloud when it isn't — each project remembers+ where it lives, and you can move between them any time.+ </p>+ </div>+ );+}++function Mode({+ icon,+ title,+ points,+}: {+ icon: React.ReactNode;+ title: string;+ points: string[];+}) {+ return (+ <div className="rounded-2xl border border-ink/10 bg-white p-6">+ <div className="flex items-center gap-2.5">+ <span className="grid size-9 place-items-center rounded-lg bg-ink/5">+ {icon}+ </span>+ <h3 className="text-[17px] font-semibold">{title}</h3>+ </div>+ <ul className="mt-4 flex flex-col gap-2.5">+ {points.map((point) => (+ <li+ key={point}+ className="flex gap-2.5 text-[14.5px] leading-[1.45] text-[#454545]"+ >+ <span className="mt-[7px] size-1.5 shrink-0 rounded-full bg-coral" />+ {point}+ </li>+ ))}+ </ul>+ </div>+ );+}diff --git a/site/src/cut/components/onboarding/slides/Referral.tsx b/site/src/cut/components/onboarding/slides/Referral.tsxnew file mode 100644index 00000000..227f15c4--- /dev/null+++ b/site/src/cut/components/onboarding/slides/Referral.tsx@@ -0,0 +1,46 @@+"use client";++import { Check } from "lucide-react";++import { REFERRAL_SOURCES, type ReferralSource } from "@/lib/onboarding/sequence";+import { cn } from "@/lib/utils";++type Props = {+ selected: ReferralSource | null;+ onSelect: (source: ReferralSource) => void;+};++export function ReferralSlide({ selected, onSelect }: Props) {+ return (+ <div className="mx-auto w-full max-w-[440px]">+ <h2 className="text-center text-[clamp(26px,3.4vw,36px)] leading-[1.1] font-semibold tracking-[-0.02em]">+ How did you hear about us?+ </h2>+ <p className="mt-3 text-center text-[16px] text-[#454545]">+ It tells us where to show up next.+ </p>+ <div className="mt-8 flex flex-col gap-2">+ {REFERRAL_SOURCES.map((source) => {+ const active = selected === source.id;+ return (+ <button+ key={source.id}+ type="button"+ onClick={() => onSelect(source.id)}+ aria-pressed={active}+ className={cn(+ "flex items-center justify-between rounded-xl border px-4 py-3.5 text-left text-[15px] font-medium transition-colors",+ active+ ? "border-ink bg-ink text-white"+ : "border-ink/15 bg-white hover:border-ink/40",+ )}+ >+ {source.label}+ <Check className={cn("size-4", active ? "opacity-100" : "opacity-0")} />+ </button>+ );+ })}+ </div>+ </div>+ );+}diff --git a/site/src/cut/components/onboarding/slides/Welcome.tsx b/site/src/cut/components/onboarding/slides/Welcome.tsxnew file mode 100644index 00000000..11d1faf9--- /dev/null+++ b/site/src/cut/components/onboarding/slides/Welcome.tsx@@ -0,0 +1,22 @@+"use client";++import { EditorMock } from "@/cut/components/editor-mock/EditorMock";++export function WelcomeSlide() {+ return (+ <div className="flex flex-col items-center gap-9 text-center">+ <div className="max-w-[700px]">+ <h2 className="text-[clamp(30px,4.4vw,46px)] leading-[1.02] font-semibold tracking-[-0.02em]">+ Welcome to Donkey Cut+ </h2>+ <p className="mt-4 text-[17px] leading-[1.55] text-[#454545]">+ A video editor that runs in your browser, generates the shots you+ don't have, and does the heavy lifting on your own Mac.+ </p>+ </div>+ <div className="w-full max-w-[840px]">+ <EditorMock showSwitcher={false} />+ </div>+ </div>+ );+}diff --git a/site/src/cut/lib/onboarding.ts b/site/src/cut/lib/onboarding.tsnew file mode 100644index 00000000..98ec841e--- /dev/null+++ b/site/src/cut/lib/onboarding.ts@@ -0,0 +1,14 @@+// One contract shared by the settings row that replays the welcome sequence+// and the overlay mounted in the app shell that shows it. The overlay is+// mounted once, high in the tree; anything that wants it opens it from here.++const EVENT = "cut-onboarding-open";++export function openOnboarding(): void {+ window.dispatchEvent(new Event(EVENT));+}++export function onOpenOnboarding(handler: () => void): () => void {+ window.addEventListener(EVENT, handler);+ return () => window.removeEventListener(EVENT, handler);+}diff --git a/site/src/lib/analytics.ts b/site/src/lib/analytics.tsindex 8409f4ab..a2cd09c8 100644--- a/site/src/lib/analytics.ts+++ b/site/src/lib/analytics.ts@@ -1,6 +1,11 @@import posthog from "posthog-js";import { useEffect } from "react";+import type {+ OnboardingRun,+ ReferralSource,+} from "@/lib/onboarding/sequence";+// Every product analytics event, in one place. `track` checks the name and// its properties against this map at compile time, so call sites can't drift// from the list. Events with `void` properties take no second argument.@@ -11,6 +16,10 @@ export type AnalyticsEvents = {home_download_clicked: { location: "hero" | "final_cta" };// Install prompts on the Cut app home's connect gate.app_install_clicked: { source: "connect_gate_button" | "connect_gate_link" };+ // The welcome sequence a new account sees, and its replay from settings.+ onboarding_started: { source: OnboardingRun };+ onboarding_referral_selected: { referralSource: ReferralSource };+ onboarding_completed: { source: OnboardingRun; skipped: boolean; step: number };// Cut projects home.project_created: { source: "projects_home" | "sidebar" | "file_import" };folder_created: void;