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
import {
type GroupableMessage,
shouldGroupWithPreviousMessage,
} from '../Channel/message-grouping-meta';
import type { NewMessageCheckable } from '../Channel/util';
import type { ChannelMessageListMeta } from '../Message';
export function buildThreadReplyListMeta(
replies: GroupableMessage[],
isNewMessageFn?: (message: NewMessageCheckable) => boolean
): Record<string, ChannelMessageListMeta> {
let foundFirstNewMessage = false;
return replies.reduce<Record<string, ChannelMessageListMeta>>(
(metaById, reply, index, items) => {
const isNewMessage = isNewMessageFn?.(reply) ?? false;
const isFirstNewMessage = isNewMessage && !foundFirstNewMessage;
if (isFirstNewMessage) {
foundFirstNewMessage = true;
}
metaById[reply.id] = {
index,
isNewMessage,
isFirstNewMessage,
isGroupedWithPrevious: shouldGroupWithPreviousMessage(
reply,
items[index - 1]
),
};
return metaById;
},
{}
);
}