Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat(chat): object-mimicry event cards + enriched event metadata + DM prompt improvements

Guse6e0889be440
diff --git a/src/cli/commands/sync.ts b/src/cli/commands/sync.ts
index b5709d7a6..b1c86fc9a 100644
--- a/src/cli/commands/sync.ts
+++ b/src/cli/commands/sync.ts
@@ -75,7 +75,7 @@ export function syncCommand(): Command {
process.exit(1);
}
} else {
- content = opts.message ?? "";
+ content = (opts.message ?? "").replace(/\\n/g, "\n").replace(/\\t/g, "\t");
}
if (!content.trim()) {
console.error("Error: --message or --message-file is required (and must not be empty)");
diff --git a/src/cli/daemon/execenv/context.ts b/src/cli/daemon/execenv/context.ts
index 82e68aff2..9c4cf1ec8 100644
--- a/src/cli/daemon/execenv/context.ts
+++ b/src/cli/daemon/execenv/context.ts
@@ -140,6 +140,7 @@ The CLI auto-detects your identity from the environment. No need to pass \`--age
### Command quick reference
| Capability | Command |
|---|---|
+| Send a message to the user | \`${cmdPrefix()} sync send-dm\` |
| Schedule / list / edit tasks | \`${cmdPrefix()} calendar set\` (also list, show, update, delete) |
| Upload a file for your owner | \`${cmdPrefix()} sync upload-artifact\` |
| Recruit a colleague agent | \`${cmdPrefix()} agent recruit\` |
@@ -225,11 +226,22 @@ Upload files for your owner to review in the app.
### Talking to the user
You're texting a colleague, not filing a report. The only thing the user sees is what you send with \`${cmdPrefix()} sync send-dm\` — your task output, reasoning, and tool calls are all off-screen. If you finish without sending, they got silence.
+\`${cmdPrefix()} sync send-dm\` sends a message to **the user** (your owner), not to a colleague agent. This is how you communicate with the human who gave you the task. Use email to talk to colleague agents.
+
Message at milestones, the way a person would: acknowledge when you pick something up, share a real step forward or a fork in the road, and deliver the result. A quick task is often one message; a long one is a few well-spaced check-ins. Trust your read of the moment — don't narrate every small step, and don't go dark for a long stretch on something they're waiting on.
Say what a colleague would say, not a transcript — the answer in your own voice. (Email- and calendar-triggered tasks have no one watching the chat; use email there.)
-\`${cmdPrefix()} sync send-dm --message "…"\` (or \`--message-file <path>\` for long/markdown). The conversation is in $ALOOK_CONVERSATION_ID, so you usually need no flags. You can send several times in one task.
+**A real person is waiting on the other end.** Send updates at every milestone of your work — not just the final result. For any task longer than a minute:
+1. **Before you start**: tell them your plan ("I'll research X, then modify Y and Z")
+2. **During work**: update when you find something important, change direction, or hit a blocker ("Found the issue — it's in the auth module, fixing now")
+3. **When done**: deliver the clear result
+
+Don't bundle everything into one giant message at the end. The user shouldn't have to sit in silence wondering what's happening. A one-line progress update costs nothing and keeps the human in the loop. But don't send repetitive or near-identical messages — each update should carry new information, not just restate what you already said.
+
+**If the user sends you a message while you're working** — especially questions like "are you there?", "what's the status?", or unrelated requests — **respond to them immediately**. Don't finish your current task first and then reply. The user reached out because they need your attention NOW. Acknowledge them right away, then resume your work.
+
+\`${cmdPrefix()} sync send-dm --message "…"\` for short messages. For longer or markdown-rich messages, write to a file first and use \`--message-file <path>\` — this preserves formatting and avoids shell escaping issues. The conversation is in $ALOOK_CONVERSATION_ID, so you usually need no flags. You can send several times in one task.
### Attachments
When your task includes attachments, their local paths are listed in the prompt JSON under "attachments".
diff --git a/src/cli/daemon/prompt.ts b/src/cli/daemon/prompt.ts
index 928f7512f..0ec372b46 100644
--- a/src/cli/daemon/prompt.ts
+++ b/src/cli/daemon/prompt.ts
@@ -2,9 +2,9 @@ import type { Task, Attachment } from "./types.js";
import { localISOString } from "./execenv/timeline.js";
const DM_RESPONSE_NOTICE =
- "Reply with `alook sync send-dm` — that's the only thing the user sees;" +
- " your task output and reasoning are not shown." +
- " Talk to them at milestones like a colleague would, and don't end your turn without sending what they need.";
+ "Reply with `alook sync send-dm` — that's the only thing the user sees; your task output and reasoning are not shown." +
+ " Talk to them at milestones like a colleague would, and don't end your turn without sending what they need." +
+ " If this task will take more than 30 seconds, send a quick ack first so the user knows you're on it.";
const EMAIL_NOTICE =
"This task was triggered automatically by an incoming email. There is no human in this session." +
diff --git a/src/web/src/app/api/calendar/route.ts b/src/web/src/app/api/calendar/route.ts
index 5c9521b14..39f026026 100644
--- a/src/web/src/app/api/calendar/route.ts
+++ b/src/web/src/app/api/calendar/route.ts
@@ -179,7 +179,12 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {
const conv = await queries.conversation.getConversation(db, body.conversation_id, ws.workspaceId);
if (conv) {
const eventContent = `${body.title}`;
- const metadata = JSON.stringify({ calendarEventId: created.id });
+ const metadata = JSON.stringify({
+ calendarEventId: created.id,
+ title: body.title,
+ scheduledAt: created.scheduledAt,
+ ...(created.repeatInterval ? { repeatInterval: created.repeatInterval } : {}),
+ });
const eventMsg = await queries.message.createMessage(db, {
conversationId: body.conversation_id,
role: "event",
@@ -196,7 +201,12 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {
content: eventMsg.content,
task_id: eventMsg.taskId,
attachment_ids: null,
- metadata: { calendarEventId: created.id },
+ metadata: {
+ calendarEventId: created.id,
+ title: body.title,
+ scheduledAt: created.scheduledAt,
+ ...(created.repeatInterval ? { repeatInterval: created.repeatInterval } : {}),
+ },
created_at: eventMsg.createdAt,
},
}).catch(() => { });
diff --git a/src/web/src/app/api/email/notify/route.ts b/src/web/src/app/api/email/notify/route.ts
index b81dc033a..2615dd20c 100644
--- a/src/web/src/app/api/email/notify/route.ts
+++ b/src/web/src/app/api/email/notify/route.ts
@@ -99,7 +99,7 @@ export async function POST(req: NextRequest) {
}
const prompt = `New email from ${body.from}: ${body.subject}`;
- const emailMetadata = JSON.stringify({ emailId: email.id });
+ const emailMetadata = JSON.stringify({ emailId: email.id, subject: body.subject, from: body.from, to: body.to, direction: "inbound" as const });
const msg = await queries.message.createMessage(db, {
conversationId,
role: "event",
@@ -118,7 +118,7 @@ export async function POST(req: NextRequest) {
content: msg.content,
task_id: msg.taskId,
attachment_ids: null,
- metadata: { emailId: email.id },
+ metadata: { emailId: email.id, subject: body.subject, from: body.from, to: body.to, direction: "inbound" },
created_at: msg.createdAt,
},
}).catch(() => {})
diff --git a/src/web/src/app/api/email/send/route.ts b/src/web/src/app/api/email/send/route.ts
index 5e34982d8..5619bdd5a 100644
--- a/src/web/src/app/api/email/send/route.ts
+++ b/src/web/src/app/api/email/send/route.ts
@@ -18,9 +18,11 @@ async function broadcastEmailSentEvent(
to: string,
subject: string,
emailId: string,
+ from: string,
) {
const eventContent = `Email sent to ${to}: ${subject}`;
- const metadata = JSON.stringify({ emailId });
+ const metadataObj = { emailId, subject, from, to, direction: "outbound" as const };
+ const metadata = JSON.stringify(metadataObj);
const eventMsg = await queries.message.createMessage(db, {
conversationId,
role: "event",
@@ -37,7 +39,7 @@ async function broadcastEmailSentEvent(
content: eventMsg.content,
task_id: eventMsg.taskId,
attachment_ids: null,
- metadata: { emailId },
+ metadata: metadataObj,
created_at: eventMsg.createdAt,
},
}).catch(() => {});
@@ -192,7 +194,7 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {
});
}
if (agent.ownerId) {
- await broadcastEmailSentEvent(db, validatedConversationId, agent.ownerId, body.agentId, body.to, body.subject, email.id);
+ await broadcastEmailSentEvent(db, validatedConversationId, agent.ownerId, body.agentId, body.to, body.subject, email.id, fromAddress);
}
}
@@ -269,7 +271,7 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {
});
}
if (agent.ownerId) {
- await broadcastEmailSentEvent(db, validatedConversationId, agent.ownerId, body.agentId, body.to, body.subject, email.id);
+ await broadcastEmailSentEvent(db, validatedConversationId, agent.ownerId, body.agentId, body.to, body.subject, email.id, fromAddress);
}
}
diff --git a/src/web/src/app/api/issues/[id]/route.ts b/src/web/src/app/api/issues/[id]/route.ts
index d8adf21f3..e9531aaed 100644
--- a/src/web/src/app/api/issues/[id]/route.ts
+++ b/src/web/src/app/api/issues/[id]/route.ts
@@ -96,7 +96,7 @@ export const PATCH = withAuth(async (req: NextRequest, ctx) => {
conversationId: conversation.id,
role: "event",
content: `Issue created: ${existing.title}`,
- metadata: JSON.stringify({ issueId: existing.id }),
+ metadata: JSON.stringify({ issueId: existing.id, title: existing.title, event: "created" as const, agentId: body.agent_id }),
});
const prompt = existing.description.trim()
@@ -132,7 +132,7 @@ export const PATCH = withAuth(async (req: NextRequest, ctx) => {
conversationId: conversation.id,
role: "event",
content: `Issue dispatch failed: ${taskErr instanceof Error ? taskErr.message : "unknown error"}`,
- metadata: JSON.stringify({ issueId: existing.id }),
+ metadata: JSON.stringify({ issueId: existing.id, title: existing.title, event: "dispatch_failed" as const }),
});
return writeError(taskErr instanceof Error ? taskErr.message : "failed to dispatch issue", 500);
}
@@ -150,7 +150,7 @@ export const PATCH = withAuth(async (req: NextRequest, ctx) => {
conversationId: existing.conversationId,
role: "event",
content: `Issue status changed: ${existing.status} -> ${body.status}`,
- metadata: JSON.stringify({ issueId: existing.id }),
+ metadata: JSON.stringify({ issueId: existing.id, title: existing.title, event: "status_changed" as const, fromStatus: existing.status, toStatus: body.status }),
});
broadcastToUser(ctx.userId, {
type: "conversation.message",
diff --git a/src/web/src/app/api/issues/route.ts b/src/web/src/app/api/issues/route.ts
index d982e6342..906babd62 100644
--- a/src/web/src/app/api/issues/route.ts
+++ b/src/web/src/app/api/issues/route.ts
@@ -182,7 +182,7 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {
role: "event",
content: `Issue created: ${created.title}`,
attachmentIds: artifactIds.length > 0 ? JSON.stringify(artifactIds) : null,
- metadata: JSON.stringify({ issueId: created.id }),
+ metadata: JSON.stringify({ issueId: created.id, title: created.title, event: "created" as const, agentId: body.agent_id }),
});
const prompt = buildIssuePrompt({
@@ -226,7 +226,7 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {
conversationId: conversation.id,
role: "event",
content: `Issue dispatch failed: ${taskErr instanceof Error ? taskErr.message : "unknown error"}`,
- metadata: JSON.stringify({ issueId: created.id }),
+ metadata: JSON.stringify({ issueId: created.id, title: created.title, event: "dispatch_failed" as const }),
});
return writeError(taskErr instanceof Error ? taskErr.message : "failed to dispatch issue", 500);
}
diff --git a/src/web/src/app/globals.css b/src/web/src/app/globals.css
index d0d84ea86..55a9d6c3e 100644
--- a/src/web/src/app/globals.css
+++ b/src/web/src/app/globals.css
@@ -88,6 +88,13 @@
--radius: 0.625rem;
--status-online: oklch(0.72 0.19 145);
--status-offline: oklch(0.65 0.2 25);
+ --te: oklch(0.55 0.1 250);
+ --ti: oklch(0.52 0.12 150);
+ --tc: oklch(0.57 0.15 28);
+ --tf: oklch(0.5 0.05 255);
+ --paper: oklch(0.97 0.005 80);
+ --e1: 0 1px 2px oklch(0.3 0.02 60 / 6%);
+ --e2: 0 10px 20px -6px oklch(0.3 0.02 60 / 18%);
--sidebar: oklch(0.98 0.005 80);
--sidebar-foreground: oklch(0.18 0.01 60);
--sidebar-primary: oklch(0.25 0.012 60);
@@ -127,6 +134,13 @@
--chart-5: oklch(0.27 0.01 60);
--status-online: oklch(0.75 0.18 145);
--status-offline: oklch(0.7 0.18 25);
+ --te: oklch(0.72 0.08 250);
+ --ti: oklch(0.75 0.12 150);
+ --tc: oklch(0.72 0.14 28);
+ --tf: oklch(0.72 0.05 255);
+ --paper: oklch(0.24 0.008 60);
+ --e1: 0 1px 3px oklch(0 0 0 / 15%);
+ --e2: 0 12px 24px -8px oklch(0 0 0 / 50%);
--sidebar: oklch(0.21 0.008 60);
--sidebar-foreground: oklch(0.93 0.006 80);
--sidebar-primary: oklch(0.488 0.243 264.376);
@@ -137,6 +151,23 @@
--sidebar-ring: oklch(0.55 0.01 60);
}
+/* ── Object-mimicry card grain texture (shared) ── */
+.card-grain {
+ position: relative;
+}
+@media (prefers-reduced-motion: reduce) {
+ .card-grain { transition: none !important; }
+}
+.card-grain::after {
+ content: "";
+ position: absolute;
+ inset: 0;
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
+ opacity: 0.03;
+ pointer-events: none;
+ mix-blend-mode: overlay;
+}
+
/* ── Homepage "1980s CRT Nostalgia" scoped tokens ── */
.landing {
--landing-bg: oklch(0.93 0.015 80);
diff --git a/src/web/src/components/agent-chat/chat-view-parts.tsx b/src/web/src/components/agent-chat/chat-view-parts.tsx
index 74e6a2a0c..31f63003e 100644
--- a/src/web/src/components/agent-chat/chat-view-parts.tsx
+++ b/src/web/src/components/agent-chat/chat-view-parts.tsx
@@ -1,7 +1,6 @@
"use client";
import React from "react";
-import { FileText } from "lucide-react";
import type { Artifact } from "@alook/shared";
import { useAgentContext } from "@/contexts/agent-context";
import { AgentPreviewCard } from "@/components/agent-preview-card";
@@ -10,8 +9,7 @@ import {
PopoverTrigger,
PopoverContent,
} from "@/components/ui/popover";
-import { SystemCard } from "@/components/agent-chat/message-list";
-import { formatSize } from "@/components/agent-chat/artifact-sheet";
+import { FileCard } from "@/components/agent-chat/event-cards/file-card";
function MentionHighlight(
props: Record<string, unknown> & { children?: React.ReactNode },
@@ -79,9 +77,6 @@ export function NapSeparator({ agentName }: { agentName: string }) {
);
}
-// Agent-side artifact (file) card — same shared SystemCard shell + card
-// language as the event cards (locked prototype: icon chip / FILE / filename /
-// size). The version badge rides along as the title's trailing element.
export function ArtifactCard({
artifact,
version,
@@ -94,18 +89,12 @@ export function ArtifactCard({
onClick: (a: Artifact) => void;
}) {
return (
- <SystemCard
- icon={FileText}
- label="FILE"
- title={artifact.filename}
- preview={formatSize(artifact.size)}
- trailing={
- hasDuplicates ? (
- <span className="shrink-0 text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5 font-normal">
- v{version}
- </span>
- ) : undefined
- }
+ <FileCard
+ filename={artifact.filename}
+ size={artifact.size}
+ contentType={artifact.content_type ?? undefined}
+ version={version}
+ hasDuplicates={hasDuplicates}
onClick={() => onClick(artifact)}
/>
);
diff --git a/src/web/src/components/agent-chat/event-cards/calendar-card.tsx b/src/web/src/components/agent-chat/event-cards/calendar-card.tsx
new file mode 100644
index 000000000..792aed332
--- /dev/null
+++ b/src/web/src/components/agent-chat/event-cards/calendar-card.tsx
@@ -0,0 +1,81 @@
+import React from "react";
+
+const REPEAT_LABELS: Record<string, string> = {
+ "1day": "Daily",
+ "1week": "Weekly",
+ "1month": "Monthly",
+};
+
+function humanizeRepeat(interval: string): string {
+ if (REPEAT_LABELS[interval]) return REPEAT_LABELS[interval];
+ const m = /^(\d+)(hour|day|week|month)s?$/.exec(interval);
+ if (m) return `Every ${m[1]} ${m[2]}${Number(m[1]) > 1 ? "s" : ""}`;
+ return interval;
+}
+
+export function CalendarCard({
+ title,
+ scheduledAt,
+ repeatInterval,
+ onClick,
+}: {
+ title: string;
+ scheduledAt?: string;
+ repeatInterval?: string;
+ onClick?: () => void;
+}) {
+ const date = scheduledAt ? new Date(scheduledAt) : null;
+ const dayOfWeek = date
+ ? date.toLocaleDateString("en-US", { weekday: "short" })
+ : null;
+ const monthStr = date
+ ? date.toLocaleDateString("en-US", { month: "short" })
+ : null;
+ const dayNum = date ? date.getDate() : null;
+ const timeStr = date
+ ? date.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" })
+ : null;
+
+ return (
+ <button
+ type="button"
+ onClick={onClick}
+ disabled={!onClick}
+ className="card-grain w-104 max-w-full overflow-hidden rounded-(--radius) border border-(--border) text-left cursor-pointer transition-[transform,box-shadow] duration-300 ease-out hover:-translate-y-0.5 [box-shadow:var(--e1)] hover:[box-shadow:var(--e2)]"
+ >
+ <span className="h-6 bg-(--tc) flex items-center px-3">
+ {date ? (
+ <span className="text-[0.62rem] font-semibold uppercase tracking-[0.06em] text-white/85">
+ {dayOfWeek} {monthStr} {dayNum}
+ </span>
+ ) : (
+ <span className="text-[0.62rem] font-semibold uppercase tracking-[0.06em] text-white/85">
+ Calendar
+ </span>
+ )}
+ {repeatInterval && (
+ <span className="ml-auto text-[0.52rem] font-semibold uppercase tracking-[0.04em] px-1 py-px rounded-full bg-white/20 text-white/90">
+ {humanizeRepeat(repeatInterval)}
+ </span>
+ )}
+ </span>
+ <span className="bg-(--paper) p-3 flex gap-3 items-start">
+ {dayNum != null && (
+ <span className="text-[1.8rem] font-bold leading-none tracking-[-0.02em] opacity-80 min-w-8 text-center shrink-0">
+ {dayNum}
+ </span>
+ )}
+ <span className="min-w-0 flex-1 flex flex-col">
+ <span className="text-[0.92rem] font-semibold tracking-[-0.01em] leading-[1.3]">
+ {title}
+ </span>
+ {timeStr && (
+ <span className="text-[0.72rem] text-(--muted-foreground) mt-1 font-mono">
+ {timeStr}
+ </span>
+ )}
+ </span>
+ </span>
+ </button>
+ );
+}
diff --git a/src/web/src/components/agent-chat/event-cards/email-card.tsx b/src/web/src/components/agent-chat/event-cards/email-card.tsx
new file mode 100644
index 000000000..b18bcf743
--- /dev/null
+++ b/src/web/src/components/agent-chat/event-cards/email-card.tsx
@@ -0,0 +1,54 @@
+import React from "react";
+
+export function EmailCard({
+ subject,
+ address,
+ direction,
+ onClick,
+}: {
+ subject: string;
+ address: string;
+ direction: "inbound" | "outbound";
+ onClick?: () => void;
+}) {
+ return (
+ <button
+ type="button"
+ onClick={onClick}
+ disabled={!onClick}
+ className="card-grain w-104 max-w-full overflow-hidden rounded-(--radius) border border-(--border) bg-(--paper) text-left flex flex-col cursor-pointer transition-[transform,box-shadow] duration-300 ease-out hover:-translate-y-0.5 [box-shadow:var(--e1)] hover:[box-shadow:var(--e2)]"
+ >
+ <span className="h-2.5 relative block">
+ <svg
+ viewBox="0 0 100 10"
+ preserveAspectRatio="none"
+ className="absolute inset-0 w-full h-full"
+ >
+ <path
+ d="M8,-1 L50,9 L92,-1"
+ stroke="var(--te)"
+ strokeWidth="2.5"
+ opacity="0.4"
+ fill="none"
+ strokeLinejoin="round"
+ strokeLinecap="round"
+ />
+ </svg>
+ </span>
+ <span className="p-3 flex flex-col">
+ <span className="flex items-center gap-1 mb-1">
+ <span className="text-[0.72rem] text-(--muted-foreground) flex-1 min-w-0 whitespace-nowrap overflow-hidden text-ellipsis">
+ {direction === "inbound" ? "from " : "to "}
+ {address}
+ </span>
+ <span className="shrink-0 text-[0.5rem] font-bold uppercase tracking-wider text-(--te) px-1 py-0.5 rounded-[3px] border-[1.5px] border-(--te) opacity-45 -rotate-3">
+ {direction === "inbound" ? "Inbound" : "Sent"}
+ </span>
+ </span>
+ <span className="text-[0.95rem] font-semibold tracking-[-0.01em] leading-[1.35] line-clamp-2">
+ {subject}
+ </span>
+ </span>
+ </button>
+ );
+}
diff --git a/src/web/src/components/agent-chat/event-cards/file-card.tsx b/src/web/src/components/agent-chat/event-cards/file-card.tsx
new file mode 100644
index 000000000..7f3b699de
--- /dev/null
+++ b/src/web/src/components/agent-chat/event-cards/file-card.tsx
@@ -0,0 +1,65 @@
+import React from "react";
+import { formatSize } from "@/components/agent-chat/artifact-sheet";
+
+function getExtension(filename: string, contentType?: string): string {
+ const dot = filename.lastIndexOf(".");
+ if (dot > -1) return filename.slice(dot + 1).toUpperCase();
+ if (contentType) {
+ const sub = contentType.split("/")[1];
+ if (sub) return sub.split(";")[0].toUpperCase();
+ }
+ return "FILE";
+}
+
+export function FileCard({
+ filename,
+ size,
+ contentType,
+ version,
+ hasDuplicates,
+ onClick,
+}: {
+ filename: string;
+ size: number;
+ contentType?: string;
+ version?: number;
+ hasDuplicates?: boolean;
+ onClick?: () => void;
+}) {
+ const ext = getExtension(filename, contentType);
+
+ return (
+ <button
+ type="button"
+ onClick={onClick}
+ disabled={!onClick}
+ className="card-grain w-104 max-w-full overflow-hidden rounded-(--radius) border border-(--border) bg-(--paper) text-left grid grid-cols-[44px_1fr] cursor-pointer transition-[transform,box-shadow] duration-300 ease-out hover:-translate-y-0.5 [box-shadow:var(--e1)] hover:[box-shadow:var(--e2)]"
+ >
+ <span className="flex flex-col items-center justify-center border-r border-(--border) bg-[oklch(from_var(--tf)_l_c_h/0.08)] gap-0.5 p-2">
+ <span className="flex flex-col gap-0.5 w-4.5">
+ <i className="h-[1.5px] rounded-sm bg-(--tf) opacity-[0.28] w-full" />
+ <i className="h-[1.5px] rounded-sm bg-(--tf) opacity-[0.28] w-[78%]" />
+ <i className="h-[1.5px] rounded-sm bg-(--tf) opacity-[0.28] w-[55%]" />
+ </span>
+ <span className="font-mono text-[0.44rem] font-semibold uppercase text-(--tf) mt-px tracking-[0.02em]">
+ {ext}
+ </span>
+ </span>
+ <span className="p-3 min-w-0 flex flex-col justify-center gap-0.5">
+ <span className="flex items-center gap-1.5 min-w-0">
+ <span className="text-[0.9rem] font-semibold tracking-[-0.01em] truncate">
+ {filename}
+ </span>
+ {hasDuplicates && version != null && (
+ <span className="shrink-0 text-xs text-(--muted-foreground) bg-(--muted) rounded-full px-1.5 py-0.5 font-normal">
+ v{version}
+ </span>
+ )}
+ </span>
+ <span className="text-[0.7rem] text-(--muted-foreground) font-mono">
+ {formatSize(size)}
+ </span>
+ </span>
+ </button>
+ );
+}
diff --git a/src/web/src/components/agent-chat/event-cards/issue-card.tsx b/src/web/src/components/agent-chat/event-cards/issue-card.tsx
new file mode 100644
index 000000000..02fbbe5df
--- /dev/null
+++ b/src/web/src/components/agent-chat/event-cards/issue-card.tsx
@@ -0,0 +1,69 @@
+import React from "react";
+
+const EVENT_LABELS: Record<string, string> = {
+ created: "Issue created",
+ status_changed: "Issue updated",
+ dispatch_failed: "Dispatch failed",
+};
+
+function stampText(
+ event: string,
+ toStatus?: string,
+): string | null {
+ if (event === "created") return "New";
+ if (event === "status_changed") return toStatus ?? "Done";
+ return null;
+}
+
+export function IssueCard({
+ title,
+ event,
+ fromStatus,
+ toStatus,
+ assigneeName,
+ onClick,
+}: {
+ title: string;
+ event: "created" | "status_changed" | "dispatch_failed";
+ fromStatus?: string;
+ toStatus?: string;
+ assigneeName?: string;
+ onClick?: () => void;
+}) {
+ const stamp = stampText(event, toStatus);
+ const meta =
+ event === "created" && assigneeName
+ ? `assigned to ${assigneeName}`
+ : event === "status_changed" && fromStatus && toStatus
+ ? `${fromStatus} → ${toStatus}`
+ : null;
+
+ return (
+ <button
+ type="button"
+ onClick={onClick}
+ disabled={!onClick}
+ className="card-grain w-104 max-w-full overflow-hidden rounded-(--radius) border border-(--border) bg-(--paper) text-left flex cursor-pointer transition-[transform,box-shadow] duration-300 ease-out hover:-translate-y-0.5 [box-shadow:var(--e1)] hover:[box-shadow:var(--e2)]"
+ >
+ <span className="w-1 bg-(--ti) shrink-0 self-stretch" />
+ <span className="flex-1 p-3 min-w-0 flex flex-col gap-1 relative">
+ <span className="text-[0.62rem] font-semibold uppercase tracking-wider text-(--ti) leading-none">
+ {EVENT_LABELS[event] ?? event}
+ </span>
+ <span className="text-[0.92rem] font-semibold tracking-[-0.01em] leading-[1.3] line-clamp-2 pr-8">
+ {title}
+ </span>
+ {meta && (
+ <span className="text-[0.75rem] text-(--muted-foreground) leading-[1.2]">
+ {meta}
+ </span>
+ )}
+ {stamp && (
+ <span className="absolute top-3 right-3 text-[0.5rem] font-bold uppercase tracking-wider text-(--ti) border-[1.5px] border-(--ti) opacity-45 rotate-[4deg] rounded-[3px] px-1 py-0.5">
+ {stamp}
+ </span>
+ )}
+ </span>
+ </button>
+ );
+}
diff --git a/src/web/src/components/agent-chat/message-list.tsx b/src/web/src/components/agent-chat/message-list.tsx
index c7f6940e5..f37e211c4 100644
--- a/src/web/src/components/agent-chat/message-list.tsx
+++ b/src/web/src/components/agent-chat/message-list.tsx
@@ -11,7 +11,10 @@ import { highlightMentions } from "@/lib/highlight-mentions";
import { TaskStream } from "@/components/task-stream";
import { RuntimeErrorBlock } from "@/components/agent-chat/runtime-error-block";
import { AnimatedAvatar, type AvatarConfig } from "@/components/avatar";
-import { FileText, Calendar, CircleDot, Mail, Flag, Copy, Check, ChevronRight } from "lucide-react";
+import { FileText, Flag, Copy, Check } from "lucide-react";
+import { EmailCard } from "@/components/agent-chat/event-cards/email-card";
+import { CalendarCard } from "@/components/agent-chat/event-cards/calendar-card";
+import { IssueCard } from "@/components/agent-chat/event-cards/issue-card";
import { eventTypeFromMessage, type GroupPosition } from "@/components/agent-chat/chat-message-utils";
import { toast } from "sonner";
@@ -76,120 +79,86 @@ export interface MessageItemProps {
onRetrySend?: (messageId: string) => void;
}
-/**
- * Shared visual shell for agent-side system cards (event + artifact). A tinted
- * icon chip, an uppercase label, a title line, and an OPTIONAL muted preview
- * line. Height follows content — a 2-line card (no preview) is genuinely
- * shorter; we never reserve a blank row to force parity (Gus). Hairline border,
- * quiet chevron, hover lift. Monochrome.
- */
-export function SystemCard({
- icon: Icon,
- label,
- title,
- preview,
- trailing,
- onClick,
-}: {
- icon: typeof Mail;
- label: string;
+type EmailData = {
+ type: "email";
+ subject: string;
+ address: string;
+ direction: "inbound" | "outbound";
+};
+type CalendarData = {
+ type: "calendar";
title: string;
- preview?: string | null;
- /** Optional inline element after the title (e.g. an artifact version badge). */
- trailing?: React.ReactNode;
- onClick?: () => void;
-}) {
- return (
- <button
- type="button"
- onClick={onClick}
- disabled={!onClick}
- className={cn(
- // Fixed footprint so email / issue / calendar / file cards are uniform
- // when stacked — width + height don't follow content (Gus, 2026-06-01).
- // h fits the 3-line variant; overflow-hidden + per-line truncate keep
- // any longer content from spilling past the fixed box.
- "group/card w-[26rem] max-w-full h-[4.75rem] overflow-hidden text-left rounded-md border bg-card",
- "flex items-center gap-3 px-3 py-2",
- onClick &&
- "cursor-pointer transition-all duration-150 hover:-translate-y-px hover:shadow-sm hover:border-foreground/15",
- )}
- >
- <span className="flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground">
- <Icon className="size-4" />
- </span>
- <span className="flex min-w-0 flex-1 flex-col gap-0.5">
- <span className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground/70">
- {label}
- </span>
- <span className="flex items-center gap-1.5 min-w-0">
- <span className="truncate text-sm font-medium text-foreground">{title}</span>
- {trailing}
- </span>
- {preview ? (
- <span className="truncate text-xs text-muted-foreground">{preview}</span>
- ) : null}
- </span>
- {onClick && (
- <ChevronRight className="size-4 shrink-0 self-center text-muted-foreground/40 transition-colors duration-150 group-hover/card:text-muted-foreground" />
- )}
- </button>
- );
-}
+ scheduledAt?: string;
+ repeatInterval?: string;
+};
+type IssueData = {
+ type: "issue";
+ title: string;
+ event: "created" | "status_changed" | "dispatch_failed";
+ fromStatus?: string;
+ toStatus?: string;
+ agentId?: string;
+};
+type EventData = EmailData | CalendarData | IssueData;
-// Parse the honest label / title / preview out of a system-event message. The
-// card describes the EVENT (an immutable historical fact), never live state —
-// so no "current status" pill. Preview is honest or omitted (Gus/Priya).
-// Email: "New email from {sender}: {subject}" | "Email sent to {recipient}: {subject}"
-// Issue: "Issue created/opened: {title}" | "Issue status changed: {X} -> {Y}"
-// Calendar: "{title}" (sometimes "Calendar event: {title}")
-function parseEventCard(
- type: "issue" | "email" | "calendar",
+function parseEventData(
+ metadata: Record<string, unknown> | null | undefined,
content: string,
-): { label: string; title: string; preview?: string } {
+ conversationType?: string | null,
+): EventData {
+ const type = eventTypeFromMessage(metadata, content, conversationType);
+
if (type === "email") {
+ if (metadata?.subject) {
+ return {
+ type: "email",
+ subject: metadata.subject as string,
+ address: (metadata.direction === "inbound" ? metadata.from : metadata.to) as string,
+ direction: metadata.direction as "inbound" | "outbound",
+ };
+ }
const sent = /^Email sent to (.+?): ([\s\S]+)$/.exec(content);
- if (sent) return { label: "EMAIL", title: sent[2], preview: `to ${sent[1]}` };
+ if (sent) return { type: "email", subject: sent[2], address: sent[1], direction: "outbound" };
const inbound = /^New email from (.+?): ([\s\S]+)$/.exec(content);
- if (inbound) return { label: "EMAIL", title: inbound[2], preview: `from ${inbound[1]}` };
+ if (inbound) return { type: "email", subject: inbound[2], address: inbound[1], direction: "inbound" };
const colon = content.indexOf(": ");
- return colon > -1
- ? { label: "EMAIL", title: content.slice(colon + 2) }
- : { label: "EMAIL", title: content };
+ return {
+ type: "email",
+ subject: colon > -1 ? content.slice(colon + 2) : content,
+ address: "",
+ direction: "inbound",
+ };
}
+
if (type === "issue") {
+ if (metadata?.event) {
+ return {
+ type: "issue",
+ title: (metadata.title as string) ?? content.replace(/^Issue (?:created|opened|status changed):?\s*/i, ""),
+ event: metadata.event as "created" | "status_changed" | "dispatch_failed",
+ fromStatus: metadata.fromStatus as string | undefined,
+ toStatus: metadata.toStatus as string | undefined,
+ agentId: metadata.agentId as string | undefined,
+ };
+ }
const status = /^Issue status changed: ([\s\S]+?) -> ([\s\S]+)$/.exec(content);
- // The status transition is the immutable event fact — show it as the preview.
- if (status) return { label: "ISSUE", title: "Status changed", preview: `Status: ${status[1]} → ${status[2]}` };
+ if (status) return { type: "issue", title: `${status[1]} → ${status[2]}`, event: "status_changed", fromStatus: status[1], toStatus: status[2] };
const created = /^Issue (?:created|opened): ([\s\S]+)$/.exec(content);
- if (created) return { label: "ISSUE", title: created[1] }; // 2-line: no honest preview
- return { label: "ISSUE", title: content.replace(/^Issue:?\s*/i, "") };
+ if (created) return { type: "issue", title: created[1], event: "created" };
+ if (/dispatch failed/i.test(content)) return { type: "issue", title: content.replace(/^Issue dispatch failed:?\s*/i, ""), event: "dispatch_failed" };
+ return { type: "issue", title: content.replace(/^Issue:?\s*/i, ""), event: "created" };
}
- // calendar — title only; strip a "Calendar event:" prefix if present. No
- // datetime/repeat preview unless it is later stamped into the message.
- return { label: "CALENDAR", title: content.replace(/^Calendar event:\s*/i, "") };
-}
-/**
- * System event (email / issue / calendar) as a clickable card. Type + icon are
- * metadata-driven (msg.metadata.{issueId,emailId,calendarEventId}), falling back
- * to the content heuristic only if metadata is absent.
- */
-function EventCard({
- content,
- metadata,
- conversationType,
- onClick,
-}: {
- content: string;
- metadata?: Record<string, unknown> | null;
- conversationType?: string | null;
- onClick?: () => void;
-}) {
- const type = eventTypeFromMessage(metadata, content, conversationType);
- const Icon = type === "issue" ? CircleDot : type === "email" ? Mail : Calendar;
- const { label, title, preview } = parseEventCard(type, content);
- return <SystemCard icon={Icon} label={label} title={title} preview={preview} onClick={onClick} />;
+ // calendar
+ if (metadata?.title) {
+ return {
+ type: "calendar",
+ title: metadata.title as string,
+ scheduledAt: metadata.scheduledAt as string | undefined,
+ repeatInterval: metadata.repeatInterval as string | undefined,
+ };
+ }
+ return { type: "calendar", title: content.replace(/^Calendar event:\s*/i, "") };
}
function AttachmentChips({
@@ -632,10 +601,19 @@ export const MessageItem = memo(function MessageItem({
: eventCalendarEventId
? () => onCalendarEventClick(eventCalendarEventId)
: undefined;
+ const data = parseEventData(msg.metadata, msg.content, conversationType);
+ let card: React.ReactNode;
+ if (data.type === "email") {
+ card = <EmailCard subject={data.subject} address={data.address} direction={data.direction} onClick={onClick} />;
+ } else if (data.type === "calendar") {
+ card = <CalendarCard title={data.title} scheduledAt={data.scheduledAt} repeatInterval={data.repeatInterval} onClick={onClick} />;
+ } else {
+ card = <IssueCard title={data.title} event={data.event} fromStatus={data.fromStatus} toStatus={data.toStatus} assigneeName={data.agentId ? agents.find(a => a.id === data.agentId)?.name : undefined} onClick={onClick} />;
+ }
return (
<div data-message-id={msg.id} {...(msg.task_id ? { "data-task-id": msg.task_id } : {})}>
<AgentRow groupPosition={groupPosition} agentName={agentName} config={agentAvatarConfig}>
- <EventCard content={msg.content} metadata={msg.metadata} conversationType={conversationType} onClick={onClick} />
+ {card}
</AgentRow>
</div>
);