Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix: scroll-to-task targets trigger message instead of agent response

Gus47f1740023bc
diff --git a/src/cli/commands/calendar.ts b/src/cli/commands/calendar.ts
index 878c74de0..6646bf300 100644
--- a/src/cli/commands/calendar.ts
+++ b/src/cli/commands/calendar.ts
@@ -11,6 +11,8 @@ interface CalendarEventResponse {
title: string;
description: string | null;
scheduled_at: string;
+ occurrence_at?: string;
+ collapsed_count?: number | null;
repeat_interval: string | null;
repeat_stop_at: string | null;
last_triggered_at: string | null;
@@ -199,7 +201,7 @@ export function calendarCommand(): Command {
}
for (const ev of events) {
const repeatBadge = ev.repeat_interval
- ? ` [every ${ev.repeat_interval}${ev.repeat_stop_at ? ` until ${formatLocalDatetime(ev.repeat_stop_at)}` : ""}]`
+ ? ` [every ${ev.repeat_interval}${ev.collapsed_count ? ` · ${ev.collapsed_count} occurrences` : ""}${ev.repeat_stop_at ? ` until ${formatLocalDatetime(ev.repeat_stop_at)}` : ""}]`
: "";
const descBadge = ev.description ? " [has description]" : "";
console.log(
diff --git a/src/shared/src/db/queries/calendar-event.ts b/src/shared/src/db/queries/calendar-event.ts
index 14f918e83..fff018fce 100644
--- a/src/shared/src/db/queries/calendar-event.ts
+++ b/src/shared/src/db/queries/calendar-event.ts
@@ -282,6 +282,21 @@ export function expandOccurrences(
return out;
}
+/**
+ * Returns how many times a recurring event fires per day.
+ * Used to decide whether to collapse high-frequency events (threshold: >5/day).
+ */
+export function getOccurrencesPerDay(repeatInterval: string): number {
+ const match = /^(\d+)(min|hour|day|week|month)$/.exec(repeatInterval);
+ if (!match) return 1;
+ const amount = parseInt(match[1]!, 10);
+ const unit = match[2]!;
+ if (unit === "month" || unit === "week" || unit === "day") return 1;
+ if (amount === 0) return 1;
+ const intervalSeconds = unit === "min" ? amount * 60 : amount * 3600;
+ return Math.floor(86400 / intervalSeconds);
+}
+
export function computeNextScheduledAt(
currentScheduledAt: string,
repeatInterval: string,
diff --git a/src/shared/src/db/queries/message.ts b/src/shared/src/db/queries/message.ts
index dcc7b603e..16af167a4 100644
--- a/src/shared/src/db/queries/message.ts
+++ b/src/shared/src/db/queries/message.ts
@@ -186,6 +186,10 @@ export async function countBufferedMessages(db: Database, conversationId: string
return rows[0]?.count ?? 0;
}
+export async function updateMessageTaskId(db: Database, messageId: string, taskId: string) {
+ await db.update(message).set({ taskId }).where(eq(message.id, messageId));
+}
+
export async function listMessagesAroundTask(
db: Database,
conversationId: string,
diff --git a/src/shared/src/index.ts b/src/shared/src/index.ts
index d60c791cc..b5351537b 100644
--- a/src/shared/src/index.ts
+++ b/src/shared/src/index.ts
@@ -219,6 +219,7 @@ export {
addRepeatInterval,
computeNextScheduledAt,
expandOccurrences,
+ getOccurrencesPerDay,
} from "./db/queries/calendar-event";
// Utils
diff --git a/src/shared/src/schemas.ts b/src/shared/src/schemas.ts
index 1fc43ee57..82a0de528 100644
--- a/src/shared/src/schemas.ts
+++ b/src/shared/src/schemas.ts
@@ -332,6 +332,7 @@ export const CalendarEventApiSchema = z.object({
description: z.string().nullable(),
scheduled_at: z.string(),
occurrence_at: z.string(),
+ collapsed_count: z.number().nullable().optional(),
repeat_interval: z.string().nullable(),
repeat_stop_at: z.string().nullable(),
last_triggered_at: z.string().nullable(),
diff --git a/src/shared/src/types.ts b/src/shared/src/types.ts
index 1be304bc2..c2e79ea67 100644
--- a/src/shared/src/types.ts
+++ b/src/shared/src/types.ts
@@ -84,6 +84,7 @@ export interface CalendarEvent {
* row represents.
*/
occurrence_at: string;
+ collapsed_count?: number | null;
repeat_interval: string | null;
repeat_stop_at: string | null;
last_triggered_at: string | null;
diff --git a/src/shared/test/calendar-collapse.test.ts b/src/shared/test/calendar-collapse.test.ts
new file mode 100644
index 000000000..093f2dc94
--- /dev/null
+++ b/src/shared/test/calendar-collapse.test.ts
@@ -0,0 +1,67 @@
+import { describe, it, expect } from "vitest";
+import { getOccurrencesPerDay, expandOccurrences } from "../src/db/queries/calendar-event";
+
+describe("calendar collapse integration", () => {
+ const COLLAPSE_THRESHOLD = 5;
+
+ it("5min recurring event collapses (not expanded individually)", () => {
+ const interval = "5min";
+ const perDay = getOccurrencesPerDay(interval);
+ expect(perDay).toBeGreaterThan(COLLAPSE_THRESHOLD);
+ expect(perDay).toBe(288);
+ });
+
+ it("6hour recurring event does NOT collapse and expands to 4 occurrences", () => {
+ const interval = "6hour";
+ const perDay = getOccurrencesPerDay(interval);
+ expect(perDay).toBeLessThanOrEqual(COLLAPSE_THRESHOLD);
+
+ const from = "2026-05-08T00:00:00.000Z";
+ const to = "2026-05-08T23:59:59.999Z";
+ const scheduledAt = "2026-05-08T00:00:00.000Z";
+ const occurrences = expandOccurrences(scheduledAt, interval, null, [], from, to);
+ expect(occurrences).toHaveLength(4);
+ });
+
+ it("mixed events: 5min collapses, 8hour does not", () => {
+ const fiveMin = getOccurrencesPerDay("5min");
+ const eightHour = getOccurrencesPerDay("8hour");
+ expect(fiveMin).toBeGreaterThan(COLLAPSE_THRESHOLD);
+ expect(eightHour).toBeLessThanOrEqual(COLLAPSE_THRESHOLD);
+ expect(eightHour).toBe(3);
+
+ const from = "2026-05-08T00:00:00.000Z";
+ const to = "2026-05-08T23:59:59.999Z";
+ const occurrences = expandOccurrences("2026-05-08T00:00:00.000Z", "8hour", null, [], from, to);
+ expect(occurrences).toHaveLength(3);
+ });
+
+ it("collapsed event produces one row per day across multi-day range", () => {
+ const interval = "5min";
+ const perDay = getOccurrencesPerDay(interval);
+ expect(perDay).toBe(288);
+
+ // Simulating what the API route does: for a 3-day range, emit 3 collapsed rows
+ const from = new Date("2026-05-08T00:00:00.000Z");
+ const to = new Date("2026-05-10T23:59:59.999Z");
+ const scheduledAt = new Date("2026-05-08T09:00:00.000Z");
+
+ const collapsedRows: { date: string; collapsed_count: number }[] = [];
+ const cursor = new Date(Date.UTC(from.getUTCFullYear(), from.getUTCMonth(), from.getUTCDate()));
+ const endDay = new Date(Date.UTC(to.getUTCFullYear(), to.getUTCMonth(), to.getUTCDate()));
+ while (cursor <= endDay) {
+ if (cursor >= new Date(Date.UTC(scheduledAt.getUTCFullYear(), scheduledAt.getUTCMonth(), scheduledAt.getUTCDate()))) {
+ collapsedRows.push({
+ date: cursor.toISOString().slice(0, 10),
+ collapsed_count: perDay,
+ });
+ }
+ cursor.setUTCDate(cursor.getUTCDate() + 1);
+ }
+
+ expect(collapsedRows).toHaveLength(3);
+ expect(collapsedRows[0]!.collapsed_count).toBe(288);
+ expect(collapsedRows[0]!.date).toBe("2026-05-08");
+ expect(collapsedRows[2]!.date).toBe("2026-05-10");
+ });
+});
diff --git a/src/shared/test/calendar-event.test.ts b/src/shared/test/calendar-event.test.ts
new file mode 100644
index 000000000..6715ba751
--- /dev/null
+++ b/src/shared/test/calendar-event.test.ts
@@ -0,0 +1,40 @@
+import { describe, it, expect } from "vitest";
+import { getOccurrencesPerDay } from "../src/db/queries/calendar-event";
+
+describe("getOccurrencesPerDay", () => {
+ it("5min returns 288", () => {
+ expect(getOccurrencesPerDay("5min")).toBe(288);
+ });
+
+ it("4hour returns 6 (>5, should collapse)", () => {
+ expect(getOccurrencesPerDay("4hour")).toBe(6);
+ });
+
+ it("6hour returns 4 (≤5, no collapse)", () => {
+ expect(getOccurrencesPerDay("6hour")).toBe(4);
+ });
+
+ it("1day returns 1 (never collapses)", () => {
+ expect(getOccurrencesPerDay("1day")).toBe(1);
+ });
+
+ it("1week returns 1 (never collapses)", () => {
+ expect(getOccurrencesPerDay("1week")).toBe(1);
+ });
+
+ it("30min returns 48 (>5, should collapse)", () => {
+ expect(getOccurrencesPerDay("30min")).toBe(48);
+ });
+
+ it("1hour returns 24 (>5, should collapse)", () => {
+ expect(getOccurrencesPerDay("1hour")).toBe(24);
+ });
+
+ it("1month returns 1 (never collapses)", () => {
+ expect(getOccurrencesPerDay("1month")).toBe(1);
+ });
+
+ it("invalid format returns 1", () => {
+ expect(getOccurrencesPerDay("bogus")).toBe(1);
+ });
+});
diff --git a/src/web/src/app/(app)/w/[slug]/agents/[id]/layout.tsx b/src/web/src/app/(app)/w/[slug]/agents/[id]/layout.tsx
index ec8a100b3..d213cfcd6 100644
--- a/src/web/src/app/(app)/w/[slug]/agents/[id]/layout.tsx
+++ b/src/web/src/app/(app)/w/[slug]/agents/[id]/layout.tsx
@@ -11,7 +11,7 @@ import { AgentEditForm } from "@/components/agent-edit-form";
import { ChannelBar } from "@/components/channel-bar";
import { Skeleton } from "@/components/ui/skeleton";
import { AgentStatusBadge } from "@/components/agent-status-badge";
-import { CalendarDays, FolderOpen, History, Mail, MessageSquare, MoreHorizontal, Pencil, Trash2, Video, X } from "lucide-react";
+import { FolderOpen, GitBranch, History, Mail, MessageSquare, MoreHorizontal, Pencil, Trash2, Video, X } from "lucide-react";
import {
DropdownMenu,
DropdownMenuTrigger,
@@ -180,11 +180,11 @@ export default function AgentDetailLayout({ children }: { children: ReactNode })
}`}>Files</span>
</Link>
<Link
- href={`/w/${slug}/calendar?agents=${agentId}`}
+ href={`/w/${slug}/threads?agentId=${agentId}`}
className="group inline-flex items-center rounded-lg text-xs text-muted-foreground h-7 px-2 hover:bg-muted hover:text-foreground transition-all"
>
- <CalendarDays className="size-3 shrink-0" />
- <span className="max-w-0 opacity-0 group-hover:max-w-20 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300 overflow-hidden transition-all duration-500 ease-out">Calendar</span>
+ <GitBranch className="size-3 shrink-0" />
+ <span className="max-w-0 opacity-0 group-hover:max-w-20 group-hover:opacity-100 group-hover:ml-1 group-hover:delay-300 overflow-hidden transition-all duration-500 ease-out">Threads</span>
</Link>
<div className="w-px h-4 bg-border mx-1" />
<button
@@ -249,11 +249,11 @@ export default function AgentDetailLayout({ children }: { children: ReactNode })
)}
<DropdownMenuItem
onClick={() =>
- router.push(`/w/${slug}/calendar?agents=${agentId}`)
+ router.push(`/w/${slug}/threads?agentId=${agentId}`)
}
>
- <CalendarDays className="size-3.5" />
- Calendar
+ <GitBranch className="size-3.5" />
+ Threads
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={() => setEditing(true)}>
diff --git a/src/web/src/app/(app)/w/[slug]/inbox/page.tsx b/src/web/src/app/(app)/w/[slug]/inbox/page.tsx
index 8b6092c37..7185dae7e 100644
--- a/src/web/src/app/(app)/w/[slug]/inbox/page.tsx
+++ b/src/web/src/app/(app)/w/[slug]/inbox/page.tsx
@@ -120,8 +120,8 @@ export default function InboxPage() {
const scrollRef = useRef<HTMLDivElement>(null);
const isFetchingRef = useRef(false);
- const loadInitial = useCallback(async () => {
- setLoading(true);
+ const loadInitial = useCallback(async (opts?: { silent?: boolean }) => {
+ if (!opts?.silent) setLoading(true);
try {
const result = await listInboxItems(workspaceId, { limit: INBOX_LIMIT });
setItems(result.items);
@@ -133,15 +133,21 @@ export default function InboxPage() {
}
}, [workspaceId]);
+ const refreshInboxCountRef = useRef(refreshInboxCount);
+ refreshInboxCountRef.current = refreshInboxCount;
+
useEffect(() => {
loadInitial();
- refreshInboxCount();
- }, [loadInitial, refreshInboxCount]);
+ }, [loadInitial]);
+
+ useEffect(() => {
+ refreshInboxCountRef.current();
+ }, []);
useEffect(() => {
return subscribeWs((msg: WsMessage) => {
if (msg.type === "task.updated" && (msg.status === "completed" || msg.status === "failed")) {
- loadInitial();
+ loadInitial({ silent: true });
}
});
}, [subscribeWs, loadInitial]);
diff --git a/src/web/src/app/api/calendar/route.ts b/src/web/src/app/api/calendar/route.ts
index 6989e5e1d..5ed1c517a 100644
--- a/src/web/src/app/api/calendar/route.ts
+++ b/src/web/src/app/api/calendar/route.ts
@@ -4,6 +4,7 @@ import {
queries,
CreateCalendarEventRequestSchema,
expandOccurrences,
+ getOccurrencesPerDay,
isEmptyHtml,
} from "@alook/shared";
import { getDb } from "@/lib/db";
@@ -36,29 +37,64 @@ export const GET = withAuth(async (req: NextRequest, ctx) => {
);
// Expand recurring rows into per-occurrence virtual rows within [from, to].
- // Non-recurring rows pass through with occurrence_at = scheduled_at.
+ // High-frequency events (>5 occurrences/day) are collapsed into one row per
+ // UTC day with a `collapsed_count` hint instead of expanding individually.
const out: (ReturnType<typeof calendarEventToResponse> & { _type?: string; _status?: string })[] = [];
for (const row of rows) {
if (!row.repeatInterval || !from || !to) {
out.push(calendarEventToResponse(row));
continue;
}
- const occurrences = expandOccurrences(
- row.scheduledAt,
- row.repeatInterval,
- row.repeatStopAt ?? null,
- row.exceptions ?? [],
- from,
- to
- );
- for (const occIso of occurrences) {
- out.push(
- calendarEventToResponse({
- ...row,
- scheduledAt: occIso,
- occurrenceAt: occIso,
- })
+ const perDay = getOccurrencesPerDay(row.repeatInterval);
+ if (perDay > 5) {
+ // Collapse: emit one representative row per UTC day in the range
+ const fromD = new Date(from);
+ const toD = new Date(to);
+ const startD = new Date(row.scheduledAt);
+ const stopD = row.repeatStopAt ? new Date(row.repeatStopAt) : null;
+
+ // Iterate UTC days in [from, to], capped at 366 days
+ const cursor = new Date(Date.UTC(fromD.getUTCFullYear(), fromD.getUTCMonth(), fromD.getUTCDate()));
+ const endDay = new Date(Date.UTC(toD.getUTCFullYear(), toD.getUTCMonth(), toD.getUTCDate()));
+ const startDay = new Date(Date.UTC(startD.getUTCFullYear(), startD.getUTCMonth(), startD.getUTCDate()));
+ let dayCount = 0;
+ while (cursor <= endDay && dayCount < 366) {
+ if (cursor >= startDay && (!stopD || cursor <= stopD)) {
+ // First occurrence time on this day: use the event's time-of-day
+ const occIso = new Date(Date.UTC(
+ cursor.getUTCFullYear(), cursor.getUTCMonth(), cursor.getUTCDate(),
+ startD.getUTCHours(), startD.getUTCMinutes(), startD.getUTCSeconds()
+ )).toISOString();
+ out.push(
+ calendarEventToResponse({
+ ...row,
+ scheduledAt: occIso,
+ occurrenceAt: occIso,
+ collapsedCount: perDay,
+ })
+ );
+ }
+ cursor.setUTCDate(cursor.getUTCDate() + 1);
+ dayCount++;
+ }
+ } else {
+ const occurrences = expandOccurrences(
+ row.scheduledAt,
+ row.repeatInterval,
+ row.repeatStopAt ?? null,
+ row.exceptions ?? [],
+ from,
+ to
);
+ for (const occIso of occurrences) {
+ out.push(
+ calendarEventToResponse({
+ ...row,
+ scheduledAt: occIso,
+ occurrenceAt: occIso,
+ })
+ );
+ }
}
}
@@ -77,6 +113,7 @@ export const GET = withAuth(async (req: NextRequest, ctx) => {
description: m.meetingUrl,
scheduled_at: m.scheduledAt,
occurrence_at: m.scheduledAt,
+ collapsed_count: null,
repeat_interval: null,
repeat_stop_at: null,
last_triggered_at: null,
diff --git a/src/web/src/app/api/conversations/[id]/messages/route.test.ts b/src/web/src/app/api/conversations/[id]/messages/route.test.ts
index 4cfe0f01b..140b87d6b 100644
--- a/src/web/src/app/api/conversations/[id]/messages/route.test.ts
+++ b/src/web/src/app/api/conversations/[id]/messages/route.test.ts
@@ -36,6 +36,7 @@ vi.mock("@alook/shared", async () => {
message: {
listMessages: (...args: any[]) => mockListMessages(...args),
createMessage: (...args: any[]) => mockCreateMessage(...args),
+ updateMessageTaskId: vi.fn().mockResolvedValue(undefined),
},
},
};
diff --git a/src/web/src/app/api/conversations/[id]/messages/route.ts b/src/web/src/app/api/conversations/[id]/messages/route.ts
index 4060829cb..b53fba1e9 100644
--- a/src/web/src/app/api/conversations/[id]/messages/route.ts
+++ b/src/web/src/app/api/conversations/[id]/messages/route.ts
@@ -203,6 +203,7 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {
parentTaskId: null,
},
);
+ queries.message.updateMessageTaskId(db, message.id, task.id).catch(() => {});
broadcastToUser(ctx.userId, { type: "task.updated", taskId: task.id, agentId: task.agentId, status: "queued" }).catch(() => {});
return writeJSON(
{ message: messageToResponse(message), task: taskToResponse(task) },
diff --git a/src/web/src/app/api/email/notify/route.test.ts b/src/web/src/app/api/email/notify/route.test.ts
index a99e72b17..f9c08bb04 100644
--- a/src/web/src/app/api/email/notify/route.test.ts
+++ b/src/web/src/app/api/email/notify/route.test.ts
@@ -35,6 +35,7 @@ vi.mock("@alook/shared", async () => {
},
message: {
createMessage: (...args: unknown[]) => mockCreateMessage(...args),
+ updateMessageTaskId: vi.fn().mockResolvedValue(undefined),
},
meetingSession: {
createMeetingSession: (...args: unknown[]) => mockCreateMeetingSession(...args),
diff --git a/src/web/src/app/api/email/notify/route.ts b/src/web/src/app/api/email/notify/route.ts
index 53cc85a60..8cdb0001e 100644
--- a/src/web/src/app/api/email/notify/route.ts
+++ b/src/web/src/app/api/email/notify/route.ts
@@ -129,6 +129,7 @@ export async function POST(req: NextRequest) {
const traceId = body.traceId || ("tr_" + nanoid());
const parentTaskId = body.traceId ? (body.sourceTaskId || null) : null;
const task = await taskService.enqueueTask(agent.id, conversationId, agent.workspaceId, prompt, TASK_TYPES.EMAIL_NOTIFICATION, { contextKey: conversationId, context, traceId, parentTaskId })
+ queries.message.updateMessageTaskId(db, msg.id, task.id).catch(() => {})
if (conversationType === TASK_TYPES.USER_DM_MESSAGE) {
broadcastToUser(agent.ownerId, {
diff --git a/src/web/src/app/api/issues/route.test.ts b/src/web/src/app/api/issues/route.test.ts
index 6e5bee5fa..c2c41b447 100644
--- a/src/web/src/app/api/issues/route.test.ts
+++ b/src/web/src/app/api/issues/route.test.ts
@@ -34,7 +34,7 @@ vi.mock("@alook/shared", async () => {
setLatestTask: (...a: unknown[]) => mockSetLatestTask(...a),
},
conversation: { createConversation: (...a: unknown[]) => mockCreateConversation(...a) },
- message: { createMessage: (...a: unknown[]) => mockCreateMessage(...a) },
+ message: { createMessage: (...a: unknown[]) => mockCreateMessage(...a), updateMessageTaskId: vi.fn().mockResolvedValue(undefined) },
artifact: { createArtifact: (...a: unknown[]) => mockCreateArtifact(...a) },
},
};
diff --git a/src/web/src/app/api/issues/route.ts b/src/web/src/app/api/issues/route.ts
index 5fa1dfb04..5f23ef3dd 100644
--- a/src/web/src/app/api/issues/route.ts
+++ b/src/web/src/app/api/issues/route.ts
@@ -182,6 +182,7 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {
parentTaskId: null,
}
);
+ queries.message.updateMessageTaskId(db, eventMessage.id, task.id).catch(() => {});
const issue = await queries.issue.setLatestTask(db, created.id, ws.workspaceId, task.id) ?? created;
broadcastToUser(ctx.userId, { type: "task.updated", taskId: task.id, agentId: task.agentId, status: "queued" }).catch(() => {});
return writeJSON(
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 6ac49ed50..e1a1a4405 100644
--- a/src/web/src/components/agent-chat/agent-chat-view.tsx
+++ b/src/web/src/components/agent-chat/agent-chat-view.tsx
@@ -1422,7 +1422,7 @@ export function AgentChatView() {
const isLastUser = messages.length > 0 && messages[messages.length - 1].id === msg.id;
const awaitingRun = isLastUser && !!activeTask && activeTask.status !== "running" && !["completed", "failed", "cancelled", "superseded"].includes(activeTask.status);
return (
- <div className="flex justify-end">
+ <div className="flex justify-end" {...(msg.task_id ? { "data-task-id": msg.task_id } : {})}>
<div className={cn(
"max-w-[80%] rounded-lg px-4 py-2 bg-primary text-primary-foreground text-base relative",
)}>
@@ -1444,7 +1444,7 @@ export function AgentChatView() {
})() : msg.role === "event" ? (() => {
const eventEmailId = msg.metadata?.emailId as string | undefined;
return (
- <div className="flex justify-start">
+ <div className="flex justify-start" {...(msg.task_id ? { "data-task-id": msg.task_id } : {})}>
<div
className={cn(
"w-full rounded-md border bg-muted/50 text-muted-foreground text-sm px-3 py-2 flex items-start gap-2",
diff --git a/src/web/src/components/app-sidebar.tsx b/src/web/src/components/app-sidebar.tsx
index b04fa3320..dab10008c 100644
--- a/src/web/src/components/app-sidebar.tsx
+++ b/src/web/src/components/app-sidebar.tsx
@@ -8,7 +8,7 @@ import type { Agent } from "@alook/shared";
import { useInboxCount } from "@/contexts/inbox-count-context";
import { Logo } from "@/components/logo";
import { cn } from "@/lib/utils";
-import { Monitor, SunMoon, Plus, CalendarDays, GitBranch, Settings, PinIcon, PinOffIcon, ArrowLeftRight, Home, CircleDot, Inbox } from "lucide-react";
+import { Monitor, SunMoon, Plus, CalendarDays, Settings, PinIcon, PinOffIcon, ArrowLeftRight, Home, CircleDot, Inbox } from "lucide-react";
import { Skeleton } from "@/components/ui/skeleton";
import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
import { useTheme } from "next-themes";
@@ -176,7 +176,6 @@ export function AppSidebar({ onNavigate }: { onNavigate?: () => void } = {}) {
const isHome = pathname === `${prefix}/home`;
const isRuntimes = pathname === `${prefix}/runtimes`;
const isCalendar = pathname === `${prefix}/calendar`;
- const isTraces = pathname.startsWith(`${prefix}/threads`);
const isInbox = pathname.startsWith(`${prefix}/inbox`);
const isIssues = pathname.startsWith(`${prefix}/issues`);
const isSettings = pathname === `${prefix}/settings`;
@@ -321,22 +320,6 @@ export function AppSidebar({ onNavigate }: { onNavigate?: () => void } = {}) {
<TooltipContent side="right">Calendar</TooltipContent>
</Tooltip>
- <Tooltip>
- <TooltipTrigger render={
- <button
- type="button"
- onClick={() => { router.push(`${prefix}/threads`); onNavigate?.(); }}
- className={cn(
- "flex items-center justify-center size-10 rounded-xl transition-colors duration-200 cursor-pointer",
- "text-muted-foreground hover:text-foreground hover:bg-accent",
- isTraces && "bg-accent text-foreground"
- )}
- />
- }>
- <GitBranch className="size-4" />
- </TooltipTrigger>
- <TooltipContent side="right">Threads</TooltipContent>
- </Tooltip>
</div>
{/* Agent avatars */}
diff --git a/src/web/src/components/calendar/calendar-agenda.tsx b/src/web/src/components/calendar/calendar-agenda.tsx
index 7545676c4..01e6ebbe7 100644
--- a/src/web/src/components/calendar/calendar-agenda.tsx
+++ b/src/web/src/components/calendar/calendar-agenda.tsx
@@ -142,6 +142,11 @@ export function CalendarAgenda({
{formatRepeatDisplay(ev.repeat_interval!)}
</span>
)}
+ {ev.collapsed_count != null && ev.collapsed_count > 1 && (
+ <span className="shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground">
+ &times; {ev.collapsed_count} today
+ </span>
+ )}
</button>
</li>
))}
diff --git a/src/web/src/components/calendar/calendar-month-grid.tsx b/src/web/src/components/calendar/calendar-month-grid.tsx
index 8a618310a..73e4b50a9 100644
--- a/src/web/src/components/calendar/calendar-month-grid.tsx
+++ b/src/web/src/components/calendar/calendar-month-grid.tsx
@@ -292,6 +292,9 @@ export function CalendarMonthGrid({
/>
)}
<span className="truncate">{ev.title}</span>
+ {ev.collapsed_count != null && ev.collapsed_count > 1 && (
+ <span className="shrink-0 text-[9px] text-muted-foreground">&times;{ev.collapsed_count}</span>
+ )}
</span>
);
})}
diff --git a/src/web/src/components/calendar/calendar-week-grid.tsx b/src/web/src/components/calendar/calendar-week-grid.tsx
index 0b2efc3bc..7e0964204 100644
--- a/src/web/src/components/calendar/calendar-week-grid.tsx
+++ b/src/web/src/components/calendar/calendar-week-grid.tsx
@@ -366,6 +366,9 @@ export function CalendarWeekGrid({
title={`${event.title}${agentName ? ` \u2014 ${agentName}` : ""}`}
>
{event.title}
+ {event.collapsed_count != null && event.collapsed_count > 1 && (
+ <span className="ml-0.5 opacity-70">&times;{event.collapsed_count}</span>
+ )}
</button>
);
})}
diff --git a/src/web/src/components/mobile-top-bar.tsx b/src/web/src/components/mobile-top-bar.tsx
index d00cef29f..ff590772f 100644
--- a/src/web/src/components/mobile-top-bar.tsx
+++ b/src/web/src/components/mobile-top-bar.tsx
@@ -1,7 +1,7 @@
"use client";
import { useRouter, usePathname } from "next/navigation";
-import { CalendarDays, CircleDot, GitBranch, Home } from "lucide-react";
+import { CalendarDays, CircleDot, Home } from "lucide-react";
import { useSidebarTrigger } from "@/components/workspace-shell";
import { useAgentContext } from "@/contexts/agent-context";
import { useWorkspace } from "@/contexts/workspace-context";
@@ -19,7 +19,6 @@ export function MobileTopBar() {
const isHomeActive = pathname === `/w/${slug}/home`;
const isCalendarActive = pathname.includes("/calendar");
- const isTracesActive = pathname.includes("/threads");
const isIssuesActive = pathname.includes("/issues");
const activeAgentMatch = pathname.match(/^\/w\/[^/]+\/agents\/([^/]+)/);
const activeAgentId = activeAgentMatch?.[1] ?? null;
@@ -100,19 +99,6 @@ export function MobileTopBar() {
<CircleDot className="size-4" />
</button>
- <button
- onClick={() => router.push(`/w/${slug}/threads`)}
- aria-label="Threads"
- className={cn(
- "shrink-0 p-1 rounded-md transition-colors",
- isTracesActive
- ? "text-foreground bg-muted"
- : "text-muted-foreground hover:text-foreground"
- )}
- >
- <GitBranch className="size-4" />
- </button>
-
<div className="flex-1 overflow-x-auto flex items-center gap-1.5 py-1 px-0.5 scrollbar-none">
{loading ? (
<Skeleton className="size-7 rounded-full" />
diff --git a/src/web/src/contexts/inbox-count-context.tsx b/src/web/src/contexts/inbox-count-context.tsx
index 8fa741ffe..68b22a8a2 100644
--- a/src/web/src/contexts/inbox-count-context.tsx
+++ b/src/web/src/contexts/inbox-count-context.tsx
@@ -36,21 +36,23 @@ export function InboxCountProvider({ children }: { children: ReactNode }) {
const prevCountRef = useRef<number | null>(null);
const pendingAgentIdRef = useRef<string | null>(null);
+ const agentsRef = useRef(agents);
+ agentsRef.current = agents;
+
const refresh = useCallback(() => {
getInboxCount(workspaceId).then((r) => {
const prev = prevCountRef.current;
prevCountRef.current = r.count;
setCount(r.count);
- // Only notify when count increases after initial load
if (prev !== null && r.count > prev) {
const agent = pendingAgentIdRef.current
- ? agents.find((a) => a.id === pendingAgentIdRef.current)
+ ? agentsRef.current.find((a) => a.id === pendingAgentIdRef.current)
: undefined;
sendTaskNotification("completed", agent?.name);
}
pendingAgentIdRef.current = null;
}).catch(() => {});
- }, [workspaceId, agents]);
+ }, [workspaceId]);
const decrement = useCallback(() => {
setCount((c) => {
diff --git a/src/web/src/lib/api/responses.ts b/src/web/src/lib/api/responses.ts
index 6fdc345b5..031b9d821 100644
--- a/src/web/src/lib/api/responses.ts
+++ b/src/web/src/lib/api/responses.ts
@@ -250,6 +250,7 @@ export function calendarEventToResponse(e: any) {
description: e.description ?? null,
scheduled_at: scheduled,
occurrence_at: occurrence,
+ collapsed_count: e.collapsedCount ?? null,
repeat_interval: e.repeatInterval ?? null,
repeat_stop_at: formatTimestampNullable(e.repeatStopAt),
last_triggered_at: formatTimestampNullable(e.lastTriggeredAt),
diff --git a/src/web/src/lib/services/task.test.ts b/src/web/src/lib/services/task.test.ts
index 33f1b44ba..55126109c 100644
--- a/src/web/src/lib/services/task.test.ts
+++ b/src/web/src/lib/services/task.test.ts
@@ -38,6 +38,7 @@ vi.mock("@alook/shared", () => ({
createMessage: vi.fn(),
activateNextBufferedMessage: vi.fn(),
revertToBuffered: vi.fn().mockResolvedValue(null),
+ updateMessageTaskId: vi.fn().mockResolvedValue(undefined),
},
conversation: {
getConversation: vi.fn(),
diff --git a/src/web/src/lib/services/task.ts b/src/web/src/lib/services/task.ts
index c6ed5cadc..d386cbee6 100644
--- a/src/web/src/lib/services/task.ts
+++ b/src/web/src/lib/services/task.ts
@@ -316,6 +316,8 @@ export class TaskService {
},
);
+ await messageQueries.updateMessageTaskId(this.db, activated.id, task.id);
+
broadcastToUser(userId, {
type: "followup.dispatched",
conversationId,