Skip to content

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

Go

feat: issue detail extraction, inbox enhancements, misc UI polish

Naiyuan Qing655aa4073280
diff --git a/apps/web/app/(dashboard)/agents/page.tsx b/apps/web/app/(dashboard)/agents/page.tsx
index b786b2386a..d27e3ee40b 100644
--- a/apps/web/app/(dashboard)/agents/page.tsx
+++ b/apps/web/app/(dashboard)/agents/page.tsx
@@ -186,7 +186,7 @@ function CreateAgentDialog({
{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-[10px] font-medium text-info">
+ <span className="shrink-0 rounded bg-info/10 px-1.5 py-0.5 text-xs font-medium text-info">
Cloud
</span>
)}
@@ -222,7 +222,7 @@ function CreateAgentDialog({
<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-[10px] font-medium text-info">
+ <span className="shrink-0 rounded bg-info/10 px-1.5 py-0.5 text-xs font-medium text-info">
Cloud
</span>
)}
@@ -812,7 +812,7 @@ function TriggersTab({
>
<span
className={`absolute top-0.5 h-4 w-4 rounded-full bg-white shadow-sm transition-transform ${
- trigger.enabled ? "left-[18px]" : "left-0.5"
+ trigger.enabled ? "left-4.5" : "left-0.5"
}`}
/>
</button>
@@ -1007,7 +1007,7 @@ function AgentDetail({
<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-[10px] font-medium text-muted-foreground">
+ <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" />
) : (
diff --git a/apps/web/app/(dashboard)/inbox/page.tsx b/apps/web/app/(dashboard)/inbox/page.tsx
index 3a8bfc926b..1b00a14e75 100644
--- a/apps/web/app/(dashboard)/inbox/page.tsx
+++ b/apps/web/app/(dashboard)/inbox/page.tsx
@@ -1,21 +1,29 @@
"use client";
-import { useState, useEffect, useMemo } from "react";
+import { useState, useMemo } from "react";
import { useInboxStore } from "@/features/inbox";
+import { useActorName } from "@/features/workspace";
+import { IssueDetail } from "@/features/issues/components";
+import { ActorAvatar } from "@/components/common/actor-avatar";
import { toast } from "sonner";
import {
- AlertCircle,
- Bot,
- CheckCircle2,
- CircleDot,
- GitPullRequest,
- MessageSquare,
- ArrowRightLeft,
+ MoreHorizontal,
+ Inbox,
+ CheckCheck,
+ Archive,
+ BookCheck,
+ ListChecks,
} from "lucide-react";
import type { InboxItem, InboxItemType, InboxSeverity } from "@multica/types";
-import Link from "next/link";
import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
+import {
+ DropdownMenu,
+ DropdownMenuTrigger,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+} from "@/components/ui/dropdown-menu";
import { api } from "@/shared/api";
// ---------------------------------------------------------------------------
@@ -28,145 +36,79 @@ const severityOrder: Record<InboxSeverity, number> = {
info: 2,
};
-const typeIcons: Record<InboxItemType, typeof AlertCircle> = {
- agent_blocked: AlertCircle,
- review_requested: GitPullRequest,
- issue_assigned: CircleDot,
- agent_completed: CheckCircle2,
- mentioned: MessageSquare,
- status_change: ArrowRightLeft,
-};
-
-const severityColors: Record<InboxSeverity, string> = {
- action_required: "text-destructive",
- attention: "text-warning",
- info: "text-muted-foreground",
+const typeLabels: Record<InboxItemType, string> = {
+ issue_assigned: "Assigned",
+ review_requested: "Review requested",
+ agent_blocked: "Agent blocked",
+ agent_completed: "Agent completed",
+ mentioned: "Mentioned",
+ status_change: "Status changed",
};
function timeAgo(dateStr: string): string {
const diff = Date.now() - new Date(dateStr).getTime();
const minutes = Math.floor(diff / 60000);
- if (minutes < 60) return `${minutes}m ago`;
+ if (minutes < 1) return "just now";
+ if (minutes < 60) return `${minutes}m`;
const hours = Math.floor(minutes / 60);
- if (hours < 24) return `${hours}h ago`;
+ if (hours < 24) return `${hours}h`;
const days = Math.floor(hours / 24);
- return `${days}d ago`;
+ return `${days}d`;
}
// ---------------------------------------------------------------------------
-// Components
+// InboxListItem
// ---------------------------------------------------------------------------
function InboxListItem({
item,
isSelected,
onClick,
+ getActorName,
+ getActorInitials,
}: {
item: InboxItem;
isSelected: boolean;
onClick: () => void;
+ getActorName: (type: string, id: string) => string;
+ getActorInitials: (type: string, id: string) => string;
}) {
- const Icon = typeIcons[item.type] ?? CircleDot;
- const colorClass = severityColors[item.severity];
-
return (
<button
onClick={onClick}
- className={`flex w-full items-start gap-3 px-4 py-3 text-left transition-colors ${
+ className={`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${
isSelected ? "bg-accent" : "hover:bg-accent/50"
- } ${!item.read ? "font-medium" : ""}`}
+ }`}
>
- <Icon className={`mt-0.5 h-4 w-4 shrink-0 ${colorClass}`} />
+ <ActorAvatar
+ actorType={item.recipient_type}
+ actorId={item.recipient_id}
+ size={28}
+ getName={getActorName}
+ getInitials={getActorInitials}
+ />
<div className="min-w-0 flex-1">
<div className="flex items-baseline justify-between gap-2">
- <span className="truncate text-sm">{item.title}</span>
+ <span
+ className={`truncate text-sm ${!item.read ? "font-medium" : "text-muted-foreground"}`}
+ >
+ {item.title}
+ </span>
<span className="shrink-0 text-xs text-muted-foreground">
{timeAgo(item.created_at)}
</span>
</div>
- {(item.type === "agent_blocked" || item.type === "review_requested") && (
- <div className="mt-0.5 flex items-center gap-1.5">
- <Bot className="h-3 w-3 text-muted-foreground" />
- <span className="text-xs text-muted-foreground">Agent action</span>
- </div>
- )}
+ <p className="mt-0.5 truncate text-xs text-muted-foreground">
+ {typeLabels[item.type] ?? item.type}
+ </p>
</div>
{!item.read && (
- <span className="mt-1.5 h-2 w-2 shrink-0 rounded-full bg-primary" />
+ <span className="h-2 w-2 shrink-0 rounded-full bg-primary" />
)}
</button>
);
}
-function InboxDetail({
- item,
- onMarkRead,
- onArchive,
-}: {
- item: InboxItem;
- onMarkRead: (id: string) => void;
- onArchive: (id: string) => void;
-}) {
- const Icon = typeIcons[item.type] ?? CircleDot;
- const colorClass = severityColors[item.severity];
-
- const severityLabel: Record<InboxSeverity, string> = {
- action_required: "Action required",
- attention: "Needs attention",
- info: "Info",
- };
-
- return (
- <div className="p-6">
- {/* Header */}
- <div className="flex items-start gap-3">
- <Icon className={`mt-1 h-5 w-5 shrink-0 ${colorClass}`} />
- <div className="min-w-0 flex-1">
- <h2 className="text-lg font-semibold truncate">{item.title}</h2>
- <div className="mt-1 flex items-center gap-3 text-sm text-muted-foreground">
- <span className={colorClass}>{severityLabel[item.severity]}</span>
- <span>·</span>
- <span>{timeAgo(item.created_at)}</span>
- </div>
- </div>
- {!item.read && (
- <Button
- variant="outline"
- size="xs"
- onClick={() => onMarkRead(item.id)}
- className="shrink-0"
- >
- Mark read
- </Button>
- )}
- {item.issue_id && (
- <Link
- href={`/issues/${item.issue_id}`}
- className="inline-flex h-7 shrink-0 items-center rounded-md border px-2.5 text-xs font-medium transition-colors hover:bg-accent"
- >
- View Issue
- </Link>
- )}
- <Button
- variant="outline"
- size="xs"
- onClick={() => onArchive(item.id)}
- className="shrink-0"
- >
- Archive
- </Button>
- </div>
-
- {/* Body */}
- {item.body && (
- <div className="mt-6 whitespace-pre-wrap text-sm leading-relaxed text-foreground/80">
- {item.body}
- </div>
- )}
- </div>
- );
-}
-
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
@@ -174,9 +116,9 @@ function InboxDetail({
export default function InboxPage() {
const [selectedId, setSelectedId] = useState<string>("");
- // Read from global store (populated by workspace hydrate + useRealtimeSync)
const storeItems = useInboxStore((s) => s.items);
const loading = useInboxStore((s) => s.loading);
+ const { getActorName, getActorInitials } = useActorName();
// Sort: severity first, then newest first
const items = useMemo(() => {
@@ -189,19 +131,19 @@ export default function InboxPage() {
);
}, [storeItems]);
- // Auto-select first item when items change
- useEffect(() => {
- if (items.length > 0 && !selectedId) {
- setSelectedId(items[0]!.id);
- }
- }, [items, selectedId]);
+ const selected = items.find((i) => i.id === selectedId) ?? null;
+ const unreadCount = items.filter((i) => !i.read).length;
- const handleMarkRead = async (id: string) => {
- try {
- await api.markInboxRead(id);
- useInboxStore.getState().markRead(id);
- } catch (err) {
- toast.error("Failed to mark as read");
+ // Click-to-read: select + auto-mark-read
+ const handleSelect = async (item: InboxItem) => {
+ setSelectedId(item.id);
+ if (!item.read) {
+ try {
+ await api.markInboxRead(item.id);
+ useInboxStore.getState().markRead(item.id);
+ } catch {
+ // silent — selection still works even if mark-read fails
+ }
}
};
@@ -209,17 +151,55 @@ export default function InboxPage() {
try {
await api.archiveInbox(id);
useInboxStore.getState().archive(id);
- // If archived item was selected, clear selection
- if (selectedId === id) {
- setSelectedId("");
- }
- } catch (err) {
+ if (selectedId === id) setSelectedId("");
+ } catch {
toast.error("Failed to archive");
}
};
- const selected = items.find((i) => i.id === selectedId) ?? null;
- const unreadCount = items.filter((i) => !i.read).length;
+ // Batch operations
+ const handleMarkAllRead = async () => {
+ try {
+ useInboxStore.getState().markAllRead();
+ await api.markAllInboxRead();
+ } catch {
+ toast.error("Failed to mark all as read");
+ useInboxStore.getState().fetch();
+ }
+ };
+
+ const handleArchiveAll = async () => {
+ try {
+ useInboxStore.getState().archiveAll();
+ setSelectedId("");
+ await api.archiveAllInbox();
+ } catch {
+ toast.error("Failed to archive all");
+ useInboxStore.getState().fetch();
+ }
+ };
+
+ const handleArchiveAllRead = async () => {
+ try {
+ const readIds = items.filter((i) => i.read).map((i) => i.id);
+ useInboxStore.getState().archiveAllRead();
+ if (readIds.includes(selectedId)) setSelectedId("");
+ await api.archiveAllReadInbox();
+ } catch {
+ toast.error("Failed to archive read items");
+ useInboxStore.getState().fetch();
+ }
+ };
+
+ const handleArchiveCompleted = async () => {
+ try {
+ await api.archiveCompletedInbox();
+ setSelectedId("");
+ await useInboxStore.getState().fetch();
+ } catch {
+ toast.error("Failed to archive completed");
+ }
+ };
if (loading) {
return (
@@ -230,8 +210,8 @@ export default function InboxPage() {
</div>
<div className="space-y-1 p-2">
{Array.from({ length: 5 }).map((_, i) => (
- <div key={i} className="flex items-start gap-3 px-4 py-3">
- <Skeleton className="h-4 w-4 shrink-0 rounded" />
+ <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" />
@@ -243,7 +223,6 @@ export default function InboxPage() {
<div className="flex-1 p-6">
<Skeleton className="h-6 w-48" />
<Skeleton className="mt-4 h-4 w-32" />
- <Skeleton className="mt-6 h-24 w-full" />
</div>
</div>
);
@@ -253,17 +232,53 @@ export default function InboxPage() {
<div className="flex flex-1 min-h-0">
{/* Left column — inbox list */}
<div className="w-80 shrink-0 overflow-y-auto border-r">
- <div className="flex h-12 items-center border-b px-4">
- <h1 className="text-sm font-semibold">Inbox</h1>
- {unreadCount > 0 && (
- <span className="ml-2 rounded-full bg-primary px-2 py-0.5 text-xs text-primary-foreground">
- {unreadCount}
- </span>
- )}
+ <div className="flex h-12 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="rounded-full bg-primary px-1.5 py-0.5 text-xs font-medium text-primary-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">
+ <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>
+
{items.length === 0 ? (
- <div className="flex flex-col items-center justify-center py-12 text-sm text-muted-foreground">
- <p>No notifications yet</p>
+ <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 className="divide-y">
@@ -272,7 +287,9 @@ export default function InboxPage() {
key={item.id}
item={item}
isSelected={item.id === selectedId}
- onClick={() => setSelectedId(item.id)}
+ onClick={() => handleSelect(item)}
+ getActorName={getActorName}
+ getActorInitials={getActorInitials}
/>
))}
</div>
@@ -280,14 +297,45 @@ export default function InboxPage() {
</div>
{/* Right column — detail */}
- <div className="flex-1 overflow-y-auto">
- {selected ? (
- <InboxDetail item={selected} onMarkRead={handleMarkRead} onArchive={handleArchive} />
+ <div className="flex-1 overflow-hidden">
+ {selected?.issue_id ? (
+ <IssueDetail
+ issueId={selected.issue_id}
+ showBreadcrumb={false}
+ 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 items-center justify-center text-muted-foreground">
- {items.length === 0
- ? "Your inbox is empty"
- : "Select an item to view details"}
+ <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>
diff --git a/apps/web/app/(dashboard)/issues/[id]/page.tsx b/apps/web/app/(dashboard)/issues/[id]/page.tsx
index 601bbf64a3..210e24be2e 100644
--- a/apps/web/app/(dashboard)/issues/[id]/page.tsx
+++ b/apps/web/app/(dashboard)/issues/[id]/page.tsx
@@ -1,312 +1,7 @@
"use client";
-import { use, useState, useEffect, useCallback } from "react";
-import Link from "next/link";
-import { useRouter } from "next/navigation";
-import {
- ChevronRight,
- Link2,
- Pencil,
- Send,
- Trash2,
- X,
-} from "lucide-react";
-import { toast } from "sonner";
-import {
- AlertDialog,
- AlertDialogAction,
- AlertDialogCancel,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogTitle,
- AlertDialogTrigger,
-} from "@/components/ui/alert-dialog";
-import { Calendar } from "@/components/ui/calendar";
-import {
- Popover,
- PopoverTrigger,
- PopoverContent,
-} from "@/components/ui/popover";
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Textarea } from "@/components/ui/textarea";
-import {
- Tooltip,
- TooltipTrigger,
- TooltipContent,
-} from "@/components/ui/tooltip";
-import { ActorAvatar } from "@/components/common/actor-avatar";
-import type { Issue, Comment, UpdateIssueRequest } from "@multica/types";
-import { StatusPicker, PriorityPicker, AssigneePicker } from "@/features/issues/components";
-import { api } from "@/shared/api";
-import { useAuthStore } from "@/features/auth";
-import { useActorName } from "@/features/workspace";
-import { useWSEvent } from "@/features/realtime";
-import { useIssueStore } from "@/features/issues";
-import type { CommentCreatedPayload, CommentUpdatedPayload, CommentDeletedPayload } from "@multica/types";
-
-// ---------------------------------------------------------------------------
-// Helpers
-// ---------------------------------------------------------------------------
-
-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 ago`;
- const hours = Math.floor(minutes / 60);
- if (hours < 24) return `${hours}h ago`;
- const days = Math.floor(hours / 24);
- return `${days}d ago`;
-}
-
-function shortDate(date: string | null): string {
- if (!date) return "—";
- return new Date(date).toLocaleDateString("en-US", {
- month: "short",
- day: "numeric",
- });
-}
-
-// ---------------------------------------------------------------------------
-// Property row
-// ---------------------------------------------------------------------------
-
-function PropRow({
- label,
- children,
-}: {
- label: string;
- children: React.ReactNode;
-}) {
- return (
- <div className="flex min-h-[32px] items-center gap-3 rounded-md px-2 -mx-2 hover:bg-accent/50 transition-colors">
- <span className="w-20 shrink-0 text-[13px] text-muted-foreground">{label}</span>
- <div className="flex min-w-0 flex-1 items-center justify-end gap-1.5 text-[13px]">
- {children}
- </div>
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Due Date Picker
-// ---------------------------------------------------------------------------
-
-function DueDatePicker({
- dueDate,
- onUpdate,
-}: {
- dueDate: string | null;
- onUpdate: (updates: Partial<UpdateIssueRequest>) => void;
-}) {
- const [open, setOpen] = useState(false);
- const date = dueDate ? new Date(dueDate) : undefined;
- const isOverdue = date ? date < new Date() : false;
-
- return (
- <Popover open={open} onOpenChange={setOpen}>
- <PopoverTrigger className="flex items-center gap-1.5 cursor-pointer rounded px-1 -mx-1 hover:bg-accent/30 transition-colors">
- {date ? (
- <span className={isOverdue ? "text-destructive" : ""}>
- {date.toLocaleDateString("en-US", { month: "short", day: "numeric" })}
- </span>
- ) : (
- <span className="text-muted-foreground">None</span>
- )}
- </PopoverTrigger>
- <PopoverContent className="w-auto p-0" align="end">
- <Calendar
- mode="single"
- selected={date}
- onSelect={(d: Date | undefined) => {
- onUpdate({ due_date: d ? d.toISOString() : null });
- setOpen(false);
- }}
- />
- {date && (
- <div className="border-t px-3 py-2">
- <Button
- variant="ghost"
- size="xs"
- onClick={() => {
- onUpdate({ due_date: null });
- setOpen(false);
- }}
- className="text-muted-foreground hover:text-foreground"
- >
- Clear date
- </Button>
- </div>
- )}
- </PopoverContent>
- </Popover>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Acceptance Criteria Editor
-// ---------------------------------------------------------------------------
-
-function AcceptanceCriteriaEditor({
- criteria,
- onUpdate,
-}: {
- criteria: string[];
- onUpdate: (updates: Partial<UpdateIssueRequest>) => void;
-}) {
- const [newItem, setNewItem] = useState("");
-
- const addItem = () => {
- if (!newItem.trim()) return;
- onUpdate({ acceptance_criteria: [...criteria, newItem.trim()] });
- setNewItem("");
- };
-
- const removeItem = (index: number) => {
- onUpdate({ acceptance_criteria: criteria.filter((_, i) => i !== index) });
- };
-
- const [adding, setAdding] = useState(false);
-
- return (
- <div className="space-y-2">
- <h3 className="text-xs font-medium text-muted-foreground">Acceptance Criteria</h3>
- {criteria.length > 0 && (
- <div className="space-y-1">
- {criteria.map((item, i) => (
- <div key={i} className="group flex items-start gap-2 text-sm">
- <span className="mt-0.5 text-muted-foreground">&bull;</span>
- <span className="flex-1">{item}</span>
- <Button
- variant="ghost"
- size="icon-xs"
- onClick={() => removeItem(i)}
- className="opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-foreground transition-opacity"
- >
- <X className="h-3.5 w-3.5" />
- </Button>
- </div>
- ))}
- </div>
- )}
- {(criteria.length > 0 || adding) ? (
- <form
- onSubmit={(e) => { e.preventDefault(); addItem(); }}
- className="flex items-center gap-2"
- >
- <input
- autoFocus={adding}
- value={newItem}
- onChange={(e) => setNewItem(e.target.value)}
- onBlur={() => { if (!newItem.trim()) setAdding(false); }}
- placeholder="Add criteria..."
- aria-label="Add acceptance criteria"
- className="flex-1 text-sm bg-transparent outline-none placeholder:text-muted-foreground"
- />
- </form>
- ) : (
- <Button
- variant="ghost"
- size="sm"
- className="text-muted-foreground h-7 px-2 text-xs"
- onClick={() => setAdding(true)}
- >
- + Add acceptance criteria
- </Button>
- )}
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Context Refs Editor
-// ---------------------------------------------------------------------------
-
-function ContextRefsEditor({
- refs,
- onUpdate,
-}: {
- refs: string[];
- onUpdate: (updates: Partial<UpdateIssueRequest>) => void;
-}) {
- const [newRef, setNewRef] = useState("");
-
- const addRef = () => {
- if (!newRef.trim()) return;
- onUpdate({ context_refs: [...refs, newRef.trim()] });
- setNewRef("");
- };
-
- const removeRef = (index: number) => {
- onUpdate({ context_refs: refs.filter((_, i) => i !== index) });
- };
-
- const [adding, setAdding] = useState(false);
-
- const isUrl = (s: string) => s.startsWith("http://") || s.startsWith("https://");
-
- return (
- <div className="space-y-2">
- <h3 className="text-xs font-medium text-muted-foreground">Context References</h3>
- {refs.length > 0 && (
- <div className="space-y-1">
- {refs.map((ref, i) => (
- <div key={i} className="group flex items-center gap-2 text-sm">
- <Link2 className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
- {isUrl(ref) ? (
- <a href={ref} target="_blank" rel="noopener noreferrer" className="flex-1 text-info hover:underline truncate">
- {ref}
- </a>
- ) : (
- <span className="flex-1 truncate">{ref}</span>
- )}
- <Button
- variant="ghost"
- size="icon-xs"
- onClick={() => removeRef(i)}
- className="opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-foreground transition-opacity"
- >
- <X className="h-3.5 w-3.5" />
- </Button>
- </div>
- ))}
- </div>
- )}
- {(refs.length > 0 || adding) ? (
- <form
- onSubmit={(e) => { e.preventDefault(); addRef(); }}
- className="flex items-center gap-2"
- >
- <input
- autoFocus={adding}
- value={newRef}
- onChange={(e) => setNewRef(e.target.value)}
- onBlur={() => { if (!newRef.trim()) setAdding(false); }}
- placeholder="Add reference URL..."
- aria-label="Add context reference URL"
- className="flex-1 text-sm bg-transparent outline-none placeholder:text-muted-foreground"
- />
- </form>
- ) : (
- <Button
- variant="ghost"
- size="sm"
- className="text-muted-foreground h-7 px-2 text-xs"
- onClick={() => setAdding(true)}
- >
- + Add context reference
- </Button>
- )}
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Page
-// ---------------------------------------------------------------------------
+import { use } from "react";
+import { IssueDetail } from "@/features/issues/components";
export default function IssueDetailPage({
params,
@@ -314,437 +9,5 @@ export default function IssueDetailPage({
params: Promise<{ id: string }>;
}) {
const { id } = use(params);
- const router = useRouter();
- const user = useAuthStore((s) => s.user);
- const { getActorName, getActorInitials } = useActorName();
- const [issue, setIssue] = useState<Issue | null>(null);
- const [comments, setComments] = useState<Comment[]>([]);
- const [loading, setLoading] = useState(true);
- const [commentText, setCommentText] = useState("");
- const [submitting, setSubmitting] = useState(false);
- const [deleting, setDeleting] = useState(false);
- const [editingCommentId, setEditingCommentId] = useState<string | null>(null);
- const [editContent, setEditContent] = useState("");
- const [editingTitle, setEditingTitle] = useState(false);
- const [titleDraft, setTitleDraft] = useState("");
- const [editingDesc, setEditingDesc] = useState(false);
- const [descDraft, setDescDraft] = useState("");
-
- // Watch the global issue store for real-time updates from other users/agents
- const storeIssue = useIssueStore((s) => s.issues.find((i) => i.id === id));
-
- useEffect(() => {
- if (storeIssue) {
- setIssue(storeIssue);
- }
- }, [storeIssue]);
-
- useEffect(() => {
- setIssue(null);
- setComments([]);
- setLoading(true);
- Promise.all([api.getIssue(id), api.listComments(id)])
- .then(([iss, cmts]) => {
- setIssue(iss);
- setComments(cmts);
- })
- .catch(console.error)
- .finally(() => setLoading(false));
- }, [id]);
-
- const handleSubmitComment = async (e: React.FormEvent) => {
- e.preventDefault();
- if (!commentText.trim() || submitting || !user) return;
- const content = commentText.trim();
- const tempId = "temp-" + Date.now();
- const tempComment: Comment = {
- id: tempId,
- issue_id: id,
- author_type: "member",
- author_id: user.id,
- content,
- type: "comment",
- created_at: new Date().toISOString(),
- updated_at: new Date().toISOString(),
- };
- setComments((prev) => [...prev, tempComment]);
- setCommentText("");
- setSubmitting(true);
- try {
- const comment = await api.createComment(id, content);
- setComments((prev) => prev.map((c) => (c.id === tempId ? comment : c)));
- } catch {
- setComments((prev) => prev.filter((c) => c.id !== tempId));
- toast.error("Failed to send comment");
- } finally {
- setSubmitting(false);
- }
- };
-
- const handleUpdateField = useCallback(
- (updates: Partial<UpdateIssueRequest>) => {
- if (!issue) return;
- const prev = issue;
- setIssue((curr) => (curr ? ({ ...curr, ...updates } as Issue) : curr));
- api.updateIssue(id, updates).catch(() => {
- setIssue(prev);
- toast.error("Failed to update issue");
- });
- },
- [issue, id],
- );
-
- const handleDelete = async () => {
- setDeleting(true);
- try {
- await api.deleteIssue(issue!.id);
- toast.success("Issue deleted");
- router.push("/issues");
- } catch {
- toast.error("Failed to delete issue");
- setDeleting(false);
- }
- };
-
- const startEditComment = (c: Comment) => {
- setEditingCommentId(c.id);
- setEditContent(c.content);
- };
-
- const handleSaveEditComment = async () => {
- if (!editingCommentId || !editContent.trim()) return;
- try {
- const updated = await api.updateComment(editingCommentId, editContent.trim());
- setComments((prev) => prev.map((c) => (c.id === updated.id ? updated : c)));
- setEditingCommentId(null);
- } catch {
- toast.error("Failed to update comment");
- }
- };
-
- const handleDeleteComment = async (commentId: string) => {
- try {
- await api.deleteComment(commentId);
- setComments((prev) => prev.filter((c) => c.id !== commentId));
- } catch {
- toast.error("Failed to delete comment");
- }
- };
-
- // Real-time comment updates
- useWSEvent(
- "comment:created",
- useCallback((payload: unknown) => {
- const { comment } = payload as CommentCreatedPayload;
- if (comment.issue_id !== id) return;
- // Skip own comments — already added locally via API response
- if (comment.author_type === "member" && comment.author_id === user?.id) return;
- setComments((prev) => {
- if (prev.some((c) => c.id === comment.id)) return prev;
- return [...prev, comment];
- });
- }, [id, user?.id]),
- );
-
- useWSEvent(
- "comment:updated",
- useCallback((payload: unknown) => {
- const { comment } = payload as CommentUpdatedPayload;
- if (comment.issue_id === id) {
- setComments((prev) => prev.map((c) => (c.id === comment.id ? comment : c)));
- }
- }, [id]),
- );
-
- useWSEvent(
- "comment:deleted",
- useCallback((payload: unknown) => {
- const { comment_id, issue_id } = payload as CommentDeletedPayload;
- if (issue_id === id) {
- setComments((prev) => prev.filter((c) => c.id !== comment_id));
- }
- }, [id]),
- );
-
- if (loading) {
- return (
- <div className="flex flex-1 min-h-0 items-center justify-center text-sm text-muted-foreground">
- Loading...
- </div>
- );
- }
-
- if (!issue) {
- return (
- <div className="flex flex-1 min-h-0 items-center justify-center text-sm text-muted-foreground">
- Issue not found
- </div>
- );
- }
-
- return (
- <div className="flex flex-1 min-h-0">
- {/* LEFT: Content area */}
- <div className="flex-1 overflow-y-auto">
- {/* Header bar */}
- <div className="sticky top-0 z-10 flex h-11 items-center justify-between border-b bg-background px-6 text-[13px]">
- <div className="flex items-center gap-1.5">
- <Link
- href="/issues"
- className="text-muted-foreground hover:text-foreground transition-colors"
- >
- Issues
- </Link>
- <ChevronRight className="h-3 w-3 text-muted-foreground/50" />
- <span className="truncate text-muted-foreground">{issue.id.slice(0, 8)}</span>
- </div>
- <AlertDialog>
- <AlertDialogTrigger
- render={<Button variant="ghost" size="icon-xs" className="text-muted-foreground hover:bg-destructive/10 hover:text-destructive" />}
- >
- <Trash2 className="h-4 w-4" />
- </AlertDialogTrigger>
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogTitle>Delete issue</AlertDialogTitle>
- <AlertDialogDescription>
- This will permanently delete this issue and all its comments. This action cannot be undone.
- </AlertDialogDescription>
- </AlertDialogHeader>
- <AlertDialogFooter>
- <AlertDialogCancel>Cancel</AlertDialogCancel>
- <AlertDialogAction
- onClick={handleDelete}
- disabled={deleting}
- className="bg-destructive text-white hover:bg-destructive/90"
- >
- {deleting ? "Deleting..." : "Delete"}
- </AlertDialogAction>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
- </div>
-
- {/* Content */}
- <div className="mx-auto w-full max-w-3xl px-8 py-8">
- <div className="mb-1 text-[13px] text-muted-foreground">{issue.id.slice(0, 8)}</div>
-
- {editingTitle ? (
- <Input
- autoFocus
- value={titleDraft}
- onChange={(e) => setTitleDraft(e.target.value)}
- onBlur={() => {
- if (titleDraft.trim()) handleUpdateField({ title: titleDraft.trim() });
- setEditingTitle(false);
- }}
- onKeyDown={(e) => {
- if (e.key === "Enter") {
- if (titleDraft.trim()) handleUpdateField({ title: titleDraft.trim() });
- setEditingTitle(false);
- } else if (e.key === "Escape") {
- setEditingTitle(false);
- }
- }}
- className="text-xl font-semibold leading-snug tracking-tight"
- />
- ) : (
- <h1
- className="text-xl font-semibold leading-snug tracking-tight cursor-pointer hover:bg-accent/50 rounded px-1 -mx-1"
- onClick={() => { setTitleDraft(issue.title); setEditingTitle(true); }}
- >
- {issue.title}
- </h1>
- )}
-
- {editingDesc ? (
- <Textarea
- autoFocus
- value={descDraft}
- onChange={(e) => setDescDraft(e.target.value)}
- onBlur={() => {
- handleUpdateField({ description: descDraft.trim() || undefined });
- setEditingDesc(false);
- }}
- onKeyDown={(e) => {
- if (e.key === "Escape") setEditingDesc(false);
- }}
- rows={4}
- className="mt-5 text-[14px] leading-[1.7] resize-none"
- />
- ) : (
- <div
- className="mt-5 text-[14px] leading-[1.7] whitespace-pre-wrap cursor-pointer hover:bg-accent/50 rounded px-1 -mx-1"
- onClick={() => { setDescDraft(issue.description || ""); setEditingDesc(true); }}
- >
- {issue.description ? (
- <span className="text-foreground/85">{issue.description}</span>
- ) : (
- <span className="text-muted-foreground">Add description...</span>
- )}
- </div>
- )}
-
- <div className="space-y-4 mt-4">
- <AcceptanceCriteriaEditor
- criteria={issue.acceptance_criteria}
- onUpdate={handleUpdateField}
- />
- <ContextRefsEditor
- refs={issue.context_refs}
- onUpdate={handleUpdateField}
- />
- </div>
-
- <div className="my-8 border-t" />
-
- {/* Activity / Comments */}
- <div>
- <h2 className="text-[13px] font-medium">Activity</h2>
-
- <div className="mt-4">
- {comments.map((comment) => {
- const isOwn = comment.author_type === "member" && comment.author_id === user?.id;
- return (
- <div key={comment.id} className={`group relative py-3${comment.id.startsWith("temp-") ? " opacity-60" : ""}`}>
- <div className="flex items-center gap-2.5">
- <ActorAvatar
- actorType={comment.author_type}
- actorId={comment.author_id}
- size={28}
- getName={getActorName}
- getInitials={getActorInitials}
- />
- <span className="text-[13px] font-medium">
- {getActorName(comment.author_type, comment.author_id)}
- </span>
- <Tooltip>
- <TooltipTrigger
- render={
- <span className="text-[12px] text-muted-foreground cursor-default">
- {timeAgo(comment.created_at)}
- </span>
- }
- />
- <TooltipContent side="top">
- {new Date(comment.created_at).toLocaleString()}
- </TooltipContent>
- </Tooltip>
- {isOwn && (
- <div className="ml-auto flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
- <Button
- variant="ghost"
- size="icon-xs"
- onClick={() => startEditComment(comment)}
- className="text-muted-foreground hover:text-foreground"
- >
- <Pencil className="h-3 w-3" />
- </Button>
- <Button
- variant="ghost"
- size="icon-xs"
- onClick={() => handleDeleteComment(comment.id)}
- className="text-muted-foreground hover:text-destructive"
- >
- <Trash2 className="h-3 w-3" />
- </Button>
- </div>
- )}
- </div>
- {editingCommentId === comment.id ? (
- <form onSubmit={(e) => { e.preventDefault(); handleSaveEditComment(); }} className="mt-2 pl-[38px]">
- <input
- autoFocus
- value={editContent}
- onChange={(e) => setEditContent(e.target.value)}
- aria-label="Edit comment"
- className="w-full text-[13px] bg-transparent border-b outline-none"
- onKeyDown={(e) => { if (e.key === "Escape") setEditingCommentId(null); }}
- />
- </form>
- ) : (
- <div className="mt-2 pl-[38px] text-[13px] leading-[1.6] text-foreground/85 whitespace-pre-wrap">
- {comment.content}
- </div>
- )}
- </div>
- );
- })}
- </div>
-
- {/* Comment input */}
- <form onSubmit={handleSubmitComment} className="mt-2 border-t pt-4">
- <div className="flex items-center gap-2">
- <Input
- type="text"
- value={commentText}
- onChange={(e) => setCommentText(e.target.value)}
- placeholder="Leave a comment..."
- className="flex-1 text-[13px]"
- />
- <Button
- type="submit"
- size="icon"
- disabled={!commentText.trim() || submitting}
- >
- <Send className="h-3.5 w-3.5" />
- </Button>
- </div>
- </form>
- </div>
- </div>
- </div>
-
- {/* RIGHT: Properties sidebar */}
- <div className="w-60 shrink-0 overflow-y-auto border-l">
- <div className="p-4">
- <div className="mb-2 text-[12px] font-medium text-muted-foreground">
- Properties
- </div>
-
- <div className="space-y-0.5">
- <PropRow label="Status">
- <StatusPicker status={issue.status} onUpdate={handleUpdateField} />
- </PropRow>
-
- <PropRow label="Priority">
- <PriorityPicker priority={issue.priority} onUpdate={handleUpdateField} />
- </PropRow>
-
- <PropRow label="Assignee">
- <AssigneePicker
- assigneeType={issue.assignee_type}
- assigneeId={issue.assignee_id}
- onUpdate={handleUpdateField}
- />
- </PropRow>
-
- <PropRow label="Due date">
- <DueDatePicker dueDate={issue.due_date} onUpdate={handleUpdateField} />
- </PropRow>
-
- <PropRow label="Created by">
- <ActorAvatar
- actorType={issue.creator_type}
- actorId={issue.creator_id}
- size={18}
- getName={getActorName}
- getInitials={getActorInitials}
- />
- <span>{getActorName(issue.creator_type, issue.creator_id)}</span>
- </PropRow>
- </div>
-
- <div className="mt-4 border-t pt-3 space-y-0.5">
- <PropRow label="Created">
- <span className="text-muted-foreground">{shortDate(issue.created_at)}</span>
- </PropRow>
- <PropRow label="Updated">
- <span className="text-muted-foreground">{shortDate(issue.updated_at)}</span>
- </PropRow>
- </div>
- </div>
- </div>
- </div>
- );
+ return <IssueDetail issueId={id} />;
}
diff --git a/apps/web/app/(dashboard)/issues/page.tsx b/apps/web/app/(dashboard)/issues/page.tsx
index 726ab343a0..3a6a901699 100644
--- a/apps/web/app/(dashboard)/issues/page.tsx
+++ b/apps/web/app/(dashboard)/issues/page.tsx
@@ -68,7 +68,7 @@ function BoardCardContent({ issue }: { issue: Issue }) {
<PriorityIcon priority={issue.priority} />
<span>{issue.id.slice(0, 8)}</span>
</div>
- <p className="mt-1.5 text-[13px] leading-snug">{issue.title}</p>
+ <p className="mt-1.5 text-sm leading-snug">{issue.title}</p>
<div className="mt-2.5 flex items-center justify-between">
<div className="flex items-center gap-2">
{issue.assignee_type && issue.assignee_id && (
@@ -261,7 +261,7 @@ function ListRow({ issue }: { issue: Issue }) {
return (
<Link
href={`/issues/${issue.id}`}
- className="flex h-9 items-center gap-2 px-4 text-[13px] transition-colors hover:bg-accent/50"
+ className="flex h-9 items-center gap-2 px-4 text-sm transition-colors hover:bg-accent/50"
>
<PriorityIcon priority={issue.priority} />
<span className="w-16 shrink-0 text-xs text-muted-foreground">
diff --git a/apps/web/app/(dashboard)/knowledge-base/page.tsx b/apps/web/app/(dashboard)/knowledge-base/page.tsx
index fd96d11799..fc08b44216 100644
--- a/apps/web/app/(dashboard)/knowledge-base/page.tsx
+++ b/apps/web/app/(dashboard)/knowledge-base/page.tsx
@@ -55,7 +55,7 @@ function renderMarkdown(text: string): React.ReactNode[] {
elements.push(
<pre
key={`code-${i}`}
- className="my-3 overflow-x-auto rounded-md bg-muted px-4 py-3 text-[13px] leading-relaxed"
+ className="my-3 overflow-x-auto rounded-md bg-muted px-4 py-3 text-sm leading-relaxed"
>
<code>{codeLines.join("\n")}</code>
</pre>
@@ -79,7 +79,7 @@ function renderMarkdown(text: string): React.ReactNode[] {
const body = dataRows.slice(1).map(parseRow);
elements.push(
<div key={`table-${i}`} className="my-3 overflow-x-auto">
- <table className="w-full text-[13px]">
+ <table className="w-full text-sm">
<thead>
<tr className="border-b">
{header.map((h, hi) => (
@@ -110,7 +110,7 @@ function renderMarkdown(text: string): React.ReactNode[] {
// Heading
if (line.startsWith("## ")) {
elements.push(
- <h2 key={`h2-${i}`} className="mt-6 mb-2 text-[15px] font-semibold">
+ <h2 key={`h2-${i}`} className="mt-6 mb-2 text-base font-semibold">
{line.slice(3)}
</h2>,
);
@@ -119,7 +119,7 @@ function renderMarkdown(text: string): React.ReactNode[] {
}
if (line.startsWith("### ")) {
elements.push(
- <h3 key={`h3-${i}`} className="mt-4 mb-1.5 text-[14px] font-medium">
+ <h3 key={`h3-${i}`} className="mt-4 mb-1.5 text-sm font-medium">
{line.slice(4)}
</h3>,
);
@@ -132,7 +132,7 @@ function renderMarkdown(text: string): React.ReactNode[] {
const checked = line.includes("[x]");
const text = line.replace(/^- \[[ x]\] /, "");
elements.push(
- <div key={`check-${i}`} className="flex items-center gap-2 py-0.5 text-[13px] text-foreground/80">
+ <div key={`check-${i}`} className="flex items-center gap-2 py-0.5 text-sm text-foreground/80">
<input type="checkbox" checked={checked} readOnly className="h-3.5 w-3.5 rounded" />
<span>{text}</span>
</div>
@@ -142,8 +142,8 @@ function renderMarkdown(text: string): React.ReactNode[] {
}
if (line.startsWith("- ")) {
elements.push(
- <div key={`li-${i}`} className="flex gap-2 py-0.5 text-[13px] text-foreground/80">
- <span className="mt-[7px] h-1 w-1 shrink-0 rounded-full bg-foreground/40" />
+ <div key={`li-${i}`} className="flex gap-2 py-0.5 text-sm text-foreground/80">
+ <span className="mt-2 h-1 w-1 shrink-0 rounded-full bg-foreground/40" />
<span>{renderInline(line.slice(2))}</span>
</div>
);
@@ -155,7 +155,7 @@ function renderMarkdown(text: string): React.ReactNode[] {
const num = line.match(/^(\d+)\. /)![1]!;
const text = line.replace(/^\d+\. /, "");
elements.push(
- <div key={`ol-${i}`} className="flex gap-2 py-0.5 text-[13px] text-foreground/80">
+ <div key={`ol-${i}`} className="flex gap-2 py-0.5 text-sm text-foreground/80">
<span className="w-4 shrink-0 text-right text-muted-foreground">{num}.</span>
<span>{text}</span>
</div>
@@ -173,7 +173,7 @@ function renderMarkdown(text: string): React.ReactNode[] {
// Paragraph
elements.push(
- <p key={`p-${i}`} className="text-[13px] leading-[1.7] text-foreground/85">
+ <p key={`p-${i}`} className="text-sm leading-relaxed text-foreground/85">
{renderInline(line)}
</p>
);
@@ -189,7 +189,7 @@ function renderInline(text: string): React.ReactNode {
return parts.map((part, i) => {
if (part.startsWith("`") && part.endsWith("`")) {
return (
- <code key={i} className="rounded bg-muted px-1 py-0.5 text-[12px]">
+ <code key={i} className="rounded bg-muted px-1 py-0.5 text-xs">
{part.slice(1, -1)}
</code>
);
@@ -220,8 +220,8 @@ function DocListItem({
>
<FileText className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" />
<div className="min-w-0 flex-1">
- <div className="truncate text-[13px] font-medium">{doc.title}</div>
- <div className="mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground">
+ <div className="truncate text-sm font-medium">{doc.title}</div>
+ <div className="mt-0.5 flex items-center gap-2 text-xs text-muted-foreground">
<span>{doc.createdBy}</span>
<span>·</span>
<span>{timeAgo(doc.updatedAt)}</span>
@@ -239,7 +239,7 @@ function DocDetail({ doc }: { doc: KBDocument }) {
<h1 className="text-xl font-semibold tracking-tight">{doc.title}</h1>
{/* Meta */}
- <div className="mt-2 flex items-center gap-3 text-[12px] text-muted-foreground">
+ <div className="mt-2 flex items-center gap-3 text-xs text-muted-foreground">
<span>By {doc.createdBy}</span>
<span>·</span>
<span>Updated {timeAgo(doc.updatedAt)}</span>
@@ -251,7 +251,7 @@ function DocDetail({ doc }: { doc: KBDocument }) {
{/* Referenced by */}
{doc.referencedBy.length > 0 && (
<div className="mt-10 border-t pt-4">
- <div className="flex items-center gap-1.5 text-[12px] text-muted-foreground">
+ <div className="flex items-center gap-1.5 text-xs text-muted-foreground">
<LinkIcon className="h-3 w-3" />
<span>Referenced by</span>
</div>
@@ -259,7 +259,7 @@ function DocDetail({ doc }: { doc: KBDocument }) {
{doc.referencedBy.map((ref) => (
<span
key={ref}
- className="rounded bg-muted px-2 py-0.5 text-[12px] font-mono"
+ className="rounded bg-muted px-2 py-0.5 text-xs font-mono"
>
{ref}
</span>
@@ -309,7 +309,7 @@ export default function KnowledgeBasePage() {
placeholder="Search docs..."
value={search}
onChange={(e) => setSearch(e.target.value)}
- className="border-0 bg-transparent shadow-none focus-visible:ring-0 flex-1 text-[13px]"
+ className="border-0 bg-transparent shadow-none focus-visible:ring-0 flex-1 text-sm"
/>
</div>
</div>
@@ -325,7 +325,7 @@ export default function KnowledgeBasePage() {
/>
))}
{filtered.length === 0 && (
- <div className="px-4 py-8 text-center text-[13px] text-muted-foreground">
+ <div className="px-4 py-8 text-center text-sm text-muted-foreground">
No documents found
</div>
)}
diff --git a/apps/web/components/markdown/Markdown.tsx b/apps/web/components/markdown/Markdown.tsx
index 348cfc3754..d5f0261cc9 100644
--- a/apps/web/components/markdown/Markdown.tsx
+++ b/apps/web/components/markdown/Markdown.tsx
@@ -129,7 +129,7 @@ function createComponents(
p: ({ children }) => <p className="my-2 leading-relaxed">{children}</p>,
// Styled lists
ul: ({ children }) => (
- <ul className="my-2 space-y-1 ps-[16px] pe-2 list-disc marker:text-muted-foreground">
+ <ul className="my-2 space-y-1 ps-4 pe-2 list-disc marker:text-muted-foreground">
{children}
</ul>
),
@@ -189,7 +189,7 @@ function createComponents(
p: ({ children }) => <p className="my-3 leading-relaxed">{children}</p>,
// Styled lists
ul: ({ children }) => (
- <ul className="my-3 space-y-1.5 ps-[16px] pe-2 list-disc marker:text-muted-foreground">
+ <ul className="my-3 space-y-1.5 ps-4 pe-2 list-disc marker:text-muted-foreground">
{children}
</ul>
),
diff --git a/apps/web/features/auth/initializer.tsx b/apps/web/features/auth/initializer.tsx
index 21903883ce..ae7820c34c 100644
--- a/apps/web/features/auth/initializer.tsx
+++ b/apps/web/features/auth/initializer.tsx
@@ -4,6 +4,9 @@ import { useEffect, type ReactNode } from "react";
import { useAuthStore } from "./store";
import { useWorkspaceStore } from "@/features/workspace";
import { api } from "@/shared/api";
+import { createLogger } from "@/shared/logger";
+
+const logger = createLogger("auth");
/**
* Initializes auth + workspace state from localStorage on mount.
@@ -25,7 +28,7 @@ export function AuthInitializer({ children }: { children: ReactNode }) {
api.listWorkspaces().then((wsList) => {
hydrateWorkspace(wsList, wsId);
- }).catch(console.error);
+ }).catch((err) => logger.error("workspace hydration failed", err));
}, [user, isLoading, hydrateWorkspace]);
return <>{children}</>;
diff --git a/apps/web/features/inbox/store.ts b/apps/web/features/inbox/store.ts
index 3249325c4e..2a97a0d376 100644
--- a/apps/web/features/inbox/store.ts
+++ b/apps/web/features/inbox/store.ts
@@ -3,6 +3,9 @@
import { create } from "zustand";
import type { InboxItem } from "@multica/types";
import { api } from "@/shared/api";
+import { createLogger } from "@/shared/logger";
+
+const logger = createLogger("inbox-store");
interface InboxState {
items: InboxItem[];
@@ -12,6 +15,9 @@ interface InboxState {
addItem: (item: InboxItem) => void;
markRead: (id: string) => void;
archive: (id: string) => void;
+ markAllRead: () => void;
+ archiveAll: () => void;
+ archiveAllRead: () => void;
unreadCount: () => number;
}
@@ -20,14 +26,14 @@ export const useInboxStore = create<InboxState>((set, get) => ({
loading: true,
fetch: async () => {
- console.log("[inbox-store] fetch start");
+ logger.debug("fetch start");
set({ loading: true });
try {
const data = await api.listInbox();
- console.log("[inbox-store] fetched", data.length, "items");
+ logger.info("fetched", data.length, "items");
set({ items: data, loading: false });
} catch (err) {
- console.error("[inbox-store] fetch failed", err);
+ logger.error("fetch failed", err);
set({ loading: false });
}
},
@@ -47,5 +53,19 @@ export const useInboxStore = create<InboxState>((set, get) => ({
set((s) => ({
items: s.items.map((i) => (i.id === id ? { ...i, archived: true } : i)),
})),
+ markAllRead: () =>
+ set((s) => ({
+ items: s.items.map((i) => (!i.archived ? { ...i, read: true } : i)),
+ })),
+ archiveAll: () =>
+ set((s) => ({
+ items: s.items.map((i) => (!i.archived ? { ...i, archived: true } : i)),
+ })),
+ archiveAllRead: () =>
+ set((s) => ({
+ items: s.items.map((i) =>
+ i.read && !i.archived ? { ...i, archived: true } : i
+ ),
+ })),
unreadCount: () => get().items.filter((i) => !i.read && !i.archived).length,
}));
diff --git a/apps/web/features/issues/components/issue-detail.tsx b/apps/web/features/issues/components/issue-detail.tsx
new file mode 100644
index 0000000000..f556e1411e
--- /dev/null
+++ b/apps/web/features/issues/components/issue-detail.tsx
@@ -0,0 +1,759 @@
+"use client";
+
+import { useState, useEffect, useCallback } from "react";
+import Link from "next/link";
+import { useRouter } from "next/navigation";
+import {
+ ChevronRight,
+ Link2,
+ Pencil,
+ Send,
+ Trash2,
+ X,
+} from "lucide-react";
+import { toast } from "sonner";
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+ AlertDialogTrigger,
+} from "@/components/ui/alert-dialog";
+import { Calendar } from "@/components/ui/calendar";
+import {
+ Popover,
+ PopoverTrigger,
+ PopoverContent,
+} from "@/components/ui/popover";
+import { Button } from "@/components/ui/button";
+import { Input } from "@/components/ui/input";
+import { Textarea } from "@/components/ui/textarea";
+import {
+ Tooltip,
+ TooltipTrigger,
+ TooltipContent,
+} from "@/components/ui/tooltip";
+import { ActorAvatar } from "@/components/common/actor-avatar";
+import type { Issue, Comment, UpdateIssueRequest } from "@multica/types";
+import { StatusPicker, PriorityPicker, AssigneePicker } from "@/features/issues/components";
+import { api } from "@/shared/api";
+import { useAuthStore } from "@/features/auth";
+import { useActorName } from "@/features/workspace";
+import { useWSEvent } from "@/features/realtime";
+import { useIssueStore } from "@/features/issues";
+import type { CommentCreatedPayload, CommentUpdatedPayload, CommentDeletedPayload } from "@multica/types";
+
+// ---------------------------------------------------------------------------
+// Helpers
+// ---------------------------------------------------------------------------
+
+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 ago`;
+ const hours = Math.floor(minutes / 60);
+ if (hours < 24) return `${hours}h ago`;
+ const days = Math.floor(hours / 24);
+ return `${days}d ago`;
+}
+
+function shortDate(date: string | null): string {
+ if (!date) return "—";
+ return new Date(date).toLocaleDateString("en-US", {
+ month: "short",
+ day: "numeric",
+ });
+}
+
+// ---------------------------------------------------------------------------
+// Property row
+// ---------------------------------------------------------------------------
+
+function PropRow({
+ label,
+ children,
+}: {
+ label: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <div className="flex min-h-8 items-center gap-3 rounded-md px-2 -mx-2 hover:bg-accent/50 transition-colors">
+ <span className="w-20 shrink-0 text-sm text-muted-foreground">{label}</span>
+ <div className="flex min-w-0 flex-1 items-center justify-end gap-1.5 text-sm">
+ {children}
+ </div>
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Due Date Picker
+// ---------------------------------------------------------------------------
+
+function DueDatePicker({
+ dueDate,
+ onUpdate,
+}: {
+ dueDate: string | null;
+ onUpdate: (updates: Partial<UpdateIssueRequest>) => void;
+}) {
+ const [open, setOpen] = useState(false);
+ const date = dueDate ? new Date(dueDate) : undefined;
+ const isOverdue = date ? date < new Date() : false;
+
+ return (
+ <Popover open={open} onOpenChange={setOpen}>
+ <PopoverTrigger className="flex items-center gap-1.5 cursor-pointer rounded px-1 -mx-1 hover:bg-accent/30 transition-colors">
+ {date ? (
+ <span className={isOverdue ? "text-destructive" : ""}>
+ {date.toLocaleDateString("en-US", { month: "short", day: "numeric" })}
+ </span>
+ ) : (
+ <span className="text-muted-foreground">None</span>
+ )}
+ </PopoverTrigger>
+ <PopoverContent className="w-auto p-0" align="end">
+ <Calendar
+ mode="single"
+ selected={date}
+ onSelect={(d: Date | undefined) => {
+ onUpdate({ due_date: d ? d.toISOString() : null });
+ setOpen(false);
+ }}
+ />
+ {date && (
+ <div className="border-t px-3 py-2">
+ <Button
+ variant="ghost"
+ size="xs"
+ onClick={() => {
+ onUpdate({ due_date: null });
+ setOpen(false);
+ }}
+ className="text-muted-foreground hover:text-foreground"
+ >
+ Clear date
+ </Button>
+ </div>
+ )}
+ </PopoverContent>
+ </Popover>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Acceptance Criteria Editor
+// ---------------------------------------------------------------------------
+
+function AcceptanceCriteriaEditor({
+ criteria,
+ onUpdate,
+}: {
+ criteria: string[];
+ onUpdate: (updates: Partial<UpdateIssueRequest>) => void;
+}) {
+ const [newItem, setNewItem] = useState("");
+
+ const addItem = () => {
+ if (!newItem.trim()) return;
+ onUpdate({ acceptance_criteria: [...criteria, newItem.trim()] });
+ setNewItem("");
+ };
+
+ const removeItem = (index: number) => {
+ onUpdate({ acceptance_criteria: criteria.filter((_, i) => i !== index) });
+ };
+
+ const [adding, setAdding] = useState(false);
+
+ return (
+ <div className="space-y-2">
+ <h3 className="text-xs font-medium text-muted-foreground">Acceptance Criteria</h3>
+ {criteria.length > 0 && (
+ <div className="space-y-1">
+ {criteria.map((item, i) => (
+ <div key={i} className="group flex items-start gap-2 text-sm">
+ <span className="mt-0.5 text-muted-foreground">&bull;</span>
+ <span className="flex-1">{item}</span>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ onClick={() => removeItem(i)}
+ className="opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-foreground transition-opacity"
+ >
+ <X className="h-3.5 w-3.5" />
+ </Button>
+ </div>
+ ))}
+ </div>
+ )}
+ {(criteria.length > 0 || adding) ? (
+ <form
+ onSubmit={(e) => { e.preventDefault(); addItem(); }}
+ className="flex items-center gap-2"
+ >
+ <input
+ autoFocus={adding}
+ value={newItem}
+ onChange={(e) => setNewItem(e.target.value)}
+ onBlur={() => { if (!newItem.trim()) setAdding(false); }}
+ placeholder="Add criteria..."
+ aria-label="Add acceptance criteria"
+ className="flex-1 text-sm bg-transparent outline-none placeholder:text-muted-foreground"
+ />
+ </form>
+ ) : (
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-muted-foreground h-7 px-2 text-xs"
+ onClick={() => setAdding(true)}
+ >
+ + Add acceptance criteria
+ </Button>
+ )}
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Context Refs Editor
+// ---------------------------------------------------------------------------
+
+function ContextRefsEditor({
+ refs,
+ onUpdate,
+}: {
+ refs: string[];
+ onUpdate: (updates: Partial<UpdateIssueRequest>) => void;
+}) {
+ const [newRef, setNewRef] = useState("");
+
+ const addRef = () => {
+ if (!newRef.trim()) return;
+ onUpdate({ context_refs: [...refs, newRef.trim()] });
+ setNewRef("");
+ };
+
+ const removeRef = (index: number) => {
+ onUpdate({ context_refs: refs.filter((_, i) => i !== index) });
+ };
+
+ const [adding, setAdding] = useState(false);
+
+ const isUrl = (s: string) => s.startsWith("http://") || s.startsWith("https://");
+
+ return (
+ <div className="space-y-2">
+ <h3 className="text-xs font-medium text-muted-foreground">Context References</h3>
+ {refs.length > 0 && (
+ <div className="space-y-1">
+ {refs.map((ref, i) => (
+ <div key={i} className="group flex items-center gap-2 text-sm">
+ <Link2 className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
+ {isUrl(ref) ? (
+ <a href={ref} target="_blank" rel="noopener noreferrer" className="flex-1 text-info hover:underline truncate">
+ {ref}
+ </a>
+ ) : (
+ <span className="flex-1 truncate">{ref}</span>
+ )}
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ onClick={() => removeRef(i)}
+ className="opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-foreground transition-opacity"
+ >
+ <X className="h-3.5 w-3.5" />
+ </Button>
+ </div>
+ ))}
+ </div>
+ )}
+ {(refs.length > 0 || adding) ? (
+ <form
+ onSubmit={(e) => { e.preventDefault(); addRef(); }}
+ className="flex items-center gap-2"
+ >
+ <input
+ autoFocus={adding}
+ value={newRef}
+ onChange={(e) => setNewRef(e.target.value)}
+ onBlur={() => { if (!newRef.trim()) setAdding(false); }}
+ placeholder="Add reference URL..."
+ aria-label="Add context reference URL"
+ className="flex-1 text-sm bg-transparent outline-none placeholder:text-muted-foreground"
+ />
+ </form>
+ ) : (
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-muted-foreground h-7 px-2 text-xs"
+ onClick={() => setAdding(true)}
+ >
+ + Add context reference
+ </Button>
+ )}
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Props
+// ---------------------------------------------------------------------------
+
+interface IssueDetailProps {
+ issueId: string;
+ showBreadcrumb?: boolean;
+ onDelete?: () => void;
+}
+
+// ---------------------------------------------------------------------------
+// IssueDetail
+// ---------------------------------------------------------------------------
+
+export function IssueDetail({ issueId, showBreadcrumb, onDelete }: IssueDetailProps) {
+ const id = issueId;
+ const router = useRouter();
+ const user = useAuthStore((s) => s.user);
+ const { getActorName, getActorInitials } = useActorName();
+ const [issue, setIssue] = useState<Issue | null>(null);
+ const [comments, setComments] = useState<Comment[]>([]);
+ const [loading, setLoading] = useState(true);
+ const [commentText, setCommentText] = useState("");
+ const [submitting, setSubmitting] = useState(false);
+ const [deleting, setDeleting] = useState(false);
+ const [editingCommentId, setEditingCommentId] = useState<string | null>(null);
+ const [editContent, setEditContent] = useState("");
+ const [editingTitle, setEditingTitle] = useState(false);
+ const [titleDraft, setTitleDraft] = useState("");
+ const [editingDesc, setEditingDesc] = useState(false);
+ const [descDraft, setDescDraft] = useState("");
+
+ // Watch the global issue store for real-time updates from other users/agents
+ const storeIssue = useIssueStore((s) => s.issues.find((i) => i.id === id));
+
+ useEffect(() => {
+ if (storeIssue) {
+ setIssue(storeIssue);
+ }
+ }, [storeIssue]);
+
+ useEffect(() => {
+ setIssue(null);
+ setComments([]);
+ setLoading(true);
+ Promise.all([api.getIssue(id), api.listComments(id)])
+ .then(([iss, cmts]) => {
+ setIssue(iss);
+ setComments(cmts);
+ })
+ .catch(console.error)
+ .finally(() => setLoading(false));
+ }, [id]);
+
+ const handleSubmitComment = async (e: React.FormEvent) => {
+ e.preventDefault();
+ if (!commentText.trim() || submitting || !user) return;
+ const content = commentText.trim();
+ const tempId = "temp-" + Date.now();
+ const tempComment: Comment = {
+ id: tempId,
+ issue_id: id,
+ author_type: "member",
+ author_id: user.id,
+ content,
+ type: "comment",
+ created_at: new Date().toISOString(),
+ updated_at: new Date().toISOString(),
+ };
+ setComments((prev) => [...prev, tempComment]);
+ setCommentText("");
+ setSubmitting(true);
+ try {
+ const comment = await api.createComment(id, content);
+ setComments((prev) => prev.map((c) => (c.id === tempId ? comment : c)));
+ } catch {
+ setComments((prev) => prev.filter((c) => c.id !== tempId));
+ toast.error("Failed to send comment");
+ } finally {
+ setSubmitting(false);
+ }
+ };
+
+ const handleUpdateField = useCallback(
+ (updates: Partial<UpdateIssueRequest>) => {
+ if (!issue) return;
+ const prev = issue;
+ setIssue((curr) => (curr ? ({ ...curr, ...updates } as Issue) : curr));
+ api.updateIssue(id, updates).catch(() => {
+ setIssue(prev);
+ toast.error("Failed to update issue");
+ });
+ },
+ [issue, id],
+ );
+
+ const handleDelete = async () => {
+ setDeleting(true);
+ try {
+ await api.deleteIssue(issue!.id);
+ toast.success("Issue deleted");
+ if (onDelete) onDelete();
+ else router.push("/issues");
+ } catch {
+ toast.error("Failed to delete issue");
+ setDeleting(false);
+ }
+ };
+
+ const startEditComment = (c: Comment) => {
+ setEditingCommentId(c.id);
+ setEditContent(c.content);
+ };
+
+ const handleSaveEditComment = async () => {
+ if (!editingCommentId || !editContent.trim()) return;
+ try {
+ const updated = await api.updateComment(editingCommentId, editContent.trim());
+ setComments((prev) => prev.map((c) => (c.id === updated.id ? updated : c)));
+ setEditingCommentId(null);
+ } catch {
+ toast.error("Failed to update comment");
+ }
+ };
+
+ const handleDeleteComment = async (commentId: string) => {
+ try {
+ await api.deleteComment(commentId);
+ setComments((prev) => prev.filter((c) => c.id !== commentId));
+ } catch {
+ toast.error("Failed to delete comment");
+ }
+ };
+
+ // Real-time comment updates
+ useWSEvent(
+ "comment:created",
+ useCallback((payload: unknown) => {
+ const { comment } = payload as CommentCreatedPayload;
+ if (comment.issue_id !== id) return;
+ // Skip own comments — already added locally via API response
+ if (comment.author_type === "member" && comment.author_id === user?.id) return;
+ setComments((prev) => {
+ if (prev.some((c) => c.id === comment.id)) return prev;
+ return [...prev, comment];
+ });
+ }, [id, user?.id]),
+ );
+
+ useWSEvent(
+ "comment:updated",
+ useCallback((payload: unknown) => {
+ const { comment } = payload as CommentUpdatedPayload;
+ if (comment.issue_id === id) {
+ setComments((prev) => prev.map((c) => (c.id === comment.id ? comment : c)));
+ }
+ }, [id]),
+ );
+
+ useWSEvent(
+ "comment:deleted",
+ useCallback((payload: unknown) => {
+ const { comment_id, issue_id } = payload as CommentDeletedPayload;
+ if (issue_id === id) {
+ setComments((prev) => prev.filter((c) => c.id !== comment_id));
+ }
+ }, [id]),
+ );
+
+ if (loading) {
+ return (
+ <div className="flex flex-1 min-h-0 items-center justify-center text-sm text-muted-foreground">
+ Loading...
+ </div>
+ );
+ }
+
+ if (!issue) {
+ return (
+ <div className="flex flex-1 min-h-0 items-center justify-center text-sm text-muted-foreground">
+ Issue not found
+ </div>
+ );
+ }
+
+ return (
+ <div className="flex flex-1 min-h-0">
+ {/* LEFT: Content area */}
+ <div className="flex-1 overflow-y-auto">
+ {/* Header bar */}
+ {showBreadcrumb !== false && (
+ <div className="sticky top-0 z-10 flex h-11 items-center justify-between border-b bg-background px-6 text-sm">
+ <div className="flex items-center gap-1.5">
+ <Link
+ href="/issues"
+ className="text-muted-foreground hover:text-foreground transition-colors"
+ >
+ Issues
+ </Link>
+ <ChevronRight className="h-3 w-3 text-muted-foreground/50" />
+ <span className="truncate text-muted-foreground">{issue.id.slice(0, 8)}</span>
+ </div>
+ <AlertDialog>
+ <AlertDialogTrigger
+ render={<Button variant="ghost" size="icon-xs" className="text-muted-foreground hover:bg-destructive/10 hover:text-destructive" />}
+ >
+ <Trash2 className="h-4 w-4" />
+ </AlertDialogTrigger>
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Delete issue</AlertDialogTitle>
+ <AlertDialogDescription>
+ This will permanently delete this issue and all its comments. This action cannot be undone.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
+ <AlertDialogAction
+ onClick={handleDelete}
+ disabled={deleting}
+ className="bg-destructive text-white hover:bg-destructive/90"
+ >
+ {deleting ? "Deleting..." : "Delete"}
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+ </div>
+ )}
+
+ {/* Content */}
+ <div className="mx-auto w-full max-w-3xl px-8 py-8">
+ <div className="mb-1 text-sm text-muted-foreground">{issue.id.slice(0, 8)}</div>
+
+ {editingTitle ? (
+ <Input
+ autoFocus
+ value={titleDraft}
+ onChange={(e) => setTitleDraft(e.target.value)}
+ onBlur={() => {
+ if (titleDraft.trim()) handleUpdateField({ title: titleDraft.trim() });
+ setEditingTitle(false);
+ }}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ if (titleDraft.trim()) handleUpdateField({ title: titleDraft.trim() });
+ setEditingTitle(false);
+ } else if (e.key === "Escape") {
+ setEditingTitle(false);
+ }
+ }}
+ className="text-xl font-semibold leading-snug tracking-tight"
+ />
+ ) : (
+ <h1
+ className="text-xl font-semibold leading-snug tracking-tight cursor-pointer hover:bg-accent/50 rounded px-1 -mx-1"
+ onClick={() => { setTitleDraft(issue.title); setEditingTitle(true); }}
+ >
+ {issue.title}
+ </h1>
+ )}
+
+ {editingDesc ? (
+ <Textarea
+ autoFocus
+ value={descDraft}
+ onChange={(e) => setDescDraft(e.target.value)}
+ onBlur={() => {
+ handleUpdateField({ description: descDraft.trim() || undefined });
+ setEditingDesc(false);
+ }}
+ onKeyDown={(e) => {
+ if (e.key === "Escape") setEditingDesc(false);
+ }}
+ rows={4}
+ className="mt-5 text-sm leading-relaxed resize-none"
+ />
+ ) : (
+ <div
+ className="mt-5 text-sm leading-relaxed whitespace-pre-wrap cursor-pointer hover:bg-accent/50 rounded px-1 -mx-1"
+ onClick={() => { setDescDraft(issue.description || ""); setEditingDesc(true); }}
+ >
+ {issue.description ? (
+ <span className="text-foreground/85">{issue.description}</span>
+ ) : (
+ <span className="text-muted-foreground">Add description...</span>
+ )}
+ </div>
+ )}
+
+ <div className="space-y-4 mt-4">
+ <AcceptanceCriteriaEditor
+ criteria={issue.acceptance_criteria}
+ onUpdate={handleUpdateField}
+ />
+ <ContextRefsEditor
+ refs={issue.context_refs}
+ onUpdate={handleUpdateField}
+ />
+ </div>
+
+ <div className="my-8 border-t" />
+
+ {/* Activity / Comments */}
+ <div>
+ <h2 className="text-sm font-medium">Activity</h2>
+
+ <div className="mt-4">
+ {comments.map((comment) => {
+ const isOwn = comment.author_type === "member" && comment.author_id === user?.id;
+ return (
+ <div key={comment.id} className={`group relative py-3${comment.id.startsWith("temp-") ? " opacity-60" : ""}`}>
+ <div className="flex items-center gap-2.5">
+ <ActorAvatar
+ actorType={comment.author_type}
+ actorId={comment.author_id}
+ size={28}
+ getName={getActorName}
+ getInitials={getActorInitials}
+ />
+ <span className="text-sm font-medium">
+ {getActorName(comment.author_type, comment.author_id)}
+ </span>
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <span className="text-xs text-muted-foreground cursor-default">
+ {timeAgo(comment.created_at)}
+ </span>
+ }
+ />
+ <TooltipContent side="top">
+ {new Date(comment.created_at).toLocaleString()}
+ </TooltipContent>
+ </Tooltip>
+ {isOwn && (
+ <div className="ml-auto flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ onClick={() => startEditComment(comment)}
+ className="text-muted-foreground hover:text-foreground"
+ >
+ <Pencil className="h-3 w-3" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ onClick={() => handleDeleteComment(comment.id)}
+ className="text-muted-foreground hover:text-destructive"
+ >
+ <Trash2 className="h-3 w-3" />
+ </Button>
+ </div>
+ )}
+ </div>
+ {editingCommentId === comment.id ? (
+ <form onSubmit={(e) => { e.preventDefault(); handleSaveEditComment(); }} className="mt-2 pl-9.5">
+ <input
+ autoFocus
+ value={editContent}
+ onChange={(e) => setEditContent(e.target.value)}
+ aria-label="Edit comment"
+ className="w-full text-sm bg-transparent border-b outline-none"
+ onKeyDown={(e) => { if (e.key === "Escape") setEditingCommentId(null); }}
+ />
+ </form>
+ ) : (
+ <div className="mt-2 pl-9.5 text-sm leading-relaxed text-foreground/85 whitespace-pre-wrap">
+ {comment.content}
+ </div>
+ )}
+ </div>
+ );
+ })}
+ </div>
+
+ {/* Comment input */}
+ <form onSubmit={handleSubmitComment} className="mt-2 border-t pt-4">
+ <div className="flex items-center gap-2">
+ <Input
+ type="text"
+ value={commentText}
+ onChange={(e) => setCommentText(e.target.value)}
+ placeholder="Leave a comment..."
+ className="flex-1 text-sm"
+ />
+ <Button
+ type="submit"
+ size="icon"
+ disabled={!commentText.trim() || submitting}
+ >
+ <Send className="h-3.5 w-3.5" />
+ </Button>
+ </div>
+ </form>
+ </div>
+ </div>
+ </div>
+
+ {/* RIGHT: Properties sidebar */}
+ <div className="w-60 shrink-0 overflow-y-auto border-l">
+ <div className="p-4">
+ <div className="mb-2 text-xs font-medium text-muted-foreground">
+ Properties
+ </div>
+
+ <div className="space-y-0.5">
+ <PropRow label="Status">
+ <StatusPicker status={issue.status} onUpdate={handleUpdateField} />
+ </PropRow>
+
+ <PropRow label="Priority">
+ <PriorityPicker priority={issue.priority} onUpdate={handleUpdateField} />
+ </PropRow>
+
+ <PropRow label="Assignee">
+ <AssigneePicker
+ assigneeType={issue.assignee_type}
+ assigneeId={issue.assignee_id}
+ onUpdate={handleUpdateField}
+ />
+ </PropRow>
+
+ <PropRow label="Due date">
+ <DueDatePicker dueDate={issue.due_date} onUpdate={handleUpdateField} />
+ </PropRow>
+
+ <PropRow label="Created by">
+ <ActorAvatar
+ actorType={issue.creator_type}
+ actorId={issue.creator_id}
+ size={18}
+ getName={getActorName}
+ getInitials={getActorInitials}
+ />
+ <span>{getActorName(issue.creator_type, issue.creator_id)}</span>
+ </PropRow>
+ </div>
+
+ <div className="mt-4 border-t pt-3 space-y-0.5">
+ <PropRow label="Created">
+ <span className="text-muted-foreground">{shortDate(issue.created_at)}</span>
+ </PropRow>
+ <PropRow label="Updated">
+ <span className="text-muted-foreground">{shortDate(issue.updated_at)}</span>
+ </PropRow>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/features/issues/components/pickers/assignee-picker.tsx b/apps/web/features/issues/components/pickers/assignee-picker.tsx
index 128c069151..cc33a8f349 100644
--- a/apps/web/features/issues/components/pickers/assignee-picker.tsx
+++ b/apps/web/features/issues/components/pickers/assignee-picker.tsx
@@ -57,7 +57,7 @@ export function AssigneePicker({
assigneeType && assigneeId ? (
<>
<div
- className={`inline-flex shrink-0 items-center justify-center rounded-full font-medium text-[8px] size-[18px] ${
+ className={`inline-flex shrink-0 items-center justify-center rounded-full font-medium text-[8px] size-4.5 ${
assigneeType === "agent"
? "bg-info/10 text-info"
: "bg-muted text-muted-foreground"
@@ -103,7 +103,7 @@ export function AssigneePicker({
setOpen(false);
}}
>
- <div className="inline-flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full bg-muted text-[8px] font-medium text-muted-foreground">
+ <div className="inline-flex size-4.5 shrink-0 items-center justify-center rounded-full bg-muted text-[8px] font-medium text-muted-foreground">
{getActorInitials("member", m.user_id)}
</div>
<span>{m.name}</span>
@@ -127,7 +127,7 @@ export function AssigneePicker({
setOpen(false);
}}
>
- <div className="inline-flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full bg-info/10 text-info">
+ <div className="inline-flex size-4.5 shrink-0 items-center justify-center rounded-full bg-info/10 text-info">
<Bot className="size-2.5" />
</div>
<span>{a.name}</span>
diff --git a/apps/web/features/issues/components/pickers/property-picker.tsx b/apps/web/features/issues/components/pickers/property-picker.tsx
index 4c734bb5e2..d9d4d3f33e 100644
--- a/apps/web/features/issues/components/pickers/property-picker.tsx
+++ b/apps/web/features/issues/components/pickers/property-picker.tsx
@@ -63,7 +63,7 @@ export function PropertyPicker({
}}
placeholder={searchPlaceholder}
aria-label="Filter options"
- className="w-full bg-transparent text-[13px] placeholder:text-muted-foreground outline-none"
+ className="w-full bg-transparent text-sm placeholder:text-muted-foreground outline-none"
/>
</div>
)}
@@ -92,7 +92,7 @@ export function PickerItem({
<button
type="button"
onClick={onClick}
- className={`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-[13px] ${hoverClassName ?? "hover:bg-accent"} transition-colors`}
+ className={`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm ${hoverClassName ?? "hover:bg-accent"} transition-colors`}
>
<span className="flex flex-1 items-center gap-2">{children}</span>
{selected && <Check className="h-3.5 w-3.5 text-muted-foreground" />}
@@ -113,7 +113,7 @@ export function PickerSection({
}) {
return (
<div>
- <div className="px-2 pt-2 pb-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wider">
+ <div className="px-2 pt-2 pb-1 text-xs font-medium text-muted-foreground uppercase tracking-wider">
{label}
</div>
{children}
@@ -127,7 +127,7 @@ export function PickerSection({
export function PickerEmpty() {
return (
- <div className="px-2 py-3 text-center text-[13px] text-muted-foreground">
+ <div className="px-2 py-3 text-center text-sm text-muted-foreground">
No results
</div>
);
diff --git a/apps/web/features/issues/store.ts b/apps/web/features/issues/store.ts
index 1dd82b595d..aa8a59ac8b 100644
--- a/apps/web/features/issues/store.ts
+++ b/apps/web/features/issues/store.ts
@@ -3,6 +3,9 @@
import { create } from "zustand";
import type { Issue } from "@multica/types";
import { api } from "@/shared/api";
+import { createLogger } from "@/shared/logger";
+
+const logger = createLogger("issue-store");
interface IssueState {
issues: Issue[];
@@ -22,14 +25,14 @@ export const useIssueStore = create<IssueState>((set) => ({
activeIssueId: null,
fetch: async () => {
- console.log("[issue-store] fetch start");
+ logger.debug("fetch start");
set({ loading: true });
try {
const res = await api.listIssues({ limit: 200 });
- console.log("[issue-store] fetched", res.issues.length, "issues");
+ logger.info("fetched", res.issues.length, "issues");
set({ issues: res.issues, loading: false });
} catch (err) {
- console.error("[issue-store] fetch failed", err);
+ logger.error("fetch failed", err);
set({ loading: false });
}
},
diff --git a/apps/web/features/realtime/provider.tsx b/apps/web/features/realtime/provider.tsx
index 83bc7c3625..5153ba862b 100644
--- a/apps/web/features/realtime/provider.tsx
+++ b/apps/web/features/realtime/provider.tsx
@@ -13,6 +13,7 @@ import { WSClient } from "@multica/sdk";
import type { WSEventType } from "@multica/types";
import { useAuthStore } from "@/features/auth";
import { useWorkspaceStore } from "@/features/workspace";
+import { createLogger } from "@/shared/logger";
import { useRealtimeSync } from "./use-realtime-sync";
const WS_URL = process.env.NEXT_PUBLIC_WS_URL ?? "ws://localhost:8080/ws";
@@ -37,7 +38,7 @@ export function WSProvider({ children }: { children: ReactNode }) {
const token = localStorage.getItem("multica_token");
if (!token) return;
- const ws = new WSClient(WS_URL);
+ const ws = new WSClient(WS_URL, { logger: createLogger("ws") });
ws.setAuth(token, workspace.id);
wsRef.current = ws;
setWsClient(ws);
diff --git a/apps/web/features/realtime/use-realtime-sync.ts b/apps/web/features/realtime/use-realtime-sync.ts
index b364a927ff..a372813de1 100644
--- a/apps/web/features/realtime/use-realtime-sync.ts
+++ b/apps/web/features/realtime/use-realtime-sync.ts
@@ -7,6 +7,7 @@ import { useIssueStore } from "@/features/issues";
import { useInboxStore } from "@/features/inbox";
import { useWorkspaceStore } from "@/features/workspace";
import { useAuthStore } from "@/features/auth";
+import { createLogger } from "@/shared/logger";
import type {
IssueCreatedPayload,
IssueUpdatedPayload,
@@ -23,6 +24,8 @@ import type {
MemberRemovedPayload,
} from "@multica/types";
+const logger = createLogger("realtime-sync");
+
/**
* Centralized WS → store sync. Called once from WSProvider.
* Subscribes to all global WS events and dispatches to Zustand stores.
@@ -72,6 +75,12 @@ export function useRealtimeSync(ws: WSClient | null) {
const { item_id } = p as InboxArchivedPayload;
useInboxStore.getState().archive(item_id);
}),
+ ws.on("inbox:batch-read", () => {
+ useInboxStore.getState().markAllRead();
+ }),
+ ws.on("inbox:batch-archived", () => {
+ useInboxStore.getState().fetch();
+ }),
];
return () => unsubs.forEach((u) => u());
@@ -108,27 +117,27 @@ export function useRealtimeSync(ws: WSClient | null) {
const unsubs = [
ws.on("workspace:updated", (p) => {
const { workspace } = p as WorkspaceUpdatedPayload;
- console.log("[realtime-sync] workspace:updated", workspace.name);
+ logger.debug("workspace:updated", workspace.name);
useWorkspaceStore.getState().updateWorkspace(workspace);
}),
ws.on("workspace:deleted", (p) => {
const { workspace_id } = p as WorkspaceDeletedPayload;
const currentWs = useWorkspaceStore.getState().workspace;
if (currentWs?.id === workspace_id) {
- console.log("[realtime-sync] current workspace deleted, switching away");
+ logger.warn("current workspace deleted, switching");
toast.info("This workspace was deleted");
useWorkspaceStore.getState().refreshWorkspaces();
}
}),
ws.on("member:updated", (p) => {
const payload = p as MemberUpdatedPayload;
- console.log("[realtime-sync] member:updated", payload.member.email, payload.member.role);
+ logger.debug("member:updated", payload.member.email, payload.member.role);
useWorkspaceStore.getState().refreshMembers();
}),
ws.on("member:added", (p) => {
const payload = p as MemberAddedPayload;
const myUserId = useAuthStore.getState().user?.id;
- console.log("[realtime-sync] member:added", payload.member.email);
+ logger.debug("member:added", payload.member.email);
if (payload.member.user_id === myUserId) {
// I was invited to a workspace — refresh list so it appears
useWorkspaceStore.getState().refreshWorkspaces();
@@ -139,9 +148,9 @@ export function useRealtimeSync(ws: WSClient | null) {
ws.on("member:removed", (p) => {
const payload = p as MemberRemovedPayload;
const myUserId = useAuthStore.getState().user?.id;
- console.log("[realtime-sync] member:removed user_id:", payload.user_id);
+ logger.debug("member:removed", payload.user_id);
if (payload.user_id === myUserId) {
- console.log("[realtime-sync] I was removed, switching away");
+ logger.warn("removed from workspace, switching");
toast.info("You were removed from this workspace");
useWorkspaceStore.getState().refreshWorkspaces();
} else {
@@ -158,7 +167,7 @@ export function useRealtimeSync(ws: WSClient | null) {
if (!ws) return;
const unsub = ws.onReconnect(async () => {
- console.log("[realtime-sync] reconnected, refetching all data");
+ logger.info("reconnected, refetching all data");
try {
await Promise.all([
useIssueStore.getState().fetch(),
diff --git a/apps/web/features/skills/components/skills-page.tsx b/apps/web/features/skills/components/skills-page.tsx
index ae5d463240..660fbbe54e 100644
--- a/apps/web/features/skills/components/skills-page.tsx
+++ b/apps/web/features/skills/components/skills-page.tsx
@@ -133,7 +133,7 @@ function SkillListItem({
)}
</div>
{(skill.files?.length ?? 0) > 0 && (
- <span className="shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground">
+ <span className="shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground">
{skill.files.length} file{skill.files.length !== 1 ? "s" : ""}
</span>
)}
diff --git a/apps/web/features/workspace/components/workspace-avatar.tsx b/apps/web/features/workspace/components/workspace-avatar.tsx
index 19c760d580..d415c8dd0b 100644
--- a/apps/web/features/workspace/components/workspace-avatar.tsx
+++ b/apps/web/features/workspace/components/workspace-avatar.tsx
@@ -1,7 +1,7 @@
import { cn } from "@/lib/utils";
const sizeMap = {
- sm: "h-5 w-5 text-[10px] rounded",
+ sm: "h-5 w-5 text-xs rounded",
md: "h-7 w-7 text-xs rounded-md",
lg: "h-9 w-9 text-sm rounded-md",
} as const;
diff --git a/apps/web/features/workspace/store.ts b/apps/web/features/workspace/store.ts
index bbabe377ed..c578ff7d9d 100644
--- a/apps/web/features/workspace/store.ts
+++ b/apps/web/features/workspace/store.ts
@@ -5,6 +5,9 @@ import type { Workspace, MemberWithUser, Agent, Skill } from "@multica/types";
import { useIssueStore } from "@/features/issues";
import { useInboxStore } from "@/features/inbox";
import { api } from "@/shared/api";
+import { createLogger } from "@/shared/logger";
+
+const logger = createLogger("workspace-store");
interface WorkspaceState {
workspace: Workspace | null;
@@ -70,7 +73,7 @@ export const useWorkspaceStore = create<WorkspaceStore>((set, get) => ({
localStorage.setItem("multica_workspace_id", nextWorkspace.id);
set({ workspace: nextWorkspace });
- console.log("[workspace-store] hydrate workspace:", nextWorkspace.name, nextWorkspace.id);
+ logger.debug("hydrate workspace", nextWorkspace.name, nextWorkspace.id);
const [nextMembers, nextAgents, nextSkills] = await Promise.all([
api.listMembers(nextWorkspace.id),
api.listAgents({ workspace_id: nextWorkspace.id }),
@@ -78,14 +81,14 @@ export const useWorkspaceStore = create<WorkspaceStore>((set, get) => ({
useIssueStore.getState().fetch(),
useInboxStore.getState().fetch(),
]);
- console.log("[workspace-store] hydrate complete, members:", nextMembers.length, "agents:", nextAgents.length);
+ logger.info("hydrate complete", "members:", nextMembers.length, "agents:", nextAgents.length);
set({ members: nextMembers, agents: nextAgents, skills: nextSkills });
return nextWorkspace;
},
switchWorkspace: async (workspaceId) => {
- console.log("[workspace-store] switching to", workspaceId);
+ logger.info("switching to", workspaceId);
const { workspaces, hydrateWorkspace } = get();
const ws = workspaces.find((item) => item.id === workspaceId);
if (!ws) return;
diff --git a/apps/web/shared/api.ts b/apps/web/shared/api.ts
index b8d6b3a3a0..e7a0a30a16 100644
--- a/apps/web/shared/api.ts
+++ b/apps/web/shared/api.ts
@@ -1,8 +1,9 @@
import { ApiClient } from "@multica/sdk";
+import { createLogger } from "./logger";
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:8080";
-export const api = new ApiClient(API_BASE_URL);
+export const api = new ApiClient(API_BASE_URL, { logger: createLogger("api") });
// Initialize token from localStorage on load
if (typeof window !== "undefined") {
diff --git a/packages/types/src/events.ts b/packages/types/src/events.ts
index e8e29a7586..51d1b8ad63 100644
--- a/packages/types/src/events.ts
+++ b/packages/types/src/events.ts
@@ -22,6 +22,8 @@ export type WSEventType =
| "inbox:new"
| "inbox:read"
| "inbox:archived"
+ | "inbox:batch-read"
+ | "inbox:batch-archived"
| "workspace:updated"
| "workspace:deleted"
| "member:added"
@@ -77,6 +79,16 @@ export interface InboxArchivedPayload {
recipient_id: string;
}
+export interface InboxBatchReadPayload {
+ recipient_id: string;
+ count: number;
+}
+
+export interface InboxBatchArchivedPayload {
+ recipient_id: string;
+ count: number;
+}
+
export interface CommentCreatedPayload {
comment: Comment;
}
diff --git a/server/cmd/server/inbox_listeners.go b/server/cmd/server/inbox_listeners.go
index 26767ec38a..56cab64017 100644
--- a/server/cmd/server/inbox_listeners.go
+++ b/server/cmd/server/inbox_listeners.go
@@ -2,7 +2,7 @@ package main
import (
"context"
- "log"
+ "log/slog"
"github.com/multica-ai/multica/server/internal/events"
"github.com/multica-ai/multica/server/internal/handler"
@@ -40,7 +40,7 @@ func registerInboxListeners(bus *events.Bus, queries *db.Queries) {
Body: util.PtrToText(issue.Description),
})
if err != nil {
- log.Printf("[inbox-listener] issue:created inbox error: %v", err)
+ slog.Error("inbox item creation failed", "event", "issue:created", "error", err)
return
}
@@ -203,7 +203,7 @@ func registerInboxListeners(bus *events.Bus, queries *db.Queries) {
Body: util.StrToText(comment.Content),
})
if err != nil {
- log.Printf("[inbox-listener] comment:created inbox error: %v", err)
+ slog.Error("inbox item creation failed", "event", "comment:created", "error", err)
return
}
diff --git a/server/cmd/server/listeners.go b/server/cmd/server/listeners.go
index 5df3049993..8008d7891a 100644
--- a/server/cmd/server/listeners.go
+++ b/server/cmd/server/listeners.go
@@ -2,7 +2,7 @@ package main
import (
"encoding/json"
- "log"
+ "log/slog"
"github.com/multica-ai/multica/server/internal/events"
"github.com/multica-ai/multica/server/internal/realtime"
@@ -44,7 +44,7 @@ func registerListeners(bus *events.Bus, hub *realtime.Hub) {
}
data, err := json.Marshal(msg)
if err != nil {
- log.Printf("[listeners] failed to marshal %s event: %v", eventType, err)
+ slog.Error("failed to marshal event", "event_type", eventType, "error", err)
return
}
if e.WorkspaceID != "" {
diff --git a/server/pkg/db/generated/inbox.sql.go b/server/pkg/db/generated/inbox.sql.go
index df8a574c98..2ad4dca1d0 100644
--- a/server/pkg/db/generated/inbox.sql.go
+++ b/server/pkg/db/generated/inbox.sql.go
@@ -11,6 +11,46 @@ import (
"github.com/jackc/pgx/v5/pgtype"
)
+const archiveAllInbox = `-- name: ArchiveAllInbox :execrows
+UPDATE inbox_item SET archived = true
+WHERE recipient_type = 'member' AND recipient_id = $1 AND archived = false
+`
+
+func (q *Queries) ArchiveAllInbox(ctx context.Context, recipientID pgtype.UUID) (int64, error) {
+ result, err := q.db.Exec(ctx, archiveAllInbox, recipientID)
+ if err != nil {
+ return 0, err
+ }
+ return result.RowsAffected(), nil
+}
+
+const archiveAllReadInbox = `-- name: ArchiveAllReadInbox :execrows
+UPDATE inbox_item SET archived = true
+WHERE recipient_type = 'member' AND recipient_id = $1 AND read = true AND archived = false
+`
+
+func (q *Queries) ArchiveAllReadInbox(ctx context.Context, recipientID pgtype.UUID) (int64, error) {
+ result, err := q.db.Exec(ctx, archiveAllReadInbox, recipientID)
+ if err != nil {
+ return 0, err
+ }
+ return result.RowsAffected(), nil
+}
+
+const archiveCompletedInbox = `-- name: ArchiveCompletedInbox :execrows
+UPDATE inbox_item SET archived = true
+WHERE recipient_type = 'member' AND recipient_id = $1 AND archived = false
+ AND issue_id IN (SELECT id FROM issue WHERE status IN ('done', 'cancelled'))
+`
+
+func (q *Queries) ArchiveCompletedInbox(ctx context.Context, recipientID pgtype.UUID) (int64, error) {
+ result, err := q.db.Exec(ctx, archiveCompletedInbox, recipientID)
+ if err != nil {
+ return 0, err
+ }
+ return result.RowsAffected(), nil
+}
+
const archiveInboxItem = `-- name: ArchiveInboxItem :one
UPDATE inbox_item SET archived = true
WHERE id = $1
@@ -179,6 +219,19 @@ func (q *Queries) ListInboxItems(ctx context.Context, arg ListInboxItemsParams)
return items, nil
}
+const markAllInboxRead = `-- name: MarkAllInboxRead :execrows
+UPDATE inbox_item SET read = true
+WHERE recipient_type = 'member' AND recipient_id = $1 AND archived = false AND read = false
+`
+
+func (q *Queries) MarkAllInboxRead(ctx context.Context, recipientID pgtype.UUID) (int64, error) {
+ result, err := q.db.Exec(ctx, markAllInboxRead, recipientID)
+ if err != nil {
+ return 0, err
+ }
+ return result.RowsAffected(), nil
+}
+
const markInboxRead = `-- name: MarkInboxRead :one
UPDATE inbox_item SET read = true
WHERE id = $1
diff --git a/server/pkg/db/queries/inbox.sql b/server/pkg/db/queries/inbox.sql
index c6d817b19e..d609897a3b 100644
--- a/server/pkg/db/queries/inbox.sql
+++ b/server/pkg/db/queries/inbox.sql
@@ -28,3 +28,20 @@ RETURNING *;
-- name: CountUnreadInbox :one
SELECT count(*) FROM inbox_item
WHERE recipient_type = $1 AND recipient_id = $2 AND read = false AND archived = false;
+
+-- name: MarkAllInboxRead :execrows
+UPDATE inbox_item SET read = true
+WHERE recipient_type = 'member' AND recipient_id = $1 AND archived = false AND read = false;
+
+-- name: ArchiveAllInbox :execrows
+UPDATE inbox_item SET archived = true
+WHERE recipient_type = 'member' AND recipient_id = $1 AND archived = false;
+
+-- name: ArchiveAllReadInbox :execrows
+UPDATE inbox_item SET archived = true
+WHERE recipient_type = 'member' AND recipient_id = $1 AND read = true AND archived = false;
+
+-- name: ArchiveCompletedInbox :execrows
+UPDATE inbox_item SET archived = true
+WHERE recipient_type = 'member' AND recipient_id = $1 AND archived = false
+ AND issue_id IN (SELECT id FROM issue WHERE status IN ('done', 'cancelled'));
diff --git a/server/pkg/protocol/events.go b/server/pkg/protocol/events.go
index 835d2e21ee..31e40188ed 100644
--- a/server/pkg/protocol/events.go
+++ b/server/pkg/protocol/events.go
@@ -24,9 +24,11 @@ const (
EventTaskFailed = "task:failed"
// Inbox events
- EventInboxNew = "inbox:new"
- EventInboxRead = "inbox:read"
- EventInboxArchived = "inbox:archived"
+ EventInboxNew = "inbox:new"
+ EventInboxRead = "inbox:read"
+ EventInboxArchived = "inbox:archived"
+ EventInboxBatchRead = "inbox:batch-read"
+ EventInboxBatchArchived = "inbox:batch-archived"
// Workspace events
EventWorkspaceUpdated = "workspace:updated"