Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(calls): show share with team in call record (#3485)
Will Hutchinson105d65ccd4c7
diff --git a/js/app/packages/block-call/component/CallRecording/CallRecordingBody.tsx b/js/app/packages/block-call/component/CallRecording/CallRecordingBody.tsxindex ae4b9af91c..a82721eb58 100644--- a/js/app/packages/block-call/component/CallRecording/CallRecordingBody.tsx+++ b/js/app/packages/block-call/component/CallRecording/CallRecordingBody.tsx@@ -1,5 +1,13 @@+import { useCallContextOptional } from '@channel/Call/CallContext';import { CustomScrollbar } from '@core/component/CustomScrollbar';+import { useCanEdit } from '@core/signal/permissions';+import ShareNetwork from '@phosphor/share-network.svg';+import {+ useSetCallRecordShareWithTeamMutation,+ useToggleShareWithTeamMutation,+} from '@queries/call/call';import type { CallRecord } from '@service-storage/generated/schemas/callRecord';+import { cn, ToggleSwitch, Tooltip } from '@ui';import { format } from 'date-fns';import type { Accessor } from 'solid-js';import { createEffect, createMemo, createSignal, on, Show } from 'solid-js';@@ -20,6 +28,75 @@ import {shouldCoalesceSeekGenerationBump,} from './call-recording-utils';+function CallRecordingShareWithTeam(props: { record: Accessor<CallRecord> }) {+ const record = props.record;+ const canEdit = useCanEdit();+ const callCtx = useCallContextOptional();+ const toggleActiveShare = useToggleShareWithTeamMutation();+ const setArchivedShare = useSetCallRecordShareWithTeamMutation();++ const isShared = createMemo(() => record().shareWithTeam);+ const isDisabled = createMemo(+ () =>+ !canEdit() || toggleActiveShare.isPending || setArchivedShare.isPending+ );++ const handleChange = async (checked: boolean) => {+ const current = record();+ try {+ const newValue = current.isActive+ ? await toggleActiveShare.mutateAsync(current.callId)+ : (+ await setArchivedShare.mutateAsync({+ callId: current.callId,+ shareWithTeam: checked,+ })+ ).shareWithTeam;++ if (callCtx?.activeCallId() === current.callId) {+ callCtx.setSharedWithTeam(newValue);+ }+ } catch (error) {+ console.error('failed to update call record team sharing', error);+ }+ };++ return (+ <section class="rounded border border-edge-muted/50 bg-surface/60 px-4 py-3">+ <div class="flex items-center justify-between gap-4">+ <Tooltip+ placement="top"+ label="When on, all team members can view and search this call's transcript and AI summary."+ >+ <div class="flex min-w-0 items-start gap-3">+ <ShareNetwork+ class={cn(+ 'mt-0.5 size-4 shrink-0',+ isShared() ? 'text-ink' : 'text-ink-muted'+ )}+ aria-hidden+ />+ <div class="min-w-0">+ <div class="text-sm font-medium text-ink">+ {isShared() ? 'Shared with team' : 'Share with team'}+ </div>+ <p class="mt-1 text-xs leading-5 text-ink-muted">+ When on, all team members can view and search this call's+ transcript and AI summary.+ </p>+ </div>+ </div>+ </Tooltip>+ <ToggleSwitch+ checked={isShared()}+ disabled={isDisabled()}+ onChange={(checked) => void handleChange(checked)}+ />+ </div>+ </section>+ );+}+export function CallRecordingBody(props: {data: Accessor<CallRecord>;transcriptTarget?: Accessor<CallTranscriptTarget | undefined>;@@ -161,6 +238,8 @@ export function CallRecordingBody(props: {</div></header>+ <CallRecordingShareWithTeam record={record} />+<CallRecordingParticipantsSection record={record} /><CallRecordingSummarySection record={record} />diff --git a/js/app/packages/queries/call/call.ts b/js/app/packages/queries/call/call.tsindex 2103691e3a..8817769e8d 100644--- a/js/app/packages/queries/call/call.ts+++ b/js/app/packages/queries/call/call.ts@@ -1,7 +1,7 @@import { toast } from '@core/component/Toast/Toast';import { ThrownResultError, throwOnErr } from '@core/util/result';import { queryClient } from '@queries/client';-import { callServiceClient } from '@service-call/client';+import { type CallRecord, callServiceClient } from '@service-call/client';import { useMutation, useQuery } from '@tanstack/solid-query';import type { Accessor } from 'solid-js';@@ -76,11 +76,46 @@ export function useCallRecordQuery(callId: Accessor<string>) {}));}+export function setCallRecordShareWithTeamCache(+ callId: string,+ shareWithTeam: boolean+) {+ queryClient.setQueryData<CallRecord>(['call', 'record', callId], (prev) => {+ if (!prev) return prev;+ return { ...prev, shareWithTeam };+ });+}++function invalidateCallRecord(callId: string) {+ queryClient.invalidateQueries({ queryKey: ['call', 'record', callId] });+}++export function useSetCallRecordShareWithTeamMutation() {+ return useMutation(() => ({+ gcTime: 0,+ mutationFn: async (params: { callId: string; shareWithTeam: boolean }) => {+ await throwOnErr(() => callServiceClient.editCallRecord(params));+ return params;+ },+ onSuccess({ callId, shareWithTeam }) {+ setCallRecordShareWithTeamCache(callId, shareWithTeam);+ invalidateCallRecord(callId);+ },+ onError(error: Error) {+ console.error('failed to set share with team', error);+ },+ }));+}+export function useToggleShareWithTeamMutation() {return useMutation(() => ({gcTime: 0,mutationFn: (callId: string) =>throwOnErr(() => callServiceClient.toggleShareWithTeam(callId)),+ onSuccess(newValue, callId) {+ setCallRecordShareWithTeamCache(callId, newValue);+ invalidateCallRecord(callId);+ },onError(error: Error) {console.error('failed to toggle share with team', error);},diff --git a/js/app/packages/service-clients/service-call/client.ts b/js/app/packages/service-clients/service-call/client.tsindex ae3afda0aa..967d6a238a 100644--- a/js/app/packages/service-clients/service-call/client.ts+++ b/js/app/packages/service-clients/service-call/client.ts@@ -67,13 +67,22 @@ export const callServiceClient = {return result.map((r) => r as unknown as boolean);},- async editCallRecord(params: { callId: string; customName: string }) {+ async editCallRecord(params: {+ callId: string;+ customName?: string;+ shareWithTeam?: boolean;+ }) {+ const body: { customName?: string; shareWithTeam?: boolean } = {};+ if (params.customName !== undefined) body.customName = params.customName;+ if (params.shareWithTeam !== undefined)+ body.shareWithTeam = params.shareWithTeam;+return (await fetchWithToken<Record<string, never>>(`${host}/call/record/${params.callId}`,{method: 'PATCH',- body: JSON.stringify({ customName: params.customName }),+ body: JSON.stringify(body),})).map(() => undefined);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.tsindex c4f7b7402f..8316b88a43 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@@ -50,6 +50,8 @@ this value when present, falling back to `started_at` otherwise. */recordingUrl?: CallRecordRecordingUrl;/** The RTC room name. */roomName: string;+ /** Whether the call is shared with the creator's team. */+ shareWithTeam: boolean;/** When the call started (created_at for active, started_at for archived). */startedAt: string;/** AI-generated summary of the call. Only set on archived `call_records`diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.tsindex 3e64b910cc..f83285c337 100644--- a/js/app/packages/service-clients/service-storage/generated/zod.ts+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts@@ -966,6 +966,9 @@ export const getCallRecordResponse = zod.nullish().describe('Presigned URL for the call recording, if available.'),roomName: zod.string().describe('The RTC room name.'),+ shareWithTeam: zod+ .boolean()+ .describe("Whether the call is shared with the creator's team."),startedAt: zod.iso.datetime({}).describe(diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.jsonindex 335870352e..6ef8c52c4b 100644--- a/js/app/packages/service-clients/service-storage/openapi.json+++ b/js/app/packages/service-clients/service-storage/openapi.json@@ -6867,6 +6867,7 @@"roomName","createdBy","startedAt",+ "shareWithTeam","isActive","participants","transcript"@@ -6932,6 +6933,10 @@"type": "string","description": "The RTC room name."},+ "shareWithTeam": {+ "type": "boolean",+ "description": "Whether the call is shared with the creator's team."+ },"startedAt": {"type": "string","format": "date-time",diff --git a/rust/cloud-storage/.sqlx/query-2f3232d6e4e86e77133d03ada2a4b3f438594de6abdfbebb41209e2541acf54b.json b/rust/cloud-storage/.sqlx/query-2f3232d6e4e86e77133d03ada2a4b3f438594de6abdfbebb41209e2541acf54b.jsonnew file mode 100644index 0000000000..5ac9f00f89--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-2f3232d6e4e86e77133d03ada2a4b3f438594de6abdfbebb41209e2541acf54b.json@@ -0,0 +1,15 @@+{+ "db_name": "PostgreSQL",+ "query": "INSERT INTO entity_access (entity_id, entity_type, source_id, source_type, access_level)\n VALUES ($1, 'call', $2, 'team', 'view')",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Uuid",+ "Text"+ ]+ },+ "nullable": []+ },+ "hash": "2f3232d6e4e86e77133d03ada2a4b3f438594de6abdfbebb41209e2541acf54b"+}diff --git a/rust/cloud-storage/.sqlx/query-42a7d2fb1eb1c98ae10f8375a262c48cb828e3c0ed342d0c2b090c2a69c62a2f.json b/rust/cloud-storage/.sqlx/query-42a7d2fb1eb1c98ae10f8375a262c48cb828e3c0ed342d0c2b090c2a69c62a2f.jsonnew file mode 100644index 0000000000..9335e3b082--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-42a7d2fb1eb1c98ae10f8375a262c48cb828e3c0ed342d0c2b090c2a69c62a2f.json@@ -0,0 +1,15 @@+{+ "db_name": "PostgreSQL",+ "query": "UPDATE call_records SET share_with_team = $2 WHERE id = $1",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Uuid",+ "Bool"+ ]+ },+ "nullable": []+ },+ "hash": "42a7d2fb1eb1c98ae10f8375a262c48cb828e3c0ed342d0c2b090c2a69c62a2f"+}diff --git a/rust/cloud-storage/.sqlx/query-432155b7428b328b1dc27cc799bb984b826b69108a323af157537027d59368a5.json b/rust/cloud-storage/.sqlx/query-432155b7428b328b1dc27cc799bb984b826b69108a323af157537027d59368a5.jsonnew file mode 100644index 0000000000..969fa5e099--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-432155b7428b328b1dc27cc799bb984b826b69108a323af157537027d59368a5.json@@ -0,0 +1,14 @@+{+ "db_name": "PostgreSQL",+ "query": "UPDATE calls SET share_with_team = false WHERE id = $1",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": []+ },+ "hash": "432155b7428b328b1dc27cc799bb984b826b69108a323af157537027d59368a5"+}diff --git a/rust/cloud-storage/.sqlx/query-5bdc882bef1ff0927cbf2e77174648b2c327ac6c646741bc6fcba7fc87c2733b.json b/rust/cloud-storage/.sqlx/query-5bdc882bef1ff0927cbf2e77174648b2c327ac6c646741bc6fcba7fc87c2733b.jsonnew file mode 100644index 0000000000..fa39b6acb8--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-5bdc882bef1ff0927cbf2e77174648b2c327ac6c646741bc6fcba7fc87c2733b.json@@ -0,0 +1,94 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT id, channel_id, room_name, created_by, started_at, ended_at, duration_ms, egress_id, recording_key, recording_started_at, custom_name, summary, share_with_team\n FROM call_records\n WHERE id = $1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "channel_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 2,+ "name": "room_name",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "created_by",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "started_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 5,+ "name": "ended_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 6,+ "name": "duration_ms",+ "type_info": "Int8"+ },+ {+ "ordinal": 7,+ "name": "egress_id",+ "type_info": "Text"+ },+ {+ "ordinal": 8,+ "name": "recording_key",+ "type_info": "Text"+ },+ {+ "ordinal": 9,+ "name": "recording_started_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 10,+ "name": "custom_name",+ "type_info": "Text"+ },+ {+ "ordinal": 11,+ "name": "summary",+ "type_info": "Text"+ },+ {+ "ordinal": 12,+ "name": "share_with_team",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ false,+ false,+ false,+ false,+ false,+ false,+ false,+ true,+ true,+ true,+ true,+ true,+ false+ ]+ },+ "hash": "5bdc882bef1ff0927cbf2e77174648b2c327ac6c646741bc6fcba7fc87c2733b"+}diff --git a/rust/cloud-storage/.sqlx/query-7cc7f1a3502e8b8522d3ca1756a38fe884107f8d404296388797b6685278fa4e.json b/rust/cloud-storage/.sqlx/query-7cc7f1a3502e8b8522d3ca1756a38fe884107f8d404296388797b6685278fa4e.jsonnew file mode 100644index 0000000000..803c48f35c--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-7cc7f1a3502e8b8522d3ca1756a38fe884107f8d404296388797b6685278fa4e.json@@ -0,0 +1,22 @@+{+ "db_name": "PostgreSQL",+ "query": "SELECT share_with_team FROM call_records WHERE id = $1",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "share_with_team",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ false+ ]+ },+ "hash": "7cc7f1a3502e8b8522d3ca1756a38fe884107f8d404296388797b6685278fa4e"+}diff --git a/rust/cloud-storage/.sqlx/query-9a097d6795fd9245014e53697e965ef12e37983d6939632758ec6c8accde3857.json b/rust/cloud-storage/.sqlx/query-9a097d6795fd9245014e53697e965ef12e37983d6939632758ec6c8accde3857.jsonnew file mode 100644index 0000000000..3bd505623f--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-9a097d6795fd9245014e53697e965ef12e37983d6939632758ec6c8accde3857.json@@ -0,0 +1,70 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT id, channel_id, room_name, created_by, created_at, egress_id, recording_key, recording_started_at, share_with_team\n FROM calls\n WHERE id = $1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "channel_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 2,+ "name": "room_name",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "created_by",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 5,+ "name": "egress_id",+ "type_info": "Text"+ },+ {+ "ordinal": 6,+ "name": "recording_key",+ "type_info": "Text"+ },+ {+ "ordinal": 7,+ "name": "recording_started_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 8,+ "name": "share_with_team",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ false,+ false,+ false,+ false,+ false,+ true,+ true,+ true,+ false+ ]+ },+ "hash": "9a097d6795fd9245014e53697e965ef12e37983d6939632758ec6c8accde3857"+}diff --git a/rust/cloud-storage/.sqlx/query-db72d933a9b6a70e81ea0b65424c72984b05eb102b424085e5ba1e20f75cd11c.json b/rust/cloud-storage/.sqlx/query-db72d933a9b6a70e81ea0b65424c72984b05eb102b424085e5ba1e20f75cd11c.jsonnew file mode 100644index 0000000000..d96b59a1b3--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-db72d933a9b6a70e81ea0b65424c72984b05eb102b424085e5ba1e20f75cd11c.json@@ -0,0 +1,106 @@+{+ "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 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 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": "recording_started_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 10,+ "name": "custom_name",+ "type_info": "Text"+ },+ {+ "ordinal": 11,+ "name": "summary",+ "type_info": "Text"+ },+ {+ "ordinal": 12,+ "name": "share_with_team!",+ "type_info": "Bool"+ },+ {+ "ordinal": 13,+ "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+ ]+ },+ "hash": "db72d933a9b6a70e81ea0b65424c72984b05eb102b424085e5ba1e20f75cd11c"+}diff --git a/rust/cloud-storage/.sqlx/query-dc95a38b8de9ded74150ab9f73406164e654829bbc05cc7717c7c8c497d16953.json b/rust/cloud-storage/.sqlx/query-dc95a38b8de9ded74150ab9f73406164e654829bbc05cc7717c7c8c497d16953.jsonnew file mode 100644index 0000000000..814fa88fc7--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-dc95a38b8de9ded74150ab9f73406164e654829bbc05cc7717c7c8c497d16953.json@@ -0,0 +1,25 @@+{+ "db_name": "PostgreSQL",+ "query": "\n INSERT INTO call_records (id, channel_id, room_name, created_by, started_at, ended_at, duration_ms, egress_id, recording_key, recording_started_at, share_permission_id, share_with_team)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)\n ",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Uuid",+ "Uuid",+ "Text",+ "Text",+ "Timestamptz",+ "Timestamptz",+ "Int8",+ "Text",+ "Text",+ "Timestamptz",+ "Text",+ "Bool"+ ]+ },+ "nullable": []+ },+ "hash": "dc95a38b8de9ded74150ab9f73406164e654829bbc05cc7717c7c8c497d16953"+}diff --git a/rust/cloud-storage/.sqlx/query-eef43a75c11964f0fd8429e0dd1018d758bfb2e302070eb7d4ba2733d94477df.json b/rust/cloud-storage/.sqlx/query-eef43a75c11964f0fd8429e0dd1018d758bfb2e302070eb7d4ba2733d94477df.jsonnew file mode 100644index 0000000000..a635cc2c88--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-eef43a75c11964f0fd8429e0dd1018d758bfb2e302070eb7d4ba2733d94477df.json@@ -0,0 +1,14 @@+{+ "db_name": "PostgreSQL",+ "query": "UPDATE call_records SET share_with_team = false WHERE id = $1",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": []+ },+ "hash": "eef43a75c11964f0fd8429e0dd1018d758bfb2e302070eb7d4ba2733d94477df"+}diff --git a/rust/cloud-storage/.sqlx/query-f0209df09903abdf1a18b48b4af612281be8c96ae49dae847c93a4218a54b900.json b/rust/cloud-storage/.sqlx/query-f0209df09903abdf1a18b48b4af612281be8c96ae49dae847c93a4218a54b900.jsonnew file mode 100644index 0000000000..4bc3bd3174--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-f0209df09903abdf1a18b48b4af612281be8c96ae49dae847c93a4218a54b900.json@@ -0,0 +1,22 @@+{+ "db_name": "PostgreSQL",+ "query": "SELECT COUNT(*) as \"count!\" FROM entity_access WHERE entity_id = $1 AND source_type = 'team'",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "count!",+ "type_info": "Int8"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid"+ ]+ },+ "nullable": [+ null+ ]+ },+ "hash": "f0209df09903abdf1a18b48b4af612281be8c96ae49dae847c93a4218a54b900"+}diff --git a/rust/cloud-storage/call/src/domain/models.rs b/rust/cloud-storage/call/src/domain/models.rsindex 2fdd90b878..f48657b6b4 100644--- a/rust/cloud-storage/call/src/domain/models.rs+++ b/rust/cloud-storage/call/src/domain/models.rs@@ -333,6 +333,8 @@ pub struct CallRecord {/// 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 shared with the creator's team.+ pub share_with_team: bool,/// Whether the call is currently active (from `calls` table).pub is_active: bool,/// Participants (both active and historic).diff --git a/rust/cloud-storage/call/src/outbound/pg_call_repo.rs b/rust/cloud-storage/call/src/outbound/pg_call_repo.rsindex 2ab818e171..3698aac409 100644--- a/rust/cloud-storage/call/src/outbound/pg_call_repo.rs+++ b/rust/cloud-storage/call/src/outbound/pg_call_repo.rs@@ -577,8 +577,8 @@ impl CallRepository for PgCallRepo {// The record keeps the same id as the original call.sqlx::query!(r#"- INSERT INTO call_records (id, channel_id, room_name, created_by, started_at, ended_at, duration_ms, egress_id, recording_key, recording_started_at, share_permission_id)- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)+ INSERT INTO call_records (id, channel_id, room_name, created_by, started_at, ended_at, duration_ms, egress_id, recording_key, recording_started_at, share_permission_id, share_with_team)+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)"#,call_id,call.channel_id,@@ -591,6 +591,7 @@ impl CallRepository for PgCallRepo {call.recording_key,call.recording_started_at,&call.share_permission_id,+ call.share_with_team,).execute(tx.as_mut()).await?;@@ -924,7 +925,7 @@ impl CallRepository for PgCallRepo {// Try active `calls` first.if let Some(active) = sqlx::query!(r#"- SELECT id, channel_id, room_name, created_by, created_at, egress_id, recording_key, recording_started_at+ SELECT id, channel_id, room_name, created_by, created_at, egress_id, recording_key, recording_started_at, share_with_teamFROM callsWHERE id = $1"#,@@ -992,6 +993,7 @@ impl CallRepository for PgCallRepo {channel_name: None,custom_name: None,summary: None,+ share_with_team: active.share_with_team,is_active: true,participants,transcript,@@ -1001,7 +1003,7 @@ impl CallRepository for PgCallRepo {// Fall back to archived `call_records`.let Some(archived) = sqlx::query!(r#"- SELECT id, channel_id, room_name, created_by, started_at, ended_at, duration_ms, egress_id, recording_key, recording_started_at, custom_name, summary+ SELECT id, channel_id, room_name, created_by, started_at, ended_at, duration_ms, egress_id, recording_key, recording_started_at, custom_name, summary, share_with_teamFROM call_recordsWHERE id = $1"#,@@ -1073,6 +1075,7 @@ impl CallRepository for PgCallRepo {channel_name: None,custom_name: archived.custom_name,summary: archived.summary,+ share_with_team: archived.share_with_team,is_active: false,participants,transcript,@@ -1220,6 +1223,7 @@ impl CallRepository for PgCallRepo {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 cWHERE EXISTS (@@ -1248,6 +1252,7 @@ impl CallRepository for PgCallRepo {recording_started_at,custom_name,summary,+ share_with_team as "share_with_team!",false as "is_active!"FROM call_records crWHERE EXISTS (@@ -1334,6 +1339,7 @@ impl CallRepository for PgCallRepo {channel_name: None,custom_name: row.custom_name,summary: row.summary,+ share_with_team: row.share_with_team,is_active: row.is_active,participants,transcript: Vec::new(),diff --git a/rust/cloud-storage/call/src/outbound/pg_call_repo/edit.rs b/rust/cloud-storage/call/src/outbound/pg_call_repo/edit.rsindex 3b8b9fa2e1..5524b07547 100644--- a/rust/cloud-storage/call/src/outbound/pg_call_repo/edit.rs+++ b/rust/cloud-storage/call/src/outbound/pg_call_repo/edit.rs@@ -56,8 +56,8 @@ pub(super) async fn update_share_permission(/// The team is resolved from the call's `created_by` in either the active/// `calls` table or the archived `call_records` table — not from the acting/// user. If the creator has no team, this is a no-op. Also keeps the-/// `calls.share_with_team` flag in sync when the call is still active so-/// `archive_call` reflects the latest choice.+/// `calls.share_with_team` and `call_records.share_with_team` flags in sync so+/// reads and future archiving reflect the latest choice.pub(super) async fn set_share_with_team(transaction: &mut Transaction<'_, Postgres>,call_id: &Uuid,@@ -86,6 +86,14 @@ pub(super) async fn set_share_with_team(.execute(transaction.as_mut()).await?;+ sqlx::query!(+ r#"UPDATE call_records SET share_with_team = $2 WHERE id = $1"#,+ call_id,+ share,+ )+ .execute(transaction.as_mut())+ .await?;+let team_id: Option<Uuid> = sqlx::query_scalar!(r#"SELECT team_iddiff --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 58c27b1fc7..d8e729526d 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@@ -561,6 +561,27 @@ async fn give_user_a_team(Ok(())}+async fn stored_call_record_share_with_team(+ pool: &Pool<Postgres>,+ call_id: Uuid,+) -> anyhow::Result<bool> {+ Ok(sqlx::query_scalar!(+ r#"SELECT share_with_team FROM call_records WHERE id = $1"#,+ call_id,+ )+ .fetch_one(pool)+ .await?)+}++async fn team_entity_access_count(pool: &Pool<Postgres>, call_id: Uuid) -> anyhow::Result<i64> {+ Ok(sqlx::query_scalar!(+ r#"SELECT COUNT(*) as "count!" FROM entity_access WHERE entity_id = $1 AND source_type = 'team'"#,+ call_id,+ )+ .fetch_one(pool)+ .await?)+}+// -- archive_call grants team view access when share_with_team is true -------#[sqlx::test(@@ -595,6 +616,7 @@ async fn archive_call_grants_team_view_access_when_share_with_team_true(assert_eq!(row.get::<String, _>("entity_type"), "call");assert_eq!(row.get::<String, _>("source_id"), team_id.to_string());assert_eq!(row.get::<AccessLevel, _>("access_level"), AccessLevel::View);+ assert!(stored_call_record_share_with_team(&pool, CALL1).await?);Ok(())}@@ -633,6 +655,7 @@ async fn archive_call_skips_team_grant_when_share_with_team_false(.await?;assert_eq!(count, 0);+ assert!(!stored_call_record_share_with_team(&pool, CALL1).await?);Ok(())}@@ -1180,9 +1203,16 @@ async fn get_stable_speaker_voices_for_call_record_returns_all_voices_for_consismigrator = "MACRO_DB_MIGRATIONS")]async fn get_call_record_returns_active_call(pool: Pool<Postgres>) -> anyhow::Result<()> {- let repo = repo(pool);+ let repo = repo(pool.clone());let now = Utc::now();+ sqlx::query!(+ r#"UPDATE calls SET share_with_team = false WHERE id = $1"#,+ CALL1,+ )+ .execute(&pool)+ .await?;+// Ingest two transcript segments into the active call.repo.create_transcript_segment(&CALL1,@@ -1225,6 +1255,7 @@ async fn get_call_record_returns_active_call(pool: Pool<Postgres>) -> anyhow::Reassert_eq!(record.call_id, CALL1);assert_eq!(record.channel_id, CH1);assert!(record.is_active);+ assert!(!record.share_with_team);assert!(record.ended_at.is_none());assert!(record.duration_ms.is_none());@@ -1259,7 +1290,15 @@ async fn get_call_record_returns_active_call(pool: Pool<Postgres>) -> anyhow::Remigrator = "MACRO_DB_MIGRATIONS")]async fn get_call_record_returns_archived_call(pool: Pool<Postgres>) -> anyhow::Result<()> {- let repo = repo(pool);+ let repo = repo(pool.clone());++ sqlx::query!(+ r#"UPDATE call_records SET share_with_team = false WHERE id = $1"#,+ CALL_ARCHIVED,+ )+ .execute(&pool)+ .await?;+let record = repo.get_call_record_by_call_id(&CALL_ARCHIVED).await?@@ -1268,6 +1307,7 @@ async fn get_call_record_returns_archived_call(pool: Pool<Postgres>) -> anyhow::assert_eq!(record.call_id, CALL_ARCHIVED);assert_eq!(record.channel_id, CH1);assert!(!record.is_active);+ assert!(!record.share_with_team);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"));@@ -1598,6 +1638,43 @@ async fn get_call_records_by_user_returns_archived_summary(Ok(())}+#[sqlx::test(+ fixtures(path = "../../../fixtures", scripts("call_repo")),+ migrator = "MACRO_DB_MIGRATIONS"+)]+async fn get_call_records_by_user_returns_share_with_team(+ pool: Pool<Postgres>,+) -> anyhow::Result<()> {+ let repo = repo(pool.clone());++ sqlx::query!(+ r#"UPDATE call_records SET share_with_team = false WHERE id = $1"#,+ CALL_ARCHIVED,+ )+ .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.share_with_team);++ let archived = records+ .iter()+ .find(|r| r.call_id == CALL_ARCHIVED)+ .expect("archived call missing");+ assert!(!archived.is_active);+ assert!(!archived.share_with_team);++ Ok(())+}+// -- delete_call_record -------------------------------------------------------#[sqlx::test(@@ -2239,6 +2316,44 @@ async fn patch_call_record_share_with_team_works_on_archived_record(assert_eq!(row.source_id, team_id.to_string());assert_eq!(row.access_level.as_deref(), Some("view"));+ assert!(stored_call_record_share_with_team(&pool, CALL_ARCHIVED).await?);++ Ok(())+}++#[sqlx::test(+ fixtures(path = "../../../fixtures", scripts("call_repo")),+ migrator = "MACRO_DB_MIGRATIONS"+)]+async fn patch_call_record_share_with_team_false_updates_archived_record_and_removes_team_access(+ pool: Pool<Postgres>,+) -> anyhow::Result<()> {+ let repo = repo(pool.clone());+ let team_id: Uuid = Uuid::from_u128(0xaaaaaaaa_aaaa_aaaa_aaaa_aaaaaaaaa013);++ give_user_a_team(&pool, USER_A.as_ref(), &team_id).await?;++ sqlx::query!(+ r#"INSERT INTO entity_access (entity_id, entity_type, source_id, source_type, access_level)+ VALUES ($1, 'call', $2, 'team', 'view')"#,+ CALL_ARCHIVED,+ team_id.to_string(),+ )+ .execute(&pool)+ .await?;++ repo.patch_call_record(+ &CALL_ARCHIVED,+ &EditCallRecordRequest {+ share_permission: None,+ share_with_team: Some(false),+ custom_name: None,+ },+ )+ .await?;++ assert_eq!(team_entity_access_count(&pool, CALL_ARCHIVED).await?, 0);+ assert!(!stored_call_record_share_with_team(&pool, CALL_ARCHIVED).await?);Ok(())}diff --git a/rust/cloud-storage/macro_db_client/migrations/20260522120000_call_record_share_with_team.sql b/rust/cloud-storage/macro_db_client/migrations/20260522120000_call_record_share_with_team.sqlnew file mode 100644index 0000000000..23c5029659--- /dev/null+++ b/rust/cloud-storage/macro_db_client/migrations/20260522120000_call_record_share_with_team.sql@@ -0,0 +1,2 @@+ALTER TABLE call_records+ ADD COLUMN IF NOT EXISTS share_with_team BOOLEAN NOT NULL DEFAULT TRUE;diff --git a/rust/cloud-storage/models_soup/src/call_record/test.rs b/rust/cloud-storage/models_soup/src/call_record/test.rsindex 9fd799e074..4efbcf3749 100644--- a/rust/cloud-storage/models_soup/src/call_record/test.rs+++ b/rust/cloud-storage/models_soup/src/call_record/test.rs@@ -20,6 +20,7 @@ fn record_with_participants(user_ids: &[&str]) -> CallRecord {channel_name: None,custom_name: None,summary: None,+ share_with_team: true,is_active: true,participants: user_ids.iter()