Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix: calendar edge uiux

Gusc350a612ee9b
diff --git a/src/shared/src/api-types.ts b/src/shared/src/api-types.ts
index e6cf8b432..14ebe2ef2 100644
--- a/src/shared/src/api-types.ts
+++ b/src/shared/src/api-types.ts
@@ -71,6 +71,15 @@ export interface UpdateCalendarEventRequest {
occurrence_at?: string;
}
+export interface DeleteCalendarEventRequest {
+ scope?: "this" | "following";
+ /**
+ * ISO of the occurrence being deleted. Defaults to the parent's
+ * current `scheduled_at` (next fire) when omitted.
+ */
+ occurrence_at?: string;
+}
+
export interface CreateWorkspaceRequest {
name: string;
}
diff --git a/src/shared/src/index.ts b/src/shared/src/index.ts
index 14d1295de..73e3fd67f 100644
--- a/src/shared/src/index.ts
+++ b/src/shared/src/index.ts
@@ -40,6 +40,7 @@ export type {
GetCalendarEventResponse,
CreateCalendarEventRequest,
UpdateCalendarEventRequest,
+ DeleteCalendarEventRequest,
CreateWorkspaceRequest,
UpdateAgentRequest,
SendMessageRequest,
@@ -93,6 +94,7 @@ export {
RepeatIntervalSchema,
CreateCalendarEventRequestSchema,
UpdateCalendarEventRequestSchema,
+ DeleteCalendarEventRequestSchema,
CalendarEventApiSchema,
} from "./schemas";
@@ -115,6 +117,7 @@ export type {
ReportMessagesRequest,
CreateCalendarEventRequestInput,
UpdateCalendarEventRequestInput,
+ DeleteCalendarEventRequestInput,
CalendarEventApi,
} from "./schemas";
diff --git a/src/shared/src/schemas.ts b/src/shared/src/schemas.ts
index 27b168ab8..dd814c035 100644
--- a/src/shared/src/schemas.ts
+++ b/src/shared/src/schemas.ts
@@ -256,6 +256,21 @@ export const UpdateCalendarEventRequestSchema = z
v.repeat_stop_date !== undefined,
{ message: "at least one field is required" }
);
+
+export const DeleteCalendarEventRequestSchema = z.object({
+ scope: z.enum(["this", "following"]).optional(),
+ occurrence_at: z
+ .string()
+ .min(1)
+ .refine((s) => !Number.isNaN(Date.parse(s)), {
+ message: "occurrence_at must be a valid ISO datetime",
+ })
+ .optional(),
+});
+export type DeleteCalendarEventRequestInput = z.infer<
+ typeof DeleteCalendarEventRequestSchema
+>;
+
export type UpdateCalendarEventRequestInput = z.infer<
typeof UpdateCalendarEventRequestSchema
>;
diff --git a/src/shared/test/calendar-schemas.test.ts b/src/shared/test/calendar-schemas.test.ts
index 06f9eddaf..bbdb41db4 100644
--- a/src/shared/test/calendar-schemas.test.ts
+++ b/src/shared/test/calendar-schemas.test.ts
@@ -3,6 +3,7 @@ import {
RepeatIntervalSchema,
CreateCalendarEventRequestSchema,
UpdateCalendarEventRequestSchema,
+ DeleteCalendarEventRequestSchema,
CalendarEventApiSchema,
} from "../src/schemas";
@@ -223,6 +224,51 @@ describe("UpdateCalendarEventRequestSchema", () => {
});
});
+describe("DeleteCalendarEventRequestSchema", () => {
+ it("accepts an empty body (legacy full delete)", () => {
+ expect(DeleteCalendarEventRequestSchema.parse({})).toEqual({});
+ });
+
+ it("accepts scope: 'this' with no occurrence_at", () => {
+ expect(
+ DeleteCalendarEventRequestSchema.parse({ scope: "this" })
+ ).toMatchObject({ scope: "this" });
+ });
+
+ it("accepts scope + occurrence_at", () => {
+ const payload = {
+ scope: "this" as const,
+ occurrence_at: "2026-04-20T09:00:00.000Z",
+ };
+ expect(DeleteCalendarEventRequestSchema.parse(payload)).toMatchObject(
+ payload
+ );
+ });
+
+ it("accepts scope: 'following'", () => {
+ expect(
+ DeleteCalendarEventRequestSchema.parse({ scope: "following" })
+ ).toMatchObject({ scope: "following" });
+ });
+
+ it("rejects a malformed scope", () => {
+ expect(() =>
+ DeleteCalendarEventRequestSchema.parse({
+ scope: "all" as unknown,
+ })
+ ).toThrow();
+ });
+
+ it("rejects a malformed occurrence_at", () => {
+ expect(() =>
+ DeleteCalendarEventRequestSchema.parse({
+ scope: "this",
+ occurrence_at: "not a date",
+ })
+ ).toThrow();
+ });
+});
+
describe("CalendarEventApiSchema", () => {
it("parses a full wire-format response", () => {
const row = {
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 02a1b5ffb..124dd939a 100644
--- a/src/web/src/app/(app)/w/[slug]/calendar/page.tsx
+++ b/src/web/src/app/(app)/w/[slug]/calendar/page.tsx
@@ -15,6 +15,7 @@ import {
} from "@/lib/api";
import {
CalendarMonthGrid,
+ buildMonthCells,
dateKey,
stepDate,
} from "@/components/calendar/calendar-month-grid";
@@ -29,9 +30,34 @@ import { CalendarEventSheet } from "@/components/calendar/calendar-event-sheet";
import type { CalendarEvent, UpdateCalendarEventRequest } from "@alook/shared";
import { isTypingTarget } from "@/components/calendar/keyboard";
-function monthRangeIso(year: number, month: number) {
- const from = new Date(year, month, 1, 0, 0, 0, 0);
- const to = new Date(year, month + 1, 0, 23, 59, 59, 999);
+/**
+ * The month grid always renders six full weeks (42 cells), which means the
+ * first and last rows usually include leading/trailing days from adjacent
+ * months. Fetch for the full visible grid — otherwise recurring occurrences
+ * that land on those out-of-month cells would silently not render.
+ */
+function gridRangeIso(year: number, month: number) {
+ const cells = buildMonthCells(year, month);
+ const first = cells[0]!.date;
+ const last = cells[cells.length - 1]!.date;
+ const from = new Date(
+ first.getFullYear(),
+ first.getMonth(),
+ first.getDate(),
+ 0,
+ 0,
+ 0,
+ 0
+ );
+ const to = new Date(
+ last.getFullYear(),
+ last.getMonth(),
+ last.getDate(),
+ 23,
+ 59,
+ 59,
+ 999
+ );
return { from: from.toISOString(), to: to.toISOString() };
}
@@ -94,7 +120,7 @@ export default function CalendarPage() {
);
const fetchEvents = useCallback(async () => {
- const { from, to } = monthRangeIso(year, month);
+ const { from, to } = gridRangeIso(year, month);
setLoading(true);
try {
const list = await listCalendarEvents(workspaceId, { from, to });
@@ -188,11 +214,15 @@ export default function CalendarPage() {
try {
const created = await createCalendarEvent(values, workspaceId);
// Only surface the new event in local state if it falls inside the
- // currently-fetched month window. Otherwise let the next month
- // navigation refetch pick it up (avoids leaking out-of-range events
- // into agenda view).
- const d = new Date(created.scheduled_at);
- if (d.getFullYear() === year && d.getMonth() === month) {
+ // currently-fetched grid window (the 42-cell span may reach into
+ // adjacent months). Otherwise let the next navigation refetch pick it
+ // up so out-of-range events don't leak into the agenda.
+ const { from, to } = gridRangeIso(year, month);
+ const createdAt = new Date(created.scheduled_at).getTime();
+ if (
+ createdAt >= new Date(from).getTime() &&
+ createdAt <= new Date(to).getTime()
+ ) {
setEvents((prev) => [...prev, created]);
}
setCreateOpen(false);
@@ -228,11 +258,21 @@ export default function CalendarPage() {
}
};
- const handleDelete = async (event: CalendarEvent) => {
+ const handleDelete = async (
+ event: CalendarEvent,
+ args?: { scope?: "this" | "following"; occurrence_at?: string }
+ ) => {
setDeletingId(event.id);
try {
- await deleteCalendarEvent(event.id, workspaceId);
- setEvents((prev) => prev.filter((e) => e.id !== event.id));
+ await deleteCalendarEvent(event.id, workspaceId, args);
+ if (args?.scope) {
+ // Scoped deletes may keep the parent row alive (advance scheduled_at,
+ // append exception, clip repeat_stop_at) — refetch so the grid shows
+ // the new series state instead of optimistically removing the row.
+ await fetchEvents();
+ } else {
+ setEvents((prev) => prev.filter((e) => e.id !== event.id));
+ }
setDetailOpen(false);
setDetail(null);
toast.success("Event deleted");
diff --git a/src/web/src/app/api/calendar/[id]/route.test.ts b/src/web/src/app/api/calendar/[id]/route.test.ts
index 003f9a3ca..d00676be0 100644
--- a/src/web/src/app/api/calendar/[id]/route.test.ts
+++ b/src/web/src/app/api/calendar/[id]/route.test.ts
@@ -97,16 +97,16 @@ describe("DELETE /api/calendar/[id]", () => {
beforeEach(() => vi.clearAllMocks());
it("404s when the event does not exist in the workspace", async () => {
- mockDelete.mockResolvedValue(null);
+ mockGet.mockResolvedValue(null);
const r = new NextRequest("http://localhost/api/calendar/ce_missing", {
method: "DELETE",
});
const res = await DELETE(r, { params: { id: "ce_missing" } } as any);
expect(res.status).toBe(404);
- expect(mockDelete).toHaveBeenCalledWith({}, "ce_missing", "ws1");
});
- it("returns the deleted event when successful", async () => {
+ it("returns the deleted event when successful (non-recurring, no body)", async () => {
+ mockGet.mockResolvedValue(sourceNonRepeating());
mockDelete.mockResolvedValue({ id: "ce_1" });
const r = new NextRequest("http://localhost/api/calendar/ce_1", {
method: "DELETE",
@@ -114,6 +114,7 @@ describe("DELETE /api/calendar/[id]", () => {
const res = await DELETE(r, { params: { id: "ce_1" } } as any);
expect(res.status).toBe(200);
expect((await res.json()).id).toBe("ce_1");
+ expect(mockDelete).toHaveBeenCalledWith({}, "ce_1", "ws1");
});
it("400s when id is missing", async () => {
@@ -125,6 +126,124 @@ describe("DELETE /api/calendar/[id]", () => {
});
});
+function delReq(id: string | undefined, body?: unknown) {
+ const init: RequestInit & { body?: string; headers?: Record<string, string> } = {
+ method: "DELETE",
+ };
+ if (body !== undefined) {
+ init.body = JSON.stringify(body);
+ init.headers = { "Content-Type": "application/json" };
+ }
+ const r = new NextRequest(`http://localhost/api/calendar/${id ?? ""}`, init);
+ return DELETE(r, { params: { id } } as any);
+}
+
+describe("DELETE /api/calendar/[id] — scope-aware", () => {
+ beforeEach(() => vi.clearAllMocks());
+
+ it("scope=this on a non-recurring event falls back to full delete", async () => {
+ mockGet.mockResolvedValue(sourceNonRepeating());
+ mockDelete.mockResolvedValue({ id: "ce_1" });
+ const res = await delReq("ce_1", { scope: "this" });
+ expect(res.status).toBe(200);
+ expect(mockDelete).toHaveBeenCalledWith({}, "ce_1", "ws1");
+ expect(mockUpdate).not.toHaveBeenCalled();
+ });
+
+ it("scope=this without occurrence_at advances the parent one interval", async () => {
+ mockGet.mockResolvedValue(sourceDaily());
+ mockUpdate.mockResolvedValue({ id: "ce_1" });
+ const res = await delReq("ce_1", { scope: "this" });
+ expect(res.status).toBe(200);
+ expect(mockUpdate).toHaveBeenCalledWith({}, "ce_1", "ws1", {
+ scheduledAt: "2026-04-18T09:00:00.000Z",
+ });
+ expect(mockDelete).not.toHaveBeenCalled();
+ });
+
+ it("scope=this on the last remaining occurrence deletes the parent", async () => {
+ mockGet.mockResolvedValue(
+ sourceDaily({
+ scheduledAt: "2026-04-17T09:00:00.000Z",
+ repeatStopAt: "2026-04-17T23:59:59.999Z",
+ })
+ );
+ mockDelete.mockResolvedValue({ id: "ce_1" });
+ const res = await delReq("ce_1", { scope: "this" });
+ expect(res.status).toBe(200);
+ expect(mockDelete).toHaveBeenCalledWith({}, "ce_1", "ws1");
+ expect(mockUpdate).not.toHaveBeenCalled();
+ });
+
+ it("scope=this on a future occurrence appends an exception", async () => {
+ mockGet.mockResolvedValue(sourceDaily({ exceptions: [] }));
+ mockUpdate.mockResolvedValue({ id: "ce_1" });
+ const res = await delReq("ce_1", {
+ scope: "this",
+ occurrence_at: "2026-04-20T09:00:00.000Z",
+ });
+ expect(res.status).toBe(200);
+ expect(mockUpdate).toHaveBeenCalledWith({}, "ce_1", "ws1", {
+ exceptions: ["2026-04-20T09:00:00.000Z"],
+ });
+ expect(mockDelete).not.toHaveBeenCalled();
+ });
+
+ it("scope=this does not duplicate an already-recorded exception", async () => {
+ mockGet.mockResolvedValue(
+ sourceDaily({ exceptions: ["2026-04-20T09:00:00.000Z"] })
+ );
+ mockUpdate.mockResolvedValue({ id: "ce_1" });
+ await delReq("ce_1", {
+ scope: "this",
+ occurrence_at: "2026-04-20T09:00:00.000Z",
+ });
+ expect(mockUpdate.mock.calls[0][3].exceptions).toEqual([
+ "2026-04-20T09:00:00.000Z",
+ ]);
+ });
+
+ it("scope=following without occurrence_at deletes the parent", async () => {
+ mockGet.mockResolvedValue(sourceDaily());
+ mockDelete.mockResolvedValue({ id: "ce_1" });
+ const res = await delReq("ce_1", { scope: "following" });
+ expect(res.status).toBe(200);
+ expect(mockDelete).toHaveBeenCalledWith({}, "ce_1", "ws1");
+ expect(mockUpdate).not.toHaveBeenCalled();
+ });
+
+ it("scope=following with occurrence_at on the next fire deletes the parent", async () => {
+ mockGet.mockResolvedValue(sourceDaily());
+ mockDelete.mockResolvedValue({ id: "ce_1" });
+ const res = await delReq("ce_1", {
+ scope: "following",
+ occurrence_at: "2026-04-17T09:00:00.000Z",
+ });
+ expect(res.status).toBe(200);
+ expect(mockDelete).toHaveBeenCalledWith({}, "ce_1", "ws1");
+ });
+
+ it("scope=following with a future occurrence_at clips repeat_stop_at 1ms earlier", async () => {
+ mockGet.mockResolvedValue(sourceDaily());
+ mockUpdate.mockResolvedValue({ id: "ce_1" });
+ const res = await delReq("ce_1", {
+ scope: "following",
+ occurrence_at: "2026-04-20T09:00:00.000Z",
+ });
+ expect(res.status).toBe(200);
+ expect(mockUpdate).toHaveBeenCalledWith({}, "ce_1", "ws1", {
+ repeatStopAt: "2026-04-20T08:59:59.999Z",
+ });
+ expect(mockDelete).not.toHaveBeenCalled();
+ });
+
+ it("400s on a malformed body", async () => {
+ mockGet.mockResolvedValue(sourceDaily());
+ const res = await delReq("ce_1", { scope: "bogus" });
+ expect(res.status).toBe(400);
+ });
+});
+
function sourceNonRepeating(overrides: Record<string, unknown> = {}) {
return {
id: "ce_1",
diff --git a/src/web/src/app/api/calendar/[id]/route.ts b/src/web/src/app/api/calendar/[id]/route.ts
index da1704c3b..c262b2f7b 100644
--- a/src/web/src/app/api/calendar/[id]/route.ts
+++ b/src/web/src/app/api/calendar/[id]/route.ts
@@ -3,6 +3,7 @@ import {
createDb,
queries,
UpdateCalendarEventRequestSchema,
+ DeleteCalendarEventRequestSchema,
isEmptyHtml,
computeNextScheduledAt,
} from "@alook/shared";
@@ -170,11 +171,118 @@ export const DELETE = withAuth(async (req, ctx) => {
const id = ctx.params?.id;
if (!id) return writeError("calendar event id is required", 400);
- const deleted = await queries.calendarEvent.deleteCalendarEvent(
+ // Body is optional: an empty payload keeps legacy "delete the whole row"
+ // behavior. Only validate when the caller actually sent one.
+ let body: { scope?: "this" | "following"; occurrence_at?: string } = {};
+ const rawText = await req.text();
+ if (rawText.trim()) {
+ let raw: unknown;
+ try {
+ raw = JSON.parse(rawText);
+ } catch {
+ return writeError("invalid request body", 400);
+ }
+ const parsed = DeleteCalendarEventRequestSchema.safeParse(raw);
+ if (!parsed.success) {
+ return writeError("validation error", 400);
+ }
+ body = parsed.data;
+ }
+
+ const source = await queries.calendarEvent.getCalendarEvent(
db,
id,
ws.workspaceId
);
- if (!deleted) return writeError("calendar event not found", 404);
- return writeJSON(calendarEventToResponse(deleted));
+ if (!source) return writeError("calendar event not found", 404);
+
+ const isRecurring = Boolean(source.repeatInterval);
+ const scope = body.scope;
+
+ // Non-recurring, or no scope given → full delete (covers legacy callers).
+ if (!scope || !isRecurring) {
+ const deleted = await queries.calendarEvent.deleteCalendarEvent(
+ db,
+ id,
+ ws.workspaceId
+ );
+ if (!deleted) return writeError("calendar event not found", 404);
+ return writeJSON(calendarEventToResponse(deleted));
+ }
+
+ const occurrenceAt = body.occurrence_at
+ ? new Date(body.occurrence_at).toISOString()
+ : source.scheduledAt;
+ const existingExceptions = source.exceptions ?? [];
+
+ if (scope === "this") {
+ if (occurrenceAt === source.scheduledAt) {
+ // Skip the next fire: advance parent to the following occurrence.
+ const next = computeNextScheduledAt(
+ source.scheduledAt,
+ source.repeatInterval!,
+ source.repeatStopAt ?? null,
+ source.scheduledAt,
+ existingExceptions
+ );
+ if (next === null) {
+ const deleted = await queries.calendarEvent.deleteCalendarEvent(
+ db,
+ id,
+ ws.workspaceId
+ );
+ if (!deleted) return writeError("calendar event not found", 404);
+ return writeJSON(calendarEventToResponse(deleted));
+ }
+ const advanced = await queries.calendarEvent.updateCalendarEvent(
+ db,
+ id,
+ ws.workspaceId,
+ { scheduledAt: next }
+ );
+ if (!advanced) return writeError("calendar event not found", 404);
+ return writeJSON(calendarEventToResponse(advanced));
+ }
+ // Skip a future occurrence: record it as an exception. No change to
+ // scheduled_at — the parent keeps firing on its normal cadence.
+ const nextExceptions = existingExceptions.includes(occurrenceAt)
+ ? existingExceptions
+ : [...existingExceptions, occurrenceAt];
+ const updated = await queries.calendarEvent.updateCalendarEvent(
+ db,
+ id,
+ ws.workspaceId,
+ { exceptions: nextExceptions }
+ );
+ if (!updated) return writeError("calendar event not found", 404);
+ return writeJSON(calendarEventToResponse(updated));
+ }
+
+ // scope === "following"
+ // If the cut point is the next fire (or earlier), the series has no
+ // remaining occurrences — just drop the row.
+ if (new Date(occurrenceAt).getTime() <= new Date(source.scheduledAt).getTime()) {
+ const deleted = await queries.calendarEvent.deleteCalendarEvent(
+ db,
+ id,
+ ws.workspaceId
+ );
+ if (!deleted) return writeError("calendar event not found", 404);
+ return writeJSON(calendarEventToResponse(deleted));
+ }
+
+ // Future cut point: clip the series one ms before the occurrence so
+ // everything from `occurrenceAt` onward is pruned by expandOccurrences
+ // (which breaks on `current > stopD`).
+ const clippedStop = new Date(
+ new Date(occurrenceAt).getTime() - 1
+ ).toISOString();
+ const updated = await queries.calendarEvent.updateCalendarEvent(
+ db,
+ id,
+ ws.workspaceId,
+ { repeatStopAt: clippedStop }
+ );
+ if (!updated) return writeError("calendar event not found", 404);
+ return writeJSON(calendarEventToResponse(updated));
});
diff --git a/src/web/src/app/globals.css b/src/web/src/app/globals.css
index 21a2dc813..5aef710a1 100644
--- a/src/web/src/app/globals.css
+++ b/src/web/src/app/globals.css
@@ -14,6 +14,7 @@
--font-mono: var(--font-dm-mono);
--font-heading: var(--font-dm-sans);
--font-display: var(--font-bricolage);
+ --font-news: var(--font-literata);
--font-brand: var(--font-caveat);
--color-sidebar-ring: var(--sidebar-ring);
--color-sidebar-border: var(--sidebar-border);
diff --git a/src/web/src/app/layout.tsx b/src/web/src/app/layout.tsx
index 1a5a383a3..c112650a4 100644
--- a/src/web/src/app/layout.tsx
+++ b/src/web/src/app/layout.tsx
@@ -1,5 +1,12 @@
import type { Metadata } from "next";
-import { DM_Sans, DM_Mono, Caveat, Bricolage_Grotesque, VT323 } from "next/font/google";
+import {
+ DM_Sans,
+ DM_Mono,
+ Caveat,
+ Bricolage_Grotesque,
+ VT323,
+ Literata,
+} from "next/font/google";
import { ThemeProvider } from "@/components/theme-provider";
import { ThemeScript } from "@/components/theme-script";
import { ToasterProvider } from "@/components/toaster-provider";
@@ -35,6 +42,12 @@ const vt323 = VT323({
weight: ["400"],
});
+const literata = Literata({
+ variable: "--font-literata",
+ subsets: ["latin"],
+ weight: ["400", "500", "600"],
+});
+
export const metadata: Metadata = {
title: "Alook",
@@ -61,7 +74,7 @@ export default function RootLayout({
return (
<html
lang="en"
- className={`${dmSans.variable} ${dmMono.variable} ${caveat.variable} ${bricolage.variable} ${vt323.variable} h-full antialiased`}
+ className={`${dmSans.variable} ${dmMono.variable} ${caveat.variable} ${bricolage.variable} ${vt323.variable} ${literata.variable} h-full antialiased`}
suppressHydrationWarning
>
<head>
diff --git a/src/web/src/components/calendar/calendar-date-picker.tsx b/src/web/src/components/calendar/calendar-date-picker.tsx
index 52dcd9771..12629366b 100644
--- a/src/web/src/components/calendar/calendar-date-picker.tsx
+++ b/src/web/src/components/calendar/calendar-date-picker.tsx
@@ -19,6 +19,12 @@ export interface CalendarDatePickerProps {
ariaLabel?: string;
/** Suppress the built-in CalendarDays icon in the trigger. */
hideIcon?: boolean;
+ /**
+ * When provided, the footer shows a "Clear" action while a value is set.
+ * Picks are still delivered through `onChange`; clearing is separate so
+ * required pickers (no clear affordance) can stay non-nullable.
+ */
+ onClear?: () => void;
}
function formatDisplay(d: Date): string {
@@ -44,6 +50,7 @@ export function CalendarDatePicker({
className,
ariaLabel = "Pick a date",
hideIcon = false,
+ onClear,
}: CalendarDatePickerProps) {
const [open, setOpen] = useState(false);
const initial = value ?? new Date();
@@ -156,7 +163,21 @@ export function CalendarDatePicker({
})}
</div>
- <div className="flex items-center justify-end pt-2 mt-1 border-t border-border/50">
+ <div className="flex items-center justify-between gap-3 pt-2 mt-1 border-t border-border/50">
+ {onClear && value ? (
+ <button
+ type="button"
+ onClick={() => {
+ onClear();
+ setOpen(false);
+ }}
+ className="text-[11px] text-muted-foreground hover:text-foreground transition-colors"
+ >
+ Clear
+ </button>
+ ) : (
+ <span aria-hidden />
+ )}
<button
type="button"
onClick={() => handleSelect(new Date())}
diff --git a/src/web/src/components/calendar/calendar-day-popover.tsx b/src/web/src/components/calendar/calendar-day-popover.tsx
index fa4e01746..e6ae05057 100644
--- a/src/web/src/components/calendar/calendar-day-popover.tsx
+++ b/src/web/src/components/calendar/calendar-day-popover.tsx
@@ -3,7 +3,8 @@
import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover";
import { cn } from "@/lib/utils";
import type { CalendarEvent, Agent } from "@alook/shared";
-import { agentChipOutline } from "./calendar-month-grid";
+import { Repeat } from "lucide-react";
+import { agentDot, agentInk } from "./calendar-month-grid";
export interface CalendarDayPopoverProps {
events: CalendarEvent[];
@@ -61,30 +62,44 @@ export function CalendarDayPopover({
{dateLabel}
</p>
<div className="flex flex-col gap-1">
- {sorted.map((ev) => (
- <button
- key={`${ev.id}@${ev.occurrence_at}`}
- type="button"
- onClick={() => {
- onOpenChange(false);
- onSelectEvent(ev);
- }}
- className={cn(
- "border flex items-center gap-2 rounded-sm px-1.5 py-1 text-left text-[11px] font-medium transition-colors",
- agentChipOutline(ev.agent_id)
- )}
- title={`${ev.title}${
- agentNameById.get(ev.agent_id)
- ? ` — ${agentNameById.get(ev.agent_id)}`
- : ""
- }`}
- >
- <span className="shrink-0 text-[10px] opacity-70 tabular-nums">
- {timeLabel(ev.scheduled_at)}
- </span>
- <span className="truncate">{ev.title}</span>
- </button>
- ))}
+ {sorted.map((ev) => {
+ const isRecurring = Boolean(ev.repeat_interval);
+ return (
+ <button
+ key={`${ev.id}@${ev.occurrence_at}`}
+ type="button"
+ onClick={() => {
+ onOpenChange(false);
+ onSelectEvent(ev);
+ }}
+ className="flex items-center gap-2 rounded-sm px-1.5 py-1 text-left text-[11px] font-medium text-foreground/85 hover:bg-accent/60 transition-colors"
+ title={`${isRecurring ? "Recurring · " : ""}${ev.title}${
+ agentNameById.get(ev.agent_id)
+ ? ` — ${agentNameById.get(ev.agent_id)}`
+ : ""
+ }`}
+ >
+ {isRecurring ? (
+ <Repeat
+ aria-hidden
+ className={cn("size-3 shrink-0", agentInk(ev.agent_id))}
+ />
+ ) : (
+ <span
+ aria-hidden
+ className={cn(
+ "size-1.5 shrink-0 rounded-full",
+ agentDot(ev.agent_id)
+ )}
+ />
+ )}
+ <span className="shrink-0 text-[10px] text-muted-foreground tabular-nums">
+ {timeLabel(ev.scheduled_at)}
+ </span>
+ <span className="truncate">{ev.title}</span>
+ </button>
+ );
+ })}
</div>
</div>
</PopoverContent>
diff --git a/src/web/src/components/calendar/calendar-event-sheet.tsx b/src/web/src/components/calendar/calendar-event-sheet.tsx
index 1efa266d9..b5434f711 100644
--- a/src/web/src/components/calendar/calendar-event-sheet.tsx
+++ b/src/web/src/components/calendar/calendar-event-sheet.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useEffect, useMemo, useState } from "react";
+import { useEffect, useMemo, useRef, useState } from "react";
import { toast } from "sonner";
import {
Sheet,
@@ -69,7 +69,10 @@ export interface CalendarEventSheetProps {
event: CalendarEvent,
patch: UpdateCalendarEventRequest
) => Promise<void>;
- onDelete?: (event: CalendarEvent) => void;
+ onDelete?: (
+ event: CalendarEvent,
+ args?: { scope?: "this" | "following"; occurrence_at?: string }
+ ) => void;
}
function pad(n: number) {
@@ -138,6 +141,11 @@ interface RecurringScopeDialogProps {
onOpenChange: (o: boolean) => void;
onConfirm: (scope: "this" | "following") => void;
loading?: boolean;
+ title: string;
+ description: string;
+ confirmLabel: string;
+ loadingLabel: string;
+ confirmVariant?: "default" | "destructive";
}
function RecurringScopeDialog({
@@ -145,6 +153,11 @@ function RecurringScopeDialog({
onOpenChange,
onConfirm,
loading,
+ title,
+ description,
+ confirmLabel,
+ loadingLabel,
+ confirmVariant = "default",
}: RecurringScopeDialogProps) {
const [scope, setScope] = useState<"this" | "following">("this");
useEffect(() => {
@@ -155,10 +168,8 @@ function RecurringScopeDialog({
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent showCloseButton={false}>
<DialogHeader>
- <DialogTitle>Update recurring event</DialogTitle>
- <DialogDescription>
- How should this change apply?
- </DialogDescription>
+ <DialogTitle>{title}</DialogTitle>
+ <DialogDescription>{description}</DialogDescription>
</DialogHeader>
<div className="flex flex-col gap-1.5 py-1">
{(
@@ -205,10 +216,11 @@ function RecurringScopeDialog({
</Button>
<Button
size="sm"
+ variant={confirmVariant}
onClick={() => onConfirm(scope)}
disabled={loading}
>
- {loading ? "Saving..." : "Update"}
+ {loading ? loadingLabel : confirmLabel}
</Button>
</DialogFooter>
</DialogContent>
@@ -240,6 +252,18 @@ export function CalendarEventSheet({
const [repeat, setRepeat] = useState("");
const [stopDate, setStopDate] = useState<Date | null>(null);
const [scopeOpen, setScopeOpen] = useState(false);
+ const [deleteScopeOpen, setDeleteScopeOpen] = useState(false);
+ const descriptionRef = useRef<HTMLDivElement | null>(null);
+ const formRef = useRef<HTMLFormElement | null>(null);
+
+ const focusDescription = () => {
+ // TipTap renders its ProseMirror root as [contenteditable="true"] inside
+ // the wrapper — there's no public ref, so query for it on demand.
+ const node = descriptionRef.current?.querySelector<HTMLElement>(
+ '[contenteditable="true"]'
+ );
+ node?.focus();
+ };
useEffect(() => {
if (!open) return;
@@ -393,6 +417,52 @@ export function CalendarEventSheet({
setScopeOpen(false);
};
+ const handleDeleteClick = () => {
+ if (!event) return;
+ if (event.repeat_interval) {
+ setDeleteScopeOpen(true);
+ return;
+ }
+ onDelete?.(event);
+ };
+
+ const handleDeleteScopeConfirm = (scope: "this" | "following") => {
+ if (!event) return;
+ onDelete?.(event, {
+ scope,
+ occurrence_at: event.occurrence_at ?? undefined,
+ });
+ setDeleteScopeOpen(false);
+ };
+
+ // Shift+Enter submits from anywhere in the sheet — including inside the
+ // description editor, where TipTap would otherwise insert a hard break.
+ // Capture-phase so we beat the editor's keydown handler.
+ const handleSubmitShortcut = (e: React.KeyboardEvent) => {
+ if (e.key !== "Enter" || !e.shiftKey) return;
+ e.preventDefault();
+ e.stopPropagation();
+ if (mode === "create") {
+ formRef.current?.requestSubmit();
+ } else {
+ void handleEditSave();
+ }
+ };
+
+ // Inline kbd hint rendered inside the submit button. Uses the button's own
+ // foreground colour at reduced opacity so it reads on the primary fill in
+ // both themes without needing a separate palette.
+ const inlineSubmitHint = (
+ <kbd
+ aria-hidden
+ className="mr-1 hidden sm:inline-flex items-center gap-0.5 font-sans font-medium leading-none opacity-60"
+ >
+ <span>⇧</span>
+ <span>+</span>
+ <span>⏎</span>
+ </kbd>
+ );
+
const a11yTitle = mode === "edit"
? title.trim() || "Untitled event"
: title.trim() || "New calendar event";
@@ -402,12 +472,21 @@ export function CalendarEventSheet({
aria-label="Event title"
value={title}
onChange={(e) => setTitle(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ // Input is single-line, so Enter would otherwise submit the create
+ // form. Intercept and move focus into the description editor — a
+ // Notion-like flow the user expects after naming the event.
+ e.preventDefault();
+ focusDescription();
+ }
+ }}
placeholder={mode === "edit" ? "Untitled event" : "New event"}
autoFocus={mode === "create"}
className={cn(
- "h-auto border-0 bg-transparent px-0 py-0 font-display text-3xl font-semibold leading-tight",
+ "h-auto rounded-none border-0 bg-transparent px-0 py-0 font-news text-4xl md:text-5xl font-medium leading-[1.1] tracking-tight",
"shadow-none focus-visible:border-0 focus-visible:ring-0 focus-visible:ring-offset-0",
- "placeholder:text-muted-foreground/40"
+ "placeholder:text-muted-foreground/40 placeholder:font-normal"
)}
/>
);
@@ -468,7 +547,14 @@ export function CalendarEventSheet({
<select
aria-label="Repeat"
value={repeat}
- onChange={(e) => setRepeat(e.target.value)}
+ onChange={(e) => {
+ const next = e.target.value;
+ setRepeat(next);
+ // Stop date only makes sense with a repeat interval. Clearing
+ // the interval hides the row but must also drop the underlying
+ // state so validation / patch-building don't see stale values.
+ if (!next) setStopDate(null);
+ }}
className={GHOST_SELECT}
>
{REPEAT_OPTIONS.map((o) => (
@@ -484,6 +570,7 @@ export function CalendarEventSheet({
<CalendarDatePicker
value={stopDate}
onChange={(d) => setStopDate(d)}
+ onClear={() => setStopDate(null)}
placeholder="No end date"
min={dateValue}
ariaLabel="Stop date"
@@ -496,7 +583,7 @@ export function CalendarEventSheet({
);
const descriptionEditor = (
- <div>
+ <div ref={descriptionRef}>
<MarkdownEditor
key={event?.id ?? "new"}
value={description}
@@ -515,7 +602,12 @@ export function CalendarEventSheet({
<SheetContent className="data-[side=right]:inset-y-2 data-[side=right]:right-2 data-[side=right]:h-auto data-[side=right]:rounded-xl data-[side=right]:border data-[side=right]:border-l">
<SheetTitle className="sr-only">{a11yTitle}</SheetTitle>
{mode === "create" ? (
- <form onSubmit={handleCreateSubmit} className="flex flex-1 flex-col min-h-0">
+ <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}
@@ -530,12 +622,20 @@ export function CalendarEventSheet({
Cancel
</Button>
<Button type="submit" disabled={submitting || !agents.length}>
- {submitting ? "Creating..." : "Create event"}
+ {submitting ? "Creating..." : (
+ <>
+ {inlineSubmitHint}
+ Create event
+ </>
+ )}
</Button>
</SheetFooter>
</form>
) : (
- <>
+ <div
+ 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}
@@ -544,7 +644,7 @@ export function CalendarEventSheet({
<SheetFooter className="sm:justify-between">
<Button
variant="destructive"
- onClick={() => event && onDelete?.(event)}
+ onClick={handleDeleteClick}
disabled={deleting || saving}
>
{deleting ? "Deleting..." : "Delete"}
@@ -561,11 +661,16 @@ export function CalendarEventSheet({
onClick={handleEditSave}
disabled={saving || !dirty}
>
- {saving ? "Saving..." : "Save"}
+ {saving ? "Saving..." : (
+ <>
+ {inlineSubmitHint}
+ Save
+ </>
+ )}
</Button>
</div>
</SheetFooter>
- </>
+ </div>
)}
</SheetContent>
</Sheet>
@@ -574,6 +679,21 @@ export function CalendarEventSheet({
onOpenChange={setScopeOpen}
onConfirm={handleScopeConfirm}
loading={saving}
+ title="Update recurring event"
+ description="How should this change apply?"
+ confirmLabel="Update"
+ loadingLabel="Saving..."
+ />
+ <RecurringScopeDialog
+ open={deleteScopeOpen}
+ onOpenChange={setDeleteScopeOpen}
+ onConfirm={handleDeleteScopeConfirm}
+ loading={deleting}
+ title="Delete recurring event"
+ description="How much of the series should be removed?"
+ confirmLabel="Delete"
+ loadingLabel="Deleting..."
+ confirmVariant="destructive"
/>
</>
);
diff --git a/src/web/src/components/calendar/calendar-month-grid.test.ts b/src/web/src/components/calendar/calendar-month-grid.test.ts
index 6b957b7fd..c65933750 100644
--- a/src/web/src/components/calendar/calendar-month-grid.test.ts
+++ b/src/web/src/components/calendar/calendar-month-grid.test.ts
@@ -2,7 +2,8 @@ import { describe, it, expect } from "vitest";
import {
buildMonthCells,
agentColor,
- agentChipOutline,
+ agentDot,
+ agentInk,
dateKey,
sameDay,
isTodayMonth,
@@ -78,26 +79,43 @@ describe("agentColor", () => {
});
});
-describe("agentChipOutline", () => {
+describe("agentDot", () => {
it("is deterministic for the same id", () => {
- expect(agentChipOutline("ag_1")).toBe(agentChipOutline("ag_1"));
+ expect(agentDot("ag_1")).toBe(agentDot("ag_1"));
});
it("cycles through the palette", () => {
const set = new Set([
- agentChipOutline("ag_a"),
- agentChipOutline("ag_bbb"),
- agentChipOutline("ag_zzz"),
- agentChipOutline("ag_1234567"),
+ agentDot("ag_a"),
+ agentDot("ag_bbb"),
+ agentDot("ag_zzz"),
+ agentDot("ag_1234567"),
]);
expect(set.size).toBeGreaterThan(1);
});
- it("returns a class string containing border-, bg-transparent, and hover:bg-", () => {
- const cls = agentChipOutline("ag_1");
- expect(cls).toMatch(/border-/);
- expect(cls).toContain("bg-transparent");
- expect(cls).toMatch(/hover:bg-/);
+ it("first space-separated token is a bg- class", () => {
+ expect(agentDot("ag_1").split(" ")[0]).toMatch(/^bg-/);
+ });
+});
+
+describe("agentInk", () => {
+ it("is deterministic for the same id", () => {
+ expect(agentInk("ag_1")).toBe(agentInk("ag_1"));
+ });
+
+ it("cycles through the palette", () => {
+ const set = new Set([
+ agentInk("ag_a"),
+ agentInk("ag_bbb"),
+ agentInk("ag_zzz"),
+ agentInk("ag_1234567"),
+ ]);
+ expect(set.size).toBeGreaterThan(1);
+ });
+
+ it("first space-separated token is a text- class", () => {
+ expect(agentInk("ag_1").split(" ")[0]).toMatch(/^text-/);
});
});
diff --git a/src/web/src/components/calendar/calendar-month-grid.tsx b/src/web/src/components/calendar/calendar-month-grid.tsx
index bcb9b1b97..e86aa84bc 100644
--- a/src/web/src/components/calendar/calendar-month-grid.tsx
+++ b/src/web/src/components/calendar/calendar-month-grid.tsx
@@ -2,7 +2,7 @@
import { cn } from "@/lib/utils";
import type { CalendarEvent, Agent } from "@alook/shared";
-import { ChevronLeft, ChevronRight } from "lucide-react";
+import { ChevronLeft, ChevronRight, Repeat } from "lucide-react";
import { Button } from "@/components/ui/button";
import { CalendarDayPopover } from "./calendar-day-popover";
import { CalendarDatePicker } from "./calendar-date-picker";
@@ -24,14 +24,28 @@ function agentColor(agentId: string): string {
// Tailwind v4 JIT only picks up classes that appear literally in source —
// so each palette entry must be a fully-enumerated class string.
-function agentChipOutline(agentId: string): string {
+function agentDot(agentId: string): string {
const palette = [
- "border-[oklch(0.55_0.12_60)] text-[oklch(0.35_0.09_60)] bg-transparent hover:bg-[oklch(0.95_0.03_60)] dark:text-[oklch(0.82_0.08_60)] dark:hover:bg-[oklch(0.25_0.03_60)]",
- "border-[oklch(0.55_0.11_120)] text-[oklch(0.35_0.09_120)] bg-transparent hover:bg-[oklch(0.95_0.03_120)] dark:text-[oklch(0.82_0.08_120)] dark:hover:bg-[oklch(0.25_0.03_120)]",
- "border-[oklch(0.55_0.11_220)] text-[oklch(0.35_0.09_220)] bg-transparent hover:bg-[oklch(0.95_0.03_220)] dark:text-[oklch(0.82_0.08_220)] dark:hover:bg-[oklch(0.25_0.03_220)]",
- "border-[oklch(0.55_0.12_30)] text-[oklch(0.35_0.09_30)] bg-transparent hover:bg-[oklch(0.95_0.03_30)] dark:text-[oklch(0.82_0.08_30)] dark:hover:bg-[oklch(0.25_0.03_30)]",
- "border-[oklch(0.55_0.11_280)] text-[oklch(0.35_0.09_280)] bg-transparent hover:bg-[oklch(0.95_0.03_280)] dark:text-[oklch(0.82_0.08_280)] dark:hover:bg-[oklch(0.25_0.03_280)]",
- "border-[oklch(0.55_0.11_160)] text-[oklch(0.35_0.09_160)] bg-transparent hover:bg-[oklch(0.95_0.03_160)] dark:text-[oklch(0.82_0.08_160)] dark:hover:bg-[oklch(0.25_0.03_160)]",
+ "bg-[oklch(0.62_0.13_60)] dark:bg-[oklch(0.72_0.11_60)]",
+ "bg-[oklch(0.62_0.12_120)] dark:bg-[oklch(0.72_0.10_120)]",
+ "bg-[oklch(0.62_0.12_220)] dark:bg-[oklch(0.72_0.10_220)]",
+ "bg-[oklch(0.62_0.13_30)] dark:bg-[oklch(0.72_0.11_30)]",
+ "bg-[oklch(0.62_0.12_280)] dark:bg-[oklch(0.72_0.10_280)]",
+ "bg-[oklch(0.62_0.12_160)] dark:bg-[oklch(0.72_0.10_160)]",
+ ];
+ let h = 0;
+ for (let i = 0; i < agentId.length; i++) h = (h * 31 + agentId.charCodeAt(i)) | 0;
+ return palette[Math.abs(h) % palette.length]!;
+}
+
+function agentInk(agentId: string): string {
+ const palette = [
+ "text-[oklch(0.52_0.14_60)] dark:text-[oklch(0.78_0.11_60)]",
+ "text-[oklch(0.52_0.13_120)] dark:text-[oklch(0.78_0.10_120)]",
+ "text-[oklch(0.52_0.13_220)] dark:text-[oklch(0.78_0.10_220)]",
+ "text-[oklch(0.52_0.14_30)] dark:text-[oklch(0.78_0.11_30)]",
+ "text-[oklch(0.52_0.13_280)] dark:text-[oklch(0.78_0.10_280)]",
+ "text-[oklch(0.52_0.13_160)] dark:text-[oklch(0.78_0.10_160)]",
];
let h = 0;
for (let i = 0; i < agentId.length; i++) h = (h * 31 + agentId.charCodeAt(i)) | 0;
@@ -280,34 +294,51 @@ export function CalendarMonthGrid({
</span>
</div>
<div className="flex flex-col gap-1">
- {dayEvents.slice(0, 3).map((ev) => (
- <span
- key={`${ev.id}@${ev.occurrence_at}`}
- role="button"
- tabIndex={-1}
- onClick={(e) => {
- e.stopPropagation();
- onSelectEvent(ev);
- }}
- onKeyDown={(e) => {
- if (e.key === "Enter" || e.key === " ") {
+ {dayEvents.slice(0, 3).map((ev) => {
+ const isRecurring = Boolean(ev.repeat_interval);
+ return (
+ <span
+ key={`${ev.id}@${ev.occurrence_at}`}
+ role="button"
+ tabIndex={-1}
+ onClick={(e) => {
e.stopPropagation();
onSelectEvent(ev);
- }
- }}
- className={cn(
- "border truncate rounded-sm px-1.5 py-0.5 text-[10px] font-medium transition-colors",
- agentChipOutline(ev.agent_id)
- )}
- title={`${ev.title}${
- agentNameById.get(ev.agent_id)
- ? ` — ${agentNameById.get(ev.agent_id)}`
- : ""
- }`}
- >
- {ev.title}
- </span>
- ))}
+ }}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" || e.key === " ") {
+ e.stopPropagation();
+ 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"
+ title={`${isRecurring ? "Recurring · " : ""}${ev.title}${
+ agentNameById.get(ev.agent_id)
+ ? ` — ${agentNameById.get(ev.agent_id)}`
+ : ""
+ }`}
+ >
+ {isRecurring ? (
+ <Repeat
+ aria-hidden
+ className={cn(
+ "size-2.5 shrink-0",
+ agentInk(ev.agent_id)
+ )}
+ />
+ ) : (
+ <span
+ aria-hidden
+ className={cn(
+ "size-1.5 shrink-0 rounded-full",
+ agentDot(ev.agent_id)
+ )}
+ />
+ )}
+ <span className="truncate">{ev.title}</span>
+ </span>
+ );
+ })}
{hiddenCount > 0 && (
<CalendarDayPopover
date={cell.date}
@@ -329,4 +360,4 @@ export function CalendarMonthGrid({
);
}
-export { agentColor, agentChipOutline };
+export { agentColor, agentDot, agentInk };
diff --git a/src/web/src/lib/api.ts b/src/web/src/lib/api.ts
index d4513591d..02d732ccc 100644
--- a/src/web/src/lib/api.ts
+++ b/src/web/src/lib/api.ts
@@ -6,6 +6,7 @@ import type {
CreateAgentRequest,
CreateCalendarEventRequest,
UpdateCalendarEventRequest,
+ DeleteCalendarEventRequest,
UpdateAgentRequest,
Email,
LoginResponse,
@@ -270,9 +271,19 @@ export const updateCalendarEvent = (
body: JSON.stringify(patch),
});
-export const deleteCalendarEvent = (id: string, workspaceId: string) =>
+export const deleteCalendarEvent = (
+ id: string,
+ workspaceId: string,
+ body?: DeleteCalendarEventRequest
+) =>
apiFetch<CalendarEvent>(`/api/calendar/${id}${wsQuery(workspaceId)}`, {
method: "DELETE",
+ ...(body && body.scope
+ ? {
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(body),
+ }
+ : {}),
});
// Auth (Better Auth — redirect helpers only, actual auth via Better Auth client)