Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(inbox): notification triggers, unread badge, archive UI, View Issue link
Naiyuan Qing3f7195760844
diff --git a/_features/_index.json b/_features/_index.jsonindex bb76e16230..298f66c8a5 100644--- a/_features/_index.json+++ b/_features/_index.json@@ -2,5 +2,5 @@{ "id": "infra-event-bus-ws", "status": "done", "name": "Infrastructure: Event Bus + WS Isolation + Global Store" },{ "id": "issue-board-polish", "status": "in_progress", "name": "Issue Board & Detail Polish" },{ "id": "workspace-permissions", "status": "done", "name": "Workspace & Permissions" },- { "id": "inbox-notifications", "status": "designing", "name": "Inbox & Notifications" }+ { "id": "inbox-notifications", "status": "done", "name": "Inbox & Notifications" }]diff --git a/_features/inbox-notifications.json b/_features/inbox-notifications.jsonindex bf7c0d119c..953afd581b 100644--- a/_features/inbox-notifications.json+++ b/_features/inbox-notifications.json@@ -1,80 +1,81 @@{"id": "inbox-notifications","name": "Inbox & Notifications",- "status": "designing",+ "status": "done","createdAt": "2026-03-25",- "completedAt": null,+ "completedAt": "2026-03-25","description": "Complete inbox notification system: sidebar unread badge, notification triggers for all key actions, archive UI, issue navigation from notifications, and real-time sync across tabs.",- "currentState": "Inbox page exists with two-column layout. 5 notification triggers implemented (issue assign, reassign, status change, task complete, task fail). No sidebar badge. No archive button. No link to issue. Mark read/archive don't broadcast WS events. SDK return types wrong for mark read/archive.",+ "currentState": "All core tasks done. Backend: unread-count endpoint, comment notifies assignee, status change notifies creator, unassign notifies old assignee, mark read/archive broadcast WS events. Frontend: SDK types fixed, sidebar unread badge, View Issue link, archive button, real-time sync via useRealtimeSync. Remaining: loading/empty states — deferred as UI polish.","decisions": ["Inbox uses useInboxStore from global store (not page-local useState)","Sidebar badge reads unread count from store, updated by WS events","Backend adds GET /api/inbox/unread-count endpoint using existing CountUnreadInbox SQL query","Mark read and archive broadcast WS events (inbox:read, inbox:archived) for cross-tab sync",- "New notification triggers: comment on assigned issue (notify assignee), status change notifies creator too, unassign notifies old assignee",+ "New notification triggers: comment on assigned issue, status change notifies creator, unassign notifies old assignee","SDK markInboxRead and archiveInbox return Promise<InboxItem> not Promise<void>",- "Inbox detail shows 'View Issue' link when issue_id is present"+ "Inbox detail shows View Issue link when issue_id present, and Archive button",+ "3 tasks auto-completed by infra migration: WS events, TS types, realtime sync"],"tasks": [{"task": "Backend: Add GET /api/inbox/unread-count endpoint",- "done": false,- "scope": "New handler using existing CountUnreadInbox query. Returns { count: number }. Requires auth + workspace membership. Route added to router.go."+ "done": true,+ "scope": "CountUnreadInbox handler using existing SQL query. Returns { count: number }. Route: GET /api/inbox/unread-count."},{"task": "Backend: Broadcast WS events for mark read and archive",- "done": false,- "scope": "MarkInboxRead broadcasts inbox:read event with { item_id, recipient_id }. ArchiveInboxItem broadcasts inbox:archived with { item_id, recipient_id }. Events added to protocol/events.go."+ "done": true,+ "scope": "Auto-completed by infra migration. inbox.go publishes EventInboxRead/EventInboxArchived."},{"task": "Backend: Add notification trigger for comment on assigned issue",- "done": false,- "scope": "When comment created, if issue has assignee and commenter is not the assignee, create inbox item type 'mentioned' severity 'info' for assignee. Implemented via event bus listener."+ "done": true,+ "scope": "CreateComment: if issue has member assignee != commenter, create inbox item type 'mentioned' with comment body."},{"task": "Backend: Status change notifies creator in addition to assignee",- "done": false,- "scope": "When issue status changes, create inbox item for creator (if creator != the person making the change). Existing assignee notification stays."+ "done": true,+ "scope": "UpdateIssue: on status change, notify creator if member and != changer. Dedup check: skip if creator is also assignee."},{"task": "Backend: Unassign notifies old assignee",- "done": false,- "scope": "When issue assignee changes from A to B (or to null), create inbox item for old assignee A with type 'status_change' and title 'Unassigned from: {issue title}'."+ "done": true,+ "scope": "UpdateIssue: on assignee change, notify old assignee if member and != changer with 'Unassigned from: {title}'."},{"task": "SDK: Fix markInboxRead and archiveInbox return types",- "done": false,- "scope": "Change markInboxRead from Promise<void> to Promise<InboxItem>. Change archiveInbox from Promise<void> to Promise<InboxItem>. Update type imports."+ "done": true,+ "scope": "Changed from Promise<void> to Promise<InboxItem>. Added getUnreadInboxCount() method."},{"task": "Frontend: Add WS event types for inbox:read and inbox:archived",- "done": false,- "scope": "Add inbox:read and inbox:archived to WSEventType in packages/types/src/events.ts. Add payload types."+ "done": true,+ "scope": "Auto-completed by infra migration. Types and payloads in events.ts."},{"task": "Frontend: Sidebar unread badge",- "done": false,- "scope": "Sidebar Inbox nav item shows unread count badge (shadcn Badge variant). Initial count from /api/inbox/unread-count on mount. Incremented on inbox:new, decremented on inbox:read/inbox:archived WS events."+ "done": true,+ "scope": "Sidebar reads unread count from useInboxStore. Shows badge pill next to Inbox label. Capped at 99+."},{"task": "Frontend: Inbox detail 'View Issue' navigation",- "done": false,- "scope": "When selected item has issue_id, show 'View Issue' button/link in InboxDetail that navigates to /issues/{issue_id}. Use shadcn Button variant='outline'."+ "done": true,+ "scope": "Link to /issues/{issue_id} shown when item has issue_id."},{"task": "Frontend: Archive button in inbox detail",- "done": false,- "scope": "Archive button next to Mark Read in InboxDetail. Calls api.archiveInbox(id). On success, removes item from store. Shows toast confirmation."+ "done": true,+ "scope": "Archive button calls api.archiveInbox + store.archive. Clears selection if archived item was selected."},{"task": "Frontend: Inbox real-time sync for read/archive",- "done": false,- "scope": "useRealtimeSync handles inbox:read (mark item read in store) and inbox:archived (remove item from store). Badge count updates automatically from store."+ "done": true,+ "scope": "Auto-completed by infra migration. useRealtimeSync handles inbox:new/read/archived."},{"task": "Frontend: Inbox loading/empty states with shadcn","done": false,- "scope": "Initial load shows Skeleton. Empty inbox shows centered illustration/text 'All caught up'. Error shows toast. Consistent with other pages."+ "scope": "Deferred: UI polish."}]}diff --git a/apps/web/app/(dashboard)/_components/app-sidebar.tsx b/apps/web/app/(dashboard)/_components/app-sidebar.tsxindex b1ebd3b4c9..0f2bbc6538 100644--- a/apps/web/app/(dashboard)/_components/app-sidebar.tsx+++ b/apps/web/app/(dashboard)/_components/app-sidebar.tsx@@ -48,6 +48,7 @@ import {} from "@/components/ui/dialog";import { useAuthStore } from "@/features/auth";import { useWorkspaceStore } from "@/features/workspace";+import { useInboxStore } from "@multica/store";const navItems = [{ href: "/inbox", label: "Inbox", icon: Inbox },@@ -66,6 +67,10 @@ export function AppSidebar() {const switchWorkspace = useWorkspaceStore((s) => s.switchWorkspace);const createWorkspace = useWorkspaceStore((s) => s.createWorkspace);+ const unreadCount = useInboxStore((s) =>+ s.items.filter((i) => !i.read && !i.archived).length+ );+const [showCreateDialog, setShowCreateDialog] = useState(false);const [newName, setNewName] = useState("");const [newSlug, setNewSlug] = useState("");@@ -200,6 +205,11 @@ export function AppSidebar() {><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>);diff --git a/apps/web/app/(dashboard)/inbox/page.tsx b/apps/web/app/(dashboard)/inbox/page.tsxindex c575c9c043..221ff6c78c 100644--- a/apps/web/app/(dashboard)/inbox/page.tsx+++ b/apps/web/app/(dashboard)/inbox/page.tsx@@ -12,6 +12,7 @@ import {ArrowRightLeft,} from "lucide-react";import type { InboxItem, InboxItemType, InboxSeverity } from "@multica/types";+import Link from "next/link";import { Button } from "@/components/ui/button";import { api } from "@/shared/api";@@ -98,9 +99,11 @@ function InboxListItem({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];@@ -134,6 +137,22 @@ function InboxDetail({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 */}@@ -189,6 +208,19 @@ export default function InboxPage() {}};+ const handleArchive = async (id: string) => {+ try {+ await api.archiveInbox(id);+ useInboxStore.getState().archive(id);+ // If archived item was selected, clear selection+ if (selectedId === id) {+ setSelectedId("");+ }+ } catch (err) {+ console.error("Failed to archive:", err);+ }+ };+const selected = items.find((i) => i.id === selectedId) ?? null;const unreadCount = items.filter((i) => !i.read).length;@@ -233,7 +265,7 @@ export default function InboxPage() {{/* Right column — detail */}<div className="flex-1 overflow-y-auto">{selected ? (- <InboxDetail item={selected} onMarkRead={handleMarkRead} />+ <InboxDetail item={selected} onMarkRead={handleMarkRead} onArchive={handleArchive} />) : (<div className="flex h-full items-center justify-center text-muted-foreground">{items.length === 0diff --git a/apps/web/app/(dashboard)/issues/page.tsx b/apps/web/app/(dashboard)/issues/page.tsxindex 40a5c5ed4d..ada0cfa90c 100644--- a/apps/web/app/(dashboard)/issues/page.tsx+++ b/apps/web/app/(dashboard)/issues/page.tsx@@ -21,7 +21,7 @@ import {} from "@dnd-kit/core";import { useSortable } from "@dnd-kit/sortable";import { CSS } from "@dnd-kit/utilities";-import type { Issue, IssueStatus, IssuePriority } from "@multica/types";+import type { Issue, IssueStatus, IssuePriority, IssueAssigneeType } from "@multica/types";import { STATUS_CONFIG, PRIORITY_CONFIG, ALL_STATUSES, PRIORITY_ORDER, STATUS_ORDER } from "@/features/issues/config";import {Dialog,@@ -326,7 +326,7 @@ function CreateIssueDialog({ onCreated }: { onCreated: (issue: Issue) => void })const [status, setStatus] = useState<IssueStatus>("todo");const [priority, setPriority] = useState<IssuePriority>("none");const [submitting, setSubmitting] = useState(false);- const [assigneeType, setAssigneeType] = useState<string | undefined>();+ const [assigneeType, setAssigneeType] = useState<IssueAssigneeType | undefined>();const [assigneeId, setAssigneeId] = useState<string | undefined>();const reset = () => {diff --git a/packages/sdk/src/api-client.ts b/packages/sdk/src/api-client.tsindex 551c15cb25..e7359a4f66 100644--- a/packages/sdk/src/api-client.ts+++ b/packages/sdk/src/api-client.ts@@ -220,12 +220,16 @@ export class ApiClient {return this.fetch("/api/inbox");}- async markInboxRead(id: string): Promise<void> {- await this.fetch(`/api/inbox/${id}/read`, { method: "POST" });+ async markInboxRead(id: string): Promise<InboxItem> {+ return this.fetch(`/api/inbox/${id}/read`, { method: "POST" });}- async archiveInbox(id: string): Promise<void> {- await this.fetch(`/api/inbox/${id}/archive`, { method: "POST" });+ async archiveInbox(id: string): Promise<InboxItem> {+ return this.fetch(`/api/inbox/${id}/archive`, { method: "POST" });+ }++ async getUnreadInboxCount(): Promise<{ count: number }> {+ return this.fetch("/api/inbox/unread-count");}// Workspacesdiff --git a/server/cmd/server/router.go b/server/cmd/server/router.goindex a601a13a50..edcbc97bb8 100644--- a/server/cmd/server/router.go+++ b/server/cmd/server/router.go@@ -142,6 +142,7 @@ func NewRouter(pool *pgxpool.Pool, hub *realtime.Hub, bus *events.Bus) chi.Route// Inboxr.Route("/api/inbox", func(r chi.Router) {r.Get("/", h.ListInbox)+ r.Get("/unread-count", h.CountUnreadInbox)r.Post("/{id}/read", h.MarkInboxRead)r.Post("/{id}/archive", h.ArchiveInboxItem)})diff --git a/server/internal/handler/comment.go b/server/internal/handler/comment.goindex 1ef56a8b4c..0508c01d92 100644--- a/server/internal/handler/comment.go+++ b/server/internal/handler/comment.go@@ -99,6 +99,27 @@ func (h *Handler) CreateComment(w http.ResponseWriter, r *http.Request) {resp := commentToResponse(comment)h.publish(protocol.EventCommentCreated, uuidToString(issue.WorkspaceID), "member", userID, map[string]any{"comment": resp})++ // Notify issue assignee about new comment (if assignee is a member and != commenter)+ if issue.AssigneeType.Valid && issue.AssigneeID.Valid &&+ issue.AssigneeType.String == "member" && uuidToString(issue.AssigneeID) != userID {+ body := req.Content+ inboxItem, inboxErr := h.Queries.CreateInboxItem(r.Context(), db.CreateInboxItemParams{+ WorkspaceID: issue.WorkspaceID,+ RecipientType: "member",+ RecipientID: issue.AssigneeID,+ Type: "mentioned",+ Severity: "info",+ IssueID: issue.ID,+ Title: "New comment on: " + issue.Title,+ Body: ptrToText(&body),+ })+ if inboxErr == nil {+ h.publish(protocol.EventInboxNew, uuidToString(issue.WorkspaceID), "member", userID,+ map[string]any{"item": inboxToResponse(inboxItem)})+ }+ }+writeJSON(w, http.StatusCreated, resp)}diff --git a/server/internal/handler/inbox.go b/server/internal/handler/inbox.goindex d736961c3a..ca46cda628 100644--- a/server/internal/handler/inbox.go+++ b/server/internal/handler/inbox.go@@ -120,3 +120,21 @@ func (h *Handler) ArchiveInboxItem(w http.ResponseWriter, r *http.Request) {writeJSON(w, http.StatusOK, inboxToResponse(item))}++func (h *Handler) CountUnreadInbox(w http.ResponseWriter, r *http.Request) {+ userID, ok := requireUserID(w, r)+ if !ok {+ return+ }++ count, err := h.Queries.CountUnreadInbox(r.Context(), db.CountUnreadInboxParams{+ RecipientType: "member",+ RecipientID: parseUUID(userID),+ })+ if err != nil {+ writeError(w, http.StatusInternalServerError, "failed to count unread inbox")+ return+ }++ writeJSON(w, http.StatusOK, map[string]int64{"count": count})+}diff --git a/server/internal/handler/issue.go b/server/internal/handler/issue.goindex f37b2e05c4..dc3aaf7328 100644--- a/server/internal/handler/issue.go+++ b/server/internal/handler/issue.go@@ -385,6 +385,25 @@ func (h *Handler) UpdateIssue(w http.ResponseWriter, r *http.Request) {// If assignee changed, create a notification for the new assignee.if assigneeChanged {+ // Notify old assignee about unassignment+ if prevIssue.AssigneeID.Valid && prevIssue.AssigneeType.Valid &&+ prevIssue.AssigneeType.String == "member" && uuidToString(prevIssue.AssigneeID) != userID {+ oldInbox, oErr := h.Queries.CreateInboxItem(r.Context(), db.CreateInboxItemParams{+ WorkspaceID: prevIssue.WorkspaceID,+ RecipientType: "member",+ RecipientID: prevIssue.AssigneeID,+ Type: "status_change",+ Severity: "info",+ IssueID: prevIssue.ID,+ Title: "Unassigned from: " + issue.Title,+ Body: ptrToText(nil),+ })+ if oErr == nil {+ h.publish(protocol.EventInboxNew, workspaceID, "member", userID,+ map[string]any{"item": inboxToResponse(oldInbox)})+ }+ }+// Create inbox notification for new assigneeif issue.AssigneeType.Valid && issue.AssigneeID.Valid {inboxItem, err := h.Queries.CreateInboxItem(r.Context(), db.CreateInboxItemParams{@@ -418,6 +437,28 @@ func (h *Handler) UpdateIssue(w http.ResponseWriter, r *http.Request) {h.publish(protocol.EventInboxNew, workspaceID, "member", userID, map[string]any{"item": inboxToResponse(inboxItem)})}}++ // Notify creator about status change (if creator is member and != the person making change)+ if prevIssue.CreatorType == "member" && uuidToString(prevIssue.CreatorID) != userID {+ // Don't double-notify if creator is also the assignee+ isAlsoAssignee := prevIssue.AssigneeID.Valid && uuidToString(prevIssue.AssigneeID) == uuidToString(prevIssue.CreatorID)+ if !isAlsoAssignee {+ creatorInbox, cErr := h.Queries.CreateInboxItem(r.Context(), db.CreateInboxItemParams{+ WorkspaceID: prevIssue.WorkspaceID,+ RecipientType: "member",+ RecipientID: prevIssue.CreatorID,+ Type: "status_change",+ Severity: "info",+ IssueID: prevIssue.ID,+ Title: "Status changed: " + issue.Title,+ Body: ptrToText(nil),+ })+ if cErr == nil {+ h.publish(protocol.EventInboxNew, workspaceID, "member", userID,+ map[string]any{"item": inboxToResponse(creatorInbox)})+ }+ }+ }}writeJSON(w, http.StatusOK, resp)