Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
Add Firehose and My Activity timeline views (#4931)
Jacob Beckermandc2c685cc187
diff --git a/apps/web/src/components/app/app-sidebar/sidebar.tsx b/apps/web/src/components/app/app-sidebar/sidebar.tsxindex a3430af924..178929cc7f 100644--- a/apps/web/src/components/app/app-sidebar/sidebar.tsx+++ b/apps/web/src/components/app/app-sidebar/sidebar.tsx@@ -62,6 +62,7 @@ import { type HotkeyToken, TOKENS } from '@core/hotkey/tokens';import type { ValidHotkey } from '@core/hotkey/types';import { activateClosestDOMScope } from '@core/hotkey/utils';import LogoIcon from '@icon/macro-logo.svg';+import { AnimatedActivityIcon } from '@icon/wide-activity';import { AnimatedCallIcon } from '@icon/wide-call';import { AnimatedChannelIcon } from '@icon/wide-channel';import { AnimatedCompanyIcon } from '@icon/wide-company';@@ -167,6 +168,14 @@ const SIDEBAR_LINKS = [hotkey: 'i',hotkeyToken: TOKENS.sidebar.goTo.inbox,},+ {+ id: 'activity',+ label: 'Activity',+ href: '/activity',+ icon: AnimatedActivityIcon,+ hotkey: 'y',+ hotkeyToken: TOKENS.sidebar.goTo.activity,+ },{id: 'search',label: 'Search',@@ -1143,7 +1152,7 @@ export const AppSidebar = (props: AppSidebarProps) => {});const topLinks = createMemo(() =>- ['home', 'inbox']+ ['home', 'inbox', 'activity'].map((id) => findLink(id)).filter((link): link is SidebarItem => link !== undefined));diff --git a/apps/web/src/components/app/split-layout/componentRegistry.tsx b/apps/web/src/components/app/split-layout/componentRegistry.tsxindex fcfbedf083..ea084757b2 100644--- a/apps/web/src/components/app/split-layout/componentRegistry.tsx+++ b/apps/web/src/components/app/split-layout/componentRegistry.tsx@@ -1,3 +1,4 @@+import { ActivityView } from '@app/features/activity-timeline/activity-view';import { Home } from '@app/features/home';import { queryStateFrom } from '@app/features/next-soup/filters/filter-store';import type { SetPredicatesInput } from '@app/features/next-soup/filters/filter-store/predicates-store';@@ -157,6 +158,23 @@ registerComponent(}));+registerComponent(+ 'activity',+ withAuth(() => {+ usePageViewTracking('activity');+ return <ActivityView />;+ })+);++// The Activity tab briefly shipped as two separate views; restored splits+// may still reference their ids.+registerComponent('firehose', () => (+ <RedirectSplit to={{ type: 'component', id: 'activity' }} />+));+registerComponent('my-activity', () => (+ <RedirectSplit to={{ type: 'component', id: 'activity' }} />+));+registerComponent('agents',withAuth(() => {diff --git a/apps/web/src/components/icon/wide-activity.tsx b/apps/web/src/components/icon/wide-activity.tsxnew file mode 100644index 0000000000..f098158814--- /dev/null+++ b/apps/web/src/components/icon/wide-activity.tsx@@ -0,0 +1,46 @@+/**+ * Activity (pulse/EKG) icon. On trigger the pulse line redraws itself+ * left-to-right, like a live heartbeat trace.+ */+export const AnimatedActivityIcon = (props: {+ triggerAnimation?: boolean;+ class?: string;+}) => {+ return (+ <svg+ width="100%"+ height="100%"+ viewBox="0 -3.75 18 18"+ fill="none"+ stroke="currentColor"+ stroke-width="1.125"+ stroke-linecap="round"+ stroke-linejoin="round"+ xmlns="http://www.w3.org/2000/svg"+ overflow="visible"+ class={`animated-activity-icon ${props.triggerAnimation ? 'animating' : ''} ${props.class ?? ''}`}+ >+ <style>{`+ .animated-activity-icon .pulse {+ stroke-dasharray: 29;+ stroke-dashoffset: 0;+ }+ .animated-activity-icon.animating .pulse {+ animation: activity-icon-draw 0.5s ease-out;+ }+ @keyframes activity-icon-draw {+ from {+ stroke-dashoffset: 29;+ }+ to {+ stroke-dashoffset: 0;+ }+ }+ `}</style>+ <polyline+ class="pulse"+ points="0.75,5.25 4.5,5.25 6.75,0.75 10.5,9.75 12.75,5.25 17.25,5.25"+ />+ </svg>+ );+};diff --git a/apps/web/src/features/activity-timeline/activity-view.tsx b/apps/web/src/features/activity-timeline/activity-view.tsxnew file mode 100644index 0000000000..0a51340a1e--- /dev/null+++ b/apps/web/src/features/activity-timeline/activity-view.tsx@@ -0,0 +1,175 @@+import {+ defineQueryFilters,+ type Query,+} from '@app/features/next-soup/filters/filter-store';+import { ENABLE_SNIPPETS } from '@core/constant/featureFlags';+import { useUserId } from '@core/context/user';+import { getTypeNoun } from '@entity/extractors-notification/notification-description-helpers';+import { NotificationRow } from '@entity/extractors-notification/notification-row';+import type { TimelineRow } from './collapse';+import { EntityEventRow } from './entity-event-row';+import { mapMyActivityEntity, mapSharedEmailEntity } from './entity-events';+import {+ createNotificationTimelineFeed,+ createSoupTimelineFeed,+} from './feeds';+import { mergeTimelineFeeds } from './merge-feeds';+import { TimelinePane } from './timeline-view';+import { useChannelLookup } from './use-channel-lookup';++/**+ * Server filters for the user's own actions: messages/threads they took part+ * in (per-message soup rows), documents/tasks they created or edited, agent+ * chats and folders they own, and calls they attended — plus, via the email+ * view, the emails they sent. Drafts live in a separate email view, so they+ * are a second query merged in below.+ */+const getMyActionsQuery = (userId: string): Query =>+ defineQueryFilters({+ include: {+ channelThreadParticipantId: [userId],+ documentOwnerId: [userId],+ isEmailAttachment: false,+ chatOwnerId: [userId],+ folderOwnerId: [userId],+ callAttended: true,+ },+ exclude: ENABLE_SNIPPETS() ? {} : { subType: ['snippet'] },+ emailView: 'sent',+ });++const getMyDraftsQuery = (): Query =>+ defineQueryFilters({ emailView: 'drafts' });++/**+ * A notification row (or collapsed run of them). Single notifications render+ * through the standard notification row; runs keep the newest notification's+ * description and swap the content slot for a count summary.+ */+function NotificationTimelineRow(props: { row: TimelineRow }) {+ const notifications = () =>+ props.row.items.flatMap((item) =>+ item.kind === 'notification' ? [item.notification] : []+ );+ const first = () => notifications()[0]!;+ const count = () => notifications().length;++ return (+ <NotificationRow+ notification={first()}+ variant="compact"+ showMarkDone={false}+ content={+ // Leave the slot on the default per-type content for single rows;+ // runs summarize as "5 messages".+ count() > 1 ? (+ <span class="truncate">+ {count()} {getTypeNoun(first().notification_metadata.tag, count())}+ </span>+ ) : undefined+ }+ />+ );+}++/**+ * "Things I did": the user's own recent actions at event granularity —+ * messages sent, threads replied to, emails sent, drafts started, documents+ * created/edited, tasks and folders created, agent sessions, and calls+ * attended.+ */+function MyActivityPane() {+ const userId = useUserId();+ const resolveChannel = useChannelLookup();++ const feed = mergeTimelineFeeds([+ createSoupTimelineFeed({+ query: () => getMyActionsQuery(userId() ?? ''),+ map: (entity) => mapMyActivityEntity(entity, userId()),+ enabled: () => userId() !== undefined,+ }),+ createSoupTimelineFeed({+ query: getMyDraftsQuery,+ map: (entity) => mapMyActivityEntity(entity, userId()),+ enabled: () => userId() !== undefined,+ }),+ ]);++ const renderRow = (row: TimelineRow) => (+ <EntityEventRow row={row} resolveChannel={resolveChannel} />+ );++ return (+ <TimelinePane+ title="Things I did"+ description="Your recent actions, for retracing your steps."+ feed={feed}+ renderRow={renderRow}+ emptyTitle="No activity yet"+ emptyDescription="Messages and emails you send, documents you edit, and tasks you create will appear here."+ />+ );+}++/**+ * "Firehose": everything going on in the team, at event granularity.+ * Notifications supply the per-event records — every channel message (with+ * its text), thread replies, mentions, document comments, task assignments,+ * calls, and GitHub PR events (opened/merged/closed, reviews, comments).+ * CRM-shared email threads are merged in from soup so team email traffic+ * (visibility inherited from CRM permissions) shows up even though it never+ * notifies this user directly.+ */+function FirehosePane() {+ const resolveChannel = useChannelLookup();++ const feed = mergeTimelineFeeds([+ // The notification stream splits by done state server-side; a timeline+ // is history, so fetch both and merge.+ createNotificationTimelineFeed({}),+ createNotificationTimelineFeed({ done: true }),+ createSoupTimelineFeed({+ query: () =>+ defineQueryFilters({+ include: { emailShared: 'only' },+ emailView: 'all',+ }),+ map: mapSharedEmailEntity,+ }),+ ]);++ const renderRow = (row: TimelineRow) =>+ row.items[0]!.kind === 'notification' ? (+ <NotificationTimelineRow row={row} />+ ) : (+ <EntityEventRow row={row} resolveChannel={resolveChannel} />+ );++ return (+ <TimelinePane+ title="Firehose"+ description="Everything happening across your team, as it happens."+ feed={feed}+ renderRow={renderRow}+ emptyTitle="Nothing happening yet"+ emptyDescription="Messages, replies, comments, shared emails, calls, and pull request activity from across your team will appear here."+ />+ );+}++/**+ * The Activity tab: "Things I did" (the user's own action timeline) on the+ * left, the team Firehose on the right, each scrolling independently.+ */+export function ActivityView() {+ return (+ <div class="flex h-full min-h-0 flex-col md:flex-row">+ <div class="min-h-0 min-w-0 flex-1 border-b border-edge-muted md:border-b-0 md:border-r">+ <MyActivityPane />+ </div>+ <div class="min-h-0 min-w-0 flex-1">+ <FirehosePane />+ </div>+ </div>+ );+}diff --git a/apps/web/src/features/activity-timeline/collapse.test.ts b/apps/web/src/features/activity-timeline/collapse.test.tsnew file mode 100644index 0000000000..fb33f04782--- /dev/null+++ b/apps/web/src/features/activity-timeline/collapse.test.ts@@ -0,0 +1,98 @@+import type { ChannelThreadEntity } from '@entity';+import type { UnifiedNotification } from '@notifications';+import { describe, expect, it } from 'vitest';+import { collapseTimeline } from './collapse';+import type { TimelineItem } from './timeline-types';++function messageNotification(args: {+ id: string;+ ts: number;+ senderId: string;+ channelId: string;+ tag?: string;+}): TimelineItem {+ return {+ kind: 'notification',+ id: args.id,+ ts: args.ts,+ notification: {+ id: args.id,+ sender_id: args.senderId,+ entity_id: args.channelId,+ notification_metadata: { tag: args.tag ?? 'channel_message_send' },+ } as unknown as UnifiedNotification,+ };+}++function sentMessage(args: {+ id: string;+ ts: number;+ channelId: string;+}): TimelineItem {+ return {+ kind: 'entity-event',+ id: args.id,+ ts: args.ts,+ verb: 'sent-message',+ entity: {+ type: 'channel_thread',+ channelId: args.channelId,+ } as unknown as ChannelThreadEntity,+ };+}++function email(id: string, ts: number): TimelineItem {+ return {+ kind: 'entity-event',+ id,+ ts,+ verb: 'sent-email',+ entity: { type: 'email' } as never,+ };+}++describe('collapseTimeline', () => {+ it('folds consecutive messages by the same sender in the same channel', () => {+ const rows = collapseTimeline([+ messageNotification({ id: 'a', ts: 30, senderId: 'u1', channelId: 'c1' }),+ messageNotification({ id: 'b', ts: 20, senderId: 'u1', channelId: 'c1' }),+ messageNotification({ id: 'c', ts: 10, senderId: 'u1', channelId: 'c1' }),+ ]);+ expect(rows).toHaveLength(1);+ expect(rows[0]!.items.map((i) => i.id)).toEqual(['a', 'b', 'c']);+ expect(rows[0]!.ts).toBe(30);+ });++ it('does not fold across different senders or channels', () => {+ const rows = collapseTimeline([+ messageNotification({ id: 'a', ts: 40, senderId: 'u1', channelId: 'c1' }),+ messageNotification({ id: 'b', ts: 30, senderId: 'u2', channelId: 'c1' }),+ messageNotification({ id: 'c', ts: 20, senderId: 'u2', channelId: 'c2' }),+ ]);+ expect(rows).toHaveLength(3);+ });++ it('breaks a run when a different event interleaves', () => {+ const rows = collapseTimeline([+ messageNotification({ id: 'a', ts: 40, senderId: 'u1', channelId: 'c1' }),+ email('e', 30),+ messageNotification({ id: 'b', ts: 20, senderId: 'u1', channelId: 'c1' }),+ ]);+ expect(rows).toHaveLength(3);+ });++ it('folds my own consecutive sent messages per channel', () => {+ const rows = collapseTimeline([+ sentMessage({ id: 'a', ts: 30, channelId: 'c1' }),+ sentMessage({ id: 'b', ts: 20, channelId: 'c1' }),+ sentMessage({ id: 'c', ts: 10, channelId: 'c2' }),+ ]);+ expect(rows).toHaveLength(2);+ expect(rows[0]!.items).toHaveLength(2);+ });++ it('never folds non-collapsible events, even consecutive identical verbs', () => {+ const rows = collapseTimeline([email('a', 30), email('b', 20)]);+ expect(rows).toHaveLength(2);+ });+});diff --git a/apps/web/src/features/activity-timeline/collapse.ts b/apps/web/src/features/activity-timeline/collapse.tsnew file mode 100644index 0000000000..f471d2c6df--- /dev/null+++ b/apps/web/src/features/activity-timeline/collapse.ts@@ -0,0 +1,67 @@+import type { TimelineItem } from './timeline-types';++/**+ * A rendered feed row: one timeline item, or a run of consecutive items+ * collapsed together ("You sent 5 messages in #squad"). `ts` is the newest+ * item's timestamp; items are kept newest-first.+ */+export type TimelineRow = {+ key: string;+ ts: number;+ items: TimelineItem[];+};++/**+ * The grouping key for collapsible items. Consecutive items sharing a key+ * fold into one row. Only repeat-noise event shapes collapse — channel+ * messages/replies by the same sender in the same place, and CI check runs+ * on the same PR. Everything else (emails, doc edits, PR reviews, …) stays+ * a row per event since each one carries distinct information.+ */+function collapseKey(item: TimelineItem): string | undefined {+ if (item.kind === 'notification') {+ const notification = item.notification;+ const tag = notification.notification_metadata.tag;+ if (tag === 'channel_message_send' || tag === 'channel_message_reply') {+ return `n:${tag}:${notification.sender_id}:${notification.entity_id}`;+ }+ if (tag === 'github_pr_check_run') {+ return `n:${tag}:${notification.entity_id}`;+ }+ if (tag === 'ai_response') {+ return `n:${tag}:${notification.entity_id}`;+ }+ return undefined;+ }++ if (item.verb === 'sent-message' || item.verb === 'replied-in-thread') {+ return item.entity.type === 'channel_thread'+ ? `e:${item.verb}:${item.entity.channelId}`+ : undefined;+ }+ return undefined;+}++/**+ * Fold consecutive same-key items in a newest-first list into single rows.+ */+export function collapseTimeline(items: TimelineItem[]): TimelineRow[] {+ const rows: (TimelineRow & { collapseKey?: string })[] = [];++ for (const item of items) {+ const key = collapseKey(item);+ const current = rows[rows.length - 1];+ if (key !== undefined && current?.collapseKey === key) {+ current.items.push(item);+ continue;+ }+ rows.push({+ collapseKey: key,+ key: `${item.kind}:${item.id}`,+ ts: item.ts,+ items: [item],+ });+ }++ return rows;+}diff --git a/apps/web/src/features/activity-timeline/entity-event-row.tsx b/apps/web/src/features/activity-timeline/entity-event-row.tsxnew file mode 100644index 0000000000..8a807255f0--- /dev/null+++ b/apps/web/src/features/activity-timeline/entity-event-row.tsx@@ -0,0 +1,181 @@+import { openEntityInSplitFromUnifiedList } from '@app/features/next-soup/utils';+import { EntityIcon, getEntityIconType } from '@core/component/EntityIcon';+import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';+import { UserIcon } from '@core/component/UserIcon';+import type { ChannelEntity, EntityData } from '@entity';+import { cn } from '@ui';+import { formatDistanceToNowStrict } from 'date-fns';+import { createMemo, Show } from 'solid-js';+import type { TimelineRow } from './collapse';+import type { EntityTimelineItem } from './timeline-types';++/**+ * The "actor verb location" title plus optional content snippet for an+ * entity-derived event (or a collapsed run of them), e.g. "You sent 5+ * messages in #general" with the latest message text alongside.+ */+function eventText(+ items: EntityTimelineItem[],+ resolveChannel: (channelId: string) => ChannelEntity | undefined+): { title: string; preview?: string } {+ const first = items[0]!;+ const entity = first.entity;+ const count = items.length;++ const channelLocation = (): string | undefined => {+ if (entity.type !== 'channel_thread') return undefined;+ const channel = resolveChannel(entity.channelId);+ if (!channel) return undefined;+ if (channel.channelType === 'direct_message') {+ return channel.name.trim() ? `a DM with ${channel.name}` : 'a DM';+ }+ return channel.name.trim()+ ? `#${channel.name.replace(/^#/, '')}`+ : undefined;+ };++ // For a collapsed run, preview the newest message; the count lives in the+ // title.+ const messagePreview = (): string | undefined =>+ entity.type === 'channel_thread' ? entity.content : undefined;++ const emailSubject = entity.type === 'email' ? entity.name : undefined;+ const emailSnippet = entity.type === 'email' ? entity.snippet : undefined;+ const emailPreview = emailSubject+ ? `**${emailSubject}**${emailSnippet ? ` — ${emailSnippet}` : ''}`+ : emailSnippet;++ switch (first.verb) {+ case 'sent-message': {+ const location = channelLocation();+ const action =+ count === 1 ? 'You sent a message' : `You sent ${count} messages`;+ return {+ title: location ? `${action} in ${location}` : action,+ preview: messagePreview(),+ };+ }+ case 'replied-in-thread': {+ const location = channelLocation();+ const action =+ count === 1+ ? 'You replied in a thread'+ : `You replied in ${count} threads`;+ return {+ title: location ? `${action} in ${location}` : action,+ preview: messagePreview(),+ };+ }+ case 'sent-email':+ return { title: 'You sent an email', preview: emailPreview };+ case 'drafted-email':+ return { title: 'You drafted an email', preview: emailPreview };+ case 'email-activity': {+ const sender =+ entity.type === 'email'+ ? (entity.senderName ?? entity.senderEmail)+ : undefined;+ return {+ title: sender ? `${sender} emailed` : 'Email activity',+ preview: emailPreview,+ };+ }+ case 'created-document':+ return { title: `You created “${entity.name}”` };+ case 'edited-document':+ // No diff available — there is no server-side edit log, only the fact+ // that the document changed since creation.+ return { title: `You edited “${entity.name}”` };+ case 'created-task':+ return { title: 'You created a task', preview: entity.name };+ case 'edited-task':+ return { title: 'You updated a task', preview: entity.name };+ case 'created-folder':+ return { title: `You created the folder “${entity.name}”` };+ case 'agent-chat':+ return { title: 'You worked with an agent', preview: entity.name };+ case 'attended-call':+ return { title: 'You attended a call', preview: entity.name };+ }+}++function EventIcon(props: { entity: EntityData }) {+ return (+ <Show+ when={+ props.entity.type === 'channel_thread'+ ? props.entity.senderId+ : undefined+ }+ fallback={+ <EntityIcon targetType={getEntityIconType(props.entity)} size="xs" />+ }+ >+ {(senderId) => (+ <div class="size-4">+ <UserIcon+ id={senderId()}+ size="fill"+ suppressClick+ showTooltip={false}+ />+ </div>+ )}+ </Show>+ );+}++/**+ * A single entity-derived activity row (or collapsed run): icon, "actor verb+ * location" title, one-line content preview, and a relative timestamp.+ * Clicking opens the newest underlying entity — channel rows open at the+ * specific message.+ */+export function EntityEventRow(props: {+ row: TimelineRow;+ resolveChannel: (channelId: string) => ChannelEntity | undefined;+}) {+ const items = createMemo(() =>+ props.row.items.flatMap((item) =>+ item.kind === 'entity-event' ? [item] : []+ )+ );+ const first = () => items()[0]!;++ const text = createMemo(() => eventText(items(), props.resolveChannel));++ const open = (openInNewSplit: boolean) => {+ void openEntityInSplitFromUnifiedList(first().entity, {+ openInNewSplit,+ });+ };++ return (+ <div+ class={cn(+ 'group/event @container/event-row flex items-center gap-2.5 px-3 py-2 min-w-0 overflow-hidden',+ 'cursor-pointer hover:bg-ink-muted/6'+ )}+ onClick={(e) => open(e.shiftKey)}+ >+ <span class="size-4 shrink-0 flex items-center justify-center [&_svg]:size-3.5">+ <EventIcon entity={first().entity} />+ </span>+ <span class="ph-no-capture min-w-0 shrink truncate text-xs text-ink">+ {text().title}+ </span>+ <Show when={text().preview?.trim()}>+ {(preview) => (+ <span class="hidden @md/event-row:inline flex-1 min-w-0 overflow-hidden ph-no-capture truncate text-xs text-ink-muted/60">+ <StaticMarkdown markdown={preview()} singleLine />+ </span>+ )}+ </Show>+ <span class="shrink-0 ml-auto text-ink-extra-muted text-xs tabular-nums">+ {formatDistanceToNowStrict(new Date(props.row.ts), {+ addSuffix: true,+ })}+ </span>+ </div>+ );+}diff --git a/apps/web/src/features/activity-timeline/entity-events.ts b/apps/web/src/features/activity-timeline/entity-events.tsnew file mode 100644index 0000000000..39202ea96c--- /dev/null+++ b/apps/web/src/features/activity-timeline/entity-events.ts@@ -0,0 +1,133 @@+import type { DateValue } from '@core/util/date';+import type { EntityData } from '@entity';+import type { EntityEventVerb, TimelineItem } from './timeline-types';++/**+ * A document whose updatedAt is within this window of createdAt renders as a+ * single "created" event; beyond it, the row splits into a "created" event+ * at creation time plus an "edited" event at last-update time. There is no+ * server-side edit log (the CRDT blame table keeps only the last editor per+ * node), so the edit event carries no diff — just the fact of the edit.+ */+const EDIT_SPLIT_WINDOW_MS = 60 * 1000;++function tsOf(value: DateValue | null | undefined): number | undefined {+ if (value == null) return undefined;+ const ms = new Date(value).getTime();+ return Number.isNaN(ms) ? undefined : ms;+}++/**+ * The timestamp a soup row sorts by. Soup activity feeds query with+ * `sort_method: 'updated_at'`, and `sortTs` (when present) mirrors the+ * server-side sort key. The primary event of every row uses this timestamp;+ * events synthesized at older timestamps (document "created") are handled by+ * the feed's completeness boundary.+ */+function entitySortTs(entity: EntityData): number | undefined {+ return (+ tsOf(entity.sortTs) ?? tsOf(entity.updatedAt) ?? tsOf(entity.createdAt)+ );+}++function event(+ entity: EntityData,+ verb: EntityEventVerb,+ ts: number | undefined,+ idSuffix = ''+): TimelineItem | undefined {+ if (ts === undefined) return undefined;+ return {+ kind: 'entity-event',+ id: `${entity.type}:${entity.id}${idSuffix}`,+ ts,+ verb,+ entity,+ };+}++/**+ * Events for a document/task row: an "edited" event at last-update time and,+ * when the row is old enough for the two to be distinct, a separate+ * "created" event back at creation time.+ */+function documentEvents(+ entity: EntityData,+ createdVerb: EntityEventVerb,+ editedVerb: EntityEventVerb+): (TimelineItem | undefined)[] {+ const created = tsOf(entity.createdAt);+ const updated = entitySortTs(entity);+ if (+ created === undefined ||+ updated === undefined ||+ updated - created < EDIT_SPLIT_WINDOW_MS+ ) {+ return [event(entity, createdVerb, updated)];+ }+ return [+ event(entity, editedVerb, updated),+ event(entity, createdVerb, created, ':created'),+ ];+}++/**+ * Map a soup row from the "Things I did" query to personal activity events.+ * The query already scopes every entity type to the user's own actions+ * (sender/owner/attendance filters + the sent email view); this assigns the+ * verb(s) each row stands for. Rows with no timeline meaning map to nothing.+ */+export function mapMyActivityEntity(+ entity: EntityData,+ userId: string | undefined+): TimelineItem[] {+ const events = (): (TimelineItem | undefined)[] => {+ switch (entity.type) {+ case 'channel_thread':+ // The query filters threads by participation; whether this was my+ // message or a thread I replied in depends on who sent the root.+ return [+ event(+ entity,+ entity.senderId === userId ? 'sent-message' : 'replied-in-thread',+ entitySortTs(entity)+ ),+ ];+ case 'email':+ return [+ event(+ entity,+ entity.isDraft ? 'drafted-email' : 'sent-email',+ entitySortTs(entity)+ ),+ ];+ case 'document':+ return entity.subType?.type === 'task'+ ? documentEvents(entity, 'created-task', 'edited-task')+ : documentEvents(entity, 'created-document', 'edited-document');+ case 'project':+ return [event(entity, 'created-folder', entitySortTs(entity))];+ case 'chat':+ return [event(entity, 'agent-chat', entitySortTs(entity))];+ case 'call':+ return [event(entity, 'attended-call', entitySortTs(entity))];+ default:+ return [];+ }+ };++ return events().filter((item): item is TimelineItem => item !== undefined);+}++/**+ * Map a CRM-shared email thread row to a Firehose event. These are the+ * team-visible email threads (visibility inherited from CRM permissions);+ * the row's sender/snippet describe the latest message on the thread.+ */+export function mapSharedEmailEntity(entity: EntityData): TimelineItem[] {+ if (entity.type !== 'email' || entity.isDraft) return [];+ const item = event(entity, 'email-activity', entitySortTs(entity));+ return item ? [item] : [];+}++export { entitySortTs };diff --git a/apps/web/src/features/activity-timeline/feeds.ts b/apps/web/src/features/activity-timeline/feeds.tsnew file mode 100644index 0000000000..9d1f2743bf--- /dev/null+++ b/apps/web/src/features/activity-timeline/feeds.ts@@ -0,0 +1,127 @@+import {+ compileToAst,+ type Query,+ queryStateFrom,+} from '@app/features/next-soup/filters/filter-store';+import type { EntityData } from '@entity';+import type { UnifiedNotification } from '@notifications';+import { useUserNotificationsQuery } from '@queries/notification/user-notifications';+import { useSoupAstItemsQuery } from '@queries/soup/items';+import { createMemo } from 'solid-js';+import { entitySortTs } from './entity-events';+import type { TimelineFeed, TimelineItem } from './timeline-types';++const PAGE_SIZE = 50;++/** Notification event types that are plumbing rather than team activity. */+const EXCLUDED_NOTIFICATION_TAGS: ReadonlySet<string> = new Set([+ 'inbox_reauth_required',+]);++/**+ * A timeline feed over the user's notification stream. The server returns+ * only one done-state per query (omitted = active), so full-history surfaces+ * create one feed per done state and merge them.+ */+export function createNotificationTimelineFeed(args: {+ done?: boolean;+}): TimelineFeed {+ const query = useUserNotificationsQuery({+ limit: PAGE_SIZE,+ done: args.done,+ });++ const rows = createMemo((): UnifiedNotification[] => query.data ?? []);++ const items = createMemo((): TimelineItem[] => {+ const mapped: TimelineItem[] = [];+ for (const notification of rows()) {+ if (+ EXCLUDED_NOTIFICATION_TAGS.has(notification.notification_metadata.tag)+ ) {+ continue;+ }+ const ts = new Date(notification.created_at).getTime();+ if (Number.isNaN(ts)) continue;+ mapped.push({+ kind: 'notification',+ id: notification.id,+ ts,+ notification,+ });+ }+ return mapped;+ });++ // Cursor position: rows arrive newest-first, so the boundary is the oldest+ // fetched row — including excluded ones, which still advance the cursor.+ const boundaryTs = createMemo((): number | undefined => {+ let boundary: number | undefined;+ for (const notification of rows()) {+ const ts = new Date(notification.created_at).getTime();+ if (Number.isNaN(ts)) continue;+ if (boundary === undefined || ts < boundary) boundary = ts;+ }+ return boundary;+ });++ return {+ items,+ boundaryTs,+ hasMore: () => query.hasNextPage ?? false,+ isLoading: () => query.isLoading,+ isFetchingMore: () => query.isFetchingNextPage,+ fetchMore: () => {+ if (!query.isFetchingNextPage) void query.fetchNextPage();+ },+ };+}++/**+ * A timeline feed over a soup query, sorted by `updated_at`, with each row+ * mapped to zero or more activity events. Events may sit at timestamps older+ * than their row (e.g. a document's "created" event); the boundary tracks+ * the row sort key so the merge withholds them until pagination catches up.+ */+export function createSoupTimelineFeed(args: {+ query: () => Query;+ map: (entity: EntityData) => TimelineItem[];+ enabled?: () => boolean;+}): TimelineFeed {+ const query = useSoupAstItemsQuery(+ () => ({+ params: { limit: PAGE_SIZE, sort_method: 'updated_at' },+ body: compileToAst(queryStateFrom(args.query())),+ }),+ () => ({ enabled: args.enabled?.() ?? true })+ );++ const entities = createMemo((): EntityData[] => query.data?.entities ?? []);++ const items = createMemo((): TimelineItem[] =>+ entities().flatMap((entity) => args.map(entity))+ );++ const boundaryTs = createMemo((): number | undefined => {+ let boundary: number | undefined;+ for (const entity of entities()) {+ const ts = entitySortTs(entity);+ if (ts === undefined) continue;+ if (boundary === undefined || ts < boundary) boundary = ts;+ }+ return boundary;+ });++ return {+ items,+ boundaryTs,+ hasMore: () => query.hasNextPage ?? false,+ // While disabled (e.g. the user id has not resolved yet) the feed reports+ // loading so the merge withholds output instead of treating it as empty.+ isLoading: () => query.isLoading || !(args.enabled?.() ?? true),+ isFetchingMore: () => query.isFetchingNextPage,+ fetchMore: () => {+ if (!query.isFetchingNextPage) void query.fetchNextPage();+ },+ };+}diff --git a/apps/web/src/features/activity-timeline/merge-feeds.test.ts b/apps/web/src/features/activity-timeline/merge-feeds.test.tsnew file mode 100644index 0000000000..3e6b38914c--- /dev/null+++ b/apps/web/src/features/activity-timeline/merge-feeds.test.ts@@ -0,0 +1,130 @@+import { describe, expect, it, vi } from 'vitest';+import { mergeTimelineFeeds } from './merge-feeds';+import type { TimelineFeed, TimelineItem } from './timeline-types';++function item(id: string, ts: number): TimelineItem {+ return { kind: 'notification', id, ts, notification: {} as never };+}++function feed(args: {+ items: TimelineItem[];+ /** Defaults to the oldest item ts (plain row-per-item feed). */+ boundaryTs?: number;+ hasMore?: boolean;+ isLoading?: boolean;+ isFetchingMore?: boolean;+ fetchMore?: () => void;+}): TimelineFeed {+ const defaultBoundary = args.items.length+ ? Math.min(...args.items.map((i) => i.ts))+ : undefined;+ return {+ items: () => args.items,+ boundaryTs: () => args.boundaryTs ?? defaultBoundary,+ hasMore: () => args.hasMore ?? false,+ isLoading: () => args.isLoading ?? false,+ isFetchingMore: () => args.isFetchingMore ?? false,+ fetchMore: args.fetchMore ?? (() => {}),+ };+}++describe('mergeTimelineFeeds', () => {+ it('interleaves fully-loaded feeds newest-first', () => {+ const merged = mergeTimelineFeeds([+ feed({ items: [item('a', 30), item('b', 10)] }),+ feed({ items: [item('c', 20)] }),+ ]);+ expect(merged.items().map((i) => i.id)).toEqual(['a', 'c', 'b']);+ expect(merged.hasMore()).toBe(false);+ });++ it('withholds items below the watermark of an incomplete feed', () => {+ const merged = mergeTimelineFeeds([+ // Loaded down to ts=100 with more pages — anything older than 100 in+ // other feeds may still be preceded by unloaded items from this feed.+ feed({ items: [item('a', 150), item('b', 100)], hasMore: true }),+ feed({ items: [item('c', 120), item('d', 50)] }),+ ]);+ expect(merged.items().map((i) => i.id)).toEqual(['a', 'c', 'b']);+ expect(merged.hasMore()).toBe(true);+ });++ it('withholds synthesized items older than their feed boundary', () => {+ const merged = mergeTimelineFeeds([+ // A row fetched at ts=100 synthesized an extra event at ts=10; the+ // boundary (cursor position) is still 100.+ feed({+ items: [item('a', 100), item('a-created', 10)],+ boundaryTs: 100,+ hasMore: true,+ }),+ ]);+ expect(merged.items().map((i) => i.id)).toEqual(['a']);+ });++ it('emits synthesized old items once every feed is exhausted', () => {+ const merged = mergeTimelineFeeds([+ feed({ items: [item('a', 100), item('a-created', 10)], boundaryTs: 100 }),+ ]);+ expect(merged.items().map((i) => i.id)).toEqual(['a', 'a-created']);+ });++ it('emits nothing while a feed with pages has loaded no items yet', () => {+ const merged = mergeTimelineFeeds([+ feed({ items: [item('a', 10)] }),+ feed({ items: [], hasMore: true }),+ ]);+ expect(merged.items()).toEqual([]);+ });++ it('emits everything once an empty feed is exhausted', () => {+ const merged = mergeTimelineFeeds([+ feed({ items: [item('a', 10)] }),+ feed({ items: [], hasMore: false }),+ ]);+ expect(merged.items().map((i) => i.id)).toEqual(['a']);+ });++ it('dedupes items by id, keeping the first occurrence', () => {+ const merged = mergeTimelineFeeds([+ feed({ items: [item('a', 30)] }),+ feed({ items: [item('a', 30), item('b', 20)] }),+ ]);+ expect(merged.items().map((i) => i.id)).toEqual(['a', 'b']);+ });++ it('fetches more only from the feeds bounding the watermark', () => {+ const fetchA = vi.fn();+ const fetchB = vi.fn();+ const merged = mergeTimelineFeeds([+ feed({ items: [item('a', 100)], hasMore: true, fetchMore: fetchA }),+ feed({ items: [item('b', 50)], hasMore: true, fetchMore: fetchB }),+ ]);+ merged.fetchMore();+ expect(fetchA).toHaveBeenCalledTimes(1);+ expect(fetchB).not.toHaveBeenCalled();+ });++ it('skips feeds that are already fetching', () => {+ const fetchA = vi.fn();+ const merged = mergeTimelineFeeds([+ feed({+ items: [item('a', 100)],+ hasMore: true,+ isFetchingMore: true,+ fetchMore: fetchA,+ }),+ ]);+ merged.fetchMore();+ expect(fetchA).not.toHaveBeenCalled();+ });++ it('does nothing when every feed is exhausted', () => {+ const fetchA = vi.fn();+ const merged = mergeTimelineFeeds([+ feed({ items: [item('a', 10)], fetchMore: fetchA }),+ ]);+ merged.fetchMore();+ expect(fetchA).not.toHaveBeenCalled();+ });+});diff --git a/apps/web/src/features/activity-timeline/merge-feeds.ts b/apps/web/src/features/activity-timeline/merge-feeds.tsnew file mode 100644index 0000000000..15c46c90bb--- /dev/null+++ b/apps/web/src/features/activity-timeline/merge-feeds.ts@@ -0,0 +1,76 @@+import type { TimelineFeed, TimelineItem } from './timeline-types';++/**+ * Merge several paginated feeds into one newest-first timeline.+ *+ * Correctness rule: an item may only be emitted once no unloaded page of any+ * feed could still contain a newer item. Each feed reports a `boundaryTs` —+ * the timestamp its pagination cursor has reached — so everything at or+ * above the *watermark* (the newest boundary across feeds that still have+ * more pages) is final. Items below it are withheld until the lagging feeds+ * catch up; synthesized items older than their source row simply surface+ * once the watermark descends past them. A feed with more pages but nothing+ * fetched yet pins the watermark at +infinity (nothing renders until its+ * first page lands).+ *+ * `fetchMore` advances the feeds that bound the watermark, so each call+ * makes progress instead of over-fetching sources that are already ahead.+ * Items are deduped by id (first occurrence wins) — sources may overlap,+ * e.g. a websocket insert reapplied to more than one notification query.+ */+export function mergeTimelineFeeds(feeds: TimelineFeed[]): TimelineFeed {+ const feedBoundary = (feed: TimelineFeed): number =>+ feed.boundaryTs() ?? Number.POSITIVE_INFINITY;++ const watermark = (): number => {+ let mark = Number.NEGATIVE_INFINITY;+ for (const feed of feeds) {+ if (!feed.hasMore()) continue;+ mark = Math.max(mark, feedBoundary(feed));+ }+ return mark;+ };++ const items = (): TimelineItem[] => {+ const mark = watermark();+ const merged: TimelineItem[] = [];+ const seen = new Set<string>();++ for (const feed of feeds) {+ for (const item of feed.items()) {+ if (item.ts < mark) continue;+ const key = `${item.kind}:${item.id}`;+ if (seen.has(key)) continue;+ seen.add(key);+ merged.push(item);+ }+ }++ merged.sort((a, b) =>+ a.ts === b.ts ? (a.id < b.id ? 1 : -1) : b.ts - a.ts+ );+ return merged;+ };++ const fetchMore = () => {+ const mark = watermark();+ if (mark === Number.NEGATIVE_INFINITY) return;+ for (const feed of feeds) {+ if (!feed.hasMore()) continue;+ if (feed.isFetchingMore() || feed.isLoading()) continue;+ if (feedBoundary(feed) >= mark) feed.fetchMore();+ }+ };++ return {+ items,+ // The merged completeness boundary is the watermark itself: -Infinity+ // when every feed is exhausted (fully complete), +Infinity while a feed+ // with pages has fetched nothing.+ boundaryTs: () => watermark(),+ hasMore: () => feeds.some((feed) => feed.hasMore()),+ isLoading: () => feeds.some((feed) => feed.isLoading()),+ isFetchingMore: () => feeds.some((feed) => feed.isFetchingMore()),+ fetchMore,+ };+}diff --git a/apps/web/src/features/activity-timeline/timeline-types.ts b/apps/web/src/features/activity-timeline/timeline-types.tsnew file mode 100644index 0000000000..4d3ffb253e--- /dev/null+++ b/apps/web/src/features/activity-timeline/timeline-types.ts@@ -0,0 +1,79 @@+import type { EntityData } from '@entity';+import type { UnifiedNotification } from '@notifications';++/**+ * The action a soup-derived timeline row stands for. Notification-derived+ * rows carry their own event type in the notification metadata instead.+ */+export type EntityEventVerb =+ | 'sent-message'+ | 'replied-in-thread'+ | 'sent-email'+ | 'drafted-email'+ | 'email-activity'+ | 'created-document'+ | 'edited-document'+ | 'created-task'+ | 'edited-task'+ | 'created-folder'+ | 'agent-chat'+ | 'attended-call';++/**+ * One row of an activity timeline: either a notification (someone did+ * something — the metadata carries actor, action, and content) or an+ * entity-derived event (an action inferred from a soup row, e.g. "you sent+ * this message"). `ts` is epoch milliseconds.+ */+export type TimelineItem =+ | {+ kind: 'notification';+ id: string;+ ts: number;+ notification: UnifiedNotification;+ }+ | {+ kind: 'entity-event';+ id: string;+ ts: number;+ verb: EntityEventVerb;+ entity: EntityData;+ };++export type NotificationTimelineItem = Extract<+ TimelineItem,+ { kind: 'notification' }+>;+export type EntityTimelineItem = Extract<+ TimelineItem,+ { kind: 'entity-event' }+>;++/**+ * A paginated stream of timeline items. Thin adapter over an infinite query+ * so heterogeneous sources (notifications, soup) can be merged into one+ * timeline.+ *+ * `boundaryTs` is the pagination cursor position expressed as a timestamp:+ * every server row with sort-ts newer than it has been fetched. Items may be+ * synthesized at timestamps older than the row they came from (e.g. a+ * document row also emits a "created" event at its creation time), so the+ * merge trusts `boundaryTs`, not item order, for completeness.+ */+export type TimelineFeed = {+ /** Items loaded so far, in any order. */+ items: () => TimelineItem[];+ /**+ * Completeness boundary: all server rows newer than this are loaded.+ * `undefined` while nothing has been fetched yet.+ */+ boundaryTs: () => number | undefined;+ /** Whether more (older) pages exist. */+ hasMore: () => boolean;+ /** Whether the first page is still loading. */+ isLoading: () => boolean;+ /** Whether an older page is currently being fetched. */+ isFetchingMore: () => boolean;+ /** Request the next (older) page. No-op while already fetching. */+ fetchMore: () => void;+};diff --git a/apps/web/src/features/activity-timeline/timeline-view.tsx b/apps/web/src/features/activity-timeline/timeline-view.tsxnew file mode 100644index 0000000000..fe1fa60483--- /dev/null+++ b/apps/web/src/features/activity-timeline/timeline-view.tsx@@ -0,0 +1,124 @@+import { dateBucket } from '@app/features/next-soup/soup-view/group-by-date';+import { LoadingBlock } from '@core/component/LoadingBlock';+import Spinner from '@phosphor/spinner.svg';+import { EmptyStatePanel } from '@ui';+import {+ createEffect,+ createMemo,+ For,+ type JSX,+ onCleanup,+ Show,+} from 'solid-js';+import { collapseTimeline, type TimelineRow } from './collapse';+import type { TimelineFeed } from './timeline-types';++type TimelineSection = {+ key: string;+ label: string;+ rows: TimelineRow[];+};++/**+ * Collapse repeat runs, then group the rows into contiguous relative-date+ * sections (Today, Yesterday, Last 7 days, …).+ */+function sectionize(rows: TimelineRow[]): TimelineSection[] {+ const sections: TimelineSection[] = [];+ for (const row of rows) {+ const bucket = dateBucket(row.ts);+ const current = sections[sections.length - 1];+ if (current && current.key === bucket.key) {+ current.rows.push(row);+ } else {+ sections.push({ key: bucket.key, label: bucket.label, rows: [row] });+ }+ }+ return sections;+}++/**+ * One scrolling activity pane: a titled, date-sectioned, infinite feed of+ * compact event rows. Row rendering is supplied by the caller.+ */+export function TimelinePane(props: {+ title: string;+ description: string;+ feed: TimelineFeed;+ renderRow: (row: TimelineRow) => JSX.Element;+ emptyTitle: string;+ emptyDescription: string;+}) {+ const sections = createMemo(() =>+ sectionize(collapseTimeline(props.feed.items()))+ );++ let sentinel: HTMLDivElement | undefined;+ createEffect(() => {+ if (!sentinel) return;+ const observer = new IntersectionObserver(+ (entries) => {+ if (entries.some((entry) => entry.isIntersecting)) {+ props.feed.fetchMore();+ }+ },+ { rootMargin: '600px' }+ );+ observer.observe(sentinel);+ onCleanup(() => observer.disconnect());+ });++ return (+ <div class="flex h-full min-h-0 flex-col">+ <div class="shrink-0 px-6 pb-2 pt-5">+ <h2 class="text-base font-semibold text-ink">{props.title}</h2>+ <p class="text-xs text-ink-muted">{props.description}</p>+ </div>+ <div class="min-h-0 flex-1 overflow-y-auto">+ <div class="mx-auto flex w-full max-w-2xl flex-col px-3 pb-10 mobile:pb-(--mobile-content-inset-bottom)">+ <Show+ when={!props.feed.isLoading()}+ fallback={+ <div class="py-16">+ <LoadingBlock />+ </div>+ }+ >+ <Show+ when={sections().length > 0}+ fallback={+ <EmptyStatePanel+ centered+ title={props.emptyTitle}+ description={props.emptyDescription}+ />+ }+ >+ <For each={sections()}>+ {(section) => (+ <section class="mt-20 first:mt-4">+ <div class="px-3 pb-3 text-sm font-semibold text-ink">+ {section.label}+ </div>+ <ul class="flex flex-col">+ <For each={section.rows}>+ {(row) => <li>{props.renderRow(row)}</li>}+ </For>+ </ul>+ </section>+ )}+ </For>+ </Show>+ </Show>++ <div ref={sentinel} class="h-px" />+ <Show when={props.feed.isFetchingMore()}>+ <div class="flex items-center justify-center py-4 text-ink-muted">+ <Spinner class="size-4 animate-spin" />+ </div>+ </Show>+ </div>+ </div>+ </div>+ );+}diff --git a/apps/web/src/features/activity-timeline/use-channel-lookup.ts b/apps/web/src/features/activity-timeline/use-channel-lookup.tsnew file mode 100644index 0000000000..4ee2f41b30--- /dev/null+++ b/apps/web/src/features/activity-timeline/use-channel-lookup.ts@@ -0,0 +1,43 @@+import {+ compileToAst,+ defineQueryFilters,+ NIL_UUID,+ queryStateFrom,+} from '@app/features/next-soup/filters/filter-store';+import type { ChannelEntity } from '@entity';+import { useSoupAstItemsQuery } from '@queries/soup/items';+import { createMemo } from 'solid-js';++const CHANNEL_LOOKUP_LIMIT = 250;+const CHANNEL_LOOKUP_STALE_MS = 5 * 60 * 1000;++/**+ * A best-effort channel-id → channel lookup for labeling timeline rows+ * ("… in #general"). Loads the user's most recently active channels in one+ * page; rows whose channel falls outside it just render without a location.+ */+export function useChannelLookup(): (+ channelId: string+) => ChannelEntity | undefined {+ const query = useSoupAstItemsQuery(+ () => ({+ params: { limit: CHANNEL_LOOKUP_LIMIT, sort_method: 'updated_at' },+ body: compileToAst(+ queryStateFrom(+ defineQueryFilters({ exclude: { channelId: [NIL_UUID] } })+ )+ ),+ }),+ () => ({ staleTime: CHANNEL_LOOKUP_STALE_MS })+ );++ const byId = createMemo(() => {+ const map = new Map<string, ChannelEntity>();+ for (const entity of query.data?.entities ?? []) {+ if (entity.type === 'channel') map.set(entity.id, entity);+ }+ return map;+ });++ return (channelId) => byId().get(channelId);+}diff --git a/apps/web/src/lib/core/hotkey/tokens.ts b/apps/web/src/lib/core/hotkey/tokens.tsindex 363d5a1ba9..76707ab82d 100644--- a/apps/web/src/lib/core/hotkey/tokens.ts+++ b/apps/web/src/lib/core/hotkey/tokens.ts@@ -92,6 +92,7 @@ export const TOKENS = {goTo: {home: 'sidebar.goTo.home',inbox: 'sidebar.goTo.inbox',+ activity: 'sidebar.goTo.activity',search: 'sidebar.goTo.search',agents: 'sidebar.goTo.agents',mail: 'sidebar.goTo.mail',diff --git a/apps/web/src/lib/queries/notification/keys.ts b/apps/web/src/lib/queries/notification/keys.tsindex e32e0e5c5e..4dc2fb73ce 100644--- a/apps/web/src/lib/queries/notification/keys.ts+++ b/apps/web/src/lib/queries/notification/keys.ts@@ -2,7 +2,7 @@ import { createQueryKeys } from '@lukemorales/query-key-factory';export const notificationKeys = createQueryKeys('notification', {all: null,- user: (params: { limit?: number }) => ({+ user: (params: { limit?: number; done?: boolean }) => ({queryKey: ['user', { infinite: true, ...params }],}),entity: (params: { eventItemId: string; limit?: number }) => ({diff --git a/apps/web/src/lib/queries/notification/user-notifications.ts b/apps/web/src/lib/queries/notification/user-notifications.tsindex baeb952c74..cdfebbabb4 100644--- a/apps/web/src/lib/queries/notification/user-notifications.ts+++ b/apps/web/src/lib/queries/notification/user-notifications.ts@@ -124,9 +124,9 @@ function normalizeLimit(limit?: number): number {type UserNotificationsPageParam = { limit: number; cursor?: string };-function userNotificationsQueryOptions(limit: number) {+function userNotificationsQueryOptions(limit: number, done?: boolean) {return {- queryKey: notificationKeys.user({ limit }).queryKey,+ queryKey: notificationKeys.user({ limit, done }).queryKey,queryFn: async ({pageParam,}: {@@ -137,6 +137,7 @@ function userNotificationsQueryOptions(limit: number) {await notificationServiceClient.userNotifications({limit: pageParam.limit,cursor: pageParam.cursor,+ done,}));},@@ -148,12 +149,22 @@ function userNotificationsQueryOptions(limit: number) {};}-/** Paginated query for all notifications for the current user. */-export function useUserNotificationsQuery(args?: { limit?: number }) {+/**+ * Paginated query for all notifications for the current user.+ *+ * `done` filters by done status. Omitted, the server returns only active+ * (not-done) notifications; `done: true` pages through the done ones —+ * surfaces that need the complete stream (e.g. the activity timeline) run+ * one query per done state and merge.+ */+export function useUserNotificationsQuery(args?: {+ limit?: number;+ done?: boolean;+}) {const limit = normalizeLimit(args?.limit);return useInfiniteQuery(() => ({- ...userNotificationsQueryOptions(limit),+ ...userNotificationsQueryOptions(limit, args?.done),select: (data: InfiniteData<GetAllUserNotificationsResponse,diff --git a/apps/web/src/lib/service-clients/service-notification/client.ts b/apps/web/src/lib/service-clients/service-notification/client.tsindex 4acff7c7f8..39e0cdfa3c 100644--- a/apps/web/src/lib/service-clients/service-notification/client.ts+++ b/apps/web/src/lib/service-clients/service-notification/client.ts@@ -74,12 +74,19 @@ export const documentMentionMetadata = z.object({type NotificationParams = { cursor?: string; limit?: number };+/**+ * Params for the user-notifications list. `done` filters by done status —+ * the server defaults to `false` (active notifications only) when omitted;+ * pass `true` to page through already-done notifications instead.+ */+type UserNotificationParams = NotificationParams & { done?: boolean };+export const notificationServiceClient = {- async userNotifications(args: NotificationParams) {- const { limit, cursor } = args;+ async userNotifications(args: UserNotificationParams) {+ const { limit, cursor, done } = args;return (await notificationFetch<GetAllUserNotificationsResponse>(- `/user_notifications?limit=${limit}${cursor ? `&cursor=${cursor}` : ''}`,+ `/user_notifications?limit=${limit}${cursor ? `&cursor=${cursor}` : ''}${done !== undefined ? `&done=${done}` : ''}`,{method: 'GET',}diff --git a/apps/web/src/routes/Root.tsx b/apps/web/src/routes/Root.tsxindex 29ca8b3a4e..8b25549b46 100644--- a/apps/web/src/routes/Root.tsx+++ b/apps/web/src/routes/Root.tsx@@ -318,6 +318,10 @@ const ROUTES: RouteDefinition[] = [path: '/inbox',component: LAYOUT_ROUTE.component,},+ {+ path: '/activity',+ component: LAYOUT_ROUTE.component,+ },{path: '/agents',component: LAYOUT_ROUTE.component,