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
feat: search + soup improvements (#1514)
gbirman76d558d5a387
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 65cab8e0de..185958a205 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@@ -9,10 +9,12 @@ import { deduplicateEntities } from '@app/component/next-soup/utils';import { arrayEquals } from '@core/util/compareUtils';import { debouncedDependent } from '@core/util/debounce';import { fuzzyMatch } from '@core/util/fuzzy';+import { mergeAdjacentMacroEmTags } from '@core/util/searchHighlight';import type { EntityData, WithNotification, WithSearch } from '@entity';import { useNotificationsForEntity } from '@notifications';import {type SoupItemsQueryFilters,+ type SoupItemsQueryArgs,useSoupItemsQuery,} from '@queries/soup/items';import { useSearchSoupQuery } from '@queries/soup/search';@@ -30,12 +32,39 @@ import {Suspense,useContext,} from 'solid-js';-import { reconcile } from 'solid-js/store';+import { isWithNotification } from '@entity';+import { match } from 'ts-pattern';const SEARCH_SERVICE_DEBOUNCE_MS = 300;const LOCAL_FUZZY_SEARCH_DEBOUNCE_MS = 20;+const NIL_UUID = '00000000-0000-0000-0000-000000000000';++const CHANNEL_PRELOAD_ARGS: SoupItemsQueryArgs = {+ params: { limit: 500, sort_method: 'updated_at' },+ body: {+ chat_filters: { chat_ids: [NIL_UUID] },+ document_filters: { document_ids: [NIL_UUID] },+ email_filters: { recipients: [NIL_UUID] },+ project_filters: { project_ids: [NIL_UUID] },+ channel_filters: {+ channel_types: [],+ },+ },+};++function mergeEntityPools(+ items: EntityData[],+ extra: EntityData[]+): EntityData[] {+ if (extra.length === 0) return items;+ const existingIds = new Set(items.map((e) => e.id));+ const newItems = extra.filter((e) => !existingIds.has(e.id));+ if (newItems.length === 0) return items;+ return [...items, ...newItems];+}+type Row<T> = {original: T;id: string;@@ -101,16 +130,20 @@ export const SoupViewContextProvider: FlowComponent<const [internalQueryFilters, setQueryFilters] =createSignal<SoupItemsQueryFilters>({});+ const trimmedSearchText = createMemo(() => searchText().trim());+const debouncedSearchForLocal = debouncedDependent(- searchText,+ trimmedSearchText,LOCAL_FUZZY_SEARCH_DEBOUNCE_MS);const debouncedSearchForService = debouncedDependent(- searchText,+ trimmedSearchText,SEARCH_SERVICE_DEBOUNCE_MS);+ const isSearching = createMemo(() => trimmedSearchText().length > 0);+const unifiedSearchIncludeArray = createMemo<UnifiedSearchIndex[]>(() => {let types = soup.filters.activeIds();@@ -265,6 +298,17 @@ export const SoupViewContextProvider: FlowComponent<}));+ // load all channels into memory for local search+ const channelItemsQuery = useSoupItemsQuery(() => CHANNEL_PRELOAD_ARGS);+ createRenderEffect(() => {+ if (+ channelItemsQuery.hasNextPage &&+ !channelItemsQuery.isFetchingNextPage+ ) {+ channelItemsQuery.fetchNextPage();+ }+ });+const nameFuzzySearchFilter = (items: EntityData[]) => {const query = debouncedSearchForLocal();if (!query || query.length === 0) return items;@@ -275,7 +319,7 @@ export const SoupViewContextProvider: FlowComponent<return {...result.item,search: {- nameHighlight: result.nameHighlight,+ nameHighlight: mergeAdjacentMacroEmTags(result.nameHighlight),contentHitData: null,source: 'local',},@@ -318,35 +362,46 @@ export const SoupViewContextProvider: FlowComponent<};};- const items = createMemo(- (prev) => {- const itemsData = itemsQuery.data;- const searchData = searchQuery.data;-- if (!itemsData && !searchData) return [];+ const localFuzzyResults = createMemo(() => {+ const pool = mergeEntityPools(+ itemsQuery.data ?? [],+ channelItemsQuery.data ?? []+ );+ return nameFuzzySearchFilter(pool);+ });- const isSearching = searchText().length > 0;+ const freshSearchResults = createMemo<EntityData[]>(() => {+ if (isSearchDisabled()) return [];+ if (searchQuery.isFetching && !searchQuery.isFetchingNextPage) return [];+ return searchQuery.data ?? [];+ });- const items = itemsData ?? [];- const searchItems = isSearching ? (searchData ?? []) : [];+ const items = createMemo<SoupEntity[]>(+ (prev) => {+ const searching = isSearching();++ if (!searching) {+ const data = itemsQuery.data;+ if (!data) return prev;+ return data.map((e) =>+ isWithNotification(e) ? e : attachNotifications(e)+ ) as SoupEntity[];+ }- let transformed: SoupEntity[] = [...searchItems];+ const local = localFuzzyResults();+ const service = freshSearchResults();- if (isSearching) {- transformed.push(...nameFuzzySearchFilter(items));- } else {- transformed.push(...items);- }+ const merged: SoupEntity[] = [...service, ...local];- const next = reconcile(transformed)(prev);+ if (merged.length === 0) return prev;- for (let i = 0; i < next.length; i++) {- const entity = next[i];+ for (let i = 0; i < merged.length; i++) {+ const entity = merged[i];if (entity.notifications) continue;- next[i] = attachNotifications(entity);+ merged[i] = attachNotifications(entity);}- return next;+ return merged;},[],{@@ -370,8 +425,7 @@ export const SoupViewContextProvider: FlowComponent<transformed = deduplicateEntities(next);- const isSearching = searchText().length > 0;- if (isSearching) {+ if (isSearching()) {transformed.sort(sortEntitiesForSearch);}@@ -398,7 +452,11 @@ export const SoupViewContextProvider: FlowComponent<soup,source: {data: entities,- isLoading: () => searchQuery.isLoading || itemsQuery.isLoading,+ isLoading: () => {+ if (itemsQuery.isLoading) return true;+ if (searchQuery.isLoading && !itemsQuery.data) return true;+ return false;+ },isFetching: () => searchQuery.isFetching || itemsQuery.isFetching,isFetchingNextPage: () =>searchQuery.isFetchingNextPage || itemsQuery.isFetchingNextPage,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 630ebd301a..603d1aceca 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@@ -49,6 +49,7 @@ import {type Accessor,createEffect,createMemo,+ createRenderEffect,createSignal,type JSX,Match,@@ -58,6 +59,7 @@ import {Suspense,Switch,} from 'solid-js';+import { createStore, reconcile } from 'solid-js/store';import { type VirtualizerHandle, VList } from 'virtua/solid';import { SoupEntitySelectionToolbar } from './soup-entity-selection-toolbar';import { SoupToolbar } from './soup-toolbar';@@ -523,13 +525,13 @@ export const SoupViewList = (props: SoupViewListProps) => {><StaticMarkdownContext><Switch>- <Match when={source.isLoading()}>+ <Match when={source.isLoading() && !rows().length}><LoadingBlock /></Match>- <Match when={!rows().length}>+ <Match when={!source.isLoading() && !rows().length}><EmptyState search={!!searchText()} /></Match>- <Match when={!source.isLoading() && rows().length}>+ <Match when={rows().length}><EntityRowProvidercontainer={localEntityListRef}canSwipeLeft={(entityId) => {@@ -703,6 +705,12 @@ const SoupList = (props: SoupListProps) => {const itemSize = createMemo(() => props.itemSize ?? DEFAULT_ITEM_SIZE);const overscan = createMemo(() => props.overscan ?? DEFAULT_OVERSCAN);+ const [stableRows, setStableRows] = createStore<SoupRow[]>([]);++ createRenderEffect(() => {+ setStableRows(reconcile(props.rows, { key: 'id' }));+ });+const handleScroll = (offset: number) => {const handle = virtualizerHandle();@@ -735,7 +743,7 @@ const SoupList = (props: SoupListProps) => {cache={props.cache}ref={registerVirtualizerHandler}class={props.virtualizerClass}- data={props.rows}+ data={stableRows}itemSize={itemSize()}bufferSize={overscan() * itemSize()}onScroll={handleScroll}diff --git a/js/app/packages/entity/src/composed/ListEntity.tsx b/js/app/packages/entity/src/composed/ListEntity.tsxindex 94a54c9e15..9c73b03a2f 100644--- a/js/app/packages/entity/src/composed/ListEntity.tsx+++ b/js/app/packages/entity/src/composed/ListEntity.tsx@@ -33,6 +33,9 @@ import {import { useSplitPanel } from '@app/component/split-layout/layoutUtils';import { mergeRefs } from '@solid-primitives/refs';+const hasSearchContentHits = (entity: EntityData) =>+ isSearchEntity(entity) && !!entity.search.contentHitData?.length;+interface ListEntityProps {entity: WithNotification<EntityData>;onClick?: (event: MouseEvent) => void;@@ -136,7 +139,7 @@ function NarrowLayout(props: LayoutProps) {when={(isEmailEntity(props.entity) || isChannelEntity(props.entity)) &&!props.hasNotifications &&- !isSearchEntity(props.entity)+ !hasSearchContentHits(props.entity)}><Entity.Slot placement="body" class="flex flex-col gap-1 pb-3 -mt-1">@@ -226,7 +229,7 @@ function WideLayout(props: LayoutProps) {{(entity) => (<><Show- when={!isSearchEntity(entity())}+ when={!hasSearchContentHits(entity())}fallback={<><span class="truncate">@@ -381,7 +384,7 @@ export function ListEntity(props: ListEntityProps) {<Showwhen={isWithNotification(props.entity) &&- !isSearchEntity(props.entity)+ !hasSearchContentHits(props.entity)}><Entity.Notification.Stacks@@ -393,7 +396,7 @@ export function ListEntity(props: ListEntityProps) {</div></Show>- <Show when={isSearchEntity(props.entity)}>+ <Show when={hasSearchContentHits(props.entity)}><div class="flex gap-2 w-full h-full items-center text-sm px-2 pb-1 -mt-2 min-w-0 overflow-hidden"><div class={cn('min-w-0 flex-1 truncate ml-4 @lg/entity:ml-6')}><Entity.Search.ContentHitsdiff --git a/js/app/packages/entity/src/extractors/entity-email-participants.tsx b/js/app/packages/entity/src/extractors/entity-email-participants.tsxindex 8bbdf1d1c8..56328ac30c 100644--- a/js/app/packages/entity/src/extractors/entity-email-participants.tsx+++ b/js/app/packages/entity/src/extractors/entity-email-participants.tsx@@ -1,6 +1,6 @@import { useEmail } from '@core/context/user';import { emailToMacroId, useDisplayName } from '@core/user';-import type { EmailEntity } from '../types/entity';+import type { EmailEntity, EmailThreadParticipants } from '../types/entity';/** Checks if a value is likely an email address */export function isLikelyEmail(value?: string): boolean {@@ -17,7 +17,7 @@ export function getEmailLocalPart(email: string): string {* Priority: macroDisplayName > participant.name > email local part*/export function resolveParticipantName(- participant: { email: string; name: string },+ participant: EmailThreadParticipants[number],macroDisplayName?: string): string {if (macroDisplayName && !isLikelyEmail(macroDisplayName)) {@@ -35,7 +35,7 @@ export function resolveParticipantName(* Returns an array of display names (possibly ["me"] if single participant is userEmail)*/export function combineParticipantNames(- participants: Array<{ email: string; name: string }> | undefined,+ participants: EmailThreadParticipants | undefined,userEmail: string | undefined,getMacroDisplayName: (email: string) => string | undefined): string[] {diff --git a/js/app/packages/entity/src/types/entity.ts b/js/app/packages/entity/src/types/entity.tsindex 6d1645ac01..25faa2459a 100644--- a/js/app/packages/entity/src/types/entity.ts+++ b/js/app/packages/entity/src/types/entity.ts@@ -70,6 +70,8 @@ export const getEntityProjectId = (e: EntityData): string | false => {return 'projectId' in e ? (e.projectId ?? false) : false;};+export type EmailThreadParticipants = Array<{ email: string; name?: string }>;+// We spread ApiThreadPreviewCursor into the email entity, should we explcitly include all those fields here, or only add them as needed?export type EmailEntity = EntityBase & {type: 'email';@@ -78,7 +80,7 @@ export type EmailEntity = EntityBase & {snippet?: string;isImportant: boolean;done: boolean;- participants?: Array<{ email: string; name: string }>;+ participants?: EmailThreadParticipants;senderEmail?: string;senderName?: string;labels?: SoupLabel[] | ApiLabel[];diff --git a/js/app/packages/queries/soup/search.ts b/js/app/packages/queries/soup/search.tsindex bee7519f94..5f5b4dc4f1 100644--- a/js/app/packages/queries/soup/search.ts+++ b/js/app/packages/queries/soup/search.ts@@ -26,7 +26,14 @@ export const useSearchSoupQuery = () => {const pageSize = createMemo(() => args().params.page_size);- const request = createMemo(() => args().body);+ const request = createMemo(() => {+ const body = args().body;+ return {+ ...body,+ query: body.query?.trim(),+ terms: body.terms?.map((t) => t.trim()),+ };+ });const terms = createMemo(() => {const query = request().query;@@ -59,7 +66,8 @@ export const useSearchSoupQuery = (const mapSearchResponseItem = useSearchResponseItemMapper();return useInfiniteQuery(() => ({- queryKey: soupKeys.search(args()).queryKey,+ queryKey: soupKeys.search({ params: args().params, body: request() })+ .queryKey,queryFn: async (ctx) => {return throwOnErr(async () =>diff --git a/js/app/packages/queries/soup/transform-utils.ts b/js/app/packages/queries/soup/transform-utils.tsindex ffd55b11a5..e36cdfb098 100644--- a/js/app/packages/queries/soup/transform-utils.ts+++ b/js/app/packages/queries/soup/transform-utils.ts@@ -36,7 +36,6 @@ import type {SoupPage,} from '@service-storage/generated/schemas';import type { UseQueryResult } from '@tanstack/solid-query';-import { max } from 'date-fns';const SEARCH_MATCH_LENGTH = 60;@@ -213,16 +212,6 @@ export const useSearchResponseItemMapper = () => {};}case 'email': {- const messageHits = result.email_message_search_results.filter(- (m) => m.message_id- );- // NOTE: guaranteed to be empty or singleton array- const threadHits = result.email_message_search_results.filter(- (m) => !m.message_id- );-- const singleMessage = messageHits.length === 1;-const search = getSearchData({results: result.email_message_search_results,type: 'email',@@ -230,39 +219,24 @@ export const useSearchResponseItemMapper = () => {const name = result.name ?? blockNameToDefaultFile('email');- // TODO: display sender for each message in the content hit list- const combinedSenders =- [...new Set(messageHits.map((m) => m.pretty_sender))].join(', ') ||- threadHits.at(0)?.pretty_sender;-- // TODO: we probably want to get the actual latest message info on the full thread- const messagesSentAt = messageHits- .map((m) => m.sent_at)- .filter((m) => m != null);- const latestMessageSentAt =- messagesSentAt.length > 0 ? max(messagesSentAt) : null;+ const participants = result.participants?.map((p) => ({+ email: p.email,+ name: p.name ?? undefined,+ }));return {type: 'email',id: result.thread_id,name,ownerId: result.owner_id,- createdAt: latestMessageSentAt ?? result.created_at,- updatedAt: latestMessageSentAt ?? result.updated_at,+ createdAt: result.created_at,+ updatedAt: result.updated_at,viewedAt: result.viewed_at,- isRead: singleMessage- ? !messageHits[0].labels.includes('UNREAD')- : false,- isImportant: singleMessage- ? messageHits[0].labels.includes('IMPORTANT')- : false,- isDraft: singleMessage- ? messageHits[0].labels.includes('DRAFT')- : false,- done: singleMessage- ? !messageHits[0].labels.includes('INBOX')- : false,- senderName: combinedSenders,+ isRead: result.is_read,+ isImportant: result.is_important,+ isDraft: result.is_draft,+ done: !result.inbox_visible,+ participants,search,};}diff --git a/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts b/js/app/packages/service-clients/service-cognition/generated/tools/schemas.tsindex f49f6a8234..77eb8fa6ca 100644--- a/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts+++ b/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts@@ -196,8 +196,18 @@ export const SearchToolResponse = z.object({})),id: z.string().uuid(),+ inbox_visible: z.boolean(),+ is_draft: z.boolean(),+ is_important: z.boolean(),+ is_read: z.boolean(),name: z.union([z.string(), z.null()]).optional(),owner_id: z.string(),+ participants: z.array(+ z.object({+ email: z.string(),+ name: z.union([z.string(), z.null()]).optional(),+ })+ ),snippet: z.union([z.string(), z.null()]).optional(),subject: z.union([z.string(), z.null()]).optional(),thread_id: z.string().uuid(),diff --git a/js/app/packages/service-clients/service-cognition/generated/tools/types.ts b/js/app/packages/service-clients/service-cognition/generated/tools/types.tsindex fd212d5d40..dfb700008a 100644--- a/js/app/packages/service-clients/service-cognition/generated/tools/types.ts+++ b/js/app/packages/service-clients/service-cognition/generated/tools/types.ts@@ -383,11 +383,22 @@ export interface SearchToolResponse {* for consistency in our data model.*/id: string;+ inbox_visible: boolean;+ is_draft: boolean;+ is_important: boolean;+ is_read: boolean;/*** Subject of the email thread*/name?: string | null;owner_id: string;+ /**+ * The participants (senders) in this email thread+ */+ participants: {+ email: string;+ name?: string | null;+ }[];snippet?: string | null;/*** The subject of the emaildiff --git a/js/app/packages/service-clients/service-search/generated/models/emailSearchParticipant.ts b/js/app/packages/service-clients/service-search/generated/models/emailSearchParticipant.tsnew file mode 100644index 0000000000..41f4a98df4--- /dev/null+++ b/js/app/packages/service-clients/service-search/generated/models/emailSearchParticipant.ts@@ -0,0 +1,15 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * search_service+ * OpenAPI spec version: 0.1.0+ */+import type { EmailSearchParticipantName } from './emailSearchParticipantName';++/**+ * A participant (sender) in an email thread+ */+export interface EmailSearchParticipant {+ email: string;+ name?: EmailSearchParticipantName;+}diff --git a/js/app/packages/service-clients/service-search/generated/models/emailSearchParticipantName.ts b/js/app/packages/service-clients/service-search/generated/models/emailSearchParticipantName.tsnew file mode 100644index 0000000000..ba42d97e48--- /dev/null+++ b/js/app/packages/service-clients/service-search/generated/models/emailSearchParticipantName.ts@@ -0,0 +1,8 @@+/**+ * Generated by orval v7.13.0 🍺+ * Do not edit manually.+ * search_service+ * OpenAPI spec version: 0.1.0+ */++export type EmailSearchParticipantName = string | null;diff --git a/js/app/packages/service-clients/service-search/generated/models/emailSearchResponseItem.ts b/js/app/packages/service-clients/service-search/generated/models/emailSearchResponseItem.tsindex bcd6e31768..3df52f12ec 100644--- a/js/app/packages/service-clients/service-search/generated/models/emailSearchResponseItem.ts+++ b/js/app/packages/service-clients/service-search/generated/models/emailSearchResponseItem.ts@@ -5,6 +5,7 @@* OpenAPI spec version: 0.1.0*/+import type { EmailSearchParticipant } from './emailSearchParticipant';import type { EmailSearchResponseItemName } from './emailSearchResponseItemName';import type { EmailSearchResponseItemSubject } from './emailSearchResponseItemSubject';import type { EmailSearchResult } from './emailSearchResult';@@ -23,6 +24,8 @@ for consistency in our data model. *//** Subject of the email thread */name?: EmailSearchResponseItemName;owner_id: string;+ /** The participants (senders) in this email thread */+ participants: EmailSearchParticipant[];/** The subject of the emailThis is only present if the search result is on the message content */subject?: EmailSearchResponseItemSubject;diff --git a/js/app/packages/service-clients/service-search/generated/models/emailSearchResponseItemWithMetadataAllOf.ts b/js/app/packages/service-clients/service-search/generated/models/emailSearchResponseItemWithMetadataAllOf.tsindex 90eac765b4..1ae175391b 100644--- a/js/app/packages/service-clients/service-search/generated/models/emailSearchResponseItemWithMetadataAllOf.ts+++ b/js/app/packages/service-clients/service-search/generated/models/emailSearchResponseItemWithMetadataAllOf.ts@@ -9,6 +9,10 @@ import type { EmailSearchResponseItemWithMetadataAllOfViewedAt } from './emailSeexport type EmailSearchResponseItemWithMetadataAllOf = {created_at: string;+ inbox_visible: boolean;+ is_draft: boolean;+ is_important: boolean;+ is_read: boolean;snippet?: EmailSearchResponseItemWithMetadataAllOfSnippet;updated_at: string;viewed_at?: EmailSearchResponseItemWithMetadataAllOfViewedAt;diff --git a/js/app/packages/service-clients/service-search/generated/models/index.ts b/js/app/packages/service-clients/service-search/generated/models/index.tsindex c0f2c7ec97..e2f9a15756 100644--- a/js/app/packages/service-clients/service-search/generated/models/index.ts+++ b/js/app/packages/service-clients/service-search/generated/models/index.ts@@ -77,6 +77,8 @@ export * from './documentSearchResultScore';export * from './documentSubType';export * from './emailFilters';export * from './emailFiltersImportance';+export * from './emailSearchParticipant';+export * from './emailSearchParticipantName';export * from './emailSearchRequest';export * from './emailSearchRequestAllOf';export * from './emailSearchRequestAllOfTwo';diff --git a/js/app/packages/service-clients/service-search/openapi.json b/js/app/packages/service-clients/service-search/openapi.jsonindex 08a2079a96..66526d3a73 100644--- a/js/app/packages/service-clients/service-search/openapi.json+++ b/js/app/packages/service-clients/service-search/openapi.json@@ -905,6 +905,19 @@}}},+ "EmailSearchParticipant": {+ "type": "object",+ "description": "A participant (sender) in an email thread",+ "required": ["email"],+ "properties": {+ "email": {+ "type": "string"+ },+ "name": {+ "type": ["string", "null"]+ }+ }+ },"EmailSearchRequest": {"allOf": [{@@ -975,7 +988,8 @@"owner_id","thread_id","user_id",- "email_message_search_results"+ "email_message_search_results",+ "participants"],"properties": {"email_message_search_results": {@@ -997,6 +1011,13 @@"owner_id": {"type": "string"},+ "participants": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/EmailSearchParticipant"+ },+ "description": "The participants (senders) in this email thread"+ },"subject": {"type": ["string", "null"],"description": "The subject of the email\nThis is only present if the search result is on the message content"@@ -1019,12 +1040,31 @@},{"type": "object",- "required": ["created_at", "updated_at"],+ "required": [+ "created_at",+ "updated_at",+ "is_read",+ "inbox_visible",+ "is_draft",+ "is_important"+ ],"properties": {"created_at": {"type": "string","format": "date-time"},+ "inbox_visible": {+ "type": "boolean"+ },+ "is_draft": {+ "type": "boolean"+ },+ "is_important": {+ "type": "boolean"+ },+ "is_read": {+ "type": "boolean"+ },"snippet": {"type": ["string", "null"]},diff --git a/rust/cloud-storage/document_storage_service/justfile b/rust/cloud-storage/document_storage_service/justfileindex d018e9a2db..8663436991 100644--- a/rust/cloud-storage/document_storage_service/justfile+++ b/rust/cloud-storage/document_storage_service/justfile@@ -10,5 +10,8 @@ mod ci '../ci.just'deploy-dev:just ci::deploy-dev document-storage-service+run: ensure::ensure_dynamodb+ cargo run -F local+check:SQLX_OFFLINE=true cargo checkdiff --git a/rust/cloud-storage/email_db_client/.sqlx/query-14398843140a148be3189f593e689c36283225f47a6b37c197bc543f3fa18703.json b/rust/cloud-storage/email_db_client/.sqlx/query-14398843140a148be3189f593e689c36283225f47a6b37c197bc543f3fa18703.jsonnew file mode 100644index 0000000000..f73606ba8c--- /dev/null+++ b/rust/cloud-storage/email_db_client/.sqlx/query-14398843140a148be3189f593e689c36283225f47a6b37c197bc543f3fa18703.json@@ -0,0 +1,34 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT\n m.thread_id,\n c.email_address as \"email_address!\",\n COALESCE(m.from_name, c.name) as \"name\"\n FROM email_messages m\n JOIN email_contacts c ON m.from_contact_id = c.id\n WHERE m.thread_id = ANY($1) AND m.from_contact_id IS NOT NULL\n ORDER BY m.created_at ASC\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "thread_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "email_address!",+ "type_info": "Varchar"+ },+ {+ "ordinal": 2,+ "name": "name",+ "type_info": "Varchar"+ }+ ],+ "parameters": {+ "Left": [+ "UuidArray"+ ]+ },+ "nullable": [+ false,+ false,+ null+ ]+ },+ "hash": "14398843140a148be3189f593e689c36283225f47a6b37c197bc543f3fa18703"+}diff --git a/rust/cloud-storage/email_db_client/.sqlx/query-3b49f494bd77e2c216db219d991337821164f685bfd1d1041df06a6aa2902fd4.json b/rust/cloud-storage/email_db_client/.sqlx/query-3b49f494bd77e2c216db219d991337821164f685bfd1d1041df06a6aa2902fd4.jsondeleted file mode 100644index a8661cf1ec..0000000000--- a/rust/cloud-storage/email_db_client/.sqlx/query-3b49f494bd77e2c216db219d991337821164f685bfd1d1041df06a6aa2902fd4.json+++ /dev/null@@ -1,77 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT\n t.id as thread_id,\n -- Return timestamps from the chosen messages directly\n COALESCE(earliest_msg.sent_at, earliest_msg.updated_at) as \"first_message_ts!\",\n COALESCE(latest_msg.sent_at, latest_msg.updated_at) as \"last_message_ts!\",\n -- Last time user viewed this thread\n uh.updated_at as \"viewed_at?\",\n latest_msg.snippet,\n earliest_msg.subject as \"subject?\",\n l.macro_id,\n latest_msg.sender as sender,\n latest_msg.pretty_sender as \"pretty_sender!\",\n latest_msg.trash_label as trash_label\n FROM email_threads t\n LEFT JOIN email_user_history uh ON uh.thread_id = t.id AND uh.link_id = $1\n LEFT JOIN email_links l ON l.id = t.link_id\n -- LATERAL join for LATEST message\n -- JOIN (Inner) acts as a filter to ensure we only return threads that actually have messages\n JOIN LATERAL (\n SELECT\n m2.snippet,\n m2.sent_at,\n m2.updated_at,\n c.email_address as sender,\n COALESCE(c.name, c.email_address) as pretty_sender,\n EXISTS(\n SELECT 1 \n FROM email_message_labels eml \n JOIN email_labels el ON el.id = eml.label_id \n WHERE eml.message_id = m2.id \n AND el.provider_label_id = 'TRASH'\n ) as trash_label\n FROM email_messages m2\n LEFT JOIN email_contacts c ON c.id = m2.from_contact_id\n WHERE m2.thread_id = t.id\n AND m2.link_id = $1\n ORDER BY\n (CASE WHEN m2.is_draft = false AND m2.sent_at IS NOT NULL THEN 0 ELSE 1 END) ASC,\n COALESCE(m2.sent_at, m2.updated_at) DESC NULLS LAST\n LIMIT 1\n ) latest_msg ON true\n -- LATERAL join for EARLIEST message\n LEFT JOIN LATERAL (\n SELECT\n m3.subject,\n m3.sent_at,\n m3.updated_at\n FROM email_messages m3\n WHERE m3.thread_id = t.id\n AND m3.link_id = $1\n ORDER BY\n -- 1. Priority: Non-drafts with valid sent_at come first (0), everything else is fallback (1)\n (CASE WHEN m3.is_draft = false AND m3.sent_at IS NOT NULL THEN 0 ELSE 1 END) ASC,\n -- 2. Sort by time (Oldest first)\n COALESCE(m3.sent_at, m3.updated_at) ASC NULLS LAST\n LIMIT 1\n ) earliest_msg ON true\n WHERE t.id = ANY($2)\n AND t.link_id = $1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "thread_id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "first_message_ts!",- "type_info": "Timestamptz"- },- {- "ordinal": 2,- "name": "last_message_ts!",- "type_info": "Timestamptz"- },- {- "ordinal": 3,- "name": "viewed_at?",- "type_info": "Timestamptz"- },- {- "ordinal": 4,- "name": "snippet",- "type_info": "Text"- },- {- "ordinal": 5,- "name": "subject?",- "type_info": "Text"- },- {- "ordinal": 6,- "name": "macro_id",- "type_info": "Text"- },- {- "ordinal": 7,- "name": "sender",- "type_info": "Varchar"- },- {- "ordinal": 8,- "name": "pretty_sender!",- "type_info": "Varchar"- },- {- "ordinal": 9,- "name": "trash_label",- "type_info": "Bool"- }- ],- "parameters": {- "Left": [- "Uuid",- "UuidArray"- ]- },- "nullable": [- false,- null,- null,- false,- true,- true,- false,- false,- null,- null- ]- },- "hash": "3b49f494bd77e2c216db219d991337821164f685bfd1d1041df06a6aa2902fd4"-}diff --git a/rust/cloud-storage/email_db_client/.sqlx/query-86d971ef2350eb0120ca72cf4a7ecfd8ac7a04922066909603459467ace0788a.json b/rust/cloud-storage/email_db_client/.sqlx/query-86d971ef2350eb0120ca72cf4a7ecfd8ac7a04922066909603459467ace0788a.jsonnew file mode 100644index 0000000000..77306de147--- /dev/null+++ b/rust/cloud-storage/email_db_client/.sqlx/query-86d971ef2350eb0120ca72cf4a7ecfd8ac7a04922066909603459467ace0788a.json@@ -0,0 +1,101 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT\n t.id as thread_id,\n -- Return timestamps from the chosen messages directly\n COALESCE(earliest_msg.sent_at, earliest_msg.updated_at) as \"first_message_ts!\",\n COALESCE(latest_msg.sent_at, latest_msg.updated_at) as \"last_message_ts!\",\n -- Last time user viewed this thread\n uh.updated_at as \"viewed_at?\",\n latest_msg.snippet,\n earliest_msg.subject as \"subject?\",\n l.macro_id,\n latest_msg.sender as sender,\n latest_msg.pretty_sender as \"pretty_sender!\",\n latest_msg.trash_label as trash_label,\n (\n SELECT m_latest.is_draft\n FROM email_messages m_latest\n WHERE m_latest.thread_id = t.id\n AND m_latest.link_id = $1\n ORDER BY m_latest.internal_date_ts DESC NULLS LAST\n LIMIT 1\n ) AS \"is_draft!\",\n t.is_read,\n t.inbox_visible,\n (\n SELECT EXISTS (\n SELECT 1\n FROM email_messages m_imp\n JOIN email_message_labels ml ON m_imp.id = ml.message_id\n JOIN email_labels l ON ml.label_id = l.id\n WHERE m_imp.thread_id = t.id\n AND l.link_id = t.link_id\n AND l.name = 'IMPORTANT'\n )\n ) AS \"is_important!\"\n FROM email_threads t\n LEFT JOIN email_user_history uh ON uh.thread_id = t.id AND uh.link_id = $1\n LEFT JOIN email_links l ON l.id = t.link_id\n -- LATERAL join for LATEST message\n -- JOIN (Inner) acts as a filter to ensure we only return threads that actually have messages\n JOIN LATERAL (\n SELECT\n m2.snippet,\n m2.sent_at,\n m2.updated_at,\n c.email_address as sender,\n COALESCE(c.name, c.email_address) as pretty_sender,\n EXISTS(\n SELECT 1 \n FROM email_message_labels eml \n JOIN email_labels el ON el.id = eml.label_id \n WHERE eml.message_id = m2.id \n AND el.provider_label_id = 'TRASH'\n ) as trash_label\n FROM email_messages m2\n LEFT JOIN email_contacts c ON c.id = m2.from_contact_id\n WHERE m2.thread_id = t.id\n AND m2.link_id = $1\n ORDER BY\n (CASE WHEN m2.is_draft = false AND m2.sent_at IS NOT NULL THEN 0 ELSE 1 END) ASC,\n COALESCE(m2.sent_at, m2.updated_at) DESC NULLS LAST\n LIMIT 1\n ) latest_msg ON true\n -- LATERAL join for EARLIEST message\n LEFT JOIN LATERAL (\n SELECT\n m3.subject,\n m3.sent_at,\n m3.updated_at\n FROM email_messages m3\n WHERE m3.thread_id = t.id\n AND m3.link_id = $1\n ORDER BY\n -- 1. Priority: Non-drafts with valid sent_at come first (0), everything else is fallback (1)\n (CASE WHEN m3.is_draft = false AND m3.sent_at IS NOT NULL THEN 0 ELSE 1 END) ASC,\n -- 2. Sort by time (Oldest first)\n COALESCE(m3.sent_at, m3.updated_at) ASC NULLS LAST\n LIMIT 1\n ) earliest_msg ON true\n WHERE t.id = ANY($2)\n AND t.link_id = $1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "thread_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "first_message_ts!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 2,+ "name": "last_message_ts!",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 3,+ "name": "viewed_at?",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 4,+ "name": "snippet",+ "type_info": "Text"+ },+ {+ "ordinal": 5,+ "name": "subject?",+ "type_info": "Text"+ },+ {+ "ordinal": 6,+ "name": "macro_id",+ "type_info": "Text"+ },+ {+ "ordinal": 7,+ "name": "sender",+ "type_info": "Varchar"+ },+ {+ "ordinal": 8,+ "name": "pretty_sender!",+ "type_info": "Varchar"+ },+ {+ "ordinal": 9,+ "name": "trash_label",+ "type_info": "Bool"+ },+ {+ "ordinal": 10,+ "name": "is_draft!",+ "type_info": "Bool"+ },+ {+ "ordinal": 11,+ "name": "is_read",+ "type_info": "Bool"+ },+ {+ "ordinal": 12,+ "name": "inbox_visible",+ "type_info": "Bool"+ },+ {+ "ordinal": 13,+ "name": "is_important!",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid",+ "UuidArray"+ ]+ },+ "nullable": [+ false,+ null,+ null,+ false,+ true,+ true,+ false,+ false,+ null,+ null,+ null,+ false,+ false,+ null+ ]+ },+ "hash": "86d971ef2350eb0120ca72cf4a7ecfd8ac7a04922066909603459467ace0788a"+}diff --git a/rust/cloud-storage/email_db_client/src/contacts/get.rs b/rust/cloud-storage/email_db_client/src/contacts/get.rsindex 750f50fae5..280ab4df64 100644--- a/rust/cloud-storage/email_db_client/src/contacts/get.rs+++ b/rust/cloud-storage/email_db_client/src/contacts/get.rs@@ -11,6 +11,8 @@ use sqlx::PgPool;use sqlx::types::Uuid;use std::collections::{HashMap, HashSet};+pub type ThreadContactsMap = HashMap<Uuid, Vec<(String, Option<String>)>>;+/// fetch message sender from db#[tracing::instrument(skip(pool), err)]pub async fn get_sender_by_message_id(@@ -369,6 +371,55 @@ whereOk(senders_map)}+/// Fetches all unique sender contacts for given thread IDs, ordered by message creation time.+/// Returns a map of thread_id -> Vec<(email, name)>.+#[tracing::instrument(skip(pool), err)]+pub async fn fetch_contacts_by_thread_ids(+ pool: &PgPool,+ thread_ids: &[Uuid],+) -> anyhow::Result<ThreadContactsMap> {+ if thread_ids.is_empty() {+ return Ok(HashMap::new());+ }++ struct Row {+ thread_id: Uuid,+ email_address: String,+ name: Option<String>,+ }++ let rows = sqlx::query_as!(+ Row,+ r#"+ SELECT+ m.thread_id,+ c.email_address as "email_address!",+ COALESCE(m.from_name, c.name) as "name"+ FROM email_messages m+ JOIN email_contacts c ON m.from_contact_id = c.id+ WHERE m.thread_id = ANY($1) AND m.from_contact_id IS NOT NULL+ ORDER BY m.created_at ASC+ "#,+ thread_ids+ )+ .fetch_all(pool)+ .await+ .context("Failed to fetch contacts by thread IDs")?;++ let mut result: ThreadContactsMap = HashMap::new();+ for row in rows {+ let contacts = result.entry(row.thread_id).or_default();+ if !contacts+ .iter()+ .any(|(e, n)| *e == row.email_address && *n == row.name)+ {+ contacts.push((row.email_address, row.name));+ }+ }++ Ok(result)+}+/// returns all email addresses and names the passed link has sent emails to.#[tracing::instrument(skip(pool), err)]pub async fn fetch_contacts_by_link_id(diff --git a/rust/cloud-storage/email_db_client/src/user_history/mod.rs b/rust/cloud-storage/email_db_client/src/user_history/mod.rsindex 1224702506..15aedf51b5 100644--- a/rust/cloud-storage/email_db_client/src/user_history/mod.rs+++ b/rust/cloud-storage/email_db_client/src/user_history/mod.rs@@ -73,7 +73,28 @@ pub async fn get_thread_summary_info(l.macro_id,latest_msg.sender as sender,latest_msg.pretty_sender as "pretty_sender!",- latest_msg.trash_label as trash_label+ latest_msg.trash_label as trash_label,+ (+ SELECT m_latest.is_draft+ FROM email_messages m_latest+ WHERE m_latest.thread_id = t.id+ AND m_latest.link_id = $1+ ORDER BY m_latest.internal_date_ts DESC NULLS LAST+ LIMIT 1+ ) AS "is_draft!",+ t.is_read,+ t.inbox_visible,+ (+ SELECT EXISTS (+ SELECT 1+ FROM email_messages m_imp+ JOIN email_message_labels ml ON m_imp.id = ml.message_id+ JOIN email_labels l ON ml.label_id = l.id+ WHERE m_imp.thread_id = t.id+ AND l.link_id = t.link_id+ AND l.name = 'IMPORTANT'+ )+ ) AS "is_important!"FROM email_threads tLEFT JOIN email_user_history uh ON uh.thread_id = t.id AND uh.link_id = $1LEFT JOIN email_links l ON l.id = t.link_id@@ -154,6 +175,10 @@ pub async fn get_thread_summary_info(}),sender: row.sender,pretty_sender: row.pretty_sender,+ is_read: row.is_read,+ inbox_visible: row.inbox_visible,+ is_draft: row.is_draft,+ is_important: row.is_important,};result.insert(row.thread_id, summary_info);}diff --git a/rust/cloud-storage/models_email/src/email/service/message.rs b/rust/cloud-storage/models_email/src/email/service/message.rsindex 4c58ed35d8..4958eb5593 100644--- a/rust/cloud-storage/models_email/src/email/service/message.rs+++ b/rust/cloud-storage/models_email/src/email/service/message.rs@@ -331,6 +331,10 @@ pub struct ThreadHistoryInfo {/// The pretty sender of the latest email in the thread./// This could be the sender's email if there is no contact name for the sender.pub pretty_sender: String,+ pub is_read: bool,+ pub inbox_visible: bool,+ pub is_draft: bool,+ pub is_important: bool,}#[derive(Debug, Clone, Serialize, Deserialize)]diff --git a/rust/cloud-storage/models_search/src/email.rs b/rust/cloud-storage/models_search/src/email.rsindex 12b0c64330..78fefcea3e 100644--- a/rust/cloud-storage/models_search/src/email.rs+++ b/rust/cloud-storage/models_search/src/email.rs@@ -36,6 +36,13 @@ pub struct EmailSearchResult {pub score: Option<f64>,}+/// A participant (sender) in an email thread+#[derive(Debug, Serialize, Deserialize, ToSchema, JsonSchema, Clone)]+pub struct EmailSearchParticipant {+ pub email: String,+ pub name: Option<String>,+}+/// A single response item, part of the EmailSearchResponse object#[derive(Debug, Serialize, Deserialize, ToSchema, JsonSchema)]pub struct EmailSearchResponseItem {@@ -58,6 +65,8 @@ pub struct EmailSearchResponseItem {/// The search results for the document/// This may be empty if the search result match was on the email subject onlypub email_message_search_results: Vec<EmailSearchResult>,+ /// The participants (senders) in this email thread+ pub participants: Vec<EmailSearchParticipant>,}/// EmailSearchResponseItem object with email metadata we fetch from email service. we don't store these@@ -69,6 +78,10 @@ pub struct EmailSearchResponseItemWithMetadata {pub updated_at: DateTime<Utc>,pub viewed_at: Option<DateTime<Utc>>,pub snippet: Option<String>,+ pub is_read: bool,+ pub inbox_visible: bool,+ pub is_draft: bool,+ pub is_important: bool,#[serde(flatten)]pub extra: EmailSearchResponseItem,}diff --git a/rust/cloud-storage/search_service/src/api/search/email.rs b/rust/cloud-storage/search_service/src/api/search/email.rsindex 149a06c70d..e2844e8e6f 100644--- a/rust/cloud-storage/search_service/src/api/search/email.rs+++ b/rust/cloud-storage/search_service/src/api/search/email.rs@@ -1,9 +1,11 @@use crate::api::context::SearchHandlerState;use crate::api::search::simple::SearchError;+use email_db_client::contacts::get::ThreadContactsMap;use indexmap::IndexMap;use models_email::service::message::{MessageSenderInfo, ThreadHistoryInfo};use models_search::email::{- EmailSearchResponseItem, EmailSearchResponseItemWithMetadata, EmailSearchResult,+ EmailSearchParticipant, EmailSearchResponseItem, EmailSearchResponseItemWithMetadata,+ EmailSearchResult,};use opensearch_client::search::model::SearchGotoContent;use sqlx::types::Uuid;@@ -55,17 +57,20 @@ pub(in crate::api::search) async fn enrich_emails(}).collect();- let message_senders_map = email_db_client::messages::get::get_message_sender_and_pretty_sender(- &ctx.db,- link.id,- &message_ids,+ let (message_senders_map, contacts_map) = tokio::try_join!(+ email_db_client::messages::get::get_message_sender_and_pretty_sender(+ &ctx.db,+ link.id,+ &message_ids,+ ),+ email_db_client::contacts::get::fetch_contacts_by_thread_ids(&ctx.db, &thread_ids),)- .await.map_err(SearchError::InternalError)?;// Construct enriched results- let enriched_results = construct_search_result(results, thread_histories, message_senders_map)- .map_err(SearchError::InternalError)?;+ let enriched_results =+ construct_search_result(results, thread_histories, message_senders_map, contacts_map)+ .map_err(SearchError::InternalError)?;Ok(enriched_results)}@@ -74,6 +79,7 @@ pub fn construct_search_result(search_results: Vec<opensearch_client::search::model::SearchHit>,thread_histories: HashMap<Uuid, ThreadHistoryInfo>,message_senders: HashMap<Uuid, MessageSenderInfo>,+ contacts_map: ThreadContactsMap,) -> anyhow::Result<Vec<EmailSearchResponseItemWithMetadata>> {// construct entity hit map of id -> vec<hits> using IndexMap to preserve insertion orderlet entity_id_hit_map: IndexMap<Uuid, Vec<EmailSearchResult>> = search_results@@ -136,11 +142,28 @@ pub fn construct_search_result(.filter_map(|(entity_id, hits)| {if let Some(info) = thread_histories.get(&entity_id) {let info = info.clone();+ let participants = contacts_map+ .get(&entity_id)+ .map(|contacts| {+ contacts+ .iter()+ .map(|(email, name)| EmailSearchParticipant {+ email: email.clone(),+ name: name.clone(),+ })+ .collect()+ })+ .unwrap_or_default();+Some(EmailSearchResponseItemWithMetadata {created_at: info.created_at,updated_at: info.updated_at,viewed_at: info.viewed_at,snippet: info.snippet,+ is_read: info.is_read,+ inbox_visible: info.inbox_visible,+ is_draft: info.is_draft,+ is_important: info.is_important,extra: EmailSearchResponseItem {id: entity_id,thread_id: entity_id,@@ -149,6 +172,7 @@ pub fn construct_search_result(name: info.subject.clone(),subject: info.subject,email_message_search_results: hits,+ participants,},})} else {diff --git a/rust/cloud-storage/search_service/src/api/search/email/test.rs b/rust/cloud-storage/search_service/src/api/search/email/test.rsindex 51ebd1d501..9581151570 100644--- a/rust/cloud-storage/search_service/src/api/search/email/test.rs+++ b/rust/cloud-storage/search_service/src/api/search/email/test.rs@@ -17,12 +17,16 @@ fn create_email_history(thread_id: &str) -> models_email::service::message::Thresubject: Some("subject".to_string()),sender: "[email protected]".to_string(),pretty_sender: "Pretty Sender".to_string(),+ is_read: false,+ inbox_visible: true,+ is_draft: false,+ is_important: false,}}#[test]fn test_construct_search_result_empty_input() {- let result = construct_search_result(vec![], HashMap::new(), HashMap::new());+ let result = construct_search_result(vec![], HashMap::new(), HashMap::new(), HashMap::new());assert!(result.is_ok());assert_eq!(result.unwrap().len(), 0);}@@ -56,7 +60,13 @@ fn test_construct_search_result_single_thread() {let mut thread_histories = HashMap::new();thread_histories.insert(thread_uuid, create_email_history(&thread_uuid.to_string()));- let result = construct_search_result(search_results, thread_histories, HashMap::new()).unwrap();+ let result = construct_search_result(+ search_results,+ thread_histories,+ HashMap::new(),+ HashMap::new(),+ )+ .unwrap();assert_eq!(result.len(), 1);assert_eq!(result[0].extra.thread_id, thread_uuid);@@ -207,12 +217,27 @@ fn test_sort_stability() {);}- let result1 =- construct_search_result(input.clone(), thread_histories.clone(), HashMap::new()).unwrap();- let result2 =- construct_search_result(input.clone(), thread_histories.clone(), HashMap::new()).unwrap();- let result3 =- construct_search_result(input.clone(), thread_histories.clone(), HashMap::new()).unwrap();+ let result1 = construct_search_result(+ input.clone(),+ thread_histories.clone(),+ HashMap::new(),+ HashMap::new(),+ )+ .unwrap();+ let result2 = construct_search_result(+ input.clone(),+ thread_histories.clone(),+ HashMap::new(),+ HashMap::new(),+ )+ .unwrap();+ let result3 = construct_search_result(+ input.clone(),+ thread_histories.clone(),+ HashMap::new(),+ HashMap::new(),+ )+ .unwrap();assert_eq!(result1.len(), 5);assert_eq!(result2.len(), 5);diff --git a/rust/cloud-storage/search_service/src/api/search/unified/test.rs b/rust/cloud-storage/search_service/src/api/search/unified/test.rsindex 863cb5d619..d92e57f3aa 100644--- a/rust/cloud-storage/search_service/src/api/search/unified/test.rs+++ b/rust/cloud-storage/search_service/src/api/search/unified/test.rs@@ -71,6 +71,10 @@ fn test_sort_unified_search_results() {updated_at: DateTime::from_timestamp(1500, 0).unwrap(),viewed_at: None,snippet: None,+ is_read: false,+ inbox_visible: true,+ is_draft: false,+ is_important: false,extra: EmailSearchResponseItem {id: email_id,name: Some("Middle Email".to_string()),@@ -79,6 +83,7 @@ fn test_sort_unified_search_results() {thread_id: email_id,user_id: "user1".to_string(),email_message_search_results: vec![],+ participants: vec![],},}),// Project with updated_at = 2000 (second newest)