Skip to content

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

Go

feat(ui): extract packages/ui — shared atomic UI layer

Naiyuan Qing35828492d565
diff --git a/apps/web/app/(auth)/login/page.tsx b/apps/web/app/(auth)/login/page.tsx
index 718b6e5200..d78ec84314 100644
--- a/apps/web/app/(auth)/login/page.tsx
+++ b/apps/web/app/(auth)/login/page.tsx
@@ -13,15 +13,15 @@ import {
CardDescription,
CardContent,
CardFooter,
-} from "@/components/ui/card";
-import { Input } from "@/components/ui/input";
-import { Button } from "@/components/ui/button";
-import { Label } from "@/components/ui/label";
+} from "@multica/ui/components/ui/card";
+import { Input } from "@multica/ui/components/ui/input";
+import { Button } from "@multica/ui/components/ui/button";
+import { Label } from "@multica/ui/components/ui/label";
import {
InputOTP,
InputOTPGroup,
InputOTPSlot,
-} from "@/components/ui/input-otp";
+} from "@multica/ui/components/ui/input-otp";
import type { User } from "@multica/core/types";
function validateCliCallback(cliCallback: string): boolean {
diff --git a/apps/web/app/(dashboard)/_components/app-sidebar.tsx b/apps/web/app/(dashboard)/_components/app-sidebar.tsx
index da9e101fd8..43f9ff7f36 100644
--- a/apps/web/app/(dashboard)/_components/app-sidebar.tsx
+++ b/apps/web/app/(dashboard)/_components/app-sidebar.tsx
@@ -30,7 +30,7 @@ import {
SidebarMenuButton,
SidebarMenuItem,
SidebarRail,
-} from "@/components/ui/sidebar";
+} from "@multica/ui/components/ui/sidebar";
import {
DropdownMenu,
DropdownMenuContent,
@@ -39,8 +39,8 @@ import {
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
-import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
+} from "@multica/ui/components/ui/dropdown-menu";
+import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
import { useAuthStore } from "@/platform/auth";
import { useWorkspaceStore } from "@/platform/workspace";
import { useQuery } from "@tanstack/react-query";
diff --git a/apps/web/app/(dashboard)/agents/page.tsx b/apps/web/app/(dashboard)/agents/page.tsx
index 474d1a1d22..e87a3a1341 100644
--- a/apps/web/app/(dashboard)/agents/page.tsx
+++ b/apps/web/app/(dashboard)/agents/page.tsx
@@ -42,28 +42,28 @@ import {
DialogTitle,
DialogDescription,
DialogFooter,
-} from "@/components/ui/dialog";
+} from "@multica/ui/components/ui/dialog";
import {
ResizablePanelGroup,
ResizablePanel,
ResizableHandle,
-} from "@/components/ui/resizable";
+} from "@multica/ui/components/ui/resizable";
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
-} from "@/components/ui/dropdown-menu";
+} from "@multica/ui/components/ui/dropdown-menu";
import {
Popover,
PopoverTrigger,
PopoverContent,
-} from "@/components/ui/popover";
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Label } from "@/components/ui/label";
+} from "@multica/ui/components/ui/popover";
+import { Button } from "@multica/ui/components/ui/button";
+import { Input } from "@multica/ui/components/ui/input";
+import { Label } from "@multica/ui/components/ui/label";
import { toast } from "sonner";
-import { Skeleton } from "@/components/ui/skeleton";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
import { api } from "@/platform/api";
import { useAuthStore } from "@/platform/auth";
import { useWorkspaceStore } from "@/platform/workspace";
diff --git a/apps/web/app/(dashboard)/inbox/page.tsx b/apps/web/app/(dashboard)/inbox/page.tsx
index 5c4addc983..8b2ae96cd4 100644
--- a/apps/web/app/(dashboard)/inbox/page.tsx
+++ b/apps/web/app/(dashboard)/inbox/page.tsx
@@ -32,20 +32,20 @@ import {
ListChecks,
} from "lucide-react";
import type { InboxItem, InboxItemType, IssueStatus, IssuePriority } from "@multica/core/types";
-import { Button } from "@/components/ui/button";
+import { Button } from "@multica/ui/components/ui/button";
import {
ResizablePanelGroup,
ResizablePanel,
ResizableHandle,
-} from "@/components/ui/resizable";
-import { Skeleton } from "@/components/ui/skeleton";
+} from "@multica/ui/components/ui/resizable";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
-} from "@/components/ui/dropdown-menu";
+} from "@multica/ui/components/ui/dropdown-menu";
// ---------------------------------------------------------------------------
// Helpers
diff --git a/apps/web/app/(dashboard)/layout.tsx b/apps/web/app/(dashboard)/layout.tsx
index 1aec45a0fa..b50ba533f0 100644
--- a/apps/web/app/(dashboard)/layout.tsx
+++ b/apps/web/app/(dashboard)/layout.tsx
@@ -4,7 +4,7 @@ import { useEffect } from "react";
import { useRouter, usePathname } from "next/navigation";
import { MulticaIcon } from "@/components/multica-icon";
import { useNavigationStore } from "@multica/core/navigation";
-import { SidebarProvider, SidebarInset } from "@/components/ui/sidebar";
+import { SidebarProvider, SidebarInset } from "@multica/ui/components/ui/sidebar";
import { useAuthStore } from "@/platform/auth";
import { useWorkspaceStore } from "@/platform/workspace";
import { AppSidebar } from "./_components/app-sidebar";
diff --git a/apps/web/app/(dashboard)/loading.tsx b/apps/web/app/(dashboard)/loading.tsx
index 8e96cdd5de..561f7d1219 100644
--- a/apps/web/app/(dashboard)/loading.tsx
+++ b/apps/web/app/(dashboard)/loading.tsx
@@ -1,4 +1,4 @@
-import { Skeleton } from "@/components/ui/skeleton";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
export default function DashboardLoading() {
return (
diff --git a/apps/web/app/(dashboard)/settings/_components/account-tab.tsx b/apps/web/app/(dashboard)/settings/_components/account-tab.tsx
index dcff60d434..c81f4d8f45 100644
--- a/apps/web/app/(dashboard)/settings/_components/account-tab.tsx
+++ b/apps/web/app/(dashboard)/settings/_components/account-tab.tsx
@@ -2,10 +2,10 @@
import { useEffect, useRef, useState } from "react";
import { Camera, Loader2, Save } from "lucide-react";
-import { Input } from "@/components/ui/input";
-import { Label } from "@/components/ui/label";
-import { Button } from "@/components/ui/button";
-import { Card, CardContent } from "@/components/ui/card";
+import { Input } from "@multica/ui/components/ui/input";
+import { Label } from "@multica/ui/components/ui/label";
+import { Button } from "@multica/ui/components/ui/button";
+import { Card, CardContent } from "@multica/ui/components/ui/card";
import { toast } from "sonner";
import { useAuthStore } from "@/platform/auth";
import { api } from "@/platform/api";
diff --git a/apps/web/app/(dashboard)/settings/_components/general-tab.tsx b/apps/web/app/(dashboard)/settings/_components/general-tab.tsx
index 5efe4a1933..bc9b1428dc 100644
--- a/apps/web/app/(dashboard)/settings/_components/general-tab.tsx
+++ b/apps/web/app/(dashboard)/settings/_components/general-tab.tsx
@@ -1,7 +1,7 @@
"use client";
import { useTheme } from "next-themes";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
const LIGHT_COLORS = {
titleBar: "#e8e8e8",
diff --git a/apps/web/app/(dashboard)/settings/_components/members-tab.tsx b/apps/web/app/(dashboard)/settings/_components/members-tab.tsx
index 2c72f30732..da194ae6df 100644
--- a/apps/web/app/(dashboard)/settings/_components/members-tab.tsx
+++ b/apps/web/app/(dashboard)/settings/_components/members-tab.tsx
@@ -4,10 +4,10 @@ import { useState } from "react";
import { Crown, Shield, User, Plus, MoreHorizontal, UserMinus, Users } from "lucide-react";
import { ActorAvatar } from "@/components/common/actor-avatar";
import type { MemberWithUser, MemberRole } from "@multica/core/types";
-import { Input } from "@/components/ui/input";
-import { Button } from "@/components/ui/button";
-import { Card, CardContent } from "@/components/ui/card";
-import { Badge } from "@/components/ui/badge";
+import { Input } from "@multica/ui/components/ui/input";
+import { Button } from "@multica/ui/components/ui/button";
+import { Card, CardContent } from "@multica/ui/components/ui/card";
+import { Badge } from "@multica/ui/components/ui/badge";
import {
AlertDialog,
AlertDialogContent,
@@ -17,14 +17,14 @@ import {
AlertDialogFooter,
AlertDialogCancel,
AlertDialogAction,
-} from "@/components/ui/alert-dialog";
+} from "@multica/ui/components/ui/alert-dialog";
import {
Select,
SelectTrigger,
SelectValue,
SelectContent,
SelectItem,
-} from "@/components/ui/select";
+} from "@multica/ui/components/ui/select";
import {
DropdownMenu,
DropdownMenuTrigger,
@@ -34,7 +34,7 @@ import {
DropdownMenuSub,
DropdownMenuSubTrigger,
DropdownMenuSubContent,
-} from "@/components/ui/dropdown-menu";
+} from "@multica/ui/components/ui/dropdown-menu";
import { toast } from "sonner";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { useAuthStore } from "@/platform/auth";
diff --git a/apps/web/app/(dashboard)/settings/_components/repositories-tab.tsx b/apps/web/app/(dashboard)/settings/_components/repositories-tab.tsx
index 598d116c0b..bd6b9737f7 100644
--- a/apps/web/app/(dashboard)/settings/_components/repositories-tab.tsx
+++ b/apps/web/app/(dashboard)/settings/_components/repositories-tab.tsx
@@ -2,9 +2,9 @@
import { useEffect, useState } from "react";
import { Save, Plus, Trash2 } from "lucide-react";
-import { Input } from "@/components/ui/input";
-import { Button } from "@/components/ui/button";
-import { Card, CardContent } from "@/components/ui/card";
+import { Input } from "@multica/ui/components/ui/input";
+import { Button } from "@multica/ui/components/ui/button";
+import { Card, CardContent } from "@multica/ui/components/ui/card";
import { toast } from "sonner";
import { useQuery } from "@tanstack/react-query";
import { useAuthStore } from "@/platform/auth";
diff --git a/apps/web/app/(dashboard)/settings/_components/tokens-tab.tsx b/apps/web/app/(dashboard)/settings/_components/tokens-tab.tsx
index 889aa92b8a..03543934f2 100644
--- a/apps/web/app/(dashboard)/settings/_components/tokens-tab.tsx
+++ b/apps/web/app/(dashboard)/settings/_components/tokens-tab.tsx
@@ -2,18 +2,18 @@
import { useEffect, useState, useCallback } from "react";
import { Key, Trash2, Copy, Check } from "lucide-react";
-import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
+import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
import type { PersonalAccessToken } from "@multica/core/types";
-import { Input } from "@/components/ui/input";
-import { Button } from "@/components/ui/button";
-import { Card, CardContent } from "@/components/ui/card";
+import { Input } from "@multica/ui/components/ui/input";
+import { Button } from "@multica/ui/components/ui/button";
+import { Card, CardContent } from "@multica/ui/components/ui/card";
import {
Select,
SelectTrigger,
SelectValue,
SelectContent,
SelectItem,
-} from "@/components/ui/select";
+} from "@multica/ui/components/ui/select";
import {
Dialog,
DialogContent,
@@ -21,7 +21,7 @@ import {
DialogTitle,
DialogDescription,
DialogFooter,
-} from "@/components/ui/dialog";
+} from "@multica/ui/components/ui/dialog";
import {
AlertDialog,
AlertDialogAction,
@@ -31,8 +31,8 @@ import {
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
-} from "@/components/ui/alert-dialog";
-import { Skeleton } from "@/components/ui/skeleton";
+} from "@multica/ui/components/ui/alert-dialog";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
import { toast } from "sonner";
import { api } from "@/platform/api";
diff --git a/apps/web/app/(dashboard)/settings/_components/workspace-tab.tsx b/apps/web/app/(dashboard)/settings/_components/workspace-tab.tsx
index 1b5d16cc7b..5e7829359a 100644
--- a/apps/web/app/(dashboard)/settings/_components/workspace-tab.tsx
+++ b/apps/web/app/(dashboard)/settings/_components/workspace-tab.tsx
@@ -2,11 +2,11 @@
import { useEffect, useState } from "react";
import { Save, LogOut } from "lucide-react";
-import { Input } from "@/components/ui/input";
-import { Textarea } from "@/components/ui/textarea";
-import { Label } from "@/components/ui/label";
-import { Button } from "@/components/ui/button";
-import { Card, CardContent } from "@/components/ui/card";
+import { Input } from "@multica/ui/components/ui/input";
+import { Textarea } from "@multica/ui/components/ui/textarea";
+import { Label } from "@multica/ui/components/ui/label";
+import { Button } from "@multica/ui/components/ui/button";
+import { Card, CardContent } from "@multica/ui/components/ui/card";
import {
AlertDialog,
AlertDialogContent,
@@ -16,7 +16,7 @@ import {
AlertDialogFooter,
AlertDialogCancel,
AlertDialogAction,
-} from "@/components/ui/alert-dialog";
+} from "@multica/ui/components/ui/alert-dialog";
import { toast } from "sonner";
import { useQuery } from "@tanstack/react-query";
import { useAuthStore } from "@/platform/auth";
diff --git a/apps/web/app/(dashboard)/settings/page.tsx b/apps/web/app/(dashboard)/settings/page.tsx
index a8c1efa0e9..c8ab373d98 100644
--- a/apps/web/app/(dashboard)/settings/page.tsx
+++ b/apps/web/app/(dashboard)/settings/page.tsx
@@ -1,7 +1,7 @@
"use client";
import { User, Palette, Key, Settings, Users, FolderGit2 } from "lucide-react";
-import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
+import { Tabs, TabsList, TabsTrigger, TabsContent } from "@multica/ui/components/ui/tabs";
import { useWorkspaceStore } from "@/platform/workspace";
import { AccountTab } from "./_components/account-tab";
import { AppearanceTab } from "./_components/general-tab";
diff --git a/apps/web/app/auth/callback/page.tsx b/apps/web/app/auth/callback/page.tsx
index 8208ae3e20..87bdd59e4b 100644
--- a/apps/web/app/auth/callback/page.tsx
+++ b/apps/web/app/auth/callback/page.tsx
@@ -11,7 +11,7 @@ import {
CardTitle,
CardDescription,
CardContent,
-} from "@/components/ui/card";
+} from "@multica/ui/components/ui/card";
import { Loader2 } from "lucide-react";
function CallbackContent() {
diff --git a/apps/web/app/globals.css b/apps/web/app/globals.css
index ab982eebe0..2a1cb7a50c 100644
--- a/apps/web/app/globals.css
+++ b/apps/web/app/globals.css
@@ -1,149 +1,13 @@
@import "tailwindcss";
@import "tw-animate-css";
@import "shadcn/tailwind.css";
+@import "@multica/ui/styles/tokens.css";
@import "./custom.css";
@custom-variant dark (&:is(.dark *));
-@theme inline {
- --font-heading: var(--font-sans);
- --font-sans: var(--font-sans);
- --font-mono: var(--font-mono);
- --color-sidebar-ring: var(--sidebar-ring);
- --color-sidebar-border: var(--sidebar-border);
- --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
- --color-sidebar-accent: var(--sidebar-accent);
- --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
- --color-sidebar-primary: var(--sidebar-primary);
- --color-sidebar-foreground: var(--sidebar-foreground);
- --color-sidebar: var(--sidebar);
- --color-chart-5: var(--chart-5);
- --color-chart-4: var(--chart-4);
- --color-chart-3: var(--chart-3);
- --color-chart-2: var(--chart-2);
- --color-chart-1: var(--chart-1);
- --color-ring: var(--ring);
- --color-input: var(--input);
- --color-border: var(--border);
- --color-destructive: var(--destructive);
- --color-success: var(--success);
- --color-warning: var(--warning);
- --color-info: var(--info);
- --color-brand: var(--brand);
- --color-brand-foreground: var(--brand-foreground);
- --color-priority: var(--priority);
- --color-canvas: var(--canvas);
- --color-accent-foreground: var(--accent-foreground);
- --color-accent: var(--accent);
- --color-muted-foreground: var(--muted-foreground);
- --color-muted: var(--muted);
- --color-secondary-foreground: var(--secondary-foreground);
- --color-secondary: var(--secondary);
- --color-primary-foreground: var(--primary-foreground);
- --color-primary: var(--primary);
- --color-popover-foreground: var(--popover-foreground);
- --color-popover: var(--popover);
- --color-card-foreground: var(--card-foreground);
- --color-card: var(--card);
- --color-foreground: var(--foreground);
- --color-background: var(--background);
- --radius-sm: calc(var(--radius) * 0.6);
- --radius-md: calc(var(--radius) * 0.8);
- --radius-lg: var(--radius);
- --radius-xl: calc(var(--radius) * 1.4);
- --radius-2xl: calc(var(--radius) * 1.8);
- --radius-3xl: calc(var(--radius) * 2.2);
- --radius-4xl: calc(var(--radius) * 2.6);
-}
-
-:root {
- --background: oklch(1 0 0);
- --foreground: oklch(0.141 0.005 285.823);
- --card: oklch(1 0 0);
- --card-foreground: oklch(0.141 0.005 285.823);
- --popover: oklch(1 0 0);
- --popover-foreground: oklch(0.141 0.005 285.823);
- --primary: oklch(0.21 0.006 285.885);
- --primary-foreground: oklch(0.985 0 0);
- --secondary: oklch(0.967 0.001 286.375);
- --secondary-foreground: oklch(0.21 0.006 285.885);
- --muted: oklch(0.967 0.001 286.375);
- --muted-foreground: oklch(0.552 0.016 285.938);
- --accent: oklch(0.967 0.001 286.375);
- --accent-foreground: oklch(0.21 0.006 285.885);
- --destructive: oklch(0.577 0.245 27.325);
- --border: oklch(0.92 0.004 286.32);
- --input: oklch(0.92 0.004 286.32);
- --ring: oklch(0.705 0.015 286.067);
- --chart-1: oklch(0.871 0.006 286.286);
- --chart-2: oklch(0.552 0.016 285.938);
- --chart-3: oklch(0.442 0.017 285.786);
- --chart-4: oklch(0.37 0.013 285.805);
- --chart-5: oklch(0.274 0.006 286.033);
- --radius: 0.625rem;
- --sidebar: oklch(0.985 0 0);
- --sidebar-foreground: oklch(0.141 0.005 285.823);
- --sidebar-primary: oklch(0.21 0.006 285.885);
- --sidebar-primary-foreground: oklch(0.985 0 0);
- --sidebar-accent: oklch(0.95 0.002 286.375);
- --sidebar-accent-foreground: oklch(0.21 0.006 285.885);
- --sidebar-border: oklch(0.92 0.004 286.32);
- --sidebar-ring: oklch(0.705 0.015 286.067);
- --brand: oklch(0.55 0.16 255);
- --brand-foreground: oklch(0.985 0 0);
- --canvas: oklch(0.95 0.002 286);
- --success: oklch(0.55 0.16 145);
- --warning: oklch(0.75 0.16 85);
- --info: oklch(0.55 0.18 250);
- --priority: oklch(0.65 0.18 50);
- --scrollbar-thumb: oklch(0 0 0 / 10%);
- --scrollbar-thumb-hover: oklch(0 0 0 / 18%);
- --scrollbar-track: transparent;
-}
-
-.dark {
- --background: oklch(0.18 0.005 285.823);
- --foreground: oklch(0.985 0 0);
- --card: oklch(0.21 0.006 285.885);
- --card-foreground: oklch(0.985 0 0);
- --popover: oklch(0.21 0.006 285.885);
- --popover-foreground: oklch(0.985 0 0);
- --primary: oklch(0.92 0.004 286.32);
- --primary-foreground: oklch(0.21 0.006 285.885);
- --secondary: oklch(0.274 0.006 286.033);
- --secondary-foreground: oklch(0.985 0 0);
- --muted: oklch(0.274 0.006 286.033);
- --muted-foreground: oklch(0.705 0.015 286.067);
- --accent: oklch(0.274 0.006 286.033);
- --accent-foreground: oklch(0.985 0 0);
- --destructive: oklch(0.704 0.191 22.216);
- --border: oklch(1 0 0 / 10%);
- --input: oklch(1 0 0 / 15%);
- --ring: oklch(0.552 0.016 285.938);
- --chart-1: oklch(0.871 0.006 286.286);
- --chart-2: oklch(0.552 0.016 285.938);
- --chart-3: oklch(0.442 0.017 285.786);
- --chart-4: oklch(0.37 0.013 285.805);
- --chart-5: oklch(0.274 0.006 286.033);
- --sidebar: oklch(0.21 0.006 285.885);
- --sidebar-foreground: oklch(0.985 0 0);
- --sidebar-primary: oklch(0.488 0.243 264.376);
- --sidebar-primary-foreground: oklch(0.985 0 0);
- --sidebar-accent: oklch(0.274 0.006 286.033);
- --sidebar-accent-foreground: oklch(0.985 0 0);
- --sidebar-border: oklch(1 0 0 / 10%);
- --sidebar-ring: oklch(0.552 0.016 285.938);
- --brand: oklch(0.65 0.16 255);
- --brand-foreground: oklch(0.985 0 0);
- --canvas: oklch(0.2 0.005 286);
- --success: oklch(0.65 0.15 145);
- --warning: oklch(0.70 0.16 85);
- --info: oklch(0.65 0.18 250);
- --priority: oklch(0.70 0.18 50);
- --scrollbar-thumb: oklch(1 0 0 / 8%);
- --scrollbar-thumb-hover: oklch(1 0 0 / 18%);
- --scrollbar-track: transparent;
-}
+@source "../../packages/ui/**/*.tsx";
+@source "../../packages/core/**/*.tsx";
@layer base {
* {
@@ -161,4 +25,4 @@
html {
@apply font-sans;
}
-}
\ No newline at end of file
+}
diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx
index 7bbf522931..574bb1ee78 100644
--- a/apps/web/app/layout.tsx
+++ b/apps/web/app/layout.tsx
@@ -1,8 +1,8 @@
import type { Metadata, Viewport } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import { ThemeProvider } from "@/components/theme-provider";
-import { Toaster } from "@/components/ui/sonner";
-import { cn } from "@/lib/utils";
+import { Toaster } from "@multica/ui/components/ui/sonner";
+import { cn } from "@multica/ui/lib/utils";
import { QueryProvider } from "@multica/core/provider";
import { AuthInitializer } from "@/features/auth";
import { WebWSProvider } from "@/platform/ws-provider";
diff --git a/apps/web/components/common/actor-avatar.tsx b/apps/web/components/common/actor-avatar.tsx
index b2956a5dc0..036074118e 100644
--- a/apps/web/components/common/actor-avatar.tsx
+++ b/apps/web/components/common/actor-avatar.tsx
@@ -1,73 +1,25 @@
"use client";
-import { useState, useEffect } from "react";
-import { Bot } from "lucide-react";
-import { cn } from "@/lib/utils";
+import { ActorAvatar as ActorAvatarBase } from "@multica/ui/components/common/actor-avatar";
import { useActorName } from "@multica/core/workspace/hooks";
interface ActorAvatarProps {
actorType: string;
actorId: string;
size?: number;
- avatarUrl?: string | null;
- getName?: (type: string, id: string) => string;
- getInitials?: (type: string, id: string) => string;
- getAvatarUrl?: (type: string, id: string) => string | null;
className?: string;
}
-function ActorAvatar({
- actorType,
- actorId,
- size = 20,
- avatarUrl,
- getName,
- getInitials,
- getAvatarUrl,
- className,
-}: ActorAvatarProps) {
- const actorNameHook = useActorName();
- const resolveName = getName ?? actorNameHook.getActorName;
- const resolveInitials = getInitials ?? actorNameHook.getActorInitials;
- const resolveAvatarUrl = getAvatarUrl ?? actorNameHook.getActorAvatarUrl;
-
- const name = resolveName(actorType, actorId);
- const initials = resolveInitials(actorType, actorId);
- const isAgent = actorType === "agent";
- const resolvedUrl = avatarUrl !== undefined ? avatarUrl : resolveAvatarUrl(actorType, actorId);
-
- const [imgError, setImgError] = useState(false);
-
- // Reset error state when URL changes (e.g. user uploads new avatar)
- useEffect(() => {
- setImgError(false);
- }, [resolvedUrl]);
-
+export function ActorAvatar({ actorType, actorId, size, className }: ActorAvatarProps) {
+ const { getActorName, getActorInitials, getActorAvatarUrl } = useActorName();
return (
- <div
- data-slot="avatar"
- className={cn(
- "inline-flex shrink-0 items-center justify-center rounded-full font-medium overflow-hidden",
- "bg-muted text-muted-foreground",
- className
- )}
- style={{ width: size, height: size, fontSize: size * 0.45 }}
- title={name}
- >
- {resolvedUrl && !imgError ? (
- <img
- src={resolvedUrl}
- alt={name}
- className="h-full w-full object-cover"
- onError={() => setImgError(true)}
- />
- ) : isAgent ? (
- <Bot style={{ width: size * 0.55, height: size * 0.55 }} />
- ) : (
- initials
- )}
- </div>
+ <ActorAvatarBase
+ name={getActorName(actorType, actorId)}
+ initials={getActorInitials(actorType, actorId)}
+ avatarUrl={getActorAvatarUrl(actorType, actorId)}
+ isAgent={actorType === "agent"}
+ size={size}
+ className={className}
+ />
);
}
-
-export { ActorAvatar, type ActorAvatarProps };
diff --git a/apps/web/components/common/mention-hover-card.tsx b/apps/web/components/common/mention-hover-card.tsx
deleted file mode 100644
index b9777d7738..0000000000
--- a/apps/web/components/common/mention-hover-card.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-"use client";
-
-import type { ReactNode } from "react";
-import { Users } from "lucide-react";
-import { useQuery } from "@tanstack/react-query";
-import { HoverCard, HoverCardTrigger, HoverCardContent } from "@/components/ui/hover-card";
-import { ActorAvatar } from "@/components/common/actor-avatar";
-import { useWorkspaceId } from "@multica/core/hooks";
-import { memberListOptions, agentListOptions } from "@multica/core/workspace/queries";
-
-interface MentionHoverCardProps {
- type: string;
- id: string;
- children: ReactNode;
-}
-
-function MentionHoverCard({ type, id, children }: MentionHoverCardProps) {
- const wsId = useWorkspaceId();
- const { data: members = [] } = useQuery(memberListOptions(wsId));
- const { data: agents = [] } = useQuery(agentListOptions(wsId));
-
- if (type === "all") {
- return (
- <HoverCard>
- <HoverCardTrigger render={<span />} className="cursor-default">
- {children}
- </HoverCardTrigger>
- <HoverCardContent align="start" className="w-auto min-w-48 max-w-72">
- <div className="flex items-center gap-2.5">
- <div className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10">
- <Users className="h-4 w-4 text-primary" />
- </div>
- <div className="min-w-0">
- <p className="text-sm font-medium">All members</p>
- <p className="text-xs text-muted-foreground">Notifies all workspace members</p>
- </div>
- </div>
- </HoverCardContent>
- </HoverCard>
- );
- }
-
- if (type === "member") {
- const member = members.find((m) => m.user_id === id);
- if (!member) return <>{children}</>;
-
- return (
- <HoverCard>
- <HoverCardTrigger render={<span />} className="cursor-default">
- {children}
- </HoverCardTrigger>
- <HoverCardContent align="start" className="w-auto min-w-48 max-w-72">
- <div className="flex items-center gap-2.5">
- <ActorAvatar actorType="member" actorId={id} size={32} />
- <div className="min-w-0">
- <p className="text-sm font-medium truncate">{member.name}</p>
- <p className="text-xs text-muted-foreground truncate">{member.email}</p>
- </div>
- </div>
- </HoverCardContent>
- </HoverCard>
- );
- }
-
- if (type === "agent") {
- const agent = agents.find((a) => a.id === id);
- if (!agent) return <>{children}</>;
-
- return (
- <HoverCard>
- <HoverCardTrigger render={<span />} className="cursor-default">
- {children}
- </HoverCardTrigger>
- <HoverCardContent align="start" className="w-auto min-w-48 max-w-72">
- <div className="flex items-center gap-2.5">
- <ActorAvatar actorType="agent" actorId={id} size={32} />
- <div className="min-w-0">
- <p className="text-sm font-medium truncate">{agent.name}</p>
- {agent.description && (
- <p className="text-xs text-muted-foreground truncate">{agent.description}</p>
- )}
- </div>
- </div>
- </HoverCardContent>
- </HoverCard>
- );
- }
-
- return <>{children}</>;
-}
-
-export { MentionHoverCard };
diff --git a/apps/web/components/loading-indicator.tsx b/apps/web/components/loading-indicator.tsx
index 8216e45b6f..541f3783ae 100644
--- a/apps/web/components/loading-indicator.tsx
+++ b/apps/web/components/loading-indicator.tsx
@@ -1,7 +1,7 @@
"use client";
import { Spinner } from "@/components/spinner";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
export type LoadingVariant = "generating" | "streaming";
diff --git a/apps/web/components/markdown/CodeBlock.tsx b/apps/web/components/markdown/CodeBlock.tsx
index ef69afb4e3..3b674fe1bd 100644
--- a/apps/web/components/markdown/CodeBlock.tsx
+++ b/apps/web/components/markdown/CodeBlock.tsx
@@ -1,243 +1 @@
-import * as React from 'react'
-import { codeToHtml, bundledLanguages, type BundledLanguage } from 'shiki'
-import { Copy, Check } from "lucide-react"
-import { Button } from "@/components/ui/button"
-import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip"
-import { cn } from '@/lib/utils'
-
-export interface CodeBlockProps {
- code: string
- language?: string
- className?: string
- /**
- * Render mode affects code block styling:
- * - 'terminal': Minimal, keeps control chars visible
- * - 'minimal': Clean code, basic styling
- * - 'full': Rich styling with background, copy button, etc.
- */
- mode?: 'terminal' | 'minimal' | 'full'
-}
-
-// Map common aliases to Shiki language names
-const LANGUAGE_ALIASES: Record<string, BundledLanguage> = {
- js: 'javascript',
- ts: 'typescript',
- py: 'python',
- sh: 'bash',
- zsh: 'bash',
- yml: 'yaml',
- rb: 'ruby',
- rs: 'rust',
- kt: 'kotlin',
- 'objective-c': 'objc',
- objc: 'objc'
-}
-
-// Simple LRU cache for highlighted code
-const highlightCache = new Map<string, string>()
-const CACHE_MAX_SIZE = 200
-
-function getCacheKey(code: string, lang: string): string {
- return `${lang}:${code}`
-}
-
-function isValidLanguage(lang: string): lang is BundledLanguage {
- const normalized = LANGUAGE_ALIASES[lang] || lang
- return normalized in bundledLanguages
-}
-
-/**
- * CodeBlock - Syntax highlighted code block using Shiki
- *
- * Uses Shiki dual themes with CSS variables for light/dark switching.
- * No JS-based dark mode detection needed — theme switching is handled
- * entirely via CSS (see globals.css for .shiki/.dark .shiki rules).
- *
- * @see https://shiki.style/guide/dual-themes
- */
-export function CodeBlock({
- code,
- language = 'text',
- className,
- mode = 'full'
-}: CodeBlockProps): React.JSX.Element {
- const [highlighted, setHighlighted] = React.useState<string | null>(null)
- const [isLoading, setIsLoading] = React.useState(true)
- const [copied, setCopied] = React.useState(false)
-
- // Resolve language alias - keep as string to allow 'text' fallback
- const langLower = language.toLowerCase()
- const resolvedLang: string = LANGUAGE_ALIASES[langLower] || langLower
-
- React.useEffect(() => {
- let cancelled = false
-
- async function highlight(): Promise<void> {
- const cacheKey = getCacheKey(code, resolvedLang)
-
- const cached = highlightCache.get(cacheKey)
- if (cached) {
- if (!cancelled) {
- setHighlighted(cached)
- setIsLoading(false)
- }
- return
- }
-
- try {
- // Use valid language or fallback to plaintext
- const lang = isValidLanguage(resolvedLang) ? resolvedLang : 'text'
-
- // Dual themes: Shiki outputs CSS variables for both themes in one pass.
- // CSS handles switching via .dark selector (see globals.css).
- const html = await codeToHtml(code, {
- lang,
- themes: {
- light: 'github-light',
- dark: 'github-dark',
- },
- defaultColor: false,
- })
-
- // Cache the result
- if (highlightCache.size >= CACHE_MAX_SIZE) {
- const firstKey = highlightCache.keys().next().value
- if (firstKey) highlightCache.delete(firstKey)
- }
- highlightCache.set(cacheKey, html)
-
- if (!cancelled) {
- setHighlighted(html)
- setIsLoading(false)
- }
- } catch (error) {
- // Fallback to plain text on error
- console.warn(`Shiki highlighting failed for language "${resolvedLang}":`, error)
- if (!cancelled) {
- setHighlighted(null)
- setIsLoading(false)
- }
- }
- }
-
- highlight()
-
- return () => {
- cancelled = true
- }
- }, [code, resolvedLang])
-
- const handleCopy = React.useCallback(async () => {
- try {
- await navigator.clipboard.writeText(code)
- setCopied(true)
- setTimeout(() => setCopied(false), 2000)
- } catch (err) {
- console.error('Failed to copy code:', err)
- }
- }, [code])
-
- // Terminal mode: raw monospace with minimal styling
- if (mode === 'terminal') {
- return (
- <pre className={cn('font-mono text-sm whitespace-pre-wrap', className)}>
- <code className="font-mono">{code}</code>
- </pre>
- )
- }
-
- // Minimal mode: just syntax highlighting, no chrome
- if (mode === 'minimal') {
- if (isLoading || !highlighted) {
- return (
- <pre className={cn('font-mono text-sm whitespace-pre-wrap', className)}>
- <code className="font-mono">{code}</code>
- </pre>
- )
- }
-
- return (
- <div
- className={cn(
- 'font-mono text-sm [&_pre]:!bg-transparent [&_pre]:!p-0 [&_pre]:whitespace-pre-wrap [&_pre]:break-all [&_code]:!bg-transparent [&_code]:font-mono [&_pre]:font-mono',
- className
- )}
- dangerouslySetInnerHTML={{ __html: highlighted }}
- />
- )
- }
-
- // Full mode: rich styling with header and copy button
- return (
- <div
- className={cn(
- 'relative group rounded-lg overflow-hidden border bg-muted/30 mb-4 last:mb-0',
- className
- )}
- >
- {/* Language label + copy button */}
- <div className="flex items-center justify-between px-3 py-1.5 bg-muted/50 border-b text-xs">
- <span className="text-muted-foreground font-medium uppercase tracking-wide">
- {resolvedLang !== 'text' ? resolvedLang : 'plain text'}
- </span>
- <Tooltip>
- <TooltipTrigger
- render={
- <Button
- variant="ghost"
- size="icon-xs"
- onClick={handleCopy}
- className="opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-foreground"
- aria-label="Copy code"
- >
- {copied ? (
- <Check className="size-3.5 text-success" />
- ) : (
- <Copy className="size-3.5" />
- )}
- </Button>
- }
- />
- <TooltipContent>Copy code</TooltipContent>
- </Tooltip>
- </div>
-
- {/* Code content */}
- <div className="p-3 overflow-x-auto">
- {isLoading || !highlighted ? (
- <pre className="font-mono text-sm whitespace-pre-wrap break-all">
- <code className="font-mono">{code}</code>
- </pre>
- ) : (
- <div
- className="font-mono text-sm [&_pre]:!bg-transparent [&_pre]:!m-0 [&_pre]:!p-0 [&_pre]:whitespace-pre-wrap [&_pre]:break-all [&_code]:!bg-transparent [&_code]:font-mono [&_pre]:font-mono"
- dangerouslySetInnerHTML={{ __html: highlighted }}
- />
- )}
- </div>
- </div>
- )
-}
-
-/**
- * InlineCode - Styled inline code span
- * Features: subtle background (3%), subtle border (5%), 75% opacity text
- */
-export function InlineCode({
- children,
- className
-}: {
- children: React.ReactNode
- className?: string
-}): React.JSX.Element {
- return (
- <code
- className={cn(
- 'px-1.5 py-0.5 rounded bg-foreground/[0.03] border border-foreground/[0.05] font-mono text-sm text-foreground/75',
- className
- )}
- >
- {children}
- </code>
- )
-}
+export { CodeBlock, InlineCode, type CodeBlockProps } from '@multica/ui/markdown'
diff --git a/apps/web/components/markdown/Markdown.tsx b/apps/web/components/markdown/Markdown.tsx
index c25e26f0f0..0410fc27c1 100644
--- a/apps/web/components/markdown/Markdown.tsx
+++ b/apps/web/components/markdown/Markdown.tsx
@@ -1,332 +1,36 @@
import * as React from 'react'
-import ReactMarkdown, { type Components, defaultUrlTransform } from 'react-markdown'
-import rehypeRaw from 'rehype-raw'
-import remarkGfm from 'remark-gfm'
-import { cn } from '@/lib/utils'
-import { CodeBlock, InlineCode } from './CodeBlock'
-import { preprocessLinks } from './linkify'
-import { preprocessMentionShortcodes } from './mentions'
+import {
+ Markdown as MarkdownBase,
+ MemoizedMarkdown as MemoizedMarkdownBase,
+ type MarkdownProps as MarkdownBaseProps,
+ type RenderMode
+} from '@multica/ui/markdown'
import { IssueMentionCard } from '@/features/issues/components/issue-mention-card'
-/**
- * Render modes for markdown content:
- *
- * - 'terminal': Raw output with minimal formatting, control chars visible
- * Best for: Debug output, raw logs, when you want to see exactly what's there
- *
- * - 'minimal': Clean rendering with syntax highlighting but no extra chrome
- * Best for: Chat messages, inline content, when you want readability without clutter
- *
- * - 'full': Rich rendering with beautiful tables, styled code blocks, proper typography
- * Best for: Documentation, long-form content, when presentation matters
- */
-export type RenderMode = 'terminal' | 'minimal' | 'full'
+export type { RenderMode }
-export interface MarkdownProps {
- children: string
- /**
- * Render mode controlling formatting level
- * @default 'minimal'
- */
- mode?: RenderMode
- className?: string
- /**
- * Message ID for memoization (optional)
- * When provided, memoizes parsed blocks to avoid re-parsing during streaming
- */
- id?: string
- /**
- * Callback when a URL is clicked
- */
- onUrlClick?: (url: string) => void
- /**
- * Callback when a file path is clicked
- */
- onFileClick?: (path: string) => void
-}
+export type MarkdownProps = MarkdownBaseProps
/**
- * Custom URL transform that allows mention:// protocol (used for @mentions)
- * while keeping the default security for all other URLs.
+ * Default renderMention that delegates to IssueMentionCard for issue mentions
+ * and renders a styled span for other mention types.
*/
-function urlTransform(url: string): string {
- if (url.startsWith('mention://')) return url
- return defaultUrlTransform(url)
-}
-
-
-// File path detection regex - matches paths starting with /, ~/, or ./
-const FILE_PATH_REGEX =
- /^(?:\/|~\/|\.\/)[\w\-./@]+\.(?:ts|tsx|js|jsx|mjs|cjs|md|json|yaml|yml|py|go|rs|css|scss|less|html|htm|txt|log|sh|bash|zsh|swift|kt|java|c|cpp|h|hpp|rb|php|xml|toml|ini|cfg|conf|env|sql|graphql|vue|svelte|astro|prisma)$/i
-
-/**
- * Create custom components based on render mode
- */
-function createComponents(
- mode: RenderMode,
- onUrlClick?: (url: string) => void,
- onFileClick?: (path: string) => void
-): Partial<Components> {
- const baseComponents: Partial<Components> = {
- // Images: render uploaded images with constrained sizing
- img: ({ src, alt }) => (
- <img
- src={src}
- alt={alt ?? ""}
- className="max-w-full h-auto rounded-md my-2"
- loading="lazy"
- />
- ),
- // Links: Make clickable with callbacks, or render as mention
- a: ({ href, children }) => {
- // Mention links: mention://member/id, mention://agent/id, mention://issue/id, mention://all/all
- if (href?.startsWith('mention://')) {
- const mentionMatch = href.match(/^mention:\/\/(member|agent|issue|all)\/(.+)$/)
- if (mentionMatch?.[1] === 'issue' && mentionMatch[2]) {
- const label = typeof children === 'string' ? children : Array.isArray(children) ? children.join('') : undefined
- return <IssueMentionCard issueId={mentionMatch[2]} fallbackLabel={label} />
- }
- return (
- <span className="text-primary font-semibold mx-0.5">
- {children}
- </span>
- )
- }
-
- const handleClick = (e: React.MouseEvent): void => {
- e.preventDefault()
- if (href) {
- // Check if it's a file path
- if (FILE_PATH_REGEX.test(href) && onFileClick) {
- onFileClick(href)
- } else if (onUrlClick) {
- onUrlClick(href)
- } else {
- // Default: open in new window
- window.open(href, '_blank', 'noopener,noreferrer')
- }
- }
- }
-
- return (
- <a
- href={href}
- onClick={handleClick}
- className="text-primary hover:underline cursor-pointer"
- >
- {children}
- </a>
- )
- }
- }
-
- // Terminal mode: minimal formatting
- if (mode === 'terminal') {
- return {
- ...baseComponents,
- // No special code handling - just monospace
- code: ({ children }) => <code className="font-mono">{children}</code>,
- pre: ({ children }) => <pre className="font-mono whitespace-pre-wrap my-2">{children}</pre>,
- // Minimal paragraph spacing
- p: ({ children }) => <p className="my-1">{children}</p>,
- // Simple lists
- ul: ({ children }) => <ul className="list-disc list-inside my-1">{children}</ul>,
- ol: ({ children }) => <ol className="list-decimal list-inside my-1">{children}</ol>,
- li: ({ children }) => <li className="my-0.5">{children}</li>,
- // Plain tables
- table: ({ children }) => <table className="my-2 font-mono text-sm">{children}</table>,
- th: ({ children }) => <th className="text-left pr-4">{children}</th>,
- td: ({ children }) => <td className="pr-4">{children}</td>
- }
- }
-
- // Minimal mode: clean with syntax highlighting
- if (mode === 'minimal') {
- return {
- ...baseComponents,
- // Inline code
- code: ({ className, children, ...props }) => {
- const match = /language-(\w+)/.exec(className || '')
- const isBlock =
- 'node' in props && props.node?.position?.start.line !== props.node?.position?.end.line
-
- // Block code - use CodeBlock with full mode
- if (match || isBlock) {
- const code = String(children).replace(/\n$/, '')
- return <CodeBlock code={code} language={match?.[1]} mode="full" className="my-1" />
- }
-
- // Inline code
- return <InlineCode>{children}</InlineCode>
- },
- pre: ({ children }) => <>{children}</>,
- // Comfortable paragraph spacing
- p: ({ children }) => <p className="my-2 leading-relaxed">{children}</p>,
- // Styled lists
- ul: ({ children }) => (
- <ul className="my-2 space-y-1 ps-4 pe-2 list-disc marker:text-muted-foreground">
- {children}
- </ul>
- ),
- ol: ({ children }) => <ol className="my-2 space-y-1 pl-6 list-decimal">{children}</ol>,
- li: ({ children }) => <li>{children}</li>,
- // Clean tables
- table: ({ children }) => (
- <div className="my-3 overflow-x-auto">
- <table className="min-w-full text-sm">{children}</table>
- </div>
- ),
- thead: ({ children }) => <thead className="border-b">{children}</thead>,
- th: ({ children }) => (
- <th className="text-left py-2 px-3 font-semibold text-muted-foreground">{children}</th>
- ),
- td: ({ children }) => <td className="py-2 px-3 border-b border-border/50">{children}</td>,
- // Headings - H1/H2 same size, differentiated by weight
- h1: ({ children }) => <h1 className="font-sans text-base font-bold mt-5 mb-3">{children}</h1>,
- h2: ({ children }) => (
- <h2 className="font-sans text-base font-semibold mt-4 mb-3">{children}</h2>
- ),
- h3: ({ children }) => (
- <h3 className="font-sans text-sm font-semibold mt-4 mb-2">{children}</h3>
- ),
- // Blockquotes
- blockquote: ({ children }) => (
- <blockquote className="border-l-2 border-muted-foreground/30 pl-3 my-2 text-muted-foreground italic">
- {children}
- </blockquote>
- ),
- // Horizontal rules
- hr: () => <hr className="my-4 border-border" />,
- // Strong/emphasis
- strong: ({ children }) => <strong className="font-semibold">{children}</strong>,
- em: ({ children }) => <em className="italic">{children}</em>
- }
- }
-
- // Full mode: rich styling
- return {
- ...baseComponents,
- // Full code blocks with copy button
- code: ({ className, children, ...props }) => {
- const match = /language-(\w+)/.exec(className || '')
- const isBlock =
- 'node' in props && props.node?.position?.start.line !== props.node?.position?.end.line
-
- if (match || isBlock) {
- const code = String(children).replace(/\n$/, '')
- return <CodeBlock code={code} language={match?.[1]} mode="full" className="my-1" />
- }
-
- return <InlineCode>{children}</InlineCode>
- },
- pre: ({ children }) => <>{children}</>,
- // Rich paragraph spacing
- p: ({ children }) => <p className="my-3 leading-relaxed">{children}</p>,
- // Styled lists
- ul: ({ children }) => (
- <ul className="my-3 space-y-1.5 ps-4 pe-2 list-disc marker:text-muted-foreground">
- {children}
- </ul>
- ),
- ol: ({ children }) => <ol className="my-3 space-y-1.5 pl-6 list-decimal">{children}</ol>,
- li: ({ children }) => <li className="leading-relaxed">{children}</li>,
- // Beautiful tables
- table: ({ children }) => (
- <div className="my-4 overflow-x-auto rounded-md border">
- <table className="min-w-full divide-y divide-border">{children}</table>
- </div>
- ),
- thead: ({ children }) => <thead className="bg-muted/50">{children}</thead>,
- tbody: ({ children }) => <tbody className="divide-y divide-border">{children}</tbody>,
- th: ({ children }) => <th className="text-left py-3 px-4 font-semibold text-sm">{children}</th>,
- td: ({ children }) => <td className="py-3 px-4 text-sm">{children}</td>,
- tr: ({ children }) => <tr className="hover:bg-muted/30 transition-colors">{children}</tr>,
- // Rich headings
- h1: ({ children }) => <h1 className="font-sans text-base font-bold mt-7 mb-4">{children}</h1>,
- h2: ({ children }) => (
- <h2 className="font-sans text-base font-semibold mt-6 mb-3">{children}</h2>
- ),
- h3: ({ children }) => <h3 className="font-sans text-sm font-semibold mt-5 mb-3">{children}</h3>,
- h4: ({ children }) => <h4 className="text-sm font-semibold mt-3 mb-1">{children}</h4>,
- // Styled blockquotes
- blockquote: ({ children }) => (
- <blockquote className="border-l-4 border-foreground/30 bg-muted/30 pl-4 pr-3 py-2 my-3 rounded-r-md">
- {children}
- </blockquote>
- ),
- // Task lists (GFM)
- input: ({ type, checked }) => {
- if (type === 'checkbox') {
- return (
- <input
- type="checkbox"
- checked={checked}
- readOnly
- className="mr-2 rounded border-muted-foreground"
- />
- )
- }
- return <input type={type} />
- },
- // Horizontal rules
- hr: () => <hr className="my-6 border-border" />,
- // Strong/emphasis
- strong: ({ children }) => <strong className="font-semibold">{children}</strong>,
- em: ({ children }) => <em className="italic">{children}</em>,
- del: ({ children }) => <del className="line-through text-muted-foreground">{children}</del>
+function defaultRenderMention({ type, id }: { type: string; id: string }): React.ReactNode {
+ if (type === 'issue') {
+ return <IssueMentionCard issueId={id} />
}
+ return null
}
/**
- * Markdown - Customizable markdown renderer with multiple render modes
- *
- * Features:
- * - Three render modes: terminal, minimal, full
- * - Syntax highlighting via Shiki
- * - GFM support (tables, task lists, strikethrough)
- * - Clickable links and file paths
- * - Memoization for streaming performance
+ * App-level Markdown wrapper that injects IssueMentionCard via renderMention.
+ * Callers that need custom mention rendering can pass their own renderMention prop.
*/
-export function Markdown({
- children,
- mode = 'minimal',
- className,
- onUrlClick,
- onFileClick
-}: MarkdownProps): React.JSX.Element {
- const components = React.useMemo(
- () => createComponents(mode, onUrlClick, onFileClick),
- [mode, onUrlClick, onFileClick]
- )
-
- // Preprocess: convert mention shortcodes and raw URLs/file paths to markdown links
- const processedContent = React.useMemo(
- () => preprocessLinks(preprocessMentionShortcodes(children)),
- [children]
- )
-
- return (
- <div className={cn('markdown-content break-words', className)}>
- <ReactMarkdown
- remarkPlugins={[[remarkGfm, { singleTilde: false }]]}
- rehypePlugins={[rehypeRaw]}
- urlTransform={urlTransform}
- components={components}
- >
- {processedContent}
- </ReactMarkdown>
- </div>
- )
+export function Markdown(props: MarkdownProps): React.JSX.Element {
+ return <MarkdownBase renderMention={defaultRenderMention} {...props} />
}
-/**
- * MemoizedMarkdown - Optimized for streaming scenarios
- *
- * Splits content into blocks and memoizes each block separately,
- * so only new/changed blocks re-render during streaming.
- */
export const MemoizedMarkdown = React.memo(Markdown, (prevProps, nextProps) => {
- // If id is provided, use it for memoization
if (prevProps.id && nextProps.id) {
return (
prevProps.id === nextProps.id &&
@@ -334,7 +38,6 @@ export const MemoizedMarkdown = React.memo(Markdown, (prevProps, nextProps) => {
prevProps.mode === nextProps.mode
)
}
- // Otherwise compare content and mode
return prevProps.children === nextProps.children && prevProps.mode === nextProps.mode
})
MemoizedMarkdown.displayName = 'MemoizedMarkdown'
diff --git a/apps/web/components/markdown/StreamingMarkdown.tsx b/apps/web/components/markdown/StreamingMarkdown.tsx
index aad2f33015..cc1e2a4afa 100644
--- a/apps/web/components/markdown/StreamingMarkdown.tsx
+++ b/apps/web/components/markdown/StreamingMarkdown.tsx
@@ -1,225 +1,22 @@
import * as React from 'react'
-import { Markdown, type RenderMode } from './Markdown'
+import {
+ StreamingMarkdown as StreamingMarkdownBase,
+ type StreamingMarkdownProps as StreamingMarkdownBaseProps
+} from '@multica/ui/markdown'
+import { IssueMentionCard } from '@/features/issues/components/issue-mention-card'
-export interface StreamingMarkdownProps {
- content: string
- isStreaming: boolean
- mode?: RenderMode
- className?: string
- onUrlClick?: (url: string) => void
- onFileClick?: (path: string) => void
-}
-
-interface Block {
- content: string
- isCodeBlock: boolean
-}
-
-/**
- * djb2 hash (XOR variant) by Daniel J. Bernstein.
- * Used to generate stable React keys for completed content blocks.
- *
- * - 5381: empirically chosen initial value that produces fewer collisions
- * - (hash << 5) + hash: equivalent to hash * 33
- * - ^ charCode: XOR variant, favored by Bernstein over additive version
- * - >>> 0: convert to unsigned 32-bit integer
- *
- * Not cryptographic — just fast with good distribution for short strings.
- * @see http://www.cse.yorku.ca/~oz/hash.html
- */
-function simpleHash(str: string): string {
- let hash = 5381
- for (let i = 0; i < str.length; i++) {
- hash = ((hash << 5) + hash) ^ str.charCodeAt(i)
- }
- return (hash >>> 0).toString(36)
-}
-
-/**
- * Split content into blocks (paragraphs and code blocks)
- *
- * Block boundaries:
- * - Double newlines (paragraph separators)
- * - Code fences (```)
- *
- * This is intentionally simple - just string scanning, no regex per line.
- */
-function splitIntoBlocks(content: string): Block[] {
- const blocks: Block[] = []
- const lines = content.split('\n')
- let currentBlock = ''
- let inCodeBlock = false
- let inMathBlock = false
-
- for (let i = 0; i < lines.length; i++) {
- const line = lines[i] ?? ''
-
- // Check for code fence (``` at start of line, optionally followed by language)
- if (line.startsWith('```')) {
- if (!inCodeBlock) {
- // Starting a code block - flush current paragraph first
- if (currentBlock.trim()) {
- blocks.push({ content: currentBlock.trim(), isCodeBlock: false })
- currentBlock = ''
- }
- inCodeBlock = true
- currentBlock = line + '\n'
- } else {
- // Ending a code block
- currentBlock += line
- blocks.push({ content: currentBlock, isCodeBlock: true })
- currentBlock = ''
- inCodeBlock = false
- }
- } else if (inCodeBlock) {
- // Inside code block - append line
- currentBlock += line + '\n'
- // Check for display math fence ($$)
- } else if (line.trim() === '$$') {
- if (!inMathBlock) {
- // Starting a math block - flush current paragraph first
- if (currentBlock.trim()) {
- blocks.push({ content: currentBlock.trim(), isCodeBlock: false })
- currentBlock = ''
- }
- inMathBlock = true
- currentBlock = line + '\n'
- } else {
- // Ending a math block
- currentBlock += line
- blocks.push({ content: currentBlock, isCodeBlock: false })
- currentBlock = ''
- inMathBlock = false
- }
- } else if (inMathBlock) {
- // Inside math block - append line (don't split on blank lines)
- currentBlock += line + '\n'
- } else if (line === '') {
- // Empty line outside code block = paragraph boundary
- if (currentBlock.trim()) {
- blocks.push({ content: currentBlock.trim(), isCodeBlock: false })
- currentBlock = ''
- }
- } else {
- // Regular text line
- if (currentBlock) {
- currentBlock += '\n' + line
- } else {
- currentBlock = line
- }
- }
- }
+export type StreamingMarkdownProps = StreamingMarkdownBaseProps
- // Flush remaining content
- if (currentBlock) {
- blocks.push({
- content: inCodeBlock || inMathBlock ? currentBlock : currentBlock.trim(),
- isCodeBlock: inCodeBlock
- })
+function defaultRenderMention({ type, id }: { type: string; id: string }): React.ReactNode {
+ if (type === 'issue') {
+ return <IssueMentionCard issueId={id} />
}
-
- return blocks
+ return null
}
/**
- * Memoized block component
- *
- * Only re-renders if content or mode changes.
- * The key is assigned by the parent based on content hash,
- * so identical content won't even attempt to render.
+ * App-level StreamingMarkdown wrapper that injects IssueMentionCard via renderMention.
*/
-const MemoizedBlock = React.memo(
- function Block({
- content,
- mode,
- className,
- onUrlClick,
- onFileClick
- }: {
- content: string
- mode: RenderMode
- className?: string
- onUrlClick?: (url: string) => void
- onFileClick?: (path: string) => void
- }) {
- return (
- <Markdown mode={mode} className={className} onUrlClick={onUrlClick} onFileClick={onFileClick}>
- {content}
- </Markdown>
- )
- },
- (prev, next) => {
- // Only re-render if content actually changed
- return prev.content === next.content && prev.mode === next.mode && prev.className === next.className
- }
-)
-MemoizedBlock.displayName = 'MemoizedBlock'
-
-/**
- * StreamingMarkdown - Optimized markdown renderer for streaming content
- *
- * Splits content into blocks (paragraphs, code blocks) and memoizes each block
- * independently. Only the last (active) block re-renders during streaming.
- *
- * Key insight: Completed blocks get a content-hash as their React key.
- * Same content = same key = React skips re-render entirely.
- *
- * @example
- * Content: "Hello\n\n```js\ncode\n```\n\nMore..."
- *
- * Block 1: "Hello" -> key="block-abc123" -> memoized
- * Block 2: "```js\ncode\n```" -> key="block-xyz789" -> memoized
- * Block 3: "More..." -> key="active-2" -> re-renders
- */
-export function StreamingMarkdown({
- content,
- isStreaming,
- mode = 'minimal',
- className,
- onUrlClick,
- onFileClick
-}: StreamingMarkdownProps): React.JSX.Element {
- // Split into blocks - memoized to avoid recomputation
- // Must be called unconditionally to satisfy Rules of Hooks
- const blocks = React.useMemo(
- () => (isStreaming ? splitIntoBlocks(content) : []),
- [content, isStreaming]
- )
-
- // Not streaming - use simple Markdown (no block splitting needed)
- if (!isStreaming) {
- return (
- <Markdown mode={mode} className={className} onUrlClick={onUrlClick} onFileClick={onFileClick}>
- {content}
- </Markdown>
- )
- }
-
- // Empty content - return null, let parent handle loading indicator
- if (blocks.length === 0) {
- return <></>
- }
-
- return (
- <>
- {blocks.map((block, i) => {
- const isLastBlock = i === blocks.length - 1
-
- // Complete blocks use content hash as key -> stable identity -> memoized
- // Last block uses "active" prefix -> always re-renders on content change
- const key = isLastBlock ? `active-${i}` : `block-${i}-${simpleHash(block.content)}`
-
- return (
- <MemoizedBlock
- key={key}
- content={block.content}
- mode={mode}
- className={className}
- onUrlClick={onUrlClick}
- onFileClick={onFileClick}
- />
- )
- })}
- </>
- )
+export function StreamingMarkdown(props: StreamingMarkdownProps): React.JSX.Element {
+ return <StreamingMarkdownBase renderMention={defaultRenderMention} {...props} />
}
diff --git a/apps/web/components/markdown/linkify.ts b/apps/web/components/markdown/linkify.ts
index f4ee1809d0..d8c23f5342 100644
--- a/apps/web/components/markdown/linkify.ts
+++ b/apps/web/components/markdown/linkify.ts
@@ -1,215 +1 @@
-import LinkifyIt from 'linkify-it'
-
-/**
- * Linkify - URL and file path detection for markdown preprocessing
- *
- * Uses linkify-it (12M downloads/week) for battle-tested URL detection,
- * plus custom regex for local file paths.
- */
-
-// Initialize linkify-it with default settings (fuzzy URLs, emails enabled)
-const linkify = new LinkifyIt()
-
-// File path regex - detects /path, ~/path, ./path with common extensions
-// Matches paths that start with /, ~/, or ./ followed by path chars and a file extension
-const FILE_PATH_REGEX =
- /(?:^|[\s([{<])((\/|~\/|\.\/)[\w\-./@]+\.(?:ts|tsx|js|jsx|mjs|cjs|md|json|yaml|yml|py|go|rs|css|scss|less|html|htm|txt|log|sh|bash|zsh|swift|kt|java|c|cpp|h|hpp|rb|php|xml|toml|ini|cfg|conf|env|sql|graphql|vue|svelte|astro|prisma|dockerfile|makefile|gitignore))(?=[\s)\]}.,;:!?>]|$)/gi
-
-interface DetectedLink {
- type: 'url' | 'email' | 'file'
- text: string
- url: string
- start: number
- end: number
-}
-
-interface CodeRange {
- start: number
- end: number
-}
-
-/**
- * Find all code block and inline code ranges in text
- * These ranges should be excluded from link detection
- */
-function findCodeRanges(text: string): CodeRange[] {
- const ranges: CodeRange[] = []
-
- // Find fenced code blocks (```...```)
- const fencedRegex = /```[\s\S]*?```/g
- let match
- while ((match = fencedRegex.exec(text)) !== null) {
- ranges.push({ start: match.index, end: match.index + match[0].length })
- }
-
- // Find display math blocks ($$...$$)
- const displayMathRegex = /\$\$[\s\S]*?\$\$/g
- while ((match = displayMathRegex.exec(text)) !== null) {
- const pos = match.index
- const insideOther = ranges.some((r) => pos >= r.start && pos < r.end)
- if (!insideOther) {
- ranges.push({ start: pos, end: pos + match[0].length })
- }
- }
-
- // Find inline math ($...$)
- const inlineMathRegex = /(?<!\$)\$(?!\$)([^\$\n]+)\$(?!\$)/g
- while ((match = inlineMathRegex.exec(text)) !== null) {
- const pos = match.index
- const insideOther = ranges.some((r) => pos >= r.start && pos < r.end)
- if (!insideOther) {
- ranges.push({ start: pos, end: pos + match[0].length })
- }
- }
-
- // Find inline code (`...`)
- // But skip escaped backticks and code inside fenced blocks
- const inlineRegex = /(?<!`)`(?!`)([^`\n]+)`(?!`)/g
- while ((match = inlineRegex.exec(text)) !== null) {
- const pos = match.index
- // Check if this is inside a fenced block or math block
- const insideOther = ranges.some((r) => pos >= r.start && pos < r.end)
- if (!insideOther) {
- ranges.push({ start: pos, end: pos + match[0].length })
- }
- }
-
- return ranges
-}
-
-/**
- * Check if a position is inside any code range
- */
-function isInsideCode(pos: number, ranges: CodeRange[]): boolean {
- return ranges.some((r) => pos >= r.start && pos < r.end)
-}
-
-/**
- * Check if a link at given position is already a markdown link
- * Looks for patterns like [text](url) or [text][ref]
- */
-function isAlreadyLinked(text: string, linkStart: number, linkEnd: number): boolean {
- // Check if preceded by ]( which indicates we're inside a markdown link href
- // Pattern: [text](URL) - we're checking if URL is our link
- const before = text.slice(Math.max(0, linkStart - 2), linkStart)
- if (before.endsWith('](')) return true
-
- // Check if preceded by ][ for reference links
- if (before.endsWith('][')) return true
-
- // Check if the link text is wrapped in []
- // Pattern: [URL](href) - URL is being used as link text
- const charBefore = text[linkStart - 1]
- const charAfter = text[linkEnd]
- if (charBefore === '[' && charAfter === ']') return true
-
- return false
-}
-
-/**
- * Check if ranges overlap
- */
-function rangesOverlap(
- a: { start: number; end: number },
- b: { start: number; end: number }
-): boolean {
- return a.start < b.end && b.start < a.end
-}
-
-/**
- * Detect all links (URLs, emails, file paths) in text
- */
-export function detectLinks(text: string): DetectedLink[] {
- const links: DetectedLink[] = []
-
- // 1. Detect URLs and emails with linkify-it
- const urlMatches = linkify.match(text) || []
- for (const match of urlMatches) {
- links.push({
- type: match.schema === 'mailto:' ? 'email' : 'url',
- text: match.text,
- url: match.url,
- start: match.index,
- end: match.lastIndex
- })
- }
-
- // 2. Detect file paths with custom regex
- // Reset regex state
- FILE_PATH_REGEX.lastIndex = 0
- let fileMatch
- while ((fileMatch = FILE_PATH_REGEX.exec(text)) !== null) {
- const path = fileMatch[1]
- if (!path) continue // Skip if no capture group
-
- // Calculate actual start position (after any leading whitespace/punctuation)
- const fullMatch = fileMatch[0]
- const pathOffset = fullMatch.indexOf(path)
- const start = fileMatch.index + pathOffset
-
- // Check for overlaps with URL matches (URLs take precedence)
- const pathRange = { start, end: start + path.length }
- const overlapsUrl = links.some((link) => rangesOverlap(pathRange, link))
- if (overlapsUrl) continue
-
- links.push({
- type: 'file',
- text: path,
- url: path, // File paths are passed as-is to onFileClick handler
- start,
- end: start + path.length
- })
- }
-
- // Sort by position
- return links.sort((a, b) => a.start - b.start)
-}
-
-/**
- * Preprocess text to convert raw URLs and file paths into markdown links
- * Skips code blocks and already-linked content
- */
-export function preprocessLinks(text: string): string {
- // Quick check - if no potential links, return early
- if (!linkify.pretest(text) && !/[~/.]\//.test(text)) {
- return text
- }
-
- const codeRanges = findCodeRanges(text)
- const links = detectLinks(text)
-
- if (links.length === 0) return text
-
- // Build result, converting raw links to markdown links
- let result = ''
- let lastIndex = 0
-
- for (const link of links) {
- // Skip if inside code block
- if (isInsideCode(link.start, codeRanges)) continue
-
- // Skip if already a markdown link
- if (isAlreadyLinked(text, link.start, link.end)) continue
-
- // Add text before this link
- result += text.slice(lastIndex, link.start)
-
- // Convert to markdown link
- result += `[${link.text}](${link.url})`
-
- lastIndex = link.end
- }
-
- // Add remaining text
- result += text.slice(lastIndex)
-
- return result
-}
-
-/**
- * Test if text contains any detectable links
- * Useful for optimization - skip preprocessing if no links present
- */
-export function hasLinks(text: string): boolean {
- return linkify.pretest(text) || /[~/.]\/[\w]/.test(text)
-}
+export { preprocessLinks, detectLinks, hasLinks } from '@multica/ui/markdown'
diff --git a/apps/web/components/markdown/mentions.ts b/apps/web/components/markdown/mentions.ts
index 06b041dfd7..1c71856d6b 100644
--- a/apps/web/components/markdown/mentions.ts
+++ b/apps/web/components/markdown/mentions.ts
@@ -1,25 +1 @@
-/**
- * Convert legacy mention shortcodes [@ id="UUID" label="LABEL"] to the
- * standard markdown link format [@LABEL](mention://member/UUID).
- *
- * These shortcodes exist in older database records from a previous mention
- * serialization format. This function normalises them so downstream parsers
- * (Tiptap @tiptap/markdown, react-markdown) only need to handle one syntax.
- */
-export function preprocessMentionShortcodes(text: string): string {
- if (!text.includes("[@ ")) return text;
- return text.replace(
- /\[@\s+([^\]]*)\]/g,
- (match, attrString: string) => {
- const attrs: Record<string, string> = {};
- const re = /(\w+)="([^"]*)"/g;
- let m;
- while ((m = re.exec(attrString)) !== null) {
- if (m[1] && m[2] !== undefined) attrs[m[1]] = m[2];
- }
- const { id, label } = attrs;
- if (!id || !label) return match;
- return `[@${label}](mention://member/${id})`;
- },
- );
-}
+export { preprocessMentionShortcodes } from '@multica/ui/markdown'
diff --git a/apps/web/components/multica-icon.tsx b/apps/web/components/multica-icon.tsx
index 45d0e5b5be..52b0fe82f7 100644
--- a/apps/web/components/multica-icon.tsx
+++ b/apps/web/components/multica-icon.tsx
@@ -1,5 +1,5 @@
import { useState, useEffect } from "react";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
interface MulticaIconProps extends React.ComponentProps<"span"> {
/**
diff --git a/apps/web/components/spinner.tsx b/apps/web/components/spinner.tsx
index 91818dfa0c..9328784ea9 100644
--- a/apps/web/components/spinner.tsx
+++ b/apps/web/components/spinner.tsx
@@ -8,7 +8,7 @@
* Inherits color from `currentColor` (use Tailwind `text-*`).
* Scales with font-size (use Tailwind `text-*` for size).
*/
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
export interface SpinnerProps {
/** Additional className for styling (color via text-*, size via Tailwind text-*) */
diff --git a/apps/web/components/theme-provider.tsx b/apps/web/components/theme-provider.tsx
index f5bcd75828..62eb983691 100644
--- a/apps/web/components/theme-provider.tsx
+++ b/apps/web/components/theme-provider.tsx
@@ -1,7 +1,7 @@
"use client"
import { ThemeProvider as NextThemesProvider } from "next-themes"
-import { TooltipProvider } from "@/components/ui/tooltip"
+import { TooltipProvider } from "@multica/ui/components/ui/tooltip"
function ThemeProvider({
children,
diff --git a/apps/web/components/theme-toggle.tsx b/apps/web/components/theme-toggle.tsx
index 69227c83bf..865269ac61 100644
--- a/apps/web/components/theme-toggle.tsx
+++ b/apps/web/components/theme-toggle.tsx
@@ -7,8 +7,8 @@ import {
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
-} from "@/components/ui/dropdown-menu"
-import { SidebarMenuButton } from "@/components/ui/sidebar"
+} from "@multica/ui/components/ui/dropdown-menu"
+import { SidebarMenuButton } from "@multica/ui/components/ui/sidebar"
export function ThemeToggle() {
const { setTheme } = useTheme()
diff --git a/apps/web/features/editor/content-editor.tsx b/apps/web/features/editor/content-editor.tsx
index b244723a91..577be9a43d 100644
--- a/apps/web/features/editor/content-editor.tsx
+++ b/apps/web/features/editor/content-editor.tsx
@@ -33,7 +33,7 @@ import {
useState,
} from "react";
import { useEditor, EditorContent } from "@tiptap/react";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
import type { UploadResult } from "@multica/core/hooks/use-file-upload";
import { useQueryClient } from "@tanstack/react-query";
import { createEditorExtensions } from "./extensions";
diff --git a/apps/web/features/editor/extensions/image-view.tsx b/apps/web/features/editor/extensions/image-view.tsx
index 945cc4b65d..5dd95acf86 100644
--- a/apps/web/features/editor/extensions/image-view.tsx
+++ b/apps/web/features/editor/extensions/image-view.tsx
@@ -11,7 +11,7 @@ import {
Trash2,
} from "lucide-react";
import { toast } from "sonner";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
// ---------------------------------------------------------------------------
// Lightbox — full-screen image preview (ESC or click backdrop to close)
diff --git a/apps/web/features/editor/extensions/mention-suggestion.tsx b/apps/web/features/editor/extensions/mention-suggestion.tsx
index afa0f4afab..94091140ec 100644
--- a/apps/web/features/editor/extensions/mention-suggestion.tsx
+++ b/apps/web/features/editor/extensions/mention-suggestion.tsx
@@ -17,7 +17,7 @@ import { workspaceKeys } from "@multica/core/workspace/queries";
import type { Issue, ListIssuesResponse, MemberWithUser, Agent } from "@multica/core/types";
import { ActorAvatar } from "@/components/common/actor-avatar";
import { StatusIcon } from "@/features/issues/components/status-icon";
-import { Badge } from "@/components/ui/badge";
+import { Badge } from "@multica/ui/components/ui/badge";
import type { IssueStatus } from "@multica/core/types";
import type { SuggestionOptions, SuggestionProps } from "@tiptap/suggestion";
diff --git a/apps/web/features/editor/readonly-content.tsx b/apps/web/features/editor/readonly-content.tsx
index 3b2531d166..aa2877eb13 100644
--- a/apps/web/features/editor/readonly-content.tsx
+++ b/apps/web/features/editor/readonly-content.tsx
@@ -27,7 +27,7 @@ import { createLowlight, common } from "lowlight";
import { toHtml } from "hast-util-to-html";
import { Maximize2, Download, Link as LinkIcon, FileText } from "lucide-react";
import { toast } from "sonner";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
import { IssueMentionCard } from "@/features/issues/components/issue-mention-card";
import { ImageLightbox } from "./extensions/image-view";
import { preprocessMarkdown } from "./utils/preprocess";
diff --git a/apps/web/features/editor/title-editor.tsx b/apps/web/features/editor/title-editor.tsx
index 05b99ca642..04eb8e3509 100644
--- a/apps/web/features/editor/title-editor.tsx
+++ b/apps/web/features/editor/title-editor.tsx
@@ -7,7 +7,7 @@ import { Document } from "@tiptap/extension-document";
import { Paragraph } from "@tiptap/extension-paragraph";
import { Text } from "@tiptap/extension-text";
import Placeholder from "@tiptap/extension-placeholder";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
import "./title-editor.css";
// ---------------------------------------------------------------------------
diff --git a/apps/web/features/issues/components/agent-live-card.tsx b/apps/web/features/issues/components/agent-live-card.tsx
index 34b41677c7..c9fd557edc 100644
--- a/apps/web/features/issues/components/agent-live-card.tsx
+++ b/apps/web/features/issues/components/agent-live-card.tsx
@@ -6,10 +6,10 @@ import { api } from "@/platform/api";
import { useWSEvent } from "@multica/core/realtime";
import type { TaskMessagePayload, TaskCompletedPayload, TaskFailedPayload, TaskCancelledPayload } from "@multica/core/types/events";
import type { AgentTask } from "@multica/core/types/agent";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
import { toast } from "sonner";
import { ActorAvatar } from "@/components/common/actor-avatar";
-import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
+import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@multica/ui/components/ui/collapsible";
import { useActorName } from "@multica/core/workspace/hooks";
import { redactSecrets } from "../utils/redact";
import { AgentTranscriptDialog } from "./agent-transcript-dialog";
diff --git a/apps/web/features/issues/components/agent-transcript-dialog.tsx b/apps/web/features/issues/components/agent-transcript-dialog.tsx
index ea7da75310..fafef95a88 100644
--- a/apps/web/features/issues/components/agent-transcript-dialog.tsx
+++ b/apps/web/features/issues/components/agent-transcript-dialog.tsx
@@ -17,9 +17,9 @@ import {
Cloud,
Cpu,
} from "lucide-react";
-import { cn } from "@/lib/utils";
-import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
-import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
+import { cn } from "@multica/ui/lib/utils";
+import { Dialog, DialogContent, DialogTitle } from "@multica/ui/components/ui/dialog";
+import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@multica/ui/components/ui/collapsible";
import { ActorAvatar } from "@/components/common/actor-avatar";
import { api } from "@/platform/api";
import type { AgentTask, Agent, AgentRuntime } from "@multica/core/types/agent";
diff --git a/apps/web/features/issues/components/batch-action-toolbar.tsx b/apps/web/features/issues/components/batch-action-toolbar.tsx
index c6e54c7adf..137b8d52fa 100644
--- a/apps/web/features/issues/components/batch-action-toolbar.tsx
+++ b/apps/web/features/issues/components/batch-action-toolbar.tsx
@@ -3,7 +3,7 @@
import { useState } from "react";
import { X, Trash2 } from "lucide-react";
import { toast } from "sonner";
-import { Button } from "@/components/ui/button";
+import { Button } from "@multica/ui/components/ui/button";
import {
AlertDialog,
AlertDialogAction,
@@ -13,12 +13,12 @@ import {
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
-} from "@/components/ui/alert-dialog";
+} from "@multica/ui/components/ui/alert-dialog";
import {
Popover,
PopoverTrigger,
PopoverContent,
-} from "@/components/ui/popover";
+} from "@multica/ui/components/ui/popover";
import type { UpdateIssueRequest } from "@multica/core/types";
import { ALL_STATUSES, STATUS_CONFIG, PRIORITY_ORDER, PRIORITY_CONFIG } from "@multica/core/issues/config";
import { useIssueSelectionStore } from "@multica/core/issues/stores/selection-store";
diff --git a/apps/web/features/issues/components/board-column.tsx b/apps/web/features/issues/components/board-column.tsx
index 652d15486e..0743ba9128 100644
--- a/apps/web/features/issues/components/board-column.tsx
+++ b/apps/web/features/issues/components/board-column.tsx
@@ -2,17 +2,17 @@
import { useMemo, type ReactNode } from "react";
import { EyeOff, MoreHorizontal, Plus } from "lucide-react";
-import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
+import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
import { useDroppable } from "@dnd-kit/core";
import { SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
import type { Issue, IssueStatus } from "@multica/core/types";
-import { Button } from "@/components/ui/button";
+import { Button } from "@multica/ui/components/ui/button";
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
-} from "@/components/ui/dropdown-menu";
+} from "@multica/ui/components/ui/dropdown-menu";
import { STATUS_CONFIG } from "@multica/core/issues/config";
import { useModalStore } from "@multica/core/modals";
import { useViewStoreApi } from "@multica/core/issues/stores/view-store-context";
diff --git a/apps/web/features/issues/components/board-view.tsx b/apps/web/features/issues/components/board-view.tsx
index b84023fd6a..2f5c75c69f 100644
--- a/apps/web/features/issues/components/board-view.tsx
+++ b/apps/web/features/issues/components/board-view.tsx
@@ -17,14 +17,14 @@ import {
import { arrayMove } from "@dnd-kit/sortable";
import { Eye, Loader2, MoreHorizontal } from "lucide-react";
import type { Issue, IssueStatus } from "@multica/core/types";
-import { Button } from "@/components/ui/button";
+import { Button } from "@multica/ui/components/ui/button";
import { useLoadMoreDoneIssues } from "@multica/core/issues/mutations";
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
-} from "@/components/ui/dropdown-menu";
+} from "@multica/ui/components/ui/dropdown-menu";
import { ALL_STATUSES, STATUS_CONFIG } from "@multica/core/issues/config";
import { useViewStoreApi, useViewStore } from "@multica/core/issues/stores/view-store-context";
import type { SortField, SortDirection } from "@multica/core/issues/stores/view-store";
diff --git a/apps/web/features/issues/components/comment-card.tsx b/apps/web/features/issues/components/comment-card.tsx
index 9aa5dea7eb..b5b62ee9a3 100644
--- a/apps/web/features/issues/components/comment-card.tsx
+++ b/apps/web/features/issues/components/comment-card.tsx
@@ -3,16 +3,16 @@
import { useRef, useState } from "react";
import { ChevronRight, Copy, MoreHorizontal, Pencil, Trash2 } from "lucide-react";
import { toast } from "sonner";
-import { Card } from "@/components/ui/card";
-import { Button } from "@/components/ui/button";
+import { Card } from "@multica/ui/components/ui/card";
+import { Button } from "@multica/ui/components/ui/button";
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
-} from "@/components/ui/dropdown-menu";
-import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
+} from "@multica/ui/components/ui/dropdown-menu";
+import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
import {
AlertDialog,
AlertDialogAction,
@@ -22,16 +22,16 @@ import {
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
-} from "@/components/ui/alert-dialog";
-import { Collapsible, CollapsibleTrigger, CollapsibleContent } from "@/components/ui/collapsible";
+} from "@multica/ui/components/ui/alert-dialog";
+import { Collapsible, CollapsibleTrigger, CollapsibleContent } from "@multica/ui/components/ui/collapsible";
import { ActorAvatar } from "@/components/common/actor-avatar";
-import { ReactionBar } from "@/components/common/reaction-bar";
-import { QuickEmojiPicker } from "@/components/common/quick-emoji-picker";
-import { cn } from "@/lib/utils";
+import { ReactionBar } from "@multica/ui/components/common/reaction-bar";
+import { QuickEmojiPicker } from "@multica/ui/components/common/quick-emoji-picker";
+import { cn } from "@multica/ui/lib/utils";
import { useActorName } from "@multica/core/workspace/hooks";
import { timeAgo } from "@multica/core/utils";
import { ContentEditor, type ContentEditorRef, copyMarkdown, ReadonlyContent } from "@/features/editor";
-import { FileUploadButton } from "@/components/common/file-upload-button";
+import { FileUploadButton } from "@multica/ui/components/common/file-upload-button";
import { useFileUpload } from "@multica/core/hooks/use-file-upload";
import { api } from "@/platform/api";
import { ReplyInput } from "./reply-input";
@@ -255,6 +255,7 @@ function CommentRow({
reactions={reactions}
currentUserId={currentUserId}
onToggle={(emoji) => onToggleReaction(entry.id, emoji)}
+ getActorName={getActorName}
hideAddButton={!isLongContent}
className="mt-1.5 pl-8"
/>
@@ -464,6 +465,7 @@ function CommentCard({
reactions={reactions}
currentUserId={currentUserId}
onToggle={(emoji) => onToggleReaction(entry.id, emoji)}
+ getActorName={getActorName}
hideAddButton={!isLongContent}
className="mt-1.5 pl-10"
/>
diff --git a/apps/web/features/issues/components/comment-input.tsx b/apps/web/features/issues/components/comment-input.tsx
index 5453917673..032f297c9e 100644
--- a/apps/web/features/issues/components/comment-input.tsx
+++ b/apps/web/features/issues/components/comment-input.tsx
@@ -2,9 +2,9 @@
import { useRef, useState } from "react";
import { ArrowUp, Loader2 } from "lucide-react";
-import { Button } from "@/components/ui/button";
+import { Button } from "@multica/ui/components/ui/button";
import { ContentEditor, type ContentEditorRef } from "@/features/editor";
-import { FileUploadButton } from "@/components/common/file-upload-button";
+import { FileUploadButton } from "@multica/ui/components/common/file-upload-button";
import { useFileUpload } from "@multica/core/hooks/use-file-upload";
import { api } from "@/platform/api";
diff --git a/apps/web/features/issues/components/issue-detail.tsx b/apps/web/features/issues/components/issue-detail.tsx
index f3a3c9c4ab..6f3068604f 100644
--- a/apps/web/features/issues/components/issue-detail.tsx
+++ b/apps/web/features/issues/components/issue-detail.tsx
@@ -20,7 +20,7 @@ import {
X,
} from "lucide-react";
import { toast } from "sonner";
-import { Skeleton } from "@/components/ui/skeleton";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
import {
AlertDialog,
AlertDialogAction,
@@ -30,8 +30,8 @@ import {
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
-} from "@/components/ui/alert-dialog";
-import { Button } from "@/components/ui/button";
+} from "@multica/ui/components/ui/alert-dialog";
+import { Button } from "@multica/ui/components/ui/button";
import {
DropdownMenu,
DropdownMenuTrigger,
@@ -43,20 +43,20 @@ import {
DropdownMenuSub,
DropdownMenuSubTrigger,
DropdownMenuSubContent,
-} from "@/components/ui/dropdown-menu";
-import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from "@/components/ui/resizable";
+} from "@multica/ui/components/ui/dropdown-menu";
+import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from "@multica/ui/components/ui/resizable";
import { ContentEditor, type ContentEditorRef } from "@/features/editor";
-import { FileUploadButton } from "@/components/common/file-upload-button";
+import { FileUploadButton } from "@multica/ui/components/common/file-upload-button";
import { TitleEditor } from "@/features/editor";
import {
Tooltip,
TooltipTrigger,
TooltipContent,
-} from "@/components/ui/tooltip";
-import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover";
-import { Checkbox } from "@/components/ui/checkbox";
-import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from "@/components/ui/command";
-import { AvatarGroup, AvatarGroupCount } from "@/components/ui/avatar";
+} from "@multica/ui/components/ui/tooltip";
+import { Popover, PopoverTrigger, PopoverContent } from "@multica/ui/components/ui/popover";
+import { Checkbox } from "@multica/ui/components/ui/checkbox";
+import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from "@multica/ui/components/ui/command";
+import { AvatarGroup, AvatarGroupCount } from "@multica/ui/components/ui/avatar";
import { ActorAvatar } from "@/components/common/actor-avatar";
import type { Issue, UpdateIssueRequest, IssueStatus, IssuePriority, TimelineEntry } from "@multica/core/types";
import { ALL_STATUSES, STATUS_CONFIG, PRIORITY_ORDER, PRIORITY_CONFIG } from "@multica/core/issues/config";
@@ -75,12 +75,12 @@ import { useUpdateIssue, useDeleteIssue } from "@multica/core/issues/mutations";
import { useIssueTimeline } from "@/features/issues/hooks/use-issue-timeline";
import { useIssueReactions } from "@/features/issues/hooks/use-issue-reactions";
import { useIssueSubscribers } from "@/features/issues/hooks/use-issue-subscribers";
-import { ReactionBar } from "@/components/common/reaction-bar";
+import { ReactionBar } from "@multica/ui/components/common/reaction-bar";
import { useFileUpload } from "@multica/core/hooks/use-file-upload";
import { api } from "@/platform/api";
import { useModalStore } from "@multica/core/modals";
import { timeAgo } from "@multica/core/utils";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
/**
* Tiny circular progress ring used in the "Sub-issue of …" line and the
@@ -757,6 +757,7 @@ export function IssueDetail({ issueId, onDelete, defaultSidebarOpen = true, layo
reactions={issueReactions}
currentUserId={user?.id}
onToggle={handleToggleIssueReaction}
+ getActorName={getActorName}
/>
)}
<FileUploadButton
diff --git a/apps/web/features/issues/components/issues-header.tsx b/apps/web/features/issues/components/issues-header.tsx
index 19d70f2224..d6596adefd 100644
--- a/apps/web/features/issues/components/issues-header.tsx
+++ b/apps/web/features/issues/components/issues-header.tsx
@@ -16,7 +16,7 @@ import {
UserMinus,
UserPen,
} from "lucide-react";
-import { Button } from "@/components/ui/button";
+import { Button } from "@multica/ui/components/ui/button";
import {
DropdownMenu,
DropdownMenuTrigger,
@@ -29,13 +29,13 @@ import {
DropdownMenuSub,
DropdownMenuSubTrigger,
DropdownMenuSubContent,
-} from "@/components/ui/dropdown-menu";
+} from "@multica/ui/components/ui/dropdown-menu";
import {
Popover,
PopoverTrigger,
PopoverContent,
-} from "@/components/ui/popover";
-import { Switch } from "@/components/ui/switch";
+} from "@multica/ui/components/ui/popover";
+import { Switch } from "@multica/ui/components/ui/switch";
import {
ALL_STATUSES,
STATUS_CONFIG,
@@ -58,7 +58,7 @@ import {
type IssuesScope,
} from "@multica/core/issues/stores/issues-scope-store";
import { filterIssues } from "@/features/issues/utils/filter";
-import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
+import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
import type { Issue } from "@multica/core/types";
// ---------------------------------------------------------------------------
diff --git a/apps/web/features/issues/components/issues-page.tsx b/apps/web/features/issues/components/issues-page.tsx
index adad3388cb..de761ef47f 100644
--- a/apps/web/features/issues/components/issues-page.tsx
+++ b/apps/web/features/issues/components/issues-page.tsx
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useMemo } from "react";
import { toast } from "sonner";
import { ChevronRight, ListTodo } from "lucide-react";
import type { IssueStatus } from "@multica/core/types";
-import { Skeleton } from "@/components/ui/skeleton";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
import { useQuery } from "@tanstack/react-query";
import { useIssueViewStore, initFilterWorkspaceSync } from "@multica/core/issues/stores/view-store";
import { useIssuesScopeStore } from "@multica/core/issues/stores/issues-scope-store";
diff --git a/apps/web/features/issues/components/list-view.tsx b/apps/web/features/issues/components/list-view.tsx
index 16d5a60367..42d7f5d7cc 100644
--- a/apps/web/features/issues/components/list-view.tsx
+++ b/apps/web/features/issues/components/list-view.tsx
@@ -3,8 +3,8 @@
import { useMemo } from "react";
import { ChevronRight, Plus } from "lucide-react";
import { Accordion } from "@base-ui/react/accordion";
-import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
-import { Button } from "@/components/ui/button";
+import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
+import { Button } from "@multica/ui/components/ui/button";
import type { Issue, IssueStatus } from "@multica/core/types";
import { STATUS_CONFIG } from "@multica/core/issues/config";
import { useModalStore } from "@multica/core/modals";
diff --git a/apps/web/features/issues/components/pickers/due-date-picker.tsx b/apps/web/features/issues/components/pickers/due-date-picker.tsx
index 5b2d759c0c..52003f9caf 100644
--- a/apps/web/features/issues/components/pickers/due-date-picker.tsx
+++ b/apps/web/features/issues/components/pickers/due-date-picker.tsx
@@ -3,13 +3,13 @@
import { useState } from "react";
import { CalendarDays } from "lucide-react";
import type { UpdateIssueRequest } from "@multica/core/types";
-import { Calendar } from "@/components/ui/calendar";
+import { Calendar } from "@multica/ui/components/ui/calendar";
import {
Popover,
PopoverTrigger,
PopoverContent,
-} from "@/components/ui/popover";
-import { Button } from "@/components/ui/button";
+} from "@multica/ui/components/ui/popover";
+import { Button } from "@multica/ui/components/ui/button";
export function DueDatePicker({
dueDate,
diff --git a/apps/web/features/issues/components/pickers/property-picker.tsx b/apps/web/features/issues/components/pickers/property-picker.tsx
index 6a53c82f18..3411f16b26 100644
--- a/apps/web/features/issues/components/pickers/property-picker.tsx
+++ b/apps/web/features/issues/components/pickers/property-picker.tsx
@@ -6,7 +6,7 @@ import {
Popover,
PopoverTrigger,
PopoverContent,
-} from "@/components/ui/popover";
+} from "@multica/ui/components/ui/popover";
// ---------------------------------------------------------------------------
// PropertyPicker — generic Popover shell with optional search
diff --git a/apps/web/features/issues/components/reply-input.tsx b/apps/web/features/issues/components/reply-input.tsx
index f2798d9025..ea11f404e1 100644
--- a/apps/web/features/issues/components/reply-input.tsx
+++ b/apps/web/features/issues/components/reply-input.tsx
@@ -3,11 +3,11 @@
import { useRef, useState, useEffect } from "react";
import { ArrowUp, Loader2 } from "lucide-react";
import { ContentEditor, type ContentEditorRef } from "@/features/editor";
-import { FileUploadButton } from "@/components/common/file-upload-button";
+import { FileUploadButton } from "@multica/ui/components/common/file-upload-button";
import { ActorAvatar } from "@/components/common/actor-avatar";
import { useFileUpload } from "@multica/core/hooks/use-file-upload";
import { api } from "@/platform/api";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
// ---------------------------------------------------------------------------
// Types
diff --git a/apps/web/features/landing/components/faq-section.tsx b/apps/web/features/landing/components/faq-section.tsx
index e32aed383e..15bc0ae3a2 100644
--- a/apps/web/features/landing/components/faq-section.tsx
+++ b/apps/web/features/landing/components/faq-section.tsx
@@ -1,7 +1,7 @@
"use client";
import { useState } from "react";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
import { useLocale } from "../i18n";
export function FAQSection() {
diff --git a/apps/web/features/landing/components/features-section.tsx b/apps/web/features/landing/components/features-section.tsx
index 6761123856..777a3a736d 100644
--- a/apps/web/features/landing/components/features-section.tsx
+++ b/apps/web/features/landing/components/features-section.tsx
@@ -18,7 +18,7 @@ import {
Sparkles,
UserMinus,
} from "lucide-react";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
import { ImageIcon } from "./shared";
import { useLocale } from "../i18n";
import type { LandingDict } from "../i18n";
diff --git a/apps/web/features/landing/components/landing-footer.tsx b/apps/web/features/landing/components/landing-footer.tsx
index a673278d24..5e7a6ffb3f 100644
--- a/apps/web/features/landing/components/landing-footer.tsx
+++ b/apps/web/features/landing/components/landing-footer.tsx
@@ -2,7 +2,7 @@
import Link from "next/link";
import { MulticaIcon } from "@/components/multica-icon";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
import { useAuthStore } from "@/features/auth";
import { useLocale, locales, localeLabels } from "../i18n";
diff --git a/apps/web/features/landing/components/landing-header.tsx b/apps/web/features/landing/components/landing-header.tsx
index dd855114d5..5536467a1c 100644
--- a/apps/web/features/landing/components/landing-header.tsx
+++ b/apps/web/features/landing/components/landing-header.tsx
@@ -2,7 +2,7 @@
import Link from "next/link";
import { MulticaIcon } from "@/components/multica-icon";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
import { useAuthStore } from "@/features/auth";
import { useLocale } from "../i18n";
import { GitHubMark, githubUrl, headerButtonClassName } from "./shared";
diff --git a/apps/web/features/landing/components/shared.tsx b/apps/web/features/landing/components/shared.tsx
index d1fd323ec0..dd51102ea0 100644
--- a/apps/web/features/landing/components/shared.tsx
+++ b/apps/web/features/landing/components/shared.tsx
@@ -1,4 +1,4 @@
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
export const githubUrl = "https://github.com/multica-ai/multica";
diff --git a/apps/web/features/modals/create-issue.tsx b/apps/web/features/modals/create-issue.tsx
index 7b38321291..089f997de4 100644
--- a/apps/web/features/modals/create-issue.tsx
+++ b/apps/web/features/modals/create-issue.tsx
@@ -3,28 +3,28 @@
import { useState, useRef } from "react";
import { useRouter } from "next/navigation";
import { CalendarDays, Check, ChevronRight, Maximize2, Minimize2, UserMinus, X as XIcon } from "lucide-react";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
import { toast } from "sonner";
import type { IssueStatus, IssuePriority, IssueAssigneeType } from "@multica/core/types";
import {
Dialog,
DialogContent,
DialogTitle,
-} from "@/components/ui/dialog";
+} from "@multica/ui/components/ui/dialog";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
+} from "@multica/ui/components/ui/dropdown-menu";
import {
Popover,
PopoverTrigger,
PopoverContent,
-} from "@/components/ui/popover";
-import { Calendar } from "@/components/ui/calendar";
-import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
-import { Button } from "@/components/ui/button";
+} from "@multica/ui/components/ui/popover";
+import { Calendar } from "@multica/ui/components/ui/calendar";
+import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
+import { Button } from "@multica/ui/components/ui/button";
import { ContentEditor, type ContentEditorRef } from "@/features/editor";
import { TitleEditor } from "@/features/editor";
import { StatusIcon, PriorityIcon } from "@/features/issues/components";
@@ -38,7 +38,7 @@ import { useIssueDraftStore } from "@multica/core/issues/stores/draft-store";
import { useCreateIssue } from "@multica/core/issues/mutations";
import { useFileUpload } from "@multica/core/hooks/use-file-upload";
import { api } from "@/platform/api";
-import { FileUploadButton } from "@/components/common/file-upload-button";
+import { FileUploadButton } from "@multica/ui/components/common/file-upload-button";
import { ActorAvatar } from "@/components/common/actor-avatar";
// ---------------------------------------------------------------------------
diff --git a/apps/web/features/modals/create-workspace.tsx b/apps/web/features/modals/create-workspace.tsx
index c8586e9f0e..5f68b0eead 100644
--- a/apps/web/features/modals/create-workspace.tsx
+++ b/apps/web/features/modals/create-workspace.tsx
@@ -4,16 +4,16 @@ import { useState } from "react";
import { useRouter } from "next/navigation";
import { toast } from "sonner";
import { ArrowLeft } from "lucide-react";
-import { Input } from "@/components/ui/input";
-import { Label } from "@/components/ui/label";
-import { Button } from "@/components/ui/button";
+import { Input } from "@multica/ui/components/ui/input";
+import { Label } from "@multica/ui/components/ui/label";
+import { Button } from "@multica/ui/components/ui/button";
import {
Dialog,
DialogContent,
DialogTitle,
DialogDescription,
-} from "@/components/ui/dialog";
-import { Card, CardContent } from "@/components/ui/card";
+} from "@multica/ui/components/ui/dialog";
+import { Card, CardContent } from "@multica/ui/components/ui/card";
import { useWorkspaceStore } from "@/platform/workspace";
const SLUG_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
diff --git a/apps/web/features/my-issues/components/my-issues-header.tsx b/apps/web/features/my-issues/components/my-issues-header.tsx
index 2e5ae44893..50da3c32dc 100644
--- a/apps/web/features/my-issues/components/my-issues-header.tsx
+++ b/apps/web/features/my-issues/components/my-issues-header.tsx
@@ -14,7 +14,7 @@ import {
SignalHigh,
SlidersHorizontal,
} from "lucide-react";
-import { Button } from "@/components/ui/button";
+import { Button } from "@multica/ui/components/ui/button";
import {
DropdownMenu,
DropdownMenuTrigger,
@@ -27,13 +27,13 @@ import {
DropdownMenuSub,
DropdownMenuSubTrigger,
DropdownMenuSubContent,
-} from "@/components/ui/dropdown-menu";
+} from "@multica/ui/components/ui/dropdown-menu";
import {
Popover,
PopoverTrigger,
PopoverContent,
-} from "@/components/ui/popover";
-import { Switch } from "@/components/ui/switch";
+} from "@multica/ui/components/ui/popover";
+import { Switch } from "@multica/ui/components/ui/switch";
import {
ALL_STATUSES,
STATUS_CONFIG,
@@ -46,7 +46,7 @@ import {
CARD_PROPERTY_OPTIONS,
} from "@multica/core/issues/stores/view-store";
import { filterIssues } from "@/features/issues/utils/filter";
-import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
+import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
import type { Issue } from "@multica/core/types";
import { myIssuesViewStore, type MyIssuesScope } from "../stores/my-issues-view-store";
diff --git a/apps/web/features/my-issues/components/my-issues-page.tsx b/apps/web/features/my-issues/components/my-issues-page.tsx
index 51b868c182..901a093aba 100644
--- a/apps/web/features/my-issues/components/my-issues-page.tsx
+++ b/apps/web/features/my-issues/components/my-issues-page.tsx
@@ -5,7 +5,7 @@ import { useStore } from "zustand";
import { toast } from "sonner";
import { ChevronRight, ListTodo } from "lucide-react";
import type { IssueStatus } from "@multica/core/types";
-import { Skeleton } from "@/components/ui/skeleton";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
import { useAuthStore } from "@/platform/auth";
import { useWorkspaceStore } from "@/platform/workspace";
import { WorkspaceAvatar } from "@/features/workspace";
diff --git a/apps/web/features/runtimes/components/charts/daily-cost-chart.tsx b/apps/web/features/runtimes/components/charts/daily-cost-chart.tsx
index d96718fd00..995df6e889 100644
--- a/apps/web/features/runtimes/components/charts/daily-cost-chart.tsx
+++ b/apps/web/features/runtimes/components/charts/daily-cost-chart.tsx
@@ -10,7 +10,7 @@ import {
ChartTooltip,
ChartTooltipContent,
type ChartConfig,
-} from "@/components/ui/chart";
+} from "@multica/ui/components/ui/chart";
import type { DailyCostData } from "../../utils";
const costChartConfig = {
diff --git a/apps/web/features/runtimes/components/charts/daily-token-chart.tsx b/apps/web/features/runtimes/components/charts/daily-token-chart.tsx
index a5bb6c8ba8..d37efc1800 100644
--- a/apps/web/features/runtimes/components/charts/daily-token-chart.tsx
+++ b/apps/web/features/runtimes/components/charts/daily-token-chart.tsx
@@ -12,7 +12,7 @@ import {
ChartLegend,
ChartLegendContent,
type ChartConfig,
-} from "@/components/ui/chart";
+} from "@multica/ui/components/ui/chart";
import type { DailyTokenData } from "../../utils";
import { formatTokens } from "../../utils";
diff --git a/apps/web/features/runtimes/components/charts/hourly-activity-chart.tsx b/apps/web/features/runtimes/components/charts/hourly-activity-chart.tsx
index 1126503874..2ebf4f58b0 100644
--- a/apps/web/features/runtimes/components/charts/hourly-activity-chart.tsx
+++ b/apps/web/features/runtimes/components/charts/hourly-activity-chart.tsx
@@ -12,7 +12,7 @@ import {
ChartTooltip,
ChartTooltipContent,
type ChartConfig,
-} from "@/components/ui/chart";
+} from "@multica/ui/components/ui/chart";
import { api } from "@/platform/api";
import type { RuntimeHourlyActivity } from "@multica/core/types";
diff --git a/apps/web/features/runtimes/components/charts/model-distribution-chart.tsx b/apps/web/features/runtimes/components/charts/model-distribution-chart.tsx
index b8a7f1c019..ec8d07fb29 100644
--- a/apps/web/features/runtimes/components/charts/model-distribution-chart.tsx
+++ b/apps/web/features/runtimes/components/charts/model-distribution-chart.tsx
@@ -4,7 +4,7 @@ import {
ChartTooltip,
ChartTooltipContent,
type ChartConfig,
-} from "@/components/ui/chart";
+} from "@multica/ui/components/ui/chart";
import type { ModelDistribution } from "../../utils";
import { formatTokens } from "../../utils";
diff --git a/apps/web/features/runtimes/components/ping-section.tsx b/apps/web/features/runtimes/components/ping-section.tsx
index 6d9d26f58a..d72e975046 100644
--- a/apps/web/features/runtimes/components/ping-section.tsx
+++ b/apps/web/features/runtimes/components/ping-section.tsx
@@ -1,6 +1,6 @@
import { useState, useEffect, useCallback, useRef } from "react";
import { Loader2, CheckCircle2, XCircle, Zap } from "lucide-react";
-import { Button } from "@/components/ui/button";
+import { Button } from "@multica/ui/components/ui/button";
import { api } from "@/platform/api";
import type { RuntimePingStatus } from "@multica/core/types";
diff --git a/apps/web/features/runtimes/components/runtimes-page.tsx b/apps/web/features/runtimes/components/runtimes-page.tsx
index 93563c71be..62ff7a4fd4 100644
--- a/apps/web/features/runtimes/components/runtimes-page.tsx
+++ b/apps/web/features/runtimes/components/runtimes-page.tsx
@@ -8,8 +8,8 @@ import {
ResizablePanelGroup,
ResizablePanel,
ResizableHandle,
-} from "@/components/ui/resizable";
-import { Skeleton } from "@/components/ui/skeleton";
+} from "@multica/ui/components/ui/resizable";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
import { useAuthStore } from "@/platform/auth";
import { useWorkspaceId } from "@multica/core/hooks";
import { runtimeListOptions, runtimeKeys } from "@multica/core/runtimes/queries";
diff --git a/apps/web/features/runtimes/components/shared.tsx b/apps/web/features/runtimes/components/shared.tsx
index bbe2dbeee5..eb0be228d8 100644
--- a/apps/web/features/runtimes/components/shared.tsx
+++ b/apps/web/features/runtimes/components/shared.tsx
@@ -1,5 +1,5 @@
import { Monitor, Cloud, Wifi, WifiOff } from "lucide-react";
-import { Badge } from "@/components/ui/badge";
+import { Badge } from "@multica/ui/components/ui/badge";
export function RuntimeModeIcon({ mode }: { mode: string }) {
return mode === "cloud" ? (
diff --git a/apps/web/features/runtimes/components/update-section.tsx b/apps/web/features/runtimes/components/update-section.tsx
index 9451aa3363..38783ba629 100644
--- a/apps/web/features/runtimes/components/update-section.tsx
+++ b/apps/web/features/runtimes/components/update-section.tsx
@@ -6,7 +6,7 @@ import {
ArrowUpCircle,
Check,
} from "lucide-react";
-import { Button } from "@/components/ui/button";
+import { Button } from "@multica/ui/components/ui/button";
import { api } from "@/platform/api";
import type { RuntimeUpdateStatus } from "@multica/core/types";
diff --git a/apps/web/features/runtimes/components/usage-section.tsx b/apps/web/features/runtimes/components/usage-section.tsx
index da5024bc13..99373d9527 100644
--- a/apps/web/features/runtimes/components/usage-section.tsx
+++ b/apps/web/features/runtimes/components/usage-section.tsx
@@ -2,7 +2,7 @@
import { useState, useEffect } from "react";
import { BarChart3 } from "lucide-react";
-import { Skeleton } from "@/components/ui/skeleton";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
import type { RuntimeUsage } from "@multica/core/types";
import { api } from "@/platform/api";
import { formatTokens, estimateCost, aggregateByDate } from "../utils";
diff --git a/apps/web/features/skills/components/file-tree.tsx b/apps/web/features/skills/components/file-tree.tsx
index a9576b718f..bcb5bd93c9 100644
--- a/apps/web/features/skills/components/file-tree.tsx
+++ b/apps/web/features/skills/components/file-tree.tsx
@@ -9,7 +9,7 @@ import {
Folder,
FolderOpen,
} from "lucide-react";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
// ---------------------------------------------------------------------------
// Tree data structures
diff --git a/apps/web/features/skills/components/file-viewer.tsx b/apps/web/features/skills/components/file-viewer.tsx
index 226ad583ef..47db3cb97a 100644
--- a/apps/web/features/skills/components/file-viewer.tsx
+++ b/apps/web/features/skills/components/file-viewer.tsx
@@ -2,9 +2,9 @@
import { useState, useMemo } from "react";
import { Pencil, Eye } from "lucide-react";
-import { Button } from "@/components/ui/button";
-import { Textarea } from "@/components/ui/textarea";
-import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
+import { Button } from "@multica/ui/components/ui/button";
+import { Textarea } from "@multica/ui/components/ui/textarea";
+import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
import { Markdown } from "@/components/markdown/Markdown";
function isMarkdown(path: string) {
diff --git a/apps/web/features/skills/components/skills-page.tsx b/apps/web/features/skills/components/skills-page.tsx
index b8cea687d7..c5eecf2797 100644
--- a/apps/web/features/skills/components/skills-page.tsx
+++ b/apps/web/features/skills/components/skills-page.tsx
@@ -18,20 +18,20 @@ import {
DialogTitle,
DialogDescription,
DialogFooter,
-} from "@/components/ui/dialog";
+} from "@multica/ui/components/ui/dialog";
import {
ResizablePanelGroup,
ResizablePanel,
ResizableHandle,
-} from "@/components/ui/resizable";
-import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
-import { Badge } from "@/components/ui/badge";
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Label } from "@/components/ui/label";
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
+} from "@multica/ui/components/ui/resizable";
+import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
+import { Badge } from "@multica/ui/components/ui/badge";
+import { Button } from "@multica/ui/components/ui/button";
+import { Input } from "@multica/ui/components/ui/input";
+import { Label } from "@multica/ui/components/ui/label";
+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@multica/ui/components/ui/tabs";
import { toast } from "sonner";
-import { Skeleton } from "@/components/ui/skeleton";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
import { api } from "@/platform/api";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { useAuthStore } from "@/platform/auth";
diff --git a/apps/web/features/workspace/components/workspace-avatar.tsx b/apps/web/features/workspace/components/workspace-avatar.tsx
index d415c8dd0b..06157c463a 100644
--- a/apps/web/features/workspace/components/workspace-avatar.tsx
+++ b/apps/web/features/workspace/components/workspace-avatar.tsx
@@ -1,4 +1,4 @@
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
const sizeMap = {
sm: "h-5 w-5 text-xs rounded",
diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts
index 39c8cd4376..ed0346557a 100644
--- a/apps/web/next.config.ts
+++ b/apps/web/next.config.ts
@@ -22,7 +22,7 @@ const allowedDevOrigins = process.env.CORS_ALLOWED_ORIGINS
: undefined;
const nextConfig: NextConfig = {
- transpilePackages: ["@multica/core"],
+ transpilePackages: ["@multica/core", "@multica/ui"],
...(allowedDevOrigins && allowedDevOrigins.length > 0
? { allowedDevOrigins }
: {}),
diff --git a/apps/web/package.json b/apps/web/package.json
index d73b850f4e..0141a0407d 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -13,6 +13,7 @@
},
"dependencies": {
"@multica/core": "workspace:*",
+ "@multica/ui": "workspace:*",
"@base-ui/react": "^1.3.0",
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/sortable": "^10.0.0",
diff --git a/packages/ui/components/common/actor-avatar.tsx b/packages/ui/components/common/actor-avatar.tsx
new file mode 100644
index 0000000000..1629dc1fca
--- /dev/null
+++ b/packages/ui/components/common/actor-avatar.tsx
@@ -0,0 +1,58 @@
+"use client";
+
+import { useState, useEffect } from "react";
+import { Bot } from "lucide-react";
+import { cn } from "@multica/ui/lib/utils";
+
+interface ActorAvatarProps {
+ name: string;
+ initials: string;
+ avatarUrl?: string | null;
+ isAgent?: boolean;
+ size?: number;
+ className?: string;
+}
+
+function ActorAvatar({
+ name,
+ initials,
+ avatarUrl,
+ isAgent,
+ size = 20,
+ className,
+}: ActorAvatarProps) {
+ const [imgError, setImgError] = useState(false);
+
+ // Reset error state when URL changes (e.g. user uploads new avatar)
+ useEffect(() => {
+ setImgError(false);
+ }, [avatarUrl]);
+
+ return (
+ <div
+ data-slot="avatar"
+ className={cn(
+ "inline-flex shrink-0 items-center justify-center rounded-full font-medium overflow-hidden",
+ "bg-muted text-muted-foreground",
+ className
+ )}
+ style={{ width: size, height: size, fontSize: size * 0.45 }}
+ title={name}
+ >
+ {avatarUrl && !imgError ? (
+ <img
+ src={avatarUrl}
+ alt={name}
+ className="h-full w-full object-cover"
+ onError={() => setImgError(true)}
+ />
+ ) : isAgent ? (
+ <Bot style={{ width: size * 0.55, height: size * 0.55 }} />
+ ) : (
+ initials
+ )}
+ </div>
+ );
+}
+
+export { ActorAvatar, type ActorAvatarProps };
diff --git a/apps/web/components/common/emoji-picker.tsx b/packages/ui/components/common/emoji-picker.tsx
similarity index 100%
rename from apps/web/components/common/emoji-picker.tsx
rename to packages/ui/components/common/emoji-picker.tsx
diff --git a/apps/web/components/common/file-upload-button.tsx b/packages/ui/components/common/file-upload-button.tsx
similarity index 97%
rename from apps/web/components/common/file-upload-button.tsx
rename to packages/ui/components/common/file-upload-button.tsx
index a52bd1dcdf..fdbe34021b 100644
--- a/apps/web/components/common/file-upload-button.tsx
+++ b/packages/ui/components/common/file-upload-button.tsx
@@ -2,7 +2,7 @@
import { useRef } from "react";
import { Paperclip } from "lucide-react";
-import { cn } from "@/lib/utils";
+import { cn } from "@multica/ui/lib/utils";
interface FileUploadButtonProps {
/** Called with the selected File — caller handles upload. */
diff --git a/packages/ui/components/common/mention-hover-card.tsx b/packages/ui/components/common/mention-hover-card.tsx
new file mode 100644
index 0000000000..170f80e50a
--- /dev/null
+++ b/packages/ui/components/common/mention-hover-card.tsx
@@ -0,0 +1,74 @@
+"use client";
+
+import type { ReactNode } from "react";
+import { Users } from "lucide-react";
+import { HoverCard, HoverCardTrigger, HoverCardContent } from "@multica/ui/components/ui/hover-card";
+import { ActorAvatar } from "./actor-avatar";
+
+interface MentionHoverCardProps {
+ type: string;
+ id: string;
+ name: string;
+ initials: string;
+ avatarUrl?: string | null;
+ role?: string;
+ children: ReactNode;
+}
+
+function MentionHoverCard({
+ type,
+ id,
+ name,
+ initials,
+ avatarUrl,
+ role,
+ children,
+}: MentionHoverCardProps) {
+ if (type === "all") {
+ return (
+ <HoverCard>
+ <HoverCardTrigger render={<span />} className="cursor-default">
+ {children}
+ </HoverCardTrigger>
+ <HoverCardContent align="start" className="w-auto min-w-48 max-w-72">
+ <div className="flex items-center gap-2.5">
+ <div className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10">
+ <Users className="h-4 w-4 text-primary" />
+ </div>
+ <div className="min-w-0">
+ <p className="text-sm font-medium">All members</p>
+ <p className="text-xs text-muted-foreground">Notifies all workspace members</p>
+ </div>
+ </div>
+ </HoverCardContent>
+ </HoverCard>
+ );
+ }
+
+ return (
+ <HoverCard>
+ <HoverCardTrigger render={<span />} className="cursor-default">
+ {children}
+ </HoverCardTrigger>
+ <HoverCardContent align="start" className="w-auto min-w-48 max-w-72">
+ <div className="flex items-center gap-2.5">
+ <ActorAvatar
+ name={name}
+ initials={initials}
+ avatarUrl={avatarUrl}
+ isAgent={type === "agent"}
+ size={32}
+ />
+ <div className="min-w-0">
+ <p className="text-sm font-medium truncate">{name}</p>
+ {role && (
+ <p className="text-xs text-muted-foreground truncate">{role}</p>
+ )}
+ </div>
+ </div>
+ </HoverCardContent>
+ </HoverCard>
+ );
+}
+
+export { MentionHoverCard, type MentionHoverCardProps };
diff --git a/apps/web/components/common/quick-emoji-picker.tsx b/packages/ui/components/common/quick-emoji-picker.tsx
similarity index 93%
rename from apps/web/components/common/quick-emoji-picker.tsx
rename to packages/ui/components/common/quick-emoji-picker.tsx
index af2e39f77d..d07418c79b 100644
--- a/apps/web/components/common/quick-emoji-picker.tsx
+++ b/packages/ui/components/common/quick-emoji-picker.tsx
@@ -2,10 +2,10 @@
import { useState, lazy, Suspense } from "react";
import { SmilePlus } from "lucide-react";
-import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover";
+import { Popover, PopoverTrigger, PopoverContent } from "@multica/ui/components/ui/popover";
const EmojiPicker = lazy(() =>
- import("@/components/common/emoji-picker").then((m) => ({ default: m.EmojiPicker })),
+ import("./emoji-picker").then((m) => ({ default: m.EmojiPicker })),
);
const QUICK_EMOJIS = ["👍", "👌", "❤️", "😄", "🎉", "😕", "🚀", "👀"];
diff --git a/apps/web/components/common/reaction-bar.tsx b/packages/ui/components/common/reaction-bar.tsx
similarity index 85%
rename from apps/web/components/common/reaction-bar.tsx
rename to packages/ui/components/common/reaction-bar.tsx
index e700cf734e..12a05c852a 100644
--- a/apps/web/components/common/reaction-bar.tsx
+++ b/packages/ui/components/common/reaction-bar.tsx
@@ -1,8 +1,7 @@
"use client";
-import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
-import { QuickEmojiPicker } from "@/components/common/quick-emoji-picker";
-import { useActorName } from "@multica/core/workspace/hooks";
+import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
+import { QuickEmojiPicker } from "./quick-emoji-picker";
interface ReactionItem {
id: string;
@@ -35,21 +34,24 @@ function groupReactions(reactions: ReactionItem[], currentUserId?: string): Grou
return Array.from(map.values());
}
-export function ReactionBar({
- reactions,
- currentUserId,
- onToggle,
- className,
- hideAddButton,
-}: {
+interface ReactionBarProps {
reactions: ReactionItem[];
currentUserId?: string;
onToggle: (emoji: string) => void;
+ getActorName: (type: string, id: string) => string;
className?: string;
hideAddButton?: boolean;
-}) {
+}
+
+function ReactionBar({
+ reactions,
+ currentUserId,
+ onToggle,
+ getActorName,
+ className,
+ hideAddButton,
+}: ReactionBarProps) {
const grouped = groupReactions(reactions, currentUserId);
- const { getActorName } = useActorName();
return (
<div className={`flex flex-wrap items-center gap-1.5 ${className ?? ""}`}>
@@ -80,3 +82,5 @@ export function ReactionBar({
</div>
);
}
+
+export { ReactionBar, type ReactionBarProps, type ReactionItem };
diff --git a/apps/web/components/ui/accordion.tsx b/packages/ui/components/ui/accordion.tsx
similarity index 98%
rename from apps/web/components/ui/accordion.tsx
rename to packages/ui/components/ui/accordion.tsx
index 6142db9117..08461bf9a8 100644
--- a/apps/web/components/ui/accordion.tsx
+++ b/packages/ui/components/ui/accordion.tsx
@@ -2,7 +2,7 @@
import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
import { ChevronDownIcon, ChevronUpIcon } from "lucide-react"
function Accordion({ className, ...props }: AccordionPrimitive.Root.Props) {
diff --git a/apps/web/components/ui/alert-dialog.tsx b/packages/ui/components/ui/alert-dialog.tsx
similarity index 98%
rename from apps/web/components/ui/alert-dialog.tsx
rename to packages/ui/components/ui/alert-dialog.tsx
index 0ee2c5f42e..6a43197bf4 100644
--- a/apps/web/components/ui/alert-dialog.tsx
+++ b/packages/ui/components/ui/alert-dialog.tsx
@@ -3,8 +3,8 @@
import * as React from "react"
import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog"
-import { cn } from "@/lib/utils"
-import { Button } from "@/components/ui/button"
+import { cn } from "@multica/ui/lib/utils"
+import { Button } from "@multica/ui/components/ui/button"
function AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) {
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
diff --git a/apps/web/components/ui/alert.tsx b/packages/ui/components/ui/alert.tsx
similarity index 97%
rename from apps/web/components/ui/alert.tsx
rename to packages/ui/components/ui/alert.tsx
index 2a176c75ac..8bebd74765 100644
--- a/apps/web/components/ui/alert.tsx
+++ b/packages/ui/components/ui/alert.tsx
@@ -1,7 +1,7 @@
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
const alertVariants = cva(
"group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",
diff --git a/apps/web/components/ui/aspect-ratio.tsx b/packages/ui/components/ui/aspect-ratio.tsx
similarity index 89%
rename from apps/web/components/ui/aspect-ratio.tsx
rename to packages/ui/components/ui/aspect-ratio.tsx
index 4c0ebaa57c..f0bdf5342a 100644
--- a/apps/web/components/ui/aspect-ratio.tsx
+++ b/packages/ui/components/ui/aspect-ratio.tsx
@@ -1,4 +1,4 @@
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function AspectRatio({
ratio,
diff --git a/apps/web/components/ui/avatar.tsx b/packages/ui/components/ui/avatar.tsx
similarity index 98%
rename from apps/web/components/ui/avatar.tsx
rename to packages/ui/components/ui/avatar.tsx
index e4fed865cf..5714db048a 100644
--- a/apps/web/components/ui/avatar.tsx
+++ b/packages/ui/components/ui/avatar.tsx
@@ -3,7 +3,7 @@
import * as React from "react"
import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Avatar({
className,
diff --git a/apps/web/components/ui/badge.tsx b/packages/ui/components/ui/badge.tsx
similarity index 97%
rename from apps/web/components/ui/badge.tsx
rename to packages/ui/components/ui/badge.tsx
index b20959dd77..99d988a15d 100644
--- a/apps/web/components/ui/badge.tsx
+++ b/packages/ui/components/ui/badge.tsx
@@ -2,7 +2,7 @@ import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
const badgeVariants = cva(
"group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
diff --git a/apps/web/components/ui/breadcrumb.tsx b/packages/ui/components/ui/breadcrumb.tsx
similarity index 98%
rename from apps/web/components/ui/breadcrumb.tsx
rename to packages/ui/components/ui/breadcrumb.tsx
index 3d85c18d40..fb267d2087 100644
--- a/apps/web/components/ui/breadcrumb.tsx
+++ b/packages/ui/components/ui/breadcrumb.tsx
@@ -2,7 +2,7 @@ import * as React from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) {
diff --git a/apps/web/components/ui/button-group.tsx b/packages/ui/components/ui/button-group.tsx
similarity index 95%
rename from apps/web/components/ui/button-group.tsx
rename to packages/ui/components/ui/button-group.tsx
index 3c97c26586..bc755bed66 100644
--- a/apps/web/components/ui/button-group.tsx
+++ b/packages/ui/components/ui/button-group.tsx
@@ -2,8 +2,8 @@ import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
-import { cn } from "@/lib/utils"
-import { Separator } from "@/components/ui/separator"
+import { cn } from "@multica/ui/lib/utils"
+import { Separator } from "@multica/ui/components/ui/separator"
const buttonGroupVariants = cva(
"flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
diff --git a/apps/web/components/ui/button.tsx b/packages/ui/components/ui/button.tsx
similarity index 98%
rename from apps/web/components/ui/button.tsx
rename to packages/ui/components/ui/button.tsx
index 8dfb51922c..dfa8abd531 100644
--- a/apps/web/components/ui/button.tsx
+++ b/packages/ui/components/ui/button.tsx
@@ -3,7 +3,7 @@
import { Button as ButtonPrimitive } from "@base-ui/react/button"
import { cva, type VariantProps } from "class-variance-authority"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
const buttonVariants = cva(
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
diff --git a/apps/web/components/ui/calendar.tsx b/packages/ui/components/ui/calendar.tsx
similarity index 98%
rename from apps/web/components/ui/calendar.tsx
rename to packages/ui/components/ui/calendar.tsx
index 1d3044aacc..654c78fc33 100644
--- a/apps/web/components/ui/calendar.tsx
+++ b/packages/ui/components/ui/calendar.tsx
@@ -8,8 +8,8 @@ import {
type Locale,
} from "react-day-picker"
-import { cn } from "@/lib/utils"
-import { Button, buttonVariants } from "@/components/ui/button"
+import { cn } from "@multica/ui/lib/utils"
+import { Button, buttonVariants } from "@multica/ui/components/ui/button"
import { ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon } from "lucide-react"
function Calendar({
diff --git a/apps/web/components/ui/card.tsx b/packages/ui/components/ui/card.tsx
similarity index 98%
rename from apps/web/components/ui/card.tsx
rename to packages/ui/components/ui/card.tsx
index 40cac5f98d..ee61af62a9 100644
--- a/apps/web/components/ui/card.tsx
+++ b/packages/ui/components/ui/card.tsx
@@ -1,6 +1,6 @@
import * as React from "react"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Card({
className,
diff --git a/apps/web/components/ui/carousel.tsx b/packages/ui/components/ui/carousel.tsx
similarity index 98%
rename from apps/web/components/ui/carousel.tsx
rename to packages/ui/components/ui/carousel.tsx
index 9deee76e24..6299f79e5e 100644
--- a/apps/web/components/ui/carousel.tsx
+++ b/packages/ui/components/ui/carousel.tsx
@@ -5,8 +5,8 @@ import useEmblaCarousel, {
type UseEmblaCarouselType,
} from "embla-carousel-react"
-import { cn } from "@/lib/utils"
-import { Button } from "@/components/ui/button"
+import { cn } from "@multica/ui/lib/utils"
+import { Button } from "@multica/ui/components/ui/button"
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
type CarouselApi = UseEmblaCarouselType[1]
diff --git a/apps/web/components/ui/chart.tsx b/packages/ui/components/ui/chart.tsx
similarity index 99%
rename from apps/web/components/ui/chart.tsx
rename to packages/ui/components/ui/chart.tsx
index 7c2dc84726..72f6fb116a 100644
--- a/apps/web/components/ui/chart.tsx
+++ b/packages/ui/components/ui/chart.tsx
@@ -4,7 +4,7 @@ import * as React from "react"
import * as RechartsPrimitive from "recharts"
import type { TooltipValueType } from "recharts"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
// Format: { THEME_NAME: CSS_SELECTOR }
const THEMES = { light: "", dark: ".dark" } as const
diff --git a/apps/web/components/ui/checkbox.tsx b/packages/ui/components/ui/checkbox.tsx
similarity index 96%
rename from apps/web/components/ui/checkbox.tsx
rename to packages/ui/components/ui/checkbox.tsx
index 4fcd84785e..3d3fd8e033 100644
--- a/apps/web/components/ui/checkbox.tsx
+++ b/packages/ui/components/ui/checkbox.tsx
@@ -2,7 +2,7 @@
import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
import { CheckIcon } from "lucide-react"
function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {
diff --git a/apps/web/components/ui/collapsible.tsx b/packages/ui/components/ui/collapsible.tsx
similarity index 100%
rename from apps/web/components/ui/collapsible.tsx
rename to packages/ui/components/ui/collapsible.tsx
diff --git a/apps/web/components/ui/combobox.tsx b/packages/ui/components/ui/combobox.tsx
similarity index 98%
rename from apps/web/components/ui/combobox.tsx
rename to packages/ui/components/ui/combobox.tsx
index 39e2b937c9..46db2974a9 100644
--- a/apps/web/components/ui/combobox.tsx
+++ b/packages/ui/components/ui/combobox.tsx
@@ -3,14 +3,14 @@
import * as React from "react"
import { Combobox as ComboboxPrimitive } from "@base-ui/react"
-import { cn } from "@/lib/utils"
-import { Button } from "@/components/ui/button"
+import { cn } from "@multica/ui/lib/utils"
+import { Button } from "@multica/ui/components/ui/button"
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput,
-} from "@/components/ui/input-group"
+} from "@multica/ui/components/ui/input-group"
import { ChevronDownIcon, XIcon, CheckIcon } from "lucide-react"
const Combobox = ComboboxPrimitive.Root
diff --git a/apps/web/components/ui/command.tsx b/packages/ui/components/ui/command.tsx
similarity index 97%
rename from apps/web/components/ui/command.tsx
rename to packages/ui/components/ui/command.tsx
index 37fb2d9e82..cf3f0026b1 100644
--- a/apps/web/components/ui/command.tsx
+++ b/packages/ui/components/ui/command.tsx
@@ -3,18 +3,18 @@
import * as React from "react"
import { Command as CommandPrimitive } from "cmdk"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
-} from "@/components/ui/dialog"
+} from "@multica/ui/components/ui/dialog"
import {
InputGroup,
InputGroupAddon,
-} from "@/components/ui/input-group"
+} from "@multica/ui/components/ui/input-group"
import { SearchIcon, CheckIcon } from "lucide-react"
function Command({
diff --git a/apps/web/components/ui/context-menu.tsx b/packages/ui/components/ui/context-menu.tsx
similarity index 99%
rename from apps/web/components/ui/context-menu.tsx
rename to packages/ui/components/ui/context-menu.tsx
index 9c0eb98fc5..22bff85a8f 100644
--- a/apps/web/components/ui/context-menu.tsx
+++ b/packages/ui/components/ui/context-menu.tsx
@@ -3,7 +3,7 @@
import * as React from "react"
import { ContextMenu as ContextMenuPrimitive } from "@base-ui/react/context-menu"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
import { ChevronRightIcon, CheckIcon } from "lucide-react"
function ContextMenu({ ...props }: ContextMenuPrimitive.Root.Props) {
diff --git a/apps/web/components/ui/dialog.tsx b/packages/ui/components/ui/dialog.tsx
similarity index 97%
rename from apps/web/components/ui/dialog.tsx
rename to packages/ui/components/ui/dialog.tsx
index 014f5aa3b6..b45442e3fd 100644
--- a/apps/web/components/ui/dialog.tsx
+++ b/packages/ui/components/ui/dialog.tsx
@@ -3,8 +3,8 @@
import * as React from "react"
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog"
-import { cn } from "@/lib/utils"
-import { Button } from "@/components/ui/button"
+import { cn } from "@multica/ui/lib/utils"
+import { Button } from "@multica/ui/components/ui/button"
import { XIcon } from "lucide-react"
function Dialog({ ...props }: DialogPrimitive.Root.Props) {
diff --git a/apps/web/components/ui/direction.tsx b/packages/ui/components/ui/direction.tsx
similarity index 100%
rename from apps/web/components/ui/direction.tsx
rename to packages/ui/components/ui/direction.tsx
diff --git a/apps/web/components/ui/drawer.tsx b/packages/ui/components/ui/drawer.tsx
similarity index 99%
rename from apps/web/components/ui/drawer.tsx
rename to packages/ui/components/ui/drawer.tsx
index a4dfff756a..4413a03eda 100644
--- a/apps/web/components/ui/drawer.tsx
+++ b/packages/ui/components/ui/drawer.tsx
@@ -3,7 +3,7 @@
import * as React from "react"
import { Drawer as DrawerPrimitive } from "vaul"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Drawer({
...props
diff --git a/apps/web/components/ui/dropdown-menu.tsx b/packages/ui/components/ui/dropdown-menu.tsx
similarity index 99%
rename from apps/web/components/ui/dropdown-menu.tsx
rename to packages/ui/components/ui/dropdown-menu.tsx
index f157768dfd..7e5b01ebc7 100644
--- a/apps/web/components/ui/dropdown-menu.tsx
+++ b/packages/ui/components/ui/dropdown-menu.tsx
@@ -3,7 +3,7 @@
import * as React from "react"
import { Menu as MenuPrimitive } from "@base-ui/react/menu"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
import { ChevronRightIcon, CheckIcon } from "lucide-react"
function DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {
diff --git a/apps/web/components/ui/empty.tsx b/packages/ui/components/ui/empty.tsx
similarity index 98%
rename from apps/web/components/ui/empty.tsx
rename to packages/ui/components/ui/empty.tsx
index b23187b049..0635fb1685 100644
--- a/apps/web/components/ui/empty.tsx
+++ b/packages/ui/components/ui/empty.tsx
@@ -1,6 +1,6 @@
import { cva, type VariantProps } from "class-variance-authority"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Empty({ className, ...props }: React.ComponentProps<"div">) {
return (
diff --git a/apps/web/components/ui/field.tsx b/packages/ui/components/ui/field.tsx
similarity index 97%
rename from apps/web/components/ui/field.tsx
rename to packages/ui/components/ui/field.tsx
index b4c0ca6f1d..74ece3ada0 100644
--- a/apps/web/components/ui/field.tsx
+++ b/packages/ui/components/ui/field.tsx
@@ -3,9 +3,9 @@
import { useMemo } from "react"
import { cva, type VariantProps } from "class-variance-authority"
-import { cn } from "@/lib/utils"
-import { Label } from "@/components/ui/label"
-import { Separator } from "@/components/ui/separator"
+import { cn } from "@multica/ui/lib/utils"
+import { Label } from "@multica/ui/components/ui/label"
+import { Separator } from "@multica/ui/components/ui/separator"
function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
return (
diff --git a/apps/web/components/ui/hover-card.tsx b/packages/ui/components/ui/hover-card.tsx
similarity index 97%
rename from apps/web/components/ui/hover-card.tsx
rename to packages/ui/components/ui/hover-card.tsx
index 58a477c859..9898fddabe 100644
--- a/apps/web/components/ui/hover-card.tsx
+++ b/packages/ui/components/ui/hover-card.tsx
@@ -2,7 +2,7 @@
import { PreviewCard as PreviewCardPrimitive } from "@base-ui/react/preview-card"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function HoverCard({ ...props }: PreviewCardPrimitive.Root.Props) {
return <PreviewCardPrimitive.Root data-slot="hover-card" {...props} />
diff --git a/apps/web/components/ui/input-group.tsx b/packages/ui/components/ui/input-group.tsx
similarity index 95%
rename from apps/web/components/ui/input-group.tsx
rename to packages/ui/components/ui/input-group.tsx
index da8f1ddcd9..190cd7541e 100644
--- a/apps/web/components/ui/input-group.tsx
+++ b/packages/ui/components/ui/input-group.tsx
@@ -3,10 +3,10 @@
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
-import { cn } from "@/lib/utils"
-import { Button } from "@/components/ui/button"
-import { Input } from "@/components/ui/input"
-import { Textarea } from "@/components/ui/textarea"
+import { cn } from "@multica/ui/lib/utils"
+import { Button } from "@multica/ui/components/ui/button"
+import { Input } from "@multica/ui/components/ui/input"
+import { Textarea } from "@multica/ui/components/ui/textarea"
function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
return (
diff --git a/apps/web/components/ui/input-otp.tsx b/packages/ui/components/ui/input-otp.tsx
similarity index 98%
rename from apps/web/components/ui/input-otp.tsx
rename to packages/ui/components/ui/input-otp.tsx
index 941b9d12cf..828bf41362 100644
--- a/apps/web/components/ui/input-otp.tsx
+++ b/packages/ui/components/ui/input-otp.tsx
@@ -3,7 +3,7 @@
import * as React from "react"
import { OTPInput, OTPInputContext } from "input-otp"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
import { MinusIcon } from "lucide-react"
function InputOTP({
diff --git a/apps/web/components/ui/input.tsx b/packages/ui/components/ui/input.tsx
similarity index 95%
rename from apps/web/components/ui/input.tsx
rename to packages/ui/components/ui/input.tsx
index 7d21babba9..2977912eab 100644
--- a/apps/web/components/ui/input.tsx
+++ b/packages/ui/components/ui/input.tsx
@@ -1,7 +1,7 @@
import * as React from "react"
import { Input as InputPrimitive } from "@base-ui/react/input"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
return (
diff --git a/apps/web/components/ui/item.tsx b/packages/ui/components/ui/item.tsx
similarity index 97%
rename from apps/web/components/ui/item.tsx
rename to packages/ui/components/ui/item.tsx
index 8eecc7553a..4faeb2c1c1 100644
--- a/apps/web/components/ui/item.tsx
+++ b/packages/ui/components/ui/item.tsx
@@ -3,8 +3,8 @@ import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
-import { cn } from "@/lib/utils"
-import { Separator } from "@/components/ui/separator"
+import { cn } from "@multica/ui/lib/utils"
+import { Separator } from "@multica/ui/components/ui/separator"
function ItemGroup({ className, ...props }: React.ComponentProps<"div">) {
return (
diff --git a/apps/web/components/ui/kbd.tsx b/packages/ui/components/ui/kbd.tsx
similarity index 94%
rename from apps/web/components/ui/kbd.tsx
rename to packages/ui/components/ui/kbd.tsx
index ff93b53226..27f1475a65 100644
--- a/apps/web/components/ui/kbd.tsx
+++ b/packages/ui/components/ui/kbd.tsx
@@ -1,4 +1,4 @@
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Kbd({ className, ...props }: React.ComponentProps<"kbd">) {
return (
diff --git a/apps/web/components/ui/label.tsx b/packages/ui/components/ui/label.tsx
similarity index 91%
rename from apps/web/components/ui/label.tsx
rename to packages/ui/components/ui/label.tsx
index 74da65c33b..51e4da9427 100644
--- a/apps/web/components/ui/label.tsx
+++ b/packages/ui/components/ui/label.tsx
@@ -2,7 +2,7 @@
import * as React from "react"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Label({ className, ...props }: React.ComponentProps<"label">) {
return (
diff --git a/apps/web/components/ui/menubar.tsx b/packages/ui/components/ui/menubar.tsx
similarity index 98%
rename from apps/web/components/ui/menubar.tsx
rename to packages/ui/components/ui/menubar.tsx
index 9738fb13bc..cd7ae041fb 100644
--- a/apps/web/components/ui/menubar.tsx
+++ b/packages/ui/components/ui/menubar.tsx
@@ -4,7 +4,7 @@ import * as React from "react"
import { Menu as MenuPrimitive } from "@base-ui/react/menu"
import { Menubar as MenubarPrimitive } from "@base-ui/react/menubar"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
import {
DropdownMenu,
DropdownMenuContent,
@@ -19,7 +19,7 @@ import {
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu"
+} from "@multica/ui/components/ui/dropdown-menu"
import { CheckIcon } from "lucide-react"
function Menubar({ className, ...props }: MenubarPrimitive.Props) {
diff --git a/apps/web/components/ui/native-select.tsx b/packages/ui/components/ui/native-select.tsx
similarity index 97%
rename from apps/web/components/ui/native-select.tsx
rename to packages/ui/components/ui/native-select.tsx
index 1edab6a117..c007ac4f88 100644
--- a/apps/web/components/ui/native-select.tsx
+++ b/packages/ui/components/ui/native-select.tsx
@@ -1,6 +1,6 @@
import * as React from "react"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
import { ChevronDownIcon } from "lucide-react"
type NativeSelectProps = Omit<React.ComponentProps<"select">, "size"> & {
diff --git a/apps/web/components/ui/navigation-menu.tsx b/packages/ui/components/ui/navigation-menu.tsx
similarity index 99%
rename from apps/web/components/ui/navigation-menu.tsx
rename to packages/ui/components/ui/navigation-menu.tsx
index e30607be70..b451db9709 100644
--- a/apps/web/components/ui/navigation-menu.tsx
+++ b/packages/ui/components/ui/navigation-menu.tsx
@@ -1,7 +1,7 @@
import { NavigationMenu as NavigationMenuPrimitive } from "@base-ui/react/navigation-menu"
import { cva } from "class-variance-authority"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
import { ChevronDownIcon } from "lucide-react"
function NavigationMenu({
diff --git a/apps/web/components/ui/pagination.tsx b/packages/ui/components/ui/pagination.tsx
similarity index 96%
rename from apps/web/components/ui/pagination.tsx
rename to packages/ui/components/ui/pagination.tsx
index db376f60ad..6e65607f71 100644
--- a/apps/web/components/ui/pagination.tsx
+++ b/packages/ui/components/ui/pagination.tsx
@@ -1,7 +1,7 @@
import * as React from "react"
-import { cn } from "@/lib/utils"
-import { Button } from "@/components/ui/button"
+import { cn } from "@multica/ui/lib/utils"
+import { Button } from "@multica/ui/components/ui/button"
import { ChevronLeftIcon, ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
function Pagination({ className, ...props }: React.ComponentProps<"nav">) {
diff --git a/apps/web/components/ui/popover.tsx b/packages/ui/components/ui/popover.tsx
similarity index 98%
rename from apps/web/components/ui/popover.tsx
rename to packages/ui/components/ui/popover.tsx
index 4dc28c308f..95112d1537 100644
--- a/apps/web/components/ui/popover.tsx
+++ b/packages/ui/components/ui/popover.tsx
@@ -3,7 +3,7 @@
import * as React from "react"
import { Popover as PopoverPrimitive } from "@base-ui/react/popover"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Popover({ ...props }: PopoverPrimitive.Root.Props) {
return <PopoverPrimitive.Root data-slot="popover" {...props} />
diff --git a/apps/web/components/ui/progress.tsx b/packages/ui/components/ui/progress.tsx
similarity index 97%
rename from apps/web/components/ui/progress.tsx
rename to packages/ui/components/ui/progress.tsx
index 986f3463a4..353f4bef9b 100644
--- a/apps/web/components/ui/progress.tsx
+++ b/packages/ui/components/ui/progress.tsx
@@ -2,7 +2,7 @@
import { Progress as ProgressPrimitive } from "@base-ui/react/progress"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Progress({
className,
diff --git a/apps/web/components/ui/radio-group.tsx b/packages/ui/components/ui/radio-group.tsx
similarity index 97%
rename from apps/web/components/ui/radio-group.tsx
rename to packages/ui/components/ui/radio-group.tsx
index 3172cf3a81..fbf818dad1 100644
--- a/apps/web/components/ui/radio-group.tsx
+++ b/packages/ui/components/ui/radio-group.tsx
@@ -3,7 +3,7 @@
import { Radio as RadioPrimitive } from "@base-ui/react/radio"
import { RadioGroup as RadioGroupPrimitive } from "@base-ui/react/radio-group"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) {
return (
diff --git a/apps/web/components/ui/resizable.tsx b/packages/ui/components/ui/resizable.tsx
similarity index 97%
rename from apps/web/components/ui/resizable.tsx
rename to packages/ui/components/ui/resizable.tsx
index 030fd4e1e3..305e07e6be 100644
--- a/apps/web/components/ui/resizable.tsx
+++ b/packages/ui/components/ui/resizable.tsx
@@ -2,7 +2,7 @@
import * as ResizablePrimitive from "react-resizable-panels"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function ResizablePanelGroup({
className,
diff --git a/apps/web/components/ui/scroll-area.tsx b/packages/ui/components/ui/scroll-area.tsx
similarity index 97%
rename from apps/web/components/ui/scroll-area.tsx
rename to packages/ui/components/ui/scroll-area.tsx
index 84c1e9fbb0..ca6781cad8 100644
--- a/apps/web/components/ui/scroll-area.tsx
+++ b/packages/ui/components/ui/scroll-area.tsx
@@ -3,7 +3,7 @@
import * as React from "react"
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function ScrollArea({
className,
diff --git a/apps/web/components/ui/select.tsx b/packages/ui/components/ui/select.tsx
similarity index 99%
rename from apps/web/components/ui/select.tsx
rename to packages/ui/components/ui/select.tsx
index e8021f5f28..2491aa5a8d 100644
--- a/apps/web/components/ui/select.tsx
+++ b/packages/ui/components/ui/select.tsx
@@ -3,7 +3,7 @@
import * as React from "react"
import { Select as SelectPrimitive } from "@base-ui/react/select"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
import { ChevronDownIcon, CheckIcon, ChevronUpIcon } from "lucide-react"
const Select = SelectPrimitive.Root
diff --git a/apps/web/components/ui/separator.tsx b/packages/ui/components/ui/separator.tsx
similarity index 92%
rename from apps/web/components/ui/separator.tsx
rename to packages/ui/components/ui/separator.tsx
index 6e1369e43c..790bb9bed4 100644
--- a/apps/web/components/ui/separator.tsx
+++ b/packages/ui/components/ui/separator.tsx
@@ -2,7 +2,7 @@
import { Separator as SeparatorPrimitive } from "@base-ui/react/separator"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Separator({
className,
diff --git a/apps/web/components/ui/sheet.tsx b/packages/ui/components/ui/sheet.tsx
similarity index 97%
rename from apps/web/components/ui/sheet.tsx
rename to packages/ui/components/ui/sheet.tsx
index 78c0a76494..b10762976f 100644
--- a/apps/web/components/ui/sheet.tsx
+++ b/packages/ui/components/ui/sheet.tsx
@@ -3,8 +3,8 @@
import * as React from "react"
import { Dialog as SheetPrimitive } from "@base-ui/react/dialog"
-import { cn } from "@/lib/utils"
-import { Button } from "@/components/ui/button"
+import { cn } from "@multica/ui/lib/utils"
+import { Button } from "@multica/ui/components/ui/button"
import { XIcon } from "lucide-react"
function Sheet({ ...props }: SheetPrimitive.Root.Props) {
diff --git a/apps/web/components/ui/sidebar.tsx b/packages/ui/components/ui/sidebar.tsx
similarity index 98%
rename from apps/web/components/ui/sidebar.tsx
rename to packages/ui/components/ui/sidebar.tsx
index 07cdf1efd4..e4b64762e4 100644
--- a/apps/web/components/ui/sidebar.tsx
+++ b/packages/ui/components/ui/sidebar.tsx
@@ -5,24 +5,24 @@ import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
-import { useIsMobile } from "@/hooks/use-mobile"
-import { cn } from "@/lib/utils"
-import { Button } from "@/components/ui/button"
-import { Input } from "@/components/ui/input"
-import { Separator } from "@/components/ui/separator"
+import { useIsMobile } from "@multica/ui/hooks/use-mobile"
+import { cn } from "@multica/ui/lib/utils"
+import { Button } from "@multica/ui/components/ui/button"
+import { Input } from "@multica/ui/components/ui/input"
+import { Separator } from "@multica/ui/components/ui/separator"
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
-} from "@/components/ui/sheet"
-import { Skeleton } from "@/components/ui/skeleton"
+} from "@multica/ui/components/ui/sheet"
+import { Skeleton } from "@multica/ui/components/ui/skeleton"
import {
Tooltip,
TooltipContent,
TooltipTrigger,
-} from "@/components/ui/tooltip"
+} from "@multica/ui/components/ui/tooltip"
import { PanelLeftIcon } from "lucide-react"
const SIDEBAR_COOKIE_NAME = "sidebar_state"
diff --git a/apps/web/components/ui/skeleton.tsx b/packages/ui/components/ui/skeleton.tsx
similarity index 84%
rename from apps/web/components/ui/skeleton.tsx
rename to packages/ui/components/ui/skeleton.tsx
index 0118624f6e..da90c642c9 100644
--- a/apps/web/components/ui/skeleton.tsx
+++ b/packages/ui/components/ui/skeleton.tsx
@@ -1,4 +1,4 @@
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
return (
diff --git a/apps/web/components/ui/slider.tsx b/packages/ui/components/ui/slider.tsx
similarity index 97%
rename from apps/web/components/ui/slider.tsx
rename to packages/ui/components/ui/slider.tsx
index 7384c7caa2..ec89ebc962 100644
--- a/apps/web/components/ui/slider.tsx
+++ b/packages/ui/components/ui/slider.tsx
@@ -3,7 +3,7 @@
import * as React from "react"
import { Slider as SliderPrimitive } from "@base-ui/react/slider"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Slider({
className,
diff --git a/apps/web/components/ui/sonner.tsx b/packages/ui/components/ui/sonner.tsx
similarity index 100%
rename from apps/web/components/ui/sonner.tsx
rename to packages/ui/components/ui/sonner.tsx
diff --git a/apps/web/components/ui/spinner.tsx b/packages/ui/components/ui/spinner.tsx
similarity index 86%
rename from apps/web/components/ui/spinner.tsx
rename to packages/ui/components/ui/spinner.tsx
index 91f6a63cd0..9b6c070751 100644
--- a/apps/web/components/ui/spinner.tsx
+++ b/packages/ui/components/ui/spinner.tsx
@@ -1,4 +1,4 @@
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
import { Loader2Icon } from "lucide-react"
function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
diff --git a/apps/web/components/ui/switch.tsx b/packages/ui/components/ui/switch.tsx
similarity index 97%
rename from apps/web/components/ui/switch.tsx
rename to packages/ui/components/ui/switch.tsx
index 9b8b44b1d1..75c5d42647 100644
--- a/apps/web/components/ui/switch.tsx
+++ b/packages/ui/components/ui/switch.tsx
@@ -2,7 +2,7 @@
import { Switch as SwitchPrimitive } from "@base-ui/react/switch"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Switch({
className,
diff --git a/apps/web/components/ui/table.tsx b/packages/ui/components/ui/table.tsx
similarity index 98%
rename from apps/web/components/ui/table.tsx
rename to packages/ui/components/ui/table.tsx
index 8dc13aee36..c0f8a15037 100644
--- a/apps/web/components/ui/table.tsx
+++ b/packages/ui/components/ui/table.tsx
@@ -2,7 +2,7 @@
import * as React from "react"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Table({ className, ...props }: React.ComponentProps<"table">) {
return (
diff --git a/apps/web/components/ui/tabs.tsx b/packages/ui/components/ui/tabs.tsx
similarity index 98%
rename from apps/web/components/ui/tabs.tsx
rename to packages/ui/components/ui/tabs.tsx
index 56c428888f..b2856216f0 100644
--- a/apps/web/components/ui/tabs.tsx
+++ b/packages/ui/components/ui/tabs.tsx
@@ -3,7 +3,7 @@
import { Tabs as TabsPrimitive } from "@base-ui/react/tabs"
import { cva, type VariantProps } from "class-variance-authority"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Tabs({
className,
diff --git a/apps/web/components/ui/textarea.tsx b/packages/ui/components/ui/textarea.tsx
similarity index 94%
rename from apps/web/components/ui/textarea.tsx
rename to packages/ui/components/ui/textarea.tsx
index 04d27f7d17..576be0a08d 100644
--- a/apps/web/components/ui/textarea.tsx
+++ b/packages/ui/components/ui/textarea.tsx
@@ -1,6 +1,6 @@
import * as React from "react"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
return (
diff --git a/apps/web/components/ui/toggle-group.tsx b/packages/ui/components/ui/toggle-group.tsx
similarity index 96%
rename from apps/web/components/ui/toggle-group.tsx
rename to packages/ui/components/ui/toggle-group.tsx
index 314f894a87..4fce9d1572 100644
--- a/apps/web/components/ui/toggle-group.tsx
+++ b/packages/ui/components/ui/toggle-group.tsx
@@ -5,8 +5,8 @@ import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
import { ToggleGroup as ToggleGroupPrimitive } from "@base-ui/react/toggle-group"
import { type VariantProps } from "class-variance-authority"
-import { cn } from "@/lib/utils"
-import { toggleVariants } from "@/components/ui/toggle"
+import { cn } from "@multica/ui/lib/utils"
+import { toggleVariants } from "@multica/ui/components/ui/toggle"
const ToggleGroupContext = React.createContext<
VariantProps<typeof toggleVariants> & {
diff --git a/apps/web/components/ui/toggle.tsx b/packages/ui/components/ui/toggle.tsx
similarity index 97%
rename from apps/web/components/ui/toggle.tsx
rename to packages/ui/components/ui/toggle.tsx
index f48e504709..88186674d6 100644
--- a/apps/web/components/ui/toggle.tsx
+++ b/packages/ui/components/ui/toggle.tsx
@@ -3,7 +3,7 @@
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
import { cva, type VariantProps } from "class-variance-authority"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
const toggleVariants = cva(
"group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
diff --git a/apps/web/components/ui/tooltip.tsx b/packages/ui/components/ui/tooltip.tsx
similarity index 98%
rename from apps/web/components/ui/tooltip.tsx
rename to packages/ui/components/ui/tooltip.tsx
index 69e8a822c0..588cb8681f 100644
--- a/apps/web/components/ui/tooltip.tsx
+++ b/packages/ui/components/ui/tooltip.tsx
@@ -2,7 +2,7 @@
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip"
-import { cn } from "@/lib/utils"
+import { cn } from "@multica/ui/lib/utils"
function TooltipProvider({
delay = 0,
diff --git a/apps/web/hooks/use-auto-scroll.ts b/packages/ui/hooks/use-auto-scroll.ts
similarity index 100%
rename from apps/web/hooks/use-auto-scroll.ts
rename to packages/ui/hooks/use-auto-scroll.ts
diff --git a/apps/web/hooks/use-mobile.ts b/packages/ui/hooks/use-mobile.ts
similarity index 100%
rename from apps/web/hooks/use-mobile.ts
rename to packages/ui/hooks/use-mobile.ts
diff --git a/apps/web/hooks/use-scroll-fade.ts b/packages/ui/hooks/use-scroll-fade.ts
similarity index 100%
rename from apps/web/hooks/use-scroll-fade.ts
rename to packages/ui/hooks/use-scroll-fade.ts
diff --git a/apps/web/lib/utils.ts b/packages/ui/lib/utils.ts
similarity index 100%
rename from apps/web/lib/utils.ts
rename to packages/ui/lib/utils.ts
diff --git a/packages/ui/markdown/CodeBlock.tsx b/packages/ui/markdown/CodeBlock.tsx
new file mode 100644
index 0000000000..68a59df854
--- /dev/null
+++ b/packages/ui/markdown/CodeBlock.tsx
@@ -0,0 +1,243 @@
+import * as React from 'react'
+import { codeToHtml, bundledLanguages, type BundledLanguage } from 'shiki'
+import { Copy, Check } from "lucide-react"
+import { Button } from "@multica/ui/components/ui/button"
+import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip"
+import { cn } from '@multica/ui/lib/utils'
+
+export interface CodeBlockProps {
+ code: string
+ language?: string
+ className?: string
+ /**
+ * Render mode affects code block styling:
+ * - 'terminal': Minimal, keeps control chars visible
+ * - 'minimal': Clean code, basic styling
+ * - 'full': Rich styling with background, copy button, etc.
+ */
+ mode?: 'terminal' | 'minimal' | 'full'
+}
+
+// Map common aliases to Shiki language names
+const LANGUAGE_ALIASES: Record<string, BundledLanguage> = {
+ js: 'javascript',
+ ts: 'typescript',
+ py: 'python',
+ sh: 'bash',
+ zsh: 'bash',
+ yml: 'yaml',
+ rb: 'ruby',
+ rs: 'rust',
+ kt: 'kotlin',
+ 'objective-c': 'objc',
+ objc: 'objc'
+}
+
+// Simple LRU cache for highlighted code
+const highlightCache = new Map<string, string>()
+const CACHE_MAX_SIZE = 200
+
+function getCacheKey(code: string, lang: string): string {
+ return `${lang}:${code}`
+}
+
+function isValidLanguage(lang: string): lang is BundledLanguage {
+ const normalized = LANGUAGE_ALIASES[lang] || lang
+ return normalized in bundledLanguages
+}
+
+/**
+ * CodeBlock - Syntax highlighted code block using Shiki
+ *
+ * Uses Shiki dual themes with CSS variables for light/dark switching.
+ * No JS-based dark mode detection needed — theme switching is handled
+ * entirely via CSS (see globals.css for .shiki/.dark .shiki rules).
+ *
+ * @see https://shiki.style/guide/dual-themes
+ */
+export function CodeBlock({
+ code,
+ language = 'text',
+ className,
+ mode = 'full'
+}: CodeBlockProps): React.JSX.Element {
+ const [highlighted, setHighlighted] = React.useState<string | null>(null)
+ const [isLoading, setIsLoading] = React.useState(true)
+ const [copied, setCopied] = React.useState(false)
+
+ // Resolve language alias - keep as string to allow 'text' fallback
+ const langLower = language.toLowerCase()
+ const resolvedLang: string = LANGUAGE_ALIASES[langLower] || langLower
+
+ React.useEffect(() => {
+ let cancelled = false
+
+ async function highlight(): Promise<void> {
+ const cacheKey = getCacheKey(code, resolvedLang)
+
+ const cached = highlightCache.get(cacheKey)
+ if (cached) {
+ if (!cancelled) {
+ setHighlighted(cached)
+ setIsLoading(false)
+ }
+ return
+ }
+
+ try {
+ // Use valid language or fallback to plaintext
+ const lang = isValidLanguage(resolvedLang) ? resolvedLang : 'text'
+
+ // Dual themes: Shiki outputs CSS variables for both themes in one pass.
+ // CSS handles switching via .dark selector (see globals.css).
+ const html = await codeToHtml(code, {
+ lang,
+ themes: {
+ light: 'github-light',
+ dark: 'github-dark',
+ },
+ defaultColor: false,
+ })
+
+ // Cache the result
+ if (highlightCache.size >= CACHE_MAX_SIZE) {
+ const firstKey = highlightCache.keys().next().value
+ if (firstKey) highlightCache.delete(firstKey)
+ }
+ highlightCache.set(cacheKey, html)
+
+ if (!cancelled) {
+ setHighlighted(html)
+ setIsLoading(false)
+ }
+ } catch (error) {
+ // Fallback to plain text on error
+ console.warn(`Shiki highlighting failed for language "${resolvedLang}":`, error)
+ if (!cancelled) {
+ setHighlighted(null)
+ setIsLoading(false)
+ }
+ }
+ }
+
+ highlight()
+
+ return () => {
+ cancelled = true
+ }
+ }, [code, resolvedLang])
+
+ const handleCopy = React.useCallback(async () => {
+ try {
+ await navigator.clipboard.writeText(code)
+ setCopied(true)
+ setTimeout(() => setCopied(false), 2000)
+ } catch (err) {
+ console.error('Failed to copy code:', err)
+ }
+ }, [code])
+
+ // Terminal mode: raw monospace with minimal styling
+ if (mode === 'terminal') {
+ return (
+ <pre className={cn('font-mono text-sm whitespace-pre-wrap', className)}>
+ <code className="font-mono">{code}</code>
+ </pre>
+ )
+ }
+
+ // Minimal mode: just syntax highlighting, no chrome
+ if (mode === 'minimal') {
+ if (isLoading || !highlighted) {
+ return (
+ <pre className={cn('font-mono text-sm whitespace-pre-wrap', className)}>
+ <code className="font-mono">{code}</code>
+ </pre>
+ )
+ }
+
+ return (
+ <div
+ className={cn(
+ 'font-mono text-sm [&_pre]:!bg-transparent [&_pre]:!p-0 [&_pre]:whitespace-pre-wrap [&_pre]:break-all [&_code]:!bg-transparent [&_code]:font-mono [&_pre]:font-mono',
+ className
+ )}
+ dangerouslySetInnerHTML={{ __html: highlighted }}
+ />
+ )
+ }
+
+ // Full mode: rich styling with header and copy button
+ return (
+ <div
+ className={cn(
+ 'relative group rounded-lg overflow-hidden border bg-muted/30 mb-4 last:mb-0',
+ className
+ )}
+ >
+ {/* Language label + copy button */}
+ <div className="flex items-center justify-between px-3 py-1.5 bg-muted/50 border-b text-xs">
+ <span className="text-muted-foreground font-medium uppercase tracking-wide">
+ {resolvedLang !== 'text' ? resolvedLang : 'plain text'}
+ </span>
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ onClick={handleCopy}
+ className="opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-foreground"
+ aria-label="Copy code"
+ >
+ {copied ? (
+ <Check className="size-3.5 text-success" />
+ ) : (
+ <Copy className="size-3.5" />
+ )}
+ </Button>
+ }
+ />
+ <TooltipContent>Copy code</TooltipContent>
+ </Tooltip>
+ </div>
+
+ {/* Code content */}
+ <div className="p-3 overflow-x-auto">
+ {isLoading || !highlighted ? (
+ <pre className="font-mono text-sm whitespace-pre-wrap break-all">
+ <code className="font-mono">{code}</code>
+ </pre>
+ ) : (
+ <div
+ className="font-mono text-sm [&_pre]:!bg-transparent [&_pre]:!m-0 [&_pre]:!p-0 [&_pre]:whitespace-pre-wrap [&_pre]:break-all [&_code]:!bg-transparent [&_code]:font-mono [&_pre]:font-mono"
+ dangerouslySetInnerHTML={{ __html: highlighted }}
+ />
+ )}
+ </div>
+ </div>
+ )
+}
+
+/**
+ * InlineCode - Styled inline code span
+ * Features: subtle background (3%), subtle border (5%), 75% opacity text
+ */
+export function InlineCode({
+ children,
+ className
+}: {
+ children: React.ReactNode
+ className?: string
+}): React.JSX.Element {
+ return (
+ <code
+ className={cn(
+ 'px-1.5 py-0.5 rounded bg-foreground/[0.03] border border-foreground/[0.05] font-mono text-sm text-foreground/75',
+ className
+ )}
+ >
+ {children}
+ </code>
+ )
+}
diff --git a/packages/ui/markdown/Markdown.tsx b/packages/ui/markdown/Markdown.tsx
new file mode 100644
index 0000000000..fedcc67c86
--- /dev/null
+++ b/packages/ui/markdown/Markdown.tsx
@@ -0,0 +1,358 @@
+import * as React from 'react'
+import ReactMarkdown, { type Components, defaultUrlTransform } from 'react-markdown'
+import rehypeRaw from 'rehype-raw'
+import remarkGfm from 'remark-gfm'
+import { cn } from '@multica/ui/lib/utils'
+import { CodeBlock, InlineCode } from './CodeBlock'
+import { preprocessLinks } from './linkify'
+import { preprocessMentionShortcodes } from './mentions'
+
+/**
+ * Render modes for markdown content:
+ *
+ * - 'terminal': Raw output with minimal formatting, control chars visible
+ * Best for: Debug output, raw logs, when you want to see exactly what's there
+ *
+ * - 'minimal': Clean rendering with syntax highlighting but no extra chrome
+ * Best for: Chat messages, inline content, when you want readability without clutter
+ *
+ * - 'full': Rich rendering with beautiful tables, styled code blocks, proper typography
+ * Best for: Documentation, long-form content, when presentation matters
+ */
+export type RenderMode = 'terminal' | 'minimal' | 'full'
+
+export interface MarkdownProps {
+ children: string
+ /**
+ * Render mode controlling formatting level
+ * @default 'minimal'
+ */
+ mode?: RenderMode
+ className?: string
+ /**
+ * Message ID for memoization (optional)
+ * When provided, memoizes parsed blocks to avoid re-parsing during streaming
+ */
+ id?: string
+ /**
+ * Callback when a URL is clicked
+ */
+ onUrlClick?: (url: string) => void
+ /**
+ * Callback when a file path is clicked
+ */
+ onFileClick?: (path: string) => void
+ /**
+ * Custom renderer for mention links (e.g. mention://issue/UUID).
+ * When not provided, mentions render as a simple styled span.
+ */
+ renderMention?: (props: { type: string; id: string }) => React.ReactNode
+}
+
+/**
+ * Custom URL transform that allows mention:// protocol (used for @mentions)
+ * while keeping the default security for all other URLs.
+ */
+function urlTransform(url: string): string {
+ if (url.startsWith('mention://')) return url
+ return defaultUrlTransform(url)
+}
+
+
+// File path detection regex - matches paths starting with /, ~/, or ./
+const FILE_PATH_REGEX =
+ /^(?:\/|~\/|\.\/)[\w\-./@]+\.(?:ts|tsx|js|jsx|mjs|cjs|md|json|yaml|yml|py|go|rs|css|scss|less|html|htm|txt|log|sh|bash|zsh|swift|kt|java|c|cpp|h|hpp|rb|php|xml|toml|ini|cfg|conf|env|sql|graphql|vue|svelte|astro|prisma)$/i
+
+/**
+ * Create custom components based on render mode
+ */
+function createComponents(
+ mode: RenderMode,
+ onUrlClick?: (url: string) => void,
+ onFileClick?: (path: string) => void,
+ renderMention?: (props: { type: string; id: string }) => React.ReactNode
+): Partial<Components> {
+ const baseComponents: Partial<Components> = {
+ // Images: render uploaded images with constrained sizing
+ img: ({ src, alt }) => (
+ <img
+ src={src}
+ alt={alt ?? ""}
+ className="max-w-full h-auto rounded-md my-2"
+ loading="lazy"
+ />
+ ),
+ // Links: Make clickable with callbacks, or render as mention
+ a: ({ href, children }) => {
+ // Mention links: mention://member/id, mention://agent/id, mention://issue/id, mention://all/all
+ if (href?.startsWith('mention://')) {
+ const mentionMatch = href.match(/^mention:\/\/(member|agent|issue|all)\/(.+)$/)
+ if (mentionMatch?.[1] && mentionMatch[2]) {
+ const type = mentionMatch[1]
+ const id = mentionMatch[2]
+
+ if (renderMention) {
+ return <>{renderMention({ type, id })}</>
+ }
+
+ // Fallback: render as a simple styled span
+ return (
+ <span className="text-primary font-semibold mx-0.5">
+ {children}
+ </span>
+ )
+ }
+ return (
+ <span className="text-primary font-semibold mx-0.5">
+ {children}
+ </span>
+ )
+ }
+
+ const handleClick = (e: React.MouseEvent): void => {
+ e.preventDefault()
+ if (href) {
+ // Check if it's a file path
+ if (FILE_PATH_REGEX.test(href) && onFileClick) {
+ onFileClick(href)
+ } else if (onUrlClick) {
+ onUrlClick(href)
+ } else {
+ // Default: open in new window
+ window.open(href, '_blank', 'noopener,noreferrer')
+ }
+ }
+ }
+
+ return (
+ <a
+ href={href}
+ onClick={handleClick}
+ className="text-primary hover:underline cursor-pointer"
+ >
+ {children}
+ </a>
+ )
+ }
+ }
+
+ // Terminal mode: minimal formatting
+ if (mode === 'terminal') {
+ return {
+ ...baseComponents,
+ // No special code handling - just monospace
+ code: ({ children }) => <code className="font-mono">{children}</code>,
+ pre: ({ children }) => <pre className="font-mono whitespace-pre-wrap my-2">{children}</pre>,
+ // Minimal paragraph spacing
+ p: ({ children }) => <p className="my-1">{children}</p>,
+ // Simple lists
+ ul: ({ children }) => <ul className="list-disc list-inside my-1">{children}</ul>,
+ ol: ({ children }) => <ol className="list-decimal list-inside my-1">{children}</ol>,
+ li: ({ children }) => <li className="my-0.5">{children}</li>,
+ // Plain tables
+ table: ({ children }) => <table className="my-2 font-mono text-sm">{children}</table>,
+ th: ({ children }) => <th className="text-left pr-4">{children}</th>,
+ td: ({ children }) => <td className="pr-4">{children}</td>
+ }
+ }
+
+ // Minimal mode: clean with syntax highlighting
+ if (mode === 'minimal') {
+ return {
+ ...baseComponents,
+ // Inline code
+ code: ({ className, children, ...props }) => {
+ const match = /language-(\w+)/.exec(className || '')
+ const isBlock =
+ 'node' in props && props.node?.position?.start.line !== props.node?.position?.end.line
+
+ // Block code - use CodeBlock with full mode
+ if (match || isBlock) {
+ const code = String(children).replace(/\n$/, '')
+ return <CodeBlock code={code} language={match?.[1]} mode="full" className="my-1" />
+ }
+
+ // Inline code
+ return <InlineCode>{children}</InlineCode>
+ },
+ pre: ({ children }) => <>{children}</>,
+ // Comfortable paragraph spacing
+ p: ({ children }) => <p className="my-2 leading-relaxed">{children}</p>,
+ // Styled lists
+ ul: ({ children }) => (
+ <ul className="my-2 space-y-1 ps-4 pe-2 list-disc marker:text-muted-foreground">
+ {children}
+ </ul>
+ ),
+ ol: ({ children }) => <ol className="my-2 space-y-1 pl-6 list-decimal">{children}</ol>,
+ li: ({ children }) => <li>{children}</li>,
+ // Clean tables
+ table: ({ children }) => (
+ <div className="my-3 overflow-x-auto">
+ <table className="min-w-full text-sm">{children}</table>
+ </div>
+ ),
+ thead: ({ children }) => <thead className="border-b">{children}</thead>,
+ th: ({ children }) => (
+ <th className="text-left py-2 px-3 font-semibold text-muted-foreground">{children}</th>
+ ),
+ td: ({ children }) => <td className="py-2 px-3 border-b border-border/50">{children}</td>,
+ // Headings - H1/H2 same size, differentiated by weight
+ h1: ({ children }) => <h1 className="font-sans text-base font-bold mt-5 mb-3">{children}</h1>,
+ h2: ({ children }) => (
+ <h2 className="font-sans text-base font-semibold mt-4 mb-3">{children}</h2>
+ ),
+ h3: ({ children }) => (
+ <h3 className="font-sans text-sm font-semibold mt-4 mb-2">{children}</h3>
+ ),
+ // Blockquotes
+ blockquote: ({ children }) => (
+ <blockquote className="border-l-2 border-muted-foreground/30 pl-3 my-2 text-muted-foreground italic">
+ {children}
+ </blockquote>
+ ),
+ // Horizontal rules
+ hr: () => <hr className="my-4 border-border" />,
+ // Strong/emphasis
+ strong: ({ children }) => <strong className="font-semibold">{children}</strong>,
+ em: ({ children }) => <em className="italic">{children}</em>
+ }
+ }
+
+ // Full mode: rich styling
+ return {
+ ...baseComponents,
+ // Full code blocks with copy button
+ code: ({ className, children, ...props }) => {
+ const match = /language-(\w+)/.exec(className || '')
+ const isBlock =
+ 'node' in props && props.node?.position?.start.line !== props.node?.position?.end.line
+
+ if (match || isBlock) {
+ const code = String(children).replace(/\n$/, '')
+ return <CodeBlock code={code} language={match?.[1]} mode="full" className="my-1" />
+ }
+
+ return <InlineCode>{children}</InlineCode>
+ },
+ pre: ({ children }) => <>{children}</>,
+ // Rich paragraph spacing
+ p: ({ children }) => <p className="my-3 leading-relaxed">{children}</p>,
+ // Styled lists
+ ul: ({ children }) => (
+ <ul className="my-3 space-y-1.5 ps-4 pe-2 list-disc marker:text-muted-foreground">
+ {children}
+ </ul>
+ ),
+ ol: ({ children }) => <ol className="my-3 space-y-1.5 pl-6 list-decimal">{children}</ol>,
+ li: ({ children }) => <li className="leading-relaxed">{children}</li>,
+ // Beautiful tables
+ table: ({ children }) => (
+ <div className="my-4 overflow-x-auto rounded-md border">
+ <table className="min-w-full divide-y divide-border">{children}</table>
+ </div>
+ ),
+ thead: ({ children }) => <thead className="bg-muted/50">{children}</thead>,
+ tbody: ({ children }) => <tbody className="divide-y divide-border">{children}</tbody>,
+ th: ({ children }) => <th className="text-left py-3 px-4 font-semibold text-sm">{children}</th>,
+ td: ({ children }) => <td className="py-3 px-4 text-sm">{children}</td>,
+ tr: ({ children }) => <tr className="hover:bg-muted/30 transition-colors">{children}</tr>,
+ // Rich headings
+ h1: ({ children }) => <h1 className="font-sans text-base font-bold mt-7 mb-4">{children}</h1>,
+ h2: ({ children }) => (
+ <h2 className="font-sans text-base font-semibold mt-6 mb-3">{children}</h2>
+ ),
+ h3: ({ children }) => <h3 className="font-sans text-sm font-semibold mt-5 mb-3">{children}</h3>,
+ h4: ({ children }) => <h4 className="text-sm font-semibold mt-3 mb-1">{children}</h4>,
+ // Styled blockquotes
+ blockquote: ({ children }) => (
+ <blockquote className="border-l-4 border-foreground/30 bg-muted/30 pl-4 pr-3 py-2 my-3 rounded-r-md">
+ {children}
+ </blockquote>
+ ),
+ // Task lists (GFM)
+ input: ({ type, checked }) => {
+ if (type === 'checkbox') {
+ return (
+ <input
+ type="checkbox"
+ checked={checked}
+ readOnly
+ className="mr-2 rounded border-muted-foreground"
+ />
+ )
+ }
+ return <input type={type} />
+ },
+ // Horizontal rules
+ hr: () => <hr className="my-6 border-border" />,
+ // Strong/emphasis
+ strong: ({ children }) => <strong className="font-semibold">{children}</strong>,
+ em: ({ children }) => <em className="italic">{children}</em>,
+ del: ({ children }) => <del className="line-through text-muted-foreground">{children}</del>
+ }
+}
+
+/**
+ * Markdown - Customizable markdown renderer with multiple render modes
+ *
+ * Features:
+ * - Three render modes: terminal, minimal, full
+ * - Syntax highlighting via Shiki
+ * - GFM support (tables, task lists, strikethrough)
+ * - Clickable links and file paths
+ * - Memoization for streaming performance
+ * - Pluggable mention rendering via renderMention prop
+ */
+export function Markdown({
+ children,
+ mode = 'minimal',
+ className,
+ onUrlClick,
+ onFileClick,
+ renderMention
+}: MarkdownProps): React.JSX.Element {
+ const components = React.useMemo(
+ () => createComponents(mode, onUrlClick, onFileClick, renderMention),
+ [mode, onUrlClick, onFileClick, renderMention]
+ )
+
+ // Preprocess: convert mention shortcodes and raw URLs/file paths to markdown links
+ const processedContent = React.useMemo(
+ () => preprocessLinks(preprocessMentionShortcodes(children)),
+ [children]
+ )
+
+ return (
+ <div className={cn('markdown-content break-words', className)}>
+ <ReactMarkdown
+ remarkPlugins={[[remarkGfm, { singleTilde: false }]]}
+ rehypePlugins={[rehypeRaw]}
+ urlTransform={urlTransform}
+ components={components}
+ >
+ {processedContent}
+ </ReactMarkdown>
+ </div>
+ )
+}
+
+/**
+ * MemoizedMarkdown - Optimized for streaming scenarios
+ *
+ * Splits content into blocks and memoizes each block separately,
+ * so only new/changed blocks re-render during streaming.
+ */
+export const MemoizedMarkdown = React.memo(Markdown, (prevProps, nextProps) => {
+ // If id is provided, use it for memoization
+ if (prevProps.id && nextProps.id) {
+ return (
+ prevProps.id === nextProps.id &&
+ prevProps.children === nextProps.children &&
+ prevProps.mode === nextProps.mode
+ )
+ }
+ // Otherwise compare content and mode
+ return prevProps.children === nextProps.children && prevProps.mode === nextProps.mode
+})
+MemoizedMarkdown.displayName = 'MemoizedMarkdown'
diff --git a/packages/ui/markdown/StreamingMarkdown.tsx b/packages/ui/markdown/StreamingMarkdown.tsx
new file mode 100644
index 0000000000..d0e7051e98
--- /dev/null
+++ b/packages/ui/markdown/StreamingMarkdown.tsx
@@ -0,0 +1,230 @@
+import * as React from 'react'
+import { Markdown, type RenderMode } from './Markdown'
+
+export interface StreamingMarkdownProps {
+ content: string
+ isStreaming: boolean
+ mode?: RenderMode
+ className?: string
+ onUrlClick?: (url: string) => void
+ onFileClick?: (path: string) => void
+ renderMention?: (props: { type: string; id: string }) => React.ReactNode
+}
+
+interface Block {
+ content: string
+ isCodeBlock: boolean
+}
+
+/**
+ * djb2 hash (XOR variant) by Daniel J. Bernstein.
+ * Used to generate stable React keys for completed content blocks.
+ *
+ * - 5381: empirically chosen initial value that produces fewer collisions
+ * - (hash << 5) + hash: equivalent to hash * 33
+ * - ^ charCode: XOR variant, favored by Bernstein over additive version
+ * - >>> 0: convert to unsigned 32-bit integer
+ *
+ * Not cryptographic — just fast with good distribution for short strings.
+ * @see http://www.cse.yorku.ca/~oz/hash.html
+ */
+function simpleHash(str: string): string {
+ let hash = 5381
+ for (let i = 0; i < str.length; i++) {
+ hash = ((hash << 5) + hash) ^ str.charCodeAt(i)
+ }
+ return (hash >>> 0).toString(36)
+}
+
+/**
+ * Split content into blocks (paragraphs and code blocks)
+ *
+ * Block boundaries:
+ * - Double newlines (paragraph separators)
+ * - Code fences (```)
+ *
+ * This is intentionally simple - just string scanning, no regex per line.
+ */
+function splitIntoBlocks(content: string): Block[] {
+ const blocks: Block[] = []
+ const lines = content.split('\n')
+ let currentBlock = ''
+ let inCodeBlock = false
+ let inMathBlock = false
+
+ for (let i = 0; i < lines.length; i++) {
+ const line = lines[i] ?? ''
+
+ // Check for code fence (``` at start of line, optionally followed by language)
+ if (line.startsWith('```')) {
+ if (!inCodeBlock) {
+ // Starting a code block - flush current paragraph first
+ if (currentBlock.trim()) {
+ blocks.push({ content: currentBlock.trim(), isCodeBlock: false })
+ currentBlock = ''
+ }
+ inCodeBlock = true
+ currentBlock = line + '\n'
+ } else {
+ // Ending a code block
+ currentBlock += line
+ blocks.push({ content: currentBlock, isCodeBlock: true })
+ currentBlock = ''
+ inCodeBlock = false
+ }
+ } else if (inCodeBlock) {
+ // Inside code block - append line
+ currentBlock += line + '\n'
+ // Check for display math fence ($$)
+ } else if (line.trim() === '$$') {
+ if (!inMathBlock) {
+ // Starting a math block - flush current paragraph first
+ if (currentBlock.trim()) {
+ blocks.push({ content: currentBlock.trim(), isCodeBlock: false })
+ currentBlock = ''
+ }
+ inMathBlock = true
+ currentBlock = line + '\n'
+ } else {
+ // Ending a math block
+ currentBlock += line
+ blocks.push({ content: currentBlock, isCodeBlock: false })
+ currentBlock = ''
+ inMathBlock = false
+ }
+ } else if (inMathBlock) {
+ // Inside math block - append line (don't split on blank lines)
+ currentBlock += line + '\n'
+ } else if (line === '') {
+ // Empty line outside code block = paragraph boundary
+ if (currentBlock.trim()) {
+ blocks.push({ content: currentBlock.trim(), isCodeBlock: false })
+ currentBlock = ''
+ }
+ } else {
+ // Regular text line
+ if (currentBlock) {
+ currentBlock += '\n' + line
+ } else {
+ currentBlock = line
+ }
+ }
+ }
+
+ // Flush remaining content
+ if (currentBlock) {
+ blocks.push({
+ content: inCodeBlock || inMathBlock ? currentBlock : currentBlock.trim(),
+ isCodeBlock: inCodeBlock
+ })
+ }
+
+ return blocks
+}
+
+/**
+ * Memoized block component
+ *
+ * Only re-renders if content or mode changes.
+ * The key is assigned by the parent based on content hash,
+ * so identical content won't even attempt to render.
+ */
+const MemoizedBlock = React.memo(
+ function Block({
+ content,
+ mode,
+ className,
+ onUrlClick,
+ onFileClick,
+ renderMention
+ }: {
+ content: string
+ mode: RenderMode
+ className?: string
+ onUrlClick?: (url: string) => void
+ onFileClick?: (path: string) => void
+ renderMention?: (props: { type: string; id: string }) => React.ReactNode
+ }) {
+ return (
+ <Markdown mode={mode} className={className} onUrlClick={onUrlClick} onFileClick={onFileClick} renderMention={renderMention}>
+ {content}
+ </Markdown>
+ )
+ },
+ (prev, next) => {
+ // Only re-render if content actually changed
+ return prev.content === next.content && prev.mode === next.mode && prev.className === next.className
+ }
+)
+MemoizedBlock.displayName = 'MemoizedBlock'
+
+/**
+ * StreamingMarkdown - Optimized markdown renderer for streaming content
+ *
+ * Splits content into blocks (paragraphs, code blocks) and memoizes each block
+ * independently. Only the last (active) block re-renders during streaming.
+ *
+ * Key insight: Completed blocks get a content-hash as their React key.
+ * Same content = same key = React skips re-render entirely.
+ *
+ * @example
+ * Content: "Hello\n\n```js\ncode\n```\n\nMore..."
+ *
+ * Block 1: "Hello" -> key="block-abc123" -> memoized
+ * Block 2: "```js\ncode\n```" -> key="block-xyz789" -> memoized
+ * Block 3: "More..." -> key="active-2" -> re-renders
+ */
+export function StreamingMarkdown({
+ content,
+ isStreaming,
+ mode = 'minimal',
+ className,
+ onUrlClick,
+ onFileClick,
+ renderMention
+}: StreamingMarkdownProps): React.JSX.Element {
+ // Split into blocks - memoized to avoid recomputation
+ // Must be called unconditionally to satisfy Rules of Hooks
+ const blocks = React.useMemo(
+ () => (isStreaming ? splitIntoBlocks(content) : []),
+ [content, isStreaming]
+ )
+
+ // Not streaming - use simple Markdown (no block splitting needed)
+ if (!isStreaming) {
+ return (
+ <Markdown mode={mode} className={className} onUrlClick={onUrlClick} onFileClick={onFileClick} renderMention={renderMention}>
+ {content}
+ </Markdown>
+ )
+ }
+
+ // Empty content - return null, let parent handle loading indicator
+ if (blocks.length === 0) {
+ return <></>
+ }
+
+ return (
+ <>
+ {blocks.map((block, i) => {
+ const isLastBlock = i === blocks.length - 1
+
+ // Complete blocks use content hash as key -> stable identity -> memoized
+ // Last block uses "active" prefix -> always re-renders on content change
+ const key = isLastBlock ? `active-${i}` : `block-${i}-${simpleHash(block.content)}`
+
+ return (
+ <MemoizedBlock
+ key={key}
+ content={block.content}
+ mode={mode}
+ className={className}
+ onUrlClick={onUrlClick}
+ onFileClick={onFileClick}
+ renderMention={renderMention}
+ />
+ )
+ })}
+ </>
+ )
+}
diff --git a/packages/ui/markdown/index.ts b/packages/ui/markdown/index.ts
new file mode 100644
index 0000000000..7d05984d00
--- /dev/null
+++ b/packages/ui/markdown/index.ts
@@ -0,0 +1,5 @@
+export { Markdown, MemoizedMarkdown, type MarkdownProps, type RenderMode } from './Markdown'
+export { CodeBlock, InlineCode, type CodeBlockProps } from './CodeBlock'
+export { StreamingMarkdown, type StreamingMarkdownProps } from './StreamingMarkdown'
+export { preprocessLinks, detectLinks, hasLinks } from './linkify'
+export { preprocessMentionShortcodes } from './mentions'
diff --git a/packages/ui/markdown/linkify.ts b/packages/ui/markdown/linkify.ts
new file mode 100644
index 0000000000..f4ee1809d0
--- /dev/null
+++ b/packages/ui/markdown/linkify.ts
@@ -0,0 +1,215 @@
+import LinkifyIt from 'linkify-it'
+
+/**
+ * Linkify - URL and file path detection for markdown preprocessing
+ *
+ * Uses linkify-it (12M downloads/week) for battle-tested URL detection,
+ * plus custom regex for local file paths.
+ */
+
+// Initialize linkify-it with default settings (fuzzy URLs, emails enabled)
+const linkify = new LinkifyIt()
+
+// File path regex - detects /path, ~/path, ./path with common extensions
+// Matches paths that start with /, ~/, or ./ followed by path chars and a file extension
+const FILE_PATH_REGEX =
+ /(?:^|[\s([{<])((\/|~\/|\.\/)[\w\-./@]+\.(?:ts|tsx|js|jsx|mjs|cjs|md|json|yaml|yml|py|go|rs|css|scss|less|html|htm|txt|log|sh|bash|zsh|swift|kt|java|c|cpp|h|hpp|rb|php|xml|toml|ini|cfg|conf|env|sql|graphql|vue|svelte|astro|prisma|dockerfile|makefile|gitignore))(?=[\s)\]}.,;:!?>]|$)/gi
+
+interface DetectedLink {
+ type: 'url' | 'email' | 'file'
+ text: string
+ url: string
+ start: number
+ end: number
+}
+
+interface CodeRange {
+ start: number
+ end: number
+}
+
+/**
+ * Find all code block and inline code ranges in text
+ * These ranges should be excluded from link detection
+ */
+function findCodeRanges(text: string): CodeRange[] {
+ const ranges: CodeRange[] = []
+
+ // Find fenced code blocks (```...```)
+ const fencedRegex = /```[\s\S]*?```/g
+ let match
+ while ((match = fencedRegex.exec(text)) !== null) {
+ ranges.push({ start: match.index, end: match.index + match[0].length })
+ }
+
+ // Find display math blocks ($$...$$)
+ const displayMathRegex = /\$\$[\s\S]*?\$\$/g
+ while ((match = displayMathRegex.exec(text)) !== null) {
+ const pos = match.index
+ const insideOther = ranges.some((r) => pos >= r.start && pos < r.end)
+ if (!insideOther) {
+ ranges.push({ start: pos, end: pos + match[0].length })
+ }
+ }
+
+ // Find inline math ($...$)
+ const inlineMathRegex = /(?<!\$)\$(?!\$)([^\$\n]+)\$(?!\$)/g
+ while ((match = inlineMathRegex.exec(text)) !== null) {
+ const pos = match.index
+ const insideOther = ranges.some((r) => pos >= r.start && pos < r.end)
+ if (!insideOther) {
+ ranges.push({ start: pos, end: pos + match[0].length })
+ }
+ }
+
+ // Find inline code (`...`)
+ // But skip escaped backticks and code inside fenced blocks
+ const inlineRegex = /(?<!`)`(?!`)([^`\n]+)`(?!`)/g
+ while ((match = inlineRegex.exec(text)) !== null) {
+ const pos = match.index
+ // Check if this is inside a fenced block or math block
+ const insideOther = ranges.some((r) => pos >= r.start && pos < r.end)
+ if (!insideOther) {
+ ranges.push({ start: pos, end: pos + match[0].length })
+ }
+ }
+
+ return ranges
+}
+
+/**
+ * Check if a position is inside any code range
+ */
+function isInsideCode(pos: number, ranges: CodeRange[]): boolean {
+ return ranges.some((r) => pos >= r.start && pos < r.end)
+}
+
+/**
+ * Check if a link at given position is already a markdown link
+ * Looks for patterns like [text](url) or [text][ref]
+ */
+function isAlreadyLinked(text: string, linkStart: number, linkEnd: number): boolean {
+ // Check if preceded by ]( which indicates we're inside a markdown link href
+ // Pattern: [text](URL) - we're checking if URL is our link
+ const before = text.slice(Math.max(0, linkStart - 2), linkStart)
+ if (before.endsWith('](')) return true
+
+ // Check if preceded by ][ for reference links
+ if (before.endsWith('][')) return true
+
+ // Check if the link text is wrapped in []
+ // Pattern: [URL](href) - URL is being used as link text
+ const charBefore = text[linkStart - 1]
+ const charAfter = text[linkEnd]
+ if (charBefore === '[' && charAfter === ']') return true
+
+ return false
+}
+
+/**
+ * Check if ranges overlap
+ */
+function rangesOverlap(
+ a: { start: number; end: number },
+ b: { start: number; end: number }
+): boolean {
+ return a.start < b.end && b.start < a.end
+}
+
+/**
+ * Detect all links (URLs, emails, file paths) in text
+ */
+export function detectLinks(text: string): DetectedLink[] {
+ const links: DetectedLink[] = []
+
+ // 1. Detect URLs and emails with linkify-it
+ const urlMatches = linkify.match(text) || []
+ for (const match of urlMatches) {
+ links.push({
+ type: match.schema === 'mailto:' ? 'email' : 'url',
+ text: match.text,
+ url: match.url,
+ start: match.index,
+ end: match.lastIndex
+ })
+ }
+
+ // 2. Detect file paths with custom regex
+ // Reset regex state
+ FILE_PATH_REGEX.lastIndex = 0
+ let fileMatch
+ while ((fileMatch = FILE_PATH_REGEX.exec(text)) !== null) {
+ const path = fileMatch[1]
+ if (!path) continue // Skip if no capture group
+
+ // Calculate actual start position (after any leading whitespace/punctuation)
+ const fullMatch = fileMatch[0]
+ const pathOffset = fullMatch.indexOf(path)
+ const start = fileMatch.index + pathOffset
+
+ // Check for overlaps with URL matches (URLs take precedence)
+ const pathRange = { start, end: start + path.length }
+ const overlapsUrl = links.some((link) => rangesOverlap(pathRange, link))
+ if (overlapsUrl) continue
+
+ links.push({
+ type: 'file',
+ text: path,
+ url: path, // File paths are passed as-is to onFileClick handler
+ start,
+ end: start + path.length
+ })
+ }
+
+ // Sort by position
+ return links.sort((a, b) => a.start - b.start)
+}
+
+/**
+ * Preprocess text to convert raw URLs and file paths into markdown links
+ * Skips code blocks and already-linked content
+ */
+export function preprocessLinks(text: string): string {
+ // Quick check - if no potential links, return early
+ if (!linkify.pretest(text) && !/[~/.]\//.test(text)) {
+ return text
+ }
+
+ const codeRanges = findCodeRanges(text)
+ const links = detectLinks(text)
+
+ if (links.length === 0) return text
+
+ // Build result, converting raw links to markdown links
+ let result = ''
+ let lastIndex = 0
+
+ for (const link of links) {
+ // Skip if inside code block
+ if (isInsideCode(link.start, codeRanges)) continue
+
+ // Skip if already a markdown link
+ if (isAlreadyLinked(text, link.start, link.end)) continue
+
+ // Add text before this link
+ result += text.slice(lastIndex, link.start)
+
+ // Convert to markdown link
+ result += `[${link.text}](${link.url})`
+
+ lastIndex = link.end
+ }
+
+ // Add remaining text
+ result += text.slice(lastIndex)
+
+ return result
+}
+
+/**
+ * Test if text contains any detectable links
+ * Useful for optimization - skip preprocessing if no links present
+ */
+export function hasLinks(text: string): boolean {
+ return linkify.pretest(text) || /[~/.]\/[\w]/.test(text)
+}
diff --git a/packages/ui/markdown/mentions.ts b/packages/ui/markdown/mentions.ts
new file mode 100644
index 0000000000..06b041dfd7
--- /dev/null
+++ b/packages/ui/markdown/mentions.ts
@@ -0,0 +1,25 @@
+/**
+ * Convert legacy mention shortcodes [@ id="UUID" label="LABEL"] to the
+ * standard markdown link format [@LABEL](mention://member/UUID).
+ *
+ * These shortcodes exist in older database records from a previous mention
+ * serialization format. This function normalises them so downstream parsers
+ * (Tiptap @tiptap/markdown, react-markdown) only need to handle one syntax.
+ */
+export function preprocessMentionShortcodes(text: string): string {
+ if (!text.includes("[@ ")) return text;
+ return text.replace(
+ /\[@\s+([^\]]*)\]/g,
+ (match, attrString: string) => {
+ const attrs: Record<string, string> = {};
+ const re = /(\w+)="([^"]*)"/g;
+ let m;
+ while ((m = re.exec(attrString)) !== null) {
+ if (m[1] && m[2] !== undefined) attrs[m[1]] = m[2];
+ }
+ const { id, label } = attrs;
+ if (!id || !label) return match;
+ return `[@${label}](mention://member/${id})`;
+ },
+ );
+}
diff --git a/packages/ui/package.json b/packages/ui/package.json
new file mode 100644
index 0000000000..7718afad66
--- /dev/null
+++ b/packages/ui/package.json
@@ -0,0 +1,53 @@
+{
+ "name": "@multica/ui",
+ "version": "0.0.0",
+ "private": true,
+ "type": "module",
+ "exports": {
+ "./components/ui/*": "./components/ui/*.tsx",
+ "./components/common/*": "./components/common/*.tsx",
+ "./markdown": "./markdown/index.ts",
+ "./markdown/*": "./markdown/*.tsx",
+ "./markdown/linkify": "./markdown/linkify.ts",
+ "./markdown/mentions": "./markdown/mentions.ts",
+ "./hooks/*": "./hooks/*.ts",
+ "./lib/utils": "./lib/utils.ts",
+ "./styles/tokens.css": "./styles/tokens.css"
+ },
+ "dependencies": {
+ "@base-ui/react": "^1.3.0",
+ "@emoji-mart/data": "^1.2.1",
+ "class-variance-authority": "catalog:",
+ "clsx": "catalog:",
+ "cmdk": "^1.1.1",
+ "date-fns": "^4.1.0",
+ "embla-carousel-react": "^8.6.0",
+ "emoji-mart": "^5.6.0",
+ "input-otp": "^1.4.2",
+ "linkify-it": "^5.0.0",
+ "lucide-react": "catalog:",
+ "next-themes": "^0.4.6",
+ "react-day-picker": "^9.14.0",
+ "react-markdown": "^10.1.0",
+ "react-resizable-panels": "^4.7.5",
+ "recharts": "3.8.0",
+ "rehype-raw": "^7.0.0",
+ "remark-gfm": "^4.0.1",
+ "shiki": "^3.21.0",
+ "sonner": "^2.0.7",
+ "tailwind-merge": "catalog:",
+ "tw-animate-css": "^1.4.0",
+ "vaul": "^1.1.2"
+ },
+ "peerDependencies": {
+ "react": "catalog:",
+ "react-dom": "catalog:"
+ },
+ "devDependencies": {
+ "@multica/tsconfig": "workspace:*",
+ "@types/linkify-it": "^5.0.0",
+ "@types/react": "catalog:",
+ "@types/react-dom": "catalog:",
+ "typescript": "catalog:"
+ }
+}
diff --git a/packages/ui/styles/tokens.css b/packages/ui/styles/tokens.css
new file mode 100644
index 0000000000..67d09fe858
--- /dev/null
+++ b/packages/ui/styles/tokens.css
@@ -0,0 +1,141 @@
+/* Multica design tokens — shared across Web + Desktop */
+
+@theme inline {
+ --font-heading: var(--font-sans);
+ --font-sans: var(--font-sans);
+ --font-mono: var(--font-mono);
+ --color-sidebar-ring: var(--sidebar-ring);
+ --color-sidebar-border: var(--sidebar-border);
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
+ --color-sidebar-accent: var(--sidebar-accent);
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
+ --color-sidebar-primary: var(--sidebar-primary);
+ --color-sidebar-foreground: var(--sidebar-foreground);
+ --color-sidebar: var(--sidebar);
+ --color-chart-5: var(--chart-5);
+ --color-chart-4: var(--chart-4);
+ --color-chart-3: var(--chart-3);
+ --color-chart-2: var(--chart-2);
+ --color-chart-1: var(--chart-1);
+ --color-ring: var(--ring);
+ --color-input: var(--input);
+ --color-border: var(--border);
+ --color-destructive: var(--destructive);
+ --color-success: var(--success);
+ --color-warning: var(--warning);
+ --color-info: var(--info);
+ --color-brand: var(--brand);
+ --color-brand-foreground: var(--brand-foreground);
+ --color-priority: var(--priority);
+ --color-canvas: var(--canvas);
+ --color-accent-foreground: var(--accent-foreground);
+ --color-accent: var(--accent);
+ --color-muted-foreground: var(--muted-foreground);
+ --color-muted: var(--muted);
+ --color-secondary-foreground: var(--secondary-foreground);
+ --color-secondary: var(--secondary);
+ --color-primary-foreground: var(--primary-foreground);
+ --color-primary: var(--primary);
+ --color-popover-foreground: var(--popover-foreground);
+ --color-popover: var(--popover);
+ --color-card-foreground: var(--card-foreground);
+ --color-card: var(--card);
+ --color-foreground: var(--foreground);
+ --color-background: var(--background);
+ --radius-sm: calc(var(--radius) * 0.6);
+ --radius-md: calc(var(--radius) * 0.8);
+ --radius-lg: var(--radius);
+ --radius-xl: calc(var(--radius) * 1.4);
+ --radius-2xl: calc(var(--radius) * 1.8);
+ --radius-3xl: calc(var(--radius) * 2.2);
+ --radius-4xl: calc(var(--radius) * 2.6);
+}
+
+:root {
+ --background: oklch(1 0 0);
+ --foreground: oklch(0.141 0.005 285.823);
+ --card: oklch(1 0 0);
+ --card-foreground: oklch(0.141 0.005 285.823);
+ --popover: oklch(1 0 0);
+ --popover-foreground: oklch(0.141 0.005 285.823);
+ --primary: oklch(0.21 0.006 285.885);
+ --primary-foreground: oklch(0.985 0 0);
+ --secondary: oklch(0.967 0.001 286.375);
+ --secondary-foreground: oklch(0.21 0.006 285.885);
+ --muted: oklch(0.967 0.001 286.375);
+ --muted-foreground: oklch(0.552 0.016 285.938);
+ --accent: oklch(0.967 0.001 286.375);
+ --accent-foreground: oklch(0.21 0.006 285.885);
+ --destructive: oklch(0.577 0.245 27.325);
+ --border: oklch(0.92 0.004 286.32);
+ --input: oklch(0.92 0.004 286.32);
+ --ring: oklch(0.705 0.015 286.067);
+ --chart-1: oklch(0.871 0.006 286.286);
+ --chart-2: oklch(0.552 0.016 285.938);
+ --chart-3: oklch(0.442 0.017 285.786);
+ --chart-4: oklch(0.37 0.013 285.805);
+ --chart-5: oklch(0.274 0.006 286.033);
+ --radius: 0.625rem;
+ --sidebar: oklch(0.985 0 0);
+ --sidebar-foreground: oklch(0.141 0.005 285.823);
+ --sidebar-primary: oklch(0.21 0.006 285.885);
+ --sidebar-primary-foreground: oklch(0.985 0 0);
+ --sidebar-accent: oklch(0.95 0.002 286.375);
+ --sidebar-accent-foreground: oklch(0.21 0.006 285.885);
+ --sidebar-border: oklch(0.92 0.004 286.32);
+ --sidebar-ring: oklch(0.705 0.015 286.067);
+ --brand: oklch(0.55 0.16 255);
+ --brand-foreground: oklch(0.985 0 0);
+ --canvas: oklch(0.95 0.002 286);
+ --success: oklch(0.55 0.16 145);
+ --warning: oklch(0.75 0.16 85);
+ --info: oklch(0.55 0.18 250);
+ --priority: oklch(0.65 0.18 50);
+ --scrollbar-thumb: oklch(0 0 0 / 10%);
+ --scrollbar-thumb-hover: oklch(0 0 0 / 18%);
+ --scrollbar-track: transparent;
+}
+
+.dark {
+ --background: oklch(0.18 0.005 285.823);
+ --foreground: oklch(0.985 0 0);
+ --card: oklch(0.21 0.006 285.885);
+ --card-foreground: oklch(0.985 0 0);
+ --popover: oklch(0.21 0.006 285.885);
+ --popover-foreground: oklch(0.985 0 0);
+ --primary: oklch(0.92 0.004 286.32);
+ --primary-foreground: oklch(0.21 0.006 285.885);
+ --secondary: oklch(0.274 0.006 286.033);
+ --secondary-foreground: oklch(0.985 0 0);
+ --muted: oklch(0.274 0.006 286.033);
+ --muted-foreground: oklch(0.705 0.015 286.067);
+ --accent: oklch(0.274 0.006 286.033);
+ --accent-foreground: oklch(0.985 0 0);
+ --destructive: oklch(0.704 0.191 22.216);
+ --border: oklch(1 0 0 / 10%);
+ --input: oklch(1 0 0 / 15%);
+ --ring: oklch(0.552 0.016 285.938);
+ --chart-1: oklch(0.871 0.006 286.286);
+ --chart-2: oklch(0.552 0.016 285.938);
+ --chart-3: oklch(0.442 0.017 285.786);
+ --chart-4: oklch(0.37 0.013 285.805);
+ --chart-5: oklch(0.274 0.006 286.033);
+ --sidebar: oklch(0.21 0.006 285.885);
+ --sidebar-foreground: oklch(0.985 0 0);
+ --sidebar-primary: oklch(0.488 0.243 264.376);
+ --sidebar-primary-foreground: oklch(0.985 0 0);
+ --sidebar-accent: oklch(0.274 0.006 286.033);
+ --sidebar-accent-foreground: oklch(0.985 0 0);
+ --sidebar-border: oklch(1 0 0 / 10%);
+ --sidebar-ring: oklch(0.552 0.016 285.938);
+ --brand: oklch(0.65 0.16 255);
+ --brand-foreground: oklch(0.985 0 0);
+ --canvas: oklch(0.2 0.005 286);
+ --success: oklch(0.65 0.15 145);
+ --warning: oklch(0.70 0.16 85);
+ --info: oklch(0.65 0.18 250);
+ --priority: oklch(0.70 0.18 50);
+ --scrollbar-thumb: oklch(1 0 0 / 8%);
+ --scrollbar-thumb-hover: oklch(1 0 0 / 18%);
+ --scrollbar-track: transparent;
+}
diff --git a/packages/ui/tsconfig.json b/packages/ui/tsconfig.json
new file mode 100644
index 0000000000..d5c672bb31
--- /dev/null
+++ b/packages/ui/tsconfig.json
@@ -0,0 +1,14 @@
+{
+ "extends": "@multica/tsconfig/react-library.json",
+ "compilerOptions": {
+ "outDir": "dist",
+ "rootDir": ".",
+ "paths": {
+ "@/lib/utils": ["./lib/utils.ts"],
+ "@/hooks/*": ["./hooks/*"],
+ "@/components/ui/*": ["./components/ui/*"]
+ }
+ },
+ "include": ["**/*.ts", "**/*.tsx"],
+ "exclude": ["node_modules", "dist"]
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index c6fa8c2319..992ad416f5 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -15,6 +15,12 @@ catalogs:
'@types/node':
specifier: ^25.0.10
version: 25.5.0
+ class-variance-authority:
+ specifier: ^0.7.1
+ version: 0.7.1
+ clsx:
+ specifier: ^2.1.1
+ version: 2.1.1
lucide-react:
specifier: ^1.0.1
version: 1.0.1
@@ -24,6 +30,9 @@ catalogs:
react-dom:
specifier: 19.2.3
version: 19.2.3
+ tailwind-merge:
+ specifier: ^3.4.0
+ version: 3.5.0
tailwindcss:
specifier: ^4
version: 4.2.2
@@ -284,6 +293,100 @@ importers:
packages/tsconfig: {}
+ packages/ui:
+ dependencies:
+ '@base-ui/react':
+ specifier: ^1.3.0
+ '@emoji-mart/data':
+ specifier: ^1.2.1
+ version: 1.2.1
+ class-variance-authority:
+ specifier: 'catalog:'
+ version: 0.7.1
+ clsx:
+ specifier: 'catalog:'
+ version: 2.1.1
+ cmdk:
+ specifier: ^1.1.1
+ date-fns:
+ specifier: ^4.1.0
+ version: 4.1.0
+ embla-carousel-react:
+ specifier: ^8.6.0
+ version: 8.6.0([email protected])
+ emoji-mart:
+ specifier: ^5.6.0
+ version: 5.6.0
+ input-otp:
+ specifier: ^1.4.2
+ linkify-it:
+ specifier: ^5.0.0
+ version: 5.0.0
+ lucide-react:
+ specifier: 'catalog:'
+ version: 1.0.1([email protected])
+ next-themes:
+ specifier: ^0.4.6
+ react:
+ specifier: 'catalog:'
+ version: 19.2.3
+ react-day-picker:
+ specifier: ^9.14.0
+ version: 9.14.0([email protected])
+ react-dom:
+ specifier: 'catalog:'
+ version: 19.2.3([email protected])
+ react-markdown:
+ specifier: ^10.1.0
+ version: 10.1.0(@types/[email protected])([email protected])
+ react-resizable-panels:
+ specifier: ^4.7.5
+ recharts:
+ specifier: 3.8.0
+ rehype-raw:
+ specifier: ^7.0.0
+ version: 7.0.0
+ remark-gfm:
+ specifier: ^4.0.1
+ version: 4.0.1
+ shiki:
+ specifier: ^3.21.0
+ version: 3.23.0
+ sonner:
+ specifier: ^2.0.7
+ tailwind-merge:
+ specifier: 'catalog:'
+ version: 3.5.0
+ tw-animate-css:
+ specifier: ^1.4.0
+ version: 1.4.0
+ vaul:
+ specifier: ^1.1.2
+ devDependencies:
+ '@multica/tsconfig':
+ specifier: workspace:*
+ version: link:../tsconfig
+ '@types/linkify-it':
+ specifier: ^5.0.0
+ version: 5.0.0
+ '@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:
+ specifier: 'catalog:'
+ version: 5.9.3
+
packages: