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): sort method not applied to group by (#4302)
dev-rbef581b65bb56
diff --git a/js/app/packages/app/component/next-soup/soup-view/create-grouped-soup-queries.ts b/js/app/packages/app/component/next-soup/soup-view/create-grouped-soup-queries.tsindex abb416867a..023c8c52e7 100644--- a/js/app/packages/app/component/next-soup/soup-view/create-grouped-soup-queries.ts+++ b/js/app/packages/app/component/next-soup/soup-view/create-grouped-soup-queries.ts@@ -50,7 +50,11 @@ export type GroupQueryData = {type CreateGroupedSoupQueriesArgs = {initialPage: Accessor<InitialGroupPage | undefined>;groupByField: Accessor<GroupByField | undefined>;- soupParams: Accessor<SoupParams>;+ soupParams: Accessor<+ Omit<SoupParams, 'sort_method'> & {+ sort_method: Exclude<SoupParams['sort_method'], 'frecency'>;+ }+ >;soupBody: Accessor<SoupAstBody>;queryOptions: Accessor<{enabled?: boolean;@@ -142,6 +146,7 @@ export function createGroupedSoupQueries(args: CreateGroupedSoupQueriesArgs) {group_by: serializeGroupByField(field),group_key: group.key,limit: args.soupParams().limit,+ sort_method: args.soupParams().sort_method ?? undefined,},body: args.soupBody(),})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.tsxindex 3a4af0c6be..2e3c0f5d1f 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@@ -143,7 +143,10 @@ interface SoupViewContextProviderProps extends SoupViewInitializeOptions {initialEnabled?: boolean;}-type ApiSortMethod = NonNullable<SoupParams['sort_method']>;+type ApiSortMethod = Exclude<+ NonNullable<SoupParams['sort_method']>,+ 'frecency'+>;const VALID_API_SORT_METHODS: ApiSortMethod[] = ['viewed_at','created_at',@@ -166,7 +169,7 @@ export const SoupViewContextProvider: FlowComponent<const queryClient = useQueryClient();- const soupParams = createMemo((): SoupParams => {+ const soupParams = createMemo(() => {const sortId = soup.sort.active()[0]?.id ?? 'updated_at';// Client-only sorts (priority, status) fall back to created_at for the APIdiff --git a/js/app/packages/queries/soup/items.ts b/js/app/packages/queries/soup/items.tsindex 31ede6ed65..1617a2ed9d 100644--- a/js/app/packages/queries/soup/items.ts+++ b/js/app/packages/queries/soup/items.ts@@ -152,12 +152,21 @@ export const useSoupAstItemsQuery = (queryKey: soupKeys.astItems({ params, body, groupBy }).queryKey,queryFn: async (ctx): Promise<SoupAstItemsPage> => {if (groupBy) {+ let sort_method = params.sort_method ?? undefined;++ // TODO(dev-rb/soup): This is temporary fix since we don't support+ // 'frecency' for group by. Replace with proper types+ if (sort_method === 'frecency') {+ sort_method = 'updated_at';+ }+const response = await throwOnErr(async () =>await storageServiceClient.getGroupedSoupAstItems({params: {group_by: serializeGroupByField(groupBy),per_group_limit: params.limit,+ sort_method,},body,})diff --git a/js/app/packages/service-clients/service-storage/client.ts b/js/app/packages/service-clients/service-storage/client.tsindex f886d43fae..78c5a474ec 100644--- a/js/app/packages/service-clients/service-storage/client.ts+++ b/js/app/packages/service-clients/service-storage/client.ts@@ -37,6 +37,7 @@ import type {GithubPullRequestsResponse,GroupedSoupGroupPage,GroupedSoupInitialPage,+ GroupedSoupSort,PostGroupedSoupAstGroupPageRequest,PostGroupedSoupAstInitialRequest,PostGroupedSoupAstRequest,@@ -400,14 +401,16 @@ export const storageServiceClient = {params: {group_by: PostGroupedSoupAstInitialRequest['group_by'];per_group_limit?: number | null;+ sort_method?: GroupedSoupSort;};body: PostSoupAstRequest;}) {- const { limit: _limit, sort_method: _sortMethod, ...filters } = args.body;+ const { limit: _limit, ...filters } = args.body;const body = {...filters,mode: 'initial',group_by: args.params.group_by,+ sort_method: args.params.sort_method,...(args.params.per_group_limit != null && {per_group_limit: args.params.per_group_limit,}),@@ -425,6 +428,7 @@ export const storageServiceClient = {group_by: PostGroupedSoupAstGroupPageRequest['group_by'];group_key: string;limit?: number | null;+ sort_method?: GroupedSoupSort;};body: PostSoupAstRequest;}) {@@ -432,11 +436,12 @@ export const storageServiceClient = {if (args.params.cursor) params.set('cursor', args.params.cursor);const searchParams = params.toString() ? `?${params.toString()}` : '';- const { limit: _limit, sort_method: _sortMethod, ...filters } = args.body;+ const { limit: _limit, ...filters } = args.body;const body = {...filters,mode: 'group_page',group_by: args.params.group_by,+ sort_method: args.params.sort_method,group_key: args.params.group_key,...(args.params.limit != null && { limit: args.params.limit }),} satisfies PostGroupedSoupAstRequest;