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(calls): add in MISSED call type (#3868)

Will Hutchinsonea474cab1e6f
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 f26b5fb011..61da0acd3f 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
@@ -335,10 +335,19 @@ export const VIEW_TAB_PRESETS: Record<ListView, ViewTabConfig> = {
filters: defineQueryFilters({}, { skipTargets: ['callf'] }),
clientFilters: { and: ['calls'] },
}),
+ missed: () => ({
+ filters: defineQueryFilters(
+ {
+ include: { callStatus: 'MISSED' },
+ },
+ { skipTargets: ['callf'] }
+ ),
+ clientFilters: { and: ['calls'] },
+ }),
unattended: () => ({
filters: defineQueryFilters(
{
- include: { callAttended: false },
+ include: { callStatus: 'UNATTENDED' },
},
{ skipTargets: ['callf'] }
),
diff --git a/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts b/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts
index f624e43c0f..1f86de763e 100644
--- a/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts
+++ b/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts
@@ -111,6 +111,7 @@ const FIELD_CONFIG: Record<
callId: { target: 'callf', field: 'CallId' },
callChannelId: { target: 'callf', field: 'ChannelId' },
callSpeakerId: { target: 'callf', field: 'Speaker' },
+ callStatus: { target: 'callf', field: 'Status' },
callAttended: { target: 'callf', field: 'Attended' },
foreignEntityRecordId: { target: 'fef', field: 'id' },
crmCompanyId: { target: 'ccf', field: 'id' },
diff --git a/js/app/packages/app/component/next-soup/filters/filter-store/types.ts b/js/app/packages/app/component/next-soup/filters/filter-store/types.ts
index 460128f0dc..f413de535a 100644
--- a/js/app/packages/app/component/next-soup/filters/filter-store/types.ts
+++ b/js/app/packages/app/component/next-soup/filters/filter-store/types.ts
@@ -1,5 +1,15 @@
export type EmailView = 'inbox' | 'drafts' | 'sent' | 'all';
+export type CallStatus = 'ATTENDED' | 'MISSED' | 'UNATTENDED';
+
+export function callStatusFromAttended(
+ attended: boolean | null | undefined
+): CallStatus | undefined {
+ if (attended === true) return 'ATTENDED';
+ if (attended === false) return 'UNATTENDED';
+ return undefined;
+}
+
export type DateRangeFilter = {
gt?: string;
gte?: string;
@@ -56,6 +66,7 @@ export type ScalarFieldFilters = {
chatDone?: boolean;
folderSeen?: boolean;
folderDone?: boolean;
+ callStatus?: CallStatus;
callAttended?: boolean;
documentCreatedAt?: DateRangeFilter;
documentUpdatedAt?: DateRangeFilter;
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 0658aa2fd5..d0427df2bc 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
@@ -1,6 +1,7 @@
import type { SoupBody, SoupItemsQueryFilters } from '@queries/soup/items';
import type { SoupApiItem } from '@service-storage/generated/schemas';
import { match } from 'ts-pattern';
+import { type CallStatus, callStatusFromAttended } from './filter-store/types';
const NIL_UUID = '00000000-0000-0000-0000-000000000000';
@@ -40,6 +41,21 @@ function isAttendedFilteredOut(
return itemAttended !== attendedFilter;
}
+function isCallAttendanceFilteredOut(
+ statusFilter: CallStatus | null | undefined,
+ attendedFilter: boolean | null | undefined,
+ itemStatus: CallStatus | null | undefined,
+ itemAttended: boolean
+): boolean {
+ if (statusFilter !== undefined && statusFilter !== null) {
+ return (
+ (itemStatus ?? callStatusFromAttended(itemAttended)) !== statusFilter
+ );
+ }
+
+ return isAttendedFilteredOut(attendedFilter, itemAttended);
+}
+
// TODO: this only supports the subset of soup filters needed for cache matching.
export function filterSoupItemByRequestBody(
item: SoupApiItem,
@@ -78,7 +94,12 @@ export function filterSoupItemByRequestBody(
{ tag: 'call' },
({ data }) =>
!isIdFilteredOut(body.call_filters?.call_ids, data.callId) &&
- !isAttendedFilteredOut(body.call_filters?.attended, data.attended)
+ !isCallAttendanceFilteredOut(
+ body.call_filters?.status,
+ body.call_filters?.attended,
+ data.status,
+ data.attended
+ )
)
.with(
{ tag: 'crmCompany' },
diff --git a/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts b/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts
index e4ae8a5083..55cc782e35 100644
--- a/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts
@@ -97,13 +97,16 @@ function filterDataToQueryFilters(data: QueryState): EntityFilters {
include.callId?.length ||
include.callChannelId?.length ||
include.callSpeakerId?.length ||
+ include.callStatus !== undefined ||
include.callAttended !== undefined
) {
filters.call_filters = {
call_ids: include.callId,
channel_ids: include.callChannelId,
speaker_ids: include.callSpeakerId,
- attended: include.callAttended,
+ status: include.callStatus,
+ attended:
+ include.callStatus === undefined ? include.callAttended : undefined,
};
}
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx
index cc9ace2028..a0a2c36f30 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx
@@ -4,6 +4,10 @@ import {
NIL_UUID,
type Query,
} from '@app/component/next-soup/filters/filter-store';
+import {
+ type CallStatus,
+ callStatusFromAttended,
+} from '@app/component/next-soup/filters/filter-store/types';
import {
activeSoupViewCounts,
soupViewCacheKey,
@@ -33,6 +37,35 @@ export type SearchableOption = {
icon?: () => JSX.Element;
};
+const CALL_STATUS_LABELS: Record<CallStatus, string> = {
+ ATTENDED: 'Attended',
+ MISSED: 'Missed',
+ UNATTENDED: 'Unattended',
+};
+
+export const CALL_STATUS_OPTIONS: {
+ label: string;
+ value: CallStatus | undefined;
+}[] = [
+ { label: CALL_STATUS_LABELS.ATTENDED, value: 'ATTENDED' },
+ { label: CALL_STATUS_LABELS.MISSED, value: 'MISSED' },
+ { label: CALL_STATUS_LABELS.UNATTENDED, value: 'UNATTENDED' },
+ { label: 'All', value: undefined },
+];
+
+export const CALL_STATUS_FILTER_OPTIONS: {
+ id: CallStatus;
+ label: string;
+}[] = [
+ { id: 'ATTENDED', label: CALL_STATUS_LABELS.ATTENDED },
+ { id: 'MISSED', label: CALL_STATUS_LABELS.MISSED },
+ { id: 'UNATTENDED', label: CALL_STATUS_LABELS.UNATTENDED },
+];
+
+export function getCallStatusLabel(status: CallStatus): string {
+ return CALL_STATUS_LABELS[status];
+}
+
/**
* Picker for the "In" chip (channels + DMs). Used by channel-message and
* call-record search.
@@ -127,6 +160,7 @@ type EmailSubFilters = Pick<EmailFilters, 'importance'>;
type CallSubFilters = {
channel_ids?: string[];
speaker_ids?: string[];
+ status?: CallStatus | null;
attended?: boolean | null;
};
@@ -211,6 +245,19 @@ export function cacheCallSubFilters(
}
}
+function getInitialCallStatus(
+ cached: CallSubFilters,
+ query: Query
+): CallStatus | undefined {
+ if ('status' in cached) return cached.status ?? undefined;
+ if ('attended' in cached) return callStatusFromAttended(cached.attended);
+
+ return (
+ query.include?.callStatus ??
+ callStatusFromAttended(query.include?.callAttended)
+ );
+}
+
type SearchFilterHookOpts = {
contentId: string;
isSearchView: Accessor<boolean>;
@@ -296,10 +343,9 @@ export function useEmailSearchFilter(opts: SearchFilterHookOpts) {
type CallFieldMap = {
callChannelId: string[] | undefined;
callSpeakerId: string[] | undefined;
- callAttended: boolean | undefined;
};
-/** Call-record search filters (in:, from:, attended). */
+/** Call-record search filters (in:, from:, status). */
export function useCallSearchFilter(opts: SearchFilterHookOpts) {
const { soup, queryFilters } = useSoupView();
const { changeIndex } = useSearchIndexController();
@@ -324,15 +370,30 @@ export function useCallSearchFilter(opts: SearchFilterHookOpts) {
const speakerIds = createMemo(
() => queryFilters.state.include.callSpeakerId ?? []
);
- const attended = createMemo(() => queryFilters.state.include.callAttended);
+ const status = createMemo(
+ () =>
+ queryFilters.state.include.callStatus ??
+ callStatusFromAttended(queryFilters.state.include.callAttended)
+ );
+
+ const setStatus = (value: CallStatus | undefined) =>
+ batch(() => {
+ if (!isActive()) changeIndex('calls');
+ queryFilters.set({
+ include: {
+ callStatus: value,
+ callAttended: undefined,
+ },
+ });
+ });
createEffect(() => {
if (!opts.isSearchView() || !isActive()) return;
const sub: CallSubFilters = {};
+ const currentStatus = status();
if (channelIds().length) sub.channel_ids = channelIds();
if (speakerIds().length) sub.speaker_ids = speakerIds();
- if (attended() !== undefined && attended() !== null)
- sub.attended = attended();
+ if (currentStatus !== undefined) sub.status = currentStatus;
cacheCallSubFilters(opts.contentId, sub);
});
@@ -344,8 +405,8 @@ export function useCallSearchFilter(opts: SearchFilterHookOpts) {
speakerIds,
setSpeakerIds: (ids: string[]) =>
mutate('callSpeakerId', ids.length ? ids : undefined),
- attended,
- setAttended: (val: boolean | undefined) => mutate('callAttended', val),
+ status,
+ setStatus,
};
}
@@ -399,17 +460,15 @@ export function useSearchIndexController() {
});
} else if (opt.value === 'calls') {
const cached = getCachedCallSubFilters(contentId);
- const attended =
- 'attended' in cached
- ? (cached.attended ?? undefined)
- : opt.queryFilters.include?.callAttended;
+ const status = getInitialCallStatus(cached, opt.queryFilters);
queryFilters.replace({
include: {
...opt.queryFilters.include,
callChannelId: cached.channel_ids,
callSpeakerId: cached.speaker_ids,
- callAttended: attended,
+ callStatus: status,
+ callAttended: undefined,
},
exclude: opt.queryFilters.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 032205d102..6e54522bc1 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
@@ -41,6 +41,7 @@ import {
Switch,
} from 'solid-js';
import {
+ CALL_STATUS_OPTIONS,
INDEX_OPTIONS,
type SearchableOption,
useCallSearchFilter,
@@ -455,7 +456,7 @@ const SearchableFilterSubmenu = (props: {
);
};
-/** Single-value sub-menu (e.g. Importance, Attended). */
+/** Single-value sub-menu (e.g. Importance, Status). */
function SingleValueSubmenu<T>(props: {
label: string;
options: { label: string; value: T }[];
@@ -544,16 +545,7 @@ const EmailSearchSubContent = (props: {
/>
);
-const ATTENDED_OPTIONS: {
- label: string;
- value: boolean | undefined;
-}[] = [
- { label: 'Attended', value: true },
- { label: 'Unattended', value: false },
- { label: 'All', value: undefined },
-];
-
-/** In + From + Attended (calls). */
+/** In + From + Status (calls). */
const CallSearchSubContent = (props: {
call: ReturnType<typeof useCallSearchFilter>;
channelOptions: Accessor<SearchableOption[]>;
@@ -581,10 +573,10 @@ const CallSearchSubContent = (props: {
onOpenChange={(v) => setOpenSub(v ? 'from' : null)}
/>
<SingleValueSubmenu
- label="Attended"
- options={ATTENDED_OPTIONS}
- current={() => props.call.attended() ?? undefined}
- onSelect={props.call.setAttended}
+ label="Status"
+ options={CALL_STATUS_OPTIONS}
+ current={() => props.call.status() ?? undefined}
+ onSelect={props.call.setStatus}
/>
</>
);
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.tsx
index 0b65f290fc..14368ad616 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.tsx
@@ -15,6 +15,10 @@ import {
queryStateFrom,
} from '@app/component/next-soup/filters/filter-store';
import { mergeQuery } from '@app/component/next-soup/filters/filter-store/query-store';
+import {
+ type CallStatus,
+ callStatusFromAttended,
+} from '@app/component/next-soup/filters/filter-store/types';
import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
import type { ListView } from '@app/constants/list-views';
@@ -37,9 +41,11 @@ import type {
FilterValue,
} from './consolidated-filter-chip';
import {
+ CALL_STATUS_FILTER_OPTIONS,
cacheCallSubFilters,
cacheChannelSubFilters,
cacheEmailSubFilters,
+ getCallStatusLabel,
INDEX_OPTIONS,
type SearchableOption,
useSearchFilterOptions,
@@ -650,41 +656,41 @@ export function useFilterRefinements() {
searchPlaceholder: 'Search speakers...',
});
- // Call attended filter
- const callAttended = queryFilters.state.include.callAttended;
- if (callAttended !== undefined && callAttended !== null) {
- const key = 'call-attended';
+ // Call status filter
+ const getCurrentCallStatus = (): CallStatus | undefined =>
+ queryFilters.state.include.callStatus ??
+ callStatusFromAttended(queryFilters.state.include.callAttended);
+
+ if (getCurrentCallStatus() !== undefined) {
+ const key = 'call-status';
seenKeys.add(key);
- const getAttendedValues = (): FilterValue[] => {
- const attended = queryFilters.state.include.callAttended;
- if (attended === undefined || attended === null) return [];
- return [
- {
- id: attended ? 'yes' : 'no',
- label: attended ? 'Attended' : 'Unattended',
- },
- ];
+ const getCallStatusValues = (): FilterValue[] => {
+ const status = getCurrentCallStatus();
+ if (status === undefined) return [];
+ return [{ id: status, label: getCallStatusLabel(status) }];
};
filters.push(
getOrCreateConsolidatedChip(key, () => ({
key,
- categoryLabel: 'Attended',
- values: getAttendedValues,
- availableOptions: [
- { id: 'yes', label: 'Attended' },
- { id: 'no', label: 'Unattended' },
- ],
+ categoryLabel: 'Status',
+ values: getCallStatusValues,
+ availableOptions: CALL_STATUS_FILTER_OPTIONS,
multiple: false,
- isValueActive: (id) =>
- id === (queryFilters.state.include.callAttended ? 'yes' : 'no'),
+ isValueActive: (id) => id === getCurrentCallStatus(),
onToggleValue: (id) =>
- queryFilters.add({ include: { callAttended: id === 'yes' } }),
+ queryFilters.set({
+ include: {
+ callStatus: id as CallStatus,
+ callAttended: undefined,
+ },
+ }),
onRemoveAll: () =>
- queryFilters.remove({
+ queryFilters.set({
include: {
- callAttended: queryFilters.state.include.callAttended,
+ callStatus: undefined,
+ callAttended: undefined,
},
}),
}))
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx
index 75051e04cd..5f1b70f051 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx
@@ -74,6 +74,7 @@ export const VIEW_TAB_LISTS: Record<TabbedListView, TabItem[]> = {
],
calls: [
{ value: 'all', label: 'All' },
+ { value: 'missed', label: 'Missed' },
{ value: 'unattended', label: 'Unattended' },
],
folders: [
diff --git a/js/app/packages/entity/src/components/Badges.tsx b/js/app/packages/entity/src/components/Badges.tsx
index 3108864bc3..00840e7c8e 100644
--- a/js/app/packages/entity/src/components/Badges.tsx
+++ b/js/app/packages/entity/src/components/Badges.tsx
@@ -3,6 +3,7 @@ import { tryMacroId, useDisplayName } from '@core/user';
import UserPlus from '@phosphor/user-plus.svg';
import { cn, HoverCard } from '@ui';
import type { ParentProps } from 'solid-js';
+import type { CallStatus } from '../types/entity';
function Badge(props: ParentProps<{ class?: string }>) {
return (
@@ -103,16 +104,39 @@ function _ImportantBadge() {
);
}
+type CallStatusBadgeConfig = {
+ class: string;
+ label: string;
+};
+
+function getCallStatusBadgeConfig(status: CallStatus): CallStatusBadgeConfig {
+ switch (status) {
+ case 'ATTENDED':
+ return {
+ class: 'text-ink-extra-muted border-edge-muted px-2',
+ label: 'attended',
+ };
+ case 'MISSED':
+ return {
+ class: 'text-accent-30 border-edge-muted px-2',
+ label: 'missed',
+ };
+ case 'UNATTENDED':
+ return {
+ class: 'text-ink-extra-muted/70 border-edge-muted px-2',
+ label: 'unattended',
+ };
+ }
+}
+
+export function CallStatusBadge(props: { status: CallStatus }) {
+ const config = () => getCallStatusBadgeConfig(props.status);
+
+ return <Badge class={config().class}>{config().label}</Badge>;
+}
+
export function AttendanceBadge(props: { attended: boolean }) {
return (
- <Badge
- class={
- props.attended
- ? 'text-ink-extra-muted border-edge-muted px-2'
- : 'text-accent-30 border-edge-muted px-2'
- }
- >
- {props.attended ? 'attended' : 'unattended'}
- </Badge>
+ <CallStatusBadge status={props.attended ? 'ATTENDED' : 'UNATTENDED'} />
);
}
diff --git a/js/app/packages/entity/src/composed/list-entity/call.tsx b/js/app/packages/entity/src/composed/list-entity/call.tsx
index 1dd516d319..cb27391b60 100644
--- a/js/app/packages/entity/src/composed/list-entity/call.tsx
+++ b/js/app/packages/entity/src/composed/list-entity/call.tsx
@@ -8,7 +8,7 @@ import type { EntityReference } from '@property/types';
import { EntityType } from '@service-properties/generated/schemas/entityType';
import { HoverCard } from '@ui';
import { For, Show } from 'solid-js';
-import { AttendanceBadge } from '../../components/Badges';
+import { CallStatusBadge } from '../../components/Badges';
import { CallRecordName } from '../../components/CallRecordName';
import { Entity } from '../../entity';
import { HitSnippet } from '../../extractors-search/HitSnippet';
@@ -112,7 +112,7 @@ export function CallNarrowBody(props: {
{(ms) => formatCallDuration(ms())}
</Show>
<Show when={props.showAttendanceBadge}>
- <AttendanceBadge attended={props.entity.attended} />
+ <CallStatusBadge status={props.entity.status} />
</Show>
</span>
<Show when={!hit() && props.entity.summary}>
diff --git a/js/app/packages/entity/src/composed/list-entity/wide-layout.tsx b/js/app/packages/entity/src/composed/list-entity/wide-layout.tsx
index 6747ee39b2..ef54334dc5 100644
--- a/js/app/packages/entity/src/composed/list-entity/wide-layout.tsx
+++ b/js/app/packages/entity/src/composed/list-entity/wide-layout.tsx
@@ -1,7 +1,7 @@
import { useMaybeSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
import { cn } from '@ui';
import { Match, Show, Switch } from 'solid-js';
-import { AttendanceBadge, SharedBadge } from '../../components/Badges';
+import { CallStatusBadge, SharedBadge } from '../../components/Badges';
import { MultiSelectCheckbox } from '../../components/MultiSelectCheckbox';
import { ProjectBreadCrumb } from '../../components/ProjectBreadCrumb';
import { UnreadIndicator } from '../../components/UnreadIndicator';
@@ -145,7 +145,7 @@ export function WideLayout(props: LayoutProps) {
{(entity) => (
<>
<Show when={(soupView?.activeTab() ?? 'all') === 'all'}>
- <AttendanceBadge attended={entity().attended} />
+ <CallStatusBadge status={entity().status} />
</Show>
<span class="flex w-10 shrink-0 justify-end">
<CallParticipants participantIds={entity().participantIds} />
diff --git a/js/app/packages/entity/src/types/entity.ts b/js/app/packages/entity/src/types/entity.ts
index 31bcb23796..c68e96731d 100644
--- a/js/app/packages/entity/src/types/entity.ts
+++ b/js/app/packages/entity/src/types/entity.ts
@@ -5,6 +5,7 @@ import type {
GithubPullRequestComment,
SoupLabel,
SoupProperty,
+ CallStatus as StorageCallStatus,
} from '@service-storage/generated/schemas';
export type EntityBase = {
@@ -153,11 +154,15 @@ export type ProjectEntity = EntityBase & {
projectId?: string;
};
+export type CallStatus = StorageCallStatus;
+
export type CallEntity = EntityBase & {
type: 'call';
channelId: string;
channelName?: string;
isActive: boolean;
+ status: CallStatus;
+ /** Compatibility flag derived from status. */
attended: boolean;
durationMs?: number;
participantIds: string[];
diff --git a/js/app/packages/entity/src/utils/buildEntityData.ts b/js/app/packages/entity/src/utils/buildEntityData.ts
index 62b04438c6..87d6afb361 100644
--- a/js/app/packages/entity/src/utils/buildEntityData.ts
+++ b/js/app/packages/entity/src/utils/buildEntityData.ts
@@ -25,6 +25,7 @@ export type BuildEntityDataArgs = {
enabled?: boolean;
channelId?: string;
isActive?: boolean;
+ status?: CallEntity['status'];
attended?: boolean;
participantIds?: string[];
isRead?: boolean;
@@ -136,12 +137,16 @@ export function buildEntityData(
})
.with('call', (): CallEntity | undefined => {
if (!args.channelId) return undefined;
+ const status: CallEntity['status'] =
+ args.status ?? (args.attended ? 'ATTENDED' : 'UNATTENDED');
+
return {
...base,
type: 'call',
channelId: args.channelId,
isActive: args.isActive ?? false,
- attended: args.attended ?? false,
+ status,
+ attended: status === 'ATTENDED',
participantIds: args.participantIds ?? [],
};
})
diff --git a/js/app/packages/entity/tests/buildEntityData.test.ts b/js/app/packages/entity/tests/buildEntityData.test.ts
index 4f5a28df13..40304337b8 100644
--- a/js/app/packages/entity/tests/buildEntityData.test.ts
+++ b/js/app/packages/entity/tests/buildEntityData.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest';
+import type { CallStatus } from '../src/types/entity';
import { buildEntityData } from '../src/utils/buildEntityData';
const base = { id: 'id-1', name: 'Hello', ownerId: 'user-1' };
@@ -182,10 +183,36 @@ describe('buildEntityData', () => {
type: 'call',
channelId: 'c-1',
isActive: false,
+ status: 'UNATTENDED',
attended: false,
participantIds: [],
});
});
+
+ it.each([
+ { status: 'ATTENDED', attended: true },
+ { status: 'MISSED', attended: false },
+ { status: 'UNATTENDED', attended: false },
+ ] satisfies Array<{
+ status: CallStatus;
+ attended: boolean;
+ }>)('builds a $status call with derived attendance', ({
+ status,
+ attended,
+ }) => {
+ expect(
+ buildEntityData({
+ ...base,
+ blockName: 'call',
+ channelId: 'c-1',
+ status,
+ })
+ ).toMatchObject({
+ type: 'call',
+ status,
+ attended,
+ });
+ });
});
describe('csv alias', () => {
diff --git a/js/app/packages/queries/soup/transform-utils.ts b/js/app/packages/queries/soup/transform-utils.ts
index 016ee2392c..279ce425d3 100644
--- a/js/app/packages/queries/soup/transform-utils.ts
+++ b/js/app/packages/queries/soup/transform-utils.ts
@@ -425,6 +425,7 @@ export const useSearchResponseItemMapper = () => {
result.metadata.channel_name ??
channels().find((c) => c.id === result.channel_id)?.name ??
undefined;
+ const status = result.metadata.status;
return [
{
@@ -437,7 +438,8 @@ export const useSearchResponseItemMapper = () => {
createdAt: result.metadata.started_at,
updatedAt: result.metadata.updated_at,
isActive: false,
- attended: result.metadata.attended,
+ status,
+ attended: status === 'ATTENDED',
durationMs: result.metadata.duration_ms,
participantIds: result.participant_ids,
search,
@@ -576,6 +578,8 @@ export const mapSoupPageToEntityList: (
}
if (item.tag === 'call') {
+ const status = item.data.status;
+
return {
type: 'call',
id: item.data.callId,
@@ -590,7 +594,8 @@ export const mapSoupPageToEntityList: (
updatedAt: item.data.endedAt ?? item.data.startedAt,
sortTs: item.data.endedAt ?? item.data.startedAt,
isActive: item.data.isActive,
- attended: item.data.attended,
+ status,
+ attended: status === 'ATTENDED',
durationMs: item.data.durationMs ?? undefined,
participantIds: item.data.participants.map((p) => p.userId),
summary: item.data.summary ?? undefined,
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 408c8e349f..f38dcdfd15 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
@@ -359,6 +359,29 @@ export const SearchToolResponse = z.object({
duration_ms: z.number().int(),
ended_at: z.string().datetime({ offset: true }),
started_at: z.string().datetime({ offset: true }),
+ status: z.any().superRefine((x, ctx) => {
+ const schemas = [
+ z.literal('ATTENDED'),
+ z.literal('MISSED'),
+ z.literal('UNATTENDED'),
+ ];
+ const errors = schemas.reduce<z.ZodError[]>(
+ (errors, schema) =>
+ ((result) =>
+ result.error ? [...errors, result.error] : errors)(
+ schema.safeParse(x)
+ ),
+ []
+ );
+ if (schemas.length - errors.length !== 1) {
+ ctx.addIssue({
+ path: ctx.path,
+ code: 'invalid_union',
+ unionErrors: errors,
+ message: 'Invalid input: Should pass single schema',
+ });
+ }
+ }),
updated_at: z.string().datetime({ offset: true }),
}),
z.null(),
@@ -499,6 +522,9 @@ export const GetThreadResponse = z.object({
export const ListCallRecords = z.object({
attended: z.union([z.boolean(), z.null()]).optional(),
channelId: z.union([z.string().uuid(), z.null()]).optional(),
+ status: z
+ .union([z.enum(['ATTENDED', 'MISSED', 'UNATTENDED']), z.null()])
+ .optional(),
});
export const ListCallRecordsResponse = z.object({
@@ -515,6 +541,9 @@ export const ListCallRecordsResponse = z.object({
isActive: z.boolean(),
participants: z.array(z.string()),
startedAt: z.string().datetime({ offset: true }),
+ status: z
+ .union([z.enum(['ATTENDED', 'MISSED', 'UNATTENDED']), z.null()])
+ .optional(),
})
),
});
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 12a8bd87b8..09b5373b2a 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
@@ -33,6 +33,16 @@ export type CodeExecutionErrorCode =
| 'too_many_requests'
| 'file_not_found'
| 'string_not_found';
+/**
+ * Viewer-relative attendance status for a call record.
+ * Serializes as `ATTENDED`, `MISSED`, or `UNATTENDED`.
+ */
+export type CallStatus = 'ATTENDED' | 'MISSED' | 'UNATTENDED';
+/**
+ * Schema-only mirror of [`CallStatus`] without variant docs, keeping AI tool
+ * schemas as a simple enum instead of `oneOf`.
+ */
+export type ToolCallStatus = 'ATTENDED' | 'MISSED' | 'UNATTENDED';
/**
* Type of channel timeline window to read.
*/
@@ -369,6 +379,7 @@ export interface CallRecordMetadata {
duration_ms: number;
ended_at: string;
started_at: string;
+ status: CallStatus;
updated_at: string;
}
export interface CallRecordSearchResponseItemWithMetadata {
@@ -464,6 +475,10 @@ export interface CallRecordSummary {
* When the call started.
*/
startedAt: string;
+ /**
+ * The caller's viewer-relative status for this call.
+ */
+ status?: ToolCallStatus | null;
}
/**
* Metadata for a channel fetched from the database
@@ -1216,17 +1231,21 @@ export interface ToolContact {
name?: string | null;
}
/**
- * List recent call records the user can access, ordered by start time descending. Results are scoped to channels the user is a member of. Transcripts are NOT included — call ReadCallRecord with a specific callId to fetch a transcript.
+ * List recent call records the user can access, ordered by start time descending. Status is relative to the caller. Transcripts are NOT included — call ReadCallRecord with a specific callId to fetch a transcript.
*/
export interface ListCallRecords {
/**
- * Optional filter on whether the caller joined the call. true = only calls the user attended; false = only calls the user did not attend; omit to include both.
+ * Deprecated compatibility filter. true = only calls the user attended; false = only calls the user did not attend; omit to include both. Ignored when status is provided.
*/
attended?: boolean | null;
/**
* Optional channel id. When provided, only calls from that channel are returned.
*/
channelId?: string | null;
+ /**
+ * Optional viewer-relative status filter. ATTENDED = calls the user joined; MISSED = calls the user did not join while they are in the channel; UNATTENDED = calls the user did not join while they are not in the channel. Prefer this over the deprecated attended filter.
+ */
+ status?: ToolCallStatus | null;
}
/**
* Response for [`ListCallRecords`].
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
index d17de9a5d5..cf151f343d 100644
--- a/js/app/packages/service-clients/service-search/generated/models/callFilters.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/callFilters.ts
@@ -5,12 +5,14 @@
* OpenAPI spec version: 0.1.0
*/
import type { CallFiltersAttended } from './callFiltersAttended';
+import type { CallFiltersStatus } from './callFiltersStatus';
/**
* Filters for call records.
*/
export interface CallFilters {
- /** Filter by whether the requesting user attended the call.
+ /** Legacy filter by whether the requesting user attended the call.
+Prefer [`CallFilters::status`] for new callers.
`None` = no filter, `Some(true)` = only calls the user joined,
`Some(false)` = only calls the user did not join. */
attended?: CallFiltersAttended;
@@ -20,4 +22,5 @@ export interface CallFilters {
channel_ids?: string[];
/** Speaker macro user ids. Empty to include all. */
speaker_ids?: string[];
+ status?: CallFiltersStatus;
}
diff --git a/js/app/packages/service-clients/service-search/generated/models/callFiltersAttended.ts b/js/app/packages/service-clients/service-search/generated/models/callFiltersAttended.ts
index 266bcec130..15032d1ba6 100644
--- a/js/app/packages/service-clients/service-search/generated/models/callFiltersAttended.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/callFiltersAttended.ts
@@ -6,7 +6,8 @@
*/
/**
- * Filter by whether the requesting user attended the call.
+ * Legacy filter by whether the requesting user attended the call.
+Prefer [`CallFilters::status`] for new callers.
`None` = no filter, `Some(true)` = only calls the user joined,
`Some(false)` = only calls the user did not join.
*/
diff --git a/js/app/packages/service-clients/service-search/generated/models/callFiltersStatus.ts b/js/app/packages/service-clients/service-search/generated/models/callFiltersStatus.ts
new file mode 100644
index 0000000000..c6024881e7
--- /dev/null
+++ b/js/app/packages/service-clients/service-search/generated/models/callFiltersStatus.ts
@@ -0,0 +1,9 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * search_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { CallStatus } from './callStatus';
+
+export type CallFiltersStatus = null | CallStatus;
diff --git a/js/app/packages/service-clients/service-search/generated/models/callRecordMetadata.ts b/js/app/packages/service-clients/service-search/generated/models/callRecordMetadata.ts
index 8d7b7859af..eaabf8635d 100644
--- a/js/app/packages/service-clients/service-search/generated/models/callRecordMetadata.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/callRecordMetadata.ts
@@ -5,6 +5,7 @@
* OpenAPI spec version: 0.1.0
*/
import type { CallRecordMetadataChannelName } from './callRecordMetadataChannelName';
+import type { CallStatus } from './callStatus';
export interface CallRecordMetadata {
attended: boolean;
@@ -13,5 +14,6 @@ export interface CallRecordMetadata {
duration_ms: number;
ended_at: string;
started_at: string;
+ status: CallStatus;
updated_at: string;
}
diff --git a/js/app/packages/service-clients/service-search/generated/models/callStatus.ts b/js/app/packages/service-clients/service-search/generated/models/callStatus.ts
new file mode 100644
index 0000000000..002b91ccd0
--- /dev/null
+++ b/js/app/packages/service-clients/service-search/generated/models/callStatus.ts
@@ -0,0 +1,19 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * search_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Viewer-relative attendance status for a call record.
+Serializes as `ATTENDED`, `MISSED`, or `UNATTENDED`.
+ */
+export type CallStatus = (typeof CallStatus)[keyof typeof CallStatus];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const CallStatus = {
+ ATTENDED: 'ATTENDED',
+ MISSED: 'MISSED',
+ UNATTENDED: 'UNATTENDED',
+} as const;
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 81c1f11720..b0d1b3b03e 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
@@ -7,6 +7,7 @@
export * from './callFilters';
export * from './callFiltersAttended';
+export * from './callFiltersStatus';
export * from './callRecordMetadata';
export * from './callRecordMetadataChannelName';
export * from './callRecordSearchResponseItem';
@@ -21,6 +22,7 @@ export * from './callRecordSearchResultSequenceNum';
export * from './callRecordSearchResultSpeakerId';
export * from './callRecordSearchResultStartedAt';
export * from './callRecordSearchResultTranscriptId';
+export * from './callStatus';
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 b5a47f945d..93679f7145 100644
--- a/js/app/packages/service-clients/service-search/openapi.json
+++ b/js/app/packages/service-clients/service-search/openapi.json
@@ -179,7 +179,7 @@
"properties": {
"attended": {
"type": ["boolean", "null"],
- "description": "Filter by whether the requesting user attended the call.\n`None` = no filter, `Some(true)` = only calls the user joined,\n`Some(false)` = only calls the user did not join."
+ "description": "Legacy filter by whether the requesting user attended the call.\nPrefer [`CallFilters::status`] for new callers.\n`None` = no filter, `Some(true)` = only calls the user joined,\n`Some(false)` = only calls the user did not join."
},
"call_ids": {
"type": "array",
@@ -201,6 +201,17 @@
"type": "string"
},
"description": "Speaker macro user ids. Empty to include all."
+ },
+ "status": {
+ "oneOf": [
+ {
+ "type": "null"
+ },
+ {
+ "$ref": "#/components/schemas/CallStatus",
+ "description": "Filter by the requesting user's viewer-relative call status."
+ }
+ ]
}
}
},
@@ -212,6 +223,7 @@
"ended_at",
"duration_ms",
"updated_at",
+ "status",
"attended"
],
"properties": {
@@ -236,6 +248,9 @@
"type": "string",
"format": "date-time"
},
+ "status": {
+ "$ref": "#/components/schemas/CallStatus"
+ },
"updated_at": {
"type": "string",
"format": "date-time"
@@ -340,6 +355,11 @@
}
}
},
+ "CallStatus": {
+ "type": "string",
+ "description": "Viewer-relative attendance status for a call record.\nSerializes as `ATTENDED`, `MISSED`, or `UNATTENDED`.",
+ "enum": ["ATTENDED", "MISSED", "UNATTENDED"]
+ },
"ChannelFilters": {
"type": "object",
"description": "The channel message filters used to filter down what channel messages you search over.",
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
index 38abf27366..5b44e8aa62 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/callFilters.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callFilters.ts
@@ -5,12 +5,14 @@
* OpenAPI spec version: 0.1.0
*/
import type { CallFiltersAttended } from './callFiltersAttended';
+import type { CallFiltersStatus } from './callFiltersStatus';
/**
* Filters for call records.
*/
export interface CallFilters {
- /** Filter by whether the requesting user attended the call.
+ /** Legacy filter by whether the requesting user attended the call.
+Prefer [`CallFilters::status`] for new callers.
`None` = no filter, `Some(true)` = only calls the user joined,
`Some(false)` = only calls the user did not join. */
attended?: CallFiltersAttended;
@@ -20,4 +22,5 @@ export interface CallFilters {
channel_ids?: string[];
/** Speaker macro user ids. Empty to include all. */
speaker_ids?: string[];
+ status?: CallFiltersStatus;
}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callFiltersAttended.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callFiltersAttended.ts
index aeb3f830f7..4f94fa82fe 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/callFiltersAttended.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callFiltersAttended.ts
@@ -6,7 +6,8 @@
*/
/**
- * Filter by whether the requesting user attended the call.
+ * Legacy filter by whether the requesting user attended the call.
+Prefer [`CallFilters::status`] for new callers.
`None` = no filter, `Some(true)` = only calls the user joined,
`Some(false)` = only calls the user did not join.
*/
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callFiltersStatus.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callFiltersStatus.ts
new file mode 100644
index 0000000000..09726c10da
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callFiltersStatus.ts
@@ -0,0 +1,9 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { CallStatus } from './callStatus';
+
+export type CallFiltersStatus = null | CallStatus;
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 ac45d94c85..eba96ca4c6 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
@@ -13,6 +13,7 @@ import type { CallRecordParticipant } from './callRecordParticipant';
import type { CallRecordRecordingPreviewUrl } from './callRecordRecordingPreviewUrl';
import type { CallRecordRecordingStartedAt } from './callRecordRecordingStartedAt';
import type { CallRecordRecordingUrl } from './callRecordRecordingUrl';
+import type { CallRecordStatus } from './callRecordStatus';
import type { CallRecordSummary } from './callRecordSummary';
import type { CallRecordTranscriptSegment } from './callRecordTranscriptSegment';
@@ -57,6 +58,7 @@ this value when present, falling back to `started_at` otherwise. */
shareWithTeam: boolean;
/** When the call started (created_at for active, started_at for archived). */
startedAt: string;
+ status?: CallRecordStatus;
/** AI-generated summary of the call. Only set on archived `call_records`
once summarization has run; active calls always return `None`. */
summary?: CallRecordSummary;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callRecordStatus.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordStatus.ts
new file mode 100644
index 0000000000..4ae6f26174
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callRecordStatus.ts
@@ -0,0 +1,9 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { CallStatus } from './callStatus';
+
+export type CallRecordStatus = null | CallStatus;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callStatus.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callStatus.ts
new file mode 100644
index 0000000000..2153716009
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callStatus.ts
@@ -0,0 +1,19 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Viewer-relative attendance status for a call record.
+Serializes as `ATTENDED`, `MISSED`, or `UNATTENDED`.
+ */
+export type CallStatus = (typeof CallStatus)[keyof typeof CallStatus];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const CallStatus = {
+ ATTENDED: 'ATTENDED',
+ MISSED: 'MISSED',
+ UNATTENDED: 'UNATTENDED',
+} as const;
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 a304057a04..5793030a7a 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
@@ -109,6 +109,7 @@ export * from './bulkWakeupResponse';
export * from './callActiveResponse';
export * from './callFilters';
export * from './callFiltersAttended';
+export * from './callFiltersStatus';
export * from './callRecord';
export * from './callRecordChannelName';
export * from './callRecordCustomName';
@@ -131,11 +132,13 @@ export * from './callRecordPreviewOneOfFourAllOfType';
export * from './callRecordRecordingPreviewUrl';
export * from './callRecordRecordingStartedAt';
export * from './callRecordRecordingUrl';
+export * from './callRecordStatus';
export * from './callRecordSummary';
export * from './callRecordTranscriptSegment';
export * from './callRecordTranscriptSegmentDiarizedSpeakerId';
export * from './callRecordTranscriptSegmentEndedAt';
export * from './callRecordTranscriptSegmentSegmentId';
+export * from './callStatus';
export * from './callTokenResponse';
export * from './channel';
export * from './channelFilters';
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
index 6d249d9f2e..df54c7a0c4 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecord.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecord.ts
@@ -4,6 +4,8 @@
* document_storage_service
* OpenAPI spec version: 0.1.0
*/
+
+import type { CallStatus } from './callStatus';
import type { SoupCallRecordChannelName } from './soupCallRecordChannelName';
import type { SoupCallRecordCustomName } from './soupCallRecordCustomName';
import type { SoupCallRecordDurationMs } from './soupCallRecordDurationMs';
@@ -16,8 +18,8 @@ import type { SoupCallRecordSummary } from './soupCallRecordSummary';
and transcript — fields that are irrelevant for the soup feed.
*/
export interface SoupCallRecord {
- /** Whether the requesting user attended this call (i.e. appears in the
-`call_participants` / `call_record_participants` table). */
+ /** Whether the requesting user attended this call. Kept for compatibility
+and derived from `status == ATTENDED`. */
attended: boolean;
/** The call identifier. */
callId: string;
@@ -39,6 +41,8 @@ export interface SoupCallRecord {
participants: SoupCallRecordParticipant[];
/** When the call started. */
startedAt: string;
+ /** Viewer-relative call status for the requesting user. */
+ status: CallStatus;
/** AI-generated summary of the call. Only set on archived
`call_records` once summarization has run; active calls always
return `None`. */
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 da256d765a..6a5002fd82 100644
--- a/js/app/packages/service-clients/service-storage/generated/zod.ts
+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts
@@ -980,6 +980,16 @@ export const getCallRecordResponse = zod
.describe(
'When the call started (created_at for active, started_at for archived).'
),
+ status: zod
+ .union([
+ zod.null(),
+ zod
+ .enum(['ATTENDED', 'MISSED', 'UNATTENDED'])
+ .describe(
+ 'Viewer-relative attendance status for a call record.\nSerializes as `ATTENDED`, `MISSED`, or `UNATTENDED`.'
+ ),
+ ])
+ .optional(),
summary: zod
.string()
.nullish()
@@ -7126,7 +7136,7 @@ export const getItemsSoupResponse = zod.object({
attended: zod
.boolean()
.describe(
- 'Whether the requesting user attended this call (i.e. appears in the\n`call_participants` \/ `call_record_participants` table).'
+ 'Whether the requesting user attended this call. Kept for compatibility\nand derived from `status == ATTENDED`.'
),
callId: zod.uuid().describe('The call identifier.'),
channelId: zod
@@ -7179,6 +7189,11 @@ export const getItemsSoupResponse = zod.object({
startedAt: zod.iso
.datetime({})
.describe('When the call started.'),
+ status: zod
+ .enum(['ATTENDED', 'MISSED', 'UNATTENDED'])
+ .describe(
+ 'Viewer-relative attendance status for a call record.\nSerializes as `ATTENDED`, `MISSED`, or `UNATTENDED`.'
+ ),
summary: zod
.string()
.nullish()
@@ -7326,7 +7341,7 @@ export const postItemsSoupBody = zod
.boolean()
.nullish()
.describe(
- 'Filter by whether the requesting user attended the call.\n`None` = no filter, `Some(true)` = only calls the user joined,\n`Some(false)` = only calls the user did not join.'
+ 'Legacy filter by whether the requesting user attended the call.\nPrefer [`CallFilters::status`] for new callers.\n`None` = no filter, `Some(true)` = only calls the user joined,\n`Some(false)` = only calls the user did not join.'
),
call_ids: zod
.array(zod.string())
@@ -7344,6 +7359,16 @@ export const postItemsSoupBody = zod
.array(zod.string())
.optional()
.describe('Speaker macro user ids. Empty to include all.'),
+ status: zod
+ .union([
+ zod.null(),
+ zod
+ .enum(['ATTENDED', 'MISSED', 'UNATTENDED'])
+ .describe(
+ 'Viewer-relative attendance status for a call record.\nSerializes as `ATTENDED`, `MISSED`, or `UNATTENDED`.'
+ ),
+ ])
+ .optional(),
})
.optional()
.describe('Filters for call records.'),
@@ -8979,7 +9004,7 @@ export const postItemsSoupResponse = zod.object({
attended: zod
.boolean()
.describe(
- 'Whether the requesting user attended this call (i.e. appears in the\n`call_participants` \/ `call_record_participants` table).'
+ 'Whether the requesting user attended this call. Kept for compatibility\nand derived from `status == ATTENDED`.'
),
callId: zod.uuid().describe('The call identifier.'),
channelId: zod
@@ -9032,6 +9057,11 @@ export const postItemsSoupResponse = zod.object({
startedAt: zod.iso
.datetime({})
.describe('When the call started.'),
+ status: zod
+ .enum(['ATTENDED', 'MISSED', 'UNATTENDED'])
+ .describe(
+ 'Viewer-relative attendance status for a call record.\nSerializes as `ATTENDED`, `MISSED`, or `UNATTENDED`.'
+ ),
summary: zod
.string()
.nullish()
@@ -10425,7 +10455,7 @@ export const postItemsSoupAstResponse = zod.object({
attended: zod
.boolean()
.describe(
- 'Whether the requesting user attended this call (i.e. appears in the\n`call_participants` \/ `call_record_participants` table).'
+ 'Whether the requesting user attended this call. Kept for compatibility\nand derived from `status == ATTENDED`.'
),
callId: zod.uuid().describe('The call identifier.'),
channelId: zod
@@ -10478,6 +10508,11 @@ export const postItemsSoupAstResponse = zod.object({
startedAt: zod.iso
.datetime({})
.describe('When the call started.'),
+ status: zod
+ .enum(['ATTENDED', 'MISSED', 'UNATTENDED'])
+ .describe(
+ 'Viewer-relative attendance status for a call record.\nSerializes as `ATTENDED`, `MISSED`, or `UNATTENDED`.'
+ ),
summary: zod
.string()
.nullish()
diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.json
index 2ae3caf7b6..6ce01ba44a 100644
--- a/js/app/packages/service-clients/service-storage/openapi.json
+++ b/js/app/packages/service-clients/service-storage/openapi.json
@@ -9541,7 +9541,7 @@
"properties": {
"attended": {
"type": ["boolean", "null"],
- "description": "Filter by whether the requesting user attended the call.\n`None` = no filter, `Some(true)` = only calls the user joined,\n`Some(false)` = only calls the user did not join."
+ "description": "Legacy filter by whether the requesting user attended the call.\nPrefer [`CallFilters::status`] for new callers.\n`None` = no filter, `Some(true)` = only calls the user joined,\n`Some(false)` = only calls the user did not join."
},
"call_ids": {
"type": "array",
@@ -9563,6 +9563,17 @@
"type": "string"
},
"description": "Speaker macro user ids. Empty to include all."
+ },
+ "status": {
+ "oneOf": [
+ {
+ "type": "null"
+ },
+ {
+ "$ref": "#/components/schemas/CallStatus",
+ "description": "Filter by the requesting user's viewer-relative call status."
+ }
+ ]
}
}
},
@@ -9654,6 +9665,17 @@
"format": "date-time",
"description": "When the call started (created_at for active, started_at for archived)."
},
+ "status": {
+ "oneOf": [
+ {
+ "type": "null"
+ },
+ {
+ "$ref": "#/components/schemas/CallStatus",
+ "description": "Viewer-relative call status when fetched in the context of a specific user."
+ }
+ ]
+ },
"summary": {
"type": ["string", "null"],
"description": "AI-generated summary of the call. Only set on archived `call_records`\nonce summarization has run; active calls always return `None`."
@@ -9815,6 +9837,11 @@
}
}
},
+ "CallStatus": {
+ "type": "string",
+ "description": "Viewer-relative attendance status for a call record.\nSerializes as `ATTENDED`, `MISSED`, or `UNATTENDED`.",
+ "enum": ["ATTENDED", "MISSED", "UNATTENDED"]
+ },
"CallTokenResponse": {
"type": "object",
"description": "Response returned when creating or joining a call.",
@@ -15863,13 +15890,14 @@
"createdBy",
"startedAt",
"isActive",
+ "status",
"attended",
"participants"
],
"properties": {
"attended": {
"type": "boolean",
- "description": "Whether the requesting user attended this call (i.e. appears in the\n`call_participants` / `call_record_participants` table)."
+ "description": "Whether the requesting user attended this call. Kept for compatibility\nand derived from `status == ATTENDED`."
},
"callId": {
"type": "string",
@@ -15919,6 +15947,10 @@
"format": "date-time",
"description": "When the call started."
},
+ "status": {
+ "$ref": "#/components/schemas/CallStatus",
+ "description": "Viewer-relative call status for the requesting user."
+ },
"summary": {
"type": ["string", "null"],
"description": "AI-generated summary of the call. Only set on archived\n`call_records` once summarization has run; active calls always\nreturn `None`."
diff --git a/js/app/tests/e2e/local-sidebar.spec.ts b/js/app/tests/e2e/local-sidebar.spec.ts
index a7bda737f7..b2258e88c9 100644
--- a/js/app/tests/e2e/local-sidebar.spec.ts
+++ b/js/app/tests/e2e/local-sidebar.spec.ts
@@ -28,7 +28,7 @@ const SIDEBAR_LIST_VIEWS = [
},
{ id: 'tasks', label: 'Tasks', tabs: ['Assigned', 'Created', 'All'] },
{ id: 'channels', label: 'Channels', tabs: ['Recent', 'People', 'Teams'] },
- { id: 'calls', label: 'Calls', tabs: ['All', 'Unattended'] },
+ { id: 'calls', label: 'Calls', tabs: ['All', 'Missed', 'Unattended'] },
{ id: 'folders', label: 'Folders', tabs: ['Owned', 'All'] },
] as const;
diff --git a/rust/cloud-storage/.sqlx/query-1787f623620cbe61083403a7e51577540398e8ce459156d6f83fcb8193fc2800.json b/rust/cloud-storage/.sqlx/query-1787f623620cbe61083403a7e51577540398e8ce459156d6f83fcb8193fc2800.json
new file mode 100644
index 0000000000..da58536bad
--- /dev/null
+++ b/rust/cloud-storage/.sqlx/query-1787f623620cbe61083403a7e51577540398e8ce459156d6f83fcb8193fc2800.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n WITH user_source_ids AS (\n SELECT cp.channel_id::text AS source_id\n FROM comms_channel_participants cp\n WHERE cp.user_id = $1 AND cp.left_at IS NULL\n UNION ALL\n SELECT t.team_id::text\n FROM team_user t\n WHERE t.user_id = $1\n UNION ALL\n SELECT $1\n ),\n visible_calls AS (\n SELECT\n cr.id,\n CASE\n WHEN EXISTS (\n SELECT 1 FROM call_record_participants crp\n WHERE crp.call_record_id = cr.id AND crp.user_id = $1\n ) THEN 'ATTENDED'\n WHEN EXISTS (\n SELECT 1 FROM comms_channel_participants ccp\n WHERE ccp.channel_id = cr.channel_id\n AND ccp.user_id = $1\n AND ccp.left_at IS NULL\n ) THEN 'MISSED'\n ELSE 'UNATTENDED'\n END AS status\n FROM call_records cr\n WHERE (\n EXISTS (\n SELECT 1 FROM entity_access ea\n WHERE ea.entity_id = cr.id\n AND ea.entity_type = 'call'\n AND ea.source_id IN (SELECT source_id FROM user_source_ids)\n ) OR EXISTS (\n SELECT 1 FROM \"SharePermission\" sp\n WHERE sp.id = cr.share_permission_id\n AND sp.\"isPublic\" = true\n AND sp.\"publicAccessLevel\" IS NOT NULL\n )\n )\n )\n SELECT id AS \"id!\"\n FROM visible_calls\n WHERE cardinality($2::text[]) = 0 OR status = ANY($2)\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id!",
+ "type_info": "Uuid"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text",
+ "TextArray"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "1787f623620cbe61083403a7e51577540398e8ce459156d6f83fcb8193fc2800"
+}
diff --git a/rust/cloud-storage/.sqlx/query-4335b5e8988b8d37dba886ecb9a1c06701a3d1f26a605fae745a70c264a9971a.json b/rust/cloud-storage/.sqlx/query-4335b5e8988b8d37dba886ecb9a1c06701a3d1f26a605fae745a70c264a9971a.json
deleted file mode 100644
index c6ed4c4137..0000000000
--- a/rust/cloud-storage/.sqlx/query-4335b5e8988b8d37dba886ecb9a1c06701a3d1f26a605fae745a70c264a9971a.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n WITH user_source_ids AS (\n SELECT cp.channel_id::text AS source_id\n FROM comms_channel_participants cp\n WHERE cp.user_id = $1 AND cp.left_at IS NULL\n UNION ALL\n SELECT t.team_id::text\n FROM team_user t\n WHERE t.user_id = $1\n UNION ALL\n SELECT $1\n )\n SELECT DISTINCT cr.id AS \"id!\"\n FROM call_records cr\n WHERE (\n EXISTS (\n SELECT 1 FROM entity_access ea\n WHERE ea.entity_id = cr.id\n AND ea.entity_type = 'call'\n AND ea.source_id IN (SELECT source_id FROM user_source_ids)\n ) OR EXISTS (\n SELECT 1 FROM \"SharePermission\" sp\n WHERE sp.id = cr.share_permission_id\n AND sp.\"isPublic\" = true\n AND sp.\"publicAccessLevel\" IS NOT NULL\n )\n )\n AND ($2::bool IS NULL OR EXISTS (\n SELECT 1 FROM call_record_participants crp\n WHERE crp.call_record_id = cr.id AND crp.user_id = $1\n ) = $2)\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id!",
- "type_info": "Uuid"
- }
- ],
- "parameters": {
- "Left": [
- "Text",
- "Bool"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "4335b5e8988b8d37dba886ecb9a1c06701a3d1f26a605fae745a70c264a9971a"
-}
diff --git a/rust/cloud-storage/.sqlx/query-79edd9ca0d31434d5d7a4db78a6b3f8eb316ff51e1099e40611ba77f5c048828.json b/rust/cloud-storage/.sqlx/query-79edd9ca0d31434d5d7a4db78a6b3f8eb316ff51e1099e40611ba77f5c048828.json
new file mode 100644
index 0000000000..2cef855296
--- /dev/null
+++ b/rust/cloud-storage/.sqlx/query-79edd9ca0d31434d5d7a4db78a6b3f8eb316ff51e1099e40611ba77f5c048828.json
@@ -0,0 +1,119 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n WITH user_source_ids AS (\n SELECT cp.channel_id::text AS source_id\n FROM comms_channel_participants cp\n WHERE cp.user_id = $1 AND cp.left_at IS NULL\n UNION ALL\n SELECT t.team_id::text AS source_id\n FROM team_user t\n WHERE t.user_id = $1\n UNION ALL\n SELECT $1 AS source_id\n ),\n visible_calls AS (\n SELECT\n c.id AS call_id,\n c.channel_id,\n c.room_name,\n c.created_by,\n c.created_at AS started_at,\n NULL::timestamptz AS ended_at,\n NULL::bigint AS duration_ms,\n c.egress_id,\n c.recording_key,\n c.preview_url,\n c.recording_started_at,\n NULL::text AS custom_name,\n NULL::text AS summary,\n c.share_with_team,\n true AS is_active,\n CASE\n WHEN EXISTS (\n SELECT 1 FROM call_participants cp\n WHERE cp.call_id = c.id AND cp.user_id = $1\n ) THEN 'ATTENDED'::text\n WHEN EXISTS (\n SELECT 1 FROM comms_channel_participants ccp\n WHERE ccp.channel_id = c.channel_id\n AND ccp.user_id = $1\n AND ccp.left_at IS NULL\n ) THEN 'MISSED'::text\n ELSE 'UNATTENDED'::text\n END AS status\n FROM calls c\n WHERE EXISTS (\n SELECT 1 FROM entity_access ea\n JOIN user_source_ids u ON u.source_id = ea.source_id\n WHERE ea.entity_id = c.id\n AND ea.entity_type = 'call'\n )\n AND ($3::bool IS FALSE OR c.channel_id = ANY($4))\n AND ($5::bool IS FALSE OR c.id = ANY($6))\n UNION ALL\n SELECT\n cr.id AS call_id,\n cr.channel_id,\n cr.room_name,\n cr.created_by,\n cr.started_at,\n cr.ended_at,\n cr.duration_ms,\n cr.egress_id,\n cr.recording_key,\n cr.preview_url,\n cr.recording_started_at,\n cr.custom_name,\n cr.summary,\n cr.share_with_team,\n false AS is_active,\n CASE\n WHEN EXISTS (\n SELECT 1 FROM call_record_participants crp\n WHERE crp.call_record_id = cr.id AND crp.user_id = $1\n ) THEN 'ATTENDED'::text\n WHEN EXISTS (\n SELECT 1 FROM comms_channel_participants ccp\n WHERE ccp.channel_id = cr.channel_id\n AND ccp.user_id = $1\n AND ccp.left_at IS NULL\n ) THEN 'MISSED'::text\n ELSE 'UNATTENDED'::text\n END AS status\n FROM call_records cr\n WHERE EXISTS (\n SELECT 1 FROM entity_access ea\n JOIN user_source_ids u ON u.source_id = ea.source_id\n WHERE ea.entity_id = cr.id\n AND ea.entity_type = 'call'\n )\n AND ($3::bool IS FALSE OR cr.channel_id = ANY($4))\n AND ($5::bool IS FALSE OR cr.id = ANY($6))\n )\n SELECT\n call_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,\n duration_ms,\n egress_id,\n recording_key,\n preview_url,\n recording_started_at,\n custom_name,\n summary,\n share_with_team as \"share_with_team!\",\n is_active as \"is_active!\",\n status as \"status!\"\n FROM visible_calls\n WHERE ($7::bool IS FALSE OR status = ANY($8::text[]))\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": "preview_url",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 10,
+ "name": "recording_started_at",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 11,
+ "name": "custom_name",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 12,
+ "name": "summary",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 13,
+ "name": "share_with_team!",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 14,
+ "name": "is_active!",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 15,
+ "name": "status!",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text",
+ "Int8",
+ "Bool",
+ "UuidArray",
+ "Bool",
+ "UuidArray",
+ "Bool",
+ "TextArray"
+ ]
+ },
+ "nullable": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ]
+ },
+ "hash": "79edd9ca0d31434d5d7a4db78a6b3f8eb316ff51e1099e40611ba77f5c048828"
+}
diff --git a/rust/cloud-storage/.sqlx/query-5945da24df02edef42222564bd97f153d87be6e876568063a7bdb183c41a01e9.json b/rust/cloud-storage/.sqlx/query-7da22b0b109d1caac6384294fafaef3148e80824e023ddee78473fbae17720de.json
similarity index 65%
rename from rust/cloud-storage/.sqlx/query-5945da24df02edef42222564bd97f153d87be6e876568063a7bdb183c41a01e9.json
rename to rust/cloud-storage/.sqlx/query-7da22b0b109d1caac6384294fafaef3148e80824e023ddee78473fbae17720de.json
index caa71c967c..25e38f7bcd 100644
--- a/rust/cloud-storage/.sqlx/query-5945da24df02edef42222564bd97f153d87be6e876568063a7bdb183c41a01e9.json
+++ b/rust/cloud-storage/.sqlx/query-7da22b0b109d1caac6384294fafaef3148e80824e023ddee78473fbae17720de.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n cr.id AS \"call_id!\",\n cr.channel_id AS \"channel_id!\",\n cr.created_by AS \"created_by!\",\n cr.started_at AS \"started_at!\",\n cr.ended_at AS \"ended_at!\",\n cr.duration_ms AS \"duration_ms!\",\n cr.custom_name AS \"custom_name?\",\n EXISTS (\n SELECT 1 FROM call_record_participants crp\n WHERE crp.call_record_id = cr.id AND crp.user_id = $2\n ) AS \"attended!\"\n FROM call_records cr\n WHERE cr.id = ANY($1)\n ",
+ "query": "\n SELECT\n cr.id AS \"call_id!\",\n cr.channel_id AS \"channel_id!\",\n cr.created_by AS \"created_by!\",\n cr.started_at AS \"started_at!\",\n cr.ended_at AS \"ended_at!\",\n cr.duration_ms AS \"duration_ms!\",\n cr.custom_name AS \"custom_name?\",\n EXISTS (\n SELECT 1 FROM call_record_participants crp\n WHERE crp.call_record_id = cr.id AND crp.user_id = $2\n ) AS \"attended!\",\n CASE\n WHEN EXISTS (\n SELECT 1 FROM call_record_participants crp\n WHERE crp.call_record_id = cr.id AND crp.user_id = $2\n ) THEN 'ATTENDED'\n WHEN EXISTS (\n SELECT 1 FROM comms_channel_participants ccp\n WHERE ccp.channel_id = cr.channel_id\n AND ccp.user_id = $2\n AND ccp.left_at IS NULL\n ) THEN 'MISSED'\n ELSE 'UNATTENDED'\n END AS \"status!\"\n FROM call_records cr\n WHERE cr.id = ANY($1)\n ",
"describe": {
"columns": [
{
@@ -42,6 +42,11 @@
"ordinal": 7,
"name": "attended!",
"type_info": "Bool"
+ },
+ {
+ "ordinal": 8,
+ "name": "status!",
+ "type_info": "Text"
}
],
"parameters": {
@@ -58,8 +63,9 @@
false,
false,
true,
+ null,
null
]
},
- "hash": "5945da24df02edef42222564bd97f153d87be6e876568063a7bdb183c41a01e9"
+ "hash": "7da22b0b109d1caac6384294fafaef3148e80824e023ddee78473fbae17720de"
}
diff --git a/rust/cloud-storage/.sqlx/query-aed29afdb2f81b6f920bf65e54981999746302c6e40062c8aa892ab292a92d72.json b/rust/cloud-storage/.sqlx/query-aed29afdb2f81b6f920bf65e54981999746302c6e40062c8aa892ab292a92d72.json
deleted file mode 100644
index 8b59ea0566..0000000000
--- a/rust/cloud-storage/.sqlx/query-aed29afdb2f81b6f920bf65e54981999746302c6e40062c8aa892ab292a92d72.json
+++ /dev/null
@@ -1,112 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n WITH user_source_ids AS (\n SELECT cp.channel_id::text AS source_id\n FROM comms_channel_participants cp\n WHERE cp.user_id = $1 AND cp.left_at IS NULL\n UNION ALL\n SELECT t.team_id::text AS source_id\n FROM team_user t\n WHERE t.user_id = $1\n UNION ALL\n SELECT $1 AS source_id\n )\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 preview_url,\n recording_started_at,\n NULL::text as \"custom_name\",\n NULL::text as \"summary\",\n share_with_team as \"share_with_team!\",\n true as \"is_active!\"\n FROM calls c\n WHERE EXISTS (\n SELECT 1 FROM entity_access ea\n JOIN user_source_ids u ON u.source_id = ea.source_id\n WHERE ea.entity_id = c.id\n AND ea.entity_type = 'call'\n )\n AND ($3::bool IS FALSE OR c.channel_id = ANY($4))\n AND ($5::bool IS NULL OR EXISTS (\n SELECT 1 FROM call_participants cp\n WHERE cp.call_id = c.id AND cp.user_id = $1\n ) = $5)\n AND ($6::bool IS FALSE OR c.id = ANY($7))\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 preview_url,\n recording_started_at,\n custom_name,\n summary,\n share_with_team as \"share_with_team!\",\n false as \"is_active!\"\n FROM call_records cr\n WHERE EXISTS (\n SELECT 1 FROM entity_access ea\n JOIN user_source_ids u ON u.source_id = ea.source_id\n WHERE ea.entity_id = cr.id\n AND ea.entity_type = 'call'\n )\n AND ($3::bool IS FALSE OR cr.channel_id = ANY($4))\n AND ($5::bool IS NULL OR EXISTS (\n SELECT 1 FROM call_record_participants crp\n WHERE crp.call_record_id = cr.id AND crp.user_id = $1\n ) = $5)\n AND ($6::bool IS FALSE OR cr.id = ANY($7))\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": "preview_url",
- "type_info": "Text"
- },
- {
- "ordinal": 10,
- "name": "recording_started_at",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 11,
- "name": "custom_name",
- "type_info": "Text"
- },
- {
- "ordinal": 12,
- "name": "summary",
- "type_info": "Text"
- },
- {
- "ordinal": 13,
- "name": "share_with_team!",
- "type_info": "Bool"
- },
- {
- "ordinal": 14,
- "name": "is_active!",
- "type_info": "Bool"
- }
- ],
- "parameters": {
- "Left": [
- "Text",
- "Int8",
- "Bool",
- "UuidArray",
- "Bool",
- "Bool",
- "UuidArray"
- ]
- },
- "nullable": [
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null
- ]
- },
- "hash": "aed29afdb2f81b6f920bf65e54981999746302c6e40062c8aa892ab292a92d72"
-}
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index 8620e18dd0..4b26d299a3 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -7387,6 +7387,7 @@ dependencies = [
"document_sub_type",
"doppleganger",
"email",
+ "item_filters",
"macro_user_id",
"model-entity",
"models_pagination",
diff --git a/rust/cloud-storage/call/Cargo.toml b/rust/cloud-storage/call/Cargo.toml
index ba2cb81f89..b98eb92321 100644
--- a/rust/cloud-storage/call/Cargo.toml
+++ b/rust/cloud-storage/call/Cargo.toml
@@ -13,6 +13,7 @@ inbound = [
"dep:model_user",
"dep:utoipa",
"entity_access/inbound",
+ "item_filters/schema",
"ports",
]
outbound = [
diff --git a/rust/cloud-storage/call/fixtures/call_repo.sql b/rust/cloud-storage/call/fixtures/call_repo.sql
index 3742309e00..b50305eb72 100644
--- a/rust/cloud-storage/call/fixtures/call_repo.sql
+++ b/rust/cloud-storage/call/fixtures/call_repo.sql
@@ -13,7 +13,8 @@ INSERT INTO comms_channels (id, name, channel_type, org_id, owner_id, created_at
('00000000-0000-0000-0000-000000000c02', 'empty-channel', 'public', NULL, 'macro|[email protected]',
'2024-01-01 00:00:00+00', '2024-01-01 00:00:00+00');
--- channel members for ch1 (user-c is a member but never joins a call)
+-- channel members for ch1 (user-c is a member but never joins a call; user-d
+-- has direct call access below but is not a channel member)
INSERT INTO comms_channel_participants (channel_id, user_id, role, joined_at) VALUES
('00000000-0000-0000-0000-000000000c01', 'macro|[email protected]', 'owner', '2024-01-01 00:00:00+00'),
('00000000-0000-0000-0000-000000000c01', 'macro|[email protected]', 'member', '2024-01-01 00:00:00+00'),
@@ -64,12 +65,14 @@ INSERT INTO call_record_transcripts (call_record_id, segment_id, speaker_id, dia
('00000000-0000-0000-0000-0000000ca2ed', 'seg-arch-3', 'macro|[email protected]', 'spk-arch-b0', 'macro|[email protected]', 'archived overridden',
'2024-01-01 10:00:11+00', '2024-01-01 10:00:13+00', 3);
--- entity_access grants for the active call (owner + channel view).
+-- entity_access grants for the active call (owner + channel view + direct user view).
INSERT INTO entity_access (entity_id, entity_type, source_id, source_type, access_level) VALUES
('00000000-0000-0000-0000-0000000ca110', 'call', 'macro|[email protected]', 'user', 'owner'),
- ('00000000-0000-0000-0000-0000000ca110', 'call', '00000000-0000-0000-0000-000000000c01', 'channel', 'view');
+ ('00000000-0000-0000-0000-0000000ca110', 'call', '00000000-0000-0000-0000-000000000c01', 'channel', 'view'),
+ ('00000000-0000-0000-0000-0000000ca110', 'call', 'macro|[email protected]', 'user', 'view');
--- entity_access grants for the archived call (owner + channel view).
+-- entity_access grants for the archived call (owner + channel view + direct user view).
INSERT INTO entity_access (entity_id, entity_type, source_id, source_type, access_level) VALUES
('00000000-0000-0000-0000-0000000ca2ed', 'call', 'macro|[email protected]', 'user', 'owner'),
- ('00000000-0000-0000-0000-0000000ca2ed', 'call', '00000000-0000-0000-0000-000000000c01', 'channel', 'view');
+ ('00000000-0000-0000-0000-0000000ca2ed', 'call', '00000000-0000-0000-0000-000000000c01', 'channel', 'view'),
+ ('00000000-0000-0000-0000-0000000ca2ed', 'call', 'macro|[email protected]', 'user', 'view');
diff --git a/rust/cloud-storage/call/src/domain/models.rs b/rust/cloud-storage/call/src/domain/models.rs
index 60bd24ad6e..ea7ce993d2 100644
--- a/rust/cloud-storage/call/src/domain/models.rs
+++ b/rust/cloud-storage/call/src/domain/models.rs
@@ -3,7 +3,10 @@
use std::fmt;
use chrono::{DateTime, Utc};
-use item_filters::ast::{LiteralTree, call::CallLiteral};
+use item_filters::{
+ CallStatus,
+ ast::{LiteralTree, call::CallLiteral},
+};
use macro_user_id::user_id::MacroUserIdStr;
use models_pagination::{Query, SimpleSortMethod};
use uuid::Uuid;
@@ -360,6 +363,9 @@ pub struct CallRecord {
pub share_with_team: bool,
/// Whether the call is currently active (from `calls` table).
pub is_active: bool,
+ /// Viewer-relative call status when fetched in the context of a specific user.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub status: Option<CallStatus>,
/// Participants (both active and historic).
pub participants: Vec<CallRecordParticipant>,
/// Transcript segments ordered by `sequence_num`.
diff --git a/rust/cloud-storage/call/src/domain/ports.rs b/rust/cloud-storage/call/src/domain/ports.rs
index a53b5a6a05..803fd30e34 100644
--- a/rust/cloud-storage/call/src/domain/ports.rs
+++ b/rust/cloud-storage/call/src/domain/ports.rs
@@ -230,12 +230,12 @@ pub trait CallRepository: Send + Sync + 'static {
user_id: MacroUserIdStr<'a>,
) -> impl Future<Output = Result<Vec<CallRecordPreview>, 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).
+ /// Fetch the most recent call records visible to the given user, spanning
+ /// both active (`calls`) and archived (`call_records`) tables. Each record
+ /// includes viewer-specific status derived from call participation and
+ /// current channel membership. 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 or status).
fn get_call_records_by_user<'a>(
&self,
user_id: MacroUserIdStr<'a>,
@@ -645,8 +645,9 @@ pub trait CallService: Send + Sync + 'static {
/// 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.
+ /// Fetch the most recent call records visible to the user, ordered by
+ /// `started_at` descending. Transcript data is excluded, and status is
+ /// computed relative to the requesting user.
fn get_user_call_records(
&self,
req: GetCallRecordsRequest,
diff --git a/rust/cloud-storage/call/src/inbound/toolset/list_call_records.rs b/rust/cloud-storage/call/src/inbound/toolset/list_call_records.rs
index 856a411729..1a0dde75ba 100644
--- a/rust/cloud-storage/call/src/inbound/toolset/list_call_records.rs
+++ b/rust/cloud-storage/call/src/inbound/toolset/list_call_records.rs
@@ -11,7 +11,10 @@ use async_trait::async_trait;
use chrono::{DateTime, Utc};
use entity_access::domain::ports::EntityAccessService;
use filter_ast::Expr;
-use item_filters::ast::{LiteralTree, call::CallLiteral};
+use item_filters::{
+ CallStatus,
+ ast::{LiteralTree, call::CallLiteral},
+};
use models_pagination::{Query, SimpleSortMethod};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
@@ -22,6 +25,17 @@ use super::CallToolContext;
/// Maximum call records returned by a single [`ListCallRecords`] invocation.
const LIST_LIMIT: u32 = 50;
+/// Schema-only mirror of [`CallStatus`] without variant docs, keeping AI tool
+/// schemas as a simple enum instead of `oneOf`.
+#[allow(dead_code)]
+#[derive(Debug, Serialize, Deserialize, JsonSchema)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+enum ToolCallStatus {
+ Attended,
+ Missed,
+ Unattended,
+}
+
/// A call-record summary. Intentionally omits the transcript — use
/// [`super::read_call_record::ReadCallRecord`] to fetch it.
#[derive(Debug, Serialize, JsonSchema)]
@@ -44,6 +58,10 @@ pub struct CallRecordSummary {
/// Call duration in milliseconds. Absent if the call is still active.
#[serde(skip_serializing_if = "Option::is_none")]
pub duration_ms: Option<i64>,
+ /// The caller's viewer-relative status for this call.
+ #[schemars(with = "Option<ToolCallStatus>")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub status: Option<CallStatus>,
/// IDs of users who participated in the call.
pub participants: Vec<String>,
/// True if the call is currently active.
@@ -63,7 +81,7 @@ pub struct ListCallRecordsResponse {
#[serde(rename_all = "camelCase")]
#[schemars(
title = "ListCallRecords",
- description = "List recent call records the user can access, ordered by start time descending. Results are scoped to channels the user is a member of. Transcripts are NOT included — call ReadCallRecord with a specific callId to fetch a transcript."
+ description = "List recent call records the user can access, ordered by start time descending. Status is relative to the caller. Transcripts are NOT included — call ReadCallRecord with a specific callId to fetch a transcript."
)]
pub struct ListCallRecords {
/// Only include calls in this channel.
@@ -73,9 +91,17 @@ pub struct ListCallRecords {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub channel_id: Option<Uuid>,
- /// Only include calls the caller attended (or did not attend).
+ /// Only include calls with this viewer-relative status for the caller.
+ #[schemars(
+ with = "Option<ToolCallStatus>",
+ description = "Optional viewer-relative status filter. ATTENDED = calls the user joined; MISSED = calls the user did not join while they are in the channel; UNATTENDED = calls the user did not join while they are not in the channel. Prefer this over the deprecated attended filter."
+ )]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub status: Option<CallStatus>,
+
+ /// Deprecated compatibility filter for calls the caller attended (or did not attend).
#[schemars(
- description = "Optional filter on whether the caller joined the call. true = only calls the user attended; false = only calls the user did not attend; omit to include both."
+ description = "Deprecated compatibility filter. true = only calls the user attended; false = only calls the user did not attend; omit to include both. Ignored when status is provided."
)]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub attended: Option<bool>,
@@ -98,7 +124,7 @@ where
) -> ToolResult<Self::Output> {
tracing::info!(params=?self, "List call records");
- let filter = build_filter(self.channel_id, self.attended);
+ let filter = build_filter(self.channel_id, self.status, self.attended);
let req = GetCallRecordsRequest {
user_id: request_context.user_id.clone(),
@@ -125,6 +151,7 @@ where
started_at: r.started_at,
ended_at: r.ended_at,
duration_ms: r.duration_ms,
+ status: r.status,
participants: r.participants.into_iter().map(|p| p.user_id).collect(),
is_active: r.is_active,
})
@@ -134,13 +161,19 @@ where
}
}
-fn build_filter(channel_id: Option<Uuid>, attended: Option<bool>) -> LiteralTree<CallLiteral> {
+pub(super) fn build_filter(
+ channel_id: Option<Uuid>,
+ status: Option<CallStatus>,
+ attended: Option<bool>,
+) -> LiteralTree<CallLiteral> {
let mut parts = Vec::new();
if let Some(id) = channel_id {
parts.push(Expr::Literal(CallLiteral::ChannelId(id)));
}
- if let Some(a) = attended {
- parts.push(Expr::Literal(CallLiteral::Attended(a)));
+ if let Some(status) = status {
+ parts.push(Expr::Literal(CallLiteral::Status(status)));
+ } else if let Some(attended) = attended {
+ parts.push(Expr::Literal(CallLiteral::Attended(attended)));
}
let mut iter = parts.into_iter();
diff --git a/rust/cloud-storage/call/src/inbound/toolset/test.rs b/rust/cloud-storage/call/src/inbound/toolset/test.rs
index b92333e883..7c5e6c24a9 100644
--- a/rust/cloud-storage/call/src/inbound/toolset/test.rs
+++ b/rust/cloud-storage/call/src/inbound/toolset/test.rs
@@ -1,7 +1,10 @@
-use super::list_call_records::ListCallRecords;
+use super::list_call_records::{ListCallRecords, build_filter};
use super::read_call_record::ReadCallRecord;
use ai_toolset::generate_tool_input_schema;
use ai_toolset::tool_object::validate_tool_schema;
+use filter_ast::Expr;
+use item_filters::{CallStatus, ast::call::CallLiteral};
+use serde_json::Value;
#[test]
fn test_list_call_records_schema_validation() {
@@ -19,6 +22,51 @@ fn test_list_call_records_schema_validation() {
description.contains("List"),
"Description should contain expected text"
);
+
+ let schema_json = serde_json::to_value(&schema).expect("schema should serialize to JSON");
+ let status_schema = schema_property(&schema_json, "status");
+ let status_values = find_enum_values(status_schema)
+ .expect("status schema should include supported enum values");
+ assert_eq!(
+ status_values,
+ vec![
+ "ATTENDED".to_string(),
+ "MISSED".to_string(),
+ "UNATTENDED".to_string(),
+ ]
+ );
+
+ let attended_schema = schema_property(&schema_json, "attended");
+ let attended_description = attended_schema
+ .get("description")
+ .and_then(Value::as_str)
+ .expect("attended schema should include a description");
+ assert!(
+ attended_description.contains("Deprecated"),
+ "attended should remain documented as deprecated compatibility"
+ );
+}
+
+#[test]
+fn test_list_call_records_status_filter_preferred_over_attended() {
+ let filter = build_filter(None, Some(CallStatus::Missed), Some(true));
+ let expr = filter.expect("status should produce a filter");
+
+ assert!(matches!(
+ expr.as_ref(),
+ Expr::Literal(CallLiteral::Status(CallStatus::Missed))
+ ));
+}
+
+#[test]
+fn test_list_call_records_attended_filter_still_supported() {
+ let filter = build_filter(None, None, Some(false));
+ let expr = filter.expect("attended should produce a filter");
+
+ assert!(matches!(
+ expr.as_ref(),
+ Expr::Literal(CallLiteral::Attended(false))
+ ));
}
#[test]
@@ -38,3 +86,32 @@ fn test_read_call_record_schema_validation() {
"Description should contain expected text"
);
}
+
+fn schema_property<'a>(schema: &'a Value, property: &str) -> &'a Value {
+ schema
+ .get("properties")
+ .and_then(Value::as_object)
+ .and_then(|properties| properties.get(property))
+ .unwrap_or_else(|| panic!("schema should include `{property}` property"))
+}
+
+fn find_enum_values(schema: &Value) -> Option<Vec<String>> {
+ if let Some(values) = schema.get("enum").and_then(Value::as_array) {
+ return Some(
+ values
+ .iter()
+ .filter_map(|value| value.as_str().map(str::to_owned))
+ .collect(),
+ );
+ }
+
+ for key in ["anyOf", "allOf"] {
+ if let Some(values) = schema.get(key).and_then(Value::as_array) {
+ if let Some(enum_values) = values.iter().find_map(find_enum_values) {
+ return Some(enum_values);
+ }
+ }
+ }
+
+ None
+}
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 dc9e325c4e..1f9e228d7c 100644
--- a/rust/cloud-storage/call/src/outbound/pg_call_repo.rs
+++ b/rust/cloud-storage/call/src/outbound/pg_call_repo.rs
@@ -11,7 +11,10 @@ use chrono::Utc;
use comms::outbound::postgres::channel_name::batch_resolve_channel_names;
use entity_access::domain::models::AccessLevel;
use filter_ast::Expr;
-use item_filters::ast::{LiteralTree, call::CallLiteral};
+use item_filters::{
+ CallStatus,
+ 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;
@@ -55,6 +58,7 @@ fn collect_channel_ids(expr: &Expr<CallLiteral>, ids: &mut Vec<Uuid>) {
match expr {
Expr::Literal(CallLiteral::ChannelId(id)) => ids.push(*id),
Expr::Literal(CallLiteral::CallId(_)) => {}
+ Expr::Literal(CallLiteral::Status(_)) => {}
Expr::Literal(CallLiteral::Attended(_)) => {}
// Speaker is transcript-segment-only; soup's call list ignores it.
Expr::Literal(CallLiteral::Speaker(_)) => {}
@@ -80,6 +84,7 @@ fn collect_call_ids(expr: &Expr<CallLiteral>, ids: &mut Vec<Uuid>) {
match expr {
Expr::Literal(CallLiteral::CallId(id)) => ids.push(*id),
Expr::Literal(CallLiteral::ChannelId(_)) => {}
+ Expr::Literal(CallLiteral::Status(_)) => {}
Expr::Literal(CallLiteral::Attended(_)) => {}
Expr::Literal(CallLiteral::Speaker(_)) => {}
Expr::And(a, b) | Expr::Or(a, b) => {
@@ -90,23 +95,132 @@ fn collect_call_ids(expr: &Expr<CallLiteral>, ids: &mut Vec<Uuid>) {
}
}
-/// Extract the `attended` literal from a call filter AST, if any.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+struct CallStatusSet {
+ attended: bool,
+ missed: bool,
+ unattended: bool,
+}
+
+impl CallStatusSet {
+ fn one(status: CallStatus) -> Self {
+ match status {
+ CallStatus::Attended => Self {
+ attended: true,
+ missed: false,
+ unattended: false,
+ },
+ CallStatus::Missed => Self {
+ attended: false,
+ missed: true,
+ unattended: false,
+ },
+ CallStatus::Unattended => Self {
+ attended: false,
+ missed: false,
+ unattended: true,
+ },
+ }
+ }
+
+ fn not_participant() -> Self {
+ Self {
+ attended: false,
+ missed: true,
+ unattended: true,
+ }
+ }
+
+ fn is_all(self) -> bool {
+ self.attended && self.missed && self.unattended
+ }
+
+ fn complement(self) -> Self {
+ Self {
+ attended: !self.attended,
+ missed: !self.missed,
+ unattended: !self.unattended,
+ }
+ }
+
+ fn intersect(self, other: Self) -> Self {
+ Self {
+ attended: self.attended && other.attended,
+ missed: self.missed && other.missed,
+ unattended: self.unattended && other.unattended,
+ }
+ }
+
+ fn union(self, other: Self) -> Self {
+ Self {
+ attended: self.attended || other.attended,
+ missed: self.missed || other.missed,
+ unattended: self.unattended || other.unattended,
+ }
+ }
+
+ fn values(self) -> Vec<CallStatus> {
+ let mut statuses = Vec::new();
+ if self.attended {
+ statuses.push(CallStatus::Attended);
+ }
+ if self.missed {
+ statuses.push(CallStatus::Missed);
+ }
+ if self.unattended {
+ statuses.push(CallStatus::Unattended);
+ }
+ statuses
+ }
+}
+
+fn call_status_sql_value(status: CallStatus) -> &'static str {
+ match status {
+ CallStatus::Attended => "ATTENDED",
+ CallStatus::Missed => "MISSED",
+ CallStatus::Unattended => "UNATTENDED",
+ }
+}
+
+fn call_status_from_sql(value: &str) -> CallStatus {
+ match value {
+ "ATTENDED" => CallStatus::Attended,
+ "MISSED" => CallStatus::Missed,
+ "UNATTENDED" => CallStatus::Unattended,
+ _ => unreachable!("call status query returned an unsupported status"),
+ }
+}
+
+/// Extract viewer-relative status constraints from a call filter AST.
///
-/// `ExpandFrame::expand_ast` only emits at most one `Attended` literal, so we
-/// return the first one we find during a simple traversal.
-fn extract_attended(filter: &LiteralTree<CallLiteral>) -> Option<bool> {
+/// Legacy `Attended(false)` means the viewer is not a participant, which now
+/// includes both missed and unattended calls.
+fn extract_status_filter(filter: &LiteralTree<CallLiteral>) -> Option<Vec<CallStatus>> {
let expr = filter.as_ref()?;
- find_attended(expr)
+ let status_set = status_set_for_expr(expr)?;
+ (!status_set.is_all()).then(|| status_set.values())
}
-fn find_attended(expr: &Expr<CallLiteral>) -> Option<bool> {
+fn status_set_for_expr(expr: &Expr<CallLiteral>) -> Option<CallStatusSet> {
match expr {
- Expr::Literal(CallLiteral::Attended(b)) => Some(*b),
- Expr::Literal(CallLiteral::CallId(_)) => None,
- Expr::Literal(CallLiteral::ChannelId(_)) => None,
- Expr::Literal(CallLiteral::Speaker(_)) => None,
- Expr::And(a, b) | Expr::Or(a, b) => find_attended(a).or_else(|| find_attended(b)),
- Expr::Not(inner) => find_attended(inner).map(|b| !b),
+ Expr::Literal(CallLiteral::Status(status)) => Some(CallStatusSet::one(*status)),
+ Expr::Literal(CallLiteral::Attended(true)) => {
+ Some(CallStatusSet::one(CallStatus::Attended))
+ }
+ Expr::Literal(CallLiteral::Attended(false)) => Some(CallStatusSet::not_participant()),
+ Expr::Literal(CallLiteral::CallId(_))
+ | Expr::Literal(CallLiteral::ChannelId(_))
+ | Expr::Literal(CallLiteral::Speaker(_)) => None,
+ Expr::And(a, b) => match (status_set_for_expr(a), status_set_for_expr(b)) {
+ (Some(left), Some(right)) => Some(left.intersect(right)),
+ (Some(status_set), None) | (None, Some(status_set)) => Some(status_set),
+ (None, None) => None,
+ },
+ Expr::Or(a, b) => match (status_set_for_expr(a), status_set_for_expr(b)) {
+ (Some(left), Some(right)) => Some(left.union(right)),
+ _ => None,
+ },
+ Expr::Not(inner) => status_set_for_expr(inner).map(CallStatusSet::complement),
}
}
@@ -1001,6 +1115,7 @@ impl CallRepository for PgCallRepo {
summary: None,
share_with_team: active.share_with_team,
is_active: true,
+ status: None,
participants,
transcript,
}));
@@ -1085,6 +1200,7 @@ impl CallRepository for PgCallRepo {
summary: archived.summary,
share_with_team: archived.share_with_team,
is_active: false,
+ status: None,
participants,
transcript,
}))
@@ -1203,7 +1319,16 @@ impl CallRepository for PgCallRepo {
let has_channel_filter = !channel_ids.is_empty();
let call_ids = extract_call_ids(filter);
let has_call_id_filter = !call_ids.is_empty();
- let attended = extract_attended(filter);
+ let status_filter = extract_status_filter(filter);
+ let has_status_filter = status_filter.is_some();
+ let status_filter_values: Vec<String> = status_filter
+ .as_deref()
+ .unwrap_or(&[])
+ .iter()
+ .copied()
+ .map(call_status_sql_value)
+ .map(str::to_string)
+ .collect();
let rows = sqlx::query!(
r#"
@@ -1217,45 +1342,94 @@ impl CallRepository for PgCallRepo {
WHERE t.user_id = $1
UNION ALL
SELECT $1 AS source_id
+ ),
+ visible_calls AS (
+ SELECT
+ c.id AS call_id,
+ c.channel_id,
+ c.room_name,
+ c.created_by,
+ c.created_at AS started_at,
+ NULL::timestamptz AS ended_at,
+ NULL::bigint AS duration_ms,
+ c.egress_id,
+ c.recording_key,
+ c.preview_url,
+ c.recording_started_at,
+ NULL::text AS custom_name,
+ NULL::text AS summary,
+ c.share_with_team,
+ true AS is_active,
+ CASE
+ WHEN EXISTS (
+ SELECT 1 FROM call_participants cp
+ WHERE cp.call_id = c.id AND cp.user_id = $1
+ ) THEN 'ATTENDED'::text
+ WHEN EXISTS (
+ SELECT 1 FROM comms_channel_participants ccp
+ WHERE ccp.channel_id = c.channel_id
+ AND ccp.user_id = $1
+ AND ccp.left_at IS NULL
+ ) THEN 'MISSED'::text
+ ELSE 'UNATTENDED'::text
+ END AS status
+ FROM calls c
+ WHERE EXISTS (
+ SELECT 1 FROM entity_access ea
+ JOIN user_source_ids u ON u.source_id = ea.source_id
+ WHERE ea.entity_id = c.id
+ AND ea.entity_type = 'call'
+ )
+ AND ($3::bool IS FALSE OR c.channel_id = ANY($4))
+ AND ($5::bool IS FALSE OR c.id = ANY($6))
+ UNION ALL
+ SELECT
+ cr.id AS call_id,
+ cr.channel_id,
+ cr.room_name,
+ cr.created_by,
+ cr.started_at,
+ cr.ended_at,
+ cr.duration_ms,
+ cr.egress_id,
+ cr.recording_key,
+ cr.preview_url,
+ cr.recording_started_at,
+ cr.custom_name,
+ cr.summary,
+ cr.share_with_team,
+ false AS is_active,
+ CASE
+ WHEN EXISTS (
+ SELECT 1 FROM call_record_participants crp
+ WHERE crp.call_record_id = cr.id AND crp.user_id = $1
+ ) THEN 'ATTENDED'::text
+ WHEN EXISTS (
+ SELECT 1 FROM comms_channel_participants ccp
+ WHERE ccp.channel_id = cr.channel_id
+ AND ccp.user_id = $1
+ AND ccp.left_at IS NULL
+ ) THEN 'MISSED'::text
+ ELSE 'UNATTENDED'::text
+ END AS status
+ FROM call_records cr
+ WHERE EXISTS (
+ SELECT 1 FROM entity_access ea
+ JOIN user_source_ids u ON u.source_id = ea.source_id
+ WHERE ea.entity_id = cr.id
+ AND ea.entity_type = 'call'
+ )
+ AND ($3::bool IS FALSE OR cr.channel_id = ANY($4))
+ AND ($5::bool IS FALSE OR cr.id = ANY($6))
)
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,
- preview_url,
- recording_started_at,
- NULL::text as "custom_name",
- NULL::text as "summary",
- share_with_team as "share_with_team!",
- true as "is_active!"
- FROM calls c
- WHERE EXISTS (
- SELECT 1 FROM entity_access ea
- JOIN user_source_ids u ON u.source_id = ea.source_id
- WHERE ea.entity_id = c.id
- AND ea.entity_type = 'call'
- )
- AND ($3::bool IS FALSE OR c.channel_id = ANY($4))
- AND ($5::bool IS NULL OR EXISTS (
- SELECT 1 FROM call_participants cp
- WHERE cp.call_id = c.id AND cp.user_id = $1
- ) = $5)
- AND ($6::bool IS FALSE OR c.id = ANY($7))
- UNION ALL
- SELECT
- id as "call_id!",
+ call_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",
+ ended_at,
+ duration_ms,
egress_id,
recording_key,
preview_url,
@@ -1263,20 +1437,10 @@ impl CallRepository for PgCallRepo {
custom_name,
summary,
share_with_team as "share_with_team!",
- false as "is_active!"
- FROM call_records cr
- WHERE EXISTS (
- SELECT 1 FROM entity_access ea
- JOIN user_source_ids u ON u.source_id = ea.source_id
- WHERE ea.entity_id = cr.id
- AND ea.entity_type = 'call'
- )
- AND ($3::bool IS FALSE OR cr.channel_id = ANY($4))
- AND ($5::bool IS NULL OR EXISTS (
- SELECT 1 FROM call_record_participants crp
- WHERE crp.call_record_id = cr.id AND crp.user_id = $1
- ) = $5)
- AND ($6::bool IS FALSE OR cr.id = ANY($7))
+ is_active as "is_active!",
+ status as "status!"
+ FROM visible_calls
+ WHERE ($7::bool IS FALSE OR status = ANY($8::text[]))
ORDER BY "started_at!" DESC
LIMIT $2
"#,
@@ -1284,9 +1448,10 @@ impl CallRepository for PgCallRepo {
limit as i64,
has_channel_filter,
&channel_ids,
- attended,
has_call_id_filter,
&call_ids,
+ has_status_filter,
+ &status_filter_values,
)
.fetch_all(&self.pool)
.await?;
@@ -1361,6 +1526,7 @@ impl CallRepository for PgCallRepo {
summary: row.summary,
share_with_team: row.share_with_team,
is_active: row.is_active,
+ status: Some(call_status_from_sql(&row.status)),
participants,
transcript: Vec::new(),
});
diff --git a/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rs b/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rs
index 89d85258a5..73e29e81eb 100644
--- a/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rs
+++ b/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rs
@@ -1,14 +1,17 @@
use std::{ops::Deref, sync::Arc, sync::LazyLock};
use crate::domain::models::{
- AddParticipantError, CallRecordPreview, CustomSpeakerAssignment, EditCallRecordRequest,
- TranscriptSegmentRequest,
+ AddParticipantError, CallRecord, CallRecordPreview, CustomSpeakerAssignment,
+ EditCallRecordRequest, TranscriptSegmentRequest,
};
use crate::domain::ports::CallRepository;
use crate::outbound::pg_call_repo::PgCallRepo;
use chrono::{Duration, SubsecRound, Utc};
use filter_ast::Expr;
-use item_filters::ast::{LiteralTree, call::CallLiteral};
+use item_filters::{
+ CallStatus,
+ ast::{LiteralTree, call::CallLiteral},
+};
use macro_db_migrator::MACRO_DB_MIGRATIONS;
use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};
use models_permissions::share_permission::UpdateSharePermissionRequestV2;
@@ -23,6 +26,15 @@ fn attended_filter(b: bool) -> LiteralTree<CallLiteral> {
Some(Arc::new(Expr::Literal(CallLiteral::Attended(b))))
}
+fn status_filter(status: CallStatus) -> LiteralTree<CallLiteral> {
+ Some(Arc::new(Expr::Literal(CallLiteral::Status(status))))
+}
+
+fn not_status_filter(status: CallStatus) -> LiteralTree<CallLiteral> {
+ let expr = Expr::Literal(CallLiteral::Status(status));
+ Some(Arc::new(Expr::is_not(expr)))
+}
+
fn call_ids_filter(ids: &[Uuid]) -> LiteralTree<CallLiteral> {
let mut iter = ids.iter().copied().map(CallLiteral::CallId);
let first = iter.next()?;
@@ -46,11 +58,27 @@ static USER_B: LazyLock<MacroUserIdStr<'static>> =
LazyLock::new(|| MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap());
static USER_C: LazyLock<MacroUserIdStr<'static>> =
LazyLock::new(|| MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap());
+static USER_D: LazyLock<MacroUserIdStr<'static>> =
+ LazyLock::new(|| MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap());
fn repo(pool: Pool<Postgres>) -> PgCallRepo {
PgCallRepo::new(pool)
}
+fn call_status(records: &[CallRecord], call_id: Uuid) -> Option<CallStatus> {
+ records
+ .iter()
+ .find(|record| record.call_id == call_id)
+ .and_then(|record| record.status)
+}
+
+fn assert_records_have_status(records: &[CallRecord], expected: CallStatus) {
+ assert!(
+ records.iter().all(|record| record.status == Some(expected)),
+ "expected every record to have status {expected:?}: {records:#?}"
+ );
+}
+
fn axis_unit_vector(axis: usize) -> Vec<f32> {
let mut v = vec![0.0_f32; 256];
v[axis] = 1.0;
@@ -1262,6 +1290,7 @@ async fn get_call_record_returns_active_call(pool: Pool<Postgres>) -> anyhow::Re
assert_eq!(record.channel_id, CH1);
assert!(record.is_active);
assert!(!record.share_with_team);
+ assert_eq!(record.status, None);
assert!(record.ended_at.is_none());
assert!(record.duration_ms.is_none());
@@ -1314,6 +1343,7 @@ async fn get_call_record_returns_archived_call(pool: Pool<Postgres>) -> anyhow::
assert_eq!(record.channel_id, CH1);
assert!(!record.is_active);
assert!(!record.share_with_team);
+ assert_eq!(record.status, None);
assert!(record.ended_at.is_some());
assert_eq!(record.duration_ms, Some(300_000));
assert_eq!(record.egress_id.as_deref(), Some("egress-arch-1"));
@@ -1497,6 +1527,156 @@ async fn get_call_records_by_user_includes_channel_member_not_in_call(
Ok(())
}
+#[sqlx::test(
+ fixtures(path = "../../../fixtures", scripts("call_repo")),
+ migrator = "MACRO_DB_MIGRATIONS"
+)]
+async fn get_call_records_by_user_status_attended_for_participant(
+ pool: Pool<Postgres>,
+) -> anyhow::Result<()> {
+ let repo = repo(pool);
+
+ let records = repo
+ .get_call_records_by_user(USER_A.deref().copied(), 10, &None)
+ .await?;
+
+ assert_eq!(records.len(), 2);
+ assert_eq!(call_status(&records, CALL1), Some(CallStatus::Attended));
+ assert_eq!(
+ call_status(&records, CALL_ARCHIVED),
+ Some(CallStatus::Attended)
+ );
+ Ok(())
+}
+
+#[sqlx::test(
+ fixtures(path = "../../../fixtures", scripts("call_repo")),
+ migrator = "MACRO_DB_MIGRATIONS"
+)]
+async fn get_call_records_by_user_status_missed_for_channel_nonparticipant(
+ pool: Pool<Postgres>,
+) -> anyhow::Result<()> {
+ let repo = repo(pool);
+
+ let records = repo
+ .get_call_records_by_user(USER_C.deref().copied(), 10, &None)
+ .await?;
+
+ assert_eq!(records.len(), 2);
+ assert_eq!(call_status(&records, CALL1), Some(CallStatus::Missed));
+ assert_eq!(
+ call_status(&records, CALL_ARCHIVED),
+ Some(CallStatus::Missed)
+ );
+ Ok(())
+}
+
+#[sqlx::test(
+ fixtures(path = "../../../fixtures", scripts("call_repo")),
+ migrator = "MACRO_DB_MIGRATIONS"
+)]
+async fn get_call_records_by_user_status_unattended_for_accessible_non_channel_nonparticipant(
+ pool: Pool<Postgres>,
+) -> anyhow::Result<()> {
+ let repo = repo(pool);
+
+ let records = repo
+ .get_call_records_by_user(USER_D.deref().copied(), 10, &None)
+ .await?;
+
+ assert_eq!(records.len(), 2);
+ assert_eq!(call_status(&records, CALL1), Some(CallStatus::Unattended));
+ assert_eq!(
+ call_status(&records, CALL_ARCHIVED),
+ Some(CallStatus::Unattended)
+ );
+ Ok(())
+}
+
+#[sqlx::test(
+ fixtures(path = "../../../fixtures", scripts("call_repo")),
+ migrator = "MACRO_DB_MIGRATIONS"
+)]
+async fn get_call_records_by_user_status_filters_return_exact_matches(
+ pool: Pool<Postgres>,
+) -> anyhow::Result<()> {
+ let repo = repo(pool);
+
+ let attended = status_filter(CallStatus::Attended);
+ let attended_records = repo
+ .get_call_records_by_user(USER_A.deref().copied(), 10, &attended)
+ .await?;
+ assert_eq!(attended_records.len(), 2);
+ assert_records_have_status(&attended_records, CallStatus::Attended);
+
+ let missed = status_filter(CallStatus::Missed);
+ let missed_records = repo
+ .get_call_records_by_user(USER_C.deref().copied(), 10, &missed)
+ .await?;
+ assert_eq!(missed_records.len(), 2);
+ assert_records_have_status(&missed_records, CallStatus::Missed);
+
+ let unattended = status_filter(CallStatus::Unattended);
+ let unattended_records = repo
+ .get_call_records_by_user(USER_D.deref().copied(), 10, &unattended)
+ .await?;
+ assert_eq!(unattended_records.len(), 2);
+ assert_records_have_status(&unattended_records, CallStatus::Unattended);
+
+ let no_unattended_for_channel_member = repo
+ .get_call_records_by_user(USER_C.deref().copied(), 10, &unattended)
+ .await?;
+ assert!(no_unattended_for_channel_member.is_empty());
+ Ok(())
+}
+
+#[sqlx::test(
+ fixtures(path = "../../../fixtures", scripts("call_repo")),
+ migrator = "MACRO_DB_MIGRATIONS"
+)]
+async fn get_call_records_by_user_status_legacy_attended_false_returns_not_participant_statuses(
+ pool: Pool<Postgres>,
+) -> anyhow::Result<()> {
+ let repo = repo(pool);
+ let filter = attended_filter(false);
+
+ let missed_records = repo
+ .get_call_records_by_user(USER_C.deref().copied(), 10, &filter)
+ .await?;
+ assert_eq!(missed_records.len(), 2);
+ assert_records_have_status(&missed_records, CallStatus::Missed);
+
+ let unattended_records = repo
+ .get_call_records_by_user(USER_D.deref().copied(), 10, &filter)
+ .await?;
+ assert_eq!(unattended_records.len(), 2);
+ assert_records_have_status(&unattended_records, CallStatus::Unattended);
+ Ok(())
+}
+
+#[sqlx::test(
+ fixtures(path = "../../../fixtures", scripts("call_repo")),
+ migrator = "MACRO_DB_MIGRATIONS"
+)]
+async fn get_call_records_by_user_status_not_filter_complements_status(
+ pool: Pool<Postgres>,
+) -> anyhow::Result<()> {
+ let repo = repo(pool);
+ let not_attended = not_status_filter(CallStatus::Attended);
+
+ let participant_records = repo
+ .get_call_records_by_user(USER_A.deref().copied(), 10, &not_attended)
+ .await?;
+ assert!(participant_records.is_empty());
+
+ let missed_records = repo
+ .get_call_records_by_user(USER_C.deref().copied(), 10, &not_attended)
+ .await?;
+ assert_eq!(missed_records.len(), 2);
+ assert_records_have_status(&missed_records, CallStatus::Missed);
+ Ok(())
+}
+
#[sqlx::test(
fixtures(path = "../../../fixtures", scripts("call_repo")),
migrator = "MACRO_DB_MIGRATIONS"
diff --git a/rust/cloud-storage/item_filters/src/ast/call.rs b/rust/cloud-storage/item_filters/src/ast/call.rs
index 0d32621870..e999aac587 100644
--- a/rust/cloud-storage/item_filters/src/ast/call.rs
+++ b/rust/cloud-storage/item_filters/src/ast/call.rs
@@ -3,7 +3,7 @@ use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
-use crate::{CallFilters, ast::ExpandErr};
+use crate::{CallFilters, CallStatus, ast::ExpandErr};
/// the possible literal values in a call filter ast
#[derive(Debug, Serialize, Deserialize, Clone)]
@@ -14,6 +14,8 @@ pub enum CallLiteral {
ChannelId(Uuid),
/// filter by the speaker of a transcript segment
Speaker(MacroUserIdStr<'static>),
+ /// viewer-relative attendance status for the call
+ Status(CallStatus),
/// whether the requesting user attended the call
Attended(bool),
}
@@ -26,6 +28,7 @@ impl ExpandFrame<CallLiteral> for CallFilters {
call_ids,
channel_ids,
speaker_ids,
+ status,
attended,
} = filter_request;
@@ -44,9 +47,10 @@ impl ExpandFrame<CallLiteral> for CallFilters {
.map(|s| MacroUserIdStr::parse_from_str(s).map(CowLike::into_owned))
.try_expand(|r| r.map(CallLiteral::Speaker), Expr::or)?;
+ let status = status.map(|status| Expr::Literal(CallLiteral::Status(status)));
let attended = attended.map(|b| Expr::Literal(CallLiteral::Attended(b)));
- Ok([call_ids, channel_ids, speaker_ids, attended]
+ Ok([call_ids, channel_ids, speaker_ids, status, attended]
.into_iter()
.fold_with(Expr::and))
}
diff --git a/rust/cloud-storage/item_filters/src/ast/tests.rs b/rust/cloud-storage/item_filters/src/ast/tests.rs
index a614ef40b6..0b55040e3d 100644
--- a/rust/cloud-storage/item_filters/src/ast/tests.rs
+++ b/rust/cloud-storage/item_filters/src/ast/tests.rs
@@ -1,7 +1,7 @@
use std::str::FromStr;
use super::*;
-use crate::{CallFilters, ForeignEntityFilters, PropertyFilter};
+use crate::{CallFilters, CallStatus, ForeignEntityFilters, PropertyFilter};
use cool_asserts::assert_matches;
use model_file_type::FileType;
use serde_json::json;
@@ -801,6 +801,39 @@ fn entity_type_ast_deserialization_rejects_invalid() {
);
}
+#[test]
+fn call_filter_status_expands_status_only() {
+ let f = CallFilters {
+ status: Some(CallStatus::Missed),
+ ..Default::default()
+ };
+ let ast = CallFilters::expand_ast(f)
+ .unwrap()
+ .expect("status filter should expand to a literal");
+ let json = serde_json::to_value(&ast).unwrap();
+ let exp = json!({ "l": { "Status": "MISSED" } });
+ assert_eq!(json, exp);
+}
+
+#[test]
+fn call_filter_status_expands_channel_and_status_as_and() {
+ let channel_id = Uuid::new_v4();
+ let f = CallFilters {
+ channel_ids: vec![channel_id.to_string()],
+ status: Some(CallStatus::Unattended),
+ ..Default::default()
+ };
+ let ast = CallFilters::expand_ast(f).unwrap().unwrap();
+ let json = serde_json::to_value(&ast).unwrap();
+ let exp = json!({
+ "&": [
+ { "l": { "ChannelId": channel_id } },
+ { "l": { "Status": "UNATTENDED" } }
+ ]
+ });
+ assert_eq!(json, exp);
+}
+
#[test]
fn it_expands_call_filter_with_attended_only() {
let f = CallFilters {
diff --git a/rust/cloud-storage/item_filters/src/lib.rs b/rust/cloud-storage/item_filters/src/lib.rs
index ec27a36635..bf8929a798 100644
--- a/rust/cloud-storage/item_filters/src/lib.rs
+++ b/rust/cloud-storage/item_filters/src/lib.rs
@@ -314,6 +314,20 @@ impl IsEmpty for EmailFilters {
}
}
+/// Viewer-relative attendance status for a call record.
+/// Serializes as `ATTENDED`, `MISSED`, or `UNATTENDED`.
+#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone, Copy)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema, schemars::JsonSchema))]
+pub enum CallStatus {
+ /// The viewer is a call participant.
+ Attended,
+ /// The viewer is not a call participant and is in the call's channel.
+ Missed,
+ /// The viewer is not a call participant and is not in the call's channel.
+ Unattended,
+}
+
/// Filters for call records.
#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Clone)]
#[cfg_attr(feature = "schema", derive(utoipa::ToSchema, schemars::JsonSchema))]
@@ -327,7 +341,11 @@ pub struct CallFilters {
/// Speaker macro user ids. Empty to include all.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub speaker_ids: Vec<String>,
- /// Filter by whether the requesting user attended the call.
+ /// Filter by the requesting user's viewer-relative call status.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub status: Option<CallStatus>,
+ /// Legacy filter by whether the requesting user attended the call.
+ /// Prefer [`CallFilters::status`] for new callers.
/// `None` = no filter, `Some(true)` = only calls the user joined,
/// `Some(false)` = only calls the user did not join.
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -340,11 +358,13 @@ impl IsEmpty for CallFilters {
call_ids,
channel_ids,
speaker_ids,
+ status,
attended,
} = self;
call_ids.is_empty()
&& channel_ids.is_empty()
&& speaker_ids.is_empty()
+ && status.is_none()
&& attended.is_none()
}
}
diff --git a/rust/cloud-storage/macro_db_client/src/call_record/get.rs b/rust/cloud-storage/macro_db_client/src/call_record/get.rs
index d90a5be13c..84c9bebac5 100644
--- a/rust/cloud-storage/macro_db_client/src/call_record/get.rs
+++ b/rust/cloud-storage/macro_db_client/src/call_record/get.rs
@@ -18,6 +18,8 @@ pub struct CallRecordMetadataRow {
pub custom_name: Option<String>,
/// Whether the requesting user was a participant on the call.
pub attended: bool,
+ /// Viewer-relative call status for the requesting user.
+ pub status: String,
}
#[derive(Debug, Clone)]
@@ -40,12 +42,12 @@ pub struct CallRecordSearchPayload {
pub segments: Vec<CallRecordTranscriptSegment>,
}
-/// `attended` optionally narrows by participation.
-#[tracing::instrument(skip(db))]
+/// `status_filter` optionally narrows visible calls by viewer-relative status.
+#[tracing::instrument(skip(db, status_filter))]
pub async fn get_accessible_call_ids(
db: &sqlx::Pool<sqlx::Postgres>,
user_id: &str,
- attended: Option<bool>,
+ status_filter: &[String],
) -> anyhow::Result<Vec<Uuid>> {
sqlx::query_scalar!(
r#"
@@ -59,29 +61,44 @@ pub async fn get_accessible_call_ids(
WHERE t.user_id = $1
UNION ALL
SELECT $1
- )
- SELECT DISTINCT cr.id AS "id!"
- FROM call_records cr
- WHERE (
- EXISTS (
- SELECT 1 FROM entity_access ea
- WHERE ea.entity_id = cr.id
- AND ea.entity_type = 'call'
- AND ea.source_id IN (SELECT source_id FROM user_source_ids)
- ) OR EXISTS (
- SELECT 1 FROM "SharePermission" sp
- WHERE sp.id = cr.share_permission_id
- AND sp."isPublic" = true
- AND sp."publicAccessLevel" IS NOT NULL
+ ),
+ visible_calls AS (
+ SELECT
+ cr.id,
+ CASE
+ WHEN EXISTS (
+ SELECT 1 FROM call_record_participants crp
+ WHERE crp.call_record_id = cr.id AND crp.user_id = $1
+ ) THEN 'ATTENDED'
+ WHEN EXISTS (
+ SELECT 1 FROM comms_channel_participants ccp
+ WHERE ccp.channel_id = cr.channel_id
+ AND ccp.user_id = $1
+ AND ccp.left_at IS NULL
+ ) THEN 'MISSED'
+ ELSE 'UNATTENDED'
+ END AS status
+ FROM call_records cr
+ WHERE (
+ EXISTS (
+ SELECT 1 FROM entity_access ea
+ WHERE ea.entity_id = cr.id
+ AND ea.entity_type = 'call'
+ AND ea.source_id IN (SELECT source_id FROM user_source_ids)
+ ) OR EXISTS (
+ SELECT 1 FROM "SharePermission" sp
+ WHERE sp.id = cr.share_permission_id
+ AND sp."isPublic" = true
+ AND sp."publicAccessLevel" IS NOT NULL
+ )
)
)
- AND ($2::bool IS NULL OR EXISTS (
- SELECT 1 FROM call_record_participants crp
- WHERE crp.call_record_id = cr.id AND crp.user_id = $1
- ) = $2)
+ SELECT id AS "id!"
+ FROM visible_calls
+ WHERE cardinality($2::text[]) = 0 OR status = ANY($2)
"#,
user_id,
- attended,
+ status_filter,
)
.fetch_all(db)
.await
@@ -203,7 +220,7 @@ pub async fn get_call_record_search_payload(
}))
}
-/// `user_id` drives the per-row `attended` flag.
+/// `user_id` drives the per-row viewer-specific status and legacy `attended` flag.
#[tracing::instrument(skip(db))]
pub async fn get_call_records_metadata(
db: &sqlx::Pool<sqlx::Postgres>,
@@ -228,7 +245,20 @@ pub async fn get_call_records_metadata(
EXISTS (
SELECT 1 FROM call_record_participants crp
WHERE crp.call_record_id = cr.id AND crp.user_id = $2
- ) AS "attended!"
+ ) AS "attended!",
+ CASE
+ WHEN EXISTS (
+ SELECT 1 FROM call_record_participants crp
+ WHERE crp.call_record_id = cr.id AND crp.user_id = $2
+ ) THEN 'ATTENDED'
+ WHEN EXISTS (
+ SELECT 1 FROM comms_channel_participants ccp
+ WHERE ccp.channel_id = cr.channel_id
+ AND ccp.user_id = $2
+ AND ccp.left_at IS NULL
+ ) THEN 'MISSED'
+ ELSE 'UNATTENDED'
+ END AS "status!"
FROM call_records cr
WHERE cr.id = ANY($1)
"#,
diff --git a/rust/cloud-storage/models_search/src/call_record.rs b/rust/cloud-storage/models_search/src/call_record.rs
index 06b9311fc2..56803c686b 100644
--- a/rust/cloud-storage/models_search/src/call_record.rs
+++ b/rust/cloud-storage/models_search/src/call_record.rs
@@ -1,5 +1,5 @@
use chrono::{DateTime, Utc};
-use item_filters::CallFilters;
+use item_filters::{CallFilters, CallStatus};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
@@ -37,6 +37,7 @@ pub struct CallRecordMetadata {
pub duration_ms: i64,
pub updated_at: DateTime<Utc>,
pub channel_name: Option<String>,
+ pub status: CallStatus,
pub attended: bool,
}
diff --git a/rust/cloud-storage/models_soup/Cargo.toml b/rust/cloud-storage/models_soup/Cargo.toml
index 1b5138e89a..6f57a68e3e 100644
--- a/rust/cloud-storage/models_soup/Cargo.toml
+++ b/rust/cloud-storage/models_soup/Cargo.toml
@@ -6,7 +6,7 @@ version = "0.1.0"
[features]
mock = []
-schema = ["dep:utoipa"]
+schema = ["dep:utoipa", "item_filters/schema"]
[dependencies]
anyhow = { workspace = true }
@@ -17,6 +17,7 @@ crm = { path = "../crm", default-features = false }
document_sub_type = { path = "../document_sub_type" }
doppleganger = { workspace = true, features = ["chrono", "uuid"] }
email = { path = "../email" }
+item_filters = { path = "../item_filters" }
macro_user_id = { path = "../macro_user_id" }
model-entity = { path = "../model-entity" }
models_pagination = { path = "../models_pagination" }
diff --git a/rust/cloud-storage/models_soup/src/call_record.rs b/rust/cloud-storage/models_soup/src/call_record.rs
index 1f758a832c..d95e3dd7e7 100644
--- a/rust/cloud-storage/models_soup/src/call_record.rs
+++ b/rust/cloud-storage/models_soup/src/call_record.rs
@@ -1,4 +1,6 @@
+use call::domain::models::{CallRecord, CallRecordParticipant};
use chrono::{DateTime, Utc};
+use item_filters::CallStatus;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
@@ -43,19 +45,32 @@ pub struct SoupCallRecord {
pub summary: Option<String>,
/// Whether the call is currently active.
pub is_active: bool,
- /// Whether the requesting user attended this call (i.e. appears in the
- /// `call_participants` / `call_record_participants` table).
+ /// Viewer-relative call status for the requesting user.
+ pub status: CallStatus,
+ /// Whether the requesting user attended this call. Kept for compatibility
+ /// and derived from `status == ATTENDED`.
pub attended: bool,
/// Participants in the call.
pub participants: Vec<SoupCallRecordParticipant>,
}
+fn participant_derived_status(participants: &[CallRecordParticipant], user_id: &str) -> CallStatus {
+ if participants.iter().any(|p| p.user_id == user_id) {
+ return CallStatus::Attended;
+ }
+
+ CallStatus::Unattended
+}
+
impl SoupCallRecord {
/// Build a `SoupCallRecord` from a domain `CallRecord` in the context of a
- /// specific viewer: `attended` is set by checking whether `user_id` appears
- /// in `record.participants`.
- pub fn from_record_for_user(record: call::domain::models::CallRecord, user_id: &str) -> Self {
- let attended = record.participants.iter().any(|p| p.user_id == user_id);
+ /// specific viewer.
+ pub fn from_record_for_user(record: CallRecord, user_id: &str) -> Self {
+ let status = record
+ .status
+ .unwrap_or_else(|| participant_derived_status(&record.participants, user_id));
+ let attended = status == CallStatus::Attended;
+
SoupCallRecord {
call_id: record.call_id,
channel_id: record.channel_id,
@@ -67,6 +82,7 @@ impl SoupCallRecord {
custom_name: record.custom_name,
summary: record.summary,
is_active: record.is_active,
+ status,
attended,
participants: record
.participants
diff --git a/rust/cloud-storage/models_soup/src/call_record/test.rs b/rust/cloud-storage/models_soup/src/call_record/test.rs
index b76af0db4f..cb3f3635a5 100644
--- a/rust/cloud-storage/models_soup/src/call_record/test.rs
+++ b/rust/cloud-storage/models_soup/src/call_record/test.rs
@@ -1,6 +1,7 @@
use super::*;
use call::domain::models::{CallRecord, CallRecordParticipant};
use chrono::Utc;
+use item_filters::CallStatus;
use uuid::Uuid;
fn record_with_participants(user_ids: &[&str]) -> CallRecord {
@@ -24,6 +25,7 @@ fn record_with_participants(user_ids: &[&str]) -> CallRecord {
summary: None,
share_with_team: true,
is_active: true,
+ status: None,
participants: user_ids
.iter()
.map(|u| CallRecordParticipant {
@@ -36,6 +38,59 @@ fn record_with_participants(user_ids: &[&str]) -> CallRecord {
}
}
+fn record_with_status(status: CallStatus, user_ids: &[&str]) -> CallRecord {
+ let mut record = record_with_participants(user_ids);
+ record.status = Some(status);
+ record
+}
+
+#[test]
+fn call_record_status_uses_record_status_when_present() {
+ let record = record_with_status(CallStatus::Missed, &["macro|[email protected]"]);
+ let soup = SoupCallRecord::from_record_for_user(record, "macro|[email protected]");
+
+ assert_eq!(soup.status, CallStatus::Missed);
+ assert!(!soup.attended);
+}
+
+#[test]
+fn call_record_status_attended_true_only_for_attended() {
+ let attended = SoupCallRecord::from_record_for_user(
+ record_with_status(CallStatus::Attended, &[]),
+ );
+ let missed = SoupCallRecord::from_record_for_user(
+ record_with_status(CallStatus::Missed, &["macro|[email protected]"]),
+ );
+ let unattended = SoupCallRecord::from_record_for_user(
+ record_with_status(CallStatus::Unattended, &["macro|[email protected]"]),
+ );
+
+ assert!(attended.attended);
+ assert!(!missed.attended);
+ assert!(!unattended.attended);
+}
+
+#[test]
+fn call_record_status_falls_back_to_participant_attended_when_status_absent() {
+ let record = record_with_participants(&["macro|[email protected]", "macro|[email protected]"]);
+ let soup = SoupCallRecord::from_record_for_user(record, "macro|[email protected]");
+
+ assert_eq!(soup.status, CallStatus::Attended);
+ assert!(soup.attended);
+}
+
+#[test]
+fn call_record_status_falls_back_to_unattended_when_status_absent() {
+ let record = record_with_participants(&["macro|[email protected]", "macro|[email protected]"]);
+ let soup = SoupCallRecord::from_record_for_user(record, "macro|[email protected]");
+
+ assert_eq!(soup.status, CallStatus::Unattended);
+ assert!(!soup.attended);
+}
+
#[test]
fn from_record_for_user_sets_attended_true_when_user_is_participant() {
let record = record_with_participants(&["macro|[email protected]", "macro|[email protected]"]);
diff --git a/rust/cloud-storage/search_service/src/api/search/call_record.rs b/rust/cloud-storage/search_service/src/api/search/call_record.rs
index 53cce9d959..c182a6f5dc 100644
--- a/rust/cloud-storage/search_service/src/api/search/call_record.rs
+++ b/rust/cloud-storage/search_service/src/api/search/call_record.rs
@@ -1,5 +1,6 @@
use comms::outbound::postgres::channel_name::batch_resolve_channel_names;
use indexmap::IndexMap;
+use item_filters::CallStatus;
use macro_user_id::user_id::MacroUserIdStr;
use models_search::call_record::{
CallRecordMetadata, CallRecordSearchResponseItem, CallRecordSearchResponseItemWithMetadata,
@@ -57,9 +58,10 @@ pub(in crate::api::search) async fn enrich_call_records(
let metadata_by_id: std::collections::HashMap<Uuid, CallRecordMetadata> = metadata_rows
.into_iter()
.map(|row| {
+ let status = parse_call_status(&row.status)?;
custom_name_by_id.insert(row.call_id, row.custom_name);
let channel_name = channel_names_by_id.get(&row.channel_id).cloned();
- (
+ Ok((
row.call_id,
CallRecordMetadata {
created_by: row.created_by,
@@ -68,11 +70,12 @@ pub(in crate::api::search) async fn enrich_call_records(
duration_ms: row.duration_ms,
updated_at: row.ended_at,
channel_name,
+ status,
attended: row.attended,
},
- )
+ ))
})
- .collect();
+ .collect::<Result<_, SearchError>>()?;
let mut hits_by_call_id: IndexMap<Uuid, Vec<CallRecordSearchResult>> = IndexMap::new();
let mut call_context: std::collections::HashMap<Uuid, (Uuid, Vec<String>)> =
@@ -135,3 +138,14 @@ pub(in crate::api::search) async fn enrich_call_records(
Ok(result)
}
+
+fn parse_call_status(status: &str) -> Result<CallStatus, SearchError> {
+ match status {
+ "ATTENDED" => Ok(CallStatus::Attended),
+ "MISSED" => Ok(CallStatus::Missed),
+ "UNATTENDED" => Ok(CallStatus::Unattended),
+ _ => Err(SearchError::InternalError(anyhow::anyhow!(
+ "unexpected call status: {status}"
+ ))),
+ }
+}
diff --git a/rust/cloud-storage/search_service/src/api/search/simple/simple_call_record.rs b/rust/cloud-storage/search_service/src/api/search/simple/simple_call_record.rs
index 0b23383bfe..4a5b92927a 100644
--- a/rust/cloud-storage/search_service/src/api/search/simple/simple_call_record.rs
+++ b/rust/cloud-storage/search_service/src/api/search/simple/simple_call_record.rs
@@ -1,6 +1,6 @@
use std::collections::HashSet;
-use item_filters::CallFilters;
+use item_filters::{CallFilters, CallStatus};
use crate::api::context::SearchHandlerState;
use crate::api::search::simple::SearchError;
@@ -17,10 +17,11 @@ pub(in crate::api::search) async fn filter_calls(
user_id: &str,
filters: &CallFilters,
) -> Result<FilterCallResponse, SearchError> {
+ let status_filter = status_filter_values(filters);
let accessible = macro_db_client::call_record::get::get_accessible_call_ids(
&ctx.db,
user_id,
- filters.attended,
+ &status_filter,
)
.await
.map_err(SearchError::InternalError)?;
@@ -42,3 +43,23 @@ pub(in crate::api::search) async fn filter_calls(
channel_ids: filters.channel_ids.clone(),
})
}
+
+fn status_filter_values(filters: &CallFilters) -> Vec<String> {
+ if let Some(status) = filters.status {
+ return vec![status_value(status).to_string()];
+ }
+
+ match filters.attended {
+ Some(true) => vec!["ATTENDED".to_string()],
+ Some(false) => vec!["MISSED".to_string(), "UNATTENDED".to_string()],
+ None => Vec::new(),
+ }
+}
+
+fn status_value(status: CallStatus) -> &'static str {
+ match status {
+ CallStatus::Attended => "ATTENDED",
+ CallStatus::Missed => "MISSED",
+ CallStatus::Unattended => "UNATTENDED",
+ }
+}