Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(call): add call to soup (#2559)

Will Hutchinsonaf022079bdc2
diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsx
index faeea0d7d8..d42a82e32f 100644
--- a/js/app/packages/app/component/Root.tsx
+++ b/js/app/packages/app/component/Root.tsx
@@ -241,6 +241,10 @@ const ROUTES: RouteDefinition[] = [
path: '/channels',
component: LAYOUT_ROUTE.component,
},
+ {
+ path: '/calls',
+ component: LAYOUT_ROUTE.component,
+ },
{
path: '/files',
component: LAYOUT_ROUTE.component,
diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsx
index ac21091ac3..d24d5e1bc2 100644
--- a/js/app/packages/app/component/app-sidebar/sidebar.tsx
+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx
@@ -1,6 +1,13 @@
import { AnimatedUsersIcon } from '@macro-icons/wide/animating/users';
import { AnimatedGearIcon } from '@macro-icons/wide/animating/gear';
-import { type Component, createSignal, For, type JSX, Show } from 'solid-js';
+import {
+ type Component,
+ createMemo,
+ createSignal,
+ For,
+ type JSX,
+ Show,
+} from 'solid-js';
import { Dynamic } from 'solid-js/web';
import { AnimatedStarIcon } from '@macro-icons/wide/animating/star';
import { AnimatedEmailIcon } from '@macro-icons/wide/animating/email';
@@ -46,6 +53,8 @@ import {
InviteModal,
setInviteModalOpen,
} from '@app/component/app-sidebar/invite-modal';
+import { ENABLE_CALLS } from '@core/constant/featureFlags';
+import PhoneCallIcon from '@icon/duotone/phone-call-duotone.svg';
interface SidebarItem {
id: ListView;
@@ -126,6 +135,7 @@ type AppSidebarProps = {
};
type SidebarHotkeyDeps = {
+ links: SidebarItem[];
hotkeyVisible: () => boolean;
setHotkeyVisible: (visible: boolean) => void;
resetHotkeysState: VoidFunction;
@@ -135,6 +145,7 @@ type SidebarHotkeyDeps = {
};
export const registerSidebarHotkeys = ({
+ links,
isSlim,
onOpenChange,
openWithSplit,
@@ -163,7 +174,7 @@ export const registerSidebarHotkeys = ({
});
const registeredGoToKeys = new Set<ValidHotkey>([
- ...SIDEBAR_LINKS.map((link) => link.hotkey),
+ ...links.map((link) => link.hotkey),
]);
// When the go to command scope is active, we want to prevent
@@ -219,7 +230,7 @@ export const registerSidebarHotkeys = ({
});
// Register navigation shortcuts in the global GO_TO command scope
- for (const link of SIDEBAR_LINKS) {
+ for (const link of links) {
const openSidebarView = (e?: KeyboardEvent) => {
e?.preventDefault();
if (hotkeyVisible()) {
@@ -338,6 +349,14 @@ const SidebarActionButton = (props: SidebarActionButtonProps) => {
);
};
+const CALLS_LINK: SidebarItem = {
+ id: 'calls',
+ label: 'Calls',
+ href: LIST_VIEW_PATHS.calls,
+ icon: PhoneCallIcon,
+ hotkey: 'l',
+};
+
export const AppSidebar = (props: AppSidebarProps) => {
const analytics = useAnalytics();
const layout = useSplitLayout();
@@ -345,6 +364,16 @@ export const AppSidebar = (props: AppSidebarProps) => {
const [hotkeyVisible, setHotkeyVisible] = createSignal(false);
+ const visibleLinks = createMemo(() => {
+ if (!ENABLE_CALLS()) return SIDEBAR_LINKS;
+ const idx = SIDEBAR_LINKS.findIndex((l) => l.id === 'channels');
+ return [
+ ...SIDEBAR_LINKS.slice(0, idx + 1),
+ CALLS_LINK,
+ ...SIDEBAR_LINKS.slice(idx + 1),
+ ];
+ });
+
const resetHotkeysState = () => {
setHotkeyVisible(false);
@@ -393,6 +422,7 @@ export const AppSidebar = (props: AppSidebarProps) => {
const [sidebarBtnHovering, setSidebarBtnHovering] = createSignal(false);
registerSidebarHotkeys({
+ links: visibleLinks(),
hotkeyVisible,
setHotkeyVisible,
resetHotkeysState,
@@ -459,7 +489,7 @@ export const AppSidebar = (props: AppSidebarProps) => {
<nav>
<ul class="w-full h-full px-2 flex flex-col gap-1">
- <For each={SIDEBAR_LINKS}>
+ <For each={visibleLinks()}>
{(link) => (
<li class="flex items-center justify-center">
<SidebarLink
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.ts
index 694150124a..2c9c8d0546 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
@@ -291,6 +291,15 @@ export const VIEW_TAB_PRESETS: Record<ListView, ViewTabConfig> = {
}),
},
},
+ calls: {
+ default: 'all',
+ tabs: {
+ all: () => ({
+ queryFilters: QUERY_FILTERS.calls,
+ clientFilters: { and: ['calls'] },
+ }),
+ },
+ },
folders: {
default: 'owned',
tabs: {
diff --git a/js/app/packages/app/component/next-soup/filters/configs.ts b/js/app/packages/app/component/next-soup/filters/configs.ts
index a66b1f3e24..16310b50ea 100644
--- a/js/app/packages/app/component/next-soup/filters/configs.ts
+++ b/js/app/packages/app/component/next-soup/filters/configs.ts
@@ -15,6 +15,7 @@ import {
hasNoPriority,
hasAssignees,
isUnassigned,
+ callsFilter,
channelsFilter,
filesAndFolderFilter,
activeAgentFilter,
@@ -325,6 +326,11 @@ export const createSoupFilters = (
label: 'Channels',
predicate: channelsFilter,
},
+ {
+ id: 'calls',
+ label: 'Calls',
+ predicate: callsFilter,
+ },
{
id: 'file-folder',
label: 'Files & Folders',
diff --git a/js/app/packages/app/component/next-soup/filters/inbox-filters.ts b/js/app/packages/app/component/next-soup/filters/inbox-filters.ts
index 3fb99c45c6..3275916272 100644
--- a/js/app/packages/app/component/next-soup/filters/inbox-filters.ts
+++ b/js/app/packages/app/component/next-soup/filters/inbox-filters.ts
@@ -156,6 +156,8 @@ export function signalFilter(entity: EntityData): boolean {
return true;
case 'channel_message':
return true;
+ case 'call':
+ return true;
}
}
diff --git a/js/app/packages/app/component/next-soup/filters/predicates.ts b/js/app/packages/app/component/next-soup/filters/predicates.ts
index 172ae98ec7..eb3a9abc11 100644
--- a/js/app/packages/app/component/next-soup/filters/predicates.ts
+++ b/js/app/packages/app/component/next-soup/filters/predicates.ts
@@ -95,6 +95,10 @@ export function channelsFilter(entity: EntityData): boolean {
return entity.type === 'channel' || entity.type === 'channel_message';
}
+export function callsFilter(entity: EntityData): boolean {
+ return entity.type === 'call';
+}
+
export function filesAndFolderFilter(entity: EntityData): boolean {
if (entity.type !== 'project' && entity.type !== 'document') return false;
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.ts
index 28c651fea1..6ddbd9114c 100644
--- a/js/app/packages/app/component/next-soup/filters/query-filters.ts
+++ b/js/app/packages/app/component/next-soup/filters/query-filters.ts
@@ -9,6 +9,7 @@ export const EXCLUDE: string[] = [NIL_UUID];
// Base filter that excludes all entity types by default
export const QUERY_FILTERS_BASE: SoupItemsQueryFilters = {
+ call_filters: { channel_ids: EXCLUDE },
channel_filters: { channel_ids: EXCLUDE },
chat_filters: { chat_ids: EXCLUDE },
document_filters: { document_ids: EXCLUDE },
@@ -64,6 +65,11 @@ export function filterSoupItemByRequestBody(
({ data }) =>
!isIdFilteredOut(body.email_filters?.email_thread_ids, data.id)
)
+ .with(
+ { tag: 'callRecord' },
+ ({ data }) =>
+ !isIdFilteredOut(body.call_filters?.channel_ids, data.channelId)
+ )
.exhaustive();
}
@@ -153,6 +159,15 @@ export const QUERY_FILTERS = {
channel_filters: {},
},
+ calls: {
+ chat_filters: { chat_ids: EXCLUDE },
+ document_filters: { document_ids: EXCLUDE },
+ email_filters: { recipients: EXCLUDE },
+ project_filters: { project_ids: EXCLUDE },
+ channel_filters: { channel_ids: EXCLUDE },
+ call_filters: {},
+ },
+
folders: {
channel_filters: { channel_ids: EXCLUDE },
chat_filters: { chat_ids: EXCLUDE },
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx
index 97a496a406..655cb10322 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx
@@ -308,6 +308,7 @@ export const VIEW_FILTER_CATEGORIES: Record<ListView, FilterCategory[]> = {
documents: DOCUMENTS_FILTER_CATEGORIES,
tasks: TASKS_FILTER_CATEGORIES,
channels: [],
+ calls: [],
folders: [],
search: [],
};
diff --git a/js/app/packages/app/component/split-layout/componentRegistry.tsx b/js/app/packages/app/component/split-layout/componentRegistry.tsx
index c82fe009e1..b9de5f9285 100644
--- a/js/app/packages/app/component/split-layout/componentRegistry.tsx
+++ b/js/app/packages/app/component/split-layout/componentRegistry.tsx
@@ -202,6 +202,21 @@ registerComponent(
})
);
+registerComponent(
+ 'calls',
+ withAuth(() => {
+ usePageViewTracking('calls');
+ const preset = getDefaultListViewPreset('calls');
+ return (
+ <SoupView
+ viewName="Calls"
+ queryFilters={preset.queryFilters}
+ initialClientFilters={preset.clientFilters}
+ />
+ );
+ })
+);
+
registerComponent(
'folders',
withAuth(() => {
diff --git a/js/app/packages/app/constants/list-views.ts b/js/app/packages/app/constants/list-views.ts
index a66bc4cb22..0ff44dff60 100644
--- a/js/app/packages/app/constants/list-views.ts
+++ b/js/app/packages/app/constants/list-views.ts
@@ -7,6 +7,7 @@ export const LIST_VIEWS = [
'documents',
'tasks',
'channels',
+ 'calls',
'folders',
'search',
] as const;
@@ -20,6 +21,7 @@ export const LIST_VIEW_PATHS = {
documents: '/documents',
tasks: '/tasks',
channels: '/channels',
+ calls: '/calls',
folders: '/folders',
search: '/search',
} as const satisfies Record<ListView, string>;
@@ -35,6 +37,7 @@ export const LIST_VIEW_ID = {
documents: 'documents',
tasks: 'tasks',
channels: 'channels',
+ calls: 'calls',
folders: 'folders',
search: 'search',
} as const satisfies Record<ListView, string>;
@@ -52,7 +55,7 @@ const BLOCK_LIST_VIEW_MAP = {
code: 'documents',
contact: 'channels',
csv: 'documents',
- call: 'channels',
+ call: 'calls',
email: 'mail',
image: 'documents',
md: 'documents',
diff --git a/js/app/packages/block-call/component/CallBlockAdapter.tsx b/js/app/packages/block-call/component/CallBlockAdapter.tsx
index 1c2d02918b..d9803d5279 100644
--- a/js/app/packages/block-call/component/CallBlockAdapter.tsx
+++ b/js/app/packages/block-call/component/CallBlockAdapter.tsx
@@ -4,6 +4,10 @@ import { MaybeResultError } from '@core/util/maybeResult';
import { useCallRecordQuery } from '@queries/call/call';
import { Match, Show, Switch } from 'solid-js';
import { CallTranscript } from './CallTranscript';
+import type { CallRecord } from '@service-storage/generated/schemas/callRecord';
+import { format } from 'date-fns';
+import PhoneCallIcon from '@icon/duotone/phone-call-duotone.svg';
+import { formatCallDuration } from '../utils';
function isUnauthorized(error: Error | null): boolean {
if (error instanceof MaybeResultError) {
@@ -12,15 +16,55 @@ function isUnauthorized(error: Error | null): boolean {
return false;
}
+function formatCallDate(dateStr: string): string {
+ return format(new Date(dateStr), 'MMM d, yyyy h:mm a');
+}
+
+function CallHeader(props: { record: CallRecord }) {
+ return (
+ <div class="px-4 py-3 border-b border-edge shrink-0 flex items-center gap-3">
+ <PhoneCallIcon class="size-5 text-ink-muted shrink-0" />
+ <div class="flex flex-col min-w-0">
+ <h2 class="text-sm font-medium text-ink truncate">
+ {props.record.channelName ?? 'Call'}
+ </h2>
+ <div class="flex items-center gap-2 text-xs text-ink-muted">
+ <Show when={props.record.endedAt}>
+ {(endedAt) => <span>{formatCallDate(endedAt())}</span>}
+ </Show>
+ <Show when={props.record.durationMs}>
+ {(ms) => (
+ <>
+ <span>&middot;</span>
+ <span>{formatCallDuration(ms())}</span>
+ </>
+ )}
+ </Show>
+ <Show when={props.record.isActive}>
+ <span class="text-success font-medium">In progress</span>
+ </Show>
+ </div>
+ </div>
+ </div>
+ );
+}
+
export function CallBlockAdapter() {
const callId = useBlockId();
const callRecord = useCallRecordQuery(() => callId);
return (
<div class="h-full flex flex-col overflow-hidden">
- <div class="px-4 py-3 border-b border-edge shrink-0">
- <h2 class="text-sm font-medium text-ink">Call Recording</h2>
- </div>
+ <Show
+ when={callRecord.data}
+ fallback={
+ <div class="px-4 py-3 border-b border-edge shrink-0">
+ <h2 class="text-sm font-medium text-ink">Call Recording</h2>
+ </div>
+ }
+ >
+ {(data) => <CallHeader record={data()} />}
+ </Show>
<div class="flex-1 overflow-y-auto">
<Switch>
<Match when={callRecord.isLoading}>
diff --git a/js/app/packages/block-call/utils.ts b/js/app/packages/block-call/utils.ts
new file mode 100644
index 0000000000..3683b8ccea
--- /dev/null
+++ b/js/app/packages/block-call/utils.ts
@@ -0,0 +1,9 @@
+export function formatCallDuration(ms: number): string {
+ const totalSeconds = Math.floor(ms / 1000);
+ const hours = Math.floor(totalSeconds / 3600);
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
+ const seconds = totalSeconds % 60;
+ if (hours > 0) return `${hours}h ${minutes}m`;
+ if (minutes > 0) return `${minutes}m ${seconds}s`;
+ return `${seconds}s`;
+}
diff --git a/js/app/packages/block-canvas/component/CanvasController.tsx b/js/app/packages/block-canvas/component/CanvasController.tsx
index e05f8363dc..0113adf7ff 100644
--- a/js/app/packages/block-canvas/component/CanvasController.tsx
+++ b/js/app/packages/block-canvas/component/CanvasController.tsx
@@ -863,6 +863,7 @@ export function CanvasController(props: ParentProps) {
const entityType = event.draggable.data.type;
// TODO: add channel message support
if (entityType === 'channel_message') return;
+ if (entityType === 'call') return;
// Track document mention and get UUID
let mentionUuid: string | undefined;
diff --git a/js/app/packages/channel/Attachments/attachment-utils.ts b/js/app/packages/channel/Attachments/attachment-utils.ts
index 9d199e7fce..6c237e84e2 100644
--- a/js/app/packages/channel/Attachments/attachment-utils.ts
+++ b/js/app/packages/channel/Attachments/attachment-utils.ts
@@ -93,5 +93,9 @@ export function getEntityClickContent(entity: EntityData): SplitContent {
id: e.channelId,
params: getChannelParams(e.messageId, e.threadId),
}))
+ .with({ type: 'call' }, (e) => ({
+ type: 'channel' as const,
+ id: e.channelId,
+ }))
.exhaustive();
}
diff --git a/js/app/packages/core/component/AI/hook/useEntityDropAttachment.ts b/js/app/packages/core/component/AI/hook/useEntityDropAttachment.ts
index fe6b55c147..71a0e2bc86 100644
--- a/js/app/packages/core/component/AI/hook/useEntityDropAttachment.ts
+++ b/js/app/packages/core/component/AI/hook/useEntityDropAttachment.ts
@@ -128,6 +128,7 @@ export function useEntityDropAttachment(
} satisfies Attachment;
})
.with('chat', () => undefined)
+ .with('call', () => undefined)
.exhaustive() satisfies Attachment | undefined;
if (attachment) {
diff --git a/js/app/packages/core/component/EntityIcon.tsx b/js/app/packages/core/component/EntityIcon.tsx
index 6aca46d209..ad781a162a 100644
--- a/js/app/packages/core/component/EntityIcon.tsx
+++ b/js/app/packages/core/component/EntityIcon.tsx
@@ -275,7 +275,7 @@ function validateEntity(entity: string): EntityWithValidIcon {
}
export const WIDE_ICONS: Record<EntityWithValidIcon, Component> = {
- call: WideChannel,
+ call: PhoneCall,
canvas: WideDiagram,
html: WideFileCode,
channel: WideChannel,
diff --git a/js/app/packages/core/component/Properties/utils/entityConversion.ts b/js/app/packages/core/component/Properties/utils/entityConversion.ts
index c3fc80a2c1..12e6853aba 100644
--- a/js/app/packages/core/component/Properties/utils/entityConversion.ts
+++ b/js/app/packages/core/component/Properties/utils/entityConversion.ts
@@ -72,5 +72,6 @@ export function macroEntityToPropertyEntityType(
.with({ type: 'email' }, () => EntityType.THREAD)
.with({ type: 'document' }, () => EntityType.DOCUMENT)
.with({ type: 'channel_message' }, () => EntityType.CHANNEL)
+ .with({ type: 'call' }, () => EntityType.CHANNEL)
.exhaustive();
}
diff --git a/js/app/packages/core/constant/allBlocks.ts b/js/app/packages/core/constant/allBlocks.ts
index adbeb32eb3..ed206a37d1 100644
--- a/js/app/packages/core/constant/allBlocks.ts
+++ b/js/app/packages/core/constant/allBlocks.ts
@@ -207,7 +207,7 @@ export function blockNameToDefaultFile(block?: BlockName | string | null) {
}
type ItemLike = {
- type: ItemType;
+ type: ItemType | 'call';
fileType?: BasicDocumentFileType;
subType?: SubType | BasicDocumentSubTypeProperty;
name?: string;
diff --git a/js/app/packages/entity/src/composed/ListEntity.tsx b/js/app/packages/entity/src/composed/ListEntity.tsx
index 572f27b260..3565f2c38d 100644
--- a/js/app/packages/entity/src/composed/ListEntity.tsx
+++ b/js/app/packages/entity/src/composed/ListEntity.tsx
@@ -8,6 +8,7 @@ import {
import { Entity } from '../entity';
import type { StreamEvent } from '@service-connection/generated/schemas';
import {
+ isCallEntity,
isChannelEntity,
isChannelMessageEntity,
isEmailEntity,
@@ -73,6 +74,7 @@ import { createElementSize } from '@solid-primitives/resize-observer';
import { isMobile } from '@core/mobile/isMobile';
import { tryMacroId, useDisplayNameParts } from '@core/user';
import { DisplayName } from '@entity/components/DisplayName';
+import { formatCallDuration } from '@block-call/utils';
const WIDE_BREAKPOINT = 512; // @lg container query = 32rem
@@ -541,6 +543,26 @@ function NarrowInboxLayout(props: LayoutProps) {
</Show>
</Entity.Slot>
</Match>
+ <Match when={isCallEntity(props.entity) && props.entity}>
+ {(entity) => (
+ <Entity.Slot
+ placement="body"
+ class="flex flex-col pb-2 min-h-[2lh] pr-4"
+ >
+ <span class="text-ink-muted text-xs truncate">
+ {entity().channelName ?? 'Call'}
+ </span>
+ <span class="text-ink-extra-muted text-xs">
+ <Show
+ when={entity().durationMs}
+ fallback={entity().isActive ? 'In progress' : 'No duration'}
+ >
+ {(ms) => formatCallDuration(ms())}
+ </Show>
+ </span>
+ </Entity.Slot>
+ )}
+ </Match>
<Match when={true}>
<Entity.Slot placement="body" class="pb-2 min-h-[2lh] pr-4" />
</Match>
@@ -672,6 +694,21 @@ function WideLayout(props: LayoutProps) {
</Show>
)}
</Match>
+ <Match when={isCallEntity(props.entity) && props.entity}>
+ {(entity) => (
+ <>
+ <Entity.Title entity={entity()} />
+ <span class="text-ink-extra-muted font-medium truncate">
+ <Show
+ when={entity().durationMs}
+ fallback={entity().isActive ? 'In progress' : ''}
+ >
+ {(ms) => formatCallDuration(ms())}
+ </Show>
+ </span>
+ </>
+ )}
+ </Match>
<Match when={props.entity}>
{(entity) => <Entity.Title entity={entity()} />}
</Match>
diff --git a/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx b/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx
index e4fbb6338e..a1aeb2a5ec 100644
--- a/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx
+++ b/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx
@@ -31,6 +31,7 @@ function getEntityType(entity: EntityData): EntityType {
.with({ type: 'email' }, () => EntityType.THREAD)
.with({ type: 'document' }, () => EntityType.DOCUMENT)
.with({ type: 'channel_message' }, () => EntityType.CHANNEL)
+ .with({ type: 'call' }, () => EntityType.CHANNEL)
.exhaustive();
}
diff --git a/js/app/packages/entity/src/extractors/entity-icon.tsx b/js/app/packages/entity/src/extractors/entity-icon.tsx
index 744802c92c..b02be69db0 100644
--- a/js/app/packages/entity/src/extractors/entity-icon.tsx
+++ b/js/app/packages/entity/src/extractors/entity-icon.tsx
@@ -11,6 +11,7 @@ import { match } from 'ts-pattern';
import { PulsingStar } from '../components/PulsingStar';
import type { ChannelEntity, EntityData } from '../types/entity';
import {
+ isCallEntity,
isChannelEntity,
isChannelMessageEntity,
isTaskEntity,
@@ -68,6 +69,7 @@ export function EntityIcon(props: EntityIconProps) {
.with({ type: 'email' }, ({ isRead, hasIcsAttachment }) =>
hasIcsAttachment ? 'emailInvite' : isRead ? 'emailRead' : 'email'
)
+ .when(isCallEntity, () => 'call')
.otherwise(() => 'default');
};
diff --git a/js/app/packages/entity/src/extractors/entity-title.tsx b/js/app/packages/entity/src/extractors/entity-title.tsx
index faadd02a65..e5e5d9f9ae 100644
--- a/js/app/packages/entity/src/extractors/entity-title.tsx
+++ b/js/app/packages/entity/src/extractors/entity-title.tsx
@@ -18,6 +18,7 @@ function extractRawTitle(entity: EntityData): string {
.with({ type: 'channel_message' }, (e) => e.channelName)
.with({ type: 'email' }, (e) => e.name || '(No Subject)')
.with({ type: 'chat' }, (e) => e.name)
+ .with({ type: 'call' }, (e) => e.name)
.otherwise(() => 'Unknown');
}
diff --git a/js/app/packages/entity/src/types/entity.ts b/js/app/packages/entity/src/types/entity.ts
index 61126d102b..0d2f23ea35 100644
--- a/js/app/packages/entity/src/types/entity.ts
+++ b/js/app/packages/entity/src/types/entity.ts
@@ -119,6 +119,15 @@ export type ProjectEntity = EntityBase & {
projectId?: string;
};
+export type CallEntity = EntityBase & {
+ type: 'call';
+ channelId: string;
+ channelName?: string;
+ isActive: boolean;
+ durationMs?: number;
+ participantIds: string[];
+};
+
export type EntityData =
| ChannelEntity
| ChannelMessageEntity
@@ -126,7 +135,8 @@ export type EntityData =
| DocumentEntity
| TaskEntity
| EmailEntity
- | ProjectEntity;
+ | ProjectEntity
+ | CallEntity;
export const isEntityData = (item: unknown): item is EntityData => {
if (typeof item !== 'object') return false;
@@ -174,6 +184,10 @@ export const isProjectEntity = (
return entity.type === 'project';
};
+export const isCallEntity = (entity: EntityData): entity is CallEntity => {
+ return entity.type === 'call';
+};
+
export const isDocumentEntity = (
entity: EntityData
): entity is DocumentEntity => {
diff --git a/js/app/packages/entity/src/utils/shared.ts b/js/app/packages/entity/src/utils/shared.ts
index 693232fea8..a2f655df4b 100644
--- a/js/app/packages/entity/src/utils/shared.ts
+++ b/js/app/packages/entity/src/utils/shared.ts
@@ -5,6 +5,7 @@ export function useIsShared(entity: EntityData) {
const { userId } = useUserContext();
return () => {
if (entity.type === 'channel') return false;
+ if (entity.type === 'call') return false;
if (entity.ownerId === userId()) return false;
return true;
};
diff --git a/js/app/packages/macro-entity/src/queries/dss.ts b/js/app/packages/macro-entity/src/queries/dss.ts
index d024c085d4..f7e4def9d1 100644
--- a/js/app/packages/macro-entity/src/queries/dss.ts
+++ b/js/app/packages/macro-entity/src/queries/dss.ts
@@ -6,6 +6,7 @@ import {
import { toast } from '@core/component/Toast/Toast';
import { useMutation } from '@tanstack/solid-query';
import type { EntityData } from '@entity';
+import type { ItemType } from '@service-storage/client';
import { queryClient } from '@queries/client';
import { soupKeys } from '@queries/soup/keys';
import {
@@ -17,26 +18,22 @@ import {
} from '@queries/soup/cache';
export function createBulkDeleteDssItemsMutation() {
- const isUnsupportedEntity = (entity: EntityData) => {
+ const isDeletable = (entity: EntityData) => {
const type = entity.type;
- return type !== 'chat' && type !== 'document' && type !== 'project';
+ return type === 'chat' || type === 'document' || type === 'project';
};
return useMutation(() => ({
mutationFn: async (entities: EntityData[]) => {
- if (entities.some(isUnsupportedEntity)) {
- throw new Error(`Unsupported entity types`);
- }
-
+ const deletable = entities.filter(isDeletable);
return await Promise.all(
- entities
- .filter((e) => e.type !== 'channel_message')
- .map((e) => {
- return deleteItem({ id: e.id, itemType: e.type });
- })
+ deletable.map((e) => {
+ return deleteItem({ id: e.id, itemType: e.type as ItemType });
+ })
);
},
onMutate: async (entities: EntityData[]) => {
- const ids = new Set(entities.map((e) => e.id));
+ const deletable = entities.filter(isDeletable);
+ const ids = new Set(deletable.map((e) => e.id));
const soupSnapshot = removeSoupEntities(ids);
const searchSnapshot = removeSearchEntities(ids);
return { soupSnapshot, searchSnapshot };
diff --git a/js/app/packages/macro-entity/src/queries/rename.ts b/js/app/packages/macro-entity/src/queries/rename.ts
index bd453f8c4b..9ea425cff5 100644
--- a/js/app/packages/macro-entity/src/queries/rename.ts
+++ b/js/app/packages/macro-entity/src/queries/rename.ts
@@ -59,8 +59,9 @@ type RenameOnMutateResult = {
const getEntityRenameData = (
operation: EntityRenameOperation
-): EntityRenameData => {
+): EntityRenameData | null => {
const { entity, newName } = operation;
+ if (entity.type === 'call') return null;
return {
id: entity.id,
itemType: entity.type,
@@ -71,6 +72,7 @@ const getEntityRenameData = (
const performEntityRename = async (operation: EntityRenameOperation) => {
const data = getEntityRenameData(operation);
+ if (!data) return { success: false };
const success = await renameItem(data);
return { success };
};
@@ -201,7 +203,9 @@ const bulkRenameMutationFn = async (
const bulkRenameOnMutate = (
params: BulkRenameDssEntityMutationVariables
): RenameOnMutateResult => {
- const updates = params.map(getEntityRenameData);
+ const updates = params
+ .map(getEntityRenameData)
+ .filter((d): d is EntityRenameData => d !== null);
const contexts = performOptimisticRenameUpdates(updates);
return { contexts, updates };
};
diff --git a/js/app/packages/queries/properties/entity.ts b/js/app/packages/queries/properties/entity.ts
index 3a648428fa..0b6a7edf48 100644
--- a/js/app/packages/queries/properties/entity.ts
+++ b/js/app/packages/queries/properties/entity.ts
@@ -156,7 +156,8 @@ export function useSaveEntityPropertyMutation(
vars: SaveEntityPropertyParams
): Promise<SaveEntityPropertyContext> => {
const current = getSoupEntityById(vars.entityId);
- if (!current || current.tag === 'channel') return;
+ if (!current || current.tag === 'channel' || current.tag === 'callRecord')
+ return;
const soupValue = apiValuesToSoupPropertyValue(vars.apiValues);
if (current.data.properties) {
@@ -403,7 +404,12 @@ export function useSetPropertyStatusCompleteMutation(
const current = getSoupEntityById(vars.entityId);
let soupTxn: SoupTransaction | undefined;
- if (current && current.tag !== 'channel' && current.data.properties) {
+ if (
+ current &&
+ current.tag !== 'channel' &&
+ current.tag !== 'callRecord' &&
+ current.data.properties
+ ) {
soupTxn = optimisticUpdateSoupEntity({
tag: current.tag,
data: {
diff --git a/js/app/packages/queries/soup/normalized-cache/operations.ts b/js/app/packages/queries/soup/normalized-cache/operations.ts
index 076375154d..9cf295d990 100644
--- a/js/app/packages/queries/soup/normalized-cache/operations.ts
+++ b/js/app/packages/queries/soup/normalized-cache/operations.ts
@@ -88,11 +88,13 @@ export function hasSoupEntity(entityId: string): boolean {
return getSoupNormalizer().getObjectById(`soup:${entityId}`) != null;
}
-/** Extract the canonical entity ID from a SoupApiItem (handles channel's nested `data.channel.id`). */
+/** Extract the canonical entity ID from a SoupApiItem (handles channel's nested `data.channel.id` and callRecord's `data.callId`). */
export function getSoupItemId(item: SoupApiItem): string {
switch (item.tag) {
case 'channel':
return item.data.channel.id;
+ case 'callRecord':
+ return item.data.callId;
default:
return item.data.id;
}
@@ -278,6 +280,7 @@ export function buildSingleEntityFilter(
...base,
email_filters: { email_thread_ids: [entityId] },
}))
+ .with('callRecord', () => null)
.exhaustive();
}
@@ -302,6 +305,9 @@ export function optimisticUpdateSoupItemViewedAt(itemId: string) {
data: { channel: { id: itemId }, viewed_at: now },
frecency_score: current.frecency_score,
});
+ } else if (current.tag === 'callRecord') {
+ // Call records don't have viewedAt — skip.
+ return;
} else {
optimisticUpdateSoupEntity({
tag: current.tag,
@@ -337,6 +343,9 @@ export function optimisticUpdateSoupItemUpdatedAt(
data: { channel: { id: itemId, updated_at: updatedAt } },
frecency_score: current.frecency_score,
});
+ } else if (current.tag === 'callRecord') {
+ // Call records use endedAt/startedAt, not updatedAt — skip optimistic timestamp updates.
+ return;
} else {
if (!shouldUpdateOptimisticTimestamp(current.data.updatedAt, updatedAt))
return;
diff --git a/js/app/packages/queries/soup/normalized-cache/types.ts b/js/app/packages/queries/soup/normalized-cache/types.ts
index 189b62e1ab..d1bf791dee 100644
--- a/js/app/packages/queries/soup/normalized-cache/types.ts
+++ b/js/app/packages/queries/soup/normalized-cache/types.ts
@@ -20,7 +20,9 @@ type SoupPartialData<T extends SoupEntityTag> = T extends 'channel'
? { channel: Partial<ChannelInner> & Pick<ChannelInner, 'id'> } & Partial<
Omit<SoupItemData<'channel'>, 'channel'>
>
- : Partial<SoupItemData<T>> & { id: string };
+ : T extends 'callRecord'
+ ? Partial<SoupItemData<'callRecord'>> & { callId: string }
+ : Partial<SoupItemData<T>> & { id: string };
// A partial soup entity for optimistic updates.
export type SoupEntityPartial<T extends SoupEntityTag = SoupEntityTag> = {
diff --git a/js/app/packages/queries/soup/recently-viewed.ts b/js/app/packages/queries/soup/recently-viewed.ts
index 730909e800..b0a48b45c6 100644
--- a/js/app/packages/queries/soup/recently-viewed.ts
+++ b/js/app/packages/queries/soup/recently-viewed.ts
@@ -18,7 +18,11 @@ const RECENTLY_VIEWED_GC_TIME = 10 * 60 * 1000; // 10 minutes
const recentlyViewedArgs: SoupItemsQueryArgs = {
params: { sort_method: 'viewed_at', limit: RECENTLY_VIEWED_LIMIT },
- body: {},
+ body: {
+ call_filters: {
+ channel_ids: ['00000000-0000-0000-0000-000000000000'],
+ },
+ },
};
const recentlyViewedQueryKey = soupKeys.items(recentlyViewedArgs).queryKey;
@@ -37,12 +41,15 @@ export function useRecentlyViewedSoupQuery() {
},
})
);
- return page.items.map((item) => ({
- id: item.tag === 'channel' ? item.data.channel.id : item.data.id,
- viewedAt:
- (item.tag === 'channel' ? item.data.viewed_at : item.data.viewedAt) ??
- undefined,
- }));
+ return page.items
+ .filter((item) => item.tag !== 'callRecord')
+ .map((item) => ({
+ id: item.tag === 'channel' ? item.data.channel.id : item.data.id,
+ viewedAt:
+ (item.tag === 'channel'
+ ? item.data.viewed_at
+ : item.data.viewedAt) ?? undefined,
+ }));
},
staleTime: RECENTLY_VIEWED_STALE_TIME,
gcTime: RECENTLY_VIEWED_GC_TIME,
diff --git a/js/app/packages/queries/soup/transform-utils.ts b/js/app/packages/queries/soup/transform-utils.ts
index cefc72b76a..8a6cbcc3e4 100644
--- a/js/app/packages/queries/soup/transform-utils.ts
+++ b/js/app/packages/queries/soup/transform-utils.ts
@@ -20,6 +20,7 @@ import type {
EmailEntity,
ChannelEntity,
ChannelMessageEntity,
+ CallEntity,
} from '@entity';
import type { ChannelType } from '@service-comms/generated/models';
import type {
@@ -358,6 +359,7 @@ export const mapSoupPageToEntityList: (
| ProjectEntity
| EmailEntity
| ChannelEntity
+ | CallEntity
)[] = (data, options) => {
return data.items
.filter(
@@ -374,7 +376,8 @@ export const mapSoupPageToEntityList: (
| ChatEntity
| ProjectEntity
| EmailEntity
- | ChannelEntity => {
+ | ChannelEntity
+ | CallEntity => {
if (item.tag === 'chat') {
return {
...item.data,
@@ -441,6 +444,23 @@ export const mapSoupPageToEntityList: (
};
}
+ if (item.tag === 'callRecord') {
+ return {
+ type: 'call',
+ id: item.data.callId,
+ name: item.data.channelName ?? 'Call',
+ channelId: item.data.channelId,
+ channelName: item.data.channelName ?? undefined,
+ ownerId: item.data.createdBy,
+ createdAt: item.data.startedAt,
+ updatedAt: item.data.endedAt ?? item.data.startedAt,
+ sortTs: item.data.endedAt ?? item.data.startedAt,
+ isActive: item.data.isActive,
+ durationMs: item.data.durationMs ?? undefined,
+ participantIds: item.data.participants.map((p) => p.userId),
+ } satisfies CallEntity;
+ }
+
if (item.tag === 'channel') {
const out: ChannelEntity = {
type: 'channel',
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.ts
index e6b44aff3e..c10fc4784b 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
@@ -414,7 +414,16 @@ export const GetThreadResponse = z.object({
export const ListEntities = z
.object({
includeTypes: z.union([
- z.array(z.enum(['document', 'ai_chat', 'project', 'email', 'channel'])),
+ z.array(
+ z.enum([
+ 'document',
+ 'ai_chat',
+ 'project',
+ 'email',
+ 'channel',
+ 'call_record',
+ ])
+ ),
z.null(),
]),
sortBy: z.enum(['recently_viewed', 'recently_updated', 'recently_created']),
@@ -450,6 +459,11 @@ export const ListEntitiesResponse = z.object({
name: z.union([z.string(), z.null()]).optional(),
type: z.literal('channel'),
}),
+ z.object({
+ createdBy: z.string(),
+ id: z.string().uuid(),
+ type: z.literal('callRecord'),
+ }),
];
const errors = schemas.reduce<z.ZodError[]>(
(errors, schema) =>
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.ts
index deec8e4c6c..644982f9ff 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
@@ -829,7 +829,14 @@ export interface ListEntities {
* Filter to specific item types. If not provided, returns all types. Example: ["document", "email"] returns only documents and emails.
*/
includeTypes:
- | ('document' | 'ai_chat' | 'project' | 'email' | 'channel')[]
+ | (
+ | 'document'
+ | 'ai_chat'
+ | 'project'
+ | 'email'
+ | 'channel'
+ | 'call_record'
+ )[]
| null;
/**
* How to sort results: recently_viewed (default), recently_updated, or recently_created.
@@ -871,6 +878,11 @@ export interface ListEntitiesResponse {
name?: string | null;
type: 'channel';
}
+ | {
+ createdBy: string;
+ id: string;
+ type: 'callRecord';
+ }
)[];
summary: string;
}
diff --git a/js/app/packages/service-clients/service-search/generated/models/callFilters.ts b/js/app/packages/service-clients/service-search/generated/models/callFilters.ts
new file mode 100644
index 0000000000..48edd2553a
--- /dev/null
+++ b/js/app/packages/service-clients/service-search/generated/models/callFilters.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * search_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Filters for call records.
+ */
+export interface CallFilters {
+ /** Channel IDs to filter calls by. Empty to include all calls. */
+ channel_ids?: string[];
+}
diff --git a/js/app/packages/service-clients/service-search/generated/models/entityFilters.ts b/js/app/packages/service-clients/service-search/generated/models/entityFilters.ts
index d050177011..a6a85f51df 100644
--- a/js/app/packages/service-clients/service-search/generated/models/entityFilters.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/entityFilters.ts
@@ -4,6 +4,7 @@
* search_service
* OpenAPI spec version: 0.1.0
*/
+import type { CallFilters } from './callFilters';
import type { ChannelFilters } from './channelFilters';
import type { ChatFilters } from './chatFilters';
import type { DocumentFilters } from './documentFilters';
@@ -15,6 +16,8 @@ import type { PropertyFilter } from './propertyFilter';
* a bundle of all of the filters for each entity type
*/
export interface EntityFilters {
+ /** the bundled [CallFilters] */
+ call_filters?: CallFilters;
/** the bundled [ChannelFilters] */
channel_filters?: ChannelFilters;
/** the bundled [ChatFilters] */
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.ts
index 192b49d4c2..2e37211230 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
@@ -5,6 +5,7 @@
* OpenAPI spec version: 0.1.0
*/
+export * from './callFilters';
export * from './channelFilters';
export * from './channelFiltersImportance';
export * from './channelFiltersOrgId';
diff --git a/js/app/packages/service-clients/service-search/openapi.json b/js/app/packages/service-clients/service-search/openapi.json
index 58f9d559f3..e9f1b80919 100644
--- a/js/app/packages/service-clients/service-search/openapi.json
+++ b/js/app/packages/service-clients/service-search/openapi.json
@@ -173,6 +173,19 @@
},
"components": {
"schemas": {
+ "CallFilters": {
+ "type": "object",
+ "description": "Filters for call records.",
+ "properties": {
+ "channel_ids": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Channel IDs to filter calls by. Empty to include all calls."
+ }
+ }
+ },
"ChannelFilters": {
"type": "object",
"description": "The channel message filters used to filter down what channel messages you search over.",
@@ -1224,6 +1237,10 @@
"type": "object",
"description": "a bundle of all of the filters for each entity type",
"properties": {
+ "call_filters": {
+ "$ref": "#/components/schemas/CallFilters",
+ "description": "the bundled [CallFilters]"
+ },
"channel_filters": {
"$ref": "#/components/schemas/ChannelFilters",
"description": "the bundled [ChannelFilters]"
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callFilters.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callFilters.ts
new file mode 100644
index 0000000000..fce0a43ce1
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callFilters.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Filters for call records.
+ */
+export interface CallFilters {
+ /** Channel IDs to filter calls by. Empty to include all calls. */
+ channel_ids?: string[];
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callRecord.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callRecord.ts
index bf83046a14..73862d5d27 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/callRecord.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callRecord.ts
@@ -4,6 +4,7 @@
* document_storage_service
* OpenAPI spec version: 0.1.0
*/
+import type { CallRecordChannelName } from './callRecordChannelName';
import type { CallRecordDurationMs } from './callRecordDurationMs';
import type { CallRecordEgressId } from './callRecordEgressId';
import type { CallRecordEndedAt } from './callRecordEndedAt';
@@ -20,6 +21,8 @@ export interface CallRecord {
callId: string;
/** The channel this call belongs to. */
channelId: string;
+ /** Resolved display name for the channel. */
+ channelName?: CallRecordChannelName;
/** User who created the call. */
createdBy: string;
/** Call duration in milliseconds (None if still active). */
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callRecordChannelName.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordChannelName.ts
new file mode 100644
index 0000000000..c4ac42c760
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordChannelName.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Resolved display name for the channel.
+ */
+export type CallRecordChannelName = string | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/entityFilterAst.ts b/js/app/packages/service-clients/service-storage/generated/schemas/entityFilterAst.ts
index 93312076ba..d8e6be2138 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/entityFilterAst.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/entityFilterAst.ts
@@ -9,6 +9,8 @@
* Describes a bundle of filters that should be applied across different entity types
*/
export interface EntityFilterAst {
+ /** the filters that should be applied to the call entity */
+ callf?: unknown;
/** the filters that should be applied to the chat entity */
cf?: unknown;
/** the filters that should be applied to the channel entity */
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/entityFilters.ts b/js/app/packages/service-clients/service-storage/generated/schemas/entityFilters.ts
index 9cfd6d353f..f73fc23302 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/entityFilters.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/entityFilters.ts
@@ -4,6 +4,7 @@
* document_storage_service
* OpenAPI spec version: 0.1.0
*/
+import type { CallFilters } from './callFilters';
import type { ChannelFilters } from './channelFilters';
import type { ChatFilters } from './chatFilters';
import type { DocumentFilters } from './documentFilters';
@@ -15,6 +16,8 @@ import type { PropertyFilter } from './propertyFilter';
* a bundle of all of the filters for each entity type
*/
export interface EntityFilters {
+ /** the bundled [CallFilters] */
+ call_filters?: CallFilters;
/** the bundled [ChannelFilters] */
channel_filters?: ChannelFilters;
/** the bundled [ChatFilters] */
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
index 8bae896175..21b91e08de 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
@@ -77,7 +77,9 @@ export * from './basicDocumentType';
export * from './basicDocumentUpdatedAt';
export * from './bomPart';
export * from './callActiveResponse';
+export * from './callFilters';
export * from './callRecord';
+export * from './callRecordChannelName';
export * from './callRecordDurationMs';
export * from './callRecordEgressId';
export * from './callRecordEndedAt';
@@ -540,6 +542,12 @@ export * from './soupAttachmentFilename';
export * from './soupAttachmentMimeType';
export * from './soupAttachmentProviderAttachmentId';
export * from './soupAttachmentSizeBytes';
+export * from './soupCallRecord';
+export * from './soupCallRecordChannelName';
+export * from './soupCallRecordDurationMs';
+export * from './soupCallRecordEndedAt';
+export * from './soupCallRecordParticipant';
+export * from './soupCallRecordParticipantLeftAt';
export * from './soupChannel';
export * from './soupChannelAllOf';
export * from './soupChannelAllOfInteractedAt';
@@ -582,6 +590,8 @@ export * from './soupItemOneOfFive';
export * from './soupItemOneOfFiveTag';
export * from './soupItemOneOfNine';
export * from './soupItemOneOfNineTag';
+export * from './soupItemOneOfOneone';
+export * from './soupItemOneOfOneoneTag';
export * from './soupItemOneOfSeven';
export * from './soupItemOneOfSevenTag';
export * from './soupItemOneOfTag';
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecord.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecord.ts
new file mode 100644
index 0000000000..5d1864b196
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecord.ts
@@ -0,0 +1,35 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupCallRecordChannelName } from './soupCallRecordChannelName';
+import type { SoupCallRecordDurationMs } from './soupCallRecordDurationMs';
+import type { SoupCallRecordEndedAt } from './soupCallRecordEndedAt';
+import type { SoupCallRecordParticipant } from './soupCallRecordParticipant';
+
+/**
+ * A call record as displayed in Soup. Excludes room_name, egress_id,
+and transcript — fields that are irrelevant for the soup feed.
+ */
+export interface SoupCallRecord {
+ /** The call identifier. */
+ callId: string;
+ /** The channel this call belongs to. */
+ channelId: string;
+ /** Resolved display name for the channel. */
+ channelName?: SoupCallRecordChannelName;
+ /** User who created the call. */
+ createdBy: string;
+ /** Call duration in milliseconds (None if still active). */
+ durationMs?: SoupCallRecordDurationMs;
+ /** When the call ended (None if still active). */
+ endedAt?: SoupCallRecordEndedAt;
+ /** Whether the call is currently active. */
+ isActive: boolean;
+ /** Participants in the call. */
+ participants: SoupCallRecordParticipant[];
+ /** When the call started. */
+ startedAt: string;
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordChannelName.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordChannelName.ts
new file mode 100644
index 0000000000..c74f9a4344
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordChannelName.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Resolved display name for the channel.
+ */
+export type SoupCallRecordChannelName = string | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordDurationMs.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordDurationMs.ts
new file mode 100644
index 0000000000..e86273dcef
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordDurationMs.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Call duration in milliseconds (None if still active).
+ */
+export type SoupCallRecordDurationMs = number | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordEndedAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordEndedAt.ts
new file mode 100644
index 0000000000..414d4ad02e
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordEndedAt.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * When the call ended (None if still active).
+ */
+export type SoupCallRecordEndedAt = string | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordParticipant.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordParticipant.ts
new file mode 100644
index 0000000000..c92075aeec
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordParticipant.ts
@@ -0,0 +1,19 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupCallRecordParticipantLeftAt } from './soupCallRecordParticipantLeftAt';
+
+/**
+ * A participant in a call record, as displayed in Soup.
+ */
+export interface SoupCallRecordParticipant {
+ /** When the user joined the call. */
+ joinedAt: string;
+ /** When the user left (None if still in an active call). */
+ leftAt?: SoupCallRecordParticipantLeftAt;
+ /** The user id. */
+ userId: string;
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordParticipantLeftAt.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordParticipantLeftAt.ts
new file mode 100644
index 0000000000..f7d2a39bd3
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordParticipantLeftAt.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * When the user left (None if still in an active call).
+ */
+export type SoupCallRecordParticipantLeftAt = string | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupItem.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupItem.ts
index 129d5f240d..6e7c0588f2 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/soupItem.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupItem.ts
@@ -7,6 +7,7 @@
import type { SoupItemOneOf } from './soupItemOneOf';
import type { SoupItemOneOfFive } from './soupItemOneOfFive';
import type { SoupItemOneOfNine } from './soupItemOneOfNine';
+import type { SoupItemOneOfOneone } from './soupItemOneOfOneone';
import type { SoupItemOneOfSeven } from './soupItemOneOfSeven';
import type { SoupItemOneOfThree } from './soupItemOneOfThree';
@@ -15,4 +16,5 @@ export type SoupItem =
| SoupItemOneOfThree
| SoupItemOneOfFive
| SoupItemOneOfSeven
- | SoupItemOneOfNine;
+ | SoupItemOneOfNine
+ | SoupItemOneOfOneone;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupItemOneOfOneone.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupItemOneOfOneone.ts
new file mode 100644
index 0000000000..49747a0d06
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupItemOneOfOneone.ts
@@ -0,0 +1,13 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { SoupCallRecord } from './soupCallRecord';
+import type { SoupItemOneOfOneoneTag } from './soupItemOneOfOneoneTag';
+
+export type SoupItemOneOfOneone = {
+ data: SoupCallRecord;
+ tag: SoupItemOneOfOneoneTag;
+};
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupItemOneOfOneoneTag.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupItemOneOfOneoneTag.ts
new file mode 100644
index 0000000000..8f722b8f74
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupItemOneOfOneoneTag.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type SoupItemOneOfOneoneTag =
+ (typeof SoupItemOneOfOneoneTag)[keyof typeof SoupItemOneOfOneoneTag];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const SoupItemOneOfOneoneTag = {
+ callRecord: 'callRecord',
+} as const;
diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.ts
index 463db6d540..39fa9f878b 100644
--- a/js/app/packages/service-clients/service-storage/generated/zod.ts
+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts
@@ -827,6 +827,10 @@ export const getCallRecordResponse = zod
.string()
.uuid()
.describe('The channel this call belongs to.'),
+ channelName: zod
+ .string()
+ .nullish()
+ .describe('Resolved display name for the channel.'),
createdBy: zod.string().describe('User who created the call.'),
durationMs: zod
.number()
@@ -4696,6 +4700,65 @@ export const getItemsSoupResponse = zod.object({
),
tag: zod.enum(['channel']),
}),
+ zod.object({
+ data: zod
+ .object({
+ callId: zod.string().uuid().describe('The call identifier.'),
+ channelId: zod
+ .string()
+ .uuid()
+ .describe('The channel this call belongs to.'),
+ channelName: zod
+ .string()
+ .nullish()
+ .describe('Resolved display name for the channel.'),
+ createdBy: zod.string().describe('User who created the call.'),
+ durationMs: zod
+ .number()
+ .nullish()
+ .describe(
+ 'Call duration in milliseconds (None if still active).'
+ ),
+ endedAt: zod
+ .string()
+ .datetime({})
+ .nullish()
+ .describe('When the call ended (None if still active).'),
+ isActive: zod
+ .boolean()
+ .describe('Whether the call is currently active.'),
+ participants: zod
+ .array(
+ zod
+ .object({
+ joinedAt: zod
+ .string()
+ .datetime({})
+ .describe('When the user joined the call.'),
+ leftAt: zod
+ .string()
+ .datetime({})
+ .nullish()
+ .describe(
+ 'When the user left (None if still in an active call).'
+ ),
+ userId: zod.string().describe('The user id.'),
+ })
+ .describe(
+ 'A participant in a call record, as displayed in Soup.'
+ )
+ )
+ .describe('Participants in the call.'),
+ startedAt: zod
+ .string()
+ .datetime({})
+ .describe('When the call started.'),
+ })
+ .describe(
+ 'A call record as displayed in Soup. Excludes room_name, egress_id,\nand transcript — fields that are irrelevant for the soup feed.'
+ ),
+ tag: zod.enum(['callRecord']),
+ }),
])
.and(
zod.object({
@@ -4717,6 +4780,17 @@ export const postItemsSoupBodyLimitMin = 0;
export const postItemsSoupBody = zod
.object({
+ call_filters: zod
+ .object({
+ channel_ids: zod
+ .array(zod.string())
+ .optional()
+ .describe(
+ 'Channel IDs to filter calls by. Empty to include all calls.'
+ ),
+ })
+ .optional()
+ .describe('Filters for call records.'),
channel_filters: zod
.object({
channel_ids: zod
@@ -6302,6 +6376,65 @@ export const postItemsSoupResponse = zod.object({
),
tag: zod.enum(['channel']),
}),
+ zod.object({
+ data: zod
+ .object({
+ callId: zod.string().uuid().describe('The call identifier.'),
+ channelId: zod
+ .string()
+ .uuid()
+ .describe('The channel this call belongs to.'),
+ channelName: zod
+ .string()
+ .nullish()
+ .describe('Resolved display name for the channel.'),
+ createdBy: zod.string().describe('User who created the call.'),
+ durationMs: zod
+ .number()
+ .nullish()
+ .describe(
+ 'Call duration in milliseconds (None if still active).'
+ ),
+ endedAt: zod
+ .string()
+ .datetime({})
+ .nullish()
+ .describe('When the call ended (None if still active).'),
+ isActive: zod
+ .boolean()
+ .describe('Whether the call is currently active.'),
+ participants: zod
+ .array(
+ zod
+ .object({
+ joinedAt: zod
+ .string()
+ .datetime({})
+ .describe('When the user joined the call.'),
+ leftAt: zod
+ .string()
+ .datetime({})
+ .nullish()
+ .describe(
+ 'When the user left (None if still in an active call).'
+ ),
+ userId: zod.string().describe('The user id.'),
+ })
+ .describe(
+ 'A participant in a call record, as displayed in Soup.'
+ )
+ )
+ .describe('Participants in the call.'),
+ startedAt: zod
+ .string()
+ .datetime({})
+ .describe('When the call started.'),
+ })
+ .describe(
+ 'A call record as displayed in Soup. Excludes room_name, egress_id,\nand transcript — fields that are irrelevant for the soup feed.'
+ ),
+ tag: zod.enum(['callRecord']),
+ }),
])
.and(
zod.object({
@@ -6323,6 +6456,10 @@ export const postItemsSoupAstBodyLimitMin = 0;
export const postItemsSoupAstBody = zod
.object({
+ callf: zod
+ .any()
+ .optional()
+ .describe('the filters that should be applied to the call entity'),
cf: zod
.any()
.optional()
@@ -7575,6 +7712,65 @@ export const postItemsSoupAstResponse = zod.object({
),
tag: zod.enum(['channel']),
}),
+ zod.object({
+ data: zod
+ .object({
+ callId: zod.string().uuid().describe('The call identifier.'),
+ channelId: zod
+ .string()
+ .uuid()
+ .describe('The channel this call belongs to.'),
+ channelName: zod
+ .string()
+ .nullish()
+ .describe('Resolved display name for the channel.'),
+ createdBy: zod.string().describe('User who created the call.'),
+ durationMs: zod
+ .number()
+ .nullish()
+ .describe(
+ 'Call duration in milliseconds (None if still active).'
+ ),
+ endedAt: zod
+ .string()
+ .datetime({})
+ .nullish()
+ .describe('When the call ended (None if still active).'),
+ isActive: zod
+ .boolean()
+ .describe('Whether the call is currently active.'),
+ participants: zod
+ .array(
+ zod
+ .object({
+ joinedAt: zod
+ .string()
+ .datetime({})
+ .describe('When the user joined the call.'),
+ leftAt: zod
+ .string()
+ .datetime({})
+ .nullish()
+ .describe(
+ 'When the user left (None if still in an active call).'
+ ),
+ userId: zod.string().describe('The user id.'),
+ })
+ .describe(
+ 'A participant in a call record, as displayed in Soup.'
+ )
+ )
+ .describe('Participants in the call.'),
+ startedAt: zod
+ .string()
+ .datetime({})
+ .describe('When the call started.'),
+ })
+ .describe(
+ 'A call record as displayed in Soup. Excludes room_name, egress_id,\nand transcript — fields that are irrelevant for the soup feed.'
+ ),
+ tag: zod.enum(['callRecord']),
+ }),
])
.and(
zod.object({
diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.json
index a008233cee..862d768cda 100644
--- a/js/app/packages/service-clients/service-storage/openapi.json
+++ b/js/app/packages/service-clients/service-storage/openapi.json
@@ -5835,6 +5835,19 @@
}
}
},
+ "CallFilters": {
+ "type": "object",
+ "description": "Filters for call records.",
+ "properties": {
+ "channel_ids": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Channel IDs to filter calls by. Empty to include all calls."
+ }
+ }
+ },
"CallRecord": {
"type": "object",
"description": "Full record of a call, unifying rows from `calls` (active) and\n`call_records` (archived) into a single response shape.",
@@ -5859,6 +5872,10 @@
"format": "uuid",
"description": "The channel this call belongs to."
},
+ "channelName": {
+ "type": ["string", "null"],
+ "description": "Resolved display name for the channel."
+ },
"createdBy": {
"type": "string",
"description": "User who created the call."
@@ -7578,6 +7595,9 @@
"type": "object",
"description": "Describes a bundle of filters that should be applied across different entity types",
"properties": {
+ "callf": {
+ "description": "the filters that should be applied to the call entity"
+ },
"cf": {
"description": "the filters that should be applied to the chat entity"
},
@@ -7602,6 +7622,10 @@
"type": "object",
"description": "a bundle of all of the filters for each entity type",
"properties": {
+ "call_filters": {
+ "$ref": "#/components/schemas/CallFilters",
+ "description": "the bundled [CallFilters]"
+ },
"channel_filters": {
"$ref": "#/components/schemas/ChannelFilters",
"description": "the bundled [ChannelFilters]"
@@ -10396,6 +10420,85 @@
}
}
},
+ "SoupCallRecord": {
+ "type": "object",
+ "description": "A call record as displayed in Soup. Excludes room_name, egress_id,\nand transcript — fields that are irrelevant for the soup feed.",
+ "required": [
+ "callId",
+ "channelId",
+ "createdBy",
+ "startedAt",
+ "isActive",
+ "participants"
+ ],
+ "properties": {
+ "callId": {
+ "type": "string",
+ "format": "uuid",
+ "description": "The call identifier."
+ },
+ "channelId": {
+ "type": "string",
+ "format": "uuid",
+ "description": "The channel this call belongs to."
+ },
+ "channelName": {
+ "type": ["string", "null"],
+ "description": "Resolved display name for the channel."
+ },
+ "createdBy": {
+ "type": "string",
+ "description": "User who created the call."
+ },
+ "durationMs": {
+ "type": ["integer", "null"],
+ "format": "int64",
+ "description": "Call duration in milliseconds (None if still active)."
+ },
+ "endedAt": {
+ "type": ["string", "null"],
+ "format": "date-time",
+ "description": "When the call ended (None if still active)."
+ },
+ "isActive": {
+ "type": "boolean",
+ "description": "Whether the call is currently active."
+ },
+ "participants": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/SoupCallRecordParticipant"
+ },
+ "description": "Participants in the call."
+ },
+ "startedAt": {
+ "type": "string",
+ "format": "date-time",
+ "description": "When the call started."
+ }
+ }
+ },
+ "SoupCallRecordParticipant": {
+ "type": "object",
+ "description": "A participant in a call record, as displayed in Soup.",
+ "required": ["userId", "joinedAt"],
+ "properties": {
+ "joinedAt": {
+ "type": "string",
+ "format": "date-time",
+ "description": "When the user joined the call."
+ },
+ "leftAt": {
+ "type": ["string", "null"],
+ "format": "date-time",
+ "description": "When the user left (None if still in an active call)."
+ },
+ "userId": {
+ "type": "string",
+ "description": "The user id."
+ }
+ }
+ },
"SoupChannel": {
"allOf": [
{
@@ -10798,6 +10901,19 @@
"enum": ["channel"]
}
}
+ },
+ {
+ "type": "object",
+ "required": ["data", "tag"],
+ "properties": {
+ "data": {
+ "$ref": "#/components/schemas/SoupCallRecord"
+ },
+ "tag": {
+ "type": "string",
+ "enum": ["callRecord"]
+ }
+ }
}
]
},
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index d970906321..826971a484 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -94,6 +94,7 @@ dependencies = [
"anyhow",
"async-trait",
"axum",
+ "call",
"chrono",
"comms",
"connection",
@@ -1746,6 +1747,8 @@ dependencies = [
"chrono",
"connection",
"entity_access",
+ "filter_ast",
+ "item_filters",
"livekit-api",
"livekit-protocol",
"macro_aws_config",
@@ -1755,6 +1758,7 @@ dependencies = [
"model-entity",
"model-error-response",
"model_user",
+ "models_pagination",
"models_permissions",
"notification",
"serde",
@@ -2985,6 +2989,7 @@ dependencies = [
"aws-sdk-secretsmanager",
"aws-sdk-sqs",
"axum",
+ "call",
"chat",
"chrono",
"comms",
@@ -6380,6 +6385,7 @@ dependencies = [
"aws-sdk-secretsmanager",
"aws-sdk-sqs",
"axum",
+ "call",
"comms",
"document_storage_service_client",
"documents",
@@ -6441,6 +6447,7 @@ dependencies = [
"anyhow",
"aws-sdk-sqs",
"axum",
+ "call",
"chrono",
"comms",
"document_storage_service_client",
@@ -6853,6 +6860,7 @@ name = "models_soup"
version = "0.1.0"
dependencies = [
"anyhow",
+ "call",
"chrono",
"comms",
"document_sub_type",
@@ -10149,6 +10157,7 @@ dependencies = [
"async-trait",
"axum",
"axum-extra",
+ "call",
"chrono",
"comms",
"cool_asserts",
diff --git a/rust/cloud-storage/ai_tools/Cargo.toml b/rust/cloud-storage/ai_tools/Cargo.toml
index 1416075e77..d5b13659be 100644
--- a/rust/cloud-storage/ai_tools/Cargo.toml
+++ b/rust/cloud-storage/ai_tools/Cargo.toml
@@ -12,6 +12,7 @@ anthropic = { path = "../anthropic" }
anyhow.workspace = true
async-trait.workspace = true
axum = { workspace = true, features = ["macros"] }
+call = { path = "../call", default-features = false, features = ["ports"] }
chrono.workspace = true
dateparser.workspace = true
comms = { path = "../comms", features = ["outbound"] }
diff --git a/rust/cloud-storage/ai_tools/src/tool_context.rs b/rust/cloud-storage/ai_tools/src/tool_context.rs
index 8fe24292bb..73486276a2 100644
--- a/rust/cloud-storage/ai_tools/src/tool_context.rs
+++ b/rust/cloud-storage/ai_tools/src/tool_context.rs
@@ -118,6 +118,7 @@ pub type ToolSoupService = SoupImpl<
ToolFrecencyService,
ReadonlyEmailPreviewAdapter<ToolEmailService>,
ToolCommsService,
+ call::domain::ports::NoOpCallRecordQueryService,
>;
/// No-op notification service for properties (tools don't send assignment notifications)
diff --git a/rust/cloud-storage/call/.sqlx/query-32d668d355465b6e54567a087cf54754567424b802606a92cf204041a9b70bf4.json b/rust/cloud-storage/call/.sqlx/query-32d668d355465b6e54567a087cf54754567424b802606a92cf204041a9b70bf4.json
new file mode 100644
index 0000000000..2073a4b13b
--- /dev/null
+++ b/rust/cloud-storage/call/.sqlx/query-32d668d355465b6e54567a087cf54754567424b802606a92cf204041a9b70bf4.json
@@ -0,0 +1,34 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT u.id as user_profile_id, mui.first_name, mui.last_name\n FROM macro_user_info mui\n JOIN \"User\" u ON mui.macro_user_id = u.macro_user_id\n WHERE u.id = ANY($1)\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "user_profile_id",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 1,
+ "name": "first_name",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 2,
+ "name": "last_name",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "TextArray"
+ ]
+ },
+ "nullable": [
+ false,
+ true,
+ true
+ ]
+ },
+ "hash": "32d668d355465b6e54567a087cf54754567424b802606a92cf204041a9b70bf4"
+}
diff --git a/rust/cloud-storage/call/.sqlx/query-4fbbbf3257ecffd107a3d848ab980c51f5a28b25de618cd976b9871b0d6bcdec.json b/rust/cloud-storage/call/.sqlx/query-4fbbbf3257ecffd107a3d848ab980c51f5a28b25de618cd976b9871b0d6bcdec.json
new file mode 100644
index 0000000000..aac1f77fbe
--- /dev/null
+++ b/rust/cloud-storage/call/.sqlx/query-4fbbbf3257ecffd107a3d848ab980c51f5a28b25de618cd976b9871b0d6bcdec.json
@@ -0,0 +1,79 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT\n id as \"call_id!\",\n channel_id as \"channel_id!\",\n room_name as \"room_name!\",\n created_by as \"created_by!\",\n created_at as \"started_at!\",\n NULL::timestamptz as \"ended_at\",\n NULL::bigint as \"duration_ms\",\n egress_id,\n recording_key,\n true as \"is_active!\"\n FROM calls c\n WHERE EXISTS (\n SELECT 1 FROM call_participants cp\n WHERE cp.call_id = c.id AND cp.user_id = $1 AND cp.left_at IS NULL\n )\n AND ($3::bool IS FALSE OR c.channel_id = ANY($4))\n UNION ALL\n SELECT\n id as \"call_id!\",\n channel_id as \"channel_id!\",\n room_name as \"room_name!\",\n created_by as \"created_by!\",\n started_at as \"started_at!\",\n ended_at as \"ended_at\",\n duration_ms as \"duration_ms\",\n egress_id,\n recording_key,\n false as \"is_active!\"\n FROM call_records cr\n WHERE EXISTS (\n SELECT 1 FROM call_record_participants crp\n WHERE crp.call_record_id = cr.id AND crp.user_id = $1\n )\n AND ($3::bool IS FALSE OR cr.channel_id = ANY($4))\n ORDER BY \"started_at!\" DESC\n LIMIT $2\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "call_id!",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "channel_id!",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 2,
+ "name": "room_name!",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 3,
+ "name": "created_by!",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 4,
+ "name": "started_at!",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 5,
+ "name": "ended_at",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 6,
+ "name": "duration_ms",
+ "type_info": "Int8"
+ },
+ {
+ "ordinal": 7,
+ "name": "egress_id",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 8,
+ "name": "recording_key",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 9,
+ "name": "is_active!",
+ "type_info": "Bool"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text",
+ "Int8",
+ "Bool",
+ "UuidArray"
+ ]
+ },
+ "nullable": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ]
+ },
+ "hash": "4fbbbf3257ecffd107a3d848ab980c51f5a28b25de618cd976b9871b0d6bcdec"
+}
diff --git a/rust/cloud-storage/call/.sqlx/query-58bbac52930eed32381004f41604e394292af9ad8de8d7ce3ed45358ad62adba.json b/rust/cloud-storage/call/.sqlx/query-58bbac52930eed32381004f41604e394292af9ad8de8d7ce3ed45358ad62adba.json
deleted file mode 100644
index 5813d4c8ad..0000000000
--- a/rust/cloud-storage/call/.sqlx/query-58bbac52930eed32381004f41604e394292af9ad8de8d7ce3ed45358ad62adba.json
+++ /dev/null
@@ -1,58 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT id, channel_id, room_name, created_by, started_at, ended_at, duration_ms\n FROM call_records\n WHERE id = $1\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id",
- "type_info": "Uuid"
- },
- {
- "ordinal": 1,
- "name": "channel_id",
- "type_info": "Uuid"
- },
- {
- "ordinal": 2,
- "name": "room_name",
- "type_info": "Text"
- },
- {
- "ordinal": 3,
- "name": "created_by",
- "type_info": "Text"
- },
- {
- "ordinal": 4,
- "name": "started_at",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 5,
- "name": "ended_at",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 6,
- "name": "duration_ms",
- "type_info": "Int8"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid"
- ]
- },
- "nullable": [
- false,
- false,
- false,
- false,
- false,
- false,
- false
- ]
- },
- "hash": "58bbac52930eed32381004f41604e394292af9ad8de8d7ce3ed45358ad62adba"
-}
diff --git a/rust/cloud-storage/call/.sqlx/query-6ca02c6511b3279813710cb93a275d215c3edeb60072739f71e5e7324772349c.json b/rust/cloud-storage/call/.sqlx/query-6ca02c6511b3279813710cb93a275d215c3edeb60072739f71e5e7324772349c.json
new file mode 100644
index 0000000000..0322fc82a7
--- /dev/null
+++ b/rust/cloud-storage/call/.sqlx/query-6ca02c6511b3279813710cb93a275d215c3edeb60072739f71e5e7324772349c.json
@@ -0,0 +1,34 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT id, name, channel_type::text as \"channel_type!\"\n FROM comms_channels\n WHERE id = ANY($1)\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "name",
+ "type_info": "Varchar"
+ },
+ {
+ "ordinal": 2,
+ "name": "channel_type!",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "UuidArray"
+ ]
+ },
+ "nullable": [
+ false,
+ true,
+ null
+ ]
+ },
+ "hash": "6ca02c6511b3279813710cb93a275d215c3edeb60072739f71e5e7324772349c"
+}
diff --git a/rust/cloud-storage/call/.sqlx/query-6dae1be229aa02fd589a494c2219f9ffafb95d71284c9062109b4fc7ccf80206.json b/rust/cloud-storage/call/.sqlx/query-6dae1be229aa02fd589a494c2219f9ffafb95d71284c9062109b4fc7ccf80206.json
new file mode 100644
index 0000000000..4905496d03
--- /dev/null
+++ b/rust/cloud-storage/call/.sqlx/query-6dae1be229aa02fd589a494c2219f9ffafb95d71284c9062109b4fc7ccf80206.json
@@ -0,0 +1,28 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT channel_id, user_id\n FROM comms_channel_participants\n WHERE channel_id = ANY($1) AND left_at IS NULL\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "channel_id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "user_id",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "UuidArray"
+ ]
+ },
+ "nullable": [
+ false,
+ false
+ ]
+ },
+ "hash": "6dae1be229aa02fd589a494c2219f9ffafb95d71284c9062109b4fc7ccf80206"
+}
diff --git a/rust/cloud-storage/call/.sqlx/query-7153394f8eb16ffb119e7cf8f3eb00791668bed040994bf21e00b397f4b05405.json b/rust/cloud-storage/call/.sqlx/query-7153394f8eb16ffb119e7cf8f3eb00791668bed040994bf21e00b397f4b05405.json
new file mode 100644
index 0000000000..4f77384840
--- /dev/null
+++ b/rust/cloud-storage/call/.sqlx/query-7153394f8eb16ffb119e7cf8f3eb00791668bed040994bf21e00b397f4b05405.json
@@ -0,0 +1,34 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT user_id, joined_at, left_at\n FROM call_participants\n WHERE call_id = $1\n ORDER BY joined_at ASC\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "user_id",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 1,
+ "name": "joined_at",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 2,
+ "name": "left_at",
+ "type_info": "Timestamptz"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ false,
+ false,
+ true
+ ]
+ },
+ "hash": "7153394f8eb16ffb119e7cf8f3eb00791668bed040994bf21e00b397f4b05405"
+}
diff --git a/rust/cloud-storage/call/.sqlx/query-740f552e0d43b70ba07c7826a01a2e03e915830607edfbc398dd1dbe2845d682.json b/rust/cloud-storage/call/.sqlx/query-740f552e0d43b70ba07c7826a01a2e03e915830607edfbc398dd1dbe2845d682.json
deleted file mode 100644
index d189f13652..0000000000
--- a/rust/cloud-storage/call/.sqlx/query-740f552e0d43b70ba07c7826a01a2e03e915830607edfbc398dd1dbe2845d682.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "SELECT recording_key FROM call_records WHERE id = $1",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "recording_key",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid"
- ]
- },
- "nullable": [
- true
- ]
- },
- "hash": "740f552e0d43b70ba07c7826a01a2e03e915830607edfbc398dd1dbe2845d682"
-}
diff --git a/rust/cloud-storage/call/.sqlx/query-79b6d9d4f6b3469253e2fe01fef337bec8f6d447731718573f170ff4fa24b88d.json b/rust/cloud-storage/call/.sqlx/query-79b6d9d4f6b3469253e2fe01fef337bec8f6d447731718573f170ff4fa24b88d.json
deleted file mode 100644
index 3413c6dfbf..0000000000
--- a/rust/cloud-storage/call/.sqlx/query-79b6d9d4f6b3469253e2fe01fef337bec8f6d447731718573f170ff4fa24b88d.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT speaker_id, content, sequence_num\n FROM call_transcripts\n WHERE call_id = $1\n ORDER BY sequence_num ASC\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "speaker_id",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "content",
- "type_info": "Text"
- },
- {
- "ordinal": 2,
- "name": "sequence_num",
- "type_info": "Int4"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid"
- ]
- },
- "nullable": [
- false,
- false,
- false
- ]
- },
- "hash": "79b6d9d4f6b3469253e2fe01fef337bec8f6d447731718573f170ff4fa24b88d"
-}
diff --git a/rust/cloud-storage/call/.sqlx/query-7e26dfe09fa65aa0bad62337b51c2d22e4703c7fe2035725142f180193c35808.json b/rust/cloud-storage/call/.sqlx/query-7e26dfe09fa65aa0bad62337b51c2d22e4703c7fe2035725142f180193c35808.json
new file mode 100644
index 0000000000..a7c9206f75
--- /dev/null
+++ b/rust/cloud-storage/call/.sqlx/query-7e26dfe09fa65aa0bad62337b51c2d22e4703c7fe2035725142f180193c35808.json
@@ -0,0 +1,34 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT user_id, joined_at, left_at\n FROM call_record_participants\n WHERE call_record_id = $1\n ORDER BY joined_at ASC\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "user_id",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 1,
+ "name": "joined_at",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 2,
+ "name": "left_at",
+ "type_info": "Timestamptz"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ false,
+ false,
+ true
+ ]
+ },
+ "hash": "7e26dfe09fa65aa0bad62337b51c2d22e4703c7fe2035725142f180193c35808"
+}
diff --git a/rust/cloud-storage/call/.sqlx/query-5764bc7a77e72625b9f348045d6ee0a3f1c0e1e6b81c50118f20fc7e6881eb9d.json b/rust/cloud-storage/call/.sqlx/query-80ec8203f3090c1d40c0c782808e4a2bfbc92a06c2c37ab8a8e243f54eb93d03.json
similarity index 52%
rename from rust/cloud-storage/call/.sqlx/query-5764bc7a77e72625b9f348045d6ee0a3f1c0e1e6b81c50118f20fc7e6881eb9d.json
rename to rust/cloud-storage/call/.sqlx/query-80ec8203f3090c1d40c0c782808e4a2bfbc92a06c2c37ab8a8e243f54eb93d03.json
index 3ddc5f257c..a3dd0b24d4 100644
--- a/rust/cloud-storage/call/.sqlx/query-5764bc7a77e72625b9f348045d6ee0a3f1c0e1e6b81c50118f20fc7e6881eb9d.json
+++ b/rust/cloud-storage/call/.sqlx/query-80ec8203f3090c1d40c0c782808e4a2bfbc92a06c2c37ab8a8e243f54eb93d03.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT user_id\n FROM call_record_participants\n WHERE call_record_id = $1\n ORDER BY joined_at ASC\n ",
+ "query": "\n SELECT user_id\n FROM comms_channel_participants\n WHERE channel_id = $1 AND left_at IS NULL\n ",
"describe": {
"columns": [
{
@@ -18,5 +18,5 @@
false
]
},
- "hash": "5764bc7a77e72625b9f348045d6ee0a3f1c0e1e6b81c50118f20fc7e6881eb9d"
+ "hash": "80ec8203f3090c1d40c0c782808e4a2bfbc92a06c2c37ab8a8e243f54eb93d03"
}
diff --git a/rust/cloud-storage/call/.sqlx/query-9b8eca330ae09809a79941d077aafafda5a2f65b86d94d3f517a34efa6d412a1.json b/rust/cloud-storage/call/.sqlx/query-9b8eca330ae09809a79941d077aafafda5a2f65b86d94d3f517a34efa6d412a1.json
deleted file mode 100644
index 0280529c3b..0000000000
--- a/rust/cloud-storage/call/.sqlx/query-9b8eca330ae09809a79941d077aafafda5a2f65b86d94d3f517a34efa6d412a1.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "SELECT COUNT(*) as \"count!\" FROM call_transcripts WHERE call_id = $1",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "count!",
- "type_info": "Int8"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid"
- ]
- },
- "nullable": [
- null
- ]
- },
- "hash": "9b8eca330ae09809a79941d077aafafda5a2f65b86d94d3f517a34efa6d412a1"
-}
diff --git a/rust/cloud-storage/call/.sqlx/query-a7baf370108371fedbc9eec0287181a1581a3cc2c483b49f0b7579dd7338bd22.json b/rust/cloud-storage/call/.sqlx/query-a7baf370108371fedbc9eec0287181a1581a3cc2c483b49f0b7579dd7338bd22.json
deleted file mode 100644
index 90d0e8b42c..0000000000
--- a/rust/cloud-storage/call/.sqlx/query-a7baf370108371fedbc9eec0287181a1581a3cc2c483b49f0b7579dd7338bd22.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "SELECT share_permission_id FROM call_records WHERE id = $1",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "share_permission_id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "a7baf370108371fedbc9eec0287181a1581a3cc2c483b49f0b7579dd7338bd22"
-}
diff --git a/rust/cloud-storage/call/.sqlx/query-cd19706a12766971babf411d05ea10a1fe2cfc2898a8043d9d648c177ef9cb37.json b/rust/cloud-storage/call/.sqlx/query-cd19706a12766971babf411d05ea10a1fe2cfc2898a8043d9d648c177ef9cb37.json
deleted file mode 100644
index 289093af9d..0000000000
--- a/rust/cloud-storage/call/.sqlx/query-cd19706a12766971babf411d05ea10a1fe2cfc2898a8043d9d648c177ef9cb37.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT user_id, left_at\n FROM call_record_participants\n WHERE call_record_id = $1\n ORDER BY joined_at ASC\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "user_id",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "left_at",
- "type_info": "Timestamptz"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid"
- ]
- },
- "nullable": [
- false,
- true
- ]
- },
- "hash": "cd19706a12766971babf411d05ea10a1fe2cfc2898a8043d9d648c177ef9cb37"
-}
diff --git a/rust/cloud-storage/call/.sqlx/query-e233b0f2888b75bd70f9b6ecc11593c8be6cf5d43c234873dbc6f3b3296c8f00.json b/rust/cloud-storage/call/.sqlx/query-e233b0f2888b75bd70f9b6ecc11593c8be6cf5d43c234873dbc6f3b3296c8f00.json
deleted file mode 100644
index a9fc472b29..0000000000
--- a/rust/cloud-storage/call/.sqlx/query-e233b0f2888b75bd70f9b6ecc11593c8be6cf5d43c234873dbc6f3b3296c8f00.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "SELECT share_permission_id FROM calls WHERE id = $1",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "share_permission_id",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "e233b0f2888b75bd70f9b6ecc11593c8be6cf5d43c234873dbc6f3b3296c8f00"
-}
diff --git a/rust/cloud-storage/call/.sqlx/query-f4f6aabb3ebbf6f8d2361b1cf8a63948bd3b0becdfdd21d780a08ffa05b2b963.json b/rust/cloud-storage/call/.sqlx/query-f4f6aabb3ebbf6f8d2361b1cf8a63948bd3b0becdfdd21d780a08ffa05b2b963.json
new file mode 100644
index 0000000000..a8cc7e657a
--- /dev/null
+++ b/rust/cloud-storage/call/.sqlx/query-f4f6aabb3ebbf6f8d2361b1cf8a63948bd3b0becdfdd21d780a08ffa05b2b963.json
@@ -0,0 +1,28 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT name, channel_type::text as \"channel_type!\"\n FROM comms_channels\n WHERE id = $1\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "name",
+ "type_info": "Varchar"
+ },
+ {
+ "ordinal": 1,
+ "name": "channel_type!",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ true,
+ null
+ ]
+ },
+ "hash": "f4f6aabb3ebbf6f8d2361b1cf8a63948bd3b0becdfdd21d780a08ffa05b2b963"
+}
diff --git a/rust/cloud-storage/call/.sqlx/query-fdce21902ca26481495bd105b110b6da30dde18159813f92012d47c820b1c5a5.json b/rust/cloud-storage/call/.sqlx/query-fdce21902ca26481495bd105b110b6da30dde18159813f92012d47c820b1c5a5.json
deleted file mode 100644
index 2f7d64c92f..0000000000
--- a/rust/cloud-storage/call/.sqlx/query-fdce21902ca26481495bd105b110b6da30dde18159813f92012d47c820b1c5a5.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT speaker_id, content, sequence_num\n FROM call_record_transcripts\n WHERE call_record_id = $1\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "speaker_id",
- "type_info": "Text"
- },
- {
- "ordinal": 1,
- "name": "content",
- "type_info": "Text"
- },
- {
- "ordinal": 2,
- "name": "sequence_num",
- "type_info": "Int4"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid"
- ]
- },
- "nullable": [
- false,
- false,
- false
- ]
- },
- "hash": "fdce21902ca26481495bd105b110b6da30dde18159813f92012d47c820b1c5a5"
-}
diff --git a/rust/cloud-storage/call/Cargo.toml b/rust/cloud-storage/call/Cargo.toml
index 3ff681d17a..fe8a7d798c 100644
--- a/rust/cloud-storage/call/Cargo.toml
+++ b/rust/cloud-storage/call/Cargo.toml
@@ -36,10 +36,13 @@ connection = { path = "../connection", default-features = false, features = [
entity_access = { path = "../entity_access", optional = true, default-features = false, features = [
"ports",
] }
+filter_ast = { path = "../filter_ast" }
+item_filters = { path = "../item_filters" }
livekit-api = { workspace = true, optional = true }
livekit-protocol = { workspace = true, optional = true }
macro_aws_config = { path = "../macro_aws_config", optional = true, features = ["s3"] }
macro_user_id = { path = "../macro_user_id" }
+models_pagination = { path = "../models_pagination" }
model-entity = { path = "../model-entity" }
model-error-response = { path = "../model-error-response", optional = true }
model_user = { path = "../model_user", optional = true, features = ["axum"] }
diff --git a/rust/cloud-storage/call/src/domain/channel_name.rs b/rust/cloud-storage/call/src/domain/channel_name.rs
new file mode 100644
index 0000000000..217a83c10e
--- /dev/null
+++ b/rust/cloud-storage/call/src/domain/channel_name.rs
@@ -0,0 +1,121 @@
+//! Channel name resolution logic.
+//!
+//! Resolves the display name for a channel based on its type, stored name,
+//! and participants. Mirrors the logic in the `comms` crate's
+//! `domain::models::channel_name` module.
+
+use std::collections::HashMap;
+
+use macro_user_id::{cowlike::CowLike, email::ReadEmailParts, user_id::MacroUserIdStr};
+use uuid::Uuid;
+
+/// Maps user IDs to display names.
+pub type NameLookup = HashMap<String, String>;
+
+/// Resolve the display name for a channel.
+///
+/// `channel_type` is the raw Postgres enum value (`"public"`,
+/// `"organization"`, `"private"`, `"direct_message"`, `"team"`).
+pub fn resolve_channel_name(
+ channel_type: &str,
+ channel_name: Option<&str>,
+ participant_user_ids: &[MacroUserIdStr<'_>],
+ channel_id: &Uuid,
+ user_id: MacroUserIdStr<'_>,
+ name_lookup: &NameLookup,
+) -> String {
+ match channel_type {
+ "organization" | "public" => channel_name.map(|n| n.to_string()).unwrap_or_else(|| {
+ tracing::warn!(
+ ?channel_id,
+ "organization or public channel should have a name"
+ );
+ if channel_type == "organization" {
+ "Organization"
+ } else {
+ "Public"
+ }
+ .to_string()
+ }),
+ "private" => resolve_private_channel_name(channel_name, participant_user_ids, name_lookup),
+ "direct_message" => resolve_direct_message_channel_name(
+ channel_name,
+ participant_user_ids,
+ channel_id,
+ user_id,
+ name_lookup,
+ ),
+ "team" => channel_name.map(|n| n.to_string()).unwrap_or_else(|| {
+ tracing::warn!(?channel_id, "team channel should have a name");
+ "Team".to_string()
+ }),
+ _ => channel_name.unwrap_or("Unknown").to_string(),
+ }
+}
+
+fn resolve_private_channel_name(
+ channel_name: Option<&str>,
+ participant_user_ids: &[MacroUserIdStr<'_>],
+ name_lookup: &NameLookup,
+) -> String {
+ if let Some(name) = channel_name
+ && !name.trim().is_empty()
+ {
+ return name.to_string();
+ }
+
+ participant_user_ids
+ .iter()
+ .map(|id| id_to_display_name(id.copied(), name_lookup))
+ .collect::<Vec<String>>()
+ .join(", ")
+}
+
+fn resolve_direct_message_channel_name(
+ channel_name: Option<&str>,
+ participant_user_ids: &[MacroUserIdStr<'_>],
+ channel_id: &Uuid,
+ user_id: MacroUserIdStr<'_>,
+ name_lookup: &NameLookup,
+) -> String {
+ if channel_name.is_some() {
+ tracing::warn!(?channel_id, "direct message channel should not have a name");
+ }
+
+ if !participant_user_ids
+ .iter()
+ .any(|p| p.as_ref() == user_id.as_ref())
+ {
+ return resolve_private_channel_name(channel_name, participant_user_ids, name_lookup);
+ }
+
+ let other = participant_user_ids
+ .iter()
+ .find(|p| p.as_ref() != user_id.as_ref());
+
+ if let Some(other) = other {
+ id_to_display_name(other.copied(), name_lookup)
+ } else {
+ "Unknown".to_string()
+ }
+}
+
+fn id_to_display_name(id: MacroUserIdStr<'_>, name_lookup: &NameLookup) -> String {
+ match name_lookup.get(id.as_ref()) {
+ Some(name) if !name.trim().is_empty() => name.clone(),
+ _ => id.email_part().local_part().to_string(),
+ }
+}
+
+/// Build a display name from optional first and last name parts.
+///
+/// Returns `None` if both are missing or `"N/A"`.
+pub fn display_name(first: Option<&str>, last: Option<&str>) -> Option<String> {
+ const NA: &str = "N/A";
+ match (first.filter(|v| *v != NA), last.filter(|v| *v != NA)) {
+ (None, None) => None,
+ (None, Some(last)) => Some(last.to_string()),
+ (Some(first), None) => Some(first.to_string()),
+ (Some(first), Some(last)) => Some(format!("{first} {last}")),
+ }
+}
diff --git a/rust/cloud-storage/call/src/domain/mod.rs b/rust/cloud-storage/call/src/domain/mod.rs
index f080d971b1..5139551d58 100644
--- a/rust/cloud-storage/call/src/domain/mod.rs
+++ b/rust/cloud-storage/call/src/domain/mod.rs
@@ -1,3 +1,6 @@
+/// Channel name resolution logic.
+pub mod channel_name;
+
/// Domain models for calls.
pub mod models;
diff --git a/rust/cloud-storage/call/src/domain/models.rs b/rust/cloud-storage/call/src/domain/models.rs
index edf110ff3f..715d888b9d 100644
--- a/rust/cloud-storage/call/src/domain/models.rs
+++ b/rust/cloud-storage/call/src/domain/models.rs
@@ -3,7 +3,9 @@
use std::fmt;
use chrono::{DateTime, Utc};
+use item_filters::ast::{LiteralTree, call::CallLiteral};
use macro_user_id::user_id::MacroUserIdStr;
+use models_pagination::{Query, SimpleSortMethod};
use uuid::Uuid;
/// Represents an active call in a channel.
@@ -196,6 +198,8 @@ pub struct CallRecord {
pub recording_key: Option<String>,
/// Presigned URL for the call recording, if available.
pub recording_url: Option<String>,
+ /// Resolved display name for the channel.
+ pub channel_name: Option<String>,
/// Whether the call is currently active (from `calls` table).
pub is_active: bool,
/// Participants (both active and historic).
@@ -204,6 +208,17 @@ pub struct CallRecord {
pub transcript: Vec<CallRecordTranscriptSegment>,
}
+/// Request to fetch recent call records for a user (used by Soup).
+#[derive(Debug)]
+pub struct GetCallRecordsRequest {
+ /// The user whose call records to fetch.
+ pub user_id: MacroUserIdStr<'static>,
+ /// Maximum number of records to return.
+ pub limit: u32,
+ /// Sort or cursor-based pagination query with optional filter.
+ pub query: Query<Uuid, SimpleSortMethod, LiteralTree<CallLiteral>>,
+}
+
/// Errors that can occur during call operations.
#[derive(Debug, thiserror::Error)]
pub enum CallError {
diff --git a/rust/cloud-storage/call/src/domain/ports.rs b/rust/cloud-storage/call/src/domain/ports.rs
index 2b2cef8a22..be7bf236ab 100644
--- a/rust/cloud-storage/call/src/domain/ports.rs
+++ b/rust/cloud-storage/call/src/domain/ports.rs
@@ -9,9 +9,12 @@ use entity_access::domain::models::{EntityAccessReceipt, MemberParticipantRole};
use macro_user_id::user_id::MacroUserIdStr;
use uuid::Uuid;
+use item_filters::ast::{LiteralTree, call::CallLiteral};
+
use super::models::{
Call, CallActiveResponse, CallError, CallParticipant, CallRecord, CallTokenResponse,
- CallWebhookEvent, EgressS3Config, LeaveCallResponse, TranscriptSegmentRequest,
+ CallWebhookEvent, EgressS3Config, GetCallRecordsRequest, LeaveCallResponse,
+ TranscriptSegmentRequest,
};
/// Repository port for persisting call state to the database.
@@ -140,6 +143,26 @@ pub trait CallRepository: Send + Sync + 'static {
&self,
call_id: &Uuid,
) -> impl Future<Output = Result<Option<CallRecord>, Self::Err>> + Send;
+
+ /// Fetch the most recent call records where the given user was a
+ /// participant, spanning both active (`calls` + `call_participants`)
+ /// and archived (`call_records` + `call_record_participants`) tables.
+ /// Transcript data is intentionally omitted. Results are ordered by
+ /// start time descending and capped at `limit`.
+ /// An optional filter tree can narrow results (e.g. by channel_id).
+ fn get_call_records_by_user<'a>(
+ &self,
+ user_id: MacroUserIdStr<'a>,
+ limit: u32,
+ filter: &LiteralTree<CallLiteral>,
+ ) -> impl Future<Output = Result<Vec<CallRecord>, Self::Err>> + Send;
+
+ /// Resolve the display name for a single channel.
+ fn resolve_channel_name<'a>(
+ &self,
+ channel_id: &Uuid,
+ user_id: MacroUserIdStr<'a>,
+ ) -> impl Future<Output = Result<Option<String>, Self::Err>> + Send;
}
/// Storage port for generating presigned recording URLs.
@@ -260,3 +283,31 @@ pub trait CallService: Send + Sync + 'static {
receipt: EntityAccessReceipt<MemberParticipantRole>,
) -> impl Future<Output = Result<CallRecord, CallError>> + Send;
}
+
+/// Lightweight read-only port for querying call records in Soup.
+///
+/// This trait is intentionally separate from [`CallService`] — Soup only
+/// needs a read-only list of recent call records, not the full call
+/// management API.
+pub trait CallRecordQueryService: Send + Sync + 'static {
+ /// Fetch the most recent call records the user participated in,
+ /// ordered by `started_at` descending. Transcript data is excluded.
+ fn get_user_call_records(
+ &self,
+ req: GetCallRecordsRequest,
+ ) -> impl Future<Output = Result<Vec<CallRecord>, CallError>> + Send;
+}
+
+/// No-op implementation of [`CallRecordQueryService`] for services
+/// that do not have call infrastructure.
+pub struct NoOpCallRecordQueryService;
+
+impl CallRecordQueryService for NoOpCallRecordQueryService {
+ /// Always returns an empty list.
+ async fn get_user_call_records(
+ &self,
+ _req: GetCallRecordsRequest,
+ ) -> Result<Vec<CallRecord>, CallError> {
+ Ok(Vec::new())
+ }
+}
diff --git a/rust/cloud-storage/call/src/domain/service.rs b/rust/cloud-storage/call/src/domain/service.rs
index faa6a3c3f6..32aca17bec 100644
--- a/rust/cloud-storage/call/src/domain/service.rs
+++ b/rust/cloud-storage/call/src/domain/service.rs
@@ -21,9 +21,11 @@ use uuid::Uuid;
use super::models::{
CallActiveResponse, CallError, CallRecord, CallTokenResponse, EgressS3Config,
- LeaveCallResponse, TranscriptSegmentRequest,
+ GetCallRecordsRequest, LeaveCallResponse, TranscriptSegmentRequest,
+};
+use super::ports::{
+ CallRecordQueryService, CallRepository, CallRtcClient, CallService, RecordingStorage,
};
-use super::ports::{CallRepository, CallRtcClient, CallService, RecordingStorage};
/// The concrete call service implementation.
pub struct CallServiceImpl<
@@ -600,6 +602,10 @@ impl<
let call_id = Uuid::parse_str(&entity.entity_id)
.map_err(|_| CallError::Internal(anyhow::anyhow!("invalid call_id in receipt")))?;
+ let user_id = receipt
+ .get_authenticated_user()
+ .map_err(|_| CallError::Auth)?;
+
let mut record = self
.repo
.get_call_record_by_call_id(&call_id)
@@ -616,6 +622,12 @@ impl<
.ok();
}
+ record.channel_name = self
+ .repo
+ .resolve_channel_name(&record.channel_id, user_id.copied())
+ .await
+ .map_err(|e| CallError::Internal(e.into()))?;
+
Ok(record)
}
@@ -656,3 +668,31 @@ fn extract_recording_key(file_url: &str) -> &str {
.map(|idx| &file_url[idx + "calls/".len()..])
.unwrap_or(file_url)
}
+
+/// Lightweight implementation of [`CallRecordQueryService`] for read-only
+/// call record queries. Unlike [`CallServiceImpl`], this only requires a
+/// repository — no RTC client, notifications, or entity access.
+pub struct CallRecordQueryServiceImpl<R: CallRepository> {
+ repo: R,
+}
+
+impl<R: CallRepository> CallRecordQueryServiceImpl<R> {
+ /// Create a new query service with the given repository.
+ pub fn new(repo: R) -> Self {
+ Self { repo }
+ }
+}
+
+impl<R: CallRepository> CallRecordQueryService for CallRecordQueryServiceImpl<R> {
+ #[tracing::instrument(err, skip(self))]
+ async fn get_user_call_records(
+ &self,
+ req: GetCallRecordsRequest,
+ ) -> Result<Vec<CallRecord>, CallError> {
+ let filter = req.query.filter();
+ self.repo
+ .get_call_records_by_user(req.user_id.copied(), req.limit, filter)
+ .await
+ .map_err(|e| CallError::Internal(e.into()))
+ }
+}
diff --git a/rust/cloud-storage/call/src/outbound/pg_call_repo.rs b/rust/cloud-storage/call/src/outbound/pg_call_repo.rs
index b73eb0d0c9..9ad631fe19 100644
--- a/rust/cloud-storage/call/src/outbound/pg_call_repo.rs
+++ b/rust/cloud-storage/call/src/outbound/pg_call_repo.rs
@@ -3,20 +3,46 @@
#[cfg(test)]
mod test;
+use std::collections::{HashMap, HashSet};
+
use chrono::Utc;
use entity_access::domain::models::AccessLevel;
-use macro_user_id::user_id::MacroUserIdStr;
+use filter_ast::Expr;
+use item_filters::ast::{LiteralTree, call::CallLiteral};
+use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};
use models_permissions::share_permission::SharePermissionV2;
use models_permissions::share_permission::channel_share_permission::ChannelSharePermission;
use sqlx::PgPool;
use uuid::Uuid;
+use crate::domain::channel_name::{NameLookup, display_name, resolve_channel_name};
use crate::domain::models::{
Call, CallParticipant, CallRecord, CallRecordParticipant, CallRecordTranscriptSegment,
TranscriptSegmentRequest,
};
use crate::domain::ports::CallRepository;
+/// Extract channel_id UUIDs from a call filter AST.
+fn extract_channel_ids(filter: &LiteralTree<CallLiteral>) -> Vec<Uuid> {
+ let Some(expr) = filter else {
+ return Vec::new();
+ };
+ let mut ids = Vec::new();
+ collect_channel_ids(expr, &mut ids);
+ ids
+}
+
+fn collect_channel_ids(expr: &Expr<CallLiteral>, ids: &mut Vec<Uuid>) {
+ match expr {
+ Expr::Literal(CallLiteral::ChannelId(id)) => ids.push(*id),
+ Expr::And(a, b) | Expr::Or(a, b) => {
+ collect_channel_ids(a, ids);
+ collect_channel_ids(b, ids);
+ }
+ Expr::Not(inner) => collect_channel_ids(inner, ids),
+ }
+}
+
/// Postgres implementation of [`CallRepository`].
pub struct PgCallRepo {
pool: PgPool,
@@ -565,6 +591,7 @@ impl CallRepository for PgCallRepo {
egress_id: active.egress_id,
recording_key: active.recording_key,
recording_url: None,
+ channel_name: None,
is_active: true,
participants,
transcript,
@@ -640,12 +667,237 @@ impl CallRepository for PgCallRepo {
egress_id: archived.egress_id,
recording_key: archived.recording_key,
recording_url: None,
+ channel_name: None,
is_active: false,
participants,
transcript,
}))
}
+ #[tracing::instrument(err, skip(self))]
+ async fn get_call_records_by_user<'a>(
+ &self,
+ user_id: MacroUserIdStr<'a>,
+ limit: u32,
+ filter: &LiteralTree<CallLiteral>,
+ ) -> Result<Vec<CallRecord>, Self::Err> {
+ // Fetch call headers from both active and archived tables, ordered by
+ // start time descending. We intentionally exclude transcripts (too
+ // large for the soup feed).
+ let channel_ids = extract_channel_ids(filter);
+ let has_channel_filter = !channel_ids.is_empty();
+
+ let rows = sqlx::query!(
+ r#"
+ SELECT
+ id as "call_id!",
+ channel_id as "channel_id!",
+ room_name as "room_name!",
+ created_by as "created_by!",
+ created_at as "started_at!",
+ NULL::timestamptz as "ended_at",
+ NULL::bigint as "duration_ms",
+ egress_id,
+ recording_key,
+ true as "is_active!"
+ FROM calls c
+ WHERE EXISTS (
+ SELECT 1 FROM call_participants cp
+ WHERE cp.call_id = c.id AND cp.user_id = $1 AND cp.left_at IS NULL
+ )
+ AND ($3::bool IS FALSE OR c.channel_id = ANY($4))
+ UNION ALL
+ SELECT
+ id as "call_id!",
+ channel_id as "channel_id!",
+ room_name as "room_name!",
+ created_by as "created_by!",
+ started_at as "started_at!",
+ ended_at as "ended_at",
+ duration_ms as "duration_ms",
+ egress_id,
+ recording_key,
+ false as "is_active!"
+ FROM call_records cr
+ WHERE EXISTS (
+ SELECT 1 FROM call_record_participants crp
+ WHERE crp.call_record_id = cr.id AND crp.user_id = $1
+ )
+ AND ($3::bool IS FALSE OR cr.channel_id = ANY($4))
+ ORDER BY "started_at!" DESC
+ LIMIT $2
+ "#,
+ user_id.as_ref(),
+ limit as i64,
+ has_channel_filter,
+ &channel_ids,
+ )
+ .fetch_all(&self.pool)
+ .await?;
+
+ let mut records = Vec::with_capacity(rows.len());
+ for row in rows {
+ // Fetch participants from the appropriate table.
+ let participants = if row.is_active {
+ sqlx::query!(
+ r#"
+ SELECT user_id, joined_at, left_at
+ FROM call_participants
+ WHERE call_id = $1
+ ORDER BY joined_at ASC
+ "#,
+ row.call_id,
+ )
+ .fetch_all(&self.pool)
+ .await?
+ .into_iter()
+ .map(|p| CallRecordParticipant {
+ user_id: p.user_id,
+ joined_at: p.joined_at,
+ left_at: p.left_at,
+ })
+ .collect()
+ } else {
+ sqlx::query!(
+ r#"
+ SELECT user_id, joined_at, left_at
+ FROM call_record_participants
+ WHERE call_record_id = $1
+ ORDER BY joined_at ASC
+ "#,
+ row.call_id,
+ )
+ .fetch_all(&self.pool)
+ .await?
+ .into_iter()
+ .map(|p| CallRecordParticipant {
+ user_id: p.user_id,
+ joined_at: p.joined_at,
+ left_at: p.left_at,
+ })
+ .collect()
+ };
+
+ records.push(CallRecord {
+ call_id: row.call_id,
+ channel_id: row.channel_id,
+ room_name: row.room_name,
+ created_by: row.created_by,
+ started_at: row.started_at,
+ ended_at: row.ended_at,
+ duration_ms: row.duration_ms,
+ egress_id: row.egress_id,
+ recording_key: row.recording_key,
+ recording_url: None,
+ channel_name: None,
+ is_active: row.is_active,
+ participants,
+ transcript: Vec::new(),
+ });
+ }
+
+ // --- Resolve channel names ---
+ let unique_channel_ids: Vec<Uuid> = {
+ let mut seen = HashSet::new();
+ records
+ .iter()
+ .filter_map(|r| seen.insert(r.channel_id).then_some(r.channel_id))
+ .collect()
+ };
+
+ let channel_info_rows = sqlx::query!(
+ r#"
+ SELECT id, name, channel_type::text as "channel_type!"
+ FROM comms_channels
+ WHERE id = ANY($1)
+ "#,
+ &unique_channel_ids
+ )
+ .fetch_all(&self.pool)
+ .await?;
+
+ let channel_map: HashMap<Uuid, (Option<String>, String)> = channel_info_rows
+ .into_iter()
+ .map(|r| (r.id, (r.name, r.channel_type)))
+ .collect();
+
+ // Identify channels needing participant-based name resolution
+ // (DM channels or unnamed private channels).
+ let needs_participants: Vec<Uuid> = channel_map
+ .iter()
+ .filter(|(_, (name, ct))| {
+ ct == "direct_message"
+ || (ct == "private" && name.as_ref().is_none_or(|n| n.trim().is_empty()))
+ })
+ .map(|(id, _)| *id)
+ .collect();
+
+ let (participant_map, name_lookup) = if needs_participants.is_empty() {
+ (HashMap::new(), NameLookup::new())
+ } else {
+ let participant_rows = sqlx::query!(
+ r#"
+ SELECT channel_id, user_id
+ FROM comms_channel_participants
+ WHERE channel_id = ANY($1) AND left_at IS NULL
+ "#,
+ &needs_participants
+ )
+ .fetch_all(&self.pool)
+ .await?;
+
+ let mut part_map: HashMap<Uuid, Vec<MacroUserIdStr<'static>>> = HashMap::new();
+ let mut all_user_ids = HashSet::new();
+ for row in participant_rows {
+ let uid = MacroUserIdStr::parse_from_str(&row.user_id)
+ .expect("valid user id from db")
+ .into_owned();
+ all_user_ids.insert(row.user_id);
+ part_map.entry(row.channel_id).or_default().push(uid);
+ }
+
+ let user_id_strings: Vec<String> = all_user_ids.into_iter().collect();
+ let name_rows = sqlx::query!(
+ r#"
+ SELECT u.id as user_profile_id, mui.first_name, mui.last_name
+ FROM macro_user_info mui
+ JOIN "User" u ON mui.macro_user_id = u.macro_user_id
+ WHERE u.id = ANY($1)
+ "#,
+ &user_id_strings
+ )
+ .fetch_all(&self.pool)
+ .await?;
+
+ let lookup: NameLookup = name_rows
+ .into_iter()
+ .filter_map(|row| {
+ let name = display_name(row.first_name.as_deref(), row.last_name.as_deref())?;
+ Some((row.user_profile_id, name))
+ })
+ .collect();
+
+ (part_map, lookup)
+ };
+
+ for record in &mut records {
+ if let Some((name, channel_type)) = channel_map.get(&record.channel_id) {
+ let empty = Vec::new();
+ let participants = participant_map.get(&record.channel_id).unwrap_or(&empty);
+ record.channel_name = Some(resolve_channel_name(
+ channel_type,
+ name.as_deref(),
+ participants,
+ &record.channel_id,
+ user_id.copied(),
+ &name_lookup,
+ ));
+ }
+ }
+
+ Ok(records)
+ }
+
#[tracing::instrument(err, skip(self))]
async fn get_user_profile_picture<'a>(
&self,
@@ -665,4 +917,89 @@ impl CallRepository for PgCallRepo {
.await
.map(|opt| opt.flatten())
}
+
+ #[tracing::instrument(err, skip(self))]
+ async fn resolve_channel_name<'a>(
+ &self,
+ channel_id: &Uuid,
+ user_id: MacroUserIdStr<'a>,
+ ) -> Result<Option<String>, Self::Err> {
+ let Some(channel_info) = sqlx::query!(
+ r#"
+ SELECT name, channel_type::text as "channel_type!"
+ FROM comms_channels
+ WHERE id = $1
+ "#,
+ channel_id
+ )
+ .fetch_optional(&self.pool)
+ .await?
+ else {
+ return Ok(None);
+ };
+
+ let channel_type = &channel_info.channel_type;
+ let needs_participants = channel_type == "direct_message"
+ || (channel_type == "private"
+ && channel_info
+ .name
+ .as_ref()
+ .is_none_or(|n| n.trim().is_empty()));
+
+ let (participant_ids, name_lookup) = if !needs_participants {
+ (Vec::new(), NameLookup::new())
+ } else {
+ let participant_rows = sqlx::query!(
+ r#"
+ SELECT user_id
+ FROM comms_channel_participants
+ WHERE channel_id = $1 AND left_at IS NULL
+ "#,
+ channel_id
+ )
+ .fetch_all(&self.pool)
+ .await?;
+
+ let mut ids = Vec::new();
+ let mut all_user_ids = Vec::new();
+ for row in participant_rows {
+ let uid = MacroUserIdStr::parse_from_str(&row.user_id)
+ .expect("valid user id from db")
+ .into_owned();
+ all_user_ids.push(row.user_id);
+ ids.push(uid);
+ }
+
+ let name_rows = sqlx::query!(
+ r#"
+ SELECT u.id as user_profile_id, mui.first_name, mui.last_name
+ FROM macro_user_info mui
+ JOIN "User" u ON mui.macro_user_id = u.macro_user_id
+ WHERE u.id = ANY($1)
+ "#,
+ &all_user_ids
+ )
+ .fetch_all(&self.pool)
+ .await?;
+
+ let lookup: NameLookup = name_rows
+ .into_iter()
+ .filter_map(|row| {
+ let name = display_name(row.first_name.as_deref(), row.last_name.as_deref())?;
+ Some((row.user_profile_id, name))
+ })
+ .collect();
+
+ (ids, lookup)
+ };
+
+ Ok(Some(resolve_channel_name(
+ channel_type,
+ channel_info.name.as_deref(),
+ &participant_ids,
+ channel_id,
+ user_id.copied(),
+ &name_lookup,
+ )))
+ }
}
diff --git a/rust/cloud-storage/document_cognition_service/Cargo.toml b/rust/cloud-storage/document_cognition_service/Cargo.toml
index 654f0f81fc..4045d59815 100644
--- a/rust/cloud-storage/document_cognition_service/Cargo.toml
+++ b/rust/cloud-storage/document_cognition_service/Cargo.toml
@@ -37,6 +37,7 @@ ai_tools = { path = "../ai_tools" }
ai_toolset = { path = "../ai_toolset" }
anyhow = { workspace = true }
async-openai = { workspace = true }
+call = { path = "../call", default-features = false, features = ["ports"] }
aws-sdk-secretsmanager = { workspace = true }
macro_aws_config = { path = "../macro_aws_config", features = ["s3"] }
aws-sdk-dynamodb = { workspace = true }
diff --git a/rust/cloud-storage/document_cognition_service/src/api/context/test.rs b/rust/cloud-storage/document_cognition_service/src/api/context/test.rs
index a811e0cc10..d8c8424ce9 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/context/test.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/context/test.rs
@@ -204,6 +204,7 @@ pub async fn test_api_context(pool: sqlx::Pool<sqlx::Postgres>) -> std::sync::Ar
frecency_service,
ReadonlyEmailPreviewAdapter(email_service),
channels_service,
+ call::domain::ports::NoOpCallRecordQueryService,
));
let ingress_queue = SqsQueue::new(
diff --git a/rust/cloud-storage/document_cognition_service/src/main.rs b/rust/cloud-storage/document_cognition_service/src/main.rs
index 508b8e86e5..c7b3f7ec3d 100644
--- a/rust/cloud-storage/document_cognition_service/src/main.rs
+++ b/rust/cloud-storage/document_cognition_service/src/main.rs
@@ -164,6 +164,7 @@ async fn main() -> anyhow::Result<()> {
frecency_service,
ReadonlyEmailPreviewAdapter(email_service),
channels_service,
+ call::domain::ports::NoOpCallRecordQueryService,
));
tracing::info!("initialized soup service");
diff --git a/rust/cloud-storage/document_storage_service/src/api/context.rs b/rust/cloud-storage/document_storage_service/src/api/context.rs
index afcf281bbe..d1e0f06300 100644
--- a/rust/cloud-storage/document_storage_service/src/api/context.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/context.rs
@@ -76,6 +76,7 @@ type DssSoupState = SoupRouterState<
FrecencyQueryServiceImpl<FrecencyPgStorage>,
ReadonlyEmailPreviewAdapter<DssEmailService>,
ChannelServiceImpl<PgCommsRepo, PgUserRepo, FrecencyPgStorage>,
+ call::domain::service::CallRecordQueryServiceImpl<call::outbound::pg_call_repo::PgCallRepo>,
>,
DssEmailService,
>;
diff --git a/rust/cloud-storage/document_storage_service/src/api/swagger.rs b/rust/cloud-storage/document_storage_service/src/api/swagger.rs
index 7a2299ffa2..445d7f83b4 100644
--- a/rust/cloud-storage/document_storage_service/src/api/swagger.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/swagger.rs
@@ -103,6 +103,7 @@ use model::{
version::DocumentStorageServiceApiVersion,
};
use models_permissions::share_permission::channel_share_permission::UpdateOperation;
+use models_soup::call_record::{SoupCallRecord, SoupCallRecordParticipant};
use models_soup::chat::SoupChat;
use models_soup::document::SoupDocument;
use models_soup::email_thread::{
@@ -343,6 +344,8 @@ use utoipa::OpenApi;
call::domain::models::CallRecord,
call::domain::models::CallRecordParticipant,
call::domain::models::CallRecordTranscriptSegment,
+ SoupCallRecord,
+ SoupCallRecordParticipant,
DocumentSubType,
diff --git a/rust/cloud-storage/document_storage_service/src/main.rs b/rust/cloud-storage/document_storage_service/src/main.rs
index 45a0789a63..b86eadf166 100644
--- a/rust/cloud-storage/document_storage_service/src/main.rs
+++ b/rust/cloud-storage/document_storage_service/src/main.rs
@@ -422,6 +422,10 @@ async fn main() -> anyhow::Result<()> {
config.queue_wait_time_seconds,
);
+ let call_record_query_service = call::domain::service::CallRecordQueryServiceImpl::new(
+ PgCallRepo::new(readonly_db.clone()),
+ );
+
let api_context = ApiContext {
soup_router_state: SoupRouterState::new(
SoupImpl::new(
@@ -429,6 +433,7 @@ async fn main() -> anyhow::Result<()> {
frecency_service,
readonly_email_service,
channel_service_for_soup,
+ call_record_query_service,
),
email_service,
),
diff --git a/rust/cloud-storage/item_filters/src/ast.rs b/rust/cloud-storage/item_filters/src/ast.rs
index c41b3804d3..3ad6030ef8 100644
--- a/rust/cloud-storage/item_filters/src/ast.rs
+++ b/rust/cloud-storage/item_filters/src/ast.rs
@@ -2,9 +2,10 @@
//! This is used to construct a strictly typed ast for the input filters, allowing consumers to have a logical represenation of the required operations
use crate::{
- ChannelFilters, ChatFilters, DocumentFilters, EmailFilters, EntityFilters, ProjectFilters,
- PropertyFilter,
+ CallFilters, ChannelFilters, ChatFilters, DocumentFilters, EmailFilters, EntityFilters,
+ ProjectFilters, PropertyFilter,
ast::{
+ call::CallLiteral,
channel::{ChannelLiteral, ChannelTypeFilter},
chat::{ChatLiteral, ChatRole},
email::EmailLiteral,
@@ -19,6 +20,8 @@ use serde::{Deserialize, Serialize};
use std::{marker::PhantomData, sync::Arc};
use thiserror::Error;
+/// contains the ast literal value for calls
+pub mod call;
/// contains the ast literal value for channels
pub mod channel;
/// contains the ast literal value for chat
@@ -101,6 +104,10 @@ pub struct EntityFilterAst {
#[serde(default, rename = "chanf")]
#[cfg_attr(feature = "schema", schema(value_type = serde_json::Value))]
pub channel_filter: LiteralTree<ChannelLiteral>,
+ /// the filters that should be applied to the call entity
+ #[serde(default, rename = "callf")]
+ #[cfg_attr(feature = "schema", schema(value_type = serde_json::Value))]
+ pub call_filter: LiteralTree<CallLiteral>,
/// the filters that should be applied based on entity properties
#[serde(default, rename = "propf")]
#[cfg_attr(feature = "schema", schema(value_type = serde_json::Value))]
@@ -122,6 +129,7 @@ impl EntityFilterAst {
email_filter: EmailFilters::expand_ast(entity_filter.email_filters)?.map(Arc::new),
channel_filter: ChannelFilters::expand_ast(entity_filter.channel_filters)?
.map(Arc::new),
+ call_filter: CallFilters::expand_ast(entity_filter.call_filters)?.map(Arc::new),
properties_filter: Vec::<PropertyFilter>::expand_ast(entity_filter.property_filters)?
.map(Arc::new),
}))
@@ -136,6 +144,7 @@ impl EntityFilterAst {
chat_filter: None,
email_filter: None,
channel_filter: None,
+ call_filter: None,
properties_filter: None,
}
}
@@ -149,6 +158,7 @@ impl IsEmpty for EntityFilterAst {
chat_filter,
email_filter,
channel_filter,
+ call_filter,
properties_filter,
} = self;
document_filter.is_none()
@@ -156,6 +166,7 @@ impl IsEmpty for EntityFilterAst {
&& chat_filter.is_none()
&& email_filter.is_none()
&& channel_filter.is_none()
+ && call_filter.is_none()
&& properties_filter.is_none()
}
}
diff --git a/rust/cloud-storage/item_filters/src/ast/call.rs b/rust/cloud-storage/item_filters/src/ast/call.rs
new file mode 100644
index 0000000000..098bfe2685
--- /dev/null
+++ b/rust/cloud-storage/item_filters/src/ast/call.rs
@@ -0,0 +1,27 @@
+use filter_ast::{ExpandFrame, Expr, FoldTree, TryExpandNode};
+use serde::{Deserialize, Serialize};
+use uuid::Uuid;
+
+use crate::{CallFilters, ast::ExpandErr};
+
+/// the possible literal values in a call filter ast
+#[derive(Debug, Serialize, Deserialize, Clone)]
+pub enum CallLiteral {
+ /// filter by the channel a call belongs to
+ ChannelId(Uuid),
+}
+
+impl ExpandFrame<CallLiteral> for CallFilters {
+ type Err = ExpandErr;
+
+ fn expand_ast(filter_request: CallFilters) -> Result<Option<Expr<CallLiteral>>, Self::Err> {
+ let CallFilters { channel_ids } = filter_request;
+
+ let channel_ids = channel_ids
+ .iter()
+ .map(|s| Uuid::parse_str(s))
+ .try_expand(|r| r.map(CallLiteral::ChannelId), Expr::or)?;
+
+ Ok([channel_ids].into_iter().fold_with(Expr::and))
+ }
+}
diff --git a/rust/cloud-storage/item_filters/src/lib.rs b/rust/cloud-storage/item_filters/src/lib.rs
index bf74bd1195..6638861f52 100644
--- a/rust/cloud-storage/item_filters/src/lib.rs
+++ b/rust/cloud-storage/item_filters/src/lib.rs
@@ -277,6 +277,22 @@ impl IsEmpty for EmailFilters {
}
}
+/// Filters for call records.
+#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Clone)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema, schemars::JsonSchema))]
+pub struct CallFilters {
+ /// Channel IDs to filter calls by. Empty to include all calls.
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ pub channel_ids: Vec<String>,
+}
+
+impl IsEmpty for CallFilters {
+ fn is_empty(&self) -> bool {
+ let CallFilters { channel_ids } = self;
+ channel_ids.is_empty()
+ }
+}
+
/// The channel message filters used to filter down what channel messages you search over.
#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Clone)]
#[cfg_attr(feature = "schema", derive(utoipa::ToSchema, schemars::JsonSchema))]
@@ -419,6 +435,9 @@ pub struct EntityFilters {
/// the bundled [ChannelFilters]
#[serde(default)]
pub channel_filters: ChannelFilters,
+ /// the bundled [CallFilters]
+ #[serde(default)]
+ pub call_filters: CallFilters,
/// the bundled [EmailFilters]
#[serde(default)]
pub email_filters: EmailFilters,
@@ -434,15 +453,16 @@ impl IsEmpty for EntityFilters {
document_filters,
chat_filters,
channel_filters,
+ call_filters,
email_filters,
property_filters,
} = self;
project_filters.is_empty()
&& document_filters.is_empty()
&& chat_filters.is_empty()
- && chat_filters.is_empty()
- && email_filters.is_empty()
&& channel_filters.is_empty()
+ && call_filters.is_empty()
+ && email_filters.is_empty()
&& property_filters.iter().all(IsEmpty::is_empty)
}
}
diff --git a/rust/cloud-storage/mcp_service/Cargo.toml b/rust/cloud-storage/mcp_service/Cargo.toml
index f062c6470b..52749066d2 100644
--- a/rust/cloud-storage/mcp_service/Cargo.toml
+++ b/rust/cloud-storage/mcp_service/Cargo.toml
@@ -12,6 +12,7 @@ anyhow = { workspace = true }
aws-sdk-secretsmanager = { workspace = true }
aws-sdk-sqs = { workspace = true }
axum = { workspace = true, features = ["tower-log"] }
+call = { path = "../call", default-features = false, features = ["ports"] }
comms = { path = "../comms", features = ["outbound"] }
document_storage_service_client = { path = "../document_storage_service_client" }
documents = { path = "../documents", features = ["ai_tools"] }
diff --git a/rust/cloud-storage/mcp_service/src/context.rs b/rust/cloud-storage/mcp_service/src/context.rs
index f6c6ddf80e..ae137d9bd0 100644
--- a/rust/cloud-storage/mcp_service/src/context.rs
+++ b/rust/cloud-storage/mcp_service/src/context.rs
@@ -176,6 +176,7 @@ async fn build_tool_context(
frecency_service,
ReadonlyEmailPreviewAdapter(email_service),
channels_service,
+ call::domain::ports::NoOpCallRecordQueryService,
));
let s3_client = macro_aws_config::s3_client().await;
diff --git a/rust/cloud-storage/memory/Cargo.toml b/rust/cloud-storage/memory/Cargo.toml
index fb5fd9809d..ff2dcf5063 100644
--- a/rust/cloud-storage/memory/Cargo.toml
+++ b/rust/cloud-storage/memory/Cargo.toml
@@ -21,6 +21,7 @@ tokio = { workspace = true }
anyhow = { workspace = true }
axum = { workspace = true }
aws-sdk-sqs = { workspace = true }
+call = { path = "../call", default-features = false, features = ["ports"] }
model_user = { path = "../model_user", features = ["axum"] }
tracing = { workspace = true }
utoipa = { workspace = true }
diff --git a/rust/cloud-storage/memory/src/context.rs b/rust/cloud-storage/memory/src/context.rs
index 24ebed775a..d5798e3566 100644
--- a/rust/cloud-storage/memory/src/context.rs
+++ b/rust/cloud-storage/memory/src/context.rs
@@ -114,6 +114,7 @@ pub async fn build_tool_service_context(
frecency_service,
ReadonlyEmailPreviewAdapter(email_service),
channels_service,
+ call::domain::ports::NoOpCallRecordQueryService,
));
// Document tool context
diff --git a/rust/cloud-storage/models_soup/Cargo.toml b/rust/cloud-storage/models_soup/Cargo.toml
index f517c4ffd5..596ec9015a 100644
--- a/rust/cloud-storage/models_soup/Cargo.toml
+++ b/rust/cloud-storage/models_soup/Cargo.toml
@@ -10,6 +10,7 @@ schema = ["dep:utoipa"]
[dependencies]
anyhow = { workspace = true }
+call = { path = "../call", default-features = false }
chrono = { workspace = true }
comms = { path = "../comms" }
document_sub_type = { path = "../document_sub_type" }
diff --git a/rust/cloud-storage/models_soup/src/call_record.rs b/rust/cloud-storage/models_soup/src/call_record.rs
new file mode 100644
index 0000000000..faca4ba30e
--- /dev/null
+++ b/rust/cloud-storage/models_soup/src/call_record.rs
@@ -0,0 +1,66 @@
+use chrono::{DateTime, Utc};
+use serde::{Deserialize, Serialize};
+use uuid::Uuid;
+
+/// A participant in a call record, as displayed in Soup.
+#[derive(Debug, Serialize, Deserialize)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+#[serde(rename_all = "camelCase")]
+pub struct SoupCallRecordParticipant {
+ /// The user id.
+ pub user_id: String,
+ /// When the user joined the call.
+ pub joined_at: DateTime<Utc>,
+ /// When the user left (None if still in an active call).
+ pub left_at: Option<DateTime<Utc>>,
+}
+
+/// A call record as displayed in Soup. Excludes room_name, egress_id,
+/// and transcript — fields that are irrelevant for the soup feed.
+#[derive(Debug, Serialize, Deserialize)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
+#[serde(rename_all = "camelCase")]
+pub struct SoupCallRecord {
+ /// The call identifier.
+ pub call_id: Uuid,
+ /// The channel this call belongs to.
+ pub channel_id: Uuid,
+ /// User who created the call.
+ pub created_by: String,
+ /// When the call started.
+ pub started_at: DateTime<Utc>,
+ /// When the call ended (None if still active).
+ pub ended_at: Option<DateTime<Utc>>,
+ /// Call duration in milliseconds (None if still active).
+ pub duration_ms: Option<i64>,
+ /// Resolved display name for the channel.
+ pub channel_name: Option<String>,
+ /// Whether the call is currently active.
+ pub is_active: bool,
+ /// Participants in the call.
+ pub participants: Vec<SoupCallRecordParticipant>,
+}
+
+impl From<call::domain::models::CallRecord> for SoupCallRecord {
+ fn from(record: call::domain::models::CallRecord) -> Self {
+ SoupCallRecord {
+ call_id: record.call_id,
+ channel_id: record.channel_id,
+ created_by: record.created_by,
+ started_at: record.started_at,
+ ended_at: record.ended_at,
+ duration_ms: record.duration_ms,
+ channel_name: record.channel_name,
+ is_active: record.is_active,
+ participants: record
+ .participants
+ .into_iter()
+ .map(|p| SoupCallRecordParticipant {
+ user_id: p.user_id,
+ joined_at: p.joined_at,
+ left_at: p.left_at,
+ })
+ .collect(),
+ }
+ }
+}
diff --git a/rust/cloud-storage/models_soup/src/item.rs b/rust/cloud-storage/models_soup/src/item.rs
index 96f4c839cf..92c00b06cd 100644
--- a/rust/cloud-storage/models_soup/src/item.rs
+++ b/rust/cloud-storage/models_soup/src/item.rs
@@ -1,3 +1,4 @@
+use crate::call_record::SoupCallRecord;
use crate::document::SoupDocument;
use crate::email_thread::SoupEnrichedEmailThreadPreview;
use crate::project::SoupProject;
@@ -18,6 +19,7 @@ pub enum SoupItem {
Project(SoupProject),
EmailThread(SoupEnrichedEmailThreadPreview),
Channel(SoupChannel),
+ CallRecord(SoupCallRecord),
}
impl SoupItem {
@@ -39,6 +41,9 @@ impl SoupItem {
SoupItem::Channel(channel) => {
EntityType::Channel.with_entity_string(channel.channel.channel.id.0.to_string())
}
+ SoupItem::CallRecord(record) => {
+ EntityType::Call.with_entity_string(record.call_id.to_string())
+ }
}
}
@@ -49,6 +54,7 @@ impl SoupItem {
SoupItem::Project(soup_project) => soup_project.updated_at,
SoupItem::EmailThread(soup_thread) => soup_thread.thread.updated_at,
SoupItem::Channel(soup_channel) => soup_channel.channel.channel.updated_at,
+ SoupItem::CallRecord(record) => record.ended_at.unwrap_or(record.started_at),
}
}
}
@@ -106,6 +112,8 @@ impl SoupItem {
(SoupItem::Channel(soup_channel), SimpleSortMethod::ViewedUpdated) => soup_channel
.viewed_at
.unwrap_or(soup_channel.channel.channel.updated_at),
+ (SoupItem::CallRecord(record), SimpleSortMethod::CreatedAt) => record.started_at,
+ (SoupItem::CallRecord(record), _) => record.ended_at.unwrap_or(record.started_at),
}
}
}
@@ -120,6 +128,7 @@ impl Identify for SoupItem {
SoupItem::Project(soup_project) => soup_project.id,
SoupItem::EmailThread(thread) => thread.thread.id,
SoupItem::Channel(soup_channel) => soup_channel.channel.channel.id.0,
+ SoupItem::CallRecord(record) => record.call_id,
}
}
}
@@ -160,6 +169,7 @@ impl SoupItem {
PropertiesEntityType::Chat,
)),
SoupItem::Channel(_) => None,
+ SoupItem::CallRecord(_) => None,
}
}
}
diff --git a/rust/cloud-storage/models_soup/src/lib.rs b/rust/cloud-storage/models_soup/src/lib.rs
index adcc6c2fbf..bab24a2da9 100644
--- a/rust/cloud-storage/models_soup/src/lib.rs
+++ b/rust/cloud-storage/models_soup/src/lib.rs
@@ -1,3 +1,4 @@
+pub mod call_record;
pub mod chat;
pub mod comms;
pub mod document;
diff --git a/rust/cloud-storage/soup/Cargo.toml b/rust/cloud-storage/soup/Cargo.toml
index 014baf4702..3bd67840d7 100644
--- a/rust/cloud-storage/soup/Cargo.toml
+++ b/rust/cloud-storage/soup/Cargo.toml
@@ -38,6 +38,7 @@ ports = ["dep:tokio", "frecency/ports"]
ai = { path = "../ai", optional = true }
anyhow = { workspace = true }
async-trait = { workspace = true, optional = true }
+call = { path = "../call", default-features = false, features = ["ports"] }
axum = { workspace = true, optional = true }
axum-extra = { workspace = true, optional = true }
chrono = { workspace = true }
diff --git a/rust/cloud-storage/soup/examples/ai_tools_cli.rs b/rust/cloud-storage/soup/examples/ai_tools_cli.rs
index 81136f2b2c..5676c0556e 100644
--- a/rust/cloud-storage/soup/examples/ai_tools_cli.rs
+++ b/rust/cloud-storage/soup/examples/ai_tools_cli.rs
@@ -70,6 +70,7 @@ async fn main() {
frecency_service,
ReadonlyEmailPreviewAdapter(email_service.clone()),
channels_service,
+ call::domain::ports::NoOpCallRecordQueryService,
);
// Create the soup tool context
diff --git a/rust/cloud-storage/soup/src/domain/models.rs b/rust/cloud-storage/soup/src/domain/models.rs
index bc67833a4a..084ad9f6f1 100644
--- a/rust/cloud-storage/soup/src/domain/models.rs
+++ b/rust/cloud-storage/soup/src/domain/models.rs
@@ -1,3 +1,4 @@
+use call::domain::models::GetCallRecordsRequest;
use comms::domain::models::GetChannelsRequest;
use email::domain::models::{GetEmailsRequest, PreviewView};
use frecency::domain::models::{AggregateFrecency, FrecencyQueryErr};
@@ -277,6 +278,32 @@ impl SoupRequest<Option<EntityFilterAst>> {
})
}
+ pub(crate) fn build_call_request(&self) -> Option<GetCallRecordsRequest> {
+ Some(GetCallRecordsRequest {
+ user_id: self.user.clone(),
+ limit: self.limit as u32,
+ query: match &self.cursor {
+ SoupQuery::Simple(SimpleQueryInner(Query::Sort(t, f))) => Some(Query::Sort(
+ *t,
+ f.as_ref().and_then(|f| f.call_filter.clone()),
+ )),
+ SoupQuery::Simple(SimpleQueryInner(Query::Cursor(CursorWithValAndFilter {
+ id,
+ limit,
+ val,
+ filter,
+ }))) => Some(Query::Cursor(CursorWithValAndFilter {
+ id: *id,
+ limit: *limit,
+ val: val.clone(),
+ filter: filter.as_ref().and_then(|f| f.call_filter.clone()),
+ })),
+ // query by frecency not yet implemented for call records
+ SoupQuery::Frecency(_) => None,
+ }?,
+ })
+ }
+
pub(crate) fn build_comms_request(&self) -> Option<GetChannelsRequest> {
Some(GetChannelsRequest {
macro_id: self.user.clone(),
@@ -352,6 +379,8 @@ pub enum SoupErr {
EmailErr(#[from] email::domain::models::EmailErr),
#[error("A comms error has occured, see logs for more details")]
CommsErr,
+ #[error("A call error has occurred, see logs for more details")]
+ CallErr,
#[error(transparent)]
AstErr(#[from] ExpandErr),
}
diff --git a/rust/cloud-storage/soup/src/domain/service.rs b/rust/cloud-storage/soup/src/domain/service.rs
index 02f538c24c..87b11fdc44 100644
--- a/rust/cloud-storage/soup/src/domain/service.rs
+++ b/rust/cloud-storage/soup/src/domain/service.rs
@@ -5,6 +5,7 @@ use crate::domain::{
},
ports::{SoupOutput, SoupRepo, SoupService},
};
+use call::domain::{models::GetCallRecordsRequest, ports::CallRecordQueryService};
use comms::domain::{models::GetChannelsRequest, ports::ChannelsService};
use cowlike::CowLike;
use doppleganger::Mirror;
@@ -23,6 +24,7 @@ use models_pagination::{
Cursor, CursorVal, Frecency, FrecencyValue, PaginateOn, Query, SimpleSortMethod, SortOn,
};
use models_soup::{
+ call_record::SoupCallRecord,
comms::SoupChannel,
email_thread::{
SoupAttachment, SoupContact, SoupEmailThreadPreview, SoupEnrichedEmailThreadPreview,
@@ -38,7 +40,7 @@ use uuid::Uuid;
mod tests;
/// struct which handles the actual implementation of soup with abstracted interfaces for mocking
-pub struct SoupImpl<T, U, V, C> {
+pub struct SoupImpl<T, U, V, C, K> {
/// the interface for interacting with the db
soup_storage: T,
/// the interface for interacting with frecency
@@ -47,22 +49,32 @@ pub struct SoupImpl<T, U, V, C> {
email_service: V,
/// the interface for interacting with comms
comms_service: C,
+ /// the interface for interacting with call records
+ call_record_service: K,
}
-impl<T, U, V, C> SoupImpl<T, U, V, C>
+impl<T, U, V, C, K> SoupImpl<T, U, V, C, K>
where
T: SoupRepo,
anyhow::Error: From<T::Err>,
U: FrecencyQueryService,
V: EmailPreviewServiceReadOnly,
C: ChannelsService,
+ K: CallRecordQueryService,
{
- pub fn new(soup_storage: T, frecency: U, email_service: V, comms_service: C) -> Self {
+ pub fn new(
+ soup_storage: T,
+ frecency: U,
+ email_service: V,
+ comms_service: C,
+ call_record_service: K,
+ ) -> Self {
SoupImpl {
soup_storage,
frecency,
email_service,
comms_service,
+ call_record_service,
}
}
@@ -342,15 +354,42 @@ where
})?,
))
}
+
+ #[tracing::instrument(err, skip(self, req))]
+ async fn handle_call_request(
+ &self,
+ req: Option<GetCallRecordsRequest>,
+ ) -> Result<impl Iterator<Item = FrecencySoupItem>, SoupErr> {
+ let Some(req) = req else {
+ return Ok(Either::Left(None.into_iter()));
+ };
+
+ Ok(Either::Right(
+ self.call_record_service
+ .get_user_call_records(req)
+ .await
+ .map_err(|_| SoupErr::CallErr)
+ .map(|records| {
+ records.into_iter().map(|record| {
+ let soup_record = SoupCallRecord::from(record);
+ FrecencySoupItem {
+ item: SoupItem::CallRecord(soup_record),
+ frecency_score: None,
+ }
+ })
+ })?,
+ ))
+ }
}
-impl<T, U, V, C> SoupService for SoupImpl<T, U, V, C>
+impl<T, U, V, C, K> SoupService for SoupImpl<T, U, V, C, K>
where
T: SoupRepo,
anyhow::Error: From<T::Err>,
U: FrecencyQueryService,
V: EmailPreviewServiceReadOnly,
C: ChannelsService,
+ K: CallRecordQueryService,
{
#[tracing::instrument(err, skip(self, req))]
async fn get_user_soup<R>(&self, req: SoupRequest<R>) -> Result<SoupOutput<R>, SoupErr>
@@ -364,6 +403,7 @@ where
let email_request = req.build_email_request();
let comms_request = req.build_comms_request();
+ let call_request = req.build_call_request();
match req.cursor {
SoupQuery::Simple(SimpleQueryInner(cursor)) => {
@@ -382,12 +422,15 @@ where
let comms_soup_fut = self.handle_comms_request(comms_request);
- let (main_soup, email_soup, comms_soup) =
- tokio::join!(main_soup_fut, email_soup_fut, comms_soup_fut);
+ let call_soup_fut = self.handle_call_request(call_request);
+
+ let (main_soup, email_soup, comms_soup, call_soup) =
+ tokio::join!(main_soup_fut, email_soup_fut, comms_soup_fut, call_soup_fut);
let page = main_soup?
.chain(email_soup?)
.chain(comms_soup?)
+ .chain(call_soup?)
.paginate_on(limit.into(), sort_method)
.filter_on(entity_filter.clone())
.sort_desc()
diff --git a/rust/cloud-storage/soup/src/domain/service/tests.rs b/rust/cloud-storage/soup/src/domain/service/tests.rs
index 9872483cab..f7b1179438 100644
--- a/rust/cloud-storage/soup/src/domain/service/tests.rs
+++ b/rust/cloud-storage/soup/src/domain/service/tests.rs
@@ -64,6 +64,17 @@ impl ChannelsService for NoopCommsService {
}
}
+struct NoopCallRecordQueryService;
+
+impl CallRecordQueryService for NoopCallRecordQueryService {
+ async fn get_user_call_records(
+ &self,
+ _req: call::domain::models::GetCallRecordsRequest,
+ ) -> Result<Vec<call::domain::models::CallRecord>, call::domain::models::CallError> {
+ Ok(Vec::new())
+ }
+}
+
fn soup_document(id: &str) -> SoupDocument {
// Create a deterministic UUID from the string ID
let uuid = Uuid::parse_str(id).unwrap_or_else(|_| {
@@ -162,6 +173,7 @@ async fn it_should_not_query_frecency() {
FrecencyQueryServiceImpl::new(MockFrecencyStorage::new()),
NoopEmailPreviewService,
NoopCommsService,
+ NoopCallRecordQueryService,
)
.get_user_soup(SoupRequest {
email_preview_view: PreviewView::StandardLabel(
@@ -243,6 +255,7 @@ async fn it_should_query_frecency() {
FrecencyQueryServiceImpl::new(frecency_mock),
NoopEmailPreviewService,
NoopCommsService,
+ NoopCallRecordQueryService,
)
.get_user_soup(SoupRequest {
email_preview_view: PreviewView::StandardLabel(
@@ -321,6 +334,7 @@ async fn it_should_sort_frecency_descending() {
FrecencyQueryServiceImpl::new(frecency_mock),
NoopEmailPreviewService,
NoopCommsService,
+ NoopCallRecordQueryService,
)
.get_user_soup(SoupRequest {
email_preview_view: PreviewView::StandardLabel(
@@ -408,20 +422,26 @@ async fn frecency_should_fallback() {
Box::pin(async move { res })
});
- let res = SoupImpl::new(soup, frecency, NoopEmailPreviewService, NoopCommsService)
- .get_user_soup(SoupRequest {
- email_preview_view: PreviewView::StandardLabel(
- email::domain::models::PreviewViewStandardLabel::Inbox,
- ),
- link_id: Some(Uuid::new_v4()),
- soup_type: SoupType::UnExpanded,
- limit: 100,
- cursor: SoupQuery::new_sort_frecency(Frecency, EntityFilters::default()),
- user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
- })
- .await
- .unwrap()
- .unwrap_right();
+ let res = SoupImpl::new(
+ soup,
+ frecency,
+ NoopEmailPreviewService,
+ NoopCommsService,
+ NoopCallRecordQueryService,
+ )
+ .get_user_soup(SoupRequest {
+ email_preview_view: PreviewView::StandardLabel(
+ email::domain::models::PreviewViewStandardLabel::Inbox,
+ ),
+ link_id: Some(Uuid::new_v4()),
+ soup_type: SoupType::UnExpanded,
+ limit: 100,
+ cursor: SoupQuery::new_sort_frecency(Frecency, EntityFilters::default()),
+ user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
+ })
+ .await
+ .unwrap()
+ .unwrap_right();
// output should be the limit
assert_eq!(res.items.len(), 100);
@@ -479,20 +499,26 @@ async fn frecency_should_paginate() {
Box::pin(async move { Ok(vec) })
});
- let res = SoupImpl::new(soup, frecency, NoopEmailPreviewService, NoopCommsService)
- .get_user_soup(SoupRequest {
- email_preview_view: PreviewView::StandardLabel(
- email::domain::models::PreviewViewStandardLabel::Inbox,
- ),
- link_id: Some(Uuid::new_v4()),
- soup_type: SoupType::UnExpanded,
- limit: 100,
- cursor: SoupQuery::new_sort_frecency(Frecency, EntityFilters::default()),
- user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
- })
- .await
- .unwrap()
- .unwrap_right();
+ let res = SoupImpl::new(
+ soup,
+ frecency,
+ NoopEmailPreviewService,
+ NoopCommsService,
+ NoopCallRecordQueryService,
+ )
+ .get_user_soup(SoupRequest {
+ email_preview_view: PreviewView::StandardLabel(
+ email::domain::models::PreviewViewStandardLabel::Inbox,
+ ),
+ link_id: Some(Uuid::new_v4()),
+ soup_type: SoupType::UnExpanded,
+ limit: 100,
+ cursor: SoupQuery::new_sort_frecency(Frecency, EntityFilters::default()),
+ user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
+ })
+ .await
+ .unwrap()
+ .unwrap_right();
// output should be the limit
assert_eq!(res.items.len(), 100);
@@ -552,28 +578,34 @@ async fn frecency_should_resume_cursor() {
Box::pin(async move { Ok(vec) })
});
- let res = SoupImpl::new(soup, frecency, NoopEmailPreviewService, NoopCommsService)
- .get_user_soup(SoupRequest {
- email_preview_view: PreviewView::StandardLabel(
- email::domain::models::PreviewViewStandardLabel::Inbox,
- ),
- link_id: Some(Uuid::new_v4()),
- soup_type: SoupType::UnExpanded,
+ let res = SoupImpl::new(
+ soup,
+ frecency,
+ NoopEmailPreviewService,
+ NoopCommsService,
+ NoopCallRecordQueryService,
+ )
+ .get_user_soup(SoupRequest {
+ email_preview_view: PreviewView::StandardLabel(
+ email::domain::models::PreviewViewStandardLabel::Inbox,
+ ),
+ link_id: Some(Uuid::new_v4()),
+ soup_type: SoupType::UnExpanded,
+ limit: 100,
+ cursor: SoupQuery::new_cursor_frecency(CursorWithValAndFilter {
+ id: Uuid::from_u128(5),
limit: 100,
- cursor: SoupQuery::new_cursor_frecency(CursorWithValAndFilter {
- id: Uuid::from_u128(5),
- limit: 100,
- val: CursorVal {
- sort_type: Frecency,
- last_val: FrecencyValue::FrecencyScore(5.0),
- },
- filter: Default::default(),
- }),
- user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
- })
- .await
- .unwrap()
- .unwrap_right();
+ val: CursorVal {
+ sort_type: Frecency,
+ last_val: FrecencyValue::FrecencyScore(5.0),
+ },
+ filter: Default::default(),
+ }),
+ user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
+ })
+ .await
+ .unwrap()
+ .unwrap_right();
// first all items should be frecency
assert!(
@@ -641,28 +673,34 @@ async fn frecency_fallback_cursor_should_resume() {
Box::pin(async move { res })
});
- let res = SoupImpl::new(soup, frecency, NoopEmailPreviewService, NoopCommsService)
- .get_user_soup(SoupRequest {
- email_preview_view: PreviewView::StandardLabel(
- email::domain::models::PreviewViewStandardLabel::Inbox,
- ),
- link_id: Some(Uuid::new_v4()),
- soup_type: SoupType::UnExpanded,
+ let res = SoupImpl::new(
+ soup,
+ frecency,
+ NoopEmailPreviewService,
+ NoopCommsService,
+ NoopCallRecordQueryService,
+ )
+ .get_user_soup(SoupRequest {
+ email_preview_view: PreviewView::StandardLabel(
+ email::domain::models::PreviewViewStandardLabel::Inbox,
+ ),
+ link_id: Some(Uuid::new_v4()),
+ soup_type: SoupType::UnExpanded,
+ limit: 100,
+ cursor: SoupQuery::new_cursor_frecency(CursorWithValAndFilter {
+ id: Uuid::from_u128(100),
limit: 100,
- cursor: SoupQuery::new_cursor_frecency(CursorWithValAndFilter {
- id: Uuid::from_u128(100),
- limit: 100,
- val: CursorVal {
- sort_type: Frecency,
- last_val: FrecencyValue::UpdatedAt(DateTime::default() + Days::new(5)),
- },
- filter: Default::default(),
- }),
- user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
- })
- .await
- .unwrap()
- .unwrap_right();
+ val: CursorVal {
+ sort_type: Frecency,
+ last_val: FrecencyValue::UpdatedAt(DateTime::default() + Days::new(5)),
+ },
+ filter: Default::default(),
+ }),
+ user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
+ })
+ .await
+ .unwrap()
+ .unwrap_right();
assert!(res.items.iter().all(|v| v.frecency_score.is_none()));
let cursor: CursorWithValAndFilter<String, Frecency, EntityFilters> =
@@ -711,6 +749,7 @@ async fn cursor_should_return_simple_sort() {
FrecencyQueryServiceImpl::new(MockFrecencyStorage::new()),
NoopEmailPreviewService,
NoopCommsService,
+ NoopCallRecordQueryService,
)
.get_user_soup(SoupRequest {
email_preview_view: PreviewView::StandardLabel(
@@ -772,19 +811,25 @@ async fn cursor_should_return_frecency() {
Box::pin(async move { Ok(vec) })
});
- let res = SoupImpl::new(soup, frecency, NoopEmailPreviewService, NoopCommsService)
- .get_user_soup(SoupRequest {
- email_preview_view: PreviewView::StandardLabel(
- email::domain::models::PreviewViewStandardLabel::Inbox,
- ),
- link_id: Some(Uuid::new_v4()),
- soup_type: SoupType::UnExpanded,
- limit: 100,
- cursor: SoupQuery::new_sort_frecency(Frecency, EntityFilters::default()),
- user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
- })
- .await
- .unwrap();
+ let res = SoupImpl::new(
+ soup,
+ frecency,
+ NoopEmailPreviewService,
+ NoopCommsService,
+ NoopCallRecordQueryService,
+ )
+ .get_user_soup(SoupRequest {
+ email_preview_view: PreviewView::StandardLabel(
+ email::domain::models::PreviewViewStandardLabel::Inbox,
+ ),
+ link_id: Some(Uuid::new_v4()),
+ soup_type: SoupType::UnExpanded,
+ limit: 100,
+ cursor: SoupQuery::new_sort_frecency(Frecency, EntityFilters::default()),
+ user: MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap(),
+ })
+ .await
+ .unwrap();
let simple_cursor = res.unwrap_right();
let cursor_decoded: CursorWithValAndFilter<String, Frecency, EntityFilters> =
@@ -828,6 +873,7 @@ async fn it_should_return_is_completed_true_for_completed_tasks() {
FrecencyQueryServiceImpl::new(MockFrecencyStorage::new()),
NoopEmailPreviewService,
NoopCommsService,
+ NoopCallRecordQueryService,
)
.get_user_soup(SoupRequest {
email_preview_view: PreviewView::StandardLabel(
@@ -874,6 +920,7 @@ async fn it_should_return_is_completed_false_for_incomplete_tasks() {
FrecencyQueryServiceImpl::new(MockFrecencyStorage::new()),
NoopEmailPreviewService,
NoopCommsService,
+ NoopCallRecordQueryService,
)
.get_user_soup(SoupRequest {
email_preview_view: PreviewView::StandardLabel(
@@ -920,6 +967,7 @@ async fn it_should_return_is_completed_none_for_non_tasks() {
FrecencyQueryServiceImpl::new(MockFrecencyStorage::new()),
NoopEmailPreviewService,
NoopCommsService,
+ NoopCallRecordQueryService,
)
.get_user_soup(SoupRequest {
email_preview_view: PreviewView::StandardLabel(
@@ -978,6 +1026,7 @@ async fn it_should_preserve_is_completed_for_mixed_items() {
FrecencyQueryServiceImpl::new(MockFrecencyStorage::new()),
NoopEmailPreviewService,
NoopCommsService,
+ NoopCallRecordQueryService,
)
.get_user_soup(SoupRequest {
email_preview_view: PreviewView::StandardLabel(
@@ -1055,6 +1104,7 @@ async fn it_should_preserve_is_completed_in_by_ids_queries() {
frecency,
NoopEmailPreviewService,
NoopCommsService,
+ NoopCallRecordQueryService,
)
.get_user_soup(SoupRequest {
email_preview_view: PreviewView::StandardLabel(
diff --git a/rust/cloud-storage/soup/src/inbound/toolset/list_entities.rs b/rust/cloud-storage/soup/src/inbound/toolset/list_entities.rs
index 205ad16131..6fdc5d8e79 100644
--- a/rust/cloud-storage/soup/src/inbound/toolset/list_entities.rs
+++ b/rust/cloud-storage/soup/src/inbound/toolset/list_entities.rs
@@ -48,6 +48,7 @@ pub enum ItemType {
Project,
Email,
Channel,
+ CallRecord,
}
#[derive(Debug, Serialize, JsonSchema)]
@@ -63,6 +64,8 @@ pub enum EntityItem {
Email { id: Uuid, subject: Option<String> },
#[serde(rename_all = "camelCase")]
Channel { id: Uuid, name: Option<String> },
+ #[serde(rename_all = "camelCase")]
+ CallRecord { id: Uuid, created_by: String },
}
impl EntityItem {
@@ -73,6 +76,7 @@ impl EntityItem {
EntityItem::Project { .. } => ItemType::Project,
EntityItem::Email { .. } => ItemType::Email,
EntityItem::Channel { .. } => ItemType::Channel,
+ EntityItem::CallRecord { .. } => ItemType::CallRecord,
}
}
}
@@ -100,6 +104,10 @@ impl From<SoupItem> for EntityItem {
id: channel.channel.channel.id.0,
name: channel.channel.channel.name.clone(),
},
+ SoupItem::CallRecord(record) => EntityItem::CallRecord {
+ id: record.call_id,
+ created_by: record.created_by,
+ },
}
}
}
@@ -220,6 +228,7 @@ pub(super) fn build_summary(
let mut projects = 0;
let mut emails = 0;
let mut channels = 0;
+ let mut call_records = 0;
for item in items {
match item {
@@ -228,6 +237,7 @@ pub(super) fn build_summary(
EntityItem::Project { .. } => projects += 1,
EntityItem::Email { .. } => emails += 1,
EntityItem::Channel { .. } => channels += 1,
+ EntityItem::CallRecord { .. } => call_records += 1,
}
}
@@ -262,6 +272,12 @@ pub(super) fn build_summary(
if channels == 1 { "" } else { "s" }
));
}
+ if call_records > 0 {
+ parts.push(format!(
+ "{call_records} call record{}",
+ if call_records == 1 { "" } else { "s" }
+ ));
+ }
let counts = parts.join(", ");
if has_more {
diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs
index c24b22d92e..e83d0aa79d 100644
--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs
+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo.rs
@@ -174,7 +174,7 @@ pub(crate) async fn populate_properties(
SoupItem::Project(x) => properties_map.remove(&x.id.to_string()),
SoupItem::EmailThread(x) => properties_map.remove(&x.thread.id.to_string()),
SoupItem::Chat(x) => properties_map.remove(&x.id.to_string()),
- SoupItem::Channel(_) => None,
+ SoupItem::Channel(_) | SoupItem::CallRecord(_) => None,
};
if let Some(props) = props {
let soup_props: Vec<SoupProperty> = props.into_iter().map(SoupProperty::from).collect();
@@ -183,7 +183,7 @@ pub(crate) async fn populate_properties(
SoupItem::Project(x) => x.properties = soup_props,
SoupItem::EmailThread(x) => x.properties = soup_props,
SoupItem::Chat(x) => x.properties = soup_props,
- SoupItem::Channel(_) => {}
+ SoupItem::Channel(_) | SoupItem::CallRecord(_) => {}
}
}
}
diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/tests.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/tests.rs
index 5e9e4b5762..c0b7b0cc89 100644
--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/tests.rs
+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/tests.rs
@@ -356,7 +356,8 @@ async fn test_expanded_soup_by_ids(pool: Pool<Postgres>) {
SoupItem::Chat(_)
| SoupItem::Project(_)
| SoupItem::EmailThread(_)
- | SoupItem::Channel(_) => None,
+ | SoupItem::Channel(_)
+ | SoupItem::CallRecord(_) => None,
})
.expect("The document should exist");
let expected_doc_id = Uuid::parse_str("11111111-aaaa-aaaa-aaaa-aaaaaaaaaaaa").unwrap(); // doc-in-A