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): filter and sort bugs (#1809)
dev-rb3104428a4eec
diff --git a/js/app/packages/app/component/next-soup/filters/filters.ts b/js/app/packages/app/component/next-soup/filters/filters.tsindex a6c5e1cc43..80cc367467 100644--- a/js/app/packages/app/component/next-soup/filters/filters.ts+++ b/js/app/packages/app/component/next-soup/filters/filters.ts@@ -220,10 +220,16 @@ export function hasCalendarInviteFilter(entity: EntityData): boolean {return entity.hasIcsAttachment === true;}+const ICS_MIME_TYPE = 'application/ics';+export function hasAttachmentFilter(entity: EntityData): boolean {if (entity.type !== 'email') return false;- return (entity.attachments?.length ?? 0) > 0;+ const filteredAttachments = entity.attachments?.filter(+ (a) => a.mimeType !== ICS_MIME_TYPE+ );++ return (filteredAttachments?.length ?? 0) > 0;}const PDF_MIME_TYPES = ['application/pdf'];diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/sort-dropdown.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/sort-dropdown.tsxindex 6182edda95..fbdd21bbb3 100644--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/sort-dropdown.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/sort-dropdown.tsx@@ -2,10 +2,9 @@ import { type Component, For, Show } from 'solid-js';import { DropdownMenu } from '@kobalte/core/dropdown-menu';import CheckIcon from '@icon/regular/check.svg';import ChevronDownIcon from '@icon/regular/caret-down.svg';-import {- SORT_OPTIONS,- type SortOption,- type SystemSortOption,+import type {+ SortOption,+ SystemSortOption,} from '@app/component/next-soup/soup-view/sort-options';import { Button } from '@app/component/next-soup/soup-view/filters-bar/button';@@ -15,7 +14,7 @@ export interface SortDropdownProps {/** Handler for sort change */onChange: (value: SystemSortOption) => void;/** Available sort options (defaults to SORT_OPTIONS) */- options?: SortOption[];+ options: SortOption[];/** Controlled open state (optional - uses internal state if not provided) */open?: boolean;/** Controlled open state setter (optional - uses internal state if not provided) */@@ -23,7 +22,7 @@ export interface SortDropdownProps {}export const SortDropdown: Component<SortDropdownProps> = (props) => {- const options = () => props.options ?? SORT_OPTIONS;+ const options = () => props.options ?? [];const currentOption = () => options().find((o) => o.value === props.value());diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-filters.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-filters.tsxindex 687e1c7427..822a07d004 100644--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-filters.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-filters.tsx@@ -5,7 +5,6 @@ import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-conteximport {AssigneeFilter,AttachmentTypeFilter,- ChannelVisibilityFilter,DocumentFolderFilter,DocumentTypeFilter,EntityTypeFilter,@@ -131,7 +130,9 @@ const TasksFilters = () => {};const ChannelsFilters = () => {- return <ChannelVisibilityFilter />;+ // No channels filters for now+ // TODO: Add channel filters+ return null;};const FilesFilters = () => {diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-sort.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-sort.tsxindex a5ebfe4e2f..4055b2ac6e 100644--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-sort.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-sort.tsx@@ -2,7 +2,10 @@ import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';import type { ListView } from '@app/constants/list-views';import { SortDropdown } from '@app/component/next-soup/soup-view/filters-bar/sort-dropdown';import {- SORT_OPTIONS,+ CHANNEL_SORT_OPTIONS,+ DEFAULT_SORT_OPTIONS,+ DOCUMENT_SORT_OPTIONS,+ EMAIL_SORT_OPTIONS,TASK_SORT_OPTIONS,type SortOption,type SystemSortOption,@@ -52,7 +55,7 @@ export const SoupViewContextSort = () => {);};-const useSortDropdown = (options: SortOption[] = SORT_OPTIONS) => {+const useSortDropdown = (options: SortOption[] = DEFAULT_SORT_OPTIONS) => {const { soup } = useSoupView();const value = createMemo(@@ -91,7 +94,7 @@ const AgentsSort = () => {};const MailSort = () => {- const sort = useSortDropdown();+ const sort = useSortDropdown(EMAIL_SORT_OPTIONS);return (<SortDropdown@@ -103,7 +106,7 @@ const MailSort = () => {};const DocumentsSort = () => {- const sort = useSortDropdown();+ const sort = useSortDropdown(DOCUMENT_SORT_OPTIONS);return (<SortDropdown@@ -127,7 +130,7 @@ const TasksSort = () => {};const ChannelsSort = () => {- const sort = useSortDropdown();+ const sort = useSortDropdown(CHANNEL_SORT_OPTIONS);return (<SortDropdowndiff --git a/js/app/packages/app/component/next-soup/soup-view/sort-options.tsx b/js/app/packages/app/component/next-soup/soup-view/sort-options.tsxindex 5bc8658444..3ccc0f245a 100644--- a/js/app/packages/app/component/next-soup/soup-view/sort-options.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/sort-options.tsx@@ -170,7 +170,7 @@ export const SORT_CONFIGS = {},} satisfies Record<string, SortConfig<SoupEntity>>;-export const SORT_OPTIONS: SortOption[] = [+const SORT_OPTIONS = [{value: 'viewed_at',label: 'Last viewed',@@ -191,10 +191,6 @@ export const SORT_OPTIONS: SortOption[] = [label: 'Frecency',icon: () => <ChartLineUpIcon class="size-3.5" />,},-];--export const TASK_SORT_OPTIONS: SortOption[] = [- ...SORT_OPTIONS,{value: 'priority',label: 'Priority',@@ -205,4 +201,43 @@ export const TASK_SORT_OPTIONS: SortOption[] = [label: 'Status',icon: () => <ListChecksIcon class="size-3.5" />,},-];+] as const satisfies SortOption[];++type OptionValue = (typeof SORT_OPTIONS)[number]['value'];++export const buildSortOptions = (options: OptionValue[]) => {+ return SORT_OPTIONS.filter((o) => options.includes(o.value));+};++export const DEFAULT_SORT_OPTIONS = buildSortOptions([+ 'viewed_at',+ 'updated_at',+ 'created_at',+ 'frecency',+]);++export const TASK_SORT_OPTIONS = buildSortOptions([+ 'viewed_at',+ 'updated_at',+ 'created_at',+ 'status',+ 'priority',+]);++export const DOCUMENT_SORT_OPTIONS = buildSortOptions([+ 'viewed_at',+ 'updated_at',+ 'created_at',+]);++export const EMAIL_SORT_OPTIONS = buildSortOptions([+ 'viewed_at',+ 'updated_at',+ 'created_at',+]);++export const CHANNEL_SORT_OPTIONS = buildSortOptions([+ 'viewed_at',+ 'updated_at',+ 'created_at',+]);