Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore(calls): re add ai call summary (#2970)
Will Hutchinson4061a4f17154
diff --git a/js/app/packages/block-call/component/CallRecording/CallRecordingMediaColumn.tsx b/js/app/packages/block-call/component/CallRecording/CallRecordingMediaColumn.tsxindex 0bfc5fda67..2767647313 100644--- a/js/app/packages/block-call/component/CallRecording/CallRecordingMediaColumn.tsx+++ b/js/app/packages/block-call/component/CallRecording/CallRecordingMediaColumn.tsx@@ -3,6 +3,7 @@ import type { Accessor, Setter } from 'solid-js';import { Show } from 'solid-js';import { cn } from '@ui/utils/classname';import { CallRecordingParticipantsSection } from './CallRecordingParticipants';+import { CallRecordingSummarySection } from './CallRecordingSummary';import { CallRecordingVideo } from './CallRecordingVideo';export type CallRecordingTimeUpdateSource = 'playback' | 'seeking' | 'seeked';@@ -50,6 +51,8 @@ export function CallRecordingMediaColumn(props: {</Show></Show>+ <CallRecordingSummarySection record={props.record} />+<divclass={cn('overflow-hidden @[860px]:block',diff --git a/js/app/packages/block-call/component/CallRecording/CallRecordingSummary.tsx b/js/app/packages/block-call/component/CallRecording/CallRecordingSummary.tsxnew file mode 100644index 0000000000..8cc4e0203f--- /dev/null+++ b/js/app/packages/block-call/component/CallRecording/CallRecordingSummary.tsx@@ -0,0 +1,36 @@+import Notepad from '@phosphor-icons/core/assets/regular/notepad.svg';+import type { CallRecord } from '@service-storage/generated/schemas/callRecord';+import type { Accessor } from 'solid-js';+import { Show, createMemo, createSignal } from 'solid-js';+import { CallRecordingSectionShell } from './CallRecordingSectionShell';++export function CallRecordingSummarySection(props: {+ record: Accessor<CallRecord>;+}) {+ const summary = createMemo(() => {+ const value = props.record().summary;+ if (!value) return null;+ const trimmed = value.trim();+ return trimmed.length > 0 ? trimmed : null;+ });+ const [open, setOpen] = createSignal(true);++ return (+ <Show when={summary()}>+ {(text) => (+ <CallRecordingSectionShell+ title="Summary"+ icon={<Notepad class="size-4 text-ink shrink-0" />}+ accordion+ accordionOpenMaxVh={45}+ open={open()}+ onToggle={() => setOpen((v) => !v)}+ >+ <div class="min-h-0 flex-1 overflow-y-auto scrollbar-hidden px-4 py-3">+ <p class="whitespace-pre-wrap text-sm text-ink">{text()}</p>+ </div>+ </CallRecordingSectionShell>+ )}+ </Show>+ );+}diff --git a/js/app/packages/entity/src/composed/list-entity/call.tsx b/js/app/packages/entity/src/composed/list-entity/call.tsxindex cb82b838f9..2a0fec42eb 100644--- a/js/app/packages/entity/src/composed/list-entity/call.tsx+++ b/js/app/packages/entity/src/composed/list-entity/call.tsx@@ -117,6 +117,13 @@ export function CallNarrowBody(props: {<AttendanceBadge attended={props.entity.attended} /></Show></span>+ <Show when={!hit() && props.entity.summary}>+ {(summary) => (+ <span class="text-ink/50 font-normal truncate text-xs">+ {summary()}+ </span>+ )}+ </Show></Entity.Slot>);}@@ -135,14 +142,23 @@ export function CallWideContent(props: {<Showwhen={hit()}fallback={- <span class="text-ink-extra-muted font-medium truncate">- <Show- when={props.entity.durationMs}- fallback={props.entity.isActive ? 'In progress' : ''}- >- {(ms) => formatCallDuration(ms())}+ <>+ <span class="text-ink-extra-muted font-medium truncate shrink-0">+ <Show+ when={props.entity.durationMs}+ fallback={props.entity.isActive ? 'In progress' : ''}+ >+ {(ms) => formatCallDuration(ms())}+ </Show>+ </span>+ <Show when={props.entity.summary}>+ {(summary) => (+ <span class="text-ink/50 font-medium truncate flex-1 min-w-0">+ {summary()}+ </span>+ )}</Show>- </span>+ </>}>{(h) => (diff --git a/js/app/packages/entity/src/types/entity.ts b/js/app/packages/entity/src/types/entity.tsindex ce678b9437..8906fc3ec8 100644--- a/js/app/packages/entity/src/types/entity.ts+++ b/js/app/packages/entity/src/types/entity.ts@@ -126,6 +126,7 @@ export type CallEntity = EntityBase & {attended: boolean;durationMs?: number;participantIds: string[];+ summary?: string;};export type AutomationEntity = EntityBase & {diff --git a/js/app/packages/queries/soup/transform-utils.ts b/js/app/packages/queries/soup/transform-utils.tsindex 6a56077d47..4944d8fe10 100644--- a/js/app/packages/queries/soup/transform-utils.ts+++ b/js/app/packages/queries/soup/transform-utils.ts@@ -533,6 +533,7 @@ export const mapSoupPageToEntityList: (attended: item.data.attended,durationMs: item.data.durationMs ?? undefined,participantIds: item.data.participants.map((p) => p.userId),+ summary: item.data.summary ?? undefined,} satisfies CallEntity;}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.tsindex 4c8e16e76e..faea8406aa 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@@ -580,6 +580,7 @@ export * from './soupCallRecordDurationMs';export * from './soupCallRecordEndedAt';export * from './soupCallRecordParticipant';export * from './soupCallRecordParticipantLeftAt';+export * from './soupCallRecordSummary';export * from './soupChannel';export * from './soupChannelAllOf';export * from './soupChannelAllOfInteractedAt';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.tsindex e2a6a93ed8..6d249d9f2e 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@@ -9,6 +9,7 @@ import type { SoupCallRecordCustomName } from './soupCallRecordCustomName';import type { SoupCallRecordDurationMs } from './soupCallRecordDurationMs';import type { SoupCallRecordEndedAt } from './soupCallRecordEndedAt';import type { SoupCallRecordParticipant } from './soupCallRecordParticipant';+import type { SoupCallRecordSummary } from './soupCallRecordSummary';/*** A call record as displayed in Soup. Excludes room_name, egress_id,@@ -38,4 +39,8 @@ export interface SoupCallRecord {participants: SoupCallRecordParticipant[];/** When the call started. */startedAt: string;+ /** AI-generated summary of the call. Only set on archived+`call_records` once summarization has run; active calls always+return `None`. */+ summary?: SoupCallRecordSummary;}diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordSummary.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordSummary.tsnew file mode 100644index 0000000000..e8fe4e19eb--- /dev/null+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupCallRecordSummary.ts@@ -0,0 +1,13 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * document_storage_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * AI-generated summary of the call. Only set on archived+`call_records` once summarization has run; active calls always+return `None`.+ */+export type SoupCallRecordSummary = string | null;diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.tsindex 835c2c47fa..41517af322 100644--- a/js/app/packages/service-clients/service-storage/generated/zod.ts+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts@@ -5129,6 +5129,12 @@ export const getItemsSoupResponse = zod.object({startedAt: zod.iso.datetime({}).describe('When the call started.'),+ summary: zod+ .string()+ .nullish()+ .describe(+ 'AI-generated summary of the call. Only set on archived\n`call_records` once summarization has run; active calls always\nreturn `None`.'+ ),}).describe('A call record as displayed in Soup. Excludes room_name, egress_id,\nand transcript — fields that are irrelevant for the soup feed.'@@ -6800,6 +6806,12 @@ export const postItemsSoupResponse = zod.object({startedAt: zod.iso.datetime({}).describe('When the call started.'),+ summary: zod+ .string()+ .nullish()+ .describe(+ 'AI-generated summary of the call. Only set on archived\n`call_records` once summarization has run; active calls always\nreturn `None`.'+ ),}).describe('A call record as displayed in Soup. Excludes room_name, egress_id,\nand transcript — fields that are irrelevant for the soup feed.'@@ -8115,6 +8127,12 @@ export const postItemsSoupAstResponse = zod.object({startedAt: zod.iso.datetime({}).describe('When the call started.'),+ summary: zod+ .string()+ .nullish()+ .describe(+ 'AI-generated summary of the call. Only set on archived\n`call_records` once summarization has run; active calls always\nreturn `None`.'+ ),}).describe('A call record as displayed in Soup. Excludes room_name, egress_id,\nand transcript — fields that are irrelevant for the soup feed.'diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.jsonindex 07edc2379c..47e26060a7 100644--- a/js/app/packages/service-clients/service-storage/openapi.json+++ b/js/app/packages/service-clients/service-storage/openapi.json@@ -11271,6 +11271,10 @@"type": "string","format": "date-time","description": "When the call started."+ },+ "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/rust/cloud-storage/.sqlx/query-f32009fa2fba59b598040e667eb240d0f0bef98666123d4f27fb2c3599ae6bd4.json b/rust/cloud-storage/.sqlx/query-01807869314da98fb35b92299c5bc1316bc32d77d88903d294f90c0593ff6f83.jsonsimilarity index 54%rename from rust/cloud-storage/.sqlx/query-f32009fa2fba59b598040e667eb240d0f0bef98666123d4f27fb2c3599ae6bd4.jsonrename to rust/cloud-storage/.sqlx/query-01807869314da98fb35b92299c5bc1316bc32d77d88903d294f90c0593ff6f83.jsonindex 482dad4c2d..1715935331 100644--- a/rust/cloud-storage/.sqlx/query-f32009fa2fba59b598040e667eb240d0f0bef98666123d4f27fb2c3599ae6bd4.json+++ b/rust/cloud-storage/.sqlx/query-01807869314da98fb35b92299c5bc1316bc32d77d88903d294f90c0593ff6f83.json@@ -1,6 +1,6 @@{"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 NULL::text as \"custom_name\",\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 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 custom_name,\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 ORDER BY \"started_at!\" DESC\n LIMIT $2\n ",+ "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 NULL::text as \"custom_name\",\n NULL::text as \"summary\",\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 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 custom_name,\n summary,\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 ORDER BY \"started_at!\" DESC\n LIMIT $2\n ","describe": {"columns": [{@@ -55,6 +55,11 @@},{"ordinal": 10,+ "name": "summary",+ "type_info": "Text"+ },+ {+ "ordinal": 11,"name": "is_active!","type_info": "Bool"}@@ -79,8 +84,9 @@null,null,null,+ null,null]},- "hash": "f32009fa2fba59b598040e667eb240d0f0bef98666123d4f27fb2c3599ae6bd4"+ "hash": "01807869314da98fb35b92299c5bc1316bc32d77d88903d294f90c0593ff6f83"}diff --git a/rust/cloud-storage/CLAUDE.md b/rust/cloud-storage/CLAUDE.mdindex 99384888cd..466fff9933 100644--- a/rust/cloud-storage/CLAUDE.md+++ b/rust/cloud-storage/CLAUDE.md@@ -241,6 +241,7 @@ The migration included comprehensive indexes:### Database Query Management- Always run tests between changes that involve changes to db queries+- Never run `cargo test` with `SQLX_OFFLINE=true`. Tests are designed to validate against the live local Postgres; offline mode forces sqlx macros to consult the cached `.sqlx` data and can either surface confusing "type annotations needed" errors when a query was not in the cache or hide regressions where a query no longer matches the schema. If tests fail with sqlx "no cached data" errors, run `just prepare_db` (with `--tests` when the failure is in test code) — do not flip offline mode on. `SQLX_OFFLINE=true` is fine for `cargo check` / `cargo build` / `cargo clippy` only.### Rust Error Handlingdiff --git a/rust/cloud-storage/call/src/outbound/pg_call_repo.rs b/rust/cloud-storage/call/src/outbound/pg_call_repo.rsindex 5c678c2e11..41e99caef3 100644--- a/rust/cloud-storage/call/src/outbound/pg_call_repo.rs+++ b/rust/cloud-storage/call/src/outbound/pg_call_repo.rs@@ -954,6 +954,7 @@ impl CallRepository for PgCallRepo {egress_id,recording_key,NULL::text as "custom_name",+ NULL::text as "summary",true as "is_active!"FROM calls cWHERE EXISTS (@@ -979,6 +980,7 @@ impl CallRepository for PgCallRepo {egress_id,recording_key,custom_name,+ summary,false as "is_active!"FROM call_records crWHERE EXISTS (@@ -1060,7 +1062,7 @@ impl CallRepository for PgCallRepo {recording_url: None,channel_name: None,custom_name: row.custom_name,- summary: None,+ summary: row.summary,is_active: row.is_active,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.rsindex f074da517c..0b560ff6b9 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@@ -1139,6 +1139,44 @@ async fn get_call_records_by_user_attended_none_returns_all(Ok(())}+#[sqlx::test(+ fixtures(path = "../../../fixtures", scripts("call_repo")),+ migrator = "MACRO_DB_MIGRATIONS"+)]+async fn get_call_records_by_user_returns_archived_summary(+ pool: Pool<Postgres>,+) -> anyhow::Result<()> {+ let repo = repo(pool.clone());+ let summary = "AI-generated summary of the archived call.";+ sqlx::query!(+ r#"UPDATE call_records SET summary = $2 WHERE id = $1"#,+ CALL_ARCHIVED,+ summary,+ )+ .execute(&pool)+ .await?;++ let records = repo+ .get_call_records_by_user(USER_A.deref().copied(), 10, &None)+ .await?;++ let active = records+ .iter()+ .find(|r| r.call_id == CALL1)+ .expect("active call missing");+ assert!(active.is_active);+ assert!(active.summary.is_none());++ let archived = records+ .iter()+ .find(|r| r.call_id == CALL_ARCHIVED)+ .expect("archived call missing");+ assert!(!archived.is_active);+ assert_eq!(archived.summary.as_deref(), Some(summary));++ Ok(())+}+// -- delete_call_record -------------------------------------------------------#[sqlx::test(diff --git a/rust/cloud-storage/models_soup/src/call_record.rs b/rust/cloud-storage/models_soup/src/call_record.rsindex a71ad12dd5..1f758a832c 100644--- a/rust/cloud-storage/models_soup/src/call_record.rs+++ b/rust/cloud-storage/models_soup/src/call_record.rs@@ -37,6 +37,10 @@ pub struct SoupCallRecord {pub channel_name: Option<String>,/// User-supplied or AI-generated display name for the call.pub custom_name: Option<String>,+ /// AI-generated summary of the call. Only set on archived+ /// `call_records` once summarization has run; active calls always+ /// return `None`.+ 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@@ -61,6 +65,7 @@ impl SoupCallRecord {duration_ms: record.duration_ms,channel_name: record.channel_name,custom_name: record.custom_name,+ summary: record.summary,is_active: record.is_active,attended,participants: recorddiff --git a/rust/cloud-storage/models_soup/src/call_record/test.rs b/rust/cloud-storage/models_soup/src/call_record/test.rsindex 7b38e2c83a..6a03945052 100644--- a/rust/cloud-storage/models_soup/src/call_record/test.rs+++ b/rust/cloud-storage/models_soup/src/call_record/test.rs@@ -55,3 +55,18 @@ fn from_record_for_user_attended_false_when_no_participants() {assert!(!soup.attended);assert!(soup.participants.is_empty());}++#[test]+fn from_record_for_user_passes_summary_through() {+ let mut record = record_with_participants(&["macro|[email protected]"]);+ record.summary = Some("AI summary".to_string());+ let soup = SoupCallRecord::from_record_for_user(record, "macro|[email protected]");+ assert_eq!(soup.summary.as_deref(), Some("AI summary"));+}++#[test]+fn from_record_for_user_summary_none_when_record_has_none() {+ let record = record_with_participants(&["macro|[email protected]"]);+ let soup = SoupCallRecord::from_record_for_user(record, "macro|[email protected]");+ assert!(soup.summary.is_none());+}