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
Seanaye/fix/channel read (#6723)
Sean Aye475b5332ac8b
diff --git a/apps/web/src/features/next-soup/utils.test.ts b/apps/web/src/features/next-soup/utils.test.tsindex c96eb452df..be1863f58a 100644--- a/apps/web/src/features/next-soup/utils.test.ts+++ b/apps/web/src/features/next-soup/utils.test.ts@@ -461,6 +461,78 @@ describe('getChannelEntityTarget', () => {expect(bulkMarkAsRead).toHaveBeenCalledWith([notification]);});+ it('marks raw GraphQL notifications when opening a mobile channel', async () => {+ const unread = sendNotification('mobile-unread', 'message');+ const read = asRead(sendNotification('mobile-read', 'read-message'));+ const reply = replyNotification('mobile-reply', 'reply', 'thread-root');+ const openWithSplit = vi.fn();+ setGlobalSplitManager({+ activeSplit: vi.fn(),+ getOrchestrator: vi.fn(() => ({+ getBlockHandle: vi.fn(async () => undefined),+ })),+ getSplitByContent: vi.fn(),+ openWithSplit,+ } as unknown as SplitManager);++ const bulkMarkAsRead = vi.fn(async () => {});+ const channel = { ...channelRow(), notifications: [unread, read, reply] };+ await openEntityInSplitFromUnifiedList(channel, {+ referredFrom: 'channels',+ notificationSource: notificationSourceWithBulkMarkAsRead(bulkMarkAsRead),+ });++ expect(openWithSplit).toHaveBeenCalledWith(+ expect.objectContaining({ type: 'channel', id: 'channel-1' }),+ expect.objectContaining({ referredFrom: 'channels' })+ );+ expect(bulkMarkAsRead).toHaveBeenCalledExactlyOnceWith([unread]);+ });++ it('uses the global source for channels without an attached notification edge', () => {+ const unread = sendNotification('rest-unread', 'message');+ const bulkMarkAsRead = vi.fn(async () => {});+ const source = {+ ...notificationSourceWithBulkMarkAsRead(bulkMarkAsRead),+ notificationsByEntity: () => ({ 'channel@channel-1': [unread] }),+ };++ markChannelNotificationsSeenOnOpen(channelRow(), source);++ expect(bulkMarkAsRead).toHaveBeenCalledExactlyOnceWith([unread]);+ });++ it('does not fall back to stale global notifications for an empty GraphQL edge', () => {+ const unread = sendNotification('stale-unread', 'message');+ const bulkMarkAsRead = vi.fn(async () => {});+ const source = {+ ...notificationSourceWithBulkMarkAsRead(bulkMarkAsRead),+ notificationsByEntity: () => ({ 'channel@channel-1': [unread] }),+ };++ markChannelNotificationsSeenOnOpen(+ { ...channelRow(), notifications: [] },+ source+ );++ expect(bulkMarkAsRead).not.toHaveBeenCalled();+ });++ it('honors local seen overrides on raw GraphQL notifications', () => {+ const unread = sendNotification('already-marked', 'message');+ const bulkMarkAsRead = vi.fn(async () => {});++ markChannelNotificationsSeenOnOpen(+ { ...channelRow(), notifications: [unread] },+ {+ ...notificationSourceWithBulkMarkAsRead(bulkMarkAsRead),+ withLocalOverrides: asRead,+ }+ );++ expect(bulkMarkAsRead).not.toHaveBeenCalled();+ });+it('does not mark a thread-stack notification when opening its parent channel row', async () => {const parentNotification = sendNotification('parent-send', 'message');const threadNotification = replyNotification(diff --git a/apps/web/src/features/next-soup/utils.ts b/apps/web/src/features/next-soup/utils.tsindex cd8b602b70..ab826c6476 100644--- a/apps/web/src/features/next-soup/utils.ts+++ b/apps/web/src/features/next-soup/utils.ts@@ -1,7 +1,11 @@import { isListViewID } from '@app/constants/list-views';import { URL_PARAMS as EMAIL_PARAMS } from '@app/features/email-thread/core/location';import { withListNavigationSource } from '@app/features/soup/collection/list-navigation-source';-import { scopeChannelNotificationsForEntity } from '@app/features/soup/entity-notifications';+import {+ type EntityWithRawNotifications,+ getEntityNotifications,+ scopeChannelNotificationsForEntity,+} from '@app/features/soup/entity-notifications';import { globalSplitManager } from '@app/signal/splitLayout';import { createCalendarBlockRange } from '@block-calendar/calendar-range';import {@@ -706,29 +710,27 @@ export const openEntityInSplitFromUnifiedList = async (/*** Mark every unread notification represented by an opened channel Soup row.*- * The row's attached Soup edge is authoritative. The channel block's message- * marker discovers notifications through the separately paginated global- * source, so it cannot reliably clear older notifications. Passing the row's- * attached notifications through the source keeps its REST cache and durable- * seen overrides in sync while the configured mutation updates GraphQL edges.+ * The row's attached Soup edge is authoritative, whether it is a raw GraphQL+ * array (mobile Channels) or a list accessor. Only rows without an edge fall+ * back to the separately paginated global source. Passing these notifications+ * through the source keeps its REST cache and durable seen overrides in sync+ * while the configured mutation updates GraphQL edges.*/export function markChannelNotificationsSeenOnOpen(- entity: EntityData,+ entity: EntityWithRawNotifications<EntityData>,notificationSource: NotificationSource) {if (- (entity.type !== 'channel' &&- entity.type !== 'channel_message' &&- entity.type !== 'channel_thread') ||- !isWithNotification(entity)+ entity.type !== 'channel' &&+ entity.type !== 'channel_message' &&+ entity.type !== 'channel_thread') {return;}- const notifications = scopeChannelNotificationsForEntity(- entity,- entity.notifications?.() ?? []- ).filter((notification) => !notificationIsRead(notification));+ const notifications = getEntityNotifications(entity, notificationSource, {+ scopeChannelThreads: true,+ }).filter((notification) => !notificationIsRead(notification));if (notifications.length === 0) return;void notificationSource.bulkMarkAsRead(notifications).catch((error) => {diff --git a/docs/AGENT_GUIDE/channels.md b/docs/AGENT_GUIDE/channels.mdindex af340a8338..4874574e8f 100644--- a/docs/AGENT_GUIDE/channels.md+++ b/docs/AGENT_GUIDE/channels.md@@ -339,6 +339,10 @@ and DMs section headers.On touch layouts, the `Recent`, `Channels`, and `DMs` pill tabs each retaintheir own loaded pages and load more as their active list approaches the end.+With `enable-graphql-soup` enabled, open an unread conversation from each tab+and return to the list: its top-level notifications should be read, including+ones older than the global notification feed's loaded page. Notifications for+separate thread stacks remain unread until that thread is opened.## Call lifecycle