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.

Hutch/feat call block (#2554)

Will Hutchinson71dc0f70cb80
diff --git a/js/app/bun.lock b/js/app/bun.lock
index ee1537ec9d..ec0449d310 100644
--- a/js/app/bun.lock
+++ b/js/app/bun.lock
@@ -58,7 +58,7 @@
"@tanstack/solid-query": "5.90.3",
"@tanstack/solid-virtual": "^3.13.13",
"@tauri-apps/plugin-haptics": "~2",
- "@tauri-apps/plugin-http": "^2.5.8",
+ "@tauri-apps/plugin-http": "~2.5.8",
"@tauri-apps/plugin-notification": "~2",
"@tauri-apps/plugin-os": "~2",
"@tauri-apps/plugin-websocket": "~2",
@@ -157,6 +157,9 @@
"typescript": "^5.0.0",
},
},
+ "packages/block-call": {
+ "name": "block-call",
+ },
"packages/block-canvas": {
"name": "block-canvas",
},
@@ -1451,6 +1454,8 @@
"bl": ["[email protected]", "", { "dependencies": { "buffer": "^5.5.0", "inherits": "^2.0.4", "readable-stream": "^3.4.0" } }, "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w=="],
+ "block-call": ["block-call@workspace:packages/block-call"],
+
"block-canvas": ["block-canvas@workspace:packages/block-canvas"],
"block-channel": ["block-channel@workspace:packages/block-channel"],
@@ -2337,7 +2342,7 @@
"pathval": ["[email protected]", "", {}, "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA=="],
- "pdfjs-dist": ["pdfjs-dist@github:macro-inc/pdf.js#f9b2ce6", { "dependencies": { "dommatrix": "^1.0.3", "web-streams-polyfill": "^3.2.1" }, "peerDependencies": { "worker-loader": "^3.0.8" }, "optionalPeers": ["worker-loader"] }, "macro-inc-pdf.js-f9b2ce6", "sha512-HDFaPbCxLG2GHpf1smUG97nku5aPGBGaCcIbK05dGdp07TBLUlDcXsM4WcE82mO5W4RBPIBVYobX5N/6M6NFrA=="],
+ "pdfjs-dist": ["pdfjs-dist@github:macro-inc/pdf.js#f9b2ce6", { "dependencies": { "dommatrix": "^1.0.3", "web-streams-polyfill": "^3.2.1" }, "peerDependencies": { "worker-loader": "^3.0.8" }, "optionalPeers": ["worker-loader"] }, "macro-inc-pdf.js-f9b2ce6"],
"performance-now": ["[email protected]", "", {}, "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow=="],
diff --git a/js/app/packages/app/constants/list-views.ts b/js/app/packages/app/constants/list-views.ts
index 01b0cb546e..a66bc4cb22 100644
--- a/js/app/packages/app/constants/list-views.ts
+++ b/js/app/packages/app/constants/list-views.ts
@@ -52,6 +52,7 @@ const BLOCK_LIST_VIEW_MAP = {
code: 'documents',
contact: 'channels',
csv: 'documents',
+ call: 'channels',
email: 'mail',
image: 'documents',
md: 'documents',
diff --git a/js/app/packages/block-call/component/CallBlockAdapter.tsx b/js/app/packages/block-call/component/CallBlockAdapter.tsx
new file mode 100644
index 0000000000..a978613711
--- /dev/null
+++ b/js/app/packages/block-call/component/CallBlockAdapter.tsx
@@ -0,0 +1,68 @@
+import { useBlockId } from '@core/block';
+import Unauthorized from '@core/component/AccessErrorViews/Unauthorized';
+import { MaybeResultError } from '@core/util/maybeResult';
+import { useCallRecordQuery } from '@queries/call/call';
+import { Match, Show, Switch } from 'solid-js';
+import { CallTranscript } from './CallTranscript';
+
+function isUnauthorized(error: Error | null): boolean {
+ if (error instanceof MaybeResultError) {
+ return error.errors[0]?.code === 'UNAUTHORIZED';
+ }
+ return false;
+}
+
+export function CallBlockAdapter() {
+ const callId = useBlockId();
+ const callRecord = useCallRecordQuery(() => callId);
+
+ return (
+ <div class="h-full flex flex-col overflow-hidden">
+ <div class="px-4 py-3 border-b border-edge shrink-0">
+ <h2 class="text-sm font-medium text-ink">Call Recording</h2>
+ </div>
+ <div class="flex-1 overflow-y-auto">
+ <Switch>
+ <Match when={callRecord.isLoading}>
+ <div class="flex items-center justify-center h-full text-ink-faint text-sm">
+ Loading call...
+ </div>
+ </Match>
+ <Match when={callRecord.isError && isUnauthorized(callRecord.error)}>
+ <Unauthorized />
+ </Match>
+ <Match when={callRecord.isError}>
+ <div class="flex items-center justify-center h-full text-failure text-sm">
+ Failed to load call recording.
+ </div>
+ </Match>
+ <Match when={callRecord.data}>
+ {(data) => (
+ <>
+ <Show when={data().recordingUrl}>
+ {(url) => (
+ <div class="p-4 border-b border-edge flex justify-center">
+ <video class="w-3/4 rounded" controls src={url()} />
+ </div>
+ )}
+ </Show>
+ <Show
+ when={data().transcript.length > 0}
+ fallback={
+ <Show when={!data().recordingUrl}>
+ <div class="flex items-center justify-center h-full text-ink-faint text-sm">
+ No recording or transcript available.
+ </div>
+ </Show>
+ }
+ >
+ <CallTranscript transcript={data().transcript} />
+ </Show>
+ </>
+ )}
+ </Match>
+ </Switch>
+ </div>
+ </div>
+ );
+}
diff --git a/js/app/packages/block-call/component/CallTranscript.tsx b/js/app/packages/block-call/component/CallTranscript.tsx
new file mode 100644
index 0000000000..e9945c3689
--- /dev/null
+++ b/js/app/packages/block-call/component/CallTranscript.tsx
@@ -0,0 +1,30 @@
+import type { CallRecordTranscriptSegment } from '@service-storage/generated/schemas/callRecordTranscriptSegment';
+import { tryMacroId, useDisplayName } from '@core/user';
+import { For } from 'solid-js';
+
+function TranscriptSegment(props: { segment: CallRecordTranscriptSegment }) {
+ const macroId = () => tryMacroId(props.segment.speakerId);
+ const [displayName] = useDisplayName(macroId());
+
+ return (
+ <div class="flex gap-2 py-1.5 px-3">
+ <span class="font-medium text-ink shrink-0">{displayName()}</span>
+ <span class="text-ink-muted">{props.segment.content}</span>
+ </div>
+ );
+}
+
+export function CallTranscript(props: {
+ transcript: CallRecordTranscriptSegment[];
+}) {
+ const sorted = () =>
+ [...props.transcript].sort((a, b) => a.sequenceNum - b.sequenceNum);
+
+ return (
+ <div class="flex flex-col divide-y divide-edge">
+ <For each={sorted()}>
+ {(segment) => <TranscriptSegment segment={segment} />}
+ </For>
+ </div>
+ );
+}
diff --git a/js/app/packages/block-call/definition.ts b/js/app/packages/block-call/definition.ts
new file mode 100644
index 0000000000..08408d33ba
--- /dev/null
+++ b/js/app/packages/block-call/definition.ts
@@ -0,0 +1,20 @@
+import { defineBlock, type ExtractLoadType, LoadErrors } from '@core/block';
+import { ENABLE_CALLS } from '@core/constant/featureFlags';
+import { ok } from '@core/util/maybeResult';
+import { CallBlockAdapter } from './component/CallBlockAdapter';
+
+export const definition = defineBlock({
+ name: 'call',
+ description: '',
+ component: CallBlockAdapter,
+ async load(source, _intent) {
+ if (!ENABLE_CALLS()) return LoadErrors.MISSING;
+ if (source.type === 'dss') {
+ return ok({ id: source.id });
+ }
+ return LoadErrors.MISSING;
+ },
+ accepted: {},
+});
+
+export type CallData = ExtractLoadType<(typeof definition)['load']>;
diff --git a/js/app/packages/block-call/package.json b/js/app/packages/block-call/package.json
new file mode 100644
index 0000000000..b51bdd451c
--- /dev/null
+++ b/js/app/packages/block-call/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "block-call",
+ "private": true,
+ "scripts": {},
+ "dependencies": {}
+}
diff --git a/js/app/packages/block-call/tsconfig.json b/js/app/packages/block-call/tsconfig.json
new file mode 100644
index 0000000000..d9677aefea
--- /dev/null
+++ b/js/app/packages/block-call/tsconfig.json
@@ -0,0 +1,11 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "jsx": "preserve",
+ "jsxImportSource": "solid-js",
+ "verbatimModuleSyntax": true,
+ "moduleResolution": "bundler",
+ "declaration": true,
+ "composite": true
+ }
+}
diff --git a/js/app/packages/core/block.ts b/js/app/packages/core/block.ts
index 39f9d7de39..6fd6a4a057 100644
--- a/js/app/packages/core/block.ts
+++ b/js/app/packages/core/block.ts
@@ -45,6 +45,7 @@ import {
* List of valid block types that can be used in the application.
*/
export const BlockRegistry = [
+ 'call',
'chat',
'write',
'pdf',
@@ -86,6 +87,7 @@ export type BlockAlias = (typeof BlockAliasRegistry)[BlockAliasKeys];
* Represents the block types that do not correspond to a document type.
*/
export const NonDocumentBlockTypes = [
+ 'call',
'chat',
'channel',
'project',
@@ -126,6 +128,7 @@ function exclude(excludeSet: BlockName[]) {
* Defines the block combinations that are valid.
*/
export const ValidBlockCombinations: BlockCombinationRules = {
+ call: allBlockNames,
chat: allBlockNames,
pdf: ENABLE_PDF_MULTISPLIT ? allBlockNames : exclude(['pdf']),
write: exclude(['write']),
@@ -144,6 +147,7 @@ export const ValidBlockCombinations: BlockCombinationRules = {
// maps block name to valid parents
export const ValidNestingCombinations: BlockCombinationRules = {
+ call: new Set([]),
canvas: new Set(['md']),
chat: new Set([]),
pdf: new Set(['md']),
diff --git a/js/app/packages/core/blockMethodRegistry.ts b/js/app/packages/core/blockMethodRegistry.ts
index 7119df4a57..dd09cf2e68 100644
--- a/js/app/packages/core/blockMethodRegistry.ts
+++ b/js/app/packages/core/blockMethodRegistry.ts
@@ -18,6 +18,7 @@ type EmptySpec = {};
type AssertSpec<T> = T extends BlockMethodSpec ? T : EmptySpec;
export interface BlockMethodRegistry {
+ call: EmptySpec;
chat: AssertSpec<BlockChatSpec>;
channel: EmptySpec;
write: EmptySpec;
diff --git a/js/app/packages/core/component/EntityIcon.tsx b/js/app/packages/core/component/EntityIcon.tsx
index 03c99ba144..6aca46d209 100644
--- a/js/app/packages/core/component/EntityIcon.tsx
+++ b/js/app/packages/core/component/EntityIcon.tsx
@@ -21,6 +21,7 @@ import FileMd from '@icon/duotone/file-md-duotone.svg';
import FilePdf from '@icon/duotone/file-pdf-duotone.svg';
import FileVideo from '@icon/duotone/file-video-duotone.svg';
import FileImage from '@icon/duotone/image-duotone.svg';
+import PhoneCall from '@icon/duotone/phone-call-duotone.svg';
import Canvas from '@icon/duotone/pencil-circle-duotone.svg';
import User from '@icon/duotone/user-duotone.svg';
import Users from '@icon/duotone/users-duotone.svg';
@@ -84,6 +85,12 @@ const ARCHIVE_EXTENSIONS = new Set(
);
export const ENTITY_ICON_CONFIGS: Record<EntityWithValidIcon, IconConfig> = {
+ call: {
+ icon: PhoneCall,
+ foreground: 'text-default',
+ background: 'bg-default-bg',
+ prettyName: 'Call',
+ },
canvas: {
icon: Canvas,
foreground: 'text-canvas',
@@ -268,6 +275,7 @@ function validateEntity(entity: string): EntityWithValidIcon {
}
export const WIDE_ICONS: Record<EntityWithValidIcon, Component> = {
+ call: WideChannel,
canvas: WideDiagram,
html: WideFileCode,
channel: WideChannel,
diff --git a/js/app/packages/core/component/FileList/constants.tsx b/js/app/packages/core/component/FileList/constants.tsx
index 4f9a125c20..807f43263a 100644
--- a/js/app/packages/core/component/FileList/constants.tsx
+++ b/js/app/packages/core/component/FileList/constants.tsx
@@ -68,6 +68,7 @@ export const fileTypeColors: Record<
image: 'bg-image/20 group/item',
canvas: 'bg-canvas/20 group/item',
video: 'bg-video/20 group/item',
+ call: defaultFileColor,
contact: defaultFileColor,
default: defaultFileColor,
chat: defaultFileColor,
diff --git a/js/app/packages/queries/call/call.ts b/js/app/packages/queries/call/call.ts
index 7e75d4abe7..d4f37c17c4 100644
--- a/js/app/packages/queries/call/call.ts
+++ b/js/app/packages/queries/call/call.ts
@@ -40,3 +40,11 @@ export function useLeaveCallMutation() {
},
}));
}
+
+export function useCallRecordQuery(callId: Accessor<string>) {
+ return useQuery(() => ({
+ queryKey: ['call', 'record', callId()],
+ queryFn: async () =>
+ await throwOnErr(() => callServiceClient.getCallRecord(callId())),
+ }));
+}
diff --git a/js/app/packages/service-clients/service-call/client.ts b/js/app/packages/service-clients/service-call/client.ts
index f2dd828b71..2c4afddfbe 100644
--- a/js/app/packages/service-clients/service-call/client.ts
+++ b/js/app/packages/service-clients/service-call/client.ts
@@ -2,9 +2,15 @@ import { SERVER_HOSTS } from '@core/constant/servers';
import { fetchWithToken } from '@core/util/fetchWithToken';
import { mapOk } from '@core/util/maybeResult';
import type { CallActiveResponse } from '@service-storage/generated/schemas/callActiveResponse';
+import type { CallRecord } from '@service-storage/generated/schemas/callRecord';
import type { CallTokenResponse } from '@service-storage/generated/schemas/callTokenResponse';
import type { LeaveCallResponse } from '@service-storage/generated/schemas/leaveCallResponse';
-export type { CallActiveResponse, CallTokenResponse, LeaveCallResponse };
+export type {
+ CallActiveResponse,
+ CallRecord,
+ CallTokenResponse,
+ LeaveCallResponse,
+};
const host: string = SERVER_HOSTS['document-storage-service'];
@@ -37,4 +43,13 @@ export const callServiceClient = {
(data) => ('callId' in data ? (data as CallActiveResponse) : null)
);
},
+
+ async getCallRecord(callId: string) {
+ return mapOk(
+ await fetchWithToken<CallRecord>(`${host}/call/record/${callId}`, {
+ method: 'GET',
+ }),
+ (result) => result
+ );
+ },
};
diff --git a/js/app/tsconfig.json b/js/app/tsconfig.json
index 4bf0b7e52a..6c6695d132 100644
--- a/js/app/tsconfig.json
+++ b/js/app/tsconfig.json
@@ -123,6 +123,9 @@
"@block-code/*": [
"./packages/block-code/*"
],
+ "@block-call/*": [
+ "./packages/block-call/*"
+ ],
"@block-channel/*": [
"./packages/block-channel/*"
],