Skip to content

armgit / macro

Public Imported from GitHub
0

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

fix(upload): add bulk-uploaded folder to history for mentions (#3261)

gbirman809c1fb04a99
diff --git a/js/app/packages/app/util/handleFileUpload.ts b/js/app/packages/app/util/handleFileUpload.ts
index 40e5c05aa9..c751ee2cc9 100644
--- a/js/app/packages/app/util/handleFileUpload.ts
+++ b/js/app/packages/app/util/handleFileUpload.ts
@@ -1,6 +1,7 @@
import { toast } from '@core/component/Toast/Toast';
import { fileTypeToBlockName } from '@core/constant/allBlocks';
import { type UploadInput, uploadFiles } from '@core/util/upload';
+import { refetchHistory } from '@queries/history/history';
import { refetchSoupEntity } from '@queries/soup/cache';
import { useSplitLayout } from '../component/split-layout/layout';
@@ -34,6 +35,7 @@ export function useHandleFileUpload({
if (!createdProjectId) return;
refetchSoupEntity(createdProjectId, 'project');
+ refetchHistory();
toast.success(`Uploaded ${upload.name}`, undefined, [
{
diff --git a/js/app/packages/queries/soup/normalized-cache/operations.test.ts b/js/app/packages/queries/soup/normalized-cache/operations.test.ts
index 3e68004280..836bff00d3 100644
--- a/js/app/packages/queries/soup/normalized-cache/operations.test.ts
+++ b/js/app/packages/queries/soup/normalized-cache/operations.test.ts
@@ -215,6 +215,11 @@ describe('buildSingleEntityFilter', () => {
filterKey: 'project_filters',
idKey: 'project_ids',
},
+ {
+ entityType: 'call' as const,
+ filterKey: 'call_filters',
+ idKey: 'call_ids',
+ },
])('unblocks only $entityType filter with the real entityId', ({
entityType,
filterKey,
@@ -233,6 +238,7 @@ describe('buildSingleEntityFilter', () => {
'chat_filters',
'channel_filters',
'project_filters',
+ 'call_filters',
].filter((k) => k !== filterKey);
for (const key of otherFilters) {
diff --git a/js/app/packages/queries/soup/normalized-cache/operations.ts b/js/app/packages/queries/soup/normalized-cache/operations.ts
index ccbee317bf..006caf5c10 100644
--- a/js/app/packages/queries/soup/normalized-cache/operations.ts
+++ b/js/app/packages/queries/soup/normalized-cache/operations.ts
@@ -1,3 +1,4 @@
+import { QUERY_FILTERS_BASE } from '@app/component/next-soup/filters/query-filters';
import { isErr } from '@core/util/maybeResult';
import type { UnifiedSearchResponseItem } from '@service-search/generated/models';
import type {
@@ -223,7 +224,6 @@ export function removeSearchEntities(entityIds: Set<string>): SoupTransaction {
* Fetch a single entity from the server and merge it into the cache.
* If the entity is already cached, updates it via normy (deep-merge).
* If it's new, prepends it to the first page of every active soup list query.
- * Falls back to `invalidateSoupEntity` for unsupported entity types (e.g. emailThread).
*/
export async function refetchSoupEntity(
entityId: string,
@@ -233,11 +233,6 @@ export async function refetchSoupEntity(
const filter = buildSingleEntityFilter(entityType, entityId);
- if (!filter) {
- invalidateSoupEntity(entityId);
- return;
- }
-
const result = await storageServiceClient.getSoupItems({
params: {},
body: filter,
@@ -263,22 +258,14 @@ export async function refetchSoupEntity(
}
}
-// UUID that matches no real entity — used to zero out soup filters
-// so omitted entity types return nothing instead of everything.
-const NIL_ID = '00000000-0000-0000-0000-000000000000';
-
/** @private */
export function buildSingleEntityFilter(
entityType: SoupEntityTag,
entityId: string
-): PostSoupRequest | null {
+): PostSoupRequest {
const base: PostSoupRequest = {
+ ...QUERY_FILTERS_BASE,
limit: 1,
- document_filters: { document_ids: [NIL_ID] },
- chat_filters: { chat_ids: [NIL_ID] },
- channel_filters: { channel_ids: [NIL_ID] },
- project_filters: { project_ids: [NIL_ID] },
- email_filters: { email_thread_ids: [NIL_ID] },
};
return match(entityType)
.with('document', () => ({
@@ -298,7 +285,10 @@ export function buildSingleEntityFilter(
...base,
email_filters: { email_thread_ids: [entityId] },
}))
- .with('call', () => null)
+ .with('call', () => ({
+ ...base,
+ call_filters: { call_ids: [entityId] },
+ }))
.exhaustive();
}