## Store migration (packages → features) - Delete `packages/store/` — stores moved into web app's feature modules - Delete `packages/hooks/` — replaced by feature-level hooks - `features/issues/store.ts` — useIssueStore (was packages/store/issue-store) - `features/inbox/store.ts` — useInboxStore (was packages/store/inbox-store) - `features/workspace/store.ts` — absorbs agent state (was packages/store/agent-store) - All imports updated from `@multica/store` → `@/features/*/store` ## Global modal system - `features/modals/store.ts` — useModalStore (zustand) - `features/modals/registry.tsx` — ModalRegistry renders active modal - Mounted in app/layout.tsx alongside Toaster - Create Workspace dialog now works (was broken: DropdownMenu ate click) ## Workspace real-time sync - useRealtimeSync subscribes to workspace:updated, member:removed - Member removal → auto-switch to another workspace - Workspace settings update → sidebar reflects name change - Workspace switch → parallel fetch issues + inbox + agents ## Bug fixes - theme-provider: guard event.key for IME composition (isComposing check) - task.go: publish comment:created + inbox:new events on task complete/fail - listeners.go: broadcast comment:created, workspace:updated, member events - events.go: add EventCommentUpdated, EventCommentDeleted constants ## Cleanup - Remove _features/ tracking files (dev-only, not for main) - Remove server/server binary from worktree - Update CLAUDE.md to reflect new architecture Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
201 lines
6.8 KiB
TypeScript
201 lines
6.8 KiB
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import { usePathname, useRouter } from "next/navigation";
|
|
import {
|
|
Inbox,
|
|
ListTodo,
|
|
Bot,
|
|
BookOpen,
|
|
ChevronDown,
|
|
Settings,
|
|
LogOut,
|
|
Plus,
|
|
Check,
|
|
} from "lucide-react";
|
|
import { MulticaIcon } from "@/components/multica-icon";
|
|
import {
|
|
Sidebar,
|
|
SidebarContent,
|
|
SidebarFooter,
|
|
SidebarGroup,
|
|
SidebarGroupContent,
|
|
SidebarHeader,
|
|
SidebarMenu,
|
|
SidebarMenuButton,
|
|
SidebarMenuItem,
|
|
} from "@/components/ui/sidebar";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuGroup,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import { useAuthStore } from "@/features/auth";
|
|
import { useWorkspaceStore } from "@/features/workspace";
|
|
import { useInboxStore } from "@/features/inbox";
|
|
import { useModalStore } from "@/features/modals";
|
|
|
|
const navItems = [
|
|
{ href: "/inbox", label: "Inbox", icon: Inbox },
|
|
{ href: "/agents", label: "Agents", icon: Bot },
|
|
{ href: "/issues", label: "Issues", icon: ListTodo },
|
|
{ href: "/knowledge-base", label: "Knowledge Base", icon: BookOpen },
|
|
];
|
|
|
|
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 unreadCount = useInboxStore((s) =>
|
|
s.items.filter((i) => !i.read && !i.archived).length
|
|
);
|
|
|
|
const logout = () => {
|
|
authLogout();
|
|
useWorkspaceStore.getState().clearWorkspace();
|
|
router.push("/login");
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<Sidebar variant="inset">
|
|
{/* Workspace Switcher */}
|
|
<SidebarHeader>
|
|
<SidebarMenu>
|
|
<SidebarMenuItem>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger
|
|
render={
|
|
<SidebarMenuButton size="lg">
|
|
<MulticaIcon className="size-4" noSpin />
|
|
<span className="flex-1 truncate font-semibold">
|
|
{workspace?.name ?? "Multica"}
|
|
</span>
|
|
<ChevronDown className="size-4" />
|
|
</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>
|
|
<DropdownMenuLabel className="text-xs text-muted-foreground">
|
|
Workspaces
|
|
</DropdownMenuLabel>
|
|
{workspaces.map((ws) => (
|
|
<DropdownMenuItem
|
|
key={ws.id}
|
|
onClick={() => {
|
|
if (ws.id !== workspace?.id) {
|
|
switchWorkspace(ws.id);
|
|
}
|
|
}}
|
|
>
|
|
<span className="flex h-5 w-5 shrink-0 items-center justify-center rounded bg-muted text-[10px] font-semibold">
|
|
{ws.name.charAt(0).toUpperCase()}
|
|
</span>
|
|
<span className="flex-1 truncate">{ws.name}</span>
|
|
{ws.id === workspace?.id && (
|
|
<Check className="h-3.5 w-3.5 text-primary" />
|
|
)}
|
|
</DropdownMenuItem>
|
|
))}
|
|
<DropdownMenuItem
|
|
onClick={() => useModalStore.getState().open("create-workspace")}
|
|
>
|
|
<Plus className="h-3.5 w-3.5" />
|
|
Create workspace
|
|
</DropdownMenuItem>
|
|
</DropdownMenuGroup>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuGroup>
|
|
<DropdownMenuItem
|
|
render={<Link href="/settings" />}
|
|
>
|
|
<Settings className="h-3.5 w-3.5" />
|
|
Settings
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem variant="destructive" onClick={logout}>
|
|
<LogOut className="h-3.5 w-3.5" />
|
|
Sign out
|
|
</DropdownMenuItem>
|
|
</DropdownMenuGroup>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</SidebarMenuItem>
|
|
</SidebarMenu>
|
|
</SidebarHeader>
|
|
|
|
{/* Navigation */}
|
|
<SidebarContent>
|
|
<SidebarGroup>
|
|
<SidebarGroupContent>
|
|
<SidebarMenu>
|
|
{navItems.map((item) => {
|
|
const isActive =
|
|
pathname === item.href ||
|
|
pathname.startsWith(item.href + "/");
|
|
return (
|
|
<SidebarMenuItem key={item.href}>
|
|
<SidebarMenuButton
|
|
isActive={isActive}
|
|
render={<Link href={item.href} />}
|
|
>
|
|
<item.icon />
|
|
<span>{item.label}</span>
|
|
{item.label === "Inbox" && unreadCount > 0 && (
|
|
<span className="ml-auto rounded-full bg-primary px-1.5 py-0.5 text-[10px] font-medium text-primary-foreground">
|
|
{unreadCount > 99 ? "99+" : unreadCount}
|
|
</span>
|
|
)}
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
);
|
|
})}
|
|
</SidebarMenu>
|
|
</SidebarGroupContent>
|
|
</SidebarGroup>
|
|
</SidebarContent>
|
|
|
|
{/* User */}
|
|
<SidebarFooter>
|
|
{user && (
|
|
<SidebarMenu>
|
|
<SidebarMenuItem>
|
|
<SidebarMenuButton size="sm">
|
|
<div className="flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-[9px] font-medium">
|
|
{user.name
|
|
.split(" ")
|
|
.map((w) => w[0])
|
|
.join("")
|
|
.toUpperCase()
|
|
.slice(0, 2)}
|
|
</div>
|
|
<span className="truncate">{user.name}</span>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
</SidebarMenu>
|
|
)}
|
|
</SidebarFooter>
|
|
</Sidebar>
|
|
</>
|
|
);
|
|
}
|