Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat(calendar): enhance calendar event prompt with description/scheduled_by context and consolidate calendar UI components

Gus4c7d86017bf2
diff --git a/src/cli/daemon/prompt.test.ts b/src/cli/daemon/prompt.test.ts
index ded9b2472..cd4180b04 100644
--- a/src/cli/daemon/prompt.test.ts
+++ b/src/cli/daemon/prompt.test.ts
@@ -93,8 +93,65 @@ describe("buildPrompt", () => {
expect(parsed.notice).toContain("final text response is visible to the user");
});
- it("does not add notice for non-email non-dm tasks", () => {
- const task = makeTask("Check inbox", "calendar_event");
+ it("adds CALENDAR_NOTICE for calendar_event tasks with no context", () => {
+ const task = makeTask("Do the standup", "calendar_event");
+ const parsed = JSON.parse(buildPrompt(task));
+ expect(parsed.notice).toContain("scheduled calendar event");
+ expect(parsed.notice).toContain("no human in this session");
+ expect(parsed.notice).toContain("email sending tool");
+ expect(parsed.description).toBeUndefined();
+ expect(parsed.scheduled_by).toBeUndefined();
+ });
+
+ it("includes description and scheduled_by for calendar_event with full context", () => {
+ const task: Task = {
+ ...makeTask("Do the standup", "calendar_event"),
+ context: {
+ description: "Check PRs merged this week",
+ scheduled_by: { name: "Gus", email: "[email protected]" },
+ },
+ };
+ const parsed = JSON.parse(buildPrompt(task));
+ expect(parsed.notice).toContain("scheduled calendar event");
+ expect(parsed.description).toBe("Check PRs merged this week");
+ expect(parsed.scheduled_by).toEqual({ name: "Gus", email: "[email protected]" });
+ });
+
+ it("includes only description for calendar_event when scheduled_by is absent", () => {
+ const task: Task = {
+ ...makeTask("Do the standup", "calendar_event"),
+ context: { description: "Check PRs merged this week" },
+ };
+ const parsed = JSON.parse(buildPrompt(task));
+ expect(parsed.notice).toContain("scheduled calendar event");
+ expect(parsed.description).toBe("Check PRs merged this week");
+ expect(parsed.scheduled_by).toBeUndefined();
+ });
+
+ it("includes only scheduled_by for calendar_event when description is absent", () => {
+ const task: Task = {
+ ...makeTask("Do the standup", "calendar_event"),
+ context: { scheduled_by: { name: "Gus", email: "[email protected]" } },
+ };
+ const parsed = JSON.parse(buildPrompt(task));
+ expect(parsed.notice).toContain("scheduled calendar event");
+ expect(parsed.description).toBeUndefined();
+ expect(parsed.scheduled_by).toEqual({ name: "Gus", email: "[email protected]" });
+ });
+
+ it("omits description for calendar_event when description is empty string", () => {
+ const task: Task = {
+ ...makeTask("Do the standup", "calendar_event"),
+ context: { description: "", scheduled_by: { name: "Gus", email: "[email protected]" } },
+ };
+ const parsed = JSON.parse(buildPrompt(task));
+ expect(parsed.notice).toContain("scheduled calendar event");
+ expect(parsed.description).toBeUndefined();
+ expect(parsed.scheduled_by).toEqual({ name: "Gus", email: "[email protected]" });
+ });
+
+ it("does not add notice for unknown task types", () => {
+ const task = makeTask("Check inbox", "some_other_type");
const parsed = JSON.parse(buildPrompt(task));
expect(parsed.notice).toBeUndefined();
});
diff --git a/src/cli/daemon/prompt.ts b/src/cli/daemon/prompt.ts
index be41ca1ac..a332fb93b 100644
--- a/src/cli/daemon/prompt.ts
+++ b/src/cli/daemon/prompt.ts
@@ -11,6 +11,12 @@ const EMAIL_NOTICE =
" If you need more information or confirmation from the human, send them an email asking for it and then exit." +
" Do not wait — when the human replies, a new task will be triggered automatically and you will be woken up with their response.";
+const CALENDAR_NOTICE =
+ "This task was triggered by a scheduled calendar event. There is no human in this session." +
+ " If you need to communicate with a human, you MUST send an email using the email sending tool." +
+ " If you need more information or confirmation, send an email asking for it and then exit." +
+ " Do not wait — when the human replies, a new task will be triggered automatically and you will be woken up with their response.";
+
const ISSUE_NOTICE =
"This task was triggered by an assigned issue. The issue_id is provided in this message." +
" Use `alook issue show --issue_id <issue_id>` to read full context." +
@@ -45,6 +51,16 @@ export function buildPrompt(task: Task, attachments?: Attachment[]): string {
obj.notice = EMAIL_NOTICE;
}
}
+ if (task.type === "calendar_event") {
+ obj.notice = CALENDAR_NOTICE;
+ const ctx = task.context as Record<string, unknown> | undefined;
+ if (ctx?.description) {
+ obj.description = ctx.description;
+ }
+ if (ctx?.scheduled_by) {
+ obj.scheduled_by = ctx.scheduled_by;
+ }
+ }
if (task.type === "issue_event") {
obj.notice = ISSUE_NOTICE;
const ctx = task.context as Record<string, unknown> | undefined;
diff --git a/src/web/src/app/(app)/w/[slug]/calendar/page.tsx b/src/web/src/app/(app)/w/[slug]/calendar/page.tsx
index 4a1aa8736..9745be254 100644
--- a/src/web/src/app/(app)/w/[slug]/calendar/page.tsx
+++ b/src/web/src/app/(app)/w/[slug]/calendar/page.tsx
@@ -33,6 +33,7 @@ import { CalendarEventSheet } from "@/components/calendar/calendar-event-sheet";
import { getWeekStart, weekRangeIso } from "@/components/calendar/calendar-week-utils";
import type { CalendarEvent, UpdateCalendarEventRequest } from "@alook/shared";
import { isTypingTarget } from "@/components/calendar/keyboard";
+import { useIsMobile } from "@/hooks/use-mobile";
/**
* The month grid always renders six full weeks (42 cells), which means the
@@ -71,6 +72,7 @@ export default function CalendarPage() {
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
+ const isMobile = useIsMobile();
const now = new Date();
const initialYear = Number(searchParams.get("y")) || now.getFullYear();
@@ -512,15 +514,16 @@ export default function CalendarPage() {
setCreateOpen(true);
}}
disabled={agents.length === 0}
+ className="min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0"
>
<Plus className="size-3.5" />
- New event
+ <span className="hidden sm:inline">New event</span>
</Button>
</div>
</div>
<div className={cn(
- "flex flex-1 flex-col gap-4 px-5 py-5",
+ "flex flex-1 flex-col gap-4 px-3 py-3 sm:px-5 sm:py-5",
view === "week" ? "min-h-0 overflow-hidden" : "overflow-y-auto"
)}>
<CalendarAgentFilter
@@ -555,6 +558,7 @@ export default function CalendarPage() {
agents={agents}
loading={loading}
focusedDate={focusedDate}
+ compact={isMobile}
onPrevWeek={handlePrevWeek}
onNextWeek={handleNextWeek}
onJumpToToday={handleJumpToToday}
diff --git a/src/web/src/components/agent-chat/agent-chat-view.tsx b/src/web/src/components/agent-chat/agent-chat-view.tsx
index ac02fc920..e7afa3ff8 100644
--- a/src/web/src/components/agent-chat/agent-chat-view.tsx
+++ b/src/web/src/components/agent-chat/agent-chat-view.tsx
@@ -51,7 +51,7 @@ import { MentionPopup } from "@/components/agent-chat/mention-popup";
import { highlightMentions } from "@/lib/highlight-mentions";
import { ArtifactSheet, formatSize } from "@/components/agent-chat/artifact-sheet";
import { EmailEventSheet } from "@/components/agent-chat/email-event-sheet";
-import { CalendarEventDetailSheet } from "@/components/agent-chat/calendar-event-sheet";
+import { CalendarEventSheet } from "@/components/calendar/calendar-event-sheet";
import { IssueSheet } from "@/components/issues/issue-sheet";
import { isPreviewable, getArtifactUrl, computeArtifactVersions } from "@/components/artifact-content-renderer";
import { FollowUpBuffer } from "@/components/agent-chat/follow-up-buffer";
@@ -2116,7 +2116,8 @@ export function AgentChatView({
workspaceId={workspaceId}
/>
- <CalendarEventDetailSheet
+ <CalendarEventSheet
+ readonly
open={calendarEventSheetOpen}
onOpenChange={(v) => {
setCalendarEventSheetOpen(v);
diff --git a/src/web/src/components/agent-chat/calendar-event-sheet.tsx b/src/web/src/components/agent-chat/calendar-event-sheet.tsx
deleted file mode 100644
index fdc1dd85b..000000000
--- a/src/web/src/components/agent-chat/calendar-event-sheet.tsx
+++ /dev/null
@@ -1,137 +0,0 @@
-"use client";
-
-import React, { useState, useEffect, useRef, useCallback } from "react";
-import {
- Sheet,
- SheetContent,
- SheetHeader,
- SheetTitle,
- SheetBody,
-} from "@/components/ui/sheet";
-import { Button } from "@/components/ui/button";
-import { X, Calendar, Loader2 } from "lucide-react";
-import { toast } from "sonner";
-import { getCalendarEvent } from "@/lib/api";
-import type { CalendarEvent } from "@alook/shared";
-
-interface CalendarEventDetailSheetProps {
- open: boolean;
- onOpenChange: (open: boolean) => void;
- calendarEventId: string | null;
- workspaceId: string;
-}
-
-const MIN_WIDTH = 320;
-const MAX_WIDTH_RATIO = 0.8;
-const DEFAULT_WIDTH = 500;
-
-export function CalendarEventDetailSheet({ open, onOpenChange, calendarEventId, workspaceId }: CalendarEventDetailSheetProps) {
- const [event, setEvent] = useState<CalendarEvent | null>(null);
- const [loading, setLoading] = useState(false);
- const [width, setWidth] = useState(DEFAULT_WIDTH);
- const dragging = useRef(false);
- const onOpenChangeRef = useRef(onOpenChange);
- useEffect(() => { onOpenChangeRef.current = onOpenChange; });
-
- useEffect(() => {
- if (!open || !calendarEventId) return;
- setLoading(true);
- setEvent(null);
-
- getCalendarEvent(calendarEventId, workspaceId)
- .then(setEvent)
- .catch(() => {
- toast.error("Calendar event not found");
- onOpenChangeRef.current(false);
- })
- .finally(() => setLoading(false));
- }, [open, calendarEventId, workspaceId]);
-
- const handleOpenChange = (v: boolean) => {
- onOpenChange(v);
- if (!v) {
- setTimeout(() => setEvent(null), 300);
- }
- };
-
- 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;
- setWidth(Math.min(maxW, Math.max(MIN_WIDTH, window.innerWidth - e.clientX)));
- }, []);
-
- const onPointerUp = useCallback(() => {
- dragging.current = false;
- }, []);
-
- return (
- <Sheet open={open} onOpenChange={handleOpenChange}>
- <SheetContent
- side="right"
- showCloseButton={false}
- style={{ width: `min(${width}px, 100vw)`, maxWidth: "none" }}
- 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"
- >
- <div
- onPointerDown={onPointerDown}
- onPointerMove={onPointerMove}
- onPointerUp={onPointerUp}
- className="hidden sm:block absolute left-0 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>
- <div className="flex items-center gap-2">
- <Calendar className="h-4 w-4 shrink-0 text-muted-foreground" />
- <SheetTitle className="truncate flex-1">
- {loading ? "Loading..." : event?.title || "Calendar Event"}
- </SheetTitle>
- <Button variant="ghost" size="icon" className="h-7 w-7" onClick={() => handleOpenChange(false)}>
- <X className="h-4 w-4" />
- </Button>
- </div>
- </SheetHeader>
-
- <SheetBody className="flex-1 overflow-y-auto thin-scrollbar">
- {loading ? (
- <div className="flex items-center justify-center py-12">
- <Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
- </div>
- ) : event ? (
- <div className="flex flex-col gap-4">
- <div className="text-sm space-y-2 border-b pb-3">
- <div className="flex gap-2">
- <span className="text-muted-foreground shrink-0">Scheduled:</span>
- <span>{new Date(event.scheduled_at).toLocaleString()}</span>
- </div>
- {event.repeat_interval && (
- <div className="flex gap-2">
- <span className="text-muted-foreground shrink-0">Repeats:</span>
- <span>Every {event.repeat_interval}</span>
- </div>
- )}
- {event.repeat_stop_at && (
- <div className="flex gap-2">
- <span className="text-muted-foreground shrink-0">Until:</span>
- <span>{new Date(event.repeat_stop_at).toLocaleDateString()}</span>
- </div>
- )}
- </div>
-
- {event.description && (
- <div className="text-sm">
- <p className="text-muted-foreground mb-1">Description</p>
- <pre className="whitespace-pre-wrap font-sans">{event.description}</pre>
- </div>
- )}
- </div>
- ) : null}
- </SheetBody>
- </SheetContent>
- </Sheet>
- );
-}
diff --git a/src/web/src/components/calendar/calendar-agent-filter.tsx b/src/web/src/components/calendar/calendar-agent-filter.tsx
index 0712ac8e1..c0f0cab24 100644
--- a/src/web/src/components/calendar/calendar-agent-filter.tsx
+++ b/src/web/src/components/calendar/calendar-agent-filter.tsx
@@ -22,7 +22,7 @@ export function CalendarAgentFilter({
onToggle,
}: CalendarAgentFilterProps) {
return (
- <div className="flex min-h-6 flex-wrap items-center gap-1.5">
+ <div className="flex min-h-6 items-center gap-1.5 overflow-x-auto flex-nowrap scrollbar-none sm:flex-wrap sm:overflow-x-visible">
{agents.length === 0 ? (
<>
<Skeleton className="h-6 w-20 rounded-full" />
@@ -38,7 +38,7 @@ export function CalendarAgentFilter({
key={a.id}
onClick={() => onToggle(a.id)}
className={cn(
- "flex h-6 items-center gap-1.5 rounded-full px-2.5 text-[11px] font-medium transition-colors",
+ "flex h-6 shrink-0 items-center gap-1.5 rounded-full px-2.5 text-[11px] font-medium transition-colors",
on
? "bg-foreground text-background"
: "bg-transparent text-muted-foreground border border-border hover:bg-accent"
@@ -47,7 +47,7 @@ export function CalendarAgentFilter({
<span
className={cn("size-2 rounded-full", agentColor(a.id).split(" ")[0])}
/>
- {a.name}
+ <span className="max-w-[120px] truncate sm:max-w-none">{a.name}</span>
</button>
);
})
diff --git a/src/web/src/components/calendar/calendar-date-picker.tsx b/src/web/src/components/calendar/calendar-date-picker.tsx
index 12629366b..60eab3e60 100644
--- a/src/web/src/components/calendar/calendar-date-picker.tsx
+++ b/src/web/src/components/calendar/calendar-date-picker.tsx
@@ -91,7 +91,7 @@ export function CalendarDatePicker({
)}
>
{!hideIcon && <CalendarDays className="size-3.5 opacity-70" />}
- <span className="tabular-nums">{label}</span>
+ <span className="hidden sm:inline tabular-nums">{label}</span>
</PopoverTrigger>
<PopoverContent align="end" className="w-64 p-3">
<div className="flex items-center justify-between pb-2">
diff --git a/src/web/src/components/calendar/calendar-event-sheet.tsx b/src/web/src/components/calendar/calendar-event-sheet.tsx
index 8808144fa..732990d89 100644
--- a/src/web/src/components/calendar/calendar-event-sheet.tsx
+++ b/src/web/src/components/calendar/calendar-event-sheet.tsx
@@ -1,7 +1,8 @@
"use client";
-import { useEffect, useMemo, useRef, useState } from "react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { toast } from "sonner";
+import { getCalendarEvent } from "@/lib/api";
import {
Sheet,
SheetContent,
@@ -22,6 +23,7 @@ import { MarkdownEditor } from "@/components/ui/markdown-editor";
import {
CalendarDays,
CalendarOff,
+ Loader2,
Repeat as RepeatIcon,
User,
X,
@@ -56,9 +58,14 @@ export interface CreateFormValues {
export interface CalendarEventSheetProps {
open: boolean;
onOpenChange: (open: boolean) => void;
- agents: Agent[];
+ agents?: Agent[];
/** When provided, the sheet is in edit mode. */
event?: CalendarEvent | null;
+ /** When provided (without `event`), the sheet self-fetches the event data. */
+ calendarEventId?: string | null;
+ workspaceId?: string;
+ /** When true, all fields render as non-editable display. */
+ readonly?: boolean;
defaultDate?: Date;
defaultAgentId?: string;
submitting?: boolean;
@@ -227,11 +234,18 @@ function RecurringScopeDialog({
);
}
+const DRAG_MIN_WIDTH = 320;
+const DRAG_MAX_WIDTH_RATIO = 0.8;
+const DRAG_DEFAULT_WIDTH = 500;
+
export function CalendarEventSheet({
open,
onOpenChange,
- agents,
+ agents = [],
event,
+ calendarEventId,
+ workspaceId,
+ readonly,
defaultDate,
defaultAgentId,
submitting,
@@ -241,7 +255,58 @@ export function CalendarEventSheet({
onUpdate,
onDelete,
}: CalendarEventSheetProps) {
- const mode = event ? "edit" : "create";
+ // --- Self-fetch logic ---
+ const [fetchedEvent, setFetchedEvent] = useState<CalendarEvent | null>(null);
+ const [fetchLoading, setFetchLoading] = useState(false);
+ const onOpenChangeRef = useRef(onOpenChange);
+ useEffect(() => { onOpenChangeRef.current = onOpenChange; });
+
+ useEffect(() => {
+ if (!open || !calendarEventId || event) return;
+ let cancelled = false;
+ setFetchLoading(true);
+ setFetchedEvent(null);
+ getCalendarEvent(calendarEventId, workspaceId ?? "")
+ .then((ev) => { if (!cancelled) setFetchedEvent(ev); })
+ .catch(() => {
+ if (cancelled) return;
+ toast.error("Calendar event not found");
+ onOpenChangeRef.current(false);
+ })
+ .finally(() => { if (!cancelled) setFetchLoading(false); });
+ return () => { cancelled = true; };
+ }, [open, calendarEventId, workspaceId, event]);
+
+ const resolvedEvent = event ?? fetchedEvent;
+
+ const handleOpenChange = (v: boolean) => {
+ onOpenChange(v);
+ if (!v) {
+ setTimeout(() => setFetchedEvent(null), 300);
+ }
+ };
+
+ // --- Resizable drag handle ---
+ const [sheetWidth, setSheetWidth] = useState(DRAG_DEFAULT_WIDTH);
+ const draggingRef = useRef(false);
+
+ const onDragPointerDown = useCallback((e: React.PointerEvent) => {
+ e.preventDefault();
+ draggingRef.current = true;
+ (e.target as HTMLElement).setPointerCapture(e.pointerId);
+ }, []);
+
+ const onDragPointerMove = useCallback((e: React.PointerEvent) => {
+ if (!draggingRef.current) return;
+ const maxW = window.innerWidth * DRAG_MAX_WIDTH_RATIO;
+ setSheetWidth(Math.min(maxW, Math.max(DRAG_MIN_WIDTH, window.innerWidth - e.clientX)));
+ }, []);
+
+ const onDragPointerUp = useCallback(() => {
+ draggingRef.current = false;
+ }, []);
+
+ const mode = resolvedEvent ? "edit" : "create";
const [agentId, setAgentId] = useState("");
const [title, setTitle] = useState("");
@@ -275,14 +340,14 @@ export function CalendarEventSheet({
useEffect(() => {
if (!open) return;
- if (event) {
- const scheduled = new Date(event.scheduled_at);
- setAgentId(event.agent_id);
- setTitle(event.title);
- setDescription(event.description ?? "");
+ if (resolvedEvent) {
+ const scheduled = new Date(resolvedEvent.scheduled_at);
+ setAgentId(resolvedEvent.agent_id);
+ setTitle(resolvedEvent.title);
+ setDescription(resolvedEvent.description ?? "");
setDateValue(scheduled);
setTimeValue(parseTime(scheduled));
- const parsed = parseRepeatInterval(event.repeat_interval ?? "");
+ const parsed = parseRepeatInterval(resolvedEvent.repeat_interval ?? "");
if (parsed) {
setRepeatEnabled(true);
setRepeatCount(String(parsed.count));
@@ -293,7 +358,7 @@ export function CalendarEventSheet({
setRepeatUnit("day");
}
setStopDate(
- event.repeat_stop_at ? new Date(event.repeat_stop_at) : null
+ resolvedEvent.repeat_stop_at ? new Date(resolvedEvent.repeat_stop_at) : null
);
} else {
setAgentId(defaultAgentId || agents[0]?.id || "");
@@ -308,25 +373,25 @@ export function CalendarEventSheet({
}
// Seed only on open transition / event id change.
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [open, event?.id]);
+ }, [open, resolvedEvent?.id]);
const dirty = useMemo(() => {
- if (!event) return true;
- const scheduled = new Date(event.scheduled_at);
+ if (!resolvedEvent) return true;
+ const scheduled = new Date(resolvedEvent.scheduled_at);
return (
- title.trim() !== event.title ||
+ title.trim() !== resolvedEvent.title ||
normalizedDescription(description) !==
- normalizedDescription(event.description) ||
- agentId !== event.agent_id ||
+ normalizedDescription(resolvedEvent.description) ||
+ agentId !== resolvedEvent.agent_id ||
dateValue.getFullYear() !== scheduled.getFullYear() ||
dateValue.getMonth() !== scheduled.getMonth() ||
dateValue.getDate() !== scheduled.getDate() ||
timeValue !== parseTime(scheduled) ||
- repeat !== (event.repeat_interval ?? "") ||
+ repeat !== (resolvedEvent.repeat_interval ?? "") ||
(stopDate ? toYYYYMMDD(stopDate) : null) !==
- (event.repeat_stop_at ? toYYYYMMDD(new Date(event.repeat_stop_at)) : null)
+ (resolvedEvent.repeat_stop_at ? toYYYYMMDD(new Date(resolvedEvent.repeat_stop_at)) : null)
);
- }, [agentId, title, description, dateValue, timeValue, repeat, stopDate, event]);
+ }, [agentId, title, description, dateValue, timeValue, repeat, stopDate, resolvedEvent]);
function validate(): string | null {
if (!agentId) return "Select an agent";
@@ -369,28 +434,28 @@ export function CalendarEventSheet({
};
function buildEditPatch(): UpdateCalendarEventRequest | null {
- if (!event) return null;
+ if (!resolvedEvent) return null;
const patch: UpdateCalendarEventRequest = {};
const scheduled = combineDateTime(dateValue, timeValue);
const scheduledIso = scheduled.toISOString();
const nextTitle = title.trim();
- if (nextTitle !== event.title) patch.title = nextTitle;
+ if (nextTitle !== resolvedEvent.title) patch.title = nextTitle;
const nextDesc = normalizedDescription(description);
- const prevDesc = normalizedDescription(event.description);
+ const prevDesc = normalizedDescription(resolvedEvent.description);
if (nextDesc !== prevDesc) patch.description = nextDesc === "" ? null : nextDesc;
- if (agentId !== event.agent_id) patch.agent_id = agentId;
+ if (agentId !== resolvedEvent.agent_id) patch.agent_id = agentId;
if (
- scheduledIso !== new Date(event.scheduled_at).toISOString()
+ scheduledIso !== new Date(resolvedEvent.scheduled_at).toISOString()
) {
patch.scheduled_at = scheduledIso;
}
- const prevRepeat = event.repeat_interval ?? "";
+ const prevRepeat = resolvedEvent.repeat_interval ?? "";
if (repeat !== prevRepeat) {
patch.repeat_interval = repeat === "" ? null : repeat;
}
const nextStop = stopDate ? toYYYYMMDD(stopDate) : null;
- const prevStop = event.repeat_stop_at
- ? toYYYYMMDD(new Date(event.repeat_stop_at))
+ const prevStop = resolvedEvent.repeat_stop_at
+ ? toYYYYMMDD(new Date(resolvedEvent.repeat_stop_at))
: null;
if (nextStop !== prevStop) {
patch.repeat_stop_date = nextStop;
@@ -409,17 +474,17 @@ export function CalendarEventSheet({
}
const commitEdit = async (patch: UpdateCalendarEventRequest) => {
- if (!event) return;
- await onUpdate?.(event, patch);
+ if (!resolvedEvent) return;
+ await onUpdate?.(resolvedEvent, patch);
};
const handleEditSave = async () => {
- if (!event) return;
+ if (!resolvedEvent) return;
const err = validate();
if (err) return toast.error(err);
const patch = buildEditPatch();
if (!patch) return;
- if (event.repeat_interval) {
+ if (resolvedEvent.repeat_interval) {
setScopeOpen(true);
return;
}
@@ -433,27 +498,27 @@ export function CalendarEventSheet({
return;
}
patch.scope = scope;
- if (scope === "this" && event?.occurrence_at) {
- patch.occurrence_at = event.occurrence_at;
+ if (scope === "this" && resolvedEvent?.occurrence_at) {
+ patch.occurrence_at = resolvedEvent.occurrence_at;
}
await commitEdit(patch);
setScopeOpen(false);
};
const handleDeleteClick = () => {
- if (!event) return;
- if (event.repeat_interval) {
+ if (!resolvedEvent) return;
+ if (resolvedEvent.repeat_interval) {
setDeleteScopeOpen(true);
return;
}
- onDelete?.(event);
+ onDelete?.(resolvedEvent);
};
const handleDeleteScopeConfirm = (scope: "this" | "following") => {
- if (!event) return;
- onDelete?.(event, {
+ if (!resolvedEvent) return;
+ onDelete?.(resolvedEvent, {
scope,
- occurrence_at: event.occurrence_at ?? undefined,
+ occurrence_at: resolvedEvent.occurrence_at ?? undefined,
});
setDeleteScopeOpen(false);
};
@@ -502,7 +567,11 @@ export function CalendarEventSheet({
resizeTitle(titleRef.current);
}, [title]);
- const titleInput = (
+ const titleInput = readonly ? (
+ <p className="w-full px-0 py-1 font-news text-xl sm:text-2xl md:text-3xl font-medium leading-[1.2] tracking-tight">
+ {title || "Untitled event"}
+ </p>
+ ) : (
<textarea
ref={(el) => {
titleRef.current = el;
@@ -524,14 +593,37 @@ export function CalendarEventSheet({
autoFocus={mode === "create"}
rows={1}
className={cn(
- "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",
+ "w-full resize-none overflow-hidden rounded-none border-0 bg-transparent px-0 py-1 font-news text-xl sm: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"
)}
/>
);
- const properties = (
+ const properties = readonly ? (
+ <div className="flex flex-col gap-1.5">
+ <PropertyRow icon={<CalendarDays className="size-3.5" />}>
+ <span className="text-sm text-foreground">
+ {dateValue.toLocaleDateString(undefined, { weekday: "short", year: "numeric", month: "short", day: "numeric" })}
+ </span>
+ </PropertyRow>
+ <PropertyRow icon={<CalendarDays className="size-3.5" />}>
+ <span className="text-sm text-foreground">{timeValue}</span>
+ </PropertyRow>
+ <PropertyRow icon={<RepeatIcon className="size-3.5" />}>
+ <span className="text-sm text-foreground">
+ {repeatEnabled ? `Every ${repeatCount} ${unitLabel(repeatUnit, parseInt(repeatCount, 10) || 1)}` : "Does not repeat"}
+ </span>
+ </PropertyRow>
+ {repeatEnabled && stopDate && (
+ <PropertyRow icon={<CalendarOff className="size-3.5" />}>
+ <span className="text-sm text-foreground">
+ Until {stopDate.toLocaleDateString()}
+ </span>
+ </PropertyRow>
+ )}
+ </div>
+ ) : (
<div className="flex flex-col gap-1.5">
<PropertyRow icon={<User className="size-3.5" />}>
<select
@@ -681,10 +773,14 @@ export function CalendarEventSheet({
</div>
);
- const descriptionEditor = (
+ const descriptionEditor = readonly ? (
+ description ? (
+ <pre className="whitespace-pre-wrap font-sans text-sm">{description}</pre>
+ ) : null
+ ) : (
<div ref={descriptionRef}>
<MarkdownEditor
- key={event?.id ?? "new"}
+ key={resolvedEvent?.id ?? "new"}
contentType="markdown"
value={description}
onChange={setDescription}
@@ -697,28 +793,53 @@ export function CalendarEventSheet({
</div>
);
+ const dragHandle = (
+ <div
+ onPointerDown={onDragPointerDown}
+ onPointerMove={onDragPointerMove}
+ onPointerUp={onDragPointerUp}
+ className="hidden sm:block absolute left-0 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"
+ />
+ );
+
+ const sheetBody = fetchLoading ? (
+ <SheetBody className="flex items-center justify-center py-12">
+ <Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
+ </SheetBody>
+ ) : (
+ <SheetBody className="flex flex-col gap-6 px-4 pt-6 pb-4 sm:px-8 sm:pt-10 sm:pb-6">
+ {titleInput}
+ {properties}
+ {descriptionEditor}
+ </SheetBody>
+ );
+
return (
<>
- <Sheet open={open} onOpenChange={onOpenChange}>
- <SheetContent 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">
+ <Sheet open={open} onOpenChange={handleOpenChange}>
+ <SheetContent
+ style={{ width: `min(${sheetWidth}px, 100vw)`, maxWidth: "none" }}
+ 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"
+ >
+ {dragHandle}
<SheetTitle className="sr-only">{a11yTitle}</SheetTitle>
- {mode === "create" ? (
+ {readonly ? (
+ <div className="flex flex-1 flex-col min-h-0">
+ {sheetBody}
+ </div>
+ ) : mode === "create" ? (
<form
ref={formRef}
onSubmit={handleCreateSubmit}
onKeyDownCapture={handleSubmitShortcut}
className="flex flex-1 flex-col min-h-0"
>
- <SheetBody className="flex flex-col gap-6 px-8 pt-10 pb-6">
- {titleInput}
- {properties}
- {descriptionEditor}
- </SheetBody>
+ {sheetBody}
<SheetFooter>
<Button
type="button"
variant="outline"
- onClick={() => onOpenChange(false)}
+ onClick={() => handleOpenChange(false)}
>
Cancel
</Button>
@@ -737,11 +858,7 @@ export function CalendarEventSheet({
onKeyDownCapture={handleSubmitShortcut}
className="flex flex-1 flex-col min-h-0"
>
- <SheetBody className="flex flex-col gap-6 px-8 pt-10 pb-6">
- {titleInput}
- {properties}
- {descriptionEditor}
- </SheetBody>
+ {sheetBody}
<SheetFooter className="sm:justify-between">
<Button
variant="destructive"
@@ -753,7 +870,7 @@ export function CalendarEventSheet({
<div className="flex items-center gap-2 sm:justify-end">
<Button
variant="outline"
- onClick={() => onOpenChange(false)}
+ onClick={() => handleOpenChange(false)}
disabled={saving}
>
Cancel
diff --git a/src/web/src/components/calendar/calendar-month-grid.tsx b/src/web/src/components/calendar/calendar-month-grid.tsx
index 73e4b50a9..77e7324c5 100644
--- a/src/web/src/components/calendar/calendar-month-grid.tsx
+++ b/src/web/src/components/calendar/calendar-month-grid.tsx
@@ -149,7 +149,7 @@ export function CalendarMonthGrid({
type="button"
aria-label="Previous month"
onClick={onPrev}
- className="flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors"
+ className="flex size-9 sm:size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors"
>
<ChevronLeft className="size-4" />
</button>
@@ -166,7 +166,7 @@ export function CalendarMonthGrid({
type="button"
aria-label="Next month"
onClick={onNext}
- className="flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors"
+ className="flex size-9 sm:size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors"
>
<ChevronRight className="size-4" />
</button>
@@ -181,8 +181,9 @@ export function CalendarMonthGrid({
<div className="grid grid-cols-7 text-[11px] text-muted-foreground">
{["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"].map((d) => (
- <div key={d} className="px-2 py-1 font-medium">
- {d}
+ <div key={d} className="px-1 sm:px-2 py-1 font-medium">
+ <span className="sm:hidden">{d[0]}</span>
+ <span className="hidden sm:inline">{d}</span>
</div>
))}
</div>
@@ -232,7 +233,7 @@ export function CalendarMonthGrid({
}
}}
className={cn(
- "group flex min-h-24 flex-col gap-1 p-2 text-left transition-colors bg-background outline-none cursor-pointer",
+ "group flex min-h-16 sm:min-h-24 flex-col gap-1 p-1 sm:p-2 text-left transition-colors bg-background outline-none cursor-pointer",
!cell.inMonth && "bg-muted/40 text-muted-foreground",
isFocused &&
"ring-2 ring-inset ring-ring/60 relative z-10"
@@ -249,7 +250,7 @@ export function CalendarMonthGrid({
{cell.date.getDate()}
</span>
</div>
- <div className="flex flex-col gap-1">
+ <div className="flex flex-col gap-1 [&>:nth-child(3)]:hidden [&>:nth-child(3)]:sm:flex">
{dayEvents.slice(0, 3).map((ev) => {
const isRecurring = Boolean(ev.repeat_interval);
return (
@@ -267,7 +268,7 @@ export function CalendarMonthGrid({
onSelectEvent(ev);
}
}}
- className="flex items-center gap-1.5 rounded-sm px-1 py-0.5 text-[10px] font-medium text-foreground/85 hover:bg-accent/60 transition-colors cursor-pointer"
+ className="flex items-center gap-1.5 rounded-sm px-1 py-0.5 text-[9px] sm:text-[10px] font-medium text-foreground/85 hover:bg-accent/60 transition-colors cursor-pointer"
title={`${isRecurring ? "Recurring · " : ""}${ev.title}${
agentNameById.get(ev.agent_id)
? ` — ${agentNameById.get(ev.agent_id)}`
diff --git a/src/web/src/components/calendar/calendar-week-grid.tsx b/src/web/src/components/calendar/calendar-week-grid.tsx
index 7e0964204..43291d21f 100644
--- a/src/web/src/components/calendar/calendar-week-grid.tsx
+++ b/src/web/src/components/calendar/calendar-week-grid.tsx
@@ -16,7 +16,8 @@ import {
} from "./calendar-week-utils";
import { dateKey, sameDay } from "./calendar-month-grid";
-const HOUR_HEIGHT = 48;
+const HOUR_HEIGHT_DEFAULT = 48;
+const HOUR_HEIGHT_COMPACT = 36;
const EVENT_HEIGHT = 24;
const HOURS = Array.from({ length: 24 }, (_, i) => i);
@@ -44,6 +45,7 @@ export interface CalendarWeekGridProps {
agents: Agent[];
loading: boolean;
focusedDate: Date;
+ compact?: boolean;
onPrevWeek: () => void;
onNextWeek: () => void;
onJumpToToday: () => void;
@@ -59,6 +61,7 @@ export function CalendarWeekGrid({
agents,
loading,
focusedDate,
+ compact = false,
onPrevWeek,
onNextWeek,
onJumpToToday,
@@ -67,6 +70,8 @@ export function CalendarWeekGrid({
onSelectEvent,
headerExtras,
}: CalendarWeekGridProps) {
+ const hourHeight = compact ? HOUR_HEIGHT_COMPACT : HOUR_HEIGHT_DEFAULT;
+ const gutterWidth = compact ? "2.5rem" : "3.5rem";
const scrollRef = useRef<HTMLDivElement>(null);
const didAutoScroll = useRef(false);
@@ -126,10 +131,10 @@ export function CalendarWeekGrid({
if (didAutoScroll.current) return;
if (!scrollRef.current) return;
const now = new Date();
- const scrollTo = Math.max(0, (now.getHours() - 1) * HOUR_HEIGHT);
+ const scrollTo = Math.max(0, (now.getHours() - 1) * hourHeight);
scrollRef.current.scrollTop = scrollTo;
didAutoScroll.current = true;
- }, []);
+ }, [hourHeight]);
const currentFractionalHour = useMemo(() => {
const now = new Date();
@@ -137,6 +142,7 @@ export function CalendarWeekGrid({
}, []);
if (loading && events.length === 0) {
+ const skelCols = `${gutterWidth} repeat(7, 1fr)`;
return (
<div className="flex flex-1 flex-col gap-3 min-h-0">
<div className="flex items-center justify-between flex-wrap gap-2 shrink-0">
@@ -144,7 +150,7 @@ export function CalendarWeekGrid({
<Skeleton className="h-7 w-32" />
</div>
<div className="flex-1 min-h-0 flex flex-col rounded-lg border border-border/50 overflow-hidden">
- <div className="grid grid-cols-[3.5rem_repeat(7,1fr)] border-b border-border/30 shrink-0">
+ <div className="border-b border-border/30 shrink-0" style={{ display: "grid", gridTemplateColumns: skelCols }}>
<div className="h-8" />
{Array.from({ length: 7 }).map((_, i) => (
<Skeleton key={i} className="h-5 mx-2 my-1.5" />
@@ -154,8 +160,8 @@ export function CalendarWeekGrid({
{Array.from({ length: 12 }).map((_, i) => (
<div
key={i}
- className="grid grid-cols-[3.5rem_repeat(7,1fr)] border-b border-border/10"
- style={{ height: HOUR_HEIGHT }}
+ className="border-b border-border/10"
+ style={{ display: "grid", gridTemplateColumns: skelCols, height: hourHeight }}
>
<Skeleton className="h-3 w-8 mx-1 my-2" />
{Array.from({ length: 7 }).map((_, j) => (
@@ -239,12 +245,12 @@ export function CalendarWeekGrid({
{/* Sticky day headers */}
<div
role="row"
- className="sticky top-0 z-10 grid grid-cols-[3.5rem_repeat(7,1fr)] border-b border-border/30 bg-background"
+ className="sticky top-0 z-10 border-b border-border/30 bg-background"
+ style={{ display: "grid", gridTemplateColumns: `${gutterWidth} repeat(7, 1fr)` }}
>
<div role="columnheader" className="h-8" />
{days.map((day) => {
const isToday = sameDay(day, today);
- const compact = false; // TODO: responsive via media query hook if needed
return (
<div
key={dateKey(day)}
@@ -275,17 +281,17 @@ export function CalendarWeekGrid({
ref={scrollRef}
className="flex-1 min-h-0 overflow-y-auto thin-scrollbar"
>
- <div className="relative grid grid-cols-[3.5rem_repeat(7,1fr)]">
+ <div className="relative" style={{ display: "grid", gridTemplateColumns: `${gutterWidth} repeat(7, 1fr)` }}>
{/* Time gutter */}
<div role="rowheader" className="relative">
{HOURS.map((hour) => (
<div
key={hour}
className="flex items-start justify-end pr-2 text-[10px] text-muted-foreground tabular-nums"
- style={{ height: HOUR_HEIGHT }}
+ style={{ height: hourHeight }}
>
<span className="-mt-1.5">
- {hour === 0 ? "" : formatHourLabel(hour, false)}
+ {hour === 0 ? "" : formatHourLabel(hour, compact)}
</span>
</div>
))}
@@ -301,14 +307,14 @@ export function CalendarWeekGrid({
<div
key={key}
className="relative border-l border-border/20"
- style={{ height: HOUR_HEIGHT * 24 }}
+ style={{ height: hourHeight * 24 }}
>
{/* Hour slots */}
{HOURS.map((hour) => (
<div
key={hour}
className="absolute inset-x-0 border-t border-border/15 cursor-pointer hover:bg-accent/30 transition-colors"
- style={{ top: hour * HOUR_HEIGHT, height: HOUR_HEIGHT }}
+ style={{ top: hour * hourHeight, height: hourHeight }}
onClick={() => onSelectSlot(day, hour)}
/>
))}
@@ -317,7 +323,7 @@ export function CalendarWeekGrid({
{isToday && (
<div
className="absolute inset-x-0 z-10 pointer-events-none"
- style={{ top: currentFractionalHour * HOUR_HEIGHT }}
+ style={{ top: currentFractionalHour * hourHeight }}
>
<div className="h-px bg-foreground/40" />
<div className="absolute -left-0.5 -top-0.75 size-1.75 rounded-full bg-foreground/40" />
@@ -329,7 +335,7 @@ export function CalendarWeekGrid({
const fracHour = getLocalFractionalHour(
event.scheduled_at
);
- const top = fracHour * HOUR_HEIGHT;
+ const top = fracHour * hourHeight;
const widthPercent = 100 / columnCount;
const leftPercent = columnIndex * widthPercent;
const agentName = agentNameById.get(event.agent_id);
@@ -352,7 +358,8 @@ export function CalendarWeekGrid({
onSelectEvent(event);
}}
className={cn(
- "absolute rounded-sm px-1.5 text-[10px] font-medium truncate text-left transition-colors hover:opacity-80 cursor-pointer",
+ "absolute rounded-sm font-medium truncate text-left transition-colors hover:opacity-80 cursor-pointer",
+ compact ? "text-[9px] px-1" : "text-[10px] px-1.5",
agentColor(event.agent_id)
)}
style={{
diff --git a/src/web/src/components/ui/sheet.tsx b/src/web/src/components/ui/sheet.tsx
index 30965d81c..8680f421c 100644
--- a/src/web/src/components/ui/sheet.tsx
+++ b/src/web/src/components/ui/sheet.tsx
@@ -97,7 +97,7 @@ function SheetBody({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="sheet-body"
- className={cn("flex-1 overflow-y-auto px-4 sm:px-6 py-5", className)}
+ className={cn("flex-1 overflow-y-auto thin-scrollbar px-4 sm:px-6 py-5", className)}
{...props}
/>
)
diff --git a/src/web/src/lib/services/calendar.test.ts b/src/web/src/lib/services/calendar.test.ts
index d61732488..1b1de0b96 100644
--- a/src/web/src/lib/services/calendar.test.ts
+++ b/src/web/src/lib/services/calendar.test.ts
@@ -14,6 +14,7 @@ const mockClaim = vi.fn();
const mockRevert = vi.fn();
const mockUpdateSchedule = vi.fn();
const mockGetAgent = vi.fn();
+const mockGetUser = vi.fn();
const mockCreateConv = vi.fn();
const mockCreateMessage = vi.fn();
const mockCreateTask = vi.fn();
@@ -26,6 +27,7 @@ vi.mock("@alook/shared", async () => {
...actual,
queries: {
agent: { getAgent: (...args: unknown[]) => mockGetAgent(...args) },
+ user: { getUser: (...args: unknown[]) => mockGetUser(...args) },
conversation: {
createConversation: (...args: unknown[]) => mockCreateConv(...args),
},
@@ -71,6 +73,7 @@ function mkEvent(over?: Partial<Record<string, unknown>>) {
beforeEach(() => {
vi.clearAllMocks();
+ mockGetUser.mockResolvedValue({ id: "u_1", name: "Gus", email: "[email protected]" });
});
describe("promoteDueCalendarEventsForWorkspace", () => {
@@ -262,6 +265,65 @@ describe("promoteDueCalendarEventsForWorkspace", () => {
);
});
+ it("passes description and scheduled_by in task context when both exist", async () => {
+ mockListDue.mockResolvedValue([mkEvent({ description: "Check PRs" })]);
+ mockGetAgent.mockResolvedValue({
+ id: "ag_1",
+ workspaceId: "ws_1",
+ runtimeId: "rt_1",
+ ownerId: "u_1",
+ });
+ mockClaim.mockResolvedValue({ id: "ce_1" });
+ mockCreateConv.mockResolvedValue({ id: "cv_1" });
+ mockCreateTask.mockResolvedValue({ id: "t_1" });
+
+ await promoteDueCalendarEventsForWorkspace(fakeDb, "ws_1", "2026-04-17T09:05:00.000Z");
+
+ expect(mockCreateTask.mock.calls[0][1].context).toEqual({
+ description: "Check PRs",
+ scheduled_by: { name: "Gus", email: "[email protected]" },
+ });
+ });
+
+ it("omits description from task context when event has no description", async () => {
+ mockListDue.mockResolvedValue([mkEvent({ description: null })]);
+ mockGetAgent.mockResolvedValue({
+ id: "ag_1",
+ workspaceId: "ws_1",
+ runtimeId: "rt_1",
+ ownerId: "u_1",
+ });
+ mockClaim.mockResolvedValue({ id: "ce_1" });
+ mockCreateConv.mockResolvedValue({ id: "cv_1" });
+ mockCreateTask.mockResolvedValue({ id: "t_1" });
+
+ await promoteDueCalendarEventsForWorkspace(fakeDb, "ws_1", "2026-04-17T09:05:00.000Z");
+
+ const ctx = mockCreateTask.mock.calls[0][1].context;
+ expect(ctx.description).toBeUndefined();
+ expect(ctx.scheduled_by).toEqual({ name: "Gus", email: "[email protected]" });
+ });
+
+ it("omits scheduled_by from task context when getUser returns null", async () => {
+ mockListDue.mockResolvedValue([mkEvent({ description: "Check PRs" })]);
+ mockGetAgent.mockResolvedValue({
+ id: "ag_1",
+ workspaceId: "ws_1",
+ runtimeId: "rt_1",
+ ownerId: "u_deleted",
+ });
+ mockGetUser.mockResolvedValue(null);
+ mockClaim.mockResolvedValue({ id: "ce_1" });
+ mockCreateConv.mockResolvedValue({ id: "cv_1" });
+ mockCreateTask.mockResolvedValue({ id: "t_1" });
+
+ await promoteDueCalendarEventsForWorkspace(fakeDb, "ws_1", "2026-04-17T09:05:00.000Z");
+
+ const ctx = mockCreateTask.mock.calls[0][1].context;
+ expect(ctx.description).toBe("Check PRs");
+ expect(ctx.scheduled_by).toBeUndefined();
+ });
+
it("does not advance the schedule when the next occurrence would exceed repeat_stop_at", async () => {
mockListDue.mockResolvedValue([
mkEvent({
diff --git a/src/web/src/lib/services/calendar.ts b/src/web/src/lib/services/calendar.ts
index d156ea7fe..d9212bf57 100644
--- a/src/web/src/lib/services/calendar.ts
+++ b/src/web/src/lib/services/calendar.ts
@@ -41,6 +41,7 @@ export async function promoteDueCalendarEventsForWorkspace(
nowIso: string = new Date().toISOString(),
): Promise<number> {
const candidates = await listDueCalendarEvents(db, workspaceId, nowIso);
+ const ownerCache = new Map<string, { name: string; email: string } | null>();
let enqueued = 0;
for (const ev of candidates) {
@@ -83,6 +84,20 @@ export async function promoteDueCalendarEventsForWorkspace(
metadata: JSON.stringify({ calendarEventId: ev.id }),
});
+ if (!ownerCache.has(agent.ownerId)) {
+ const u = await queries.user.getUser(db, agent.ownerId);
+ ownerCache.set(agent.ownerId, u ? { name: u.name, email: u.email } : null);
+ }
+ const ownerInfo = ownerCache.get(agent.ownerId)!;
+
+ const taskContext: Record<string, unknown> = {};
+ if (ev.description) {
+ taskContext.description = ev.description;
+ }
+ if (ownerInfo) {
+ taskContext.scheduled_by = ownerInfo;
+ }
+
await queries.task.createTask(db, {
agentId: ev.agentId,
runtimeId: agent.runtimeId,
@@ -93,6 +108,7 @@ export async function promoteDueCalendarEventsForWorkspace(
priority: 0,
traceId: "tr_" + nanoid(),
parentTaskId: null,
+ context: Object.keys(taskContext).length > 0 ? taskContext : undefined,
});
if (ev.repeatInterval) {