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 { queryClient } from '@queries/client';
import { agentSessionChangesKeys } from './keys';
import { refreshAgentSessionLists } from './list-sync';
import type { AgentSessionChangesEvent } from './realtime-protocol';
/**
* A session's changes moved on the server. The event carries no body, so
* the summary refetches; the patch query is keyed by changeset id and a new
* capture simply reads a new key.
*/
export async function handleAgentSessionChanges(
event: AgentSessionChangesEvent
): Promise<void> {
await Promise.all([
invalidateAgentSessionChanges(event.agentSessionId),
refreshAgentSessionLists(event.agentSessionId),
]);
}
/** Drop and refetch one session's changes summary. */
export async function invalidateAgentSessionChanges(
sessionId: string
): Promise<void> {
const filters = {
queryKey: agentSessionChangesKeys.summary(sessionId).queryKey,
exact: true,
};
await queryClient.cancelQueries(filters);
await queryClient.invalidateQueries(filters);
}