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
refactor(soup): clean up soup filters and configs (#1892)
dev-rb7eafabdd329f
diff --git a/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts b/js/app/packages/app/component/app-sidebar/soup-filter-presets.tsindex 3f6625451f..c9d30734b7 100644--- a/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts+++ b/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts@@ -1,7 +1,5 @@-import {- QUERY_FILTERS,- type FilterID,-} from '@app/component/next-soup/filters/filters';+import { QUERY_FILTERS } from '@app/component/next-soup/filters/query-filters';+import type { FilterID } from '@app/component/next-soup/filters/configs';import {applyInboxQueryFilters,applyOtherQueryFilters,diff --git a/js/app/packages/app/component/next-soup/create-soup-state.ts b/js/app/packages/app/component/next-soup/create-soup-state.tsindex cd7bf6c372..eaa27d4ff1 100644--- a/js/app/packages/app/component/next-soup/create-soup-state.ts+++ b/js/app/packages/app/component/next-soup/create-soup-state.ts@@ -58,7 +58,11 @@ export const createSoupState = <TId extends string = FilterID>(const filters = createFilterState({filters:- filterConfigs ?? createSoupFilters(notificationSource, user.userId),+ filterConfigs ??+ (createSoupFilters(+ notificationSource,+ user.userId+ ) as FilterConfig<SoupEntity>[]),groups: filterGroups ?? SOUP_FILTER_GROUPS,initialFilters,});diff --git a/js/app/packages/app/component/next-soup/filters/configs.ts b/js/app/packages/app/component/next-soup/filters/configs.tsnew file mode 100644index 0000000000..4dd2af6404--- /dev/null+++ b/js/app/packages/app/component/next-soup/filters/configs.ts@@ -0,0 +1,410 @@+import type {+ FilterConfig,+ FilterGroupConfig,+} from '@app/component/next-soup/filters/create-filter-state';+import {+ isNotStarted,+ isInProgress,+ isInReview,+ isCompleted,+ isCanceled,+ isUrgentPriority,+ isHighPriority,+ isMediumPriority,+ isLowPriority,+ hasNoPriority,+ hasAssignees,+ isUnassigned,+ channelsFilter,+ filesAndFolderFilter,+ activeAgentFilter,+ emailDraftsFilter,+ noDraftsFilter,+ hasCalendarInviteFilter,+ hasAttachmentFilter,+ hasPdfAttachmentFilter,+ hasImageAttachmentFilter,+ hasDocumentAttachmentFilter,+ sharedEntity,+ ownedAgentFilter,+ sharedAgentFilter,+ taskAssignedToUserFilter,+ agentFilter,+ documentFilter,+ emailFilter,+ fileFilter,+ notDoneFilter,+ peopleFilter,+ projectFilter,+ taskFilter,+ teamsFilter,+ unreadFilter,+} from '@app/component/next-soup/filters/predicates';+import {+ signalFilter,+ noiseFilter,+ explicitNoiseFilter,+} from '@app/component/next-soup/filters/inbox-filters';+import { codeFileExtensions } from '@block-code/util/languageSupport';+import {+ type EntityData,+ isEmailEntity,+ isDocumentEntity,+ getEntityProjectId,+} from '@entity';+import type { NotificationSource } from '@notifications';++type EntityFilterConfig = FilterConfig<EntityData> & { label?: string };++export const ENTITY_TYPE_FILTER_CONFIGS = [+ {+ id: 'document',+ label: 'Docs',+ predicate: documentFilter,+ group: 'entity-type',+ },+ {+ id: 'agent',+ label: 'Agents',+ predicate: agentFilter,+ group: 'entity-type',+ },+ {+ id: 'people',+ label: 'People',+ predicate: peopleFilter,+ group: 'entity-type',+ },+ {+ id: 'teams',+ label: 'Teams',+ predicate: teamsFilter,+ group: 'entity-type',+ },+ {+ id: 'task',+ label: 'Tasks',+ predicate: taskFilter,+ group: 'entity-type',+ },+ {+ id: 'email',+ label: 'Mail',+ predicate: emailFilter,+ group: 'entity-type',+ },+ {+ id: 'file',+ label: 'Files',+ predicate: fileFilter,+ group: 'entity-type',+ },+] as const satisfies EntityFilterConfig[];++export const EMAIL_CONTEXTUAL_FILTERS = [+ {+ id: 'email-unread',+ label: 'Unread',+ predicate: (entity) => isEmailEntity(entity) && !entity.isRead,+ },+ {+ id: 'email-read',+ label: 'Read',+ predicate: (entity) => isEmailEntity(entity) && entity.isRead,+ },+ {+ id: 'email-done',+ label: 'Done',+ predicate: (entity) => isEmailEntity(entity) && entity.done,+ },+ {+ id: 'email-not-done',+ label: 'Not Done',+ predicate: (entity) => isEmailEntity(entity) && !entity.done,+ },+] as const satisfies EntityFilterConfig[];++export const TASK_STATUS_FILTERS = [+ {+ id: 'task-not-started',+ label: 'Not Started',+ predicate: isNotStarted,+ },+ {+ id: 'task-in-progress',+ label: 'In Progress',+ predicate: isInProgress,+ },+ {+ id: 'task-in-review',+ label: 'In Review',+ predicate: isInReview,+ },+ {+ id: 'task-completed',+ label: 'Completed',+ predicate: isCompleted,+ },+ {+ id: 'task-canceled',+ label: 'Canceled',+ predicate: isCanceled,+ },+] as const satisfies EntityFilterConfig[];++export const TASK_PRIORITY_FILTERS = [+ {+ id: 'task-critical',+ label: 'Critical',+ predicate: isUrgentPriority,+ },+ {+ id: 'task-high-priority',+ label: 'High Priority',+ predicate: isHighPriority,+ },+ {+ id: 'task-medium-priority',+ label: 'Medium Priority',+ predicate: isMediumPriority,+ },+ {+ id: 'task-low-priority',+ label: 'Low Priority',+ predicate: isLowPriority,+ },+ {+ id: 'task-no-priority',+ label: 'No Priority',+ predicate: hasNoPriority,+ },+] as const satisfies EntityFilterConfig[];++export const TASK_ASSIGNEE_FILTERS = [+ {+ id: 'task-has-assignee',+ label: 'Has Assignee',+ predicate: hasAssignees,+ },+ {+ id: 'task-unassigned',+ label: 'Unassigned',+ predicate: isUnassigned,+ },+] as const satisfies EntityFilterConfig[];++export const TASK_CONTEXTUAL_FILTERS = [+ ...TASK_STATUS_FILTERS,+ ...TASK_PRIORITY_FILTERS,+ ...TASK_ASSIGNEE_FILTERS,+] as const satisfies EntityFilterConfig[];++const DOCUMENT_CONTEXTUAL_FILTERS = [+ {+ id: 'in-folder',+ label: 'In Folder',+ predicate: (entity) => !!getEntityProjectId(entity),+ },+ {+ id: 'doc-markdown',+ label: 'Markdown',+ predicate: (entity) => isDocumentEntity(entity) && entity.fileType === 'md',+ },+ {+ id: 'doc-canvas',+ label: 'Canvas',+ predicate: (entity) =>+ isDocumentEntity(entity) && entity.fileType === 'canvas',+ },+] as const satisfies EntityFilterConfig[];++const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp'] as const;++export const FILE_TYPE_FILTERS = [+ {+ id: 'file-code',+ label: 'Code',+ predicate: (entity) => {+ if (entity.type !== 'document') return false;+ const fileType = entity.fileType ?? '';+ return (codeFileExtensions as readonly string[]).includes(fileType);+ },+ },+ {+ id: 'file-image',+ label: 'Images',+ predicate: (entity) => {+ if (entity.type !== 'document') return false;+ const fileType = entity.fileType ?? '';+ return (IMAGE_EXTENSIONS as readonly string[]).includes(fileType);+ },+ },+ {+ id: 'file-pdf',+ label: 'PDFs',+ predicate: (entity) => {+ if (entity.type !== 'document') return false;+ return entity.fileType === 'pdf';+ },+ },+ {+ id: 'file-other',+ label: 'Other',+ predicate: (entity) => {+ if (entity.type !== 'document') return false;+ const fileType = entity.fileType ?? '';+ // Exclude markdown, canvas, code, images, and PDFs+ if (['md', 'canvas'].includes(fileType)) return false;+ if ((codeFileExtensions as readonly string[]).includes(fileType))+ return false;+ if ((IMAGE_EXTENSIONS as readonly string[]).includes(fileType))+ return false;+ if (fileType === 'pdf') return false;+ return true;+ },+ },+] as const satisfies EntityFilterConfig[];++export const createSoupFilters = (+ notificationSource: NotificationSource,+ getUserID: () => string | undefined+) => {+ const list = [+ {+ id: 'signal',+ label: 'Inbox',+ predicate: signalFilter,+ group: 'focus',+ },+ {+ id: 'noise',+ label: 'Other',+ predicate: noiseFilter,+ group: 'focus',+ },+ {+ id: 'explicit-noise',+ label: 'Explicit Noise',+ predicate: (entity: EntityData) => !explicitNoiseFilter(entity),+ group: 'focus',+ },+ {+ id: 'unread',+ label: 'Unread',+ predicate: unreadFilter(notificationSource),+ },+ {+ id: 'read',+ label: 'Read',+ predicate: (entity: EntityData) =>+ !unreadFilter(notificationSource)(entity),+ },+ {+ id: 'not-done',+ label: 'Not done',+ predicate: notDoneFilter(notificationSource),+ },+ {+ id: 'done',+ label: 'Done',+ predicate: (entity: EntityData) =>+ !notDoneFilter(notificationSource)(entity),+ },+ ...ENTITY_TYPE_FILTER_CONFIGS,+ {+ id: 'channels',+ label: 'Channels',+ predicate: channelsFilter,+ },+ {+ id: 'file-folder',+ label: 'Files & Folders',+ predicate: filesAndFolderFilter,+ },+ {+ id: 'folders',+ label: 'Folders',+ predicate: projectFilter,+ },+ {+ id: 'active-agent',+ label: 'Running agents',+ predicate: activeAgentFilter,+ },+ {+ id: 'email-drafts',+ label: 'Email drafts',+ predicate: emailDraftsFilter,+ },+ {+ id: 'no-drafts',+ label: 'No drafts',+ predicate: noDraftsFilter,+ },+ {+ id: 'has-calendar-invite',+ label: 'Has calendar invite',+ predicate: hasCalendarInviteFilter,+ },+ {+ id: 'has-attachment',+ label: 'Has attachment',+ predicate: hasAttachmentFilter,+ },+ {+ id: 'attachment-pdf',+ label: 'PDF attachment',+ predicate: hasPdfAttachmentFilter,+ },+ {+ id: 'attachment-image',+ label: 'Image attachment',+ predicate: hasImageAttachmentFilter,+ },+ {+ id: 'attachment-document',+ label: 'Document attachment',+ predicate: hasDocumentAttachmentFilter,+ },+ {+ id: 'shared-entity',+ label: 'Shared entities',+ predicate: sharedEntity(getUserID),+ },+ {+ id: 'owned-agent',+ label: 'Owned by me',+ predicate: ownedAgentFilter(getUserID),+ },+ {+ id: 'shared-agent',+ label: 'Shared with me',+ predicate: sharedAgentFilter(getUserID),+ },+ {+ id: 'assigned-to',+ label: 'Task assigned to user',+ predicate: taskAssignedToUserFilter(getUserID),+ },+ ...TASK_STATUS_FILTERS,+ ...TASK_PRIORITY_FILTERS,+ ...DOCUMENT_CONTEXTUAL_FILTERS,+ ...FILE_TYPE_FILTERS,+ ] as const satisfies EntityFilterConfig[];++ return list;+};++/**+ * Default filter group configurations for soup filters.+ * - 'focus': Mutually exclusive (signal/noise/explicit-noise)+ * - 'entity-type': Mutually exclusive by default+ */+export const SOUP_FILTER_GROUPS: FilterGroupConfig[] = [+ { id: 'focus', allowMultiple: false },+ { id: 'entity-type', allowMultiple: false },+];++type SoupFilter = ReturnType<typeof createSoupFilters>[number];++export type FilterID = Extract<SoupFilter, { id: string & {} }>['id'];diff --git a/js/app/packages/app/component/next-soup/filters/filters.ts b/js/app/packages/app/component/next-soup/filters/filters.tsdeleted file mode 100644index 80cc367467..0000000000--- a/js/app/packages/app/component/next-soup/filters/filters.ts+++ /dev/null@@ -1,1090 +0,0 @@-import {- getEntityProjectId,- getTaskAssigneeIds,- isTaskEntity,- type TaskEntityWithProperties,- type EntityData,- type WithNotification,- isChannelEntity,- isChatEntity,- isDocumentEntity,- isEmailEntity,-} from '@entity';-import {- signalFilter,- noiseFilter,- explicitNoiseFilter,-} from './signal-filters';-import {- type EntityWithValidIcon,- getIconConfig,-} from '@core/component/EntityIcon';-import type { SoupBody, SoupItemsQueryFilters } from '@queries/soup/items';-import type {- SoupApiItem,- SoupProperty,-} from '@service-storage/generated/schemas';-import { codeFileExtensions } from '@block-code/util/languageSupport';-import type { FilterConfig, FilterGroupConfig } from './create-filter-state';-import type { Component } from 'solid-js';-import { AnimatedChannelIcon } from '@macro-icons/wide/animating/channel';-import { AnimatedChatIcon } from '@macro-icons/wide/animating/chat';-import { AnimatedEmailIcon } from '@macro-icons/wide/animating/email';-import { AnimatedFileMdIcon } from '@macro-icons/wide/animating/fileMd';-import { AnimatedFolderIcon } from '@macro-icons/wide/animating/folder';-import { AnimatedStarIcon } from '@macro-icons/wide/animating/star';-import { AnimatedTaskIcon } from '@macro-icons/wide/animating/task';-import { ChannelTypeEnum } from '@service-comms/client';-import { match } from 'ts-pattern';-import { compositeEntity, type NotificationSource } from '@notifications';-import {- PROPERTY_OPTION_IDS,- SYSTEM_PROPERTY_IDS,-} from '@core/component/Properties/constants';--export const NIL_UUID = '00000000-0000-0000-0000-000000000000';--export const EXCLUDE: string[] = [NIL_UUID];--/** Base filter that excludes all entity types by default */-export const QUERY_FILTERS_BASE: SoupItemsQueryFilters = {- channel_filters: { channel_ids: EXCLUDE },- chat_filters: { chat_ids: EXCLUDE },- document_filters: { document_ids: EXCLUDE },- email_filters: { recipients: EXCLUDE },- project_filters: { project_ids: EXCLUDE },-};--function isIdFilteredOut(ids: string[] | undefined, value: string): boolean {- if (!ids || ids.length === 0) return false;- return !ids.includes(value);-}--// TODO: this only supports for item type and id filters, other filters to be added later-export function filterSoupItemByRequestBody(- item: SoupApiItem,- body: SoupBody-): boolean {- return match(item)- .with(- { tag: 'document' },- ({ data }) =>- !isIdFilteredOut(body.document_filters?.document_ids, data.id)- )- .with(- { tag: 'chat' },- ({ data }) => !isIdFilteredOut(body.chat_filters?.chat_ids, data.id)- )- .with(- { tag: 'channel' },- ({ data }) =>- !isIdFilteredOut(body.channel_filters?.channel_ids, data.channel.id)- )- .with(- { tag: 'project' },- ({ data }) => !isIdFilteredOut(body.project_filters?.project_ids, data.id)- )- .with(- { tag: 'emailThread' },- ({ data }) =>- !isIdFilteredOut(body.email_filters?.email_thread_ids, data.id)- )- .exhaustive();-}--type EntityFilterConfig = FilterConfig<EntityData> & { label?: string };--/**- * Unread filter - entity has unread content.- *- * Entity-specific logic:- * - Emails: Uses `isRead` boolean field- * - Everything else: Has at least one notification with viewedAt === null- */-export function unreadFilter(notificationSource: NotificationSource) {- return function (entity: EnhancedEntity): boolean {- if (entity.type === 'email') {- return !entity.isRead;- }- const notifications =- notificationSource.notificationsByEntity()[compositeEntity(entity)];-- return notifications?.some((n) => !n.viewed_at) ?? false;- };-}--/**- * NotDone filter - entity has outstanding items.- *- * Entity-specific logic:- * - Emails: Uses `done` field (derived from !inboxVisible - email is "not done" when in inbox)- * - Everything else: Has at least one notification with done === false- */-export function notDoneFilter(notificationSource: NotificationSource) {- return function (entity: WithNotification<EntityData>) {- if (entity.type === 'email') return !entity.done;- // Tasks are handled by signalFilter based on assignee/status, not notifications- if (isTaskEntity(entity)) return true;-- const notifications =- notificationSource.notificationsByEntity()[compositeEntity(entity)];-- return notifications?.some(({ done }) => !done);- };-}--type EnhancedEntity = WithNotification<EntityData>;--/** Document filter (markdown, canvas) - excludes tasks */-export function documentFilter(entity: EntityData): boolean {- if (entity.type !== 'document') return false;- if (entity.subType?.type === 'task') return false;- const fileType = entity.fileType ?? '';- return fileType === 'md' || fileType === 'canvas';-}--/** Task filter */-export function taskFilter(entity: EntityData): boolean {- return entity.type === 'document' && entity.subType?.type === 'task';-}--/** Email filter */-export function emailFilter(entity: EntityData): boolean {- return entity.type === 'email';-}--/** People filter (direct messages) */-export function peopleFilter(entity: EntityData): boolean {- return entity.type === 'channel' && entity.channelType === 'direct_message';-}--/** Teams filter (group channels) */-export function teamsFilter(entity: EntityData): boolean {- return entity.type === 'channel' && entity.channelType !== 'direct_message';-}--/** Chat/agent filter */-export function agentFilter(entity: EntityData): boolean {- return entity.type === 'chat';-}--/** Project/folder filter */-export function projectFilter(entity: EntityData): boolean {- return entity.type === 'project';-}--/** File filter (non-markdown documents) */-export function fileFilter(entity: EntityData): boolean {- if (entity.type !== 'document') return false;- const fileType = entity.fileType ?? '';- return !['md', 'canvas'].includes(fileType);-}--export function channelsFilter(entity: EntityData): boolean {- return entity.type === 'channel';-}--export function filesAndFolderFilter(entity: EntityData): boolean {- if (entity.type !== 'project' && entity.type !== 'document') return false;-- if (entity.type === 'document') {- const fileType = entity.fileType ?? '';- return !['md', 'canvas'].includes(fileType);- }-- return true;-}--export function activeAgentFilter(entity: EntityData): boolean {- if (entity.type !== 'chat') return false;-- // [TODO] Check status of agent- return true;-}--export function emailDraftsFilter(entity: EntityData): boolean {- if (entity.type !== 'email') return false;-- return entity.isDraft;-}--export function noDraftsFilter(entity: EntityData): boolean {- if (entity.type !== 'email') return false;-- return !entity.isDraft;-}--export function hasCalendarInviteFilter(entity: EntityData): boolean {- if (entity.type !== 'email') return false;-- return entity.hasIcsAttachment === true;-}--const ICS_MIME_TYPE = 'application/ics';--export function hasAttachmentFilter(entity: EntityData): boolean {- if (entity.type !== 'email') return false;-- const filteredAttachments = entity.attachments?.filter(- (a) => a.mimeType !== ICS_MIME_TYPE- );-- return (filteredAttachments?.length ?? 0) > 0;-}--const PDF_MIME_TYPES = ['application/pdf'];-const IMAGE_MIME_TYPES = [- 'image/png',- 'image/jpeg',- 'image/gif',- 'image/webp',- 'image/svg+xml',-];-const DOCUMENT_MIME_TYPES = [- 'application/msword',- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',- 'application/vnd.ms-excel',- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',- 'application/vnd.ms-powerpoint',- 'application/vnd.openxmlformats-officedocument.presentationml.presentation',- 'text/plain',- 'text/csv',-];--function hasAttachmentOfType(entity: EntityData, mimeTypes: string[]): boolean {- if (entity.type !== 'email') return false;- if (!entity.attachments?.length) return false;-- return entity.attachments.some((a) => {- if (!a.mimeType) return false;- return mimeTypes.some((type) => a.mimeType?.startsWith(type));- });-}--export function hasPdfAttachmentFilter(entity: EntityData): boolean {- return hasAttachmentOfType(entity, PDF_MIME_TYPES);-}--export function hasImageAttachmentFilter(entity: EntityData): boolean {- return hasAttachmentOfType(entity, IMAGE_MIME_TYPES);-}--export function hasDocumentAttachmentFilter(entity: EntityData): boolean {- return hasAttachmentOfType(entity, DOCUMENT_MIME_TYPES);-}--export function sharedEntity(getUserID: () => string | undefined) {- return function (entity: EntityData): boolean {- const userID = getUserID();- if (userID == null) return false;-- return entity.ownerId !== userID;- };-}--/** Filter for agents (chats) owned by the current user */-export function ownedAgentFilter(getUserID: () => string | undefined) {- return function (entity: EntityData): boolean {- if (entity.type !== 'chat') return false;- const userID = getUserID();- if (userID == null) return false;-- return entity.ownerId === userID;- };-}--/** Filter for agents (chats) shared with the current user (owned by someone else) */-export function sharedAgentFilter(getUserID: () => string | undefined) {- return function (entity: EntityData): boolean {- if (entity.type !== 'chat') return false;- const userID = getUserID();- if (userID == null) return false;-- return entity.ownerId !== userID;- };-}--export function taskAssignedToUserFilter(getUserID: () => string | undefined) {- return function (entity: EntityData): boolean {- const userID = getUserID();- if (!isTaskEntity(entity) || userID == null) return false;-- const taskEntity = entity as unknown as TaskEntityWithProperties;- return getTaskAssigneeIds(taskEntity).includes(userID);- };-}--export function hasProperties(- entity: EntityData-): entity is EntityData & { properties: SoupProperty[] } {- return 'properties' in entity && Array.isArray(entity.properties);-}--export function getPropertyById(- entity: EntityData,- propertyId: string-): SoupProperty | undefined {- if (!hasProperties(entity)) return undefined;-- return entity.properties.find((p) => p.definition.id === propertyId);-}--export function hasAssignees(entity: EntityData): boolean {- if (!isTaskEntity(entity)) return false;- return getTaskAssigneeIds(entity).length > 0;-}--export function isAssignedTo(entity: EntityData, userId: string): boolean {- if (!isTaskEntity(entity)) return false;-- const assigneeIds = getTaskAssigneeIds(entity);- // If no assignees, consider it assigned to everyone (or unassigned)- if (assigneeIds.length === 0) return false;- return assigneeIds.includes(userId);-}--export function isUnassigned(entity: EntityData): boolean {- if (!isTaskEntity(entity)) return false;- return getTaskAssigneeIds(entity).length === 0;-}--export function getStatusOptionId(entity: EntityData): string | undefined {- if (!isTaskEntity(entity)) return undefined;- const taskWithProps = entity as TaskEntityWithProperties;-- const properties = taskWithProps.properties;-- if (!properties) return undefined;-- const statusProperty = properties.find(- (p) => p.definition.id === SYSTEM_PROPERTY_IDS.STATUS- );-- if (!statusProperty?.value) return undefined;-- const value = statusProperty.value;-- if (value.type === 'SelectOption') {- return value.value[0];- }-- return undefined;-}--export function hasStatus(entity: EntityData, statusOptionId: string): boolean {- return getStatusOptionId(entity) === statusOptionId;-}--export function isNotStarted(entity: EntityData): boolean {- return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.NOT_STARTED);-}--export function isInProgress(entity: EntityData): boolean {- return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS);-}--export function isInReview(entity: EntityData): boolean {- return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.IN_REVIEW);-}--export function isCompleted(entity: EntityData): boolean {- if (!isTaskEntity(entity)) return false;- // Check both the subType flag and status property- if (entity.subType?.is_completed) return true;- return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.COMPLETED);-}--export function isCanceled(entity: EntityData): boolean {- return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.CANCELED);-}--export function isClosed(entity: EntityData): boolean {- return isCompleted(entity) || isCanceled(entity);-}--export function isOpen(entity: EntityData): boolean {- if (!isTaskEntity(entity)) return false;- return !isClosed(entity);-}--export function getPriorityOptionId(entity: EntityData): string | undefined {- if (!isTaskEntity(entity)) return undefined;- const taskWithProps = entity as TaskEntityWithProperties;-- const properties = taskWithProps.properties;-- if (!properties) return undefined;-- const priorityProperty = properties.find(- (p) => p.definition.id === SYSTEM_PROPERTY_IDS.PRIORITY- );-- if (!priorityProperty?.value) return undefined;-- const value = priorityProperty.value;-- if (value.type === 'SelectOption') {- return value.value[0];- }-- return undefined;-}--export function hasPriority(- entity: EntityData,- priorityOptionId: string-): boolean {- return getPriorityOptionId(entity) === priorityOptionId;-}--export function isUrgentPriority(entity: EntityData): boolean {- return hasPriority(entity, PROPERTY_OPTION_IDS.PRIORITY.URGENT);-}--export function isHighPriority(entity: EntityData): boolean {- return hasPriority(entity, PROPERTY_OPTION_IDS.PRIORITY.HIGH);-}--export function isMediumPriority(entity: EntityData): boolean {- return hasPriority(entity, PROPERTY_OPTION_IDS.PRIORITY.MEDIUM);-}--export function isLowPriority(entity: EntityData): boolean {- return hasPriority(entity, PROPERTY_OPTION_IDS.PRIORITY.LOW);-}--export function hasNoPriority(entity: EntityData): boolean {- if (!isTaskEntity(entity)) return false;- return getPriorityOptionId(entity) === undefined;-}--export const ENTITY_TYPE_FILTER_CONFIGS = [- // Entity type filters (mutually exclusive)- {- id: 'document',- label: 'Docs',- predicate: documentFilter,- group: 'entity-type',- },- {- id: 'agent',- label: 'Agents',- predicate: agentFilter,- group: 'entity-type',- },- {- id: 'people',- label: 'People',- predicate: peopleFilter,- group: 'entity-type',- },- {- id: 'teams',- label: 'Teams',- predicate: teamsFilter,- group: 'entity-type',- },- {- id: 'task',- label: 'Tasks',- predicate: taskFilter,- group: 'entity-type',- },- {- id: 'email',- label: 'Mail',- predicate: emailFilter,- group: 'entity-type',- },- {- id: 'file',- label: 'Files',- predicate: fileFilter,- group: 'entity-type',- },-] as const;--export const EMAIL_CONTEXTUAL_FILTERS: EntityFilterConfig[] = [- {- id: 'email-unread',- label: 'Unread',- predicate: (entity) => isEmailEntity(entity) && !entity.isRead,- },- {- id: 'email-read',- label: 'Read',- predicate: (entity) => isEmailEntity(entity) && entity.isRead,- },- {- id: 'email-done',- label: 'Done',- predicate: (entity) => isEmailEntity(entity) && entity.done,- },- {- id: 'email-not-done',- label: 'Not Done',- predicate: (entity) => isEmailEntity(entity) && !entity.done,- },-];--export const TASK_STATUS_FILTERS: EntityFilterConfig[] = [- {- id: 'task-not-started',- label: 'Not Started',- predicate: isNotStarted,- },- {- id: 'task-in-progress',- label: 'In Progress',- predicate: isInProgress,- },- {- id: 'task-in-review',- label: 'In Review',- predicate: isInReview,- },- {- id: 'task-completed',- label: 'Completed',- predicate: isCompleted,- },- {- id: 'task-canceled',- label: 'Canceled',- predicate: isCanceled,- },-];--export const TASK_PRIORITY_FILTERS: EntityFilterConfig[] = [- {- id: 'task-critical',- label: 'Critical',- predicate: isUrgentPriority,- },- {- id: 'task-high-priority',- label: 'High Priority',- predicate: isHighPriority,- },- {- id: 'task-medium-priority',- label: 'Medium Priority',- predicate: isMediumPriority,- },- {- id: 'task-low-priority',- label: 'Low Priority',- predicate: isLowPriority,- },- {- id: 'task-no-priority',- label: 'No Priority',- predicate: hasNoPriority,- },-];--export const TASK_ASSIGNEE_FILTERS: EntityFilterConfig[] = [- {- id: 'task-has-assignee',- label: 'Has Assignee',- predicate: hasAssignees,- },- {- id: 'task-unassigned',- label: 'Unassigned',- predicate: isUnassigned,- },-];--export const TASK_CONTEXTUAL_FILTERS: EntityFilterConfig[] = [- ...TASK_STATUS_FILTERS,- ...TASK_PRIORITY_FILTERS,- ...TASK_ASSIGNEE_FILTERS,-];--export const DOCUMENT_CONTEXTUAL_FILTERS: EntityFilterConfig[] = [- {- id: 'doc-recent',- label: 'Recently Edited',- predicate: (entity) => {- if (!isDocumentEntity(entity)) return false;- const updatedAt = entity.updatedAt- ? new Date(entity.updatedAt)- : undefined;- if (!updatedAt) return false;- const dayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);- return updatedAt > dayAgo;- },- },- {- id: 'doc-edited-this-week',- label: 'Edited This Week',- predicate: (entity) => {- if (!isDocumentEntity(entity)) return false;- const updatedAt = entity.updatedAt- ? new Date(entity.updatedAt)- : undefined;- if (!updatedAt) return false;- const weekAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);- return updatedAt > weekAgo;- },- },- {- id: 'in-folder',- label: 'In Folder',- predicate: (entity) => !!getEntityProjectId(entity),- },- {- id: 'doc-markdown',- label: 'Markdown',- predicate: (entity) => isDocumentEntity(entity) && entity.fileType === 'md',- },- {- id: 'doc-canvas',- label: 'Canvas',- predicate: (entity) =>- isDocumentEntity(entity) && entity.fileType === 'canvas',- },-];--export const CHANNEL_CONTEXTUAL_FILTERS: EntityFilterConfig[] = [- {- id: 'channel-recent-activity',- label: 'Recent Activity',- predicate: (entity) => {- if (!isChannelEntity(entity)) return false;- const interactedAt = entity.interactedAt- ? new Date(entity.interactedAt)- : undefined;- if (!interactedAt) return false;- const dayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);- return interactedAt > dayAgo;- },- },- {- id: 'channel-public',- label: 'Public',- predicate: (entity) =>- isChannelEntity(entity) && entity.channelType === 'public',- },- {- id: 'channel-private',- label: 'Private',- predicate: (entity) =>- isChannelEntity(entity) && entity.channelType === 'private',- },-];--export const CHAT_CONTEXTUAL_FILTERS: EntityFilterConfig[] = [- {- id: 'chat-recent',- label: 'Recent',- predicate: (entity) => {- if (!isChatEntity(entity)) return false;- const updatedAt = entity.updatedAt- ? new Date(entity.updatedAt)- : undefined;- if (!updatedAt) return false;- const dayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);- return updatedAt > dayAgo;- },- },-];--/**- * Agent ownership filter options for the filter bar.- * Note: The actual predicates are registered in createSoupFilters with getUserID closure.- * These are just the IDs and labels for building filter UI options.- */-export const AGENT_OWNERSHIP_FILTERS: readonly { id: string; label: string }[] =- [- { id: 'owned-agent', label: 'Owned by me' },- { id: 'shared-agent', label: 'Shared with me' },- ] as const;--export const GENERAL_CONTEXTUAL_FILTERS: EntityFilterConfig[] = [- {- id: 'recently-viewed',- label: 'Recently Viewed',- predicate: (entity) => {- const viewedAt = entity.viewedAt ? new Date(entity.viewedAt) : undefined;- if (!viewedAt) return false;- const hourAgo = new Date(Date.now() - 60 * 60 * 1000);- return viewedAt > hourAgo;- },- },- {- id: 'recently-created',- label: 'Recently Created',- predicate: (entity) => {- const createdAt = entity.createdAt- ? new Date(entity.createdAt)- : undefined;- if (!createdAt) return false;- const weekAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);- return createdAt > weekAgo;- },- },- {- id: 'recently-updated',- label: 'Recently Updated',- predicate: (entity) => {- const updatedAt = entity.updatedAt- ? new Date(entity.updatedAt)- : undefined;- if (!updatedAt) return false;- const dayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);- return updatedAt > dayAgo;- },- },- {- id: 'high-frecency',- label: 'Frequently Used',- predicate: (entity) => {- const score = entity.frecencyScore ?? 0;- return score > 100; // High frecency threshold- },- },-];--const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp'] as const;--export const FILE_TYPE_FILTERS: EntityFilterConfig[] = [- {- id: 'file-code',- label: 'Code',- predicate: (entity) => {- if (entity.type !== 'document') return false;- const fileType = entity.fileType ?? '';- return (codeFileExtensions as readonly string[]).includes(fileType);- },- },- {- id: 'file-image',- label: 'Images',- predicate: (entity) => {- if (entity.type !== 'document') return false;- const fileType = entity.fileType ?? '';- return (IMAGE_EXTENSIONS as readonly string[]).includes(fileType);- },- },- {- id: 'file-pdf',- label: 'PDFs',- predicate: (entity) => {- if (entity.type !== 'document') return false;- return entity.fileType === 'pdf';- },- },- {- id: 'file-other',- label: 'Other',- predicate: (entity) => {- if (entity.type !== 'document') return false;- const fileType = entity.fileType ?? '';- // Exclude markdown, canvas, code, images, and PDFs- if (['md', 'canvas'].includes(fileType)) return false;- if ((codeFileExtensions as readonly string[]).includes(fileType))- return false;- if ((IMAGE_EXTENSIONS as readonly string[]).includes(fileType))- return false;- if (fileType === 'pdf') return false;- return true;- },- },-];--export const createSoupFilters = (- notificationSource: NotificationSource,- getUserID: () => string | undefined-) => {- const list = [- // Focus filters (mutually exclusive)- {- id: 'signal',- label: 'Inbox',- predicate: signalFilter,- group: 'focus',- },- {- id: 'noise',- label: 'Other',- predicate: noiseFilter,- group: 'focus',- },- {- id: 'explicit-noise',- label: 'Explicit Noise',- predicate: (entity: EntityData) => !explicitNoiseFilter(entity),- group: 'focus',- },-- // Notification filters- {- id: 'unread',- label: 'Unread',- predicate: unreadFilter(notificationSource),- },- {- id: 'read',- label: 'Read',- predicate: (entity: EntityData) =>- !unreadFilter(notificationSource)(entity),- },- {- id: 'not-done',- label: 'Not done',- predicate: notDoneFilter(notificationSource),- },- {- id: 'done',- label: 'Done',- predicate: (entity: EntityData) =>- !notDoneFilter(notificationSource)(entity),- },- ...ENTITY_TYPE_FILTER_CONFIGS,- {- id: 'channels',- label: 'Channels',- predicate: channelsFilter,- },- {- id: 'file-folder',- label: 'Files & Folders',- predicate: filesAndFolderFilter,- },- {- id: 'folders',- label: 'Folders',- predicate: projectFilter,- },- {- id: 'active-agent',- label: 'Running agents',- predicate: activeAgentFilter,- },- {- id: 'email-drafts',- label: 'Email drafts',- predicate: emailDraftsFilter,- },- {- id: 'no-drafts',- label: 'No drafts',- predicate: noDraftsFilter,- },- {- id: 'has-calendar-invite',- label: 'Has calendar invite',- predicate: hasCalendarInviteFilter,- },- {- id: 'has-attachment',- label: 'Has attachment',- predicate: hasAttachmentFilter,- },- {- id: 'attachment-pdf',- label: 'PDF attachment',- predicate: hasPdfAttachmentFilter,- },- {- id: 'attachment-image',- label: 'Image attachment',- predicate: hasImageAttachmentFilter,- },- {- id: 'attachment-document',- label: 'Document attachment',- predicate: hasDocumentAttachmentFilter,- },- {- id: 'shared-entity',- label: 'Shared entities',- predicate: sharedEntity(getUserID),- },- {- id: 'owned-agent',- label: 'Owned by me',- predicate: ownedAgentFilter(getUserID),- },- {- id: 'shared-agent',- label: 'Shared with me',- predicate: sharedAgentFilter(getUserID),- },- {- id: 'assigned-to',- label: 'Task assigned to user',- predicate: taskAssignedToUserFilter(getUserID),- },- ...TASK_PRIORITY_FILTERS,- ...DOCUMENT_CONTEXTUAL_FILTERS,- ...CHANNEL_CONTEXTUAL_FILTERS,- ...CHAT_CONTEXTUAL_FILTERS,- ...FILE_TYPE_FILTERS,- ] as const satisfies EntityFilterConfig[];-- return list;-};--/**- * Default filter group configurations for soup filters.- * - 'focus': Mutually exclusive (signal/noise/explicit-noise)- * - 'entity-type': Mutually exclusive by default- */-export const SOUP_FILTER_GROUPS: FilterGroupConfig[] = [- { id: 'focus', allowMultiple: false },- { id: 'entity-type', allowMultiple: false },-];--type SoupFilter = ReturnType<typeof createSoupFilters>[number];--export type FilterID = Extract<SoupFilter, { id: string & {} }>['id'];--const ENTITY_TYPE_FILTERS = [- 'document',- 'task',- 'email',- 'people',- 'teams',- 'agent',- 'file',-] as const satisfies FilterID[];--type EntityTypeFilters = (typeof ENTITY_TYPE_FILTERS)[number];--const ENTITY_TYPE_TO_ICON_TYPE: Record<EntityTypeFilters, EntityWithValidIcon> =- {- document: 'md',- email: 'email',- task: 'task',- people: 'channel',- teams: 'direct_message',- agent: 'chat',- file: 'project',- };--export const getEntityTypeFilterIcon = (filter: EntityTypeFilters) => {- return getIconConfig(ENTITY_TYPE_TO_ICON_TYPE[filter]);-};--/**- * Mapping of entity type filter IDs to their animated icon components.- * Used to provide hover animations on filter buttons.- */-export const ANIMATED_ICONS: Partial<- Record<EntityTypeFilters, Component<{ triggerAnimation?: boolean }>>-> = {- document: AnimatedFileMdIcon,- agent: AnimatedStarIcon,- people: AnimatedChatIcon,- teams: AnimatedChannelIcon,- task: AnimatedTaskIcon,- email: AnimatedEmailIcon,- file: AnimatedFolderIcon,-};--export const FILE_ASSOCIATION_TYPES = [- 'code',- 'image',- 'pdf',- 'unknown',-] as const;--/** Expands file association types to file extensions for soup or search */-export const getFileAssociations = (type: 'soup' | 'search') => {- return FILE_ASSOCIATION_TYPES.flatMap((fileType) => {- if (fileType === 'code')- return type === 'soup' ? ['assoc:code'] : codeFileExtensions;- if (fileType === 'image')- return type === 'soup' ? ['assoc:image'] : [NIL_UUID];- if (fileType === 'unknown')- return type === 'soup' ? ['assoc:other'] : [NIL_UUID];- return [fileType];- });-};--export const QUERY_FILTERS = {- /** Docs filter - markdown and canvas documents (excludes tasks) */- document: {- channel_filters: { channel_ids: EXCLUDE },- chat_filters: { chat_ids: EXCLUDE },- email_filters: { recipients: EXCLUDE },- project_filters: { project_ids: EXCLUDE },- document_filters: { file_types: ['md', 'canvas'] },- },-- /** Tasks filter - markdown documents with task subType */- task: {- channel_filters: { channel_ids: EXCLUDE },- chat_filters: { chat_ids: EXCLUDE },- email_filters: { recipients: EXCLUDE },- project_filters: { project_ids: EXCLUDE },- document_filters: { file_types: ['md'] },- },-- /** Mail filter - emails */- email: {- channel_filters: { channel_ids: EXCLUDE },- chat_filters: { chat_ids: EXCLUDE },- document_filters: { document_ids: EXCLUDE },- project_filters: { project_ids: EXCLUDE },- email_filters: {},- },-- /** People filter - direct message channels */- people: {- chat_filters: { chat_ids: EXCLUDE },- document_filters: { document_ids: EXCLUDE },- email_filters: { recipients: EXCLUDE },- project_filters: { project_ids: EXCLUDE },- channel_filters: { channel_types: [ChannelTypeEnum.DirectMessage] },- },-- /** Teams filter - group channels (non-DM) */- teams: {- chat_filters: { chat_ids: EXCLUDE },- document_filters: { document_ids: EXCLUDE },- email_filters: { recipients: EXCLUDE },- project_filters: { project_ids: EXCLUDE },- channel_filters: {- channel_types: [- ChannelTypeEnum.Private,- ChannelTypeEnum.Organization,- ChannelTypeEnum.Public,- ],- },- },-- /** Agents filter - chats */- agent: {- channel_filters: { channel_ids: EXCLUDE },- document_filters: { document_ids: EXCLUDE },- email_filters: { recipients: EXCLUDE },- project_filters: { project_ids: EXCLUDE },- chat_filters: {},- },-- /** Files filter - non-markdown documents (code, images, pdfs, etc.) */- file: {- channel_filters: { channel_ids: EXCLUDE },- chat_filters: { chat_ids: EXCLUDE },- email_filters: { recipients: EXCLUDE },- document_filters: { file_types: getFileAssociations('soup') },- },-- /** Channels filter - all channels (teams and people) */- channels: {- chat_filters: { chat_ids: EXCLUDE },- document_filters: { document_ids: EXCLUDE },- email_filters: { recipients: EXCLUDE },- project_filters: { project_ids: EXCLUDE },- channel_filters: {},- },-- /** Default - include all entity types (no filter active) */- default: {},-} satisfies Record<string, SoupItemsQueryFilters>;--export type QueryFilterKey = keyof typeof QUERY_FILTERS;diff --git a/js/app/packages/app/component/next-soup/filters/signal-filters.ts b/js/app/packages/app/component/next-soup/filters/inbox-filters.tssimilarity index 74%rename from js/app/packages/app/component/next-soup/filters/signal-filters.tsrename to js/app/packages/app/component/next-soup/filters/inbox-filters.tsindex c51ec533b2..6b6105a1ca 100644--- a/js/app/packages/app/component/next-soup/filters/signal-filters.ts+++ b/js/app/packages/app/component/next-soup/filters/inbox-filters.ts@@ -6,37 +6,48 @@ import {type EntityData,} from '@entity';import { useUserId } from '@core/context/user';-import { createMemo } from 'solid-js';-import {- DEPRIORITY_LABEL_SIGNAL_TOGGLES,- PRIORITY_LABEL_SIGNAL_TOGGLES,-} from '@app/component/next-soup/filters/signal-configs';--/** Labels that indicate priority emails (signal) */-const PRIORITY_LABELS = createMemo(- () =>- new Set(- PRIORITY_LABEL_SIGNAL_TOGGLES.filter(({ enabled }) => enabled()).map(- ({ key }) => key- )- )-);--/** Labels that indicate depriority emails (noise) */-const DEPRIORITY_LABELS = createMemo(- () =>- new Set(- DEPRIORITY_LABEL_SIGNAL_TOGGLES.filter(({ enabled }) => enabled()).map(- ({ key }) => key- )- )-);--// ============================================================================-// Signal/Noise Configuration-// ============================================================================--/** Extract label tokens from email labels for matching */++const PRIORITY_LABELS = [+ {+ key: 'CATEGORY_PERSONAL',+ label: 'Personal',+ defaultValue: true,+ },+ {+ key: 'SENT',+ label: 'Sent',+ defaultValue: true,+ },+ {+ key: 'IMPORTANT',+ label: 'Important',+ defaultValue: false,+ },+];++const DEPRIORITY_LABELS = [+ {+ key: 'CATEGORY_UPDATES',+ label: 'Updates',+ defaultValue: true,+ },+ {+ key: 'CATEGORY_PROMOTIONS',+ label: 'Promotions',+ defaultValue: true,+ },+ {+ key: 'CATEGORY_SOCIAL',+ label: 'Social',+ defaultValue: true,+ },+ {+ key: 'CATEGORY_FORUMS',+ label: 'Forums',+ defaultValue: true,+ },+];+const getLabelTokens = (labels?: Array<{ id?: string; providerLabelId?: string; name?: string }>): string[] => {@@ -54,20 +65,19 @@ const getLabelTokens = (type EmailEntity = Extract<EntityData, { type: 'email' }>;-/** Analyze email for priority/depriority indicators */function getEmailSignalInfo(entity: EmailEntity): {hasPriority: boolean;hasDepriority: boolean;} {const labelTokens = getLabelTokens(entity.labels);- const priorityLabels = PRIORITY_LABELS();- const depriorityLabels = DEPRIORITY_LABELS();+ const priorityLabels = PRIORITY_LABELS;+ const depriorityLabels = DEPRIORITY_LABELS;- const hasPriorityLabel = labelTokens.some((label) =>- priorityLabels.has(label)+ const hasPriorityLabel = priorityLabels.some((label) =>+ labelTokens.includes(label.key));- const hasDeprioritizingLabel = labelTokens.some((label) =>- depriorityLabels.has(label)+ const hasDeprioritizingLabel = depriorityLabels.some((label) =>+ labelTokens.includes(label.key));return {diff --git a/js/app/packages/app/component/next-soup/filters/index.ts b/js/app/packages/app/component/next-soup/filters/index.tsindex dbcb57d8fd..f620e6bddc 100644--- a/js/app/packages/app/component/next-soup/filters/index.ts+++ b/js/app/packages/app/component/next-soup/filters/index.ts@@ -1,32 +1,8 @@-export {- agentFilter,- documentFilter,- emailFilter,- fileFilter,- notDoneFilter,- peopleFilter,- projectFilter,- taskFilter,- teamsFilter,- unreadFilter,- createSoupFilters,- SOUP_FILTER_GROUPS,- TASK_STATUS_FILTERS,- TASK_PRIORITY_FILTERS,- TASK_ASSIGNEE_FILTERS,- TASK_CONTEXTUAL_FILTERS,- DOCUMENT_CONTEXTUAL_FILTERS,- CHANNEL_CONTEXTUAL_FILTERS,- CHAT_CONTEXTUAL_FILTERS,- FILE_TYPE_FILTERS,- type FilterID,-} from './filters';-export {noiseFilter,signalFilter,explicitNoiseFilter,-} from './signal-filters';+} from './inbox-filters';export {createFilterState,@@ -39,3 +15,10 @@ export {type FilterGroupConfig,type FilterPredicate,} from './create-filter-state';++export {+ createSoupFilters,+ SOUP_FILTER_GROUPS,+ ENTITY_TYPE_FILTER_CONFIGS,+ type FilterID,+} from './configs';diff --git a/js/app/packages/app/component/next-soup/filters/predicates.ts b/js/app/packages/app/component/next-soup/filters/predicates.tsnew file mode 100644index 0000000000..09a086d93f--- /dev/null+++ b/js/app/packages/app/component/next-soup/filters/predicates.ts@@ -0,0 +1,307 @@+import { PROPERTY_OPTION_IDS } from '@core/component/Properties/constants';+import {+ type WithNotification,+ type EntityData,+ isTaskEntity,+ type TaskEntityWithProperties,+ getTaskAssigneeIds,+ getTaskStatusOptionId,+} from '@entity';+import { getTaskPriorityOptionId } from '@entity/utils/task-properties';+import { type NotificationSource, compositeEntity } from '@notifications';++/**+ * Unread filter - entity has unread content.+ *+ * Entity-specific logic:+ * - Emails: Uses `isRead` boolean field+ * - Everything else: Has at least one notification with viewedAt === null+ */+export function unreadFilter(notificationSource: NotificationSource) {+ return function (entity: EntityData): boolean {+ if (entity.type === 'email') {+ return !entity.isRead;+ }+ const notifications =+ notificationSource.notificationsByEntity()[compositeEntity(entity)];++ return notifications?.some((n) => !n.viewed_at) ?? false;+ };+}++/**+ * NotDone filter - entity has outstanding items.+ *+ * Entity-specific logic:+ * - Emails: Uses `done` field (derived from !inboxVisible - email is "not done" when in inbox)+ * - Everything else: Has at least one notification with done === false+ */+export function notDoneFilter(notificationSource: NotificationSource) {+ return function (entity: WithNotification<EntityData>) {+ if (entity.type === 'email') return !entity.done;+ // Tasks are handled by signalFilter based on assignee/status, not notifications+ if (isTaskEntity(entity)) return true;++ const notifications =+ notificationSource.notificationsByEntity()[compositeEntity(entity)];++ return notifications?.some(({ done }) => !done);+ };+}++/** Document filter (markdown, canvas) - excludes tasks */+export function documentFilter(entity: EntityData): boolean {+ if (entity.type !== 'document') return false;+ if (entity.subType?.type === 'task') return false;+ const fileType = entity.fileType ?? '';+ return fileType === 'md' || fileType === 'canvas';+}++export function taskFilter(entity: EntityData): boolean {+ return entity.type === 'document' && entity.subType?.type === 'task';+}++export function emailFilter(entity: EntityData): boolean {+ return entity.type === 'email';+}++export function peopleFilter(entity: EntityData): boolean {+ return entity.type === 'channel' && entity.channelType === 'direct_message';+}++export function teamsFilter(entity: EntityData): boolean {+ return entity.type === 'channel' && entity.channelType !== 'direct_message';+}++export function agentFilter(entity: EntityData): boolean {+ return entity.type === 'chat';+}++export function projectFilter(entity: EntityData): boolean {+ return entity.type === 'project';+}++export function fileFilter(entity: EntityData): boolean {+ if (entity.type !== 'document') return false;+ const fileType = entity.fileType ?? '';+ return !['md', 'canvas'].includes(fileType);+}++export function channelsFilter(entity: EntityData): boolean {+ return entity.type === 'channel';+}++export function filesAndFolderFilter(entity: EntityData): boolean {+ if (entity.type !== 'project' && entity.type !== 'document') return false;++ if (entity.type === 'document') {+ const fileType = entity.fileType ?? '';+ return !['md', 'canvas'].includes(fileType);+ }++ return true;+}++export function activeAgentFilter(entity: EntityData): boolean {+ if (entity.type !== 'chat') return false;++ // [TODO] Check status of agent+ return true;+}++export function emailDraftsFilter(entity: EntityData): boolean {+ if (entity.type !== 'email') return false;++ return entity.isDraft;+}++export function noDraftsFilter(entity: EntityData): boolean {+ if (entity.type !== 'email') return false;++ return !entity.isDraft;+}++export function hasCalendarInviteFilter(entity: EntityData): boolean {+ if (entity.type !== 'email') return false;++ return entity.hasIcsAttachment === true;+}++const ICS_MIME_TYPE = 'application/ics';++export function hasAttachmentFilter(entity: EntityData): boolean {+ if (entity.type !== 'email') return false;++ const filteredAttachments = entity.attachments?.filter(+ (a) => a.mimeType !== ICS_MIME_TYPE+ );++ return (filteredAttachments?.length ?? 0) > 0;+}++const PDF_MIME_TYPES = ['application/pdf'];+const IMAGE_MIME_TYPES = [+ 'image/png',+ 'image/jpeg',+ 'image/gif',+ 'image/webp',+ 'image/svg+xml',+];+const DOCUMENT_MIME_TYPES = [+ 'application/msword',+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',+ 'application/vnd.ms-excel',+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',+ 'application/vnd.ms-powerpoint',+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation',+ 'text/plain',+ 'text/csv',+];++function hasAttachmentOfType(entity: EntityData, mimeTypes: string[]): boolean {+ if (entity.type !== 'email') return false;+ if (!entity.attachments?.length) return false;++ return entity.attachments.some((a) => {+ if (!a.mimeType) return false;+ return mimeTypes.some((type) => a.mimeType?.startsWith(type));+ });+}++export function hasPdfAttachmentFilter(entity: EntityData): boolean {+ return hasAttachmentOfType(entity, PDF_MIME_TYPES);+}++export function hasImageAttachmentFilter(entity: EntityData): boolean {+ return hasAttachmentOfType(entity, IMAGE_MIME_TYPES);+}++export function hasDocumentAttachmentFilter(entity: EntityData): boolean {+ return hasAttachmentOfType(entity, DOCUMENT_MIME_TYPES);+}++export function sharedEntity(getUserID: () => string | undefined) {+ return function (entity: EntityData): boolean {+ const userID = getUserID();+ if (userID == null) return false;++ return entity.ownerId !== userID;+ };+}++export function ownedAgentFilter(getUserID: () => string | undefined) {+ return function (entity: EntityData): boolean {+ if (entity.type !== 'chat') return false;+ const userID = getUserID();+ if (userID == null) return false;++ return entity.ownerId === userID;+ };+}++export function sharedAgentFilter(getUserID: () => string | undefined) {+ return function (entity: EntityData): boolean {+ if (entity.type !== 'chat') return false;+ const userID = getUserID();+ if (userID == null) return false;++ return entity.ownerId !== userID;+ };+}++export function taskAssignedToUserFilter(getUserID: () => string | undefined) {+ return function (entity: EntityData): boolean {+ const userID = getUserID();+ if (!isTaskEntity(entity) || userID == null) return false;++ const taskEntity = entity as unknown as TaskEntityWithProperties;+ return getTaskAssigneeIds(taskEntity).includes(userID);+ };+}++export function hasAssignees(entity: EntityData): boolean {+ if (!isTaskEntity(entity)) return false;+ return getTaskAssigneeIds(entity).length > 0;+}++export function isAssignedTo(entity: EntityData, userId: string): boolean {+ if (!isTaskEntity(entity)) return false;++ const assigneeIds = getTaskAssigneeIds(entity);+ // If no assignees, consider it assigned to everyone (or unassigned)+ if (assigneeIds.length === 0) return false;+ return assigneeIds.includes(userId);+}++export function isUnassigned(entity: EntityData): boolean {+ if (!isTaskEntity(entity)) return false;+ return getTaskAssigneeIds(entity).length === 0;+}++export function hasStatus(entity: EntityData, statusOptionId: string): boolean {+ if (!isTaskEntity(entity)) return false;+ return getTaskStatusOptionId(entity) === statusOptionId;+}++export function isNotStarted(entity: EntityData): boolean {+ return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.NOT_STARTED);+}++export function isInProgress(entity: EntityData): boolean {+ return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS);+}++export function isInReview(entity: EntityData): boolean {+ return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.IN_REVIEW);+}++export function isCompleted(entity: EntityData): boolean {+ if (!isTaskEntity(entity)) return false;+ // Check both the subType flag and status property+ if (entity.subType?.is_completed) return true;+ return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.COMPLETED);+}++export function isCanceled(entity: EntityData): boolean {+ return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.CANCELED);+}++export function isClosed(entity: EntityData): boolean {+ return isCompleted(entity) || isCanceled(entity);+}++export function isOpen(entity: EntityData): boolean {+ if (!isTaskEntity(entity)) return false;+ return !isClosed(entity);+}++export function hasPriority(+ entity: EntityData,+ priorityOptionId: string+): boolean {+ if (!isTaskEntity(entity)) return false;++ return getTaskPriorityOptionId(entity) === priorityOptionId;+}++export function isUrgentPriority(entity: EntityData): boolean {+ return hasPriority(entity, PROPERTY_OPTION_IDS.PRIORITY.URGENT);+}++export function isHighPriority(entity: EntityData): boolean {+ return hasPriority(entity, PROPERTY_OPTION_IDS.PRIORITY.HIGH);+}++export function isMediumPriority(entity: EntityData): boolean {+ return hasPriority(entity, PROPERTY_OPTION_IDS.PRIORITY.MEDIUM);+}++export function isLowPriority(entity: EntityData): boolean {+ return hasPriority(entity, PROPERTY_OPTION_IDS.PRIORITY.LOW);+}++export function hasNoPriority(entity: EntityData): boolean {+ if (!isTaskEntity(entity)) return false;++ return getTaskPriorityOptionId(entity) === undefined;+}diff --git a/js/app/packages/app/component/next-soup/filters/query-filters.ts b/js/app/packages/app/component/next-soup/filters/query-filters.tsnew file mode 100644index 0000000000..623e199995--- /dev/null+++ b/js/app/packages/app/component/next-soup/filters/query-filters.ts@@ -0,0 +1,148 @@+import { codeFileExtensions } from '@block-code/util/languageSupport';+import type { SoupItemsQueryFilters, SoupBody } from '@queries/soup/items';+import { ChannelTypeEnum } from '@service-comms/client';+import type { SoupApiItem } from '@service-storage/generated/schemas';+import { match } from 'ts-pattern';++export const NIL_UUID = '00000000-0000-0000-0000-000000000000';++export const EXCLUDE: string[] = [NIL_UUID];++// Base filter that excludes all entity types by default+export const QUERY_FILTERS_BASE: SoupItemsQueryFilters = {+ channel_filters: { channel_ids: EXCLUDE },+ chat_filters: { chat_ids: EXCLUDE },+ document_filters: { document_ids: EXCLUDE },+ email_filters: { recipients: EXCLUDE },+ project_filters: { project_ids: EXCLUDE },+};++function isIdFilteredOut(ids: string[] | undefined, value: string): boolean {+ if (!ids || ids.length === 0) return false;+ return !ids.includes(value);+}++// TODO: this only supports for item type and id filters, other filters to be added later+export function filterSoupItemByRequestBody(+ item: SoupApiItem,+ body: SoupBody+): boolean {+ return match(item)+ .with(+ { tag: 'document' },+ ({ data }) =>+ !isIdFilteredOut(body.document_filters?.document_ids, data.id)+ )+ .with(+ { tag: 'chat' },+ ({ data }) => !isIdFilteredOut(body.chat_filters?.chat_ids, data.id)+ )+ .with(+ { tag: 'channel' },+ ({ data }) =>+ !isIdFilteredOut(body.channel_filters?.channel_ids, data.channel.id)+ )+ .with(+ { tag: 'project' },+ ({ data }) => !isIdFilteredOut(body.project_filters?.project_ids, data.id)+ )+ .with(+ { tag: 'emailThread' },+ ({ data }) =>+ !isIdFilteredOut(body.email_filters?.email_thread_ids, data.id)+ )+ .exhaustive();+}++export const FILE_ASSOCIATION_TYPES = [+ 'code',+ 'image',+ 'pdf',+ 'unknown',+] as const;++/** Expands file association types to file extensions for soup or search */+export const getFileAssociations = (type: 'soup' | 'search') => {+ return FILE_ASSOCIATION_TYPES.flatMap((fileType) => {+ if (fileType === 'code')+ return type === 'soup' ? ['assoc:code'] : codeFileExtensions;+ if (fileType === 'image')+ return type === 'soup' ? ['assoc:image'] : [NIL_UUID];+ if (fileType === 'unknown')+ return type === 'soup' ? ['assoc:other'] : [NIL_UUID];+ return [fileType];+ });+};++export const QUERY_FILTERS = {+ document: {+ channel_filters: { channel_ids: EXCLUDE },+ chat_filters: { chat_ids: EXCLUDE },+ email_filters: { recipients: EXCLUDE },+ project_filters: { project_ids: EXCLUDE },+ document_filters: { file_types: ['md', 'canvas'] },+ },++ task: {+ channel_filters: { channel_ids: EXCLUDE },+ chat_filters: { chat_ids: EXCLUDE },+ email_filters: { recipients: EXCLUDE },+ project_filters: { project_ids: EXCLUDE },+ document_filters: { file_types: ['md'] },+ },++ email: {+ channel_filters: { channel_ids: EXCLUDE },+ chat_filters: { chat_ids: EXCLUDE },+ document_filters: { document_ids: EXCLUDE },+ project_filters: { project_ids: EXCLUDE },+ email_filters: {},+ },++ people: {+ chat_filters: { chat_ids: EXCLUDE },+ document_filters: { document_ids: EXCLUDE },+ email_filters: { recipients: EXCLUDE },+ project_filters: { project_ids: EXCLUDE },+ channel_filters: { channel_types: [ChannelTypeEnum.DirectMessage] },+ },++ teams: {+ chat_filters: { chat_ids: EXCLUDE },+ document_filters: { document_ids: EXCLUDE },+ email_filters: { recipients: EXCLUDE },+ project_filters: { project_ids: EXCLUDE },+ channel_filters: {+ channel_types: [+ ChannelTypeEnum.Private,+ ChannelTypeEnum.Organization,+ ChannelTypeEnum.Public,+ ],+ },+ },++ agent: {+ channel_filters: { channel_ids: EXCLUDE },+ document_filters: { document_ids: EXCLUDE },+ email_filters: { recipients: EXCLUDE },+ project_filters: { project_ids: EXCLUDE },+ chat_filters: {},+ },++ file: {+ channel_filters: { channel_ids: EXCLUDE },+ chat_filters: { chat_ids: EXCLUDE },+ email_filters: { recipients: EXCLUDE },+ document_filters: { file_types: getFileAssociations('soup') },+ },++ channels: {+ chat_filters: { chat_ids: EXCLUDE },+ document_filters: { document_ids: EXCLUDE },+ email_filters: { recipients: EXCLUDE },+ project_filters: { project_ids: EXCLUDE },+ channel_filters: {},+ },++ default: {},+} satisfies Record<string, SoupItemsQueryFilters>;diff --git a/js/app/packages/app/component/next-soup/filters/signal-configs.ts b/js/app/packages/app/component/next-soup/filters/signal-configs.tsdeleted file mode 100644index a7334c4f94..0000000000--- a/js/app/packages/app/component/next-soup/filters/signal-configs.ts+++ /dev/null@@ -1,81 +0,0 @@-import { makePersisted } from '@solid-primitives/storage';-import { createSignal } from 'solid-js';--type SignalConfig<T extends string> = {- key: T;- label: string;- defaultValue: boolean;-};--type SignalToggle<T extends string> = SignalConfig<T> & {- enabled: () => boolean;- setEnabled: (value: boolean) => void;-};--const makeToggle = (storageKey: string, defaultValue: boolean) =>- makePersisted(createSignal(defaultValue), { name: storageKey });--const toStorageKey = (scope: string, key: string) =>- `signalFilter_${scope}_${key.toLowerCase().replace(/[^a-z0-9]+/g, '_')}`;--const createSignalToggles = <T extends string>(- scope: string,- configs: SignalConfig<T>[]-): SignalToggle<T>[] =>- configs.map((config) => {- const [enabled, setEnabled] = makeToggle(- toStorageKey(scope, config.key),- config.defaultValue- );- return { ...config, enabled, setEnabled };- });--const PRIORITY_LABEL_SIGNAL_CONFIGS: SignalConfig<string>[] = [- {- key: 'CATEGORY_PERSONAL',- label: 'Personal',- defaultValue: true,- },- {- key: 'SENT',- label: 'Sent',- defaultValue: true,- },- {- key: 'IMPORTANT',- label: 'Important',- defaultValue: false,- },-];--const DEPRIORITY_LABEL_SIGNAL_CONFIGS: SignalConfig<string>[] = [- {- key: 'CATEGORY_UPDATES',- label: 'Updates',- defaultValue: true,- },- {- key: 'CATEGORY_PROMOTIONS',- label: 'Promotions',- defaultValue: true,- },- {- key: 'CATEGORY_SOCIAL',- label: 'Social',- defaultValue: true,- },- {- key: 'CATEGORY_FORUMS',- label: 'Forums',- defaultValue: true,- },-];--export const PRIORITY_LABEL_SIGNAL_TOGGLES = createSignalToggles(- 'priority_label',- PRIORITY_LABEL_SIGNAL_CONFIGS-);-export const DEPRIORITY_LABEL_SIGNAL_TOGGLES = createSignalToggles(- 'depriority_label',- DEPRIORITY_LABEL_SIGNAL_CONFIGS-);diff --git a/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts b/js/app/packages/app/component/next-soup/soup-view/create-search-state.tsindex 31efd77bd2..7a207ed6fb 100644--- a/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts+++ b/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts@@ -1,8 +1,6 @@import type { SoupState } from '@app/component/next-soup/create-soup-state';-import {- type FilterID,- getFileAssociations,-} from '@app/component/next-soup/filters/filters';+import type { FilterID } from '@app/component/next-soup/filters/configs';+import { getFileAssociations } from '@app/component/next-soup/filters/query-filters';import { useSearchContext } from '@app/component/next-soup/search-context';import {createSoupFreshSearch,diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-controls.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-controls.tsxindex a69b9f57e4..fae004a45a 100644--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-controls.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-controls.tsx@@ -14,12 +14,11 @@ import { NO_ASSIGNEE } from '@app/component/next-soup/soup-view/task-sub-filter-import { PropertyValueIcon } from '@core/component/Properties/component/propertyValue/PropertyValueIcon';import { PROPERTY_OPTION_IDS } from '@core/component/Properties/constants';import { EntityIcon } from '@core/component/EntityIcon';-import { TASK_STATUS_OPTIONS } from '@entity';import { useProjectsQuery } from '@queries/storage/projects';import {getFileAssociations,QUERY_FILTERS_BASE,-} from '@app/component/next-soup/filters/filters';+} from '@app/component/next-soup/filters/query-filters';import { ChannelTypeEnum } from '@service-comms/client';import type { ChannelType } from '@service-comms/generated/models';import type { SoupItemsQueryFilters } from '@queries/soup/items';@@ -31,6 +30,7 @@ import {} from './filter-primitives';import { useFilterOptions } from './use-filter-options';import { useQuickAccess } from '@core/context/quickAccess';+import { TASK_STATUS_FILTERS } from '@app/component/next-soup/filters/configs';export const AssigneeFilter = () => {const { assigneeFilter, setAssigneeFilter } = useSoupView();@@ -349,30 +349,34 @@ export const DocumentFolderFilter = () => {return <FolderFilter target="document" label="Folder" />;};-export const TaskStatusFilter = () => {- const { statusFilter, setStatusFilter } = useSoupView();+const STATUS_FILTER_PROPERTY_ID = {+ 'task-not-started': PROPERTY_OPTION_IDS.STATUS.NOT_STARTED,+ 'task-in-progress': PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS,+ 'task-in-review': PROPERTY_OPTION_IDS.STATUS.IN_REVIEW,+ 'task-completed': PROPERTY_OPTION_IDS.STATUS.COMPLETED,+ 'task-canceled': PROPERTY_OPTION_IDS.STATUS.CANCELED,+} satisfies Record<(typeof TASK_STATUS_FILTERS)[number]['id'], string>;- const statusOptions: Option[] = TASK_STATUS_OPTIONS.map((o) => ({- value: o.value,- label: o.label,- icon: () => <PropertyValueIcon optionId={o.value} class="size-3.5" />,+export const TaskStatusFilter = () => {+ const statusOptions = TASK_STATUS_FILTERS.map((o) => ({+ value: o.id,+ label: o.label ?? 'Unknown status',+ icon: () => (+ <PropertyValueIcon+ optionId={STATUS_FILTER_PROPERTY_ID[o.id]}+ class="size-3.5"+ />+ ),}));- const activeStatus = createMemo((): Option[] => {- const current = statusFilter();- return statusOptions.filter((o) => current.includes(o.value));- });-- const handleStatusChange = (options: Option[]) => {- setStatusFilter(options.map((o) => o.value));- };+ const status = useFilterOptions(statusOptions, { target: 'or' });return (<FilterSelectlabel="Status"options={statusOptions}- active={activeStatus()}- onChange={handleStatusChange}+ active={status.active()}+ onChange={status.onChange}/>);};diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.ts b/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.tsindex 4aec03672d..1445acce12 100644--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.ts+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.ts@@ -2,7 +2,7 @@ import {VIEW_TAB_PRESETS,type PresetContext,} from '@app/component/app-sidebar/soup-filter-presets';-import type { FilterID } from '@app/component/next-soup/filters/filters';+import type { FilterID } from '@app/component/next-soup/filters/configs';import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';import { isListViewID } from '@app/constants/list-views';@@ -19,8 +19,6 @@ export function useFilterRefinements() {soup,queryFilters,setQueryFilters,- statusFilter,- setStatusFilter,assigneeFilter,setAssigneeFilter,activeTab,@@ -72,8 +70,7 @@ export function useFilterRefinements() {const hasQueryFilterDiff = !deepEqual(queryFilters(), preset.queryFilters);- const hasSubFilters =- statusFilter().length > 0 || assigneeFilter().length > 0;+ const hasSubFilters = assigneeFilter().length > 0;return hasClientFilterDiff || hasQueryFilterDiff || hasSubFilters;});@@ -85,7 +82,6 @@ export function useFilterRefinements() {batch(() => {soup.filters.set(preset.clientFilters);setQueryFilters(preset.queryFilters);- setStatusFilter([]);setAssigneeFilter([]);});};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 39d51fc154..d5391d7250 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@@ -74,8 +74,6 @@ interface SoupViewContextValues {isLocalSearchSettling: Accessor<boolean>;queryFilters: Accessor<SoupBody>;setQueryFilters: Setter<SoupBody>;- statusFilter: Accessor<string[]>;- setStatusFilter: Setter<string[]>;assigneeFilter: Accessor<string[]>;setAssigneeFilter: Setter<string[]>;activeTab: Accessor<string | undefined>;@@ -136,14 +134,12 @@ export const SoupViewContextProvider: FlowComponent<const [internalQueryFilters, setInternalQueryFilters] =createSignal<SoupBody>({ ...(props.queryFilters ?? {}) });- const [statusFilter, setStatusFilter] = createSignal<string[]>([]);const [assigneeFilter, setAssigneeFilter] = createSignal<string[]>([]);const [activeTab, setActiveTab] = createSignal<string | undefined>(undefined);// Clear sub-filters when task filter is deactivatedcreateEffect(() => {if (!soup.filters.isActive('task')) {- setStatusFilter([]);setAssigneeFilter([]);}});@@ -279,7 +275,6 @@ export const SoupViewContextProvider: FlowComponent<const next = [];- const currentStatusFilter = statusFilter();const currentAssigneeFilter = assigneeFilter();for (const entity of transformed) {@@ -288,14 +283,10 @@ export const SoupViewContextProvider: FlowComponent<}// Apply task sub-filters- if (- (currentStatusFilter.length > 0 || currentAssigneeFilter.length > 0) &&- isTaskEntity(entity)- ) {+ if (currentAssigneeFilter.length > 0 && isTaskEntity(entity)) {const taskEntity = entity as unknown as TaskEntityWithProperties;if (!matchesTaskSubFilters(taskEntity, {- statusFilter: currentStatusFilter,assigneeFilter: currentAssigneeFilter,})) {@@ -377,8 +368,6 @@ export const SoupViewContextProvider: FlowComponent<isLocalSearchSettling: search.isLocalSearchSettling,queryFilters,setQueryFilters,- statusFilter,- setStatusFilter,assigneeFilter,setAssigneeFilter,activeTab,diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsxindex 8c3c2eea7f..2e8429d5b8 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx@@ -2,7 +2,7 @@ import {VIEW_TAB_PRESETS,type PresetContext,} from '@app/component/app-sidebar/soup-filter-presets';-import type { FilterID } from '@app/component/next-soup/filters/filters';+import type { FilterID } from '@app/component/next-soup/filters/configs';import type { SoupItemsQueryFilters } from '@queries/soup/items';import { useSoup } from '@app/component/next-soup/soup-context';import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsxindex 67252b5e1d..a683124c9d 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx@@ -79,7 +79,7 @@ import { isMobile } from '@core/mobile/isMobile';import type { SystemSortOption } from '@app/component/next-soup/soup-view/sort-options';import { usePropertyEditorHotkeys } from '@app/component/property-edit-modal/hooks/usePropertyEditorHotkeys';import type { SoupItemsQueryFilters } from '@queries/soup/items';-import type { FilterID } from '@app/component/next-soup/filters/filters';+import type { FilterID } from '@app/component/next-soup/filters';import {SoupViewTabs,useApplyPreset,diff --git a/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.test.ts b/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.test.tsindex 6c28fbee15..dd7c0569b4 100644--- a/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.test.ts+++ b/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.test.ts@@ -1,8 +1,5 @@import { describe, expect, it } from 'vitest';-import {- PROPERTY_OPTION_IDS,- SYSTEM_PROPERTY_IDS,-} from '@core/component/Properties/constants';+import { SYSTEM_PROPERTY_IDS } from '@core/component/Properties/constants';import type { SoupProperty } from '@service-storage/generated/schemas';import type { TaskEntityWithProperties } from '@entity/types/entity';import { matchesTaskSubFilters, NO_ASSIGNEE } from './task-sub-filter-matcher';@@ -32,39 +29,6 @@ const createTask = (props?: {};describe('matchesTaskSubFilters', () => {- it('keeps tasks without properties when sub-filters are active', () => {- const task = createTask();-- expect(- matchesTaskSubFilters(task, {- statusFilter: [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS],- })- ).toBe(true);-- expect(- matchesTaskSubFilters(task, {- assigneeFilter: ['user-1'],- })- ).toBe(true);- });-- it('filters out tasks with non-matching status when properties exist', () => {- const task = createTask({- properties: [- createSoupProperty(SYSTEM_PROPERTY_IDS.STATUS, {- type: 'SelectOption',- value: [PROPERTY_OPTION_IDS.STATUS.IN_REVIEW],- }),- ],- });-- expect(- matchesTaskSubFilters(task, {- statusFilter: [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS],- })- ).toBe(false);- });-it('filters out tasks with non-matching assignee when properties exist', () => {const task = createTask({properties: [@@ -82,72 +46,6 @@ describe('matchesTaskSubFilters', () => {).toBe(false);});- it('keeps tasks when status and assignee both match', () => {- const task = createTask({- properties: [- createSoupProperty(SYSTEM_PROPERTY_IDS.STATUS, {- type: 'SelectOption',- value: [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS],- }),- createSoupProperty(SYSTEM_PROPERTY_IDS.ASSIGNEES, {- type: 'EntityReference',- value: [{ entity_type: 'USER', entity_id: 'user-1' }],- }),- ],- });-- expect(- matchesTaskSubFilters(task, {- statusFilter: [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS],- assigneeFilter: ['user-1'],- })- ).toBe(true);- });-- it('matches any status when multiple statuses are in filter', () => {- const taskInProgress = createTask({- properties: [- createSoupProperty(SYSTEM_PROPERTY_IDS.STATUS, {- type: 'SelectOption',- value: [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS],- }),- ],- });-- const taskInReview = createTask({- properties: [- createSoupProperty(SYSTEM_PROPERTY_IDS.STATUS, {- type: 'SelectOption',- value: [PROPERTY_OPTION_IDS.STATUS.IN_REVIEW],- }),- ],- });-- const taskDone = createTask({- properties: [- createSoupProperty(SYSTEM_PROPERTY_IDS.STATUS, {- type: 'SelectOption',- value: [PROPERTY_OPTION_IDS.STATUS.COMPLETED],- }),- ],- });-- const multiStatusFilter = [- PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS,- PROPERTY_OPTION_IDS.STATUS.IN_REVIEW,- ];-- expect(- matchesTaskSubFilters(taskInProgress, { statusFilter: multiStatusFilter })- ).toBe(true);- expect(- matchesTaskSubFilters(taskInReview, { statusFilter: multiStatusFilter })- ).toBe(true);- expect(- matchesTaskSubFilters(taskDone, { statusFilter: multiStatusFilter })- ).toBe(false);- });-it('matches any assignee when multiple assignees are in filter', () => {const taskUser1 = createTask({properties: [@@ -189,21 +87,6 @@ describe('matchesTaskSubFilters', () => {).toBe(false);});- it('treats empty arrays the same as undefined filters', () => {- const task = createTask({- properties: [- createSoupProperty(SYSTEM_PROPERTY_IDS.STATUS, {- type: 'SelectOption',- value: [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS],- }),- ],- });-- expect(- matchesTaskSubFilters(task, { statusFilter: [], assigneeFilter: [] })- ).toBe(true);- });-it('matches unassigned tasks when NO_ASSIGNEE filter is active', () => {const taskWithNoAssignees = createTask({properties: [diff --git a/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.ts b/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.tsindex 5470f782f1..690f180899 100644--- a/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.ts+++ b/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.ts@@ -1,13 +1,9 @@-import {- getTaskAssigneeIds,- getTaskStatusOptionId,-} from '@entity/utils/task-properties';+import { getTaskAssigneeIds } from '@entity/utils/task-properties';import type { TaskEntityWithProperties } from '@entity/types/entity';export const NO_ASSIGNEE = 'NO_ASSIGNEE';type TaskSubFilters = {- statusFilter?: string[];assigneeFilter?: string[];};@@ -15,12 +11,11 @@ export const matchesTaskSubFilters = (taskEntity: TaskEntityWithProperties,filters: TaskSubFilters): boolean => {- const { statusFilter, assigneeFilter } = filters;+ const { assigneeFilter } = filters;- const hasStatusFilter = statusFilter && statusFilter.length > 0;const hasAssigneeFilter = assigneeFilter && assigneeFilter.length > 0;- if (!hasStatusFilter && !hasAssigneeFilter) {+ if (!hasAssigneeFilter) {return true;}@@ -30,13 +25,6 @@ export const matchesTaskSubFilters = (return true;}- if (hasStatusFilter) {- const taskStatus = getTaskStatusOptionId(taskEntity);- if (!taskStatus || !statusFilter.includes(taskStatus)) {- return false;- }- }-if (hasAssigneeFilter) {const taskAssignees = getTaskAssigneeIds(taskEntity);const includesNoAssignee = assigneeFilter.includes(NO_ASSIGNEE);diff --git a/js/app/packages/app/component/next-soup/soup-view/task-sub-filters.tsx b/js/app/packages/app/component/next-soup/soup-view/task-sub-filters.tsxdeleted file mode 100644index e2ad722f3f..0000000000--- a/js/app/packages/app/component/next-soup/soup-view/task-sub-filters.tsx+++ /dev/null@@ -1,208 +0,0 @@-import {- type Accessor,- type Component,- type ParentProps,- Show,-} from 'solid-js';-import { Popover } from '@kobalte/core/popover';-import { TASK_STATUS_OPTIONS } from '@entity';-import { PropertyValueIcon } from '@core/component/Properties/component/propertyValue/PropertyValueIcon';-import { PropertyOptionSelector } from '@core/component/Properties/component/modal/shared/PropertyOptionSelector';-import { PropertyEntitySelector } from '@core/component/Properties/component/modal/shared/PropertyEntitySelector';-import type { SelectableOption } from '@core/component/Properties/component/modal/shared/types';-import { UserIcon } from '@core/component/UserIcon';-import { useContacts } from '@queries/contacts/contacts';-import { useUserId } from '@core/context/user';-import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';-import UserCircleIcon from '@icon/regular/user-circle.svg';-import CaretDownIcon from '@icon/regular/caret-down.svg';-import XIcon from '@icon/regular/x.svg?component-solid';-import CircleDashedIcon from '@icon/regular/circle-dashed.svg';--type DropdownProps = {- open: () => boolean;- onOpenChange: (isOpen: boolean) => void;-};--const statusOptions: SelectableOption[] = TASK_STATUS_OPTIONS.map((o) => ({- id: o.value,- label: o.label,-}));--function FilterTrigger(- props: ParentProps<{- filter: Accessor<string[]>;- }>-) {- const hasFilter = () => props.filter().length > 0;- return (- <Popover.Trigger- as="button"- type="button"- class="flex items-center gap-1 h-[22px] touch:mobile-width:h-9 px-2.5 shrink-0 rounded-full active:bg-accent/20 text-xs"- classList={{- 'bg-accent/20 text-accent': hasFilter(),- 'text-ink-muted hover:text-accent hover:bg-accent/20': !hasFilter(),- }}- >- {props.children}- </Popover.Trigger>- );-}--export const TaskStatusDropdown: Component<DropdownProps> = (props) => {- const { statusFilter, setStatusFilter } = useSoupView();- const open = () => props.open();- const setOpen = (v: boolean) => props.onOpenChange(v);-- const hasFilter = () => statusFilter().length > 0;-- const activeLabel = () => {- const filters = statusFilter();- if (filters.length === 0) return 'Status';- if (filters.length === 1) {- return (- TASK_STATUS_OPTIONS.find((o) => o.value === filters[0])?.label ??- 'Status'- );- }- return `${filters.length} statuses`;- };-- const toggleOption = (id: string) => {- const current = statusFilter();- if (current.includes(id)) {- setStatusFilter(current.filter((s) => s !== id));- } else {- setStatusFilter([...current, id]);- }- };-- return (- <Popover- open={open()}- onOpenChange={(isOpen) => {- setOpen(isOpen);- }}- placement="bottom-start"- gutter={4}- >- <FilterTrigger filter={statusFilter}>- <Show- when={hasFilter() && statusFilter()[0]}- fallback={<CircleDashedIcon class="size-3.5" />}- >- {(firstStatus) => (- <PropertyValueIcon optionId={firstStatus()} class="size-3.5" />- )}- </Show>- <span class="leading-none">{activeLabel()}</span>- <Show- when={hasFilter()}- fallback={<CaretDownIcon class="size-3 opacity-60" />}- >- <span- class="ml-0.5 hover:text-accent/60"- onClick={(e) => {- e.stopPropagation();- e.preventDefault();- setStatusFilter([]);- }}- >- <XIcon class="size-3" />- </span>- </Show>- </FilterTrigger>- <Popover.Portal>- <Popover.Content class="z-50 bg-panel border border-edge-muted shadow-lg w-[300px]">- <PropertyOptionSelector- config={{ isMultiSelect: true, placeholder: 'Filter status...' }}- options={statusOptions}- isLoading={false}- error={null}- selectedOptions={() => new Set(statusFilter())}- onToggleOption={toggleOption}- onClose={() => setOpen(false)}- />- </Popover.Content>- </Popover.Portal>- </Popover>- );-};--export const TaskAssigneeDropdown: Component<DropdownProps> = (props) => {- const { assigneeFilter, setAssigneeFilter } = useSoupView();- const open = () => props.open();- const setOpen = (v: boolean) => props.onOpenChange(v);- const contacts = useContacts();- const userId = useUserId();-- const hasFilter = () => assigneeFilter().length > 0;-- const activeAssigneeLabel = () => {- const filters = assigneeFilter();- if (filters.length === 0) return 'Assignee';- if (filters.length === 1) {- const contact = contacts().find((c) => c.id === filters[0]);- if (contact && contact.id === userId())- return contact.name ? `${contact.name} (me)` : 'Me';- return contact?.name || filters[0];- }- return `${filters.length} assignees`;- };-- return (- <Popover- open={open()}- onOpenChange={(isOpen) => {- setOpen(isOpen);- }}- placement="bottom-start"- gutter={4}- >- <FilterTrigger filter={assigneeFilter}>- <Show- when={hasFilter() && assigneeFilter()[0]}- keyed- fallback={<UserCircleIcon class="size-3.5" />}- >- {(id) => (- <UserIcon id={id} size="xs" suppressClick showTooltip={false} />- )}- </Show>- <span class="leading-none">{activeAssigneeLabel()}</span>- <Show- when={hasFilter()}- fallback={<CaretDownIcon class="size-3 opacity-60" />}- >- <span- class="ml-0.5 hover:text-accent/60"- onClick={(e) => {- e.stopPropagation();- e.preventDefault();- setAssigneeFilter([]);- }}- >- <XIcon class="size-3" />- </span>- </Show>- </FilterTrigger>- <Popover.Portal>- <Popover.Content class="z-50 bg-panel border border-edge-muted shadow-lg w-[300px]">- <PropertyEntitySelector- config={{- isMultiSelect: true,- placeholder: 'Filter assignee...',- specificEntityType: 'USER',- }}- selectedOptions={() => new Set(assigneeFilter())}- setSelectedOptions={(ids) => {- setAssigneeFilter([...ids]);- }}- onClose={() => setOpen(false)}- />- </Popover.Content>- </Popover.Portal>- </Popover>- );-};diff --git a/js/app/packages/block-project/component/Block.tsx b/js/app/packages/block-project/component/Block.tsxindex 936d844d2c..a788cef8a7 100644--- a/js/app/packages/block-project/component/Block.tsx+++ b/js/app/packages/block-project/component/Block.tsx@@ -28,7 +28,7 @@ import {} from '@app/component/next-soup/create-soup-state';import { SoupViewContextProvider } from '@app/component/next-soup/soup-view/soup-view-context';import { SoupViewList } from '@app/component/next-soup/soup-view/soup-view';-import { NIL_UUID } from '@app/component/next-soup/filters/filters';+import { NIL_UUID } from '@app/component/next-soup/filters/query-filters';// HACK: prevent lint error on custom directivefalse && fileFolderDrop;diff --git a/js/app/packages/queries/soup/items.ts b/js/app/packages/queries/soup/items.tsindex d56f6b3d5a..22d190f9d8 100644--- a/js/app/packages/queries/soup/items.ts+++ b/js/app/packages/queries/soup/items.ts@@ -1,4 +1,4 @@-import { filterSoupItemByRequestBody } from '@app/component/next-soup/filters/filters';+import { filterSoupItemByRequestBody } from '@app/component/next-soup/filters/query-filters';import { throwOnErr } from '@core/util/maybeResult';import type { EntityData } from '@entity';import { soupKeys } from '@queries/soup/keys';