Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat: improve ui

Gus92d81034b379
diff --git a/src/web/src/app/(app)/w/[slug]/issues/page.tsx b/src/web/src/app/(app)/w/[slug]/issues/page.tsx
index 66b5e8593..8324536c6 100644
--- a/src/web/src/app/(app)/w/[slug]/issues/page.tsx
+++ b/src/web/src/app/(app)/w/[slug]/issues/page.tsx
@@ -2,42 +2,23 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useLocalStorage } from "@/hooks/use-local-storage";
-import { Check, CircleDot, Eye, EyeOff, File as FileIcon, GitBranch, Loader2, MessageSquare, Plus, Trash2, X } from "lucide-react";
-import Link from "next/link";
+import { CircleDot, Eye, EyeOff, Loader2, Plus, Trash2 } from "lucide-react";
import type { Agent, Artifact, Issue, IssueComment, Message, WsMessage } from "@alook/shared";
-import { isTerminalIssueStatus } from "@alook/shared";
import { useWorkspace } from "@/contexts/workspace-context";
import { useAgentContext } from "@/contexts/agent-context";
import { createIssue, deleteIssue, getIssue, getTask, getTaskMessages, listIssues, updateIssue } from "@/lib/api";
import type { TaskApi, TaskMessage } from "@alook/shared";
import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
import { Badge } from "@/components/ui/badge";
import { Skeleton } from "@/components/ui/skeleton";
-import {
- Dialog,
- DialogContent,
- DialogTitle,
- DialogTrigger,
-} from "@/components/ui/dialog";
-import { MarkdownEditor } from "@/components/ui/markdown-editor";
-import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover";
-import { Sheet, SheetContent, SheetHeader, SheetTitle } from "@/components/ui/sheet";
-import { Select, SelectTrigger, SelectValue, SelectPopup, SelectItem } from "@/components/ui/select";
import { AvatarRenderer, parseAvatarUrl } from "@/components/avatar";
import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "@/components/ui/context-menu";
-import { Textarea } from "@/components/ui/textarea";
+import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { cn } from "@/lib/utils";
import { toast } from "sonner";
-import { Streamdown } from "streamdown";
import { DndContext, DragOverlay, PointerSensor, useSensor, useSensors, useDroppable, useDraggable, type DragEndEvent, type DragStartEvent } from "@dnd-kit/core";
+import { IssueSheet } from "@/components/issues/issue-sheet";
-// TODO: re-enable when Codex CLI fixes image_url serialization bug
-// const MAX_ATTACHMENT_SIZE = 10 * 1024 * 1024;
-// const MAX_ATTACHMENTS = 10;
-
-const SIDECAR_MIN_WIDTH = 320;
-const SIDECAR_MAX_WIDTH_RATIO = 0.8;
const SIDECAR_DEFAULT_WIDTH = 448;
const COLUMNS = [
@@ -46,24 +27,12 @@ const COLUMNS = [
{ id: "review", label: "Review", statuses: ["review"] },
{ id: "completed", label: "Completed", statuses: ["done", "closed", "canceled", "failed"] },
] as const;
-const SELECTOR_STATUSES = ["todo", "in_progress", "review", "done"] as const;
-
-function statusLabel(status: string) {
- if (status === "done") return "Complete";
- return status.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
-}
function formatDate(value: string | null) {
if (!value) return "";
return new Date(value).toLocaleString(undefined, { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" });
}
-function formatFileSize(bytes: number): string {
- if (bytes < 1024) return `${bytes} B`;
- if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
- return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
-}
-
function AgentAvatar({ agent, size = 24 }: { agent?: Agent | null; size?: number }) {
const avatarConfig = parseAvatarUrl(agent?.avatar_url);
if (avatarConfig) {
@@ -79,21 +48,6 @@ function AgentAvatar({ agent, size = 24 }: { agent?: Agent | null; size?: number
);
}
-function AgentIdentity({ agent, muted = false, size = 24 }: { agent: Agent; muted?: boolean; size?: number }) {
- const email = agent.email_handle ? `${agent.email_handle}@alook.ai` : "";
- return (
- <div className="flex min-w-0 items-center gap-2">
- <AgentAvatar agent={agent} size={size} />
- <div className="flex min-w-0 flex-1 items-center gap-1.5">
- <div className={cn("truncate text-sm font-medium", muted && "text-muted-foreground")}>{agent.name}</div>
- {email ? (
- <div className="truncate text-xs text-muted-foreground">{email}</div>
- ) : null}
- </div>
- </div>
- );
-}
-
function IssueCard({
issue,
selected,
@@ -214,137 +168,29 @@ function DraggableIssueCard({
);
}
-function MessageRow({ message }: { message: Message }) {
- if (message.role === "event") {
- return (
- <div className="rounded-md border bg-muted/50 text-muted-foreground text-xs px-3 py-2">
- {message.content}
- </div>
- );
- }
- return (
- <div className="rounded-lg border border-border/60 bg-background/55 p-3">
- <div className="mb-1 flex items-center justify-between gap-2 text-xs text-muted-foreground">
- <span className="capitalize">{message.role}</span>
- <span>{new Date(message.created_at).toLocaleString()}</span>
- </div>
- <div className="prose prose-sm dark:prose-invert max-w-none text-sm break-words">
- <Streamdown>{message.content}</Streamdown>
- </div>
- </div>
- );
-}
-
-function CommentRow({ comment, agents }: { comment: IssueComment; agents: Agent[] }) {
- const authorLabel = comment.author_type === "agent"
- ? agents.find((a) => a.id === comment.author_id)?.name ?? "Agent"
- : "You";
-
- return (
- <div className="rounded-lg border border-border/60 bg-background p-3">
- <div className="mb-1 flex items-center justify-between gap-2 text-xs text-muted-foreground">
- <span className="font-medium">{authorLabel}</span>
- <span>{new Date(comment.created_at).toLocaleString()}</span>
- </div>
- <div className="prose prose-sm dark:prose-invert max-w-none text-sm break-words">
- <Streamdown>{comment.content}</Streamdown>
- </div>
- </div>
- );
-}
-
-function CommentInput({ issueId, workspaceId, onCommented }: { issueId: string; workspaceId: string; onCommented: () => void }) {
- const [content, setContent] = useState("");
- const [submitting, setSubmitting] = useState(false);
-
- const submit = async () => {
- if (!content.trim() || submitting) return;
- setSubmitting(true);
- try {
- await fetch(`/api/issues/${issueId}/comments?workspace_id=${workspaceId}`, {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ content: content.trim() }),
- });
- setContent("");
- onCommented();
- } finally {
- setSubmitting(false);
- }
- };
-
- return (
- <div className="pt-3 space-y-2">
- <Textarea
- placeholder="Leave a comment..."
- value={content}
- onChange={(e) => setContent(e.target.value)}
- className="min-h-[60px] text-sm"
- onKeyDown={(e) => { if (e.key === "Enter" && e.metaKey) submit(); }}
- />
- <div className="flex justify-end">
- <Button size="sm" onClick={submit} disabled={!content.trim() || submitting}>
- {submitting ? "Sending..." : "Comment"}
- </Button>
- </div>
- </div>
- );
-}
-
-function AttachmentList({ artifacts, workspaceId }: { artifacts: Artifact[]; workspaceId: string }) {
- if (artifacts.length === 0) return null;
-
- return (
- <div className="space-y-1">
- {artifacts.map((artifact) => (
- <a
- key={artifact.id}
- href={`/api/artifacts/${artifact.id}/content?workspace_id=${workspaceId}&download=1`}
- target="_blank"
- rel="noopener noreferrer"
- className="flex items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-accent"
- >
- <FileIcon className="size-3.5 shrink-0 text-muted-foreground" />
- <span className="min-w-0 flex-1 truncate">{artifact.filename}</span>
- <span className="shrink-0 text-xs text-muted-foreground">{formatFileSize(artifact.size)}</span>
- </a>
- ))}
- </div>
- );
-}
-
export default function IssuesPage() {
const { workspaceId, slug } = useWorkspace();
const { agents, loading: agentsLoading, subscribeWs } = useAgentContext();
const [recentAgentId, setRecentAgentId] = useLocalStorage<string>(`issue-recent-agent-id-${workspaceId}`, "");
- const [draft, setDraft] = useLocalStorage<{ title: string; description: string; agentId?: string }>(`issue-draft-${workspaceId}`, { title: "", description: "" });
+ const [draft, setDraft] = useLocalStorage<{ title: string; description: string; agentId: string }>(`issue-draft-${workspaceId}`, { title: "", description: "", agentId: "" });
const [showCompleted, setShowCompleted] = useLocalStorage<boolean>("issues-show-completed", true);
const [issues, setIssues] = useState<Issue[]>([]);
const [loading, setLoading] = useState(true);
const [creating, setCreating] = useState(false);
- const [dialogOpen, setDialogOpen] = useState(false);
- const [assigneeOpen, setAssigneeOpen] = useState(false);
+ const [saving, setSaving] = useState(false);
+ const [deleting, setDeleting] = useState(false);
+ const [sheetOpen, setSheetOpen] = useState(false);
const [selectedId, setSelectedId] = useState<string | null>(null);
const [detail, setDetail] = useState<{ issue: Issue & { trace_id?: string | null }; messages: Message[]; comments: IssueComment[]; artifacts: Artifact[] } | null>(null);
const [detailLoading, setDetailLoading] = useState(false);
const [activeTask, setActiveTask] = useState<TaskApi | null>(null);
const [taskLatestText, setTaskLatestText] = useState<string>("");
- const [form, setForm] = useState({ title: "", description: "", agentId: "" });
const [sidecarWidth, setSidecarWidth] = useState(SIDECAR_DEFAULT_WIDTH);
const [activeDragId, setActiveDragId] = useState<string | null>(null);
- const sidecarDragging = useRef(false);
- const timelineRef = useRef<HTMLDivElement>(null);
const pendingStatusUpdate = useRef<string | null>(null);
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 8 } }));
-
const agentsById = useMemo(() => new Map(agents.map(a => [a.id, a])), [agents]);
- const selectedFormAgent = agentsById.get(form.agentId) ?? null;
-
- function agentName(agentId: string | null) {
- if (!agentId) return "Unassigned";
- return agentsById.get(agentId)?.name ?? agentId;
- }
async function reload() {
setLoading(true);
@@ -366,29 +212,9 @@ export default function IssuesPage() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [workspaceId]);
- const formHydrated = useRef(false);
-
- useEffect(() => {
- if (formHydrated.current) return;
- if (draft.agentId !== undefined) {
- formHydrated.current = true;
- setForm({ title: draft.title, description: draft.description, agentId: draft.agentId });
- } else if (agents.length > 0) {
- formHydrated.current = true;
- const preferredValid = recentAgentId && agents.some((a) => a.id === recentAgentId);
- const preferred = preferredValid ? recentAgentId : agents[0].id;
- setForm((prev) => ({ ...prev, agentId: preferred }));
- }
- }, [draft, agents, recentAgentId]);
-
- useEffect(() => {
- if (!dialogOpen) return;
- setDraft({ title: form.title, description: form.description, agentId: form.agentId });
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [form.title, form.description, form.agentId, dialogOpen]);
-
async function openIssue(issueId: string) {
setSelectedId(issueId);
+ setSheetOpen(true);
setDetailLoading(true);
try {
const res = await getIssue(workspaceId, issueId);
@@ -402,7 +228,6 @@ export default function IssuesPage() {
const detailConvId = detail?.issue.conversation_id ?? null;
const detailTaskId = detail?.issue.latest_task_id ?? null;
- const isTaskActive = activeTask && !["completed", "failed", "cancelled", "superseded"].includes(activeTask.status);
useEffect(() => {
if (!detailTaskId) { setActiveTask(null); setTaskLatestText(""); return; }
@@ -413,6 +238,8 @@ export default function IssuesPage() {
return () => { cancelled = true; };
}, [detailTaskId, workspaceId]);
+ const isTaskActive = activeTask && !["completed", "failed", "cancelled", "superseded"].includes(activeTask.status);
+
useEffect(() => {
if (!isTaskActive || !detailTaskId) return;
let cancelled = false;
@@ -465,34 +292,86 @@ export default function IssuesPage() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [detailConvId, selectedId, subscribeWs]);
- useEffect(() => {
- if (timelineRef.current) {
- timelineRef.current.scrollTop = timelineRef.current.scrollHeight;
- }
- }, [detail]);
+ // --- Sheet handlers ---
- async function handleCreate() {
- if (!form.title.trim()) return;
+ const handleCreate = useCallback(async (values: { agent_id?: string; title: string; description: string }) => {
setCreating(true);
try {
const res = await createIssue(workspaceId, {
- agent_id: form.agentId || undefined,
- title: form.title.trim(),
- description: form.description.trim(),
- // files: attachments, // TODO: disabled until Codex CLI fixes image_url serialization bug
+ agent_id: values.agent_id,
+ title: values.title,
+ description: values.description,
});
setIssues((prev) => [res.issue, ...prev]);
- setDialogOpen(false);
- if (form.agentId) setRecentAgentId(form.agentId);
- resetDraft();
- await openIssue(res.issue.id);
+ if (values.agent_id) setRecentAgentId(values.agent_id);
+ setDraft({ title: "", description: "", agentId: "" });
+ setSelectedId(res.issue.id);
+ openIssue(res.issue.id);
toast.success("Issue created");
} catch (err) {
toast.error(err instanceof Error ? err.message : "Failed to create issue");
} finally {
setCreating(false);
}
- }
+ }, [workspaceId]); // eslint-disable-line react-hooks/exhaustive-deps
+
+ const handleUpdate = useCallback(async (issueId: string, patch: { title?: string; description?: string }) => {
+ setSaving(true);
+ try {
+ const updated = await updateIssue(workspaceId, issueId, patch);
+ setIssues((prev) => prev.map((i) => i.id === issueId ? { ...i, ...patch, updated_at: updated.updated_at } : i));
+ if (detail?.issue.id === issueId) {
+ setDetail((prev) => prev ? { ...prev, issue: { ...prev.issue, ...patch, updated_at: updated.updated_at } } : prev);
+ }
+ toast.success("Issue updated");
+ } catch (err) {
+ toast.error(err instanceof Error ? err.message : "Failed to update issue");
+ } finally {
+ setSaving(false);
+ }
+ }, [workspaceId, detail]); // eslint-disable-line react-hooks/exhaustive-deps
+
+ const handleStatusChange = useCallback(async (issueId: string, newStatus: string) => {
+ const issue = issues.find((i) => i.id === issueId);
+ if (!issue) return;
+ const oldStatus = issue.status;
+ if (newStatus === oldStatus) return;
+
+ const now = new Date().toISOString();
+ setIssues((prev) => prev.map((i) => i.id === issueId ? { ...i, status: newStatus as Issue["status"], updated_at: now } : i));
+ if (detail?.issue.id === issueId) {
+ setDetail((prev) => prev ? { ...prev, issue: { ...prev.issue, status: newStatus as Issue["status"], updated_at: now } } : prev);
+ }
+
+ pendingStatusUpdate.current = issueId;
+ try {
+ await updateIssue(workspaceId, issueId, { status: newStatus as Issue["status"] });
+ } catch (err) {
+ setIssues((prev) => prev.map((i) => i.id === issueId ? { ...i, status: oldStatus } : i));
+ if (detail?.issue.id === issueId) {
+ setDetail((prev) => prev ? { ...prev, issue: { ...prev.issue, status: oldStatus } } : prev);
+ }
+ toast.error(err instanceof Error ? err.message : "Failed to update issue status");
+ } finally {
+ pendingStatusUpdate.current = null;
+ }
+ }, [workspaceId, issues, detail]); // eslint-disable-line react-hooks/exhaustive-deps
+
+ const handleDeleteFromSheet = useCallback(async (issueId: string) => {
+ setDeleting(true);
+ try {
+ await deleteIssue(workspaceId, issueId);
+ setIssues((prev) => prev.filter((i) => i.id !== issueId));
+ setSheetOpen(false);
+ setSelectedId(null);
+ setDetail(null);
+ toast.success("Issue deleted");
+ } catch (err) {
+ toast.error(err instanceof Error ? err.message : "Failed to delete issue");
+ } finally {
+ setDeleting(false);
+ }
+ }, [workspaceId]);
const handleDeleteIssue = useCallback(async (issueId: string) => {
try {
@@ -500,6 +379,7 @@ export default function IssuesPage() {
setIssues((prev) => prev.filter((i) => i.id !== issueId));
if (selectedId === issueId) {
setSelectedId(null);
+ setSheetOpen(false);
setDetail(null);
}
toast.success("Issue deleted");
@@ -508,29 +388,17 @@ export default function IssuesPage() {
}
}, [workspaceId, selectedId]);
- const onSidecarPointerDown = useCallback((e: React.PointerEvent) => {
- e.preventDefault();
- sidecarDragging.current = true;
- (e.target as HTMLElement).setPointerCapture(e.pointerId);
- }, []);
- const onSidecarPointerMove = useCallback((e: React.PointerEvent) => {
- if (!sidecarDragging.current) return;
- const maxW = window.innerWidth * SIDECAR_MAX_WIDTH_RATIO;
- setSidecarWidth(Math.min(maxW, Math.max(SIDECAR_MIN_WIDTH, window.innerWidth - e.clientX)));
+ const handleSheetOpenChange = useCallback((open: boolean) => {
+ setSheetOpen(open);
+ if (!open) {
+ setSelectedId(null);
+ setDetail(null);
+ setActiveTask(null);
+ setTaskLatestText("");
+ }
}, []);
- const onSidecarPointerUp = useCallback(() => { sidecarDragging.current = false; }, []);
-
- // TODO: attachment functions disabled until Codex CLI fixes image_url serialization bug
- // function handleFileSelect(event: React.ChangeEvent<HTMLInputElement>) { ... }
- // function removeAttachment(index: number) { ... }
-
- function resetDraft() {
- const preferredValid = recentAgentId && agents.some((a) => a.id === recentAgentId);
- const defaultAgent = preferredValid ? recentAgentId : agents[0]?.id || "";
- setForm({ title: "", description: "", agentId: defaultAgent });
- setDraft({ title: "", description: "" });
- formHydrated.current = true;
- }
+
+ // --- DnD handlers ---
function handleDragStart(event: DragStartEvent) {
setActiveDragId(event.active.id as string);
@@ -574,29 +442,8 @@ export default function IssuesPage() {
}
}
- async function handleStatusChange(newStatus: string) {
- if (!detail) return;
- const issueId = detail.issue.id;
- const oldStatus = detail.issue.status;
- if (newStatus === oldStatus) return;
-
- const now = new Date().toISOString();
- setDetail((prev) => prev ? { ...prev, issue: { ...prev.issue, status: newStatus as Issue["status"], updated_at: now } } : prev);
- setIssues((prev) => prev.map((i) => i.id === issueId ? { ...i, status: newStatus as Issue["status"], updated_at: now } : i));
-
- pendingStatusUpdate.current = issueId;
- try {
- await updateIssue(workspaceId, issueId, { status: newStatus as Issue["status"] });
- } catch (err) {
- setDetail((prev) => prev ? { ...prev, issue: { ...prev.issue, status: oldStatus } } : prev);
- setIssues((prev) => prev.map((i) => i.id === issueId ? { ...i, status: oldStatus } : i));
- toast.error(err instanceof Error ? err.message : "Failed to update issue status");
- } finally {
- pendingStatusUpdate.current = null;
- }
- }
-
const boardLoading = loading || agentsLoading;
+ const selectedIssue = selectedId ? issues.find((i) => i.id === selectedId) ?? null : null;
return (
<div className="relative flex h-full min-h-0 flex-col bg-background/30">
@@ -604,137 +451,23 @@ export default function IssuesPage() {
<div className="min-w-0">
<h1 className="text-base font-semibold tracking-normal">Issues</h1>
</div>
- <Dialog
- open={dialogOpen}
- onOpenChange={(open) => {
- setDialogOpen(open);
- }}
- >
- {!showCompleted && (
- <Button variant="outline" size="sm" className="w-full sm:w-auto" onClick={() => setShowCompleted(true)}>
- <Eye className="size-3" />
- Show completed
- </Button>
- )}
- <DialogTrigger render={<Button size="sm" className="w-full sm:w-auto" />}>
+ <div className="flex items-center gap-2">
+ <Button size="sm" className="w-full sm:w-auto" onClick={() => { setSelectedId(null); setSheetOpen(true); }}>
<Plus className="size-4" />
New issue
- </DialogTrigger>
- <DialogContent className="flex max-h-[min(720px,calc(100dvh-2rem))] grid-rows-none flex-col gap-0 overflow-hidden p-0 sm:max-w-2xl" showCloseButton={false}>
- <div className="flex shrink-0 items-center border-b border-border/40 px-4 py-2">
- <DialogTitle className="text-sm tracking-tight">New Issue</DialogTitle>
- </div>
-
- <div className="shrink-0 space-y-1 border-b border-border/30 px-4 py-2.5">
- <div className="flex min-w-0 items-center gap-2 text-sm">
- <span className="w-18 shrink-0 text-muted-foreground">Title</span>
- <div className="-ml-1.5 min-w-0 flex-1 rounded-md bg-muted/40">
- <Input
- id="issue-title"
- value={form.title}
- onChange={(event) => setForm((prev) => ({ ...prev, title: event.target.value }))}
- placeholder="Short, actionable summary"
- className="h-7 border-0 bg-transparent px-1.5 text-sm shadow-none focus-visible:ring-0 placeholder:text-muted-foreground/50"
- disabled={creating}
- />
- </div>
- </div>
- <div className="flex min-w-0 items-center gap-2 text-sm">
- <span className="w-18 shrink-0 text-muted-foreground">Assign</span>
- <Popover open={assigneeOpen} onOpenChange={setAssigneeOpen}>
- <PopoverTrigger
- render={
- <button
- type="button"
- disabled={creating}
- className="-ml-1.5 flex h-7 min-w-0 flex-1 items-center rounded-md bg-muted/40 px-1.5 text-left outline-none transition-colors hover:bg-muted/60 focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50"
- />
- }
- >
- {selectedFormAgent ? (
- <AgentIdentity agent={selectedFormAgent} size={18} />
- ) : (
- <span className="text-sm text-muted-foreground/70">Unassigned</span>
- )}
- </PopoverTrigger>
- <PopoverContent align="start" className="max-h-64 w-72 overflow-y-auto p-1">
- <button
- type="button"
- onClick={() => {
- setForm((prev) => ({ ...prev, agentId: "" }));
- setDraft((prev) => ({ ...prev, agentId: "" }));
- setAssigneeOpen(false);
- }}
- className="flex w-full items-center justify-between gap-2 rounded-md px-2 py-2 text-left text-sm transition-colors hover:bg-accent hover:text-accent-foreground"
- >
- <span className="text-muted-foreground">None (unassigned)</span>
- {!form.agentId ? <Check className="size-3.5 shrink-0" /> : null}
- </button>
- {agents.map((agent) => (
- <button
- key={agent.id}
- type="button"
- onClick={() => {
- setForm((prev) => ({ ...prev, agentId: agent.id }));
- setDraft((prev) => ({ ...prev, agentId: agent.id }));
- setAssigneeOpen(false);
- }}
- className="flex w-full items-center justify-between gap-2 rounded-md px-2 py-2 text-left text-sm transition-colors hover:bg-accent hover:text-accent-foreground"
- >
- <AgentIdentity agent={agent} size={18} />
- {form.agentId === agent.id ? <Check className="size-3.5 shrink-0" /> : null}
- </button>
- ))}
- </PopoverContent>
- </Popover>
- </div>
- </div>
-
- <div className="min-h-0 flex-1 overflow-y-auto thin-scrollbar px-4 py-3">
- <MarkdownEditor
- value={form.description}
- onChange={(description) => setForm((prev) => ({ ...prev, description }))}
- placeholder="Context, constraints, expected outcome"
- minHeight="14rem"
- variant="seamless"
- contentType="markdown"
- agents={agents}
- className="min-h-full"
- />
- </div>
-
- <div className="flex shrink-0 items-center justify-end gap-1 border-t border-border/30 px-3 py-2">
- <Button
- variant="ghost"
- size="sm"
- className="h-7 px-2 text-xs text-muted-foreground"
- onClick={() => {
- setDialogOpen(false);
- resetDraft();
- }}
- disabled={creating}
- >
- <X className="mr-1 size-3" />
- Discard
- </Button>
- <Button
- size="sm"
- className="h-7 px-3 text-xs"
- onClick={handleCreate}
- disabled={creating || !form.title.trim()}
- >
- {creating ? <Loader2 className="mr-1 size-3 animate-spin" /> : <Plus className="mr-1 size-3" />}
- Create
- </Button>
- </div>
- </DialogContent>
- </Dialog>
+ </Button>
+ </div>
</div>
<div className="hidden min-h-0 flex-1 lg:block overflow-y-auto thin-scrollbar p-4">
{boardLoading ? (
- <div className={cn("grid h-full gap-4", showCompleted ? "grid-cols-4" : "grid-cols-3")}>
- {Array.from({ length: showCompleted ? 12 : 9 }).map((_, i) => <Skeleton key={i} className="h-24 rounded-lg" />)}
+ <div className={cn("grid h-full gap-4", showCompleted ? "grid-cols-4" : "grid-cols-[1fr_1fr_1fr_36px]")}>
+ {Array.from({ length: 9 }).map((_, i) => <Skeleton key={i} className="h-24 rounded-lg" />)}
+ {showCompleted ? (
+ Array.from({ length: 3 }).map((_, i) => <Skeleton key={`c${i}`} className="h-24 rounded-lg" />)
+ ) : (
+ <Skeleton className="h-full rounded-lg" />
+ )}
</div>
) : issues.length === 0 ? (
<div className="flex flex-col items-center justify-center h-full animate-[fade-up_400ms_ease-out_both]">
@@ -744,7 +477,7 @@ export default function IssuesPage() {
</div>
) : (
<DndContext sensors={sensors} onDragStart={handleDragStart} onDragEnd={handleDragEnd}>
- <div className={cn("grid h-full gap-4", showCompleted ? "grid-cols-4" : "grid-cols-3")}>
+ <div className={cn("grid h-full gap-4", showCompleted ? "grid-cols-4" : "grid-cols-[1fr_1fr_1fr_36px]")}>
{COLUMNS.filter(col => col.id !== "completed" || showCompleted).map((col) => {
const columnIssues = issues.filter((issue) => (col.statuses as readonly string[]).includes(issue.status));
return (
@@ -754,18 +487,26 @@ export default function IssuesPage() {
<div className="flex items-center gap-1.5">
<span>{columnIssues.length}</span>
{col.id === "completed" && (
- <button
- type="button"
- disabled={!!activeDragId}
- onClick={() => setShowCompleted(false)}
- className="rounded p-0.5 text-muted-foreground/60 transition-colors hover:bg-muted hover:text-muted-foreground disabled:opacity-40"
- >
- <EyeOff className="size-3.5" />
- </button>
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <button
+ type="button"
+ aria-label="Hide completed column"
+ disabled={!!activeDragId}
+ onClick={() => setShowCompleted(false)}
+ className="rounded p-0.5 text-muted-foreground/60 transition-colors hover:bg-muted hover:text-muted-foreground disabled:opacity-40"
+ />
+ }
+ >
+ <EyeOff className="size-3.5" />
+ </TooltipTrigger>
+ <TooltipContent>Hide completed</TooltipContent>
+ </Tooltip>
)}
</div>
</div>
- <div className="min-h-0 flex-1 space-y-2 overflow-y-auto thin-scrollbar p-2">
+ <div className={cn("min-h-0 flex-1 space-y-2 overflow-y-auto thin-scrollbar p-2", col.id === "completed" && "animate-[fade-up_300ms_ease-out_both]")}>
{columnIssues.length === 0 ? (
<div className="flex h-full min-h-20 items-center justify-center rounded-lg border border-dashed border-border/45 text-xs text-muted-foreground/70">
Empty
@@ -779,6 +520,33 @@ export default function IssuesPage() {
</DroppableColumn>
);
})}
+ {!showCompleted && (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <div
+ role="button"
+ tabIndex={0}
+ aria-label="Show completed column"
+ onClick={() => { if (!activeDragId) setShowCompleted(true); }}
+ onKeyDown={(e) => { if ((e.key === "Enter" || e.key === " ") && !activeDragId) { e.preventDefault(); setShowCompleted(true); } }}
+ className={cn(
+ "flex h-full items-center justify-center rounded-lg border border-dashed border-border/60 bg-muted/20 transition-colors",
+ activeDragId ? "pointer-events-none opacity-40" : "cursor-pointer hover:bg-muted/40"
+ )}
+ />
+ }
+ >
+ <div className="flex flex-col items-center justify-center gap-3 h-full py-3">
+ <Eye className="size-3.5 text-muted-foreground/60 shrink-0" />
+ <span className="text-xs font-medium text-muted-foreground" style={{ writingMode: "vertical-rl" }}>
+ Completed ({issues.filter(i => (COLUMNS[3].statuses as readonly string[]).includes(i.status)).length})
+ </span>
+ </div>
+ </TooltipTrigger>
+ <TooltipContent>Show completed</TooltipContent>
+ </Tooltip>
+ )}
</div>
<DragOverlay style={{ zIndex: 9999 }}>
{activeDragId ? (() => {
@@ -815,13 +583,21 @@ export default function IssuesPage() {
<div className="flex items-center gap-1.5">
<Badge variant="outline">{columnIssues.length}</Badge>
{col.id === "completed" && (
- <button
- type="button"
- onClick={() => setShowCompleted(false)}
- className="rounded p-0.5 text-muted-foreground/60 transition-colors hover:bg-muted hover:text-muted-foreground"
- >
- <EyeOff className="size-3.5" />
- </button>
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <button
+ type="button"
+ aria-label="Hide completed column"
+ onClick={() => setShowCompleted(false)}
+ className="rounded p-0.5 text-muted-foreground/60 transition-colors hover:bg-muted hover:text-muted-foreground"
+ />
+ }
+ >
+ <EyeOff className="size-3.5" />
+ </TooltipTrigger>
+ <TooltipContent>Hide completed</TooltipContent>
+ </Tooltip>
)}
</div>
</div>
@@ -833,153 +609,48 @@ export default function IssuesPage() {
</section>
);
})}
+ {!showCompleted && (
+ <div
+ role="button"
+ tabIndex={0}
+ aria-label="Show completed issues"
+ onClick={() => setShowCompleted(true)}
+ onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); setShowCompleted(true); } }}
+ className="flex cursor-pointer items-center gap-2 rounded-lg border border-dashed border-border/60 px-3 py-2.5 text-sm text-muted-foreground transition-colors hover:bg-muted/30"
+ >
+ <Eye className="size-3.5" />
+ <span>Show Completed ({issues.filter(i => (COLUMNS[3].statuses as readonly string[]).includes(i.status)).length})</span>
+ </div>
+ )}
</div>
)}
</div>
- <Sheet open={!!selectedId} onOpenChange={(open) => { if (!open) { setSelectedId(null); setDetail(null); setActiveTask(null); setTaskLatestText(""); } }}>
- <SheetContent
- side="right"
- showCloseButton={false}
- className="data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border"
- style={{ width: `min(${sidecarWidth}px, 100vw)`, maxWidth: "none" }}
- >
- <div
- onPointerDown={onSidecarPointerDown}
- onPointerMove={onSidecarPointerMove}
- onPointerUp={onSidecarPointerUp}
- onLostPointerCapture={onSidecarPointerUp}
- className="hidden sm:block absolute -left-px top-0 bottom-0 w-1.5 cursor-col-resize z-10 hover:bg-primary/20 active:bg-primary/30 transition-colors rounded-l-xl"
- />
- <SheetHeader className="relative z-10 border-b-0 pb-2">
- <SheetTitle>
- {detailLoading || !detail ? (
- <div className="space-y-2">
- <Skeleton className="h-5 w-56" />
- <Skeleton className="h-4 w-40" />
- </div>
- ) : (
- <div className="space-y-1">
- <div className="flex items-center gap-2">
- <span className="min-w-0 flex-1 truncate text-base font-semibold">{detail.issue.title}</span>
- <Button variant="ghost" size="icon-sm" className="ml-auto shrink-0" onClick={() => { setSelectedId(null); setDetail(null); setActiveTask(null); setTaskLatestText(""); }}>
- <X className="size-4" />
- </Button>
- </div>
- <div className="flex items-center gap-2 text-xs text-muted-foreground">
- {detail.issue.agent_id && detail.issue.conversation_id && (
- <div className="flex items-center gap-0.5">
- <Link
- href={`/w/${slug}/agents/${detail.issue.agent_id}?conv=${detail.issue.conversation_id}${detail.issue.latest_task_id ? `&task=${detail.issue.latest_task_id}` : ""}`}
- className="group inline-flex items-center rounded-lg text-xs text-muted-foreground h-7 px-2 hover:bg-muted hover:text-foreground transition-all"
- >
- <MessageSquare className="size-3 shrink-0" />
- <span className="max-w-0 opacity-0 group-hover:max-w-16 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300 overflow-hidden transition-all duration-500 ease-out">Chat</span>
- </Link>
- {detail.issue.trace_id && (
- <Link
- href={`/w/${slug}/threads/${detail.issue.trace_id}`}
- className="group inline-flex items-center rounded-lg text-xs text-muted-foreground h-7 px-2 hover:bg-muted hover:text-foreground transition-all"
- >
- <GitBranch className="size-3 shrink-0" />
- <span className="max-w-0 opacity-0 group-hover:max-w-20 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300 overflow-hidden transition-all duration-500 ease-out">Thread</span>
- </Link>
- )}
- </div>
- )}
- <Select value={detail.issue.status} onValueChange={(val) => { if (val) handleStatusChange(val); }}>
- <SelectTrigger className="w-fit h-5 shrink-0 gap-1 rounded-full border px-2 text-[10px] font-medium">
- {detail.issue.status === "in_progress" && <Loader2 className="size-3 animate-spin" />}
- <SelectValue placeholder={statusLabel(detail.issue.status)} />
- </SelectTrigger>
- <SelectPopup portal={false} alignItemWithTrigger={false} side="bottom" sideOffset={4} className="min-w-0 p-0.5">
- {SELECTOR_STATUSES.map((s) => (
- <SelectItem key={s} value={s} className="py-1 pl-1.5 pr-6 text-[11px]">{statusLabel(s)}</SelectItem>
- ))}
- </SelectPopup>
- </Select>
- {detail.issue.agent_id && agentsById.get(detail.issue.agent_id) ? (
- <span className="flex items-center gap-1">
- <AgentAvatar agent={agentsById.get(detail.issue.agent_id)} size={14} />
- <span className="truncate">{agentName(detail.issue.agent_id)}</span>
- </span>
- ) : !detail.issue.agent_id ? (
- <span className="text-muted-foreground/60">Unassigned</span>
- ) : null}
- <span className="shrink-0">{formatDate(detail.issue.updated_at)}</span>
- </div>
- </div>
- )}
- </SheetTitle>
- </SheetHeader>
- {detailLoading || !detail ? (
- <div className="flex-1 px-6 py-5 space-y-3">
- <Skeleton className="h-24" />
- <Skeleton className="h-16" />
- </div>
- ) : (
- <>
- <div className="shrink-0 space-y-6 px-6 pt-2 pb-3">
- {detail.issue.description && (
- <div className="prose prose-sm dark:prose-invert max-w-none text-sm break-words">
- <Streamdown>{detail.issue.description}</Streamdown>
- </div>
- )}
- <AttachmentList artifacts={detail.artifacts ?? []} workspaceId={workspaceId} />
- </div>
-
- <div ref={timelineRef} className="flex-1 min-h-0 overflow-y-auto thin-scrollbar mx-6 mt-2 mb-4 px-4 py-4 space-y-3 border rounded-lg">
- {(() => {
- const events = detail.messages
- .filter((m) => m.role === "event")
- .map((m) => ({ kind: "event" as const, id: m.id, created_at: m.created_at, data: m }));
- const comments = (detail.comments ?? [])
- .map((c) => ({ kind: "comment" as const, id: c.id, created_at: c.created_at, data: c }));
- const timeline = [...events, ...comments].sort(
- (a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime()
- );
-
- if (timeline.length === 0 && !isTaskActive) {
- return <div className="text-xs text-muted-foreground">No activity yet.</div>;
- }
-
- return (
- <div className="relative pl-4">
- <div className="absolute left-[5px] top-2 bottom-2 w-px bg-border" />
- <div className="space-y-3">
- {timeline.map((item) => (
- <div key={item.id} className="relative">
- <div className="absolute -left-4 top-2.5 size-2.5 rounded-full border-2 border-background bg-muted-foreground/40" />
- {item.kind === "event"
- ? <MessageRow message={item.data} />
- : <CommentRow comment={item.data} agents={agents} />
- }
- </div>
- ))}
- {isTaskActive && (
- <div className="relative">
- <div className="absolute -left-4 top-2.5 size-2.5 rounded-full border-2 border-background bg-emerald-500 animate-pulse" />
- <div className="rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2">
- <div className="flex items-center gap-2 text-xs text-emerald-600 dark:text-emerald-400">Working</div>
- {taskLatestText && <p className="mt-1 text-[11px] text-muted-foreground line-clamp-2">{taskLatestText}</p>}
- </div>
- </div>
- )}
- </div>
- </div>
- );
- })()}
- </div>
-
- {!isTaskActive && !isTerminalIssueStatus(detail.issue.status) && (
- <div className="shrink-0 px-6 pb-4">
- <CommentInput issueId={detail.issue.id} workspaceId={workspaceId} onCommented={() => openIssue(detail.issue.id)} />
- </div>
- )}
- </>
- )}
- </SheetContent>
- </Sheet>
+ <IssueSheet
+ open={sheetOpen}
+ onOpenChange={handleSheetOpenChange}
+ agents={agents}
+ issue={selectedIssue}
+ detail={detail ? { messages: detail.messages, comments: detail.comments, artifacts: detail.artifacts, traceId: detail.issue.trace_id } : null}
+ detailLoading={detailLoading}
+ activeTask={activeTask}
+ taskLatestText={taskLatestText}
+ submitting={creating}
+ saving={saving}
+ deleting={deleting}
+ defaultAgentId={recentAgentId}
+ slug={slug}
+ workspaceId={workspaceId}
+ width={sidecarWidth}
+ onWidthChange={setSidecarWidth}
+ draft={draft}
+ onDraftChange={setDraft}
+ onCreate={handleCreate}
+ onUpdate={handleUpdate}
+ onStatusChange={handleStatusChange}
+ onDelete={handleDeleteFromSheet}
+ onCommented={() => selectedId && openIssue(selectedId)}
+ />
</div>
);
}
diff --git a/src/web/src/components/avatar/avatar-generator.tsx b/src/web/src/components/avatar/avatar-generator.tsx
index b09455655..0cefcabf5 100644
--- a/src/web/src/components/avatar/avatar-generator.tsx
+++ b/src/web/src/components/avatar/avatar-generator.tsx
@@ -167,18 +167,21 @@ export function AvatarGenerator({ config, onChange, layout = "vertical", mobile
}, [layout, onChange]);
const renderShapeThumb = (key: string) => (
- <svg viewBox="0 0 200 200" width="40" height="40" className="dark:invert">
- {Shapes[key]?.render()}
+ <svg viewBox="0 0 200 200" width="40" height="40">
+ <rect width="200" height="200" rx="56" fill="hsl(var(--muted))" />
+ <g transform="translate(100,100) scale(0.8) translate(-100,-100)">
+ {Shapes[key]?.render()}
+ </g>
</svg>
);
const renderNoseThumb = (key: string) => (
- <svg viewBox="-14 -10 28 20" width="36" height="24" className="dark:invert">
- {Noses[key]?.render()}
+ <svg viewBox="-14 -10 28 20" width="36" height="24">
+ {Noses[key]?.render("currentColor")}
</svg>
);
const renderEyeThumb = (key: string) => (
- <svg viewBox="-18 -8 36 16" width="44" height="22" className="dark:invert">
- {Eyes[key]?.render(8)}
+ <svg viewBox="-18 -10 36 20" width="44" height="24">
+ {Eyes[key]?.render(8, "currentColor")}
</svg>
);
@@ -265,16 +268,13 @@ export function AvatarGenerator({ config, onChange, layout = "vertical", mobile
type="button"
onClick={() => onChange(p.config)}
className={cn(
- "flex flex-col items-center gap-1 rounded-xl border p-2 transition-all",
+ "flex items-center justify-center rounded-xl border p-2 transition-all",
isActive
? "border-primary border-2 bg-primary/5 shadow-sm"
: "border-border bg-background hover:border-primary/40"
)}
>
<AvatarRenderer config={p.config} size={56} />
- <span className="text-[10px] text-muted-foreground">
- {p.name}
- </span>
</button>
);
})}
@@ -327,7 +327,7 @@ export function AvatarGenerator({ config, onChange, layout = "vertical", mobile
? "ring-2 ring-primary ring-offset-2"
: "ring-1 ring-border"
)}
- style={{ backgroundColor: c.value }}
+ style={{ background: `linear-gradient(135deg, ${c.gradient[0]}, ${c.gradient[1]}, ${c.gradient[2]})` }}
/>
))}
</div>
diff --git a/src/web/src/components/avatar/avatar-parts.tsx b/src/web/src/components/avatar/avatar-parts.tsx
index 1c04676cd..1c2232357 100644
--- a/src/web/src/components/avatar/avatar-parts.tsx
+++ b/src/web/src/components/avatar/avatar-parts.tsx
@@ -1,25 +1,15 @@
-// Avatar parts library — inline SVG components for modular avatar generation.
-// Ported from Jacky's Notion-style avatar generator prototype.
-// All shapes are pure SVG paths — no external PNG files needed.
-
+import { useId } from "react";
import type { ReactNode } from "react";
// ─────────────────────────────────────────────────────────────
-// STROKE / FILL CONSTANTS
+// STYLE CONSTANTS
// ─────────────────────────────────────────────────────────────
-const STROKE = "#1F1F1F";
-const FILL = "#FFFFFF";
-const SW_OUT = 8;
-const SW_INNER = 5;
-const SW_FACE = 5;
+const SHAPE_FILL = "rgba(255,255,255,0.92)";
+const SHAPE_STROKE = "rgba(255,255,255,0.95)";
+const SHAPE_SW = 3.5;
+const DEFAULT_FACE_COLOR = "#27272a";
-const sp = (w = SW_OUT) =>
- ({ fill: FILL, stroke: STROKE, strokeWidth: w, strokeLinejoin: "round" as const, strokeLinecap: "round" as const });
-const lp = (w = SW_INNER) =>
- ({ fill: "none", stroke: STROKE, strokeWidth: w, strokeLinejoin: "round" as const, strokeLinecap: "round" as const });
-const lpf = (w = SW_FACE) =>
- ({ fill: "none", stroke: STROKE, strokeWidth: w, strokeLinejoin: "round" as const, strokeLinecap: "round" as const });
-const fp = { fill: STROKE };
+const shapeStyle = { fill: SHAPE_FILL, stroke: SHAPE_STROKE, strokeWidth: SHAPE_SW };
// ─────────────────────────────────────────────────────────────
// PALETTES
@@ -27,25 +17,27 @@ const fp = { fill: STROKE };
export interface ColorOption {
name: string;
value: string;
+ gradient: [string, string, string];
+ faceColor: string;
}
export const BG_COLORS: ColorOption[] = [
- { name: "Purple", value: "#9B7FE8" },
- { name: "Teal", value: "#2BAA9C" },
- { name: "Orange", value: "#F39A4F" },
- { name: "Blue", value: "#3D7EE8" },
- { name: "Pink", value: "#F8B4C4" },
- { name: "Yellow", value: "#F4C141" },
- { name: "Green", value: "#7FCB6F" },
- { name: "Beige", value: "#D6CCB8" },
- { name: "Red", value: "#EE5E48" },
- { name: "Lake Blue", value: "#3FA8C0" },
- { name: "Gray", value: "#C9D1D9" },
- { name: "Deep Purple", value: "#6A4DCC" },
+ { name: "Purple", value: "#a855f7", gradient: ["#c084fc", "#a855f7", "#7c3aed"], faceColor: "#2e1065" },
+ { name: "Teal", value: "#14b8a6", gradient: ["#5eead4", "#14b8a6", "#0d9488"], faceColor: "#134e4a" },
+ { name: "Orange", value: "#f97316", gradient: ["#fdba74", "#f97316", "#c2410c"], faceColor: "#7c2d12" },
+ { name: "Blue", value: "#3b82f6", gradient: ["#93c5fd", "#3b82f6", "#1d4ed8"], faceColor: "#1e3a5f" },
+ { name: "Pink", value: "#f472b6", gradient: ["#fda4af", "#f472b6", "#be185d"], faceColor: "#831843" },
+ { name: "Yellow", value: "#eab308", gradient: ["#fde047", "#eab308", "#a16207"], faceColor: "#713f12" },
+ { name: "Green", value: "#22c55e", gradient: ["#86efac", "#22c55e", "#15803d"], faceColor: "#14532d" },
+ { name: "Beige", value: "#d6ccb8", gradient: ["#e8e0d4", "#d6ccb8", "#b8a990"], faceColor: "#57534e" },
+ { name: "Red", value: "#ef4444", gradient: ["#fca5a5", "#ef4444", "#991b1b"], faceColor: "#7f1d1d" },
+ { name: "Lake Blue", value: "#6366f1", gradient: ["#a5b4fc", "#6366f1", "#3730a3"], faceColor: "#312e81" },
+ { name: "Gray", value: "#9ca3af", gradient: ["#d4d4d8", "#9ca3af", "#6b7280"], faceColor: "#374151" },
+ { name: "Deep Purple", value: "#8b5cf6", gradient: ["#c4b5fd", "#8b5cf6", "#5b21b6"], faceColor: "#3b0764" },
];
// ─────────────────────────────────────────────────────────────
-// SHAPES (outlines)
+// SHAPES (rounded silhouettes only)
// ─────────────────────────────────────────────────────────────
export interface ShapeDef {
name: string;
@@ -56,89 +48,62 @@ export interface ShapeDef {
export const Shapes: Record<string, ShapeDef> = {
circle: {
name: "Circle",
- face: { cx: 100, cy: 105, w: 80 },
- render: () => <circle cx="100" cy="100" r="70" {...sp()} />,
+ face: { cx: 100, cy: 100, w: 80 },
+ render: () => <circle cx="100" cy="100" r="66" {...shapeStyle} />,
},
rounded: {
name: "Rounded",
- face: { cx: 100, cy: 105, w: 90 },
- render: () => <rect x="30" y="30" width="140" height="140" rx="20" {...sp()} />,
+ face: { cx: 100, cy: 100, w: 90 },
+ render: () => <rect x="30" y="30" width="140" height="140" rx="32" {...shapeStyle} />,
},
hexagon: {
name: "Hexagon",
- face: { cx: 100, cy: 105, w: 86 },
- render: () => <path d="M100 28 L162 64 L162 136 L100 172 L38 136 L38 64 Z" {...sp()} />,
+ face: { cx: 100, cy: 100, w: 86 },
+ render: () => (
+ <path d="M100 32 C108 32 114 35 120 39 L155 60 C161 64 165 70 165 78 L165 122 C165 130 161 136 155 140 L120 161 C114 165 108 168 100 168 C92 168 86 165 80 161 L45 140 C39 136 35 130 35 122 L35 78 C35 70 39 64 45 60 L80 39 C86 35 92 32 100 32 Z" {...shapeStyle} />
+ ),
},
task: {
name: "Task",
- face: { cx: 92, cy: 92, w: 70 },
- render: () => (
- <g>
- <rect x="34" y="34" width="132" height="132" rx="14" {...sp()} />
- <path d="M70 110 L102 138 L168 64" {...lp(SW_OUT)} />
- </g>
- ),
+ face: { cx: 100, cy: 100, w: 80 },
+ render: () => <rect x="34" y="34" width="132" height="132" rx="24" {...shapeStyle} />,
},
book: {
name: "Book",
- face: { cx: 100, cy: 105, w: 90 },
+ face: { cx: 100, cy: 100, w: 80 },
render: () => (
- <g>
- <path d="M30 60 C 60 50, 85 56, 100 70 C 115 56, 140 50, 170 60 L 170 158 C 140 148, 115 154, 100 168 C 85 154, 60 148, 30 158 Z" {...sp()} />
- <path d="M100 70 L100 84" {...lp(SW_INNER)} />
- <path d="M100 154 L100 168" {...lp(SW_INNER)} />
- </g>
+ <path d="M42 162 L42 88 C42 54 68 34 100 34 C132 34 158 54 158 88 L158 162 C158 166 154 170 150 170 L50 170 C46 170 42 166 42 162 Z" {...shapeStyle} />
),
},
mail: {
name: "Mail",
- face: { cx: 100, cy: 118, w: 80 },
- render: () => (
- <g>
- <rect x="30" y="56" width="140" height="100" rx="12" {...sp()} />
- <path d="M36 64 L100 108 L164 64" {...lp(SW_INNER)} />
- </g>
- ),
+ face: { cx: 100, cy: 100, w: 86 },
+ render: () => <rect x="28" y="54" width="144" height="92" rx="46" {...shapeStyle} />,
},
calendar: {
name: "Calendar",
- face: { cx: 100, cy: 122, w: 80 },
+ face: { cx: 100, cy: 100, w: 80 },
render: () => (
- <g>
- <rect x="30" y="48" width="140" height="124" rx="12" {...sp()} />
- <path d="M30 80 L170 80" {...lp(SW_INNER)} />
- <path d="M62 36 L62 60" {...lp(SW_INNER)} />
- <path d="M138 36 L138 60" {...lp(SW_INNER)} />
- </g>
+ <path d="M100 34 C138 34 166 52 166 80 C166 94 158 106 158 118 C158 148 138 166 100 166 C62 166 42 148 42 118 C42 106 34 94 34 80 C34 52 62 34 100 34 Z" {...shapeStyle} />
),
},
bulb: {
name: "Bulb",
- face: { cx: 100, cy: 100, w: 70 },
- render: () => (
- <g>
- <path d="M100 26 C 62 26, 36 52, 36 86 C 36 110, 52 126, 68 138 L 68 148 A 6 6 0 0 0 74 154 L 126 154 A 6 6 0 0 0 132 148 L 132 138 C 148 126, 164 110, 164 86 C 164 52, 138 26, 100 26 Z" {...sp()} />
- <path d="M76 162 L124 162" {...lp(SW_INNER)} />
- <path d="M82 172 L118 172" {...lp(SW_INNER)} />
- </g>
- ),
+ face: { cx: 100, cy: 104, w: 76 },
+ render: () => <ellipse cx="100" cy="104" rx="58" ry="66" {...shapeStyle} />,
},
folder: {
name: "Folder",
- face: { cx: 100, cy: 118, w: 90 },
+ face: { cx: 102, cy: 108, w: 80 },
render: () => (
- <path d="M30 64 A 10 10 0 0 1 40 54 L 84 54 L 96 66 L 160 66 A 10 10 0 0 1 170 76 L 170 158 A 10 10 0 0 1 160 168 L 40 168 A 10 10 0 0 1 30 158 Z" {...sp()} />
+ <path d="M62 144 C40 144 32 128 36 116 C32 104 40 90 54 88 C56 72 70 60 88 62 C100 50 118 50 132 58 C144 52 162 60 162 76 C172 82 174 98 166 108 C172 120 164 136 150 140 Z" {...shapeStyle} />
),
},
mountain: {
name: "Mountain",
- face: { cx: 100, cy: 130, w: 70 },
+ face: { cx: 100, cy: 100, w: 76 },
render: () => (
- <g>
- <path d="M28 168 L100 56 L172 168 Z" {...sp()} />
- <path d="M100 56 L100 28" {...lpf(SW_INNER)} />
- <path d="M100 30 L122 38 L100 46" {...sp(SW_INNER)} />
- </g>
+ <path d="M92 36 C120 32 156 48 164 78 C172 108 156 148 124 160 C92 172 48 156 38 124 C28 92 62 40 92 36 Z" {...shapeStyle} />
),
},
};
@@ -146,21 +111,47 @@ export const Shapes: Record<string, ShapeDef> = {
export const SHAPE_KEYS = Object.keys(Shapes);
// ─────────────────────────────────────────────────────────────
-// NOSES
+// NOSES (mouths)
// ─────────────────────────────────────────────────────────────
export interface NoseDef {
name: string;
- render: () => ReactNode;
+ render: (color?: string) => ReactNode;
}
export const Noses: Record<string, NoseDef> = {
- dot: { name: "Dot", render: () => <circle cx="0" cy="0" r="3.2" {...fp} /> },
- dash: { name: "Dash", render: () => <line x1="-8" y1="0" x2="8" y2="0" {...lpf(SW_FACE)} /> },
- hookL: { name: "Hook", render: () => <path d="M-4 -6 L-4 5 L7 5" {...lpf(SW_FACE)} /> },
- smile: { name: "Smile", render: () => <path d="M-8 -3 Q0 7 8 -3" {...lpf(SW_FACE)} /> },
- caret: { name: "Caret", render: () => <path d="M-8 5 L0 -5 L8 5" {...lpf(SW_FACE)} /> },
- arrow: { name: "Arrow", render: () => <path d="M-8 -3 L0 4 L8 -3" {...lpf(SW_FACE)} /> },
- oh: { name: "o", render: () => <circle cx="0" cy="0" r="4" {...lpf(SW_FACE - 1)} /> },
+ dot: {
+ name: "Dot",
+ render: (c = DEFAULT_FACE_COLOR) => <circle cx="0" cy="0" r="3" fill={c} />,
+ },
+ dash: {
+ name: "Dash",
+ render: (c = DEFAULT_FACE_COLOR) => <line x1="-7" y1="0" x2="7" y2="0" stroke={c} strokeWidth="4" strokeLinecap="round" />,
+ },
+ hookL: {
+ name: "Hook",
+ render: (c = DEFAULT_FACE_COLOR) => <path d="M-8 0 Q-4 5 0 1 Q4 5 8 0" fill="none" stroke={c} strokeWidth="3.5" strokeLinecap="round" strokeLinejoin="round" />,
+ },
+ smile: {
+ name: "Smile",
+ render: (c = DEFAULT_FACE_COLOR) => <path d="M-8 0 Q0 8 8 0" fill="none" stroke={c} strokeWidth="4" strokeLinecap="round" />,
+ },
+ caret: {
+ name: "Caret",
+ render: (c = DEFAULT_FACE_COLOR) => (
+ <g>
+ <path d="M-7 0 Q0 6 7 0" fill="none" stroke={c} strokeWidth="3.5" strokeLinecap="round" />
+ <ellipse cx="2" cy="5" rx="3" ry="3.5" fill="#f472b6" />
+ </g>
+ ),
+ },
+ arrow: {
+ name: "Arrow",
+ render: (c = DEFAULT_FACE_COLOR) => <ellipse cx="0" cy="0" rx="4.5" ry="5.5" fill={c} />,
+ },
+ oh: {
+ name: "o",
+ render: (c = DEFAULT_FACE_COLOR) => <ellipse cx="0" cy="0" rx="5" ry="5.5" fill="none" stroke={c} strokeWidth="3.5" />,
+ },
};
export const NOSE_KEYS = Object.keys(Noses);
@@ -170,46 +161,65 @@ export const NOSE_KEYS = Object.keys(Noses);
// ─────────────────────────────────────────────────────────────
export interface EyeDef {
name: string;
- render: (dx: number) => ReactNode;
+ render: (dx: number, color?: string) => ReactNode;
}
-const eye = (l: ReactNode, r: ReactNode = l) => {
- const EyePair = (dx: number) => (
- <g>
- <g transform={`translate(${-dx}, 0)`}>{l}</g>
- <g transform={`translate(${dx}, 0)`}>{r}</g>
- </g>
+const eye = (l: (c: string) => ReactNode, r?: (c: string) => ReactNode) => {
+ const rFn = r ?? l;
+ const EyePair = (dx: number, c = DEFAULT_FACE_COLOR) => (
+ <g>
+ <g transform={`translate(${-dx}, 0)`}>{l(c)}</g>
+ <g transform={`translate(${dx}, 0)`}>{rFn(c)}</g>
+ </g>
);
EyePair.displayName = "EyePair";
return EyePair;
};
export const Eyes: Record<string, EyeDef> = {
- dots: { name: "Dots", render: eye(<circle cx="0" cy="0" r="4.5" {...fp} />) },
+ dots: {
+ name: "Dots",
+ render: eye((c) => <circle cx="0" cy="0" r="5" fill={c} />),
+ },
big: {
name: "Big",
- render: eye(
+ render: eye((c) => (
<g>
- <circle cx="0" cy="0" r="7" {...sp(SW_FACE - 1)} />
- <circle cx="2" cy="-2" r="2" {...fp} />
+ <circle cx="0" cy="0" r="7.5" fill={c} />
+ <circle cx="2" cy="-2" r="2.5" fill="rgba(255,255,255,0.9)" />
</g>
- ),
+ )),
+ },
+ rings: {
+ name: "Rings",
+ render: eye((c) => <ellipse cx="0" cy="0" rx="6" ry="7" fill="none" stroke={c} strokeWidth="3.5" />),
+ },
+ arches: {
+ name: "Arches",
+ render: eye((c) => <path d="M-7 2 Q0 -6 7 2" fill="none" stroke={c} strokeWidth="4" strokeLinecap="round" />),
+ },
+ lines: {
+ name: "Lines",
+ render: eye((c) => <path d="M-7 0 Q0 -4 7 0" fill="none" stroke={c} strokeWidth="4" strokeLinecap="round" />),
+ },
+ happy: {
+ name: "Happy",
+ render: eye((c) => <path d="M-7 4 Q0 -8 7 4" fill="none" stroke={c} strokeWidth="4" strokeLinecap="round" />),
+ },
+ sleepy: {
+ name: "Sleepy",
+ render: eye((c) => <path d="M-7 -2 Q0 6 7 -2" fill="none" stroke={c} strokeWidth="4" strokeLinecap="round" />),
},
- rings: { name: "Rings", render: eye(<circle cx="0" cy="0" r="5" {...lpf(SW_FACE - 1)} />) },
- arches: { name: "Arches", render: eye(<path d="M-7 3 Q0 -7 7 3" {...lpf(SW_FACE)} />) },
- lines: { name: "Lines", render: eye(<line x1="-7" y1="0" x2="7" y2="0" {...lpf(SW_FACE)} />) },
- happy: { name: "Happy", render: eye(<path d="M-7 3 L0 -5 L7 3" {...lpf(SW_FACE)} />) },
- sleepy: { name: "Sleepy", render: eye(<path d="M-7 -2 Q0 6 7 -2" {...lpf(SW_FACE)} />) },
shy: {
name: "Shy",
- render: eye(<path d="M-6 -3 A6 6 0 0 1 6 -3 L6 1 A6 6 0 0 1 -6 1 Z" {...fp} />),
+ render: eye((c) => <ellipse cx="0" cy="0" rx="6" ry="7" fill={c} />),
},
wink: {
name: "Wink",
- render: (dx: number) => (
+ render: (dx: number, c = DEFAULT_FACE_COLOR) => (
<g>
- <g transform={`translate(${-dx}, 0)`}><circle cx="0" cy="0" r="4.5" {...fp} /></g>
- <g transform={`translate(${dx}, 0)`}><path d="M-7 1 Q0 -6 7 1" {...lpf(SW_FACE)} /></g>
+ <g transform={`translate(${-dx}, 0)`}><circle cx="0" cy="0" r="5" fill={c} /></g>
+ <g transform={`translate(${dx}, 0)`}><path d="M-7 2 Q0 -6 7 2" fill="none" stroke={c} strokeWidth="4" strokeLinecap="round" /></g>
</g>
),
},
@@ -283,10 +293,13 @@ interface AvatarRendererProps {
}
export function AvatarRenderer({ config, size = 200, className }: AvatarRendererProps) {
+ const uid = useId().replace(/:/g, "");
const sh = Shapes[config.shape] ?? Shapes.book!;
const ey = Eyes[config.eye];
const no = Noses[config.nose];
- const bgColor = BG_COLORS[config.bg]?.value ?? BG_COLORS[0]!.value;
+ const bgEntry = BG_COLORS[config.bg] ?? BG_COLORS[0]!;
+ const [g0, g1, g2] = bgEntry.gradient;
+ const faceColor = bgEntry.faceColor;
const { cx, cy, w } = sh.face;
const eyeDx = Math.max(11, w * 0.22);
@@ -300,11 +313,26 @@ export function AvatarRenderer({ config, size = 200, className }: AvatarRenderer
className={className}
style={{ display: "block" }}
>
- <rect x="0" y="0" width="200" height="200" rx="56" fill={bgColor} />
- <g transform="translate(100,100) scale(0.85) translate(-100,-100)">
- <g data-avatar-shape="">{sh.render()}</g>
- {ey && <g transform={`translate(${cx}, ${eyeY})`}><g data-avatar-eyes="">{ey.render(eyeDx)}</g></g>}
- {no && <g transform={`translate(${cx}, ${cy + 5})`}><g data-avatar-nose="">{no.render()}</g></g>}
+ <defs>
+ <linearGradient id={`bg-${uid}`} x1="0%" y1="0%" x2="100%" y2="100%">
+ <stop offset="0%" stopColor={g0} />
+ <stop offset="50%" stopColor={g1} />
+ <stop offset="100%" stopColor={g2} />
+ </linearGradient>
+ <radialGradient id={`gl-${uid}`} cx="30%" cy="25%" r="60%">
+ <stop offset="0%" stopColor="rgba(255,255,255,0.32)" />
+ <stop offset="100%" stopColor="rgba(255,255,255,0)" />
+ </radialGradient>
+ <filter id={`sh-${uid}`} x="-10%" y="-5%" width="120%" height="130%">
+ <feDropShadow dx="0" dy="3" stdDeviation="4" floodColor="rgba(0,0,0,0.18)" />
+ </filter>
+ </defs>
+ <rect x="0" y="0" width="200" height="200" rx="56" fill={`url(#bg-${uid})`} />
+ <rect x="0" y="0" width="200" height="200" rx="56" fill={`url(#gl-${uid})`} />
+ <g transform="translate(100,100) scale(0.8) translate(-100,-100)">
+ <g data-avatar-shape="" filter={`url(#sh-${uid})`}>{sh.render()}</g>
+ {ey && <g transform={`translate(${cx}, ${eyeY})`}><g data-avatar-eyes="">{ey.render(eyeDx, faceColor)}</g></g>}
+ {no && <g transform={`translate(${cx}, ${cy + 5})`}><g data-avatar-nose="">{no.render(faceColor)}</g></g>}
</g>
</svg>
);
@@ -335,7 +363,6 @@ export function parseAvatarUrl(avatarUrl: string | null | undefined): AvatarConf
try {
const parsed = JSON.parse(avatarUrl.slice(AVATAR_PREFIX.length));
if (isValidAvatarConfig(parsed)) return parsed;
- // Fallback for old format (had "outline"/"eyes"/"bgColor" fields)
if (typeof parsed === "object" && parsed !== null && "outline" in parsed) {
return DEFAULT_CONFIG;
}
diff --git a/src/web/src/components/issues/issue-sheet.tsx b/src/web/src/components/issues/issue-sheet.tsx
new file mode 100644
index 000000000..cb344fc4a
--- /dev/null
+++ b/src/web/src/components/issues/issue-sheet.tsx
@@ -0,0 +1,655 @@
+"use client";
+
+import { useCallback, useEffect, useRef, useState } from "react";
+import {
+ Sheet,
+ SheetContent,
+ SheetTitle,
+ SheetBody,
+ SheetFooter,
+} from "@/components/ui/sheet";
+import { Button } from "@/components/ui/button";
+import { MarkdownEditor } from "@/components/ui/markdown-editor";
+import { Skeleton } from "@/components/ui/skeleton";
+import { Textarea } from "@/components/ui/textarea";
+import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover";
+import {
+ Check,
+ CircleDot,
+ File as FileIcon,
+ GitBranch,
+ Loader2,
+ MessageSquare,
+ Trash2,
+ User,
+} from "lucide-react";
+import Link from "next/link";
+import { cn } from "@/lib/utils";
+import { toast } from "sonner";
+import { Streamdown } from "streamdown";
+import type { Agent, Artifact, Issue, IssueComment, Message, TaskApi } from "@alook/shared";
+import { isTerminalIssueStatus } from "@alook/shared";
+import { AvatarRenderer, parseAvatarUrl } from "@/components/avatar";
+
+// --- Constants ---
+
+const MIN_WIDTH = 320;
+const MAX_WIDTH_RATIO = 0.8;
+
+const GHOST_CONTROL =
+ "h-7 border-0 bg-transparent px-1.5 text-xs text-foreground hover:bg-accent transition-colors -ml-1.5";
+
+const GHOST_SELECT = cn(
+ GHOST_CONTROL,
+ "rounded-md outline-none focus-visible:bg-accent focus-visible:ring-0 appearance-none pr-6"
+);
+
+const SELECTOR_STATUSES = ["todo", "in_progress", "review", "done"] as const;
+
+function statusLabel(status: string) {
+ if (status === "done") return "Complete";
+ return status.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
+}
+
+// --- Sub-components ---
+
+function AgentAvatar({ agent, size = 24 }: { agent?: Agent | null; size?: number }) {
+ const avatarConfig = parseAvatarUrl(agent?.avatar_url);
+ if (avatarConfig) {
+ return <AvatarRenderer config={avatarConfig} size={size} className="shrink-0 rounded-full" />;
+ }
+ return (
+ <span
+ className="flex shrink-0 items-center justify-center rounded-full border border-border bg-muted text-[11px] font-medium text-muted-foreground"
+ style={{ width: size, height: size }}
+ >
+ {(agent?.name ?? "?").slice(0, 1).toUpperCase()}
+ </span>
+ );
+}
+
+function AgentIdentity({ agent, size = 24 }: { agent: Agent; size?: number }) {
+ const email = agent.email_handle ? `${agent.email_handle}@alook.ai` : "";
+ return (
+ <div className="flex min-w-0 items-center gap-2">
+ <AgentAvatar agent={agent} size={size} />
+ <div className="flex min-w-0 flex-1 items-center gap-1.5">
+ <div className="truncate text-xs font-medium">{agent.name}</div>
+ {email ? <div className="truncate text-[11px] text-muted-foreground">{email}</div> : null}
+ </div>
+ </div>
+ );
+}
+
+interface PropertyRowProps {
+ icon?: React.ReactNode;
+ children: React.ReactNode;
+}
+
+function PropertyRow({ icon, children }: PropertyRowProps) {
+ return (
+ <div className="group flex items-center gap-2">
+ <span className="inline-flex size-6 shrink-0 items-center justify-center text-muted-foreground">
+ {icon}
+ </span>
+ <div className="flex min-w-0 flex-wrap items-center gap-1">{children}</div>
+ </div>
+ );
+}
+
+function MessageRow({ message }: { message: Message }) {
+ if (message.role === "event") {
+ return (
+ <div className="rounded-md border bg-muted/50 text-muted-foreground text-xs px-3 py-2">
+ {message.content}
+ </div>
+ );
+ }
+ return (
+ <div className="rounded-lg border border-border/60 bg-background/55 p-3">
+ <div className="mb-1 flex items-center justify-between gap-2 text-xs text-muted-foreground">
+ <span className="capitalize">{message.role}</span>
+ <span>{new Date(message.created_at).toLocaleString()}</span>
+ </div>
+ <div className="prose prose-sm dark:prose-invert max-w-none text-sm break-words">
+ <Streamdown>{message.content}</Streamdown>
+ </div>
+ </div>
+ );
+}
+
+function CommentRow({ comment, agents }: { comment: IssueComment; agents: Agent[] }) {
+ const authorLabel = comment.author_type === "agent"
+ ? agents.find((a) => a.id === comment.author_id)?.name ?? "Agent"
+ : "You";
+ return (
+ <div className="rounded-lg border border-border/60 bg-background p-3">
+ <div className="mb-1 flex items-center justify-between gap-2 text-xs text-muted-foreground">
+ <span className="font-medium">{authorLabel}</span>
+ <span>{new Date(comment.created_at).toLocaleString()}</span>
+ </div>
+ <div className="prose prose-sm dark:prose-invert max-w-none text-sm break-words">
+ <Streamdown>{comment.content}</Streamdown>
+ </div>
+ </div>
+ );
+}
+
+function AttachmentList({ artifacts, workspaceId }: { artifacts: Artifact[]; workspaceId: string }) {
+ if (artifacts.length === 0) return null;
+ return (
+ <div className="space-y-1">
+ {artifacts.map((artifact) => (
+ <a
+ key={artifact.id}
+ href={`/api/artifacts/${artifact.id}/content?workspace_id=${workspaceId}&download=1`}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="flex items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-accent"
+ >
+ <FileIcon className="size-3.5 shrink-0 text-muted-foreground" />
+ <span className="min-w-0 flex-1 truncate">{artifact.filename}</span>
+ <span className="shrink-0 text-xs text-muted-foreground">
+ {artifact.size < 1024
+ ? `${artifact.size} B`
+ : artifact.size < 1024 * 1024
+ ? `${(artifact.size / 1024).toFixed(1)} KB`
+ : `${(artifact.size / (1024 * 1024)).toFixed(1)} MB`}
+ </span>
+ </a>
+ ))}
+ </div>
+ );
+}
+
+// --- Main component ---
+
+export interface IssueSheetProps {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ agents: Agent[];
+ issue?: Issue | null;
+ detail?: { messages: Message[]; comments: IssueComment[]; artifacts: Artifact[]; traceId?: string | null } | null;
+ detailLoading?: boolean;
+ activeTask?: TaskApi | null;
+ taskLatestText?: string;
+ submitting?: boolean;
+ saving?: boolean;
+ deleting?: boolean;
+ defaultAgentId?: string;
+ slug: string;
+ workspaceId: string;
+ width?: number;
+ onWidthChange?: (width: number) => void;
+ draft?: { title: string; description: string; agentId: string };
+ onDraftChange?: (draft: { title: string; description: string; agentId: string }) => void;
+ onCreate?: (values: { agent_id?: string; title: string; description: string }) => Promise<void>;
+ onUpdate?: (issueId: string, patch: { title?: string; description?: string }) => Promise<void>;
+ onStatusChange?: (issueId: string, status: string) => Promise<void>;
+ onDelete?: (issueId: string) => void;
+ onCommented?: () => void;
+}
+
+export function IssueSheet({
+ open,
+ onOpenChange,
+ agents,
+ issue,
+ detail,
+ detailLoading,
+ activeTask,
+ taskLatestText,
+ submitting,
+ saving,
+ deleting,
+ defaultAgentId,
+ slug,
+ workspaceId,
+ width = 448,
+ onWidthChange,
+ draft,
+ onDraftChange,
+ onCreate,
+ onUpdate,
+ onStatusChange,
+ onDelete,
+ onCommented,
+}: IssueSheetProps) {
+ const mode = issue ? "detail" : "create";
+
+ // Local editing state
+ const [title, setTitle] = useState("");
+ const [description, setDescription] = useState("");
+ const [agentId, setAgentId] = useState(defaultAgentId ?? "");
+ const [assigneeOpen, setAssigneeOpen] = useState(false);
+ const [commentContent, setCommentContent] = useState("");
+ const [commentSubmitting, setCommentSubmitting] = useState(false);
+
+ const titleRef = useRef<HTMLTextAreaElement>(null);
+ const descriptionRef = useRef<HTMLDivElement>(null);
+ const timelineRef = useRef<HTMLDivElement>(null);
+ const dragging = useRef(false);
+
+ const isTaskActive = activeTask && !["completed", "failed", "cancelled", "superseded"].includes(activeTask.status);
+
+ // Seed state on open/issue change
+ useEffect(() => {
+ if (!open) return;
+ if (issue) {
+ setTitle(issue.title);
+ setDescription(issue.description ?? "");
+ } else {
+ setTitle(draft?.title ?? "");
+ setDescription(draft?.description ?? "");
+ setAgentId(draft?.agentId ?? defaultAgentId ?? "");
+ }
+ }, [open, issue?.id]); // eslint-disable-line react-hooks/exhaustive-deps
+
+ // Sync draft to parent (create mode only)
+ useEffect(() => {
+ if (mode !== "create" || !open) return;
+ onDraftChange?.({ title, description, agentId });
+ }, [title, description, agentId, mode, open]); // eslint-disable-line react-hooks/exhaustive-deps
+
+ // Auto-scroll timeline
+ useEffect(() => {
+ if (timelineRef.current) {
+ timelineRef.current.scrollTop = timelineRef.current.scrollHeight;
+ }
+ }, [detail?.messages?.length, detail?.comments?.length]);
+
+ // Dirty tracking (detail mode)
+ const dirty = mode === "detail" && issue
+ ? title !== issue.title || description !== (issue.description ?? "")
+ : false;
+
+ // --- Title auto-resize ---
+ const resizeTitle = useCallback((el?: HTMLTextAreaElement | null) => {
+ const target = el ?? titleRef.current;
+ if (!target) return;
+ target.style.height = "auto";
+ target.style.height = `${target.scrollHeight}px`;
+ }, []);
+
+ useEffect(() => {
+ requestAnimationFrame(() => resizeTitle());
+ }, [title, resizeTitle]);
+
+ // --- Drag handle ---
+ const onPointerDown = useCallback((e: React.PointerEvent) => {
+ e.preventDefault();
+ dragging.current = true;
+ (e.target as HTMLElement).setPointerCapture(e.pointerId);
+ }, []);
+
+ const onPointerMove = useCallback((e: React.PointerEvent) => {
+ if (!dragging.current) return;
+ const maxW = window.innerWidth * MAX_WIDTH_RATIO;
+ const newWidth = Math.min(maxW, Math.max(MIN_WIDTH, window.innerWidth - e.clientX));
+ onWidthChange?.(newWidth);
+ }, [onWidthChange]);
+
+ const onPointerUp = useCallback(() => {
+ dragging.current = false;
+ }, []);
+
+ // --- Handlers ---
+ const handleCreate = async () => {
+ if (!title.trim() || submitting) return;
+ await onCreate?.({ agent_id: agentId || undefined, title: title.trim(), description: description.trim() });
+ };
+
+ const handleSave = async () => {
+ if (!issue || !dirty || saving) return;
+ const patch: { title?: string; description?: string } = {};
+ if (title !== issue.title) patch.title = title.trim();
+ if (description !== (issue.description ?? "")) patch.description = description.trim();
+ await onUpdate?.(issue.id, patch);
+ };
+
+ const handleStatusChange = (newStatus: string) => {
+ if (!issue || newStatus === issue.status) return;
+ onStatusChange?.(issue.id, newStatus);
+ };
+
+ const handleCommentSubmit = async () => {
+ if (!commentContent.trim() || commentSubmitting || !issue) return;
+ setCommentSubmitting(true);
+ try {
+ const res = await fetch(`/api/issues/${issue.id}/comments?workspace_id=${workspaceId}`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ content: commentContent.trim() }),
+ });
+ if (!res.ok) throw new Error("Failed to send comment");
+ setCommentContent("");
+ onCommented?.();
+ } catch {
+ toast.error("Failed to send comment");
+ } finally {
+ setCommentSubmitting(false);
+ }
+ };
+
+ // Shift+Enter capture handler (skip when inside comment textarea)
+ const commentRef = useRef<HTMLTextAreaElement>(null);
+ const onKeyDownCapture = useCallback((e: React.KeyboardEvent) => {
+ if (e.key === "Enter" && e.shiftKey) {
+ if (commentRef.current && commentRef.current.contains(e.target as Node)) return;
+ e.preventDefault();
+ e.stopPropagation();
+ if (mode === "create") handleCreate();
+ else handleSave();
+ }
+ }, [mode, title, description, agentId, issue, dirty, submitting, saving]); // eslint-disable-line react-hooks/exhaustive-deps
+
+ // Enter on title → focus description
+ const onTitleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
+ if (e.key === "Enter" && !e.shiftKey) {
+ e.preventDefault();
+ const editor = descriptionRef.current?.querySelector('[contenteditable="true"]') as HTMLElement | null;
+ editor?.focus();
+ }
+ };
+
+ const selectedAgent = agents.find((a) => a.id === agentId) ?? null;
+ const detailAgent = issue?.agent_id ? agents.find((a) => a.id === issue.agent_id) ?? null : null;
+
+ return (
+ <Sheet open={open} onOpenChange={onOpenChange}>
+ <SheetContent
+ side="right"
+ showCloseButton={false}
+ className="data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border"
+ style={{ width: `min(${width}px, 100vw)`, maxWidth: "none" }}
+ >
+ {/* Resize drag handle */}
+ <div
+ onPointerDown={onPointerDown}
+ onPointerMove={onPointerMove}
+ onPointerUp={onPointerUp}
+ onLostPointerCapture={onPointerUp}
+ className="hidden sm:block absolute -left-px top-0 bottom-0 w-1.5 cursor-col-resize z-10 hover:bg-primary/20 active:bg-primary/30 transition-colors rounded-l-xl"
+ />
+
+ {/* Hidden accessible title */}
+ <SheetTitle className="sr-only">
+ {mode === "create" ? "New Issue" : (issue?.title ?? "Issue")}
+ </SheetTitle>
+
+ <div className="flex flex-1 min-h-0 flex-col" onKeyDownCapture={onKeyDownCapture}>
+ <SheetBody className="flex flex-col gap-0 p-0 overflow-hidden">
+ {/* Title */}
+ <div className="shrink-0 px-2 sm:px-3 pt-5 pb-1">
+ <textarea
+ ref={(el) => {
+ titleRef.current = el;
+ resizeTitle(el);
+ }}
+ value={title}
+ onChange={(e) => {
+ setTitle(e.target.value);
+ resizeTitle(e.target);
+ }}
+ onKeyDown={onTitleKeyDown}
+ placeholder={mode === "create" ? "New issue" : "Untitled"}
+ autoFocus={mode === "create"}
+ rows={1}
+ className="w-full resize-none overflow-hidden rounded-none border-0 bg-transparent px-0 py-1 font-news text-2xl md:text-3xl font-medium leading-[1.2] tracking-tight shadow-none outline-none focus-visible:border-0 focus-visible:ring-0 focus-visible:ring-offset-0 placeholder:text-muted-foreground/40 placeholder:font-normal"
+ />
+ </div>
+
+ {/* Properties */}
+ <div className="shrink-0 space-y-1.5 px-2 sm:px-3 py-2">
+ {/* Agent row */}
+ <PropertyRow icon={<User className="size-3.5" />}>
+ {mode === "create" ? (
+ <Popover open={assigneeOpen} onOpenChange={setAssigneeOpen}>
+ <PopoverTrigger
+ render={
+ <button
+ type="button"
+ disabled={submitting}
+ className={cn(GHOST_CONTROL, "flex items-center gap-1.5 rounded-md")}
+ />
+ }
+ >
+ {selectedAgent ? (
+ <span className="truncate">{selectedAgent.name}</span>
+ ) : (
+ <span className="text-muted-foreground/70">Unassigned</span>
+ )}
+ </PopoverTrigger>
+ <PopoverContent align="start" className="max-h-64 w-72 overflow-y-auto thin-scrollbar p-1">
+ <button
+ type="button"
+ onClick={() => { setAgentId(""); setAssigneeOpen(false); }}
+ className="flex w-full items-center justify-between gap-2 rounded-md px-2 py-2 text-left text-sm transition-colors hover:bg-accent hover:text-accent-foreground"
+ >
+ <span className="text-muted-foreground">None (unassigned)</span>
+ {!agentId ? <Check className="size-3.5 shrink-0" /> : null}
+ </button>
+ {agents.map((agent) => (
+ <button
+ key={agent.id}
+ type="button"
+ onClick={() => { setAgentId(agent.id); setAssigneeOpen(false); }}
+ className="flex w-full items-center justify-between gap-2 rounded-md px-2 py-2 text-left text-sm transition-colors hover:bg-accent hover:text-accent-foreground"
+ >
+ <AgentIdentity agent={agent} size={18} />
+ {agentId === agent.id ? <Check className="size-3.5 shrink-0" /> : null}
+ </button>
+ ))}
+ </PopoverContent>
+ </Popover>
+ ) : (
+ <span className="text-xs truncate">
+ {detailAgent ? detailAgent.name : <span className="text-muted-foreground/70">Unassigned</span>}
+ </span>
+ )}
+ </PropertyRow>
+
+ {/* Status row (detail mode only) */}
+ {mode === "detail" && issue && (
+ <PropertyRow icon={<CircleDot className="size-3.5" />}>
+ <select
+ value={issue.status}
+ onChange={(e) => handleStatusChange(e.target.value)}
+ className={GHOST_SELECT}
+ >
+ {SELECTOR_STATUSES.map((s) => (
+ <option key={s} value={s}>{statusLabel(s)}</option>
+ ))}
+ </select>
+ </PropertyRow>
+ )}
+
+ {/* Chat link row */}
+ {mode === "detail" && issue?.agent_id && issue?.conversation_id && (
+ <PropertyRow icon={<MessageSquare className="size-3.5" />}>
+ <Link
+ href={`/w/${slug}/agents/${issue.agent_id}?conv=${issue.conversation_id}${issue.latest_task_id ? `&task=${issue.latest_task_id}` : ""}`}
+ className={cn(GHOST_CONTROL, "inline-flex items-center rounded-md")}
+ >
+ Chat
+ </Link>
+ </PropertyRow>
+ )}
+
+ {/* Thread link row */}
+ {mode === "detail" && detail?.traceId && (
+ <PropertyRow icon={<GitBranch className="size-3.5" />}>
+ <Link
+ href={`/w/${slug}/threads/${detail.traceId}`}
+ className={cn(GHOST_CONTROL, "inline-flex items-center rounded-md")}
+ >
+ Thread
+ </Link>
+ </PropertyRow>
+ )}
+ </div>
+
+ {/* Description */}
+ <div
+ className={cn(
+ "px-2 sm:px-3 py-2",
+ mode === "create" ? "shrink-0" : "shrink-0 max-h-48 overflow-y-auto thin-scrollbar"
+ )}
+ ref={descriptionRef}
+ >
+ <MarkdownEditor
+ key={issue?.id ?? "new"}
+ value={description}
+ onChange={setDescription}
+ placeholder="Describe the issue..."
+ minHeight={mode === "create" ? "10rem" : "4rem"}
+ variant="seamless"
+ contentType="markdown"
+ agents={agents}
+ />
+ </div>
+
+ {/* Attachments (detail mode) */}
+ {mode === "detail" && detail?.artifacts && detail.artifacts.length > 0 && (
+ <div className="shrink-0 px-2 sm:px-3 py-2">
+ <AttachmentList artifacts={detail.artifacts} workspaceId={workspaceId} />
+ </div>
+ )}
+
+ {/* Timeline (detail mode only) */}
+ {mode === "detail" && (
+ <div
+ ref={timelineRef}
+ className="flex-1 min-h-0 overflow-y-auto thin-scrollbar border rounded-lg mx-2 sm:mx-3 mb-3 px-4 py-4 space-y-3"
+ >
+ {detailLoading ? (
+ <div className="space-y-3">
+ <Skeleton className="h-12" />
+ <Skeleton className="h-8" />
+ <Skeleton className="h-12" />
+ </div>
+ ) : (() => {
+ const events = (detail?.messages ?? [])
+ .filter((m) => m.role === "event")
+ .map((m) => ({ kind: "event" as const, id: m.id, created_at: m.created_at, data: m }));
+ const comments = (detail?.comments ?? [])
+ .map((c) => ({ kind: "comment" as const, id: c.id, created_at: c.created_at, data: c }));
+ const timeline = [...events, ...comments].sort(
+ (a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime()
+ );
+
+ if (timeline.length === 0 && !isTaskActive) {
+ return <div className="text-xs text-muted-foreground">No activity yet.</div>;
+ }
+
+ return (
+ <div className="relative pl-4">
+ <div className="absolute left-[5px] top-2 bottom-2 w-px bg-border" />
+ <div className="space-y-3">
+ {timeline.map((item) => (
+ <div key={item.id} className="relative">
+ <div className="absolute -left-4 top-2.5 size-2.5 rounded-full border-2 border-background bg-muted-foreground/40" />
+ {item.kind === "event"
+ ? <MessageRow message={item.data} />
+ : <CommentRow comment={item.data} agents={agents} />}
+ </div>
+ ))}
+ {isTaskActive && (
+ <div className="relative">
+ <div className="absolute -left-4 top-2.5 size-2.5 rounded-full border-2 border-background bg-emerald-500 animate-pulse" />
+ <div className="rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2">
+ <div className="flex items-center gap-2 text-xs text-emerald-600 dark:text-emerald-400">Working</div>
+ {taskLatestText && <p className="mt-1 text-[11px] text-muted-foreground line-clamp-2">{taskLatestText}</p>}
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ );
+ })()}
+ </div>
+ )}
+
+ {/* Comment input (detail mode, non-terminal, no active task) */}
+ {mode === "detail" && issue && !isTaskActive && !isTerminalIssueStatus(issue.status) && (
+ <div className="shrink-0 px-2 sm:px-3 pb-3 space-y-2">
+ <Textarea
+ ref={commentRef}
+ placeholder="Leave a comment..."
+ value={commentContent}
+ onChange={(e) => setCommentContent(e.target.value)}
+ className="min-h-[60px] text-sm"
+ onKeyDown={(e) => { if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) handleCommentSubmit(); }}
+ />
+ <div className="flex justify-end">
+ <Button size="sm" onClick={handleCommentSubmit} disabled={!commentContent.trim() || commentSubmitting}>
+ {commentSubmitting ? "Sending..." : "Comment"}
+ </Button>
+ </div>
+ </div>
+ )}
+ </SheetBody>
+
+ {/* Footer */}
+ <SheetFooter className={cn(mode === "detail" && "sm:justify-between")}>
+ {mode === "create" ? (
+ <>
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => onOpenChange(false)}
+ disabled={submitting}
+ >
+ Cancel
+ </Button>
+ <Button
+ size="sm"
+ onClick={handleCreate}
+ disabled={!title.trim() || submitting}
+ >
+ {submitting && <Loader2 className="mr-1.5 size-3.5 animate-spin" />}
+ <kbd className="mr-1 hidden sm:inline-flex items-center gap-0.5 font-sans font-medium leading-none opacity-60">
+ <span>&#x21E7;</span><span>+</span><span>&#x23CE;</span>
+ </kbd>
+ Create
+ </Button>
+ </>
+ ) : (
+ <>
+ <Button
+ variant="destructive"
+ size="sm"
+ onClick={() => issue && onDelete?.(issue.id)}
+ disabled={deleting || saving}
+ >
+ <Trash2 className="mr-1.5 size-3.5" />
+ Delete
+ </Button>
+ <div className="flex gap-2">
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => onOpenChange(false)}
+ >
+ Cancel
+ </Button>
+ <Button
+ size="sm"
+ onClick={handleSave}
+ disabled={!dirty || !title.trim() || saving}
+ >
+ {saving && <Loader2 className="mr-1.5 size-3.5 animate-spin" />}
+ <kbd className="mr-1 hidden sm:inline-flex items-center gap-0.5 font-sans font-medium leading-none opacity-60">
+ <span>&#x21E7;</span><span>+</span><span>&#x23CE;</span>
+ </kbd>
+ Save
+ </Button>
+ </div>
+ </>
+ )}
+ </SheetFooter>
+ </div>
+ </SheetContent>
+ </Sheet>
+ );
+}