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(soup): hoist group helpers above rows memo to avoid TDZ (#3398)

gbirman8ae033498aa4
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
index a1edb97de1..84e9eb8ff6 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
@@ -349,75 +349,6 @@ export const SoupViewContextProvider: FlowComponent<
return [...featured, ...rest];
};
- const rows = createMemo((): SoupRow[] => {
- const field = groupByField();
- const groups = itemsQuery.data?.groups;
-
- // Not grouped - build simple entity rows
- if (!field || !groups) {
- return entities().map((entity, index) =>
- soup.buildRow({ id: entity.id, index, original: entity })
- );
- }
-
- // Grouped - build header + entity + loadMore rows for each group
- const result: SoupRow[] = [];
- let globalIndex = 0;
-
- for (const apiGroup of groups) {
- const groupMeta = buildGroupMeta(apiGroup);
- const query = groupQueries().find((q) => q.key === apiGroup.key);
- const groupEntities = query?.data() ?? [];
-
- // Get first entity to use for header original
- // If the group has no entities, we can skip it
- const firstEntity = groupEntities[0];
-
- if (!firstEntity) continue;
-
- // Header row
- result.push(
- soup.buildRow({
- id: `header:${apiGroup.key}`,
- index: globalIndex++,
- original: firstEntity,
- group: groupMeta,
- isGrouped: true,
- })
- );
-
- // Entity rows
- for (const entity of groupEntities) {
- result.push(
- soup.buildRow({
- id: entity.id,
- index: globalIndex++,
- original: entity,
- group: groupMeta,
- })
- );
- }
-
- // We can stop here if the group has no more data
- // that needs to be fetched
- if (!groupMeta.hasMore()) continue;
-
- const lastEntity = groupEntities[groupEntities.length - 1];
-
- result.push(
- soup.buildRow({
- id: `loadmore:${apiGroup.key}`,
- index: globalIndex++,
- original: lastEntity,
- group: groupMeta,
- isLoadMore: true,
- })
- );
- }
-
- return result;
- });
-
const instructionsIdQuery = useInstructionsMdIdQuery();
const groupQueries = createInfiniteQueries<GroupedSoupPage, SoupEntity[]>(
@@ -522,6 +453,75 @@ export const SoupViewContextProvider: FlowComponent<
};
};
+ const rows = createMemo((): SoupRow[] => {
+ const field = groupByField();
+ const groups = itemsQuery.data?.groups;
+
+ // Not grouped - build simple entity rows
+ if (!field || !groups) {
+ return entities().map((entity, index) =>
+ soup.buildRow({ id: entity.id, index, original: entity })
+ );
+ }
+
+ // Grouped - build header + entity + loadMore rows for each group
+ const result: SoupRow[] = [];
+ let globalIndex = 0;
+
+ for (const apiGroup of groups) {
+ const groupMeta = buildGroupMeta(apiGroup);
+ const query = groupQueries().find((q) => q.key === apiGroup.key);
+ const groupEntities = query?.data() ?? [];
+
+ // Get first entity to use for header original
+ // If the group has no entities, we can skip it
+ const firstEntity = groupEntities[0];
+
+ if (!firstEntity) continue;
+
+ // Header row
+ result.push(
+ soup.buildRow({
+ id: `header:${apiGroup.key}`,
+ index: globalIndex++,
+ original: firstEntity,
+ group: groupMeta,
+ isGrouped: true,
+ })
+ );
+
+ // Entity rows
+ for (const entity of groupEntities) {
+ result.push(
+ soup.buildRow({
+ id: entity.id,
+ index: globalIndex++,
+ original: entity,
+ group: groupMeta,
+ })
+ );
+ }
+
+ // We can stop here if the group has no more data
+ // that needs to be fetched
+ if (!groupMeta.hasMore()) continue;
+
+ const lastEntity = groupEntities[groupEntities.length - 1];
+
+ result.push(
+ soup.buildRow({
+ id: `loadmore:${apiGroup.key}`,
+ index: globalIndex++,
+ original: lastEntity,
+ group: groupMeta,
+ isLoadMore: true,
+ })
+ );
+ }
+
+ return result;
+ });
+
const { searchQuery } = search;
const context = {