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
Hide channel thread soup entities in frontend (#4260)
Sean Aye0fc81b7195a1
diff --git a/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts b/js/app/packages/app/component/app-sidebar/soup-filter-presets.tsindex 1e43e4a63c..61d52eb0bc 100644--- a/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts+++ b/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts@@ -468,14 +468,16 @@ export const VIEW_TAB_PRESETS: Record<ListView, ViewTabConfig> = {all: () => ({// Temporary: search has no full-text index over foreign entities yet,// so always exclude them (matching no record id) until search supports- // them. CRM rows are NIL-excluded the same way. `search-supported`- // mirrors these exclusions client-side so entities that enter the- // soup cache outside this query (e.g. websocket-driven inserts)- // don't surface in the search feed.+ // them. CRM rows and non-displayable channel-thread rows are+ // NIL-excluded the same way. `search-supported` mirrors these+ // exclusions client-side so entities that enter the soup cache outside+ // this query (e.g. websocket-driven inserts) don't surface in the+ // search feed.filters: {include: {foreignEntityRecordId: [NIL_UUID],crmCompanyId: [NIL_UUID],+ channelThreadId: [NIL_UUID],},exclude: getDisabledSnippetSubtypeExclude(),},diff --git a/js/app/packages/app/component/next-soup/debug/DocumentWherePlayground.tsx b/js/app/packages/app/component/next-soup/debug/DocumentWherePlayground.tsxindex 117d2f1fb6..709780de0c 100644--- a/js/app/packages/app/component/next-soup/debug/DocumentWherePlayground.tsx+++ b/js/app/packages/app/component/next-soup/debug/DocumentWherePlayground.tsx@@ -201,6 +201,7 @@ const SIMPLE_SOUP_NON_DOCUMENT_FILTERS: Pick<PostSoupRequest,| 'call_filters'| 'channel_filters'+ | 'channel_thread_filters'| 'chat_filters'| 'crm_company_filters'| 'email_filters'@@ -209,6 +210,7 @@ const SIMPLE_SOUP_NON_DOCUMENT_FILTERS: Pick<> = {call_filters: { call_ids: [NIL_UUID] },channel_filters: { channel_ids: [NIL_UUID] },+ channel_thread_filters: { thread_ids: [NIL_UUID] },chat_filters: { chat_ids: [NIL_UUID] },crm_company_filters: { company_ids: [NIL_UUID] },email_filters: { email_thread_ids: [NIL_UUID] },@@ -219,6 +221,7 @@ const SIMPLE_SOUP_NON_DOCUMENT_FILTERS: Pick<const AST_SOUP_DOCUMENT_ONLY_FILTERS: Query['include'] = {callId: [NIL_UUID],channelId: [NIL_UUID],+ channelThreadId: [NIL_UUID],chatId: [NIL_UUID],crmCompanyId: [NIL_UUID],foreignEntityRecordId: [NIL_UUID],diff --git a/js/app/packages/app/component/next-soup/filters/configs/entity.ts b/js/app/packages/app/component/next-soup/filters/configs/entity.tsindex c7ba2e22c6..facdc19ae7 100644--- a/js/app/packages/app/component/next-soup/filters/configs/entity.ts+++ b/js/app/packages/app/component/next-soup/filters/configs/entity.ts@@ -95,6 +95,7 @@ export const searchSupportedFilter = config({include: {foreignEntityRecordId: [NIL_UUID],crmCompanyId: [NIL_UUID],+ channelThreadId: [NIL_UUID],},},});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 547754acd0..7d80e00086 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@@ -22,6 +22,7 @@ type QueryTarget =| 'df'| 'ef'| 'chanf'+ | 'cthf'| 'cf'| 'pf'| 'callf'@@ -103,6 +104,7 @@ const FIELD_CONFIG: Record<channelDone: { target: 'chanf', field: 'NotificationDone' },channelImportance: { target: 'chanf', field: 'Importance' },channelSenderId: { target: 'chanf', field: 'Sender' },+ channelThreadId: { target: 'cthf', field: 'ThreadId' },chatId: { target: 'cf', field: 'cid' },chatOwnerId: { target: 'cf', field: 'o' },chatProjectId: { target: 'cf', field: 'pid' },@@ -177,6 +179,7 @@ const emptyTargetAstLists = (): Record<QueryTarget, BackendAst[]> => ({df: [],ef: [],chanf: [],+ cthf: [],cf: [],pf: [],callf: [],@@ -381,6 +384,11 @@ 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);+if (state.emailView) {result.emailView = state.emailView;}@@ -392,6 +400,7 @@ const ID_FIELD_NAMES: Partial<Record<QueryTarget, FieldName>> = {df: 'documentId',ef: 'threadId',chanf: 'channelId',+ cthf: 'channelThreadId',cf: 'chatId',pf: 'folderId',callf: 'callId',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 b125037f08..53c43acb01 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,6 +37,7 @@ export type ArrayFieldFilters = {channelId?: string[];channelType?: string[];channelSenderId?: string[];+ channelThreadId?: string[];chatId?: string[];chatOwnerId?: string[];chatProjectId?: string[];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 9f276cd70c..1d4a434656 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@@ -11,6 +11,7 @@ const EXCLUDE: string[] = [NIL_UUID];export const QUERY_FILTERS_BASE: SoupItemsQueryFilters = {call_filters: { call_ids: EXCLUDE },channel_filters: { channel_ids: EXCLUDE },+ channel_thread_filters: { thread_ids: EXCLUDE },chat_filters: { chat_ids: EXCLUDE },crm_company_filters: { company_ids: EXCLUDE },document_filters: { document_ids: EXCLUDE },@@ -84,7 +85,15 @@ export function filterSoupItemByRequestBody(.with({ tag: 'channelThread' },({ data }) =>- !isIdFilteredOut(body.channel_filters?.channel_ids, data.channel_id)+ !isIdFilteredOut(body.channel_thread_filters?.thread_ids, data.id) &&+ !isIdFilteredOut(+ body.channel_thread_filters?.channel_ids,+ data.channel_id+ ) &&+ !isValueFilteredOut(+ body.channel_thread_filters?.root_sender_ids,+ data.sender_id+ )).with({ tag: 'project' },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 ba37a14356..e9da217979 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@@ -76,6 +76,13 @@ function filterDataToQueryFilters(data: QueryState): EntityFilters {};}+ // Channel thread filters+ if (include.channelThreadId?.length) {+ filters.channel_thread_filters = {+ thread_ids: include.channelThreadId,+ };+ }+// Chat filtersif (include.chatId?.length ||diff --git a/js/app/packages/companies/Company/use-company-emails-query.ts b/js/app/packages/companies/Company/use-company-emails-query.tsindex 72cf3a9e12..f12277e824 100644--- a/js/app/packages/companies/Company/use-company-emails-query.ts+++ b/js/app/packages/companies/Company/use-company-emails-query.ts@@ -24,6 +24,7 @@ export function useCompanyEmailsQuery(const base = {df: { l: { id: NIL_UUID } },chanf: { l: { ChannelId: NIL_UUID } },+ cthf: { l: { ThreadId: NIL_UUID } },cf: { l: { cid: NIL_UUID } },pf: { l: { pid: NIL_UUID } },callf: { l: { CallId: NIL_UUID } },diff --git a/js/app/packages/contacts/Contact/use-contact-emails-query.ts b/js/app/packages/contacts/Contact/use-contact-emails-query.tsindex b3f9a3abc5..753f16da1d 100644--- a/js/app/packages/contacts/Contact/use-contact-emails-query.ts+++ b/js/app/packages/contacts/Contact/use-contact-emails-query.ts@@ -25,6 +25,7 @@ export function useContactEmailsQuery(const base = {df: { l: { id: NIL_UUID } },chanf: { l: { ChannelId: NIL_UUID } },+ cthf: { l: { ThreadId: NIL_UUID } },cf: { l: { cid: NIL_UUID } },pf: { l: { pid: NIL_UUID } },callf: { l: { CallId: NIL_UUID } },diff --git a/js/app/packages/queries/soup/normalized-cache/operations.test.ts b/js/app/packages/queries/soup/normalized-cache/operations.test.tsindex 110203e9eb..bb259cc243 100644--- a/js/app/packages/queries/soup/normalized-cache/operations.test.ts+++ b/js/app/packages/queries/soup/normalized-cache/operations.test.ts@@ -242,6 +242,7 @@ describe('buildSingleEntityFilter', () => {'document_filters','chat_filters','channel_filters',+ 'channel_thread_filters','project_filters','call_filters',].filter((k) => k !== filterKey);diff --git a/js/app/packages/queries/soup/quick-access-crm-companies.ts b/js/app/packages/queries/soup/quick-access-crm-companies.tsindex 4aea19cf51..1b6faeacdc 100644--- a/js/app/packages/queries/soup/quick-access-crm-companies.ts+++ b/js/app/packages/queries/soup/quick-access-crm-companies.ts@@ -1,4 +1,4 @@-import { NIL_UUID } from '@app/component/next-soup/filters/filter-store';+import { QUERY_FILTERS_BASE } from '@app/component/next-soup/filters/query-filters';import { ENABLE_CRM } from '@core/constant/featureFlags';import { type CrmCompanyEntity, isCrmCompanyEntity } from '@entity';import { useSoupItemsQuery } from '@queries/soup/items';@@ -17,9 +17,7 @@ const STALE_TIME = 5 * 60 * 1000;* `viewedAt`, this one widens the pool to all team companies up to a* cap so users can `@`-mention companies they've never opened.*- * Every other entity type is filtered out via the nil-uuid sentinel- * pattern — that's the established way to scope a soup call to a- * single entity type (see `use-company-query.ts`).+ * Every other entity type is filtered out by extending `QUERY_FILTERS_BASE`.*/export function useQuickAccessCrmCompaniesQuery() {const query = useSoupItemsQuery(@@ -29,14 +27,9 @@ export function useQuickAccessCrmCompaniesQuery() {sort_method: 'viewed_updated',},body: {- call_filters: { call_ids: [NIL_UUID] },- channel_filters: { channel_ids: [NIL_UUID] },- chat_filters: { chat_ids: [NIL_UUID] },- document_filters: { document_ids: [NIL_UUID] },- email_filters: { email_thread_ids: [NIL_UUID] },- foreign_entity_filters: { ids: [NIL_UUID] },- project_filters: { project_ids: [NIL_UUID] },- // crm_company_filters intentionally omitted = all visible companies+ ...QUERY_FILTERS_BASE,+ // crm_company_filters intentionally unset = all visible companies+ crm_company_filters: undefined,},}),() => ({ staleTime: STALE_TIME, enabled: ENABLE_CRM })diff --git a/js/app/packages/queries/soup/quick-access-snippets.ts b/js/app/packages/queries/soup/quick-access-snippets.tsindex 8010aa06b7..01c50fcd4f 100644--- a/js/app/packages/queries/soup/quick-access-snippets.ts+++ b/js/app/packages/queries/soup/quick-access-snippets.ts@@ -1,4 +1,4 @@-import { NIL_UUID } from '@app/component/next-soup/filters/filter-store';+import { QUERY_FILTERS_BASE } from '@app/component/next-soup/filters/query-filters';import { useFeatureFlag } from '@app/lib/analytics/posthog';import {ENABLE_SNIPPETS_FLAG,@@ -20,9 +20,8 @@ const STALE_TIME = 5 * 60 * 1000;* this one widens the pool so the `;` menu lists team snippets the user has* never opened.*- * Every other entity type is filtered out via the nil-uuid sentinel pattern- * (see `quick-access-crm-companies.ts`); documents are narrowed to the- * snippet sub type.+ * Every other entity type is filtered out by extending `QUERY_FILTERS_BASE`;+ * documents are narrowed to the snippet sub type.*/export function useQuickAccessSnippetsQuery() {const snippetsFlag = useFeatureFlag(ENABLE_SNIPPETS_FLAG, {@@ -36,14 +35,8 @@ export function useQuickAccessSnippetsQuery() {sort_method: 'viewed_updated',},body: {- call_filters: { call_ids: [NIL_UUID] },- channel_filters: { channel_ids: [NIL_UUID] },- chat_filters: { chat_ids: [NIL_UUID] },- crm_company_filters: { company_ids: [NIL_UUID] },+ ...QUERY_FILTERS_BASE,document_filters: { sub_types: ['snippet'] },- email_filters: { email_thread_ids: [NIL_UUID] },- foreign_entity_filters: { ids: [NIL_UUID] },- project_filters: { project_ids: [NIL_UUID] },},}),() => ({ staleTime: STALE_TIME, enabled: snippetsFlag().enabled })diff --git a/js/app/packages/queries/soup/recently-viewed.ts b/js/app/packages/queries/soup/recently-viewed.tsindex 72cf73eee9..725a2233e7 100644--- a/js/app/packages/queries/soup/recently-viewed.ts+++ b/js/app/packages/queries/soup/recently-viewed.ts@@ -1,4 +1,4 @@-import { NIL_UUID } from '@app/component/next-soup/filters/filter-store';+import { QUERY_FILTERS_BASE } from '@app/component/next-soup/filters/query-filters';import { ENABLE_CRM } from '@core/constant/featureFlags';import { throwOnErr } from '@core/util/result';import { storageServiceClient } from '@service-storage/client';@@ -21,15 +21,14 @@ const RECENTLY_VIEWED_GC_TIME = 10 * 60 * 1000; // 10 minutesconst recentlyViewedArgs: SoupItemsQueryArgs = {params: { sort_method: 'viewed_at', limit: RECENTLY_VIEWED_LIMIT },body: {- // No viewed_at signal on calls — exclude.- call_filters: {- call_ids: [NIL_UUID],- },- foreign_entity_filters: {- ids: [NIL_UUID],- },+ ...QUERY_FILTERS_BASE,+ channel_filters: undefined,+ chat_filters: undefined,+ document_filters: undefined,+ email_filters: undefined,+ project_filters: undefined,// CRM companies only surface in recently-viewed when the feature is enabled.- ...(ENABLE_CRM ? {} : { crm_company_filters: { company_ids: [NIL_UUID] } }),+ ...(ENABLE_CRM ? { crm_company_filters: undefined } : {}),},};