Skip to content

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

Go

refactor: extract all shared logic to packages — apps are now thin routing shells

Naiyuan Qingd911cdf5acc1
diff --git a/apps/desktop/src/renderer/src/App.tsx b/apps/desktop/src/renderer/src/App.tsx
index 0c09ccf8b4..8360ddff40 100644
--- a/apps/desktop/src/renderer/src/App.tsx
+++ b/apps/desktop/src/renderer/src/App.tsx
@@ -1,19 +1,19 @@
import { RouterProvider } from "react-router-dom";
+import { CoreProvider } from "@multica/core/platform";
import { ThemeProvider } from "./components/theme-provider";
-import { Toaster } from "@multica/ui/components/ui/sonner";
-import { QueryProvider } from "@multica/core/provider";
-import { AuthInitializer } from "./platform/auth-initializer";
+import { Toaster } from "sonner";
import { router } from "./router";
export default function App() {
return (
<ThemeProvider>
- <QueryProvider>
- <AuthInitializer>
- <RouterProvider router={router} />
- </AuthInitializer>
- <Toaster />
- </QueryProvider>
+ <CoreProvider
+ apiBaseUrl={import.meta.env.VITE_API_URL}
+ wsUrl={import.meta.env.VITE_WS_URL}
+ >
+ <RouterProvider router={router} />
+ </CoreProvider>
+ <Toaster />
</ThemeProvider>
);
}
diff --git a/apps/desktop/src/renderer/src/components/dashboard-shell.tsx b/apps/desktop/src/renderer/src/components/dashboard-shell.tsx
index 82be615e6b..78460a5e8b 100644
--- a/apps/desktop/src/renderer/src/components/dashboard-shell.tsx
+++ b/apps/desktop/src/renderer/src/components/dashboard-shell.tsx
@@ -1,71 +1,19 @@
-import { useEffect } from "react";
-import { Outlet, useLocation, useNavigate } from "react-router-dom";
-import { useNavigationStore } from "@multica/core/navigation";
-import { SidebarProvider, SidebarInset } from "@multica/ui/components/ui/sidebar";
-import { WorkspaceIdProvider } from "@multica/core/hooks";
-import { ModalRegistry } from "@multica/views/modals/registry";
-import { useAuthStore } from "@/platform/auth";
-import { useWorkspaceStore } from "@/platform/workspace";
+import { Outlet } from "react-router-dom";
import { DesktopNavigationProvider } from "@/platform/navigation";
-import { DesktopWSProvider } from "@/platform/ws-provider";
+import { DashboardLayout } from "@multica/views/layout";
import { TitleBar } from "./title-bar";
-import { AppSidebar } from "./app-sidebar";
import { MulticaIcon } from "./multica-icon";
export function DashboardShell() {
- const navigate = useNavigate();
- const location = useLocation();
- const user = useAuthStore((s) => s.user);
- const isLoading = useAuthStore((s) => s.isLoading);
- const workspace = useWorkspaceStore((s) => s.workspace);
-
- useEffect(() => {
- if (!isLoading && !user) {
- navigate("/login", { replace: true });
- }
- }, [user, isLoading, navigate]);
-
- useEffect(() => {
- useNavigationStore.getState().onPathChange(location.pathname);
- }, [location.pathname]);
-
- if (isLoading) {
- return (
- <div className="flex h-screen flex-col">
- <TitleBar />
- <div className="flex flex-1 items-center justify-center">
- <MulticaIcon className="size-6" />
- </div>
- </div>
- );
- }
-
- if (!user) return null;
-
return (
<DesktopNavigationProvider>
- <DesktopWSProvider>
- <div className="flex h-screen flex-col">
- <TitleBar />
- <div className="flex flex-1 min-h-0">
- <SidebarProvider className="flex-1">
- <AppSidebar />
- <SidebarInset className="overflow-hidden">
- {workspace ? (
- <WorkspaceIdProvider wsId={workspace.id}>
- <Outlet />
- <ModalRegistry />
- </WorkspaceIdProvider>
- ) : (
- <div className="flex flex-1 items-center justify-center">
- <MulticaIcon className="size-6 animate-pulse" />
- </div>
- )}
- </SidebarInset>
- </SidebarProvider>
- </div>
- </div>
- </DesktopWSProvider>
+ <DashboardLayout
+ header={<TitleBar />}
+ loginPath="/login"
+ loadingIndicator={<MulticaIcon className="size-6" />}
+ >
+ <Outlet />
+ </DashboardLayout>
</DesktopNavigationProvider>
);
}
diff --git a/apps/desktop/src/renderer/src/pages/login.tsx b/apps/desktop/src/renderer/src/pages/login.tsx
index 2e306ad558..536144ad47 100644
--- a/apps/desktop/src/renderer/src/pages/login.tsx
+++ b/apps/desktop/src/renderer/src/pages/login.tsx
@@ -1,139 +1,18 @@
-import { useState, useCallback } from "react";
import { useNavigate } from "react-router-dom";
-import { useAuthStore } from "@/platform/auth";
-import { useWorkspaceStore } from "@/platform/workspace";
-import { api } from "@/platform/api";
-import {
- Card,
- CardHeader,
- CardTitle,
- CardDescription,
- CardContent,
-} 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 { LoginPage } from "@multica/views/auth";
import { MulticaIcon } from "../components/multica-icon";
import { TitleBar } from "../components/title-bar";
-export function LoginPage() {
+export function DesktopLoginPage() {
const navigate = useNavigate();
- const [step, setStep] = useState<"email" | "code">("email");
- const [email, setEmail] = useState("");
- const [code, setCode] = useState("");
- const [error, setError] = useState("");
- const [loading, setLoading] = useState(false);
-
- const handleSendCode = useCallback(async () => {
- setLoading(true);
- setError("");
- try {
- await useAuthStore.getState().sendCode(email);
- setStep("code");
- } catch {
- setError("Failed to send code");
- } finally {
- setLoading(false);
- }
- }, [email]);
-
- const handleVerify = useCallback(async () => {
- setLoading(true);
- setError("");
- try {
- await useAuthStore.getState().verifyCode(email, code);
- const wsList = await api.listWorkspaces();
- useWorkspaceStore.getState().hydrateWorkspace(wsList);
- navigate("/issues", { replace: true });
- } catch {
- setError("Invalid code");
- } finally {
- setLoading(false);
- }
- }, [email, code, navigate]);
return (
<div className="flex h-screen flex-col">
<TitleBar />
- <div className="flex flex-1 items-center justify-center">
- <Card className="w-[380px]">
- <CardHeader className="text-center">
- <div className="mx-auto mb-4">
- <MulticaIcon bordered size="lg" />
- </div>
- <CardTitle>Sign in to Multica</CardTitle>
- <CardDescription>
- {step === "email"
- ? "Enter your email to get a login code"
- : `We sent a code to ${email}`}
- </CardDescription>
- </CardHeader>
- <CardContent>
- {step === "email" ? (
- <form
- onSubmit={(e) => {
- e.preventDefault();
- handleSendCode();
- }}
- >
- <div className="space-y-4">
- <div className="space-y-2">
- <Label htmlFor="email">Email</Label>
- <Input
- id="email"
- type="email"
- placeholder="[email protected]"
- value={email}
- onChange={(e) => setEmail(e.target.value)}
- autoFocus
- />
- </div>
- {error && <p className="text-sm text-destructive">{error}</p>}
- <Button type="submit" className="w-full" disabled={!email || loading}>
- {loading ? "Sending..." : "Send Code"}
- </Button>
- </div>
- </form>
- ) : (
- <form
- onSubmit={(e) => {
- e.preventDefault();
- handleVerify();
- }}
- >
- <div className="space-y-4">
- <div className="space-y-2">
- <Label htmlFor="code">Verification Code</Label>
- <Input
- id="code"
- placeholder="Enter 6-digit code"
- value={code}
- onChange={(e) => setCode(e.target.value)}
- autoFocus
- />
- </div>
- {error && <p className="text-sm text-destructive">{error}</p>}
- <Button type="submit" className="w-full" disabled={!code || loading}>
- {loading ? "Verifying..." : "Verify"}
- </Button>
- <Button
- type="button"
- variant="ghost"
- className="w-full"
- onClick={() => {
- setStep("email");
- setCode("");
- setError("");
- }}
- >
- Back
- </Button>
- </div>
- </form>
- )}
- </CardContent>
- </Card>
- </div>
+ <LoginPage
+ logo={<MulticaIcon bordered size="lg" />}
+ onSuccess={() => navigate("/issues", { replace: true })}
+ />
</div>
);
}
diff --git a/apps/desktop/src/renderer/src/pages/placeholder.tsx b/apps/desktop/src/renderer/src/pages/placeholder.tsx
deleted file mode 100644
index d746debde8..0000000000
--- a/apps/desktop/src/renderer/src/pages/placeholder.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-export function PlaceholderPage({ title }: { title: string }) {
- return (
- <div className="flex flex-1 items-center justify-center">
- <div className="text-center">
- <h1 className="text-2xl font-bold">{title}</h1>
- <p className="mt-2 text-muted-foreground">
- Coming soon — requires page extraction to @multica/views.
- </p>
- </div>
- </div>
- );
-}
diff --git a/apps/desktop/src/renderer/src/platform/api.ts b/apps/desktop/src/renderer/src/platform/api.ts
deleted file mode 100644
index 90f91c1167..0000000000
--- a/apps/desktop/src/renderer/src/platform/api.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { ApiClient } from "@multica/core/api/client";
-import { setApiInstance } from "@multica/core/api";
-import { createLogger } from "@multica/core/logger";
-import { desktopStorage } from "./storage";
-
-const API_BASE_URL = "http://localhost:8080";
-
-export const api = new ApiClient(API_BASE_URL, {
- logger: createLogger("api"),
- onUnauthorized: () => {
- desktopStorage.removeItem("multica_token");
- desktopStorage.removeItem("multica_workspace_id");
- },
-});
-
-setApiInstance(api);
-
-const token = desktopStorage.getItem("multica_token");
-if (token) api.setToken(token);
-const wsId = desktopStorage.getItem("multica_workspace_id");
-if (wsId) api.setWorkspaceId(wsId);
diff --git a/apps/desktop/src/renderer/src/platform/auth-initializer.tsx b/apps/desktop/src/renderer/src/platform/auth-initializer.tsx
deleted file mode 100644
index 4ad4ac3bf3..0000000000
--- a/apps/desktop/src/renderer/src/platform/auth-initializer.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { useEffect, type ReactNode } from "react";
-import { useAuthStore } from "./auth";
-import { useWorkspaceStore } from "./workspace";
-import { api } from "./api";
-import { desktopStorage } from "./storage";
-import { createLogger } from "@multica/core/logger";
-
-const logger = createLogger("auth");
-
-export function AuthInitializer({ children }: { children: ReactNode }) {
- useEffect(() => {
- const token = desktopStorage.getItem("multica_token");
- if (!token) {
- useAuthStore.setState({ isLoading: false });
- return;
- }
-
- api.setToken(token);
- const wsId = desktopStorage.getItem("multica_workspace_id");
-
- const mePromise = api.getMe();
- const wsPromise = api.listWorkspaces();
-
- Promise.all([mePromise, wsPromise])
- .then(([user, wsList]) => {
- useAuthStore.setState({ user, isLoading: false });
- useWorkspaceStore.getState().hydrateWorkspace(wsList, wsId);
- })
- .catch((err) => {
- logger.error("auth init failed", err);
- api.setToken(null);
- api.setWorkspaceId(null);
- desktopStorage.removeItem("multica_token");
- desktopStorage.removeItem("multica_workspace_id");
- useAuthStore.setState({ user: null, isLoading: false });
- });
- }, []);
-
- return <>{children}</>;
-}
diff --git a/apps/desktop/src/renderer/src/platform/auth.ts b/apps/desktop/src/renderer/src/platform/auth.ts
deleted file mode 100644
index 103d453d3e..0000000000
--- a/apps/desktop/src/renderer/src/platform/auth.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { createAuthStore, registerAuthStore } from "@multica/core/auth";
-import { api } from "./api";
-import { desktopStorage } from "./storage";
-
-export const useAuthStore = createAuthStore({
- api,
- storage: desktopStorage,
-});
-
-registerAuthStore(useAuthStore);
diff --git a/apps/desktop/src/renderer/src/platform/index.ts b/apps/desktop/src/renderer/src/platform/index.ts
deleted file mode 100644
index e3aba27f51..0000000000
--- a/apps/desktop/src/renderer/src/platform/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export { api } from "./api";
-export { useAuthStore } from "./auth";
-export { useWorkspaceStore } from "./workspace";
-export { desktopStorage } from "./storage";
diff --git a/apps/desktop/src/renderer/src/platform/storage.ts b/apps/desktop/src/renderer/src/platform/storage.ts
deleted file mode 100644
index 14e691e56b..0000000000
--- a/apps/desktop/src/renderer/src/platform/storage.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import type { StorageAdapter } from "@multica/core/types/storage";
-
-export const desktopStorage: StorageAdapter = {
- getItem: (key) => localStorage.getItem(key),
- setItem: (key, value) => localStorage.setItem(key, value),
- removeItem: (key) => localStorage.removeItem(key),
-};
diff --git a/apps/desktop/src/renderer/src/platform/workspace.ts b/apps/desktop/src/renderer/src/platform/workspace.ts
deleted file mode 100644
index b0b4d618b8..0000000000
--- a/apps/desktop/src/renderer/src/platform/workspace.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { createWorkspaceStore, registerWorkspaceStore } from "@multica/core/workspace";
-import { toast } from "sonner";
-import { api } from "./api";
-import { desktopStorage } from "./storage";
-
-export const useWorkspaceStore = createWorkspaceStore(api, {
- storage: desktopStorage,
- onError: (msg) => toast.error(msg),
-});
-
-registerWorkspaceStore(useWorkspaceStore);
diff --git a/apps/desktop/src/renderer/src/platform/ws-provider.tsx b/apps/desktop/src/renderer/src/platform/ws-provider.tsx
deleted file mode 100644
index 351f32b77f..0000000000
--- a/apps/desktop/src/renderer/src/platform/ws-provider.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { WSProvider } from "@multica/core/realtime";
-import { useAuthStore } from "./auth";
-import { useWorkspaceStore } from "./workspace";
-import { desktopStorage } from "./storage";
-import { toast } from "sonner";
-
-const WS_URL = "ws://localhost:8080/ws";
-
-export function DesktopWSProvider({ children }: { children: React.ReactNode }) {
- return (
- <WSProvider
- wsUrl={WS_URL}
- authStore={useAuthStore}
- workspaceStore={useWorkspaceStore}
- storage={desktopStorage}
- onToast={(message, type) => {
- if (type === "error") toast.error(message);
- else toast.info(message);
- }}
- >
- {children}
- </WSProvider>
- );
-}
diff --git a/apps/desktop/src/renderer/src/router.tsx b/apps/desktop/src/renderer/src/router.tsx
index 81ea6e4c49..21698a2098 100644
--- a/apps/desktop/src/renderer/src/router.tsx
+++ b/apps/desktop/src/renderer/src/router.tsx
@@ -1,14 +1,15 @@
import { createHashRouter, Navigate } from "react-router-dom";
import { DashboardShell } from "./components/dashboard-shell";
-import { LoginPage } from "./pages/login";
+import { DesktopLoginPage } from "./pages/login";
import { IssueDetailPage } from "./pages/issue-detail-page";
-import { PlaceholderPage } from "./pages/placeholder";
-
// Extracted pages from @multica/views
import { IssuesPage } from "@multica/views/issues/components";
import { MyIssuesPage } from "@multica/views/my-issues";
import { RuntimesPage } from "@multica/views/runtimes";
import { SkillsPage } from "@multica/views/skills";
+import { AgentsPage } from "@multica/views/agents";
+import { InboxPage } from "@multica/views/inbox";
+import { SettingsPage } from "@multica/views/settings";
export const router = createHashRouter([
{
@@ -21,11 +22,10 @@ export const router = createHashRouter([
{ path: "my-issues", element: <MyIssuesPage /> },
{ path: "runtimes", element: <RuntimesPage /> },
{ path: "skills", element: <SkillsPage /> },
- { path: "agents", element: <PlaceholderPage title="Agents" /> },
- { path: "inbox", element: <PlaceholderPage title="Inbox" /> },
- { path: "settings", element: <PlaceholderPage title="Settings" /> },
- { path: "board", element: <PlaceholderPage title="Board" /> },
+ { path: "agents", element: <AgentsPage /> },
+ { path: "inbox", element: <InboxPage /> },
+ { path: "settings", element: <SettingsPage /> },
],
},
- { path: "/login", element: <LoginPage /> },
+ { path: "/login", element: <DesktopLoginPage /> },
]);
diff --git a/apps/web/app/(auth)/login/page.test.tsx b/apps/web/app/(auth)/login/page.test.tsx
index 9fa7feb641..4ecb511dcd 100644
--- a/apps/web/app/(auth)/login/page.test.tsx
+++ b/apps/web/app/(auth)/login/page.test.tsx
@@ -12,7 +12,7 @@ vi.mock("next/navigation", () => ({
// Mock auth store
const mockSendCode = vi.fn();
const mockVerifyCode = vi.fn();
-vi.mock("@/platform/auth", () => ({
+vi.mock("@multica/core/auth", () => ({
useAuthStore: (selector: (s: any) => any) =>
selector({
sendCode: mockSendCode,
@@ -27,7 +27,7 @@ vi.mock("@/features/auth/auth-cookie", () => ({
// Mock workspace store
const mockHydrateWorkspace = vi.fn();
-vi.mock("@/platform/workspace", () => ({
+vi.mock("@multica/core/workspace", () => ({
useWorkspaceStore: (selector: (s: any) => any) =>
selector({
hydrateWorkspace: mockHydrateWorkspace,
@@ -35,7 +35,7 @@ vi.mock("@/platform/workspace", () => ({
}));
// Mock api
-vi.mock("@/platform/api", () => ({
+vi.mock("@multica/core/api", () => ({
api: {
listWorkspaces: vi.fn().mockResolvedValue([]),
verifyCode: vi.fn(),
diff --git a/apps/web/app/(auth)/login/page.tsx b/apps/web/app/(auth)/login/page.tsx
index d78ec84314..30df4edfbb 100644
--- a/apps/web/app/(auth)/login/page.tsx
+++ b/apps/web/app/(auth)/login/page.tsx
@@ -2,10 +2,10 @@
import { Suspense, useState, useEffect, useCallback } from "react";
import { useSearchParams, useRouter } from "next/navigation";
-import { useAuthStore } from "@/platform/auth";
+import { useAuthStore } from "@multica/core/auth";
import { setLoggedInCookie } from "@/features/auth/auth-cookie";
-import { useWorkspaceStore } from "@/platform/workspace";
-import { api } from "@/platform/api";
+import { useWorkspaceStore } from "@multica/core/workspace";
+import { api } from "@multica/core/api";
import {
Card,
CardHeader,
diff --git a/apps/web/app/(dashboard)/_components/app-sidebar.tsx b/apps/web/app/(dashboard)/_components/app-sidebar.tsx
deleted file mode 100644
index 55bcb2611d..0000000000
--- a/apps/web/app/(dashboard)/_components/app-sidebar.tsx
+++ /dev/null
@@ -1,239 +0,0 @@
-"use client";
-
-import React from "react";
-import Link from "next/link";
-import { usePathname, useRouter } from "next/navigation";
-import {
- Inbox,
- ListTodo,
- Bot,
- Monitor,
- ChevronDown,
- Settings,
- LogOut,
- Plus,
- Check,
- BookOpenText,
- SquarePen,
- CircleUser,
-} from "lucide-react";
-import { WorkspaceAvatar } from "@multica/views/workspace/workspace-avatar";
-import { useIssueDraftStore } from "@multica/core/issues/stores/draft-store";
-import {
- Sidebar,
- SidebarContent,
- SidebarGroup,
- SidebarGroupContent,
- SidebarHeader,
- SidebarFooter,
- SidebarMenu,
- SidebarMenuButton,
- SidebarMenuItem,
- SidebarRail,
-} from "@multica/ui/components/ui/sidebar";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuGroup,
- DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuSeparator,
- DropdownMenuTrigger,
-} 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";
-import { inboxKeys, deduplicateInboxItems } from "@multica/core/inbox/queries";
-import { api } from "@/platform/api";
-import { useModalStore } from "@multica/core/modals";
-
-const primaryNav = [
- { href: "/inbox", label: "Inbox", icon: Inbox },
- { href: "/my-issues", label: "My Issues", icon: CircleUser },
- { href: "/issues", label: "Issues", icon: ListTodo },
-];
-
-const workspaceNav = [
- { href: "/agents", label: "Agents", icon: Bot },
- { href: "/runtimes", label: "Runtimes", icon: Monitor },
- { href: "/skills", label: "Skills", icon: BookOpenText },
- { href: "/settings", label: "Settings", icon: Settings },
-];
-
-function DraftDot() {
- const hasDraft = useIssueDraftStore((s) => !!(s.draft.title || s.draft.description));
- if (!hasDraft) return null;
- return <span className="absolute top-0 right-0 size-1.5 rounded-full bg-brand" />;
-}
-
-export function AppSidebar() {
- const pathname = usePathname();
- const router = useRouter();
- const user = useAuthStore((s) => s.user);
- const authLogout = useAuthStore((s) => s.logout);
- const workspace = useWorkspaceStore((s) => s.workspace);
- const workspaces = useWorkspaceStore((s) => s.workspaces);
- const switchWorkspace = useWorkspaceStore((s) => s.switchWorkspace);
-
- const wsId = workspace?.id;
- const { data: inboxItems = [] } = useQuery({
- queryKey: wsId ? inboxKeys.list(wsId) : ["inbox", "disabled"],
- queryFn: () => api.listInbox(),
- enabled: !!wsId,
- });
- const unreadCount = React.useMemo(
- () => deduplicateInboxItems(inboxItems).filter((i) => !i.read).length,
- [inboxItems],
- );
-
- const logout = () => {
- router.push("/");
- authLogout();
- useWorkspaceStore.getState().clearWorkspace();
- };
-
- return (
- <Sidebar variant="inset">
- {/* Workspace Switcher */}
- <SidebarHeader className="py-3">
- <div className="flex items-center gap-4">
- <SidebarMenu className="min-w-0 flex-1">
- <SidebarMenuItem>
- <DropdownMenu>
- <DropdownMenuTrigger
- render={
- <SidebarMenuButton>
- <WorkspaceAvatar name={workspace?.name ?? "M"} size="sm" />
- <span className="flex-1 truncate font-medium">
- {workspace?.name ?? "Multica"}
- </span>
- <ChevronDown className="size-3 text-muted-foreground" />
- </SidebarMenuButton>
- }
- />
- <DropdownMenuContent
- className="w-52"
- align="start"
- side="bottom"
- sideOffset={4}
- >
- <DropdownMenuGroup>
- <DropdownMenuLabel className="text-xs text-muted-foreground">
- {user?.email}
- </DropdownMenuLabel>
- </DropdownMenuGroup>
- <DropdownMenuSeparator />
- <DropdownMenuGroup className="group/ws-section">
- <DropdownMenuLabel className="flex items-center text-xs text-muted-foreground">
- Workspaces
- <Tooltip>
- <TooltipTrigger
- className="ml-auto opacity-0 group-hover/ws-section:opacity-100 transition-opacity rounded hover:bg-accent p-0.5"
- onClick={() => useModalStore.getState().open("create-workspace")}
- >
- <Plus className="h-3.5 w-3.5" />
- </TooltipTrigger>
- <TooltipContent side="right">
- Create workspace
- </TooltipContent>
- </Tooltip>
- </DropdownMenuLabel>
- {workspaces.map((ws) => (
- <DropdownMenuItem
- key={ws.id}
- onClick={() => {
- if (ws.id !== workspace?.id) {
- router.push("/issues");
- switchWorkspace(ws.id);
- }
- }}
- >
- <WorkspaceAvatar name={ws.name} size="sm" />
- <span className="flex-1 truncate">{ws.name}</span>
- {ws.id === workspace?.id && (
- <Check className="h-3.5 w-3.5 text-primary" />
- )}
- </DropdownMenuItem>
- ))}
- </DropdownMenuGroup>
- <DropdownMenuSeparator />
- <DropdownMenuGroup>
- <DropdownMenuItem variant="destructive" onClick={logout}>
- <LogOut className="h-3.5 w-3.5" />
- Log out
- </DropdownMenuItem>
- </DropdownMenuGroup>
- </DropdownMenuContent>
- </DropdownMenu>
- </SidebarMenuItem>
- </SidebarMenu>
- <Tooltip>
- <TooltipTrigger
- className="relative flex h-7 w-7 items-center justify-center rounded-lg bg-background text-foreground shadow-sm hover:bg-accent"
- onClick={() => useModalStore.getState().open("create-issue")}
- >
- <SquarePen className="size-3.5" />
- <DraftDot />
- </TooltipTrigger>
- <TooltipContent side="bottom">New issue</TooltipContent>
- </Tooltip>
- </div>
- </SidebarHeader>
-
- {/* Navigation */}
- <SidebarContent>
- <SidebarGroup>
- <SidebarGroupContent>
- <SidebarMenu className="gap-0.5">
- {primaryNav.map((item) => {
- const isActive = pathname === item.href;
- return (
- <SidebarMenuItem key={item.href}>
- <SidebarMenuButton
- isActive={isActive}
- render={<Link href={item.href} />}
- className="text-muted-foreground hover:not-data-active:bg-sidebar-accent/70 data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground"
- >
- <item.icon />
- <span>{item.label}</span>
- {item.label === "Inbox" && unreadCount > 0 && (
- <span className="ml-auto text-xs">
- {unreadCount > 99 ? "99+" : unreadCount}
- </span>
- )}
- </SidebarMenuButton>
- </SidebarMenuItem>
- );
- })}
- </SidebarMenu>
- </SidebarGroupContent>
- </SidebarGroup>
-
- <SidebarGroup>
- <SidebarGroupContent>
- <SidebarMenu className="gap-0.5">
- {workspaceNav.map((item) => {
- const isActive = pathname === item.href;
- return (
- <SidebarMenuItem key={item.href}>
- <SidebarMenuButton
- isActive={isActive}
- render={<Link href={item.href} />}
- className="text-muted-foreground hover:not-data-active:bg-sidebar-accent/70 data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground"
- >
- <item.icon />
- <span>{item.label}</span>
- </SidebarMenuButton>
- </SidebarMenuItem>
- );
- })}
- </SidebarMenu>
- </SidebarGroupContent>
- </SidebarGroup>
- </SidebarContent>
- <SidebarFooter />
- <SidebarRail />
- </Sidebar>
- );
-}
diff --git a/apps/web/app/(dashboard)/agents/page.tsx b/apps/web/app/(dashboard)/agents/page.tsx
index a9eaf29060..336d8549db 100644
--- a/apps/web/app/(dashboard)/agents/page.tsx
+++ b/apps/web/app/(dashboard)/agents/page.tsx
@@ -1,1279 +1 @@
-"use client";
-
-import { useState, useEffect, useRef, useMemo } from "react";
-import { useDefaultLayout } from "react-resizable-panels";
-import {
- Bot,
- Cloud,
- Monitor,
- Plus,
- ListTodo,
- FileText,
- BookOpenText,
- Trash2,
- Save,
- Clock,
- CheckCircle2,
- XCircle,
- Loader2,
- AlertCircle,
- MoreHorizontal,
- Play,
- ChevronDown,
- Globe,
- Lock,
- Settings,
- Camera,
- Archive,
-} from "lucide-react";
-import type {
- Agent,
- AgentStatus,
- AgentVisibility,
- AgentTask,
- RuntimeDevice,
- CreateAgentRequest,
- UpdateAgentRequest,
-} from "@multica/core/types";
-import {
- Dialog,
- DialogContent,
- DialogHeader,
- DialogTitle,
- DialogDescription,
- DialogFooter,
-} from "@multica/ui/components/ui/dialog";
-import {
- ResizablePanelGroup,
- ResizablePanel,
- ResizableHandle,
-} from "@multica/ui/components/ui/resizable";
-import {
- DropdownMenu,
- DropdownMenuTrigger,
- DropdownMenuContent,
- DropdownMenuItem,
-} from "@multica/ui/components/ui/dropdown-menu";
-import {
- Popover,
- PopoverTrigger,
- PopoverContent,
-} 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 "@multica/ui/components/ui/skeleton";
-import { api } from "@/platform/api";
-import { useAuthStore } from "@/platform/auth";
-import { useWorkspaceStore } from "@/platform/workspace";
-import { runtimeListOptions } from "@multica/core/runtimes/queries";
-import { useQuery, useQueryClient } from "@tanstack/react-query";
-import { useWorkspaceId } from "@multica/core/hooks";
-import { issueListOptions } from "@multica/core/issues/queries";
-import { skillListOptions, agentListOptions, workspaceKeys } from "@multica/core/workspace/queries";
-import { ActorAvatar } from "@multica/views/common/actor-avatar";
-import { useFileUpload } from "@multica/core/hooks/use-file-upload";
-
-
-// ---------------------------------------------------------------------------
-// Helpers
-// ---------------------------------------------------------------------------
-
-const statusConfig: Record<AgentStatus, { label: string; color: string; dot: string }> = {
- idle: { label: "Idle", color: "text-muted-foreground", dot: "bg-muted-foreground" },
- working: { label: "Working", color: "text-success", dot: "bg-success" },
- blocked: { label: "Blocked", color: "text-warning", dot: "bg-warning" },
- error: { label: "Error", color: "text-destructive", dot: "bg-destructive" },
- offline: { label: "Offline", color: "text-muted-foreground/50", dot: "bg-muted-foreground/40" },
-};
-
-const taskStatusConfig: Record<string, { label: string; icon: typeof CheckCircle2; color: string }> = {
- queued: { label: "Queued", icon: Clock, color: "text-muted-foreground" },
- dispatched: { label: "Dispatched", icon: Play, color: "text-info" },
- running: { label: "Running", icon: Loader2, color: "text-success" },
- completed: { label: "Completed", icon: CheckCircle2, color: "text-success" },
- failed: { label: "Failed", icon: XCircle, color: "text-destructive" },
- cancelled: { label: "Cancelled", icon: XCircle, color: "text-muted-foreground" },
-};
-
-
-function generateId(): string {
- return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
-}
-
-function getRuntimeDevice(agent: Agent, runtimes: RuntimeDevice[]): RuntimeDevice | undefined {
- return runtimes.find((runtime) => runtime.id === agent.runtime_id);
-}
-
-// ---------------------------------------------------------------------------
-// Create Agent Dialog
-// ---------------------------------------------------------------------------
-
-function CreateAgentDialog({
- runtimes,
- onClose,
- onCreate,
-}: {
- runtimes: RuntimeDevice[];
- onClose: () => void;
- onCreate: (data: CreateAgentRequest) => Promise<void>;
-}) {
- const [name, setName] = useState("");
- const [description, setDescription] = useState("");
- const [selectedRuntimeId, setSelectedRuntimeId] = useState(runtimes[0]?.id ?? "");
- const [visibility, setVisibility] = useState<AgentVisibility>("private");
- const [creating, setCreating] = useState(false);
- const [runtimeOpen, setRuntimeOpen] = useState(false);
-
- useEffect(() => {
- if (!selectedRuntimeId && runtimes[0]) {
- setSelectedRuntimeId(runtimes[0].id);
- }
- }, [runtimes, selectedRuntimeId]);
-
- const selectedRuntime = runtimes.find((d) => d.id === selectedRuntimeId) ?? null;
-
- const handleSubmit = async () => {
- if (!name.trim() || !selectedRuntime) return;
- setCreating(true);
- try {
- await onCreate({
- name: name.trim(),
- description: description.trim(),
- runtime_id: selectedRuntime.id,
- visibility,
- });
- onClose();
- } catch (err) {
- toast.error(err instanceof Error ? err.message : "Failed to create agent");
- setCreating(false);
- }
- };
-
- return (
- <Dialog open onOpenChange={(v) => { if (!v) onClose(); }}>
- <DialogContent className="sm:max-w-md">
- <DialogHeader>
- <DialogTitle>Create Agent</DialogTitle>
- <DialogDescription>
- Create a new AI agent for your workspace.
- </DialogDescription>
- </DialogHeader>
-
- <div className="space-y-4">
- <div>
- <Label className="text-xs text-muted-foreground">Name</Label>
- <Input
- autoFocus
- type="text"
- value={name}
- onChange={(e) => setName(e.target.value)}
- placeholder="e.g. Deep Research Agent"
- className="mt-1"
- onKeyDown={(e) => e.key === "Enter" && handleSubmit()}
- />
- </div>
-
- <div>
- <Label className="text-xs text-muted-foreground">Description</Label>
- <Input
- type="text"
- value={description}
- onChange={(e) => setDescription(e.target.value)}
- placeholder="What does this agent do?"
- className="mt-1"
- />
- </div>
-
- <div>
- <Label className="text-xs text-muted-foreground">Visibility</Label>
- <div className="mt-1.5 flex gap-2">
- <button
- type="button"
- onClick={() => setVisibility("workspace")}
- className={`flex flex-1 items-center gap-2 rounded-lg border px-3 py-2.5 text-sm transition-colors ${
- visibility === "workspace"
- ? "border-primary bg-primary/5"
- : "border-border hover:bg-muted"
- }`}
- >
- <Globe className="h-4 w-4 shrink-0 text-muted-foreground" />
- <div className="text-left">
- <div className="font-medium">Workspace</div>
- <div className="text-xs text-muted-foreground">All members can assign</div>
- </div>
- </button>
- <button
- type="button"
- onClick={() => setVisibility("private")}
- className={`flex flex-1 items-center gap-2 rounded-lg border px-3 py-2.5 text-sm transition-colors ${
- visibility === "private"
- ? "border-primary bg-primary/5"
- : "border-border hover:bg-muted"
- }`}
- >
- <Lock className="h-4 w-4 shrink-0 text-muted-foreground" />
- <div className="text-left">
- <div className="font-medium">Private</div>
- <div className="text-xs text-muted-foreground">Only you can assign</div>
- </div>
- </button>
- </div>
- </div>
-
- <div>
- <Label className="text-xs text-muted-foreground">Runtime</Label>
- <Popover open={runtimeOpen} onOpenChange={setRuntimeOpen}>
- <PopoverTrigger
- disabled={runtimes.length === 0}
- className="flex w-full items-center gap-3 rounded-lg border border-border bg-background px-3 py-2.5 mt-1.5 text-left text-sm transition-colors hover:bg-muted disabled:pointer-events-none disabled:opacity-50"
- >
- {selectedRuntime?.runtime_mode === "cloud" ? (
- <Cloud className="h-4 w-4 shrink-0 text-muted-foreground" />
- ) : (
- <Monitor className="h-4 w-4 shrink-0 text-muted-foreground" />
- )}
- <div className="min-w-0 flex-1">
- <div className="flex items-center gap-2">
- <span className="truncate font-medium">
- {selectedRuntime?.name ?? "No runtime available"}
- </span>
- {selectedRuntime?.runtime_mode === "cloud" && (
- <span className="shrink-0 rounded bg-info/10 px-1.5 py-0.5 text-xs font-medium text-info">
- Cloud
- </span>
- )}
- </div>
- <div className="truncate text-xs text-muted-foreground">
- {selectedRuntime?.device_info ?? "Register a runtime before creating an agent"}
- </div>
- </div>
- <ChevronDown className={`h-4 w-4 shrink-0 text-muted-foreground transition-transform ${runtimeOpen ? "rotate-180" : ""}`} />
- </PopoverTrigger>
- <PopoverContent align="start" className="w-[var(--anchor-width)] p-1 max-h-60 overflow-y-auto">
- {runtimes.map((device) => (
- <button
- key={device.id}
- onClick={() => {
- setSelectedRuntimeId(device.id);
- setRuntimeOpen(false);
- }}
- className={`flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm transition-colors ${
- device.id === selectedRuntimeId ? "bg-accent" : "hover:bg-accent/50"
- }`}
- >
- {device.runtime_mode === "cloud" ? (
- <Cloud className="h-4 w-4 shrink-0 text-muted-foreground" />
- ) : (
- <Monitor className="h-4 w-4 shrink-0 text-muted-foreground" />
- )}
- <div className="min-w-0 flex-1">
- <div className="flex items-center gap-2">
- <span className="truncate font-medium">{device.name}</span>
- {device.runtime_mode === "cloud" && (
- <span className="shrink-0 rounded bg-info/10 px-1.5 py-0.5 text-xs font-medium text-info">
- Cloud
- </span>
- )}
- </div>
- <div className="truncate text-xs text-muted-foreground">{device.device_info}</div>
- </div>
- <span
- className={`h-2 w-2 shrink-0 rounded-full ${
- device.status === "online" ? "bg-success" : "bg-muted-foreground/40"
- }`}
- />
- </button>
- ))}
- </PopoverContent>
- </Popover>
- </div>
- </div>
-
- <DialogFooter>
- <Button variant="ghost" onClick={onClose}>
- Cancel
- </Button>
- <Button
- onClick={handleSubmit}
- disabled={creating || !name.trim() || !selectedRuntime}
- >
- {creating ? "Creating..." : "Create"}
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Agent List Item
-// ---------------------------------------------------------------------------
-
-function AgentListItem({
- agent,
- isSelected,
- onClick,
-}: {
- agent: Agent;
- isSelected: boolean;
- onClick: () => void;
-}) {
- const st = statusConfig[agent.status];
- const isArchived = !!agent.archived_at;
-
- return (
- <button
- onClick={onClick}
- className={`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors ${
- isSelected ? "bg-accent" : "hover:bg-accent/50"
- }`}
- >
- <ActorAvatar actorType="agent" actorId={agent.id} size={32} className={`rounded-lg ${isArchived ? "opacity-50 grayscale" : ""}`} />
-
- <div className="min-w-0 flex-1">
- <div className="flex items-center gap-2">
- <span className={`truncate text-sm font-medium ${isArchived ? "text-muted-foreground" : ""}`}>{agent.name}</span>
- {agent.runtime_mode === "cloud" ? (
- <Cloud className="h-3 w-3 text-muted-foreground" />
- ) : (
- <Monitor className="h-3 w-3 text-muted-foreground" />
- )}
- </div>
- <div className="flex items-center gap-1.5 mt-0.5">
- {isArchived ? (
- <span className="text-xs text-muted-foreground">Archived</span>
- ) : (
- <>
- <span className={`h-1.5 w-1.5 rounded-full ${st.dot}`} />
- <span className={`text-xs ${st.color}`}>{st.label}</span>
- </>
- )}
- </div>
- </div>
- </button>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Instructions Tab
-// ---------------------------------------------------------------------------
-
-function InstructionsTab({
- agent,
- onSave,
-}: {
- agent: Agent;
- onSave: (instructions: string) => Promise<void>;
-}) {
- const [value, setValue] = useState(agent.instructions ?? "");
- const [saving, setSaving] = useState(false);
- const isDirty = value !== (agent.instructions ?? "");
-
- // Sync when switching between agents.
- useEffect(() => {
- setValue(agent.instructions ?? "");
- }, [agent.id, agent.instructions]);
-
- const handleSave = async () => {
- setSaving(true);
- try {
- await onSave(value);
- } catch {
- // toast handled by parent
- } finally {
- setSaving(false);
- }
- };
-
- return (
- <div className="space-y-4">
- <div>
- <h3 className="text-sm font-semibold">Agent Instructions</h3>
- <p className="text-xs text-muted-foreground mt-0.5">
- Define this agent&apos;s identity and working style. These instructions are
- injected into the agent&apos;s context for every task.
- </p>
- </div>
-
- <textarea
- value={value}
- onChange={(e) => setValue(e.target.value)}
- placeholder={`Define this agent's role, expertise, and working style.\n\nExample:\nYou are a frontend engineer specializing in React and TypeScript.\n\n## Working Style\n- Write small, focused PRs — one commit per logical change\n- Prefer composition over inheritance\n- Always add unit tests for new components\n\n## Constraints\n- Do not modify shared/ types without explicit approval\n- Follow the existing component patterns in features/`}
- className="w-full min-h-[300px] rounded-md border bg-transparent px-3 py-2 text-sm font-mono placeholder:text-muted-foreground/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-y"
- />
-
- <div className="flex items-center justify-between">
- <span className="text-xs text-muted-foreground">
- {value.length > 0 ? `${value.length} characters` : "No instructions set"}
- </span>
- <Button
- size="xs"
- onClick={handleSave}
- disabled={!isDirty || saving}
- >
- {saving ? (
- <Loader2 className="h-3 w-3 animate-spin" />
- ) : (
- <Save className="h-3 w-3" />
- )}
- Save
- </Button>
- </div>
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Skills Tab (picker — skills are managed on /skills page)
-// ---------------------------------------------------------------------------
-
-function SkillsTab({
- agent,
-}: {
- agent: Agent;
-}) {
- const qc = useQueryClient();
- const wsId = useWorkspaceId();
- const { data: workspaceSkills = [] } = useQuery(skillListOptions(wsId));
- const [saving, setSaving] = useState(false);
- const [showPicker, setShowPicker] = useState(false);
-
- const agentSkillIds = new Set(agent.skills.map((s) => s.id));
- const availableSkills = workspaceSkills.filter((s) => !agentSkillIds.has(s.id));
-
- const handleAdd = async (skillId: string) => {
- setSaving(true);
- try {
- const newIds = [...agent.skills.map((s) => s.id), skillId];
- await api.setAgentSkills(agent.id, { skill_ids: newIds });
- qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) });
- } catch (e) {
- toast.error(e instanceof Error ? e.message : "Failed to add skill");
- } finally {
- setSaving(false);
- setShowPicker(false);
- }
- };
-
- const handleRemove = async (skillId: string) => {
- setSaving(true);
- try {
- const newIds = agent.skills.filter((s) => s.id !== skillId).map((s) => s.id);
- await api.setAgentSkills(agent.id, { skill_ids: newIds });
- qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) });
- } catch (e) {
- toast.error(e instanceof Error ? e.message : "Failed to remove skill");
- } finally {
- setSaving(false);
- }
- };
-
- return (
- <div className="space-y-4">
- <div className="flex items-center justify-between">
- <div>
- <h3 className="text-sm font-semibold">Skills</h3>
- <p className="text-xs text-muted-foreground mt-0.5">
- Reusable skills assigned to this agent. Manage skills on the Skills page.
- </p>
- </div>
- <Button
- variant="outline"
- size="xs"
- onClick={() => setShowPicker(true)}
- disabled={saving || availableSkills.length === 0}
- >
- <Plus className="h-3 w-3" />
- Add Skill
- </Button>
- </div>
-
- {agent.skills.length === 0 ? (
- <div className="flex flex-col items-center justify-center rounded-lg border border-dashed py-12">
- <FileText className="h-8 w-8 text-muted-foreground/40" />
- <p className="mt-3 text-sm text-muted-foreground">No skills assigned</p>
- <p className="mt-1 text-xs text-muted-foreground">
- Add skills from the workspace to this agent.
- </p>
- {availableSkills.length > 0 && (
- <Button
- onClick={() => setShowPicker(true)}
- size="xs"
- className="mt-3"
- disabled={saving}
- >
- <Plus className="h-3 w-3" />
- Add Skill
- </Button>
- )}
- </div>
- ) : (
- <div className="space-y-2">
- {agent.skills.map((skill) => (
- <div
- key={skill.id}
- className="flex items-center gap-3 rounded-lg border px-4 py-3"
- >
- <div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-muted">
- <FileText className="h-4 w-4 text-muted-foreground" />
- </div>
- <div className="min-w-0 flex-1">
- <div className="text-sm font-medium">{skill.name}</div>
- {skill.description && (
- <div className="text-xs text-muted-foreground truncate">
- {skill.description}
- </div>
- )}
- </div>
- <Button
- variant="ghost"
- size="icon-xs"
- onClick={() => handleRemove(skill.id)}
- disabled={saving}
- className="text-muted-foreground hover:text-destructive"
- >
- <Trash2 className="h-3.5 w-3.5" />
- </Button>
- </div>
- ))}
- </div>
- )}
-
- {/* Skill Picker Dialog */}
- {showPicker && (
- <Dialog open onOpenChange={(v) => { if (!v) setShowPicker(false); }}>
- <DialogContent className="max-w-md">
- <DialogHeader>
- <DialogTitle className="text-sm">Add Skill</DialogTitle>
- <DialogDescription className="text-xs">
- Select a skill to assign to this agent.
- </DialogDescription>
- </DialogHeader>
- <div className="max-h-64 overflow-y-auto space-y-1">
- {availableSkills.map((skill) => (
- <button
- key={skill.id}
- onClick={() => handleAdd(skill.id)}
- disabled={saving}
- className="flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm transition-colors hover:bg-accent/50"
- >
- <FileText className="h-4 w-4 shrink-0 text-muted-foreground" />
- <div className="min-w-0 flex-1">
- <div className="font-medium">{skill.name}</div>
- {skill.description && (
- <div className="text-xs text-muted-foreground truncate">
- {skill.description}
- </div>
- )}
- </div>
- </button>
- ))}
- {availableSkills.length === 0 && (
- <p className="py-6 text-center text-xs text-muted-foreground">
- All workspace skills are already assigned.
- </p>
- )}
- </div>
- <DialogFooter>
- <Button variant="ghost" onClick={() => setShowPicker(false)}>
- Cancel
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- )}
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Tasks Tab
-// ---------------------------------------------------------------------------
-
-function TasksTab({ agent }: { agent: Agent }) {
- const [tasks, setTasks] = useState<AgentTask[]>([]);
- const [loading, setLoading] = useState(true);
- const wsId = useWorkspaceId();
- const { data: issues = [] } = useQuery(issueListOptions(wsId));
-
- useEffect(() => {
- setLoading(true);
- api
- .listAgentTasks(agent.id)
- .then(setTasks)
- .catch(() => setTasks([]))
- .finally(() => setLoading(false));
- }, [agent.id]);
-
- if (loading) {
- return (
- <div className="space-y-2">
- {Array.from({ length: 3 }).map((_, i) => (
- <div key={i} className="flex items-center gap-3 rounded-lg border px-4 py-3">
- <Skeleton className="h-4 w-4 rounded shrink-0" />
- <div className="flex-1 space-y-1.5">
- <Skeleton className="h-4 w-1/2" />
- <Skeleton className="h-3 w-1/3" />
- </div>
- <Skeleton className="h-4 w-16" />
- </div>
- ))}
- </div>
- );
- }
-
- // Sort: active tasks (running > dispatched > queued) first, then completed/failed by date
- const activeStatuses = ["running", "dispatched", "queued"];
- const sortedTasks = [...tasks].sort((a, b) => {
- const aActive = activeStatuses.indexOf(a.status);
- const bActive = activeStatuses.indexOf(b.status);
- const aIsActive = aActive !== -1;
- const bIsActive = bActive !== -1;
- if (aIsActive && !bIsActive) return -1;
- if (!aIsActive && bIsActive) return 1;
- if (aIsActive && bIsActive) return aActive - bActive;
- return new Date(b.created_at).getTime() - new Date(a.created_at).getTime();
- });
-
- const issueMap = new Map(issues.map((i) => [i.id, i]));
-
- return (
- <div className="space-y-4">
- <div>
- <h3 className="text-sm font-semibold">Task Queue</h3>
- <p className="text-xs text-muted-foreground mt-0.5">
- Issues assigned to this agent and their execution status.
- </p>
- </div>
-
- {tasks.length === 0 ? (
- <div className="flex flex-col items-center justify-center rounded-lg border border-dashed py-12">
- <ListTodo className="h-8 w-8 text-muted-foreground/40" />
- <p className="mt-3 text-sm text-muted-foreground">No tasks in queue</p>
- <p className="mt-1 text-xs text-muted-foreground">
- Assign an issue to this agent to get started.
- </p>
- </div>
- ) : (
- <div className="space-y-1.5">
- {sortedTasks.map((task) => {
- const config = taskStatusConfig[task.status] ?? taskStatusConfig.queued!;
- const Icon = config.icon;
- const issue = issueMap.get(task.issue_id);
- const isActive = task.status === "running" || task.status === "dispatched";
- const isRunning = task.status === "running";
-
- return (
- <div
- key={task.id}
- className={`flex items-center gap-3 rounded-lg border px-4 py-3 ${
- isRunning
- ? "border-success/40 bg-success/5"
- : task.status === "dispatched"
- ? "border-info/40 bg-info/5"
- : ""
- }`}
- >
- <Icon
- className={`h-4 w-4 shrink-0 ${config.color} ${
- isRunning ? "animate-spin" : ""
- }`}
- />
- <div className="min-w-0 flex-1">
- <div className="flex items-center gap-2">
- {issue && (
- <span className="shrink-0 text-xs font-mono text-muted-foreground">
- {issue.identifier}
- </span>
- )}
- <span className={`text-sm truncate ${isActive ? "font-medium" : ""}`}>
- {issue?.title ?? `Issue ${task.issue_id.slice(0, 8)}...`}
- </span>
- </div>
- <div className="text-xs text-muted-foreground mt-0.5">
- {isRunning && task.started_at
- ? `Started ${new Date(task.started_at).toLocaleString()}`
- : task.status === "dispatched" && task.dispatched_at
- ? `Dispatched ${new Date(task.dispatched_at).toLocaleString()}`
- : task.status === "completed" && task.completed_at
- ? `Completed ${new Date(task.completed_at).toLocaleString()}`
- : task.status === "failed" && task.completed_at
- ? `Failed ${new Date(task.completed_at).toLocaleString()}`
- : `Queued ${new Date(task.created_at).toLocaleString()}`}
- </div>
- </div>
- <span className={`shrink-0 text-xs font-medium ${config.color}`}>
- {config.label}
- </span>
- </div>
- );
- })}
- </div>
- )}
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Settings Tab
-// ---------------------------------------------------------------------------
-
-function SettingsTab({
- agent,
- runtimes,
- onSave,
-}: {
- agent: Agent;
- runtimes: RuntimeDevice[];
- onSave: (updates: Partial<Agent>) => Promise<void>;
-}) {
- const [name, setName] = useState(agent.name);
- const [description, setDescription] = useState(agent.description ?? "");
- const [visibility, setVisibility] = useState<AgentVisibility>(agent.visibility);
- const [maxTasks, setMaxTasks] = useState(agent.max_concurrent_tasks);
- const [saving, setSaving] = useState(false);
- const { upload, uploading } = useFileUpload(api);
- const fileInputRef = useRef<HTMLInputElement>(null);
-
- const handleAvatarUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
- const file = e.target.files?.[0];
- if (!file) return;
- e.target.value = "";
- try {
- const result = await upload(file);
- if (!result) return;
- await onSave({ avatar_url: result.link });
- toast.success("Avatar updated");
- } catch (err) {
- toast.error(err instanceof Error ? err.message : "Failed to upload avatar");
- }
- };
-
- const dirty =
- name !== agent.name ||
- description !== (agent.description ?? "") ||
- visibility !== agent.visibility ||
- maxTasks !== agent.max_concurrent_tasks;
-
- const handleSave = async () => {
- if (!name.trim()) {
- toast.error("Name is required");
- return;
- }
- setSaving(true);
- try {
- await onSave({ name: name.trim(), description, visibility, max_concurrent_tasks: maxTasks });
- toast.success("Settings saved");
- } catch {
- toast.error("Failed to save settings");
- } finally {
- setSaving(false);
- }
- };
-
- const runtimeDevice = runtimes.find((r) => r.id === agent.runtime_id);
-
- return (
- <div className="max-w-lg space-y-6">
- <div>
- <Label className="text-xs text-muted-foreground">Avatar</Label>
- <div className="mt-1.5 flex items-center gap-4">
- <button
- type="button"
- className="group relative h-16 w-16 shrink-0 rounded-full bg-muted overflow-hidden focus:outline-none focus-visible:ring-2 focus-visible:ring-ring"
- onClick={() => fileInputRef.current?.click()}
- disabled={uploading}
- >
- <ActorAvatar actorType="agent" actorId={agent.id} size={64} className="rounded-none" />
- <div className="absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 transition-opacity group-hover:opacity-100">
- {uploading ? (
- <Loader2 className="h-5 w-5 animate-spin text-white" />
- ) : (
- <Camera className="h-5 w-5 text-white" />
- )}
- </div>
- </button>
- <input
- ref={fileInputRef}
- type="file"
- accept="image/*"
- className="hidden"
- onChange={handleAvatarUpload}
- />
- <div className="text-xs text-muted-foreground">
- Click to upload avatar
- </div>
- </div>
- </div>
-
- <div>
- <Label className="text-xs text-muted-foreground">Name</Label>
- <Input
- value={name}
- onChange={(e) => setName(e.target.value)}
- className="mt-1"
- />
- </div>
-
- <div>
- <Label className="text-xs text-muted-foreground">Description</Label>
- <Input
- value={description}
- onChange={(e) => setDescription(e.target.value)}
- placeholder="What does this agent do?"
- className="mt-1"
- />
- </div>
-
- <div>
- <Label className="text-xs text-muted-foreground">Visibility</Label>
- <div className="mt-1.5 flex gap-2">
- <button
- type="button"
- onClick={() => setVisibility("workspace")}
- className={`flex flex-1 items-center gap-2 rounded-lg border px-3 py-2.5 text-sm transition-colors ${
- visibility === "workspace"
- ? "border-primary bg-primary/5"
- : "border-border hover:bg-muted"
- }`}
- >
- <Globe className="h-4 w-4 shrink-0 text-muted-foreground" />
- <div className="text-left">
- <div className="font-medium">Workspace</div>
- <div className="text-xs text-muted-foreground">All members can assign</div>
- </div>
- </button>
- <button
- type="button"
- onClick={() => setVisibility("private")}
- className={`flex flex-1 items-center gap-2 rounded-lg border px-3 py-2.5 text-sm transition-colors ${
- visibility === "private"
- ? "border-primary bg-primary/5"
- : "border-border hover:bg-muted"
- }`}
- >
- <Lock className="h-4 w-4 shrink-0 text-muted-foreground" />
- <div className="text-left">
- <div className="font-medium">Private</div>
- <div className="text-xs text-muted-foreground">Only you can assign</div>
- </div>
- </button>
- </div>
- </div>
-
- <div>
- <Label className="text-xs text-muted-foreground">Max Concurrent Tasks</Label>
- <Input
- type="number"
- min={1}
- max={50}
- value={maxTasks}
- onChange={(e) => setMaxTasks(Number(e.target.value))}
- className="mt-1 w-24"
- />
- </div>
-
- <div>
- <Label className="text-xs text-muted-foreground">Runtime</Label>
- <div className="mt-1 flex items-center gap-2 rounded-lg border px-3 py-2.5 text-sm text-muted-foreground">
- {agent.runtime_mode === "cloud" ? (
- <Cloud className="h-4 w-4" />
- ) : (
- <Monitor className="h-4 w-4" />
- )}
- {runtimeDevice?.name ?? (agent.runtime_mode === "cloud" ? "Cloud" : "Local")}
- </div>
- </div>
-
- <Button onClick={handleSave} disabled={!dirty || saving} size="sm">
- {saving ? <Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" /> : <Save className="h-3.5 w-3.5 mr-1.5" />}
- Save Changes
- </Button>
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Agent Detail
-// ---------------------------------------------------------------------------
-
-type DetailTab = "instructions" | "skills" | "tasks" | "settings";
-
-const detailTabs: { id: DetailTab; label: string; icon: typeof FileText }[] = [
- { id: "instructions", label: "Instructions", icon: FileText },
- { id: "skills", label: "Skills", icon: BookOpenText },
- { id: "tasks", label: "Tasks", icon: ListTodo },
- { id: "settings", label: "Settings", icon: Settings },
-];
-
-function AgentDetail({
- agent,
- runtimes,
- onUpdate,
- onArchive,
- onRestore,
-}: {
- agent: Agent;
- runtimes: RuntimeDevice[];
- onUpdate: (id: string, data: Partial<Agent>) => Promise<void>;
- onArchive: (id: string) => Promise<void>;
- onRestore: (id: string) => Promise<void>;
-}) {
- const st = statusConfig[agent.status];
- const runtimeDevice = getRuntimeDevice(agent, runtimes);
- const [activeTab, setActiveTab] = useState<DetailTab>("instructions");
- const [confirmArchive, setConfirmArchive] = useState(false);
- const isArchived = !!agent.archived_at;
-
- return (
- <div className="flex h-full flex-col">
- {/* Archive Banner */}
- {isArchived && (
- <div className="flex items-center gap-2 bg-muted/50 px-4 py-2 text-xs text-muted-foreground border-b">
- <AlertCircle className="h-3.5 w-3.5 shrink-0" />
- <span className="flex-1">This agent is archived. It cannot be assigned or mentioned.</span>
- <Button variant="outline" size="sm" className="h-6 text-xs" onClick={() => onRestore(agent.id)}>
- Restore
- </Button>
- </div>
- )}
-
- {/* Header */}
- <div className="flex h-12 shrink-0 items-center gap-3 border-b px-4">
- <ActorAvatar actorType="agent" actorId={agent.id} size={28} className={`rounded-md ${isArchived ? "opacity-50" : ""}`} />
- <div className="min-w-0 flex-1">
- <div className="flex items-center gap-2">
- <h2 className={`text-sm font-semibold truncate ${isArchived ? "text-muted-foreground" : ""}`}>{agent.name}</h2>
- {isArchived ? (
- <span className="rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground">
- Archived
- </span>
- ) : (
- <span className={`flex items-center gap-1.5 text-xs ${st.color}`}>
- <span className={`h-1.5 w-1.5 rounded-full ${st.dot}`} />
- {st.label}
- </span>
- )}
- <span className="flex items-center gap-1 rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground">
- {agent.runtime_mode === "cloud" ? (
- <Cloud className="h-3 w-3" />
- ) : (
- <Monitor className="h-3 w-3" />
- )}
- {runtimeDevice?.name ?? (agent.runtime_mode === "cloud" ? "Cloud" : "Local")}
- </span>
- </div>
- </div>
- {!isArchived && (
- <DropdownMenu>
- <DropdownMenuTrigger
- render={
- <Button variant="ghost" size="icon-sm" />
- }
- >
- <MoreHorizontal className="h-4 w-4 text-muted-foreground" />
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="w-auto">
- <DropdownMenuItem
- className="text-destructive"
- onClick={() => setConfirmArchive(true)}
- >
- <Trash2 className="h-3.5 w-3.5" />
- Archive Agent
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- )}
- </div>
-
- {/* Tabs */}
- <div className="flex border-b px-6">
- {detailTabs.map((tab) => (
- <button
- key={tab.id}
- onClick={() => setActiveTab(tab.id)}
- className={`flex items-center gap-1.5 border-b-2 px-3 py-2.5 text-xs font-medium transition-colors ${
- activeTab === tab.id
- ? "border-primary text-foreground"
- : "border-transparent text-muted-foreground hover:text-foreground"
- }`}
- >
- <tab.icon className="h-3.5 w-3.5" />
- {tab.label}
- </button>
- ))}
- </div>
-
- {/* Tab Content */}
- <div className="flex-1 overflow-y-auto p-6">
- {activeTab === "instructions" && (
- <InstructionsTab
- agent={agent}
- onSave={(instructions) => onUpdate(agent.id, { instructions })}
- />
- )}
- {activeTab === "skills" && (
- <SkillsTab agent={agent} />
- )}
- {activeTab === "tasks" && <TasksTab agent={agent} />}
- {activeTab === "settings" && (
- <SettingsTab
- agent={agent}
- runtimes={runtimes}
- onSave={(updates) => onUpdate(agent.id, updates)}
- />
- )}
- </div>
-
- {/* Archive Confirmation */}
- {confirmArchive && (
- <Dialog open onOpenChange={(v) => { if (!v) setConfirmArchive(false); }}>
- <DialogContent className="max-w-sm" showCloseButton={false}>
- <div className="flex items-center gap-3">
- <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-destructive/10">
- <AlertCircle className="h-5 w-5 text-destructive" />
- </div>
- <DialogHeader className="flex-1 gap-1">
- <DialogTitle className="text-sm font-semibold">Archive agent?</DialogTitle>
- <DialogDescription className="text-xs">
- &quot;{agent.name}&quot; will be archived. It won&apos;t be assignable or mentionable, but all history is preserved. You can restore it later.
- </DialogDescription>
- </DialogHeader>
- </div>
- <DialogFooter>
- <Button variant="ghost" onClick={() => setConfirmArchive(false)}>
- Cancel
- </Button>
- <Button
- variant="destructive"
- onClick={() => {
- setConfirmArchive(false);
- onArchive(agent.id);
- }}
- >
- Archive
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- )}
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Page
-// ---------------------------------------------------------------------------
-
-export default function AgentsPage() {
- const isLoading = useAuthStore((s) => s.isLoading);
- const workspace = useWorkspaceStore((s) => s.workspace);
- const qc = useQueryClient();
- const wsId = useWorkspaceId();
- const { data: agents = [] } = useQuery(agentListOptions(wsId));
- const [selectedId, setSelectedId] = useState<string>("");
- const [showArchived, setShowArchived] = useState(false);
- const [showCreate, setShowCreate] = useState(false);
- const { data: runtimes = [] } = useQuery(runtimeListOptions(wsId));
- const { defaultLayout, onLayoutChanged } = useDefaultLayout({
- id: "multica_agents_layout",
- });
-
- const filteredAgents = useMemo(
- () => showArchived ? agents.filter((a) => !!a.archived_at) : agents.filter((a) => !a.archived_at),
- [agents, showArchived],
- );
-
- const archivedCount = useMemo(() => agents.filter((a) => !!a.archived_at).length, [agents]);
-
- // Select first agent on initial load or when filter changes
- useEffect(() => {
- if (filteredAgents.length > 0 && !filteredAgents.some((a) => a.id === selectedId)) {
- setSelectedId(filteredAgents[0]!.id);
- }
- }, [filteredAgents, selectedId]);
-
- const handleCreate = async (data: CreateAgentRequest) => {
- const agent = await api.createAgent(data);
- qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) });
- setSelectedId(agent.id);
- };
-
- const handleUpdate = async (id: string, data: Record<string, unknown>) => {
- try {
- await api.updateAgent(id, data as UpdateAgentRequest);
- qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) });
- toast.success("Agent updated");
- } catch (e) {
- toast.error(e instanceof Error ? e.message : "Failed to update agent");
- throw e;
- }
- };
-
- const handleArchive = async (id: string) => {
- try {
- await api.archiveAgent(id);
- qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) });
- toast.success("Agent archived");
- } catch (e) {
- toast.error(e instanceof Error ? e.message : "Failed to archive agent");
- }
- };
-
- const handleRestore = async (id: string) => {
- try {
- await api.restoreAgent(id);
- qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) });
- toast.success("Agent restored");
- } catch (e) {
- toast.error(e instanceof Error ? e.message : "Failed to restore agent");
- }
- };
-
- const selected = agents.find((a) => a.id === selectedId) ?? null;
-
- if (isLoading) {
- return (
- <div className="flex flex-1 min-h-0">
- {/* List skeleton */}
- <div className="w-72 border-r">
- <div className="flex h-12 items-center justify-between border-b px-4">
- <Skeleton className="h-4 w-16" />
- <Skeleton className="h-6 w-6 rounded" />
- </div>
- <div className="divide-y">
- {Array.from({ length: 4 }).map((_, i) => (
- <div key={i} className="flex items-center gap-3 px-4 py-3">
- <Skeleton className="h-8 w-8 rounded-full" />
- <div className="flex-1 space-y-1.5">
- <Skeleton className="h-4 w-24" />
- <Skeleton className="h-3 w-16" />
- </div>
- </div>
- ))}
- </div>
- </div>
- {/* Detail skeleton */}
- <div className="flex-1 p-6 space-y-6">
- <div className="flex items-center gap-3">
- <Skeleton className="h-10 w-10 rounded-full" />
- <div className="space-y-1.5">
- <Skeleton className="h-5 w-32" />
- <Skeleton className="h-3 w-20" />
- </div>
- </div>
- <div className="space-y-3">
- <Skeleton className="h-8 w-full rounded-lg" />
- <Skeleton className="h-8 w-full rounded-lg" />
- <Skeleton className="h-8 w-3/4 rounded-lg" />
- </div>
- </div>
- </div>
- );
- }
-
- return (
- <ResizablePanelGroup
- orientation="horizontal"
- className="flex-1 min-h-0"
- defaultLayout={defaultLayout}
- onLayoutChanged={onLayoutChanged}
- >
- <ResizablePanel id="list" defaultSize={280} minSize={240} maxSize={400} groupResizeBehavior="preserve-pixel-size">
- {/* Left column — agent list */}
- <div className="overflow-y-auto h-full border-r">
- <div className="flex h-12 items-center justify-between border-b px-4">
- <h1 className="text-sm font-semibold">Agents</h1>
- <div className="flex items-center gap-1">
- {archivedCount > 0 && (
- <Button
- variant={showArchived ? "secondary" : "ghost"}
- size="icon-xs"
- onClick={() => setShowArchived(!showArchived)}
- title={showArchived ? "Show active agents" : "Show archived agents"}
- >
- <Archive className="h-4 w-4 text-muted-foreground" />
- </Button>
- )}
- <Button
- variant="ghost"
- size="icon-xs"
- onClick={() => setShowCreate(true)}
- >
- <Plus className="h-4 w-4 text-muted-foreground" />
- </Button>
- </div>
- </div>
- {filteredAgents.length === 0 ? (
- <div className="flex flex-col items-center justify-center px-4 py-12">
- <Bot className="h-8 w-8 text-muted-foreground/40" />
- <p className="mt-3 text-sm text-muted-foreground">
- {showArchived ? "No archived agents" : archivedCount > 0 ? "No active agents" : "No agents yet"}
- </p>
- {!showArchived && (
- <Button
- onClick={() => setShowCreate(true)}
- size="xs"
- className="mt-3"
- >
- <Plus className="h-3 w-3" />
- Create Agent
- </Button>
- )}
- </div>
- ) : (
- <div className="divide-y">
- {filteredAgents.map((agent) => (
- <AgentListItem
- key={agent.id}
- agent={agent}
- isSelected={agent.id === selectedId}
- onClick={() => setSelectedId(agent.id)}
- />
- ))}
- </div>
- )}
- </div>
- </ResizablePanel>
-
- <ResizableHandle />
-
- <ResizablePanel id="detail" minSize="50%">
- {/* Right column — agent detail */}
- {selected ? (
- <AgentDetail
- key={selected.id}
- agent={selected}
- runtimes={runtimes}
- onUpdate={handleUpdate}
- onArchive={handleArchive}
- onRestore={handleRestore}
- />
- ) : (
- <div className="flex h-full flex-col items-center justify-center text-muted-foreground">
- <Bot className="h-10 w-10 text-muted-foreground/30" />
- <p className="mt-3 text-sm">Select an agent to view details</p>
- <Button
- onClick={() => setShowCreate(true)}
- size="xs"
- className="mt-3"
- >
- <Plus className="h-3 w-3" />
- Create Agent
- </Button>
- </div>
- )}
- </ResizablePanel>
-
- {showCreate && (
- <CreateAgentDialog
- runtimes={runtimes}
- onClose={() => setShowCreate(false)}
- onCreate={handleCreate}
- />
- )}
- </ResizablePanelGroup>
- );
-}
+export { AgentsPage as default } from "@multica/views/agents";
diff --git a/apps/web/app/(dashboard)/inbox/page.tsx b/apps/web/app/(dashboard)/inbox/page.tsx
index 5ab6f1fbce..8a17599646 100644
--- a/apps/web/app/(dashboard)/inbox/page.tsx
+++ b/apps/web/app/(dashboard)/inbox/page.tsx
@@ -1,468 +1 @@
-"use client";
-
-import { useState, useEffect, useCallback, useMemo } from "react";
-import { useSearchParams } from "next/navigation";
-import { useDefaultLayout } from "react-resizable-panels";
-import { useQuery } from "@tanstack/react-query";
-import { useWorkspaceId } from "@multica/core/hooks";
-import {
- inboxListOptions,
- deduplicateInboxItems,
-} from "@multica/core/inbox/queries";
-import {
- useMarkInboxRead,
- useArchiveInbox,
- useMarkAllInboxRead,
- useArchiveAllInbox,
- useArchiveAllReadInbox,
- useArchiveCompletedInbox,
-} from "@multica/core/inbox/mutations";
-import { IssueDetail, StatusIcon, PriorityIcon } from "@multica/views/issues/components";
-import { STATUS_CONFIG, PRIORITY_CONFIG } from "@multica/core/issues/config";
-import { useActorName } from "@multica/core/workspace/hooks";
-import { ActorAvatar } from "@multica/views/common/actor-avatar";
-import { toast } from "sonner";
-import {
- ArrowRight,
- MoreHorizontal,
- Inbox,
- CheckCheck,
- Archive,
- BookCheck,
- ListChecks,
-} from "lucide-react";
-import type { InboxItem, InboxItemType, IssueStatus, IssuePriority } from "@multica/core/types";
-import { Button } from "@multica/ui/components/ui/button";
-import {
- ResizablePanelGroup,
- ResizablePanel,
- ResizableHandle,
-} from "@multica/ui/components/ui/resizable";
-import { Skeleton } from "@multica/ui/components/ui/skeleton";
-import {
- DropdownMenu,
- DropdownMenuTrigger,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuSeparator,
-} from "@multica/ui/components/ui/dropdown-menu";
-
-// ---------------------------------------------------------------------------
-// Helpers
-// ---------------------------------------------------------------------------
-
-const typeLabels: Record<InboxItemType, string> = {
- issue_assigned: "Assigned",
- unassigned: "Unassigned",
- assignee_changed: "Assignee changed",
- status_changed: "Status changed",
- priority_changed: "Priority changed",
- due_date_changed: "Due date changed",
- new_comment: "New comment",
- mentioned: "Mentioned",
- review_requested: "Review requested",
- task_completed: "Task completed",
- task_failed: "Task failed",
- agent_blocked: "Agent blocked",
- agent_completed: "Agent completed",
- reaction_added: "Reacted",
-};
-
-function timeAgo(dateStr: string): string {
- const diff = Date.now() - new Date(dateStr).getTime();
- const minutes = Math.floor(diff / 60000);
- if (minutes < 1) return "just now";
- if (minutes < 60) return `${minutes}m`;
- const hours = Math.floor(minutes / 60);
- if (hours < 24) return `${hours}h`;
- const days = Math.floor(hours / 24);
- return `${days}d`;
-}
-
-function shortDate(dateStr: string): string {
- if (!dateStr) return "";
- return new Date(dateStr).toLocaleDateString("en-US", {
- month: "short",
- day: "numeric",
- });
-}
-
-// ---------------------------------------------------------------------------
-// InboxDetailLabel — renders rich subtitle per notification type
-// ---------------------------------------------------------------------------
-
-function InboxDetailLabel({ item }: { item: InboxItem }) {
- const { getActorName } = useActorName();
- const details = item.details ?? {};
-
- switch (item.type) {
- case "status_changed": {
- if (!details.to) return <span>{typeLabels[item.type]}</span>;
- const label = STATUS_CONFIG[details.to as IssueStatus]?.label ?? details.to;
- return (
- <span className="inline-flex items-center gap-1">
- Set status to
- <StatusIcon status={details.to as IssueStatus} className="h-3 w-3" />
- {label}
- </span>
- );
- }
- case "priority_changed": {
- if (!details.to) return <span>{typeLabels[item.type]}</span>;
- const label = PRIORITY_CONFIG[details.to as IssuePriority]?.label ?? details.to;
- return (
- <span className="inline-flex items-center gap-1">
- Set priority to
- <PriorityIcon priority={details.to as IssuePriority} className="h-3 w-3" />
- {label}
- </span>
- );
- }
- case "issue_assigned": {
- if (details.new_assignee_id) {
- return <span>Assigned to {getActorName(details.new_assignee_type ?? "member", details.new_assignee_id)}</span>;
- }
- return <span>{typeLabels[item.type]}</span>;
- }
- case "unassigned":
- return <span>Removed assignee</span>;
- case "assignee_changed": {
- if (details.new_assignee_id) {
- return <span>Assigned to {getActorName(details.new_assignee_type ?? "member", details.new_assignee_id)}</span>;
- }
- return <span>{typeLabels[item.type]}</span>;
- }
- case "due_date_changed": {
- if (details.to) return <span>Set due date to {shortDate(details.to)}</span>;
- return <span>Removed due date</span>;
- }
- case "new_comment": {
- if (item.body) return <span>{item.body}</span>;
- return <span>{typeLabels[item.type]}</span>;
- }
- case "reaction_added": {
- const emoji = details.emoji;
- if (emoji) return <span>Reacted {emoji} to your comment</span>;
- return <span>{typeLabels[item.type]}</span>;
- }
- default:
- return <span>{typeLabels[item.type] ?? item.type}</span>;
- }
-}
-
-// ---------------------------------------------------------------------------
-// InboxListItem
-// ---------------------------------------------------------------------------
-
-function InboxListItem({
- item,
- isSelected,
- onClick,
- onArchive,
-}: {
- item: InboxItem;
- isSelected: boolean;
- onClick: () => void;
- onArchive: () => void;
-}) {
- return (
- <button
- onClick={onClick}
- className={`group flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${
- isSelected ? "bg-accent" : "hover:bg-accent/50"
- }`}
- >
- <ActorAvatar
- actorType={item.actor_type ?? item.recipient_type}
- actorId={item.actor_id ?? item.recipient_id}
- size={28}
- />
- <div className="min-w-0 flex-1">
- <div className="flex items-center justify-between gap-2">
- <div className="flex min-w-0 items-center gap-1.5">
- {!item.read && (
- <span className="h-1.5 w-1.5 shrink-0 rounded-full bg-brand" />
- )}
- <span
- className={`truncate text-sm ${!item.read ? "font-medium" : "text-muted-foreground"}`}
- >
- {item.title}
- </span>
- </div>
- <div className="flex shrink-0 items-center gap-1">
- <span
- role="button"
- tabIndex={-1}
- title="Archive"
- onClick={(e) => {
- e.stopPropagation();
- onArchive();
- }}
- onKeyDown={(e) => {
- if (e.key === "Enter" || e.key === " ") {
- e.stopPropagation();
- onArchive();
- }
- }}
- className="hidden rounded p-0.5 text-muted-foreground hover:bg-accent hover:text-foreground group-hover:inline-flex"
- >
- <Archive className="h-3.5 w-3.5" />
- </span>
- {item.issue_status && (
- <StatusIcon status={item.issue_status} className="h-3.5 w-3.5 shrink-0" />
- )}
- </div>
- </div>
- <div className="mt-0.5 flex items-center justify-between gap-2">
- <p className={`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-xs ${item.read ? "text-muted-foreground/60" : "text-muted-foreground"}`}>
- <InboxDetailLabel item={item} />
- </p>
- <span className={`shrink-0 text-xs ${item.read ? "text-muted-foreground/60" : "text-muted-foreground"}`}>
- {timeAgo(item.created_at)}
- </span>
- </div>
- </div>
- </button>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Page
-// ---------------------------------------------------------------------------
-
-export default function InboxPage() {
- const searchParams = useSearchParams();
- const urlIssue = searchParams.get("issue") ?? "";
-
- const [selectedKey, setSelectedKeyState] = useState(() => urlIssue);
-
- // Sync from URL when searchParams change (e.g. Next.js navigation)
- useEffect(() => {
- setSelectedKeyState(urlIssue);
- }, [urlIssue]);
-
- const setSelectedKey = useCallback((key: string) => {
- setSelectedKeyState(key);
- const url = key ? `/inbox?issue=${key}` : "/inbox";
- window.history.replaceState(null, "", url);
- }, []);
-
- const wsId = useWorkspaceId();
- const { data: rawItems = [], isLoading: loading } = useQuery(inboxListOptions(wsId));
- const items = useMemo(() => deduplicateInboxItems(rawItems), [rawItems]);
-
- const { defaultLayout, onLayoutChanged } = useDefaultLayout({
- id: "multica_inbox_layout",
- });
-
- const selected = items.find((i) => (i.issue_id ?? i.id) === selectedKey) ?? null;
- const unreadCount = items.filter((i) => !i.read).length;
-
- const markReadMutation = useMarkInboxRead();
- const archiveMutation = useArchiveInbox();
- const markAllReadMutation = useMarkAllInboxRead();
- const archiveAllMutation = useArchiveAllInbox();
- const archiveAllReadMutation = useArchiveAllReadInbox();
- const archiveCompletedMutation = useArchiveCompletedInbox();
-
- // Click-to-read: select + auto-mark-read
- const handleSelect = (item: InboxItem) => {
- setSelectedKey(item.issue_id ?? item.id);
- if (!item.read) {
- markReadMutation.mutate(item.id, {
- onError: () => toast.error("Failed to mark as read"),
- });
- }
- };
-
- const handleArchive = (id: string) => {
- const archived = items.find((i) => i.id === id);
- if (archived && (archived.issue_id ?? archived.id) === selectedKey) setSelectedKey("");
- archiveMutation.mutate(id, {
- onError: () => toast.error("Failed to archive"),
- });
- };
-
- // Batch operations
- const handleMarkAllRead = () => {
- markAllReadMutation.mutate(undefined, {
- onError: () => toast.error("Failed to mark all as read"),
- });
- };
-
- const handleArchiveAll = () => {
- setSelectedKey("");
- archiveAllMutation.mutate(undefined, {
- onError: () => toast.error("Failed to archive all"),
- });
- };
-
- const handleArchiveAllRead = () => {
- const readKeys = items.filter((i) => i.read).map((i) => i.issue_id ?? i.id);
- if (readKeys.includes(selectedKey)) setSelectedKey("");
- archiveAllReadMutation.mutate(undefined, {
- onError: () => toast.error("Failed to archive read items"),
- });
- };
-
- const handleArchiveCompleted = () => {
- setSelectedKey("");
- archiveCompletedMutation.mutate(undefined, {
- onError: () => toast.error("Failed to archive completed"),
- });
- };
-
- if (loading) {
- return (
- <ResizablePanelGroup orientation="horizontal" className="flex-1 min-h-0" defaultLayout={defaultLayout} onLayoutChanged={onLayoutChanged}>
- <ResizablePanel id="list" defaultSize={320} minSize={240} maxSize={480} groupResizeBehavior="preserve-pixel-size">
- <div className="flex flex-col border-r h-full">
- <div className="flex h-12 shrink-0 items-center border-b px-4">
- <Skeleton className="h-5 w-16" />
- </div>
- <div className="flex-1 min-h-0 overflow-y-auto space-y-1 p-2">
- {Array.from({ length: 5 }).map((_, i) => (
- <div key={i} className="flex items-center gap-3 px-4 py-2.5">
- <Skeleton className="h-7 w-7 shrink-0 rounded-full" />
- <div className="flex-1 space-y-2">
- <Skeleton className="h-4 w-3/4" />
- <Skeleton className="h-3 w-1/2" />
- </div>
- </div>
- ))}
- </div>
- </div>
- </ResizablePanel>
- <ResizableHandle />
- <ResizablePanel id="detail" minSize="40%">
- <div className="p-6">
- <Skeleton className="h-6 w-48" />
- <Skeleton className="mt-4 h-4 w-32" />
- </div>
- </ResizablePanel>
- </ResizablePanelGroup>
- );
- }
-
- return (
- <ResizablePanelGroup orientation="horizontal" className="flex-1 min-h-0" defaultLayout={defaultLayout} onLayoutChanged={onLayoutChanged}>
- <ResizablePanel id="list" defaultSize={320} minSize={240} maxSize={480} groupResizeBehavior="preserve-pixel-size">
- {/* Left column — inbox list */}
- <div className="flex flex-col border-r h-full">
- <div className="flex h-12 shrink-0 items-center justify-between border-b px-4">
- <div className="flex items-center gap-2">
- <h1 className="text-sm font-semibold">Inbox</h1>
- {unreadCount > 0 && (
- <span className="text-xs text-muted-foreground">
- {unreadCount}
- </span>
- )}
- </div>
- <DropdownMenu>
- <DropdownMenuTrigger
- render={
- <Button
- variant="ghost"
- size="icon-xs"
- className="text-muted-foreground"
- />
- }
- >
- <MoreHorizontal className="h-4 w-4" />
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="w-auto">
- <DropdownMenuItem onClick={handleMarkAllRead}>
- <CheckCheck className="h-4 w-4" />
- Mark all as read
- </DropdownMenuItem>
- <DropdownMenuSeparator />
- <DropdownMenuItem onClick={handleArchiveAll}>
- <Archive className="h-4 w-4" />
- Archive all
- </DropdownMenuItem>
- <DropdownMenuItem onClick={handleArchiveAllRead}>
- <BookCheck className="h-4 w-4" />
- Archive all read
- </DropdownMenuItem>
- <DropdownMenuItem onClick={handleArchiveCompleted}>
- <ListChecks className="h-4 w-4" />
- Archive completed
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
-
- <div className="flex-1 min-h-0 overflow-y-auto">
- {items.length === 0 ? (
- <div className="flex flex-col items-center justify-center py-16 text-muted-foreground">
- <Inbox className="mb-3 h-8 w-8 text-muted-foreground/50" />
- <p className="text-sm">No notifications</p>
- </div>
- ) : (
- <div>
- {items.map((item) => (
- <InboxListItem
- key={item.id}
- item={item}
- isSelected={(item.issue_id ?? item.id) === selectedKey}
- onClick={() => handleSelect(item)}
- onArchive={() => handleArchive(item.id)}
- />
- ))}
- </div>
- )}
- </div>
- </div>
- </ResizablePanel>
- <ResizableHandle />
- <ResizablePanel id="detail" minSize="40%">
- {/* Right column — detail */}
- <div className="flex flex-col min-h-0 h-full">
- {selected?.issue_id ? (
- <IssueDetail
- key={selected.id}
- issueId={selected.issue_id}
- defaultSidebarOpen={false}
- layoutId="multica_inbox_issue_detail_layout"
- highlightCommentId={selected.details?.comment_id ?? undefined}
- onDelete={() => {
- handleArchive(selected.id);
- }}
- />
- ) : selected ? (
- <div className="p-6">
- <h2 className="text-lg font-semibold">{selected.title}</h2>
- <p className="mt-1 text-sm text-muted-foreground">
- {typeLabels[selected.type]} · {timeAgo(selected.created_at)}
- </p>
- {selected.body && (
- <div className="mt-4 whitespace-pre-wrap text-sm leading-relaxed text-foreground/80">
- {selected.body}
- </div>
- )}
- <div className="mt-4">
- <Button
- variant="outline"
- size="sm"
- onClick={() => handleArchive(selected.id)}
- >
- <Archive className="mr-1.5 h-3.5 w-3.5" />
- Archive
- </Button>
- </div>
- </div>
- ) : (
- <div className="flex h-full flex-col items-center justify-center text-muted-foreground">
- <Inbox className="mb-3 h-10 w-10 text-muted-foreground/30" />
- <p className="text-sm">
- {items.length === 0
- ? "Your inbox is empty"
- : "Select a notification to view details"}
- </p>
- </div>
- )}
- </div>
- </ResizablePanel>
- </ResizablePanelGroup>
- );
-}
+export { InboxPage as default } from "@multica/views/inbox";
diff --git a/apps/web/app/(dashboard)/layout.tsx b/apps/web/app/(dashboard)/layout.tsx
index bb96558a8e..bc8f957fe6 100644
--- a/apps/web/app/(dashboard)/layout.tsx
+++ b/apps/web/app/(dashboard)/layout.tsx
@@ -1,64 +1,16 @@
"use client";
-import { useEffect } from "react";
-import { useRouter, usePathname } from "next/navigation";
+import { DashboardLayout } from "@multica/views/layout";
import { MulticaIcon } from "@/components/multica-icon";
-import { useNavigationStore } from "@multica/core/navigation";
-import { SidebarProvider, SidebarInset } from "@multica/ui/components/ui/sidebar";
-import { useAuthStore } from "@/platform/auth";
-import { useWorkspaceStore } from "@/platform/workspace";
-import { WorkspaceIdProvider } from "@multica/core/hooks";
-import { ModalRegistry } from "@multica/views/modals/registry";
import { SearchCommand } from "@/features/search";
-import { AppSidebar } from "./_components/app-sidebar";
-
-export default function DashboardLayout({
- children,
-}: {
- children: React.ReactNode;
-}) {
- const router = useRouter();
- const pathname = usePathname();
- const user = useAuthStore((s) => s.user);
- const isLoading = useAuthStore((s) => s.isLoading);
- const workspace = useWorkspaceStore((s) => s.workspace);
-
- useEffect(() => {
- if (!isLoading && !user) {
- router.push("/");
- }
- }, [user, isLoading, router]);
-
- useEffect(() => {
- useNavigationStore.getState().onPathChange(pathname);
- }, [pathname]);
-
- if (isLoading) {
- return (
- <div className="flex h-screen items-center justify-center">
- <MulticaIcon className="size-6" />
- </div>
- );
- }
-
- if (!user) return null;
+export default function Layout({ children }: { children: React.ReactNode }) {
return (
- <SidebarProvider className="h-svh">
- <AppSidebar />
- <SidebarInset className="overflow-hidden">
- {workspace ? (
- <WorkspaceIdProvider wsId={workspace.id}>
- {children}
- <ModalRegistry />
- </WorkspaceIdProvider>
- ) : (
- <div className="flex flex-1 items-center justify-center">
- <MulticaIcon className="size-6 animate-pulse" />
- </div>
- )}
- </SidebarInset>
- <SearchCommand />
- </SidebarProvider>
+ <DashboardLayout
+ loadingIndicator={<MulticaIcon className="size-6" />}
+ extra={<SearchCommand />}
+ >
+ {children}
+ </DashboardLayout>
);
}
diff --git a/apps/web/app/(dashboard)/settings/page.tsx b/apps/web/app/(dashboard)/settings/page.tsx
index c8ab373d98..e8e62d0f0d 100644
--- a/apps/web/app/(dashboard)/settings/page.tsx
+++ b/apps/web/app/(dashboard)/settings/page.tsx
@@ -1,71 +1 @@
-"use client";
-
-import { User, Palette, Key, Settings, Users, FolderGit2 } from "lucide-react";
-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";
-import { TokensTab } from "./_components/tokens-tab";
-import { WorkspaceTab } from "./_components/workspace-tab";
-import { MembersTab } from "./_components/members-tab";
-import { RepositoriesTab } from "./_components/repositories-tab";
-
-const accountTabs = [
- { value: "profile", label: "Profile", icon: User },
- { value: "appearance", label: "Appearance", icon: Palette },
- { value: "tokens", label: "API Tokens", icon: Key },
-];
-
-const workspaceTabs = [
- { value: "workspace", label: "General", icon: Settings },
- { value: "repositories", label: "Repositories", icon: FolderGit2 },
- { value: "members", label: "Members", icon: Users },
-];
-
-export default function SettingsPage() {
- const workspaceName = useWorkspaceStore((s) => s.workspace?.name);
-
- return (
- <Tabs defaultValue="profile" orientation="vertical" className="flex-1 min-h-0 gap-0">
- {/* Left nav */}
- <div className="w-52 shrink-0 border-r overflow-y-auto p-4">
- <h1 className="text-sm font-semibold mb-4 px-2">Settings</h1>
- <TabsList variant="line" className="flex-col items-stretch">
- {/* My Account group */}
- <span className="px-2 pb-1 pt-2 text-xs font-medium text-muted-foreground">
- My Account
- </span>
- {accountTabs.map((tab) => (
- <TabsTrigger key={tab.value} value={tab.value}>
- <tab.icon className="h-4 w-4" />
- {tab.label}
- </TabsTrigger>
- ))}
-
- {/* Workspace group */}
- <span className="px-2 pb-1 pt-4 text-xs font-medium text-muted-foreground truncate">
- {workspaceName ?? "Workspace"}
- </span>
- {workspaceTabs.map((tab) => (
- <TabsTrigger key={tab.value} value={tab.value}>
- <tab.icon className="h-4 w-4" />
- {tab.label}
- </TabsTrigger>
- ))}
- </TabsList>
- </div>
-
- {/* Right content */}
- <div className="flex-1 min-w-0 overflow-y-auto">
- <div className="w-full max-w-3xl mx-auto p-6">
- <TabsContent value="profile"><AccountTab /></TabsContent>
- <TabsContent value="appearance"><AppearanceTab /></TabsContent>
- <TabsContent value="tokens"><TokensTab /></TabsContent>
- <TabsContent value="workspace"><WorkspaceTab /></TabsContent>
- <TabsContent value="repositories"><RepositoriesTab /></TabsContent>
- <TabsContent value="members"><MembersTab /></TabsContent>
- </div>
- </div>
- </Tabs>
- );
-}
+export { SettingsPage as default } from "@multica/views/settings";
diff --git a/apps/web/app/auth/callback/page.tsx b/apps/web/app/auth/callback/page.tsx
index 87bdd59e4b..d496103753 100644
--- a/apps/web/app/auth/callback/page.tsx
+++ b/apps/web/app/auth/callback/page.tsx
@@ -2,9 +2,9 @@
import { Suspense, useEffect, useState } from "react";
import { useSearchParams, useRouter } from "next/navigation";
-import { useAuthStore } from "@/platform/auth";
-import { useWorkspaceStore } from "@/platform/workspace";
-import { api } from "@/platform/api";
+import { useAuthStore } from "@multica/core/auth";
+import { useWorkspaceStore } from "@multica/core/workspace";
+import { api } from "@multica/core/api";
import {
Card,
CardHeader,
diff --git a/apps/web/app/globals.css b/apps/web/app/globals.css
index 5e0ad0bd20..be2a2c959d 100644
--- a/apps/web/app/globals.css
+++ b/apps/web/app/globals.css
@@ -7,8 +7,8 @@
@custom-variant dark (&:is(.dark *));
@source "../../../packages/ui/**/*.tsx";
-@source "../../../packages/core/**/*.tsx";
-@source "../../../packages/views/**/*.tsx";
+@source "../../../packages/core/**/*.{ts,tsx}";
+@source "../../../packages/views/**/*.{ts,tsx}";
@layer base {
* {
diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx
index caf0d8439c..7c796a921b 100644
--- a/apps/web/app/layout.tsx
+++ b/apps/web/app/layout.tsx
@@ -3,10 +3,7 @@ import { Geist, Geist_Mono } from "next/font/google";
import { ThemeProvider } from "@/components/theme-provider";
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";
-import { WebNavigationProvider } from "@/platform/navigation";
+import { WebProviders } from "@/components/web-providers";
import { LocaleSync } from "@/components/locale-sync";
import "./globals.css";
@@ -65,14 +62,10 @@ export default function RootLayout({
<body className="h-full overflow-hidden">
<LocaleSync />
<ThemeProvider>
- <QueryProvider>
- <WebNavigationProvider>
- <AuthInitializer>
- <WebWSProvider>{children}</WebWSProvider>
- </AuthInitializer>
- </WebNavigationProvider>
- <Toaster />
- </QueryProvider>
+ <WebProviders>
+ {children}
+ </WebProviders>
+ <Toaster />
</ThemeProvider>
</body>
</html>
diff --git a/apps/web/components/theme-provider.tsx b/apps/web/components/theme-provider.tsx
index 62eb983691..c2cedca1b2 100644
--- a/apps/web/components/theme-provider.tsx
+++ b/apps/web/components/theme-provider.tsx
@@ -3,6 +3,18 @@
import { ThemeProvider as NextThemesProvider } from "next-themes"
import { TooltipProvider } from "@multica/ui/components/ui/tooltip"
+// Suppress React 19 false-positive about next-themes' inline <script>.
+// The script works correctly; React 19 just warns about any <script> in components.
+// See: https://github.com/pacocoursey/next-themes/issues/337
+if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
+ const orig = console.error;
+ console.error = (...args: unknown[]) => {
+ if (typeof args[0] === "string" && args[0].includes("Encountered a script tag"))
+ return;
+ orig.apply(console, args);
+ };
+}
+
function ThemeProvider({
children,
...props
diff --git a/apps/web/components/web-providers.tsx b/apps/web/components/web-providers.tsx
new file mode 100644
index 0000000000..570e69cb9d
--- /dev/null
+++ b/apps/web/components/web-providers.tsx
@@ -0,0 +1,21 @@
+"use client";
+
+import { CoreProvider } from "@multica/core/platform";
+import { WebNavigationProvider } from "@/platform/navigation";
+import {
+ setLoggedInCookie,
+ clearLoggedInCookie,
+} from "@/features/auth/auth-cookie";
+
+export function WebProviders({ children }: { children: React.ReactNode }) {
+ return (
+ <CoreProvider
+ apiBaseUrl={process.env.NEXT_PUBLIC_API_URL}
+ wsUrl={process.env.NEXT_PUBLIC_WS_URL}
+ onLogin={setLoggedInCookie}
+ onLogout={clearLoggedInCookie}
+ >
+ <WebNavigationProvider>{children}</WebNavigationProvider>
+ </CoreProvider>
+ );
+}
diff --git a/apps/web/features/auth/index.ts b/apps/web/features/auth/index.ts
deleted file mode 100644
index e9881ed34c..0000000000
--- a/apps/web/features/auth/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export { useAuthStore } from "@/platform/auth";
-export { AuthInitializer } from "./initializer";
-export { setLoggedInCookie } from "./auth-cookie";
diff --git a/apps/web/features/auth/initializer.tsx b/apps/web/features/auth/initializer.tsx
deleted file mode 100644
index 715fbf79f2..0000000000
--- a/apps/web/features/auth/initializer.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-"use client";
-
-import { useEffect, type ReactNode } from "react";
-import { useAuthStore } from "@/platform/auth";
-import { useWorkspaceStore } from "@/platform/workspace";
-import { api } from "@/platform/api";
-import { createLogger } from "@multica/core/logger";
-import { setLoggedInCookie, clearLoggedInCookie } from "./auth-cookie";
-
-const logger = createLogger("auth");
-
-/**
- * Initializes auth + workspace state from localStorage on mount.
- * Fires getMe() and listWorkspaces() in parallel when a cached token exists.
- */
-export function AuthInitializer({ children }: { children: ReactNode }) {
- useEffect(() => {
- const token = localStorage.getItem("multica_token");
- if (!token) {
- clearLoggedInCookie();
- useAuthStore.setState({ isLoading: false });
- return;
- }
-
- api.setToken(token);
- const wsId = localStorage.getItem("multica_workspace_id");
-
- // Fire getMe and listWorkspaces in parallel
- const mePromise = api.getMe();
- const wsPromise = api.listWorkspaces();
-
- Promise.all([mePromise, wsPromise])
- .then(([user, wsList]) => {
- setLoggedInCookie();
- useAuthStore.setState({ user, isLoading: false });
- useWorkspaceStore.getState().hydrateWorkspace(wsList, wsId);
- })
- .catch((err) => {
- logger.error("auth init failed", err);
- api.setToken(null);
- api.setWorkspaceId(null);
- localStorage.removeItem("multica_token");
- localStorage.removeItem("multica_workspace_id");
- clearLoggedInCookie();
- useAuthStore.setState({ user: null, isLoading: false });
- });
- }, []);
-
- return <>{children}</>;
-}
diff --git a/apps/web/features/landing/components/how-it-works-section.tsx b/apps/web/features/landing/components/how-it-works-section.tsx
index 25fe70fb43..6bfc68a2c0 100644
--- a/apps/web/features/landing/components/how-it-works-section.tsx
+++ b/apps/web/features/landing/components/how-it-works-section.tsx
@@ -1,7 +1,7 @@
"use client";
import Link from "next/link";
-import { useAuthStore } from "@/features/auth";
+import { useAuthStore } from "@multica/core/auth";
import { useLocale } from "../i18n";
import { GitHubMark, githubUrl, heroButtonClassName } from "./shared";
diff --git a/apps/web/features/landing/components/landing-footer.tsx b/apps/web/features/landing/components/landing-footer.tsx
index 5e7a6ffb3f..af0113a5a8 100644
--- a/apps/web/features/landing/components/landing-footer.tsx
+++ b/apps/web/features/landing/components/landing-footer.tsx
@@ -3,7 +3,7 @@
import Link from "next/link";
import { MulticaIcon } from "@/components/multica-icon";
import { cn } from "@multica/ui/lib/utils";
-import { useAuthStore } from "@/features/auth";
+import { useAuthStore } from "@multica/core/auth";
import { useLocale, locales, localeLabels } from "../i18n";
export function LandingFooter() {
diff --git a/apps/web/features/landing/components/landing-header.tsx b/apps/web/features/landing/components/landing-header.tsx
index 5536467a1c..d48a66a681 100644
--- a/apps/web/features/landing/components/landing-header.tsx
+++ b/apps/web/features/landing/components/landing-header.tsx
@@ -3,7 +3,7 @@
import Link from "next/link";
import { MulticaIcon } from "@/components/multica-icon";
import { cn } from "@multica/ui/lib/utils";
-import { useAuthStore } from "@/features/auth";
+import { useAuthStore } from "@multica/core/auth";
import { useLocale } from "../i18n";
import { GitHubMark, githubUrl, headerButtonClassName } from "./shared";
diff --git a/apps/web/features/landing/components/landing-hero.tsx b/apps/web/features/landing/components/landing-hero.tsx
index 9e5f089df1..84bec79206 100644
--- a/apps/web/features/landing/components/landing-hero.tsx
+++ b/apps/web/features/landing/components/landing-hero.tsx
@@ -2,7 +2,7 @@
import Image from "next/image";
import Link from "next/link";
-import { useAuthStore } from "@/features/auth";
+import { useAuthStore } from "@multica/core/auth";
import { useLocale } from "../i18n";
import {
ClaudeCodeLogo,
diff --git a/apps/web/features/search/components/search-command.tsx b/apps/web/features/search/components/search-command.tsx
index 581839b4eb..f450610b48 100644
--- a/apps/web/features/search/components/search-command.tsx
+++ b/apps/web/features/search/components/search-command.tsx
@@ -5,7 +5,7 @@ import { useRouter } from "next/navigation";
import { Loader2, MessageSquare, SearchIcon } from "lucide-react";
import { Command as CommandPrimitive } from "cmdk";
import type { SearchIssueResult } from "@multica/core/types";
-import { api } from "@/platform/api";
+import { api } from "@multica/core/api";
import { StatusIcon } from "@multica/views/issues/components";
import { STATUS_CONFIG } from "@multica/core/issues/config";
import {
diff --git a/apps/web/platform/api.ts b/apps/web/platform/api.ts
deleted file mode 100644
index a3cef97cd0..0000000000
--- a/apps/web/platform/api.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { ApiClient } from "@multica/core/api/client";
-import { setApiInstance } from "@multica/core/api";
-import { createLogger } from "@multica/core/logger";
-
-const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || "";
-
-export const api = new ApiClient(API_BASE_URL, {
- logger: createLogger("api"),
- onUnauthorized: () => {
- if (typeof window !== "undefined") {
- localStorage.removeItem("multica_token");
- localStorage.removeItem("multica_workspace_id");
- if (window.location.pathname !== "/") {
- window.location.href = "/";
- }
- }
- },
-});
-
-// Register as the global singleton for @multica/core queries/mutations
-setApiInstance(api);
-
-// Hydrate from localStorage
-if (typeof window !== "undefined") {
- const token = localStorage.getItem("multica_token");
- if (token) api.setToken(token);
- const wsId = localStorage.getItem("multica_workspace_id");
- if (wsId) api.setWorkspaceId(wsId);
-}
diff --git a/apps/web/platform/auth.ts b/apps/web/platform/auth.ts
deleted file mode 100644
index 602885c7d3..0000000000
--- a/apps/web/platform/auth.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { createAuthStore, registerAuthStore } from "@multica/core/auth";
-import { api } from "./api";
-import { webStorage } from "./storage";
-import {
- setLoggedInCookie,
- clearLoggedInCookie,
-} from "../features/auth/auth-cookie";
-
-export const useAuthStore = createAuthStore({
- api,
- storage: webStorage,
- onLogin: setLoggedInCookie,
- onLogout: clearLoggedInCookie,
-});
-
-registerAuthStore(useAuthStore);
diff --git a/apps/web/platform/index.ts b/apps/web/platform/index.ts
deleted file mode 100644
index 88e6436eb7..0000000000
--- a/apps/web/platform/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export { api } from "./api";
-export { useAuthStore } from "./auth";
-export { useWorkspaceStore } from "./workspace";
diff --git a/apps/web/platform/workspace.ts b/apps/web/platform/workspace.ts
deleted file mode 100644
index 9f10ffc6bc..0000000000
--- a/apps/web/platform/workspace.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { createWorkspaceStore, registerWorkspaceStore } from "@multica/core/workspace";
-import { toast } from "sonner";
-import { api } from "./api";
-import { webStorage } from "./storage";
-
-export const useWorkspaceStore = createWorkspaceStore(api, {
- storage: webStorage,
- onError: (msg) => toast.error(msg),
-});
-
-registerWorkspaceStore(useWorkspaceStore);
diff --git a/apps/web/platform/ws-provider.tsx b/apps/web/platform/ws-provider.tsx
deleted file mode 100644
index 5b72c147f0..0000000000
--- a/apps/web/platform/ws-provider.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-"use client";
-
-import { WSProvider } from "@multica/core/realtime";
-import { useAuthStore } from "./auth";
-import { useWorkspaceStore } from "./workspace";
-import { webStorage } from "./storage";
-import { toast } from "sonner";
-
-const WS_URL = process.env.NEXT_PUBLIC_WS_URL || "ws://localhost:8080/ws";
-
-export function WebWSProvider({ children }: { children: React.ReactNode }) {
- return (
- <WSProvider
- wsUrl={WS_URL}
- authStore={useAuthStore}
- workspaceStore={useWorkspaceStore}
- storage={webStorage}
- onToast={(message, type) => {
- if (type === "error") toast.error(message);
- else toast.info(message);
- }}
- >
- {children}
- </WSProvider>
- );
-}
diff --git a/docs/plans/2026-04-09-desktop-app.md b/docs/plans/2026-04-09-desktop-app.md
new file mode 100644
index 0000000000..45f4a1f877
--- /dev/null
+++ b/docs/plans/2026-04-09-desktop-app.md
@@ -0,0 +1,1082 @@
+# Desktop App (Electron) Implementation Plan
+
+> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
+
+**Goal:** Create `apps/desktop/` Electron app that reuses `@multica/core`, `@multica/ui`, `@multica/views` — identical UI to web, with a custom frameless title bar.
+
+**Architecture:** electron-vite (Vite for main/preload/renderer), react-router-dom `createHashRouter` for routing, platform layer mirrors `apps/web/platform/`. Title bar uses `titleBarStyle: 'hiddenInset'` with a draggable top bar reserved for future tabs.
+
+**Tech Stack:** Electron 36+, electron-vite, react-router-dom v7, electron-store, next-themes, Tailwind CSS v4, shadcn/ui tokens.
+
+**Branch:** `feat/desktop-app` (from latest `main`)
+
+**Scope:** Skeleton app with full infrastructure + all extracted pages wired. Non-extracted pages (agents, inbox, settings) get placeholder routes — extraction is a follow-up task.
+
+---
+
+## Work Breakdown
+
+| Category | Count | Nature |
+|---|---|---|
+| New files to create | ~20 | Scaffold, platform layer, router, shell components |
+| Config files | ~5 | electron.vite.config, electron-builder.yml, package.json, tsconfig |
+| Pages wired from packages | 6 | issues, issues/:id, my-issues, runtimes, skills, board |
+| Placeholder pages | 3 | agents, inbox, settings (follow-up extraction) |
+| Login page | 1 | Desktop-specific (no Google OAuth initially, email OTP only) |
+
+---
+
+## Phase 1: Scaffold + Config (Tasks 1-3)
+
+### Task 1: Scaffold electron-vite project
+
+**Action:** Run scaffolding, then clean up to fit monorepo.
+
+```bash
+cd apps && npm create @quick-start/electron@latest desktop -- --template react-ts
+```
+
+Then restructure to match monorepo conventions. Remove generated boilerplate files we don't need.
+
+**Final directory structure:**
+```
+apps/desktop/
+├── src/
+│ ├── main/
+│ │ └── index.ts
+│ ├── preload/
+│ │ ├── index.ts
+│ │ └── index.d.ts
+│ └── renderer/
+│ ├── src/
+│ │ ├── main.tsx
+│ │ ├── App.tsx
+│ │ ├── globals.css
+│ │ ├── platform/
+│ │ ├── components/
+│ │ └── pages/
+│ └── index.html
+├── electron.vite.config.ts
+├── electron-builder.yml
+├── package.json
+└── tsconfig.json (three: root, node, web)
+```
+
+**Modify:** `package.json` (root) — add `"dev:desktop": "turbo dev --filter=@multica/desktop"` to scripts.
+
+**Verify:** `cd apps/desktop && pnpm install` succeeds.
+
+**Commit:** `chore: scaffold electron-vite desktop app`
+
+---
+
+### Task 2: Configure electron.vite.config.ts for monorepo
+
+**File:** `apps/desktop/electron.vite.config.ts`
+
+Key requirements:
+- Renderer uses `@vitejs/plugin-react` and `@tailwindcss/vite`
+- Resolve monorepo packages (`@multica/core`, `@multica/ui`, `@multica/views`)
+- Alias `@/` to `src/renderer/src/` for platform layer imports
+
+```typescript
+import { resolve } from "path";
+import { defineConfig, externalizeDepsPlugin } from "electron-vite";
+import react from "@vitejs/plugin-react";
+import tailwindcss from "@tailwindcss/vite";
+
+export default defineConfig({
+ main: {
+ plugins: [externalizeDepsPlugin()],
+ },
+ preload: {
+ plugins: [externalizeDepsPlugin()],
+ },
+ renderer: {
+ plugins: [react(), tailwindcss()],
+ resolve: {
+ alias: {
+ "@": resolve("src/renderer/src"),
+ },
+ },
+ },
+});
+```
+
+**Verify:** `pnpm exec electron-vite build` completes without errors.
+
+---
+
+### Task 3: Configure package.json and dependencies
+
+**File:** `apps/desktop/package.json`
+
+```json
+{
+ "name": "@multica/desktop",
+ "version": "0.1.0",
+ "private": true,
+ "type": "module",
+ "main": "./out/main/index.js",
+ "scripts": {
+ "dev": "electron-vite dev",
+ "build": "electron-vite build",
+ "typecheck": "tsc --noEmit",
+ "preview": "electron-vite preview",
+ "package": "electron-builder"
+ },
+ "dependencies": {
+ "@multica/core": "workspace:*",
+ "@multica/ui": "workspace:*",
+ "@multica/views": "workspace:*",
+ "electron-store": "^10.0.0",
+ "react-router-dom": "^7.6.0",
+ "next-themes": "^0.4.6",
+ "sonner": "^2.0.7"
+ },
+ "devDependencies": {
+ "@multica/tsconfig": "workspace:*",
+ "@tailwindcss/vite": "catalog:",
+ "@types/react": "catalog:",
+ "@types/react-dom": "catalog:",
+ "@vitejs/plugin-react": "^4.5.2",
+ "electron": "^36.3.1",
+ "electron-builder": "^26.0.12",
+ "electron-vite": "^3.1.0",
+ "react": "catalog:",
+ "react-dom": "catalog:",
+ "tailwindcss": "catalog:",
+ "typescript": "catalog:"
+ }
+}
+```
+
+**File:** `apps/desktop/electron-builder.yml`
+
+```yaml
+appId: ai.multica.desktop
+productName: Multica
+directories:
+ buildResources: build
+files:
+ - "!**/.vscode/*"
+ - "!src/*"
+ - "!electron.vite.config.*"
+ - "!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}"
+ - "!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}"
+mac:
+ target:
+ - dmg
+ - zip
+ artifactName: ${name}-${version}-${arch}.${ext}
+ entitlementsInherit: build/entitlements.mac.plist
+dmg:
+ artifactName: ${name}-${version}.${ext}
+linux:
+ target:
+ - AppImage
+ - deb
+ artifactName: ${name}-${version}-${arch}.${ext}
+win:
+ target:
+ - nsis
+ artifactName: ${name}-${version}-setup.${ext}
+```
+
+**Also add** `@tailwindcss/vite` to the pnpm catalog in `pnpm-workspace.yaml` if not already present.
+
+**Verify:** `pnpm install` from root succeeds, no version conflicts.
+
+**Commit:** `chore(desktop): configure dependencies and electron-builder`
+
+---
+
+## Phase 2: Electron Main + Preload (Tasks 4-5)
+
+### Task 4: Main process — frameless window
+
+**File:** `apps/desktop/src/main/index.ts`
+
+```typescript
+import { app, shell, BrowserWindow } from "electron";
+import { join } from "path";
+import { is } from "@electron-toolkit/utils";
+
+let mainWindow: BrowserWindow | null = null;
+
+function createWindow(): void {
+ mainWindow = new BrowserWindow({
+ width: 1280,
+ height: 800,
+ minWidth: 900,
+ minHeight: 600,
+ titleBarStyle: "hiddenInset", // macOS: keeps traffic lights, hides title
+ trafficLightPosition: { x: 16, y: 14 }, // position traffic lights inside our custom bar
+ show: false,
+ webPreferences: {
+ preload: join(__dirname, "../preload/index.js"),
+ sandbox: false,
+ },
+ });
+
+ mainWindow.on("ready-to-show", () => {
+ mainWindow?.show();
+ });
+
+ // Open external links in browser
+ mainWindow.webContents.setWindowOpenHandler((details) => {
+ shell.openExternal(details.url);
+ return { action: "deny" };
+ });
+
+ // Dev: load from Vite dev server. Prod: load built HTML.
+ if (is.dev && process.env["ELECTRON_RENDERER_URL"]) {
+ mainWindow.loadURL(process.env["ELECTRON_RENDERER_URL"]);
+ } else {
+ mainWindow.loadFile(join(__dirname, "../renderer/index.html"));
+ }
+}
+
+app.whenReady().then(() => {
+ createWindow();
+
+ app.on("activate", () => {
+ if (BrowserWindow.getAllWindows().length === 0) createWindow();
+ });
+});
+
+app.on("window-all-closed", () => {
+ if (process.platform !== "darwin") app.quit();
+});
+```
+
+**Note:** `@electron-toolkit/utils` provides `is.dev` helper. Add to devDependencies:
+```
+"@electron-toolkit/utils": "^4.0.0"
+```
+
+---
+
+### Task 5: Preload script — electron-store bridge
+
+**File:** `apps/desktop/src/preload/index.ts`
+
+```typescript
+import { contextBridge } from "electron";
+import Store from "electron-store";
+
+const store = new Store<Record<string, string>>({
+ name: "multica-desktop",
+});
+
+contextBridge.exposeInMainWorld("electronStore", {
+ get: (key: string): string | null => store.get(key) ?? null,
+ set: (key: string, value: string): void => store.set(key, value),
+ delete: (key: string): void => store.delete(key),
+});
+```
+
+**File:** `apps/desktop/src/preload/index.d.ts`
+
+```typescript
+declare global {
+ interface Window {
+ electronStore: {
+ get(key: string): string | null;
+ set(key: string, value: string): void;
+ delete(key: string): void;
+ };
+ }
+}
+export {};
+```
+
+**Commit:** `feat(desktop): add main process with frameless window and preload bridge`
+
+---
+
+## Phase 3: Renderer Platform Layer (Tasks 6-11)
+
+These files mirror `apps/web/platform/` exactly.
+
+### Task 6: Storage adapter
+
+**File:** `apps/desktop/src/renderer/src/platform/storage.ts`
+
+```typescript
+import type { StorageAdapter } from "@multica/core/types/storage";
+
+export const desktopStorage: StorageAdapter = {
+ getItem: (key) => window.electronStore.get(key),
+ setItem: (key, value) => window.electronStore.set(key, value),
+ removeItem: (key) => window.electronStore.delete(key),
+};
+```
+
+---
+
+### Task 7: API client
+
+**File:** `apps/desktop/src/renderer/src/platform/api.ts`
+
+```typescript
+import { ApiClient } from "@multica/core/api/client";
+import { setApiInstance } from "@multica/core/api";
+import { createLogger } from "@multica/core/logger";
+import { desktopStorage } from "./storage";
+
+// TODO: make configurable via settings
+const API_BASE_URL = "http://localhost:8080";
+
+export const api = new ApiClient(API_BASE_URL, {
+ logger: createLogger("api"),
+ onUnauthorized: () => {
+ desktopStorage.removeItem("multica_token");
+ desktopStorage.removeItem("multica_workspace_id");
+ // Navigate to login — handled by auth state change in React tree
+ },
+});
+
+setApiInstance(api);
+
+// Hydrate from persisted storage
+const token = desktopStorage.getItem("multica_token");
+if (token) api.setToken(token);
+const wsId = desktopStorage.getItem("multica_workspace_id");
+if (wsId) api.setWorkspaceId(wsId);
+```
+
+---
+
+### Task 8: Auth + workspace store instances
+
+**File:** `apps/desktop/src/renderer/src/platform/auth.ts`
+
+```typescript
+import { createAuthStore, registerAuthStore } from "@multica/core/auth";
+import { api } from "./api";
+import { desktopStorage } from "./storage";
+
+export const useAuthStore = createAuthStore({
+ api,
+ storage: desktopStorage,
+ // No cookies in desktop — onLogin/onLogout are no-ops
+});
+
+registerAuthStore(useAuthStore);
+```
+
+**File:** `apps/desktop/src/renderer/src/platform/workspace.ts`
+
+```typescript
+import { createWorkspaceStore, registerWorkspaceStore } from "@multica/core/workspace";
+import { toast } from "sonner";
+import { api } from "./api";
+import { desktopStorage } from "./storage";
+
+export const useWorkspaceStore = createWorkspaceStore(api, {
+ storage: desktopStorage,
+ onError: (msg) => toast.error(msg),
+});
+
+registerWorkspaceStore(useWorkspaceStore);
+```
+
+---
+
+### Task 9: Navigation provider (react-router → NavigationAdapter)
+
+**File:** `apps/desktop/src/renderer/src/platform/navigation.tsx`
+
+```typescript
+import { useNavigate, useLocation } from "react-router-dom";
+import {
+ NavigationProvider,
+ type NavigationAdapter,
+} from "@multica/views/navigation";
+
+export function DesktopNavigationProvider({
+ children,
+}: {
+ children: React.ReactNode;
+}) {
+ const navigate = useNavigate();
+ const location = useLocation();
+
+ const adapter: NavigationAdapter = {
+ push: (path) => navigate(path),
+ replace: (path) => navigate(path, { replace: true }),
+ back: () => navigate(-1),
+ pathname: location.pathname,
+ searchParams: new URLSearchParams(location.search),
+ };
+
+ return <NavigationProvider value={adapter}>{children}</NavigationProvider>;
+}
+```
+
+---
+
+### Task 10: WebSocket provider
+
+**File:** `apps/desktop/src/renderer/src/platform/ws-provider.tsx`
+
+```typescript
+import { WSProvider } from "@multica/core/realtime";
+import { useAuthStore } from "./auth";
+import { useWorkspaceStore } from "./workspace";
+import { desktopStorage } from "./storage";
+import { toast } from "sonner";
+
+// TODO: make configurable via settings
+const WS_URL = "ws://localhost:8080/ws";
+
+export function DesktopWSProvider({ children }: { children: React.ReactNode }) {
+ return (
+ <WSProvider
+ wsUrl={WS_URL}
+ authStore={useAuthStore}
+ workspaceStore={useWorkspaceStore}
+ storage={desktopStorage}
+ onToast={(message, type) => {
+ if (type === "error") toast.error(message);
+ else toast.info(message);
+ }}
+ >
+ {children}
+ </WSProvider>
+ );
+}
+```
+
+---
+
+### Task 11: Auth initializer (desktop version)
+
+**File:** `apps/desktop/src/renderer/src/platform/auth-initializer.tsx`
+
+Same as web version but uses `desktopStorage` instead of `localStorage`, and no cookies.
+
+```typescript
+import { useEffect, type ReactNode } from "react";
+import { useAuthStore } from "./auth";
+import { useWorkspaceStore } from "./workspace";
+import { api } from "./api";
+import { desktopStorage } from "./storage";
+import { createLogger } from "@multica/core/logger";
+
+const logger = createLogger("auth");
+
+export function AuthInitializer({ children }: { children: ReactNode }) {
+ useEffect(() => {
+ const token = desktopStorage.getItem("multica_token");
+ if (!token) {
+ useAuthStore.setState({ isLoading: false });
+ return;
+ }
+
+ api.setToken(token);
+ const wsId = desktopStorage.getItem("multica_workspace_id");
+
+ const mePromise = api.getMe();
+ const wsPromise = api.listWorkspaces();
+
+ Promise.all([mePromise, wsPromise])
+ .then(([user, wsList]) => {
+ useAuthStore.setState({ user, isLoading: false });
+ useWorkspaceStore.getState().hydrateWorkspace(wsList, wsId);
+ })
+ .catch((err) => {
+ logger.error("auth init failed", err);
+ api.setToken(null);
+ api.setWorkspaceId(null);
+ desktopStorage.removeItem("multica_token");
+ desktopStorage.removeItem("multica_workspace_id");
+ useAuthStore.setState({ user: null, isLoading: false });
+ });
+ }, []);
+
+ return <>{children}</>;
+}
+```
+
+**File:** `apps/desktop/src/renderer/src/platform/index.ts`
+
+```typescript
+export { api } from "./api";
+export { useAuthStore } from "./auth";
+export { useWorkspaceStore } from "./workspace";
+export { desktopStorage } from "./storage";
+```
+
+**Commit:** `feat(desktop): add renderer platform layer — storage, api, auth, ws, navigation`
+
+---
+
+## Phase 4: Title Bar + Shell (Tasks 12-14)
+
+### Task 12: Title bar component
+
+**File:** `apps/desktop/src/renderer/src/components/title-bar.tsx`
+
+A draggable top bar that accounts for macOS traffic lights. Content is placeholder for future tabs.
+
+```typescript
+export function TitleBar() {
+ return (
+ <div
+ className="h-11 shrink-0 flex items-center border-b bg-sidebar select-none"
+ style={{ WebkitAppRegion: "drag" } as React.CSSProperties}
+ >
+ {/* Left: traffic light inset area (macOS) */}
+ <div className="w-[78px] shrink-0" />
+
+ {/* Center: reserved for tabs (future) */}
+ <div className="flex-1 flex items-center px-2">
+ {/* Tab bar placeholder */}
+ </div>
+
+ {/* Right: reserved for window actions (future) */}
+ <div className="w-[40px] shrink-0" />
+ </div>
+ );
+}
+```
+
+**Note:** `WebkitAppRegion: "drag"` makes the whole bar draggable. Buttons/interactive elements inside need `WebkitAppRegion: "no-drag"`.
+
+---
+
+### Task 13: Dashboard shell (sidebar + title bar + content)
+
+**File:** `apps/desktop/src/renderer/src/components/dashboard-shell.tsx`
+
+Replicates `apps/web/app/(dashboard)/layout.tsx` structure but with title bar and react-router's `<Outlet>`.
+
+```typescript
+import { useEffect } from "react";
+import { Outlet, useNavigate, useLocation } from "react-router-dom";
+import { useNavigationStore } from "@multica/core/navigation";
+import { SidebarProvider, SidebarInset } from "@multica/ui/components/ui/sidebar";
+import { WorkspaceIdProvider } from "@multica/core/hooks";
+import { ModalRegistry } from "@multica/views/modals/registry";
+import { useAuthStore } from "@/platform/auth";
+import { useWorkspaceStore } from "@/platform/workspace";
+import { TitleBar } from "./title-bar";
+import { AppSidebar } from "./app-sidebar";
+import { MulticaIcon } from "./multica-icon";
+
+export function DashboardShell() {
+ const navigate = useNavigate();
+ const location = useLocation();
+ const user = useAuthStore((s) => s.user);
+ const isLoading = useAuthStore((s) => s.isLoading);
+ const workspace = useWorkspaceStore((s) => s.workspace);
+
+ useEffect(() => {
+ if (!isLoading && !user) {
+ navigate("/login", { replace: true });
+ }
+ }, [user, isLoading, navigate]);
+
+ useEffect(() => {
+ useNavigationStore.getState().onPathChange(location.pathname);
+ }, [location.pathname]);
+
+ if (isLoading) {
+ return (
+ <div className="flex h-screen flex-col">
+ <TitleBar />
+ <div className="flex flex-1 items-center justify-center">
+ <MulticaIcon className="size-6" />
+ </div>
+ </div>
+ );
+ }
+
+ if (!user) return null;
+
+ return (
+ <div className="flex h-screen flex-col">
+ <TitleBar />
+ <div className="flex flex-1 min-h-0">
+ <SidebarProvider className="flex-1">
+ <AppSidebar />
+ <SidebarInset className="overflow-hidden">
+ {workspace ? (
+ <WorkspaceIdProvider wsId={workspace.id}>
+ <Outlet />
+ <ModalRegistry />
+ </WorkspaceIdProvider>
+ ) : (
+ <div className="flex flex-1 items-center justify-center">
+ <MulticaIcon className="size-6 animate-pulse" />
+ </div>
+ )}
+ </SidebarInset>
+ </SidebarProvider>
+ </div>
+ </div>
+ );
+}
+```
+
+---
+
+### Task 14: Copy shared app components
+
+Copy these from `apps/web/` to `apps/desktop/src/renderer/src/components/`, adjusting imports:
+
+- `multica-icon.tsx` — Copy as-is (pure CSS, no dependencies)
+- `app-sidebar.tsx` — Copy from `apps/web/app/(dashboard)/_components/app-sidebar.tsx`, change:
+ - `@/platform/auth` → `@/platform/auth` (same alias, different root)
+ - `@/platform/workspace` → `@/platform/workspace`
+ - Any `next/link` → `AppLink` from `@multica/views/navigation` (check if already using AppLink)
+- `theme-provider.tsx` — Copy, uses `next-themes` which works in Electron too
+
+**Commit:** `feat(desktop): add title bar, dashboard shell, and shared components`
+
+---
+
+## Phase 5: Router + Pages (Tasks 15-17)
+
+### Task 15: CSS entry point
+
+**File:** `apps/desktop/src/renderer/src/globals.css`
+
+```css
+@import "tailwindcss";
+@import "tw-animate-css";
+@import "shadcn/tailwind.css";
+@import "@multica/ui/styles/tokens.css";
+
+@custom-variant dark (&:is(.dark *));
+
+@source "../../../../packages/ui/**/*.tsx";
+@source "../../../../packages/core/**/*.tsx";
+@source "../../../../packages/views/**/*.tsx";
+@source "./**/*.tsx";
+
+@layer base {
+ * {
+ @apply border-border outline-ring/50;
+ scrollbar-width: thin;
+ scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
+ }
+ *::-webkit-scrollbar { width: 6px; height: 6px; }
+ *::-webkit-scrollbar-track { background: var(--scrollbar-track); }
+ *::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
+ *::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }
+ body {
+ @apply bg-background text-foreground;
+ }
+ html {
+ @apply font-sans;
+ }
+}
+```
+
+**Note:** `@source` paths need to be relative from `apps/desktop/src/renderer/src/` to `packages/`.
+
+---
+
+### Task 16: Router + page wiring
+
+**File:** `apps/desktop/src/renderer/src/router.tsx`
+
+```typescript
+import { createHashRouter, Navigate } from "react-router-dom";
+import { DashboardShell } from "./components/dashboard-shell";
+import { LoginPage } from "./pages/login";
+
+// Extracted pages from @multica/views
+import { IssuesPage } from "@multica/views/issues/components";
+import { IssueDetail } from "@multica/views/issues/components";
+import MyIssuesPage from "@multica/views/my-issues";
+import RuntimesPage from "@multica/views/runtimes";
+import SkillsPage from "@multica/views/skills";
+
+// Placeholder pages (not yet extracted to @multica/views)
+import { PlaceholderPage } from "./pages/placeholder";
+
+export const router = createHashRouter([
+ {
+ path: "/",
+ element: <DashboardShell />,
+ children: [
+ { index: true, element: <Navigate to="/issues" replace /> },
+ { path: "issues", element: <IssuesPage /> },
+ { path: "issues/:id", element: <IssueDetail /> },
+ { path: "my-issues", element: <MyIssuesPage /> },
+ { path: "runtimes", element: <RuntimesPage /> },
+ { path: "skills", element: <SkillsPage /> },
+ { path: "agents", element: <PlaceholderPage title="Agents" /> },
+ { path: "inbox", element: <PlaceholderPage title="Inbox" /> },
+ { path: "settings", element: <PlaceholderPage title="Settings" /> },
+ { path: "board", element: <PlaceholderPage title="Board" /> },
+ ],
+ },
+ { path: "/login", element: <LoginPage /> },
+]);
+```
+
+**File:** `apps/desktop/src/renderer/src/pages/placeholder.tsx`
+
+```typescript
+export function PlaceholderPage({ title }: { title: string }) {
+ return (
+ <div className="flex flex-1 items-center justify-center">
+ <div className="text-center">
+ <h1 className="text-2xl font-bold">{title}</h1>
+ <p className="mt-2 text-muted-foreground">
+ Coming soon — requires page extraction to @multica/views.
+ </p>
+ </div>
+ </div>
+ );
+}
+```
+
+**Note on IssueDetail route:** The web version uses `issues/[id]/page.tsx` which passes the `id` param. The desktop version needs a thin wrapper:
+
+**File:** `apps/desktop/src/renderer/src/pages/issue-detail-page.tsx`
+
+```typescript
+import { useParams } from "react-router-dom";
+import { IssueDetail } from "@multica/views/issues/components";
+
+export function IssueDetailPage() {
+ const { id } = useParams<{ id: string }>();
+ if (!id) return null;
+ return <IssueDetail issueId={id} />;
+}
+```
+
+Check how `IssueDetail` receives the issue ID (via prop or via navigation adapter). Adjust accordingly.
+
+---
+
+### Task 17: App entry + provider nesting
+
+**File:** `apps/desktop/src/renderer/src/App.tsx`
+
+```typescript
+import { RouterProvider } from "react-router-dom";
+import { ThemeProvider } from "./components/theme-provider";
+import { Toaster } from "@multica/ui/components/ui/sonner";
+import { QueryProvider } from "@multica/core/provider";
+import { AuthInitializer } from "./platform/auth-initializer";
+import { DesktopWSProvider } from "./platform/ws-provider";
+import { DesktopNavigationProvider } from "./platform/navigation";
+import { router } from "./router";
+
+export default function App() {
+ return (
+ <ThemeProvider>
+ <QueryProvider>
+ <RouterProvider router={router} />
+ <Toaster />
+ </QueryProvider>
+ </ThemeProvider>
+ );
+}
+```
+
+**Important:** `DesktopNavigationProvider` and `AuthInitializer` need to be INSIDE the router context (they use `useNavigate`/`useLocation`). So they go inside `DashboardShell`, not at the App root. The `RouterProvider` provides the router context.
+
+Adjust `DashboardShell` to wrap children with providers:
+
+```typescript
+// Inside DashboardShell, wrap the return:
+return (
+ <DesktopNavigationProvider>
+ <AuthInitializer>
+ <DesktopWSProvider>
+ <div className="flex h-screen flex-col">
+ <TitleBar />
+ {/* ... rest of shell */}
+ </div>
+ </DesktopWSProvider>
+ </AuthInitializer>
+ </DesktopNavigationProvider>
+);
+```
+
+**File:** `apps/desktop/src/renderer/src/main.tsx`
+
+```typescript
+import React from "react";
+import ReactDOM from "react-dom/client";
+import App from "./App";
+import "./globals.css";
+
+ReactDOM.createRoot(document.getElementById("root")!).render(
+ <React.StrictMode>
+ <App />
+ </React.StrictMode>,
+);
+```
+
+**File:** `apps/desktop/src/renderer/index.html`
+
+```html
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Multica</title>
+ </head>
+ <body class="h-full overflow-hidden antialiased">
+ <div id="root" class="h-full"></div>
+ <script type="module" src="/src/main.tsx"></script>
+ </body>
+</html>
+```
+
+**Commit:** `feat(desktop): add router, pages, and app entry with provider nesting`
+
+---
+
+## Phase 6: Login Page + Final Verification (Tasks 18-20)
+
+### Task 18: Desktop login page
+
+**File:** `apps/desktop/src/renderer/src/pages/login.tsx`
+
+Simplified login page — email OTP only (no Google OAuth for desktop MVP). Uses `useAuthStore` and `useWorkspaceStore` from platform layer.
+
+Uses `useNavigate` from react-router-dom instead of `useRouter` from next/navigation.
+
+Structure: same Card-based layout as web login, with email input → send code → verify code flow.
+
+After successful login, navigate to `/issues`.
+
+```typescript
+import { useState, useCallback } from "react";
+import { useNavigate } from "react-router-dom";
+import { useAuthStore } from "@/platform/auth";
+import { useWorkspaceStore } from "@/platform/workspace";
+import { api } from "@/platform/api";
+import { Card, CardHeader, CardTitle, CardDescription, CardContent } 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 { MulticaIcon } from "../components/multica-icon";
+import { TitleBar } from "../components/title-bar";
+
+export function LoginPage() {
+ const navigate = useNavigate();
+ const [step, setStep] = useState<"email" | "code">("email");
+ const [email, setEmail] = useState("");
+ const [code, setCode] = useState("");
+ const [error, setError] = useState("");
+ const [loading, setLoading] = useState(false);
+
+ const handleSendCode = useCallback(async () => {
+ setLoading(true);
+ setError("");
+ try {
+ await useAuthStore.getState().sendCode(email);
+ setStep("code");
+ } catch {
+ setError("Failed to send code");
+ } finally {
+ setLoading(false);
+ }
+ }, [email]);
+
+ const handleVerify = useCallback(async () => {
+ setLoading(true);
+ setError("");
+ try {
+ await useAuthStore.getState().verifyCode(email, code);
+ const wsList = await api.listWorkspaces();
+ useWorkspaceStore.getState().hydrateWorkspace(wsList);
+ navigate("/issues", { replace: true });
+ } catch {
+ setError("Invalid code");
+ } finally {
+ setLoading(false);
+ }
+ }, [email, code, navigate]);
+
+ return (
+ <div className="flex h-screen flex-col">
+ <TitleBar />
+ <div className="flex flex-1 items-center justify-center">
+ <Card className="w-[380px]">
+ <CardHeader className="text-center">
+ <div className="mx-auto mb-4">
+ <MulticaIcon bordered size="lg" />
+ </div>
+ <CardTitle>Sign in to Multica</CardTitle>
+ <CardDescription>
+ {step === "email"
+ ? "Enter your email to get a login code"
+ : `We sent a code to ${email}`}
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ {step === "email" ? (
+ <form onSubmit={(e) => { e.preventDefault(); handleSendCode(); }}>
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <Label htmlFor="email">Email</Label>
+ <Input
+ id="email"
+ type="email"
+ placeholder="[email protected]"
+ value={email}
+ onChange={(e) => setEmail(e.target.value)}
+ autoFocus
+ />
+ </div>
+ {error && <p className="text-sm text-destructive">{error}</p>}
+ <Button className="w-full" disabled={!email || loading}>
+ {loading ? "Sending..." : "Send Code"}
+ </Button>
+ </div>
+ </form>
+ ) : (
+ <form onSubmit={(e) => { e.preventDefault(); handleVerify(); }}>
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <Label htmlFor="code">Verification Code</Label>
+ <Input
+ id="code"
+ placeholder="Enter 6-digit code"
+ value={code}
+ onChange={(e) => setCode(e.target.value)}
+ autoFocus
+ />
+ </div>
+ {error && <p className="text-sm text-destructive">{error}</p>}
+ <Button className="w-full" disabled={!code || loading}>
+ {loading ? "Verifying..." : "Verify"}
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ className="w-full"
+ onClick={() => { setStep("email"); setCode(""); setError(""); }}
+ >
+ Back
+ </Button>
+ </div>
+ </form>
+ )}
+ </CardContent>
+ </Card>
+ </div>
+ </div>
+ );
+}
+```
+
+---
+
+### Task 19: TypeScript configuration
+
+**File:** `apps/desktop/tsconfig.json`
+
+```json
+{
+ "files": [],
+ "references": [
+ { "path": "tsconfig.node.json" },
+ { "path": "tsconfig.web.json" }
+ ]
+}
+```
+
+**File:** `apps/desktop/tsconfig.node.json`
+
+```json
+{
+ "extends": "@multica/tsconfig/base.json",
+ "compilerOptions": {
+ "outDir": "out",
+ "types": ["electron-vite/node"]
+ },
+ "include": ["src/main/**/*", "src/preload/**/*", "electron.vite.config.ts"]
+}
+```
+
+**File:** `apps/desktop/tsconfig.web.json`
+
+```json
+{
+ "extends": "@multica/tsconfig/react-library.json",
+ "compilerOptions": {
+ "outDir": "out",
+ "baseUrl": ".",
+ "paths": {
+ "@/*": ["src/renderer/src/*"]
+ },
+ "types": ["electron-vite/client"]
+ },
+ "include": ["src/renderer/src/**/*", "src/preload/index.d.ts"]
+}
+```
+
+---
+
+### Task 20: Final verification
+
+**Step 1:** Run `pnpm install` from root.
+
+**Step 2:** Run `pnpm dev:desktop` (or `cd apps/desktop && pnpm dev`).
+
+**Step 3:** Verify:
+- [ ] Electron window opens with frameless title bar
+- [ ] Traffic lights (🔴🟡🟢) appear at correct position
+- [ ] Title bar area is draggable
+- [ ] Redirects to login page (no stored token)
+- [ ] Login flow works (email → code → dashboard)
+- [ ] Sidebar renders with correct navigation links
+- [ ] Issues page loads and shows data
+- [ ] Issue detail works when clicking an issue
+- [ ] My Issues, Runtimes, Skills pages load
+- [ ] Agents, Inbox, Settings show placeholder
+- [ ] Dark/light theme switching works
+- [ ] WebSocket connection establishes (check console)
+- [ ] Real-time updates work (create issue in web → appears in desktop)
+
+**Step 4:** Run `pnpm typecheck` from root — verify desktop passes.
+
+**Commit:** `feat(desktop): desktop app MVP — full dashboard with shared packages`
+
+---
+
+## Follow-Up Tasks (Not in scope)
+
+These are for future PRs:
+
+1. **Extract fat pages to @multica/views:**
+ - `agents/page.tsx` (1279 lines) → `packages/views/agents/`
+ - `inbox/page.tsx` (468 lines) → `packages/views/inbox/`
+ - `settings/page.tsx` + `_components/` → `packages/views/settings/`
+ - `login/page.tsx` → `packages/views/auth/` (with `useNavigation()` instead of `useRouter()`)
+
+2. **App sidebar extraction:** Copy from web or extract shared sidebar to `@multica/views/layout/`
+
+3. **Desktop-specific features:** Tray icon, auto-updater, global shortcuts, daemon management, deep links
+
+4. **Google OAuth for desktop:** Electron OAuth flow (redirect to system browser → callback)
+
+5. **Configurable API URL:** Settings page or env file for connecting to different backends
+
+---
+
+## Execution Order & Commits
+
+| # | Commit | Files | Risk |
+|---|---|---|---|
+| 1 | `chore: scaffold electron-vite desktop app` | config | Low |
+| 2 | `chore(desktop): configure dependencies and electron-builder` | config | Low |
+| 3 | `feat(desktop): add main process with frameless window and preload bridge` | 3 files | Low |
+| 4 | `feat(desktop): add renderer platform layer` | 7 files | Low |
+| 5 | `feat(desktop): add title bar, dashboard shell, and shared components` | 4 files | Med — sidebar copy |
+| 6 | `feat(desktop): add router, pages, and app entry` | 6 files | Med — integration |
+| 7 | `feat(desktop): desktop app MVP — verification pass` | fixes | Low |
diff --git a/docs/plans/2026-04-09-monorepo-extraction.md b/docs/plans/2026-04-09-monorepo-extraction.md
new file mode 100644
index 0000000000..52a5046ad5
--- /dev/null
+++ b/docs/plans/2026-04-09-monorepo-extraction.md
@@ -0,0 +1,868 @@
+# Monorepo Full Extraction Plan
+
+> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
+
+**Goal:** 让每个 app 只剩路由定义 + NavigationAdapter + 真正独有的功能(landing page、title bar、cookie)。所有业务逻辑、UI、状态管理、API、WS 全部在共享包里,零重复。
+
+**核心洞察:** Electron renderer 就是浏览器。localStorage、fetch、WebSocket 和 Next.js 客户端页面完全一样。URL 是环境配置不是 app 差异。所以除了 NavigationAdapter(路由框架不同),没有任何东西需要在每个 app 里单独写。
+
+**Architecture:** `@multica/core` 自带完整初始化(API、stores、WS),不需要每个 app 调用 factory。`@multica/views` 包含所有页面和 layout。每个 app 只提供路由壳子。
+
+**Tech Stack:** React 19, TanStack Query, Zustand, Tailwind CSS v4, shadcn/ui, TypeScript strict mode.
+
+**Branch:** `feat/monorepo-extraction` (from latest `feat/desktop-app`)
+
+---
+
+## Work Breakdown
+
+| Phase | Tasks | What it achieves |
+|---|---|---|
+| Phase 1: Core 自包含初始化 | 1-2 | core 自己初始化 API/stores/WS,app 不需要写任何 platform 代码 |
+| Phase 2: Sidebar & Layout | 3-5 | 共享 AppSidebar + DashboardLayout,删除两端重复 |
+| Phase 3: Login | 6-7 | 共享 LoginPage + AuthInitializer |
+| Phase 4: Agents | 8-10 | 1,279 行 → 共享模块 |
+| Phase 5: Inbox | 11-13 | 468 行 → 共享模块 |
+| Phase 6: Settings | 14-16 | 1,277 行 → 共享模块 |
+| Phase 7: 清理 | 17-18 | 删除所有 platform 目录、placeholder、死代码 |
+
+---
+
+## Phase 1: Core 自包含初始化
+
+### 设计思路
+
+现在每个 app 都要手动调用 `new ApiClient()`、`createAuthStore()`、`createWorkspaceStore()`、包 `<WSProvider>`。但这些逻辑在两个 app 里完全一样。
+
+方案:`@multica/core` 导出一个 `<CoreProvider>` 包裹整个应用。它内部自动完成所有初始化。配置通过环境变量(`VITE_API_URL` / `NEXT_PUBLIC_API_URL`)或 prop 注入。SSR-safe 的 localStorage wrapper 内置到 core 里作为默认 storage(`typeof window` 守卫对 Electron 无害)。
+
+```tsx
+// 任何 app 的根组件,只需要这样:
+<CoreProvider
+ apiBaseUrl={import.meta.env.VITE_API_URL ?? ""}
+ wsUrl={import.meta.env.VITE_WS_URL ?? "ws://localhost:8080/ws"}
+ onLogin={setLoggedInCookie} // 可选,Web 独有
+ onLogout={clearLoggedInCookie} // 可选,Web 独有
+>
+ {children}
+</CoreProvider>
+```
+
+Desktop 更简单(没有可选回调):
+```tsx
+<CoreProvider
+ apiBaseUrl={import.meta.env.VITE_API_URL ?? "http://localhost:8080"}
+ wsUrl={import.meta.env.VITE_WS_URL ?? "ws://localhost:8080/ws"}
+>
+ {children}
+</CoreProvider>
+```
+
+### Task 1: 在 `@multica/core` 里创建 CoreProvider
+
+**Files:**
+- Create: `packages/core/platform/storage.ts` — 内置 SSR-safe localStorage
+- Create: `packages/core/platform/core-provider.tsx` — CoreProvider 组件
+- Create: `packages/core/platform/auth-initializer.tsx` — 共享 AuthInitializer
+- Create: `packages/core/platform/types.ts` — CoreProviderProps
+- Create: `packages/core/platform/index.ts` — barrel export
+- Modify: `packages/core/package.json` — add `"./platform"` export
+
+**Step 1: Create built-in SSR-safe storage**
+
+```typescript
+// packages/core/platform/storage.ts
+import type { StorageAdapter } from "../types/storage";
+
+/** SSR-safe localStorage. Works in both Next.js (SSR) and Electron (always client). */
+export const defaultStorage: StorageAdapter = {
+ getItem: (k) => (typeof window !== "undefined" ? localStorage.getItem(k) : null),
+ setItem: (k, v) => { if (typeof window !== "undefined") localStorage.setItem(k, v); },
+ removeItem: (k) => { if (typeof window !== "undefined") localStorage.removeItem(k); },
+};
+```
+
+**Step 2: Create types**
+
+```typescript
+// packages/core/platform/types.ts
+export interface CoreProviderProps {
+ children: React.ReactNode;
+ /** API base URL. Default: "" (same-origin). */
+ apiBaseUrl?: string;
+ /** WebSocket URL. Default: "ws://localhost:8080/ws". */
+ wsUrl?: string;
+ /** Called after successful login (e.g. set cookie for Next.js middleware). */
+ onLogin?: () => void;
+ /** Called after logout (e.g. clear cookie). */
+ onLogout?: () => void;
+}
+```
+
+**Step 3: Create AuthInitializer**
+
+Merge the identical logic from both apps. Uses `defaultStorage`, reads from existing singletons.
+
+```typescript
+// packages/core/platform/auth-initializer.tsx
+import { useEffect, type ReactNode } from "react";
+import { getApi } from "../api";
+import { useAuthStore } from "../auth";
+import { useWorkspaceStore } from "../workspace";
+import { createLogger } from "../logger";
+import { defaultStorage } from "./storage";
+
+const logger = createLogger("auth");
+
+export function AuthInitializer({
+ children,
+ onLogin,
+ onLogout,
+}: {
+ children: ReactNode;
+ onLogin?: () => void;
+ onLogout?: () => void;
+}) {
+ useEffect(() => {
+ const token = defaultStorage.getItem("multica_token");
+ if (!token) {
+ onLogout?.();
+ useAuthStore.setState({ isLoading: false });
+ return;
+ }
+
+ const api = getApi();
+ api.setToken(token);
+ const wsId = defaultStorage.getItem("multica_workspace_id");
+
+ Promise.all([api.getMe(), api.listWorkspaces()])
+ .then(([user, wsList]) => {
+ onLogin?.();
+ useAuthStore.setState({ user, isLoading: false });
+ useWorkspaceStore.getState().hydrateWorkspace(wsList, wsId);
+ })
+ .catch((err) => {
+ logger.error("auth init failed", err);
+ api.setToken(null);
+ api.setWorkspaceId(null);
+ defaultStorage.removeItem("multica_token");
+ defaultStorage.removeItem("multica_workspace_id");
+ onLogout?.();
+ useAuthStore.setState({ user: null, isLoading: false });
+ });
+ }, []);
+
+ return <>{children}</>;
+}
+```
+
+**Step 4: Create CoreProvider**
+
+This is the one component that wires everything together. Each app wraps its root with this.
+
+```typescript
+// packages/core/platform/core-provider.tsx
+"use client";
+
+import { type ReactNode, useMemo } from "react";
+import { ApiClient } from "../api/client";
+import { setApiInstance } from "../api";
+import { createAuthStore, registerAuthStore } from "../auth";
+import { createWorkspaceStore, registerWorkspaceStore } from "../workspace";
+import { WSProvider } from "../realtime";
+import { QueryProvider } from "../provider";
+import { createLogger } from "../logger";
+import { defaultStorage } from "./storage";
+import { AuthInitializer } from "./auth-initializer";
+import type { CoreProviderProps } from "./types";
+
+// Module-level singletons — created once, shared across renders.
+let initialized = false;
+let authStore: ReturnType<typeof createAuthStore>;
+let workspaceStore: ReturnType<typeof createWorkspaceStore>;
+
+function initCore(apiBaseUrl: string) {
+ if (initialized) return;
+
+ const api = new ApiClient(apiBaseUrl, {
+ logger: createLogger("api"),
+ onUnauthorized: () => {
+ defaultStorage.removeItem("multica_token");
+ defaultStorage.removeItem("multica_workspace_id");
+ },
+ });
+ setApiInstance(api);
+
+ // Hydrate token from storage
+ const token = defaultStorage.getItem("multica_token");
+ if (token) api.setToken(token);
+ const wsId = defaultStorage.getItem("multica_workspace_id");
+ if (wsId) api.setWorkspaceId(wsId);
+
+ authStore = createAuthStore({ api, storage: defaultStorage });
+ registerAuthStore(authStore);
+
+ workspaceStore = createWorkspaceStore(api, {
+ storage: defaultStorage,
+ });
+ registerWorkspaceStore(workspaceStore);
+
+ initialized = true;
+}
+
+export function CoreProvider({
+ children,
+ apiBaseUrl = "",
+ wsUrl = "ws://localhost:8080/ws",
+ onLogin,
+ onLogout,
+}: CoreProviderProps) {
+ // Initialize singletons on first render
+ useMemo(() => initCore(apiBaseUrl), [apiBaseUrl]);
+
+ return (
+ <QueryProvider>
+ <AuthInitializer onLogin={onLogin} onLogout={onLogout}>
+ <WSProvider
+ wsUrl={wsUrl}
+ authStore={authStore}
+ workspaceStore={workspaceStore}
+ storage={defaultStorage}
+ >
+ {children}
+ </WSProvider>
+ </AuthInitializer>
+ </QueryProvider>
+ );
+}
+```
+
+**Step 5: Barrel export + package.json**
+
+```typescript
+// packages/core/platform/index.ts
+export { CoreProvider } from "./core-provider";
+export type { CoreProviderProps } from "./types";
+export { AuthInitializer } from "./auth-initializer";
+export { defaultStorage } from "./storage";
+```
+
+Add to `packages/core/package.json` exports:
+```json
+"./platform": "./platform/index.ts"
+```
+
+**Step 6: Run typecheck**
+
+Run: `pnpm typecheck`
+Expected: PASS
+
+**Step 7: Commit**
+
+```bash
+git add packages/core/platform/ packages/core/package.json
+git commit -m "feat(core): add CoreProvider — single component for full app initialization"
+```
+
+---
+
+### Task 2: Migrate both apps to CoreProvider
+
+**Files:**
+- Modify: `apps/web/app/layout.tsx` — replace all providers with `<CoreProvider>`
+- Modify: `apps/desktop/src/renderer/src/App.tsx` — replace all providers with `<CoreProvider>`
+- Delete: `apps/web/platform/api.ts`
+- Delete: `apps/web/platform/auth.ts`
+- Delete: `apps/web/platform/workspace.ts`
+- Delete: `apps/web/platform/storage.ts`
+- Delete: `apps/web/platform/ws-provider.tsx`
+- Delete: `apps/web/features/auth/initializer.tsx`
+- Delete: `apps/desktop/src/renderer/src/platform/api.ts`
+- Delete: `apps/desktop/src/renderer/src/platform/auth.ts`
+- Delete: `apps/desktop/src/renderer/src/platform/workspace.ts`
+- Delete: `apps/desktop/src/renderer/src/platform/storage.ts`
+- Delete: `apps/desktop/src/renderer/src/platform/ws-provider.tsx`
+- Delete: `apps/desktop/src/renderer/src/platform/auth-initializer.tsx`
+- Keep: `apps/web/platform/navigation.tsx` — NavigationAdapter (唯一不可共享)
+- Keep: `apps/desktop/src/renderer/src/platform/navigation.tsx` — NavigationAdapter
+- Keep: `apps/web/features/auth/auth-cookie.ts` — Web 独有
+
+**Step 1: Update web root layout**
+
+```typescript
+// apps/web/app/layout.tsx
+import { CoreProvider } from "@multica/core/platform";
+import { WebNavigationProvider } from "@/platform/navigation";
+import { setLoggedInCookie, clearLoggedInCookie } from "@/features/auth/auth-cookie";
+import { ThemeProvider } from "@/components/theme-provider";
+import { Toaster } from "sonner";
+
+export default function RootLayout({ children }: { children: React.ReactNode }) {
+ return (
+ <html lang="en" suppressHydrationWarning>
+ <body>
+ <ThemeProvider>
+ <CoreProvider
+ apiBaseUrl={process.env.NEXT_PUBLIC_API_URL}
+ wsUrl={process.env.NEXT_PUBLIC_WS_URL}
+ onLogin={setLoggedInCookie}
+ onLogout={clearLoggedInCookie}
+ >
+ <WebNavigationProvider>
+ {children}
+ </WebNavigationProvider>
+ </CoreProvider>
+ <Toaster />
+ </ThemeProvider>
+ </body>
+ </html>
+ );
+}
+```
+
+**Step 2: Update desktop App.tsx**
+
+```typescript
+// apps/desktop/src/renderer/src/App.tsx
+import { RouterProvider } from "react-router-dom";
+import { CoreProvider } from "@multica/core/platform";
+import { ThemeProvider } from "./components/theme-provider";
+import { Toaster } from "sonner";
+import { router } from "./router";
+
+export function App() {
+ return (
+ <ThemeProvider>
+ <CoreProvider
+ apiBaseUrl={import.meta.env.VITE_API_URL}
+ wsUrl={import.meta.env.VITE_WS_URL}
+ >
+ <RouterProvider router={router} />
+ </CoreProvider>
+ <Toaster />
+ </ThemeProvider>
+ );
+}
+```
+
+**Step 3: Fix all `@/platform/*` imports across both apps**
+
+Search all files for:
+- `from "@/platform/api"` → `from "@multica/core/api"` (use singleton proxy `api`)
+- `from "@/platform/auth"` → `from "@multica/core/auth"` (use singleton `useAuthStore`)
+- `from "@/platform/workspace"` → `from "@multica/core/workspace"` (use singleton `useWorkspaceStore`)
+
+These singletons already exist and are registered by CoreProvider on init. Every component can import them directly from core.
+
+**Step 4: Delete all platform files except navigation**
+
+Web — delete entire `apps/web/platform/` except `navigation.tsx`. Flatten:
+```
+apps/web/platform/navigation.tsx → keep (only file left)
+```
+
+Desktop — delete entire `apps/desktop/.../platform/` except `navigation.tsx`. Flatten:
+```
+apps/desktop/.../platform/navigation.tsx → keep (only file left)
+```
+
+**Step 5: Run typecheck + tests**
+
+Run: `pnpm typecheck && pnpm test`
+Expected: PASS
+
+**Step 6: Commit**
+
+```bash
+git commit -m "refactor: migrate both apps to CoreProvider — delete all platform duplication"
+```
+
+---
+
+## Phase 2: Sidebar & Layout
+
+### Task 3: Extract `AppSidebar` to `@multica/views/layout`
+
+**Why:** Web and Desktop sidebars are 99% identical (239 vs 236 lines). Only difference: `Link`/`usePathname`/`useRouter` (web) vs `AppLink`/`useNavigation` (desktop). Since `useNavigation` + `AppLink` is the abstraction in views, the desktop version is already the correct shared version.
+
+**Files:**
+- Create: `packages/views/layout/app-sidebar.tsx` — copy from desktop version
+- Create: `packages/views/layout/index.ts`
+- Modify: `packages/views/package.json` (add `"./layout"` export)
+- Modify: `apps/web/app/(dashboard)/layout.tsx` — import from views
+- Modify: `apps/desktop/src/renderer/src/components/dashboard-shell.tsx` — import from views
+- Delete: `apps/web/app/(dashboard)/_components/app-sidebar.tsx`
+- Delete: `apps/desktop/src/renderer/src/components/app-sidebar.tsx`
+
+**Step 1: Create shared AppSidebar**
+
+Copy desktop `app-sidebar.tsx` into `packages/views/layout/app-sidebar.tsx`. Key changes:
+- `import { useAuthStore } from "@multica/core/auth"` (singleton)
+- `import { useWorkspaceStore } from "@multica/core/workspace"` (singleton)
+- `import { api } from "@multica/core/api"` (singleton proxy)
+- `import { useNavigation, AppLink } from "../navigation"` (relative within views)
+- `import { useModalStore } from "@multica/core/modals"`
+- All `@multica/ui` imports unchanged
+
+**Step 2: Barrel export + package.json**
+
+```typescript
+// packages/views/layout/index.ts
+export { AppSidebar } from "./app-sidebar";
+```
+
+Add to `packages/views/package.json`:
+```json
+"./layout": "./layout/index.ts"
+```
+
+**Step 3: Update both apps, delete old files**
+
+**Step 4: Run typecheck**
+
+Run: `pnpm typecheck`
+
+**Step 5: Commit**
+
+```bash
+git commit -m "refactor(views): extract shared AppSidebar to @multica/views/layout"
+```
+
+---
+
+### Task 4: Extract `DashboardLayout` to `@multica/views/layout`
+
+**Why:** Both apps have identical dashboard shell: auth guard → loading → sidebar + workspace provider + content. Only differences: web has `SearchCommand`, desktop has `TitleBar`. These are slots.
+
+**Files:**
+- Create: `packages/views/layout/dashboard-layout.tsx`
+- Modify: `packages/views/layout/index.ts` (add export)
+- Modify: `apps/web/app/(dashboard)/layout.tsx` (~10 lines after)
+- Modify: `apps/desktop/src/renderer/src/components/dashboard-shell.tsx` (~10 lines after)
+
+**Step 1: Create shared DashboardLayout**
+
+```typescript
+// packages/views/layout/dashboard-layout.tsx
+"use client";
+
+import { useEffect, type ReactNode } from "react";
+import { useNavigationStore } from "@multica/core/navigation";
+import { SidebarProvider, SidebarInset } from "@multica/ui/components/ui/sidebar";
+import { WorkspaceIdProvider } from "@multica/core/hooks";
+import { useAuthStore } from "@multica/core/auth";
+import { useWorkspaceStore } from "@multica/core/workspace";
+import { ModalRegistry } from "../modals/registry";
+import { useNavigation } from "../navigation";
+import { AppSidebar } from "./app-sidebar";
+
+interface DashboardLayoutProps {
+ children: ReactNode;
+ /** Above sidebar (e.g. desktop TitleBar) */
+ header?: ReactNode;
+ /** Sibling of SidebarInset (e.g. web SearchCommand) */
+ extra?: ReactNode;
+ /** Loading indicator */
+ loadingIndicator?: ReactNode;
+ /** Redirect path when not authenticated. Default: "/" */
+ loginPath?: string;
+}
+
+export function DashboardLayout({
+ children, header, extra, loadingIndicator, loginPath = "/",
+}: DashboardLayoutProps) {
+ const { pathname, push } = useNavigation();
+ const user = useAuthStore((s) => s.user);
+ const isLoading = useAuthStore((s) => s.isLoading);
+ const workspace = useWorkspaceStore((s) => s.workspace);
+
+ useEffect(() => {
+ if (!isLoading && !user) push(loginPath);
+ }, [user, isLoading, push, loginPath]);
+
+ useEffect(() => {
+ useNavigationStore.getState().onPathChange(pathname);
+ }, [pathname]);
+
+ if (isLoading) {
+ return (
+ <div className="flex h-screen flex-col">
+ {header}
+ <div className="flex flex-1 items-center justify-center">
+ {loadingIndicator}
+ </div>
+ </div>
+ );
+ }
+
+ if (!user) return null;
+
+ return (
+ <div className="flex h-screen flex-col">
+ {header}
+ <div className="flex flex-1 min-h-0">
+ <SidebarProvider className="flex-1">
+ <AppSidebar />
+ <SidebarInset className="overflow-hidden">
+ {workspace ? (
+ <WorkspaceIdProvider wsId={workspace.id}>
+ {children}
+ <ModalRegistry />
+ </WorkspaceIdProvider>
+ ) : (
+ <div className="flex flex-1 items-center justify-center">
+ {loadingIndicator}
+ </div>
+ )}
+ </SidebarInset>
+ {extra}
+ </SidebarProvider>
+ </div>
+ </div>
+ );
+}
+```
+
+**Step 2: Slim down web layout**
+
+```typescript
+// apps/web/app/(dashboard)/layout.tsx
+"use client";
+import { DashboardLayout } from "@multica/views/layout";
+import { MulticaIcon } from "@/components/multica-icon";
+import { SearchCommand } from "@/features/search";
+
+export default function Layout({ children }: { children: React.ReactNode }) {
+ return (
+ <DashboardLayout
+ loadingIndicator={<MulticaIcon className="size-6" />}
+ extra={<SearchCommand />}
+ >
+ {children}
+ </DashboardLayout>
+ );
+}
+```
+
+**Step 3: Slim down desktop shell**
+
+```typescript
+// apps/desktop/src/renderer/src/components/dashboard-shell.tsx
+import { Outlet } from "react-router-dom";
+import { DesktopNavigationProvider } from "@/platform/navigation";
+import { DashboardLayout } from "@multica/views/layout";
+import { TitleBar } from "./title-bar";
+import { MulticaIcon } from "./multica-icon";
+
+export function DashboardShell() {
+ return (
+ <DesktopNavigationProvider>
+ <DashboardLayout
+ header={<TitleBar />}
+ loginPath="/login"
+ loadingIndicator={<MulticaIcon className="size-6" />}
+ >
+ <Outlet />
+ </DashboardLayout>
+ </DesktopNavigationProvider>
+ );
+}
+```
+
+**Step 4: Run typecheck**
+
+Run: `pnpm typecheck`
+
+**Step 5: Commit**
+
+```bash
+git commit -m "refactor(views): extract shared DashboardLayout to @multica/views/layout"
+```
+
+---
+
+### Task 5: Build + smoke test
+
+Run: `pnpm build && make check`
+
+Fix any issues, commit:
+```bash
+git commit -m "fix: fixups from layout extraction"
+```
+
+---
+
+## Phase 3: Shared Login Page
+
+### Task 6: Extract `LoginPage` to `@multica/views/auth`
+
+**Why:** Desktop login (139 lines) is a simple email/code form. Web login (393 lines) has extra: CLI callback, Google OAuth, OTP component. Strategy: extract the core email/code form to views. Desktop uses it directly. Web keeps its own richer version (too different to merge).
+
+**Files:**
+- Create: `packages/views/auth/login-page.tsx`
+- Create: `packages/views/auth/index.ts`
+- Modify: `packages/views/package.json` (add `"./auth"` export)
+- Modify: `apps/desktop/src/renderer/src/pages/login.tsx` (~10 lines after)
+
+**Step 1: Create shared LoginPage**
+
+Props: `logo?: ReactNode`, `onSuccess: () => void`. Internally uses `useAuthStore`/`useWorkspaceStore`/`api` from core singletons.
+
+**Step 2: Update desktop login**
+
+```typescript
+import { useNavigate } from "react-router-dom";
+import { LoginPage } from "@multica/views/auth";
+import { MulticaIcon } from "../components/multica-icon";
+import { TitleBar } from "../components/title-bar";
+
+export function DesktopLoginPage() {
+ const navigate = useNavigate();
+ return (
+ <div className="flex h-screen flex-col">
+ <TitleBar />
+ <LoginPage
+ logo={<MulticaIcon bordered size="lg" />}
+ onSuccess={() => navigate("/issues", { replace: true })}
+ />
+ </div>
+ );
+}
+```
+
+Web login stays as-is (CLI callback + Google OAuth = web-only features).
+
+**Step 3: Run typecheck**
+
+**Step 4: Commit**
+
+```bash
+git commit -m "feat(views): extract shared LoginPage to @multica/views/auth"
+```
+
+---
+
+### Task 7: Verify login flow in both apps
+
+Run: `pnpm typecheck && pnpm test`
+
+---
+
+## Phase 4: Extract Agents Page (1,279 lines → shared module)
+
+### Task 8: Create `@multica/views/agents`
+
+**Files:**
+- Create: `packages/views/agents/config.ts` — statusConfig, taskStatusConfig
+- Create: `packages/views/agents/components/agents-page.tsx` — main page
+- Create: `packages/views/agents/components/create-agent-dialog.tsx`
+- Create: `packages/views/agents/components/agent-list-item.tsx`
+- Create: `packages/views/agents/components/agent-detail.tsx`
+- Create: `packages/views/agents/components/tabs/instructions-tab.tsx`
+- Create: `packages/views/agents/components/tabs/skills-tab.tsx`
+- Create: `packages/views/agents/components/tabs/tasks-tab.tsx`
+- Create: `packages/views/agents/components/tabs/settings-tab.tsx`
+- Create: `packages/views/agents/components/index.ts`
+- Create: `packages/views/agents/index.ts`
+- Modify: `packages/views/package.json` (add `"./agents"` export)
+
+**Key migration:** All `@/platform/*` imports → `@multica/core/*` singletons. All `@multica/ui` and `@multica/core` imports stay as-is. `@multica/views` imports become relative.
+
+**Step 1:** Extract config → components → barrel
+**Step 2:** Run `pnpm typecheck`
+**Step 3:** Commit
+
+```bash
+git commit -m "feat(views): extract agents page to @multica/views/agents"
+```
+
+---
+
+### Task 9: Wire web agents route
+
+```typescript
+// apps/web/app/(dashboard)/agents/page.tsx — 1 line replaces 1,279
+export { AgentsPage as default } from "@multica/views/agents";
+```
+
+Commit: `refactor(web): replace agents page with @multica/views/agents import`
+
+---
+
+### Task 10: Wire desktop agents route
+
+```typescript
+// router.tsx
+import { AgentsPage } from "@multica/views/agents";
+{ path: "agents", element: <AgentsPage /> },
+```
+
+Commit: `feat(desktop): wire agents page from @multica/views`
+
+---
+
+## Phase 5: Extract Inbox Page (468 lines → shared module)
+
+### Task 11: Create `@multica/views/inbox`
+
+**Files:**
+- Create: `packages/views/inbox/components/inbox-page.tsx`
+- Create: `packages/views/inbox/components/inbox-list-item.tsx`
+- Create: `packages/views/inbox/components/inbox-detail-label.tsx`
+- Create: `packages/views/inbox/components/index.ts`
+- Create: `packages/views/inbox/index.ts`
+- Modify: `packages/views/package.json` (add `"./inbox"` export)
+
+**Key migration:**
+- `import { useSearchParams } from "next/navigation"` → `import { useNavigation } from "../navigation"` — use `searchParams` from adapter
+- `window.history.replaceState(null, "", url)` → `replace(url)` from `useNavigation()`
+- `@/platform/*` → `@multica/core/*` singletons
+
+Commit: `feat(views): extract inbox page to @multica/views/inbox`
+
+---
+
+### Task 12: Wire web inbox route
+
+```typescript
+// apps/web/app/(dashboard)/inbox/page.tsx — 1 line replaces 468
+export { InboxPage as default } from "@multica/views/inbox";
+```
+
+Commit: `refactor(web): replace inbox page with @multica/views/inbox import`
+
+---
+
+### Task 13: Wire desktop inbox route
+
+```typescript
+import { InboxPage } from "@multica/views/inbox";
+{ path: "inbox", element: <InboxPage /> },
+```
+
+Commit: `feat(desktop): wire inbox page from @multica/views`
+
+---
+
+## Phase 6: Extract Settings Page (1,277 lines → shared module)
+
+### Task 14: Create `@multica/views/settings`
+
+**Files:**
+- Create: `packages/views/settings/components/settings-page.tsx`
+- Create: `packages/views/settings/components/account-tab.tsx`
+- Create: `packages/views/settings/components/appearance-tab.tsx`
+- Create: `packages/views/settings/components/tokens-tab.tsx`
+- Create: `packages/views/settings/components/workspace-tab.tsx`
+- Create: `packages/views/settings/components/members-tab.tsx`
+- Create: `packages/views/settings/components/repositories-tab.tsx`
+- Create: `packages/views/settings/components/index.ts`
+- Create: `packages/views/settings/index.ts`
+- Modify: `packages/views/package.json` (add `"./settings"` export)
+
+**Key migration:** Same pattern — `@/platform/*` → `@multica/core/*` singletons.
+
+Commit: `feat(views): extract settings page to @multica/views/settings`
+
+---
+
+### Task 15: Wire web settings route
+
+```typescript
+// apps/web/app/(dashboard)/settings/page.tsx — 1 line replaces 1,277 (page + 6 tabs)
+export { SettingsPage as default } from "@multica/views/settings";
+```
+
+Delete `apps/web/app/(dashboard)/settings/_components/` (all 6 files).
+
+Commit: `refactor(web): replace settings page with @multica/views/settings import`
+
+---
+
+### Task 16: Wire desktop settings route
+
+```typescript
+import { SettingsPage } from "@multica/views/settings";
+{ path: "settings", element: <SettingsPage /> },
+```
+
+Commit: `feat(desktop): wire settings page from @multica/views`
+
+---
+
+## Phase 7: Cleanup
+
+### Task 17: Delete dead code
+
+- Delete `apps/desktop/src/renderer/src/pages/placeholder.tsx`
+- Delete `apps/web/platform/` directory entirely (only `navigation.tsx` remains — move to `apps/web/app/` or `apps/web/lib/`)
+- Delete `apps/desktop/src/renderer/src/platform/` directory (only `navigation.tsx` remains — move)
+- Remove unused imports across both apps
+- Clean up `apps/web/features/auth/` — only `auth-cookie.ts` should remain
+
+Commit: `chore: delete dead platform code after monorepo extraction`
+
+---
+
+### Task 18: Full verification
+
+Run: `make check`
+Expected: ALL PASS
+
+---
+
+## Final Architecture
+
+### Each app after extraction
+
+```
+apps/web/
+├── app/
+│ ├── layout.tsx # CoreProvider + WebNavigationProvider + ThemeProvider
+│ ├── (auth)/login/page.tsx # Web 独有:CLI callback, Google OAuth
+│ ├── (dashboard)/
+│ │ ├── layout.tsx # DashboardLayout + SearchCommand (10 行)
+│ │ ├── issues/page.tsx # 1 行 re-export
+│ │ ├── agents/page.tsx # 1 行 re-export
+│ │ ├── inbox/page.tsx # 1 行 re-export
+│ │ ├── settings/page.tsx # 1 行 re-export
+│ │ └── ... (all 1-line)
+│ └── (landing)/ # Web 独有
+├── lib/
+│ └── navigation.tsx # WebNavigationProvider(唯一平台代码)
+├── features/
+│ ├── auth/auth-cookie.ts # Web 独有
+│ ├── landing/ # Web 独有
+│ └── search/ # Web 独有
+└── components/ # theme, icon, loading (少量)
+
+apps/desktop/
+├── src/main/ # Electron 主进程
+├── src/preload/ # preload bridge
+├── src/renderer/src/
+│ ├── App.tsx # CoreProvider + RouterProvider + ThemeProvider
+│ ├── router.tsx # 路由表(全部 @multica/views/*)
+│ ├── lib/
+│ │ └── navigation.tsx # DesktopNavigationProvider(唯一平台代码)
+│ ├── components/
+│ │ ├── dashboard-shell.tsx # DashboardLayout + TitleBar (10 行)
+│ │ ├── title-bar.tsx # Desktop 独有
+│ │ └── multica-icon.tsx # Desktop 独有
+│ └── pages/
+│ └── login.tsx # LoginPage + TitleBar (10 行)
+```
+
+### 数字对比
+
+| 指标 | 之前 | 之后 |
+|------|------|------|
+| Web platform 文件 | 6 个 | 1 个 (navigation.tsx) |
+| Desktop platform 文件 | 7 个 | 1 个 (navigation.tsx) |
+| Web agents/page.tsx | 1,279 行 | 1 行 |
+| Web inbox/page.tsx | 468 行 | 1 行 |
+| Web settings/ 总计 | 1,277 行 | 1 行 |
+| Web sidebar | 239 行 | 0 (共享) |
+| Desktop sidebar | 236 行 (重复) | 0 (共享) |
+| Desktop placeholders | 3 个 | 0 |
+| 共享 views 模块 | 7 个 | 12 个 |
+| 两端重复代码 | ~1,500 行 | 0 行 |
diff --git a/packages/core/package.json b/packages/core/package.json
index 492ca4e691..e4f502cfec 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -41,7 +41,8 @@
"./provider": "./provider.tsx",
"./logger": "./logger.ts",
"./utils": "./utils.ts",
- "./constants/*": "./constants/*.ts"
+ "./constants/*": "./constants/*.ts",
+ "./platform": "./platform/index.ts"
},
"dependencies": {
"@tanstack/react-query": "catalog:",
diff --git a/packages/core/platform/auth-initializer.tsx b/packages/core/platform/auth-initializer.tsx
new file mode 100644
index 0000000000..4f5c8db295
--- /dev/null
+++ b/packages/core/platform/auth-initializer.tsx
@@ -0,0 +1,51 @@
+"use client";
+
+import { useEffect, type ReactNode } from "react";
+import { getApi } from "../api";
+import { useAuthStore } from "../auth";
+import { useWorkspaceStore } from "../workspace";
+import { createLogger } from "../logger";
+import { defaultStorage } from "./storage";
+
+const logger = createLogger("auth");
+
+export function AuthInitializer({
+ children,
+ onLogin,
+ onLogout,
+}: {
+ children: ReactNode;
+ onLogin?: () => void;
+ onLogout?: () => void;
+}) {
+ useEffect(() => {
+ const token = defaultStorage.getItem("multica_token");
+ if (!token) {
+ onLogout?.();
+ useAuthStore.setState({ isLoading: false });
+ return;
+ }
+
+ const api = getApi();
+ api.setToken(token);
+ const wsId = defaultStorage.getItem("multica_workspace_id");
+
+ Promise.all([api.getMe(), api.listWorkspaces()])
+ .then(([user, wsList]) => {
+ onLogin?.();
+ useAuthStore.setState({ user, isLoading: false });
+ useWorkspaceStore.getState().hydrateWorkspace(wsList, wsId);
+ })
+ .catch((err) => {
+ logger.error("auth init failed", err);
+ api.setToken(null);
+ api.setWorkspaceId(null);
+ defaultStorage.removeItem("multica_token");
+ defaultStorage.removeItem("multica_workspace_id");
+ onLogout?.();
+ useAuthStore.setState({ user: null, isLoading: false });
+ });
+ }, []);
+
+ return <>{children}</>;
+}
diff --git a/packages/core/platform/core-provider.tsx b/packages/core/platform/core-provider.tsx
new file mode 100644
index 0000000000..1bccd64e70
--- /dev/null
+++ b/packages/core/platform/core-provider.tsx
@@ -0,0 +1,73 @@
+"use client";
+
+import { useMemo } from "react";
+import { ApiClient } from "../api/client";
+import { setApiInstance } from "../api";
+import { createAuthStore, registerAuthStore } from "../auth";
+import { createWorkspaceStore, registerWorkspaceStore } from "../workspace";
+import { WSProvider } from "../realtime";
+import { QueryProvider } from "../provider";
+import { createLogger } from "../logger";
+import { defaultStorage } from "./storage";
+import { AuthInitializer } from "./auth-initializer";
+import type { CoreProviderProps } from "./types";
+
+// Module-level singletons — created once, shared across renders.
+let initialized = false;
+let authStore: ReturnType<typeof createAuthStore>;
+let workspaceStore: ReturnType<typeof createWorkspaceStore>;
+
+function initCore(apiBaseUrl: string) {
+ if (initialized) return;
+
+ const api = new ApiClient(apiBaseUrl, {
+ logger: createLogger("api"),
+ onUnauthorized: () => {
+ defaultStorage.removeItem("multica_token");
+ defaultStorage.removeItem("multica_workspace_id");
+ },
+ });
+ setApiInstance(api);
+
+ // Hydrate token from storage
+ const token = defaultStorage.getItem("multica_token");
+ if (token) api.setToken(token);
+ const wsId = defaultStorage.getItem("multica_workspace_id");
+ if (wsId) api.setWorkspaceId(wsId);
+
+ authStore = createAuthStore({ api, storage: defaultStorage });
+ registerAuthStore(authStore);
+
+ workspaceStore = createWorkspaceStore(api, {
+ storage: defaultStorage,
+ });
+ registerWorkspaceStore(workspaceStore);
+
+ initialized = true;
+}
+
+export function CoreProvider({
+ children,
+ apiBaseUrl = "",
+ wsUrl = "ws://localhost:8080/ws",
+ onLogin,
+ onLogout,
+}: CoreProviderProps) {
+ // Initialize singletons on first render
+ useMemo(() => initCore(apiBaseUrl), [apiBaseUrl]);
+
+ return (
+ <QueryProvider>
+ <AuthInitializer onLogin={onLogin} onLogout={onLogout}>
+ <WSProvider
+ wsUrl={wsUrl}
+ authStore={authStore}
+ workspaceStore={workspaceStore}
+ storage={defaultStorage}
+ >
+ {children}
+ </WSProvider>
+ </AuthInitializer>
+ </QueryProvider>
+ );
+}
diff --git a/packages/core/platform/index.ts b/packages/core/platform/index.ts
new file mode 100644
index 0000000000..cfc76c275c
--- /dev/null
+++ b/packages/core/platform/index.ts
@@ -0,0 +1,4 @@
+export { CoreProvider } from "./core-provider";
+export type { CoreProviderProps } from "./types";
+export { AuthInitializer } from "./auth-initializer";
+export { defaultStorage } from "./storage";
diff --git a/apps/web/platform/storage.ts b/packages/core/platform/storage.ts
similarity index 54%
rename from apps/web/platform/storage.ts
rename to packages/core/platform/storage.ts
index 9307328019..85a97c1150 100644
--- a/apps/web/platform/storage.ts
+++ b/packages/core/platform/storage.ts
@@ -1,10 +1,7 @@
-import type { StorageAdapter } from "@multica/core/types/storage";
+import type { StorageAdapter } from "../types/storage";
-/**
- * SSR-safe localStorage wrapper.
- * Returns null / no-ops when running on the server (typeof window === "undefined").
- */
-export const webStorage: StorageAdapter = {
+/** SSR-safe localStorage. Works in both Next.js (SSR) and Electron (always client). */
+export const defaultStorage: StorageAdapter = {
getItem: (k) =>
typeof window !== "undefined" ? localStorage.getItem(k) : null,
setItem: (k, v) => {
diff --git a/packages/core/platform/types.ts b/packages/core/platform/types.ts
new file mode 100644
index 0000000000..b1d93c908e
--- /dev/null
+++ b/packages/core/platform/types.ts
@@ -0,0 +1,11 @@
+export interface CoreProviderProps {
+ children: React.ReactNode;
+ /** API base URL. Default: "" (same-origin). */
+ apiBaseUrl?: string;
+ /** WebSocket URL. Default: "ws://localhost:8080/ws". */
+ wsUrl?: string;
+ /** Called after successful login (e.g. set cookie for Next.js middleware). */
+ onLogin?: () => void;
+ /** Called after logout (e.g. clear cookie). */
+ onLogout?: () => void;
+}
diff --git a/packages/views/agents/components/agent-detail.tsx b/packages/views/agents/components/agent-detail.tsx
new file mode 100644
index 0000000000..26daa5839b
--- /dev/null
+++ b/packages/views/agents/components/agent-detail.tsx
@@ -0,0 +1,204 @@
+"use client";
+
+import { useState } from "react";
+import {
+ Cloud,
+ Monitor,
+ FileText,
+ BookOpenText,
+ ListTodo,
+ Trash2,
+ AlertCircle,
+ MoreHorizontal,
+ Settings,
+} from "lucide-react";
+import type { Agent, RuntimeDevice } from "@multica/core/types";
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogDescription,
+ DialogFooter,
+} from "@multica/ui/components/ui/dialog";
+import {
+ DropdownMenu,
+ DropdownMenuTrigger,
+ DropdownMenuContent,
+ DropdownMenuItem,
+} from "@multica/ui/components/ui/dropdown-menu";
+import { Button } from "@multica/ui/components/ui/button";
+import { ActorAvatar } from "../../common/actor-avatar";
+import { statusConfig } from "../config";
+import { InstructionsTab } from "./tabs/instructions-tab";
+import { SkillsTab } from "./tabs/skills-tab";
+import { TasksTab } from "./tabs/tasks-tab";
+import { SettingsTab } from "./tabs/settings-tab";
+
+function getRuntimeDevice(agent: Agent, runtimes: RuntimeDevice[]): RuntimeDevice | undefined {
+ return runtimes.find((runtime) => runtime.id === agent.runtime_id);
+}
+
+type DetailTab = "instructions" | "skills" | "tasks" | "settings";
+
+const detailTabs: { id: DetailTab; label: string; icon: typeof FileText }[] = [
+ { id: "instructions", label: "Instructions", icon: FileText },
+ { id: "skills", label: "Skills", icon: BookOpenText },
+ { id: "tasks", label: "Tasks", icon: ListTodo },
+ { id: "settings", label: "Settings", icon: Settings },
+];
+
+export function AgentDetail({
+ agent,
+ runtimes,
+ onUpdate,
+ onArchive,
+ onRestore,
+}: {
+ agent: Agent;
+ runtimes: RuntimeDevice[];
+ onUpdate: (id: string, data: Partial<Agent>) => Promise<void>;
+ onArchive: (id: string) => Promise<void>;
+ onRestore: (id: string) => Promise<void>;
+}) {
+ const st = statusConfig[agent.status];
+ const runtimeDevice = getRuntimeDevice(agent, runtimes);
+ const [activeTab, setActiveTab] = useState<DetailTab>("instructions");
+ const [confirmArchive, setConfirmArchive] = useState(false);
+ const isArchived = !!agent.archived_at;
+
+ return (
+ <div className="flex h-full flex-col">
+ {/* Archive Banner */}
+ {isArchived && (
+ <div className="flex items-center gap-2 bg-muted/50 px-4 py-2 text-xs text-muted-foreground border-b">
+ <AlertCircle className="h-3.5 w-3.5 shrink-0" />
+ <span className="flex-1">This agent is archived. It cannot be assigned or mentioned.</span>
+ <Button variant="outline" size="sm" className="h-6 text-xs" onClick={() => onRestore(agent.id)}>
+ Restore
+ </Button>
+ </div>
+ )}
+
+ {/* Header */}
+ <div className="flex h-12 shrink-0 items-center gap-3 border-b px-4">
+ <ActorAvatar actorType="agent" actorId={agent.id} size={28} className={`rounded-md ${isArchived ? "opacity-50" : ""}`} />
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <h2 className={`text-sm font-semibold truncate ${isArchived ? "text-muted-foreground" : ""}`}>{agent.name}</h2>
+ {isArchived ? (
+ <span className="rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground">
+ Archived
+ </span>
+ ) : (
+ <span className={`flex items-center gap-1.5 text-xs ${st.color}`}>
+ <span className={`h-1.5 w-1.5 rounded-full ${st.dot}`} />
+ {st.label}
+ </span>
+ )}
+ <span className="flex items-center gap-1 rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground">
+ {agent.runtime_mode === "cloud" ? (
+ <Cloud className="h-3 w-3" />
+ ) : (
+ <Monitor className="h-3 w-3" />
+ )}
+ {runtimeDevice?.name ?? (agent.runtime_mode === "cloud" ? "Cloud" : "Local")}
+ </span>
+ </div>
+ </div>
+ {!isArchived && (
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button variant="ghost" size="icon-sm" />
+ }
+ >
+ <MoreHorizontal className="h-4 w-4 text-muted-foreground" />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-auto">
+ <DropdownMenuItem
+ className="text-destructive"
+ onClick={() => setConfirmArchive(true)}
+ >
+ <Trash2 className="h-3.5 w-3.5" />
+ Archive Agent
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </div>
+
+ {/* Tabs */}
+ <div className="flex border-b px-6">
+ {detailTabs.map((tab) => (
+ <button
+ key={tab.id}
+ onClick={() => setActiveTab(tab.id)}
+ className={`flex items-center gap-1.5 border-b-2 px-3 py-2.5 text-xs font-medium transition-colors ${
+ activeTab === tab.id
+ ? "border-primary text-foreground"
+ : "border-transparent text-muted-foreground hover:text-foreground"
+ }`}
+ >
+ <tab.icon className="h-3.5 w-3.5" />
+ {tab.label}
+ </button>
+ ))}
+ </div>
+
+ {/* Tab Content */}
+ <div className="flex-1 overflow-y-auto p-6">
+ {activeTab === "instructions" && (
+ <InstructionsTab
+ agent={agent}
+ onSave={(instructions) => onUpdate(agent.id, { instructions })}
+ />
+ )}
+ {activeTab === "skills" && (
+ <SkillsTab agent={agent} />
+ )}
+ {activeTab === "tasks" && <TasksTab agent={agent} />}
+ {activeTab === "settings" && (
+ <SettingsTab
+ agent={agent}
+ runtimes={runtimes}
+ onSave={(updates) => onUpdate(agent.id, updates)}
+ />
+ )}
+ </div>
+
+ {/* Archive Confirmation */}
+ {confirmArchive && (
+ <Dialog open onOpenChange={(v) => { if (!v) setConfirmArchive(false); }}>
+ <DialogContent className="max-w-sm" showCloseButton={false}>
+ <div className="flex items-center gap-3">
+ <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-destructive/10">
+ <AlertCircle className="h-5 w-5 text-destructive" />
+ </div>
+ <DialogHeader className="flex-1 gap-1">
+ <DialogTitle className="text-sm font-semibold">Archive agent?</DialogTitle>
+ <DialogDescription className="text-xs">
+ &quot;{agent.name}&quot; will be archived. It won&apos;t be assignable or mentionable, but all history is preserved. You can restore it later.
+ </DialogDescription>
+ </DialogHeader>
+ </div>
+ <DialogFooter>
+ <Button variant="ghost" onClick={() => setConfirmArchive(false)}>
+ Cancel
+ </Button>
+ <Button
+ variant="destructive"
+ onClick={() => {
+ setConfirmArchive(false);
+ onArchive(agent.id);
+ }}
+ >
+ Archive
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )}
+ </div>
+ );
+}
diff --git a/packages/views/agents/components/agent-list-item.tsx b/packages/views/agents/components/agent-list-item.tsx
new file mode 100644
index 0000000000..be0c393510
--- /dev/null
+++ b/packages/views/agents/components/agent-list-item.tsx
@@ -0,0 +1,51 @@
+"use client";
+
+import { Cloud, Monitor } from "lucide-react";
+import type { Agent } from "@multica/core/types";
+import { ActorAvatar } from "../../common/actor-avatar";
+import { statusConfig } from "../config";
+
+export function AgentListItem({
+ agent,
+ isSelected,
+ onClick,
+}: {
+ agent: Agent;
+ isSelected: boolean;
+ onClick: () => void;
+}) {
+ const st = statusConfig[agent.status];
+ const isArchived = !!agent.archived_at;
+
+ return (
+ <button
+ onClick={onClick}
+ className={`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors ${
+ isSelected ? "bg-accent" : "hover:bg-accent/50"
+ }`}
+ >
+ <ActorAvatar actorType="agent" actorId={agent.id} size={32} className={`rounded-lg ${isArchived ? "opacity-50 grayscale" : ""}`} />
+
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <span className={`truncate text-sm font-medium ${isArchived ? "text-muted-foreground" : ""}`}>{agent.name}</span>
+ {agent.runtime_mode === "cloud" ? (
+ <Cloud className="h-3 w-3 text-muted-foreground" />
+ ) : (
+ <Monitor className="h-3 w-3 text-muted-foreground" />
+ )}
+ </div>
+ <div className="flex items-center gap-1.5 mt-0.5">
+ {isArchived ? (
+ <span className="text-xs text-muted-foreground">Archived</span>
+ ) : (
+ <>
+ <span className={`h-1.5 w-1.5 rounded-full ${st.dot}`} />
+ <span className={`text-xs ${st.color}`}>{st.label}</span>
+ </>
+ )}
+ </div>
+ </div>
+ </button>
+ );
+}
diff --git a/packages/views/agents/components/agents-page.tsx b/packages/views/agents/components/agents-page.tsx
new file mode 100644
index 0000000000..523a1476e3
--- /dev/null
+++ b/packages/views/agents/components/agents-page.tsx
@@ -0,0 +1,235 @@
+"use client";
+
+import { useState, useEffect, useMemo } from "react";
+import { useDefaultLayout } from "react-resizable-panels";
+import { Bot, Plus, Archive } from "lucide-react";
+import type { Agent, CreateAgentRequest, UpdateAgentRequest } from "@multica/core/types";
+import {
+ ResizablePanelGroup,
+ ResizablePanel,
+ ResizableHandle,
+} from "@multica/ui/components/ui/resizable";
+import { Button } from "@multica/ui/components/ui/button";
+import { toast } from "sonner";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
+import { api } from "@multica/core/api";
+import { useAuthStore } from "@multica/core/auth";
+import { useWorkspaceStore } from "@multica/core/workspace";
+import { runtimeListOptions } from "@multica/core/runtimes/queries";
+import { useQuery, useQueryClient } from "@tanstack/react-query";
+import { useWorkspaceId } from "@multica/core/hooks";
+import { agentListOptions, workspaceKeys } from "@multica/core/workspace/queries";
+import { CreateAgentDialog } from "./create-agent-dialog";
+import { AgentListItem } from "./agent-list-item";
+import { AgentDetail } from "./agent-detail";
+
+export function AgentsPage() {
+ const isLoading = useAuthStore((s) => s.isLoading);
+ const workspace = useWorkspaceStore((s) => s.workspace);
+ const qc = useQueryClient();
+ const wsId = useWorkspaceId();
+ const { data: agents = [] } = useQuery(agentListOptions(wsId));
+ const [selectedId, setSelectedId] = useState<string>("");
+ const [showArchived, setShowArchived] = useState(false);
+ const [showCreate, setShowCreate] = useState(false);
+ const { data: runtimes = [] } = useQuery(runtimeListOptions(wsId));
+ const { defaultLayout, onLayoutChanged } = useDefaultLayout({
+ id: "multica_agents_layout",
+ });
+
+ const filteredAgents = useMemo(
+ () => showArchived ? agents.filter((a) => !!a.archived_at) : agents.filter((a) => !a.archived_at),
+ [agents, showArchived],
+ );
+
+ const archivedCount = useMemo(() => agents.filter((a) => !!a.archived_at).length, [agents]);
+
+ // Select first agent on initial load or when filter changes
+ useEffect(() => {
+ if (filteredAgents.length > 0 && !filteredAgents.some((a) => a.id === selectedId)) {
+ setSelectedId(filteredAgents[0]!.id);
+ }
+ }, [filteredAgents, selectedId]);
+
+ const handleCreate = async (data: CreateAgentRequest) => {
+ const agent = await api.createAgent(data);
+ qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) });
+ setSelectedId(agent.id);
+ };
+
+ const handleUpdate = async (id: string, data: Record<string, unknown>) => {
+ try {
+ await api.updateAgent(id, data as UpdateAgentRequest);
+ qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) });
+ toast.success("Agent updated");
+ } catch (e) {
+ toast.error(e instanceof Error ? e.message : "Failed to update agent");
+ throw e;
+ }
+ };
+
+ const handleArchive = async (id: string) => {
+ try {
+ await api.archiveAgent(id);
+ qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) });
+ toast.success("Agent archived");
+ } catch (e) {
+ toast.error(e instanceof Error ? e.message : "Failed to archive agent");
+ }
+ };
+
+ const handleRestore = async (id: string) => {
+ try {
+ await api.restoreAgent(id);
+ qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) });
+ toast.success("Agent restored");
+ } catch (e) {
+ toast.error(e instanceof Error ? e.message : "Failed to restore agent");
+ }
+ };
+
+ const selected = agents.find((a) => a.id === selectedId) ?? null;
+
+ if (isLoading) {
+ return (
+ <div className="flex flex-1 min-h-0">
+ {/* List skeleton */}
+ <div className="w-72 border-r">
+ <div className="flex h-12 items-center justify-between border-b px-4">
+ <Skeleton className="h-4 w-16" />
+ <Skeleton className="h-6 w-6 rounded" />
+ </div>
+ <div className="divide-y">
+ {Array.from({ length: 4 }).map((_, i) => (
+ <div key={i} className="flex items-center gap-3 px-4 py-3">
+ <Skeleton className="h-8 w-8 rounded-full" />
+ <div className="flex-1 space-y-1.5">
+ <Skeleton className="h-4 w-24" />
+ <Skeleton className="h-3 w-16" />
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+ {/* Detail skeleton */}
+ <div className="flex-1 p-6 space-y-6">
+ <div className="flex items-center gap-3">
+ <Skeleton className="h-10 w-10 rounded-full" />
+ <div className="space-y-1.5">
+ <Skeleton className="h-5 w-32" />
+ <Skeleton className="h-3 w-20" />
+ </div>
+ </div>
+ <div className="space-y-3">
+ <Skeleton className="h-8 w-full rounded-lg" />
+ <Skeleton className="h-8 w-full rounded-lg" />
+ <Skeleton className="h-8 w-3/4 rounded-lg" />
+ </div>
+ </div>
+ </div>
+ );
+ }
+
+ return (
+ <ResizablePanelGroup
+ orientation="horizontal"
+ className="flex-1 min-h-0"
+ defaultLayout={defaultLayout}
+ onLayoutChanged={onLayoutChanged}
+ >
+ <ResizablePanel id="list" defaultSize={280} minSize={240} maxSize={400} groupResizeBehavior="preserve-pixel-size">
+ {/* Left column — agent list */}
+ <div className="overflow-y-auto h-full border-r">
+ <div className="flex h-12 items-center justify-between border-b px-4">
+ <h1 className="text-sm font-semibold">Agents</h1>
+ <div className="flex items-center gap-1">
+ {archivedCount > 0 && (
+ <Button
+ variant={showArchived ? "secondary" : "ghost"}
+ size="icon-xs"
+ onClick={() => setShowArchived(!showArchived)}
+ title={showArchived ? "Show active agents" : "Show archived agents"}
+ >
+ <Archive className="h-4 w-4 text-muted-foreground" />
+ </Button>
+ )}
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ onClick={() => setShowCreate(true)}
+ >
+ <Plus className="h-4 w-4 text-muted-foreground" />
+ </Button>
+ </div>
+ </div>
+ {filteredAgents.length === 0 ? (
+ <div className="flex flex-col items-center justify-center px-4 py-12">
+ <Bot className="h-8 w-8 text-muted-foreground/40" />
+ <p className="mt-3 text-sm text-muted-foreground">
+ {showArchived ? "No archived agents" : archivedCount > 0 ? "No active agents" : "No agents yet"}
+ </p>
+ {!showArchived && (
+ <Button
+ onClick={() => setShowCreate(true)}
+ size="xs"
+ className="mt-3"
+ >
+ <Plus className="h-3 w-3" />
+ Create Agent
+ </Button>
+ )}
+ </div>
+ ) : (
+ <div className="divide-y">
+ {filteredAgents.map((agent) => (
+ <AgentListItem
+ key={agent.id}
+ agent={agent}
+ isSelected={agent.id === selectedId}
+ onClick={() => setSelectedId(agent.id)}
+ />
+ ))}
+ </div>
+ )}
+ </div>
+ </ResizablePanel>
+
+ <ResizableHandle />
+
+ <ResizablePanel id="detail" minSize="50%">
+ {/* Right column — agent detail */}
+ {selected ? (
+ <AgentDetail
+ key={selected.id}
+ agent={selected}
+ runtimes={runtimes}
+ onUpdate={handleUpdate}
+ onArchive={handleArchive}
+ onRestore={handleRestore}
+ />
+ ) : (
+ <div className="flex h-full flex-col items-center justify-center text-muted-foreground">
+ <Bot className="h-10 w-10 text-muted-foreground/30" />
+ <p className="mt-3 text-sm">Select an agent to view details</p>
+ <Button
+ onClick={() => setShowCreate(true)}
+ size="xs"
+ className="mt-3"
+ >
+ <Plus className="h-3 w-3" />
+ Create Agent
+ </Button>
+ </div>
+ )}
+ </ResizablePanel>
+
+ {showCreate && (
+ <CreateAgentDialog
+ runtimes={runtimes}
+ onClose={() => setShowCreate(false)}
+ onCreate={handleCreate}
+ />
+ )}
+ </ResizablePanelGroup>
+ );
+}
diff --git a/packages/views/agents/components/create-agent-dialog.tsx b/packages/views/agents/components/create-agent-dialog.tsx
new file mode 100644
index 0000000000..879f703ced
--- /dev/null
+++ b/packages/views/agents/components/create-agent-dialog.tsx
@@ -0,0 +1,229 @@
+"use client";
+
+import { useState, useEffect } from "react";
+import {
+ Cloud,
+ Monitor,
+ ChevronDown,
+ Globe,
+ Lock,
+} from "lucide-react";
+import type {
+ AgentVisibility,
+ RuntimeDevice,
+ CreateAgentRequest,
+} from "@multica/core/types";
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogDescription,
+ DialogFooter,
+} from "@multica/ui/components/ui/dialog";
+import {
+ Popover,
+ PopoverTrigger,
+ PopoverContent,
+} 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";
+
+export function CreateAgentDialog({
+ runtimes,
+ onClose,
+ onCreate,
+}: {
+ runtimes: RuntimeDevice[];
+ onClose: () => void;
+ onCreate: (data: CreateAgentRequest) => Promise<void>;
+}) {
+ const [name, setName] = useState("");
+ const [description, setDescription] = useState("");
+ const [selectedRuntimeId, setSelectedRuntimeId] = useState(runtimes[0]?.id ?? "");
+ const [visibility, setVisibility] = useState<AgentVisibility>("private");
+ const [creating, setCreating] = useState(false);
+ const [runtimeOpen, setRuntimeOpen] = useState(false);
+
+ useEffect(() => {
+ if (!selectedRuntimeId && runtimes[0]) {
+ setSelectedRuntimeId(runtimes[0].id);
+ }
+ }, [runtimes, selectedRuntimeId]);
+
+ const selectedRuntime = runtimes.find((d) => d.id === selectedRuntimeId) ?? null;
+
+ const handleSubmit = async () => {
+ if (!name.trim() || !selectedRuntime) return;
+ setCreating(true);
+ try {
+ await onCreate({
+ name: name.trim(),
+ description: description.trim(),
+ runtime_id: selectedRuntime.id,
+ visibility,
+ });
+ onClose();
+ } catch (err) {
+ toast.error(err instanceof Error ? err.message : "Failed to create agent");
+ setCreating(false);
+ }
+ };
+
+ return (
+ <Dialog open onOpenChange={(v) => { if (!v) onClose(); }}>
+ <DialogContent className="sm:max-w-md">
+ <DialogHeader>
+ <DialogTitle>Create Agent</DialogTitle>
+ <DialogDescription>
+ Create a new AI agent for your workspace.
+ </DialogDescription>
+ </DialogHeader>
+
+ <div className="space-y-4">
+ <div>
+ <Label className="text-xs text-muted-foreground">Name</Label>
+ <Input
+ autoFocus
+ type="text"
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ placeholder="e.g. Deep Research Agent"
+ className="mt-1"
+ onKeyDown={(e) => e.key === "Enter" && handleSubmit()}
+ />
+ </div>
+
+ <div>
+ <Label className="text-xs text-muted-foreground">Description</Label>
+ <Input
+ type="text"
+ value={description}
+ onChange={(e) => setDescription(e.target.value)}
+ placeholder="What does this agent do?"
+ className="mt-1"
+ />
+ </div>
+
+ <div>
+ <Label className="text-xs text-muted-foreground">Visibility</Label>
+ <div className="mt-1.5 flex gap-2">
+ <button
+ type="button"
+ onClick={() => setVisibility("workspace")}
+ className={`flex flex-1 items-center gap-2 rounded-lg border px-3 py-2.5 text-sm transition-colors ${
+ visibility === "workspace"
+ ? "border-primary bg-primary/5"
+ : "border-border hover:bg-muted"
+ }`}
+ >
+ <Globe className="h-4 w-4 shrink-0 text-muted-foreground" />
+ <div className="text-left">
+ <div className="font-medium">Workspace</div>
+ <div className="text-xs text-muted-foreground">All members can assign</div>
+ </div>
+ </button>
+ <button
+ type="button"
+ onClick={() => setVisibility("private")}
+ className={`flex flex-1 items-center gap-2 rounded-lg border px-3 py-2.5 text-sm transition-colors ${
+ visibility === "private"
+ ? "border-primary bg-primary/5"
+ : "border-border hover:bg-muted"
+ }`}
+ >
+ <Lock className="h-4 w-4 shrink-0 text-muted-foreground" />
+ <div className="text-left">
+ <div className="font-medium">Private</div>
+ <div className="text-xs text-muted-foreground">Only you can assign</div>
+ </div>
+ </button>
+ </div>
+ </div>
+
+ <div>
+ <Label className="text-xs text-muted-foreground">Runtime</Label>
+ <Popover open={runtimeOpen} onOpenChange={setRuntimeOpen}>
+ <PopoverTrigger
+ disabled={runtimes.length === 0}
+ className="flex w-full items-center gap-3 rounded-lg border border-border bg-background px-3 py-2.5 mt-1.5 text-left text-sm transition-colors hover:bg-muted disabled:pointer-events-none disabled:opacity-50"
+ >
+ {selectedRuntime?.runtime_mode === "cloud" ? (
+ <Cloud className="h-4 w-4 shrink-0 text-muted-foreground" />
+ ) : (
+ <Monitor className="h-4 w-4 shrink-0 text-muted-foreground" />
+ )}
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <span className="truncate font-medium">
+ {selectedRuntime?.name ?? "No runtime available"}
+ </span>
+ {selectedRuntime?.runtime_mode === "cloud" && (
+ <span className="shrink-0 rounded bg-info/10 px-1.5 py-0.5 text-xs font-medium text-info">
+ Cloud
+ </span>
+ )}
+ </div>
+ <div className="truncate text-xs text-muted-foreground">
+ {selectedRuntime?.device_info ?? "Register a runtime before creating an agent"}
+ </div>
+ </div>
+ <ChevronDown className={`h-4 w-4 shrink-0 text-muted-foreground transition-transform ${runtimeOpen ? "rotate-180" : ""}`} />
+ </PopoverTrigger>
+ <PopoverContent align="start" className="w-[var(--anchor-width)] p-1 max-h-60 overflow-y-auto">
+ {runtimes.map((device) => (
+ <button
+ key={device.id}
+ onClick={() => {
+ setSelectedRuntimeId(device.id);
+ setRuntimeOpen(false);
+ }}
+ className={`flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm transition-colors ${
+ device.id === selectedRuntimeId ? "bg-accent" : "hover:bg-accent/50"
+ }`}
+ >
+ {device.runtime_mode === "cloud" ? (
+ <Cloud className="h-4 w-4 shrink-0 text-muted-foreground" />
+ ) : (
+ <Monitor className="h-4 w-4 shrink-0 text-muted-foreground" />
+ )}
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <span className="truncate font-medium">{device.name}</span>
+ {device.runtime_mode === "cloud" && (
+ <span className="shrink-0 rounded bg-info/10 px-1.5 py-0.5 text-xs font-medium text-info">
+ Cloud
+ </span>
+ )}
+ </div>
+ <div className="truncate text-xs text-muted-foreground">{device.device_info}</div>
+ </div>
+ <span
+ className={`h-2 w-2 shrink-0 rounded-full ${
+ device.status === "online" ? "bg-success" : "bg-muted-foreground/40"
+ }`}
+ />
+ </button>
+ ))}
+ </PopoverContent>
+ </Popover>
+ </div>
+ </div>
+
+ <DialogFooter>
+ <Button variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ <Button
+ onClick={handleSubmit}
+ disabled={creating || !name.trim() || !selectedRuntime}
+ >
+ {creating ? "Creating..." : "Create"}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+}
diff --git a/packages/views/agents/components/index.ts b/packages/views/agents/components/index.ts
new file mode 100644
index 0000000000..01cdf9ce75
--- /dev/null
+++ b/packages/views/agents/components/index.ts
@@ -0,0 +1 @@
+export { AgentsPage } from "./agents-page";
diff --git a/packages/views/agents/components/tabs/instructions-tab.tsx b/packages/views/agents/components/tabs/instructions-tab.tsx
new file mode 100644
index 0000000000..419966f6c8
--- /dev/null
+++ b/packages/views/agents/components/tabs/instructions-tab.tsx
@@ -0,0 +1,71 @@
+"use client";
+
+import { useState, useEffect } from "react";
+import { Loader2, Save } from "lucide-react";
+import type { Agent } from "@multica/core/types";
+import { Button } from "@multica/ui/components/ui/button";
+
+export function InstructionsTab({
+ agent,
+ onSave,
+}: {
+ agent: Agent;
+ onSave: (instructions: string) => Promise<void>;
+}) {
+ const [value, setValue] = useState(agent.instructions ?? "");
+ const [saving, setSaving] = useState(false);
+ const isDirty = value !== (agent.instructions ?? "");
+
+ // Sync when switching between agents.
+ useEffect(() => {
+ setValue(agent.instructions ?? "");
+ }, [agent.id, agent.instructions]);
+
+ const handleSave = async () => {
+ setSaving(true);
+ try {
+ await onSave(value);
+ } catch {
+ // toast handled by parent
+ } finally {
+ setSaving(false);
+ }
+ };
+
+ return (
+ <div className="space-y-4">
+ <div>
+ <h3 className="text-sm font-semibold">Agent Instructions</h3>
+ <p className="text-xs text-muted-foreground mt-0.5">
+ Define this agent&apos;s identity and working style. These instructions are
+ injected into the agent&apos;s context for every task.
+ </p>
+ </div>
+
+ <textarea
+ value={value}
+ onChange={(e) => setValue(e.target.value)}
+ placeholder={`Define this agent's role, expertise, and working style.\n\nExample:\nYou are a frontend engineer specializing in React and TypeScript.\n\n## Working Style\n- Write small, focused PRs — one commit per logical change\n- Prefer composition over inheritance\n- Always add unit tests for new components\n\n## Constraints\n- Do not modify shared/ types without explicit approval\n- Follow the existing component patterns in features/`}
+ className="w-full min-h-[300px] rounded-md border bg-transparent px-3 py-2 text-sm font-mono placeholder:text-muted-foreground/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-y"
+ />
+
+ <div className="flex items-center justify-between">
+ <span className="text-xs text-muted-foreground">
+ {value.length > 0 ? `${value.length} characters` : "No instructions set"}
+ </span>
+ <Button
+ size="xs"
+ onClick={handleSave}
+ disabled={!isDirty || saving}
+ >
+ {saving ? (
+ <Loader2 className="h-3 w-3 animate-spin" />
+ ) : (
+ <Save className="h-3 w-3" />
+ )}
+ Save
+ </Button>
+ </div>
+ </div>
+ );
+}
diff --git a/packages/views/agents/components/tabs/settings-tab.tsx b/packages/views/agents/components/tabs/settings-tab.tsx
new file mode 100644
index 0000000000..6102db798f
--- /dev/null
+++ b/packages/views/agents/components/tabs/settings-tab.tsx
@@ -0,0 +1,195 @@
+"use client";
+
+import { useState, useRef } from "react";
+import {
+ Cloud,
+ Monitor,
+ Loader2,
+ Save,
+ Globe,
+ Lock,
+ Camera,
+} from "lucide-react";
+import type { Agent, AgentVisibility, RuntimeDevice } from "@multica/core/types";
+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 { api } from "@multica/core/api";
+import { useFileUpload } from "@multica/core/hooks/use-file-upload";
+import { ActorAvatar } from "../../../common/actor-avatar";
+
+export function SettingsTab({
+ agent,
+ runtimes,
+ onSave,
+}: {
+ agent: Agent;
+ runtimes: RuntimeDevice[];
+ onSave: (updates: Partial<Agent>) => Promise<void>;
+}) {
+ const [name, setName] = useState(agent.name);
+ const [description, setDescription] = useState(agent.description ?? "");
+ const [visibility, setVisibility] = useState<AgentVisibility>(agent.visibility);
+ const [maxTasks, setMaxTasks] = useState(agent.max_concurrent_tasks);
+ const [saving, setSaving] = useState(false);
+ const { upload, uploading } = useFileUpload(api);
+ const fileInputRef = useRef<HTMLInputElement>(null);
+
+ const handleAvatarUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
+ const file = e.target.files?.[0];
+ if (!file) return;
+ e.target.value = "";
+ try {
+ const result = await upload(file);
+ if (!result) return;
+ await onSave({ avatar_url: result.link });
+ toast.success("Avatar updated");
+ } catch (err) {
+ toast.error(err instanceof Error ? err.message : "Failed to upload avatar");
+ }
+ };
+
+ const dirty =
+ name !== agent.name ||
+ description !== (agent.description ?? "") ||
+ visibility !== agent.visibility ||
+ maxTasks !== agent.max_concurrent_tasks;
+
+ const handleSave = async () => {
+ if (!name.trim()) {
+ toast.error("Name is required");
+ return;
+ }
+ setSaving(true);
+ try {
+ await onSave({ name: name.trim(), description, visibility, max_concurrent_tasks: maxTasks });
+ toast.success("Settings saved");
+ } catch {
+ toast.error("Failed to save settings");
+ } finally {
+ setSaving(false);
+ }
+ };
+
+ const runtimeDevice = runtimes.find((r) => r.id === agent.runtime_id);
+
+ return (
+ <div className="max-w-lg space-y-6">
+ <div>
+ <Label className="text-xs text-muted-foreground">Avatar</Label>
+ <div className="mt-1.5 flex items-center gap-4">
+ <button
+ type="button"
+ className="group relative h-16 w-16 shrink-0 rounded-full bg-muted overflow-hidden focus:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ onClick={() => fileInputRef.current?.click()}
+ disabled={uploading}
+ >
+ <ActorAvatar actorType="agent" actorId={agent.id} size={64} className="rounded-none" />
+ <div className="absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 transition-opacity group-hover:opacity-100">
+ {uploading ? (
+ <Loader2 className="h-5 w-5 animate-spin text-white" />
+ ) : (
+ <Camera className="h-5 w-5 text-white" />
+ )}
+ </div>
+ </button>
+ <input
+ ref={fileInputRef}
+ type="file"
+ accept="image/*"
+ className="hidden"
+ onChange={handleAvatarUpload}
+ />
+ <div className="text-xs text-muted-foreground">
+ Click to upload avatar
+ </div>
+ </div>
+ </div>
+
+ <div>
+ <Label className="text-xs text-muted-foreground">Name</Label>
+ <Input
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ className="mt-1"
+ />
+ </div>
+
+ <div>
+ <Label className="text-xs text-muted-foreground">Description</Label>
+ <Input
+ value={description}
+ onChange={(e) => setDescription(e.target.value)}
+ placeholder="What does this agent do?"
+ className="mt-1"
+ />
+ </div>
+
+ <div>
+ <Label className="text-xs text-muted-foreground">Visibility</Label>
+ <div className="mt-1.5 flex gap-2">
+ <button
+ type="button"
+ onClick={() => setVisibility("workspace")}
+ className={`flex flex-1 items-center gap-2 rounded-lg border px-3 py-2.5 text-sm transition-colors ${
+ visibility === "workspace"
+ ? "border-primary bg-primary/5"
+ : "border-border hover:bg-muted"
+ }`}
+ >
+ <Globe className="h-4 w-4 shrink-0 text-muted-foreground" />
+ <div className="text-left">
+ <div className="font-medium">Workspace</div>
+ <div className="text-xs text-muted-foreground">All members can assign</div>
+ </div>
+ </button>
+ <button
+ type="button"
+ onClick={() => setVisibility("private")}
+ className={`flex flex-1 items-center gap-2 rounded-lg border px-3 py-2.5 text-sm transition-colors ${
+ visibility === "private"
+ ? "border-primary bg-primary/5"
+ : "border-border hover:bg-muted"
+ }`}
+ >
+ <Lock className="h-4 w-4 shrink-0 text-muted-foreground" />
+ <div className="text-left">
+ <div className="font-medium">Private</div>
+ <div className="text-xs text-muted-foreground">Only you can assign</div>
+ </div>
+ </button>
+ </div>
+ </div>
+
+ <div>
+ <Label className="text-xs text-muted-foreground">Max Concurrent Tasks</Label>
+ <Input
+ type="number"
+ min={1}
+ max={50}
+ value={maxTasks}
+ onChange={(e) => setMaxTasks(Number(e.target.value))}
+ className="mt-1 w-24"
+ />
+ </div>
+
+ <div>
+ <Label className="text-xs text-muted-foreground">Runtime</Label>
+ <div className="mt-1 flex items-center gap-2 rounded-lg border px-3 py-2.5 text-sm text-muted-foreground">
+ {agent.runtime_mode === "cloud" ? (
+ <Cloud className="h-4 w-4" />
+ ) : (
+ <Monitor className="h-4 w-4" />
+ )}
+ {runtimeDevice?.name ?? (agent.runtime_mode === "cloud" ? "Cloud" : "Local")}
+ </div>
+ </div>
+
+ <Button onClick={handleSave} disabled={!dirty || saving} size="sm">
+ {saving ? <Loader2 className="h-3.5 w-3.5 mr-1.5 animate-spin" /> : <Save className="h-3.5 w-3.5 mr-1.5" />}
+ Save Changes
+ </Button>
+ </div>
+ );
+}
diff --git a/packages/views/agents/components/tabs/skills-tab.tsx b/packages/views/agents/components/tabs/skills-tab.tsx
new file mode 100644
index 0000000000..53b7896387
--- /dev/null
+++ b/packages/views/agents/components/tabs/skills-tab.tsx
@@ -0,0 +1,178 @@
+"use client";
+
+import { useState } from "react";
+import { Plus, FileText, Trash2 } from "lucide-react";
+import type { Agent } from "@multica/core/types";
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogDescription,
+ DialogFooter,
+} from "@multica/ui/components/ui/dialog";
+import { Button } from "@multica/ui/components/ui/button";
+import { toast } from "sonner";
+import { api } from "@multica/core/api";
+import { useWorkspaceId } from "@multica/core/hooks";
+import { skillListOptions, workspaceKeys } from "@multica/core/workspace/queries";
+import { useQuery, useQueryClient } from "@tanstack/react-query";
+
+export function SkillsTab({
+ agent,
+}: {
+ agent: Agent;
+}) {
+ const qc = useQueryClient();
+ const wsId = useWorkspaceId();
+ const { data: workspaceSkills = [] } = useQuery(skillListOptions(wsId));
+ const [saving, setSaving] = useState(false);
+ const [showPicker, setShowPicker] = useState(false);
+
+ const agentSkillIds = new Set(agent.skills.map((s) => s.id));
+ const availableSkills = workspaceSkills.filter((s) => !agentSkillIds.has(s.id));
+
+ const handleAdd = async (skillId: string) => {
+ setSaving(true);
+ try {
+ const newIds = [...agent.skills.map((s) => s.id), skillId];
+ await api.setAgentSkills(agent.id, { skill_ids: newIds });
+ qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) });
+ } catch (e) {
+ toast.error(e instanceof Error ? e.message : "Failed to add skill");
+ } finally {
+ setSaving(false);
+ setShowPicker(false);
+ }
+ };
+
+ const handleRemove = async (skillId: string) => {
+ setSaving(true);
+ try {
+ const newIds = agent.skills.filter((s) => s.id !== skillId).map((s) => s.id);
+ await api.setAgentSkills(agent.id, { skill_ids: newIds });
+ qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) });
+ } catch (e) {
+ toast.error(e instanceof Error ? e.message : "Failed to remove skill");
+ } finally {
+ setSaving(false);
+ }
+ };
+
+ return (
+ <div className="space-y-4">
+ <div className="flex items-center justify-between">
+ <div>
+ <h3 className="text-sm font-semibold">Skills</h3>
+ <p className="text-xs text-muted-foreground mt-0.5">
+ Reusable skills assigned to this agent. Manage skills on the Skills page.
+ </p>
+ </div>
+ <Button
+ variant="outline"
+ size="xs"
+ onClick={() => setShowPicker(true)}
+ disabled={saving || availableSkills.length === 0}
+ >
+ <Plus className="h-3 w-3" />
+ Add Skill
+ </Button>
+ </div>
+
+ {agent.skills.length === 0 ? (
+ <div className="flex flex-col items-center justify-center rounded-lg border border-dashed py-12">
+ <FileText className="h-8 w-8 text-muted-foreground/40" />
+ <p className="mt-3 text-sm text-muted-foreground">No skills assigned</p>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Add skills from the workspace to this agent.
+ </p>
+ {availableSkills.length > 0 && (
+ <Button
+ onClick={() => setShowPicker(true)}
+ size="xs"
+ className="mt-3"
+ disabled={saving}
+ >
+ <Plus className="h-3 w-3" />
+ Add Skill
+ </Button>
+ )}
+ </div>
+ ) : (
+ <div className="space-y-2">
+ {agent.skills.map((skill) => (
+ <div
+ key={skill.id}
+ className="flex items-center gap-3 rounded-lg border px-4 py-3"
+ >
+ <div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-muted">
+ <FileText className="h-4 w-4 text-muted-foreground" />
+ </div>
+ <div className="min-w-0 flex-1">
+ <div className="text-sm font-medium">{skill.name}</div>
+ {skill.description && (
+ <div className="text-xs text-muted-foreground truncate">
+ {skill.description}
+ </div>
+ )}
+ </div>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ onClick={() => handleRemove(skill.id)}
+ disabled={saving}
+ className="text-muted-foreground hover:text-destructive"
+ >
+ <Trash2 className="h-3.5 w-3.5" />
+ </Button>
+ </div>
+ ))}
+ </div>
+ )}
+
+ {/* Skill Picker Dialog */}
+ {showPicker && (
+ <Dialog open onOpenChange={(v) => { if (!v) setShowPicker(false); }}>
+ <DialogContent className="max-w-md">
+ <DialogHeader>
+ <DialogTitle className="text-sm">Add Skill</DialogTitle>
+ <DialogDescription className="text-xs">
+ Select a skill to assign to this agent.
+ </DialogDescription>
+ </DialogHeader>
+ <div className="max-h-64 overflow-y-auto space-y-1">
+ {availableSkills.map((skill) => (
+ <button
+ key={skill.id}
+ onClick={() => handleAdd(skill.id)}
+ disabled={saving}
+ className="flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm transition-colors hover:bg-accent/50"
+ >
+ <FileText className="h-4 w-4 shrink-0 text-muted-foreground" />
+ <div className="min-w-0 flex-1">
+ <div className="font-medium">{skill.name}</div>
+ {skill.description && (
+ <div className="text-xs text-muted-foreground truncate">
+ {skill.description}
+ </div>
+ )}
+ </div>
+ </button>
+ ))}
+ {availableSkills.length === 0 && (
+ <p className="py-6 text-center text-xs text-muted-foreground">
+ All workspace skills are already assigned.
+ </p>
+ )}
+ </div>
+ <DialogFooter>
+ <Button variant="ghost" onClick={() => setShowPicker(false)}>
+ Cancel
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )}
+ </div>
+ );
+}
diff --git a/packages/views/agents/components/tabs/tasks-tab.tsx b/packages/views/agents/components/tabs/tasks-tab.tsx
new file mode 100644
index 0000000000..d405caf578
--- /dev/null
+++ b/packages/views/agents/components/tabs/tasks-tab.tsx
@@ -0,0 +1,135 @@
+"use client";
+
+import { useState, useEffect } from "react";
+import { ListTodo } from "lucide-react";
+import type { Agent, AgentTask } from "@multica/core/types";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
+import { api } from "@multica/core/api";
+import { useWorkspaceId } from "@multica/core/hooks";
+import { issueListOptions } from "@multica/core/issues/queries";
+import { useQuery } from "@tanstack/react-query";
+import { taskStatusConfig } from "../../config";
+
+export function TasksTab({ agent }: { agent: Agent }) {
+ const [tasks, setTasks] = useState<AgentTask[]>([]);
+ const [loading, setLoading] = useState(true);
+ const wsId = useWorkspaceId();
+ const { data: issues = [] } = useQuery(issueListOptions(wsId));
+
+ useEffect(() => {
+ setLoading(true);
+ api
+ .listAgentTasks(agent.id)
+ .then(setTasks)
+ .catch(() => setTasks([]))
+ .finally(() => setLoading(false));
+ }, [agent.id]);
+
+ if (loading) {
+ return (
+ <div className="space-y-2">
+ {Array.from({ length: 3 }).map((_, i) => (
+ <div key={i} className="flex items-center gap-3 rounded-lg border px-4 py-3">
+ <Skeleton className="h-4 w-4 rounded shrink-0" />
+ <div className="flex-1 space-y-1.5">
+ <Skeleton className="h-4 w-1/2" />
+ <Skeleton className="h-3 w-1/3" />
+ </div>
+ <Skeleton className="h-4 w-16" />
+ </div>
+ ))}
+ </div>
+ );
+ }
+
+ // Sort: active tasks (running > dispatched > queued) first, then completed/failed by date
+ const activeStatuses = ["running", "dispatched", "queued"];
+ const sortedTasks = [...tasks].sort((a, b) => {
+ const aActive = activeStatuses.indexOf(a.status);
+ const bActive = activeStatuses.indexOf(b.status);
+ const aIsActive = aActive !== -1;
+ const bIsActive = bActive !== -1;
+ if (aIsActive && !bIsActive) return -1;
+ if (!aIsActive && bIsActive) return 1;
+ if (aIsActive && bIsActive) return aActive - bActive;
+ return new Date(b.created_at).getTime() - new Date(a.created_at).getTime();
+ });
+
+ const issueMap = new Map(issues.map((i) => [i.id, i]));
+
+ return (
+ <div className="space-y-4">
+ <div>
+ <h3 className="text-sm font-semibold">Task Queue</h3>
+ <p className="text-xs text-muted-foreground mt-0.5">
+ Issues assigned to this agent and their execution status.
+ </p>
+ </div>
+
+ {tasks.length === 0 ? (
+ <div className="flex flex-col items-center justify-center rounded-lg border border-dashed py-12">
+ <ListTodo className="h-8 w-8 text-muted-foreground/40" />
+ <p className="mt-3 text-sm text-muted-foreground">No tasks in queue</p>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Assign an issue to this agent to get started.
+ </p>
+ </div>
+ ) : (
+ <div className="space-y-1.5">
+ {sortedTasks.map((task) => {
+ const config = taskStatusConfig[task.status] ?? taskStatusConfig.queued!;
+ const Icon = config.icon;
+ const issue = issueMap.get(task.issue_id);
+ const isActive = task.status === "running" || task.status === "dispatched";
+ const isRunning = task.status === "running";
+
+ return (
+ <div
+ key={task.id}
+ className={`flex items-center gap-3 rounded-lg border px-4 py-3 ${
+ isRunning
+ ? "border-success/40 bg-success/5"
+ : task.status === "dispatched"
+ ? "border-info/40 bg-info/5"
+ : ""
+ }`}
+ >
+ <Icon
+ className={`h-4 w-4 shrink-0 ${config.color} ${
+ isRunning ? "animate-spin" : ""
+ }`}
+ />
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ {issue && (
+ <span className="shrink-0 text-xs font-mono text-muted-foreground">
+ {issue.identifier}
+ </span>
+ )}
+ <span className={`text-sm truncate ${isActive ? "font-medium" : ""}`}>
+ {issue?.title ?? `Issue ${task.issue_id.slice(0, 8)}...`}
+ </span>
+ </div>
+ <div className="text-xs text-muted-foreground mt-0.5">
+ {isRunning && task.started_at
+ ? `Started ${new Date(task.started_at).toLocaleString()}`
+ : task.status === "dispatched" && task.dispatched_at
+ ? `Dispatched ${new Date(task.dispatched_at).toLocaleString()}`
+ : task.status === "completed" && task.completed_at
+ ? `Completed ${new Date(task.completed_at).toLocaleString()}`
+ : task.status === "failed" && task.completed_at
+ ? `Failed ${new Date(task.completed_at).toLocaleString()}`
+ : `Queued ${new Date(task.created_at).toLocaleString()}`}
+ </div>
+ </div>
+ <span className={`shrink-0 text-xs font-medium ${config.color}`}>
+ {config.label}
+ </span>
+ </div>
+ );
+ })}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/packages/views/agents/config.ts b/packages/views/agents/config.ts
new file mode 100644
index 0000000000..43c65a15c6
--- /dev/null
+++ b/packages/views/agents/config.ts
@@ -0,0 +1,25 @@
+import type { AgentStatus } from "@multica/core/types";
+import {
+ Clock,
+ CheckCircle2,
+ XCircle,
+ Loader2,
+ Play,
+} from "lucide-react";
+
+export const statusConfig: Record<AgentStatus, { label: string; color: string; dot: string }> = {
+ idle: { label: "Idle", color: "text-muted-foreground", dot: "bg-muted-foreground" },
+ working: { label: "Working", color: "text-success", dot: "bg-success" },
+ blocked: { label: "Blocked", color: "text-warning", dot: "bg-warning" },
+ error: { label: "Error", color: "text-destructive", dot: "bg-destructive" },
+ offline: { label: "Offline", color: "text-muted-foreground/50", dot: "bg-muted-foreground/40" },
+};
+
+export const taskStatusConfig: Record<string, { label: string; icon: typeof CheckCircle2; color: string }> = {
+ queued: { label: "Queued", icon: Clock, color: "text-muted-foreground" },
+ dispatched: { label: "Dispatched", icon: Play, color: "text-info" },
+ running: { label: "Running", icon: Loader2, color: "text-success" },
+ completed: { label: "Completed", icon: CheckCircle2, color: "text-success" },
+ failed: { label: "Failed", icon: XCircle, color: "text-destructive" },
+ cancelled: { label: "Cancelled", icon: XCircle, color: "text-muted-foreground" },
+};
diff --git a/packages/views/agents/index.ts b/packages/views/agents/index.ts
new file mode 100644
index 0000000000..5477f4bb96
--- /dev/null
+++ b/packages/views/agents/index.ts
@@ -0,0 +1 @@
+export { AgentsPage } from "./components";
diff --git a/packages/views/auth/index.ts b/packages/views/auth/index.ts
new file mode 100644
index 0000000000..1cb1254d8b
--- /dev/null
+++ b/packages/views/auth/index.ts
@@ -0,0 +1 @@
+export { LoginPage } from "./login-page";
diff --git a/packages/views/auth/login-page.tsx b/packages/views/auth/login-page.tsx
new file mode 100644
index 0000000000..3a167c8be4
--- /dev/null
+++ b/packages/views/auth/login-page.tsx
@@ -0,0 +1,151 @@
+"use client";
+
+import { useState, useCallback, type ReactNode } from "react";
+import {
+ Card,
+ CardHeader,
+ CardTitle,
+ CardDescription,
+ CardContent,
+} 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 { useAuthStore } from "@multica/core/auth";
+import { useWorkspaceStore } from "@multica/core/workspace";
+import { api } from "@multica/core/api";
+
+interface LoginPageProps {
+ /** Logo element rendered above the title */
+ logo?: ReactNode;
+ /** Called after successful login + workspace hydration */
+ onSuccess: () => void;
+}
+
+export function LoginPage({ logo, onSuccess }: LoginPageProps) {
+ const [step, setStep] = useState<"email" | "code">("email");
+ const [email, setEmail] = useState("");
+ const [code, setCode] = useState("");
+ const [error, setError] = useState("");
+ const [loading, setLoading] = useState(false);
+
+ const handleSendCode = useCallback(async () => {
+ setLoading(true);
+ setError("");
+ try {
+ await useAuthStore.getState().sendCode(email);
+ setStep("code");
+ } catch {
+ setError("Failed to send code");
+ } finally {
+ setLoading(false);
+ }
+ }, [email]);
+
+ const handleVerify = useCallback(async () => {
+ setLoading(true);
+ setError("");
+ try {
+ await useAuthStore.getState().verifyCode(email, code);
+ const wsList = await api.listWorkspaces();
+ useWorkspaceStore.getState().hydrateWorkspace(wsList);
+ onSuccess();
+ } catch {
+ setError("Invalid code");
+ } finally {
+ setLoading(false);
+ }
+ }, [email, code, onSuccess]);
+
+ return (
+ <div className="flex flex-1 items-center justify-center">
+ <Card className="w-[380px]">
+ <CardHeader className="text-center">
+ {logo && <div className="mx-auto mb-4">{logo}</div>}
+ <CardTitle>Sign in to Multica</CardTitle>
+ <CardDescription>
+ {step === "email"
+ ? "Enter your email to get a login code"
+ : `We sent a code to ${email}`}
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ {step === "email" ? (
+ <form
+ onSubmit={(e) => {
+ e.preventDefault();
+ handleSendCode();
+ }}
+ >
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <Label htmlFor="login-email">Email</Label>
+ <Input
+ id="login-email"
+ type="email"
+ placeholder="[email protected]"
+ value={email}
+ onChange={(e) => setEmail(e.target.value)}
+ autoFocus
+ />
+ </div>
+ {error && (
+ <p className="text-sm text-destructive">{error}</p>
+ )}
+ <Button
+ type="submit"
+ className="w-full"
+ disabled={!email || loading}
+ >
+ {loading ? "Sending..." : "Send Code"}
+ </Button>
+ </div>
+ </form>
+ ) : (
+ <form
+ onSubmit={(e) => {
+ e.preventDefault();
+ handleVerify();
+ }}
+ >
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <Label htmlFor="login-code">Verification Code</Label>
+ <Input
+ id="login-code"
+ placeholder="Enter 6-digit code"
+ value={code}
+ onChange={(e) => setCode(e.target.value)}
+ autoFocus
+ />
+ </div>
+ {error && (
+ <p className="text-sm text-destructive">{error}</p>
+ )}
+ <Button
+ type="submit"
+ className="w-full"
+ disabled={!code || loading}
+ >
+ {loading ? "Verifying..." : "Verify"}
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ className="w-full"
+ onClick={() => {
+ setStep("email");
+ setCode("");
+ setError("");
+ }}
+ >
+ Back
+ </Button>
+ </div>
+ </form>
+ )}
+ </CardContent>
+ </Card>
+ </div>
+ );
+}
diff --git a/packages/views/inbox/components/inbox-detail-label.tsx b/packages/views/inbox/components/inbox-detail-label.tsx
new file mode 100644
index 0000000000..79fce46eda
--- /dev/null
+++ b/packages/views/inbox/components/inbox-detail-label.tsx
@@ -0,0 +1,92 @@
+"use client";
+
+import { STATUS_CONFIG, PRIORITY_CONFIG } from "@multica/core/issues/config";
+import { useActorName } from "@multica/core/workspace/hooks";
+import { StatusIcon, PriorityIcon } from "../../issues/components";
+import type { InboxItem, InboxItemType, IssueStatus, IssuePriority } from "@multica/core/types";
+
+const typeLabels: Record<InboxItemType, string> = {
+ issue_assigned: "Assigned",
+ unassigned: "Unassigned",
+ assignee_changed: "Assignee changed",
+ status_changed: "Status changed",
+ priority_changed: "Priority changed",
+ due_date_changed: "Due date changed",
+ new_comment: "New comment",
+ mentioned: "Mentioned",
+ review_requested: "Review requested",
+ task_completed: "Task completed",
+ task_failed: "Task failed",
+ agent_blocked: "Agent blocked",
+ agent_completed: "Agent completed",
+ reaction_added: "Reacted",
+};
+
+export { typeLabels };
+
+function shortDate(dateStr: string): string {
+ if (!dateStr) return "";
+ return new Date(dateStr).toLocaleDateString("en-US", {
+ month: "short",
+ day: "numeric",
+ });
+}
+
+export function InboxDetailLabel({ item }: { item: InboxItem }) {
+ const { getActorName } = useActorName();
+ const details = item.details ?? {};
+
+ switch (item.type) {
+ case "status_changed": {
+ if (!details.to) return <span>{typeLabels[item.type]}</span>;
+ const label = STATUS_CONFIG[details.to as IssueStatus]?.label ?? details.to;
+ return (
+ <span className="inline-flex items-center gap-1">
+ Set status to
+ <StatusIcon status={details.to as IssueStatus} className="h-3 w-3" />
+ {label}
+ </span>
+ );
+ }
+ case "priority_changed": {
+ if (!details.to) return <span>{typeLabels[item.type]}</span>;
+ const label = PRIORITY_CONFIG[details.to as IssuePriority]?.label ?? details.to;
+ return (
+ <span className="inline-flex items-center gap-1">
+ Set priority to
+ <PriorityIcon priority={details.to as IssuePriority} className="h-3 w-3" />
+ {label}
+ </span>
+ );
+ }
+ case "issue_assigned": {
+ if (details.new_assignee_id) {
+ return <span>Assigned to {getActorName(details.new_assignee_type ?? "member", details.new_assignee_id)}</span>;
+ }
+ return <span>{typeLabels[item.type]}</span>;
+ }
+ case "unassigned":
+ return <span>Removed assignee</span>;
+ case "assignee_changed": {
+ if (details.new_assignee_id) {
+ return <span>Assigned to {getActorName(details.new_assignee_type ?? "member", details.new_assignee_id)}</span>;
+ }
+ return <span>{typeLabels[item.type]}</span>;
+ }
+ case "due_date_changed": {
+ if (details.to) return <span>Set due date to {shortDate(details.to)}</span>;
+ return <span>Removed due date</span>;
+ }
+ case "new_comment": {
+ if (item.body) return <span>{item.body}</span>;
+ return <span>{typeLabels[item.type]}</span>;
+ }
+ case "reaction_added": {
+ const emoji = details.emoji;
+ if (emoji) return <span>Reacted {emoji} to your comment</span>;
+ return <span>{typeLabels[item.type]}</span>;
+ }
+ default:
+ return <span>{typeLabels[item.type] ?? item.type}</span>;
+ }
+}
diff --git a/packages/views/inbox/components/inbox-list-item.tsx b/packages/views/inbox/components/inbox-list-item.tsx
new file mode 100644
index 0000000000..51d3b4ccf5
--- /dev/null
+++ b/packages/views/inbox/components/inbox-list-item.tsx
@@ -0,0 +1,92 @@
+"use client";
+
+import { StatusIcon } from "../../issues/components";
+import { ActorAvatar } from "../../common/actor-avatar";
+import { Archive } from "lucide-react";
+import type { InboxItem } from "@multica/core/types";
+import { InboxDetailLabel } from "./inbox-detail-label";
+
+function timeAgo(dateStr: string): string {
+ const diff = Date.now() - new Date(dateStr).getTime();
+ const minutes = Math.floor(diff / 60000);
+ if (minutes < 1) return "just now";
+ if (minutes < 60) return `${minutes}m`;
+ const hours = Math.floor(minutes / 60);
+ if (hours < 24) return `${hours}h`;
+ const days = Math.floor(hours / 24);
+ return `${days}d`;
+}
+
+export { timeAgo };
+
+export function InboxListItem({
+ item,
+ isSelected,
+ onClick,
+ onArchive,
+}: {
+ item: InboxItem;
+ isSelected: boolean;
+ onClick: () => void;
+ onArchive: () => void;
+}) {
+ return (
+ <button
+ onClick={onClick}
+ className={`group flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${
+ isSelected ? "bg-accent" : "hover:bg-accent/50"
+ }`}
+ >
+ <ActorAvatar
+ actorType={item.actor_type ?? item.recipient_type}
+ actorId={item.actor_id ?? item.recipient_id}
+ size={28}
+ />
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center justify-between gap-2">
+ <div className="flex min-w-0 items-center gap-1.5">
+ {!item.read && (
+ <span className="h-1.5 w-1.5 shrink-0 rounded-full bg-brand" />
+ )}
+ <span
+ className={`truncate text-sm ${!item.read ? "font-medium" : "text-muted-foreground"}`}
+ >
+ {item.title}
+ </span>
+ </div>
+ <div className="flex shrink-0 items-center gap-1">
+ <span
+ role="button"
+ tabIndex={-1}
+ title="Archive"
+ onClick={(e) => {
+ e.stopPropagation();
+ onArchive();
+ }}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" || e.key === " ") {
+ e.stopPropagation();
+ onArchive();
+ }
+ }}
+ className="hidden rounded p-0.5 text-muted-foreground hover:bg-accent hover:text-foreground group-hover:inline-flex"
+ >
+ <Archive className="h-3.5 w-3.5" />
+ </span>
+ {item.issue_status && (
+ <StatusIcon status={item.issue_status} className="h-3.5 w-3.5 shrink-0" />
+ )}
+ </div>
+ </div>
+ <div className="mt-0.5 flex items-center justify-between gap-2">
+ <p className={`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-xs ${item.read ? "text-muted-foreground/60" : "text-muted-foreground"}`}>
+ <InboxDetailLabel item={item} />
+ </p>
+ <span className={`shrink-0 text-xs ${item.read ? "text-muted-foreground/60" : "text-muted-foreground"}`}>
+ {timeAgo(item.created_at)}
+ </span>
+ </div>
+ </div>
+ </button>
+ );
+}
diff --git a/packages/views/inbox/components/inbox-page.tsx b/packages/views/inbox/components/inbox-page.tsx
new file mode 100644
index 0000000000..b16ede35b6
--- /dev/null
+++ b/packages/views/inbox/components/inbox-page.tsx
@@ -0,0 +1,283 @@
+"use client";
+
+import { useState, useEffect, useCallback, useMemo } from "react";
+import { useDefaultLayout } from "react-resizable-panels";
+import { useQuery } from "@tanstack/react-query";
+import { useWorkspaceId } from "@multica/core/hooks";
+import {
+ inboxListOptions,
+ deduplicateInboxItems,
+} from "@multica/core/inbox/queries";
+import {
+ useMarkInboxRead,
+ useArchiveInbox,
+ useMarkAllInboxRead,
+ useArchiveAllInbox,
+ useArchiveAllReadInbox,
+ useArchiveCompletedInbox,
+} from "@multica/core/inbox/mutations";
+import { IssueDetail } from "../../issues/components";
+import { useNavigation } from "../../navigation";
+import { toast } from "sonner";
+import {
+ MoreHorizontal,
+ Inbox,
+ CheckCheck,
+ Archive,
+ BookCheck,
+ ListChecks,
+} from "lucide-react";
+import type { InboxItem } from "@multica/core/types";
+import { Button } from "@multica/ui/components/ui/button";
+import {
+ ResizablePanelGroup,
+ ResizablePanel,
+ ResizableHandle,
+} from "@multica/ui/components/ui/resizable";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
+import {
+ DropdownMenu,
+ DropdownMenuTrigger,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+} from "@multica/ui/components/ui/dropdown-menu";
+import { InboxListItem, timeAgo } from "./inbox-list-item";
+import { typeLabels } from "./inbox-detail-label";
+
+export function InboxPage() {
+ const { searchParams, replace } = useNavigation();
+ const urlIssue = searchParams.get("issue") ?? "";
+
+ const [selectedKey, setSelectedKeyState] = useState(() => urlIssue);
+
+ // Sync from URL when searchParams change (e.g. navigation)
+ useEffect(() => {
+ setSelectedKeyState(urlIssue);
+ }, [urlIssue]);
+
+ const setSelectedKey = useCallback((key: string) => {
+ setSelectedKeyState(key);
+ const url = key ? `/inbox?issue=${key}` : "/inbox";
+ replace(url);
+ }, [replace]);
+
+ const wsId = useWorkspaceId();
+ const { data: rawItems = [], isLoading: loading } = useQuery(inboxListOptions(wsId));
+ const items = useMemo(() => deduplicateInboxItems(rawItems), [rawItems]);
+
+ const { defaultLayout, onLayoutChanged } = useDefaultLayout({
+ id: "multica_inbox_layout",
+ });
+
+ const selected = items.find((i) => (i.issue_id ?? i.id) === selectedKey) ?? null;
+ const unreadCount = items.filter((i) => !i.read).length;
+
+ const markReadMutation = useMarkInboxRead();
+ const archiveMutation = useArchiveInbox();
+ const markAllReadMutation = useMarkAllInboxRead();
+ const archiveAllMutation = useArchiveAllInbox();
+ const archiveAllReadMutation = useArchiveAllReadInbox();
+ const archiveCompletedMutation = useArchiveCompletedInbox();
+
+ // Click-to-read: select + auto-mark-read
+ const handleSelect = (item: InboxItem) => {
+ setSelectedKey(item.issue_id ?? item.id);
+ if (!item.read) {
+ markReadMutation.mutate(item.id, {
+ onError: () => toast.error("Failed to mark as read"),
+ });
+ }
+ };
+
+ const handleArchive = (id: string) => {
+ const archived = items.find((i) => i.id === id);
+ if (archived && (archived.issue_id ?? archived.id) === selectedKey) setSelectedKey("");
+ archiveMutation.mutate(id, {
+ onError: () => toast.error("Failed to archive"),
+ });
+ };
+
+ // Batch operations
+ const handleMarkAllRead = () => {
+ markAllReadMutation.mutate(undefined, {
+ onError: () => toast.error("Failed to mark all as read"),
+ });
+ };
+
+ const handleArchiveAll = () => {
+ setSelectedKey("");
+ archiveAllMutation.mutate(undefined, {
+ onError: () => toast.error("Failed to archive all"),
+ });
+ };
+
+ const handleArchiveAllRead = () => {
+ const readKeys = items.filter((i) => i.read).map((i) => i.issue_id ?? i.id);
+ if (readKeys.includes(selectedKey)) setSelectedKey("");
+ archiveAllReadMutation.mutate(undefined, {
+ onError: () => toast.error("Failed to archive read items"),
+ });
+ };
+
+ const handleArchiveCompleted = () => {
+ setSelectedKey("");
+ archiveCompletedMutation.mutate(undefined, {
+ onError: () => toast.error("Failed to archive completed"),
+ });
+ };
+
+ if (loading) {
+ return (
+ <ResizablePanelGroup orientation="horizontal" className="flex-1 min-h-0" defaultLayout={defaultLayout} onLayoutChanged={onLayoutChanged}>
+ <ResizablePanel id="list" defaultSize={320} minSize={240} maxSize={480} groupResizeBehavior="preserve-pixel-size">
+ <div className="flex flex-col border-r h-full">
+ <div className="flex h-12 shrink-0 items-center border-b px-4">
+ <Skeleton className="h-5 w-16" />
+ </div>
+ <div className="flex-1 min-h-0 overflow-y-auto space-y-1 p-2">
+ {Array.from({ length: 5 }).map((_, i) => (
+ <div key={i} className="flex items-center gap-3 px-4 py-2.5">
+ <Skeleton className="h-7 w-7 shrink-0 rounded-full" />
+ <div className="flex-1 space-y-2">
+ <Skeleton className="h-4 w-3/4" />
+ <Skeleton className="h-3 w-1/2" />
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+ </ResizablePanel>
+ <ResizableHandle />
+ <ResizablePanel id="detail" minSize="40%">
+ <div className="p-6">
+ <Skeleton className="h-6 w-48" />
+ <Skeleton className="mt-4 h-4 w-32" />
+ </div>
+ </ResizablePanel>
+ </ResizablePanelGroup>
+ );
+ }
+
+ return (
+ <ResizablePanelGroup orientation="horizontal" className="flex-1 min-h-0" defaultLayout={defaultLayout} onLayoutChanged={onLayoutChanged}>
+ <ResizablePanel id="list" defaultSize={320} minSize={240} maxSize={480} groupResizeBehavior="preserve-pixel-size">
+ {/* Left column -- inbox list */}
+ <div className="flex flex-col border-r h-full">
+ <div className="flex h-12 shrink-0 items-center justify-between border-b px-4">
+ <div className="flex items-center gap-2">
+ <h1 className="text-sm font-semibold">Inbox</h1>
+ {unreadCount > 0 && (
+ <span className="text-xs text-muted-foreground">
+ {unreadCount}
+ </span>
+ )}
+ </div>
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ className="text-muted-foreground"
+ />
+ }
+ >
+ <MoreHorizontal className="h-4 w-4" />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-auto">
+ <DropdownMenuItem onClick={handleMarkAllRead}>
+ <CheckCheck className="h-4 w-4" />
+ Mark all as read
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onClick={handleArchiveAll}>
+ <Archive className="h-4 w-4" />
+ Archive all
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={handleArchiveAllRead}>
+ <BookCheck className="h-4 w-4" />
+ Archive all read
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={handleArchiveCompleted}>
+ <ListChecks className="h-4 w-4" />
+ Archive completed
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+
+ <div className="flex-1 min-h-0 overflow-y-auto">
+ {items.length === 0 ? (
+ <div className="flex flex-col items-center justify-center py-16 text-muted-foreground">
+ <Inbox className="mb-3 h-8 w-8 text-muted-foreground/50" />
+ <p className="text-sm">No notifications</p>
+ </div>
+ ) : (
+ <div>
+ {items.map((item) => (
+ <InboxListItem
+ key={item.id}
+ item={item}
+ isSelected={(item.issue_id ?? item.id) === selectedKey}
+ onClick={() => handleSelect(item)}
+ onArchive={() => handleArchive(item.id)}
+ />
+ ))}
+ </div>
+ )}
+ </div>
+ </div>
+ </ResizablePanel>
+ <ResizableHandle />
+ <ResizablePanel id="detail" minSize="40%">
+ {/* Right column -- detail */}
+ <div className="flex flex-col min-h-0 h-full">
+ {selected?.issue_id ? (
+ <IssueDetail
+ key={selected.id}
+ issueId={selected.issue_id}
+ defaultSidebarOpen={false}
+ layoutId="multica_inbox_issue_detail_layout"
+ highlightCommentId={selected.details?.comment_id ?? undefined}
+ onDelete={() => {
+ handleArchive(selected.id);
+ }}
+ />
+ ) : selected ? (
+ <div className="p-6">
+ <h2 className="text-lg font-semibold">{selected.title}</h2>
+ <p className="mt-1 text-sm text-muted-foreground">
+ {typeLabels[selected.type]} · {timeAgo(selected.created_at)}
+ </p>
+ {selected.body && (
+ <div className="mt-4 whitespace-pre-wrap text-sm leading-relaxed text-foreground/80">
+ {selected.body}
+ </div>
+ )}
+ <div className="mt-4">
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => handleArchive(selected.id)}
+ >
+ <Archive className="mr-1.5 h-3.5 w-3.5" />
+ Archive
+ </Button>
+ </div>
+ </div>
+ ) : (
+ <div className="flex h-full flex-col items-center justify-center text-muted-foreground">
+ <Inbox className="mb-3 h-10 w-10 text-muted-foreground/30" />
+ <p className="text-sm">
+ {items.length === 0
+ ? "Your inbox is empty"
+ : "Select a notification to view details"}
+ </p>
+ </div>
+ )}
+ </div>
+ </ResizablePanel>
+ </ResizablePanelGroup>
+ );
+}
diff --git a/packages/views/inbox/components/index.ts b/packages/views/inbox/components/index.ts
new file mode 100644
index 0000000000..592304e2f8
--- /dev/null
+++ b/packages/views/inbox/components/index.ts
@@ -0,0 +1 @@
+export { InboxPage } from "./inbox-page";
diff --git a/packages/views/inbox/index.ts b/packages/views/inbox/index.ts
new file mode 100644
index 0000000000..bd36d63c81
--- /dev/null
+++ b/packages/views/inbox/index.ts
@@ -0,0 +1 @@
+export { InboxPage } from "./components";
diff --git a/apps/desktop/src/renderer/src/components/app-sidebar.tsx b/packages/views/layout/app-sidebar.tsx
similarity index 94%
rename from apps/desktop/src/renderer/src/components/app-sidebar.tsx
rename to packages/views/layout/app-sidebar.tsx
index c22d9c1bae..6e27bcaeb0 100644
--- a/apps/desktop/src/renderer/src/components/app-sidebar.tsx
+++ b/packages/views/layout/app-sidebar.tsx
@@ -1,6 +1,7 @@
+"use client";
+
import React from "react";
-import { AppLink } from "@multica/views/navigation";
-import { useNavigation } from "@multica/views/navigation";
+import { AppLink, useNavigation } from "../navigation";
import {
Inbox,
ListTodo,
@@ -15,7 +16,7 @@ import {
SquarePen,
CircleUser,
} from "lucide-react";
-import { WorkspaceAvatar } from "@multica/views/workspace/workspace-avatar";
+import { WorkspaceAvatar } from "../workspace/workspace-avatar";
import { useIssueDraftStore } from "@multica/core/issues/stores/draft-store";
import {
Sidebar,
@@ -39,11 +40,11 @@ import {
DropdownMenuTrigger,
} 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 { useAuthStore } from "@multica/core/auth";
+import { useWorkspaceStore } from "@multica/core/workspace";
import { useQuery } from "@tanstack/react-query";
import { inboxKeys, deduplicateInboxItems } from "@multica/core/inbox/queries";
-import { api } from "@/platform/api";
+import { api } from "@multica/core/api";
import { useModalStore } from "@multica/core/modals";
const primaryNav = [
@@ -189,7 +190,7 @@ export function AppSidebar() {
<SidebarMenuItem key={item.href}>
<SidebarMenuButton
isActive={isActive}
- render={<AppLink href={item.href}>{null}</AppLink>}
+ render={<AppLink href={item.href} />}
className="text-muted-foreground hover:not-data-active:bg-sidebar-accent/70 data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground"
>
<item.icon />
@@ -216,7 +217,7 @@ export function AppSidebar() {
<SidebarMenuItem key={item.href}>
<SidebarMenuButton
isActive={isActive}
- render={<AppLink href={item.href}>{null}</AppLink>}
+ render={<AppLink href={item.href} />}
className="text-muted-foreground hover:not-data-active:bg-sidebar-accent/70 data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground"
>
<item.icon />
diff --git a/packages/views/layout/dashboard-layout.tsx b/packages/views/layout/dashboard-layout.tsx
new file mode 100644
index 0000000000..dfe0b4ae75
--- /dev/null
+++ b/packages/views/layout/dashboard-layout.tsx
@@ -0,0 +1,81 @@
+"use client";
+
+import { useEffect, type ReactNode } from "react";
+import { useNavigationStore } from "@multica/core/navigation";
+import { SidebarProvider, SidebarInset } from "@multica/ui/components/ui/sidebar";
+import { WorkspaceIdProvider } from "@multica/core/hooks";
+import { useAuthStore } from "@multica/core/auth";
+import { useWorkspaceStore } from "@multica/core/workspace";
+import { ModalRegistry } from "../modals/registry";
+import { useNavigation } from "../navigation";
+import { AppSidebar } from "./app-sidebar";
+
+interface DashboardLayoutProps {
+ children: ReactNode;
+ /** Above sidebar area (e.g. desktop TitleBar) */
+ header?: ReactNode;
+ /** Sibling of SidebarInset (e.g. web SearchCommand) */
+ extra?: ReactNode;
+ /** Loading indicator */
+ loadingIndicator?: ReactNode;
+ /** Redirect path when not authenticated. Default: "/" */
+ loginPath?: string;
+}
+
+export function DashboardLayout({
+ children,
+ header,
+ extra,
+ loadingIndicator,
+ loginPath = "/",
+}: DashboardLayoutProps) {
+ const { pathname, push } = useNavigation();
+ const user = useAuthStore((s) => s.user);
+ const isLoading = useAuthStore((s) => s.isLoading);
+ const workspace = useWorkspaceStore((s) => s.workspace);
+
+ useEffect(() => {
+ if (!isLoading && !user) push(loginPath);
+ }, [user, isLoading, push, loginPath]);
+
+ useEffect(() => {
+ useNavigationStore.getState().onPathChange(pathname);
+ }, [pathname]);
+
+ if (isLoading) {
+ return (
+ <div className="flex h-screen flex-col">
+ {header}
+ <div className="flex flex-1 items-center justify-center">
+ {loadingIndicator}
+ </div>
+ </div>
+ );
+ }
+
+ if (!user) return null;
+
+ return (
+ <div className="flex h-screen flex-col">
+ {header}
+ <div className="flex flex-1 min-h-0">
+ <SidebarProvider className="flex-1">
+ <AppSidebar />
+ <SidebarInset className="overflow-hidden">
+ {workspace ? (
+ <WorkspaceIdProvider wsId={workspace.id}>
+ {children}
+ <ModalRegistry />
+ </WorkspaceIdProvider>
+ ) : (
+ <div className="flex flex-1 items-center justify-center">
+ {loadingIndicator}
+ </div>
+ )}
+ </SidebarInset>
+ {extra}
+ </SidebarProvider>
+ </div>
+ </div>
+ );
+}
diff --git a/packages/views/layout/index.ts b/packages/views/layout/index.ts
new file mode 100644
index 0000000000..27f29deecf
--- /dev/null
+++ b/packages/views/layout/index.ts
@@ -0,0 +1,2 @@
+export { AppSidebar } from "./app-sidebar";
+export { DashboardLayout } from "./dashboard-layout";
diff --git a/packages/views/navigation/app-link.tsx b/packages/views/navigation/app-link.tsx
index 715f33d6ab..4eae32ab54 100644
--- a/packages/views/navigation/app-link.tsx
+++ b/packages/views/navigation/app-link.tsx
@@ -1,31 +1,28 @@
"use client";
+import { forwardRef } from "react";
import { useNavigation } from "./context";
interface AppLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
href: string;
- children: React.ReactNode;
}
-export function AppLink({
- href,
- children,
- onClick,
- ...props
-}: AppLinkProps) {
- const { push } = useNavigation();
+export const AppLink = forwardRef<HTMLAnchorElement, AppLinkProps>(
+ function AppLink({ href, children, onClick, ...props }, ref) {
+ const { push } = useNavigation();
- const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
- // Allow ctrl/cmd+click to open in new tab
- if (e.metaKey || e.ctrlKey || e.shiftKey) return;
- e.preventDefault();
- onClick?.(e);
- push(href);
- };
+ const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
+ // Allow ctrl/cmd+click to open in new tab
+ if (e.metaKey || e.ctrlKey || e.shiftKey) return;
+ e.preventDefault();
+ onClick?.(e);
+ push(href);
+ };
- return (
- <a href={href} onClick={handleClick} {...props}>
- {children}
- </a>
- );
-}
+ return (
+ <a ref={ref} href={href} onClick={handleClick} {...props}>
+ {children}
+ </a>
+ );
+ },
+);
diff --git a/packages/views/package.json b/packages/views/package.json
index 5e44e0c0d0..73eb8aae0e 100644
--- a/packages/views/package.json
+++ b/packages/views/package.json
@@ -18,8 +18,13 @@
"./modals/create-workspace": "./modals/create-workspace.tsx",
"./my-issues": "./my-issues/index.ts",
"./skills": "./skills/index.ts",
+ "./agents": "./agents/index.ts",
+ "./inbox": "./inbox/index.ts",
"./runtimes": "./runtimes/index.ts",
- "./workspace/workspace-avatar": "./workspace/workspace-avatar.tsx"
+ "./workspace/workspace-avatar": "./workspace/workspace-avatar.tsx",
+ "./layout": "./layout/index.ts",
+ "./auth": "./auth/index.ts",
+ "./settings": "./settings/index.ts"
},
"dependencies": {
"@multica/core": "workspace:*",
@@ -55,6 +60,7 @@
"remark-gfm": "^4.0.1",
"react-resizable-panels": "^4.7.5",
"recharts": "3.8.0",
+ "next-themes": "^0.4.6",
"sonner": "^2.0.7"
},
"peerDependencies": {
diff --git a/apps/web/app/(dashboard)/settings/_components/account-tab.tsx b/packages/views/settings/components/account-tab.tsx
similarity index 98%
rename from apps/web/app/(dashboard)/settings/_components/account-tab.tsx
rename to packages/views/settings/components/account-tab.tsx
index c81f4d8f45..2061389b0c 100644
--- a/apps/web/app/(dashboard)/settings/_components/account-tab.tsx
+++ b/packages/views/settings/components/account-tab.tsx
@@ -7,8 +7,8 @@ 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";
+import { useAuthStore } from "@multica/core/auth";
+import { api } from "@multica/core/api";
import { useFileUpload } from "@multica/core/hooks/use-file-upload";
export function AccountTab() {
diff --git a/apps/web/app/(dashboard)/settings/_components/general-tab.tsx b/packages/views/settings/components/appearance-tab.tsx
similarity index 100%
rename from apps/web/app/(dashboard)/settings/_components/general-tab.tsx
rename to packages/views/settings/components/appearance-tab.tsx
diff --git a/packages/views/settings/components/index.ts b/packages/views/settings/components/index.ts
new file mode 100644
index 0000000000..544ba343a1
--- /dev/null
+++ b/packages/views/settings/components/index.ts
@@ -0,0 +1 @@
+export { SettingsPage } from "./settings-page";
diff --git a/apps/web/app/(dashboard)/settings/_components/members-tab.tsx b/packages/views/settings/components/members-tab.tsx
similarity index 98%
rename from apps/web/app/(dashboard)/settings/_components/members-tab.tsx
rename to packages/views/settings/components/members-tab.tsx
index ee245b5383..47932925fe 100644
--- a/apps/web/app/(dashboard)/settings/_components/members-tab.tsx
+++ b/packages/views/settings/components/members-tab.tsx
@@ -2,7 +2,7 @@
import { useState } from "react";
import { Crown, Shield, User, Plus, MoreHorizontal, UserMinus, Users } from "lucide-react";
-import { ActorAvatar } from "@multica/views/common/actor-avatar";
+import { ActorAvatar } from "../../common/actor-avatar";
import type { MemberWithUser, MemberRole } from "@multica/core/types";
import { Input } from "@multica/ui/components/ui/input";
import { Button } from "@multica/ui/components/ui/button";
@@ -37,11 +37,11 @@ import {
} from "@multica/ui/components/ui/dropdown-menu";
import { toast } from "sonner";
import { useQuery, useQueryClient } from "@tanstack/react-query";
-import { useAuthStore } from "@/platform/auth";
-import { useWorkspaceStore } from "@/platform/workspace";
+import { useAuthStore } from "@multica/core/auth";
+import { useWorkspaceStore } from "@multica/core/workspace";
import { useWorkspaceId } from "@multica/core/hooks";
import { memberListOptions, workspaceKeys } from "@multica/core/workspace/queries";
-import { api } from "@/platform/api";
+import { api } from "@multica/core/api";
const roleConfig: Record<MemberRole, { label: string; icon: typeof Crown; description: string }> = {
owner: { label: "Owner", icon: Crown, description: "Full access, manage all settings" },
diff --git a/apps/web/app/(dashboard)/settings/_components/repositories-tab.tsx b/packages/views/settings/components/repositories-tab.tsx
similarity index 96%
rename from apps/web/app/(dashboard)/settings/_components/repositories-tab.tsx
rename to packages/views/settings/components/repositories-tab.tsx
index bd6b9737f7..e414be6be9 100644
--- a/apps/web/app/(dashboard)/settings/_components/repositories-tab.tsx
+++ b/packages/views/settings/components/repositories-tab.tsx
@@ -7,11 +7,11 @@ 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";
-import { useWorkspaceStore } from "@/platform/workspace";
+import { useAuthStore } from "@multica/core/auth";
+import { useWorkspaceStore } from "@multica/core/workspace";
import { useWorkspaceId } from "@multica/core/hooks";
import { memberListOptions } from "@multica/core/workspace/queries";
-import { api } from "@/platform/api";
+import { api } from "@multica/core/api";
import type { WorkspaceRepo } from "@multica/core/types";
export function RepositoriesTab() {
diff --git a/packages/views/settings/components/settings-page.tsx b/packages/views/settings/components/settings-page.tsx
new file mode 100644
index 0000000000..025f15ce48
--- /dev/null
+++ b/packages/views/settings/components/settings-page.tsx
@@ -0,0 +1,71 @@
+"use client";
+
+import { User, Palette, Key, Settings, Users, FolderGit2 } from "lucide-react";
+import { Tabs, TabsList, TabsTrigger, TabsContent } from "@multica/ui/components/ui/tabs";
+import { useWorkspaceStore } from "@multica/core/workspace";
+import { AccountTab } from "./account-tab";
+import { AppearanceTab } from "./appearance-tab";
+import { TokensTab } from "./tokens-tab";
+import { WorkspaceTab } from "./workspace-tab";
+import { MembersTab } from "./members-tab";
+import { RepositoriesTab } from "./repositories-tab";
+
+const accountTabs = [
+ { value: "profile", label: "Profile", icon: User },
+ { value: "appearance", label: "Appearance", icon: Palette },
+ { value: "tokens", label: "API Tokens", icon: Key },
+];
+
+const workspaceTabs = [
+ { value: "workspace", label: "General", icon: Settings },
+ { value: "repositories", label: "Repositories", icon: FolderGit2 },
+ { value: "members", label: "Members", icon: Users },
+];
+
+export function SettingsPage() {
+ const workspaceName = useWorkspaceStore((s) => s.workspace?.name);
+
+ return (
+ <Tabs defaultValue="profile" orientation="vertical" className="flex-1 min-h-0 gap-0">
+ {/* Left nav */}
+ <div className="w-52 shrink-0 border-r overflow-y-auto p-4">
+ <h1 className="text-sm font-semibold mb-4 px-2">Settings</h1>
+ <TabsList variant="line" className="flex-col items-stretch">
+ {/* My Account group */}
+ <span className="px-2 pb-1 pt-2 text-xs font-medium text-muted-foreground">
+ My Account
+ </span>
+ {accountTabs.map((tab) => (
+ <TabsTrigger key={tab.value} value={tab.value}>
+ <tab.icon className="h-4 w-4" />
+ {tab.label}
+ </TabsTrigger>
+ ))}
+
+ {/* Workspace group */}
+ <span className="px-2 pb-1 pt-4 text-xs font-medium text-muted-foreground truncate">
+ {workspaceName ?? "Workspace"}
+ </span>
+ {workspaceTabs.map((tab) => (
+ <TabsTrigger key={tab.value} value={tab.value}>
+ <tab.icon className="h-4 w-4" />
+ {tab.label}
+ </TabsTrigger>
+ ))}
+ </TabsList>
+ </div>
+
+ {/* Right content */}
+ <div className="flex-1 min-w-0 overflow-y-auto">
+ <div className="w-full max-w-3xl mx-auto p-6">
+ <TabsContent value="profile"><AccountTab /></TabsContent>
+ <TabsContent value="appearance"><AppearanceTab /></TabsContent>
+ <TabsContent value="tokens"><TokensTab /></TabsContent>
+ <TabsContent value="workspace"><WorkspaceTab /></TabsContent>
+ <TabsContent value="repositories"><RepositoriesTab /></TabsContent>
+ <TabsContent value="members"><MembersTab /></TabsContent>
+ </div>
+ </div>
+ </Tabs>
+ );
+}
diff --git a/apps/web/app/(dashboard)/settings/_components/tokens-tab.tsx b/packages/views/settings/components/tokens-tab.tsx
similarity index 99%
rename from apps/web/app/(dashboard)/settings/_components/tokens-tab.tsx
rename to packages/views/settings/components/tokens-tab.tsx
index 03543934f2..adc77ad8dc 100644
--- a/apps/web/app/(dashboard)/settings/_components/tokens-tab.tsx
+++ b/packages/views/settings/components/tokens-tab.tsx
@@ -34,7 +34,7 @@ import {
} from "@multica/ui/components/ui/alert-dialog";
import { Skeleton } from "@multica/ui/components/ui/skeleton";
import { toast } from "sonner";
-import { api } from "@/platform/api";
+import { api } from "@multica/core/api";
export function TokensTab() {
const [tokens, setTokens] = useState<PersonalAccessToken[]>([]);
diff --git a/apps/web/app/(dashboard)/settings/_components/workspace-tab.tsx b/packages/views/settings/components/workspace-tab.tsx
similarity index 98%
rename from apps/web/app/(dashboard)/settings/_components/workspace-tab.tsx
rename to packages/views/settings/components/workspace-tab.tsx
index 5e7829359a..fedb8d4aeb 100644
--- a/apps/web/app/(dashboard)/settings/_components/workspace-tab.tsx
+++ b/packages/views/settings/components/workspace-tab.tsx
@@ -19,11 +19,11 @@ import {
} from "@multica/ui/components/ui/alert-dialog";
import { toast } from "sonner";
import { useQuery } from "@tanstack/react-query";
-import { useAuthStore } from "@/platform/auth";
-import { useWorkspaceStore } from "@/platform/workspace";
+import { useAuthStore } from "@multica/core/auth";
+import { useWorkspaceStore } from "@multica/core/workspace";
import { useWorkspaceId } from "@multica/core/hooks";
import { memberListOptions } from "@multica/core/workspace/queries";
-import { api } from "@/platform/api";
+import { api } from "@multica/core/api";
export function WorkspaceTab() {
const user = useAuthStore((s) => s.user);
diff --git a/packages/views/settings/index.ts b/packages/views/settings/index.ts
new file mode 100644
index 0000000000..3195fd5a72
--- /dev/null
+++ b/packages/views/settings/index.ts
@@ -0,0 +1 @@
+export { SettingsPage } from "./components";
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 3983ecef58..b2b1996612 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -552,6 +552,9 @@ importers:
lucide-react:
specifier: 'catalog:'
version: 1.0.1([email protected])
+ next-themes:
+ specifier: ^0.4.6
react:
specifier: 'catalog:'
version: 19.2.3