Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
feat: send welcome email on agent creation and show email animation in chat
Generee5286062a28
diff --git a/src/web/src/app/(app)/w/[slug]/runtimes/page.tsx b/src/web/src/app/(app)/w/[slug]/runtimes/page.tsxindex 94dcb436e..ace0a9acd 100644--- a/src/web/src/app/(app)/w/[slug]/runtimes/page.tsx+++ b/src/web/src/app/(app)/w/[slug]/runtimes/page.tsx@@ -331,17 +331,14 @@ export default function RuntimesPage() {<div className="flex-1 overflow-y-auto px-5 py-5">{runtimes.length === 0 ? (- <div className="flex flex-1 items-center justify-center py-12">+ <div className="flex flex-1 items-center justify-center min-h-[60vh]"><div className="text-center animate-[fade-up_400ms_ease-out_both]"><p className="text-muted-foreground text-sm">- No machines connected.- </p>- <p className="text-xs text-muted-foreground mt-2 max-w-xs mx-auto">Connect a machine to start running agents locally.</p><Buttonsize="sm"- className="mt-5"+ className="mt-4 glow-border"onClick={() => {setGeneratedToken("");setSheetOpen(true);diff --git a/src/web/src/app/api/agents/route.ts b/src/web/src/app/api/agents/route.tsindex d55704fbb..ab86c166e 100644--- a/src/web/src/app/api/agents/route.ts+++ b/src/web/src/app/api/agents/route.ts@@ -1,6 +1,6 @@import { NextRequest } from "next/server";import { getCloudflareContext } from "@opennextjs/cloudflare"-import { queries, isValidHandle, isOnline, CreateAgentRequestSchema } from "@alook/shared"+import { queries, isValidHandle, isOnline, CreateAgentRequestSchema, TASK_TYPES } from "@alook/shared"import { getDb } from "@/lib/db"import { withAuth } from "@/lib/middleware/auth";import { withWorkspaceMember } from "@/lib/middleware/workspace";@@ -82,6 +82,29 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {await queries.whitelist.addWhitelist(db, newAgent.id, ws.workspaceId, ctx.email.toLowerCase());}+ // Send welcome email to owner+ if (newAgent.runtimeId && newAgent.emailHandle && ctx.email && isOnline(runtime.machineLastSeenAt)) {+ try {+ const conv = await queries.conversation.createConversation(db, {+ workspaceId: ws.workspaceId,+ agentId: newAgent.id,+ userId: ctx.userId,+ title: `Welcome: ${ctx.email}`.slice(0, 50),+ type: TASK_TYPES.EMAIL_NOTIFICATION,+ });+ const taskService = new TaskService(db);+ await taskService.enqueueTask(+ newAgent.id,+ conv.id,+ ws.workspaceId,+ `You have just been created by your owner (${ctx.email}). Please send them a welcome email introducing yourself as "${name}". In the email: 1) Introduce yourself warmly — your name, your email address, and what you can help with. 2) Briefly introduce the Alook platform — a personal AI agent platform where agents can handle emails, schedule tasks, and work autonomously. 3) Let them know they can chat with you directly or email you anytime. Be warm, professional, and concise.`,+ TASK_TYPES.EMAIL_NOTIFICATION,+ );+ } catch {+ // Best-effort — don't fail agent creation+ }+ }+if (isOnline(runtime.machineLastSeenAt)) {const taskService = new TaskService(db);await taskService.reconcileAgentStatus(newAgent.id, ws.workspaceId);diff --git a/src/web/src/components/agent-chat/agent-chat-view.tsx b/src/web/src/components/agent-chat/agent-chat-view.tsxindex 0e6916ed5..ab2a61e52 100644--- a/src/web/src/components/agent-chat/agent-chat-view.tsx+++ b/src/web/src/components/agent-chat/agent-chat-view.tsx@@ -26,7 +26,7 @@ import { toast } from "sonner";import { cn } from "@/lib/utils";import { Skeleton } from "@/components/ui/skeleton";import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";-import { ArrowUp, Box, FileText, Loader2, Mic, Paperclip, RotateCcw, Square, X } from "lucide-react";+import { ArrowUp, Box, FileText, Loader2, Mail, Mic, Paperclip, RotateCcw, Square, X } from "lucide-react";import { useSpeechRecognition } from "@/hooks/use-speech-recognition";import { ArtifactSheet, formatSize } from "@/components/agent-chat/artifact-sheet";import { isPreviewable, getArtifactUrl } from "@/components/artifact-content-renderer";@@ -157,7 +157,7 @@ function PendingFileChips({export function AgentChatView() {const params = useParams();const { workspaceId } = useWorkspace();- const { subscribeWs } = useAgentContext();+ const { agents, activeTaskCounts, subscribeWs } = useAgentContext();const agentId = params.id as string;const [conversation, setConversation] = useState<Conversation | null>(null);@@ -838,11 +838,37 @@ export function AgentChatView() {</div>)}- {messages.length === 0 && !activeTask && (- <p className="text-center text-muted-foreground py-20 text-sm">- Send a message to start chatting with the agent.- </p>- )}+ {messages.length === 0 && !activeTask && (() => {+ const agent = agents.find(a => a.id === agentId);+ const isNewAgent = agent?.created_at && (Date.now() - new Date(agent.created_at).getTime() < 5 * 60 * 1000);+ const hasEmailTask = (activeTaskCounts[agentId] ?? 0) > 0;++ if (isNewAgent && hasEmailTask) {+ return (+ <div className="flex flex-col items-center justify-center py-20 gap-3 animate-[fade-up_400ms_ease-out_both]">+ <div className="relative animate-bounce">+ <Mail className="size-8 text-primary" />+ <span className="absolute -top-1 -right-1 flex size-3">+ <span className="animate-ping absolute inline-flex size-full rounded-full bg-primary/60" />+ <span className="relative inline-flex size-3 rounded-full bg-primary" />+ </span>+ </div>+ <p className="text-sm text-muted-foreground text-center max-w-xs">+ Your agent is sending you a welcome email.+ </p>+ <p className="text-xs text-muted-foreground/60 text-center max-w-xs">+ Wait for the email task in the top-left to complete, then check your inbox. Or send a message below to start chatting.+ </p>+ </div>+ );+ }++ return (+ <p className="text-center text-muted-foreground py-20 text-sm">+ Send a message to start chatting with the agent.+ </p>+ );+ })()}{timeline.map((item) => {if (item.kind === "artifact") {