Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(storybook): Storybook workspace for interaction prototypes, with the voice input studies (MUL-9218) (#10569)

Jiayuan Zhangf337d4d5972c
diff --git a/.gitignore b/.gitignore
index a6d3c9c14b..b15bb63032 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,7 @@ out
build
bin
dist-electron
+storybook-static
*.tsbuildinfo
# ...except electron-builder's source resources dir, which holds tracked
# config files (entitlements, icons) — not build output.
diff --git a/.multica/environments.toml b/.multica/environments.toml
index 6b8a69eb8d..0c1d8d9b3a 100644
--- a/.multica/environments.toml
+++ b/.multica/environments.toml
@@ -23,3 +23,10 @@ stop = "bash scripts/agent-environment.sh stop desktop"
url = ""
ready = "http://localhost:$MULTICA_PORT"
ttl = "24h"
+
+# Design prototypes in apps/storybook. Needs no API or database.
+[environments.storybook]
+label = "Storybook"
+start = "pnpm -C apps/storybook exec storybook dev -p $MULTICA_PORT --host 127.0.0.1 --no-open --ci"
+url = "http://127.0.0.1:$MULTICA_PORT"
+ttl = "24h"
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index fd367021cb..28c7a8489e 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -41,7 +41,7 @@
"@electron-toolkit/preload": "^3.0.2",
"@electron-toolkit/utils": "^4.0.0",
"@fontsource-variable/geist-mono": "^5.3.0",
- "@fontsource-variable/inter": "^5.2.5",
+ "@fontsource-variable/inter": "catalog:",
"@fontsource-variable/jetbrains-mono": "^5.3.0",
"@fontsource-variable/source-serif-4": "^5.2.9",
"@multica/core": "workspace:*",
diff --git a/apps/storybook/.storybook/main.ts b/apps/storybook/.storybook/main.ts
new file mode 100644
index 0000000000..c30903dd0c
--- /dev/null
+++ b/apps/storybook/.storybook/main.ts
@@ -0,0 +1,17 @@
+import type { StorybookConfig } from "@storybook/react-vite";
+import tailwindcss from "@tailwindcss/vite";
+import react from "@vitejs/plugin-react";
+import { mergeConfig } from "vite";
+
+const config: StorybookConfig = {
+ stories: ["../src/**/*.stories.@(ts|tsx)"],
+ framework: { name: "@storybook/react-vite", options: {} },
+ core: { disableTelemetry: true },
+ viteFinal: (base) =>
+ mergeConfig(base, {
+ plugins: [react(), tailwindcss()],
+ resolve: { dedupe: ["react", "react-dom"] },
+ }),
+};
+
+export default config;
diff --git a/apps/storybook/.storybook/preview.tsx b/apps/storybook/.storybook/preview.tsx
new file mode 100644
index 0000000000..bc35ee8ff5
--- /dev/null
+++ b/apps/storybook/.storybook/preview.tsx
@@ -0,0 +1,83 @@
+import { useLayoutEffect, type ReactNode } from "react";
+import type { Preview } from "@storybook/react-vite";
+import { TooltipProvider } from "@multica/ui/components/ui/tooltip";
+import { StoryEnvProvider } from "../src/voice-input/env";
+import type { Lang } from "../src/voice-input/copy";
+import type { VoiceSource } from "../src/voice-input/voice-session";
+import "./styles.css";
+
+function DocumentSync({ theme, lang, children }: { theme: string; lang: Lang; children: ReactNode }) {
+ useLayoutEffect(() => {
+ document.documentElement.classList.toggle("dark", theme === "dark");
+ document.documentElement.lang = lang === "zh" ? "zh-CN" : "en";
+ }, [theme, lang]);
+ return children;
+}
+
+const preview: Preview = {
+ globalTypes: {
+ theme: {
+ description: "Theme",
+ toolbar: {
+ title: "Theme",
+ icon: "mirror",
+ items: [
+ { value: "light", title: "Light" },
+ { value: "dark", title: "Dark" },
+ ],
+ dynamicTitle: true,
+ },
+ },
+ lang: {
+ description: "Copy and sample speech",
+ toolbar: {
+ title: "Language",
+ icon: "globe",
+ items: [
+ { value: "zh", title: "中文" },
+ { value: "en", title: "English" },
+ ],
+ dynamicTitle: true,
+ },
+ },
+ voice: {
+ description: "Where the voice comes from",
+ toolbar: {
+ title: "Voice",
+ icon: "speaker",
+ items: [
+ { value: "simulated", title: "Simulated speaker" },
+ { value: "microphone", title: "My microphone" },
+ ],
+ dynamicTitle: true,
+ },
+ },
+ },
+ initialGlobals: { theme: "light", lang: "zh", voice: "simulated" },
+ parameters: {
+ layout: "centered",
+ options: {
+ storySort: { order: ["Comment box", ["Compare all", "*"], "Voice input", ["Composer (A + C)", "Waveform", ["Compare all", "*"], "Settings", "First use", "Edge cases", "Explored", ["All directions", "*"]]] },
+ },
+ controls: { disable: true },
+ actions: { disable: true },
+ },
+ decorators: [
+ (Story, context) => {
+ const lang = context.globals.lang as Lang;
+ return (
+ <DocumentSync theme={context.globals.theme as string} lang={lang}>
+ <StoryEnvProvider lang={lang} source={context.globals.voice as VoiceSource}>
+ <TooltipProvider>
+ <div className="font-sans text-foreground antialiased">
+ <Story />
+ </div>
+ </TooltipProvider>
+ </StoryEnvProvider>
+ </DocumentSync>
+ );
+ },
+ ],
+};
+
+export default preview;
diff --git a/apps/storybook/.storybook/styles.css b/apps/storybook/.storybook/styles.css
new file mode 100644
index 0000000000..ccf29da946
--- /dev/null
+++ b/apps/storybook/.storybook/styles.css
@@ -0,0 +1,27 @@
+@import "tailwindcss";
+@import "tw-animate-css";
+@import "shadcn/tailwind.css";
+@import "@fontsource-variable/inter";
+@import "@multica/ui/styles/tokens.css";
+@import "@multica/ui/styles/theme-variables.css";
+@import "@multica/ui/styles/appearance.css";
+@import "@multica/ui/styles/base.css";
+
+@custom-variant dark (&:is(.dark *));
+
+/* Same stack as apps/desktop/src/renderer/src/globals.css. */
+:root {
+ --font-sans: "Inter Variable", "Inter", var(--font-cjk-sans);
+ --font-cjk-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
+ "Microsoft YaHei", "Noto Sans CJK SC", "Apple SD Gothic Neo",
+ "Malgun Gothic", "Noto Sans CJK KR", sans-serif;
+ --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
+}
+
+html,
+body {
+ background: var(--page-canvas);
+}
+
+@source "../../../packages/ui/**/*.tsx";
+@source "../src/**/*.tsx";
diff --git a/apps/storybook/eslint.config.mjs b/apps/storybook/eslint.config.mjs
new file mode 100644
index 0000000000..3b71cd1cf6
--- /dev/null
+++ b/apps/storybook/eslint.config.mjs
@@ -0,0 +1,13 @@
+import reactConfig from "@multica/eslint-config/react";
+import { NO_ROUND_CONTROLS } from "@multica/eslint-config/control-shape";
+
+export default [
+ { ignores: ["storybook-static/**"] },
+ ...reactConfig,
+ {
+ files: ["**/*.tsx"],
+ rules: {
+ "no-restricted-syntax": ["error", NO_ROUND_CONTROLS],
+ },
+ },
+];
diff --git a/apps/storybook/package.json b/apps/storybook/package.json
new file mode 100644
index 0000000000..371ed2a9ff
--- /dev/null
+++ b/apps/storybook/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "@multica/storybook",
+ "version": "0.0.0",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "storybook": "storybook dev -p 6006 --no-open",
+ "build-storybook": "storybook build",
+ "typecheck": "tsc --noEmit",
+ "lint": "eslint ."
+ },
+ "dependencies": {
+ "@fontsource-variable/inter": "catalog:",
+ "@multica/ui": "workspace:*",
+ "react": "catalog:",
+ "react-dom": "catalog:",
+ "shadcn": "catalog:",
+ "tw-animate-css": "catalog:"
+ },
+ "devDependencies": {
+ "@multica/eslint-config": "workspace:*",
+ "@multica/tsconfig": "workspace:*",
+ "@storybook/react-vite": "^10.6.7",
+ "@tailwindcss/vite": "catalog:",
+ "@types/react": "catalog:",
+ "@types/react-dom": "catalog:",
+ "@typescript/native": "catalog:",
+ "@vitejs/plugin-react": "catalog:",
+ "storybook": "^10.6.7",
+ "tailwindcss": "catalog:",
+ "typescript": "catalog:",
+ "vite": "^8.0.1"
+ }
+}
diff --git a/apps/storybook/src/comment-box/comment-box.stories.tsx b/apps/storybook/src/comment-box/comment-box.stories.tsx
new file mode 100644
index 0000000000..1a9ee173f9
--- /dev/null
+++ b/apps/storybook/src/comment-box/comment-box.stories.tsx
@@ -0,0 +1,178 @@
+import type { ReactNode } from "react";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import type { Lang } from "../voice-input/copy";
+import { useStoryEnv } from "../voice-input/env";
+import { TEXT, ThreadCard, type Preset } from "./parts";
+import { DIRECTIONS, DIRECTION_BY_ID, type Direction, type DirectionId } from "./variants";
+
+const meta = {
+ title: "Comment box",
+ id: "comment-box",
+ parameters: { layout: "fullscreen" },
+} satisfies Meta;
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+const PAGE = {
+ compareTitle: { zh: "评论框和回复框:五个方向", en: "Comment and reply box: five directions" },
+ compareLead: {
+ zh: "A 是线上现状,B 到 E 是重新设计。每个框都能直接输入,输入 @ 会出现智能体提示,点麦克风会进入录音条。⌘↵ 发送。",
+ en: "A is what ships; B to E are redesigns. Every box is live: type to try it, type @ to bring up the agent chip, click the mic for the recording strip. ⌘↵ sends.",
+ },
+ try: { zh: "试一试", en: "Try it" },
+ states: { zh: "所有状态", en: "Every state" },
+ comment: { zh: "评论框", en: "Comment box" },
+ reply: { zh: "回复框", en: "Reply box" },
+ inThread: { zh: "讨论串里的回复框", en: "Reply box in a thread" },
+ atFoot: { zh: "时间线底部的评论框", en: "Comment box at the foot of the timeline" },
+};
+
+const STATES: { id: string; label: Record<Lang, string>; preset: (lang: Lang) => Preset }[] = [
+ { id: "empty", label: { zh: "空", en: "Empty" }, preset: () => ({}) },
+ { id: "focused", label: { zh: "聚焦", en: "Focused" }, preset: () => ({ focused: true }) },
+ {
+ id: "typing",
+ label: { zh: "输入中,会叫起智能体", en: "Typing, starts an agent" },
+ preset: (lang) => ({ text: TEXT.sample[lang], focused: true }),
+ },
+ {
+ id: "restart",
+ label: { zh: "会重启运行", en: "Would restart a run" },
+ preset: (lang) => ({ text: TEXT.sample[lang], focused: true, restart: true }),
+ },
+ { id: "recording", label: { zh: "录音中", en: "Recording" }, preset: () => ({ recording: true, focused: true }) },
+];
+
+const COMPARE_STATES = ["empty", "typing"] as const;
+
+function Label({ children }: { children: ReactNode }) {
+ return <div className="mb-2 text-caption text-muted-foreground">{children}</div>;
+}
+
+function ReplyFrame({ children }: { children: ReactNode }) {
+ return <div className="rounded-lg bg-card px-4 py-2.5 ring-1 ring-border">{children}</div>;
+}
+
+function DirectionHeading({ direction, size = "row" }: { direction: Direction; size?: "row" | "page" }) {
+ const { lang } = useStoryEnv();
+ return (
+ <>
+ <div className="text-caption font-medium text-brand">{direction.letter}</div>
+ {size === "page" ? (
+ <h1 className="mt-1 text-title font-semibold">{direction.name[lang]}</h1>
+ ) : (
+ <h2 className="text-body font-semibold">{direction.name[lang]}</h2>
+ )}
+ <p className={size === "page" ? "mt-2 text-body text-muted-foreground" : "mt-0.5 text-caption text-muted-foreground"}>
+ {direction.pitch[lang]}
+ </p>
+ </>
+ );
+}
+
+function ComparePage() {
+ const { lang } = useStoryEnv();
+ const byId = Object.fromEntries(STATES.map((s) => [s.id, s]));
+ return (
+ <div className="min-h-screen bg-background p-10">
+ <header className="max-w-3xl">
+ <h1 className="text-title font-semibold">{PAGE.compareTitle[lang]}</h1>
+ <p className="mt-1.5 text-body text-muted-foreground">{PAGE.compareLead[lang]}</p>
+ </header>
+ <div className="mt-8 divide-y divide-border">
+ {DIRECTIONS.map((direction) => (
+ <section key={`${direction.id}-${lang}`} className="flex gap-8 py-6">
+ <div className="w-56 shrink-0">
+ <DirectionHeading direction={direction} />
+ </div>
+ <div className="grid min-w-0 max-w-[1120px] flex-1 grid-cols-2 gap-x-6 gap-y-5">
+ {COMPARE_STATES.map((state) => (
+ <div key={`c-${state}`}>
+ <Label>
+ {PAGE.comment[lang]} · {byId[state]!.label[lang]}
+ </Label>
+ <direction.Comment preset={byId[state]!.preset(lang)} />
+ </div>
+ ))}
+ {COMPARE_STATES.map((state) => (
+ <div key={`r-${state}`}>
+ <Label>
+ {PAGE.reply[lang]} · {byId[state]!.label[lang]}
+ </Label>
+ <ReplyFrame>
+ <direction.Reply preset={byId[state]!.preset(lang)} />
+ </ReplyFrame>
+ </div>
+ ))}
+ </div>
+ </section>
+ ))}
+ </div>
+ </div>
+ );
+}
+
+function DirectionPage({ id }: { id: DirectionId }) {
+ const { lang } = useStoryEnv();
+ const direction = DIRECTION_BY_ID[id];
+ return (
+ <div key={lang} className="min-h-screen bg-background p-10">
+ <div className="flex items-start gap-12">
+ <div className="w-[800px] shrink-0 space-y-10">
+ <section>
+ <h2 className="mb-3 text-caption font-medium text-muted-foreground">{PAGE.try[lang]}</h2>
+ <Label>{PAGE.inThread[lang]}</Label>
+ <ThreadCard>
+ <direction.Reply />
+ </ThreadCard>
+ <div className="mt-6">
+ <Label>{PAGE.atFoot[lang]}</Label>
+ <direction.Comment />
+ </div>
+ </section>
+ <section>
+ <h2 className="mb-3 text-caption font-medium text-muted-foreground">{PAGE.states[lang]}</h2>
+ <div className="grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-x-6 gap-y-5">
+ {STATES.map((state) => (
+ <div key={state.id} className="contents">
+ <div>
+ <Label>
+ {PAGE.comment[lang]} · {state.label[lang]}
+ </Label>
+ <direction.Comment preset={state.preset(lang)} />
+ </div>
+ <div>
+ <Label>
+ {PAGE.reply[lang]} · {state.label[lang]}
+ </Label>
+ <ReplyFrame>
+ <direction.Reply preset={state.preset(lang)} />
+ </ReplyFrame>
+ </div>
+ </div>
+ ))}
+ </div>
+ </section>
+ </div>
+ <aside className="w-72 shrink-0 pt-1">
+ <DirectionHeading direction={direction} size="page" />
+ <ul className="mt-5 space-y-2 text-body">
+ {direction.notes[lang].map((note) => (
+ <li key={note} className="flex gap-2">
+ <span className="mt-2 size-1 shrink-0 rounded-full bg-faint-foreground" />
+ <span>{note}</span>
+ </li>
+ ))}
+ </ul>
+ </aside>
+ </div>
+ </div>
+ );
+}
+
+export const Compare: Story = { name: "Compare all", render: () => <ComparePage /> };
+export const Current: Story = { name: "A · Current", render: () => <DirectionPage id="current" /> };
+export const Tidy: Story = { name: "B · Tidy", render: () => <DirectionPage id="tidy" /> };
+export const GrowsOnFocus: Story = { name: "C · Grows on focus", render: () => <DirectionPage id="growing" /> };
+export const SameAsChat: Story = { name: "D · Same as chat", render: () => <DirectionPage id="chat" /> };
+export const LabelledSend: Story = { name: "E · Labelled send", render: () => <DirectionPage id="label" /> };
diff --git a/apps/storybook/src/comment-box/parts.tsx b/apps/storybook/src/comment-box/parts.tsx
new file mode 100644
index 0000000000..e708b973ec
--- /dev/null
+++ b/apps/storybook/src/comment-box/parts.tsx
@@ -0,0 +1,257 @@
+import { useState, type CSSProperties, type FocusEvent, type ReactNode } from "react";
+import { ArrowUp, Check, ChevronDown, Mic, Paperclip, X } from "@multica/ui/icons";
+import { ActorAvatar } from "@multica/ui/components/common/actor-avatar";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { SubmitButton } from "@multica/ui/components/common/submit-button";
+import { Button } from "@multica/ui/components/ui/button";
+import { Kbd } from "@multica/ui/components/ui/kbd";
+import { cn } from "@multica/ui/lib/utils";
+import type { Lang } from "../voice-input/copy";
+import { useStoryEnv } from "../voice-input/env";
+import { RecDot, formatElapsed } from "../voice-input/primitives";
+import { LevelStreamProvider, useLevelSamples } from "../voice-input/waveform/stream";
+import { VARIANT_BY_ID } from "../voice-input/waveform/variants";
+
+export type Kind = "comment" | "reply";
+
+/** A frozen starting point for a box, so the state grid can show every case at once. */
+export interface Preset {
+ text?: string;
+ focused?: boolean;
+ restart?: boolean;
+ recording?: boolean;
+}
+
+type Copy = Record<Lang, string>;
+
+export const TEXT = {
+ placeholder: {
+ comment: { zh: "留下评论...", en: "Leave a comment..." },
+ reply: { zh: "回复...", en: "Leave a reply..." },
+ },
+ sample: {
+ zh: "@Lambda 帮我看一下这个 PR 的 CI 为什么挂了",
+ en: "@Lambda can you check why CI failed on this PR",
+ },
+ dictated: { zh: ",顺便看一下 daemon 的单元测试。", en: ", and look at the daemon unit tests too." },
+ willStart: { zh: "发送后开始", en: "Will start when sent" },
+ restartChip: { zh: "停止并重新开始", en: "Stop and start over" },
+ restartSend: { zh: "停止并发送", en: "Stop and send" },
+ send: { zh: "发送", en: "Send" },
+ comment: { zh: "评论", en: "Comment" },
+ reply: { zh: "回复", en: "Reply" },
+ mic: { zh: "语音输入", en: "Dictate" },
+ attach: { zh: "添加附件", en: "Attach files" },
+ add: { zh: "添加", en: "Add" },
+ uploadFile: { zh: "上传文件", en: "Upload a file" },
+ mention: { zh: "提及成员或智能体", en: "Mention someone" },
+ command: { zh: "快捷指令", en: "Quick actions" },
+ cancel: { zh: "取消", en: "Cancel" },
+ insert: { zh: "插入", en: "Insert" },
+ to: { zh: "发给", en: "To" },
+} satisfies Record<string, Copy | Record<Kind, Copy>>;
+
+export function useCopy() {
+ const { lang } = useStoryEnv();
+ return { lang, t: (copy: Copy) => copy[lang] };
+}
+
+/** Draft, focus and recording state every direction shares. Typing `@` brings up the agent chip. */
+export function useBox(kind: Kind, preset: Preset = {}) {
+ const { lang } = useStoryEnv();
+ const [text, setText] = useState(preset.text ?? "");
+ const [hasFocus, setHasFocus] = useState(false);
+ const [recording, setRecording] = useState(!!preset.recording);
+ const empty = !text.trim();
+ const mentions = text.includes("@");
+ return {
+ kind,
+ text,
+ setText,
+ empty,
+ focused: hasFocus || !!preset.focused,
+ recording,
+ chip: mentions ? (preset.restart ? ("restart" as const) : ("start" as const)) : null,
+ restart: !!preset.restart && mentions,
+ focusProps: {
+ onFocus: () => setHasFocus(true),
+ onBlur: (event: FocusEvent<HTMLElement>) => {
+ if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setHasFocus(false);
+ },
+ },
+ startRecording: () => setRecording(true),
+ stopRecording: (insert: boolean) => {
+ setRecording(false);
+ if (insert) setText((current) => (current.trim() ? current + TEXT.dictated[lang] : TEXT.dictated[lang].replace(/^[,,]\s*/, "")));
+ },
+ send: () => setText(""),
+ };
+}
+
+export type Box = ReturnType<typeof useBox>;
+
+export function Draft({ box, className }: { box: Box; className?: string }) {
+ const { t } = useCopy();
+ return (
+ <textarea
+ value={box.text}
+ rows={1}
+ onChange={(event) => box.setText(event.target.value)}
+ onKeyDown={(event) => {
+ if (event.key === "Enter" && (event.metaKey || event.ctrlKey) && !box.empty) {
+ event.preventDefault();
+ box.send();
+ }
+ }}
+ placeholder={t(TEXT.placeholder[box.kind])}
+ className={cn(
+ "block w-full resize-none bg-transparent text-body leading-[1.625] text-foreground outline-none placeholder:text-muted-foreground",
+ className,
+ )}
+ style={{ fieldSizing: "content" } as CSSProperties}
+ />
+ );
+}
+
+export function AgentAvatar() {
+ return <ActorAvatar name="Lambda" initials="L" isAgent size="xs" />;
+}
+
+export function MemberAvatar({ size = "sm" }: { size?: "sm" | "md" }) {
+ return <ActorAvatar name="Jiayuan" initials="J" size={size} className="bg-brand/15 text-brand" />;
+}
+
+/** The recipient chip as it ships (comment-trigger-chips.tsx); `named` adds the agent name. */
+export function RecipientChip({ tone, named = false }: { tone: "start" | "restart"; named?: boolean }) {
+ const { t } = useCopy();
+ return (
+ <button
+ type="button"
+ className={cn(
+ "inline-flex h-6 min-w-0 max-w-full animate-in fade-in cursor-pointer items-center gap-1.5 rounded-md border border-transparent px-1.5 text-micro font-medium transition-colors",
+ tone === "restart"
+ ? "text-destructive hover:bg-destructive/10"
+ : "text-muted-foreground hover:bg-muted hover:text-foreground",
+ )}
+ >
+ <AgentAvatar />
+ {named && <span className="shrink-0 text-foreground">Lambda</span>}
+ <span className="truncate">{t(tone === "restart" ? TEXT.restartChip : TEXT.willStart)}</span>
+ <ChevronDown aria-hidden className="size-3 shrink-0 text-faint-foreground" />
+ </button>
+ );
+}
+
+export function MicButton({ box, className }: { box: Box; className?: string }) {
+ const { t } = useCopy();
+ return (
+ <IconButton label={t(TEXT.mic)} onClick={box.startRecording} className={cn("text-muted-foreground", className)}>
+ <Mic />
+ </IconButton>
+ );
+}
+
+export function AttachButton({ small = false, className }: { small?: boolean; className?: string }) {
+ const { t } = useCopy();
+ return (
+ <IconButton label={t(TEXT.attach)} size={small ? "icon-xs" : "icon-sm"} className={cn("text-muted-foreground", className)}>
+ <Paperclip className={small ? "size-3.5" : "size-4"} />
+ </IconButton>
+ );
+}
+
+/** The send button as it ships: primary fill, dimmed to 50% while there is nothing to send. */
+export function ShippedSend({ box }: { box: Box }) {
+ const { t } = useCopy();
+ return (
+ <SubmitButton
+ onClick={box.send}
+ disabled={box.empty}
+ ariaLabel={t(TEXT.send)}
+ tooltip={
+ <>
+ {t(TEXT.send)} <Kbd>⌘↵</Kbd>
+ </>
+ }
+ />
+ );
+}
+
+/** Same 28 px circle as every other control; a quiet tint until there is something to send. */
+export function QuietSend({ box, className }: { box: Box; className?: string }) {
+ const { t } = useCopy();
+ const ready = !box.empty || box.recording;
+ return (
+ <Button
+ size="icon-sm"
+ aria-label={t(TEXT.send)}
+ disabled={!ready}
+ onClick={box.send}
+ className={cn(
+ // eslint-disable-next-line no-restricted-syntax -- composer send button, the one round button
+ "rounded-full transition-colors disabled:opacity-100",
+ ready ? "bg-foreground text-background hover:bg-foreground/85" : "bg-muted text-faint-foreground",
+ className,
+ )}
+ >
+ <ArrowUp />
+ </Button>
+ );
+}
+
+function Elapsed() {
+ const { elapsedMs } = useLevelSamples();
+ return <span className="text-caption tabular-nums text-muted-foreground">{formatElapsed(elapsedMs)}</span>;
+}
+
+const DotsWave = VARIANT_BY_ID.dots.Wave;
+
+/** The shipped recording strip (option C waveform); `send` is each direction's own send control. */
+export function RecordingStrip({ box, send }: { box: Box; send: ReactNode }) {
+ const { t } = useCopy();
+ return (
+ <LevelStreamProvider scenario="speech">
+ <div className="flex min-w-0 flex-1 items-center gap-1">
+ <IconButton label={t(TEXT.cancel)} onClick={() => box.stopRecording(false)} className="text-muted-foreground">
+ <X />
+ </IconButton>
+ <span className="flex shrink-0 items-center gap-1.5 pl-1 pr-2">
+ <RecDot />
+ <Elapsed />
+ </span>
+ <div className="min-w-0 flex-1 text-foreground">
+ <DotsWave density="strip" />
+ </div>
+ <IconButton label={t(TEXT.insert)} onClick={() => box.stopRecording(true)} className="ml-1 text-foreground">
+ <Check />
+ </IconButton>
+ {send}
+ </div>
+ </LevelStreamProvider>
+ );
+}
+
+const THREAD = {
+ zh: "方案 C(静音成点)已经做进产品,评论、回复和 Chat 的录音条都换成了这一版。",
+ en: "Option C (dots to bars) is in the product now, across the comment, reply and chat recording strips.",
+};
+
+/** A thread card from the issue timeline, with the reply row at its foot. */
+export function ThreadCard({ children }: { children: ReactNode }) {
+ const { t } = useCopy();
+ return (
+ <div className="overflow-hidden rounded-lg bg-card ring-1 ring-border">
+ <div className="flex gap-2.5 px-4 py-3">
+ <ActorAvatar name="Lambda" initials="L" isAgent size="md" className="mt-0.5" />
+ <div className="min-w-0">
+ <div className="flex items-baseline gap-2">
+ <span className="text-body font-medium">Lambda</span>
+ <span className="text-caption text-muted-foreground">25m</span>
+ </div>
+ <p className="mt-0.5 text-body text-foreground">{t(THREAD)}</p>
+ </div>
+ </div>
+ <div className="border-t border-border/50 px-4 py-2.5">{children}</div>
+ </div>
+ );
+}
diff --git a/apps/storybook/src/comment-box/variants.tsx b/apps/storybook/src/comment-box/variants.tsx
new file mode 100644
index 0000000000..f27758cbd9
--- /dev/null
+++ b/apps/storybook/src/comment-box/variants.tsx
@@ -0,0 +1,539 @@
+import type { ComponentType, ReactNode } from "react";
+import { AtSign, Paperclip, Plus } from "@multica/ui/icons";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { Button } from "@multica/ui/components/ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuShortcut,
+ DropdownMenuTrigger,
+} from "@multica/ui/components/ui/dropdown-menu";
+import { cn } from "@multica/ui/lib/utils";
+import type { Lang } from "../voice-input/copy";
+import {
+ AttachButton,
+ Draft,
+ MemberAvatar,
+ MicButton,
+ QuietSend,
+ RecipientChip,
+ RecordingStrip,
+ ShippedSend,
+ TEXT,
+ useBox,
+ useCopy,
+ type Box,
+ type Preset,
+} from "./parts";
+
+export interface BoxProps {
+ preset?: Preset;
+}
+
+function ReplyRow({ children, avatarClassName }: { children: ReactNode; avatarClassName?: string }) {
+ return (
+ <div className="flex items-start gap-2.5">
+ <span className={cn("shrink-0", avatarClassName)}>
+ <MemberAvatar />
+ </span>
+ <div className="min-w-0 flex-1">{children}</div>
+ </div>
+ );
+}
+
+/* A · Current: comment-input.tsx and reply-input.tsx as they ship. */
+
+function ShippedRestart({ box }: { box: Box }) {
+ const { t } = useCopy();
+ return (
+ <Button
+ size="sm"
+ variant="destructive"
+ // eslint-disable-next-line no-restricted-syntax -- composer send button, the one round button
+ className="rounded-full"
+ onClick={box.send}
+ >
+ {t(TEXT.restartSend)}
+ </Button>
+ );
+}
+
+function ShippedActions({ box }: { box: Box }) {
+ return (
+ <>
+ <MicButton box={box} />
+ <AttachButton small />
+ {box.restart ? <ShippedRestart box={box} /> : <ShippedSend box={box} />}
+ </>
+ );
+}
+
+function CurrentComment({ preset }: BoxProps) {
+ const box = useBox("comment", preset);
+ return (
+ <div {...box.focusProps} className="relative flex flex-col rounded-lg bg-card pb-8 ring-1 ring-border">
+ <div className="px-3 py-2">
+ <Draft box={box} />
+ </div>
+ {box.recording ? (
+ <div className="absolute inset-x-1.5 bottom-1 flex items-center">
+ <RecordingStrip box={box} send={<ShippedSend box={{ ...box, empty: false }} />} />
+ </div>
+ ) : (
+ <>
+ <div className="absolute bottom-1 left-2 right-36 min-w-0">{box.chip && <RecipientChip tone={box.chip} />}</div>
+ <div className="absolute bottom-1 right-1.5 flex items-center gap-1">
+ <ShippedActions box={box} />
+ </div>
+ </>
+ )}
+ </div>
+ );
+}
+
+function CurrentReply({ preset }: BoxProps) {
+ const box = useBox("reply", preset);
+ return (
+ <ReplyRow avatarClassName="mt-0.5">
+ <div
+ {...box.focusProps}
+ className={cn("relative flex flex-col", (!box.empty || box.chip || box.recording) && "pb-9")}
+ >
+ <Draft box={box} />
+ {box.recording ? (
+ <div className="absolute inset-x-0 bottom-0 flex items-center">
+ <RecordingStrip box={box} send={<ShippedSend box={{ ...box, empty: false }} />} />
+ </div>
+ ) : (
+ <>
+ <div className="absolute bottom-0 left-0 right-32 min-w-0">{box.chip && <RecipientChip tone={box.chip} />}</div>
+ <div className="absolute bottom-0 right-0 flex items-center gap-1">
+ <ShippedActions box={box} />
+ </div>
+ </>
+ )}
+ </div>
+ </ReplyRow>
+ );
+}
+
+/* Shared by the redesigns. */
+
+function RestartPill({ box }: { box: Box }) {
+ const { t } = useCopy();
+ return (
+ <Button
+ size="sm"
+ variant="destructive"
+ // eslint-disable-next-line no-restricted-syntax -- composer send button, the one round button
+ className="h-7 rounded-full px-3"
+ onClick={box.send}
+ >
+ {t(TEXT.restartSend)}
+ </Button>
+ );
+}
+
+function TidyActions({ box }: { box: Box }) {
+ return (
+ <>
+ <MicButton box={box} />
+ <AttachButton />
+ {box.restart ? <RestartPill box={box} /> : <QuietSend box={box} />}
+ </>
+ );
+}
+
+function focusRing(box: Box) {
+ return box.focused ? "ring-foreground/25" : "ring-border";
+}
+
+/* B · Tidy: same layout, one control size, a quiet send, the toolbar in normal flow. */
+
+function TidyComment({ preset }: BoxProps) {
+ const box = useBox("comment", preset);
+ return (
+ <div {...box.focusProps} className={cn("flex flex-col rounded-lg bg-card ring-1 transition-shadow", focusRing(box))}>
+ <div className="px-3 pt-2.5">
+ <Draft box={box} />
+ </div>
+ <div className="flex h-10 items-center gap-1 px-1.5">
+ {box.recording ? (
+ <RecordingStrip box={box} send={<QuietSend box={box} />} />
+ ) : (
+ <>
+ <div className="min-w-0 flex-1 overflow-hidden pl-0.5">{box.chip && <RecipientChip tone={box.chip} named />}</div>
+ <TidyActions box={box} />
+ </>
+ )}
+ </div>
+ </div>
+ );
+}
+
+function TidyReply({ preset }: BoxProps) {
+ const box = useBox("reply", preset);
+ const toolbar = !box.empty || !!box.chip || box.recording;
+ return (
+ <ReplyRow avatarClassName="mt-1">
+ <div {...box.focusProps}>
+ <div className="flex items-start gap-1">
+ <Draft box={box} className="min-w-0 flex-1 py-px" />
+ {!toolbar && (
+ <div className="-my-px flex shrink-0 items-center gap-1">
+ <TidyActions box={box} />
+ </div>
+ )}
+ </div>
+ {toolbar && (
+ <div className="mt-1 flex h-8 items-center gap-1">
+ {box.recording ? (
+ <RecordingStrip box={box} send={<QuietSend box={box} />} />
+ ) : (
+ <>
+ <div className="min-w-0 flex-1 overflow-hidden">{box.chip && <RecipientChip tone={box.chip} named />}</div>
+ <TidyActions box={box} />
+ </>
+ )}
+ </div>
+ )}
+ </div>
+ </ReplyRow>
+ );
+}
+
+/* C · Grows on focus: one line at rest, the toolbar and send appear once you are writing. */
+
+function GrowingBox({ box, compact }: { box: Box; compact?: boolean }) {
+ const expanded = box.focused || !box.empty || box.recording;
+ return (
+ <div
+ {...box.focusProps}
+ className={cn(
+ "bg-card ring-1 transition-shadow",
+ compact ? "rounded-md" : "rounded-lg",
+ expanded ? "ring-foreground/25 shadow-[0_1px_3px_rgb(0_0_0/0.05)]" : "ring-border",
+ )}
+ >
+ <div className="flex items-start">
+ <Draft box={box} className={cn("min-w-0 flex-1 px-3", compact ? "py-1" : "py-2")} />
+ {!expanded && (
+ <div className={cn("flex shrink-0 items-center gap-0.5 pr-1", compact ? "py-0.5" : "py-1.5")}>
+ <MicButton box={box} />
+ <AttachButton />
+ </div>
+ )}
+ </div>
+ {expanded && (
+ <div className="flex h-9 animate-in fade-in slide-in-from-top-1 items-center gap-1 px-1.5 pb-1 duration-150">
+ {box.recording ? (
+ <RecordingStrip box={box} send={<QuietSend box={box} />} />
+ ) : (
+ <>
+ <div className="min-w-0 flex-1 overflow-hidden pl-0.5">{box.chip && <RecipientChip tone={box.chip} named />}</div>
+ <TidyActions box={box} />
+ </>
+ )}
+ </div>
+ )}
+ </div>
+ );
+}
+
+function GrowingComment({ preset }: BoxProps) {
+ return <GrowingBox box={useBox("comment", preset)} />;
+}
+
+function GrowingReply({ preset }: BoxProps) {
+ const box = useBox("reply", preset);
+ return (
+ <ReplyRow avatarClassName="mt-1.5">
+ <GrowingBox box={box} compact />
+ </ReplyRow>
+ );
+}
+
+/* D · Same as chat: a "+" menu on the left, mic and send on the right, recipients on a "To" line. */
+
+function AddMenu() {
+ const { t } = useCopy();
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <IconButton label={t(TEXT.add)} className="text-muted-foreground">
+ <Plus />
+ </IconButton>
+ }
+ />
+ <DropdownMenuContent align="start" side="top" sideOffset={6} className="min-w-48">
+ <DropdownMenuItem>
+ <Paperclip />
+ {t(TEXT.uploadFile)}
+ </DropdownMenuItem>
+ <DropdownMenuItem>
+ <AtSign />
+ {t(TEXT.mention)}
+ <DropdownMenuShortcut>@</DropdownMenuShortcut>
+ </DropdownMenuItem>
+ <DropdownMenuItem>
+ <span className="flex size-4 items-center justify-center text-caption font-medium">/</span>
+ {t(TEXT.command)}
+ <DropdownMenuShortcut>/</DropdownMenuShortcut>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
+
+function ChatBox({ box, compact }: { box: Box; compact?: boolean }) {
+ const { t } = useCopy();
+ return (
+ <div
+ {...box.focusProps}
+ className={cn("flex flex-col overflow-hidden bg-card ring-1 transition-shadow", compact ? "rounded-lg" : "rounded-xl", focusRing(box))}
+ >
+ {box.chip && (
+ <div className="flex animate-in fade-in items-center gap-1 border-b border-border/60 px-2 py-1">
+ <span className="pl-1 text-caption text-muted-foreground">{t(TEXT.to)}</span>
+ <RecipientChip tone={box.chip} named />
+ </div>
+ )}
+ <div className={cn("px-3", compact ? "pt-1.5" : "pt-2.5")}>
+ <Draft box={box} />
+ </div>
+ <div className={cn("flex items-center gap-1 px-1.5", compact ? "h-9" : "h-10")}>
+ {box.recording ? (
+ <RecordingStrip box={box} send={<QuietSend box={box} />} />
+ ) : (
+ <>
+ <AddMenu />
+ <div className="flex-1" />
+ <MicButton box={box} />
+ {box.restart ? <RestartPill box={box} /> : <QuietSend box={box} />}
+ </>
+ )}
+ </div>
+ </div>
+ );
+}
+
+function ChatComment({ preset }: BoxProps) {
+ return <ChatBox box={useBox("comment", preset)} />;
+}
+
+function ChatReply({ preset }: BoxProps) {
+ const box = useBox("reply", preset);
+ return (
+ <ReplyRow avatarClassName="mt-2">
+ <ChatBox box={box} compact />
+ </ReplyRow>
+ );
+}
+
+/* E · Labelled send: the button names the action; restart is the same button in red. */
+
+function LabelSend({ box }: { box: Box }) {
+ const { t } = useCopy();
+ const ready = !box.empty || box.recording;
+ const label = box.restart ? TEXT.restartSend : box.kind === "reply" ? TEXT.reply : TEXT.comment;
+ return (
+ <Button
+ size="sm"
+ variant={box.restart ? "destructive" : "default"}
+ disabled={!ready}
+ onClick={box.send}
+ className={cn("gap-2 disabled:opacity-100", !ready && "bg-muted text-faint-foreground")}
+ >
+ {t(label)}
+ <span className={cn("text-micro font-normal", ready ? "opacity-60" : "opacity-80")}>⌘↵</span>
+ </Button>
+ );
+}
+
+function LabelBox({ box, compact }: { box: Box; compact?: boolean }) {
+ const toolbar = !compact || box.focused || !box.empty || box.recording;
+ return (
+ <div {...box.focusProps} className={cn("bg-card ring-1 transition-shadow", compact ? "rounded-md" : "rounded-lg", focusRing(box))}>
+ <Draft box={box} className={cn("px-3", compact ? "py-1" : "min-h-[52px] pt-2.5 pb-1")} />
+ {toolbar && (
+ <div className={cn("flex items-center gap-1 px-1.5 pb-1.5", compact && "animate-in fade-in duration-150")}>
+ {box.recording ? (
+ <RecordingStrip box={box} send={<LabelSend box={box} />} />
+ ) : (
+ <>
+ <AttachButton />
+ <MicButton box={box} />
+ <div className="flex min-w-0 flex-1 justify-end overflow-hidden">{box.chip && <RecipientChip tone={box.chip} named />}</div>
+ <LabelSend box={box} />
+ </>
+ )}
+ </div>
+ )}
+ </div>
+ );
+}
+
+function LabelComment({ preset }: BoxProps) {
+ return <LabelBox box={useBox("comment", preset)} />;
+}
+
+function LabelReply({ preset }: BoxProps) {
+ const box = useBox("reply", preset);
+ return (
+ <ReplyRow avatarClassName="mt-1.5">
+ <LabelBox box={box} compact />
+ </ReplyRow>
+ );
+}
+
+export type DirectionId = "current" | "tidy" | "growing" | "chat" | "label";
+
+export interface Direction {
+ id: DirectionId;
+ letter: string;
+ name: Record<Lang, string>;
+ pitch: Record<Lang, string>;
+ notes: Record<Lang, string[]>;
+ Comment: ComponentType<BoxProps>;
+ Reply: ComponentType<BoxProps>;
+}
+
+export const DIRECTIONS: Direction[] = [
+ {
+ id: "current",
+ letter: "A",
+ name: { zh: "现状", en: "Current" },
+ pitch: {
+ zh: "线上的评论框和回复框,照着 comment-input.tsx 和 reply-input.tsx 复刻。",
+ en: "The comment and reply boxes as they ship, rebuilt from comment-input.tsx and reply-input.tsx.",
+ },
+ notes: {
+ zh: [
+ "三个按钮三种规格:麦克风 28px 配 16px 图标,附件 24px 配 14px 图标,发送是 28px 实心圆",
+ "没内容时发送键是一块半透明的实心灰圆,反而是框里最重的东西",
+ "空的评论框也预留了一整行工具栏,又高又空",
+ "评论是带边框的卡片,回复是没有边框的裸文本;回复一输入,工具栏冒出来,高度会跳",
+ "「停止并发送」是文字胶囊,和圆形发送键不是一个形状",
+ "智能体提示只有头像,看不出是谁会被叫起来",
+ ],
+ en: [
+ "Three buttons, three specs: a 28 px mic with a 16 px icon, a 24 px paperclip with a 14 px icon, a filled 28 px send circle",
+ "With nothing to send, the send button is a half-transparent grey disc, the heaviest thing in the box",
+ "The empty comment box reserves a whole toolbar row, so it looks tall and empty",
+ "Comments are a bordered card and replies are bare text; typing a reply pops the toolbar in and the height jumps",
+ "Stop and send is a text pill, a different shape from the round send button",
+ "The agent chip shows only an avatar, not who will start",
+ ],
+ },
+ Comment: CurrentComment,
+ Reply: CurrentReply,
+ },
+ {
+ id: "tidy",
+ letter: "B",
+ name: { zh: "统一规格", en: "Tidy" },
+ pitch: {
+ zh: "布局不动,只把按钮统一:都是 28px、16px 图标、同一种样式;发送键没内容时是浅色底,能发送时才变实心。",
+ en: "Same layout with the controls unified: all 28 px with 16 px icons in one style; send stays a light tint until there is something to send.",
+ },
+ notes: {
+ zh: [
+ "改动最小,基本只动两个文件",
+ "工具栏改成正常排版,不再靠绝对定位和写死的右边距",
+ "聚焦时边框加深,知道光标在哪个框里",
+ "「停止并发送」也是 28px 高,和圆形按钮在同一条线上",
+ "智能体提示带上名字:「Lambda 发送后开始」",
+ ],
+ en: [
+ "The smallest change, essentially two files",
+ "The toolbar is laid out in normal flow, no absolute positioning or hard-coded right offsets",
+ "The border darkens on focus, so you can see which box has the caret",
+ "Stop and send is 28 px tall too, on one line with the round buttons",
+ "The agent chip names the agent: “Lambda will start when sent”",
+ ],
+ },
+ Comment: TidyComment,
+ Reply: TidyReply,
+ },
+ {
+ id: "growing",
+ letter: "C",
+ name: { zh: "单行展开", en: "Grows on focus" },
+ pitch: {
+ zh: "空着时只有一行,右边放麦克风和附件;点进去或开始输入才展开工具栏和发送键。评论框和回复框是同一个组件。",
+ en: "One line at rest with the mic and paperclip on the right; focus or type and it grows a toolbar with send. Comments and replies are the same component.",
+ },
+ notes: {
+ zh: [
+ "时间线底部和每个讨论串都省下一行高度",
+ "没东西可发时不出现发送键",
+ "评论和回复长得一样,只是尺寸不同",
+ "代价:展开时高度会变一次(带过渡)",
+ ],
+ en: [
+ "Saves a row at the foot of the timeline and in every thread",
+ "No send button until there is something to send",
+ "Comments and replies look the same, just at two sizes",
+ "The trade-off: the height changes once on focus (animated)",
+ ],
+ },
+ Comment: GrowingComment,
+ Reply: GrowingReply,
+ },
+ {
+ id: "chat",
+ letter: "D",
+ name: { zh: "和 Chat 统一", en: "Same as chat" },
+ pitch: {
+ zh: "照搬 Chat 输入框:左边一个「+」收纳附件、提及和快捷指令,右边是麦克风和发送。会被叫起来的智能体放到顶部「发给」一行。",
+ en: "Borrowed from the chat composer: a “+” on the left holds attach, mention and quick actions; mic and send sit on the right. Agents that will start move to a “To” line on top.",
+ },
+ notes: {
+ zh: [
+ "Chat、评论、回复三处同一套输入框,学一次就会",
+ "「发给 Lambda」放在最上面,像邮件收件人,发送前一眼看清谁会被叫起来",
+ "附件收进「+」,多一次点击(拖拽和粘贴不受影响)",
+ "回复框空着也是两行高,讨论串会变长",
+ ],
+ en: [
+ "Chat, comments and replies share one composer, so it is learned once",
+ "“To Lambda” sits on top like an email recipient, so you see who will start before you send",
+ "Attach moves into “+”, one extra click (drag and paste still work)",
+ "An empty reply box is two rows tall, so threads get longer",
+ ],
+ },
+ Comment: ChatComment,
+ Reply: ChatReply,
+ },
+ {
+ id: "label",
+ letter: "E",
+ name: { zh: "文字发送键", en: "Labelled send" },
+ pitch: {
+ zh: "发送键写明动作:「评论」「回复」;会重启运行时,同一个按钮变成红色「停止并发送」。工具放左边,智能体提示紧挨着发送键。",
+ en: "The send button names the action, Comment or Reply; when it would restart a run, the same button turns red and reads Stop and send. Tools sit on the left, the agent chip next to send.",
+ },
+ notes: {
+ zh: [
+ "动作一目了然,不用猜圆圈箭头是什么",
+ "正常和重启是同一个形状,只换颜色和文案",
+ "提示和按钮连成一句话:「Lambda 发送后开始 · 评论 ⌘↵」",
+ "回复框收起时只有一行,聚焦后才出现工具栏",
+ "文字按钮比圆形图标更占宽度",
+ ],
+ en: [
+ "The action is spelled out; no guessing what the arrow circle does",
+ "Normal and restart share one shape, only colour and label change",
+ "Chip and button read as one sentence: “Lambda will start when sent · Comment ⌘↵”",
+ "The reply box is one line until focused, then grows its toolbar",
+ "A text button takes more width than a round icon",
+ ],
+ },
+ Comment: LabelComment,
+ Reply: LabelReply,
+ },
+];
+
+export const DIRECTION_BY_ID = Object.fromEntries(DIRECTIONS.map((d) => [d.id, d])) as Record<DirectionId, Direction>;
diff --git a/apps/storybook/src/voice-input/a-inline-waveform.stories.tsx b/apps/storybook/src/voice-input/a-inline-waveform.stories.tsx
new file mode 100644
index 0000000000..73072a994b
--- /dev/null
+++ b/apps/storybook/src/voice-input/a-inline-waveform.stories.tsx
@@ -0,0 +1,39 @@
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { InlineWaveform } from "./concepts/inline-waveform";
+import { INLINE_WAVEFORM } from "./concepts/info";
+import { useStoryEnv } from "./env";
+import { Gallery, samples } from "./gallery";
+import { label } from "./labels";
+import { DemoStage } from "./stage";
+
+const meta = { title: "Voice input/Explored/A · Inline waveform", id: "voice-input-a-inline-waveform" } satisfies Meta;
+export default meta;
+
+export const TryIt: StoryObj = {
+ name: "Try it",
+ render: () => (
+ <DemoStage info={INLINE_WAVEFORM}>
+ <InlineWaveform />
+ </DemoStage>
+ ),
+};
+
+function States() {
+ const { lang, copy } = useStoryEnv();
+ const s = samples(lang);
+ return (
+ <Gallery
+ columns={2}
+ items={[
+ { label: label("idle", lang), node: <InlineWaveform frozen={s.idle} framed={false} /> },
+ { label: label("requesting", lang), node: <InlineWaveform frozen={s.requesting} framed={false} /> },
+ { label: label("listening", lang), node: <InlineWaveform frozen={s.listening} framed={false} initialDraft={copy.userMessage} /> },
+ { label: label("processing", lang), node: <InlineWaveform frozen={s.processing} framed={false} initialDraft={copy.userMessage} /> },
+ { label: label("noSpeech", lang), node: <InlineWaveform frozen={s.noSpeech} framed={false} /> },
+ { label: label("denied", lang), node: <InlineWaveform frozen={s.denied} framed={false} /> },
+ ]}
+ />
+ );
+}
+
+export const AllStates: StoryObj = { name: "States", render: () => <States /> };
diff --git a/apps/storybook/src/voice-input/b-live-dictation.stories.tsx b/apps/storybook/src/voice-input/b-live-dictation.stories.tsx
new file mode 100644
index 0000000000..c1a8df995a
--- /dev/null
+++ b/apps/storybook/src/voice-input/b-live-dictation.stories.tsx
@@ -0,0 +1,43 @@
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { CHAT_SCRIPT } from "./copy";
+import { LiveDictation } from "./concepts/live-dictation";
+import { LIVE_DICTATION } from "./concepts/info";
+import { useStoryEnv } from "./env";
+import { Gallery, samples } from "./gallery";
+import { label } from "./labels";
+import { DemoStage } from "./stage";
+
+const meta = { title: "Voice input/Explored/B · Live dictation", id: "voice-input-b-live-dictation" } satisfies Meta;
+export default meta;
+
+export const TryIt: StoryObj = {
+ name: "Try it",
+ render: () => (
+ <DemoStage info={LIVE_DICTATION}>
+ <LiveDictation />
+ </DemoStage>
+ ),
+};
+
+function States() {
+ const { lang } = useStoryEnv();
+ const s = samples(lang);
+ return (
+ <Gallery
+ columns={2}
+ items={[
+ { label: label("idle", lang), node: <LiveDictation frozen={s.idle} framed={false} /> },
+ { label: label("requesting", lang), node: <LiveDictation frozen={s.requesting} framed={false} /> },
+ { label: label("listening", lang), node: <LiveDictation frozen={s.listening} framed={false} /> },
+ {
+ label: label("polish", lang),
+ node: <LiveDictation frozen={s.idle} framed={false} initialDraft={CHAT_SCRIPT[lang].phrases.join("")} showPolish />,
+ },
+ { label: label("noSpeech", lang), node: <LiveDictation frozen={s.noSpeech} framed={false} /> },
+ { label: label("network", lang), node: <LiveDictation frozen={s.network} framed={false} /> },
+ ]}
+ />
+ );
+}
+
+export const AllStates: StoryObj = { name: "States", render: () => <States /> };
diff --git a/apps/storybook/src/voice-input/c-push-to-talk.stories.tsx b/apps/storybook/src/voice-input/c-push-to-talk.stories.tsx
new file mode 100644
index 0000000000..6e0b7b1e98
--- /dev/null
+++ b/apps/storybook/src/voice-input/c-push-to-talk.stories.tsx
@@ -0,0 +1,38 @@
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { PushToTalk } from "./concepts/push-to-talk";
+import { PUSH_TO_TALK } from "./concepts/info";
+import { useStoryEnv } from "./env";
+import { Gallery, samples } from "./gallery";
+import { label } from "./labels";
+import { DemoStage } from "./stage";
+
+const meta = { title: "Voice input/Explored/C · Push-to-talk", id: "voice-input-c-push-to-talk" } satisfies Meta;
+export default meta;
+
+export const TryIt: StoryObj = {
+ name: "Try it",
+ render: () => (
+ <DemoStage info={PUSH_TO_TALK}>
+ <PushToTalk />
+ </DemoStage>
+ ),
+};
+
+function States() {
+ const { lang } = useStoryEnv();
+ const s = samples(lang);
+ return (
+ <Gallery
+ columns={3}
+ items={[
+ { label: label("idle", lang), node: <PushToTalk frozen={s.idle} /> },
+ { label: label("listening", lang), node: <PushToTalk frozen={s.listening} /> },
+ { label: label("locked", lang), node: <PushToTalk frozen={s.listening} frozenLocked /> },
+ { label: label("processing", lang), node: <PushToTalk frozen={s.processing} /> },
+ { label: label("noSpeech", lang), node: <PushToTalk frozen={s.noSpeech} /> },
+ ]}
+ />
+ );
+}
+
+export const AllStates: StoryObj = { name: "States", render: () => <States /> };
diff --git a/apps/storybook/src/voice-input/chat-frame.tsx b/apps/storybook/src/voice-input/chat-frame.tsx
new file mode 100644
index 0000000000..cb2af7b80f
--- /dev/null
+++ b/apps/storybook/src/voice-input/chat-frame.tsx
@@ -0,0 +1,224 @@
+import { useCallback, useEffect, useRef, useState, type ReactNode, type Ref } from "react";
+import { Bot, ChevronDown, Maximize2, Mic, Minus, Plus, SquarePen } from "@multica/ui/icons";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { SubmitButton } from "@multica/ui/components/common/submit-button";
+import { cn } from "@multica/ui/lib/utils";
+import { useStoryEnv } from "./env";
+
+export interface DemoMessage {
+ id: number;
+ text: string;
+ viaVoice?: boolean;
+}
+
+/** Messages the reviewer sends in a demo, appended under the seeded exchange. */
+export function useDemoChat() {
+ const [messages, setMessages] = useState<DemoMessage[]>([]);
+ const send = useCallback((text: string, viaVoice = false) => {
+ if (!text.trim()) return;
+ setMessages((m) => [...m, { id: Date.now(), text: text.trim(), viaVoice }]);
+ }, []);
+ return { messages, send };
+}
+
+function AgentAvatar({ className }: { className?: string }) {
+ return (
+ <span className={cn("flex size-5 shrink-0 items-center justify-center rounded-full bg-brand/12 text-brand", className)}>
+ <Bot className="size-3" />
+ </span>
+ );
+}
+
+function UserBubble({ message }: { message: DemoMessage }) {
+ const { copy } = useStoryEnv();
+ return (
+ <div className="flex flex-col items-end gap-1">
+ <div className="max-w-[80%] break-words rounded-2xl bg-muted px-3.5 py-2 text-body">{message.text}</div>
+ {message.viaVoice && (
+ <span className="flex items-center gap-1 pr-1 text-micro text-faint-foreground">
+ <Mic className="size-3" />
+ {copy.dictate}
+ </span>
+ )}
+ </div>
+ );
+}
+
+/**
+ * The floating chat window (packages/views/chat/components/chat-window.tsx),
+ * with a seeded exchange so the composer reads in context.
+ */
+export function ChatWindowFrame({
+ children,
+ messages = [],
+ overlay,
+ width = 460,
+ height = 600,
+ className,
+}: {
+ children: ReactNode;
+ messages?: DemoMessage[];
+ overlay?: ReactNode;
+ width?: number;
+ height?: number;
+ className?: string;
+}) {
+ const { copy } = useStoryEnv();
+ const listRef = useRef<HTMLDivElement>(null);
+ useEffect(() => {
+ listRef.current?.scrollTo({ top: listRef.current.scrollHeight, behavior: "smooth" });
+ }, [messages.length]);
+
+ return (
+ <div
+ className={cn(
+ "@container relative flex flex-col overflow-hidden rounded-xl bg-surface-raised shadow-[var(--floating-shadow)] ring-1 ring-floating-border",
+ className,
+ )}
+ style={{ width, height }}
+ >
+ <div className="flex items-center justify-between gap-2 border-b px-4 py-2.5">
+ <div className="flex min-w-0 items-center gap-1">
+ <IconButton label="New chat" className="text-muted-foreground">
+ <SquarePen />
+ </IconButton>
+ <span className="truncate text-body font-medium">{copy.sessionTitle}</span>
+ </div>
+ <div className="flex shrink-0 items-center gap-0.5">
+ <IconButton label="Expand" className="text-muted-foreground">
+ <Maximize2 />
+ </IconButton>
+ <IconButton label="Minimize" className="text-muted-foreground">
+ <Minus />
+ </IconButton>
+ </div>
+ </div>
+ <div ref={listRef} className="min-h-0 flex-1 overflow-y-auto px-5">
+ <div className="space-y-4 py-4">
+ <UserBubble message={{ id: 0, text: copy.userMessage }} />
+ <div className="text-body leading-relaxed">{copy.agentReply}</div>
+ {messages.map((m) => (
+ <UserBubble key={m.id} message={m} />
+ ))}
+ </div>
+ </div>
+ {children}
+ {overlay}
+ </div>
+ );
+}
+
+/** The agent picker that sits at the composer's bottom-left. */
+export function AgentPicker() {
+ const { copy } = useStoryEnv();
+ return (
+ <button
+ type="button"
+ className="-ml-1 flex cursor-pointer items-center gap-1.5 rounded-md px-1.5 py-1 outline-none transition-colors hover:bg-accent"
+ >
+ <AgentAvatar />
+ <span className="max-w-28 truncate text-caption font-medium">{copy.agentName}</span>
+ <ChevronDown className="size-3 shrink-0 text-muted-foreground" />
+ </button>
+ );
+}
+
+export function AddButton() {
+ return (
+ <IconButton label="Add" className="text-muted-foreground">
+ <Plus />
+ </IconButton>
+ );
+}
+
+/**
+ * The chat composer card (packages/views/chat/components/chat-input.tsx):
+ * editor area on top, tools pinned to the bottom corners.
+ */
+export function ComposerSurface({
+ children,
+ above,
+ left,
+ right,
+ bottom,
+ active,
+ className,
+ surfaceRef,
+}: {
+ children: ReactNode;
+ /** Rows between the editor and the toolbar, such as an inline error. */
+ above?: ReactNode;
+ left?: ReactNode;
+ right?: ReactNode;
+ /** Replaces the left corner with a row that runs up to `right` (or the edge without it). */
+ bottom?: ReactNode;
+ /** Draw the focus ring while voice is capturing, even without DOM focus. */
+ active?: boolean;
+ className?: string;
+ surfaceRef?: Ref<HTMLDivElement>;
+}) {
+ return (
+ <div className="relative z-10 flex flex-col px-5 pb-3 pt-0">
+ <div
+ ref={surfaceRef}
+ className={cn(
+ "relative flex min-h-16 max-h-96 flex-col rounded-lg border border-surface-border bg-surface pb-9 transition-[border-color,box-shadow] focus-within:border-brand focus-within:ring-2 focus-within:ring-ring/20",
+ active && "border-brand ring-2 ring-ring/20",
+ className,
+ )}
+ >
+ <div className="min-h-0 flex-1 overflow-y-auto px-3 py-2 text-body">{children}</div>
+ {above && <div className="px-2 pb-1">{above}</div>}
+ {bottom ? (
+ <div className={cn("absolute bottom-1 left-1.5 flex h-8 items-center gap-1", right ? "right-12" : "right-1.5")}>
+ {bottom}
+ </div>
+ ) : (
+ <div className="absolute bottom-1.5 left-1.5 flex items-center gap-1">{left}</div>
+ )}
+ {right && <div className="absolute bottom-1 right-1.5 flex items-center gap-1">{right}</div>}
+ </div>
+ </div>
+ );
+}
+
+/** Plain text stand-in for the Tiptap editor: same type, same placeholder treatment. */
+export function DraftEditor({
+ value,
+ onChange,
+ placeholder,
+ onSubmit,
+ textareaRef,
+ className,
+}: {
+ value: string;
+ onChange: (value: string) => void;
+ placeholder: string;
+ onSubmit?: () => void;
+ textareaRef?: Ref<HTMLTextAreaElement>;
+ className?: string;
+}) {
+ return (
+ <textarea
+ ref={textareaRef}
+ value={value}
+ onChange={(e) => onChange(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
+ e.preventDefault();
+ onSubmit?.();
+ }
+ }}
+ placeholder={placeholder}
+ className={cn(
+ "block max-h-40 min-h-5 w-full resize-none bg-transparent text-body outline-none field-sizing-content placeholder:text-muted-foreground",
+ className,
+ )}
+ />
+ );
+}
+
+export function SendButton({ onClick, disabled }: { onClick: () => void; disabled?: boolean }) {
+ const { copy } = useStoryEnv();
+ return <SubmitButton onClick={onClick} disabled={disabled} tooltip={copy.send} ariaLabel={copy.send} />;
+}
diff --git a/apps/storybook/src/voice-input/composer.stories.tsx b/apps/storybook/src/voice-input/composer.stories.tsx
new file mode 100644
index 0000000000..5e3422234d
--- /dev/null
+++ b/apps/storybook/src/voice-input/composer.stories.tsx
@@ -0,0 +1,199 @@
+import type { ReactNode } from "react";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { ChatWindowFrame, useDemoChat } from "./chat-frame";
+import { COMMENT_SCRIPT, type Lang } from "./copy";
+import { useStoryEnv } from "./env";
+import { Gallery, samples } from "./gallery";
+import { ChatComposer, CommentComposer, IssuePage } from "./composer/surfaces";
+import { VoiceProvider, type FrozenVoice } from "./composer/voice-provider";
+import { ShortcutKeys } from "./composer/voice-ui";
+import { useVoiceSettings } from "./settings/store";
+
+const meta = {
+ title: "Voice input/Composer (A + C)",
+ id: "voice-input-composer",
+ parameters: { layout: "fullscreen" },
+} satisfies Meta;
+export default meta;
+
+const NOTES: Record<"chat" | "issue" | "together", Record<Lang, { title: string; pitch: string }>> = {
+ chat: {
+ zh: { title: "聊天输入框", pitch: "同一个麦克风按钮,点按是 A,按住是 C。" },
+ en: { title: "Chat composer", pitch: "One mic button: a tap is A, a hold is C." },
+ },
+ issue: {
+ zh: { title: "Issue 评论和回复", pitch: "评论框和讨论里的回复框接的是同一套语音层,行为完全一致。" },
+ en: { title: "Issue comments and replies", pitch: "The comment box and the thread reply box plug into the same voice layer and behave identically." },
+ },
+ together: {
+ zh: { title: "同时打开", pitch: "整个应用只有一个录音。快捷键把文字送进最近获得焦点的输入框,浮层就出现在那个输入框上方。" },
+ en: {
+ title: "Both open",
+ pitch: "The app has one recording at a time. The shortcut dictates into the composer that last had focus, and the HUD appears above that composer.",
+ },
+ },
+};
+
+function Aside({ note }: { note: keyof typeof NOTES }) {
+ const { lang, source } = useStoryEnv();
+ const { settings } = useVoiceSettings();
+ const n = NOTES[note][lang];
+ const zh = lang === "zh";
+ const keys = <ShortcutKeys keys={settings.shortcut} />;
+ const steps: ReactNode[] = zh
+ ? [
+ <>点一下麦克风,或按一下 {keys}:底部变成录音条(A)。✓ 插入,↑ 直接发送,Esc 取消。</>,
+ <>按住麦克风或 {keys} 说话:输入框上方浮出小条(C),松开就插入。</>,
+ <>插入后会出现「润色」,一键把口语整理成书面语。</>,
+ ]
+ : [
+ <>Tap the mic, or tap {keys}: the toolbar becomes the recording strip (A). ✓ inserts, ↑ sends, Esc cancels.</>,
+ <>Hold the mic or {keys} and talk: a pill floats above the composer (C). Let go to insert.</>,
+ <>After inserting, “Polish” turns speech into written text in one click.</>,
+ ];
+ return (
+ <aside className="w-72 shrink-0 pt-2">
+ <div className="text-caption font-medium text-brand">A + C</div>
+ <h1 className="mt-1 text-title font-semibold">{n.title}</h1>
+ <p className="mt-2 text-body text-muted-foreground">{n.pitch}</p>
+ <ul className="mt-5 space-y-2.5 text-body">
+ {steps.map((step, i) => (
+ <li key={i} className="flex gap-2">
+ <span className="mt-2 size-1 shrink-0 rounded-full bg-faint-foreground" />
+ <span>{step}</span>
+ </li>
+ ))}
+ </ul>
+ <p className="mt-6 text-caption text-faint-foreground">
+ {source === "simulated"
+ ? zh
+ ? "当前是模拟说话人。工具栏「Voice」切到「My microphone」可以用真麦克风试。"
+ : "Using the simulated speaker. Switch Voice → My microphone in the toolbar to use your own voice."
+ : zh
+ ? "正在使用你的麦克风。"
+ : "Using your microphone."}
+ </p>
+ </aside>
+ );
+}
+
+function ChatWindow() {
+ const chat = useDemoChat();
+ return (
+ <ChatWindowFrame messages={chat.messages}>
+ <ChatComposer onSend={chat.send} />
+ </ChatWindowFrame>
+ );
+}
+
+export const Chat: StoryObj = {
+ render: () => (
+ <VoiceProvider primaryId="chat">
+ <div className="flex items-start gap-10 p-8">
+ <ChatWindow />
+ <Aside note="chat" />
+ </div>
+ </VoiceProvider>
+ ),
+};
+
+export const IssueComment: StoryObj = {
+ name: "Issue comment",
+ render: () => (
+ <VoiceProvider primaryId="comment">
+ <div className="flex items-start gap-10 p-8">
+ <IssuePage />
+ <Aside note="issue" />
+ </div>
+ </VoiceProvider>
+ ),
+};
+
+export const Together: StoryObj = {
+ name: "Chat and issue together",
+ render: () => (
+ <VoiceProvider primaryId="comment">
+ <div className="flex items-start gap-6 p-8">
+ <IssuePage width={640} height={680} />
+ <ChatWindow />
+ <Aside note="together" />
+ </div>
+ </VoiceProvider>
+ ),
+};
+
+function Frozen({ state, children }: { state: FrozenVoice; children: ReactNode }) {
+ return (
+ <VoiceProvider primaryId={state.activeId ?? "chat"} frozen={state}>
+ {children}
+ </VoiceProvider>
+ );
+}
+
+function StatesGallery() {
+ const { lang } = useStoryEnv();
+ const chat = samples(lang);
+ const comment = samples(lang, COMMENT_SCRIPT[lang]);
+ const zh = lang === "zh";
+ const rows: { label: string; chat: FrozenVoice; comment: FrozenVoice; draft?: { chat: string; comment: string } }[] = [
+ { label: zh ? "空闲" : "Idle", chat: { session: chat.idle, activeId: null }, comment: { session: comment.idle, activeId: null } },
+ {
+ label: zh ? "点按:录音条(A)" : "Tap: recording strip (A)",
+ chat: { session: chat.listening, activeId: "chat", mode: "strip" },
+ comment: { session: comment.listening, activeId: "comment", mode: "strip" },
+ },
+ {
+ label: zh ? "按住:浮层(C)" : "Hold: floating pill (C)",
+ chat: { session: chat.listening, activeId: "chat", mode: "hud" },
+ comment: { session: comment.listening, activeId: "comment", mode: "hud" },
+ },
+ {
+ label: zh ? "转写中" : "Transcribing",
+ chat: { session: chat.processing, activeId: "chat", mode: "strip" },
+ comment: { session: comment.processing, activeId: "comment", mode: "strip" },
+ },
+ {
+ label: zh ? "已插入,提供润色" : "Inserted, Polish offered",
+ chat: { session: chat.idle, activeId: null, offerFor: "chat" },
+ comment: { session: comment.idle, activeId: null, offerFor: "comment" },
+ draft: {
+ chat: chat.processing.finalText,
+ comment: comment.processing.finalText,
+ },
+ },
+ {
+ label: zh ? "没听清" : "Nothing heard",
+ chat: { session: chat.noSpeech, activeId: "chat" },
+ comment: { session: comment.noSpeech, activeId: "comment" },
+ },
+ ];
+ return (
+ <Gallery
+ columns={2}
+ items={rows.flatMap((row) => [
+ {
+ label: `${row.label} · ${zh ? "聊天" : "Chat"}`,
+ node: (
+ <Frozen state={row.chat}>
+ <div className="w-[460px] pt-16">
+ <ChatComposer onSend={() => {}} initialDraft={row.draft?.chat} />
+ </div>
+ </Frozen>
+ ),
+ },
+ {
+ label: `${row.label} · ${zh ? "Issue 评论" : "Issue comment"}`,
+ node: (
+ <Frozen state={row.comment}>
+ <div className="w-[560px] pt-16">
+ <CommentComposer onSend={() => {}} initialDraft={row.draft?.comment} />
+ </div>
+ </Frozen>
+ ),
+ },
+ ])}
+ />
+ );
+}
+
+export const AllStates: StoryObj = { name: "All states", render: () => <StatesGallery /> };
diff --git a/apps/storybook/src/voice-input/composer/surfaces.tsx b/apps/storybook/src/voice-input/composer/surfaces.tsx
new file mode 100644
index 0000000000..5ba70529e4
--- /dev/null
+++ b/apps/storybook/src/voice-input/composer/surfaces.tsx
@@ -0,0 +1,286 @@
+import { useRef, useState, type ReactNode } from "react";
+import { Bot, ChevronRight, Mic, Paperclip } from "@multica/ui/icons";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { cn } from "@multica/ui/lib/utils";
+import { CHAT_SCRIPT, COMMENT_SCRIPT, REPLY_SCRIPT, type VoiceScript } from "../copy";
+import { useStoryEnv } from "../env";
+import { AddButton, AgentPicker, ComposerSurface, DraftEditor, SendButton } from "../chat-frame";
+import { useVoiceTarget, type VoiceTarget } from "./voice-provider";
+import { PolishChip, VoiceErrorRow, VoiceHud, VoiceMicButton, VoiceStrip } from "./voice-ui";
+
+export type SendHandler = (text: string, viaVoice: boolean) => void;
+
+/** Draft state plus the voice target, the part every composer shares. */
+function useVoiceComposer(id: string, script: VoiceScript, onSend: SendHandler, initialDraft = "") {
+ const [draft, setDraft] = useState(initialDraft);
+ const draftRef = useRef(draft);
+ draftRef.current = draft;
+ const target = useVoiceTarget({
+ id,
+ script,
+ getDraft: () => draftRef.current,
+ setDraft,
+ send: (text) => onSend(text, true),
+ });
+ const recording = target.phase === "listening" || target.phase === "requesting";
+ const strip = target.active && target.mode === "strip" && (recording || target.phase === "processing");
+ const submit = () => {
+ if (!draft.trim()) return;
+ onSend(draft, false);
+ setDraft("");
+ };
+ return { draft, setDraft, target, recording, strip, submit };
+}
+
+function Landed({ target, children }: { target: VoiceTarget; children: ReactNode }) {
+ return (
+ <div key={target.landed} className={cn(target.landed > 0 && "voice-landed")}>
+ {children}
+ </div>
+ );
+}
+
+/** The floating chat window's composer (packages/views/chat/components/chat-input.tsx). */
+export function ChatComposer({ id = "chat", onSend, initialDraft }: { id?: string; onSend: SendHandler; initialDraft?: string }) {
+ const { lang, copy } = useStoryEnv();
+ const c = useVoiceComposer(id, CHAT_SCRIPT[lang], onSend, initialDraft);
+ return (
+ <div className="relative" onFocusCapture={c.target.onFocus}>
+ <VoiceHud target={c.target} />
+ <ComposerSurface
+ active={c.target.active && c.recording}
+ above={c.target.phase === "error" ? <VoiceErrorRow target={c.target} /> : undefined}
+ bottom={c.strip ? <VoiceStrip target={c.target} /> : undefined}
+ left={
+ <>
+ <AddButton />
+ <AgentPicker />
+ <PolishChip target={c.target} />
+ </>
+ }
+ right={
+ c.strip ? undefined : (
+ <>
+ <VoiceMicButton target={c.target} />
+ <SendButton disabled={!c.draft.trim()} onClick={c.submit} />
+ </>
+ )
+ }
+ >
+ <Landed target={c.target}>
+ <DraftEditor value={c.draft} onChange={c.setDraft} placeholder={copy.placeholder} onSubmit={c.submit} />
+ </Landed>
+ </ComposerSurface>
+ </div>
+ );
+}
+
+function TriggerChip() {
+ const { copy } = useStoryEnv();
+ return (
+ <span className="inline-flex h-6 min-w-0 items-center gap-1.5 rounded-md px-1.5 text-micro font-medium text-muted-foreground">
+ <span className="flex size-4 items-center justify-center rounded-full bg-brand/12 text-brand">
+ <Bot className="size-2.5" />
+ </span>
+ <span className="truncate">
+ {copy.agentName} · {copy.willStart}
+ </span>
+ </span>
+ );
+}
+
+/** The issue's comment box (packages/views/issues/components/comment-input.tsx). */
+export function CommentComposer({
+ id = "comment",
+ onSend,
+ initialDraft,
+ trigger = true,
+}: {
+ id?: string;
+ onSend: SendHandler;
+ initialDraft?: string;
+ /** The "agent starts after sending" chip; off outside an issue. */
+ trigger?: boolean;
+}) {
+ const { lang, copy } = useStoryEnv();
+ const c = useVoiceComposer(id, COMMENT_SCRIPT[lang], onSend, initialDraft);
+ const ring = c.target.active && c.recording;
+ return (
+ <div className="relative" onFocusCapture={c.target.onFocus}>
+ <VoiceHud target={c.target} />
+ <div
+ data-mc="comment-composer"
+ className={cn(
+ "relative flex flex-col rounded-lg bg-card pb-8 ring-1 ring-border transition-shadow",
+ ring && "ring-2 ring-brand/70",
+ )}
+ >
+ <div className="px-3 py-2">
+ <Landed target={c.target}>
+ <DraftEditor value={c.draft} onChange={c.setDraft} placeholder={copy.commentPlaceholder} onSubmit={c.submit} />
+ </Landed>
+ </div>
+ <div className="px-2 pb-1 empty:hidden">
+ <VoiceErrorRow target={c.target} />
+ </div>
+ {c.strip ? (
+ <div className="absolute bottom-1 left-1.5 right-1.5 flex h-8 items-center gap-1">
+ <VoiceStrip target={c.target} />
+ </div>
+ ) : (
+ <>
+ <div className="absolute bottom-1 left-2 right-36 flex min-w-0 items-center gap-1.5">
+ {trigger && <TriggerChip />}
+ <PolishChip target={c.target} />
+ </div>
+ <div className="absolute bottom-1 right-1.5 flex items-center gap-1">
+ <IconButton label={copy.attach} className="text-muted-foreground">
+ <Paperclip />
+ </IconButton>
+ <VoiceMicButton target={c.target} />
+ <SendButton disabled={!c.draft.trim()} onClick={c.submit} />
+ </div>
+ </>
+ )}
+ </div>
+ </div>
+ );
+}
+
+function Avatar({ kind, className }: { kind: "agent" | "human"; className?: string }) {
+ return kind === "agent" ? (
+ <span className={cn("flex size-6 shrink-0 items-center justify-center rounded-full bg-brand/12 text-brand", className)}>
+ <Bot className="size-3.5" />
+ </span>
+ ) : (
+ <span
+ className={cn(
+ "flex size-6 shrink-0 items-center justify-center rounded-full bg-multica-ink text-micro font-semibold text-multica-paper",
+ className,
+ )}
+ >
+ J
+ </span>
+ );
+}
+
+/** A reply inside a comment thread (packages/views/issues/components/reply-input.tsx). */
+export function ReplyComposer({ id = "reply", onSend }: { id?: string; onSend: SendHandler }) {
+ const { lang, copy } = useStoryEnv();
+ const c = useVoiceComposer(id, REPLY_SCRIPT[lang], onSend);
+ const ring = c.target.active && c.recording;
+ const tall = !!c.draft || c.strip || c.target.offered || c.target.phase === "error";
+ return (
+ <div className="flex items-start gap-2.5" onFocusCapture={c.target.onFocus}>
+ <Avatar kind="human" className="mt-0.5 size-5" />
+ <div className={cn("relative flex min-w-0 flex-1 flex-col rounded-md transition-shadow", tall && "pb-9", ring && "ring-2 ring-brand/70 ring-offset-4 ring-offset-card")}>
+ <VoiceHud target={c.target} />
+ <Landed target={c.target}>
+ <DraftEditor value={c.draft} onChange={c.setDraft} placeholder={copy.replyPlaceholder} onSubmit={c.submit} className="pr-20" />
+ </Landed>
+ <div className="pt-1 empty:hidden">
+ <VoiceErrorRow target={c.target} />
+ </div>
+ {c.strip ? (
+ <div className="absolute bottom-0 left-0 right-0 flex h-8 items-center gap-1">
+ <VoiceStrip target={c.target} compact />
+ </div>
+ ) : (
+ <>
+ <div className="absolute bottom-0 left-0 flex items-center">
+ <PolishChip target={c.target} />
+ </div>
+ <div className="absolute bottom-0 right-0 flex items-center gap-1">
+ <VoiceMicButton target={c.target} />
+ <SendButton disabled={!c.draft.trim()} onClick={c.submit} />
+ </div>
+ </>
+ )}
+ </div>
+ </div>
+ );
+}
+
+export interface PostedComment {
+ id: number;
+ text: string;
+ viaVoice?: boolean;
+}
+
+function VoiceMeta() {
+ const { copy } = useStoryEnv();
+ return (
+ <span className="inline-flex items-center gap-1 text-micro text-faint-foreground">
+ <Mic className="size-3" />
+ {copy.dictate}
+ </span>
+ );
+}
+
+function CommentRow({ who, name, time, text, viaVoice }: { who: "agent" | "human"; name: string; time: string; text: string; viaVoice?: boolean }) {
+ return (
+ <div className="flex gap-2.5 px-4 py-3">
+ <Avatar kind={who} />
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2 text-caption">
+ <span className="font-medium text-foreground">{name}</span>
+ <span className="text-faint-foreground">{time}</span>
+ {viaVoice && <VoiceMeta />}
+ </div>
+ <p className="mt-1 whitespace-pre-wrap text-body leading-relaxed">{text}</p>
+ </div>
+ </div>
+ );
+}
+
+/**
+ * An issue page cut down to the activity column: a thread with a reply box and
+ * the comment box under it — two more composers on the same voice layer.
+ */
+export function IssuePage({ width = 720, height = 760, className }: { width?: number; height?: number; className?: string }) {
+ const { copy } = useStoryEnv();
+ const [replies, setReplies] = useState<PostedComment[]>([]);
+ const [comments, setComments] = useState<PostedComment[]>([]);
+ const post = (set: typeof setComments): SendHandler => (text, viaVoice) => {
+ if (text.trim()) set((list) => [...list, { id: Date.now(), text: text.trim(), viaVoice }]);
+ };
+ return (
+ <div
+ className={cn("flex flex-col overflow-hidden rounded-xl bg-background ring-1 ring-border", className)}
+ style={{ width, height }}
+ >
+ <div className="flex items-center gap-1.5 border-b px-6 py-2.5 text-caption text-muted-foreground">
+ <span>Multica</span>
+ <ChevronRight className="size-3" />
+ <span className="font-medium text-foreground">{copy.issueKey}</span>
+ </div>
+ <div className="min-h-0 flex-1 overflow-y-auto px-8 pb-6 pt-6">
+ <h1 className="text-title-lg font-semibold tracking-tight">{copy.sessionTitle}</h1>
+ <p className="mt-3 text-body leading-relaxed text-muted-foreground">{copy.issueBody}</p>
+ <h2 className="mt-8 mb-3 text-body font-semibold">{copy.activity}</h2>
+ <div className="space-y-4">
+ <div className="overflow-hidden rounded-xl border bg-card">
+ <CommentRow who="human" name={copy.humanName} time={copy.minutesAgo} text={copy.humanComment} />
+ <div className="border-t border-border/50">
+ <CommentRow who="agent" name={copy.agentName} time={copy.minutesAgo} text={copy.agentReply} />
+ </div>
+ {replies.map((r) => (
+ <div key={r.id} className="border-t border-border/50">
+ <CommentRow who="human" name={copy.humanName} time={copy.justNow} text={r.text} viaVoice={r.viaVoice} />
+ </div>
+ ))}
+ <div className="border-t border-border/50 px-4 py-2.5">
+ <ReplyComposer onSend={post(setReplies)} />
+ </div>
+ </div>
+ {comments.map((c) => (
+ <div key={c.id} className="rounded-xl border bg-card">
+ <CommentRow who="human" name={copy.humanName} time={copy.justNow} text={c.text} viaVoice={c.viaVoice} />
+ </div>
+ ))}
+ <CommentComposer onSend={post(setComments)} />
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/storybook/src/voice-input/composer/voice-provider.tsx b/apps/storybook/src/voice-input/composer/voice-provider.tsx
new file mode 100644
index 0000000000..f83f4a2996
--- /dev/null
+++ b/apps/storybook/src/voice-input/composer/voice-provider.tsx
@@ -0,0 +1,350 @@
+import {
+ createContext,
+ useCallback,
+ useContext,
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+ type ReactNode,
+} from "react";
+import { CHAT_SCRIPT, type VoiceScript } from "../copy";
+import { appendDictation, useStoryEnv } from "../env";
+import { useVoiceSession, type VoiceSession, type VoiceSessionOptions } from "../voice-session";
+import { useVoiceSettings } from "../settings/store";
+
+/**
+ * One voice layer for every composer. The provider owns the single recording
+ * (there is never more than one), the shortcut, and the commit; a composer
+ * only registers how to read and write its draft. Chat, issue comments and
+ * thread replies all plug in the same way, so they behave the same.
+ *
+ * Presentation follows the press, not the composer:
+ * tap → "strip": the composer's toolbar becomes the recording strip (A)
+ * hold → "hud": a floating pill above the composer; release inserts (C)
+ */
+
+export type VoiceMode = "pending" | "strip" | "hud";
+export type CommitKind = "insert" | "send";
+
+export interface VoiceTargetSpec {
+ id: string;
+ /** What the simulated speaker says into this composer. */
+ script: VoiceScript;
+ getDraft: () => string;
+ setDraft: (value: string) => void;
+ send: (text: string) => void;
+}
+
+interface PolishOffer {
+ id: string;
+ before: string;
+ raw: string;
+}
+
+interface VoiceContextValue {
+ session: VoiceSession;
+ activeId: string | null;
+ mode: VoiceMode;
+ focusedId: string | null;
+ landed: Record<string, number>;
+ offer: PolishOffer | null;
+ polishing: boolean;
+ register: (spec: VoiceTargetSpec) => () => void;
+ focus: (id: string) => void;
+ press: (id: string, via: "key" | "pointer") => void;
+ release: () => void;
+ stopAnd: (kind: CommitKind) => void;
+ cancel: () => void;
+ retry: () => void;
+ polish: () => void;
+ dismissOffer: () => void;
+}
+
+/** Shorter than this is a tap (toggle), longer is a hold (push-to-talk). */
+export const TAP_MS = 250;
+
+const FILLERS = /^(um,?\s*|uh,?\s*|嗯,?|呃,?)/i;
+
+const VoiceContext = createContext<VoiceContextValue | null>(null);
+
+export interface FrozenVoice {
+ session: VoiceSession;
+ activeId: string | null;
+ mode?: VoiceMode;
+ offerFor?: string;
+}
+
+export function VoiceProvider({
+ primaryId,
+ frozen,
+ simulate,
+ gate,
+ children,
+}: {
+ /** Where the shortcut sends text when no composer has had focus yet. */
+ primaryId: string;
+ /** Pin the layer at one state, for galleries. */
+ frozen?: FrozenVoice;
+ simulate?: Pick<VoiceSessionOptions, "failWith" | "permission">;
+ /** Runs before a recording starts; return false to hold it (e.g. first-use setup). */
+ gate?: () => boolean;
+ children: ReactNode;
+}) {
+ const { lang, source } = useStoryEnv();
+ const { settings } = useVoiceSettings();
+ const targets = useRef(new Map<string, VoiceTargetSpec>());
+ const [activeId, setActiveId] = useState<string | null>(null);
+ const [mode, setMode] = useState<VoiceMode>("strip");
+ const [focusedId, setFocusedId] = useState<string | null>(null);
+ const [landed, setLanded] = useState<Record<string, number>>({});
+ const [offer, setOffer] = useState<PolishOffer | null>(null);
+ const [polishing, setPolishing] = useState(false);
+ const pressRef = useRef<{ at: number; via: "key" | "pointer" } | null>(null);
+ const commitRef = useRef<CommitKind>("insert");
+
+ const script = (activeId && targets.current.get(activeId)?.script) || CHAT_SCRIPT[lang];
+ const live = useVoiceSession({
+ source,
+ lang,
+ script,
+ polish: settings.polish === "auto",
+ processingMs: settings.engine === "local" ? 650 : 1000,
+ permission: settings.micPermission === "prompt" ? "prompt" : "granted",
+ failWith: settings.micPermission === "denied" ? "permission-denied" : null,
+ ...simulate,
+ });
+ const session = frozen?.session ?? live;
+ const { phase } = session;
+
+ // Land the text once the recording is transcribed.
+ const activeRef = useRef(activeId);
+ activeRef.current = activeId;
+ useEffect(() => {
+ if (frozen || live.phase !== "done") return;
+ const target = activeRef.current ? targets.current.get(activeRef.current) : undefined;
+ if (target) {
+ const raw = settings.removeFillers ? live.result.replace(FILLERS, "") : live.result;
+ const before = target.getDraft();
+ const text = appendDictation(before, raw, lang);
+ if (commitRef.current === "send") {
+ target.send(text);
+ target.setDraft("");
+ setOffer(null);
+ } else {
+ target.setDraft(text);
+ setLanded((m) => ({ ...m, [target.id]: (m[target.id] ?? 0) + 1 }));
+ setOffer(settings.polish === "offer" ? { id: target.id, before, raw: live.result } : null);
+ }
+ }
+ commitRef.current = "insert";
+ live.reset();
+ // Only the transition into "done" should land text.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [live.phase]);
+
+ // Back to idle (landed or cancelled): release the composer.
+ useEffect(() => {
+ if (!frozen && live.phase === "idle") {
+ setActiveId(null);
+ pressRef.current = null;
+ }
+ }, [frozen, live.phase]);
+
+ // A press that is still down after TAP_MS is a hold.
+ useEffect(() => {
+ if (mode !== "pending") return;
+ const t = window.setTimeout(() => {
+ if (pressRef.current) setMode("hud");
+ }, TAP_MS);
+ return () => window.clearTimeout(t);
+ }, [mode]);
+
+ // The offer only stands while the inserted text is the newest thing.
+ useEffect(() => {
+ if (!offer) return;
+ const t = window.setTimeout(() => setOffer(null), 9000);
+ return () => window.clearTimeout(t);
+ }, [offer]);
+
+ const stopAnd = useCallback(
+ (kind: CommitKind) => {
+ commitRef.current = kind;
+ pressRef.current = null;
+ live.stop();
+ },
+ [live],
+ );
+
+ const press = useCallback(
+ (id: string, via: "key" | "pointer") => {
+ if (frozen) return;
+ const s = live.phase;
+ if (s === "listening" || s === "requesting" || s === "paused") {
+ // A second press ends a tapped (strip) recording.
+ if (mode === "strip") stopAnd("insert");
+ return;
+ }
+ if (s !== "idle" && s !== "error") return;
+ if (gate && !gate()) return;
+ setOffer(null);
+ setActiveId(id);
+ const next: VoiceMode = settings.activation === "toggle" ? "strip" : settings.activation === "hold" ? "hud" : "pending";
+ setMode(next);
+ pressRef.current = next === "strip" ? null : { at: performance.now(), via };
+ live.start();
+ },
+ [frozen, live, mode, settings.activation, stopAnd, gate],
+ );
+
+ const release = useCallback(() => {
+ const p = pressRef.current;
+ if (!p) return;
+ pressRef.current = null;
+ if (settings.activation === "auto" && performance.now() - p.at < TAP_MS) {
+ setMode("strip");
+ return;
+ }
+ stopAnd("insert");
+ }, [settings.activation, stopAnd]);
+
+ const cancel = useCallback(() => {
+ pressRef.current = null;
+ live.cancel();
+ }, [live]);
+
+ const polish = useCallback(() => {
+ if (!offer) return;
+ const target = targets.current.get(offer.id);
+ const spec = target?.script;
+ setPolishing(true);
+ window.setTimeout(() => {
+ if (target && spec) {
+ const raw = offer.raw.trim();
+ const polished = raw === spec.phrases.join("").trim() ? spec.polished : raw.replace(FILLERS, "");
+ target.setDraft(appendDictation(offer.before, polished, lang));
+ setLanded((m) => ({ ...m, [offer.id]: (m[offer.id] ?? 0) + 1 }));
+ }
+ setPolishing(false);
+ setOffer(null);
+ }, 900);
+ }, [offer, lang]);
+
+ // The shortcut: matched in the capture phase so Enter while recording sends
+ // the recording instead of submitting the editor underneath.
+ const keyState = useRef({ press, release, stopAnd, cancel, mode, phase, focusedId, primaryId, shortcut: settings.shortcut });
+ keyState.current = { press, release, stopAnd, cancel, mode, phase, focusedId, primaryId, shortcut: settings.shortcut };
+ useEffect(() => {
+ if (frozen) return;
+ const matches = (e: KeyboardEvent) => {
+ const keys = keyState.current.shortcut;
+ const code = keys[keys.length - 1] === "Space" ? "Space" : `Key${keys[keys.length - 1]}`;
+ return (
+ e.code === code &&
+ e.altKey === keys.includes("⌥") &&
+ (e.metaKey || e.ctrlKey) === keys.includes("⌘") &&
+ e.shiftKey === keys.includes("⇧")
+ );
+ };
+ const down = (e: KeyboardEvent) => {
+ const k = keyState.current;
+ const recording = k.phase === "listening" || k.phase === "requesting";
+ if (matches(e)) {
+ e.preventDefault();
+ if (!e.repeat) k.press(k.focusedId ?? k.primaryId, "key");
+ } else if (e.key === "Escape" && recording) {
+ e.preventDefault();
+ k.cancel();
+ } else if (e.key === "Enter" && !e.shiftKey && k.phase === "listening" && k.mode === "strip") {
+ e.preventDefault();
+ e.stopPropagation();
+ k.stopAnd("send");
+ }
+ };
+ const up = (e: KeyboardEvent) => {
+ if (e.code === "Space" || e.key === "Alt" || e.key === "Meta" || e.key === "Shift") keyState.current.release();
+ };
+ window.addEventListener("keydown", down, true);
+ window.addEventListener("keyup", up, true);
+ return () => {
+ window.removeEventListener("keydown", down, true);
+ window.removeEventListener("keyup", up, true);
+ };
+ }, [frozen]);
+
+ const register = useCallback((spec: VoiceTargetSpec) => {
+ targets.current.set(spec.id, spec);
+ return () => {
+ targets.current.delete(spec.id);
+ };
+ }, []);
+
+ const value = useMemo<VoiceContextValue>(
+ () => ({
+ session,
+ activeId: frozen ? frozen.activeId : activeId,
+ mode: frozen?.mode ?? mode,
+ focusedId,
+ landed,
+ offer: frozen?.offerFor ? { id: frozen.offerFor, before: "", raw: "" } : offer,
+ polishing,
+ register,
+ focus: setFocusedId,
+ press,
+ release,
+ stopAnd,
+ cancel,
+ retry: live.retry,
+ polish,
+ dismissOffer: () => setOffer(null),
+ }),
+ [session, frozen, activeId, mode, focusedId, landed, offer, polishing, register, press, release, stopAnd, cancel, live.retry, polish],
+ );
+
+ return <VoiceContext.Provider value={value}>{children}</VoiceContext.Provider>;
+}
+
+export function useVoiceLayer(): VoiceContextValue {
+ const ctx = useContext(VoiceContext);
+ if (!ctx) throw new Error("useVoiceLayer needs a VoiceProvider");
+ return ctx;
+}
+
+/**
+ * What a composer needs from the layer: register its draft, report focus, and
+ * read whether it is the one being dictated into.
+ */
+export function useVoiceTarget(spec: VoiceTargetSpec) {
+ const layer = useVoiceLayer();
+ const specRef = useRef(spec);
+ specRef.current = spec;
+ const { register } = layer;
+ useEffect(
+ () =>
+ register({
+ id: spec.id,
+ get script() {
+ return specRef.current.script;
+ },
+ getDraft: () => specRef.current.getDraft(),
+ setDraft: (v) => specRef.current.setDraft(v),
+ send: (t) => specRef.current.send(t),
+ }),
+ [register, spec.id],
+ );
+ const active = layer.activeId === spec.id;
+ return {
+ id: spec.id,
+ active,
+ mode: layer.mode,
+ session: layer.session,
+ phase: active ? layer.session.phase : ("idle" as const),
+ focused: layer.focusedId === spec.id,
+ landed: layer.landed[spec.id] ?? 0,
+ offered: layer.offer?.id === spec.id,
+ layer,
+ onFocus: () => layer.focus(spec.id),
+ };
+}
+
+export type VoiceTarget = ReturnType<typeof useVoiceTarget>;
diff --git a/apps/storybook/src/voice-input/composer/voice-ui.tsx b/apps/storybook/src/voice-input/composer/voice-ui.tsx
new file mode 100644
index 0000000000..b6fb62a3a4
--- /dev/null
+++ b/apps/storybook/src/voice-input/composer/voice-ui.tsx
@@ -0,0 +1,183 @@
+import { ArrowUp, Check, Mic, Sparkles, X } from "@multica/ui/icons";
+import { Button } from "@multica/ui/components/ui/button";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { Kbd, KbdGroup } from "@multica/ui/components/ui/kbd";
+import { cn } from "@multica/ui/lib/utils";
+import { useStoryEnv } from "../env";
+import { Elapsed, InlineVoiceError, LevelBars, RecDot, Shimmer, Waveform, formatElapsed } from "../primitives";
+import { useVoiceSettings } from "../settings/store";
+import type { VoiceTarget } from "./voice-provider";
+
+export function ShortcutKeys({ keys }: { keys: string[] }) {
+ return (
+ <KbdGroup>
+ {keys.map((k) => (
+ <Kbd key={k}>{k}</Kbd>
+ ))}
+ </KbdGroup>
+ );
+}
+
+/**
+ * The one mic control every composer carries. Tap to dictate into the
+ * toolbar strip; press and hold to talk, release to insert.
+ */
+export function VoiceMicButton({ target }: { target: VoiceTarget }) {
+ const { copy } = useStoryEnv();
+ const { settings } = useVoiceSettings();
+ const { layer, active, mode, phase } = target;
+ const live = active && (mode === "pending" || mode === "hud") && phase !== "error";
+ const tooltip =
+ settings.activation === "auto" ? copy.micTooltip : settings.activation === "hold" ? copy.holdToTalk : copy.dictate;
+ return (
+ <IconButton
+ label={tooltip}
+ shortcut={<ShortcutKeys keys={settings.shortcut} />}
+ onPointerDown={(e) => {
+ if (e.button !== 0) return;
+ e.currentTarget.setPointerCapture(e.pointerId);
+ target.onFocus();
+ layer.press(target.id, "pointer");
+ }}
+ onPointerUp={() => layer.release()}
+ onPointerCancel={() => layer.release()}
+ className={cn("touch-none text-muted-foreground", live && "bg-brand/10 text-brand hover:bg-brand/15 hover:text-brand")}
+ >
+ {live && phase === "listening" ? <LevelBars levels={target.session.levels} /> : <Mic />}
+ </IconButton>
+ );
+}
+
+/**
+ * A's recording strip. Replaces the composer's bottom row while a tapped
+ * recording runs: cancel, timer, waveform, insert, send.
+ */
+export function VoiceStrip({ target, compact }: { target: VoiceTarget; compact?: boolean }) {
+ const { copy } = useStoryEnv();
+ const { settings } = useVoiceSettings();
+ const { layer, session, phase } = target;
+ if (phase === "requesting") {
+ return (
+ <>
+ <IconButton label={copy.cancel} onClick={layer.cancel} className="text-muted-foreground">
+ <X />
+ </IconButton>
+ <Shimmer className="flex-1 pl-1">{copy.requestingTitle}…</Shimmer>
+ </>
+ );
+ }
+ if (phase === "processing") {
+ return (
+ <>
+ <span className="flex size-[var(--button-height-sm)] shrink-0 items-center justify-center">
+ <Mic className="size-4 text-muted-foreground" />
+ </span>
+ <Shimmer className="flex-1 pl-1">{settings.polish === "auto" ? copy.polishing : copy.transcribing}…</Shimmer>
+ </>
+ );
+ }
+ return (
+ <>
+ <IconButton label={copy.cancel} shortcut={<Kbd>Esc</Kbd>} onClick={layer.cancel} className="text-muted-foreground">
+ <X />
+ </IconButton>
+ <span className="flex shrink-0 items-center gap-1.5 pl-1 pr-2">
+ <RecDot />
+ <Elapsed ms={session.elapsedMs} />
+ </span>
+ <Waveform levels={session.levels} bars={compact ? 36 : 64} className="min-w-0 flex-1 overflow-hidden text-foreground" />
+ <IconButton
+ label={copy.insert}
+ shortcut={<ShortcutKeys keys={settings.shortcut} />}
+ onClick={() => layer.stopAnd("insert")}
+ className="ml-1 text-foreground"
+ >
+ <Check />
+ </IconButton>
+ <Button
+ size="icon-sm"
+ // eslint-disable-next-line no-restricted-syntax -- composer send button, the one round button
+ className="shrink-0 rounded-full"
+ aria-label={copy.send}
+ onClick={() => layer.stopAnd("send")}
+ >
+ <ArrowUp />
+ </Button>
+ </>
+ );
+}
+
+/**
+ * C's floating pill, anchored above whichever composer receives the text.
+ * Always dark ink, like a system indicator, so it reads over any page.
+ */
+export function VoiceHud({ target, className }: { target: VoiceTarget; className?: string }) {
+ const { copy } = useStoryEnv();
+ const { settings, activeModel } = useVoiceSettings();
+ const { session, phase, mode, active } = target;
+ if (!active || mode !== "hud" || phase === "error" || phase === "idle") return null;
+ const text = session.finalText + session.interimText;
+ const showText = phase === "listening" && text && (settings.engine === "cloud" || activeModel?.streaming);
+ return (
+ <div
+ className={cn(
+ "pointer-events-none absolute bottom-full left-1/2 z-30 mb-3 flex -translate-x-1/2 flex-col items-center gap-2",
+ className,
+ )}
+ >
+ {showText && (
+ <div className="max-w-[340px] truncate rounded-md bg-multica-ink/80 px-2.5 py-1 text-caption text-multica-paper/80 backdrop-blur animate-in fade-in [direction:rtl]">
+ <span className="[direction:ltr] [unicode-bidi:embed]">{text}</span>
+ </div>
+ )}
+ <div className="flex h-10 items-center gap-2.5 whitespace-nowrap rounded-full bg-multica-ink pl-3.5 pr-4 text-multica-paper shadow-[var(--floating-shadow)] animate-in fade-in zoom-in-95 slide-in-from-bottom-2">
+ {phase === "processing" ? (
+ <>
+ <Mic className="size-4 opacity-70" />
+ <span className="voice-shimmer text-caption font-medium [--foreground:#fff] [--muted-foreground:rgb(255_255_255/0.5)]">
+ {copy.transcribing}…
+ </span>
+ </>
+ ) : phase === "requesting" ? (
+ <>
+ <Mic className="size-4 opacity-70" />
+ <span className="text-caption opacity-80">{copy.requestingTitle}…</span>
+ </>
+ ) : (
+ <>
+ <RecDot className="bg-[#ff5a52]" />
+ <Waveform levels={session.levels} bars={28} className="h-5 w-[86px]" />
+ <span className="text-caption tabular-nums opacity-70">{formatElapsed(session.elapsedMs)}</span>
+ <span className="text-caption opacity-70">{copy.releaseToInsert}</span>
+ </>
+ )}
+ </div>
+ </div>
+ );
+}
+
+export function VoiceErrorRow({ target }: { target: VoiceTarget }) {
+ const { copy } = useStoryEnv();
+ const { layer, session, phase } = target;
+ if (phase !== "error" || !session.error) return null;
+ return <InlineVoiceError error={session.error} copy={copy} onRetry={layer.retry} onDismiss={layer.cancel} />;
+}
+
+/** After an insert, one click turns the spoken text into written text. */
+export function PolishChip({ target }: { target: VoiceTarget }) {
+ const { copy } = useStoryEnv();
+ const { layer, offered } = target;
+ if (!offered) return null;
+ return (
+ <Button
+ size="xs"
+ variant="brandSubtle"
+ onClick={layer.polish}
+ disabled={layer.polishing}
+ className="animate-in fade-in slide-in-from-left-1"
+ >
+ <Sparkles />
+ {layer.polishing ? <Shimmer className="text-caption">{copy.polishing}…</Shimmer> : copy.polish}
+ </Button>
+ );
+}
diff --git a/apps/storybook/src/voice-input/concepts/focus-mode.tsx b/apps/storybook/src/voice-input/concepts/focus-mode.tsx
new file mode 100644
index 0000000000..c7b71c41b1
--- /dev/null
+++ b/apps/storybook/src/voice-input/concepts/focus-mode.tsx
@@ -0,0 +1,298 @@
+import { useEffect, useState } from "react";
+import { ArrowUp, Check, Mic, Pause, Play, Sparkles, X } from "@multica/ui/icons";
+import { Button } from "@multica/ui/components/ui/button";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { Switch } from "@multica/ui/components/ui/switch";
+import { Tabs, TabsList, TabsTrigger } from "@multica/ui/components/ui/tabs";
+import { Kbd } from "@multica/ui/components/ui/kbd";
+import { cn } from "@multica/ui/lib/utils";
+import { CHAT_SCRIPT } from "../copy";
+import { appendDictation, useStoryEnv } from "../env";
+import { AddButton, AgentPicker, ChatWindowFrame, ComposerSurface, DraftEditor, SendButton, useDemoChat } from "../chat-frame";
+import { Elapsed, LiveTranscript, RecDot, Shimmer, errorMessage } from "../primitives";
+import { isToggleChord, useWindowKeys } from "../use-dictation";
+import { useVoiceSession, type VoiceSession } from "../voice-session";
+import { MicButton } from "./inline-waveform";
+
+export interface FocusReview {
+ raw: string;
+ polished: string;
+}
+
+/** Concentric rings driven by the level history: the newest sample in the core, older ones outward. */
+function Orb({ levels, phase }: { levels: number[]; phase: VoiceSession["phase"] }) {
+ const n = levels.length;
+ const live = phase === "listening";
+ const core = live ? (levels[n - 1] ?? 0) : 0;
+ const mid = live ? (levels[n - 4] ?? 0) : 0;
+ const outer = live ? (levels[n - 8] ?? 0) : 0;
+ const shrink = phase === "processing";
+ return (
+ <div className={cn("relative flex size-40 items-center justify-center transition-transform duration-500", shrink && "scale-50")}>
+ <span
+ className="absolute size-20 rounded-full bg-brand/8 transition-transform duration-150 ease-out"
+ style={{ transform: `scale(${1 + outer * 0.95})` }}
+ />
+ <span
+ className="absolute size-20 rounded-full bg-brand/14 transition-transform duration-100 ease-out"
+ style={{ transform: `scale(${1 + mid * 0.6})` }}
+ />
+ <span
+ className={cn(
+ "absolute flex size-20 items-center justify-center rounded-full text-brand-foreground transition-[transform,background-color] duration-75",
+ phase === "paused" || phase === "error" ? "bg-muted-foreground/40" : "bg-brand",
+ )}
+ style={{ transform: `scale(${1 + core * 0.18})` }}
+ >
+ {phase === "paused" ? <Pause className="size-6" /> : <Mic className="size-7" />}
+ </span>
+ </div>
+ );
+}
+
+function FocusPanel({
+ session,
+ review,
+ polishOn,
+ onPolishChange,
+ onClose,
+ onDone,
+ onInsert,
+ onSend,
+}: {
+ session: VoiceSession;
+ review: FocusReview | null;
+ polishOn: boolean;
+ onPolishChange: (on: boolean) => void;
+ onClose: () => void;
+ onDone: () => void;
+ onInsert: (text: string) => void;
+ onSend: (text: string) => void;
+}) {
+ const { copy } = useStoryEnv();
+ const { phase } = session;
+ const [view, setView] = useState<"polished" | "raw">(polishOn ? "polished" : "raw");
+ const [edited, setEdited] = useState<string | null>(null);
+ const reviewText = edited ?? (review ? (view === "polished" ? review.polished : review.raw) : "");
+
+ const status =
+ review ? null : phase === "requesting" ? (
+ <Shimmer>{copy.requestingTitle}…</Shimmer>
+ ) : phase === "processing" ? (
+ <Shimmer>{polishOn ? copy.polishing : copy.transcribing}…</Shimmer>
+ ) : phase === "error" ? (
+ <span className="text-caption font-medium text-destructive">{copy.stopped}</span>
+ ) : phase === "paused" ? (
+ <span className="text-caption font-medium text-muted-foreground">{copy.paused}</span>
+ ) : (
+ <span className="flex items-center gap-1.5 text-caption font-medium">
+ <RecDot />
+ {copy.listening}
+ </span>
+ );
+
+ return (
+ <div className="absolute inset-0 z-30 flex flex-col bg-surface-raised animate-in fade-in zoom-in-[0.98] duration-200">
+ <div className="flex items-center justify-between gap-2 border-b px-4 py-2.5">
+ <div className="flex h-7 items-center gap-2">
+ {review ? <span className="text-body font-medium">{copy.dictate}</span> : status}
+ {!review && phase !== "requesting" && phase !== "error" && <Elapsed ms={session.elapsedMs} />}
+ </div>
+ <IconButton label={copy.cancel} shortcut={<Kbd>Esc</Kbd>} onClick={onClose} className="text-muted-foreground">
+ <X />
+ </IconButton>
+ </div>
+
+ {review ? (
+ <div className="flex min-h-0 flex-1 flex-col gap-3 p-4">
+ {review.raw !== review.polished && (
+ <Tabs value={view} onValueChange={(v) => { setView(v as "polished" | "raw"); setEdited(null); }}>
+ <TabsList>
+ <TabsTrigger value="polished">
+ <Sparkles />
+ {copy.polish}
+ </TabsTrigger>
+ <TabsTrigger value="raw">{copy.original}</TabsTrigger>
+ </TabsList>
+ </Tabs>
+ )}
+ <textarea
+ value={reviewText}
+ onChange={(e) => setEdited(e.target.value)}
+ className="min-h-0 flex-1 resize-none rounded-lg border border-surface-border bg-surface p-3 text-body-lg leading-relaxed outline-none focus:border-brand focus:ring-2 focus:ring-ring/20"
+ />
+ <div className="flex items-center justify-end gap-2">
+ <Button variant="outline" onClick={() => onInsert(reviewText)}>
+ {copy.insert}
+ </Button>
+ <Button onClick={() => onSend(reviewText)}>
+ <ArrowUp />
+ {copy.send}
+ </Button>
+ </div>
+ </div>
+ ) : (
+ <>
+ <div className="flex flex-col items-center pt-6">
+ <Orb levels={session.levels} phase={phase} />
+ </div>
+ <div className="min-h-0 flex-1 overflow-y-auto px-6 pb-4">
+ {phase === "error" && session.error ? (
+ <p className="text-center text-body text-destructive">{errorMessage(session.error, copy)}</p>
+ ) : session.finalText || session.interimText ? (
+ <p className="text-title-sm leading-relaxed">
+ <LiveTranscript
+ finalText={session.finalText}
+ interimText={session.interimText}
+ caret={phase === "listening"}
+ />
+ </p>
+ ) : (
+ <p className="text-center text-title-sm text-faint-foreground">{copy.speakNow}</p>
+ )}
+ </div>
+ <div className="flex items-center justify-between gap-2 border-t px-4 py-3">
+ <label className="flex cursor-pointer items-center gap-2 text-caption text-muted-foreground">
+ <Switch size="sm" checked={polishOn} onCheckedChange={onPolishChange} />
+ <Sparkles className="size-3.5" />
+ {copy.polish}
+ </label>
+ <div className="flex items-center gap-2">
+ {phase === "error" ? (
+ <Button variant="outline" onClick={session.start}>
+ {copy.retry}
+ </Button>
+ ) : (
+ <IconButton
+ variant="outline"
+ size="icon"
+ label={phase === "paused" ? copy.resume : copy.pause}
+ disabled={phase !== "listening" && phase !== "paused"}
+ onClick={phase === "paused" ? session.resume : session.pause}
+ >
+ {phase === "paused" ? <Play /> : <Pause />}
+ </IconButton>
+ )}
+ <Button variant="brand" onClick={onDone} disabled={phase !== "listening" && phase !== "paused"}>
+ <Check />
+ {copy.done}
+ </Button>
+ </div>
+ </div>
+ </>
+ )}
+ </div>
+ );
+}
+
+/**
+ * D. Focus mode — for thinking out loud. The mic opens a full-panel listening
+ * space: a level-reactive orb, the transcript in large type, pause, and a
+ * review step that offers the polished and the original text side by side.
+ */
+export function FocusMode({
+ frozen,
+ frozenReview = null,
+ initialOpen = false,
+}: {
+ frozen?: VoiceSession;
+ frozenReview?: FocusReview | null;
+ initialOpen?: boolean;
+}) {
+ const { lang, source, copy } = useStoryEnv();
+ const [polishOn, setPolishOn] = useState(true);
+ const live = useVoiceSession({ source, lang, script: CHAT_SCRIPT[lang], polish: true, processingMs: 1300 });
+ const session = frozen ?? live;
+ const chat = useDemoChat();
+ const [draft, setDraft] = useState("");
+ const [open, setOpen] = useState(initialOpen);
+ const [liveReview, setReview] = useState<FocusReview | null>(null);
+ const review = frozen ? frozenReview : liveReview;
+
+ useEffect(() => {
+ if (frozen || session.phase !== "done") return;
+ setReview({ raw: session.finalText, polished: polishOn ? session.result : session.finalText });
+ session.reset();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [session.phase]);
+
+ const openPanel = () => {
+ setOpen(true);
+ setReview(null);
+ session.start();
+ };
+ const close = () => {
+ session.cancel();
+ setReview(null);
+ setOpen(false);
+ };
+
+ useWindowKeys(
+ {
+ down: (e) => {
+ if (isToggleChord(e)) {
+ e.preventDefault();
+ if (!open) openPanel();
+ else if (session.phase === "listening" || session.phase === "paused") session.stop();
+ } else if (e.key === "Escape" && open) {
+ close();
+ } else if (e.code === "Space" && open && !review && !e.metaKey && !e.ctrlKey) {
+ e.preventDefault();
+ if (session.phase === "listening") session.pause();
+ else if (session.phase === "paused") session.resume();
+ }
+ },
+ },
+ !frozen,
+ );
+
+ const send = (text: string, viaVoice = false) => {
+ chat.send(text, viaVoice);
+ setDraft("");
+ };
+
+ return (
+ <ChatWindowFrame
+ messages={chat.messages}
+ overlay={
+ open ? (
+ <FocusPanel
+ session={session}
+ review={review}
+ polishOn={polishOn}
+ onPolishChange={setPolishOn}
+ onClose={close}
+ onDone={session.stop}
+ onInsert={(text) => {
+ setDraft(appendDictation(draft, text, lang));
+ setReview(null);
+ setOpen(false);
+ }}
+ onSend={(text) => {
+ send(appendDictation(draft, text, lang), true);
+ setReview(null);
+ setOpen(false);
+ }}
+ />
+ ) : null
+ }
+ >
+ <ComposerSurface
+ left={
+ <>
+ <AddButton />
+ <AgentPicker />
+ </>
+ }
+ right={
+ <>
+ <MicButton label={copy.dictate} onClick={openPanel} />
+ <SendButton disabled={!draft.trim()} onClick={() => send(draft)} />
+ </>
+ }
+ >
+ <DraftEditor value={draft} onChange={setDraft} placeholder={copy.placeholder} onSubmit={() => send(draft)} />
+ </ComposerSurface>
+ </ChatWindowFrame>
+ );
+}
diff --git a/apps/storybook/src/voice-input/concepts/info.ts b/apps/storybook/src/voice-input/concepts/info.ts
new file mode 100644
index 0000000000..9a7a63366b
--- /dev/null
+++ b/apps/storybook/src/voice-input/concepts/info.ts
@@ -0,0 +1,84 @@
+import type { ConceptInfo } from "../stage";
+
+export const INLINE_WAVEFORM: ConceptInfo = {
+ letter: "A",
+ name: { en: "Inline waveform", zh: "工具栏波形" },
+ pitch: {
+ en: "The toolbar turns into a recording strip. Text arrives when you stop, so you review it before it goes anywhere.",
+ zh: "点麦克风后,输入框底部的工具栏变成录音条。停止后文字才落进草稿,发送前可以先看一遍。",
+ },
+ how: {
+ en: ["Click the mic, or press ⌘⇧Space", "✓ or ⌘⇧Space stops and inserts", "↑ or Enter stops and sends", "Esc or × throws it away"],
+ zh: ["点麦克风,或按 ⌘⇧Space", "✓ 或 ⌘⇧Space:停止并插入草稿", "↑ 或 Enter:停止并直接发送", "Esc 或 ×:丢弃"],
+ },
+ bestFor: { en: "Everyday messages. Familiar from ChatGPT and Claude.", zh: "日常发消息。和 ChatGPT、Claude 的做法一致,用户无需学习。" },
+ tradeoff: {
+ en: "You can't see words while talking, so long dictation feels blind.",
+ zh: "说话时看不到文字,长段口述时心里没底。",
+ },
+};
+
+export const LIVE_DICTATION: ConceptInfo = {
+ letter: "B",
+ name: { en: "Live dictation", zh: "实时上屏" },
+ pitch: {
+ en: "Nothing changes shape. Words stream into the draft as you speak; uncertain words stay grey until they settle. An optional Polish cleans it up afterwards.",
+ zh: "界面不变形。边说边上屏,还没确定的词显示为灰色,确定后变黑。说完可以一键「润色」。",
+ },
+ how: {
+ en: ["Click the mic, or press ⌘⇧Space", "Click the level meter or press Esc to stop", "Enter stops and sends", "After stopping, try Polish"],
+ zh: ["点麦克风,或按 ⌘⇧Space", "点跳动的音量条或按 Esc 停止", "Enter:停止并发送", "停止后试试「润色」"],
+ },
+ bestFor: { en: "People who think while they talk and want to see it land.", zh: "边想边说、需要看着文字上屏的人。" },
+ tradeoff: {
+ en: "Raw speech is messy on screen; needs a good streaming recognizer.",
+ zh: "口语原文直接上屏会比较乱;依赖流式识别的质量。",
+ },
+};
+
+export const PUSH_TO_TALK: ConceptInfo = {
+ letter: "C",
+ name: { en: "Push-to-talk", zh: "按住说话" },
+ pitch: {
+ en: "Hold a key anywhere and talk; let go and the text lands in the draft. A small HUD is the only sign it's listening. Tap instead of hold to lock it hands-free.",
+ zh: "在任何地方按住快捷键说话,松开文字就落进草稿。只有一个小浮层提示正在听。轻点而不是按住,就锁定为免手持模式。",
+ },
+ how: {
+ en: ["Hold ⌥Space (or press and hold the mic), talk, release", "Tap the mic once to lock; tap ■ to stop", "Esc while holding cancels"],
+ zh: ["按住 ⌥Space(或按住麦克风按钮)说话,松开", "轻点麦克风一下即锁定,点 ■ 停止", "按住时按 Esc 取消"],
+ },
+ bestFor: { en: "Power users and the desktop app, where it can become a global shortcut.", zh: "重度用户和桌面端,可以做成全局快捷键。" },
+ tradeoff: { en: "Hidden until you learn the shortcut.", zh: "不学快捷键就发现不了。" },
+};
+
+export const FOCUS_MODE: ConceptInfo = {
+ letter: "D",
+ name: { en: "Focus mode", zh: "专注模式" },
+ pitch: {
+ en: "The mic opens a full-panel listening space: an orb that breathes with your voice, the transcript in large type, pause, and a review step with polished and original side by side.",
+ zh: "麦克风打开一个整面板的聆听空间:随声音起伏的圆、大字号实时文字、可暂停,最后有一个审阅步骤,润色版和原文可以切换对比。",
+ },
+ how: {
+ en: ["Click the mic, or press ⌘⇧Space", "Space pauses and resumes", "Done → review → Insert or Send", "Toggle Polish before you finish"],
+ zh: ["点麦克风,或按 ⌘⇧Space", "空格键暂停 / 继续", "完成 → 审阅 → 插入或发送", "结束前可以开关「润色」"],
+ },
+ bestFor: { en: "Long briefs to an agent: specs, bug reports, thinking out loud.", zh: "给智能体口述长需求:规格、Bug 描述、边想边说。" },
+ tradeoff: { en: "Covers the conversation; too heavy for a one-liner.", zh: "会盖住对话;一句话的场景太重。" },
+};
+
+export const SEND_SLOT: ConceptInfo = {
+ letter: "E",
+ name: { en: "Hold the send button", zh: "按住发送键" },
+ pitch: {
+ en: "The messenger pattern. With an empty draft the send button is a mic: hold to talk, release to send, slide left to cancel, slide up to lock.",
+ zh: "即时通讯的做法。草稿为空时,发送键就是麦克风:按住说话,松开发送,左滑取消,上滑锁定。",
+ },
+ how: {
+ en: ["Clear the draft; the send button becomes a mic", "Press and hold it, talk, release to send", "While holding: drag left to cancel, drag up to lock", "Tap once to lock hands-free"],
+ zh: ["草稿为空时发送键变成麦克风", "按住说话,松开直接发送", "按住时:向左拖取消,向上拖锁定", "轻点一下也可以锁定"],
+ },
+ bestFor: { en: "Mobile and the compact floating chat, where space is tight.", zh: "移动端和小尺寸的悬浮聊天窗,空间紧张的地方。" },
+ tradeoff: { en: "Sends without review; drag gestures are awkward with a mouse.", zh: "不经审阅直接发出;用鼠标做拖拽手势比较别扭。" },
+};
+
+export const ALL_CONCEPTS = [INLINE_WAVEFORM, LIVE_DICTATION, PUSH_TO_TALK, FOCUS_MODE, SEND_SLOT];
diff --git a/apps/storybook/src/voice-input/concepts/inline-waveform.tsx b/apps/storybook/src/voice-input/concepts/inline-waveform.tsx
new file mode 100644
index 0000000000..9aae7b63a4
--- /dev/null
+++ b/apps/storybook/src/voice-input/concepts/inline-waveform.tsx
@@ -0,0 +1,170 @@
+import { useState } from "react";
+import { ArrowUp, Check, Mic, X } from "@multica/ui/icons";
+import { Button } from "@multica/ui/components/ui/button";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { Kbd, KbdGroup } from "@multica/ui/components/ui/kbd";
+import { cn } from "@multica/ui/lib/utils";
+import { CHAT_SCRIPT } from "../copy";
+import { useStoryEnv } from "../env";
+import { AddButton, AgentPicker, ChatWindowFrame, ComposerSurface, DraftEditor, SendButton, useDemoChat } from "../chat-frame";
+import { Elapsed, InlineVoiceError, RecDot, Shimmer, Waveform } from "../primitives";
+import { isToggleChord, useDictationCommit, useWindowKeys } from "../use-dictation";
+import { useVoiceSession, type VoiceSession, type VoiceSessionOptions } from "../voice-session";
+
+export const TOGGLE_KEYS = (
+ <KbdGroup>
+ <Kbd>⌘</Kbd>
+ <Kbd>⇧</Kbd>
+ <Kbd>Space</Kbd>
+ </KbdGroup>
+);
+
+export function MicButton({ onClick, label }: { onClick?: () => void; label: string }) {
+ return (
+ <IconButton label={label} shortcut={TOGGLE_KEYS} onClick={onClick} className="text-muted-foreground">
+ <Mic />
+ </IconButton>
+ );
+}
+
+/**
+ * A. Inline waveform — the toolbar becomes a recording strip. Stop with ✓ to
+ * review the text in the draft, or ↑ to send it as is.
+ */
+export function InlineWaveform({
+ frozen,
+ initialDraft = "",
+ framed = true,
+ simulate,
+}: {
+ frozen?: VoiceSession;
+ initialDraft?: string;
+ framed?: boolean;
+ /** Walk through permission and failure paths with the simulated speaker. */
+ simulate?: Pick<VoiceSessionOptions, "failWith" | "permission">;
+}) {
+ const { lang, source, copy } = useStoryEnv();
+ const live = useVoiceSession({ source, lang, script: CHAT_SCRIPT[lang], processingMs: 1100, ...simulate });
+ const session = frozen ?? live;
+ const chat = useDemoChat();
+ const [draft, setDraft] = useState(initialDraft);
+ const { stopAnd, landed } = useDictationCommit(session, {
+ lang,
+ draft,
+ setDraft,
+ send: chat.send,
+ enabled: !frozen,
+ });
+
+ const { phase } = session;
+ const recording = phase === "listening";
+
+ useWindowKeys(
+ {
+ down: (e) => {
+ if (isToggleChord(e)) {
+ e.preventDefault();
+ if (recording) stopAnd("insert");
+ else if (phase === "idle" || phase === "error") session.start();
+ } else if (e.key === "Escape" && (recording || phase === "requesting")) {
+ session.cancel();
+ } else if (e.key === "Enter" && recording) {
+ e.preventDefault();
+ stopAnd("send");
+ }
+ },
+ },
+ !frozen,
+ );
+
+ let bottom = null;
+ if (phase === "requesting") {
+ bottom = (
+ <>
+ <IconButton label={copy.cancel} onClick={session.cancel} className="text-muted-foreground">
+ <X />
+ </IconButton>
+ <Shimmer className="flex-1 pl-1">{copy.requestingTitle}…</Shimmer>
+ </>
+ );
+ } else if (recording) {
+ bottom = (
+ <>
+ <IconButton label={copy.cancel} shortcut={<Kbd>Esc</Kbd>} onClick={session.cancel} className="text-muted-foreground">
+ <X />
+ </IconButton>
+ <span className="flex items-center gap-1.5 pl-1 pr-2">
+ <RecDot />
+ <Elapsed ms={session.elapsedMs} />
+ </span>
+ <Waveform levels={session.levels} bars={64} className="min-w-0 flex-1 overflow-hidden text-foreground" />
+ <IconButton label={copy.done} shortcut={TOGGLE_KEYS} onClick={() => stopAnd("insert")} className="ml-1 text-foreground">
+ <Check />
+ </IconButton>
+ <Button
+ size="icon-sm"
+ // eslint-disable-next-line no-restricted-syntax -- composer send button, the one round button
+ className="rounded-full"
+ aria-label={copy.send}
+ onClick={() => stopAnd("send")}
+ >
+ <ArrowUp />
+ </Button>
+ </>
+ );
+ } else if (phase === "processing") {
+ bottom = (
+ <>
+ <span className="flex size-[var(--button-height-sm)] items-center justify-center">
+ <Mic className="size-4 text-muted-foreground" />
+ </span>
+ <Shimmer className="flex-1 pl-1">{copy.transcribing}…</Shimmer>
+ </>
+ );
+ }
+
+ const composer = (
+ <ComposerSurface
+ active={recording}
+ above={
+ phase === "error" && session.error ? (
+ <InlineVoiceError error={session.error} copy={copy} onRetry={session.retry} onDismiss={session.cancel} />
+ ) : undefined
+ }
+ bottom={bottom}
+ left={
+ <>
+ <AddButton />
+ <AgentPicker />
+ </>
+ }
+ right={
+ bottom ? undefined : <>
+ <MicButton label={copy.dictate} onClick={session.start} />
+ <SendButton
+ disabled={!draft.trim()}
+ onClick={() => {
+ chat.send(draft);
+ setDraft("");
+ }}
+ />
+ </>
+ }
+ >
+ <div key={landed} className={cn(landed > 0 && "voice-landed")}>
+ <DraftEditor
+ value={draft}
+ onChange={setDraft}
+ placeholder={copy.placeholder}
+ onSubmit={() => {
+ chat.send(draft);
+ setDraft("");
+ }}
+ />
+ </div>
+ </ComposerSurface>
+ );
+
+ if (!framed) return <div className="w-[460px]">{composer}</div>;
+ return <ChatWindowFrame messages={chat.messages}>{composer}</ChatWindowFrame>;
+}
diff --git a/apps/storybook/src/voice-input/concepts/live-dictation.tsx b/apps/storybook/src/voice-input/concepts/live-dictation.tsx
new file mode 100644
index 0000000000..a1856dba50
--- /dev/null
+++ b/apps/storybook/src/voice-input/concepts/live-dictation.tsx
@@ -0,0 +1,176 @@
+import { useEffect, useState } from "react";
+import { Sparkles } from "@multica/ui/icons";
+import { Button } from "@multica/ui/components/ui/button";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { Kbd } from "@multica/ui/components/ui/kbd";
+import { cn } from "@multica/ui/lib/utils";
+import { CHAT_SCRIPT } from "../copy";
+import { appendDictation, useStoryEnv } from "../env";
+import { AddButton, AgentPicker, ChatWindowFrame, ComposerSurface, DraftEditor, SendButton, useDemoChat } from "../chat-frame";
+import { Elapsed, InlineVoiceError, LevelBars, LiveTranscript, RecDot, Shimmer } from "../primitives";
+import { isToggleChord, useDictationCommit, useWindowKeys } from "../use-dictation";
+import { useVoiceSession, type VoiceSession } from "../voice-session";
+import { MicButton, TOGGLE_KEYS } from "./inline-waveform";
+
+/**
+ * B. Live dictation — nothing changes shape. Words stream into the draft
+ * where you are typing; uncertain words stay muted until the recognizer
+ * commits them. A Polish chip offers an optional cleanup afterwards.
+ */
+export function LiveDictation({
+ frozen,
+ initialDraft = "",
+ framed = true,
+ showPolish,
+}: {
+ frozen?: VoiceSession;
+ initialDraft?: string;
+ framed?: boolean;
+ /** Pin the post-dictation Polish chip, for the state gallery. */
+ showPolish?: boolean;
+}) {
+ const { lang, source, copy } = useStoryEnv();
+ const script = CHAT_SCRIPT[lang];
+ const live = useVoiceSession({ source, lang, script, processingMs: 200 });
+ const session = frozen ?? live;
+ const chat = useDemoChat();
+ const [draft, setDraft] = useState(initialDraft);
+ const { stopAnd, lastInsert, clearLastInsert } = useDictationCommit(session, {
+ lang,
+ draft,
+ setDraft,
+ send: chat.send,
+ enabled: !frozen,
+ });
+ const [polishing, setPolishing] = useState(false);
+
+ // The chip is an offer, not a mode: it leaves once you type or after a while.
+ useEffect(() => {
+ if (!lastInsert) return;
+ const id = window.setTimeout(clearLastInsert, 8000);
+ return () => window.clearTimeout(id);
+ }, [lastInsert, clearLastInsert]);
+
+ const { phase } = session;
+ const capturing = phase === "listening" || phase === "requesting";
+
+ useWindowKeys(
+ {
+ down: (e) => {
+ if (isToggleChord(e)) {
+ e.preventDefault();
+ if (phase === "listening") stopAnd("insert");
+ else if (phase === "idle" || phase === "error") session.start();
+ } else if (e.key === "Escape" && capturing) {
+ stopAnd("insert");
+ } else if (e.key === "Enter" && phase === "listening") {
+ e.preventDefault();
+ stopAnd("send");
+ }
+ },
+ },
+ !frozen,
+ );
+
+ const polish = () => {
+ if (!lastInsert) return;
+ setPolishing(true);
+ window.setTimeout(() => {
+ const raw = lastInsert.raw.trim();
+ const polished = raw === script.phrases.join("").trim() ? script.polished : raw.replace(/^(um,?\s*|嗯,?)/i, "");
+ setDraft(appendDictation(lastInsert.before, polished, lang));
+ setPolishing(false);
+ clearLastInsert();
+ }, 900);
+ };
+
+ const showChip = showPolish || (!!lastInsert && phase === "idle");
+
+ const send = () => {
+ chat.send(draft);
+ setDraft("");
+ clearLastInsert();
+ };
+
+ const composer = (
+ <ComposerSurface
+ active={capturing}
+ above={
+ phase === "error" && session.error ? (
+ <InlineVoiceError error={session.error} copy={copy} onRetry={session.retry} onDismiss={session.cancel} />
+ ) : undefined
+ }
+ left={
+ capturing ? (
+ <span className="flex h-7 items-center gap-1.5 pl-1.5 text-caption">
+ <RecDot />
+ {phase === "requesting" ? (
+ <Shimmer>{copy.requestingTitle}…</Shimmer>
+ ) : (
+ <>
+ <span className="font-medium text-foreground">{copy.listening}</span>
+ <Elapsed ms={session.elapsedMs} />
+ <span className="pl-1 text-faint-foreground">·</span>
+ <Kbd>Esc</Kbd>
+ <span className="text-muted-foreground">{copy.done}</span>
+ </>
+ )}
+ </span>
+ ) : (
+ <>
+ <AddButton />
+ <AgentPicker />
+ {showChip && (
+ <Button
+ size="xs"
+ variant="brandSubtle"
+ className="ml-1 animate-in fade-in slide-in-from-left-1"
+ onClick={polish}
+ disabled={polishing}
+ >
+ <Sparkles />
+ {polishing ? <Shimmer className="text-caption">{copy.polishing}…</Shimmer> : copy.polish}
+ </Button>
+ )}
+ </>
+ )
+ }
+ right={
+ <>
+ {capturing ? (
+ <IconButton
+ label={copy.stop}
+ shortcut={TOGGLE_KEYS}
+ onClick={() => (phase === "requesting" ? session.cancel() : stopAnd("insert"))}
+ className="bg-brand/10 text-brand hover:bg-brand/15 hover:text-brand"
+ >
+ <LevelBars levels={session.levels} />
+ </IconButton>
+ ) : (
+ <MicButton label={copy.dictate} onClick={session.start} />
+ )}
+ <SendButton disabled={!draft.trim() && !capturing} onClick={() => (capturing ? stopAnd("send") : send())} />
+ </>
+ }
+ >
+ {capturing || phase === "processing" ? (
+ <div className="min-h-5 text-body">
+ {draft}
+ {draft && session.finalText + session.interimText && lang === "en" ? " " : ""}
+ {phase === "requesting" && !draft ? (
+ <span className="text-muted-foreground">{copy.speakNow}</span>
+ ) : (
+ <LiveTranscript finalText={session.finalText} interimText={session.interimText} />
+ )}
+ </div>
+ ) : (
+ <div className={cn(polishing && "opacity-60 transition-opacity")}>
+ <DraftEditor value={draft} onChange={(v) => { setDraft(v); clearLastInsert(); }} placeholder={copy.placeholder} onSubmit={send} />
+ </div>
+ )}
+ </ComposerSurface>
+ );
+
+ if (!framed) return <div className="w-[460px]">{composer}</div>;
+ return <ChatWindowFrame messages={chat.messages}>{composer}</ChatWindowFrame>;
+}
diff --git a/apps/storybook/src/voice-input/concepts/push-to-talk.tsx b/apps/storybook/src/voice-input/concepts/push-to-talk.tsx
new file mode 100644
index 0000000000..c9c789b4b8
--- /dev/null
+++ b/apps/storybook/src/voice-input/concepts/push-to-talk.tsx
@@ -0,0 +1,230 @@
+import { useRef, useState } from "react";
+import { Lock, Mic, Square } from "@multica/ui/icons";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { Kbd, KbdGroup } from "@multica/ui/components/ui/kbd";
+import { cn } from "@multica/ui/lib/utils";
+import { CHAT_SCRIPT } from "../copy";
+import { useStoryEnv } from "../env";
+import { AddButton, AgentPicker, ChatWindowFrame, ComposerSurface, DraftEditor, SendButton, useDemoChat } from "../chat-frame";
+import { InlineVoiceError, RecDot, Waveform, formatElapsed } from "../primitives";
+import { useDictationCommit, useWindowKeys } from "../use-dictation";
+import { useVoiceSession, type VoiceSession } from "../voice-session";
+
+const HOLD_KEYS = (
+ <KbdGroup>
+ <Kbd>⌥</Kbd>
+ <Kbd>Space</Kbd>
+ </KbdGroup>
+);
+
+/** A short press is a tap (lock hands-free); a longer one is push-to-talk. */
+const TAP_MS = 250;
+
+/**
+ * The HUD: always-dark ink, like a system indicator, so it reads the same over
+ * any page and in either theme.
+ */
+export function TalkHud({
+ session,
+ locked,
+ onStop,
+ hint,
+}: {
+ session: VoiceSession;
+ locked: boolean;
+ onStop: () => void;
+ hint: string;
+}) {
+ const { phase } = session;
+ const tail = (session.finalText + session.interimText).slice(-46);
+ return (
+ <div className="pointer-events-none absolute inset-x-0 bottom-[132px] z-20 flex flex-col items-center gap-2">
+ {tail && phase === "listening" && (
+ <div className="max-w-[80%] truncate rounded-md bg-multica-ink/80 px-2.5 py-1 text-caption text-multica-paper/80 backdrop-blur animate-in fade-in">
+ {(session.finalText + session.interimText).length > 46 ? "…" : ""}
+ {tail}
+ </div>
+ )}
+ <div
+ className={cn(
+ "pointer-events-auto flex h-10 items-center gap-2.5 rounded-full bg-multica-ink pl-3.5 text-multica-paper shadow-[var(--floating-shadow)] transition-[width] animate-in fade-in zoom-in-95 slide-in-from-bottom-2",
+ locked && phase === "listening" ? "pr-1.5" : "pr-4",
+ )}
+ >
+ {phase === "processing" ? (
+ <>
+ <Mic className="size-4 opacity-70" />
+ <span className="voice-shimmer text-caption font-medium [--foreground:#fff] [--muted-foreground:rgb(255_255_255/0.5)]">
+ {hint}
+ </span>
+ </>
+ ) : phase === "requesting" ? (
+ <>
+ <Mic className="size-4 opacity-70" />
+ <span className="text-caption opacity-80">{hint}</span>
+ </>
+ ) : (
+ <>
+ <RecDot className="bg-[#ff5a52]" />
+ <Waveform levels={session.levels} bars={28} className="h-5 w-[86px]" />
+ <span className="text-caption tabular-nums opacity-70">{formatElapsed(session.elapsedMs)}</span>
+ {locked ? (
+ <button
+ type="button"
+ aria-label="Stop"
+ onClick={onStop}
+ // eslint-disable-next-line no-restricted-syntax -- the HUD's stop control mirrors the composer send/stop button
+ className="flex size-7 cursor-pointer items-center justify-center rounded-full bg-multica-paper text-multica-ink transition-transform active:scale-95"
+ >
+ <Square className="size-3 fill-current" />
+ </button>
+ ) : (
+ <span className="text-caption opacity-70">{hint}</span>
+ )}
+ </>
+ )}
+ </div>
+ </div>
+ );
+}
+
+/**
+ * C. Push-to-talk — hold ⌥Space (or press and hold the mic) and talk; let go
+ * to drop the text into the draft. Tap instead of hold to lock it hands-free.
+ */
+export function PushToTalk({
+ frozen,
+ frozenLocked = false,
+ initialDraft = "",
+}: {
+ frozen?: VoiceSession;
+ frozenLocked?: boolean;
+ initialDraft?: string;
+}) {
+ const { lang, source, copy } = useStoryEnv();
+ const live = useVoiceSession({ source, lang, script: CHAT_SCRIPT[lang], processingMs: 700 });
+ const session = frozen ?? live;
+ const chat = useDemoChat();
+ const [draft, setDraft] = useState(initialDraft);
+ const { stopAnd, landed } = useDictationCommit(session, { lang, draft, setDraft, send: chat.send, enabled: !frozen });
+ const [lockedState, setLocked] = useState(false);
+ const locked = frozen ? frozenLocked : lockedState;
+ const pressRef = useRef<{ at: number; via: "key" | "pointer" } | null>(null);
+ const { phase } = session;
+
+ const press = (via: "key" | "pointer") => {
+ if (phase === "listening" && locked) {
+ setLocked(false);
+ stopAnd("insert");
+ return;
+ }
+ if (phase !== "idle" && phase !== "error") return;
+ pressRef.current = { at: performance.now(), via };
+ setLocked(false);
+ session.start();
+ };
+
+ const release = () => {
+ const p = pressRef.current;
+ pressRef.current = null;
+ if (!p) return;
+ if (performance.now() - p.at < TAP_MS) {
+ setLocked(true);
+ return;
+ }
+ stopAnd("insert");
+ };
+
+ useWindowKeys(
+ {
+ down: (e) => {
+ if (e.code === "Space" && e.altKey && !e.repeat) {
+ e.preventDefault();
+ press("key");
+ } else if (e.key === "Escape" && (phase === "listening" || phase === "requesting")) {
+ pressRef.current = null;
+ setLocked(false);
+ session.cancel();
+ }
+ },
+ up: (e) => {
+ if (pressRef.current?.via === "key" && (e.code === "Space" || e.key === "Alt")) release();
+ },
+ },
+ !frozen,
+ );
+
+ const hudVisible = phase === "listening" || phase === "processing" || phase === "requesting";
+ const hudHint =
+ phase === "processing" ? `${copy.transcribing}…` : phase === "requesting" ? `${copy.requestingTitle}…` : copy.releaseToInsert;
+
+ const send = () => {
+ chat.send(draft);
+ setDraft("");
+ };
+
+ return (
+ <ChatWindowFrame
+ messages={chat.messages}
+ overlay={
+ hudVisible ? (
+ <TalkHud
+ session={session}
+ locked={locked}
+ hint={hudHint}
+ onStop={() => {
+ setLocked(false);
+ stopAnd("insert");
+ }}
+ />
+ ) : null
+ }
+ >
+ <ComposerSurface
+ above={
+ phase === "error" && session.error ? (
+ <InlineVoiceError error={session.error} copy={copy} onRetry={() => press("pointer")} onDismiss={session.cancel} />
+ ) : undefined
+ }
+ left={
+ <>
+ <AddButton />
+ <AgentPicker />
+ </>
+ }
+ right={
+ <>
+ <IconButton
+ label={phase === "listening" && locked ? copy.stop : copy.holdToTalk}
+ shortcut={HOLD_KEYS}
+ onPointerDown={(e) => {
+ e.currentTarget.setPointerCapture(e.pointerId);
+ press("pointer");
+ }}
+ onPointerUp={() => pressRef.current?.via === "pointer" && release()}
+ className={cn(
+ "touch-none text-muted-foreground",
+ phase === "listening" && "bg-brand/10 text-brand hover:bg-brand/15 hover:text-brand",
+ )}
+ >
+ {phase === "listening" && locked ? <Lock /> : <Mic />}
+ </IconButton>
+ <SendButton disabled={!draft.trim()} onClick={send} />
+ </>
+ }
+ >
+ <div key={landed} className={cn(landed > 0 && "voice-landed")}>
+ <DraftEditor value={draft} onChange={setDraft} placeholder={copy.placeholder} onSubmit={send} />
+ </div>
+ </ComposerSurface>
+ {phase === "idle" && !draft && (
+ <div className="pointer-events-none absolute inset-x-0 bottom-[118px] flex justify-center">
+ <span className="flex items-center gap-1.5 text-caption text-faint-foreground">
+ {copy.holdToTalk}
+ {HOLD_KEYS}
+ </span>
+ </div>
+ )}
+ </ChatWindowFrame>
+ );
+}
diff --git a/apps/storybook/src/voice-input/concepts/send-slot.tsx b/apps/storybook/src/voice-input/concepts/send-slot.tsx
new file mode 100644
index 0000000000..af343b67c6
--- /dev/null
+++ b/apps/storybook/src/voice-input/concepts/send-slot.tsx
@@ -0,0 +1,247 @@
+import { useRef, useState, type PointerEvent } from "react";
+import { ArrowUp, ChevronLeft, ChevronUp, Loader2, Lock, Mic, Trash2 } from "@multica/ui/icons";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { cn } from "@multica/ui/lib/utils";
+import { CHAT_SCRIPT } from "../copy";
+import { useStoryEnv } from "../env";
+import { AddButton, AgentPicker, ChatWindowFrame, ComposerSurface, DraftEditor, SendButton, useDemoChat } from "../chat-frame";
+import { Elapsed, InlineVoiceError, RecDot, Shimmer, Waveform } from "../primitives";
+import { useDictationCommit, useWindowKeys } from "../use-dictation";
+import { useVoiceSession, type VoiceSession } from "../voice-session";
+
+const CANCEL_DX = -110;
+const LOCK_DY = -56;
+const TAP_MS = 250;
+
+/**
+ * E. Hold the send button — the messenger pattern. With an empty draft the
+ * send slot is a mic: hold to talk, release to send, slide left to cancel,
+ * slide up to lock and keep talking hands-free.
+ */
+export function SendSlot({
+ frozen,
+ frozenDrag = { dx: 0, dy: 0 },
+ frozenLocked = false,
+ initialDraft = "",
+}: {
+ frozen?: VoiceSession;
+ frozenDrag?: { dx: number; dy: number };
+ frozenLocked?: boolean;
+ initialDraft?: string;
+}) {
+ const { lang, source, copy } = useStoryEnv();
+ const live = useVoiceSession({ source, lang, script: CHAT_SCRIPT[lang], polish: true, processingMs: 900 });
+ const session = frozen ?? live;
+ const chat = useDemoChat();
+ const [draft, setDraft] = useState(initialDraft);
+ const { stopAnd } = useDictationCommit(session, { lang, draft, setDraft, send: chat.send, enabled: !frozen });
+ const [dragState, setDrag] = useState({ dx: 0, dy: 0 });
+ const [lockedState, setLocked] = useState(false);
+ const drag = frozen ? frozenDrag : dragState;
+ const locked = frozen ? frozenLocked : lockedState;
+ const pressRef = useRef<{ x: number; y: number; at: number } | null>(null);
+ const { phase } = session;
+ const recording = phase === "listening" || phase === "requesting";
+
+ useWindowKeys(
+ {
+ down: (e) => {
+ if (e.key === "Escape" && recording) {
+ pressRef.current = null;
+ setLocked(false);
+ setDrag({ dx: 0, dy: 0 });
+ session.cancel();
+ }
+ },
+ },
+ !frozen,
+ );
+
+ const onPointerDown = (e: PointerEvent<HTMLButtonElement>) => {
+ if (phase !== "idle" && phase !== "error") return;
+ e.currentTarget.setPointerCapture(e.pointerId);
+ pressRef.current = { x: e.clientX, y: e.clientY, at: performance.now() };
+ setLocked(false);
+ session.start();
+ };
+ const onPointerMove = (e: PointerEvent<HTMLButtonElement>) => {
+ const p = pressRef.current;
+ if (!p || locked) return;
+ const dx = Math.min(0, e.clientX - p.x);
+ const dy = Math.min(0, e.clientY - p.y);
+ if (dx < CANCEL_DX) {
+ pressRef.current = null;
+ setDrag({ dx: 0, dy: 0 });
+ session.cancel();
+ return;
+ }
+ if (dy < LOCK_DY) {
+ pressRef.current = null;
+ setDrag({ dx: 0, dy: 0 });
+ setLocked(true);
+ return;
+ }
+ // Commit to one axis, the way a thumb does.
+ setDrag(Math.abs(dx) > Math.abs(dy) ? { dx, dy: 0 } : { dx: 0, dy });
+ };
+ const onPointerUp = () => {
+ const p = pressRef.current;
+ pressRef.current = null;
+ setDrag({ dx: 0, dy: 0 });
+ if (!p) return;
+ if (performance.now() - p.at < TAP_MS) {
+ setLocked(true);
+ return;
+ }
+ stopAnd("send");
+ };
+
+ const send = () => {
+ chat.send(draft);
+ setDraft("");
+ };
+
+ const holding = recording && !locked;
+ const cancelProgress = Math.min(1, drag.dx / CANCEL_DX);
+ const lockProgress = Math.min(1, drag.dy / LOCK_DY);
+ const level = session.level;
+
+ let slot;
+ if (draft.trim() && phase === "idle") {
+ slot = <SendButton onClick={send} />;
+ } else if (phase === "processing") {
+ slot = (
+ <span className="flex size-[var(--button-height-sm)] items-center justify-center rounded-full bg-primary text-primary-foreground">
+ <Loader2 className="size-4 animate-spin" />
+ </span>
+ );
+ } else if (recording && locked) {
+ slot = (
+ <button
+ type="button"
+ aria-label={copy.send}
+ onClick={() => {
+ setLocked(false);
+ stopAnd("send");
+ }}
+ // eslint-disable-next-line no-restricted-syntax -- composer send button, the one round button
+ className="flex size-[var(--button-height-sm)] cursor-pointer items-center justify-center rounded-full bg-primary text-primary-foreground transition-transform active:scale-95"
+ >
+ <ArrowUp className="size-4.5" />
+ </button>
+ );
+ } else {
+ slot = (
+ <button
+ type="button"
+ aria-label={copy.holdToTalk}
+ title={copy.holdToTalk}
+ onPointerDown={onPointerDown}
+ onPointerMove={onPointerMove}
+ onPointerUp={onPointerUp}
+ onPointerCancel={onPointerUp}
+ className={cn(
+ // eslint-disable-next-line no-restricted-syntax -- composer send button, the one round button
+ "relative flex size-[var(--button-height-sm)] touch-none cursor-pointer select-none items-center justify-center rounded-full bg-primary text-primary-foreground transition-transform duration-150",
+ holding && "z-10 scale-[1.55] bg-brand text-brand-foreground",
+ )}
+ style={
+ holding
+ ? {
+ translate: `${drag.dx}px ${drag.dy}px`,
+ boxShadow: `0 0 0 ${2 + level * 9}px color-mix(in oklab, var(--brand) 22%, transparent)`,
+ }
+ : undefined
+ }
+ >
+ <Mic className="size-4" />
+ </button>
+ );
+ }
+
+ let editorArea;
+ let bottom;
+ if (recording) {
+ editorArea = (
+ <div className="flex h-5 items-center gap-2 pr-10">
+ <RecDot />
+ <Elapsed ms={session.elapsedMs} className="text-foreground" />
+ {locked ? (
+ <span className="ml-auto flex items-center gap-1 text-caption text-muted-foreground">
+ <Lock className="size-3" />
+ {copy.locked}
+ </span>
+ ) : (
+ <span
+ className="ml-auto flex items-center gap-0.5 text-caption text-muted-foreground"
+ style={{ translate: `${drag.dx * 0.6}px 0`, opacity: 1 - cancelProgress * 0.8 }}
+ >
+ <ChevronLeft className="size-3.5 animate-pulse" />
+ {copy.slideToCancel}
+ </span>
+ )}
+ </div>
+ );
+ bottom = (
+ <>
+ {locked ? (
+ <IconButton
+ label={copy.cancel}
+ onClick={() => {
+ setLocked(false);
+ session.cancel();
+ }}
+ className="text-muted-foreground"
+ >
+ <Trash2 />
+ </IconButton>
+ ) : (
+ <span className="w-1" />
+ )}
+ <Waveform
+ levels={session.levels}
+ bars={56}
+ className={cn("min-w-0 flex-1 overflow-hidden", cancelProgress > 0.5 ? "text-destructive" : "text-foreground")}
+ />
+ </>
+ );
+ } else if (phase === "processing") {
+ editorArea = <Shimmer className="text-body">{copy.transcribing}…</Shimmer>;
+ } else {
+ editorArea = <DraftEditor value={draft} onChange={setDraft} placeholder={copy.placeholder} onSubmit={send} />;
+ }
+
+ return (
+ <ChatWindowFrame messages={chat.messages}>
+ <div className="relative">
+ {holding && (
+ <div
+ className="pointer-events-none absolute bottom-[62px] right-[22px] z-20 flex w-9 flex-col items-center gap-1 rounded-full bg-popover py-2 text-muted-foreground shadow-[var(--floating-shadow)] ring-1 ring-floating-border animate-in fade-in slide-in-from-bottom-2"
+ style={{ translate: `0 ${drag.dy * 0.4}px` }}
+ >
+ <Lock className={cn("size-3.5 transition-colors", lockProgress > 0.6 && "text-brand")} />
+ <ChevronUp className="size-3.5 animate-bounce" />
+ </div>
+ )}
+ <ComposerSurface
+ active={recording}
+ above={
+ phase === "error" && session.error ? (
+ <InlineVoiceError error={session.error} copy={copy} onDismiss={session.cancel} />
+ ) : undefined
+ }
+ bottom={recording ? bottom : undefined}
+ left={
+ <>
+ <AddButton />
+ <AgentPicker />
+ </>
+ }
+ right={slot}
+ >
+ {editorArea}
+ </ComposerSurface>
+ </div>
+ </ChatWindowFrame>
+ );
+}
diff --git a/apps/storybook/src/voice-input/copy.ts b/apps/storybook/src/voice-input/copy.ts
new file mode 100644
index 0000000000..095d25f314
--- /dev/null
+++ b/apps/storybook/src/voice-input/copy.ts
@@ -0,0 +1,175 @@
+export type Lang = "en" | "zh";
+
+/** What the simulated speaker says, as the recognizer would chunk it. */
+export interface VoiceScript {
+ /** Phrases are committed as final text one at a time, like a recognizer's results. */
+ phrases: string[];
+ /** The cleaned-up text a polish pass would return. */
+ polished: string;
+}
+
+export const CHAT_SCRIPT: Record<Lang, VoiceScript> = {
+ en: {
+ phrases: [
+ "Um, can you look at why the inbox unread count",
+ " doesn't refresh after switching workspaces?",
+ " I think the query key is missing the workspace ID.",
+ " Please fix it, open a PR, and add a test.",
+ ],
+ polished:
+ "Can you look at why the inbox unread count doesn't refresh after switching workspaces? I think the query key is missing the workspace ID. Please fix it, open a PR, and add a test.",
+ },
+ zh: {
+ phrases: [
+ "嗯,帮我看一下切换工作区之后",
+ "收件箱未读数不刷新的问题,",
+ "我怀疑是 query key 里没带 workspace ID,",
+ "修一下然后开个 PR,顺便补个测试。",
+ ],
+ polished:
+ "帮我看一下切换工作区后收件箱未读数不刷新的问题。我怀疑是 query key 里没带 workspace ID,请修复后开个 PR,并补一个测试。",
+ },
+};
+
+export const COMMENT_SCRIPT: Record<Lang, VoiceScript> = {
+ en: {
+ phrases: [
+ "Um, I just reproduced it in the Design workspace,",
+ " switching back still shows 3,",
+ " a page refresh fixes it,",
+ " so it's the cache key.",
+ ],
+ polished:
+ "I just reproduced it in the Design workspace: switching back still shows 3 and a page refresh fixes it, so it's the cache key.",
+ },
+ zh: {
+ phrases: ["嗯,我刚在 Design 工作区复现了,", "切回来以后角标还是 3,", "刷新一下页面就好了,", "应该就是缓存 key 的问题。"],
+ polished: "我刚在 Design 工作区复现了:切回来以后角标还是 3,刷新页面后恢复正常,应该就是缓存 key 的问题。",
+ },
+};
+
+export const REPLY_SCRIPT: Record<Lang, VoiceScript> = {
+ en: {
+ phrases: ["Yes, it's the same one,", " have Lambda fix both."],
+ polished: "Yes, it's the same one. Have Lambda fix both.",
+ },
+ zh: {
+ phrases: ["对,是同一个,", "让 Lambda 顺便把那边也改了。"],
+ polished: "对,是同一个。让 Lambda 顺便把那边也改了。",
+ },
+};
+
+export const COPY = {
+ en: {
+ agentName: "Lambda",
+ sessionTitle: "Inbox badge after workspace switch",
+ placeholder: "Message Lambda…",
+ commentPlaceholder: "Leave a comment…",
+ dictate: "Dictate",
+ holdToTalk: "Hold to talk",
+ listening: "Listening",
+ speakNow: "Speak now…",
+ paused: "Paused",
+ stopped: "Stopped",
+ transcribing: "Transcribing",
+ polishing: "Polishing",
+ cancel: "Cancel",
+ done: "Done",
+ insert: "Insert",
+ send: "Send",
+ stop: "Stop",
+ pause: "Pause",
+ resume: "Resume",
+ retry: "Try again",
+ releaseToInsert: "Release to insert",
+ releaseToSend: "Release to send",
+ slideToCancel: "Slide left to cancel",
+ lockHint: "Slide up to lock",
+ locked: "Locked",
+ escToCancel: "to cancel",
+ enterToSend: "to send",
+ polish: "Polish",
+ original: "Original",
+ requestingTitle: "Allow microphone access",
+ requestingBody: "Your browser will ask for permission. Audio is only used to transcribe what you say.",
+ deniedTitle: "Microphone is blocked.",
+ deniedBody: "Allow microphone access in your browser's site settings, then try again.",
+ noSpeech: "Didn't catch that. Try speaking closer to the microphone.",
+ network: "Couldn't transcribe. Your recording is kept.",
+ you: "You",
+ userMessage: "The inbox badge still shows 3 after I switched to the Design workspace.",
+ agentReply:
+ "I can reproduce it. The unread count query is cached per user, not per workspace, so the old value sticks until a refetch. Want me to fix it?",
+ microphone: "MacBook Pro Microphone",
+ language: "Language",
+ voiceInput: "Voice input",
+ micTooltip: "Click to dictate, hold to talk",
+ replyPlaceholder: "Reply…",
+ activity: "Activity",
+ issueKey: "MUL-1342",
+ issueBody: "After switching from Multica to Design, the inbox badge keeps showing 3 until the page is refreshed.",
+ humanName: "Jiayuan",
+ humanComment: "Is this the same cache bug we fixed for issue counts?",
+ minutesAgo: "2m ago",
+ justNow: "just now",
+ willStart: "Starts after sending",
+ attach: "Attach file",
+ },
+ zh: {
+ agentName: "Lambda",
+ sessionTitle: "切换工作区后收件箱角标不更新",
+ placeholder: "给 Lambda 发消息…",
+ commentPlaceholder: "写评论…",
+ dictate: "语音输入",
+ holdToTalk: "按住说话",
+ listening: "正在听",
+ speakNow: "请说话…",
+ paused: "已暂停",
+ stopped: "已停止",
+ transcribing: "正在转写",
+ polishing: "正在润色",
+ cancel: "取消",
+ done: "完成",
+ insert: "插入",
+ send: "发送",
+ stop: "停止",
+ pause: "暂停",
+ resume: "继续",
+ retry: "重试",
+ releaseToInsert: "松开插入",
+ releaseToSend: "松开发送",
+ slideToCancel: "左滑取消",
+ lockHint: "上滑锁定",
+ locked: "已锁定",
+ escToCancel: "取消",
+ enterToSend: "发送",
+ polish: "润色",
+ original: "原文",
+ requestingTitle: "允许使用麦克风",
+ requestingBody: "浏览器会请求权限。音频只用于把你说的话转成文字。",
+ deniedTitle: "麦克风已被禁用。",
+ deniedBody: "请在浏览器的网站设置中允许麦克风,然后重试。",
+ noSpeech: "没有听清,请靠近麦克风再说一次。",
+ network: "转写失败,录音已保留。",
+ you: "你",
+ userMessage: "我切到 Design 工作区之后,收件箱角标还显示 3。",
+ agentReply:
+ "已复现。未读数的查询按用户缓存而不是按工作区缓存,所以在重新拉取之前旧值会一直保留。需要我修复吗?",
+ microphone: "MacBook Pro 麦克风",
+ language: "语言",
+ voiceInput: "语音输入",
+ micTooltip: "点按听写,按住说话",
+ replyPlaceholder: "回复…",
+ activity: "动态",
+ issueKey: "MUL-1342",
+ issueBody: "从 Multica 切到 Design 工作区后,收件箱角标一直显示 3,刷新页面才恢复。",
+ humanName: "Jiayuan",
+ humanComment: "这和之前 issue 计数那个缓存问题是同一个吗?",
+ minutesAgo: "2 分钟前",
+ justNow: "刚刚",
+ willStart: "发送后开始",
+ attach: "添加附件",
+ },
+} satisfies Record<Lang, Record<string, string>>;
+
+export type Copy = (typeof COPY)["en"];
diff --git a/apps/storybook/src/voice-input/d-focus-mode.stories.tsx b/apps/storybook/src/voice-input/d-focus-mode.stories.tsx
new file mode 100644
index 0000000000..2cb722d2a4
--- /dev/null
+++ b/apps/storybook/src/voice-input/d-focus-mode.stories.tsx
@@ -0,0 +1,50 @@
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { CHAT_SCRIPT } from "./copy";
+import { FocusMode } from "./concepts/focus-mode";
+import { FOCUS_MODE } from "./concepts/info";
+import { useStoryEnv } from "./env";
+import { Gallery, samples } from "./gallery";
+import { label } from "./labels";
+import { DemoStage } from "./stage";
+
+const meta = { title: "Voice input/Explored/D · Focus mode", id: "voice-input-d-focus-mode" } satisfies Meta;
+export default meta;
+
+export const TryIt: StoryObj = {
+ name: "Try it",
+ render: () => (
+ <DemoStage info={FOCUS_MODE}>
+ <FocusMode />
+ </DemoStage>
+ ),
+};
+
+function States() {
+ const { lang } = useStoryEnv();
+ const s = samples(lang);
+ const script = CHAT_SCRIPT[lang];
+ return (
+ <Gallery
+ columns={3}
+ items={[
+ { label: label("listeningEmpty", lang), node: <FocusMode frozen={s.listeningEmpty} initialOpen /> },
+ { label: label("listening", lang), node: <FocusMode frozen={s.listening} initialOpen /> },
+ { label: label("paused", lang), node: <FocusMode frozen={s.paused} initialOpen /> },
+ { label: label("processing", lang), node: <FocusMode frozen={s.processing} initialOpen /> },
+ {
+ label: label("review", lang),
+ node: (
+ <FocusMode
+ frozen={s.idle}
+ initialOpen
+ frozenReview={{ raw: script.phrases.join(""), polished: script.polished }}
+ />
+ ),
+ },
+ { label: label("noSpeech", lang), node: <FocusMode frozen={s.noSpeech} initialOpen /> },
+ ]}
+ />
+ );
+}
+
+export const AllStates: StoryObj = { name: "States", render: () => <States /> };
diff --git a/apps/storybook/src/voice-input/e-send-slot.stories.tsx b/apps/storybook/src/voice-input/e-send-slot.stories.tsx
new file mode 100644
index 0000000000..3745e84ddf
--- /dev/null
+++ b/apps/storybook/src/voice-input/e-send-slot.stories.tsx
@@ -0,0 +1,39 @@
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { SendSlot } from "./concepts/send-slot";
+import { SEND_SLOT } from "./concepts/info";
+import { useStoryEnv } from "./env";
+import { Gallery, samples } from "./gallery";
+import { label } from "./labels";
+import { DemoStage } from "./stage";
+
+const meta = { title: "Voice input/Explored/E · Hold the send button", id: "voice-input-e-send-slot" } satisfies Meta;
+export default meta;
+
+export const TryIt: StoryObj = {
+ name: "Try it",
+ render: () => (
+ <DemoStage info={SEND_SLOT}>
+ <SendSlot />
+ </DemoStage>
+ ),
+};
+
+function States() {
+ const { lang, copy } = useStoryEnv();
+ const s = samples(lang);
+ return (
+ <Gallery
+ columns={3}
+ items={[
+ { label: label("idle", lang), node: <SendSlot frozen={s.idle} /> },
+ { label: label("idleDraft", lang), node: <SendSlot frozen={s.idle} initialDraft={copy.userMessage} /> },
+ { label: label("listening", lang), node: <SendSlot frozen={s.listening} /> },
+ { label: label("cancelling", lang), node: <SendSlot frozen={s.listening} frozenDrag={{ dx: -70, dy: 0 }} /> },
+ { label: label("locking", lang), node: <SendSlot frozen={s.listening} frozenDrag={{ dx: 0, dy: -40 }} /> },
+ { label: label("locked", lang), node: <SendSlot frozen={s.listening} frozenLocked /> },
+ ]}
+ />
+ );
+}
+
+export const AllStates: StoryObj = { name: "States", render: () => <States /> };
diff --git a/apps/storybook/src/voice-input/edge-cases.stories.tsx b/apps/storybook/src/voice-input/edge-cases.stories.tsx
new file mode 100644
index 0000000000..6c4c27e37f
--- /dev/null
+++ b/apps/storybook/src/voice-input/edge-cases.stories.tsx
@@ -0,0 +1,93 @@
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { ChatComposer } from "./composer/surfaces";
+import { VoiceProvider } from "./composer/voice-provider";
+import type { VoiceSessionOptions } from "./voice-session";
+import { useStoryEnv } from "./env";
+import { label, type StateLabel } from "./labels";
+
+const meta = {
+ title: "Voice input/Edge cases",
+ parameters: { layout: "centered" },
+} satisfies Meta;
+export default meta;
+
+/**
+ * The failure paths on the shared composer. The error sits inside whichever
+ * composer was dictated into; the draft is never touched.
+ */
+function Case({ state, simulate, note }: {
+ state: StateLabel;
+ simulate: Pick<VoiceSessionOptions, "failWith" | "permission">;
+ note: { en: string; zh: string };
+}) {
+ const { lang } = useStoryEnv();
+ return (
+ <div className="flex w-[460px] flex-col gap-3 p-8">
+ <div>
+ <h1 className="text-title-sm font-semibold">{label(state, lang)}</h1>
+ <p className="mt-1 text-caption text-muted-foreground">{note[lang]}</p>
+ </div>
+ <VoiceProvider primaryId="chat" simulate={simulate}>
+ <div className="pt-14">
+ <ChatComposer onSend={() => {}} />
+ </div>
+ </VoiceProvider>
+ </div>
+ );
+}
+
+export const FirstUse: StoryObj = {
+ name: "First use: permission prompt",
+ render: () => (
+ <Case
+ state="requesting"
+ simulate={{ permission: "prompt" }}
+ note={{
+ en: "Click the mic. The first start waits on the browser's permission prompt; later starts go straight to listening.",
+ zh: "点麦克风。第一次会等待浏览器弹出的权限请求;之后再点会直接开始听。",
+ }}
+ />
+ ),
+};
+
+export const Blocked: StoryObj = {
+ name: "Microphone blocked",
+ render: () => (
+ <Case
+ state="denied"
+ simulate={{ failWith: "permission-denied" }}
+ note={{
+ en: "Click the mic. Permission is refused; the composer says how to fix it and offers no retry that would fail again.",
+ zh: "点麦克风。权限被拒绝;输入框里说明怎么解决,不提供注定失败的重试。",
+ }}
+ />
+ ),
+};
+
+export const NothingHeard: StoryObj = {
+ name: "Nothing heard",
+ render: () => (
+ <Case
+ state="noSpeech"
+ simulate={{ failWith: "no-speech" }}
+ note={{
+ en: "Click the mic and wait. After a few seconds of silence the session ends on its own.",
+ zh: "点麦克风后不说话。静音几秒后自动结束。",
+ }}
+ />
+ ),
+};
+
+export const TranscriptionFails: StoryObj = {
+ name: "Transcription fails",
+ render: () => (
+ <Case
+ state="network"
+ simulate={{ failWith: "network" }}
+ note={{
+ en: "Click the mic, let it talk, then ✓. Transcription fails; the recording is kept so Try again doesn't make you repeat yourself.",
+ zh: "点麦克风,等它说一会儿,再点 ✓。转写失败;录音保留,「重试」不需要再说一遍。",
+ }}
+ />
+ ),
+};
diff --git a/apps/storybook/src/voice-input/env.tsx b/apps/storybook/src/voice-input/env.tsx
new file mode 100644
index 0000000000..043cdc65c9
--- /dev/null
+++ b/apps/storybook/src/voice-input/env.tsx
@@ -0,0 +1,27 @@
+import { createContext, useContext, type ReactNode } from "react";
+import { COPY, type Copy, type Lang } from "./copy";
+import type { VoiceSource } from "./voice-session";
+
+interface StoryEnv {
+ lang: Lang;
+ source: VoiceSource;
+}
+
+const StoryEnvContext = createContext<StoryEnv>({ lang: "en", source: "simulated" });
+
+export function StoryEnvProvider({ lang, source, children }: StoryEnv & { children: ReactNode }) {
+ return <StoryEnvContext.Provider value={{ lang, source }}>{children}</StoryEnvContext.Provider>;
+}
+
+export function useStoryEnv(): StoryEnv & { copy: Copy } {
+ const env = useContext(StoryEnvContext);
+ return { ...env, copy: COPY[env.lang] };
+}
+
+/** Appends dictated text to a draft the way a person would have typed it. */
+export function appendDictation(draft: string, text: string, lang: Lang): string {
+ if (!text) return draft;
+ if (!draft.trim()) return text;
+ const sep = lang === "zh" || /\s$/.test(draft) ? "" : " ";
+ return draft + sep + text;
+}
diff --git a/apps/storybook/src/voice-input/first-use.stories.tsx b/apps/storybook/src/voice-input/first-use.stories.tsx
new file mode 100644
index 0000000000..bc60dc3fec
--- /dev/null
+++ b/apps/storybook/src/voice-input/first-use.stories.tsx
@@ -0,0 +1,85 @@
+import { useState } from "react";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { ChatWindowFrame, useDemoChat } from "./chat-frame";
+import { useStoryEnv } from "./env";
+import { Gallery, samples } from "./gallery";
+import { ChatComposer } from "./composer/surfaces";
+import { VoiceProvider } from "./composer/voice-provider";
+import { FirstUseDialog, type SetupStep } from "./setup/first-use";
+import { VoiceSettingsProvider } from "./settings/store";
+
+const meta = {
+ title: "Voice input/First use",
+ id: "voice-input-first-use",
+ parameters: { layout: "fullscreen" },
+} satisfies Meta;
+export default meta;
+
+/** The first press on the mic opens setup; afterwards it records straight away. */
+function FirstPress() {
+ const chat = useDemoChat();
+ const [setupDone, setSetupDone] = useState(false);
+ const [open, setOpen] = useState(false);
+ return (
+ <div className="relative flex min-h-screen items-start justify-center p-8">
+ <VoiceProvider
+ primaryId="chat"
+ gate={() => {
+ if (setupDone) return true;
+ setOpen(true);
+ return false;
+ }}
+ >
+ <ChatWindowFrame messages={chat.messages}>
+ <ChatComposer onSend={chat.send} />
+ </ChatWindowFrame>
+ </VoiceProvider>
+ {open && (
+ <div className="absolute inset-0 z-50 flex items-center justify-center bg-black/30 animate-in fade-in">
+ <FirstUseDialog
+ onClose={() => {
+ setOpen(false);
+ setSetupDone(true);
+ }}
+ />
+ </div>
+ )}
+ </div>
+ );
+}
+
+export const TryIt: StoryObj = {
+ name: "Try it",
+ render: () => (
+ <VoiceSettingsProvider initial={{ micPermission: "prompt", models: { "sense-voice": { state: "available" }, "parakeet-v3": { state: "available" } } }}>
+ <FirstPress />
+ </VoiceSettingsProvider>
+ ),
+};
+
+function StepsGallery() {
+ const { lang } = useStoryEnv();
+ const zh = lang === "zh";
+ const s = samples(lang);
+ const steps: { step: SetupStep; label: string }[] = [
+ { step: "permission", label: zh ? "1 · 麦克风权限" : "1 · Microphone permission" },
+ { step: "engine", label: zh ? "2 · 选择识别方式" : "2 · Choose the engine" },
+ { step: "try", label: zh ? "3 · 试一下(按住时)" : "3 · Try it (holding)" },
+ { step: "done", label: zh ? "4 · 完成" : "4 · Done" },
+ ];
+ return (
+ <Gallery
+ columns={2}
+ items={steps.map(({ step, label }) => ({
+ label,
+ node: (
+ <VoiceSettingsProvider initial={{ models: { "sense-voice": { state: "ready" }, "parakeet-v3": { state: "ready" } } }}>
+ <FirstUseDialog initialStep={step} frozen={step === "try" ? s.listening : undefined} />
+ </VoiceSettingsProvider>
+ ),
+ }))}
+ />
+ );
+}
+
+export const AllSteps: StoryObj = { name: "All steps", render: () => <StepsGallery /> };
diff --git a/apps/storybook/src/voice-input/gallery.tsx b/apps/storybook/src/voice-input/gallery.tsx
new file mode 100644
index 0000000000..b604bbe066
--- /dev/null
+++ b/apps/storybook/src/voice-input/gallery.tsx
@@ -0,0 +1,38 @@
+import type { ReactNode } from "react";
+import { CHAT_SCRIPT, type Lang, type VoiceScript } from "./copy";
+import { mockSession, type VoiceSession } from "./voice-session";
+
+/** Frozen sessions at the interesting points of one dictation. */
+export function samples(lang: Lang, script: VoiceScript = CHAT_SCRIPT[lang]) {
+ const [p0 = "", p1 = "", p2 = ""] = script.phrases;
+ const cut = lang === "zh" ? p2.indexOf(" ") : p2.indexOf(" ", 18);
+ return {
+ idle: mockSession(),
+ requesting: mockSession({ phase: "requesting" }),
+ listeningEmpty: mockSession({ phase: "listening", elapsedMs: 900, speaking: false }),
+ listening: mockSession({
+ phase: "listening",
+ elapsedMs: 7400,
+ finalText: p0 + p1,
+ interimText: p2.slice(0, cut),
+ }),
+ paused: mockSession({ phase: "paused", elapsedMs: 9100, finalText: p0 + p1 + p2, speaking: false }),
+ processing: mockSession({ phase: "processing", elapsedMs: 12300, finalText: script.phrases.join("") }),
+ denied: mockSession({ phase: "error", error: "permission-denied" }),
+ noSpeech: mockSession({ phase: "error", error: "no-speech" }),
+ network: mockSession({ phase: "error", error: "network" }),
+ } satisfies Record<string, VoiceSession>;
+}
+
+export function Gallery({ items, columns = 3 }: { items: { label: string; node: ReactNode }[]; columns?: number }) {
+ return (
+ <div className="grid gap-x-8 gap-y-10 p-8" style={{ gridTemplateColumns: `repeat(${columns}, max-content)` }}>
+ {items.map((item) => (
+ <figure key={item.label} className="flex flex-col gap-3">
+ <figcaption className="text-caption font-medium text-muted-foreground">{item.label}</figcaption>
+ {item.node}
+ </figure>
+ ))}
+ </div>
+ );
+}
diff --git a/apps/storybook/src/voice-input/labels.ts b/apps/storybook/src/voice-input/labels.ts
new file mode 100644
index 0000000000..c770966a40
--- /dev/null
+++ b/apps/storybook/src/voice-input/labels.ts
@@ -0,0 +1,24 @@
+import type { Lang } from "./copy";
+
+const LABELS = {
+ idle: { en: "Idle", zh: "空闲" },
+ idleDraft: { en: "Idle, with a draft", zh: "空闲(已有草稿)" },
+ requesting: { en: "Asking for the microphone", zh: "请求麦克风权限" },
+ listeningEmpty: { en: "Listening, nothing said yet", zh: "正在听,还没开口" },
+ listening: { en: "Listening", zh: "正在听" },
+ locked: { en: "Locked hands-free", zh: "已锁定(免手持)" },
+ paused: { en: "Paused", zh: "已暂停" },
+ processing: { en: "Transcribing", zh: "转写中" },
+ polish: { en: "Inserted, Polish offered", zh: "已插入,提供润色" },
+ review: { en: "Review", zh: "审阅" },
+ cancelling: { en: "Sliding to cancel", zh: "左滑取消中" },
+ locking: { en: "Sliding to lock", zh: "上滑锁定中" },
+ filled: { en: "Filled from voice", zh: "已从语音填好" },
+ denied: { en: "Microphone blocked", zh: "麦克风被禁用" },
+ noSpeech: { en: "Nothing heard", zh: "没有听到声音" },
+ network: { en: "Transcription failed", zh: "转写失败" },
+} satisfies Record<string, Record<Lang, string>>;
+
+export type StateLabel = keyof typeof LABELS;
+
+export const label = (key: StateLabel, lang: Lang) => LABELS[key][lang];
diff --git a/apps/storybook/src/voice-input/overview.stories.tsx b/apps/storybook/src/voice-input/overview.stories.tsx
new file mode 100644
index 0000000000..8c18c558ae
--- /dev/null
+++ b/apps/storybook/src/voice-input/overview.stories.tsx
@@ -0,0 +1,79 @@
+import type { ReactNode } from "react";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { FocusMode } from "./concepts/focus-mode";
+import { ALL_CONCEPTS } from "./concepts/info";
+import { InlineWaveform } from "./concepts/inline-waveform";
+import { LiveDictation } from "./concepts/live-dictation";
+import { PushToTalk } from "./concepts/push-to-talk";
+import { SendSlot } from "./concepts/send-slot";
+import { useStoryEnv } from "./env";
+import { samples } from "./gallery";
+import type { ConceptInfo } from "./stage";
+
+const meta = {
+ title: "Voice input/Explored/All directions",
+ id: "voice-input-overview",
+ parameters: { layout: "fullscreen" },
+} satisfies Meta;
+export default meta;
+
+function Card({ info, children }: { info: ConceptInfo; children: ReactNode }) {
+ const { lang } = useStoryEnv();
+ return (
+ <section className="flex flex-col gap-4 rounded-xl bg-surface p-5 ring-1 ring-surface-border">
+ <header>
+ <div className="flex items-baseline gap-2">
+ <span className="text-caption font-medium text-brand">{info.letter}</span>
+ <h2 className="text-title-sm font-semibold">{info.name[lang]}</h2>
+ </div>
+ <p className="mt-1 text-caption text-muted-foreground">{info.pitch[lang]}</p>
+ </header>
+ <div className="flex h-[420px] items-center justify-center overflow-hidden rounded-lg bg-page-canvas">
+ <div style={{ zoom: 0.68 }}>{children}</div>
+ </div>
+ <dl className="grid grid-cols-2 gap-3 text-caption">
+ <div>
+ <dt className="font-medium">{lang === "zh" ? "适合" : "Best for"}</dt>
+ <dd className="mt-0.5 text-muted-foreground">{info.bestFor[lang]}</dd>
+ </div>
+ <div>
+ <dt className="font-medium">{lang === "zh" ? "代价" : "Trade-off"}</dt>
+ <dd className="mt-0.5 text-muted-foreground">{info.tradeoff[lang]}</dd>
+ </div>
+ </dl>
+ </section>
+ );
+}
+
+function Overview() {
+ const { lang } = useStoryEnv();
+ const s = samples(lang);
+ const renders = [
+ <InlineWaveform key="a" frozen={s.listening} />,
+ <LiveDictation key="b" frozen={s.listening} />,
+ <PushToTalk key="c" frozen={s.listening} />,
+ <FocusMode key="d" frozen={s.listening} initialOpen />,
+ <SendSlot key="e" frozen={s.listening} />,
+ ];
+ return (
+ <div className="min-h-screen bg-page-canvas p-8">
+ <header className="mb-6 max-w-3xl">
+ <h1 className="text-display-sm font-semibold">{lang === "zh" ? "第一轮探索:五种方向" : "First round: five directions"}</h1>
+ <p className="mt-2 text-body text-muted-foreground">
+ {lang === "zh"
+ ? "每个方向都定格在「正在听」这一刻。最终选了 A + C,见「Composer (A + C)」。这里保留探索过程,方便回看。"
+ : "Each direction is frozen mid-dictation. A + C were picked; see “Composer (A + C)”. The exploration stays here for reference."}
+ </p>
+ </header>
+ <div className="grid grid-cols-3 gap-6">
+ {ALL_CONCEPTS.map((info, i) => (
+ <Card key={info.letter} info={info}>
+ {renders[i]}
+ </Card>
+ ))}
+ </div>
+ </div>
+ );
+}
+
+export const AllDirections: StoryObj = { name: "Overview", render: () => <Overview /> };
diff --git a/apps/storybook/src/voice-input/primitives.tsx b/apps/storybook/src/voice-input/primitives.tsx
new file mode 100644
index 0000000000..2eb557a9b5
--- /dev/null
+++ b/apps/storybook/src/voice-input/primitives.tsx
@@ -0,0 +1,147 @@
+import type { ReactNode } from "react";
+import { AlertCircle, MicOff, RotateCcw } from "@multica/ui/icons";
+import { Button } from "@multica/ui/components/ui/button";
+import { Kbd } from "@multica/ui/components/ui/kbd";
+import { cn } from "@multica/ui/lib/utils";
+import type { Copy } from "./copy";
+import type { VoiceError } from "./voice-session";
+import "./voice.css";
+
+export function formatElapsed(ms: number): string {
+ const total = Math.floor(ms / 1000);
+ return `${Math.floor(total / 60)}:${String(total % 60).padStart(2, "0")}`;
+}
+
+/** Scrolling level history: newest sample on the right. */
+export function Waveform({
+ levels,
+ bars = 40,
+ className,
+ barClassName,
+ minHeight = 10,
+}: {
+ levels: number[];
+ bars?: number;
+ className?: string;
+ barClassName?: string;
+ minHeight?: number;
+}) {
+ const slice = levels.slice(-bars);
+ return (
+ <div aria-hidden className={cn("voice-wave-fade flex h-5 items-center justify-end gap-[2px]", className)}>
+ {slice.map((v, i) => (
+ <span
+ key={i}
+ className={cn("w-[2px] shrink-0 rounded-full bg-current", barClassName)}
+ style={{ height: `${Math.max(minHeight, Math.min(100, v * 110))}%` }}
+ />
+ ))}
+ </div>
+ );
+}
+
+/** A compact three-bar meter that fits where an icon would be. */
+export function LevelBars({ levels, className }: { levels: number[]; className?: string }) {
+ const n = levels.length;
+ const pick = [levels[n - 3] ?? 0, levels[n - 1] ?? 0, levels[n - 5] ?? 0];
+ const shape = [0.7, 1, 0.8];
+ return (
+ <span aria-hidden className={cn("flex h-3.5 items-center gap-[2px]", className)}>
+ {pick.map((v, i) => (
+ <span
+ key={i}
+ className="w-[3px] rounded-full bg-current transition-[height] duration-75"
+ style={{ height: `${Math.max(22, Math.min(100, v * shape[i]! * 130))}%` }}
+ />
+ ))}
+ </span>
+ );
+}
+
+export function RecDot({ className }: { className?: string }) {
+ return <span aria-hidden className={cn("voice-rec-dot size-2 shrink-0 rounded-full bg-destructive", className)} />;
+}
+
+export function Elapsed({ ms, className }: { ms: number; className?: string }) {
+ return <span className={cn("text-caption tabular-nums text-muted-foreground", className)}>{formatElapsed(ms)}</span>;
+}
+
+export function Shimmer({ children, className }: { children: ReactNode; className?: string }) {
+ return <span className={cn("voice-shimmer text-caption font-medium", className)}>{children}</span>;
+}
+
+/** Committed words in full ink, words the recognizer may still revise in muted ink. */
+export function LiveTranscript({
+ finalText,
+ interimText,
+ caret = true,
+ className,
+}: {
+ finalText: string;
+ interimText: string;
+ caret?: boolean;
+ className?: string;
+}) {
+ return (
+ <span className={cn("whitespace-pre-wrap break-words", className)}>
+ {finalText}
+ <span className="text-muted-foreground">{interimText}</span>
+ {caret && <span className="voice-caret" />}
+ </span>
+ );
+}
+
+export function KeyHint({ keys, label }: { keys: string[]; label: string }) {
+ return (
+ <span className="inline-flex items-center gap-1 text-caption text-muted-foreground">
+ {keys.map((k) => (
+ <Kbd key={k}>{k}</Kbd>
+ ))}
+ <span>{label}</span>
+ </span>
+ );
+}
+
+export function errorMessage(error: VoiceError, copy: Copy): string {
+ if (error === "permission-denied") return copy.deniedBody;
+ if (error === "no-speech") return copy.noSpeech;
+ return copy.network;
+}
+
+/** One-line error row that sits inside a composer, above its toolbar. */
+export function InlineVoiceError({
+ error,
+ copy,
+ onRetry,
+ onDismiss,
+}: {
+ error: VoiceError;
+ copy: Copy;
+ onRetry?: () => void;
+ onDismiss?: () => void;
+}) {
+ const Icon = error === "permission-denied" ? MicOff : AlertCircle;
+ return (
+ <div
+ role="alert"
+ className="flex items-center gap-2 rounded-md bg-destructive/8 px-2 py-1.5 text-caption text-destructive"
+ >
+ <Icon className="size-3.5 shrink-0" />
+ <span className="min-w-0 flex-1">
+ {error === "permission-denied" && <span className="font-medium">{copy.deniedTitle} </span>}
+ {errorMessage(error, copy)}
+ </span>
+ {onRetry && error !== "permission-denied" && (
+ <Button size="xs" variant="ghost" className="text-destructive hover:text-destructive" onClick={onRetry}>
+ <RotateCcw />
+ {copy.retry}
+ </Button>
+ )}
+ {onDismiss && (
+ <Button size="xs" variant="ghost" className="text-muted-foreground" onClick={onDismiss}>
+ {copy.cancel}
+ </Button>
+ )}
+ </div>
+ );
+}
diff --git a/apps/storybook/src/voice-input/settings.stories.tsx b/apps/storybook/src/voice-input/settings.stories.tsx
new file mode 100644
index 0000000000..8524265cc2
--- /dev/null
+++ b/apps/storybook/src/voice-input/settings.stories.tsx
@@ -0,0 +1,100 @@
+import type { ReactNode } from "react";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { useStoryEnv } from "./env";
+import { Gallery } from "./gallery";
+import { EngineCard, ShortcutCard, VoiceNotices, VoiceSettingsPage } from "./settings/voice-settings-page";
+import { VoiceSettingsProvider, type VoiceSettings } from "./settings/store";
+
+const meta = {
+ title: "Voice input/Settings",
+ id: "voice-input-settings",
+ parameters: { layout: "fullscreen" },
+} satisfies Meta;
+export default meta;
+
+export const Desktop: StoryObj = {
+ render: () => (
+ <VoiceSettingsProvider>
+ <VoiceSettingsPage />
+ </VoiceSettingsProvider>
+ ),
+};
+
+export const Web: StoryObj = {
+ render: () => (
+ <VoiceSettingsProvider initial={{ platform: "web", engine: "cloud" }}>
+ <VoiceSettingsPage />
+ </VoiceSettingsProvider>
+ ),
+};
+
+function Case({ initial, children }: { initial: Partial<VoiceSettings>; children: ReactNode }) {
+ return (
+ <VoiceSettingsProvider initial={initial}>
+ <div className="w-[620px] space-y-3">{children}</div>
+ </VoiceSettingsProvider>
+ );
+}
+
+function SettingsStates() {
+ const { lang } = useStoryEnv();
+ const zh = lang === "zh";
+ return (
+ <Gallery
+ columns={2}
+ items={[
+ {
+ label: zh ? "本机引擎,模型还没下载" : "On-device engine, no model yet",
+ node: (
+ <Case initial={{ models: { "sense-voice": { state: "available" } } }}>
+ <VoiceNotices />
+ </Case>
+ ),
+ },
+ {
+ label: zh ? "没有麦克风权限" : "Microphone permission denied",
+ node: (
+ <Case initial={{ micPermission: "denied" }}>
+ <VoiceNotices />
+ </Case>
+ ),
+ },
+ {
+ label: zh ? "模型下载中" : "Model downloading",
+ node: (
+ <Case initial={{ models: { "parakeet-v3": { state: "downloading", progress: 42 }, "whisper-turbo": { state: "ready" } } }}>
+ <EngineCard />
+ </Case>
+ ),
+ },
+ {
+ label: zh ? "云端引擎" : "Cloud engine",
+ node: (
+ <Case initial={{ engine: "cloud" }}>
+ <EngineCard />
+ </Case>
+ ),
+ },
+ {
+ label: zh ? "仅按住模式" : "Hold-only behavior",
+ node: (
+ <Case initial={{ activation: "hold", globalShortcut: true }}>
+ <ShortcutCard />
+ </Case>
+ ),
+ },
+ {
+ label: zh ? "网页端:只有云端" : "Web: cloud only",
+ node: (
+ <Case initial={{ platform: "web", engine: "cloud" }}>
+ <VoiceNotices />
+ <EngineCard />
+ </Case>
+ ),
+ },
+ ]}
+ />
+ );
+}
+
+export const States: StoryObj = { render: () => <SettingsStates /> };
diff --git a/apps/storybook/src/voice-input/settings/copy.ts b/apps/storybook/src/voice-input/settings/copy.ts
new file mode 100644
index 0000000000..c96c66ef32
--- /dev/null
+++ b/apps/storybook/src/voice-input/settings/copy.ts
@@ -0,0 +1,186 @@
+import type { Lang } from "../copy";
+
+export const SETTINGS_COPY = {
+ en: {
+ nav: {
+ personal: "Personal",
+ profile: "Profile",
+ preferences: "Preferences",
+ appearance: "Appearance",
+ notifications: "Notifications",
+ shortcuts: "Keyboard shortcuts",
+ voice: "Voice input",
+ tokens: "API Tokens",
+ search: "Search settings",
+ },
+ scopeDevice: "This device only",
+ intro: "Dictate into chat, comments and replies. These settings stay on this device.",
+ shortcutSection: "Shortcut",
+ shortcut: "Voice input",
+ shortcutHint: "Tap to start dictating, or hold to talk and release to insert.",
+ changeShortcut: "Change shortcut",
+ pressKeys: "Press new keys…",
+ activation: "Behavior",
+ activationHint: {
+ auto: "Tap to toggle, hold to talk.",
+ toggle: "Tap to start, tap again to stop.",
+ hold: "Records only while held.",
+ },
+ activationOptions: { auto: "Auto", toggle: "Toggle", hold: "Hold" },
+ background: "Works in the background",
+ backgroundHint: "When Multica isn't in front, the shortcut opens quick chat and starts dictating. Needs Accessibility permission.",
+ cancelKey: "Cancel",
+ cancelHint: "Discards the recording.",
+ recognitionSection: "Recognition",
+ engine: "Engine",
+ engineHint: {
+ local: "Runs on this computer. Works offline, and audio never leaves it.",
+ cloud: "Runs on Multica's servers. Uses no local resources; needs a connection.",
+ },
+ engineOptions: { local: "On this device", cloud: "Cloud" },
+ models: "Models",
+ modelsHint: "Downloaded once, used offline. Pick one.",
+ recommended: { zh: "Best for Chinese", en: "Best for English" },
+ streaming: "Live text",
+ speed: "Speed",
+ accuracy: "Accuracy",
+ download: "Download",
+ use: "Use",
+ inUse: "In use",
+ deleteModel: "Delete",
+ cancelDownload: "Cancel download",
+ language: "Spoken language",
+ languageOptions: { auto: "Detect automatically", zh: "Chinese", en: "English", ja: "Japanese" },
+ chineseScript: "Chinese output",
+ scriptOptions: { simplified: "Simplified", traditional: "Traditional" },
+ micSection: "Microphone",
+ device: "Input device",
+ devices: { default: "System default (MacBook Pro Microphone)", airpods: "AirPods Pro", studio: "Studio Display Microphone" },
+ test: "Test microphone",
+ testHint: "Say something and watch the meter move.",
+ startTest: "Test",
+ stopTest: "Stop",
+ sounds: "Sounds",
+ soundsHint: "Play a sound when recording starts and stops.",
+ muteOthers: "Mute other audio while recording",
+ textSection: "Text",
+ fillers: "Remove filler words",
+ fillersHint: "Drops “um”, “uh”, “嗯” and similar pauses.",
+ polish: "Polish",
+ polishHint: "Polish sends the text to Multica AI to turn speech into written text.",
+ polishOptions: { off: "Off", offer: "Offer after inserting", auto: "Always" },
+ vocabulary: "Custom words",
+ vocabularyHint: "Names, products and terms, so they're spelled right.",
+ addWord: "Add a word…",
+ privacySection: "Privacy",
+ keep: "Keep recordings",
+ keepHint: "Kept recordings can be retried when transcription fails.",
+ keepOptions: { off: "Don't keep", "7d": "7 days", "30d": "30 days" },
+ privacyLocal: "With the on-device engine, audio and text stay on this computer.",
+ privacyCloud: "Audio is sent to Multica to be transcribed and deleted right after.",
+ trySection: "Try it",
+ trySectionHint: "Uses the settings above.",
+ noModelTitle: "No speech model yet",
+ noModelBody: "Voice input needs a model on this device before it can work.",
+ noModelAction: "Download",
+ deniedTitle: "Multica can't use the microphone",
+ deniedBody: "Allow Multica in System Settings → Privacy & Security → Microphone.",
+ deniedAction: "Open System Settings",
+ webTitle: "On-device recognition needs the desktop app",
+ webBody: "In the browser, voice input uses the cloud engine.",
+ webAction: "Get the desktop app",
+ onlyDesktop: "Desktop app only",
+ },
+ zh: {
+ nav: {
+ personal: "个人",
+ profile: "个人资料",
+ preferences: "偏好设置",
+ appearance: "外观",
+ notifications: "通知",
+ shortcuts: "快捷键",
+ voice: "语音输入",
+ tokens: "API Token",
+ search: "搜索设置",
+ },
+ scopeDevice: "仅本设备",
+ intro: "在聊天、评论和回复里用语音输入。这些设置只保存在这台设备上。",
+ shortcutSection: "快捷键",
+ shortcut: "语音输入",
+ shortcutHint: "按一下开始听写;按住说话,松开插入。",
+ changeShortcut: "修改快捷键",
+ pressKeys: "按下新的快捷键…",
+ activation: "触发方式",
+ activationHint: {
+ auto: "按一下切换,按住说话。",
+ toggle: "按一下开始,再按一下结束。",
+ hold: "只在按住时录音。",
+ },
+ activationOptions: { auto: "自动", toggle: "仅切换", hold: "仅按住" },
+ background: "在后台也可用",
+ backgroundHint: "Multica 不在前台时按快捷键,会打开快速聊天并开始听写。需要辅助功能权限。",
+ cancelKey: "取消",
+ cancelHint: "丢弃这次录音。",
+ recognitionSection: "识别",
+ engine: "识别引擎",
+ engineHint: {
+ local: "在这台电脑上识别,离线可用,音频不会离开本机。",
+ cloud: "由 Multica 云端识别,不占本机资源,需要联网。",
+ },
+ engineOptions: { local: "本机", cloud: "云端" },
+ models: "模型",
+ modelsHint: "下载一次,离线使用。选一个即可。",
+ recommended: { zh: "中文推荐", en: "英文推荐" },
+ streaming: "实时出字",
+ speed: "速度",
+ accuracy: "准确度",
+ download: "下载",
+ use: "使用",
+ inUse: "使用中",
+ deleteModel: "删除",
+ cancelDownload: "取消下载",
+ language: "说话语言",
+ languageOptions: { auto: "自动识别", zh: "中文", en: "英文", ja: "日语" },
+ chineseScript: "中文输出",
+ scriptOptions: { simplified: "简体", traditional: "繁体" },
+ micSection: "麦克风",
+ device: "输入设备",
+ devices: { default: "系统默认(MacBook Pro 麦克风)", airpods: "AirPods Pro", studio: "Studio Display 麦克风" },
+ test: "测试麦克风",
+ testHint: "说句话,看看音量条有没有动。",
+ startTest: "测试",
+ stopTest: "停止",
+ sounds: "提示音",
+ soundsHint: "开始和结束录音时播放提示音。",
+ muteOthers: "录音时静音其他声音",
+ textSection: "文字处理",
+ fillers: "去掉语气词",
+ fillersHint: "去掉「嗯」「呃」「um」这类停顿词。",
+ polish: "润色",
+ polishHint: "润色会把文字发给 Multica AI,把口语整理成书面语。",
+ polishOptions: { off: "关闭", offer: "插入后可一键润色", auto: "总是润色" },
+ vocabulary: "自定义词汇",
+ vocabularyHint: "人名、产品名和术语,帮助识别拼对。",
+ addWord: "添加词汇…",
+ privacySection: "隐私",
+ keep: "保留录音",
+ keepHint: "保留后,转写失败时可以直接重试。",
+ keepOptions: { off: "不保留", "7d": "7 天", "30d": "30 天" },
+ privacyLocal: "使用本机引擎时,音频和文字都不会离开这台电脑。",
+ privacyCloud: "音频会发送到 Multica 识别,识别完立即删除。",
+ trySection: "试一下",
+ trySectionHint: "使用上面的设置。",
+ noModelTitle: "还没有语音模型",
+ noModelBody: "语音输入需要先在这台设备上下载一个模型。",
+ noModelAction: "下载",
+ deniedTitle: "Multica 没有麦克风权限",
+ deniedBody: "在「系统设置 → 隐私与安全性 → 麦克风」里允许 Multica。",
+ deniedAction: "打开系统设置",
+ webTitle: "本机识别需要桌面端",
+ webBody: "在浏览器里,语音输入使用云端引擎。",
+ webAction: "下载桌面端",
+ onlyDesktop: "仅桌面端",
+ },
+} satisfies Record<Lang, unknown>;
+
+export type SettingsCopy = (typeof SETTINGS_COPY)["en"];
diff --git a/apps/storybook/src/voice-input/settings/layout.tsx b/apps/storybook/src/voice-input/settings/layout.tsx
new file mode 100644
index 0000000000..24e4d37d8d
--- /dev/null
+++ b/apps/storybook/src/voice-input/settings/layout.tsx
@@ -0,0 +1,166 @@
+import type { ReactNode } from "react";
+import { Bell, Keyboard, KeyRound, Laptop, Mic, Palette, Search, SlidersHorizontal, User } from "@multica/ui/icons";
+import { Card, CardContent } from "@multica/ui/components/ui/card";
+import { cn } from "@multica/ui/lib/utils";
+import type { SettingsCopy } from "./copy";
+
+/*
+ * Copies of the settings building blocks in
+ * packages/views/settings/components/settings-layout.tsx and the page chrome in
+ * settings-page.tsx. They read the app's stores there, so the mock carries the
+ * markup and classes only.
+ */
+
+export function ScopeBadge({ label }: { label: string }) {
+ return (
+ <span className="inline-flex h-5 min-w-0 shrink-0 items-center gap-1 rounded-full bg-muted px-2 text-caption font-medium text-muted-foreground">
+ <Laptop aria-hidden="true" className="size-3" />
+ <span className="truncate">{label}</span>
+ </span>
+ );
+}
+
+export function SettingsSection({ title, description, children }: { title?: ReactNode; description?: ReactNode; children: ReactNode }) {
+ return (
+ <section className="space-y-3">
+ {(title || description) && (
+ <div className="px-0.5">
+ {title && <h3 className="text-body font-semibold">{title}</h3>}
+ {description && <p className="mt-1 text-caption leading-5 text-muted-foreground">{description}</p>}
+ </div>
+ )}
+ {children}
+ </section>
+ );
+}
+
+export function SettingsCard({ children, className }: { children: ReactNode; className?: string }) {
+ return (
+ <Card className={cn("gap-0 py-0 shadow-none", className)}>
+ <CardContent className="divide-y divide-surface-border px-0">{children}</CardContent>
+ </Card>
+ );
+}
+
+const WIDTHS = { text: "sm:w-96", "select-wide": "sm:w-72", select: "sm:w-48", none: "sm:max-w-none" } as const;
+
+export function SettingsRow({
+ label,
+ description,
+ children,
+ size,
+ align = "center",
+ className,
+}: {
+ label: ReactNode;
+ description?: ReactNode;
+ children?: ReactNode;
+ size?: keyof typeof WIDTHS;
+ align?: "center" | "start";
+ className?: string;
+}) {
+ return (
+ <div
+ className={cn(
+ "flex min-h-16 gap-4 px-4 py-3.5 sm:justify-between sm:gap-8",
+ size ? "flex-col sm:flex-row" : "flex-row justify-between",
+ align === "center" ? (size ? "sm:items-center" : "items-center") : size ? "sm:items-start" : "items-start",
+ className,
+ )}
+ >
+ <div className="min-w-0 flex-1">
+ <div className="text-body font-medium">{label}</div>
+ {description && <div className="mt-0.5 text-caption leading-5 text-muted-foreground">{description}</div>}
+ </div>
+ {children !== undefined && (
+ <div className={cn("shrink-0 sm:w-auto sm:max-w-[56%]", size ? "w-full" : "w-auto max-w-[56%]", size && WIDTHS[size])}>
+ {children}
+ </div>
+ )}
+ </div>
+ );
+}
+
+/** packages/views/common/segmented-toggle.tsx */
+export function SegmentedToggle<T extends string>({
+ value,
+ options,
+ onChange,
+ disabled = [],
+}: {
+ value: T;
+ options: ReadonlyArray<readonly [T, ReactNode]>;
+ onChange: (value: T) => void;
+ disabled?: T[];
+}) {
+ return (
+ <div className="grid auto-cols-fr grid-flow-col gap-1 rounded-md bg-muted p-1">
+ {options.map(([key, label]) => (
+ <button
+ key={key}
+ type="button"
+ aria-pressed={value === key}
+ disabled={disabled.includes(key)}
+ onClick={() => key !== value && onChange(key)}
+ className={cn(
+ "whitespace-nowrap rounded-sm px-2 py-1 text-caption font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-40",
+ value === key ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {label}
+ </button>
+ ))}
+ </div>
+ );
+}
+
+/** The settings page: navigation on the left, the open tab on the right. */
+export function SettingsShell({ copy, title, scope, children }: { copy: SettingsCopy; title: string; scope: string; children: ReactNode }) {
+ const nav = [
+ { icon: User, label: copy.nav.profile },
+ { icon: SlidersHorizontal, label: copy.nav.preferences },
+ { icon: Palette, label: copy.nav.appearance },
+ { icon: Bell, label: copy.nav.notifications },
+ { icon: Keyboard, label: copy.nav.shortcuts },
+ { icon: Mic, label: copy.nav.voice, active: true },
+ { icon: KeyRound, label: copy.nav.tokens },
+ ];
+ return (
+ <div className="flex min-h-screen bg-background">
+ <nav className="w-60 shrink-0 border-r border-border/60 px-2 pt-4">
+ <div className="relative mx-0 mb-3">
+ <Search className="pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" />
+ <div className="flex h-8 w-full items-center rounded-lg border border-input pl-[37px] text-body text-muted-foreground">
+ {copy.nav.search}
+ </div>
+ </div>
+ <div className="flex h-7 items-center px-3 text-caption font-medium text-muted-foreground">{copy.nav.personal}</div>
+ <ul className="space-y-px">
+ {nav.map((item) => (
+ <li key={item.label}>
+ <span
+ className={cn(
+ "flex min-h-8 items-center gap-2.5 rounded-lg px-3 py-1.5 text-body",
+ item.active ? "bg-surface-selected text-surface-selected-foreground" : "text-muted-foreground",
+ )}
+ >
+ <item.icon className="size-4 shrink-0" />
+ <span className="truncate">{item.label}</span>
+ </span>
+ </li>
+ ))}
+ </ul>
+ </nav>
+ <main className="min-w-0 flex-1">
+ <div className="flex h-12 items-center gap-2 border-b border-border/60 px-10">
+ <h2 className="flex items-center gap-2 text-body font-medium">
+ <Mic className="size-4 text-muted-foreground" />
+ {title}
+ </h2>
+ <ScopeBadge label={scope} />
+ </div>
+ <div className="mx-auto w-full max-w-[56rem] px-10 py-8">{children}</div>
+ </main>
+ </div>
+ );
+}
diff --git a/apps/storybook/src/voice-input/settings/store.tsx b/apps/storybook/src/voice-input/settings/store.tsx
new file mode 100644
index 0000000000..f2b2b63fc5
--- /dev/null
+++ b/apps/storybook/src/voice-input/settings/store.tsx
@@ -0,0 +1,199 @@
+import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
+
+/** How the voice shortcut and the mic button react to a press. */
+export type Activation = "auto" | "toggle" | "hold";
+export type Engine = "local" | "cloud";
+/** Off; a Polish chip after inserting (B's idea, borrowed into A); or always. */
+export type PolishMode = "off" | "offer" | "auto";
+export type Platform = "desktop" | "web";
+
+export interface LocalModel {
+ id: string;
+ name: string;
+ sizeMb: number;
+ languages: { en: string; zh: string };
+ /** 1–3, for the speed and accuracy dots. */
+ speed: number;
+ accuracy: number;
+ /** Streams text while you talk, so the HUD can show it live. */
+ streaming: boolean;
+ recommendedFor?: "zh" | "en";
+}
+
+/**
+ * Local speech models in the shape Handy ships them (GGUF via transcribe-cpp).
+ * Sizes and language coverage are from Handy's catalog; the dots are a rough
+ * guide for the mock, not benchmarks.
+ */
+export const LOCAL_MODELS: LocalModel[] = [
+ {
+ id: "sense-voice",
+ name: "SenseVoice Small",
+ sizeMb: 152,
+ languages: { en: "Chinese, English, Japanese, Korean, Cantonese", zh: "中文、英文、日语、韩语、粤语" },
+ speed: 3,
+ accuracy: 2,
+ streaming: false,
+ recommendedFor: "zh",
+ },
+ {
+ id: "parakeet-v3",
+ name: "Parakeet V3",
+ sizeMb: 456,
+ languages: { en: "English + 24 European languages, auto-detect", zh: "英文 + 24 种欧洲语言,自动识别" },
+ speed: 3,
+ accuracy: 3,
+ streaming: false,
+ recommendedFor: "en",
+ },
+ {
+ id: "whisper-turbo",
+ name: "Whisper Large v3 Turbo",
+ sizeMb: 1620,
+ languages: { en: "99 languages", zh: "99 种语言" },
+ speed: 1,
+ accuracy: 3,
+ streaming: false,
+ },
+ {
+ id: "moonshine-small",
+ name: "Moonshine V2 Small",
+ sizeMb: 99,
+ languages: { en: "English only, streams as you talk", zh: "仅英文,边说边出字" },
+ speed: 3,
+ accuracy: 2,
+ streaming: true,
+ },
+];
+
+export type ModelStatus = { state: "available" } | { state: "downloading"; progress: number } | { state: "ready" };
+
+export interface VoiceSettings {
+ platform: Platform;
+ shortcut: string[];
+ activation: Activation;
+ /** Also answer the shortcut while Multica is in the background (desktop). */
+ globalShortcut: boolean;
+ engine: Engine;
+ model: string;
+ language: "auto" | "zh" | "en" | "ja";
+ chineseScript: "simplified" | "traditional";
+ microphone: string;
+ sounds: boolean;
+ muteOthers: boolean;
+ removeFillers: boolean;
+ polish: PolishMode;
+ vocabulary: string[];
+ keepRecordings: "off" | "7d" | "30d";
+ /** Permission state of the OS / browser microphone prompt. */
+ micPermission: "granted" | "prompt" | "denied";
+ models: Record<string, ModelStatus>;
+}
+
+export const DEFAULT_SETTINGS: VoiceSettings = {
+ platform: "desktop",
+ shortcut: ["⌥", "Space"],
+ activation: "auto",
+ globalShortcut: false,
+ engine: "local",
+ model: "sense-voice",
+ language: "auto",
+ chineseScript: "simplified",
+ microphone: "default",
+ sounds: true,
+ muteOthers: false,
+ removeFillers: true,
+ polish: "offer",
+ vocabulary: ["Multica", "Lambda", "Tiptap", "workspace ID"],
+ keepRecordings: "off",
+ micPermission: "granted",
+ models: {
+ "sense-voice": { state: "ready" },
+ "parakeet-v3": { state: "available" },
+ "whisper-turbo": { state: "available" },
+ "moonshine-small": { state: "available" },
+ },
+};
+
+interface VoiceSettingsContext {
+ settings: VoiceSettings;
+ update: (patch: Partial<VoiceSettings>) => void;
+ download: (id: string) => void;
+ remove: (id: string) => void;
+ /** The model in use when the engine is local, if it is on disk. */
+ activeModel: LocalModel | null;
+}
+
+const Context = createContext<VoiceSettingsContext | null>(null);
+
+export function VoiceSettingsProvider({
+ initial,
+ children,
+}: {
+ initial?: Partial<VoiceSettings>;
+ children: ReactNode;
+}) {
+ const [settings, setSettings] = useState<VoiceSettings>(() => ({
+ ...DEFAULT_SETTINGS,
+ ...initial,
+ models: { ...DEFAULT_SETTINGS.models, ...initial?.models },
+ }));
+ const timers = useRef(new Map<string, number>());
+ useEffect(() => {
+ const map = timers.current;
+ return () => map.forEach((t) => window.clearInterval(t));
+ }, []);
+
+ const update = useCallback((patch: Partial<VoiceSettings>) => setSettings((s) => ({ ...s, ...patch })), []);
+
+ const download = useCallback((id: string) => {
+ const model = LOCAL_MODELS.find((m) => m.id === id);
+ if (!model || timers.current.has(id)) return;
+ // Paced so a 150 MB model takes about four seconds in the demo.
+ const step = Math.max(0.6, 2400 / model.sizeMb);
+ setSettings((s) => ({ ...s, models: { ...s.models, [id]: { state: "downloading", progress: 0 } } }));
+ const t = window.setInterval(() => {
+ setSettings((s) => {
+ const cur = s.models[id];
+ const progress = cur?.state === "downloading" ? Math.min(100, cur.progress + step) : 100;
+ if (progress >= 100) {
+ window.clearInterval(timers.current.get(id));
+ timers.current.delete(id);
+ return { ...s, models: { ...s.models, [id]: { state: "ready" } } };
+ }
+ return { ...s, models: { ...s.models, [id]: { state: "downloading", progress } } };
+ });
+ }, 60);
+ timers.current.set(id, t);
+ }, []);
+
+ const remove = useCallback((id: string) => {
+ window.clearInterval(timers.current.get(id));
+ timers.current.delete(id);
+ setSettings((s) => ({ ...s, models: { ...s.models, [id]: { state: "available" } } }));
+ }, []);
+
+ const value = useMemo<VoiceSettingsContext>(() => {
+ const model = LOCAL_MODELS.find((m) => m.id === settings.model) ?? null;
+ const ready = model && settings.models[model.id]?.state === "ready";
+ return { settings, update, download, remove, activeModel: ready ? model : null };
+ }, [settings, update, download, remove]);
+
+ return <Context.Provider value={value}>{children}</Context.Provider>;
+}
+
+const FALLBACK: VoiceSettingsContext = {
+ settings: DEFAULT_SETTINGS,
+ update: () => {},
+ download: () => {},
+ remove: () => {},
+ activeModel: LOCAL_MODELS[0]!,
+};
+
+export function useVoiceSettings(): VoiceSettingsContext {
+ return useContext(Context) ?? FALLBACK;
+}
+
+export function formatSize(mb: number): string {
+ return mb >= 1000 ? `${(mb / 1024).toFixed(1)} GB` : `${mb} MB`;
+}
diff --git a/apps/storybook/src/voice-input/settings/voice-settings-page.tsx b/apps/storybook/src/voice-input/settings/voice-settings-page.tsx
new file mode 100644
index 0000000000..e673995b73
--- /dev/null
+++ b/apps/storybook/src/voice-input/settings/voice-settings-page.tsx
@@ -0,0 +1,554 @@
+import { useEffect, useState, type ReactNode } from "react";
+import {
+ AlertCircle,
+ CheckCircle2,
+ Download,
+ ExternalLink,
+ Info,
+ MicOff,
+ ShieldCheck,
+ Trash2,
+ X,
+} from "@multica/ui/icons";
+import { Button } from "@multica/ui/components/ui/button";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { Kbd } from "@multica/ui/components/ui/kbd";
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@multica/ui/components/ui/select";
+import { Switch } from "@multica/ui/components/ui/switch";
+import { cn } from "@multica/ui/lib/utils";
+import { useStoryEnv } from "../env";
+import { CommentComposer } from "../composer/surfaces";
+import { VoiceProvider } from "../composer/voice-provider";
+import { ShortcutKeys } from "../composer/voice-ui";
+import { SETTINGS_COPY, type SettingsCopy } from "./copy";
+import { SegmentedToggle, SettingsCard, SettingsRow, SettingsSection, SettingsShell } from "./layout";
+import { LOCAL_MODELS, formatSize, useVoiceSettings, type LocalModel, type ModelStatus } from "./store";
+
+export function useSettingsCopy(): SettingsCopy {
+ return SETTINGS_COPY[useStoryEnv().lang];
+}
+
+function SelectRow<T extends string>({
+ label,
+ description,
+ value,
+ options,
+ onChange,
+ size = "select",
+}: {
+ label: string;
+ description?: string;
+ value: T;
+ options: Record<T, string>;
+ onChange: (v: T) => void;
+ size?: "select" | "select-wide";
+}) {
+ const items = (Object.keys(options) as T[]).map((k) => ({ value: k, label: options[k] }));
+ return (
+ <SettingsRow label={label} description={description} size={size}>
+ <Select items={items} value={value} onValueChange={(v) => v && onChange(v as T)}>
+ <SelectTrigger size="sm" className="w-full" aria-label={label}>
+ <SelectValue>{options[value]}</SelectValue>
+ </SelectTrigger>
+ <SelectContent align="end">
+ {items.map((o) => (
+ <SelectItem key={o.value} value={o.value}>
+ {o.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </SettingsRow>
+ );
+}
+
+function SwitchRow({ label, description, checked, onChange }: { label: string; description?: string; checked: boolean; onChange: (v: boolean) => void }) {
+ return (
+ <SettingsRow label={label} description={description}>
+ <Switch checked={checked} onCheckedChange={onChange} aria-label={label} />
+ </SettingsRow>
+ );
+}
+
+/** A banner above the sections for anything that stops voice input working. */
+function Notice({
+ tone,
+ icon,
+ title,
+ body,
+ action,
+}: {
+ tone: "danger" | "info";
+ icon: ReactNode;
+ title: string;
+ body: string;
+ action?: ReactNode;
+}) {
+ return (
+ <div
+ role="note"
+ className={cn(
+ "flex items-start gap-3 rounded-xl border px-4 py-3",
+ tone === "danger" ? "border-destructive/25 bg-destructive/5" : "border-surface-border bg-surface",
+ )}
+ >
+ <span className={cn("mt-0.5 shrink-0 [&_svg]:size-4", tone === "danger" ? "text-destructive" : "text-muted-foreground")}>{icon}</span>
+ <div className="min-w-0 flex-1">
+ <p className="text-body font-medium">{title}</p>
+ <p className="mt-0.5 text-caption leading-5 text-muted-foreground">{body}</p>
+ </div>
+ {action && <div className="shrink-0 self-center">{action}</div>}
+ </div>
+ );
+}
+
+export function VoiceNotices() {
+ const copy = useSettingsCopy();
+ const { settings, update, download, activeModel } = useVoiceSettings();
+ const notices: ReactNode[] = [];
+ if (settings.micPermission === "denied") {
+ notices.push(
+ <Notice
+ key="denied"
+ tone="danger"
+ icon={<MicOff />}
+ title={copy.deniedTitle}
+ body={copy.deniedBody}
+ action={
+ <Button size="sm" variant="outline" onClick={() => update({ micPermission: "granted" })}>
+ {copy.deniedAction}
+ <ExternalLink data-icon="inline-end" />
+ </Button>
+ }
+ />,
+ );
+ }
+ if (settings.platform === "web") {
+ notices.push(
+ <Notice
+ key="web"
+ tone="info"
+ icon={<Info />}
+ title={copy.webTitle}
+ body={copy.webBody}
+ action={
+ <Button size="sm" variant="outline">
+ {copy.webAction}
+ </Button>
+ }
+ />,
+ );
+ } else if (settings.engine === "local" && !activeModel) {
+ const model = LOCAL_MODELS.find((m) => m.id === settings.model) ?? LOCAL_MODELS[0]!;
+ const status = settings.models[model.id];
+ if (status?.state !== "downloading") {
+ notices.push(
+ <Notice
+ key="model"
+ tone="danger"
+ icon={<AlertCircle />}
+ title={copy.noModelTitle}
+ body={copy.noModelBody}
+ action={
+ <Button size="sm" variant="brand" onClick={() => download(model.id)}>
+ <Download data-icon="inline-start" />
+ {copy.noModelAction} {model.name} · {formatSize(model.sizeMb)}
+ </Button>
+ }
+ />,
+ );
+ }
+ }
+ return notices.length ? <div className="space-y-3">{notices}</div> : null;
+}
+
+function ShortcutRecorder() {
+ const copy = useSettingsCopy();
+ const { settings, update } = useVoiceSettings();
+ const [recording, setRecording] = useState(false);
+ useEffect(() => {
+ if (!recording) return;
+ const down = (e: KeyboardEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ if (e.key === "Escape") return setRecording(false);
+ if (["Alt", "Meta", "Control", "Shift"].includes(e.key)) return;
+ const keys = [e.metaKey || e.ctrlKey ? "⌘" : "", e.altKey ? "⌥" : "", e.shiftKey ? "⇧" : ""].filter(Boolean);
+ if (!keys.length) return;
+ const main = e.code === "Space" ? "Space" : e.code.replace(/^Key/, "");
+ update({ shortcut: [...keys, main] });
+ setRecording(false);
+ };
+ window.addEventListener("keydown", down, true);
+ return () => window.removeEventListener("keydown", down, true);
+ }, [recording, update]);
+ return (
+ <button
+ type="button"
+ aria-label={copy.changeShortcut}
+ onClick={() => setRecording(true)}
+ className={cn(
+ "flex h-8 min-w-28 items-center justify-center gap-2 rounded-md border px-2.5 text-caption transition-colors",
+ recording ? "border-brand bg-brand/5 text-brand ring-3 ring-ring/30" : "border-input hover:bg-surface-hover",
+ )}
+ >
+ {recording ? copy.pressKeys : <ShortcutKeys keys={settings.shortcut} />}
+ </button>
+ );
+}
+
+function Dots({ n, label }: { n: number; label: string }) {
+ return (
+ <span className="inline-flex items-center gap-1" title={label}>
+ {label}
+ <span className="inline-flex gap-0.5">
+ {[1, 2, 3].map((i) => (
+ <span key={i} className={cn("size-1.5 rounded-full", i <= n ? "bg-foreground/70" : "bg-foreground/15")} />
+ ))}
+ </span>
+ </span>
+ );
+}
+
+function ModelRow({ model, status, selected }: { model: LocalModel; status: ModelStatus; selected: boolean }) {
+ const copy = useSettingsCopy();
+ const { lang } = useStoryEnv();
+ const { update, download, remove } = useVoiceSettings();
+ const ready = status.state === "ready";
+ return (
+ <div className={cn("flex items-center gap-3 px-4 py-3", selected && ready && "bg-brand/[0.035]")}>
+ <button
+ type="button"
+ aria-label={`${copy.use} ${model.name}`}
+ disabled={!ready}
+ onClick={() => update({ model: model.id })}
+ className={cn(
+ // eslint-disable-next-line no-restricted-syntax -- a radio
+ "flex size-4 shrink-0 items-center justify-center rounded-full border transition-colors disabled:opacity-40",
+ selected && ready ? "border-brand bg-brand" : "border-input",
+ )}
+ >
+ {selected && ready && <span className="size-1.5 rounded-full bg-brand-foreground" />}
+ </button>
+ <div className="min-w-0 flex-1">
+ <div className="flex flex-wrap items-center gap-1.5">
+ <span className="text-body font-medium">{model.name}</span>
+ {model.recommendedFor === lang && (
+ <span className="rounded-full bg-brand/10 px-1.5 py-px text-micro font-medium text-brand">{copy.recommended[lang]}</span>
+ )}
+ {model.streaming && (
+ <span className="rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground">{copy.streaming}</span>
+ )}
+ </div>
+ <div className="mt-0.5 truncate text-caption text-muted-foreground">{model.languages[lang]}</div>
+ <div className="mt-1 flex items-center gap-3 text-micro text-faint-foreground">
+ <span className="tabular-nums">{formatSize(model.sizeMb)}</span>
+ <Dots n={model.speed} label={copy.speed} />
+ <Dots n={model.accuracy} label={copy.accuracy} />
+ </div>
+ </div>
+ <div className="flex shrink-0 items-center justify-end gap-1">
+ {status.state === "available" && (
+ <Button size="xs" variant="outline" onClick={() => download(model.id)}>
+ <Download data-icon="inline-start" />
+ {copy.download}
+ </Button>
+ )}
+ {status.state === "downloading" && (
+ <div className="flex w-40 items-center gap-2">
+ <div className="h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-muted">
+ <div className="h-full rounded-full bg-brand transition-[width] duration-100" style={{ width: `${status.progress}%` }} />
+ </div>
+ <span className="w-8 text-right text-micro tabular-nums text-muted-foreground">{Math.round(status.progress)}%</span>
+ <IconButton label={copy.cancelDownload} onClick={() => remove(model.id)} className="text-muted-foreground">
+ <X />
+ </IconButton>
+ </div>
+ )}
+ {ready &&
+ (selected ? (
+ <span className="flex items-center gap-1 px-2 text-caption font-medium text-brand">
+ <CheckCircle2 className="size-3.5" />
+ {copy.inUse}
+ </span>
+ ) : (
+ <>
+ <Button size="xs" variant="ghost" onClick={() => update({ model: model.id })}>
+ {copy.use}
+ </Button>
+ <IconButton label={copy.deleteModel} onClick={() => remove(model.id)} className="text-muted-foreground">
+ <Trash2 />
+ </IconButton>
+ </>
+ ))}
+ </div>
+ </div>
+ );
+}
+
+export function ShortcutCard() {
+ const copy = useSettingsCopy();
+ const { settings, update } = useVoiceSettings();
+ return (
+ <SettingsCard>
+ <SettingsRow label={copy.shortcut} description={copy.shortcutHint}>
+ <ShortcutRecorder />
+ </SettingsRow>
+ <SettingsRow label={copy.activation} description={copy.activationHint[settings.activation]} size="select-wide">
+ <SegmentedToggle
+ value={settings.activation}
+ onChange={(activation) => update({ activation })}
+ options={[
+ ["auto", copy.activationOptions.auto],
+ ["toggle", copy.activationOptions.toggle],
+ ["hold", copy.activationOptions.hold],
+ ]}
+ />
+ </SettingsRow>
+ {settings.platform === "desktop" && (
+ <SwitchRow
+ label={copy.background}
+ description={copy.backgroundHint}
+ checked={settings.globalShortcut}
+ onChange={(globalShortcut) => update({ globalShortcut })}
+ />
+ )}
+ <SettingsRow label={copy.cancelKey} description={copy.cancelHint}>
+ <Kbd>Esc</Kbd>
+ </SettingsRow>
+ </SettingsCard>
+ );
+}
+
+export function EngineCard() {
+ const copy = useSettingsCopy();
+ const { settings, update } = useVoiceSettings();
+ const web = settings.platform === "web";
+ const engine = web ? "cloud" : settings.engine;
+ return (
+ <SettingsCard>
+ <SettingsRow label={copy.engine} description={web ? copy.webBody : copy.engineHint[engine]} size="select">
+ <SegmentedToggle
+ value={engine}
+ onChange={(e) => update({ engine: e })}
+ disabled={web ? ["local"] : []}
+ options={[
+ ["local", copy.engineOptions.local],
+ ["cloud", copy.engineOptions.cloud],
+ ]}
+ />
+ </SettingsRow>
+ {engine === "local" && (
+ <div>
+ <div className="px-4 pt-3 pb-1">
+ <div className="text-body font-medium">{copy.models}</div>
+ <div className="mt-0.5 text-caption text-muted-foreground">{copy.modelsHint}</div>
+ </div>
+ <div className="divide-y divide-surface-border">
+ {LOCAL_MODELS.map((m) => (
+ <ModelRow key={m.id} model={m} status={settings.models[m.id] ?? { state: "available" }} selected={settings.model === m.id} />
+ ))}
+ </div>
+ </div>
+ )}
+ <SelectRow
+ label={copy.language}
+ value={settings.language}
+ options={copy.languageOptions}
+ onChange={(language) => update({ language })}
+ />
+ {(settings.language === "auto" || settings.language === "zh") && (
+ <SettingsRow label={copy.chineseScript} size="select">
+ <SegmentedToggle
+ value={settings.chineseScript}
+ onChange={(chineseScript) => update({ chineseScript })}
+ options={[
+ ["simplified", copy.scriptOptions.simplified],
+ ["traditional", copy.scriptOptions.traditional],
+ ]}
+ />
+ </SettingsRow>
+ )}
+ </SettingsCard>
+ );
+}
+
+function useTestMeter(on: boolean) {
+ const [level, setLevel] = useState(0);
+ useEffect(() => {
+ if (!on) return setLevel(0);
+ const t0 = performance.now();
+ const id = window.setInterval(() => {
+ const t = performance.now() - t0;
+ const speaking = Math.sin(t / 900) > -0.3;
+ const v = speaking ? 0.25 + 0.55 * Math.abs(Math.sin(t / 80) * Math.sin(t / 210)) + Math.random() * 0.15 : 0.04 + Math.random() * 0.04;
+ setLevel((l) => l * 0.4 + v * 0.6);
+ }, 50);
+ return () => window.clearInterval(id);
+ }, [on]);
+ return level;
+}
+
+function MicCard() {
+ const copy = useSettingsCopy();
+ const { settings, update } = useVoiceSettings();
+ const [testing, setTesting] = useState(false);
+ const level = useTestMeter(testing);
+ const segments = 16;
+ return (
+ <SettingsCard>
+ <SelectRow
+ label={copy.device}
+ value={settings.microphone as keyof SettingsCopy["devices"]}
+ options={copy.devices}
+ onChange={(microphone) => update({ microphone })}
+ size="select-wide"
+ />
+ <SettingsRow label={copy.test} description={copy.testHint} size="select-wide">
+ <div className="flex items-center gap-3">
+ <div className="flex h-3 flex-1 items-center gap-[3px]" aria-hidden>
+ {Array.from({ length: segments }, (_, i) => (
+ <span
+ key={i}
+ className={cn(
+ "h-full flex-1 rounded-[1px] transition-colors duration-75",
+ i / segments < level ? (i > segments * 0.8 ? "bg-warning" : "bg-success") : "bg-muted",
+ )}
+ />
+ ))}
+ </div>
+ <Button size="xs" variant="outline" onClick={() => setTesting((t) => !t)}>
+ {testing ? copy.stopTest : copy.startTest}
+ </Button>
+ </div>
+ </SettingsRow>
+ <SwitchRow label={copy.sounds} description={copy.soundsHint} checked={settings.sounds} onChange={(sounds) => update({ sounds })} />
+ {settings.platform === "desktop" && (
+ <SwitchRow label={copy.muteOthers} checked={settings.muteOthers} onChange={(muteOthers) => update({ muteOthers })} />
+ )}
+ </SettingsCard>
+ );
+}
+
+function Vocabulary() {
+ const copy = useSettingsCopy();
+ const { settings, update } = useVoiceSettings();
+ const [draft, setDraft] = useState("");
+ const add = () => {
+ const w = draft.trim();
+ if (w && !settings.vocabulary.includes(w)) update({ vocabulary: [...settings.vocabulary, w] });
+ setDraft("");
+ };
+ return (
+ <SettingsRow label={copy.vocabulary} description={copy.vocabularyHint} size="text" align="start">
+ <div className="flex min-h-8 flex-wrap items-center gap-1 rounded-md border border-input px-1.5 py-1 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50">
+ {settings.vocabulary.map((w) => (
+ <span key={w} className="inline-flex h-6 items-center gap-1 rounded-sm bg-muted pl-2 pr-1 text-caption">
+ {w}
+ <button
+ type="button"
+ aria-label={`${copy.deleteModel} ${w}`}
+ onClick={() => update({ vocabulary: settings.vocabulary.filter((x) => x !== w) })}
+ className="flex size-4 items-center justify-center rounded-xs text-muted-foreground hover:bg-surface-hover hover:text-foreground"
+ >
+ <X className="size-3" />
+ </button>
+ </span>
+ ))}
+ <input
+ value={draft}
+ onChange={(e) => setDraft(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && !e.nativeEvent.isComposing) {
+ e.preventDefault();
+ add();
+ }
+ }}
+ placeholder={copy.addWord}
+ className="h-6 min-w-24 flex-1 bg-transparent px-1 text-caption outline-none placeholder:text-muted-foreground"
+ />
+ </div>
+ </SettingsRow>
+ );
+}
+
+function TextCard() {
+ const copy = useSettingsCopy();
+ const { settings, update } = useVoiceSettings();
+ return (
+ <SettingsCard>
+ <SwitchRow
+ label={copy.fillers}
+ description={copy.fillersHint}
+ checked={settings.removeFillers}
+ onChange={(removeFillers) => update({ removeFillers })}
+ />
+ <SelectRow
+ label={copy.polish}
+ description={copy.polishHint}
+ value={settings.polish}
+ options={copy.polishOptions}
+ onChange={(polish) => update({ polish })}
+ size="select-wide"
+ />
+ <Vocabulary />
+ </SettingsCard>
+ );
+}
+
+function PrivacyCard() {
+ const copy = useSettingsCopy();
+ const { settings, update } = useVoiceSettings();
+ const local = settings.platform === "desktop" && settings.engine === "local";
+ return (
+ <SettingsCard>
+ <SelectRow
+ label={copy.keep}
+ description={copy.keepHint}
+ value={settings.keepRecordings}
+ options={copy.keepOptions}
+ onChange={(keepRecordings) => update({ keepRecordings })}
+ />
+ <div className="flex items-center gap-2 px-4 py-3 text-caption text-muted-foreground">
+ <ShieldCheck className="size-4 shrink-0" />
+ {local ? copy.privacyLocal : copy.privacyCloud}
+ </div>
+ </SettingsCard>
+ );
+}
+
+/** Settings → Voice input. Every control feeds the same store the composers read. */
+export function VoiceSettingsPage() {
+ const copy = useSettingsCopy();
+ return (
+ <SettingsShell copy={copy} title={copy.nav.voice} scope={copy.scopeDevice}>
+ <div className="space-y-8">
+ <p className="max-w-2xl text-body leading-6 text-muted-foreground">{copy.intro}</p>
+ <VoiceNotices />
+ <SettingsSection title={copy.shortcutSection}>
+ <ShortcutCard />
+ </SettingsSection>
+ <SettingsSection title={copy.recognitionSection}>
+ <EngineCard />
+ </SettingsSection>
+ <SettingsSection title={copy.micSection}>
+ <MicCard />
+ </SettingsSection>
+ <SettingsSection title={copy.textSection}>
+ <TextCard />
+ </SettingsSection>
+ <SettingsSection title={copy.privacySection}>
+ <PrivacyCard />
+ </SettingsSection>
+ <SettingsSection title={copy.trySection} description={copy.trySectionHint}>
+ <VoiceProvider primaryId="settings-try">
+ <div className="pt-14">
+ <CommentComposer id="settings-try" onSend={() => {}} trigger={false} />
+ </div>
+ </VoiceProvider>
+ </SettingsSection>
+ </div>
+ </SettingsShell>
+ );
+}
+
diff --git a/apps/storybook/src/voice-input/setup/first-use.tsx b/apps/storybook/src/voice-input/setup/first-use.tsx
new file mode 100644
index 0000000000..919fe97eca
--- /dev/null
+++ b/apps/storybook/src/voice-input/setup/first-use.tsx
@@ -0,0 +1,396 @@
+import { useEffect, useRef, useState } from "react";
+import { Check, CheckCircle2, Cloud, Download, Laptop, Mic, X } from "@multica/ui/icons";
+import { Button } from "@multica/ui/components/ui/button";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { cn } from "@multica/ui/lib/utils";
+import type { Lang, VoiceScript } from "../copy";
+import { useStoryEnv } from "../env";
+import { RecDot, Shimmer, Waveform } from "../primitives";
+import { ShortcutKeys } from "../composer/voice-ui";
+import { LOCAL_MODELS, formatSize, useVoiceSettings, type Engine } from "../settings/store";
+import { useVoiceSession, type VoiceSession } from "../voice-session";
+
+export type SetupStep = "permission" | "engine" | "try" | "done";
+
+const STEPS: SetupStep[] = ["permission", "engine", "try", "done"];
+
+const TRY_SCRIPT: Record<Lang, VoiceScript> = {
+ en: { phrases: ["Can we move tomorrow's design review", " to three?"], polished: "Can we move tomorrow's design review to three?" },
+ zh: { phrases: ["明天的设计评审", "能改到三点吗?"], polished: "明天的设计评审能改到三点吗?" },
+};
+
+const C = {
+ en: {
+ stepNames: { permission: "Microphone", engine: "Engine", try: "Try it", done: "Done" },
+ permissionTitle: "Talk instead of typing",
+ permissionBody: "Dictate into chat, comments and replies. Two quick steps first.",
+ permissionPoints: ["Tap the mic to dictate, or hold it to talk.", "Audio is only used to turn what you say into text."],
+ allow: "Allow microphone",
+ waiting: "Waiting for macOS…",
+ engineTitle: "Where should speech be recognized?",
+ local: "On this device",
+ localBody: "Works offline and audio never leaves this computer.",
+ localNeeds: "Downloads",
+ cloud: "Multica Cloud",
+ cloudBody: "Ready right away. Audio is sent to Multica and deleted after.",
+ recommended: "Recommended",
+ continue: "Continue",
+ downloading: "Downloading",
+ useCloudMeanwhile: "Use the cloud while it downloads",
+ tryTitle: "Try it",
+ tryBody: "Hold the button, or hold the shortcut, and read this out:",
+ holdHere: "Hold to talk",
+ heard: "Got it",
+ again: "Try again",
+ doneTitle: "You're set",
+ doneShortcut: "Shortcut",
+ doneEngine: "Engine",
+ doneHint: "Change these anytime in Settings → Voice input.",
+ finish: "Start dictating",
+ skip: "Skip",
+ },
+ zh: {
+ stepNames: { permission: "麦克风", engine: "识别方式", try: "试一下", done: "完成" },
+ permissionTitle: "用说的,不用打字",
+ permissionBody: "在聊天、评论和回复里都能用语音输入。先做两步设置。",
+ permissionPoints: ["点一下麦克风开始听写,按住就是边说边录。", "音频只用来把你说的话转成文字。"],
+ allow: "允许使用麦克风",
+ waiting: "等待 macOS 授权…",
+ engineTitle: "在哪里识别语音?",
+ local: "本机",
+ localBody: "离线可用,音频不会离开这台电脑。",
+ localNeeds: "需要下载",
+ cloud: "Multica 云端",
+ cloudBody: "马上能用。音频发送到 Multica 识别,识别完即删除。",
+ recommended: "推荐",
+ continue: "继续",
+ downloading: "正在下载",
+ useCloudMeanwhile: "下载期间先用云端",
+ tryTitle: "试一下",
+ tryBody: "按住下面的按钮或快捷键,读出这句话:",
+ holdHere: "按住说话",
+ heard: "识别成功",
+ again: "再试一次",
+ doneTitle: "设置好了",
+ doneShortcut: "快捷键",
+ doneEngine: "识别方式",
+ doneHint: "随时可以在「设置 → 语音输入」里修改。",
+ finish: "开始使用",
+ skip: "跳过",
+ },
+};
+
+function StepDots({ step, lang }: { step: SetupStep; lang: Lang }) {
+ const at = STEPS.indexOf(step);
+ return (
+ <ol className="flex items-center gap-2 text-micro">
+ {STEPS.slice(0, 3).map((s, i) => (
+ <li key={s} className="flex items-center gap-2">
+ <span
+ className={cn(
+ "flex size-4 items-center justify-center rounded-full text-[10px] font-semibold",
+ i < at ? "bg-brand text-brand-foreground" : i === at ? "bg-foreground text-background" : "bg-muted text-muted-foreground",
+ )}
+ >
+ {i < at ? <Check className="size-2.5" /> : i + 1}
+ </span>
+ <span className={cn(i === at ? "font-medium text-foreground" : "text-muted-foreground")}>{C[lang].stepNames[s]}</span>
+ {i < 2 && <span className="h-px w-5 bg-border" />}
+ </li>
+ ))}
+ </ol>
+ );
+}
+
+function EngineOption({
+ selected,
+ onSelect,
+ icon,
+ title,
+ body,
+ badge,
+ extra,
+}: {
+ selected: boolean;
+ onSelect: () => void;
+ icon: React.ReactNode;
+ title: string;
+ body: string;
+ badge?: string;
+ extra?: React.ReactNode;
+}) {
+ return (
+ <button
+ type="button"
+ onClick={onSelect}
+ aria-pressed={selected}
+ className={cn(
+ "flex w-full items-start gap-3 rounded-lg border p-3.5 text-left transition-colors",
+ selected ? "border-brand bg-brand/5 ring-1 ring-brand" : "border-input hover:bg-surface-hover",
+ )}
+ >
+ <span className={cn("mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md", selected ? "bg-brand/12 text-brand" : "bg-muted text-muted-foreground")}>
+ {icon}
+ </span>
+ <span className="min-w-0 flex-1">
+ <span className="flex items-center gap-1.5">
+ <span className="text-body font-medium">{title}</span>
+ {badge && <span className="rounded-full bg-brand/10 px-1.5 py-px text-micro font-medium text-brand">{badge}</span>}
+ </span>
+ <span className="mt-0.5 block text-caption text-muted-foreground">{body}</span>
+ {extra}
+ </span>
+ </button>
+ );
+}
+
+function TryPad({ session, lang, onPress, onRelease }: { session: VoiceSession; lang: Lang; onPress: () => void; onRelease: () => void }) {
+ const c = C[lang];
+ const { phase } = session;
+ const listening = phase === "listening" || phase === "requesting";
+ return (
+ <div className="flex flex-col items-center gap-4 rounded-lg bg-surface px-4 py-6 ring-1 ring-surface-border">
+ <p className="text-center text-title-sm font-medium">“{TRY_SCRIPT[lang].polished}”</p>
+ <div className="flex h-6 items-center">
+ {listening ? (
+ <span className="flex items-center gap-2">
+ <RecDot />
+ <Waveform levels={session.levels} bars={40} className="h-6 w-40 text-foreground" />
+ </span>
+ ) : phase === "processing" ? (
+ <Shimmer>{lang === "zh" ? "正在转写…" : "Transcribing…"}</Shimmer>
+ ) : null}
+ </div>
+ <button
+ type="button"
+ onPointerDown={(e) => {
+ e.currentTarget.setPointerCapture(e.pointerId);
+ onPress();
+ }}
+ onPointerUp={onRelease}
+ aria-label={c.holdHere}
+ className={cn(
+ // eslint-disable-next-line no-restricted-syntax -- the composer send button's hold-to-talk twin, the setup's one primary control
+ "flex size-16 touch-none items-center justify-center rounded-full transition-all",
+ listening ? "scale-110 bg-brand text-brand-foreground shadow-[0_0_0_8px_color-mix(in_oklab,var(--brand)_18%,transparent)]" : "bg-foreground text-background hover:scale-105",
+ )}
+ >
+ <Mic className="size-6" />
+ </button>
+ <span className="text-caption text-muted-foreground">{c.holdHere}</span>
+ </div>
+ );
+}
+
+/**
+ * First-use setup, shown the first time someone presses the mic. Modeled on
+ * Handy's onboarding (permissions → model → try it), trimmed to what Multica
+ * needs before the first dictation.
+ */
+export function FirstUseDialog({
+ initialStep = "permission",
+ frozen,
+ onClose,
+}: {
+ initialStep?: SetupStep;
+ /** Pin the try step's session, for the gallery. */
+ frozen?: VoiceSession;
+ onClose?: () => void;
+}) {
+ const { lang, source } = useStoryEnv();
+ const c = C[lang];
+ const { settings, update, download } = useVoiceSettings();
+ const [step, setStep] = useState<SetupStep>(initialStep);
+ const [asking, setAsking] = useState(false);
+ const [choice, setChoice] = useState<Engine>(settings.engine);
+ const model = LOCAL_MODELS.find((m) => m.recommendedFor === lang) ?? LOCAL_MODELS[0]!;
+ const status = settings.models[model.id];
+ const [heard, setHeard] = useState("");
+
+ const live = useVoiceSession({ source, lang, script: TRY_SCRIPT[lang], processingMs: 600 });
+ const session = frozen ?? live;
+ const liveRef = useRef(live);
+ liveRef.current = live;
+ useEffect(() => {
+ if (liveRef.current.phase === "done") {
+ setHeard(liveRef.current.result);
+ liveRef.current.reset();
+ }
+ }, [live.phase]);
+
+ useEffect(() => {
+ if (step !== "try" || frozen) return;
+ const down = (e: KeyboardEvent) => {
+ if (e.code === "Space" && e.altKey) {
+ e.preventDefault();
+ if (!e.repeat && liveRef.current.phase === "idle") liveRef.current.start();
+ }
+ };
+ const up = (e: KeyboardEvent) => {
+ if ((e.code === "Space" || e.key === "Alt") && liveRef.current.phase === "listening") liveRef.current.stop();
+ };
+ window.addEventListener("keydown", down);
+ window.addEventListener("keyup", up);
+ return () => {
+ window.removeEventListener("keydown", down);
+ window.removeEventListener("keyup", up);
+ };
+ }, [step, frozen]);
+
+ const allow = () => {
+ setAsking(true);
+ window.setTimeout(() => {
+ setAsking(false);
+ update({ micPermission: "granted" });
+ setStep("engine");
+ }, 1100);
+ };
+
+ const continueFromEngine = () => {
+ update({ engine: choice, model: model.id });
+ if (choice === "local" && status?.state !== "ready") download(model.id);
+ setStep("try");
+ };
+
+ const downloading = settings.models[model.id]?.state === "downloading";
+ const progress = (() => {
+ const s = settings.models[model.id];
+ return s?.state === "downloading" ? s.progress : s?.state === "ready" ? 100 : 0;
+ })();
+
+ return (
+ <div role="dialog" aria-label={c.permissionTitle} className="w-[480px] overflow-hidden rounded-xl bg-surface-raised shadow-[var(--floating-shadow)] ring-1 ring-floating-border">
+ <div className="flex items-center justify-between border-b px-5 py-3">
+ <StepDots step={step} lang={lang} />
+ <IconButton label={c.skip} onClick={onClose} className="text-muted-foreground">
+ <X />
+ </IconButton>
+ </div>
+ <div className="px-6 py-6">
+ {step === "permission" && (
+ <>
+ <span className="flex size-10 items-center justify-center rounded-lg bg-brand/10 text-brand">
+ <Mic className="size-5" />
+ </span>
+ <h2 className="mt-4 text-title font-semibold">{c.permissionTitle}</h2>
+ <p className="mt-1.5 text-body text-muted-foreground">{c.permissionBody}</p>
+ <ul className="mt-4 space-y-2 text-body">
+ {c.permissionPoints.map((p) => (
+ <li key={p} className="flex gap-2">
+ <Check className="mt-1 size-3.5 shrink-0 text-brand" />
+ {p}
+ </li>
+ ))}
+ </ul>
+ <Button className="mt-6 w-full" variant="brand" onClick={allow} disabled={asking}>
+ {asking ? <Shimmer className="[--foreground:currentColor]">{c.waiting}</Shimmer> : c.allow}
+ </Button>
+ </>
+ )}
+
+ {step === "engine" && (
+ <>
+ <h2 className="text-title font-semibold">{c.engineTitle}</h2>
+ <div className="mt-4 space-y-2.5">
+ <EngineOption
+ selected={choice === "local"}
+ onSelect={() => setChoice("local")}
+ icon={<Laptop className="size-4" />}
+ title={c.local}
+ badge={c.recommended}
+ body={c.localBody}
+ extra={
+ <span className="mt-2 flex items-center gap-1.5 text-micro text-faint-foreground">
+ <Download className="size-3" />
+ {c.localNeeds} {model.name} · {formatSize(model.sizeMb)}
+ </span>
+ }
+ />
+ <EngineOption
+ selected={choice === "cloud"}
+ onSelect={() => setChoice("cloud")}
+ icon={<Cloud className="size-4" />}
+ title={c.cloud}
+ body={c.cloudBody}
+ />
+ </div>
+ <Button className="mt-6 w-full" variant="brand" onClick={continueFromEngine}>
+ {c.continue}
+ </Button>
+ </>
+ )}
+
+ {step === "try" && (
+ <>
+ <h2 className="text-title font-semibold">{c.tryTitle}</h2>
+ <p className="mt-1.5 text-body text-muted-foreground">{c.tryBody}</p>
+ {settings.engine === "local" && progress < 100 && (
+ <div className="mt-4 rounded-lg border border-surface-border px-3 py-2.5">
+ <div className="flex items-center justify-between text-caption">
+ <span>
+ {c.downloading} {model.name}
+ </span>
+ <span className="tabular-nums text-muted-foreground">{Math.round(progress)}%</span>
+ </div>
+ <div className="mt-2 h-1.5 overflow-hidden rounded-full bg-muted">
+ <div className="h-full rounded-full bg-brand transition-[width]" style={{ width: `${progress}%` }} />
+ </div>
+ {downloading && (
+ <button type="button" onClick={() => update({ engine: "cloud" })} className="mt-2 text-caption text-brand hover:underline">
+ {c.useCloudMeanwhile}
+ </button>
+ )}
+ </div>
+ )}
+ <div className="mt-4">
+ {heard && !frozen ? (
+ <div className="flex flex-col items-center gap-3 rounded-lg bg-success/8 px-4 py-6 ring-1 ring-success/25">
+ <CheckCircle2 className="size-6 text-success" />
+ <p className="text-center text-title-sm font-medium">{heard}</p>
+ <span className="text-caption text-muted-foreground">{c.heard}</span>
+ </div>
+ ) : (
+ <TryPad session={session} lang={lang} onPress={() => live.start()} onRelease={() => live.stop()} />
+ )}
+ </div>
+ <div className="mt-6 flex gap-2">
+ {heard && (
+ <Button variant="outline" className="flex-1" onClick={() => setHeard("")}>
+ {c.again}
+ </Button>
+ )}
+ <Button variant="brand" className="flex-1" disabled={!heard && !frozen} onClick={() => setStep("done")}>
+ {c.continue}
+ </Button>
+ </div>
+ </>
+ )}
+
+ {step === "done" && (
+ <>
+ <span className="flex size-10 items-center justify-center rounded-lg bg-success/10 text-success">
+ <CheckCircle2 className="size-5" />
+ </span>
+ <h2 className="mt-4 text-title font-semibold">{c.doneTitle}</h2>
+ <dl className="mt-4 divide-y divide-surface-border rounded-lg border border-surface-border text-body">
+ <div className="flex items-center justify-between px-3.5 py-2.5">
+ <dt className="text-muted-foreground">{c.doneShortcut}</dt>
+ <dd>
+ <ShortcutKeys keys={settings.shortcut} />
+ </dd>
+ </div>
+ <div className="flex items-center justify-between px-3.5 py-2.5">
+ <dt className="text-muted-foreground">{c.doneEngine}</dt>
+ <dd>{settings.engine === "local" ? `${c.local} · ${model.name}` : c.cloud}</dd>
+ </div>
+ </dl>
+ <p className="mt-3 text-caption text-muted-foreground">{c.doneHint}</p>
+ <Button className="mt-6 w-full" variant="brand" onClick={onClose}>
+ {c.finish}
+ </Button>
+ </>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/apps/storybook/src/voice-input/stage.tsx b/apps/storybook/src/voice-input/stage.tsx
new file mode 100644
index 0000000000..342c2fc7f5
--- /dev/null
+++ b/apps/storybook/src/voice-input/stage.tsx
@@ -0,0 +1,54 @@
+import type { ReactNode } from "react";
+import type { Lang } from "./copy";
+import { useStoryEnv } from "./env";
+
+export interface ConceptInfo {
+ letter: string;
+ name: Record<Lang, string>;
+ pitch: Record<Lang, string>;
+ how: Record<Lang, string[]>;
+ bestFor: Record<Lang, string>;
+ tradeoff: Record<Lang, string>;
+}
+
+/** A concept's live demo with its name and how to drive it. */
+export function DemoStage({ info, children }: { info: ConceptInfo; children: ReactNode }) {
+ const { lang, source } = useStoryEnv();
+ return (
+ <div className="flex items-start gap-10 p-8">
+ {children}
+ <aside className="w-72 shrink-0 pt-2">
+ <div className="text-caption font-medium text-brand">{info.letter}</div>
+ <h1 className="mt-1 text-title font-semibold">{info.name[lang]}</h1>
+ <p className="mt-2 text-body text-muted-foreground">{info.pitch[lang]}</p>
+ <ul className="mt-5 space-y-2 text-body">
+ {info.how[lang].map((step) => (
+ <li key={step} className="flex gap-2">
+ <span className="mt-2 size-1 shrink-0 rounded-full bg-faint-foreground" />
+ <span>{step}</span>
+ </li>
+ ))}
+ </ul>
+ <dl className="mt-6 space-y-3 text-caption">
+ <div>
+ <dt className="font-medium text-foreground">{lang === "zh" ? "适合" : "Best for"}</dt>
+ <dd className="mt-0.5 text-muted-foreground">{info.bestFor[lang]}</dd>
+ </div>
+ <div>
+ <dt className="font-medium text-foreground">{lang === "zh" ? "代价" : "Trade-off"}</dt>
+ <dd className="mt-0.5 text-muted-foreground">{info.tradeoff[lang]}</dd>
+ </div>
+ </dl>
+ <p className="mt-6 text-caption text-faint-foreground">
+ {source === "simulated"
+ ? lang === "zh"
+ ? "当前是模拟说话人。工具栏「Voice」切到「My microphone」可以用真麦克风试(Chrome 会做实时识别)。"
+ : "Using the simulated speaker. Switch Voice → My microphone in the toolbar to try your own voice (Chrome transcribes live)."
+ : lang === "zh"
+ ? "正在使用你的麦克风。"
+ : "Using your microphone."}
+ </p>
+ </aside>
+ </div>
+ );
+}
diff --git a/apps/storybook/src/voice-input/use-dictation.ts b/apps/storybook/src/voice-input/use-dictation.ts
new file mode 100644
index 0000000000..0630c7a7ca
--- /dev/null
+++ b/apps/storybook/src/voice-input/use-dictation.ts
@@ -0,0 +1,91 @@
+import { useCallback, useEffect, useRef, useState } from "react";
+import type { Lang } from "./copy";
+import { appendDictation } from "./env";
+import type { VoiceSession } from "./voice-session";
+
+export type CommitMode = "insert" | "send";
+
+/**
+ * Lands a finished session's text: into the draft for review, or straight out
+ * as a message. `landed` bumps on every insert so the editor can flash.
+ */
+export function useDictationCommit(
+ session: VoiceSession,
+ {
+ lang,
+ draft,
+ setDraft,
+ send,
+ enabled = true,
+ }: {
+ lang: Lang;
+ draft: string;
+ setDraft: (value: string) => void;
+ send: (text: string, viaVoice: boolean) => void;
+ enabled?: boolean;
+ },
+) {
+ const modeRef = useRef<CommitMode>("insert");
+ const draftRef = useRef(draft);
+ draftRef.current = draft;
+ const [landed, setLanded] = useState(0);
+ const [lastInsert, setLastInsert] = useState<{ before: string; raw: string } | null>(null);
+
+ useEffect(() => {
+ if (!enabled || session.phase !== "done") return;
+ const before = draftRef.current;
+ const text = appendDictation(before, session.result, lang);
+ if (modeRef.current === "send") {
+ send(text, true);
+ setDraft("");
+ setLastInsert(null);
+ } else {
+ setDraft(text);
+ setLanded((n) => n + 1);
+ setLastInsert({ before, raw: session.result });
+ }
+ modeRef.current = "insert";
+ session.reset();
+ // Only the transition into "done" should land text.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [session.phase, enabled]);
+
+ const stopAnd = useCallback(
+ (mode: CommitMode) => {
+ modeRef.current = mode;
+ session.stop();
+ },
+ [session],
+ );
+
+ return { stopAnd, landed, lastInsert, clearLastInsert: () => setLastInsert(null) };
+}
+
+/** Window-level key handling for a demo, active only while `enabled`. */
+export function useWindowKeys(
+ handlers: { down?: (e: KeyboardEvent) => void; up?: (e: KeyboardEvent) => void },
+ enabled = true,
+) {
+ const ref = useRef(handlers);
+ ref.current = handlers;
+ useEffect(() => {
+ if (!enabled) return;
+ const down = (e: KeyboardEvent) => ref.current.down?.(e);
+ const up = (e: KeyboardEvent) => ref.current.up?.(e);
+ window.addEventListener("keydown", down);
+ window.addEventListener("keyup", up);
+ return () => {
+ window.removeEventListener("keydown", down);
+ window.removeEventListener("keyup", up);
+ };
+ }, [enabled]);
+}
+
+/** ⌘⇧Space on macOS, Ctrl+Shift+Space elsewhere. */
+export function isToggleChord(e: KeyboardEvent): boolean {
+ return e.code === "Space" && e.shiftKey && (e.metaKey || e.ctrlKey) && !e.repeat;
+}
+
+export function isActive(phase: VoiceSession["phase"]): boolean {
+ return phase === "listening" || phase === "paused" || phase === "requesting";
+}
diff --git a/apps/storybook/src/voice-input/voice-session.ts b/apps/storybook/src/voice-input/voice-session.ts
new file mode 100644
index 0000000000..e2e31c8869
--- /dev/null
+++ b/apps/storybook/src/voice-input/voice-session.ts
@@ -0,0 +1,432 @@
+import { useCallback, useEffect, useRef, useState } from "react";
+import type { Lang, VoiceScript } from "./copy";
+
+export type VoicePhase = "idle" | "requesting" | "listening" | "paused" | "processing" | "done" | "error";
+export type VoiceError = "permission-denied" | "no-speech" | "network";
+export type VoiceSource = "simulated" | "microphone";
+
+export interface VoiceSnapshot {
+ phase: VoicePhase;
+ /** Smoothed input level, 0..1. */
+ level: number;
+ /** Level history, oldest first, one sample every SAMPLE_MS. */
+ levels: number[];
+ elapsedMs: number;
+ finalText: string;
+ interimText: string;
+ /** What gets inserted once the session is done. */
+ result: string;
+ error: VoiceError | null;
+}
+
+export interface VoiceSession extends VoiceSnapshot {
+ start: () => void;
+ stop: () => void;
+ cancel: () => void;
+ pause: () => void;
+ resume: () => void;
+ reset: () => void;
+ /** Re-transcribe the kept recording after a transcription failure; otherwise start over. */
+ retry: () => void;
+}
+
+export interface VoiceSessionOptions {
+ source: VoiceSource;
+ lang: Lang;
+ script: VoiceScript;
+ /** Return the polished text instead of the raw transcript. */
+ polish?: boolean;
+ processingMs?: number;
+ /** Simulated failure, to walk through error states. */
+ failWith?: VoiceError | null;
+ /** Simulated permission: "prompt" shows the request step on the first start. */
+ permission?: "granted" | "prompt";
+}
+
+export const SAMPLE_MS = 50;
+export const HISTORY = 160;
+
+const EMPTY: VoiceSnapshot = {
+ phase: "idle",
+ level: 0,
+ levels: Array.from({ length: HISTORY }, () => 0),
+ elapsedMs: 0,
+ finalText: "",
+ interimText: "",
+ result: "",
+ error: null,
+};
+
+const FILLERS = /^(um,?\s*|uh,?\s*|嗯,?|呃,?)/i;
+
+function tidy(text: string): string {
+ const t = text.trim().replace(FILLERS, "");
+ return t.charAt(0).toUpperCase() + t.slice(1);
+}
+
+/** Where the simulated speaker is at `t` ms into the recording. */
+function scriptAt(script: VoiceScript, lang: Lang, t: number) {
+ const msPerChar = lang === "zh" ? 210 : 52;
+ const gap = 420;
+ let cursor = 650;
+ let finalText = "";
+ for (const phrase of script.phrases) {
+ const duration = phrase.length * msPerChar;
+ if (t < cursor) return { finalText, interimText: "", speaking: false, finished: false };
+ if (t < cursor + duration) {
+ const shown = Math.floor((t - cursor) / msPerChar);
+ // Recognizers emit whole words (or two-character chunks in Chinese), not letters.
+ let cut = lang === "zh" ? shown - (shown % 2) : phrase.lastIndexOf(" ", shown);
+ while (cut > 0 && /[A-Za-z]/.test(phrase[cut - 1]!) && /[A-Za-z]/.test(phrase[cut] ?? "")) cut--;
+ return { finalText, interimText: phrase.slice(0, Math.max(0, cut)), speaking: true, finished: false };
+ }
+ finalText += phrase;
+ cursor += duration + gap;
+ }
+ return { finalText, interimText: "", speaking: false, finished: true };
+}
+
+/** A believable speech envelope: syllable-rate wobble on top of noise. */
+function speechLevel(t: number, speaking: boolean): number {
+ if (!speaking) return 0.03 + Math.random() * 0.04;
+ const syllable = 0.5 + 0.5 * Math.sin(t / 70) * Math.sin(t / 190 + 1.3);
+ return Math.min(1, 0.22 + syllable * 0.55 + Math.random() * 0.2);
+}
+
+type SpeechRecognitionLike = {
+ lang: string;
+ continuous: boolean;
+ interimResults: boolean;
+ start: () => void;
+ stop: () => void;
+ abort: () => void;
+ onresult: ((event: { resultIndex: number; results: ArrayLike<ArrayLike<{ transcript: string }> & { isFinal: boolean }> }) => void) | null;
+ onerror: ((event: { error: string }) => void) | null;
+ onend: (() => void) | null;
+};
+
+function createRecognizer(): SpeechRecognitionLike | null {
+ const w = window as unknown as Record<string, (new () => SpeechRecognitionLike) | undefined>;
+ const Ctor = w.SpeechRecognition ?? w.webkitSpeechRecognition;
+ return Ctor ? new Ctor() : null;
+}
+
+interface MicRig {
+ stream: MediaStream;
+ context: AudioContext;
+ analyser: AnalyserNode;
+ buffer: Float32Array<ArrayBuffer>;
+ recognizer: SpeechRecognitionLike | null;
+ recognized: { final: string; interim: string };
+ wantRecognition: boolean;
+}
+
+export function useVoiceSession(options: VoiceSessionOptions): VoiceSession {
+ const [snap, setSnap] = useState<VoiceSnapshot>(EMPTY);
+ const optsRef = useRef(options);
+ optsRef.current = options;
+ const stateRef = useRef<VoiceSnapshot>(EMPTY);
+ const timerRef = useRef<number | null>(null);
+ const phaseStartedRef = useRef(0);
+ const permissionGrantedRef = useRef(false);
+ const micRef = useRef<MicRig | null>(null);
+ const lastTickRef = useRef(0);
+ const retriedRef = useRef(false);
+
+ const commit = useCallback((patch: Partial<VoiceSnapshot>) => {
+ stateRef.current = { ...stateRef.current, ...patch };
+ setSnap(stateRef.current);
+ }, []);
+
+ const teardownMic = useCallback(() => {
+ const rig = micRef.current;
+ micRef.current = null;
+ if (!rig) return;
+ rig.wantRecognition = false;
+ rig.recognizer?.abort();
+ rig.stream.getTracks().forEach((track) => track.stop());
+ void rig.context.close();
+ }, []);
+
+ const stopTimer = useCallback(() => {
+ if (timerRef.current !== null) window.clearInterval(timerRef.current);
+ timerRef.current = null;
+ }, []);
+
+ const finish = useCallback(() => {
+ const s = stateRef.current;
+ const { script, polish, failWith } = optsRef.current;
+ const spoken = (s.finalText + s.interimText).trim();
+ if (!spoken) {
+ commit({ phase: "error", error: "no-speech", level: 0 });
+ stopTimer();
+ return;
+ }
+ if (failWith === "network" && !retriedRef.current) {
+ commit({ phase: "error", error: "network", level: 0 });
+ stopTimer();
+ return;
+ }
+ const completeScript = spoken === script.phrases.join("").trim();
+ const result = polish ? (completeScript && optsRef.current.source === "simulated" ? script.polished : tidy(spoken)) : spoken;
+ commit({ phase: "done", finalText: spoken, interimText: "", result, level: 0 });
+ stopTimer();
+ }, [commit, stopTimer]);
+
+ const tick = useCallback(() => {
+ const now = performance.now();
+ const dt = now - lastTickRef.current;
+ lastTickRef.current = now;
+ const s = stateRef.current;
+ const opts = optsRef.current;
+
+ if (s.phase === "requesting") {
+ if (opts.source === "simulated" && now - phaseStartedRef.current > 1400) {
+ if (opts.failWith === "permission-denied") {
+ commit({ phase: "error", error: "permission-denied" });
+ stopTimer();
+ return;
+ }
+ permissionGrantedRef.current = true;
+ phaseStartedRef.current = now;
+ commit({ phase: "listening", elapsedMs: 0 });
+ }
+ return;
+ }
+
+ if (s.phase === "processing") {
+ if (now - phaseStartedRef.current > (opts.processingMs ?? 900)) finish();
+ return;
+ }
+
+ if (s.phase === "paused") {
+ commit({ level: 0, levels: [...s.levels.slice(1), 0] });
+ return;
+ }
+
+ if (s.phase !== "listening") return;
+
+ const elapsedMs = s.elapsedMs + dt;
+ let level: number;
+ let finalText = s.finalText;
+ let interimText = s.interimText;
+
+ const rig = micRef.current;
+ if (opts.source === "microphone" && rig) {
+ rig.analyser.getFloatTimeDomainData(rig.buffer);
+ let sum = 0;
+ for (const v of rig.buffer) sum += v * v;
+ const rms = Math.sqrt(sum / rig.buffer.length);
+ level = Math.min(1, Math.pow(rms * 6, 0.75));
+ if (rig.recognizer) {
+ finalText = rig.recognized.final;
+ interimText = rig.recognized.interim;
+ } else {
+ const at = scriptAt(opts.script, opts.lang, elapsedMs);
+ finalText = at.finalText;
+ interimText = at.interimText;
+ }
+ } else {
+ const silent = opts.failWith === "no-speech";
+ const at = silent
+ ? { finalText: "", interimText: "", speaking: false }
+ : scriptAt(opts.script, opts.lang, elapsedMs);
+ level = speechLevel(elapsedMs, at.speaking);
+ finalText = at.finalText;
+ interimText = at.interimText;
+ if (silent && elapsedMs > 3600) {
+ commit({ phase: "error", error: "no-speech", level: 0 });
+ stopTimer();
+ return;
+ }
+ }
+
+ const smoothed = s.level * 0.45 + level * 0.55;
+ commit({
+ elapsedMs,
+ level: smoothed,
+ levels: [...s.levels.slice(1), smoothed],
+ finalText,
+ interimText,
+ });
+ }, [commit, finish, stopTimer]);
+
+ const ensureTimer = useCallback(() => {
+ if (timerRef.current !== null) return;
+ lastTickRef.current = performance.now();
+ timerRef.current = window.setInterval(tick, SAMPLE_MS);
+ }, [tick]);
+
+ const startMic = useCallback(async () => {
+ try {
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
+ if (stateRef.current.phase !== "requesting") {
+ stream.getTracks().forEach((track) => track.stop());
+ return;
+ }
+ const context = new AudioContext();
+ const analyser = context.createAnalyser();
+ analyser.fftSize = 1024;
+ context.createMediaStreamSource(stream).connect(analyser);
+ const recognizer = createRecognizer();
+ const rig: MicRig = {
+ stream,
+ context,
+ analyser,
+ buffer: new Float32Array(analyser.fftSize),
+ recognizer,
+ recognized: { final: "", interim: "" },
+ wantRecognition: true,
+ };
+ if (recognizer) {
+ recognizer.lang = optsRef.current.lang === "zh" ? "zh-CN" : "en-US";
+ recognizer.continuous = true;
+ recognizer.interimResults = true;
+ let committed = "";
+ recognizer.onresult = (event) => {
+ let interim = "";
+ for (let i = event.resultIndex; i < event.results.length; i++) {
+ const result = event.results[i]!;
+ const text = result[0]?.transcript ?? "";
+ if (result.isFinal) committed += text;
+ else interim += text;
+ }
+ rig.recognized = { final: committed, interim };
+ };
+ recognizer.onerror = (event) => {
+ if (event.error === "not-allowed") commit({ phase: "error", error: "permission-denied" });
+ if (event.error === "network") commit({ phase: "error", error: "network" });
+ };
+ // Chrome ends continuous recognition on its own after a pause; keep it going.
+ recognizer.onend = () => {
+ if (rig.wantRecognition && stateRef.current.phase === "listening") recognizer.start();
+ };
+ recognizer.start();
+ }
+ micRef.current = rig;
+ permissionGrantedRef.current = true;
+ phaseStartedRef.current = performance.now();
+ commit({ phase: "listening", elapsedMs: 0 });
+ } catch {
+ commit({ phase: "error", error: "permission-denied" });
+ stopTimer();
+ }
+ }, [commit, stopTimer]);
+
+ const start = useCallback(() => {
+ const phase = stateRef.current.phase;
+ if (phase === "listening" || phase === "requesting" || phase === "processing") return;
+ teardownMic();
+ retriedRef.current = false;
+ stateRef.current = { ...EMPTY };
+ const opts = optsRef.current;
+ phaseStartedRef.current = performance.now();
+ const needsPrompt =
+ opts.source === "microphone" ||
+ opts.failWith === "permission-denied" ||
+ (opts.permission === "prompt" && !permissionGrantedRef.current);
+ commit({ phase: needsPrompt ? "requesting" : "listening" });
+ ensureTimer();
+ if (opts.source === "microphone") void startMic();
+ }, [commit, ensureTimer, startMic, teardownMic]);
+
+ const stop = useCallback(() => {
+ const phase = stateRef.current.phase;
+ if (phase === "requesting") {
+ teardownMic();
+ stopTimer();
+ commit({ ...EMPTY });
+ return;
+ }
+ if (phase !== "listening" && phase !== "paused") return;
+ const rig = micRef.current;
+ if (rig) {
+ rig.wantRecognition = false;
+ rig.recognizer?.stop();
+ // Give the recognizer a moment to deliver its last final result.
+ window.setTimeout(() => {
+ const r = micRef.current?.recognized;
+ if (r) commit({ finalText: r.final, interimText: r.interim });
+ teardownMic();
+ }, 500);
+ }
+ phaseStartedRef.current = performance.now();
+ commit({ phase: "processing", level: 0 });
+ ensureTimer();
+ }, [commit, ensureTimer, stopTimer, teardownMic]);
+
+ const cancel = useCallback(() => {
+ teardownMic();
+ stopTimer();
+ commit({ ...EMPTY });
+ }, [commit, stopTimer, teardownMic]);
+
+ const pause = useCallback(() => {
+ if (stateRef.current.phase !== "listening") return;
+ micRef.current?.recognizer?.stop();
+ if (micRef.current) micRef.current.wantRecognition = false;
+ commit({ phase: "paused", level: 0 });
+ }, [commit]);
+
+ const resume = useCallback(() => {
+ if (stateRef.current.phase !== "paused") return;
+ const rig = micRef.current;
+ if (rig?.recognizer) {
+ rig.wantRecognition = true;
+ rig.recognizer.start();
+ }
+ lastTickRef.current = performance.now();
+ commit({ phase: "listening" });
+ }, [commit]);
+
+ const retry = useCallback(() => {
+ if (stateRef.current.error !== "network") {
+ start();
+ return;
+ }
+ retriedRef.current = true;
+ phaseStartedRef.current = performance.now();
+ commit({ phase: "processing", error: null });
+ ensureTimer();
+ }, [commit, ensureTimer, start]);
+
+ useEffect(() => () => {
+ stopTimer();
+ teardownMic();
+ }, [stopTimer, teardownMic]);
+
+ return { ...snap, start, stop, cancel, pause, resume, reset: cancel, retry };
+}
+
+/** Deterministic speech-like level history, for frozen state stories. */
+function syntheticLevels(seed: number, speaking: boolean): number[] {
+ return Array.from({ length: HISTORY }, (_, i) => {
+ if (!speaking) return 0.04;
+ const t = (i + seed) * SAMPLE_MS;
+ const word = Math.sin(t / 900 + seed) > -0.55 ? 1 : 0.1;
+ const syllable = 0.5 + 0.5 * Math.sin(t / 70) * Math.sin(t / 190 + 1.3);
+ const noise = (Math.sin(i * 12.9898 + seed * 78.233) * 43758.5453) % 1;
+ return Math.min(1, word * (0.2 + syllable * 0.55) + Math.abs(noise) * 0.12);
+ });
+}
+
+const noop = () => {};
+
+/** A frozen session in any phase, for side-by-side state stories. */
+export function mockSession(patch: Partial<VoiceSnapshot> & { speaking?: boolean } = {}): VoiceSession {
+ const { speaking = patch.phase === "listening", ...rest } = patch;
+ const levels = rest.levels ?? syntheticLevels(7, speaking);
+ return {
+ ...EMPTY,
+ levels,
+ level: rest.level ?? levels[levels.length - 1] ?? 0,
+ ...rest,
+ start: noop,
+ stop: noop,
+ cancel: noop,
+ pause: noop,
+ resume: noop,
+ reset: noop,
+ retry: noop,
+ };
+}
diff --git a/apps/storybook/src/voice-input/voice.css b/apps/storybook/src/voice-input/voice.css
new file mode 100644
index 0000000000..b782fe7afa
--- /dev/null
+++ b/apps/storybook/src/voice-input/voice.css
@@ -0,0 +1,72 @@
+/* Motion used only by the voice input prototypes. */
+
+@keyframes voice-shimmer {
+ from { background-position: 150% 0; }
+ to { background-position: -50% 0; }
+}
+
+.voice-shimmer {
+ background-image: linear-gradient(
+ 90deg,
+ var(--muted-foreground) 0%,
+ var(--muted-foreground) 40%,
+ var(--foreground) 50%,
+ var(--muted-foreground) 60%,
+ var(--muted-foreground) 100%
+ );
+ background-size: 250% 100%;
+ background-clip: text;
+ color: transparent;
+ animation: voice-shimmer 1.6s linear infinite;
+}
+
+@keyframes voice-caret {
+ 0%, 45% { opacity: 1; }
+ 55%, 100% { opacity: 0; }
+}
+
+.voice-caret {
+ display: inline-block;
+ width: 1.5px;
+ height: 1.1em;
+ margin-left: 1px;
+ vertical-align: -0.15em;
+ background: var(--brand);
+ animation: voice-caret 1s step-end infinite;
+}
+
+@keyframes voice-rec-dot {
+ 0%, 100% { opacity: 1; }
+ 50% { opacity: 0.35; }
+}
+
+.voice-rec-dot {
+ animation: voice-rec-dot 1.2s ease-in-out infinite;
+}
+
+@keyframes voice-landed {
+ from { background-color: color-mix(in oklab, var(--brand) 18%, transparent); }
+ to { background-color: transparent; }
+}
+
+.voice-landed {
+ border-radius: 3px;
+ animation: voice-landed 1.4s cubic-bezier(0.23, 1, 0.32, 1);
+}
+
+/* Fade the oldest waveform samples out at the leading edge. */
+.voice-wave-fade {
+ mask-image: linear-gradient(90deg, transparent 0, #000 24px);
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .voice-shimmer,
+ .voice-caret,
+ .voice-rec-dot,
+ .voice-landed {
+ animation: none;
+ }
+ .voice-shimmer {
+ color: var(--muted-foreground);
+ }
+}
diff --git a/apps/storybook/src/voice-input/waveform.stories.tsx b/apps/storybook/src/voice-input/waveform.stories.tsx
new file mode 100644
index 0000000000..bae511d663
--- /dev/null
+++ b/apps/storybook/src/voice-input/waveform.stories.tsx
@@ -0,0 +1,207 @@
+import { useState } from "react";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { Button } from "@multica/ui/components/ui/button";
+import { cn } from "@multica/ui/lib/utils";
+import type { Lang } from "./copy";
+import { useStoryEnv } from "./env";
+import { HudFrame, StripFrame } from "./waveform/frames";
+import { LevelStreamProvider, type Scenario } from "./waveform/stream";
+import { VARIANTS, VARIANT_BY_ID, type VariantId, type WaveVariant } from "./waveform/variants";
+
+const meta = {
+ title: "Voice input/Waveform",
+ id: "voice-input-waveform",
+ parameters: { layout: "fullscreen" },
+} satisfies Meta;
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+const SCENARIOS: { id: Scenario; label: Record<Lang, string> }[] = [
+ { id: "speech", label: { zh: "正常说话", en: "Speaking" } },
+ { id: "silence", label: { zh: "没出声", en: "Silent" } },
+ { id: "loud", label: { zh: "大声", en: "Loud" } },
+];
+
+const TEXT = {
+ compareTitle: { zh: "波形图:六个方向对比", en: "Waveform: six directions side by side" },
+ compareLead: {
+ zh: "所有方向读的是同一路输入,左边是输入框里的录音条,右边是按住说话时的浮层。工具栏「Voice」切到「My microphone」可以用你自己的声音。",
+ en: "Every direction reads the same input. Left is the composer's recording strip, right is the push-to-talk pill. Switch Voice → My microphone in the toolbar to use your own voice.",
+ },
+ pause: { zh: "暂停", en: "Pause" },
+ resume: { zh: "继续", en: "Resume" },
+ restart: { zh: "重新开始", en: "Restart" },
+ live: { zh: "实时", en: "Live" },
+ stills: { zh: "静帧:三种输入", en: "Stills: three inputs" },
+ mic: { zh: "正在使用你的麦克风。", en: "Using your microphone." },
+ simulated: {
+ zh: "当前是模拟说话人。工具栏「Voice」切到「My microphone」可以用真麦克风试。",
+ en: "Using the simulated speaker. Switch Voice → My microphone in the toolbar to try your own voice.",
+ },
+};
+
+function Controls({
+ scenario,
+ onScenario,
+ paused,
+ onPause,
+ onRestart,
+}: {
+ scenario: Scenario;
+ onScenario: (s: Scenario) => void;
+ paused: boolean;
+ onPause: () => void;
+ onRestart: () => void;
+}) {
+ const { lang, source } = useStoryEnv();
+ return (
+ <div className="flex items-center gap-1">
+ {source === "simulated" &&
+ SCENARIOS.map((s) => (
+ <Button
+ key={s.id}
+ size="xs"
+ variant={scenario === s.id ? "secondary" : "ghost"}
+ onClick={() => onScenario(s.id)}
+ >
+ {s.label[lang]}
+ </Button>
+ ))}
+ <span className="mx-1 h-4 w-px bg-border" />
+ <Button size="xs" variant="ghost" onClick={onPause}>
+ {paused ? TEXT.resume[lang] : TEXT.pause[lang]}
+ </Button>
+ <Button size="xs" variant="ghost" onClick={onRestart}>
+ {TEXT.restart[lang]}
+ </Button>
+ </div>
+ );
+}
+
+function useLiveControls() {
+ const [scenario, setScenario] = useState<Scenario>("speech");
+ const [paused, setPaused] = useState(false);
+ const [run, setRun] = useState(0);
+ return {
+ scenario,
+ paused,
+ run,
+ controls: (
+ <Controls
+ scenario={scenario}
+ onScenario={(s) => {
+ setScenario(s);
+ setPaused(false);
+ }}
+ paused={paused}
+ onPause={() => setPaused((p) => !p)}
+ onRestart={() => {
+ setRun((r) => r + 1);
+ setPaused(false);
+ }}
+ />
+ ),
+ };
+}
+
+function ComparePage() {
+ const { lang } = useStoryEnv();
+ const { scenario, paused, run, controls } = useLiveControls();
+ return (
+ <div className="min-h-screen bg-background p-10">
+ <header className="flex items-end justify-between gap-8">
+ <div className="max-w-2xl">
+ <h1 className="text-title font-semibold">{TEXT.compareTitle[lang]}</h1>
+ <p className="mt-1.5 text-body text-muted-foreground">{TEXT.compareLead[lang]}</p>
+ </div>
+ {controls}
+ </header>
+ <LevelStreamProvider key={run} scenario={scenario} paused={paused}>
+ <div className="mt-8 divide-y divide-border">
+ {VARIANTS.map((variant) => (
+ <CompareRow key={variant.id} variant={variant} />
+ ))}
+ </div>
+ </LevelStreamProvider>
+ </div>
+ );
+}
+
+function CompareRow({ variant }: { variant: WaveVariant }) {
+ const { lang } = useStoryEnv();
+ return (
+ <section className="flex items-center gap-8 py-5">
+ <div className="w-56 shrink-0">
+ <div className="text-caption font-medium text-brand">{variant.letter}</div>
+ <h2 className="text-body font-semibold">{variant.name[lang]}</h2>
+ <p className="mt-0.5 text-caption text-muted-foreground">{variant.pitch[lang]}</p>
+ </div>
+ <StripFrame Wave={variant.Wave} className="-mx-5 -mb-3" />
+ <HudFrame Wave={variant.Wave} />
+ </section>
+ );
+}
+
+function VariantPage({ id }: { id: VariantId }) {
+ const { lang, source } = useStoryEnv();
+ const variant = VARIANT_BY_ID[id];
+ const { scenario, paused, run, controls } = useLiveControls();
+ return (
+ <div className="min-h-screen bg-background p-10">
+ <div className="flex items-start gap-12">
+ <div className="space-y-10">
+ <section>
+ <div className="mb-3 flex items-center justify-between">
+ <h2 className="text-caption font-medium text-muted-foreground">{TEXT.live[lang]}</h2>
+ {controls}
+ </div>
+ <LevelStreamProvider key={run} scenario={scenario} paused={paused}>
+ <div className="flex flex-col items-center gap-4">
+ <HudFrame Wave={variant.Wave} />
+ <StripFrame Wave={variant.Wave} />
+ </div>
+ </LevelStreamProvider>
+ </section>
+ <section>
+ <h2 className="mb-3 text-caption font-medium text-muted-foreground">{TEXT.stills[lang]}</h2>
+ <div className="space-y-1">
+ {SCENARIOS.map((s, index) => (
+ <LevelStreamProvider key={s.id} scenario={s.id} frozen prefillMs={4050} seed={11 + index}>
+ <div className="flex items-center gap-4">
+ <span className="w-14 shrink-0 text-caption text-muted-foreground">{s.label[lang]}</span>
+ <StripFrame Wave={variant.Wave} className="-mx-5 -mb-3 w-[520px]" />
+ <HudFrame Wave={variant.Wave} />
+ </div>
+ </LevelStreamProvider>
+ ))}
+ </div>
+ </section>
+ </div>
+ <aside className="w-72 shrink-0 pt-1">
+ <div className="text-caption font-medium text-brand">{variant.letter}</div>
+ <h1 className="mt-1 text-title font-semibold">{variant.name[lang]}</h1>
+ <p className="mt-2 text-body text-muted-foreground">{variant.pitch[lang]}</p>
+ <ul className="mt-5 space-y-2 text-body">
+ {variant.notes[lang].map((note) => (
+ <li key={note} className="flex gap-2">
+ <span className="mt-2 size-1 shrink-0 rounded-full bg-faint-foreground" />
+ <span>{note}</span>
+ </li>
+ ))}
+ </ul>
+ <p className={cn("mt-6 text-caption text-faint-foreground")}>
+ {source === "simulated" ? TEXT.simulated[lang] : TEXT.mic[lang]}
+ </p>
+ </aside>
+ </div>
+ </div>
+ );
+}
+
+export const Compare: Story = { name: "Compare all", render: () => <ComparePage /> };
+export const Current: Story = { name: "A · Current", render: () => <VariantPage id="current" /> };
+export const SmoothScroll: Story = { name: "B · Smooth scroll", render: () => <VariantPage id="smooth" /> };
+export const DotsToBars: Story = { name: "C · Dots to bars", render: () => <VariantPage id="dots" /> };
+export const LiveSpectrum: Story = { name: "D · Live spectrum", render: () => <VariantPage id="spectrum" /> };
+export const FlowingLine: Story = { name: "E · Flowing line", render: () => <VariantPage id="line" /> };
+export const WholeRecording: Story = { name: "F · Whole recording", render: () => <VariantPage id="timeline" /> };
diff --git a/apps/storybook/src/voice-input/waveform/frames.tsx b/apps/storybook/src/voice-input/waveform/frames.tsx
new file mode 100644
index 0000000000..84be31beb4
--- /dev/null
+++ b/apps/storybook/src/voice-input/waveform/frames.tsx
@@ -0,0 +1,75 @@
+import type { ComponentType } from "react";
+import { ArrowUp, Check, X } from "@multica/ui/icons";
+import { Button } from "@multica/ui/components/ui/button";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { Kbd } from "@multica/ui/components/ui/kbd";
+import { cn } from "@multica/ui/lib/utils";
+import { ComposerSurface } from "../chat-frame";
+import { useStoryEnv } from "../env";
+import { RecDot, formatElapsed } from "../primitives";
+import { useLevelSamples } from "./stream";
+import type { WaveProps } from "./variants";
+
+function Elapsed({ className }: { className?: string }) {
+ const { elapsedMs } = useLevelSamples();
+ return <span className={cn("text-caption tabular-nums", className)}>{formatElapsed(elapsedMs)}</span>;
+}
+
+const DRAFT = {
+ zh: "帮我看一下这个 PR,重点关注",
+ en: "Take a look at this PR, especially",
+};
+
+/** The composer's recording strip as it ships: cancel, timer, waveform, insert, send. */
+export function StripFrame({ Wave, className }: { Wave: ComponentType<WaveProps>; className?: string }) {
+ const { lang, copy } = useStoryEnv();
+ return (
+ <div className={cn("w-[560px]", className)}>
+ <ComposerSurface
+ active
+ bottom={
+ <>
+ <IconButton label={copy.cancel} shortcut={<Kbd>Esc</Kbd>} className="text-muted-foreground">
+ <X />
+ </IconButton>
+ <span className="flex shrink-0 items-center gap-1.5 pl-1 pr-2">
+ <RecDot />
+ <Elapsed className="text-muted-foreground" />
+ </span>
+ <div className="min-w-0 flex-1 overflow-hidden text-foreground">
+ <Wave density="strip" />
+ </div>
+ <IconButton label={copy.insert} className="ml-1 text-foreground">
+ <Check />
+ </IconButton>
+ <Button
+ size="icon-sm"
+ // eslint-disable-next-line no-restricted-syntax -- composer send button, the one round button
+ className="shrink-0 rounded-full"
+ aria-label={copy.send}
+ >
+ <ArrowUp />
+ </Button>
+ </>
+ }
+ >
+ <p className="text-body">{DRAFT[lang]}</p>
+ </ComposerSurface>
+ </div>
+ );
+}
+
+/** The push-to-talk pill as it ships: always dark ink, 86 px of waveform. */
+export function HudFrame({ Wave }: { Wave: ComponentType<WaveProps> }) {
+ const { copy } = useStoryEnv();
+ return (
+ <div className="flex h-10 w-fit items-center gap-2.5 whitespace-nowrap rounded-full bg-multica-ink pl-3.5 pr-4 text-multica-paper shadow-[var(--floating-shadow)]">
+ <RecDot className="bg-[#ff5a52]" />
+ <div className="w-[86px]">
+ <Wave density="hud" />
+ </div>
+ <Elapsed className="opacity-70" />
+ <span className="text-caption opacity-70">{copy.releaseToInsert}</span>
+ </div>
+ );
+}
diff --git a/apps/storybook/src/voice-input/waveform/stream.tsx b/apps/storybook/src/voice-input/waveform/stream.tsx
new file mode 100644
index 0000000000..a213a846f3
--- /dev/null
+++ b/apps/storybook/src/voice-input/waveform/stream.tsx
@@ -0,0 +1,234 @@
+import { createContext, useContext, useEffect, useMemo, useSyncExternalStore, type ReactNode } from "react";
+import { useStoryEnv } from "../env";
+
+/** Same cadence as the desktop recorder (packages/views/voice/recorder.ts). */
+export const SAMPLE_MS = 50;
+const MAX_SAMPLES = 6000;
+export const BANDS = 16;
+
+export type Scenario = "speech" | "silence" | "loud";
+
+/**
+ * One shared input every waveform variant reads, so they can be compared on
+ * identical audio. Levels use the recorder's formula: RMS of the time-domain
+ * signal × 5, clamped to 1.
+ */
+export interface LevelStream {
+ /** Every sample since the start, oldest first. */
+ samples: number[];
+ /** Latest spectrum, low to high frequency, 0..1. */
+ bands: number[];
+ startedAt: number;
+ /** When the newest sample arrived. */
+ lastAt: number;
+ /** Animation clock; stops moving while frozen. */
+ now: () => number;
+ version: number;
+}
+
+interface StreamStore {
+ stream: LevelStream;
+ subscribe: (listener: () => void) => () => void;
+ getVersion: () => number;
+ setPaused: (paused: boolean) => void;
+}
+
+const StreamContext = createContext<StreamStore | null>(null);
+
+function mulberry32(seed: number) {
+ let a = seed;
+ return () => {
+ a = (a + 0x6d2b79f5) | 0;
+ let t = Math.imul(a ^ (a >>> 15), 1 | a);
+ t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
+ };
+}
+
+/** Phrases with word-level gaps and a longer breath between sentences. */
+function speechEnvelope(t: number): number {
+ const cycle = t % 6400;
+ const speaking = (cycle > 300 && cycle < 2500) || (cycle > 2900 && cycle < 4700);
+ if (!speaking) return 0;
+ const word = (t % 330) / 330;
+ const wordShape = Math.pow(Math.sin(Math.PI * word), 0.6);
+ const syllable = 0.55 + 0.45 * Math.sin(t / 61) * Math.sin(t / 173 + 1.3);
+ const phrase = 0.75 + 0.25 * Math.sin(t / 900);
+ return wordShape * syllable * phrase;
+}
+
+function simulatedLevel(scenario: Scenario, t: number, rand: () => number): number {
+ const noise = 0.015 + rand() * 0.03;
+ if (scenario === "silence") return noise;
+ const gain = scenario === "loud" ? 1.25 : 0.72;
+ const env = speechEnvelope(t);
+ return Math.min(1, noise + env * gain + (env > 0 ? rand() * 0.12 : 0));
+}
+
+function simulatedBands(level: number, rand: () => number): number[] {
+ return Array.from({ length: BANDS }, (_, i) => {
+ // Speech energy sits in the low-mid bands and rolls off above.
+ const weight = Math.exp(-Math.pow((i - 3.5) / 4.2, 2)) * 0.85 + 0.15;
+ return Math.min(1, level * weight * (0.55 + rand() * 0.7));
+ });
+}
+
+interface Options {
+ scenario: Scenario;
+ paused?: boolean;
+ frozen?: boolean;
+ /** Fill this many ms of history up front, so a frozen frame looks mid-recording. */
+ prefillMs?: number;
+ seed?: number;
+}
+
+function createStore({ scenario, frozen = false, prefillMs = 0, seed = 7 }: Options, useMic: boolean) {
+ const rand = mulberry32(seed);
+ const listeners = new Set<() => void>();
+ const startedAt = performance.now() - prefillMs;
+ const samples: number[] = [];
+ let bands = Array.from({ length: BANDS }, () => 0);
+ for (let t = 0; t < prefillMs; t += SAMPLE_MS) {
+ const level = simulatedLevel(scenario, t, rand);
+ samples.push(level);
+ bands = simulatedBands(level, rand);
+ }
+ const frozenAt = performance.now();
+ let pausedAt: number | null = null;
+ const stream: LevelStream = {
+ samples,
+ bands,
+ startedAt,
+ lastAt: frozenAt,
+ now: () => (frozen ? frozenAt : (pausedAt ?? performance.now())),
+ version: 0,
+ };
+ const emit = () => {
+ stream.version += 1;
+ listeners.forEach((listener) => listener());
+ };
+ const push = (level: number, nextBands: number[]) => {
+ if (pausedAt !== null) return;
+ stream.samples.push(level);
+ if (stream.samples.length > MAX_SAMPLES) stream.samples.shift();
+ stream.bands = nextBands;
+ stream.lastAt = performance.now();
+ emit();
+ };
+
+ const start = (): (() => void) => {
+ if (frozen) return () => {};
+ if (useMic) return startMicrophone(push);
+ const timer = window.setInterval(() => {
+ const level = simulatedLevel(scenario, performance.now() - stream.startedAt, rand);
+ push(level, simulatedBands(level, rand));
+ }, SAMPLE_MS);
+ return () => window.clearInterval(timer);
+ };
+
+ const store: StreamStore = {
+ stream,
+ subscribe: (listener) => {
+ listeners.add(listener);
+ return () => listeners.delete(listener);
+ },
+ getVersion: () => stream.version,
+ setPaused: (paused) => {
+ if (paused === (pausedAt !== null)) return;
+ if (paused) {
+ pausedAt = performance.now();
+ return;
+ }
+ const resumedAt = performance.now();
+ const pause = resumedAt - (pausedAt ?? resumedAt);
+ stream.startedAt += pause;
+ stream.lastAt += pause;
+ pausedAt = null;
+ },
+ };
+ return { store, start };
+}
+
+function startMicrophone(push: (level: number, bands: number[]) => void): () => void {
+ let cancelled = false;
+ let cleanup = () => {};
+ void navigator.mediaDevices
+ .getUserMedia({ audio: true })
+ .then((media) => {
+ if (cancelled) {
+ media.getTracks().forEach((track) => track.stop());
+ return;
+ }
+ const context = new AudioContext();
+ const resume = () => void context.resume();
+ window.addEventListener("pointerdown", resume);
+ const analyser = context.createAnalyser();
+ analyser.fftSize = 512;
+ analyser.smoothingTimeConstant = 0.5;
+ context.createMediaStreamSource(media).connect(analyser);
+ const time = new Uint8Array(analyser.fftSize);
+ const freq = new Uint8Array(analyser.frequencyBinCount);
+ const timer = window.setInterval(() => {
+ analyser.getByteTimeDomainData(time);
+ let sum = 0;
+ for (const sample of time) {
+ const v = (sample - 128) / 128;
+ sum += v * v;
+ }
+ const level = Math.min(1, Math.sqrt(sum / time.length) * 5);
+ analyser.getByteFrequencyData(freq);
+ const bands = Array.from({ length: BANDS }, (_, i) => {
+ // Log-spaced bins from ~170 Hz to ~8 kHz.
+ const lo = Math.floor(2 * Math.pow(48, i / BANDS));
+ const hi = Math.max(lo + 1, Math.floor(2 * Math.pow(48, (i + 1) / BANDS)));
+ let peak = 0;
+ for (let b = lo; b < hi; b++) peak = Math.max(peak, freq[b] ?? 0);
+ return Math.pow(peak / 255, 1.6);
+ });
+ push(level, bands);
+ }, SAMPLE_MS);
+ cleanup = () => {
+ window.clearInterval(timer);
+ window.removeEventListener("pointerdown", resume);
+ media.getTracks().forEach((track) => track.stop());
+ void context.close();
+ };
+ })
+ .catch(() => {});
+ return () => {
+ cancelled = true;
+ cleanup();
+ };
+}
+
+export function LevelStreamProvider({ children, paused = false, ...options }: Options & { children: ReactNode }) {
+ const { source } = useStoryEnv();
+ const useMic = source === "microphone" && !options.frozen;
+ const { scenario, frozen, prefillMs, seed } = options;
+ const created = useMemo(
+ () => createStore({ scenario, frozen, prefillMs, seed }, useMic),
+ [scenario, frozen, prefillMs, seed, useMic],
+ );
+ useEffect(() => created.start(), [created]);
+ useEffect(() => created.store.setPaused(paused), [created, paused]);
+ return <StreamContext.Provider value={created.store}>{children}</StreamContext.Provider>;
+}
+
+function useStore(): StreamStore {
+ const store = useContext(StreamContext);
+ if (!store) throw new Error("LevelStreamProvider is missing");
+ return store;
+}
+
+/** For canvas renderers: read on every animation frame, no re-render. */
+export function useLevelStream(): LevelStream {
+ return useStore().stream;
+}
+
+/** For DOM renderers: re-renders on every new sample, like the shipping meter. */
+export function useLevelSamples(): { samples: number[]; elapsedMs: number } {
+ const store = useStore();
+ useSyncExternalStore(store.subscribe, store.getVersion);
+ const { stream } = store;
+ return { samples: stream.samples, elapsedMs: stream.lastAt - stream.startedAt };
+}
diff --git a/apps/storybook/src/voice-input/waveform/variants.tsx b/apps/storybook/src/voice-input/waveform/variants.tsx
new file mode 100644
index 0000000000..dbc8502c30
--- /dev/null
+++ b/apps/storybook/src/voice-input/waveform/variants.tsx
@@ -0,0 +1,374 @@
+import { useEffect, useRef, type ComponentType } from "react";
+import { cn } from "@multica/ui/lib/utils";
+import type { Lang } from "../copy";
+import { BANDS, SAMPLE_MS, useLevelSamples, useLevelStream, type LevelStream } from "./stream";
+
+export type Density = "strip" | "hud";
+
+export interface WaveProps {
+ density: Density;
+ className?: string;
+}
+
+const clamp01 = (v: number) => Math.min(1, Math.max(0, v));
+
+/** Recorder level (RMS × 5) to bar height: a noise gate, then a gentle curve so quiet speech still moves. */
+function perceptual(v: number): number {
+ return Math.pow(clamp01((v - 0.035) / 0.6), 0.8);
+}
+
+/** Frame-rate independent easing toward `target`, faster up than down. */
+function follow(current: number, target: number, dt: number, attackMs: number, releaseMs: number): number {
+ const tau = target > current ? attackMs : releaseMs;
+ return current + (target - current) * (1 - Math.exp(-dt / tau));
+}
+
+const easeOut = (t: number) => 1 - Math.pow(1 - t, 3);
+
+/** Each bar's slide progress toward the next sample slot, 0..1. */
+function slideProgress(stream: LevelStream, now: number): number {
+ return clamp01((now - stream.lastAt) / SAMPLE_MS);
+}
+
+function capsule(ctx: CanvasRenderingContext2D, x: number, cy: number, width: number, height: number) {
+ const h = Math.max(width, height);
+ ctx.beginPath();
+ ctx.roundRect(x, cy - h / 2, width, h, width / 2);
+ ctx.fill();
+}
+
+type Draw = (ctx: CanvasRenderingContext2D, w: number, h: number, stream: LevelStream, now: number, dt: number) => void;
+
+/** A crisp canvas the size of its box, redrawn every animation frame in the current text color. */
+function useCanvas(draw: Draw) {
+ const ref = useRef<HTMLCanvasElement>(null);
+ const stream = useLevelStream();
+ const drawRef = useRef(draw);
+ drawRef.current = draw;
+ useEffect(() => {
+ const canvas = ref.current;
+ const ctx = canvas?.getContext("2d");
+ if (!canvas || !ctx) return;
+ let w = 0;
+ let h = 0;
+ const resize = () => {
+ const rect = canvas.getBoundingClientRect();
+ const dpr = window.devicePixelRatio || 1;
+ w = rect.width;
+ h = rect.height;
+ canvas.width = Math.round(w * dpr);
+ canvas.height = Math.round(h * dpr);
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
+ };
+ const observer = new ResizeObserver(resize);
+ observer.observe(canvas);
+ resize();
+ let last = performance.now();
+ let raf = 0;
+ const frame = () => {
+ const real = performance.now();
+ const dt = Math.min(64, real - last);
+ last = real;
+ ctx.clearRect(0, 0, w, h);
+ ctx.fillStyle = ctx.strokeStyle = getComputedStyle(canvas).color;
+ ctx.globalAlpha = 1;
+ drawRef.current(ctx, w, h, stream, stream.now(), dt);
+ raf = requestAnimationFrame(frame);
+ };
+ raf = requestAnimationFrame(frame);
+ return () => {
+ cancelAnimationFrame(raf);
+ observer.disconnect();
+ };
+ }, [stream]);
+ return ref;
+}
+
+function WaveCanvas({ draw, className }: { draw: Draw; className?: string }) {
+ const ref = useCanvas(draw);
+ return <canvas ref={ref} aria-hidden className={cn("block h-5 w-full", className)} />;
+}
+
+/** A: what ships today (packages/views/voice/voice-ui.tsx), DOM bars re-rendered per sample. */
+function CurrentWave({ density, className }: WaveProps) {
+ const { samples } = useLevelSamples();
+ const bars = density === "hud" ? 28 : 64;
+ return (
+ <div
+ aria-hidden
+ className={cn("flex h-5 items-center justify-end gap-[2px] overflow-hidden", className)}
+ style={{ maskImage: "linear-gradient(90deg, transparent 0, #000 24px)" }}
+ >
+ {samples.slice(-Math.min(bars, 64)).map((level, index) => (
+ <span
+ key={index}
+ className="w-[2px] shrink-0 rounded-full bg-current"
+ style={{ height: `${Math.max(10, Math.min(100, level * 110))}%` }}
+ />
+ ))}
+ </div>
+ );
+}
+
+/** B: the same history, sliding continuously and smoothed, with a dot line for silence. */
+function SmoothWave({ density, className }: WaveProps) {
+ const pitch = density === "hud" ? 3.5 : 4;
+ const bar = 2;
+ const fade = density === "hud" ? 16 : 28;
+ return (
+ <WaveCanvas
+ className={className}
+ draw={(ctx, w, h, stream, now) => {
+ const s = stream.samples;
+ const progress = slideProgress(stream, now);
+ const count = Math.ceil(w / pitch) + 2;
+ for (let k = 0; k < count; k++) {
+ const i = s.length - 1 - k;
+ if (i < 0) break;
+ const v = 0.25 * (s[i - 1] ?? s[i]!) + 0.5 * s[i]! + 0.25 * (s[i + 1] ?? s[i]!);
+ const grow = k === 0 ? easeOut(progress) : 1;
+ const x = w - bar - (k + progress) * pitch;
+ if (x < -bar) break;
+ ctx.globalAlpha = clamp01(x / fade);
+ capsule(ctx, x, h / 2, bar, Math.max(2, perceptual(v) * h * grow));
+ }
+ }}
+ />
+ );
+}
+
+/** C: silence is a row of dots; speech stretches dots into thicker capsules. */
+function DotsWave({ density, className }: WaveProps) {
+ const pitch = density === "hud" ? 4.5 : 5;
+ const bar = density === "hud" ? 2.5 : 3;
+ const fade = density === "hud" ? 14 : 24;
+ return (
+ <WaveCanvas
+ className={className}
+ draw={(ctx, w, h, stream, now) => {
+ const s = stream.samples;
+ const progress = slideProgress(stream, now);
+ const count = Math.ceil(w / pitch) + 2;
+ for (let k = 0; k < count; k++) {
+ const i = s.length - 1 - k;
+ if (i < 0) break;
+ const p = perceptual(s[i]!);
+ const x = w - bar - (k + progress) * pitch;
+ if (x < -bar) break;
+ const edge = clamp01(x / fade);
+ if (p < 0.08) {
+ ctx.globalAlpha = 0.4 * edge;
+ capsule(ctx, x, h / 2, bar, bar);
+ continue;
+ }
+ const grow = k === 0 ? easeOut(progress) : 1;
+ ctx.globalAlpha = edge;
+ capsule(ctx, x, h / 2, bar, bar + (h - bar) * p * grow);
+ }
+ }}
+ />
+ );
+}
+
+/** D: bars stay put and dance with the spectrum, low frequencies in the middle (Handy-style overlay). */
+function SpectrumWave({ density, className }: WaveProps) {
+ const pitch = density === "hud" ? 4.5 : 5;
+ const bar = density === "hud" ? 2.5 : 3;
+ const heights = useRef<number[]>([]);
+ return (
+ <WaveCanvas
+ className={className}
+ draw={(ctx, w, h, stream, _now, dt) => {
+ // A compact cluster reads as one voice; a full-width row is mostly idle highs.
+ const count = Math.max(3, Math.min(density === "hud" ? 19 : 33, Math.floor((w + pitch - bar) / pitch)));
+ const offset = (w - (count * pitch - (pitch - bar))) / 2;
+ const center = (count - 1) / 2;
+ const bands = stream.bands;
+ for (let i = 0; i < count; i++) {
+ const d = center === 0 ? 0 : Math.abs(i - center) / center;
+ // Speech lives below ~3 kHz: spread the lower 60% of bands across the cluster.
+ const f = d * (BANDS - 1) * 0.6;
+ const lo = Math.floor(f);
+ const mix = f - lo;
+ const band = (bands[lo] ?? 0) * (1 - mix) + (bands[lo + 1] ?? bands[lo] ?? 0) * mix;
+ const target = Math.max(2, clamp01(band * (1.25 - 0.45 * d)) * h);
+ const cur = heights.current[i] ?? 2;
+ heights.current[i] = follow(cur, target, dt, 40, 170);
+ capsule(ctx, offset + i * pitch, h / 2, bar, heights.current[i]!);
+ }
+ }}
+ />
+ );
+}
+
+/** E: three layered sine curves whose amplitude follows the voice, tapered at both ends. */
+function LineWave({ density, className }: WaveProps) {
+ const amp = useRef(0);
+ const layers = [
+ { k: 1, freq: 0.85, speed: 1.1, alpha: 1, width: 1.5 },
+ { k: 0.65, freq: 1.3, speed: -1.6, alpha: 0.45, width: 1.25 },
+ { k: 0.4, freq: 1.8, speed: 2.2, alpha: 0.25, width: 1 },
+ ];
+ const step = density === "hud" ? 1.5 : 2;
+ return (
+ <WaveCanvas
+ className={className}
+ draw={(ctx, w, h, stream, now, dt) => {
+ const latest = stream.samples[stream.samples.length - 1] ?? 0;
+ amp.current = follow(amp.current, Math.min(1, perceptual(latest) * 1.5), dt, 70, 260);
+ const a = 0.07 + amp.current * 0.93;
+ const t = now / 1000;
+ // Keep the wavelength constant, so a wide strip shows more cycles instead of a stretched curve.
+ const cycles = Math.max(2, w / 150);
+ ctx.lineCap = "round";
+ ctx.lineJoin = "round";
+ for (const layer of layers) {
+ ctx.globalAlpha = layer.alpha;
+ ctx.lineWidth = layer.width;
+ ctx.beginPath();
+ for (let x = 0; x <= w; x += step) {
+ const u = x / w;
+ const env = Math.pow(Math.sin(Math.PI * u), 2);
+ const phase = t * layer.speed * (1 + amp.current * 1.4);
+ const y = h / 2 + Math.sin(2 * Math.PI * layer.freq * cycles * u + phase) * env * a * layer.k * (h / 2 - 1.5);
+ if (x === 0) ctx.moveTo(x, y);
+ else ctx.lineTo(x, y);
+ }
+ ctx.stroke();
+ }
+ }}
+ />
+ );
+}
+
+/** F: the whole recording fills the track left to right, halving its resolution when full. */
+function TimelineWave({ density, className }: WaveProps) {
+ const pitch = density === "hud" ? 3 : 4;
+ const bar = density === "hud" ? 1.5 : 2;
+ return (
+ <WaveCanvas
+ className={className}
+ draw={(ctx, w, h, stream, now) => {
+ const s = stream.samples;
+ const slots = Math.max(1, Math.floor((w + pitch - bar) / pitch));
+ let bucket = 1;
+ while (Math.ceil(s.length / bucket) > slots) bucket *= 2;
+ const used = Math.ceil(s.length / bucket);
+ const progress = slideProgress(stream, now);
+ for (let i = 0; i < slots; i++) {
+ const x = i * pitch;
+ if (i >= used) {
+ ctx.globalAlpha = 0.18;
+ capsule(ctx, x, h / 2, bar, bar);
+ continue;
+ }
+ let peak = 0;
+ for (let j = i * bucket; j < Math.min(s.length, (i + 1) * bucket); j++) peak = Math.max(peak, s[j]!);
+ const grow = bucket === 1 && i === used - 1 ? easeOut(progress) : 1;
+ ctx.globalAlpha = 1;
+ capsule(ctx, x, h / 2, bar, Math.max(bar, perceptual(peak) * h * grow));
+ }
+ }}
+ />
+ );
+}
+
+export type VariantId = "current" | "smooth" | "dots" | "spectrum" | "line" | "timeline";
+
+export interface WaveVariant {
+ id: VariantId;
+ letter: string;
+ name: Record<Lang, string>;
+ pitch: Record<Lang, string>;
+ notes: Record<Lang, string[]>;
+ Wave: ComponentType<WaveProps>;
+}
+
+export const VARIANTS: WaveVariant[] = [
+ {
+ id: "current",
+ letter: "A",
+ name: { zh: "现状", en: "Current" },
+ pitch: {
+ zh: "线上实现:每 50ms 来一个采样,整排柱子向左跳一格。",
+ en: "What ships: a sample every 50 ms, and the whole row jumps one slot left.",
+ },
+ notes: {
+ zh: ["20 fps 的跳格能看出顿挫", "安静时柱子仍有 10% 高,看起来一直在“响”", "线性映射:小声几乎不动,大声很快顶格"],
+ en: ["The 20 fps step is visible as stutter", "Bars keep 10% height in silence, so it always looks loud", "Linear mapping: soft speech barely moves, loud speech clips fast"],
+ },
+ Wave: CurrentWave,
+ },
+ {
+ id: "smooth",
+ letter: "B",
+ name: { zh: "平滑滚动", en: "Smooth scroll" },
+ pitch: {
+ zh: "同样的历史柱状图,改成 60fps 连续滑动,新柱从右边“长”出来。",
+ en: "The same history bars, gliding at 60 fps, with new bars growing in at the right.",
+ },
+ notes: {
+ zh: ["和现状最接近,改动最小", "相邻采样轻微平滑,高度用感知曲线映射", "安静时收成一条 2px 的点线"],
+ en: ["Closest to today, the smallest change", "Neighbouring samples are smoothed; heights use a perceptual curve", "Silence collapses to a 2 px dotted line"],
+ },
+ Wave: SmoothWave,
+ },
+ {
+ id: "dots",
+ letter: "C",
+ name: { zh: "静音成点", en: "Dots to bars" },
+ pitch: {
+ zh: "安静时是一排浅色小圆点,说话时圆点被撑开成胶囊。",
+ en: "Silence is a row of faint dots; speech stretches them into capsules.",
+ },
+ notes: {
+ zh: ["一眼区分“在听但没声音”和“正在说话”", "柱子更粗(3px)、更稀,读起来更轻松", "观感接近 ChatGPT 的听写"],
+ en: ["Tells “listening, but quiet” from “speaking” at a glance", "Thicker (3 px), sparser bars that read more calmly", "Feels close to ChatGPT dictation"],
+ },
+ Wave: DotsWave,
+ },
+ {
+ id: "spectrum",
+ letter: "D",
+ name: { zh: "实时频谱", en: "Live spectrum" },
+ pitch: {
+ zh: "柱子不滚动,原地随频谱起伏;低频在中间,高频在两侧。",
+ en: "Bars stay put and move with the spectrum, lows in the middle and highs at the sides.",
+ },
+ notes: {
+ zh: ["参考 Handy 的录音浮层", "快起慢落,跳动有弹性", "需要录音器多输出一份频谱(AnalyserNode 现成就有),目前只输出音量"],
+ en: ["After Handy’s recording overlay", "Fast attack, slow release, so it bounces", "The recorder would also need to emit a spectrum (AnalyserNode has it); today it only emits level"],
+ },
+ Wave: SpectrumWave,
+ },
+ {
+ id: "line",
+ letter: "E",
+ name: { zh: "流动曲线", en: "Flowing line" },
+ pitch: {
+ zh: "三条叠加的正弦曲线,振幅跟着音量走,两端收尖。",
+ en: "Three layered sine curves whose amplitude follows the voice, tapered at both ends.",
+ },
+ notes: {
+ zh: ["最安静、最不抢眼", "只反映当下,看不出前几秒的起伏", "安静时是一条缓慢呼吸的细线"],
+ en: ["The calmest and least distracting", "Shows only the present, not the last few seconds", "Silence is a thin, slowly breathing line"],
+ },
+ Wave: LineWave,
+ },
+ {
+ id: "timeline",
+ letter: "F",
+ name: { zh: "全程概览", en: "Whole recording" },
+ pitch: {
+ zh: "柱子从左往右写满整条,写满后自动压缩,始终显示整段录音。",
+ en: "Bars fill the track left to right, then compress, so the whole recording stays visible.",
+ },
+ notes: {
+ zh: ["能感知“已经说了多久”", "空余位置用浅点占位", "录得越久,细节被压得越狠"],
+ en: ["Gives a sense of how long you have been talking", "Empty slots show as faint dots", "Long recordings lose detail as they compress"],
+ },
+ Wave: TimelineWave,
+ },
+];
+
+export const VARIANT_BY_ID = Object.fromEntries(VARIANTS.map((v) => [v.id, v])) as Record<VariantId, WaveVariant>;
diff --git a/apps/storybook/tsconfig.json b/apps/storybook/tsconfig.json
new file mode 100644
index 0000000000..ec3e69e578
--- /dev/null
+++ b/apps/storybook/tsconfig.json
@@ -0,0 +1,11 @@
+{
+ "extends": "@multica/tsconfig/react-library.json",
+ "compilerOptions": {
+ "noEmit": true,
+ "declaration": false,
+ "declarationMap": false,
+ "types": ["vite/client"]
+ },
+ "include": ["src/**/*.ts", "src/**/*.tsx", ".storybook/*.ts", ".storybook/*.tsx"],
+ "exclude": ["node_modules", "storybook-static"]
+}
diff --git a/knip.jsonc b/knip.jsonc
index e9703652bb..02979daa20 100644
--- a/knip.jsonc
+++ b/knip.jsonc
@@ -53,6 +53,10 @@
"apps/docs": {},
+ "apps/storybook": {
+ "entry": ["eslint.config.mjs"]
+ },
+
// The three shared packages export raw .ts/.tsx compiled by their
// consumers (CLAUDE.md "Project Shape"), so `entry` names only the config
// files knip would otherwise miss and the apps supply the real entry
diff --git a/package.json b/package.json
index 784552795b..d86a321e37 100644
--- a/package.json
+++ b/package.json
@@ -6,6 +6,7 @@
"scripts": {
"dev:web": "turbo dev --filter=@multica/web",
"dev:docs": "turbo dev --filter=@multica/docs",
+ "storybook": "pnpm -C apps/storybook storybook",
"dev:desktop": "turbo dev --filter=@multica/desktop",
"dev:desktop:staging": "turbo dev:staging --filter=@multica/desktop",
"dev:mobile": "pnpm -C apps/mobile dev",
diff --git a/packages/eslint-config/base.js b/packages/eslint-config/base.js
index d6eb38f57a..c4fc9cd695 100644
--- a/packages/eslint-config/base.js
+++ b/packages/eslint-config/base.js
@@ -55,6 +55,7 @@ export default [
"**/vitest.config.*",
"**/vite.config.*",
"**/electron.vite.config.*",
+ "**/.storybook/**",
"**/eslint.config.*",
"**/scripts/**",
"**/src/main/**",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f0a232d5a8..0e043e165d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -21,6 +21,9 @@ catalogs:
'@dnd-kit/utilities':
specifier: ^3.2.2
version: 3.2.2
+ '@fontsource-variable/inter':
+ specifier: ^5.2.5
+ version: 5.2.8
'@formatjs/intl-localematcher':
specifier: ^0.8.4
version: 0.8.4
@@ -261,7 +264,7 @@ importers:
specifier: ^5.3.0
version: 5.3.0
'@fontsource-variable/inter':
- specifier: ^5.2.5
+ specifier: 'catalog:'
version: 5.2.8
'@fontsource-variable/jetbrains-mono':
specifier: ^5.3.0
@@ -648,6 +651,64 @@ importers:
specifier: 'catalog:'
+ apps/storybook:
+ dependencies:
+ '@fontsource-variable/inter':
+ specifier: 'catalog:'
+ version: 5.2.8
+ '@multica/ui':
+ specifier: workspace:*
+ version: link:../../packages/ui
+ react:
+ specifier: 'catalog:'
+ version: 19.2.3
+ react-dom:
+ specifier: 'catalog:'
+ version: 19.2.3([email protected])
+ shadcn:
+ specifier: 'catalog:'
+ version: 4.1.0(@types/[email protected])(@typescript/[email protected])
+ tw-animate-css:
+ specifier: 'catalog:'
+ version: 1.4.0
+ devDependencies:
+ '@multica/eslint-config':
+ specifier: workspace:*
+ version: link:../../packages/eslint-config
+ '@multica/tsconfig':
+ specifier: workspace:*
+ version: link:../../packages/tsconfig
+ '@storybook/react-vite':
+ specifier: ^10.6.7
+ '@tailwindcss/vite':
+ specifier: 'catalog:'
+ '@types/react':
+ specifier: ^19.2.0
+ version: 19.2.14
+ '@types/react-dom':
+ specifier: ^19.2.0
+ version: 19.2.3(@types/[email protected])
+ '@typescript/native':
+ specifier: 'catalog:'
+ '@vitejs/plugin-react':
+ specifier: 'catalog:'
+ storybook:
+ specifier: ^10.6.7
+ version: 10.6.7(@types/[email protected])([email protected])
+ tailwindcss:
+ specifier: 'catalog:'
+ version: 4.2.2
+ typescript:
+ specifier: 'catalog:'
+ version: '@typescript/[email protected]'
+ vite:
+ specifier: ^8.0.1
+
apps/web:
dependencies:
'@multica/core':
@@ -1854,18 +1915,30 @@ packages:
'@emnapi/[email protected]':
resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==}
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-l9Oo58x0HOP5znGzVhYW9U3e5wVuA4LAZU2AGezTmkhO1CgQRFDhDg4nneHsu/t3WniXg9QrG2nIXL/ZS8ln8Q==}
+
'@emnapi/[email protected]':
resolution: {integrity: sha512-TC8MkTuZUtcTSiFeuC0ksCh9QIJ5+F21MvZ4Wn4ORfYaFJ/0dsiudv5tVkejgwZlwQ39jL9WWDe2lz8x0WglOA==}
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-UC+ZhH3XtczQYfOlu3lNEkdW/p4dsJ1r/bP7H8+rhao3TTTMO1ATq/4DdIi23XuGoFY+Cz0JmCbdVl0hz9jZcA==}
+
'@emnapi/[email protected]':
resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==}
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-55coeOFKHv1ywEcUXJtWU5f+Jr/W5tZDvZig8DLKSwUN1JpROQ4rk/SNOQiFWmaR/VKF4zuFyW1B8JduOSv6Pg==}
+
'@emnapi/[email protected]':
resolution: {integrity: sha512-kyOl3X0DuTiT1h2ft8r2fYO8JYtU9a9Xis/zBSiGArNaagCOWx90N1k2wxp18czFDH+OgcWGb5ZP/XMt3dcyPA==}
'@emnapi/[email protected]':
resolution: {integrity: sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==}
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-3U4+MIWHImeyu1wnmVygh5WlgfYDtyf0k8AbLhMFxOipihf6nrWC4syIm/SwEeec0mNSafiiNnMJwbza/Is6Lw==}
+
'@emnapi/[email protected]':
resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==}
@@ -2728,6 +2801,15 @@ packages:
resolution: {integrity: sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
+ '@joshwooding/[email protected]':
+ resolution: {integrity: sha512-qvsTEwEFefhdirGOPnu9Wp6ChfIwy2dBCRuETU3uE+4cC+PFoxMSiiEhxk4lOluA34eARHA0OxqsEUYDqRMgeQ==}
+ peerDependencies:
+ typescript: '>= 4.3.x'
+ vite: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0
+ peerDependenciesMeta:
+ typescript:
+ optional: true
+
'@jridgewell/[email protected]':
resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}
@@ -2778,12 +2860,6 @@ packages:
resolution: {integrity: sha512-cXu86tF4VQVfwz8W1SPbhoRyHJkti6mjH/XJIxp40jhO4j2k1m4KYrEykxqWPkFF3vrK4rgQppBh//AwyGSXPA==}
engines: {node: '>=18'}
- '@napi-rs/[email protected]':
- resolution: {integrity: sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==}
- peerDependencies:
- '@emnapi/core': ^1.7.1
- '@emnapi/runtime': ^1.7.1
-
'@napi-rs/[email protected]':
resolution: {integrity: sha512-UMduMbqO5s5zF2NkNacMT/yK5Y5QiKvWr2+50bzIIxFDwVJ2h49b+oyjaCGPhJxd2/gC2x39EHv/gHVuu36x2Q==}
engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0}
@@ -2972,48 +3048,97 @@ packages:
resolution: {integrity: sha512-cifvXDhcqMwwTlTK04GBNeIe7yyo28Mfby85QXFe1Yk8nmi36Ab/5UQwptOx84SsoGNRg+EVSjwzfSZMy6pmlw==}
engines: {node: '>=14'}
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-0LC7ye4hvqbIKxAzThzvswgHLFu2AURKzYLeSVvLdu2TBOYWQDmHnTqPLeA597BcUCxiLqLsS4CJ5uoI5WYWCQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm]
+ os: [android]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-n9uozULWflPqBtdmI8lAabLqGKNgLVNN0ZH8HfgCwpKGNtzRzauB76jTiW/3YLkcA7N1zskpi9GdVnZuu1SAvg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [android]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-b5jtVTH6AU5CJXHNdj7Jj9IEiR9yVjjnwHzPJhGyHGPdcsZSzBCkS9GBbV33niRMvKthDwQRFRJfI4a+k4PvYg==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [android]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-9BbdjHETk6O3zH/DDid9IgBtF0GlpLabNKN231uraXpRDSfY+iiZxTP5bk1Z63GBownVdhdINFIeddmMz4MzpQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [android]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-obCE8B7ISKkJidjlhv9xRGJPOSDG2Yu6PRga9Ruaz35uintHxbp1Ki/Yc71wx4rj3Edrm0a1kzG1TAwit0wFpg==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [darwin]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-gh+6ecoHUy4/sUcolBl/1qPXKBbYNxFY0Pk0ujgQvINTMSftJY7o4yb8gOkDJPeZeB8+a+u7xTe6umoP8N5HFA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [darwin]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-JL6Xb5IwPQT8rUzlpsX7E+AgfcdNklXNPFp8pjCQQ5MQOQo5rtEB2ui+3Hgg9Sn7Y9Egj6YOLLiHhLpdAe12Aw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [darwin]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-qd1hl2d+lXgHv/VQ/M9qm8TrMC5T4RqDBwtOnl+1D0QMjwcz+8AaB4JSg8STgeag0GP6a6L74XEGAsrTSJWNzQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [darwin]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-SDQ/3MQFw58fqQz3Z1PhSKFF3JoCF4gmlNjziDm8X02tTahCw0qJbd7FGPDKw1i4VTBZene9JPyC3mHtSvi+wA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [freebsd]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-M5XXcNa7aOqLPKTR41msfghKu2yQ4xWvCm11/gwU0JzOzHNk5sgW//rVEjJ+LO48+VDAMzXTSzurUVxIDKwozw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [freebsd]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-Av+D1MIqzV0YMGPT9we2SIZaMKD7Cxs4CvXSx/yxaWHewZjYEjScpOf5igc8IILASViw4WTnjlwUdI1KzVtDHQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm]
+ os: [linux]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-T/GXusuOkPNQhCQCSBbcU/N8j0rAypuDBl1IyFK+lyYT594XsVz80clPC/OtbSSpBGyJxj8uYEfctxVuxVYoww==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [linux]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-Cs2fdJ8cPpFdeebj6p4dag8A4+56hPvZ0AhQQzlaLswGz1tz7bXt1nETLeorrM9+AMcWFFkqxcXwDGfTVidY8g==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm]
+ os: [linux]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-oKu4RcBlXSqo3OC62dp6YTnQaZIurNDpCX3BnAM3+bJxt7s8J2TJKMnC0UYer1qhlRaDCg6wkTaTw+2IlsZ12w==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [linux]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-qdOfTcT6SY8gsJrrV92uyEUyjqMGPpIB5JZUG6QN5dukYd+7/j0kX6MwK1DgQj39jtUYixxPiaRUiEN1+0CXgQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [linux]
+ libc: [glibc]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-WJBbD186AZmMGaSIhlktC+rPl8L3peCTXAh88Ih9uEvK0en2mPojGyCGYiL6mHtV1RPV3JyfJW5t6n5hh0lXhA==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -3021,6 +3146,13 @@ packages:
os: [linux]
libc: [glibc]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-EoTCZneNFU/P2qrpEM+RHmQwt+CvDkyGESG6qhr7KaegXLZwePfbrkCDfAk8/rhxbDUVGsZILX+2tqPzFtoFWA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [linux]
+ libc: [musl]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-t1AcYOwEzgceadT4v5e+vaCCb0AncCA3v5AyzfBAz/tMq11qzVccXKzNHtkWdjBsgvTKwRkaUF3QvT4kot8vcQ==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -3028,6 +3160,13 @@ packages:
os: [linux]
libc: [musl]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-zALjmZYgxFLHjXeudcDF0xFGNydTAtkAeXAr2EuC17ywCyFxcmQra4w0BMde0Yi/re4Bi4iwEoEXtYN7l6eBLQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [ppc64]
+ os: [linux]
+ libc: [glibc]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-RsnO/NoD8376LMJq8JS8TwI0ieNaFRTuNe2GVJntQg6gwZNMENZsEbknHdVwjpOmxdGLGodcwaGSbAeRr5Bgjw==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -3035,6 +3174,13 @@ packages:
os: [linux]
libc: [glibc]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-fPP8M6zQLS7Jz7o9d5ArUSuAuSK3e+WCYVrCpdzeCOejidtZExJ9tjhDrAd3HEPqARBCPmdpqxESPFqy44vkBQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [riscv64]
+ os: [linux]
+ libc: [glibc]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-48fSVfR9TZi5CASZFyv0VC6z6BCoeihFsX031mAD/oSH7d9PYsPgIqza7d9mjP7Z2KTEpTFyH6SIu0Ui6R1vdg==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -3042,6 +3188,13 @@ packages:
os: [linux]
libc: [glibc]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-7IcC4Ao02oGpfnjt+X/oF4U2mllo2qoSkw5xxiXNKL9MCTsTiAC6616beOuehdxGcnz1bRoPC1RQ2f1GQDdN+g==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [riscv64]
+ os: [linux]
+ libc: [musl]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-T8CpdD+SfE01DnIOD4HpVxu0ZJOfMJ/VhCvikKfaXAxkZ+9veyLM/D2hpi7Y2hFUyPmVQO3FNZHmYzV/WlVR4g==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -3049,6 +3202,13 @@ packages:
os: [linux]
libc: [musl]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-pbXIhiNFHoqWeqDNLiJ9JkpHz1IM9k4DXa66x+1GTWMG7iLxtkXgE53iiuKSXwmk3zIYmaPVfBvgcAhS583K4Q==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [s390x]
+ os: [linux]
+ libc: [glibc]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-QLdeMsCcacenPEFsfxnBUDF1y6opyz5+fmOz9bfD5Y7fiGCMupUCuB3KTPQhNwshIG1P9fPqar9MHxuBDd4bwQ==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -3056,6 +3216,13 @@ packages:
os: [linux]
libc: [glibc]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-MYCguB9RvBvlSd6gbuNI7QwiLoCCAlGnlRJFPrzLI6U1/9wkC/WK6LtBAUln55H1Ctqw45PWmqrobKoMhsYQzQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [linux]
+ libc: [glibc]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-659ujfqLy6k7cuH3sbzhd8b+ztSq+i6E2E9pG78Q0BmHjAExfGIdgc8cGgMdwAozDXeZFHkJ+LXYJdWsaGdgyw==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -3063,6 +3230,13 @@ packages:
os: [linux]
libc: [glibc]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-5eY0B/bxf1xIUxb4NOTvOI3KWtBQfPWYyKAzgcrCt0mDibSZygVpO1Pz8bkeiSZ5Jj9+M09dkggG3H8I5d0Uyg==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [linux]
+ libc: [musl]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-/Mw/9j4TfZcnKphPrzOE6t4MMknXadcAAuVUlDRTF/ETWB5xOgQvOJV2Mh9We/bWxZdoxaGAdc+hy4GuYwQ2yQ==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -3070,24 +3244,53 @@ packages:
os: [linux]
libc: [musl]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-Gld0ajrFTUXNtdw20fVBuTQx66FA75nIVg+//pPfR3sXkuABB4mTBhl3r9JNzrJpgW//qiwxf0nWXUWGJSL3UQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [openharmony]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-8rIKWR2BFuifbIK/1XB9wTaSdtuJ25dlE7ZQYDnEwj/2xH2vHsxnvIjHT3ZjSVuLLwGGlSslIG/fbOJ8TV8rTw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [openharmony]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-T6KVD7rhLzFlwGRXMnxUFfkCZD8FHnb968wVXW1mXzgRFc5RNXOBY2mPPDZ77x5Ln76ltLMgtPg0cOkU1NSrEQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [wasm32]
+
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-Ujvw4X+LD1CCGULcsQcvb4YNVoBGqt+JHgNNzGGaCImELiZLk477ifUH53gIbE7EKd933NdTi25JWEr9K2HwXw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [win32]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-5U9kQYMfRRI6Zq7KDxgbIP0RMnKrfn3gLepRMgJuRkPSUALTiRCk9d/uyhb4lGDjUdzwK7mBkKqhLgzBPCmLpQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [win32]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-0cwxKO7KHQQQfo4Uf4B2SQrhgm+cJaP9OvFFhx52Tkg4bezsacu83GB2/In5bC415Ueeym+kXdnge/57rbSfTw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [ia32]
+ os: [win32]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-25P7AaHk4R88Yv2XH4gToDVmh0cOu+bEURQU10CRrmvgabfRArSGAP5osmwUKeSUHj0VS50upbpbRWWW/m7mHA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [ia32]
os: [win32]
+ '@oxc-parser/[email protected]':
+ resolution: {integrity: sha512-rOrnSQSCbhI2kowr9XxE7m9a8oQXnBHjnS6j95LxxAnEZ0+Fz20WlRXG4ondQb+ejjt2KOsa65sE6++L6kUd+w==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [win32]
+
'@oxc-parser/[email protected]':
resolution: {integrity: sha512-ORMh3JE1s6V7ySicdRK7vgaDQnn5o+UHg9ct989PlWHbel8O9ARrmWXM6kZjrBMtNucxNayQ8g69G0VfWzhANw==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -3097,107 +3300,213 @@ packages:
'@oxc-project/[email protected]':
resolution: {integrity: sha512-k1YNu55DuvAip/MGE1FTsIuU3FUCn6v/ujG9V7Nq5Df/kX2CWb13hhwD0lmJGMGqE+bE1MXvv9SZVnMzEXlWcg==}
+ '@oxc-project/[email protected]':
+ resolution: {integrity: sha512-aIYXQBo4lCbO4z0R3FHeucQHpF46l2LbMdxRvqvuRuW2OxdnSkcng5B8+K12spgLDj93rtN3+J2Vac/TIO+ciQ==}
+
'@oxc-project/[email protected]':
resolution: {integrity: sha512-u6JZdLBTLotrNC9Vd6vPssINdzcCzleKAH6EJKImQb7GtYvX5keN2dxkoK44stCc4tffE6QQRtZTXVSzsLUlWA==}
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-xQoCRv+gKax9KTdwdaQNnAFOai8neay7g3jExDIORzhbrejwGSJaZNTdOJHR5ziLg2joMxOCMOFMo4zuxza2uQ==}
+ cpu: [arm]
+ os: [android]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-y09e0L0SRI2OA2tUIrjBgoV3eH5hvUKXNkJqXmNo5V2WxIjyC7I7aJfRLMEVpA8yi95f90gFDvO0VMgrDw+vwA==}
cpu: [arm]
os: [android]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-HF5oiE2L05yInPYCFD/4uxSrEZW4SuIfn99Y6L1xnJnzl066JR+MJs2rIdstw8A2MPlAKH+13dpFPNycjqzvGg==}
+ cpu: [arm64]
+ os: [android]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-cl4icWaZFnLdg8m6qtnh5rBMuGbxc/ptStFHLeCNwr+2cZjkjNwQu/jYRS0CHlnPecOJMpuS5M6/BH+0J/YkEg==}
cpu: [arm64]
os: [android]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-UX4u49CVCAD8QZNELaW8eMGgMAGwFWYEPbvNsh+3r/gs4NX3KfpiACMVwRQT0EuH3uat9hM5Zl+Ppm9pJD8tgg==}
+ cpu: [arm64]
+ os: [darwin]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-At29QEMF6HajbQvgY8K6OXnHD1x9rad74xBEfmCB6ZqCGsdq75aK7tOYcTbOanMy8qdIBrfL3SMr3p/lfSlb9w==}
cpu: [arm64]
os: [darwin]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-J9xPx7YBkrRmJ+xl561ztnMWEc1aOyjEIxBiGX1dVb3u7bGSnfObfcZk+Pd+uM0HZAPNsQ1xvD8j52A/uOSqNQ==}
+ cpu: [x64]
+ os: [darwin]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-A5Kqr1EUj4oIL5CF4WRssq/o5P0Y11cwoFouMRmQ7YnC/A8V93nv1nb7aSU8HwcgmXropjLNkVTl4MN87cu28Q==}
cpu: [x64]
os: [darwin]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-fRlt7OvSaQkWj6+EDTVxawVxOlqJB2QSnBfkeCyK4RTvsGctbw3BiH2Tb7DzMs7bikc4BRBpvWP5zF9K8b54Zg==}
+ cpu: [x64]
+ os: [freebsd]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-R5xkRBRRz7ceH/P5Jrc6G7FmdUdgpLYyESFAUDVTNQ9K0sGPxcp4ljiwEwEqsvNcQ4sYbMRrWcHHBCu7ksAJVw==}
cpu: [x64]
os: [freebsd]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-gK+vPUcPQITkGwBKpZGrcDHSlU6eDGl7AQacxS2CEKAZIBHWkOVFeJwLZ4tYnA1acJqRM5lt7yYwPCVqGHIJ7A==}
+ cpu: [arm]
+ os: [linux]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-k/RuYL4L/R58IBn3wT5ma3Wh4k62bp1eYCFRWCmMsasUOqL+H6sW0VGFadEzKWXFFlz+2uIMoeMk9ySSZJHgbg==}
cpu: [arm]
os: [linux]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-L/Rgas7SrOKy/z7IH+HxSFRqVO4PuLDKLEGKvnhoCBBq3UJ0YzGBou3qMzaAGgkJwsIvX2pBF+7ojzfUhLiZxQ==}
+ cpu: [arm]
+ os: [linux]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-bnHAak3ujYfH5pKk4NieFNbvYvernfoQDgwLddbZ3OtMYrem87/qjlA+u+aKG0oZcqSLGCful/6/CEA+aeAgaA==}
cpu: [arm]
os: [linux]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-CUEYvlX1Fk7E9kUMzuswru1J9HLxMwnpDeQGjQuI4ZH+iNCoa2X9T+pvyzrbsgl7WnIeTFTlNlHsRfVdf5g9/g==}
+ cpu: [arm64]
+ os: [linux]
+ libc: [glibc]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-vDT3KHgzYp47gmtNOqL2VNhCyl5Zv643eyxm//A68J8DeUGXrvD1pZFiaT4jSfe+RInfnn1R2yVHye4enx6RnA==}
cpu: [arm64]
os: [linux]
libc: [glibc]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-ViN1ZibQyxwC67GpoP33oo+S9UyUnkog13vzQb9+v9bCNvrVzJuk0MRdacjtv/9xfRMVF/eqHFyl8YOeykI10Q==}
+ cpu: [arm64]
+ os: [linux]
+ libc: [musl]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-+kMlQvbzfyEYtu5FcjE4p+ttBLpKW4d/AsAsuE69BxV6V4twZJeIQZFfD8gh/wqglY0MkPSezWXQH0jBV13MUw==}
cpu: [arm64]
os: [linux]
libc: [musl]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-CU1sCqWnhGqYD5I1HedHk5pujrn7ssDkNB/AEQd/pd3D/EojVSgJUlpbafwIbyhia3PgIfkvdFpRPWSALzVumA==}
+ cpu: [ppc64]
+ os: [linux]
+ libc: [glibc]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-shjfMhmZ3gq9fv/w7bi3PnZlgOPG+2QAOFf0BJF0EgBSIGZ6PMLN2zbGEblTUYB/NKVDRyYhE2ff3dJ1QqNPkA==}
cpu: [ppc64]
os: [linux]
libc: [glibc]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-jWVyZtIHca4Gb96x7dag+y69vlei7ffjrsveLkmf2ZhqEAz6ZSBnY1GWvgZUaZlwZP62A3xD092BW97Q5VGc+g==}
+ cpu: [riscv64]
+ os: [linux]
+ libc: [glibc]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-zGelwFR5oRo+b69k8Lrzun86DyUHzfKN6cnjbR9l7Z7NIRznOE/2ZvPa1IUKqAL2PzAXOdwkfVqNvO1H2RlpAw==}
cpu: [riscv64]
os: [linux]
libc: [glibc]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-LF29obFqNgBUgDX7rmUK7M4D0JQG5LxhYzn3xXmECcHU9aQAdWG7NiY052qybtesEdwHQXKNTWYQ7mTsybNvWg==}
+ cpu: [riscv64]
+ os: [linux]
+ libc: [musl]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-qxZ1SWCXJY0eyhAlP6Lmo9F2Nrtx7EkYj9oCgL8apDPCwXwCEDA2U697bbT81JIc2IrVjxO4KX6WU2N+oN9Z4w==}
cpu: [riscv64]
os: [linux]
libc: [musl]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-+NYcm+cCHBbtdQQ3A4phQTSuVRYnNHz7wrl9XRAPEovcdoqi0mb1K5ZOl+jN54ZD+q1zz3V0vltbFJmzecJKmw==}
+ cpu: [s390x]
+ os: [linux]
+ libc: [glibc]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-sGCecF3cx2DFlH4t/z7ApnOnXqN48p5p5mlHDEnHTAukQa2P+qMVE4CwyWE9W+q/m3QJ7kKfGrIjax31f44oFQ==}
cpu: [s390x]
os: [linux]
libc: [glibc]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-UQqZDdG2r2HhAOsZEgufkIWHPQ886IUyuJQkoZByvzhW8j51R4UNzGBJFkTiTnLhQnggwJRdJgFWK4uY6ZVIMw==}
+ cpu: [x64]
+ os: [linux]
+ libc: [glibc]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-k/VlMMcSzMlahb3/fENM4rTlsJ0s3fFROA0KXPBmKggqmTSaE383sl8F3KCOXPLmVsYfW6hCitMhXCEtNeZxxg==}
cpu: [x64]
os: [linux]
libc: [glibc]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-3Q9PMRjalWkT6NZ4jfujuqTCFwoWErg3y3BnOgb544B8IMw4PktiwWOigMfOHNRLMghZeJ7hpfpZf4CP7rV7Og==}
+ cpu: [x64]
+ os: [linux]
+ libc: [musl]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-8hbnZyNi97b/8wapYaIF9+t9GmZKBW2vunaOc3h9HGJptH7b7XpvZqOTBSm/MpTjr7H497BlgOaSfLUdhmy2bw==}
cpu: [x64]
os: [linux]
libc: [musl]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-Eljeq3ndtyKhM+Es8LITi4Zl2htzuRZcrPMF3kMCsrILztvU6AjZ3FuEhHHKobPUB9rMpzLpJP5bDqXI7r+iog==}
+ cpu: [arm64]
+ os: [openharmony]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-MvyGik3a6pVgZ0t/kWlbmFxFLmXQJwgLsY2eYFHLpy0wGwRbfzeIGgDwQ3kXqE30z+kSXennRkCrT7TUvkptNg==}
cpu: [arm64]
os: [openharmony]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-HGDbNsIywqc4LxU38+CTJNnB/6BF7rheWOJ259b4eE0aEnelYblC8x+1tEd63bp31fYne63RQz9Jb4yVnC7Yig==}
+ engines: {node: '>=14.0.0'}
+ cpu: [wasm32]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-vHcssMPwO08RTvj/c0iOBz90attxyG3wQJ0dTcyEQK43LRpcdLWZlV5feBhv6Isn6ahbQIzHbCgfa81+RiML0Q==}
engines: {node: '>=14.0.0'}
cpu: [wasm32]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-iWx25CBEgH49iE9q5coEGI/jb1jl5kkCY9z6U5Og67xCkQ/WFMDc2J5U78+AE91SUxM2NqSLhJC8/PLfWnImww==}
+ cpu: [arm64]
+ os: [win32]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-uokJqro2iBqkFvJdKQLP7d8/BUmFwESQFVmIJUQKj1Xn1a/LysJoe1vmeECLF5b3jsV8CAL5sEMJXX6SdK9Nhg==}
cpu: [arm64]
os: [win32]
+ '@oxc-resolver/[email protected]':
+ resolution: {integrity: sha512-VPoCAhKvCQTlG7vxqaBXcmuvbh77BfnGXj8g0pbvVXpm1F/R8rDVwqIWcEbMzrI1JvJlm8v7T9uMVQb6UctMRg==}
+ cpu: [x64]
+ os: [win32]
+
'@oxc-resolver/[email protected]':
resolution: {integrity: sha512-UqGPmo56KDfLlfXFAFIrNflHT8tFxWGEivWg3Zeyp4Uy2NlKN1FGPr6/BxcLGG3+kZ6Wp14g5Uj+n71boqZfiw==}
cpu: [x64]
@@ -4352,6 +4661,15 @@ packages:
'@rolldown/[email protected]':
resolution: {integrity: sha512-qujRfC8sFVInYSPPMLQByRh7zhwkGFS4+tyMQ83srV1qrxL4g8E2tyxVVyxd0+8QeBM1mIk9KbWxkegRr76XzA==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-P9ZvnfouRu4MSC+ilERaw6FmZs8zqKhpHxEs4aGDGWQAMzQGXnhvCSvoNwokfNvdt7t3Y5Y4p6gStQgezeIqug==}
+ engines: {node: '>=14.0.0'}
+ peerDependencies:
+ rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
+ peerDependenciesMeta:
+ rollup:
+ optional: true
+
resolution: {integrity: sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==}
@@ -4451,6 +4769,63 @@ packages:
'@standard-schema/[email protected]':
resolution: {integrity: sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==}
+ '@storybook/[email protected]':
+ resolution: {integrity: sha512-6DI3XP4He/nMMK4vGLl9tkneygr5bJvYx5EwNZMzw15tCosvGuWRREBvWqTHjZdoRa8HJpqosoFm60splBoAew==}
+ peerDependencies:
+ storybook: ^10.6.7
+ vite: ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0
+
+ '@storybook/[email protected]':
+ resolution: {integrity: sha512-FcOqPAXACP0I3oJ/ws6/rrPT9WGhu915Cg8D02a9YxLo0DE9zI+a9A5gRGvmQ09fiWPukqI8ZAEoQEdWUKMQdQ==}
+
+ '@storybook/[email protected]':
+ resolution: {integrity: sha512-FpUB/xizIrV1ILhCIYFo+TtQNN9YEoLjfcnAW0JtOXL+BcM2aisSysI0B54JMWDnljriXySBHgN6ps4s9lb75A==}
+ peerDependencies:
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+
+ '@storybook/[email protected]':
+ resolution: {integrity: sha512-h5VsEhWyLI4BsqcFwK/nOwvy5t8Hu3Tt7msUn4smHM0NbqtMlyZmA3LH58Q2plRy41T6lg0BLVjz5S/9s8cTZA==}
+ peerDependencies:
+ '@types/react': ^19.2.0
+ '@types/react-dom': ^19.2.0
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+ react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+ storybook: ^10.6.7
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
+ '@storybook/[email protected]':
+ resolution: {integrity: sha512-7mpJApW6zy4riLPq7o0he80eQy1GofdqEPWWpCHQDMVuOJAvmuuX656hY5flboZwWC18g/6yWbxrRQx5uf7pDQ==}
+ peerDependencies:
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+ react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+ storybook: ^10.6.7
+ typescript: '>= 4.9.x'
+ vite: ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0
+ peerDependenciesMeta:
+ typescript:
+ optional: true
+
+ '@storybook/[email protected]':
+ resolution: {integrity: sha512-PzQG9vNKRMjk81W1zli6mrsjUkp+05GzEmdpxxpmSvf5I2KrhUjO+FBN0s4wdJTrJRDZwjZzXcR0TkvkBxAB4g==}
+ peerDependencies:
+ '@types/react': ^19.2.0
+ '@types/react-dom': ^19.2.0
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+ react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+ storybook: ^10.6.7
+ typescript: '>= 4.9.x'
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ typescript:
+ optional: true
+
resolution: {integrity: sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw==}
@@ -4616,6 +4991,12 @@ packages:
peerDependencies:
'@testing-library/dom': '>=7.21.4'
+ '@testing-library/[email protected]':
+ resolution: {integrity: sha512-tA4stGNp3mLGOGO+lh87UA56Tz4c8NVGBSkyIF58O+W/bs2Re9BCI9xihnL70+DsThncFznE0skS88SM1D2hyg==}
+ engines: {node: '>=12', npm: '>=6'}
+ peerDependencies:
+ '@testing-library/dom': '>=7.21.4'
+
'@tiptap/[email protected]':
resolution: {integrity: sha512-Cz50pvciQrxdSxgTkHOVz0uD0Yl/8Xt0QatGD6ILm47jW8EzyHR9RkUGs/D5IqzXKuVPntfw1ttaT926vXfiRg==}
peerDependencies:
@@ -4869,9 +5250,6 @@ packages:
cpu: [arm64]
os: [win32]
- '@tybys/[email protected]':
- resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==}
-
resolution: {integrity: sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==}
@@ -4995,6 +5373,9 @@ packages:
resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-eOIHzCUSH7SMfonMG1LsC2f8vxBFtho6NGBznK41R84YzPuvSBzrhEps33IsQiOW9+VL6NQ9DbjQJznk/S4uRA==}
+
resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==}
@@ -5075,6 +5456,9 @@ packages:
resolution: {integrity: sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-A4STmOXPhMUtHH+S6ymgE2GiBSMqf4oTvcQZMcHzokuTLVYzXTB8ttjcgxOVaAp2lGwEdzZ0J+cRbbeevQj1UQ==}
+
resolution: {integrity: sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==}
@@ -5481,6 +5865,9 @@ packages:
babel-plugin-react-compiler:
optional: true
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==}
+
'@vitest/[email protected]':
resolution: {integrity: sha512-EIxG7k4wlWweuCLG9Y5InKFwpMEOyrMb6ZJ1ihYu02LVj/bzUwn2VMU+13PinsjRW75XnITeFrQBMH5+dLvCDA==}
@@ -5495,6 +5882,9 @@ packages:
vite:
optional: true
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==}
+
'@vitest/[email protected]':
resolution: {integrity: sha512-3RZLZlh88Ib0J7NQTRATfc/3ZPOnSUn2uDBUoGNn5T36+bALixmzphN26OUD3LRXWkJu4H0s5vvUeqBiw+kS0A==}
@@ -5504,12 +5894,21 @@ packages:
'@vitest/[email protected]':
resolution: {integrity: sha512-0Vy9euT1kgsnj1CHttwi9i9o+4rRLEaPRSOJ5gyv579GJkNpgJK+B4HSv/rAWixx2wdAFci1X4CEPjiu2bXIMg==}
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==}
+
'@vitest/[email protected]':
resolution: {integrity: sha512-pz77k+PgNpyMDv2FV6qmk5ZVau6c3R8HC8v342T2xlFxQKTrSeYw9waIJG8KgV9fFwAtTu4ceRzMivPTH6wSxw==}
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==}
+
'@vitest/[email protected]':
resolution: {integrity: sha512-XfPXT6a8TZY3dcGY8EdwsBulFCIw+BeeX0RZn2x/BtiY/75YGh8FeWGG8QISN/WhaqSrE2OrlDgtF8q5uhOTmw==}
+ '@webcontainer/[email protected]':
+ resolution: {integrity: sha512-6aN99yL695Hi9SuIk1oC88l9o0gmxL1nGWWQ/kNy81HigJ0FoaoTXpytCj6ItzgyCEwA9kF1wixsTuv5cjsgng==}
+
'@xmldom/[email protected]':
resolution: {integrity: sha512-KRYzxepc14G/CEpEGc3Yn+JKaAeT63smlDr+vjB8jRfgTBBI9wRj/nkQEO+ucV8p8I9bfKLWp37uHgFrbntPvw==}
engines: {node: '>=10.0.0'}
@@ -5974,6 +6373,10 @@ packages:
resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==}
+ resolution: {integrity: sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==}
+ engines: {node: '>=18'}
+
resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==}
engines: {node: '>=18'}
@@ -6002,6 +6405,10 @@ packages:
resolution: {integrity: sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==}
+ resolution: {integrity: sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==}
+ engines: {node: '>= 16'}
+
resolution: {integrity: sha512-PvVJm3oGqrveUVW2Vt/eZGeiAIsJszYweUcYwcskg9e+IubNYKKD+rHHem7A6XVO22eDAL+inxNIGAzZ/VIWlA==}
peerDependencies:
@@ -6539,6 +6946,10 @@ packages:
babel-plugin-macros:
optional: true
+ resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==}
+ engines: {node: '>=6'}
+
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
@@ -6643,6 +7054,10 @@ packages:
resolution: {integrity: sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==}
+ engines: {node: '>=6.0.0'}
+
resolution: {integrity: sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==}
@@ -6753,6 +7168,10 @@ packages:
resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}
+ resolution: {integrity: sha512-AnfC1ATldl49/cvZdLPDjBfrRNwbDO05aibiOtzQu3qtlbJtomNLhF30HEtn/7iBz50dlMECqATo3fG0LrdEgw==}
+ engines: {node: '>=14'}
+
resolution: {integrity: sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==}
engines: {node: '>= 0.8'}
@@ -7045,6 +7464,9 @@ packages:
resolution: {integrity: sha512-m5KgiH85xAhhW8Wta0vShLcUvOsh3LLPI2YVwcbio1l7E09NTLL1EyMZFM1OyWowoH0skScNbhOPl4kcBgzTww==}
+ resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
+
resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}
@@ -8388,6 +8810,9 @@ packages:
engines: {node: '>=6'}
hasBin: true
+ resolution: {integrity: sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==}
+
resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==}
@@ -8652,6 +9077,9 @@ packages:
resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==}
hasBin: true
+ resolution: {integrity: sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==}
+
resolution: {integrity: sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==}
engines: {node: '>=8'}
@@ -9492,6 +9920,10 @@ packages:
resolution: {integrity: sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==}
+ resolution: {integrity: sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA==}
+ engines: {node: '>=18'}
+
resolution: {integrity: sha512-smsWv2LzFjP03xmvFoJ331ss6h+jixfA4UUV/Bsiyuu4YJPfN+FIQGOIiv4w9/+MoHkfkJ22UIaQWRVFRfH6Vw==}
engines: {node: '>=20'}
@@ -9526,10 +9958,17 @@ packages:
resolution: {integrity: sha512-qFOyK5PjiWZd+QQIh+1jhdb9LpxTF0qs7Pm8o5QHYZ0M3vKqSqzsZaEB6oWlxZ+q2sJBMI/Ktgd2N5ZwQoRHfg==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-bkgD4qHlN7WxLdX8bLXdaU54TtQtAIg/ZBAfm0aje/mo3MRDo3P0hZSgr4U7O3xfX+fQmR5AP04JS/TGcZLcFA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+
resolution: {integrity: sha512-ov0NzaDCOInknS7mP1cwKdJERt3utPW8ldjtdUXQ8Ty0GEFD08wk422vCUN0d7pST6kqtV7dxoI9w1Zi0l/9TA==}
engines: {node: ^20.19.0 || >=22.12.0}
+ resolution: {integrity: sha512-w5tLwYN3Zo24w5EeWJjJWZOwhYqTtC8PS2B1tIt7BZUuqTIcU07sQValbDw+rq7+AuAGzOHklgK+ifsy4lpXfw==}
+
resolution: {integrity: sha512-FY91FiDBj7ls5MsFS9jN3tjz2o0/zsdSsymlakySaBwVJZorHhkWyICLZMKxlu1R9vYo+sd3z1jwb4J8x7bNDw==}
@@ -9626,6 +10065,10 @@ packages:
resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==}
+ resolution: {integrity: sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==}
+ engines: {node: '>= 14.16'}
+
resolution: {integrity: sha512-eRWB5LBz7PpDu4PUlwT0PhnQfTQJlDDdPa35urV4Osrm0t0AqQFGn+UIkU3klZvwJ8KPO3VbBFsXquA6p6kqZw==}
engines: {node: '>=12', npm: '>=6'}
@@ -9954,6 +10397,15 @@ packages:
resolution: {integrity: sha512-ePrwPfxAnB+7hgnEr8vpKxL9cmnp7F322t8oqcPshbIQQhDKgFDW4tjhF2wjVbdXF9O/nyuy3sQWd9JGpiLPvA==}
+ resolution: {integrity: sha512-ZtAp5XTO5HRzQctjPU0ybY0RRCQO19X/8fxn3w7y2VVTUbGHDKULPTL4ky3vB05euSgG5NpALhEhDPvQ56wvXg==}
+ peerDependencies:
+ typescript: '>= 4.3.x'
+
+ resolution: {integrity: sha512-gIYjtVTU4NCWZnb/LXVSWfClZXnjzX3+xxi69Tkfu4YsmYuqiOk8giLkKt/WwxWqh+U66CTh8Kqbha1uPv8/qQ==}
+ engines: {node: ^20.9.0 || >=22}
+
resolution: {integrity: sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==}
peerDependencies:
@@ -10820,6 +11272,21 @@ packages:
resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-/1h87XqC+8tZ5PQ/GVWOg78tCQuEAshYWwok5niBcnHEKzZy6Ls06uuT5/rhQ3iUB0y8iexEVHmUe3jaaxNguw==}
+ hasBin: true
+ peerDependencies:
+ '@types/react': ^19.2.0
+ prettier: ^2 || ^3
+ vite-plus: ^0.1.15 || ^0.2.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ prettier:
+ optional: true
+ vite-plus:
+ optional: true
+
resolution: {integrity: sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg==}
engines: {node: '>= 0.10.0'}
@@ -10900,6 +11367,10 @@ packages:
resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-SlyRoSkdh1dYP0PzclLE7r0M9sgbFKKMFXpFRUMNuKhQSbC6VQIGzq3E0qsfvGJaUFJPGv6Ws1NZ/haTAjfbMA==}
+ engines: {node: '>=12'}
+
resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==}
engines: {node: '>=8'}
@@ -11056,10 +11527,18 @@ packages:
resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==}
engines: {node: '>=12.0.0'}
+ resolution: {integrity: sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==}
+ engines: {node: '>=14.0.0'}
+
resolution: {integrity: sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==}
engines: {node: '>=14.0.0'}
+ resolution: {integrity: sha512-u8KszXvGfU68hVcZpRHKG28T0krMuv2G5nDhiHaMLen/gIuFEgIJhaJuO69qjnXg5paSrbPMFfx3brNuN8eVSg==}
+ engines: {node: '>=14.0.0'}
+
resolution: {integrity: sha512-YQ7uPjgWUibIK6DW5lrKujGwUKhLevU4hcGbP5O6TcIUb+oTjJYJVWPS4nZsIHrEEEG6myk/oqAJUEQmpZrHsg==}
@@ -11605,15 +12084,27 @@ packages:
engines: {node: '>=8.3.0'}
peerDependencies:
bufferutil: ^4.0.1
- utf-8-validate: ^5.0.2
+ utf-8-validate: ^5.0.2
+ peerDependenciesMeta:
+ bufferutil:
+ optional: true
+ utf-8-validate:
+ optional: true
+
+ resolution: {integrity: sha512-It4dO0K5v//JtTXuPkfEOaI3uUN87iYPnqo/ZzqCoG3g8uhA66QUMs/SrM0YK7/NAu+r4LMh/9dq2A7k+rHs+w==}
+ engines: {node: '>=10.0.0'}
+ peerDependencies:
+ bufferutil: ^4.0.1
+ utf-8-validate: '>=5.0.2'
peerDependenciesMeta:
bufferutil:
optional: true
utf-8-validate:
optional: true
- resolution: {integrity: sha512-It4dO0K5v//JtTXuPkfEOaI3uUN87iYPnqo/ZzqCoG3g8uhA66QUMs/SrM0YK7/NAu+r4LMh/9dq2A7k+rHs+w==}
+ resolution: {integrity: sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ==}
engines: {node: '>=10.0.0'}
peerDependencies:
bufferutil: ^4.0.1
@@ -11624,6 +12115,10 @@ packages:
utf-8-validate:
optional: true
+ resolution: {integrity: sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw==}
+ engines: {node: '>=18'}
+
resolution: {integrity: sha512-g/eziiSUNBSsdDJtCLB8bdYEUMj4jR7AGeUo96p/3dTafgjHhpF4RiCFPiRILwjQoDXx5MqkBr4fwWtR3Ky4Wg==}
engines: {node: '>=20'}
@@ -12388,10 +12883,10 @@ snapshots:
dotenv: 17.4.1
eciesjs: 0.4.18
execa: 5.1.1
- fdir: 6.5.0([email protected])
+ fdir: 6.5.0([email protected])
ignore: 5.3.2
object-treeify: 1.1.33
- picomatch: 4.0.3
+ picomatch: 4.0.7
which: 4.0.0
@@ -12521,17 +13016,34 @@ snapshots:
tslib: 2.8.1
optional: true
+ '@emnapi/[email protected]':
+ dependencies:
+ '@emnapi/wasi-threads': 1.2.2
+ tslib: 2.8.1
+ optional: true
+
'@emnapi/[email protected]':
dependencies:
'@emnapi/wasi-threads': 1.2.2
tslib: 2.8.1
optional: true
+ '@emnapi/[email protected]':
+ dependencies:
+ '@emnapi/wasi-threads': 1.2.1
+ tslib: 2.8.1
+ optional: true
+
'@emnapi/[email protected]':
dependencies:
tslib: 2.8.1
optional: true
+ '@emnapi/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
'@emnapi/[email protected]':
dependencies:
tslib: 2.8.1
@@ -12542,6 +13054,11 @@ snapshots:
tslib: 2.8.1
optional: true
+ '@emnapi/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
'@emnapi/[email protected]':
dependencies:
tslib: 2.8.1
@@ -12813,7 +13330,7 @@ snapshots:
node-forge: 1.4.0
npm-package-arg: 11.0.3
ora: 3.4.0
- picomatch: 4.0.5
+ picomatch: 4.0.7
pretty-format: 29.7.0
progress: 2.0.3
prompts: 2.4.2
@@ -12996,7 +13513,7 @@ snapshots:
hermes-parser: 0.36.1
jsc-safe-url: 0.2.4
lightningcss: 1.32.0
- picomatch: 4.0.5
+ picomatch: 4.0.7
postcss: 8.5.26
resolve-from: 5.0.0
optionalDependencies:
@@ -13382,6 +13899,14 @@ snapshots:
'@types/yargs': 17.0.35
chalk: 4.1.2
+ dependencies:
+ glob: 13.0.6
+ react-docgen-typescript: 2.4.0(@typescript/[email protected])
+ optionalDependencies:
+ typescript: '@typescript/[email protected]'
+
'@jridgewell/[email protected]':
dependencies:
'@jridgewell/sourcemap-codec': 1.5.5
@@ -13486,11 +14011,18 @@ snapshots:
outvariant: 1.4.3
strict-event-emitter: 0.5.1
dependencies:
'@emnapi/core': 1.10.0
'@emnapi/runtime': 1.10.0
- '@tybys/wasm-util': 0.10.1
+ '@tybys/wasm-util': 0.10.3
+ optional: true
+
+ dependencies:
+ '@emnapi/core': 1.11.0
+ '@emnapi/runtime': 1.11.0
+ '@tybys/wasm-util': 0.10.3
optional: true
@@ -13507,6 +14039,13 @@ snapshots:
'@tybys/wasm-util': 0.10.3
optional: true
+ dependencies:
+ '@emnapi/core': 1.9.2
+ '@emnapi/runtime': 1.9.2
+ '@tybys/wasm-util': 0.10.3
+ optional: true
+
'@next/[email protected]': {}
@@ -13665,115 +14204,236 @@ snapshots:
'@opentelemetry/[email protected]': {}
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ dependencies:
+ '@emnapi/core': 1.9.2
+ '@emnapi/runtime': 1.9.2
+ '@napi-rs/wasm-runtime': 1.2.3(@emnapi/[email protected])(@emnapi/[email protected])
+ optional: true
+
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-parser/[email protected]':
+ optional: true
+
'@oxc-parser/[email protected]':
optional: true
'@oxc-project/[email protected]': {}
+ '@oxc-project/[email protected]': {}
+
'@oxc-project/[email protected]': {}
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ dependencies:
+ '@emnapi/core': 1.11.0
+ '@emnapi/runtime': 1.11.0
+ '@napi-rs/wasm-runtime': 1.2.3(@emnapi/[email protected])(@emnapi/[email protected])
+ optional: true
+
'@oxc-resolver/[email protected]':
dependencies:
'@emnapi/core': 1.11.2
@@ -13781,9 +14441,15 @@ snapshots:
'@napi-rs/wasm-runtime': 1.2.3(@emnapi/[email protected])(@emnapi/[email protected])
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
+ '@oxc-resolver/[email protected]':
+ optional: true
+
'@oxc-resolver/[email protected]':
optional: true
@@ -14906,6 +15572,12 @@ snapshots:
'@rolldown/[email protected]': {}
+ '@rollup/[email protected]':
+ dependencies:
+ '@types/estree': 1.0.8
+ estree-walker: 2.0.2
+ picomatch: 4.0.7
+
'@rtsao/[email protected]': {}
'@sec-ant/[email protected]': {}
@@ -15025,6 +15697,66 @@ snapshots:
'@standard-schema/[email protected]': {}
+ dependencies:
+ storybook: 10.6.7(@types/[email protected])([email protected])
+ ts-dedent: 2.2.0
+
+ '@storybook/[email protected]': {}
+
+ dependencies:
+ react: 19.2.3
+
+ dependencies:
+ react: 19.2.3
+ react-dom: 19.2.3([email protected])
+ storybook: 10.6.7(@types/[email protected])([email protected])
+ optionalDependencies:
+ '@types/react': 19.2.14
+ '@types/react-dom': 19.2.3(@types/[email protected])
+
+ dependencies:
+ '@joshwooding/vite-plugin-react-docgen-typescript': 0.7.0(@typescript/[email protected])([email protected](@emnapi/[email protected])(@emnapi/[email protected])(@types/[email protected])([email protected])([email protected])([email protected]))
+ '@rollup/pluginutils': 5.5.1
+ empathic: 2.1.0
+ magic-string: 1.4.3
+ react: 19.2.3
+ react-docgen: 8.0.4
+ react-dom: 19.2.3([email protected])
+ resolve: 1.22.12
+ storybook: 10.6.7(@types/[email protected])([email protected])
+ tsconfig-paths: 4.2.0
+ optionalDependencies:
+ typescript: '@typescript/[email protected]'
+ transitivePeerDependencies:
+ - '@types/react'
+ - '@types/react-dom'
+ - rollup
+ - supports-color
+
+ dependencies:
+ '@storybook/global': 5.0.0
+ react: 19.2.3
+ react-docgen: 8.0.4
+ react-docgen-typescript: 2.4.0(@typescript/[email protected])
+ react-dom: 19.2.3([email protected])
+ storybook: 10.6.7(@types/[email protected])([email protected])
+ optionalDependencies:
+ '@types/react': 19.2.14
+ '@types/react-dom': 19.2.3(@types/[email protected])
+ typescript: '@typescript/[email protected]'
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
tslib: 2.8.1
@@ -15168,6 +15900,10 @@ snapshots:
dependencies:
'@testing-library/dom': 10.4.1
+ '@testing-library/[email protected](@testing-library/[email protected])':
+ dependencies:
+ '@testing-library/dom': 10.4.1
+
dependencies:
'@tiptap/pm': 3.31.3
@@ -15424,11 +16160,6 @@ snapshots:
optional: true
- '@tybys/[email protected]':
- dependencies:
- tslib: 2.8.1
- optional: true
-
dependencies:
tslib: 2.8.1
@@ -15592,6 +16323,8 @@ snapshots:
'@types/[email protected]': {}
+ '@types/[email protected]': {}
+
dependencies:
'@types/estree': 1.0.8
@@ -15678,6 +16411,8 @@ snapshots:
dependencies:
csstype: 3.2.3
+ '@types/[email protected]': {}
+
dependencies:
'@types/node': 25.5.0
@@ -15858,7 +16593,7 @@ snapshots:
debug: 4.4.3
minimatch: 10.2.4
semver: 7.7.4
- tinyglobby: 0.2.15
+ tinyglobby: 0.2.17
ts-api-utils: 2.5.0(@typescript/[email protected])
typescript: '@typescript/[email protected]'
transitivePeerDependencies:
@@ -15873,7 +16608,7 @@ snapshots:
debug: 4.4.3
minimatch: 10.2.4
semver: 7.7.4
- tinyglobby: 0.2.15
+ tinyglobby: 0.2.17
ts-api-utils: 2.5.0([email protected])
typescript: 6.0.3
transitivePeerDependencies:
@@ -16056,7 +16791,7 @@ snapshots:
dependencies:
'@emnapi/core': 1.10.0
'@emnapi/runtime': 1.10.0
- '@napi-rs/wasm-runtime': 1.1.4(@emnapi/[email protected])(@emnapi/[email protected])
+ '@napi-rs/wasm-runtime': 1.2.3(@emnapi/[email protected])(@emnapi/[email protected])
optional: true
@@ -16099,6 +16834,14 @@ snapshots:
optionalDependencies:
babel-plugin-react-compiler: 1.0.0
+ '@vitest/[email protected]':
+ dependencies:
+ '@types/chai': 5.2.3
+ '@vitest/spy': 3.2.4
+ '@vitest/utils': 3.2.4
+ chai: 5.3.3
+ tinyrainbow: 2.0.0
+
'@vitest/[email protected]':
dependencies:
'@standard-schema/spec': 1.1.0
@@ -16144,6 +16887,10 @@ snapshots:
msw: 2.12.14(@types/[email protected])([email protected])
+ '@vitest/[email protected]':
+ dependencies:
+ tinyrainbow: 2.0.0
+
'@vitest/[email protected]':
dependencies:
tinyrainbow: 3.1.0
@@ -16160,14 +16907,26 @@ snapshots:
magic-string: 0.30.21
pathe: 2.0.3
+ '@vitest/[email protected]':
+ dependencies:
+ tinyspy: 4.0.6
+
'@vitest/[email protected]': {}
+ '@vitest/[email protected]':
+ dependencies:
+ '@vitest/pretty-format': 3.2.4
+ loupe: 3.2.1
+ tinyrainbow: 2.0.0
+
'@vitest/[email protected]':
dependencies:
'@vitest/pretty-format': 4.1.0
convert-source-map: 2.0.0
tinyrainbow: 3.1.0
+ '@webcontainer/[email protected]': {}
+
'@xmldom/[email protected]': {}
'@yuku-core/[email protected]':
@@ -16722,6 +17481,14 @@ snapshots:
+ dependencies:
+ assertion-error: 2.0.1
+ check-error: 2.1.3
+ deep-eql: 5.0.2
+ loupe: 3.2.1
+ pathval: 2.0.1
+
@@ -16745,6 +17512,8 @@ snapshots:
+
dependencies:
chevrotain: 12.0.0
@@ -17294,6 +18063,8 @@ snapshots:
+
@@ -17394,6 +18165,10 @@ snapshots:
dependencies:
esutils: 2.0.3
+ dependencies:
+ esutils: 2.0.3
+
@@ -17551,6 +18326,8 @@ snapshots:
+
@@ -18124,6 +18901,8 @@ snapshots:
'@types/estree-jsx': 1.0.5
'@types/unist': 3.0.3
+
dependencies:
'@types/estree': 1.0.8
@@ -18561,6 +19340,10 @@ snapshots:
optionalDependencies:
picomatch: 4.0.5
+ optionalDependencies:
+ picomatch: 4.0.7
+
dependencies:
node-domexception: 1.0.0
@@ -19686,6 +20469,8 @@ snapshots:
+
optionalDependencies:
graceful-fs: 4.2.11
@@ -19908,6 +20693,8 @@ snapshots:
dependencies:
js-tokens: 4.0.0
+
@@ -21326,6 +22113,13 @@ snapshots:
regex: 6.1.0
regex-recursion: 6.0.2
+ dependencies:
+ default-browser: 5.5.0
+ define-lazy-prop: 3.0.0
+ is-inside-container: 1.0.0
+ wsl-utils: 0.1.0
+
dependencies:
default-browser: 5.5.0
@@ -21392,6 +22186,31 @@ snapshots:
object-keys: 1.1.1
safe-push-apply: 1.0.0
+ dependencies:
+ '@oxc-project/types': 0.127.0
+ optionalDependencies:
+ '@oxc-parser/binding-android-arm-eabi': 0.127.0
+ '@oxc-parser/binding-android-arm64': 0.127.0
+ '@oxc-parser/binding-darwin-arm64': 0.127.0
+ '@oxc-parser/binding-darwin-x64': 0.127.0
+ '@oxc-parser/binding-freebsd-x64': 0.127.0
+ '@oxc-parser/binding-linux-arm-gnueabihf': 0.127.0
+ '@oxc-parser/binding-linux-arm-musleabihf': 0.127.0
+ '@oxc-parser/binding-linux-arm64-gnu': 0.127.0
+ '@oxc-parser/binding-linux-arm64-musl': 0.127.0
+ '@oxc-parser/binding-linux-ppc64-gnu': 0.127.0
+ '@oxc-parser/binding-linux-riscv64-gnu': 0.127.0
+ '@oxc-parser/binding-linux-riscv64-musl': 0.127.0
+ '@oxc-parser/binding-linux-s390x-gnu': 0.127.0
+ '@oxc-parser/binding-linux-x64-gnu': 0.127.0
+ '@oxc-parser/binding-linux-x64-musl': 0.127.0
+ '@oxc-parser/binding-openharmony-arm64': 0.127.0
+ '@oxc-parser/binding-wasm32-wasi': 0.127.0
+ '@oxc-parser/binding-win32-arm64-msvc': 0.127.0
+ '@oxc-parser/binding-win32-ia32-msvc': 0.127.0
+ '@oxc-parser/binding-win32-x64-msvc': 0.127.0
+
dependencies:
'@oxc-project/types': 0.143.0
@@ -21416,6 +22235,28 @@ snapshots:
'@oxc-parser/binding-win32-ia32-msvc': 0.143.0
'@oxc-parser/binding-win32-x64-msvc': 0.143.0
+ optionalDependencies:
+ '@oxc-resolver/binding-android-arm-eabi': 11.21.2
+ '@oxc-resolver/binding-android-arm64': 11.21.2
+ '@oxc-resolver/binding-darwin-arm64': 11.21.2
+ '@oxc-resolver/binding-darwin-x64': 11.21.2
+ '@oxc-resolver/binding-freebsd-x64': 11.21.2
+ '@oxc-resolver/binding-linux-arm-gnueabihf': 11.21.2
+ '@oxc-resolver/binding-linux-arm-musleabihf': 11.21.2
+ '@oxc-resolver/binding-linux-arm64-gnu': 11.21.2
+ '@oxc-resolver/binding-linux-arm64-musl': 11.21.2
+ '@oxc-resolver/binding-linux-ppc64-gnu': 11.21.2
+ '@oxc-resolver/binding-linux-riscv64-gnu': 11.21.2
+ '@oxc-resolver/binding-linux-riscv64-musl': 11.21.2
+ '@oxc-resolver/binding-linux-s390x-gnu': 11.21.2
+ '@oxc-resolver/binding-linux-x64-gnu': 11.21.2
+ '@oxc-resolver/binding-linux-x64-musl': 11.21.2
+ '@oxc-resolver/binding-openharmony-arm64': 11.21.2
+ '@oxc-resolver/binding-wasm32-wasi': 11.21.2
+ '@oxc-resolver/binding-win32-arm64-msvc': 11.21.2
+ '@oxc-resolver/binding-win32-x64-msvc': 11.21.2
+
optionalDependencies:
'@oxc-resolver/binding-android-arm-eabi': 11.24.2
@@ -21521,6 +22362,8 @@ snapshots:
+
@@ -21886,6 +22729,25 @@ snapshots:
- bufferutil
- utf-8-validate
+ dependencies:
+ typescript: '@typescript/[email protected]'
+
+ dependencies:
+ '@babel/core': 7.29.0
+ '@babel/traverse': 7.29.0
+ '@babel/types': 7.29.0
+ '@types/babel__core': 7.20.5
+ '@types/babel__traverse': 7.28.0
+ '@types/doctrine': 0.0.9
+ '@types/resolve': 1.20.6
+ doctrine: 3.0.0
+ resolve: 1.22.12
+ strip-indent: 4.1.1
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
react: 19.2.3
@@ -23015,6 +23877,32 @@ snapshots:
es-errors: 1.3.0
internal-slot: 1.1.0
+ dependencies:
+ '@storybook/global': 5.0.0
+ '@storybook/icons': 2.2.0([email protected])
+ '@testing-library/dom': 10.4.1
+ '@testing-library/jest-dom': 6.9.1
+ '@testing-library/user-event': 14.6.10(@testing-library/[email protected])
+ '@vitest/expect': 3.2.4
+ '@vitest/spy': 3.2.4
+ '@webcontainer/env': 1.1.1
+ esbuild: 0.25.12
+ jsonc-parser: 3.3.1
+ open: 10.2.0
+ oxc-parser: 0.127.0
+ oxc-resolver: 11.21.2
+ recast: 0.23.11
+ semver: 7.8.5
+ use-sync-external-store: 1.6.0([email protected])
+ ws: 8.23.0
+ optionalDependencies:
+ '@types/react': 19.2.14
+ transitivePeerDependencies:
+ - bufferutil
+ - react
+ - utf-8-validate
+
@@ -23120,6 +24008,8 @@ snapshots:
dependencies:
min-indent: 1.0.1
+
@@ -23150,7 +24040,7 @@ snapshots:
lines-and-columns: 1.2.4
mz: 2.7.0
pirates: 4.0.7
- tinyglobby: 0.2.15
+ tinyglobby: 0.2.17
ts-interface-checker: 0.1.13
@@ -23288,8 +24178,12 @@ snapshots:
fdir: 6.5.0([email protected])
picomatch: 4.0.5
+
+
@@ -24000,6 +24894,12 @@ snapshots:
+
+ dependencies:
+ is-wsl: 3.1.1
+
dependencies:
is-wsl: 3.1.1
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 5b58119985..8d388657df 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -8,6 +8,7 @@ catalog:
'@dnd-kit/modifiers': ^9.0.0
'@dnd-kit/sortable': ^10.0.0
'@dnd-kit/utilities': ^3.2.2
+ '@fontsource-variable/inter': ^5.2.5
'@formatjs/intl-localematcher': ^0.8.4
'@tailwindcss/postcss': ^4
'@tailwindcss/vite': ^4