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
feat(inbox): new inbox view (#4419)
dev-rbd443ac3c134f
diff --git a/js/app/packages/app/component/PreviewPanel.tsx b/js/app/packages/app/component/PreviewPanel.tsxindex 0b7a3f7bb2..147b77e863 100644--- a/js/app/packages/app/component/PreviewPanel.tsx+++ b/js/app/packages/app/component/PreviewPanel.tsx@@ -87,7 +87,10 @@ const PreviewPanelContent: Component<NonNullableFields<PreviewPanel>> = (if (props.selectedEntity.type === 'document') {blockType = fileTypeToResolvedBlockName(props.selectedEntity.fileType);blockId = props.selectedEntity.id;- } else if (props.selectedEntity.type === 'channel_message') {+ } else if (+ props.selectedEntity.type === 'channel_message' ||+ props.selectedEntity.type === 'channel_thread'+ ) {blockType = 'channel';blockId = props.selectedEntity.channelId;} else if (props.selectedEntity.type === 'foreign') {@@ -124,7 +127,7 @@ const PreviewPanelContent: Component<NonNullableFields<PreviewPanel>> = (}const entity = props.selectedEntity;- if (isChannelMessageEntity(entity)) {+ if (isChannelMessageEntity(entity) || entity.type === 'channel_thread') {const channelId = entity.channelId;const messageId = entity.messageId;const threadId = entity.threadId;diff --git a/js/app/packages/app/component/next-soup/actions/make-copy-action.ts b/js/app/packages/app/component/next-soup/actions/make-copy-action.tsindex c86ef298b1..9475ecb5c7 100644--- a/js/app/packages/app/component/next-soup/actions/make-copy-action.ts+++ b/js/app/packages/app/component/next-soup/actions/make-copy-action.ts@@ -11,6 +11,7 @@ export const makeCopyAction = () => {entity.type !== 'channel' &&entity.type !== 'email' &&entity.type !== 'channel_message' &&+ entity.type !== 'channel_thread' &&entity.type !== 'foreign');};diff --git a/js/app/packages/app/component/next-soup/actions/make-copy-link-action.ts b/js/app/packages/app/component/next-soup/actions/make-copy-link-action.tsindex 77276cf345..6b667d3a06 100644--- a/js/app/packages/app/component/next-soup/actions/make-copy-link-action.ts+++ b/js/app/packages/app/component/next-soup/actions/make-copy-link-action.ts@@ -12,14 +12,17 @@ const getEntityUrlType = (entity: EntityData): string => {if (entity.type === 'document') {const { fileType, subType } = entity;return fileTypeToBlockName(subType?.type ?? fileType);- } else if (entity.type === 'channel_message') {+ } else if (+ entity.type === 'channel_message' ||+ entity.type === 'channel_thread'+ ) {return 'channel';}return entity.type;};const getEntityUrlId = (entity: EntityData): string => {- if (entity.type === 'channel_message') {+ if (entity.type === 'channel_message' || entity.type === 'channel_thread') {return entity.channelId;}return entity.id;@@ -28,7 +31,9 @@ const getEntityUrlId = (entity: EntityData): string => {const getEntityUrlParams = (entity: EntityData): Record<string, string> | undefined => {- if (entity.type !== 'channel_message') return undefined;+ if (entity.type !== 'channel_message' && entity.type !== 'channel_thread') {+ return undefined;+ }return getChannelParams(entity.messageId, entity.threadId);};diff --git a/js/app/packages/app/component/next-soup/actions/make-delete-action.ts b/js/app/packages/app/component/next-soup/actions/make-delete-action.tsindex 19ac5a5c18..d1140485e1 100644--- a/js/app/packages/app/component/next-soup/actions/make-delete-action.ts+++ b/js/app/packages/app/component/next-soup/actions/make-delete-action.ts@@ -16,7 +16,9 @@ export const makeDeleteAction = (options: MakeDeleteOptions) => {const { userId } = options;const canExecute = (entity: EntityData): boolean => {- if (entity.type === 'channel_message') return false;+ if (entity.type === 'channel_message' || entity.type === 'channel_thread') {+ return false;+ }if (entity.type === 'email') {return true;}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.tsindex edf9a57001..39c7a193c2 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@@ -137,7 +137,9 @@ export const makeMarkDoneAction = (options: MakeMarkDoneOptions) => {}));const canExecute = (entity: EntityData): boolean => {- if (entity.type === 'channel_message') return false;+ if (entity.type === 'channel_message' || entity.type === 'channel_thread') {+ return false;+ }if (entity.type === 'email' ||entity.type === 'channel' ||diff --git a/js/app/packages/app/component/next-soup/actions/make-move-to-project-action.ts b/js/app/packages/app/component/next-soup/actions/make-move-to-project-action.tsindex ec6b941758..d1dfd394d7 100644--- a/js/app/packages/app/component/next-soup/actions/make-move-to-project-action.ts+++ b/js/app/packages/app/component/next-soup/actions/make-move-to-project-action.ts@@ -10,6 +10,7 @@ export const makeMoveToProjectAction = () => {return (entity.type !== 'channel' &&entity.type !== 'channel_message' &&+ entity.type !== 'channel_thread' &&entity.type !== 'foreign');};diff --git a/js/app/packages/app/component/next-soup/actions/make-rename-action.ts b/js/app/packages/app/component/next-soup/actions/make-rename-action.tsindex 6c9e5c6a39..bb53b4426d 100644--- a/js/app/packages/app/component/next-soup/actions/make-rename-action.ts+++ b/js/app/packages/app/component/next-soup/actions/make-rename-action.ts@@ -14,7 +14,9 @@ export const makeRenameAction = (options: MakeRenameOptions) => {const canExecute = (entity: EntityData): boolean => {if (entity.type === 'email') return false;- if (entity.type === 'channel_message') return false;+ if (entity.type === 'channel_message' || entity.type === 'channel_thread') {+ return false;+ }if (entity.type === 'foreign') return false;if (entity.type === 'channel') {diff --git a/js/app/packages/app/component/next-soup/filters/filter-store/compile.test.ts b/js/app/packages/app/component/next-soup/filters/filter-store/compile.test.tsindex 5dffd3b689..5e9991c075 100644--- a/js/app/packages/app/component/next-soup/filters/filter-store/compile.test.ts+++ b/js/app/packages/app/component/next-soup/filters/filter-store/compile.test.ts@@ -120,4 +120,32 @@ describe('compileToAst', () => {'&': [{ l: { fes: 'github_pull_request' } }, { l: { nd: false } }],});});++ it('compiles channel message thread ids onto regular channel filters', () => {+ const ast = compileToAst(+ queryStateFrom({+ include: {+ channelMessageThreadId: ['00000000-0000-0000-0000-000000000001'],+ },+ })+ );++ expect(ast.chanf).toEqual({+ l: { ThreadId: '00000000-0000-0000-0000-000000000001' },+ });+ });++ it('compiles channel-thread root sender excludes onto channel-thread filters', () => {+ const ast = compileToAst(+ queryStateFrom({+ exclude: {+ channelThreadRootSenderId: ['macro|[email protected]'],+ },+ })+ );++ expect(ast.cthf).toEqual({+ '!': { l: { RootSender: 'macro|[email protected]' } },+ });+ });});diff --git a/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts b/js/app/packages/app/component/next-soup/filters/filter-store/compile.tsindex 7d80e00086..a90d1ee770 100644--- a/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts+++ b/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts@@ -104,7 +104,9 @@ const FIELD_CONFIG: Record<channelDone: { target: 'chanf', field: 'NotificationDone' },channelImportance: { target: 'chanf', field: 'Importance' },channelSenderId: { target: 'chanf', field: 'Sender' },+ channelMessageThreadId: { target: 'chanf', field: 'ThreadId' },channelThreadId: { target: 'cthf', field: 'ThreadId' },+ channelThreadRootSenderId: { target: 'cthf', field: 'RootSender' },chatId: { target: 'cf', field: 'cid' },chatOwnerId: { target: 'cf', field: 'o' },chatProjectId: { target: 'cf', field: 'pid' },@@ -384,10 +386,13 @@ export function compileToAst(state: QueryState): TargetAstMap {}}- // Channel-thread soup items are not displayable in the frontend. Always- // exclude them at the AST layer so hidden rows do not consume page limits or- // grouped counts.- result.cthf ??= AST.literal('ThreadId', NIL_UUID);+ // Unless explicitly includes/excluded, channel threads are excluded by default+ if (+ !('channelThreadId' in state.include) &&+ !('channelThreadId' in state.exclude)+ ) {+ result.cthf ??= AST.literal('ThreadId', NIL_UUID);+ }if (state.emailView) {result.emailView = state.emailView;diff --git a/js/app/packages/app/component/next-soup/filters/filter-store/types.ts b/js/app/packages/app/component/next-soup/filters/filter-store/types.tsindex 53c43acb01..aa5cf6d138 100644--- a/js/app/packages/app/component/next-soup/filters/filter-store/types.ts+++ b/js/app/packages/app/component/next-soup/filters/filter-store/types.ts@@ -37,7 +37,9 @@ export type ArrayFieldFilters = {channelId?: string[];channelType?: string[];channelSenderId?: string[];+ channelMessageThreadId?: string[];channelThreadId?: string[];+ channelThreadRootSenderId?: string[];chatId?: string[];chatOwnerId?: string[];chatProjectId?: string[];diff --git a/js/app/packages/app/component/next-soup/filters/inbox-filters.ts b/js/app/packages/app/component/next-soup/filters/inbox-filters.tsindex 886240a75a..8664d300c7 100644--- a/js/app/packages/app/component/next-soup/filters/inbox-filters.ts+++ b/js/app/packages/app/component/next-soup/filters/inbox-filters.ts@@ -116,6 +116,8 @@ export function signalFilter(entity: EntityData): boolean {return true;case 'channel_message':return true;+ case 'channel_thread':+ return true;case 'call':return true;case 'crm_company':diff --git a/js/app/packages/app/component/next-soup/filters/predicates.ts b/js/app/packages/app/component/next-soup/filters/predicates.tsindex 6a0c4fb3ee..7d35b02056 100644--- a/js/app/packages/app/component/next-soup/filters/predicates.ts+++ b/js/app/packages/app/component/next-soup/filters/predicates.ts@@ -72,14 +72,18 @@ export function emailFilter(entity: EntityData): boolean {export function peopleFilter(entity: EntityData): boolean {return (- (entity.type === 'channel' || entity.type === 'channel_message') &&+ (entity.type === 'channel' ||+ entity.type === 'channel_message' ||+ entity.type === 'channel_thread') &&entity.channelType === 'direct_message');}export function teamsFilter(entity: EntityData): boolean {return (- (entity.type === 'channel' || entity.type === 'channel_message') &&+ (entity.type === 'channel' ||+ entity.type === 'channel_message' ||+ entity.type === 'channel_thread') &&entity.channelType !== 'direct_message');}@@ -107,7 +111,11 @@ export function githubPrFilter(entity: EntityData): boolean {}export function channelsFilter(entity: EntityData): boolean {- return entity.type === 'channel' || entity.type === 'channel_message';+ return (+ entity.type === 'channel' ||+ entity.type === 'channel_message' ||+ entity.type === 'channel_thread'+ );}export function callsFilter(entity: EntityData): boolean {diff --git a/js/app/packages/app/component/next-soup/filters/query-filters.ts b/js/app/packages/app/component/next-soup/filters/query-filters.tsindex 1d4a434656..0af20ba88d 100644--- a/js/app/packages/app/component/next-soup/filters/query-filters.ts+++ b/js/app/packages/app/component/next-soup/filters/query-filters.ts@@ -34,6 +34,16 @@ function isValueFilteredOut(return !values.includes(value);}+function isAnyValueFilteredOut(+ values: string[] | undefined,+ candidates: (string | null | undefined)[]+): boolean {+ if (!values || values.length === 0) return false;+ return !candidates.some(+ (candidate) => candidate && values.includes(candidate)+ );+}+function isAttendedFilteredOut(attendedFilter: boolean | null | undefined,itemAttended: boolean@@ -80,7 +90,11 @@ export function filterSoupItemByRequestBody(.with({ tag: 'channel' },({ data }) =>- !isIdFilteredOut(body.channel_filters?.channel_ids, data.channel.id)+ !isIdFilteredOut(body.channel_filters?.channel_ids, data.channel.id) &&+ !isAnyValueFilteredOut(body.channel_filters?.thread_ids, [+ data.latest_message?.thread_id,+ data.latest_non_thread_message?.thread_id,+ ])).with({ tag: 'channelThread' },diff --git a/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts b/js/app/packages/app/component/next-soup/soup-view/create-search-state.tsindex 5580b866a1..1b3c14fe1c 100644--- a/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts+++ b/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts@@ -105,19 +105,25 @@ function filterDataToQueryFilters(data: QueryState): EntityFilters {if (include.channelId?.length ||include.channelType?.length ||- include.channelSenderId?.length+ include.channelSenderId?.length ||+ include.channelMessageThreadId?.length) {filters.channel_filters = {channel_ids: include.channelId,channel_types: include.channelType,sender_ids: include.channelSenderId,+ thread_ids: include.channelMessageThreadId,};}// Channel thread filters- if (include.channelThreadId?.length) {+ if (+ include.channelThreadId?.length ||+ include.channelThreadRootSenderId?.length+ ) {filters.channel_thread_filters = {thread_ids: include.channelThreadId,+ root_sender_ids: include.channelThreadRootSenderId,};}diff --git a/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts b/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.tsindex 770ac904a8..979d82e125 100644--- a/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts+++ b/js/app/packages/app/component/next-soup/soup-view/create-soup-entity-actions.ts@@ -129,7 +129,9 @@ export function createSoupEntityActions(): {// TODO(dev-rb/github): Allow GitHub PRs once they map to /pr.if (entity.type === 'foreign') return false;const contentId =- entity.type === 'channel_message' ? entity.channelId : entity.id;+ entity.type === 'channel_message' || entity.type === 'channel_thread'+ ? entity.channelId+ : entity.id;const contentType = itemToBlockName(entity);return !splitManager.getSplitByContent(contentType, contentId);};@@ -155,7 +157,10 @@ export function createSoupEntityActions(): {},referredFrom: 'entity-actions-menu',});- } else if (entity.type === 'channel_message') {+ } else if (+ entity.type === 'channel_message' ||+ entity.type === 'channel_thread'+ ) {splitManager.createNewSplit({content: {type: 'channel',@@ -193,7 +198,7 @@ export function createSoupEntityActions(): {} else if (entity.type !== 'foreign') {splitManager.createNewSplit({content: {- type: entity.type,+ type: itemToBlockName(entity),id: entity.id,},referredFrom: 'entity-actions-menu',diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsxindex 4fe6ceb4c3..05617fdeae 100644--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx@@ -10,6 +10,11 @@ import {SplitToolbarRight,} from '@app/component/split-layout/components/SplitToolbar';import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';+import { useFeatureFlag } from '@app/lib/analytics/posthog';+import {+ ENABLE_NEW_INBOX_FLAG,+ ENABLE_NEW_INBOX_OVERRIDE,+} from '@core/constant/featureFlags';import { registerHotkey } from '@core/hotkey/hotkeys';import { TOKENS } from '@core/hotkey/tokens';import { isMobile } from '@core/mobile/isMobile';@@ -58,12 +63,27 @@ export function SoupFiltersBar() {return content.type === 'component' && content.id === 'search';});+ // The new inbox hides sort (it's fixed to updated_at for this view).+ const newInboxFlag = useFeatureFlag(ENABLE_NEW_INBOX_FLAG, {+ enabledOverride: ENABLE_NEW_INBOX_OVERRIDE,+ });+ const isNewInbox = createMemo(() => {+ const content = panel.handle.content();+ return (+ content.type === 'component' &&+ content.id === 'inbox' &&+ newInboxFlag().enabled+ );+ });+return (<Show when={!isMobile()}><SplitToolbarLeft><div class="flex items-start gap-1 min-w-0 flex-1"><Show when={!isSearchView()} fallback={<SearchFiltersRow />}>- <SoupViewContextSort />+ <Show when={!isNewInbox()}>+ <SoupViewContextSort />+ </Show><SoupViewContextGroup /><UnifiedFilterDropdownopen={filterDropdownOpen}diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsxindex c5e3e94f1e..22e207860d 100644--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx@@ -14,12 +14,20 @@ import {queryStateFrom,} from '@app/component/next-soup/filters/filter-store';import { mergeQuery } from '@app/component/next-soup/filters/filter-store/query-store';-import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';+import {+ type ReadFilter,+ useSoupView,+} from '@app/component/next-soup/soup-view/soup-view-context';import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';import type { ListView } from '@app/constants/list-views';import { isListViewID } from '@app/constants/list-views';+import { useFeatureFlag } from '@app/lib/analytics/posthog';import { EntityIcon } from '@core/component/EntityIcon';import { UserIcon } from '@core/component/UserIcon';+import {+ ENABLE_NEW_INBOX_FLAG,+ ENABLE_NEW_INBOX_OVERRIDE,+} from '@core/constant/featureFlags';import { useUserId } from '@core/context/user';import { registerHotkey } from '@core/hotkey/hotkeys';import { TOKENS } from '@core/hotkey/tokens';@@ -466,6 +474,53 @@ interface UnifiedFilterDropdownProps {hideTrigger?: boolean;}+const READ_FILTER_OPTIONS: { id: ReadFilter; label: string }[] = [+ { id: 'unread', label: 'Unread' },+ { id: 'read', label: 'Read' },+ { id: 'all', label: 'All' },+];++/** Single-select read/unread/all submenu for the inbox. */+const ReadStatusSubmenu = (props: {+ value: ReadFilter;+ onChange: (value: ReadFilter) => void;+}) => {+ return (+ <Dropdown.Sub>+ <Dropdown.SubTrigger>+ <span class="text-ink">Status</span>+ <CaretRightIcon class="size-3 text-ink-muted" />+ </Dropdown.SubTrigger>++ <Dropdown.SubContent>+ <Dropdown.Group>+ <For each={READ_FILTER_OPTIONS}>+ {(option) => {+ const active = () => props.value === option.id;+ return (+ <Dropdown.Item+ onSelect={() => props.onChange(option.id)}+ closeOnSelect+ >+ <TypeIndicator active={active()} />+ <span+ class={cn(+ 'flex-1 truncate',+ active() ? 'text-ink' : 'text-ink-muted'+ )}+ >+ {option.label}+ </span>+ </Dropdown.Item>+ );+ }}+ </For>+ </Dropdown.Group>+ </Dropdown.SubContent>+ </Dropdown.Sub>+ );+};+export const UnifiedFilterDropdown = (props: UnifiedFilterDropdownProps = {}) => {@@ -476,8 +531,15 @@ export const UnifiedFilterDropdown = (props.onOpenChange?.(v);};const panel = useSplitPanelOrThrow();- const { soup, queryFilters, assigneeFilter, setAssigneeFilter, activeTab } =- useSoupView();+ const {+ soup,+ queryFilters,+ assigneeFilter,+ setAssigneeFilter,+ activeTab,+ readFilter,+ setReadFilter,+ } = useSoupView();const contacts = useContacts();const userId = useUserId();@@ -487,6 +549,11 @@ export const UnifiedFilterDropdown = (return undefined;return content.id;});++ const newInboxFlag = useFeatureFlag(ENABLE_NEW_INBOX_FLAG, {+ enabledOverride: ENABLE_NEW_INBOX_OVERRIDE,+ });+ const isNewInbox = () => currentView() === 'inbox' && newInboxFlag().enabled;const githubLinkStatus = useGithubLinkStatusQuery({enabled: () => currentView() === 'inbox',});@@ -673,7 +740,7 @@ export const UnifiedFilterDropdown = (};return (- <Show when={categories().length > 0 || isTasksView()}>+ <Show when={categories().length > 0 || isTasksView() || isNewInbox()}><Dropdownopen={open()}onOpenChange={handleOpenChange}@@ -695,8 +762,16 @@ export const UnifiedFilterDropdown = (<Dropdown.Content><Dropdown.Group>+ <Show when={isNewInbox()}>+ <ReadStatusSubmenu+ value={readFilter()}+ onChange={setReadFilter}+ />+ </Show><Show- when={categories().length === 1 && !isTasksView()}+ when={+ categories().length === 1 && !isTasksView() && !isNewInbox()+ }fallback={<><For each={categories()}>diff --git a/js/app/packages/app/component/next-soup/soup-view/group-options.ts b/js/app/packages/app/component/next-soup/soup-view/group-options.tsindex 3eadd6a445..ed1a1bcd6d 100644--- a/js/app/packages/app/component/next-soup/soup-view/group-options.ts+++ b/js/app/packages/app/component/next-soup/soup-view/group-options.ts@@ -12,12 +12,33 @@ export interface GroupOption {label: string;}-const _GROUP_OPTIONS: GroupOption[] = [+const GROUP_OPTIONS = [{ value: 'none', label: 'None' },{ value: 'date', label: 'Date' },{ value: 'entity_type', label: 'Type' },{ value: 'project', label: 'Project' },-];+ { value: `property:${SYSTEM_PROPERTY_IDS.STATUS}`, label: 'Status' },+ { value: `property:${SYSTEM_PROPERTY_IDS.PRIORITY}`, label: 'Priority' },+ { value: `property:${SYSTEM_PROPERTY_IDS.ASSIGNEES}`, label: 'Assignee' },+ { value: 'project', label: 'Project' },+ { value: 'date', label: 'Date' },+] as const satisfies GroupOption[];++const _buildGroupOptions = (+ keys: (typeof GROUP_OPTIONS)[number]['value'][]+) => {+ const options = [];++ for (const key of keys) {+ const option = GROUP_OPTIONS.find((o) => o.value === key);++ if (!option) continue;++ options.push(option);+ }++ return options;+};const _DEFAULT_GROUP_OPTIONS: GroupOption[] = [{ value: 'none', label: 'None' },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 2e3c0f5d1f..f5f80af4b5 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@@ -35,6 +35,8 @@ import {import { useFeatureFlag } from '@app/lib/analytics/posthog';import {ENABLE_FEATURED_SEARCH_RESULTS,+ ENABLE_NEW_INBOX_FLAG,+ ENABLE_NEW_INBOX_OVERRIDE,ENABLE_SUPPORTED_SOUP_FOREIGN_ENTITIES_FLAG,ENABLE_SUPPORTED_SOUP_FOREIGN_ENTITIES_OVERRIDE,} from '@core/constant/featureFlags';@@ -45,7 +47,10 @@ import {isWithNotification,toNotificationEntity,} from '@entity';-import { useNotificationsForEntity } from '@notifications';+import {+ useEntityTypeNotifications,+ useNotificationsForEntity,+} from '@notifications';import { useQueryClient } from '@queries/client';import type {GroupMeta as ApiGroupMeta,@@ -96,6 +101,8 @@ type SoupViewInitializeOptions = {additionalEntities?: Accessor<EntityData[]>;};+export type ReadFilter = 'all' | 'unread' | 'read';+interface SoupViewContextValues {soup: SoupState;initialize: (options?: SoupViewInitializeOptions) => void;@@ -116,6 +123,8 @@ interface SoupViewContextValues {setInboxFilter: Setter<string[] | undefined>;activeTab: Accessor<string | undefined>;setActiveTab: Setter<string | undefined>;+ readFilter: Accessor<ReadFilter>;+ setReadFilter: Setter<ReadFilter>;groupByField: Accessor<GroupByField | undefined>;fetchNextGroupPage: (groupKey: string) => Promise<void>;isFetchingGroupPage: (groupKey: string) => boolean;@@ -275,6 +284,10 @@ export const SoupViewContextProvider: FlowComponent<'soup.tab',{ default: undefined });+ const [readFilter, setReadFilter] = useEntryState<ReadFilter>(+ 'soup.readFilter',+ { default: 'unread' }+ );const groupByField = createMemo((): GroupByField | undefined => {const id = soup.grouping.activeGroupId();@@ -298,6 +311,41 @@ export const SoupViewContextProvider: FlowComponent<}});+ const notificationSource = useGlobalNotificationSource();++ const activeListView = createMemo<ListView | undefined>(() => {+ const content = panel.handle.content();+ if (content.type !== 'component') return;+ return isListViewID(content.id) ? content.id : undefined;+ });++ // The new inbox surfaces channel threads the user was mentioned in or replied+ // to (matching the experimental inbox), injected as `channelThreadId`+ // includes — soup otherwise only surfaces whole channels.+ const newInboxFlag = useFeatureFlag(ENABLE_NEW_INBOX_FLAG, {+ enabledOverride: ENABLE_NEW_INBOX_OVERRIDE,+ });+ const channelNotifications = useEntityTypeNotifications(+ notificationSource,+ 'channel'+ );+ const mentionedMessages = createMemo(() =>+ channelNotifications()+ .map((notification) => {+ const metadata = notification.notification_metadata;+ if (metadata.tag === 'channel_mention') {+ return metadata.content.threadId ?? metadata.content.messageId;+ }+ if (metadata.tag === 'channel_message_reply') {+ return metadata.content.threadId;+ }+ return undefined;+ })+ .filter((id): id is string => Boolean(id))+ );+ const isNewInbox = () =>+ activeListView() === 'inbox' && newInboxFlag().enabled;+const applyInboxFilter = (state: QueryState): QueryState => {const inboxes = inboxFilter();if (inboxes === undefined) return state;@@ -310,8 +358,63 @@ export const SoupViewContextProvider: FlowComponent<};};+ const applyInboxThreadFilter = (state: QueryState): QueryState => {+ if (!isNewInbox()) return state;+ const threadIds = mentionedMessages();+ if (!threadIds.length) return state;+ return {+ ...state,+ include: {+ ...state.include,+ channelThreadId: threadIds,+ },+ };+ };++ // Unread/read/all filter for the new inbox: injects the per-entity-type seen+ // filters ('all' leaves them unset). Matches the experimental inbox.+ const applyInboxReadFilter = (state: QueryState): QueryState => {+ if (!isNewInbox()) return state;+ const filter = readFilter();+ if (filter === 'all') return state;+ const seen = filter === 'read';+ return {+ ...state,+ include: {+ ...state.include,+ documentSeen: seen,+ emailSeen: seen,+ channelSeen: seen,+ chatSeen: seen,+ folderSeen: seen,+ },+ };+ };++ // The inbox only surfaces missed calls. The preset NILs `callId` to exclude+ // calls entirely, so drop that exclusion and filter to missed status instead.+ const applyInboxCallFilter = (state: QueryState): QueryState => {+ if (!isNewInbox()) return state;+ const { callId: _callId, ...include } = state.include;+ return {+ ...state,+ include: {+ ...include,+ callStatus: 'MISSED',+ },+ };+ };++ const applyViewFilters = (state: QueryState): QueryState => {+ let next = applyInboxFilter(state);+ next = applyInboxThreadFilter(next);+ next = applyInboxReadFilter(next);+ next = applyInboxCallFilter(next);+ return next;+ };+const soupBody = createMemo(() =>- compileToAst(applyInboxFilter(queryFilters.state))+ compileToAst(applyViewFilters(queryFilters.state)));const [searchText, setSearchText] = useEntryState<string>('search.text', {@@ -320,7 +423,7 @@ export const SoupViewContextProvider: FlowComponent<const search = createSearchState({soup,- filters: () => applyInboxFilter(queryFilters.state),+ filters: () => applyViewFilters(queryFilters.state),assignees: assigneeFilter,disableLocalSearch: () => config().disableLocalSearch ?? false,searchPaused: sourceSearchPaused,@@ -338,7 +441,6 @@ export const SoupViewContextProvider: FlowComponent<});};- const notificationSource = useGlobalNotificationSource();const userId = useUserId();const showSupportedForeignEntitiesFF = useFeatureFlag(ENABLE_SUPPORTED_SOUP_FOREIGN_ENTITIES_FLAG,@@ -364,12 +466,6 @@ export const SoupViewContextProvider: FlowComponent<};};- const activeListView = createMemo<ListView | undefined>(() => {- const content = panel.handle.content();- if (content.type !== 'component') return;- return isListViewID(content.id) ? content.id : undefined;- });-const itemsQuery = useSoupAstItemsQuery(() => ({params: soupParams(),@@ -648,6 +744,8 @@ export const SoupViewContextProvider: FlowComponent<setInboxFilter,activeTab,setActiveTab,+ readFilter,+ setReadFilter,groupByField,fetchNextGroupPage,isFetchingGroupPage,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 4cd24d03a2..775e480ecb 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@@ -39,6 +39,8 @@ import {SoupViewTabs,useApplyPreset,} from '@app/component/next-soup/soup-view/soup-view-tabs';+import { InboxListEntity } from '@app/component/next-soup/soup-view/views/inbox/InboxListEntity';+import { InboxExpansionProvider } from '@app/component/next-soup/soup-view/views/inbox/inbox-expansion';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 {@@ -59,6 +61,7 @@ import { SplitPanelContext } from '@app/component/split-layout/context';import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';import { LIST_VIEW_DOCS_URL } from '@app/constants/docs-links';import { isListViewID, type ListView } from '@app/constants/list-views';+import { useFeatureFlag } from '@app/lib/analytics/posthog';import { DEBUG_SETTING_KEYS, useDebugSetting } from '@app/lib/debugSettings';import { usePreference } from '@app/preferences/use-preference';import { CustomScrollbar } from '@core/component/CustomScrollbar';@@ -66,7 +69,11 @@ import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/componentimport { LoadingBlock } from '@core/component/LoadingBlock';import { Resize } from '@core/component/Resize';import { UserIcon } from '@core/component/UserIcon';-import { ENABLE_UNIFIED_LIST_AI_INPUT } from '@core/constant/featureFlags';+import {+ ENABLE_NEW_INBOX_FLAG,+ ENABLE_NEW_INBOX_OVERRIDE,+ ENABLE_UNIFIED_LIST_AI_INPUT,+} from '@core/constant/featureFlags';import { useUserId } from '@core/context/user';import {soupListContainerAttribute,@@ -835,6 +842,20 @@ export const SoupViewList = (props: SoupViewListProps) => {return isListViewID(id) ? id : undefined;};+ // Render the inbox with the new notification card layout when the flag is on.+ const newInboxFlag = useFeatureFlag(ENABLE_NEW_INBOX_FLAG, {+ enabledOverride: ENABLE_NEW_INBOX_OVERRIDE,+ });+ const isNewInboxEnabled = () =>+ currentView() === 'inbox' && newInboxFlag().enabled;++ // The per-row component depends on the active view (and the inbox flag).+ const listEntityComponent = () => {+ if (currentView() === 'tasks') return TaskListEntity;+ if (isNewInboxEnabled()) return InboxListEntity;+ return ListEntity;+ };+useSoupViewHotkeys({splitId: panel.handle.id,scopeId: scopeId(),@@ -1025,6 +1046,20 @@ export const SoupViewList = (props: SoupViewListProps) => {);onCleanup(previewCaptorTeardown);+ // The new inbox opens with the preview pane active by default. Wait for the+ // flag to resolve and a row to focus, then open the preview once — after that+ // the user controls it (including closing it) freely.+ if (persistedPreview === undefined) {+ let previewDefaulted = false;+ createEffect(() => {+ if (previewDefaulted || !isNewInboxEnabled()) return;+ const focused = soup.focus.id();+ if (!focused) return;+ previewDefaulted = true;+ soup.setPreviewEntity(focused);+ });+ }+// Which groups are collapsed is also per-entry state: captured on nav-away// and restored on back/forward.const collapsedCaptorTeardown = panel.handle.registerEntryStateCaptor(@@ -1181,130 +1216,153 @@ export const SoupViewList = (props: SoupViewListProps) => {</Match><Match when={rows().length}><ListLayoutProvider ref={localEntityListRef}>- <Show when={currentView() === 'tasks' && !isMobile()}>- <ResponsiveTaskListHeader class="shrink-0" />- </Show>- <EntityRowProvider- container={localEntityListRef}- canSwipeLeft={(entityId) => {- const entity = entityById().get(entityId);- if (!entity) return false;-- const tab = activeTab();-- if (- !isListViewID(contentId) ||- (tab && !canExecuteMarkDoneOnView(contentId, tab))- )- return false;-- return markDoneAction.canExecute(entity.original);- }}- onSwipeLeft={(entityId) => {- const entity = entityById().get(entityId);- if (!entity) return;- markDoneAction.executeWithSoup(- [entity.original],- soup- );- }}- setCollapseEntity={soup.collapseEntity.set}- >- <SoupList- cache={readListEntryState()?.virtualCache}- ref={(el) => {- setLocalEntityListRef(el);- soupNavigationTouchHighlight(el);+ <InboxExpansionProvider>+ <Show when={currentView() === 'tasks' && !isMobile()}>+ <ResponsiveTaskListHeader class="shrink-0" />+ </Show>+ <EntityRowProvider+ container={localEntityListRef}+ canSwipeLeft={(entityId) => {+ const entity = entityById().get(entityId);+ if (!entity) return false;++ const tab = activeTab();++ if (+ !isListViewID(contentId) ||+ (tab && !canExecuteMarkDoneOnView(contentId, tab))+ )+ return false;++ return markDoneAction.canExecute(entity.original);+ }}+ onSwipeLeft={(entityId) => {+ const entity = entityById().get(entityId);+ if (!entity) return;+ markDoneAction.executeWithSoup(+ [entity.original],+ soup+ );}}- virtualizerClass={cn(- previewVisible() && 'pt-1' /* scuffed */,- 'scrollbar-hidden'- )}- class="overflow-hidden flex min-w-0"- virtualizerRef={registerVirtualizerHandler}- onScrollBottom={debouncedFetchMore}- scrollBottomOffset={300}- rows={rows()}+ setCollapseEntity={soup.collapseEntity.set}>- {(row, i) => {- const timestamp = () => {- if (row.original.sortTs)- return row.original.sortTs;-- const sort_ = soup.sort.active();- if (!sort_.length) return;-- switch (sort_[0].id) {- case 'viewed_at':- return row.original.viewedAt;- case 'created_at':- return row.original.createdAt;- case 'updated_at':- return row.original.updatedAt;- default:- return row.original.createdAt;- }- };-- return (- <>- <Show when={i() === 0 && featuredCount() > 0}>- <SoupSectionHeader>- <span class="truncate">- Featured Results- </span>- </SoupSectionHeader>- </Show>- <Show- when={- i() === featuredCount() &&- featuredCount() > 0- }- >- <SoupSectionHeader>- <span class="truncate">More Results</span>- </SoupSectionHeader>- </Show>-- <Switch>- {/* Group header row */}- <Match when={row.getIsGrouped() && row.group}>- {(group) => (- <Dynamic- component={- group().renderHeader ??- DefaultGroupHeader- }- group={group()}- highlighted={row.isFocused()}- />- )}- </Match>-- {/* Load more row */}- <Match+ <SoupList+ cache={readListEntryState()?.virtualCache}+ ref={(el) => {+ setLocalEntityListRef(el);+ soupNavigationTouchHighlight(el);+ }}+ virtualizerClass={cn(+ previewVisible() && 'pt-1' /* scuffed */,+ 'scrollbar-hidden'+ )}+ class="overflow-hidden flex min-w-0"+ virtualizerRef={registerVirtualizerHandler}+ onScrollBottom={debouncedFetchMore}+ scrollBottomOffset={300}+ rows={rows()}+ >+ {(row, i) => {+ const timestamp = () => {+ if (row.original.sortTs)+ return row.original.sortTs;++ const sort_ = soup.sort.active();+ if (!sort_.length) return;++ switch (sort_[0].id) {+ case 'viewed_at':+ return row.original.viewedAt;+ case 'created_at':+ return row.original.createdAt;+ case 'updated_at':+ return row.original.updatedAt;+ default:+ return row.original.createdAt;+ }+ };++ return (+ <>+ <Show when={i() === 0 && featuredCount() > 0}>+ <SoupSectionHeader>+ <span class="truncate">+ Featured Results+ </span>+ </SoupSectionHeader>+ </Show>+ <Showwhen={- row.group?.isExpanded() &&- row.getIsLoadMore() &&- row.group+ i() === featuredCount() &&+ featuredCount() > 0}>- {(group) => {- const highlighted = () => row.isFocused();- return (- <div- class={cn(- 'my-1 rounded min-h-9 flex items-center justify-center',- highlighted()- ? 'w-[calc(100%-0.5rem)] mx-1 bg-active/60'- : 'mx-auto'- )}- >- <Show- when={- !isFetchingGroupPage(group().key)- }- fallback={+ <SoupSectionHeader>+ <span class="truncate">More Results</span>+ </SoupSectionHeader>+ </Show>++ <Switch>+ {/* Group header row */}+ <Match+ when={row.getIsGrouped() && row.group}+ >+ {(group) => (+ <Dynamic+ component={+ group().renderHeader ??+ DefaultGroupHeader+ }+ group={group()}+ highlighted={row.isFocused()}+ />+ )}+ </Match>++ {/* Load more row */}+ <Match+ when={+ row.group?.isExpanded() &&+ row.getIsLoadMore() &&+ row.group+ }+ >+ {(group) => {+ const highlighted = () =>+ row.isFocused();+ return (+ <div+ class={cn(+ 'my-1 rounded min-h-9 flex items-center justify-center',+ highlighted()+ ? 'w-[calc(100%-0.5rem)] mx-1 bg-active/60'+ : 'mx-auto'+ )}+ >+ <Show+ when={+ !isFetchingGroupPage(+ group().key+ )+ }+ fallback={+ <Button+ variant="base"+ size="sm"+ depth={2}+ class={cn({+ 'bg-surface':+ !highlighted(),+ 'border-transparent':+ highlighted(),+ })}+ disabled+ >+ <Spinner class="size-3 animate-spin" />+ Loading...+ </Button>+ }+ ><Buttonvariant="base"size="sm"@@ -1314,138 +1372,123 @@ export const SoupViewList = (props: SoupViewListProps) => {'border-transparent':highlighted(),})}- disabled+ onClick={() => {+ fetchNextGroupPage(+ group().key+ );+ }}>- <Spinner class="size-3 animate-spin" />- Loading...+ <CaretDownIcon class="size-2.5" />+ Load More</Button>- }- >- <Button- variant="base"- size="sm"- depth={2}- class={cn({- 'bg-surface': !highlighted(),- 'border-transparent':- highlighted(),- })}- onClick={() => {- fetchNextGroupPage(group().key);- }}- >- <CaretDownIcon class="size-2.5" />- Load More- </Button>- </Show>- </div>- );- }}- </Match>-- {/* Entity row */}- <Match- when={!row.group || row.group?.isExpanded()}- >- <SoupEntityContextMenu- entity={row.original}+ </Show>+ </div>+ );+ }}+ </Match>++ {/* Entity row */}+ <Match+ when={+ !row.group || row.group?.isExpanded()+ }>- <Dynamic- component={- currentView() === 'tasks'- ? TaskListEntity- : ListEntity- }+ <SoupEntityContextMenuentity={row.original}- timestamp={timestamp()}- highlighted={row.isFocused()}- onMouseMove={() => {- if (isKeypressActive()) return;- if (soup.previewEntity()) return;- soup.focus.setIndex(row.index);- }}- showUnrollNotifications={- row.original.type !== 'email' &&- soup.predicates.isActive('inbox') &&- !soup.predicates.isActive('noise')- }- checked={row.isSelected()}- onChecked={(- next: boolean,- shiftKey: boolean- ) =>- handleMultiSelectChecked({- entity: row.original,- entityIndex: i(),- next,- shiftKey: shiftKey ?? false,- })- }- onClick={(event: MouseEvent) => {- onEntityClick({- type: 'entity',- entity: row.original,- event,- location: undefined,- rowIndex: row.index,- });- }}- onProjectClick={(- projectEntity,- event- ) => {- onEntityClick({- type: 'project',+ >+ <Dynamic+ component={listEntityComponent()}+ entity={row.original}+ timestamp={timestamp()}+ highlighted={row.isFocused()}+ onMouseMove={() => {+ if (isKeypressActive()) return;+ if (soup.previewEntity()) return;+ soup.focus.setIndex(row.index);+ }}+ showUnrollNotifications={+ row.original.type !== 'email' &&+ soup.predicates.isActive('inbox') &&+ !soup.predicates.isActive('noise')+ }+ checked={row.isSelected()}+ onChecked={(+ next: boolean,+ shiftKey: boolean+ ) =>+ handleMultiSelectChecked({+ entity: row.original,+ entityIndex: i(),+ next,+ shiftKey: shiftKey ?? false,+ })+ }+ onClick={(event: MouseEvent) => {+ onEntityClick({+ type: 'entity',+ entity: row.original,+ event,+ location: undefined,+ rowIndex: row.index,+ });+ }}+ onProjectClick={(projectEntity,- entity: row.original,- event,- location: undefined,- rowIndex: row.index,- });- }}- onContentHitClick={(- e: PointerEvent | MouseEvent,- location?: SearchLocation- ) => {- onEntityClick({- type: 'entity',- entity: row.original,- event: e,- location,- rowIndex: row.index,- });- }}- entityRowConfig={{- swipeLeftColor: 'bg-success',- swipeLeftRevealedComponent: (- <CheckIcon class="size-8 text-panel" />- ),- }}- />- </SoupEntityContextMenu>- </Match>- </Switch>- <Show- when={- i() === rows().length - 1 &&- isSearchServiceLoading()- }- >- <div class="flex items-center gap-2 p-3 text-xs text-text-muted">- <Spinner class="size-3 animate-spin" />- Searching...- </div>- </Show>- <Show when={i() === rows().length - 1}>- {/* Desktop-only: mobile clearance comes+ event+ ) => {+ onEntityClick({+ type: 'project',+ projectEntity,+ entity: row.original,+ event,+ location: undefined,+ rowIndex: row.index,+ });+ }}+ onContentHitClick={(+ e: PointerEvent | MouseEvent,+ location?: SearchLocation+ ) => {+ onEntityClick({+ type: 'entity',+ entity: row.original,+ event: e,+ location,+ rowIndex: row.index,+ });+ }}+ entityRowConfig={{+ swipeLeftColor: 'bg-success',+ swipeLeftRevealedComponent: (+ <CheckIcon class="size-8 text-panel" />+ ),+ }}+ />+ </SoupEntityContextMenu>+ </Match>+ </Switch>+ <Show+ when={+ i() === rows().length - 1 &&+ isSearchServiceLoading()+ }+ >+ <div class="flex items-center gap-2 p-3 text-xs text-text-muted">+ <Spinner class="size-3 animate-spin" />+ Searching...+ </div>+ </Show>+ <Show when={i() === rows().length - 1}>+ {/* Desktop-only: mobile clearance comesfrom the in-scroll trailing spacer. */}- <div class="h-15 mobile:hidden" />- </Show>- </>- );- }}- </SoupList>- </EntityRowProvider>+ <div class="h-15 mobile:hidden" />+ </Show>+ </>+ );+ }}+ </SoupList>+ </EntityRowProvider>+ </InboxExpansionProvider></ListLayoutProvider><Show when={!props.customScrollbarHidden}>@@ -1470,7 +1513,10 @@ export const SoupViewList = (props: SoupViewListProps) => {<Resize.Panelid="soup-preview"minSize={300}- target={{ kind: 'percent', percent: 70 }}+ target={{+ kind: 'percent',+ percent: isNewInboxEnabled() ? 50 : 70,+ }}><PreviewPanelselectedEntity={soup.focus.item()}diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxCard.tsx b/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxCard.tsxnew file mode 100644index 0000000000..27fe66c9af--- /dev/null+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxCard.tsx@@ -0,0 +1,196 @@+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import { cn } from '@ui';+import { For, type JSX, Show } from 'solid-js';++interface SlotProps {+ class?: string;+ children?: JSX.Element;+}++export interface InboxCardAttachment {+ id: string;+ /** Media url; when absent, `fallback` fills the tile instead. */+ src?: string;+ kind?: 'image' | 'video';+ thumbSrc?: string;+ alt?: string;+ /** Tile contents when there's no `src` (e.g. a non-media entity preview). */+ fallback?: () => JSX.Element;+}++interface RootProps extends SlotProps {+ /** De-emphasize the row (e.g. already read). */+ dimmed?: boolean;+ selected?: boolean;+ highlighted?: boolean;+ onClick?: (event: MouseEvent) => void;+}++function Root(props: RootProps): JSX.Element {+ const interactive = (): boolean => Boolean(props.onClick);+ const onKeyDown = (event: KeyboardEvent): void => {+ if (!interactive()) return;+ if (event.key !== 'Enter' && event.key !== ' ') return;+ event.preventDefault();+ props.onClick?.(event as unknown as MouseEvent);+ };++ return (+ <div+ class={cn(+ 'group/inbox-item relative grid min-h-16 w-full grid-cols-[2.5rem_minmax(0,1fr)] items-center gap-x-3 rounded-lg px-2 py-1.5',++ {+ 'bg-accent/8': props.selected,+ 'bg-accent/16': props.selected && props.highlighted,+ 'bg-hover/30':+ props.highlighted && !props.selected && !isTouchDevice(),+ 'hover:bg-hover/30':+ !props.highlighted && !props.selected && !isTouchDevice(),+ 'opacity-65': props.dimmed,+ },+ props.class+ )}+ role={interactive() ? 'button' : undefined}+ tabIndex={interactive() ? 0 : undefined}+ onClick={props.onClick}+ onKeyDown={onKeyDown}+ >+ {props.children}+ </div>+ );+}++interface IconProps extends SlotProps {+ /** Avatar image url; falls back to `fallback` when absent. */+ src?: string;+ /** Shown when there's no `src` (e.g. initials or an icon). */+ fallback?: JSX.Element;+}++function Icon(props: IconProps): JSX.Element {+ return (+ <span+ class={cn(+ 'relative grid size-10 shrink-0 place-items-center self-start overflow-visible rounded-full',+ props.class+ )}+ >+ <span class="grid size-full place-items-center overflow-hidden rounded-full bg-active text-ink-muted">+ <Show when={props.src} fallback={props.fallback}>+ {(src) => <img src={src()} alt="" class="size-full object-cover" />}+ </Show>+ </span>+ {props.children}+ </span>+ );+}++function Body(props: SlotProps): JSX.Element {+ return (+ <div class={cn('flex min-w-0 flex-col gap-1', props.class)}>+ {props.children}+ </div>+ );+}++function Header(props: SlotProps): JSX.Element {+ return (+ <div class={cn('flex min-w-0 items-center gap-1 text-sm', props.class)}>+ {props.children}+ </div>+ );+}++function Title(props: SlotProps): JSX.Element {+ return (+ <div class={cn('min-w-0 flex-1 truncate', props.class)}>+ {props.children}+ </div>+ );+}++function Content(props: SlotProps): JSX.Element {+ return <div class={cn('min-w-0', props.class)}>{props.children}</div>;+}++function Attachments(props: {+ items: InboxCardAttachment[];+ max?: number;+ class?: string;+}): JSX.Element {+ const max = (): number => props.max ?? 4;+ const visible = (): InboxCardAttachment[] => props.items.slice(0, max());+ const overflow = (): number =>+ Math.max(props.items.length - visible().length, 0);++ return (+ <div+ class={cn('flex max-w-full flex-wrap items-center gap-1.5', props.class)}+ >+ <For each={visible()}>+ {(attachment) => (+ <Show when={attachment.src} fallback={attachment.fallback?.()}>+ {(src) => (+ <Show+ when={attachment.kind === 'video'}+ fallback={+ <img+ src={attachment.thumbSrc ?? src()}+ alt={attachment.alt ?? ''}+ loading="lazy"+ class="size-12 rounded-lg border border-edge object-cover"+ />+ }+ >+ <video+ src={src()}+ muted+ playsinline+ preload="metadata"+ class="size-12 rounded-lg border border-edge object-cover"+ />+ </Show>+ )}+ </Show>+ )}+ </For>+ <Show when={overflow() > 0}>+ <div class="grid size-12 place-items-center rounded-lg border border-edge bg-surface text-xs font-medium text-ink-muted">+ +{overflow()}+ </div>+ </Show>+ </div>+ );+}++interface MetaProps extends SlotProps {+ timestamp?: string;+}++function Meta(props: MetaProps): JSX.Element {+ return (+ <div+ class={cn(+ 'flex min-w-0 items-center gap-1.5 text-xs text-ink-extra-muted',+ props.class+ )}+ >+ <Show when={props.timestamp}>+ <span class="shrink-0">{props.timestamp}</span>+ </Show>+ {props.children}+ </div>+ );+}++export const InboxCard = {+ Root,+ Icon,+ Body,+ Header,+ Title,+ Content,+ Attachments,+ Meta,+};diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxListEntity.tsx b/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxListEntity.tsxnew file mode 100644index 0000000000..963f82ba0e--- /dev/null+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxListEntity.tsx@@ -0,0 +1,57 @@+import { useSoup } from '@app/component/next-soup/soup-context';+import { useChannelsContext } from '@core/context/channels';+import { MaybeEntityRow } from '@entity';+import type { BaseListEntityProps } from '@entity/composed/list-entity/shared';+import { createMemo } from 'solid-js';+import { InboxCardLayout, toInboxCardDisplayItem } from './inbox-card-layouts';+import { useInboxExpansion } from './inbox-expansion';+import { scopeThreadNotifications } from './utils';++/**+ * Inbox-specific list entity: renders the notification `InboxCardLayout` for a+ * soup row. Soup owns the query, virtualization, selection and preview, so this+ * adapter only maps the row into the card's display item and derives `selected`+ * from the focused row (which is what the preview shows).+ *+ * Expand/collapse of thread sub-items is read from the view-level+ * `InboxExpansionProvider` when present (so it survives the row scrolling out of+ * view); without a provider the card falls back to its own local state.+ */+export function InboxListEntity(props: BaseListEntityProps) {+ const soup = useSoup();+ const expansion = useInboxExpansion();+ const channels = useChannelsContext();++ // A channel_thread soup entity comes back with a generic name ("Channel+ // thread"), so resolve the real channel name for the row's location label.+ const entity = createMemo(() => {+ const scoped = scopeThreadNotifications(props.entity);+ if (scoped.type !== 'channel_thread') return scoped;+ const name = channels.channelsById()[scoped.channelId]?.name;+ return name ? { ...scoped, name } : scoped;+ });++ const item = createMemo(() => toInboxCardDisplayItem(entity()));+ // The preview follows the focused row, so the selected row is the focused one+ // (preview target and focus can diverge from `previewEntity` after a click).+ const selected = () => soup.focus.id() === props.entity.id;++ return (+ <div class="mx-1" ref={props.ref} onMouseMove={props.onMouseMove}>+ <MaybeEntityRow entityId={props.entity.id} config={props.entityRowConfig}>+ <InboxCardLayout+ item={item()}+ selected={selected()}+ highlighted={props.highlighted}+ onClick={props.onClick}+ expanded={+ expansion ? expansion.isExpanded(props.entity.id) : undefined+ }+ onToggleExpanded={+ expansion ? () => expansion.toggle(props.entity.id) : undefined+ }+ />+ </MaybeEntityRow>+ </div>+ );+}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.tsxnew file mode 100644index 0000000000..26ad196b88--- /dev/null+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx@@ -0,0 +1,1535 @@+import { ListPropertyValue } from '@app/component/next-soup/soup-view/views/tasks/list-property-value';+import { mapMediaItems } from '@channel/Media/media-items';+import { BotIcon } from '@channel/Message/BotIcon';+import { MACRO_AI_BOT_ID, MACRO_AI_NAME } from '@channel/macroAi';+import { EntityIcon, getEntityIconType } from '@core/component/EntityIcon';+import { ItemPreview } from '@core/component/ItemPreview';+import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';+import { unifiedListMarkdownTheme } from '@core/component/LexicalMarkdown/theme';+import { UserIcon } from '@core/component/UserIcon';+import { isMacroAgentId } from '@core/constant/macroAgent';+import { tryMacroId, useDisplayName } from '@core/user';+import {+ type EntityData,+ isGithubPrEntity,+ type Notification,+ unreadFilterFn,+ type WithNotification,+} from '@entity';+import MacroLogo from '@icon/macro-logo.svg';+import GithubIcon from '@icon/mcp-github.svg';+import FilesIcon from '@phosphor/files.svg';+import ArrowBendUpLeftIcon from '@phosphor-icons/core/regular/arrow-bend-up-left.svg?component-solid';+import AtIcon from '@phosphor-icons/core/regular/at.svg?component-solid';+import ChatCircleIcon from '@phosphor-icons/core/regular/chat-circle.svg?component-solid';+import ChatTextIcon from '@phosphor-icons/core/regular/chat-text.svg?component-solid';+import PhoneIcon from '@phosphor-icons/core/regular/phone.svg?component-solid';+import UserPlusIcon from '@phosphor-icons/core/regular/user-plus.svg?component-solid';+import {+ PropertiesProvider,+ type PropertySaveHandler,+} from '@property/context/PropertiesContext';+import type { PropertyApiValues, Property as PropertyT } from '@property/types';+import { senderFromStorageId } from '@queries/channel/message-sender';+import { useBulkSaveEntityPropertiesMutation } from '@queries/properties/entity';+import { stringToItemType } from '@service-storage/client';+import { EntityType } from '@service-storage/generated/schemas';+import { cn } from '@ui';+import {+ createMemo,+ createSignal,+ For,+ type JSX,+ Match,+ Show,+ Switch,+} from 'solid-js';+import { match, P } from 'ts-pattern';+import { InboxCard, type InboxCardAttachment } from './InboxCard';+import {+ formatCompactRelativeTimestamp,+ getGithubTitle,+ getInboxTaskProperties,+ getNotificationTag,+ itemContent,+} from './utils';++export interface InboxCardLayoutProps {+ /** The already-derived item to render. */+ item: InboxCardDisplayItem;+ selected?: boolean;+ highlighted?: boolean;+ expanded?: boolean;+ onClick?: (event: MouseEvent) => void;+ onToggleExpanded?: () => void;+}++type NotificationTag = ReturnType<typeof getNotificationTag>;++/** The notification driving the row's action/sender (most recent first). */+const getFirstNotification = (item: WithNotification<EntityData>) =>+ item.notifications?.()?.[0];++const isUnreadNotification = (notification?: Notification) =>+ notification ? !notification.viewed_at : false;++const getGithubSender = (entity: EntityData, notification?: Notification) => {+ const content = notification?.notification_metadata.content as+ | { senderGithubLogin?: string | null }+ | undefined;+ const pr =+ entity.type === 'foreign' && entity.foreignSource === 'github_pull_request'+ ? entity.metadata+ : undefined;+ const login = content?.senderGithubLogin ?? pr?.authorLogin ?? undefined;+ let imageUrl: string | undefined;+ if (content?.senderGithubLogin) {+ imageUrl = `https://github.com/${encodeURIComponent(content.senderGithubLogin)}.png?size=80`;+ } else if (pr?.authorId) {+ imageUrl = `https://avatars.githubusercontent.com/u/${pr.authorId}?s=80&v=4`;+ } else if (login) {+ imageUrl = `https://github.com/${encodeURIComponent(login)}.png?size=80`;+ }++ return { id: login, fallbackName: login, imageUrl };+};++const getNotificationSenderFallbackName = (+ notification: Notification+): string | undefined => {+ const content = notification.notification_metadata.content as+ | { sender?: string; senderGithubLogin?: string }+ | undefined;++ switch (notification.notification_metadata.tag) {+ case 'new_email':+ return content?.sender ?? undefined;+ case 'ai_response':+ return 'Macro agent';+ case 'channel_message_send':+ return content?.sender ?? notification.sender_id ?? undefined;+ case 'github_pr_status_changed':+ case 'github_review_requested':+ case 'github_pr_comment':+ case 'github_pr_mention':+ case 'github_pr_review':+ return content?.senderGithubLogin ?? notification.sender_id ?? undefined;+ default:+ return undefined;+ }+};++const getTimestamp = (entity: EntityData, notification?: Notification) => {+ const messageTime =+ entity.type === 'channel'+ ? entity.latestRootMessage?.createdAt+ : entity.type === 'channel_message' || entity.type === 'channel_thread'+ ? (entity.createdAt ?? entity.updatedAt)+ : undefined;+ const raw =+ messageTime ??+ notification?.created_at ??+ notification?.updated_at ??+ entity.updatedAt ??+ entity.createdAt;+ return raw != null ? String(raw) : undefined;+};++const initials = (name: string) =>+ name+ .split(/\s+/)+ .filter(Boolean)+ .slice(0, 2)+ .map((part) => part[0]?.toUpperCase())+ .join('') || '?';++type SenderIconProps = {+ class?: string;+ senderId?: string;+};++export function SenderIcon(props: SenderIconProps) {+ // Bot senders render their own avatar; Macro AI keeps its dedicated logo.+ const botSender = () => {+ const sender = props.senderId+ ? senderFromStorageId(props.senderId)+ : undefined;+ if (sender?.type !== 'bot' || isMacroAgentId(sender.id)) return;+ return sender;+ };++ return (+ <div class={cn('shrink-0 size-(--user-icon-width)', props.class)}>+ <Show+ when={botSender()}+ fallback={<UserIcon id={props.senderId ?? ''} size="fill" />}+ >+ {(bot) => (+ <BotIcon name={bot().name} avatarUrl={bot().avatar_url} size="fill" />+ )}+ </Show>+ </div>+ );+}++function Avatar(props: {+ senderId?: string;+ fallbackName?: string;+ imageUrl?: string;+}) {+ const parsedSender = () =>+ props.senderId ? senderFromStorageId(props.senderId) : undefined;+ const isMacroAgent = () => {+ const sender = parsedSender();+ return sender?.type === 'bot' && isMacroAgentId(sender.id);+ };++ return (+ <Switch+ fallback={+ <span class="text-xs text-ink-muted">+ {initials(props.fallbackName ?? props.senderId ?? '')}+ </span>+ }+ >+ <Match when={props.imageUrl}>+ {(url) => <img src={url()} alt="" class="size-full object-cover" />}+ </Match>+ <Match when={isMacroAgent()}>+ <MacroLogo class="m-auto size-1/2 text-accent" />+ </Match>+ <Match when={props.senderId}>+ {(senderId) => <SenderIcon senderId={senderId()} />}+ </Match>+ </Switch>+ );+}++const tagBubbleIcon = (tag: NotificationTag) =>+ match(tag)+ .with('new_email', () => () => (+ <span class="grid size-3 place-items-center">+ <EntityIcon targetType="email" size="fill" />+ </span>+ ))+ .with('task_assigned', () => () => (+ <span class="grid size-3 place-items-center">+ <EntityIcon targetType="task" size="fill" />+ </span>+ ))+ .with('ai_response', () => () => (+ <span class="grid size-3 place-items-center">+ <EntityIcon targetType="chat" size="fill" />+ </span>+ ))+ .with('channel_mention', 'mentioned_in_document_comment', () => () => (+ <AtIcon class="size-3" />+ ))+ .with('document_mention', () => () => <FilesIcon class="size-3" />)+ .with(+ 'channel_message_reply',+ 'replied_to_document_comment_thread',+ () => () => <ArrowBendUpLeftIcon class="size-3" />+ )+ .with('commented_on_document', () => () => (+ <ChatCircleIcon class="size-3" />+ ))+ .with('channel_message_send', () => () => <ChatTextIcon class="size-3" />)+ .with('channel_invite', 'invite_to_team', () => () => (+ <UserPlusIcon class="size-3" />+ ))+ .with('call_started', () => () => <PhoneIcon class="size-3" />)+ .with(+ 'github_pr_status_changed',+ 'github_pr_check_run',+ 'github_review_requested',+ 'github_pr_comment',+ 'github_pr_mention',+ 'github_pr_review',+ () => () => <GithubIcon class="size-3" />+ )+ .with(+ P.when((value) => value?.startsWith('github_') ?? false),+ () => () => <GithubIcon class="size-3" />+ )+ .otherwise(() => undefined);++/** Avatar action bubble derived from the notification tag (mention, reply, …). */+function ActionBubble(props: { tag: NotificationTag }) {+ const renderIcon = () => tagBubbleIcon(props.tag);++ return (+ <Show when={renderIcon()}>+ {(renderIcon) => (+ <span class="absolute -bottom-1 -right-1 grid size-5 place-items-center overflow-hidden rounded-full bg-surface text-ink-muted ring-2 ring-surface">+ {renderIcon()()}+ </span>+ )}+ </Show>+ );+}++function Badge(props: { unread: boolean }) {+ return (+ <Show when={props.unread}>+ <span class="ml-auto flex shrink-0 items-center">+ <span class="size-2 rounded-full bg-accent" />+ </span>+ </Show>+ );+}++function PropertyPills(props: { entityId: string; properties?: PropertyT[] }) {+ const properties = createMemo(() => props.properties ?? []);++ const saveMutation = useBulkSaveEntityPropertiesMutation();++ const saveOne = (property: PropertyT, apiValues: PropertyApiValues) =>+ saveMutation.mutateAsync({+ properties: [+ {+ entityId: props.entityId,+ entityType: EntityType.TASK,+ property,+ apiValues,+ },+ ],+ });++ const saveHandler: PropertySaveHandler = {+ saveProperty: (property, value) => saveOne(property, value),+ saveDate: (property, date) =>+ saveOne(property, { valueType: 'DATE', value: date }),+ };++ return (+ <Show when={properties().length}>+ <PropertiesProvider+ entityType={EntityType.TASK}+ canEdit={true}+ properties={properties}+ onRefresh={() => {}}+ onPropertyAdded={() => {}}+ onPropertyDeleted={() => {}}+ saveHandler={saveHandler}+ >+ <div class="flex flex-wrap items-center gap-1 text-xs">+ <For each={properties()}>+ {(property) => <ListPropertyValue property={property} />}+ </For>+ </div>+ </PropertiesProvider>+ </Show>+ );+}++const relativeTime = (timestamp: string | undefined): string | undefined =>+ timestamp ? formatCompactRelativeTimestamp(timestamp) : undefined;++const createSenderDisplayName = (+ senderId: () => string | undefined,+ fallbackName?: () => string | undefined+) => {+ const macroId = () => {+ const id = senderId();+ return id ? tryMacroId(id) : undefined;+ };++ const [displayName] = useDisplayName(macroId());++ const botName = () => {+ const id = senderId();+ if (!id) return undefined;++ const parsed = senderFromStorageId(id);+ if (parsed.type !== 'bot') return undefined;++ if (parsed.name) return parsed.name;+ return parsed.id === MACRO_AI_BOT_ID ? MACRO_AI_NAME : 'Bot';+ };++ return () => botName() || displayName() || fallbackName?.() || senderId();+};++const buildActionLabel = (args: {+ sender?: string;+ action: string;+ location?: string;+}): string =>+ [args.sender, args.action, args.location].filter(Boolean).join(' ');++const channelLocation = (entity: EntityData): string | undefined => {+ if (+ entity.type !== 'channel' &&+ entity.type !== 'channel_message' &&+ entity.type !== 'channel_thread'+ ) {+ return undefined;+ }+ if (entity.channelType === 'direct_message') return undefined;+ return entity.name.startsWith('#') ? entity.name : `#${entity.name}`;+};++const entityLocation = (entity: EntityData): string | undefined => {+ if (+ (entity.type === 'channel' ||+ entity.type === 'channel_message' ||+ entity.type === 'channel_thread') &&+ entity.channelType === 'direct_message'+ ) {+ return undefined;+ }+ return entity.name;+};++const githubLocation = (entity: EntityData): string | undefined => {+ if (+ entity.type !== 'foreign' ||+ entity.foreignSource !== 'github_pull_request'+ ) {+ return entity.name;+ }+ return `${entity.metadata.owner}/${entity.metadata.repo}#${entity.metadata.number}`;+};++const githubAction = (notification?: Notification): string => {+ const metadata = notification?.notification_metadata;++ return match(metadata)+ .with(+ { tag: 'github_pr_status_changed', content: { status: 'merged' } },+ () => 'merged'+ )+ .with(+ { tag: 'github_pr_status_changed', content: { status: 'closed' } },+ () => 'closed'+ )+ .with({ tag: 'github_review_requested' }, () => 'requested your review on')+ .with({ tag: 'github_pr_comment' }, () => 'commented on')+ .with({ tag: 'github_pr_mention' }, () => 'mentioned you in')+ .with({ tag: 'github_pr_review' }, () => 'reviewed')+ .otherwise(() => 'updated');+};++function BaseCard(props: {+ selected?: boolean;+ highlighted?: boolean;+ onClick?: (event: MouseEvent) => void;+ unread: boolean;+ leading: JSX.Element;+ title: JSX.Element;+ preview?: string;+ attachments?: InboxCardAttachment[];+ entityId: string;+ properties?: PropertyT[];+ timestamp?: string;+ /** Extra controls rendered in the meta line, after the timestamp. */+ metaActions?: JSX.Element;+}) {+ return (+ <InboxCard.Root+ dimmed={!props.unread}+ selected={props.selected}+ highlighted={props.highlighted}+ onClick={props.onClick}+ >+ {props.leading}+ <InboxCard.Body>+ <InboxCard.Header>+ <InboxCard.Title>{props.title}</InboxCard.Title>+ <Badge unread={props.unread} />+ </InboxCard.Header>++ <Show when={props.preview?.trim()}>+ {(value) => (+ <InboxCard.Content class="truncate text-sm text-ink/60">+ <StaticMarkdown+ markdown={value()}+ singleLine+ theme={unifiedListMarkdownTheme}+ />+ </InboxCard.Content>+ )}+ </Show>++ <PropertyPills+ entityId={props.entityId}+ properties={props.properties}+ />++ <Show when={props.attachments?.length}>+ <InboxCard.Attachments items={props.attachments!} />+ </Show>++ <Show when={props.timestamp || props.metaActions}>+ <InboxCard.Meta timestamp={relativeTime(props.timestamp)}>+ {props.metaActions}+ </InboxCard.Meta>+ </Show>+ </InboxCard.Body>+ </InboxCard.Root>+ );+}++export function ChannelCardLayout(props: InboxCardLayoutProps) {+ const subItems = createMemo(() => {+ const entity = props.item.entity;+ let notifications = entity.notifications?.() ?? [];++ const next = [];++ for (const notification of notifications) {+ const meta = notification.notification_metadata;++ const isValid = (+ [+ 'document_mention',+ 'call_started',+ 'channel_invite',+ ] as NotificationTag[]+ ).includes(meta.tag);++ if (!isValid) continue;++ let isCurrentMessage = false;++ if (entity.type === 'channel') {+ if (+ meta.tag === 'document_mention' &&+ meta.content.messageId === entity.latestRootMessage?.messageId+ ) {+ isCurrentMessage = true;+ }+ }++ if (isCurrentMessage) continue;++ next.push(notification);+ }++ return next.toSorted((a, b) => notificationTime(b) - notificationTime(a));+ });++ const hasSubItems = createMemo(() => subItems().length > 0);++ const [localExpanded, setLocalExpanded] = createSignal(false);+ const expanded = () => props.expanded ?? localExpanded();+ const toggleExpanded = () => {+ if (props.onToggleExpanded) {+ props.onToggleExpanded();+ return;+ }+ setLocalExpanded((value) => !value);+ };++ const entity = createMemo(() => props.item.entity);++ const senderId = () => {+ const value = props.item.entity;+ return value.type === 'channel'+ ? value.latestRootMessage?.senderId+ : undefined;+ };++ const senderName = createSenderDisplayName(senderId);++ const isDM = createMemo(() => {+ const value = entity();+ return value.type === 'channel' && value.channelType === 'direct_message';+ });++ const text = createMemo(() => {+ const location = channelLocation(entity());+ const tag = getNotificationTag(props.item.notification);++ let sender;+ let action = '';++ if (tag === 'document_mention' && isDM()) {+ action = 'shared a document with you';+ sender = senderName();+ } else if (tag === 'channel_message_send') {+ action = 'sent you a message';+ sender = senderName();+ }++ const content = itemContent(entity(), props.item.notification);++ return {+ title: buildActionLabel({+ sender,+ action,+ location,+ }),+ content,+ };+ });++ return (+ <InboxCard.Root+ dimmed={!props.item.unread}+ selected={props.selected}+ highlighted={props.highlighted}+ onClick={props.onClick}+ >+ <Show+ when={!isDM()}+ fallback={+ <InboxCard.Icon fallback={<Avatar senderId={senderId()} />}>+ <ActionBubble tag={getNotificationTag(props.item.notification)} />+ </InboxCard.Icon>+ }+ >+ <InboxCard.Icon+ fallback={+ <EntityIcon+ class="size-3"+ targetType={getEntityIconType(entity())}+ size="fill"+ theme="monochrome"+ />+ }+ />+ </Show>+ <InboxCard.Body>+ <InboxCard.Header>+ <InboxCard.Title>{text().title}</InboxCard.Title>+ <Badge unread={props.item.unread} />+ </InboxCard.Header>++ <div class="flex items-center gap-1">+ <Show when={!isDM()}>+ <span class="flex gap-1 items-center text-xs">+ <Show when={senderId()}>+ {(id) => (+ <UserIcon+ id={id()}+ size="sm"+ suppressClick+ showTooltip={false}+ />+ )}+ </Show>+ {senderName()}+ </span>+ </Show>+ <Show when={text().content?.trim()}>+ {(value) => (+ <InboxCard.Content class="truncate text-sm text-ink/60">+ <StaticMarkdown+ markdown={value()}+ singleLine+ theme={unifiedListMarkdownTheme}+ />+ </InboxCard.Content>+ )}+ </Show>+ </div>++ <Show when={props.item.timestamp || hasSubItems()}>+ <InboxCard.Meta timestamp={relativeTime(props.item.timestamp)}>+ <Show when={hasSubItems()}>+ <Show when={props.item.timestamp}>+ <span aria-hidden="true">•</span>+ </Show>+ <button+ type="button"+ class="rounded text-ink-extra-muted transition-colors hover:text-ink-muted focus-visible:outline-none focus-visible:ring focus-visible:ring-accent/40 truncate"+ onClick={(event) => {+ event.preventDefault();+ event.stopPropagation();+ toggleExpanded();+ }}+ >+ {expanded()+ ? 'Hide all notifications'+ : 'Show all notifications'}+ </button>+ </Show>+ </InboxCard.Meta>+ </Show>+ </InboxCard.Body>+ <Show when={expanded() && hasSubItems()}>+ <div class="w-full col-start-2 flex flex-col gap-1 border-l border-edge-muted">+ <For each={subItems()}>+ {(notification) => (+ <ThreadReplySubItem+ notification={notification}+ threadEntityId={props.item.entity.id}+ onClick={props.onClick}+ isDM={isDM()}+ />+ )}+ </For>+ </div>+ </Show>+ </InboxCard.Root>+ );+}++export function ChannelMessageCardLayout(props: InboxCardLayoutProps) {+ const senderId = () => {+ const value = props.item.entity;+ return value.type === 'channel_message' ? value.senderId : undefined;+ };++ const senderName = createSenderDisplayName(senderId);++ const text = createMemo(() => {+ const location = channelLocation(props.item.entity);+ const tag = getNotificationTag(props.item.notification);+ let action = 'sent a message';+ if (tag === 'channel_mention') {+ action = location ? 'mentioned you in' : 'mentioned you';+ } else if (location) {+ action = 'sent a message in';+ }++ return {+ title: buildActionLabel({ sender: senderName(), action, location }),+ content: itemContent(props.item.entity, props.item.notification),+ };+ });++ return (+ <BaseCard+ entityId={props.item.entity.id}+ selected={props.selected}+ highlighted={props.highlighted}+ onClick={props.onClick}+ unread={props.item.unread}+ timestamp={props.item.timestamp}+ leading={+ <InboxCard.Icon fallback={<Avatar senderId={senderId()} />}>+ <ActionBubble tag={getNotificationTag(props.item.notification)} />+ </InboxCard.Icon>+ }+ title={text().title}+ preview={text().content}+ />+ );+}++const notificationTime = (notification: Notification): number => {+ const raw = notification.created_at ?? notification.updated_at;+ const time = raw != null ? Date.parse(String(raw)) : 0;+ return Number.isNaN(time) ? 0 : time;+};++function ThreadReplySubItem(props: {+ isDM?: boolean;+ notification: Notification;+ threadEntityId: string;+ selected?: boolean;+ onClick?: (event: MouseEvent) => void;+}) {+ const senderId = () => props.notification.sender_id ?? undefined;+ const senderFallbackName = () =>+ getNotificationSenderFallbackName(props.notification);+ const senderName = createSenderDisplayName(senderId, senderFallbackName);++ const messageContent = () => {+ const notification = props.notification;+ const meta = notification.notification_metadata;+ return match(meta)+ .with({ tag: 'channel_message_reply' }, (m) => m.content.messageContent)+ .with({ tag: 'document_mention' }, (m) => m.content.messageContent)+ .with({ tag: 'call_started' }, (m) => m.content.channel_name?.toString())+ .with({ tag: 'channel_invite' }, (m) =>+ m.content.messageContent?.toString()+ )+ .with({ tag: 'channel_mention' }, (m) => m.content.messageContent)+ .otherwise(() => undefined);+ };++ const action = () => {+ const tag = getNotificationTag(props.notification);++ if (tag === 'channel_mention') return 'mentioned you';+ if (tag === 'channel_message_reply') return 'replied';+ if (tag === 'document_mention') return 'shared a document with you';+ if (tag === 'call_started') return 'started a call';+ if (tag === 'channel_invite') return 'started a conversation';++ return 'sent a message';+ };++ const timestamp = () => {+ const raw = props.notification.created_at ?? props.notification.updated_at;+ return raw != null ? String(raw) : undefined;+ };++ return (+ <BaseCard+ entityId={props.threadEntityId}+ selected={props.selected}+ onClick={props.onClick}+ unread={isUnreadNotification(props.notification)}+ timestamp={timestamp()}+ leading={+ <InboxCard.Icon+ fallback={+ <Avatar senderId={senderId()} fallbackName={senderFallbackName()} />+ }+ >+ <ActionBubble tag={getNotificationTag(props.notification)} />+ </InboxCard.Icon>+ }+ title={buildActionLabel({+ sender: props.isDM ? undefined : senderName(),+ action: action(),+ })}+ preview={messageContent()}+ />+ );+}++export function ChannelThreadCardLayout(props: InboxCardLayoutProps) {+ const isLatestNotificationReply = createMemo(() => {+ const notification = props.item.notification;+ const notificationMetadata = notification?.notification_metadata;++ return notificationMetadata?.tag === 'channel_message_reply';+ });++ // When the latest notification is a reply, the thread's notifications become+ // expandable sub items (most recent first).+ const subItems = createMemo(() => {+ if (!isLatestNotificationReply()) return [];+ const notifications = props.item.entity.notifications?.() ?? [];+ return notifications.toSorted(+ (a, b) => notificationTime(b) - notificationTime(a)+ );+ });++ const hasSubItems = () => subItems().length > 0;++ const [localExpanded, setLocalExpanded] = createSignal(false);+ const expanded = () => props.expanded ?? localExpanded();+ const toggleExpanded = () => {+ if (props.onToggleExpanded) {+ props.onToggleExpanded();+ return;+ }+ setLocalExpanded((value) => !value);+ };++ const senderId = createMemo(() => {+ const value = props.item.entity;++ if (isLatestNotificationReply()) {+ return props.item.notification?.sender_id ?? undefined;+ }++ return value.type === 'channel_thread' ? value.senderId : undefined;+ });++ const isDM = createMemo(() => {+ const notification = props.item.notification;+ const meta = notification?.notification_metadata;+ return match(meta)+ .with(+ P.union(+ { tag: 'channel_mention' },+ { tag: 'channel_message_reply' },+ { tag: 'channel_message_send' }+ ),+ (m) => m.content.channelType === 'directMessage'+ )+ .otherwise(() => false);+ });++ const senderName = createSenderDisplayName(senderId);++ const text = createMemo(() => {+ const metadata = props.item.notification?.notification_metadata;+ const location = channelLocation(props.item.entity);++ const includeLocation = location && !isDM();++ let action = includeLocation ? 'started a thread in' : 'started a thread';++ if (metadata?.tag === 'channel_mention') {+ action = includeLocation ? 'mentioned you in' : 'mentioned you';+ } else if (metadata?.tag === 'channel_message_reply') {+ action = includeLocation ? 'replied in' : 'replied';+ }++ let content = itemContent(props.item.entity, props.item.notification);+ if (metadata?.tag === 'channel_message_reply') {+ content = metadata.content.messageContent;+ }++ return {+ title: buildActionLabel({+ sender: senderName(),+ action,+ location: includeLocation ? location : undefined,+ }),+ content,+ };+ });++ const attachments = createMemo(() => {+ if (+ isLatestNotificationReply() ||+ props.item.entity.type !== 'channel_thread'+ )+ return;++ const itemAttachments = props.item.entity.attachments;++ return itemAttachments.map((attachment): InboxCardAttachment => {+ const media = mapMediaItems([attachment])[0];+ if (media) {+ return {+ id: media.id,+ src: media.src,+ kind: media.kind,+ thumbSrc: media.thumbSrc,+ };+ }+ return {+ id: attachment.entity_id,+ fallback: () => (+ <ItemPreview+ id={attachment.entity_id}+ type={stringToItemType(attachment.entity_type)}+ />+ ),+ };+ });+ });++ return (+ <div class="flex flex-col gap-1">+ <BaseCard+ entityId={props.item.entity.id}+ selected={props.selected}+ highlighted={props.highlighted}+ onClick={props.onClick}+ unread={props.item.unread}+ timestamp={props.item.timestamp}+ leading={+ <Show+ when={isLatestNotificationReply()}+ fallback={+ <InboxCard.Icon fallback={<Avatar senderId={senderId()} />}>+ <ActionBubble+ tag={getNotificationTag(props.item.notification)}+ />+ </InboxCard.Icon>+ }+ >+ <InboxCard.Icon+ fallback={<ChatTextIcon class="size-4 shrink-0" />}+ />+ </Show>+ }+ title={text().title}+ preview={text().content}+ attachments={attachments()}+ metaActions={+ hasSubItems() ? (+ <>+ <Show when={props.item.timestamp}>+ <span aria-hidden="true">•</span>+ </Show>+ <button+ type="button"+ class="rounded text-ink-extra-muted transition-colors hover:text-ink-muted focus-visible:outline-none focus-visible:ring focus-visible:ring-accent/40 truncate"+ onClick={(event) => {+ event.preventDefault();+ event.stopPropagation();+ toggleExpanded();+ }}+ >+ {expanded() ? 'Hide thread messages' : 'Show thread messages'}+ </button>+ </>+ ) : undefined+ }+ />+ <Show when={expanded() && hasSubItems()}>+ <div class="ml-5 flex flex-col gap-1 border-l border-edge-muted pl-4">+ <For each={subItems()}>+ {(notification) => (+ <ThreadReplySubItem+ notification={notification}+ threadEntityId={props.item.entity.id}+ onClick={props.onClick}+ isDM={isDM()}+ />+ )}+ </For>+ </div>+ </Show>+ </div>+ );+}++export function DocumentCardLayout(props: InboxCardLayoutProps) {+ const senderId = () => props.item.notification?.sender_id ?? undefined;++ const senderFallbackName = () =>+ props.item.notification+ ? getNotificationSenderFallbackName(props.item.notification)+ : undefined;++ const senderName = createSenderDisplayName(senderId, senderFallbackName);++ const text = createMemo(() => {+ const metadata = props.item.notification?.notification_metadata;+ const location = entityLocation(props.item.entity);+ const content = itemContent(props.item.entity, props.item.notification);++ if (metadata?.tag === 'document_mention') {+ return {+ title: buildActionLabel({+ sender: senderName(),+ action: 'shared',+ location,+ }),+ content: metadata.content.messageContent,+ };+ }++ if (metadata?.tag === 'mentioned_in_document_comment') {+ let action = 'mentioned you';+ if (location) action = 'mentioned you in';++ return {+ title: buildActionLabel({+ sender: senderName(),+ action,+ location,+ }),+ content,+ };+ }++ if (metadata?.tag === 'replied_to_document_comment_thread') {+ let action = 'replied';+ if (location) action = 'replied in';++ return {+ title: buildActionLabel({+ sender: senderName(),+ action,+ location,+ }),+ content,+ };+ }++ return { title: props.item.entity.name, content };+ });++ return (+ <BaseCard+ entityId={props.item.entity.id}+ selected={props.selected}+ highlighted={props.highlighted}+ onClick={props.onClick}+ unread={props.item.unread}+ timestamp={props.item.timestamp}+ leading={+ <InboxCard.Icon+ fallback={+ <Show+ when={props.item.notification}+ fallback={+ <EntityIcon targetType={getEntityIconType(props.item.entity)} />+ }+ >+ <Avatar+ senderId={senderId()}+ fallbackName={senderFallbackName()}+ />+ </Show>+ }+ >+ <ActionBubble tag={getNotificationTag(props.item.notification)} />+ </InboxCard.Icon>+ }+ title={text().title}+ preview={text().content}+ />+ );+}++export function TaskCardLayout(props: InboxCardLayoutProps) {+ const senderId = () =>+ props.item.notification?.sender_id ?? props.item.entity.ownerId;++ const senderFallbackName = () =>+ props.item.notification+ ? getNotificationSenderFallbackName(props.item.notification)+ : undefined;++ const senderName = createSenderDisplayName(senderId, senderFallbackName);++ const text = createMemo(() => {+ const content = itemContent(props.item.entity, props.item.notification);++ if (getNotificationTag(props.item.notification) === 'task_assigned') {+ return {+ title: buildActionLabel({+ sender: senderName(),+ action: 'assigned you a task',+ }),+ content: content || props.item.entity.name,+ };+ }++ return { title: props.item.entity.name, content };+ });++ return (+ <BaseCard+ entityId={props.item.entity.id}+ selected={props.selected}+ highlighted={props.highlighted}+ onClick={props.onClick}+ unread={props.item.unread}+ timestamp={props.item.timestamp}+ leading={+ <InboxCard.Icon+ fallback={+ <Show+ when={props.item.notification}+ fallback={+ <EntityIcon targetType={getEntityIconType(props.item.entity)} />+ }+ >+ <Avatar+ senderId={senderId()}+ fallbackName={senderFallbackName()}+ />+ </Show>+ }+ >+ <ActionBubble tag={getNotificationTag(props.item.notification)} />+ </InboxCard.Icon>+ }+ title={text().title}+ preview={text().content}+ properties={getInboxTaskProperties(props.item.entity)}+ />+ );+}++export function AiCardLayout(props: InboxCardLayoutProps) {+ const senderId = () => props.item.notification?.sender_id ?? undefined;++ const senderFallbackName = () => {+ return props.item.notification+ ? getNotificationSenderFallbackName(props.item.notification)+ : 'Ai';+ };++ const senderName = createSenderDisplayName(senderId, () => 'Macro');++ const text = createMemo(() => {+ const content = itemContent(props.item.entity, props.item.notification);+ const location = entityLocation(props.item.entity);++ if (getNotificationTag(props.item.notification) !== 'ai_response') {+ return { title: props.item.entity.name, content };+ }++ let action = 'responded';+ if (location) action = 'responded in';++ return {+ title: buildActionLabel({+ sender: senderName(),+ action,+ location,+ }),+ content,+ };+ });++ return (+ <BaseCard+ entityId={props.item.entity.id}+ selected={props.selected}+ highlighted={props.highlighted}+ onClick={props.onClick}+ unread={props.item.unread}+ timestamp={props.item.timestamp}+ leading={+ <InboxCard.Icon+ fallback={+ <Show+ when={props.item.notification}+ fallback={+ <EntityIcon targetType={getEntityIconType(props.item.entity)} />+ }+ >+ <Avatar+ senderId={senderId()}+ fallbackName={senderFallbackName()}+ />+ </Show>+ }+ >+ <ActionBubble tag={getNotificationTag(props.item.notification)} />+ </InboxCard.Icon>+ }+ title={text().title}+ preview={text().content}+ />+ );+}++export function EmailCardLayout(props: InboxCardLayoutProps) {+ const senderId = () => props.item.notification?.sender_id ?? undefined;++ const senderFallbackName = () => {+ const entity = props.item.entity;+ if (entity.type !== 'email') return undefined;++ if (entity.senderName) return entity.senderName;++ return props.item.notification+ ? (getNotificationSenderFallbackName(props.item.notification) ??+ entity.senderEmail)+ : entity.senderEmail;+ };++ const senderName = createSenderDisplayName(senderId, senderFallbackName);++ const text = createMemo(() => {+ const metadata = props.item.notification?.notification_metadata;+ const content = itemContent(props.item.entity, props.item.notification);+ let subject: string | undefined;+ if (metadata?.tag === 'new_email') {+ subject = metadata.content.subject;+ }++ let entitySnippet: string | undefined;+ if (props.item.entity.type === 'email') {+ entitySnippet = props.item.entity.snippet;+ }++ return {+ title: buildActionLabel({+ sender: senderName(),+ action: 'sent an email',+ }),+ content: subject || entitySnippet || props.item.entity.name || content,+ };+ });++ return (+ <BaseCard+ entityId={props.item.entity.id}+ selected={props.selected}+ highlighted={props.highlighted}+ onClick={props.onClick}+ unread={props.item.unread}+ timestamp={props.item.timestamp}+ leading={+ <InboxCard.Icon+ fallback={+ <Avatar senderId={senderId()} fallbackName={senderFallbackName()} />+ }+ >+ <ActionBubble tag="new_email" />+ </InboxCard.Icon>+ }+ title={text().title}+ preview={text().content}+ />+ );+}++export function GithubCardLayout(props: InboxCardLayoutProps) {+ const sender = createMemo(() =>+ getGithubSender(props.item.entity, props.item.notification)+ );++ const senderId = () => sender().id;+ const senderFallbackName = () => sender().fallbackName;++ const avatarUrl = () => sender().imageUrl;++ const senderName = createSenderDisplayName(senderId, senderFallbackName);++ const text = createMemo(() => {+ const entity = props.item.entity;++ if (isGithubPrEntity(entity)) {+ const hasGithubNotification = getNotificationTag(+ props.item.notification+ )?.startsWith('github_');++ let sender = entity.metadata.authorLogin;+ let action = 'opened';+ if (hasGithubNotification) {+ sender = senderName() ?? entity.metadata.authorLogin;+ action = githubAction(props.item.notification);+ }++ return {+ title: buildActionLabel({+ sender,+ action,+ location: githubLocation(entity),+ }),+ content:+ getGithubTitle(entity, props.item.notification) ||+ entity.metadata.name,+ };+ }++ return {+ title: buildActionLabel({+ sender: senderName(),+ action: githubAction(props.item.notification),+ location: githubLocation(entity),+ }),+ content: getGithubTitle(entity, props.item.notification) || entity.name,+ };+ });++ return (+ <BaseCard+ entityId={props.item.entity.id}+ selected={props.selected}+ highlighted={props.highlighted}+ onClick={props.onClick}+ unread={props.item.unread}+ timestamp={props.item.timestamp}+ leading={+ <Show+ when={avatarUrl()}+ fallback={+ <InboxCard.Icon+ fallback={+ <EntityIcon+ class="size-3"+ targetType="githubPullRequest"+ size="fill"+ theme="monochrome"+ />+ }+ />+ }+ >+ <InboxCard.Icon+ fallback={+ <Avatar+ senderId={senderId()}+ fallbackName={senderFallbackName()}+ imageUrl={avatarUrl()}+ />+ }+ >+ <ActionBubble+ tag={+ getNotificationTag(props.item.notification) ??+ 'github_pr_status_changed'+ }+ />+ </InboxCard.Icon>+ </Show>+ }+ title={text().title}+ preview={text().content}+ />+ );+}++export function CallCardLayout(props: InboxCardLayoutProps) {+ const senderId = () => props.item.notification?.sender_id ?? undefined;++ const senderName = createSenderDisplayName(senderId, () =>+ props.item.notification+ ? getNotificationSenderFallbackName(props.item.notification)+ : undefined+ );++ const text = createMemo(() => {+ const entity = props.item.entity;+ const content = itemContent(entity, props.item.notification);+ const location = entityLocation(entity);++ if (getNotificationTag(props.item.notification) === 'call_started') {+ return {+ title: buildActionLabel({+ sender: senderName(),+ action: location ? 'started a call in' : 'started a call',+ location,+ }),+ content,+ };+ }++ if (entity.type === 'call' && entity.status === 'MISSED') {+ return {+ title: entity.name ? `Missed call in #${entity.name}` : 'Missed call',+ content,+ };+ }++ if (entity.type === 'call' && entity.status === 'UNATTENDED') {+ return {+ title: entity.name+ ? `Call unattended in #${entity.name}`+ : 'Call unattended',+ content,+ };+ }++ return { title: entity.name ? `Call in #${entity.name}` : 'Call', content };+ });++ return (+ <BaseCard+ entityId={props.item.entity.id}+ selected={props.selected}+ highlighted={props.highlighted}+ onClick={props.onClick}+ unread={props.item.unread}+ timestamp={props.item.timestamp}+ leading={+ <InboxCard.Icon+ fallback={+ <EntityIcon+ class="size-3"+ targetType="call"+ size="fill"+ theme="monochrome"+ />+ }+ />+ }+ title={text().title}+ />+ );+}++export function GenericCardLayout(props: InboxCardLayoutProps) {+ const text = createMemo(() => ({+ title: props.item.entity.name+ ? `${props.item.entity.name} updated`+ : 'Updated',+ content: itemContent(props.item.entity, props.item.notification),+ }));++ return (+ <BaseCard+ entityId={props.item.entity.id}+ selected={props.selected}+ highlighted={props.highlighted}+ onClick={props.onClick}+ unread={props.item.unread}+ timestamp={props.item.timestamp}+ leading={+ <InboxCard.Icon+ fallback={+ <EntityIcon+ class="size-3"+ targetType={getEntityIconType(props.item.entity)}+ size="fill"+ theme="monochrome"+ />+ }+ />+ }+ title={text().title}+ preview={text().content}+ />+ );+}++export function InboxCardLayout(props: InboxCardLayoutProps) {+ const notificationTag = () => getNotificationTag(props.item.notification);+ const isGithub = () => {+ const entity = props.item.entity;+ const tag = notificationTag();++ if (tag?.startsWith('github_')) return true;++ return (+ entity.type === 'foreign' &&+ entity.foreignSource === 'github_pull_request'+ );+ };+ const isTask = () => {+ const entity = props.item.entity;++ return (+ notificationTag() === 'task_assigned' ||+ (entity.type === 'document' && entity.subType?.type === 'task')+ );+ };++ return (+ <Switch>+ <Match when={props.item.entity.type === 'email'}>+ <EmailCardLayout {...props} />+ </Match>+ <Match+ when={+ notificationTag() === 'call_started' ||+ props.item.entity.type === 'call'+ }+ >+ <CallCardLayout {...props} />+ </Match>+ <Match when={isGithub()}>+ <GithubCardLayout {...props} />+ </Match>+ <Match+ when={+ notificationTag() === 'ai_response' ||+ props.item.entity.type === 'chat'+ }+ >+ <AiCardLayout {...props} />+ </Match>+ <Match when={isTask()}>+ <TaskCardLayout {...props} />+ </Match>+ <Match when={props.item.entity.type === 'document'}>+ <DocumentCardLayout {...props} />+ </Match>+ <Match when={props.item.entity.type === 'channel'}>+ <ChannelCardLayout {...props} />+ </Match>+ <Match when={props.item.entity.type === 'channel_message'}>+ <ChannelMessageCardLayout {...props} />+ </Match>+ <Match when={props.item.entity.type === 'channel_thread'}>+ <ChannelThreadCardLayout {...props} />+ </Match>+ <Match when={true}>+ <GenericCardLayout {...props} />+ </Match>+ </Switch>+ );+}++export type InboxCardDisplayItem = {+ entity: WithNotification<EntityData>;+ notification?: Notification;+ unread: boolean;+ timestamp?: string;+};++export function toInboxCardDisplayItem(+ item: WithNotification<EntityData>+): InboxCardDisplayItem {+ const notification = getFirstNotification(item);++ return {+ entity: item,+ notification,+ unread: unreadFilterFn(item),+ timestamp: getTimestamp(item, notification),+ };+}diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-expansion.tsx b/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-expansion.tsxnew file mode 100644index 0000000000..0b6b5bdbac--- /dev/null+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-expansion.tsx@@ -0,0 +1,45 @@+import {+ createContext,+ createSignal,+ type FlowComponent,+ useContext,+} from 'solid-js';++type InboxExpansion = {+ isExpanded: (entityId: string) => boolean;+ toggle: (entityId: string) => void;+};++const InboxExpansionContext = createContext<InboxExpansion>();++/**+ * View-level expand/collapse state for inbox rows (which thread rows have their+ * reply sub-items open). Owned above the virtualizer so it survives rows+ * unmounting as they scroll out of view — the card's own local state can't,+ * since virtua remounts offscreen rows.+ */+export const InboxExpansionProvider: FlowComponent = (props) => {+ // Set behind a signal with `equals: false` so mutating it in place still+ // notifies the rows that read `isExpanded`.+ const [expanded, setExpanded] = createSignal(new Set<string>(), {+ equals: false,+ });++ const value: InboxExpansion = {+ isExpanded: (entityId) => expanded().has(entityId),+ toggle: (entityId) =>+ setExpanded((set) => {+ if (set.has(entityId)) set.delete(entityId);+ else set.add(entityId);+ return set;+ }),+ };++ return (+ <InboxExpansionContext.Provider value={value}>+ {props.children}+ </InboxExpansionContext.Provider>+ );+};++export const useInboxExpansion = () => useContext(InboxExpansionContext);diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/utils.ts b/js/app/packages/app/component/next-soup/soup-view/views/inbox/utils.tsnew file mode 100644index 0000000000..9483a9aa51--- /dev/null+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/utils.ts@@ -0,0 +1,201 @@+import type { EntityData, Notification, WithNotification } from '@entity';+import {+ getSortedKeyProperties,+ soupPropertyToProperty,+} from '@entity/extractors-property/property-helpers';+import type { SoupProperty } from '@service-storage/generated/schemas/soupProperty';+import {+ differenceInDays,+ differenceInHours,+ differenceInMilliseconds,+ differenceInMonths,+ differenceInWeeks,+ differenceInYears,+ format,+} from 'date-fns';+import { match } from 'ts-pattern';++/**+ * Soup attaches notifications per `toNotificationEntity`, which maps a+ * `channel_thread` to its whole channel — so its notifications come back+ * channel-wide. Scope them to this thread's own message: the sends/mentions for+ * the message, and replies whose `threadId` is the message.+ */+export function scopeThreadNotifications(+ entity: WithNotification<EntityData>+): WithNotification<EntityData> {+ if (entity.type !== 'channel_thread') return entity;++ const notifications = entity.notifications;+ if (!notifications) return entity;++ const messageId = entity.messageId;+ return {+ ...entity,+ notifications: () =>+ notifications().filter((notification) =>+ match(notification.notification_metadata)+ .with(+ { tag: 'channel_message_send' },+ (m) => m.content.messageId === messageId+ )+ .with(+ { tag: 'channel_mention' },+ (m) => m.content.messageId === messageId+ )+ .with(+ { tag: 'channel_message_reply' },+ (m) => m.content.threadId === messageId+ )+ .otherwise(() => false)+ ),+ };+}++function notificationContent(notification: Notification): string | undefined {+ const content = notification.notification_metadata.content as+ | {+ messageContent?: string;+ text?: string;+ snippet?: string;+ summary?: string;+ commentSnippet?: string;+ textSnippet?: string;+ reviewSnippet?: string;+ }+ | undefined;+ switch (notification.notification_metadata.tag) {+ case 'channel_mention':+ case 'channel_message_send':+ case 'channel_message_reply':+ return content?.messageContent;+ case 'mentioned_in_document_comment':+ case 'replied_to_document_comment_thread':+ case 'commented_on_document':+ return content?.text;+ case 'new_email':+ return content?.snippet || undefined;+ case 'ai_response':+ return content?.summary;+ case 'github_pr_comment':+ return content?.commentSnippet;+ case 'github_pr_mention':+ return content?.textSnippet;+ case 'github_pr_review':+ return content?.reviewSnippet;+ default:+ return undefined;+ }+}++export function getNotificationTag(notification?: Notification) {+ return notification?.notification_metadata.tag;+}++const channelMessageContent = (entity: EntityData): string | undefined => {+ if (entity.type === 'channel') return entity.latestRootMessage?.content;+ if (entity.type === 'channel_message' || entity.type === 'channel_thread') {+ return entity.content;+ }+ return undefined;+};++export function itemContent(+ entity: EntityData,+ notification?: Notification+): string | undefined {+ const meta = notification?.notification_metadata;++ if (meta?.tag === 'document_mention') {+ return meta.content.messageContent;+ }++ const channel = channelMessageContent(entity);+ if (channel) return channel;+ return notification ? notificationContent(notification) : undefined;+}++export function getGithubLocationLabel(+ entity: EntityData,+ notification?: Notification+) {+ if (+ entity.type === 'foreign' &&+ entity.foreignSource === 'github_pull_request'+ ) {+ const { owner, repo, number } = entity.metadata;+ return `${owner}/${repo}#${number}`;+ }+ const content = notification?.notification_metadata.content as+ | { owner?: string; repo?: string; number?: number }+ | undefined;+ if (!content?.owner || !content.repo || content.number == null) {+ return undefined;+ }+ return `${content.owner}/${content.repo}#${content.number}`;+}++export function getGithubTitle(+ entity: EntityData,+ notification?: Notification+) {+ if (+ entity.type === 'foreign' &&+ entity.foreignSource === 'github_pull_request'+ ) {+ return entity.metadata.name;+ }+ const content = notification?.notification_metadata.content as+ | { title?: string }+ | undefined;++ return content?.title;+}++export function getEmailSubject(notification?: Notification) {+ const content = notification?.notification_metadata.content as+ | { subject?: string }+ | undefined;+ return content?.subject;+}++/** Key task properties (pills), derived from the document entity. */+export function getInboxTaskProperties(entity: EntityData) {+ if (entity.type !== 'document') return undefined;+ if (!('properties' in entity) || !entity.properties?.length) return undefined;++ const keyProperties = getSortedKeyProperties(+ entity.properties.map((property: SoupProperty) =>+ soupPropertyToProperty(property)+ )+ );+ return keyProperties.length ? keyProperties : undefined;+}++export function formatCompactRelativeTimestamp(value: string) {+ const date = new Date(value);+ if (Number.isNaN(date.getTime())) return value;++ const now = new Date();+ const ageMs = differenceInMilliseconds(now, date);+ if (ageMs < 12 * 60 * 60 * 1000) return format(date, 'p');++ const hours = differenceInHours(now, date);+ if (hours < 24) return `${Math.max(12, hours)}h`;++ const days = differenceInDays(now, date);+ if (days < 7) return `${Math.max(1, days)}d`;++ const weeks = differenceInWeeks(now, date);+ if (weeks < 5) return `${Math.max(1, weeks)}w`;++ const months = differenceInMonths(now, date);+ if (months < 12) return `${Math.max(1, months)}mo`;++ return `${Math.max(1, differenceInYears(now, date))}y`;+}++export function getFirstName(value: string) {+ const name = value.includes('@') ? value.split('@')[0] : value;+ return name.split(/[\s._-]+/).filter(Boolean)[0] ?? name;+}diff --git a/js/app/packages/app/component/next-soup/utils.ts b/js/app/packages/app/component/next-soup/utils.tsindex a5338bc25e..86a1b8067e 100644--- a/js/app/packages/app/component/next-soup/utils.ts+++ b/js/app/packages/app/component/next-soup/utils.ts@@ -182,7 +182,10 @@ export const openEntityInNewTab = ({const { fileType, subType } = entity;const blockName = fileTypeToBlockName(subType?.type ?? fileType);entityPath = `/app/${blockName}/${entity.id}`;- } else if (entity.type === 'channel_message') {+ } else if (+ entity.type === 'channel_message' ||+ entity.type === 'channel_thread'+ ) {entityPath = `/app/channel/${entity.channelId}`;} else {entityPath = `/app/${entity.type}/${entity.id}`;@@ -191,7 +194,7 @@ export const openEntityInNewTab = ({// Add location params if presentlet entityUrl = new URL(entityPath, window.location.origin);- if (entity.type === 'channel_message') {+ if (entity.type === 'channel_message' || entity.type === 'channel_thread') {entityUrl.searchParams.set(CHANNEL_PARAMS.message, entity.messageId);if (entity.threadId) {entityUrl.searchParams.set(CHANNEL_PARAMS.thread, entity.threadId);@@ -367,7 +370,10 @@ export const openEntityInSplitFromUnifiedList = async (let params: Record<string, string> | undefined;if (entity.type === 'channel' && location?.type === 'channel') {params = getChannelParams(location.messageId, location.threadId);- } else if (entity.type === 'channel_message') {+ } else if (+ entity.type === 'channel_message' ||+ entity.type === 'channel_thread'+ ) {params = getChannelParams(entity.messageId, entity.threadId);} else if (entity.type === 'call' && location?.type === 'call_record') {params = { [CALL_PARAMS.transcriptId]: location.transcriptId };@@ -397,7 +403,10 @@ export const openEntityInSplitFromUnifiedList = async (// Navigate to specific location if providedif (location) {await navigateToLocation(content.id, location, blockOrchestrator);- } else if (entity.type === 'channel_message') {+ } else if (+ entity.type === 'channel_message' ||+ entity.type === 'channel_thread'+ ) {// NOTE: This will force target message navigation in case the split is already open.await navigateToLocation(entity.channelId,@@ -423,6 +432,9 @@ function getEntitySplitContent(entity: EntityData) {.with({ type: 'channel_message' }, (entity) => {return { type: 'channel' as const, id: entity.channelId };})+ .with({ type: 'channel_thread' }, (entity) => {+ return { type: 'channel' as const, id: entity.channelId };+ }).with({ type: 'foreign' }, (entity) => {return { type: 'unknown' as const, id: entity.id };})diff --git a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx b/js/app/packages/app/component/split-layout/components/SplitHeader.tsxindex f8d094dd80..6f5d79ff40 100644--- a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx+++ b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx@@ -56,7 +56,7 @@ function getEntitySplitContent(data: EntityDragEvent['draggable']['data']):};}- if (data.type === 'channel_message') {+ if (data.type === 'channel_message' || data.type === 'channel_thread') {return { type: 'channel', id: data.channelId };}diff --git a/js/app/packages/block-canvas/component/CanvasController.tsx b/js/app/packages/block-canvas/component/CanvasController.tsxindex c1bbb84e7e..37cbb538ce 100644--- a/js/app/packages/block-canvas/component/CanvasController.tsx+++ b/js/app/packages/block-canvas/component/CanvasController.tsx@@ -862,7 +862,9 @@ export function CanvasController(props: ParentProps) {const entityType = event.draggable.data.type;// TODO: add channel message support- if (entityType === 'channel_message') return;+ if (entityType === 'channel_message' || entityType === 'channel_thread') {+ return;+ }// Automation and foreign entities aren't yet renderable as canvas mentions.if (entityType === 'automation' || entityType === 'foreign') return;// CRM companies/contacts aren't renderable as canvas mentions.diff --git a/js/app/packages/channel/Attachments/attachment-utils.ts b/js/app/packages/channel/Attachments/attachment-utils.tsindex a75cdd6def..bcc95f7f35 100644--- a/js/app/packages/channel/Attachments/attachment-utils.ts+++ b/js/app/packages/channel/Attachments/attachment-utils.ts@@ -39,6 +39,11 @@ export function getEntityClickContent(entity: EntityData): SplitContent {id: e.channelId,params: getChannelParams(e.messageId, e.threadId),}))+ .with({ type: 'channel_thread' }, (e) => ({+ type: 'channel' as const,+ id: e.channelId,+ params: getChannelParams(e.messageId, e.threadId),+ })).with({ type: 'call' }, (e) => ({type: 'call' as const,id: e.id,diff --git a/js/app/packages/core/component/AI/hook/useEntityDropAttachment.ts b/js/app/packages/core/component/AI/hook/useEntityDropAttachment.tsindex d607e20145..6cf81a2be6 100644--- a/js/app/packages/core/component/AI/hook/useEntityDropAttachment.ts+++ b/js/app/packages/core/component/AI/hook/useEntityDropAttachment.ts@@ -78,7 +78,7 @@ export function useEntityDropAttachment(entity_id: entityId,entity_type: 'project' as EntityType,}))- .with(P.union('channel', 'channel_message'), () => {+ .with(P.union('channel', 'channel_message', 'channel_thread'), () => {const channelId ='channelId' in data ? (data.channelId as string) : entityId;return {diff --git a/js/app/packages/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts b/js/app/packages/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.tsindex 27b308737d..f23dff3035 100644--- a/js/app/packages/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts+++ b/js/app/packages/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts@@ -281,6 +281,7 @@ const getDocumentMentionItemType = (.with('channel', () => 'channel').with('project', () => 'project').with('channel_message', () => 'channel')+ .with('channel_thread', () => 'channel').with('automation', () => 'automation').with('call', () => 'call').with('foreign', () => {diff --git a/js/app/packages/core/constant/allBlocks.ts b/js/app/packages/core/constant/allBlocks.tsindex 5088789c49..2685723488 100644--- a/js/app/packages/core/constant/allBlocks.ts+++ b/js/app/packages/core/constant/allBlocks.ts@@ -238,6 +238,7 @@ export function itemToBlockName(if (item.fileType) {return fileTypeToBlockName(item.fileType, icon);}+ if (item.type === 'channel_thread') return 'channel';return fileTypeToBlockName(item.type, icon);}diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.tsindex d4fb22b8eb..e201729183 100644--- a/js/app/packages/core/constant/featureFlags.ts+++ b/js/app/packages/core/constant/featureFlags.ts@@ -437,6 +437,13 @@ export const ENABLE_HOME_OVERRIDE = DEV_MODE_ENV ? true : undefined;export const ENABLE_NEW_PRICING_OVERRIDE =resolveFeatureFlag('ENABLE_NEW_PRICING', DEV_MODE_ENV) || undefined;+// New inbox: renders the Inbox list view with the notification card layout and+// expandable thread reply sub-items. PostHog-gated with a dev-mode default;+// override with VITE_ENABLE_NEW_INBOX.+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 const ENABLE_TAGS_FE_FLAG = 'enable-tags-fe';export const ENABLE_TAGS_FE_OVERRIDE =resolveFeatureFlag('ENABLE_TAGS_FE', DEV_MODE_ENV) || undefined;diff --git a/js/app/packages/core/internal/trackBlockOpened.ts b/js/app/packages/core/internal/trackBlockOpened.tsindex 4266b21ba5..b362e38dd3 100644--- a/js/app/packages/core/internal/trackBlockOpened.ts+++ b/js/app/packages/core/internal/trackBlockOpened.ts@@ -22,6 +22,7 @@ function isSoupEntityTag(.with('email','channel_message',+ 'channel_thread','automation','foreign','crm_company',diff --git a/js/app/packages/entity/mocks/mockEntityData.ts b/js/app/packages/entity/mocks/mockEntityData.tsindex b669f88ece..5fce20e600 100644--- a/js/app/packages/entity/mocks/mockEntityData.ts+++ b/js/app/packages/entity/mocks/mockEntityData.ts@@ -282,6 +282,7 @@ const MOCK_CHANNEL_PUBLIC: ChannelEntity = {content: "Hey everyone! Don't forget about the team meeting at 2pm",senderId: MOCK_USER_IDS.teamMember1,createdAt: MOCK_TIMESTAMPS.today,+ mentions: [],},frecencyScore: 0.91,};@@ -300,6 +301,7 @@ const MOCK_CHANNEL_PRIVATE: ChannelEntity = {content: 'Updated the mockups in Figma',senderId: MOCK_USER_IDS.teamMember2,createdAt: MOCK_TIMESTAMPS.yesterday,+ mentions: [],},frecencyScore: 0.83,};@@ -319,6 +321,7 @@ const MOCK_CHANNEL_DIRECT_MESSAGE: ChannelEntity = {content: 'Can you review the PR?',senderId: MOCK_USER_IDS.teamMember1,createdAt: MOCK_TIMESTAMPS.today,+ mentions: [],},frecencyScore: 0.87,};@@ -337,6 +340,7 @@ const MOCK_CHANNEL_ANNOUNCEMENTS: ChannelEntity = {content: 'Q4 results are in!',senderId: MOCK_USER_IDS.owner,createdAt: MOCK_TIMESTAMPS.lastWeek,+ mentions: [],},frecencyScore: 0.72,};@@ -355,6 +359,7 @@ const MOCK_CHANNEL_EMPTY_MESSAGE: ChannelEntity = {content: '',senderId: MOCK_USER_IDS.teamMember2,createdAt: MOCK_TIMESTAMPS.today,+ mentions: [],},frecencyScore: 0.68,};diff --git a/js/app/packages/entity/src/composed/ListEntity.tsx b/js/app/packages/entity/src/composed/ListEntity.tsxindex 04462c3512..f828dfbe4f 100644--- a/js/app/packages/entity/src/composed/ListEntity.tsx+++ b/js/app/packages/entity/src/composed/ListEntity.tsx@@ -60,7 +60,7 @@ interface ListEntityProps extends BaseListEntityProps {showUnrollNotifications?: boolean;}-function MaybeEntityRow(props: {+export function MaybeEntityRow(props: {entityId: string;children: JSX.Element;config?: EntityRowConfig;diff --git a/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx b/js/app/packages/entity/src/extractors-property/entity-key-properties.tsxindex 21a3cd53ea..0aa1d20222 100644--- a/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx+++ b/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx@@ -41,6 +41,7 @@ function getEntityType(entity: EntityData): EntityType {.with({ type: 'email' }, () => EntityType.THREAD).with({ type: 'document' }, () => EntityType.DOCUMENT).with({ type: 'channel_message' }, () => EntityType.CHANNEL)+ .with({ type: 'channel_thread' }, () => EntityType.CHANNEL).with({ type: 'call' }, () => EntityType.CHANNEL).with({ type: 'crm_company' }, () => EntityType.COMPANY).with({ type: 'crm_contact' }, () => {diff --git a/js/app/packages/entity/src/extractors/entity-title.tsx b/js/app/packages/entity/src/extractors/entity-title.tsxindex 2af6ca0867..a99ab09ab6 100644--- a/js/app/packages/entity/src/extractors/entity-title.tsx+++ b/js/app/packages/entity/src/extractors/entity-title.tsx@@ -17,6 +17,7 @@ function extractRawTitle(entity: EntityData): JSX.Element {.with({ type: 'project' }, (e) => e.name).with({ type: 'channel' }, (e) => e.name).with({ type: 'channel_message' }, (e) => e.channelName)+ .with({ type: 'channel_thread' }, (e) => e.name).with({ type: 'email' }, (e) => e.name || '(No Subject)').with({ type: 'chat' }, (e) => e.name).with({ type: 'call' }, (e) => e.name || blockNameToDefaultFile('call'))diff --git a/js/app/packages/entity/src/index.ts b/js/app/packages/entity/src/index.tsindex a1d3464601..47652547cc 100644--- a/js/app/packages/entity/src/index.ts+++ b/js/app/packages/entity/src/index.ts@@ -4,7 +4,11 @@ export { MultiSelectCheckbox } from './components/MultiSelectCheckbox';export { ProjectBreadCrumb } from './components/ProjectBreadCrumb';export { UnreadIndicator } from './components/UnreadIndicator';export { InlineEntity } from './composed/InlineEntity';-export { ListEntity, ListLayoutProvider } from './composed/ListEntity';+export {+ ListEntity,+ ListLayoutProvider,+ MaybeEntityRow,+} from './composed/ListEntity';export { Entity } from './entity';export { EntityIcon as EntityRowIcon } from './extractors/entity-icon';@@ -43,4 +47,5 @@ export {export {formatDateAndTime,formatRelativeTimestamp,+ formatTimestamp,} from './utils/timestamp';diff --git a/js/app/packages/entity/src/types/entity.ts b/js/app/packages/entity/src/types/entity.tsindex f2a02913f3..b21d49c14a 100644--- a/js/app/packages/entity/src/types/entity.ts+++ b/js/app/packages/entity/src/types/entity.ts@@ -3,8 +3,12 @@ import type { ApiLabel } from '@service-email/generated/schemas';import type {GithubPullRequestCheckRun,GithubPullRequestComment,+ SoupCountedReaction,SoupLabel,+ SoupMessageAttachment,+ SoupMessageSender,SoupProperty,+ SoupThreadReply,CallStatus as StorageCallStatus,} from '@service-storage/generated/schemas';@@ -49,23 +53,29 @@ export type GithubPullRequestEntity = ForeignEntityBase & {deletions: number;comments: GithubPullRequestComment[];checks: GithubPullRequestCheckRun[];+ authorLogin?: string;+ authorId?: number;};};export type ForeignEntity = UnknownForeignEntity | GithubPullRequestEntity;+type ChannelEntityLatestMessage = {+ messageId: string;+ threadId?: string | null;+ content: string;+ senderId: string;+ createdAt: DateValue;+ mentions: string[];+};+export type ChannelEntity = EntityBase & {type: 'channel';channelType: 'direct_message' | 'private' | 'public' | 'team';interactedAt?: DateValue | null;participantIds?: string[];- latestMessage?: {- messageId: string;- threadId?: string | null;- content: string;- senderId: string;- createdAt: DateValue;- };+ latestMessage?: ChannelEntityLatestMessage;+ latestRootMessage?: ChannelEntityLatestMessage;};export type ChannelMessageEntity = EntityBase & {@@ -79,6 +89,28 @@ export type ChannelMessageEntity = EntityBase & {content: string;};+export type ChannelThreadEntity = EntityBase & {+ type: 'channel_thread';+ channelId: string;+ channelType?: ChannelEntity['channelType'];+ messageId: string;+ threadId: string;+ senderId: string;+ sender: SoupMessageSender;+ content: string;+ attachments: SoupMessageAttachment[];+ reactions: SoupCountedReaction[];+ editedAt?: DateValue | null;+ deletedAt?: DateValue | null;+ thread: {+ replyCount: number;+ latestReplyAt?: DateValue | null;+ preview: SoupThreadReply[];+ };+ replyCount?: number;+ latestReplyAt?: DateValue | null;+};+export type ChatEntity = EntityBase & {type: 'chat';projectId?: string;@@ -228,6 +260,7 @@ export type CrmContactEntity = EntityBase & {export type EntityData =| ChannelEntity| ChannelMessageEntity+ | ChannelThreadEntity| ChatEntity| DocumentEntity| TaskEntity@@ -243,6 +276,7 @@ export type EntityData =const ENTITY_TYPE_VALUES = new Set<EntityData['type']>(['channel','channel_message',+ 'channel_thread','chat','document','email',@@ -310,6 +344,12 @@ export const isChannelMessageEntity = (return entity.type === 'channel_message';};+export const isChannelThreadEntity = (+ entity: EntityData+): entity is ChannelThreadEntity => {+ return entity.type === 'channel_thread';+};+const _isChatEntity = (entity: EntityData): entity is ChatEntity => {return entity.type === 'chat';};diff --git a/js/app/packages/entity/src/utils/notification.ts b/js/app/packages/entity/src/utils/notification.tsindex 110b215f88..3f01061f6b 100644--- a/js/app/packages/entity/src/utils/notification.ts+++ b/js/app/packages/entity/src/utils/notification.ts@@ -49,7 +49,7 @@ export function toNotificationEntity(entity: EntityData): Entity {return { type: 'foreign_entity', id: entity.id };}- if (entity.type === 'channel_message') {+ if (entity.type === 'channel_message' || entity.type === 'channel_thread') {return { type: 'channel', id: entity.channelId };}diff --git a/js/app/packages/macro-entity/src/queries/rename.ts b/js/app/packages/macro-entity/src/queries/rename.tsindex 15575f4238..2bb3d2821a 100644--- a/js/app/packages/macro-entity/src/queries/rename.ts+++ b/js/app/packages/macro-entity/src/queries/rename.ts@@ -130,6 +130,7 @@ const renameDssSetData = (} else if (itemType !== 'email' &&itemType !== 'channel_message' &&+ itemType !== 'channel_thread' &&itemType !== 'automation' &&itemType !== 'foreign' &&// CRM companies/contacts aren't renamed via the FileList path (theirdiff --git a/js/app/packages/property/src/utils/entityConversion.ts b/js/app/packages/property/src/utils/entityConversion.tsindex 88aab5c6e0..ef79ba4ef6 100644--- a/js/app/packages/property/src/utils/entityConversion.ts+++ b/js/app/packages/property/src/utils/entityConversion.ts@@ -72,6 +72,7 @@ export function macroEntityToPropertyEntityType(.with({ type: 'email' }, () => EntityType.THREAD).with({ type: 'document' }, () => EntityType.DOCUMENT).with({ type: 'channel_message' }, () => EntityType.CHANNEL)+ .with({ type: 'channel_thread' }, () => EntityType.CHANNEL).with({ type: 'call' }, () => EntityType.CHANNEL).with({ type: 'crm_company' }, () => EntityType.COMPANY).with({ type: 'crm_contact' }, () => {diff --git a/js/app/packages/queries/soup/transform-utils.ts b/js/app/packages/queries/soup/transform-utils.tsindex 815c49a974..2fca7c4cf2 100644--- a/js/app/packages/queries/soup/transform-utils.ts+++ b/js/app/packages/queries/soup/transform-utils.ts@@ -13,6 +13,7 @@ import type {CallEntity,ChannelEntity,ChannelMessageEntity,+ ChannelThreadEntity,ChatEntity,ContentHitData,CrmCompanyEntity,@@ -54,12 +55,7 @@ type InnerSearchResult =| ProjectSearchResult| CallRecordSearchResult;-// Channel thread soup items are currently only exposed to AI tooling; the app-// entity list does not have enough channel metadata to render them directly.-type DisplayableSoupItem = Exclude<- SoupPage['items'][number],- { tag: 'channelThread' }->;+type DisplayableSoupItem = SoupPage['items'][number];type SoupEntity =| DocumentEntity@@ -67,6 +63,7 @@ type SoupEntity =| ProjectEntity| EmailEntity| ChannelEntity+ | ChannelThreadEntity| CallEntity| CrmCompanyEntity| ForeignEntity;@@ -515,7 +512,7 @@ const resolveDocumentEntityName = (export const isDisplayableSoupItem = (item: SoupPage['items'][number]-): item is DisplayableSoupItem => item.tag !== 'channelThread';+): item is DisplayableSoupItem => Boolean(item);/*** The email soup query encodes "no sort timestamp" — e.g. a never-viewed thread@@ -621,9 +618,38 @@ export const mapApiSoupItemToEntity = (item: DisplayableSoupItem): SoupEntity =>summary: item.data.summary ?? undefined,} satisfies CallEntity;})+ .with({ tag: 'channelThread' }, (item) => {+ const out: ChannelThreadEntity = {+ type: 'channel_thread',+ id: item.data.id,+ name: 'Channel thread',+ channelId: item.data.channel_id,+ messageId: item.data.id,+ threadId: item.data.id,+ senderId: item.data.sender_id,+ sender: item.data.sender,+ content: item.data.content,+ attachments: item.data.attachments,+ reactions: item.data.reactions,+ ownerId: item.data.sender_id,+ createdAt: item.data.created_at,+ updatedAt: item.data.thread.latest_reply_at ?? item.data.updated_at,+ sortTs: item.data.thread.latest_reply_at ?? item.data.updated_at,+ editedAt: item.data.edited_at,+ deletedAt: item.data.deleted_at,+ thread: {+ replyCount: item.data.thread.reply_count,+ latestReplyAt: item.data.thread.latest_reply_at,+ preview: item.data.thread.preview,+ },+ replyCount: item.data.thread.reply_count,+ latestReplyAt: item.data.thread.latest_reply_at,+ };+ return out;+ }).with({ tag: 'channel' }, (item) => {- const latestMessage =- item.data.latest_message ?? item.data.latest_non_thread_message;+ const latestMessage = item.data.latest_message;+ const latestRootMessage = item.data.latest_non_thread_message;const out: ChannelEntity = {type: 'channel',@@ -642,15 +668,31 @@ export const mapApiSoupItemToEntity = (item: DisplayableSoupItem): SoupEntity =>messageId: latestMessage.message_id,threadId: latestMessage.thread_id ?? undefined,content: latestMessage.content,+ mentions: latestMessage.mentions,senderId: latestMessage.sender_id,createdAt: latestMessage.created_at,}: undefined,+ latestRootMessage: latestRootMessage+ ? {+ messageId: latestRootMessage.message_id,+ threadId: latestRootMessage.thread_id ?? undefined,+ content: latestRootMessage.content,+ mentions: latestRootMessage.mentions,+ senderId: latestRootMessage.sender_id,+ createdAt: latestRootMessage.created_at,+ }+ : undefined,};return out;}).with({ tag: 'foreignEntity' }, (item) => {- const metadata = item.data.metadata as unknown as GithubPullRequest;+ // `authorLogin`/`authorId` are enrichment-only fields the backend now+ // returns but that aren't on the base generated schema yet.+ const metadata = item.data.metadata as unknown as GithubPullRequest & {+ authorLogin?: string | null;+ authorId?: number | null;+ };let status: GithubPullRequestEntity['metadata']['status'] = 'open';@@ -682,6 +724,8 @@ export const mapApiSoupItemToEntity = (item: DisplayableSoupItem): SoupEntity =>deletions: metadata.deletions ?? 0,comments: metadata.comments ?? [],checks: metadata.checks?.filter(Boolean) ?? [],+ authorLogin: metadata.authorLogin ?? undefined,+ authorId: metadata.authorId ?? undefined,},};diff --git a/js/app/packages/service-clients/service-storage/client.ts b/js/app/packages/service-clients/service-storage/client.tsindex 2ff29fc2bb..ebfc0d49f1 100644--- a/js/app/packages/service-clients/service-storage/client.ts+++ b/js/app/packages/service-clients/service-storage/client.ts@@ -205,6 +205,7 @@ export type ItemType =| 'channel'| 'email'| 'channel_message'+ | 'channel_thread'| 'call'| 'automation'| 'foreign'