Skip to content

armgit / macro

Public Imported from GitHub
0

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

feat(soup): foreign entity includes me filter (#4139)

dev-rb803ef83bf6cb
diff --git a/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts b/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts
index 7a60fc522e..421d2bb9ec 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
@@ -69,6 +69,7 @@ const getInboxSignalFilters = () => {
// defineQueryFilters excludes unreferenced entity types). Rendering is
// still gated on the supported-foreign-entities flag client-side.
foreignEntityDone: false,
+ foreignEntityIncludesMe: true,
emailShared: 'exclude',
},
exclude: getDisabledSnippetSubtypeExclude(),
@@ -107,7 +108,10 @@ export const VIEW_TAB_PRESETS: Record<ListView, ViewTabConfig> = {
all: () => ({
filters: {
// crm companies aren't surfaced outside the Companies view.
- include: { crmCompanyId: [NIL_UUID] },
+ include: {
+ crmCompanyId: [NIL_UUID],
+ foreignEntityIncludesMe: true,
+ },
exclude: {
documentId: [NIL_UUID],
threadId: [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.ts
index acbf0c14bb..583a1d7369 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
@@ -58,8 +58,8 @@ const AST = {
not(ast: BackendAst): BackendAst {
return { '!': ast };
},
- literal(field: string, value: unknown): BackendAst {
- return { l: { [field]: value } };
+ literal(field: string, value?: unknown): BackendAst {
+ return value === undefined ? { l: field } : { l: { [field]: value } };
},
};
@@ -69,6 +69,8 @@ const FIELD_CONFIG: Record<
target: QueryTarget;
field: string;
formatValue?: (value: unknown) => unknown;
+ // unit: true -> `{ l: field }`; unit: false/undefined -> `{ l: { field: value } }`
+ unit?: boolean;
}
> = {
documentId: { target: 'df', field: 'id' },
@@ -116,6 +118,7 @@ const FIELD_CONFIG: Record<
foreignEntityRecordId: { target: 'fef', field: 'id' },
foreignEntitySeen: { target: 'fef', field: 'ns' },
foreignEntityDone: { target: 'fef', field: 'nd' },
+ foreignEntityIncludesMe: { target: 'fef', field: 'me', unit: true },
crmCompanyId: { target: 'ccf', field: 'id' },
crmCompanyHidden: { target: 'ccf', field: 'hidden' },
};
@@ -177,6 +180,15 @@ export function compileToAst(state: QueryState): TargetAstMap {
const includeVal = state.include[fieldName];
const excludeVal = state.exclude[fieldName];
+ if (config.unit) {
+ if (includeVal === true) {
+ byTarget[config.target].push(AST.literal(config.field));
+ } else if (excludeVal === true) {
+ byTarget[config.target].push(AST.not(AST.literal(config.field)));
+ }
+ continue;
+ }
+
const format = config.formatValue ?? ((v: unknown) => v);
if (Array.isArray(includeVal) || Array.isArray(excludeVal)) {
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.ts
index 910344ac20..561e5a1624 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
@@ -68,6 +68,7 @@ export type ScalarFieldFilters = {
folderDone?: boolean;
foreignEntitySeen?: boolean;
foreignEntityDone?: boolean;
+ foreignEntityIncludesMe?: boolean;
callStatus?: CallStatus;
callAttended?: boolean;
crmCompanyHidden?: boolean;