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
fix(inbox): optimistic update and ui fixes (#4578)
dev-rb304b72191a97
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsxindex 6354f1bd5e..18ff00272d 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx@@ -420,9 +420,10 @@ export const SoupViewContextProvider: FlowComponent<documentSeen: seen,emailSeen: seen,channelSeen: seen,- channelThreadSeen: seen,+ // channelThreadSeen: seen,chatSeen: seen,folderSeen: seen,+ foreignEntitySeen: seen,},};};diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsxindex 73a63818da..4520122893 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx@@ -312,9 +312,28 @@ const useSoupNotificationInvalidators = () => {notificationSource,'channel',(notification) => {+ const meta = notification.notification_metadata;++ let threadId;++ if (+ meta.tag === 'channel_mention' ||+ meta.tag === 'channel_message_reply'+ ) {+ threadId = meta.content.threadId?.toString();+ }+refetchSoupEntity(notification.entity_id, 'channel');invalidateSoupEntity(notification.entity_id);invalidateEntityNotifications(notification.entity_id);++ // For new inbox, we want to display channel threads so we should refetch the thread+ // item if this notification was for a thread+ if (threadId) {+ refetchSoupEntity(threadId, 'channelThread');+ invalidateSoupEntity(threadId);+ invalidateEntityNotifications(threadId);+ }});@@ -1651,12 +1670,20 @@ export const SoupViewList = (props: SoupViewListProps) => {)}><Show- when={soup.focus.item()}+ when={+ (soup.focus.row() && !isNewInboxEnabled()) ||+ (soup.focus.row()?.getIsGrouped() === false &&+ isNewInboxEnabled())+ }fallback={<EmptyStatePanelgraphic={EmptyStatePreviewIcon}title="Nothing selected"- description="Select an item from your inbox to preview it here."+ description={+ isNewInboxEnabled()+ ? 'Select an item from your inbox to preview it here.'+ : 'Select an item from the list to preview it here'+ }centered/>}diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx b/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-card-layouts.tsxindex ec08082f74..5729ea57c4 100644--- a/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx@@ -563,6 +563,7 @@ export function ChannelCardLayout(props: InboxCardLayoutProps) {const senderName = createSenderDisplayName(senderId);const currentUserId = useUserId();+const senderLabel = () =>senderId() === currentUserId() ? 'You' : senderName();@@ -575,7 +576,7 @@ export function ChannelCardLayout(props: InboxCardLayoutProps) {const location = channelLocation(entity());const tag = getNotificationTag(props.item.notification);- let sender = isDM() ? entity().name || senderName() : '';+ let sender = isDM() ? senderName() : '';let action = '';if (tag === 'document_mention' && isDM()) {diff --git a/js/app/packages/core/types/index.ts b/js/app/packages/core/types/index.tsindex 9161f93625..5b59f10a15 100644--- a/js/app/packages/core/types/index.ts+++ b/js/app/packages/core/types/index.ts@@ -6,6 +6,7 @@ export const EntityType = {email: 'email',channel_message: 'channel_message',automation: 'automation',+ channel_thread: 'channel_thread',} as const;export type EntityType = (typeof EntityType)[keyof typeof EntityType];diff --git a/js/app/packages/queries/soup/normalized-cache/normalizer.ts b/js/app/packages/queries/soup/normalized-cache/normalizer.tsindex 6d76fbb6dd..f21d9616f8 100644--- a/js/app/packages/queries/soup/normalized-cache/normalizer.ts+++ b/js/app/packages/queries/soup/normalized-cache/normalizer.ts@@ -28,7 +28,6 @@ export const getNormalizationObjectKey = (const channel = data?.channel as Record<string, unknown> | undefined;return channel?.id ? soupNormKey(channel.id as string) : undefined;}- if (obj.tag === 'channelThread') return undefined;return data?.id ? soupNormKey(data.id as string) : undefined;}return undefined;diff --git a/js/app/packages/queries/soup/normalized-cache/operations.ts b/js/app/packages/queries/soup/normalized-cache/operations.tsindex 923f5f5ca9..97adb82c13 100644--- a/js/app/packages/queries/soup/normalized-cache/operations.ts+++ b/js/app/packages/queries/soup/normalized-cache/operations.ts@@ -74,8 +74,6 @@ function cancelSoupQueries() {export function optimisticUpdateSoupEntity<T extends SoupEntityTag>(partial: SoupEntityPartial<T>): SoupTransaction {- if (partial.tag === 'channelThread') return { rollback: () => {} };-cancelSoupQueries();const normalizer = getSoupNormalizer();@@ -174,8 +172,6 @@ export function getSoupItemId(item: SoupApiItem): string {* and upsert into each resolvable group. Date / unresolved labels invalidate.*/export function insertSoupEntity(item: SoupApiItem): SoupTransaction {- if (item.tag === 'channelThread') return { rollback: () => {} };-cancelSoupQueries();const previous = snapshotSoup();@@ -357,8 +353,6 @@ export async function refetchSoupEntity(entityType: SoupEntityTag,options?: { includeRoot?: boolean }): Promise<void> {- if (entityType === 'channelThread') return;-const { storageServiceClient } = await import('@service-storage/client');const filter = buildSingleEntityFilter(entityType, entityId, options);@@ -380,8 +374,6 @@ export async function refetchSoupEntity(if (!page.items.length) return;for (const item of page.items) {- if (item.tag === 'channelThread') continue;-const itemId = getSoupItemId(item);if (hasSoupEntity(itemId)) {optimisticUpdateSoupEntity(item);@@ -435,7 +427,10 @@ export function buildSingleEntityFilter(...base,foreign_entity_filters: { ids: [entityId] },}))- .with('channelThread', () => base)+ .with('channelThread', () => ({+ ...base,+ channel_thread_filters: { thread_ids: [entityId] },+ })).exhaustive();}@@ -460,11 +455,7 @@ export function optimisticUpdateSoupItemViewedAt(itemId: string) {data: { channel: { id: itemId }, viewed_at: now },frecency_score: current.frecency_score,});- } else if (- current.tag === 'call' ||- current.tag === 'foreignEntity' ||- current.tag === 'channelThread'- ) {+ } else if (current.tag === 'call' || current.tag === 'foreignEntity') {// Call records, foreign entities, and channel threads don't have viewedAt — skip.return;} else {@@ -502,12 +493,16 @@ export function optimisticUpdateSoupItemUpdatedAt(data: { channel: { id: itemId, updated_at: updatedAt } },frecency_score: current.frecency_score,});- } else if (current.tag === 'call' || current.tag === 'channelThread') {+ } else if (current.tag === 'call') {// Call records use endedAt/startedAt and channel threads nest message timestamps — skip.return;} else {- if (!shouldUpdateOptimisticTimestamp(current.data.updatedAt, updatedAt))- return;+ const timestamp =+ current.tag === 'channelThread'+ ? current.data.updated_at+ : current.data.updatedAt;++ if (!shouldUpdateOptimisticTimestamp(timestamp, updatedAt)) return;optimisticUpdateSoupEntity({tag: current.tag,