Skip to content

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

Go

feat(subscribers): interactive subscriber management with AvatarGroup + Command popover

Naiyuan Qing05c0471945dd
diff --git a/apps/web/app/(dashboard)/inbox/page.tsx b/apps/web/app/(dashboard)/inbox/page.tsx
index 7f020eb26d..809303c3ce 100644
--- a/apps/web/app/(dashboard)/inbox/page.tsx
+++ b/apps/web/app/(dashboard)/inbox/page.tsx
@@ -54,7 +54,6 @@ const typeLabels: Record<InboxItemType, string> = {
task_failed: "Task failed",
agent_blocked: "Agent blocked",
agent_completed: "Agent completed",
- status_change: "Status changed",
};
function timeAgo(dateStr: string): string {
diff --git a/apps/web/features/issues/components/issue-detail.tsx b/apps/web/features/issues/components/issue-detail.tsx
index 63963fa307..9c3832fa28 100644
--- a/apps/web/features/issues/components/issue-detail.tsx
+++ b/apps/web/features/issues/components/issue-detail.tsx
@@ -56,6 +56,8 @@ import {
} from "@/components/ui/tooltip";
import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover";
import { Checkbox } from "@/components/ui/checkbox";
+import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from "@/components/ui/command";
+import { Avatar, AvatarFallback, AvatarGroup, AvatarGroupCount } from "@/components/ui/avatar";
import { ActorAvatar } from "@/components/common/actor-avatar";
import type { Issue, Comment, IssueSubscriber, UpdateIssueRequest, IssueStatus, IssuePriority } from "@/shared/types";
import { ALL_STATUSES, STATUS_CONFIG, PRIORITY_ORDER, PRIORITY_CONFIG } from "@/features/issues/config";
@@ -269,24 +271,28 @@ export function IssueDetail({ issueId, onDelete }: IssueDetailProps) {
(s) => s.user_type === "member" && s.user_id === user?.id
);
- const handleToggleSubscribe = async () => {
- if (!user || !issue) return;
+ const toggleSubscriber = async (userId: string, currentlySubscribed: boolean) => {
+ if (!issue) return;
try {
- if (isSubscribed) {
- await api.unsubscribeFromIssue(id);
- setSubscribers((prev) => prev.filter((s) => s.user_id !== user.id));
+ if (currentlySubscribed) {
+ await api.unsubscribeFromIssue(id, userId);
+ setSubscribers((prev) => prev.filter((s) => s.user_id !== userId));
} else {
- await api.subscribeToIssue(id);
+ await api.subscribeToIssue(id, userId);
setSubscribers((prev) => [
...prev,
- { issue_id: id, user_type: "member" as const, user_id: user.id, reason: "manual" as const, created_at: new Date().toISOString() },
+ { issue_id: id, user_type: "member" as const, user_id: userId, reason: "manual" as const, created_at: new Date().toISOString() },
]);
}
} catch {
- toast.error("Failed to update subscription");
+ toast.error("Failed to update subscriber");
}
};
+ const handleToggleSubscribe = () => {
+ if (user) toggleSubscriber(user.id, isSubscribed);
+ };
+
// Real-time comment updates
useWSEvent(
"comment:created",
@@ -676,55 +682,51 @@ export function IssueDetail({ issueId, onDelete }: IssueDetailProps) {
{isSubscribed ? "Unsubscribe" : "Subscribe"}
</button>
<Popover>
- <PopoverTrigger className="flex items-center -space-x-1.5 hover:opacity-80 transition-opacity cursor-pointer">
- {subscribers.slice(0, 5).map((sub) => (
- <ActorAvatar
- key={sub.user_id}
- actorType={sub.user_type}
- actorId={sub.user_id}
- size={24}
- className="ring-2 ring-background"
- />
- ))}
- {subscribers.length > 5 && (
- <span className="flex items-center justify-center h-6 w-6 rounded-full bg-muted text-[10px] font-medium ring-2 ring-background">
- +{subscribers.length - 5}
- </span>
- )}
- {subscribers.length === 0 && (
- <span className="flex items-center justify-center h-6 w-6 rounded-full border border-dashed border-muted-foreground/30 text-muted-foreground">
- <Users className="h-3 w-3" />
- </span>
- )}
+ <PopoverTrigger className="cursor-pointer hover:opacity-80 transition-opacity">
+ {subscribers.length > 0 ? (
+ <AvatarGroup>
+ {subscribers.slice(0, 4).map((sub) => (
+ <Avatar key={sub.user_id} size="sm">
+ <AvatarFallback>{getActorInitials(sub.user_type, sub.user_id)}</AvatarFallback>
+ </Avatar>
+ ))}
+ {subscribers.length > 4 && (
+ <AvatarGroupCount>+{subscribers.length - 4}</AvatarGroupCount>
+ )}
+ </AvatarGroup>
+ ) : (
+ <span className="flex items-center justify-center h-6 w-6 rounded-full border border-dashed border-muted-foreground/30 text-muted-foreground">
+ <Users className="h-3 w-3" />
+ </span>
+ )}
</PopoverTrigger>
<PopoverContent align="end" className="w-64 p-0">
- <div className="px-3 py-2 border-b">
- <p className="text-sm text-muted-foreground">Subscribers</p>
- </div>
- <div className="max-h-64 overflow-y-auto py-1">
- {subscribers.map((sub) => {
- const subName = getActorName(sub.user_type, sub.user_id);
- return (
- <div key={sub.user_id} className="flex items-center gap-2.5 px-3 py-1.5">
- <Checkbox checked disabled className="h-3.5 w-3.5" />
- <ActorAvatar actorType={sub.user_type} actorId={sub.user_id} size={22} />
- <span className="text-sm truncate flex-1">{subName}</span>
- {sub.reason !== "manual" && (
- <span className="text-[11px] text-muted-foreground capitalize">{sub.reason}</span>
- )}
- </div>
- );
- })}
- {members
- .filter((m) => !subscribers.some((s) => s.user_id === m.user_id))
- .map((m) => (
- <div key={m.user_id} className="flex items-center gap-2.5 px-3 py-1.5 opacity-50">
- <Checkbox checked={false} disabled className="h-3.5 w-3.5" />
- <ActorAvatar actorType="member" actorId={m.user_id} size={22} />
- <span className="text-sm truncate flex-1">{m.name}</span>
- </div>
- ))}
- </div>
+ <Command>
+ <CommandInput placeholder="Change subscribers..." />
+ <CommandList>
+ <CommandEmpty>No members found</CommandEmpty>
+ <CommandGroup>
+ {members.map((m) => {
+ const sub = subscribers.find((s) => s.user_id === m.user_id);
+ const isSubbed = !!sub;
+ return (
+ <CommandItem
+ key={m.user_id}
+ onSelect={() => toggleSubscriber(m.user_id, isSubbed)}
+ className="flex items-center gap-2.5"
+ >
+ <Checkbox checked={isSubbed} className="pointer-events-none" />
+ <ActorAvatar actorType="member" actorId={m.user_id} size={22} />
+ <span className="truncate flex-1">{m.name}</span>
+ {sub?.reason && sub.reason !== "manual" && (
+ <span className="text-xs text-muted-foreground capitalize">{sub.reason}</span>
+ )}
+ </CommandItem>
+ );
+ })}
+ </CommandGroup>
+ </CommandList>
+ </Command>
</PopoverContent>
</Popover>
</div>
diff --git a/apps/web/shared/api/client.ts b/apps/web/shared/api/client.ts
index 8420177a1b..61332e5e72 100644
--- a/apps/web/shared/api/client.ts
+++ b/apps/web/shared/api/client.ts
@@ -206,12 +206,18 @@ export class ApiClient {
return this.fetch(`/api/issues/${issueId}/subscribers`);
}
- async subscribeToIssue(issueId: string): Promise<void> {
- await this.fetch(`/api/issues/${issueId}/subscribe`, { method: "POST" });
+ async subscribeToIssue(issueId: string, userId?: string): Promise<void> {
+ await this.fetch(`/api/issues/${issueId}/subscribe`, {
+ method: "POST",
+ body: JSON.stringify(userId ? { user_id: userId } : {}),
+ });
}
- async unsubscribeFromIssue(issueId: string): Promise<void> {
- await this.fetch(`/api/issues/${issueId}/unsubscribe`, { method: "POST" });
+ async unsubscribeFromIssue(issueId: string, userId?: string): Promise<void> {
+ await this.fetch(`/api/issues/${issueId}/unsubscribe`, {
+ method: "POST",
+ body: JSON.stringify(userId ? { user_id: userId } : {}),
+ });
}
// Agents
diff --git a/apps/web/shared/types/inbox.ts b/apps/web/shared/types/inbox.ts
index 1eac356850..4f5b08640c 100644
--- a/apps/web/shared/types/inbox.ts
+++ b/apps/web/shared/types/inbox.ts
@@ -14,8 +14,7 @@ export type InboxItemType =
| "task_completed"
| "task_failed"
| "agent_blocked"
- | "agent_completed"
- | "status_change";
+ | "agent_completed";
export interface InboxItem {
id: string;
diff --git a/server/internal/handler/subscriber.go b/server/internal/handler/subscriber.go
index 78f4e18bb7..5637386132 100644
--- a/server/internal/handler/subscriber.go
+++ b/server/internal/handler/subscriber.go
@@ -1,6 +1,7 @@
package handler
import (
+ "encoding/json"
"net/http"
"github.com/go-chi/chi/v5"
@@ -49,7 +50,8 @@ func (h *Handler) ListIssueSubscribers(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, resp)
}
-// SubscribeToIssue subscribes the current user to an issue with reason "manual".
+// SubscribeToIssue subscribes a user to an issue with reason "manual".
+// If request body contains user_id, subscribes that user; otherwise subscribes the caller.
func (h *Handler) SubscribeToIssue(w http.ResponseWriter, r *http.Request) {
issueID := chi.URLParam(r, "id")
issue, ok := h.loadIssueForUser(w, r, issueID)
@@ -57,12 +59,22 @@ func (h *Handler) SubscribeToIssue(w http.ResponseWriter, r *http.Request) {
return
}
- userID := requestUserID(r)
+ // Default to current user; allow specifying another user
+ targetUserID := requestUserID(r)
+ var req struct {
+ UserID *string `json:"user_id"`
+ }
+ if r.Body != nil {
+ json.NewDecoder(r.Body).Decode(&req)
+ }
+ if req.UserID != nil && *req.UserID != "" {
+ targetUserID = *req.UserID
+ }
err := h.Queries.AddIssueSubscriber(r.Context(), db.AddIssueSubscriberParams{
IssueID: issue.ID,
UserType: "member",
- UserID: parseUUID(userID),
+ UserID: parseUUID(targetUserID),
Reason: "manual",
})
if err != nil {
@@ -71,16 +83,19 @@ func (h *Handler) SubscribeToIssue(w http.ResponseWriter, r *http.Request) {
}
workspaceID := uuidToString(issue.WorkspaceID)
- h.publish(protocol.EventSubscriberAdded, workspaceID, "member", userID, map[string]any{
- "issue_id": issueID,
- "user_id": userID,
- "reason": "manual",
+ callerID := requestUserID(r)
+ h.publish(protocol.EventSubscriberAdded, workspaceID, "member", callerID, map[string]any{
+ "issue_id": issueID,
+ "user_type": "member",
+ "user_id": targetUserID,
+ "reason": "manual",
})
writeJSON(w, http.StatusOK, map[string]bool{"subscribed": true})
}
-// UnsubscribeFromIssue removes the current user's subscription from an issue.
+// UnsubscribeFromIssue removes a user's subscription from an issue.
+// If request body contains user_id, unsubscribes that user; otherwise unsubscribes the caller.
func (h *Handler) UnsubscribeFromIssue(w http.ResponseWriter, r *http.Request) {
issueID := chi.URLParam(r, "id")
issue, ok := h.loadIssueForUser(w, r, issueID)
@@ -88,12 +103,21 @@ func (h *Handler) UnsubscribeFromIssue(w http.ResponseWriter, r *http.Request) {
return
}
- userID := requestUserID(r)
+ targetUserID := requestUserID(r)
+ var req struct {
+ UserID *string `json:"user_id"`
+ }
+ if r.Body != nil {
+ json.NewDecoder(r.Body).Decode(&req)
+ }
+ if req.UserID != nil && *req.UserID != "" {
+ targetUserID = *req.UserID
+ }
err := h.Queries.RemoveIssueSubscriber(r.Context(), db.RemoveIssueSubscriberParams{
IssueID: issue.ID,
UserType: "member",
- UserID: parseUUID(userID),
+ UserID: parseUUID(targetUserID),
})
if err != nil {
writeError(w, http.StatusInternalServerError, "failed to unsubscribe")
@@ -101,9 +125,11 @@ func (h *Handler) UnsubscribeFromIssue(w http.ResponseWriter, r *http.Request) {
}
workspaceID := uuidToString(issue.WorkspaceID)
- h.publish(protocol.EventSubscriberRemoved, workspaceID, "member", userID, map[string]any{
- "issue_id": issueID,
- "user_id": userID,
+ callerID := requestUserID(r)
+ h.publish(protocol.EventSubscriberRemoved, workspaceID, "member", callerID, map[string]any{
+ "issue_id": issueID,
+ "user_type": "member",
+ "user_id": targetUserID,
})
writeJSON(w, http.StatusOK, map[string]bool{"subscribed": false})