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
fix(soup): keep GraphQL Soup lists when a page lacks its soup payload (#7697)
teo9de2188802ae
diff --git a/apps/web/src/lib/queries/soup/graphql/items.test.ts b/apps/web/src/lib/queries/soup/graphql/items.test.tsindex 7214d5f8f8..6fed24df8c 100644--- a/apps/web/src/lib/queries/soup/graphql/items.test.ts+++ b/apps/web/src/lib/queries/soup/graphql/items.test.ts@@ -927,6 +927,53 @@ describe('createGraphqlSoupAstItemsQuery', () => {}});+ it('keeps other pages when one page result omits its soup payload', async () => {+ const fake = makeFakeClient();+ getGraphqlSoupClientMock.mockReturnValue(fake.client);+ const { query, dispose } = createRoot((dispose) => ({+ dispose,+ query: createGraphqlSoupAstItemsQuery(+ () => ({ params: { sort_method: 'updated_at' }, body: {} }),+ () => ({ enabled: true })+ ),+ }));+ try {+ fake.executions[0].next(+ graphqlSoupPage({ items: [{ id: 'a' }], next_cursor: 'next' })+ );+ const next = query.fetchNextPage();+ await vi.waitFor(() => expect(fake.executions).toHaveLength(2));+ fake.executions[1].next(+ graphqlSoupPage({ items: [{ id: 'b' }], next_cursor: 'more' })+ );+ await next;+ const ids = () => query.data()?.entities.map((entity) => entity.id);+ expect(ids()).toEqual(['a', 'b']);++ fake.executions[0].next({ user: { id: 'viewer' } });+ expect(query.error()).toBeUndefined();+ expect(ids()).toEqual(['b']);+ expect(query.hasNextPage()).toBe(true);++ fake.executions[1].next({ user: { id: 'viewer' } });+ expect(query.error()).toBeUndefined();+ expect(ids()).toEqual([]);+ expect(query.hasNextPage()).toBe(false);++ fake.executions[0].next(+ graphqlSoupPage({ items: [{ id: 'a' }], next_cursor: 'next' })+ );+ fake.executions[1].next(+ graphqlSoupPage({ items: [{ id: 'b' }], next_cursor: 'more' })+ );+ expect(query.error()).toBeUndefined();+ expect(ids()).toEqual(['a', 'b']);+ expect(query.hasNextPage()).toBe(true);+ } finally {+ dispose();+ }+ });+it('retains the page projection when only query activity changes', () => {const fake = makeFakeClient();getGraphqlSoupClientMock.mockReturnValue(fake.client);diff --git a/apps/web/src/lib/queries/soup/graphql/items.ts b/apps/web/src/lib/queries/soup/graphql/items.tsindex 81927b767b..6fc8f41dd8 100644--- a/apps/web/src/lib/queries/soup/graphql/items.ts+++ b/apps/web/src/lib/queries/soup/graphql/items.ts@@ -119,6 +119,12 @@ const itemsById = (items: readonly SoupApiItem[]) =>items.map((item) => [mapApiSoupItemToEntity(item).id, item]));+// A page result can carry the viewer without its `soup` field. Selection runs+// over every loaded page, so such a page reads as unloaded instead of failing+// the whole list.+const hasSoupPage = (page: SoupQuery | ChannelListSoupQuery): boolean =>+ page.user?.soup != null;+/** Creates the live urql query for a flat Soup AST request. */export function createGraphqlSoupAstItemsQuery(args: Accessor<GraphqlSoupAstItemsQueryArgs>,@@ -591,7 +597,8 @@ export function createGraphqlSoupAstItemsQuery(SoupQuery | ChannelListSoupQuery,string | null>): ServerProjection => {- const mappedPages = pages.map(mapGraphqlSoupPage);+ const soupPages = pages.filter(hasSoupPage);+ const mappedPages = soupPages.map(mapGraphqlSoupPage);const oldestFetchedTimestamp = soupPageTimestamp(mappedPages.flatMap((page) => page.items.map(mapApiSoupItemToEntity)),sortMethod@@ -602,7 +609,7 @@ export function createGraphqlSoupAstItemsQuery(showSupportedForeignEntities,}));- const records = pages.flatMap<GraphqlSoupItem>(+ const records = soupPages.flatMap<GraphqlSoupItem>((page) => page.user.soup.items);return {@@ -638,7 +645,9 @@ export function createGraphqlSoupAstItemsQuery(return { input };},getNextPageParam: (lastPage) =>- lastPage.user.soup.nextCursor ?? undefined,+ hasSoupPage(lastPage)+ ? (lastPage.user.soup.nextCursor ?? undefined)+ : undefined,enabled:queryOptions.enabled &&!queryOptions.localOnly &&