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[ios-soup]: limit max unrolled notifications (#2477)
Peter Chinmanbcd0c9e1f9bd
diff --git a/js/app/packages/entity/src/composed/ListEntity.tsx b/js/app/packages/entity/src/composed/ListEntity.tsxindex c2682352cd..572f27b260 100644--- a/js/app/packages/entity/src/composed/ListEntity.tsx+++ b/js/app/packages/entity/src/composed/ListEntity.tsx@@ -24,7 +24,6 @@ import {createEffect,createMemo,createSignal,- For,Match,onCleanup,Show,@@ -62,22 +61,14 @@ import { ProjectBreadCrumb } from '../components/ProjectBreadCrumb';import {filterNotDoneNotifications,filterValidNotifications,- extractMessageContent,- isNotificationUnread,} from '../utils/notification';import { getActionVerb } from '../extractors-notification/notification-description-helpers';import type { NotificationType } from '@core/types';import { useSplitPanel } from '@app/component/split-layout/layoutUtils';-import { useGlobalNotificationSource } from '@app/component/GlobalAppState';-import { toast } from '@core/component/Toast/Toast';import { EntityRow, EntityRowContext } from '@app/component/mobile/EntityRow';-import {- type NotificationStack,- stackNotifications,- getMostRecentNotification,- getAllNotificationsFromGroup,-} from '@notifications';+import { stackNotifications } from '@notifications';import { mergeRefs } from '@solid-primitives/refs';+import type { EntityRowConfig } from '../extractors-notification';import { createElementSize } from '@solid-primitives/resize-observer';import { isMobile } from '@core/mobile/isMobile';import { tryMacroId, useDisplayNameParts } from '@core/user';@@ -151,13 +142,6 @@ function useCharacterCount(ref: Accessor<HTMLElement | undefined>) {return chars;}-type EntityRowConfig = {- swipeLeftColor?: string;- swipeLeftRevealedComponent?: JSX.Element;- swipeRightColor?: string;- swipeRightRevealedComponent?: JSX.Element;-};-interface ListEntityProps {entity: WithNotification<EntityData>;onClick?: (event: MouseEvent) => void;@@ -749,154 +733,6 @@ function MaybeEntityRow(props: {);}-function StackRowLayout(props: {- stack: NotificationStack;- entity: WithNotification<EntityData>;- unread: boolean;-}) {- const msgContent = () =>- extractMessageContent(getMostRecentNotification(props.stack));-- return (- <Entity.Layout- class="w-full text-sm grid bg-edge/10 border-edge-muted"- style={{- 'grid-template-columns':- 'var(--soup-stack-row-unread-column-width) 1fr 8ch',- 'grid-template-rows': 'auto auto',- 'grid-template-areas': '"unread title timestamp" "unread body body"',- 'border-left-width': 'var(--soup-stack-row-border-l)',- }}- >- <Entity.Slot placement="unread" class="flex items-center justify-center">- <UnreadIndicator- class="mx-(--soup-inbox-unread-indicator-padding-x) size-(--soup-inbox-unread-indicator-diameter)"- active={props.unread}- />- </Entity.Slot>- <Entity.Slot- placement="title"- class="flex items-center gap-2 truncate font-semibold pt-3"- >- <Entity.Notification.Icon stack={props.stack} class="size-3.5" />- <Entity.Notification.Description stack={props.stack} />- </Entity.Slot>- <Entity.Slot- placement="timestamp"- class="text-xs text-right text-ink-extra-muted font-light pt-3 pr-4"- >- <Entity.Timestamp entity={props.entity} />- </Entity.Slot>- <Entity.Slot- placement="body"- class="text-ink-extra-muted truncate pb-2 min-h-[1lh] pr-4"- >- <Show when={msgContent()}>- {(content) => (- <StaticMarkdown- theme={unifiedListMarkdownTheme}- markdown={content()}- singleLine- />- )}- </Show>- </Entity.Slot>- </Entity.Layout>- );-}--function StackRow(props: {- stack: NotificationStack;- entity: WithNotification<EntityData>;- entityRowConfig?: EntityRowConfig;-}) {- const ctx = useContext(EntityRowContext);- const notificationSource = useGlobalNotificationSource();- const stackEntityId = getMostRecentNotification(props.stack).id;- const unread = () => isNotificationUnread(props.stack);-- const handleSwipeLeft = async () => {- await ctx?.collapseEntity(stackEntityId);- void notificationSource.bulkMarkAsDone(- getAllNotificationsFromGroup(props.stack)- );- toast.success('Marked as done');- };-- if (!ctx) {- return (- <StackRowLayout- stack={props.stack}- entity={props.entity}- unread={unread()}- />- );- }-- return (- <EntityRow- entityId={stackEntityId}- onSwipeLeft={handleSwipeLeft}- swipeLeftColor={props.entityRowConfig?.swipeLeftColor}- swipeLeftRevealedComponent={- props.entityRowConfig?.swipeLeftRevealedComponent- }- swipeRightColor={props.entityRowConfig?.swipeRightColor}- swipeRightRevealedComponent={- props.entityRowConfig?.swipeRightRevealedComponent- }- >- <StackRowLayout- stack={props.stack}- entity={props.entity}- unread={unread()}- />- </EntityRow>- );-}--function MobileMultiStackLayout(props: {- stacks: NotificationStack[];- entity: WithNotification<EntityData>;- entityRowConfig?: EntityRowConfig;-}) {- const isDirectMessage = () =>- isChannelEntity(props.entity) &&- props.entity.channelType === 'direct_message';-- return (- <div class="pl-(--soup-stack-row-padding-l) pb-3 relative">- {/* Non-swipeable header */}- <div class="grid grid-cols-[calc(var(--soup-inbox-left-of-content)-var(--soup-stack-row-padding-l))_auto] w-full text-sm items-center pr-4 py-3">- <div class="ml-(--soup-stack-header-icon-padding-l) mr-(--soup-inbox-icon-padding-r) shrink-0 size-(--soup-stack-icon-diameter) bg-edge-muted rounded-full flex items-center justify-center">- <Entity.Icon- entity={props.entity}- class={cn(- !isDirectMessage() &&- 'size-[calc(var(--soup-stack-icon-diameter)*var(--soup-inbox-icon-factor))]'- )}- />- </div>- <span class="flex-1 truncate font-semibold text-sm">- <Entity.Title entity={props.entity} />- </span>- </div>- {/* Stack rows */}- <div class="flex flex-col gap-3">- <For each={props.stacks}>- {(stack) => (- <StackRow- stack={stack}- entity={props.entity}- entityRowConfig={props.entityRowConfig}- />- )}- </For>- </div>- </div>- );-}-export function ListEntity(props: ListEntityProps) {const unread = () => unreadFilterFn(props.entity);const isShared = useIsShared(props.entity);@@ -1003,7 +839,7 @@ export function ListEntity(props: ListEntityProps) {isMobile() && (hasBeenMultiStack() || mobileStacks().length > 1)}>- <MobileMultiStackLayout+ <Entity.Notification.MobileStacksstacks={mobileStacks()}entity={props.entity}entityRowConfig={props.entityRowConfig}diff --git a/js/app/packages/entity/src/entity.ts b/js/app/packages/entity/src/entity.tsindex 6b6b98fa8f..172863076e 100644--- a/js/app/packages/entity/src/entity.ts+++ b/js/app/packages/entity/src/entity.ts@@ -15,6 +15,7 @@ import { ContentHits } from './extractors-search';// Notification componentsimport {NotificationStacks,+ MobileNotificationStacks,NotificationIcon,NotificationSender,NotificationContent,@@ -43,6 +44,7 @@ export const Entity = {},Notification: {Stacks: NotificationStacks,+ MobileStacks: MobileNotificationStacks,Icon: NotificationIcon,Sender: NotificationSender,Content: NotificationContent,diff --git a/js/app/packages/entity/src/extractors-notification/index.ts b/js/app/packages/entity/src/extractors-notification/index.tsindex e65bbcf392..cdd05e92ff 100644--- a/js/app/packages/entity/src/extractors-notification/index.ts+++ b/js/app/packages/entity/src/extractors-notification/index.ts@@ -1,4 +1,6 @@export { NotificationStacks } from './notification-stacks';+export { MobileNotificationStacks } from './mobile-notification-stacks';+export type { EntityRowConfig } from './mobile-notification-stacks';export { NotificationIcon } from './notification-icon';export { NotificationSender } from './notification-sender';export { NotificationSenderIcon } from './notification-sender-icon';diff --git a/js/app/packages/entity/src/extractors-notification/mobile-notification-stacks.tsx b/js/app/packages/entity/src/extractors-notification/mobile-notification-stacks.tsxnew file mode 100644index 0000000000..555081ac1f--- /dev/null+++ b/js/app/packages/entity/src/extractors-notification/mobile-notification-stacks.tsx@@ -0,0 +1,201 @@+import { Show, useContext, createEffect, type JSX } from 'solid-js';+import { reconcile, createStore } from 'solid-js/store';+import {+ type NotificationStack,+ getMostRecentNotification,+ getAllNotificationsFromGroup,+} from '@notifications';+import type { WithNotification } from '../types/notification';+import { isChannelEntity, type EntityData } from '../types/entity';+import { CollapsibleList } from '../components/CollapsibleList';+import {+ extractMessageContent,+ isNotificationUnread,+} from '../utils/notification';+import { Entity } from '../entity';+import { UnreadIndicator } from '../components/UnreadIndicator';+import { EntityRow, EntityRowContext } from '@app/component/mobile/EntityRow';+import { useGlobalNotificationSource } from '@app/component/GlobalAppState';+import { toast } from '@core/component/Toast/Toast';+import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';+import { unifiedListMarkdownTheme } from '@core/component/LexicalMarkdown/theme';+import { cn } from '@ui/utils/classname';++export type EntityRowConfig = {+ swipeLeftColor?: string;+ swipeLeftRevealedComponent?: JSX.Element;+ swipeRightColor?: string;+ swipeRightRevealedComponent?: JSX.Element;+};++function MobileStackRowLayout(props: {+ stack: NotificationStack;+ entity: WithNotification<EntityData>;+ unread: boolean;+}) {+ const msgContent = () =>+ extractMessageContent(getMostRecentNotification(props.stack));++ return (+ <Entity.Layout+ class="w-full text-sm grid bg-edge/10 border-edge-muted"+ style={{+ 'grid-template-columns':+ 'var(--soup-stack-row-unread-column-width) 1fr 8ch',+ 'grid-template-rows': 'auto auto',+ 'grid-template-areas': '"unread title timestamp" "unread body body"',+ 'border-left-width': 'var(--soup-stack-row-border-l)',+ }}+ >+ <Entity.Slot placement="unread" class="flex items-center justify-center">+ <UnreadIndicator+ class="mx-(--soup-inbox-unread-indicator-padding-x) size-(--soup-inbox-unread-indicator-diameter)"+ active={props.unread}+ />+ </Entity.Slot>+ <Entity.Slot+ placement="title"+ class="flex items-center gap-2 truncate font-semibold pt-3"+ >+ <Entity.Notification.Icon stack={props.stack} class="size-3.5" />+ <Entity.Notification.Description stack={props.stack} />+ </Entity.Slot>+ <Entity.Slot+ placement="timestamp"+ class="text-xs text-right text-ink-extra-muted font-light pt-3 pr-4"+ >+ <Entity.Timestamp entity={props.entity} />+ </Entity.Slot>+ <Entity.Slot+ placement="body"+ class="text-ink-extra-muted truncate pb-2 min-h-[1lh] pr-4"+ >+ <Show when={msgContent()}>+ {(content) => (+ <StaticMarkdown+ theme={unifiedListMarkdownTheme}+ markdown={content()}+ singleLine+ />+ )}+ </Show>+ </Entity.Slot>+ </Entity.Layout>+ );+}++function MobileStackRow(props: {+ stack: NotificationStack;+ entity: WithNotification<EntityData>;+ entityRowConfig?: EntityRowConfig;+}) {+ const ctx = useContext(EntityRowContext);+ const notificationSource = useGlobalNotificationSource();+ const stackEntityId = () => getMostRecentNotification(props.stack).id;+ const unread = () => isNotificationUnread(props.stack);++ const handleSwipeLeft = async () => {+ await ctx?.collapseEntity(stackEntityId());+ void notificationSource.bulkMarkAsDone(+ getAllNotificationsFromGroup(props.stack)+ );+ toast.success('Marked as done');+ };++ if (!ctx) {+ return (+ <MobileStackRowLayout+ stack={props.stack}+ entity={props.entity}+ unread={unread()}+ />+ );+ }++ return (+ <EntityRow+ entityId={stackEntityId()}+ onSwipeLeft={handleSwipeLeft}+ swipeLeftColor={props.entityRowConfig?.swipeLeftColor}+ swipeLeftRevealedComponent={+ props.entityRowConfig?.swipeLeftRevealedComponent+ }+ swipeRightColor={props.entityRowConfig?.swipeRightColor}+ swipeRightRevealedComponent={+ props.entityRowConfig?.swipeRightRevealedComponent+ }+ >+ <MobileStackRowLayout+ stack={props.stack}+ entity={props.entity}+ unread={unread()}+ />+ </EntityRow>+ );+}++// Wraps a NotificationStack with a stable id for reconcile, since+// NotificationStack itself has no id field.+type KeyedStack = NotificationStack & { id: string };++function keyStack(stack: NotificationStack): KeyedStack {+ return { ...stack, id: getMostRecentNotification(stack).id };+}++interface MobileNotificationStacksProps {+ stacks: NotificationStack[];+ entity: WithNotification<EntityData>;+ entityRowConfig?: EntityRowConfig;+ visibleCount?: number;+}++export function MobileNotificationStacks(props: MobileNotificationStacksProps) {+ const [stacks, setStacks] = createStore<KeyedStack[]>([]);++ createEffect(() => {+ setStacks(+ reconcile(props.stacks.map(keyStack), { key: 'id', merge: false })+ );+ });++ const isDirectMessage = () =>+ isChannelEntity(props.entity) &&+ props.entity.channelType === 'direct_message';++ return (+ <div class="pl-(--soup-stack-row-padding-l) pb-3 relative">+ {/* Non-swipeable header */}+ <div class="grid grid-cols-[calc(var(--soup-inbox-left-of-content)-var(--soup-stack-row-padding-l))_auto] w-full text-sm items-center pr-4 py-3">+ <div class="ml-(--soup-stack-header-icon-padding-l) mr-(--soup-inbox-icon-padding-r) shrink-0 size-(--soup-stack-icon-diameter) bg-edge-muted rounded-full flex items-center justify-center">+ <Entity.Icon+ entity={props.entity}+ class={cn(+ !isDirectMessage() &&+ 'size-[calc(var(--soup-stack-icon-diameter)*var(--soup-inbox-icon-factor))]'+ )}+ />+ </div>+ <span class="flex-1 truncate font-semibold text-sm">+ <Entity.Title entity={props.entity} />+ </span>+ </div>+ {/* Stack rows */}+ <div class="flex flex-col gap-3">+ <CollapsibleList+ items={stacks}+ visibleCount={props.visibleCount ?? 3}+ togglePosition="bottom"+ expandText={(count) => `Show ${count} more`}+ >+ {(stack) => (+ <MobileStackRow+ stack={stack}+ entity={props.entity}+ entityRowConfig={props.entityRowConfig}+ />+ )}+ </CollapsibleList>+ </div>+ </div>+ );+}