Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(inbox): various fixes and changes (#4602)

dev-rb3df7db6d73bf
diff --git a/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts b/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts
index 164362165d..d25fc56cc6 100644
--- a/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts
+++ b/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts
@@ -6,6 +6,7 @@ import {
} from '@app/component/next-soup/filters/filter-store';
import type { ListView } from '@app/constants/list-views';
import {
+ ENABLE_NEW_INBOX,
ENABLE_SNIPPETS,
ENABLE_SUPPORTED_SOUP_FOREIGN_ENTITIES_OVERRIDE,
} from '@core/constant/featureFlags';
@@ -127,12 +128,12 @@ export const VIEW_TAB_PRESETS: Record<ListView, ViewTabConfig> = {
signal: () => ({
filters: getInboxSignalFilters(),
clientFilters: { and: ['inbox'] },
- groupBy: 'date',
+ groupBy: ENABLE_NEW_INBOX() ? 'date' : undefined,
}),
noise: () => ({
filters: getInboxNoiseFilters(),
clientFilters: { and: ['noise'] },
- groupBy: 'date',
+ groupBy: ENABLE_NEW_INBOX() ? 'date' : undefined,
}),
all: () => ({
filters: {
@@ -157,7 +158,7 @@ export const VIEW_TAB_PRESETS: Record<ListView, ViewTabConfig> = {
emailView: 'all',
},
clientFilters: { and: ['explicit-noise'] },
- groupBy: 'date',
+ groupBy: ENABLE_NEW_INBOX() ? 'date' : undefined,
}),
},
},
diff --git a/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts b/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts
index 05da9f5c21..94f9a7e9bf 100644
--- a/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts
+++ b/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts
@@ -7,8 +7,14 @@ import {
restoreSoupFocus,
} from '@app/component/next-soup/utils';
import { useMaybePreviewPanel } from '@app/component/PreviewPanel';
+import { useSplitPanel } from '@app/component/split-layout/layoutUtils';
import type { ListView } from '@app/constants/list-views';
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { toast } from '@core/component/Toast/Toast';
+import {
+ ENABLE_NEW_INBOX_FLAG,
+ ENABLE_NEW_INBOX_OVERRIDE,
+} from '@core/constant/featureFlags';
import type { HotkeyGroup } from '@core/hotkey/types';
import type { EntityData } from '@entity';
import type { NotificationSource } from '@notifications';
@@ -55,6 +61,24 @@ type MarkDoneExecuteOpts = Pick<MarkDoneVariables, 'silent' | 'onUndoHandle'>;
/** Must be invoked inside a component tree that provides MutationUndoProvider. */
export const makeMarkDoneAction = (options: MakeMarkDoneOptions) => {
+ const splitPanel = useSplitPanel();
+
+ const newInboxFlag = useFeatureFlag(ENABLE_NEW_INBOX_FLAG, {
+ enabledOverride: ENABLE_NEW_INBOX_OVERRIDE,
+ });
+
+ // Channel and channel_thread entities share the same notification bucket.
+ // The new inbox renders them as separate rows, so marking a channel as done
+ // should not clear thread notifications.
+ //
+ // TODO: This should probably be the default case after the new inbox is released
+ // or we should rework how notifications are sent to not be under just the 'channel'
+ // entity
+ const scopeChannelNotificationsToEntity = () =>
+ newInboxFlag().enabled &&
+ (splitPanel?.handle.content().id === 'inbox' ||
+ splitPanel?.handle.referredFrom() === 'inbox');
+
const { notificationSource, hotkeyGroup } = options;
const previewPanel = useMaybePreviewPanel();
const inPreview = previewPanel !== undefined;
@@ -147,9 +171,12 @@ export const makeMarkDoneAction = (options: MakeMarkDoneOptions) => {
}));
const canExecute = (entity: EntityData): boolean => {
- if (entity.type === 'channel_message' || entity.type === 'channel_thread') {
+ if (entity.type === 'channel_message') {
return false;
}
+ if (entity.type === 'channel_thread') {
+ return scopeChannelNotificationsToEntity();
+ }
if (
entity.type === 'email' ||
entity.type === 'channel' ||
@@ -172,6 +199,7 @@ export const makeMarkDoneAction = (options: MakeMarkDoneOptions) => {
const { emailIds, notificationIds } = resolveMarkEntitiesDoneVariables({
entities,
notificationSource: notificationSource(),
+ scopeChannelNotificationsToEntity: scopeChannelNotificationsToEntity(),
});
await mutation.mutateAsync({
entities,
diff --git a/js/app/packages/app/component/next-soup/filters/predicates.ts b/js/app/packages/app/component/next-soup/filters/predicates.ts
index 14e5c6a7c3..005f985702 100644
--- a/js/app/packages/app/component/next-soup/filters/predicates.ts
+++ b/js/app/packages/app/component/next-soup/filters/predicates.ts
@@ -15,6 +15,19 @@ import { compositeEntity, type NotificationSource } from '@notifications';
import { PROPERTY_OPTION_IDS } from '@property/constants';
import { NO_ASSIGNEE } from './configs/base';
+function getPredicateNotifications(
+ entity: EntityData,
+ notificationSource: NotificationSource
+) {
+ const attachedNotifications = (entity as WithNotification<EntityData>)
+ .notifications;
+ if (attachedNotifications) return attachedNotifications();
+
+ return notificationSource.notificationsByEntity()[
+ compositeEntity(toNotificationEntity(entity))
+ ];
+}
+
/**
* Unread filter - entity has unread content.
*
@@ -28,10 +41,7 @@ export function unreadFilter(notificationSource: NotificationSource) {
return !entity.isRead;
}
- const notifications =
- notificationSource.notificationsByEntity()[
- compositeEntity(toNotificationEntity(entity))
- ];
+ const notifications = getPredicateNotifications(entity, notificationSource);
return notifications?.some((n) => !n.viewed_at) ?? false;
};
@@ -48,10 +58,7 @@ export function notDoneFilter(notificationSource: NotificationSource) {
return function (entity: WithNotification<EntityData>) {
if (entity.type === 'email') return !entity.done;
- const notifications =
- notificationSource.notificationsByEntity()[
- compositeEntity(toNotificationEntity(entity))
- ];
+ const notifications = getPredicateNotifications(entity, notificationSource);
return notifications?.some(({ done }) => !done);
};
diff --git a/js/app/packages/app/component/next-soup/soup-view/date-group-header.tsx b/js/app/packages/app/component/next-soup/soup-view/date-group-header.tsx
deleted file mode 100644
index a08cb82e33..0000000000
--- a/js/app/packages/app/component/next-soup/soup-view/date-group-header.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import type { GroupHeaderProps } from '@app/component/next-soup/create-soup-state';
-import ChevronRightIcon from '@phosphor/caret-right.svg';
-import { cn } from '@ui';
-
-export const DateGroupHeader = (props: GroupHeaderProps) => {
- return (
- <button
- type="button"
- onClick={() => props.group.toggle()}
- class="flex w-full items-center gap-1.5 px-4 py-4 text-sm font-medium text-ink-extra-muted hover:bg-active data-highlighted:bg-active"
- data-highlighted={props.highlighted || undefined}
- >
- <ChevronRightIcon
- class={cn('size-4 shrink-0 transition-transform', {
- 'rotate-90': props.group.isExpanded(),
- })}
- />
- <span class="truncate">{props.group.label}</span>
- </button>
- );
-};
diff --git a/js/app/packages/app/component/next-soup/soup-view/section-header.tsx b/js/app/packages/app/component/next-soup/soup-view/section-header.tsx
new file mode 100644
index 0000000000..16670b900b
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/section-header.tsx
@@ -0,0 +1,30 @@
+import { cn, Layer } from '@ui';
+import type { JSX } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+
+export const SoupSectionHeader = (props: {
+ children: JSX.Element;
+ onClick?: () => void;
+ highlighted?: boolean;
+ class?: string;
+}) => {
+ return (
+ <Layer depth={2}>
+ <Dynamic
+ component={props.onClick ? 'button' : 'div'}
+ type={props.onClick ? 'button' : undefined}
+ onClick={props.onClick}
+ data-highlighted={props.highlighted || undefined}
+ class={cn(
+ 'group/header relative w-[calc(100%-0.5rem)] mx-1 my-0.5 rounded-lg px-2 py-2 flex items-center gap-2.5 text-xs font-semibold tracking-tight',
+ 'text-text-muted bg-surface border border-edge-muted relative',
+ props.onClick && 'hover:bg-active',
+ props.class,
+ props.highlighted && 'bg-active'
+ )}
+ >
+ {props.children}
+ </Dynamic>
+ </Layer>
+ );
+};
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.tsx
index 18ff00272d..fa2c884168 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
@@ -20,13 +20,15 @@ import {
} from '@app/component/next-soup/filters/filter-store/query-store';
import { createGroupedSoupQueries } from '@app/component/next-soup/soup-view/create-grouped-soup-queries';
import { createSearchState } from '@app/component/next-soup/soup-view/create-search-state';
-import { DateGroupHeader } from '@app/component/next-soup/soup-view/date-group-header';
import { dateBucket } from '@app/component/next-soup/soup-view/group-by-date';
import {
INBOX_FILTER_ENTRY_KEY,
registerInboxFilterSplit,
} from '@app/component/next-soup/soup-view/inbox-filter-controllers';
-import { deduplicateEntities } from '@app/component/next-soup/utils';
+import {
+ deduplicateEntities,
+ scopeChannelNotificationsForEntity,
+} from '@app/component/next-soup/utils';
import { useEntryState } from '@app/component/split-layout/entry-state';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
import {
@@ -394,7 +396,13 @@ export const SoupViewContextProvider: FlowComponent<
};
const applyInboxThreadFilter = (state: QueryState): QueryState => {
- if (!isNewInbox()) return state;
+ if (!isNewInbox()) {
+ return {
+ ...state,
+ include: { ...state.include, channelThreadId: [NIL_UUID] },
+ };
+ }
+
const id = userId();
if (!id) return state;
return {
@@ -493,12 +501,16 @@ export const SoupViewContextProvider: FlowComponent<
});
const attachNotifications = (entity: EntityData) => {
+ const notifications = useNotificationsForEntity(
+ notificationSource,
+ toNotificationEntity(entity)
+ );
return {
...entity,
- notifications: useNotificationsForEntity(
- notificationSource,
- toNotificationEntity(entity)
- ),
+ notifications: () =>
+ isNewInbox()
+ ? scopeChannelNotificationsForEntity(entity, notifications())
+ : notifications(),
};
};
@@ -819,7 +831,6 @@ export const SoupViewContextProvider: FlowComponent<
count: group.entities.length,
isExpanded: () => soup.grouping.isExpanded(key),
toggle: () => soup.grouping.toggle(key),
- renderHeader: DateGroupHeader,
};
dateRows.push(
soup.buildRow({
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.tsx
index 21ce052c36..fde3ceb732 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
@@ -21,11 +21,11 @@ import { useSoup } from '@app/component/next-soup/soup-context';
import { registerDocumentsFilterSplit } from '@app/component/next-soup/soup-view/documents-filter-controllers';
import { EmptyState } from '@app/component/next-soup/soup-view/empty-states';
import { InboxSelector } from '@app/component/next-soup/soup-view/filters-bar/inbox-selector';
-import { useSearchTagsFlag } from '@app/component/next-soup/soup-view/filters-bar/search/search-tags-flag';
import { SoupFiltersBar } from '@app/component/next-soup/soup-view/filters-bar/soup-filters-bar';
import { SoupSearchbar } from '@app/component/next-soup/soup-view/filters-bar/soup-view-search-bar';
import { useFilterRefinements } from '@app/component/next-soup/soup-view/filters-bar/use-filter-refinements';
import { MaybeSoupEntityActionDrawerManager } from '@app/component/next-soup/soup-view/SoupEntityActionDrawerManager';
+import { SoupSectionHeader } from '@app/component/next-soup/soup-view/section-header';
import { SoupEntityContextMenu } from '@app/component/next-soup/soup-view/soup-entity-context-menu';
import {
persistSoupNavigationTouchHighlight,
@@ -43,9 +43,11 @@ import {
import { CompanyKanban } from '@app/component/next-soup/soup-view/views/companies/CompanyKanban';
import { CompanyListEntity } from '@app/component/next-soup/soup-view/views/companies/CompanyListEntity';
import { ResponsiveCompanyListHeader } from '@app/component/next-soup/soup-view/views/companies/CompanyListHeader';
+import { DateGroupHeader } from '@app/component/next-soup/soup-view/views/inbox/date-group-header';
import { InboxListEntity } from '@app/component/next-soup/soup-view/views/inbox/InboxListEntity';
import { TaskListEntity } from '@app/component/next-soup/soup-view/views/tasks/TaskListEntity';
import { ResponsiveTaskListHeader } from '@app/component/next-soup/soup-view/views/tasks/TaskListHeader';
+import { TaskGroupHeader } from '@app/component/next-soup/soup-view/views/tasks/task-group-header';
import {
openEntityInNewTab,
openEntityInSplitFromUnifiedList,
@@ -72,7 +74,6 @@ import { CustomScrollbar } from '@core/component/CustomScrollbar';
import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import { LoadingBlock } from '@core/component/LoadingBlock';
import { Resize } from '@core/component/Resize';
-import { UserIcon } from '@core/component/UserIcon';
import {
ENABLE_NEW_INBOX_FLAG,
ENABLE_NEW_INBOX_OVERRIDE,
@@ -86,8 +87,6 @@ import {
import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';
import { TOKENS } from '@core/hotkey/tokens';
import { isMobile } from '@core/mobile/isMobile';
-import { useDisplayName } from '@core/user/displayName';
-import { type MacroId, tryMacroId } from '@core/user/macroId';
import { openExternalUrl } from '@core/util/url';
import { useIsKeyPressActive } from '@core/util/useIsKeyPressActive';
import EmptyStatePreviewIcon from '@design/empty-state-doc.svg';
@@ -103,13 +102,10 @@ import { createEffectOnEntityTypeNotification } from '@notifications';
import CaretDownIcon from '@phosphor/caret-down.svg';
import ChevronRightIcon from '@phosphor/caret-right.svg';
import CheckIcon from '@phosphor/check.svg';
-import CircleDashed from '@phosphor/circle-dashed.svg';
import InfoIcon from '@phosphor/info.svg';
import KanbanIcon from '@phosphor/kanban.svg';
import ListIcon from '@phosphor/list.svg';
import Spinner from '@phosphor/spinner.svg';
-import { PropertyValueIcon } from '@property/component/propertyValue/PropertyValueIcon';
-import { PROPERTY_OPTION_IDS, SYSTEM_PROPERTY_IDS } from '@property/constants';
import { useQueryClient } from '@queries/client';
import { emailKeys } from '@queries/email/keys';
import { invalidateEntityNotifications } from '@queries/notification/user-notifications';
@@ -139,111 +135,20 @@ import {
import { Dynamic } from 'solid-js/web';
import { Virtualizer, type VirtualizerHandle } from 'virtua/solid';
import type { CacheSnapshot } from 'virtua/unstable_core';
+import { useSearchTagsFlag } from './filters-bar/search/search-tags-flag';
import { SoupEntitySelectionToolbar } from './soup-entity-selection-toolbar';
import { useSoupNavigationHotkeys } from './use-soup-navigation-hotkeys';
import { useSoupViewHotkeys } from './use-soup-view-hotkeys';
-const WIDE_SPLIT_PANEL_BREAKPOINT = window.innerWidth * 0.25;
+const WIDE_SPLIT_PANEL_BREAKPOINT = 512;
-export const SoupSectionHeader = (props: {
- children: JSX.Element;
- onClick?: () => void;
- highlighted?: boolean;
- class?: string;
-}) => {
- return (
- <Layer depth={2}>
- <Dynamic
- component={props.onClick ? 'button' : 'div'}
- type={props.onClick ? 'button' : undefined}
- onClick={props.onClick}
- data-highlighted={props.highlighted || undefined}
- class={cn(
- 'group/header relative w-[calc(100%-0.5rem)] mx-1 my-0.5 rounded-lg px-2 py-2 flex items-center gap-2.5 text-xs font-semibold tracking-tight',
- 'text-text-muted bg-surface border border-edge-muted relative',
- props.onClick && 'hover:bg-active',
- props.class,
- props.highlighted && 'bg-active'
- )}
- >
- {props.children}
- </Dynamic>
- </Layer>
- );
-};
-
-const AssigneeGroupContent = (props: {
- assigneeId: MacroId;
- fallbackLabel: string;
-}) => {
- const [assigneeName] = useDisplayName(props.assigneeId, {
- emailFallback: 'local-part',
- });
- return (
- <>
- <UserIcon
- id={props.assigneeId}
- size="sm"
- suppressClick
- showTooltip={false}
- />
- <span class="truncate">
- {assigneeName() || props.assigneeId || props.fallbackLabel}
- </span>
- </>
- );
-};
-
-const STATUS_GROUP_HEADER_TINTS: Record<string, string> = {
- [PROPERTY_OPTION_IDS.STATUS.NOT_STARTED]:
- 'bg-task/5 border-task/10 data-highlighted:bg-task/10 hover:bg-task/10',
- [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS]:
- 'bg-alert/5 border-alert/10 data-highlighted:bg-alert/10 hover:bg-alert/10',
- [PROPERTY_OPTION_IDS.STATUS.IN_REVIEW]:
- 'bg-note/5 border-note/10 data-highlighted:bg-note/10 hover:bg-note/10',
- [PROPERTY_OPTION_IDS.STATUS.COMPLETED]:
- 'bg-accent/5 border-accent/10 data-highlighted:bg-accent/10 hover:bg-accent/10',
- [PROPERTY_OPTION_IDS.STATUS.CANCELED]:
- 'bg-ink/5 border-ink/10 data-highlighted:bg-ink/10 hover:bg-ink/10',
-};
-
-const DefaultGroupHeader = (
+export const DefaultGroupHeader = (
props: GroupHeaderProps & { highlighted?: boolean }
) => {
- const { groupByField } = useSoupView();
- const assigneeId = createMemo(() => {
- const field = groupByField();
- if (
- field?.type !== 'property' ||
- (field.propertyDefinitionId !== SYSTEM_PROPERTY_IDS.ASSIGNEES &&
- field.propertyDefinitionId !== SYSTEM_PROPERTY_IDS.COMPANY_OWNER) ||
- props.group.key === ''
- ) {
- return;
- }
- return tryMacroId(props.group.key);
- });
-
- const statusTint = createMemo(() => {
- const field = groupByField();
- if (
- field?.type !== 'property' ||
- field.propertyDefinitionId !== SYSTEM_PROPERTY_IDS.STATUS
- ) {
- return;
- }
-
- const optionId = props.group.value ?? props.group.key;
- if (typeof optionId !== 'string') return;
-
- return STATUS_GROUP_HEADER_TINTS[optionId];
- });
-
return (
<SoupSectionHeader
onClick={() => props.group.toggle()}
highlighted={props.highlighted}
- class={statusTint()}
>
<Layer depth={3}>
<div class="flex items-center justify-center size-4.5 rounded-xs group-hover/header:bg-ink/5">
@@ -254,33 +159,8 @@ const DefaultGroupHeader = (
/>
</div>
</Layer>
- <Switch>
- <Match when={assigneeId()}>
- {(id) => (
- <AssigneeGroupContent
- assigneeId={id()}
- fallbackLabel={props.group.label}
- />
- )}
- </Match>
- <Match
- when={typeof props.group.value !== 'string' || !props.group.value}
- >
- <CircleDashed class="size-3.5 text-ink-extra-muted" />
- <span class="truncate">{props.group.label}</span>
- </Match>
- <Match
- when={typeof props.group.value === 'string' && props.group.value}
- >
- {(value) => (
- <>
- <PropertyValueIcon optionId={value()} class="size-3.5" />
- <span class="truncate">{props.group.label}</span>
- </>
- )}
- </Match>
- </Switch>
+ <span class="truncate">{props.group.label}</span>
<span
class={cn(
'shrink-0 tabular-nums text-xs font-medium',
@@ -1037,6 +917,12 @@ export const SoupViewList = (props: SoupViewListProps) => {
return ListEntity;
};
+ const groupHeaderComponent = () => {
+ if (currentView() === 'tasks') return TaskGroupHeader;
+ if (isNewInboxEnabled()) return DateGroupHeader;
+ return DefaultGroupHeader;
+ };
+
useSoupViewHotkeys({
splitId: panel.handle.id,
scopeId: scopeId(),
@@ -1480,7 +1366,7 @@ export const SoupViewList = (props: SoupViewListProps) => {
<Dynamic
component={
group().renderHeader ??
- DefaultGroupHeader
+ groupHeaderComponent()
}
group={group()}
highlighted={row.isFocused()}
diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/date-group-header.tsx b/js/app/packages/app/component/next-soup/soup-view/views/inbox/date-group-header.tsx
new file mode 100644
index 0000000000..d80bed583e
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/date-group-header.tsx
@@ -0,0 +1,27 @@
+import type { GroupHeaderProps } from '@app/component/next-soup/create-soup-state';
+import { SoupSectionHeader } from '@app/component/next-soup/soup-view/section-header';
+import ChevronRightIcon from '@phosphor/caret-right.svg';
+import { cn, Layer } from '@ui';
+
+export const DateGroupHeader = (
+ props: GroupHeaderProps & { highlighted?: boolean }
+) => {
+ return (
+ <SoupSectionHeader
+ onClick={() => props.group.toggle()}
+ highlighted={props.highlighted}
+ >
+ <Layer depth={3}>
+ <div class="flex items-center justify-center size-4.5 rounded-xs group-hover/header:bg-ink/5">
+ <ChevronRightIcon
+ class={cn('size-2.5', {
+ 'rotate-90': props.group.isExpanded(),
+ })}
+ />
+ </div>
+ </Layer>
+
+ <span class="truncate">{props.group.label}</span>
+ </SoupSectionHeader>
+ );
+};
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.tsx
index 5729ea57c4..bd6614cff2 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
@@ -543,46 +543,55 @@ function BaseCard(props: {
export function ChannelCardLayout(props: InboxCardLayoutProps) {
const entity = createMemo(() => props.item.entity);
- const senderId = () => {
+ const messageSenderId = createMemo(() => {
const value = props.item.entity;
if (value.type !== 'channel') return;
const latestSender = value.latestRootMessage?.senderId;
- if (value.channelType === 'direct_message') {
- const otherParticipant = value.participantIds?.filter(
- (i) => i !== value.ownerId
- )?.[0];
-
- return latestSender ?? otherParticipant ?? 'Unknown';
- }
-
return latestSender;
- };
+ });
- const senderName = createSenderDisplayName(senderId);
- const currentUserId = useUserId();
+ const messageSenderName = createSenderDisplayName(messageSenderId);
- const senderLabel = () =>
- senderId() === currentUserId() ? 'You' : senderName();
+ const currentUserId = useUserId();
const isDM = createMemo(() => {
const value = entity();
return value.type === 'channel' && value.channelType === 'direct_message';
});
+ const senderAvatarId = createMemo(() => {
+ if (!isDM()) {
+ return messageSenderId();
+ }
+
+ const value = props.item.entity;
+
+ if (value.type !== 'channel') return;
+
+ const participant = value.participantIds?.filter(
+ (id) => id !== currentUserId()
+ )[0];
+
+ if (!participant) return;
+
+ return participant;
+ });
+
+ const senderLabel = () =>
+ messageSenderId() === currentUserId() ? 'You' : messageSenderName();
+
const text = createMemo(() => {
const location = channelLocation(entity());
const tag = getNotificationTag(props.item.notification);
- let sender = isDM() ? senderName() : '';
+ let sender = isDM() ? entity().name || messageSenderName() : '';
let action = '';
if (tag === 'document_mention' && isDM()) {
action = 'shared a document with you';
- } else if (tag === 'channel_message_send' && isDM()) {
- action = 'sent you a message';
}
const content = itemContent(entity(), props.item.notification);
@@ -608,7 +617,9 @@ export function ChannelCardLayout(props: InboxCardLayoutProps) {
<Show
when={!isDM()}
fallback={
- <InboxCard.Icon fallback={<InboxAvatar senderId={senderId()} />} />
+ <InboxCard.Icon
+ fallback={<InboxAvatar senderId={senderAvatarId()} />}
+ />
}
>
<InboxCard.Icon
@@ -633,9 +644,10 @@ export function ChannelCardLayout(props: InboxCardLayoutProps) {
<div class="col-start-2 row-start-2 flex min-w-0 items-center gap-1 text-sm">
<InboxCard.Content class="truncate">
- <Show when={!isDM()}>
+ <Show when={senderLabel()}>
<span class="whitespace-nowrap mr-1">{senderLabel()}:</span>
</Show>
+
<Show when={text().content?.trim()}>
{(value) => (
<StaticMarkdown
diff --git a/js/app/packages/app/component/next-soup/soup-view/views/tasks/task-group-header.tsx b/js/app/packages/app/component/next-soup/soup-view/views/tasks/task-group-header.tsx
new file mode 100644
index 0000000000..c32ad0a510
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/views/tasks/task-group-header.tsx
@@ -0,0 +1,132 @@
+import type { GroupHeaderProps } from '@app/component/next-soup/create-soup-state';
+import { SoupSectionHeader } from '@app/component/next-soup/soup-view/section-header';
+import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
+import { UserIcon } from '@core/component/UserIcon';
+import { type MacroId, tryMacroId, useDisplayName } from '@core/user';
+import ChevronRightIcon from '@phosphor/caret-right.svg';
+import CircleDashed from '@phosphor/circle-dashed.svg';
+import { PROPERTY_OPTION_IDS, SYSTEM_PROPERTY_IDS } from '@property';
+import { PropertyValueIcon } from '@property/component/propertyValue';
+import { cn, Layer } from '@ui';
+import { createMemo, Match, Switch } from 'solid-js';
+
+const AssigneeGroupContent = (props: {
+ assigneeId: MacroId;
+ fallbackLabel: string;
+}) => {
+ const [assigneeName] = useDisplayName(props.assigneeId, {
+ emailFallback: 'local-part',
+ });
+ return (
+ <>
+ <UserIcon
+ id={props.assigneeId}
+ size="sm"
+ suppressClick
+ showTooltip={false}
+ />
+ <span class="truncate">
+ {assigneeName() || props.assigneeId || props.fallbackLabel}
+ </span>
+ </>
+ );
+};
+
+const STATUS_GROUP_HEADER_TINTS: Record<string, string> = {
+ [PROPERTY_OPTION_IDS.STATUS.NOT_STARTED]:
+ 'bg-task/5 border-task/10 data-highlighted:bg-task/10 hover:bg-task/10',
+ [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS]:
+ 'bg-alert/5 border-alert/10 data-highlighted:bg-alert/10 hover:bg-alert/10',
+ [PROPERTY_OPTION_IDS.STATUS.IN_REVIEW]:
+ 'bg-note/5 border-note/10 data-highlighted:bg-note/10 hover:bg-note/10',
+ [PROPERTY_OPTION_IDS.STATUS.COMPLETED]:
+ 'bg-accent/5 border-accent/10 data-highlighted:bg-accent/10 hover:bg-accent/10',
+ [PROPERTY_OPTION_IDS.STATUS.CANCELED]:
+ 'bg-ink/5 border-ink/10 data-highlighted:bg-ink/10 hover:bg-ink/10',
+};
+
+export const TaskGroupHeader = (
+ props: GroupHeaderProps & { highlighted?: boolean }
+) => {
+ const { groupByField } = useSoupView();
+ const assigneeId = createMemo(() => {
+ const field = groupByField();
+ if (
+ field?.type !== 'property' ||
+ (field.propertyDefinitionId !== SYSTEM_PROPERTY_IDS.ASSIGNEES &&
+ field.propertyDefinitionId !== SYSTEM_PROPERTY_IDS.COMPANY_OWNER) ||
+ props.group.key === ''
+ ) {
+ return;
+ }
+ return tryMacroId(props.group.key);
+ });
+
+ const statusTint = createMemo(() => {
+ const field = groupByField();
+ if (
+ field?.type !== 'property' ||
+ field.propertyDefinitionId !== SYSTEM_PROPERTY_IDS.STATUS
+ ) {
+ return;
+ }
+
+ const optionId = props.group.value ?? props.group.key;
+ if (typeof optionId !== 'string') return;
+
+ return STATUS_GROUP_HEADER_TINTS[optionId];
+ });
+
+ return (
+ <SoupSectionHeader
+ onClick={() => props.group.toggle()}
+ highlighted={props.highlighted}
+ class={statusTint()}
+ >
+ <Layer depth={3}>
+ <div class="flex items-center justify-center size-4.5 rounded-xs group-hover/header:bg-ink/5">
+ <ChevronRightIcon
+ class={cn('size-2.5', {
+ 'rotate-90': props.group.isExpanded(),
+ })}
+ />
+ </div>
+ </Layer>
+ <Switch>
+ <Match when={assigneeId()}>
+ {(id) => (
+ <AssigneeGroupContent
+ assigneeId={id()}
+ fallbackLabel={props.group.label}
+ />
+ )}
+ </Match>
+ <Match
+ when={typeof props.group.value !== 'string' || !props.group.value}
+ >
+ <CircleDashed class="size-3.5 text-ink-extra-muted" />
+
+ <span class="truncate">{props.group.label}</span>
+ </Match>
+ <Match
+ when={typeof props.group.value === 'string' && props.group.value}
+ >
+ {(value) => (
+ <>
+ <PropertyValueIcon optionId={value()} class="size-3.5" />
+ <span class="truncate">{props.group.label}</span>
+ </>
+ )}
+ </Match>
+ </Switch>
+ <span
+ class={cn(
+ 'shrink-0 tabular-nums text-xs font-medium',
+ 'px-1.5 py-px rounded-full bg-ink/10 text-ink-extra-muted'
+ )}
+ >
+ {props.group.count}
+ </span>
+ </SoupSectionHeader>
+ );
+};
diff --git a/js/app/packages/app/component/next-soup/utils.ts b/js/app/packages/app/component/next-soup/utils.ts
index 4a55ce1111..be4c1f99e6 100644
--- a/js/app/packages/app/component/next-soup/utils.ts
+++ b/js/app/packages/app/component/next-soup/utils.ts
@@ -34,8 +34,11 @@ import {
import { queryKeys } from '@macro-entity';
import {
compositeEntity,
+ getAllNotificationsFromGroup,
type NotificationSource,
setDoneOverride,
+ stackNotifications,
+ type UnifiedNotification,
} from '@notifications';
import { queryClient } from '@queries/client';
import { emailKeys } from '@queries/email/keys';
@@ -688,6 +691,91 @@ export type MarkEntitiesDoneContext = {
applyUndone: () => void;
};
+function channelThreadNotificationIds(
+ notifications: UnifiedNotification[],
+ threadId?: string
+): Set<string> {
+ const ids = new Set<string>();
+
+ if (threadId !== undefined) {
+ for (const notification of notifications) {
+ const metadata = notification.notification_metadata;
+
+ const belongsToThread = match(metadata)
+ .with(
+ { tag: 'channel_message_send' },
+ (m) => m.content.messageId === threadId
+ )
+ .with(
+ { tag: 'channel_mention' },
+ (m) => (m.content.threadId ?? m.content.messageId) === threadId
+ )
+ .with(
+ { tag: 'channel_message_reply' },
+ (m) => m.content.threadId === threadId
+ )
+ .otherwise(() => false);
+
+ if (!belongsToThread) {
+ continue;
+ }
+ ids.add(notification.id);
+ }
+
+ return ids;
+ }
+
+ for (const stack of stackNotifications(notifications)) {
+ // New inbox renders thread replies and mentions separately from channels.
+ if (
+ stack.type !== 'channel_message_reply' &&
+ stack.type !== 'channel_mention'
+ ) {
+ continue;
+ }
+
+ for (const notification of getAllNotificationsFromGroup(stack)) {
+ ids.add(notification.id);
+ }
+ }
+
+ return ids;
+}
+
+export function scopeChannelNotificationsForEntity(
+ entity: EntityData,
+ notifications: UnifiedNotification[]
+): UnifiedNotification[] {
+ if (entity.type === 'channel') {
+ const threadNotificationIds = channelThreadNotificationIds(notifications);
+ return notifications.filter(
+ (notification) => !threadNotificationIds.has(notification.id)
+ );
+ }
+
+ if (entity.type === 'channel_thread') {
+ const threadNotificationIds = channelThreadNotificationIds(
+ notifications,
+ entity.messageId
+ );
+ return notifications.filter((notification) =>
+ threadNotificationIds.has(notification.id)
+ );
+ }
+
+ return notifications;
+}
+
+function notificationsForMarkDone(
+ entity: EntityData,
+ notifications: UnifiedNotification[],
+ scopeChannelNotificationsToEntity: boolean
+): UnifiedNotification[] {
+ if (!scopeChannelNotificationsToEntity) return notifications;
+
+ return scopeChannelNotificationsForEntity(entity, notifications);
+}
+
/**
* Extract the email ids and notification ids targeted by a mark-done on these
* entities. The ids are snapshotted here so mutationFn/undoFn/redoFn operate
@@ -696,17 +784,36 @@ export type MarkEntitiesDoneContext = {
export function resolveMarkEntitiesDoneVariables(args: {
entities: EntityData[];
notificationSource: NotificationSource;
+ /**
+ * Channel and channel_thread entities share the same notification bucket.
+ * When true, channel mark-done skips thread-stack notifications, and
+ * channel_thread mark-done only targets that thread's stack.
+ */
+ scopeChannelNotificationsToEntity?: boolean;
}): { emailIds: string[]; notificationIds: string[] } {
- const { entities, notificationSource } = args;
+ const {
+ entities,
+ notificationSource,
+ scopeChannelNotificationsToEntity = false,
+ } = args;
const emailIds = entities.filter((e) => e.type === 'email').map((e) => e.id);
const notificationIds = entities.flatMap((entity) => {
- return (
+ const notificationsForEntity =
notificationSource.notificationsByEntity()[
compositeEntity(toNotificationEntity(entity))
- ] ?? []
+ ] ?? [];
+
+ return notificationsForMarkDone(
+ entity,
+ notificationsForEntity,
+ scopeChannelNotificationsToEntity
).map((n) => n.id);
});
- return { emailIds, notificationIds };
+
+ return {
+ emailIds: [...new Set(emailIds)],
+ notificationIds: [...new Set(notificationIds)],
+ };
}
/**
diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.ts
index ff2298ade7..b37bb8edfe 100644
--- a/js/app/packages/core/constant/featureFlags.ts
+++ b/js/app/packages/core/constant/featureFlags.ts
@@ -470,6 +470,13 @@ export const ENABLE_NEW_PRICING_OVERRIDE =
export const ENABLE_NEW_INBOX_FLAG = 'enable-new-inbox-view';
export const ENABLE_NEW_INBOX_OVERRIDE =
resolveFeatureFlag('ENABLE_NEW_INBOX', DEV_MODE_ENV) || undefined;
+export function ENABLE_NEW_INBOX() {
+ if (ENABLE_NEW_INBOX_OVERRIDE !== undefined) {
+ return ENABLE_NEW_INBOX_OVERRIDE;
+ }
+
+ return analytics.posthog.isFeatureEnabled(ENABLE_NEW_INBOX_FLAG) ?? false;
+}
export const ENABLE_TAGS_FE_FLAG = 'enable-tags-fe';
export const ENABLE_TAGS_FE_OVERRIDE =