/** * One meeting's own page: back to Meetings, the title with who can see it, * Summary · Transcript · Notepad under it, then the player and the open tab. * Summary is the written notes (with mention chips and Copy), Transcript the * turns as speaker bubbles, Notepad what people jotted down; Summary and * Transcript end with "Ask about this meeting" when the host answers it. The * quiet card on the right names the speakers and says which transcript * version this is, with Transcribe again. * * Until the transcript exists the page says where the meeting is: still * recording here (with Pause and Stop, so taking notes never hides it), not * finished yet on another device, transcribing, or failed with the reason and * what to try. Audio uploads while it records, so after Stop it reads * Transcribing, not Uploading. */ import { useOpenGeniText, createOpenGeniText, type OpenGeniText } from "../messages/runtime"; import { regionRestrictedText } from "../inference-region"; import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react"; import { AudioLinesIcon, CheckIcon, ChevronDownIcon, CreditCardIcon, GlobeIcon, LayersIcon, LoaderCircleIcon, LockIcon, PencilIcon, RefreshCwIcon, Trash2Icon, } from "lucide-react"; import { toast } from "sonner"; import { userErrorText } from "../ui/api-error"; import type { Recording, RecordingNote, RecordingPerson, RecordingTranscriptVersion, RecordingTranscriptionModel, RecordingVisibility, } from "@opengeni/contracts"; import { activeSegmentIndex, defaultSpeakerName, formatDuration, languageName, meetingHereStatus, meetingPhase, meetingUploadFailure, ownerLiveLaneName, speakerColorSlots, speakerDisplayName, speakerIsNamed, meetingTitle, transcribingText, transcriptErrorText, transcriptFixModel, transcriptNeedsCredits, useRecording, useRecordingModels, useRecordingNotes, useRecordingPeople, useRecordingsClient, useLiveTranscript, useTranscript, type MeetingHereStatus, type RecordingsClientOverride, } from "../recordings"; import { Button } from "../ui/button"; import { ConfirmDialog } from "../ui/confirm-dialog"; import { DetailAside, DetailAsideItem, DetailMeta, DetailPage, DetailPageBody, DetailPageHeader, } from "../ui/detail-page"; import { DetailSection } from "../ui/detail-sheet"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "../ui/dropdown-menu"; import { EmptyState } from "../ui/empty-state"; import { ErrorMessage } from "../ui/error-message"; import { Field, FieldStack, TextInput } from "../ui/field"; import { FormDialog } from "../ui/form-dialog"; import { MoreMenu } from "../ui/page-actions"; import { Notice } from "../ui/notice"; import { formatAbsoluteTime } from "../ui/relative-time"; import { SegmentedControl } from "../ui/segmented-control"; import { NativeSelect, type SelectOption } from "../ui/select-menu"; import { Skeleton } from "../ui/skeleton"; import { cn } from "../app/lib/utils"; import { WorkspaceReachFields, type ReachWorkspace, type WorkspaceReach, } from "../app/components/workspace-reach"; import { DeleteMeetingDialog } from "./delete-meeting-dialog"; import { DETECT_LANGUAGE, meetingLanguageOptions } from "./meeting-languages"; import { MeetingPlayer, type MeetingPlayerHandle, type MeetingPlayerSource, } from "./meeting-player"; import { MeetingTranscript, NewSpeakerNameDialog, SpeakerDot, SpeakerNameMenu, speakerIsSuggested, type TranscriptActions, } from "./meeting-transcript"; import { liveSpeakerName, RecordingBar, recorderLiveLines, useOnline } from "./recorder-panel"; import { LiveTranscript, liveStatus } from "./live-transcript"; import { MeetingAsk, type MeetingAskRequest, type MeetingAskResult } from "./meeting-ask"; import { meetingMentionResolver } from "./meeting-mentions"; import { useAnnounceMeetingOnScreen } from "./meeting-on-screen"; import { useUiEventTarget } from "../app/lib/ui-events"; import { MeetingNotepad, MeetingNotesSection, MeetingSummary } from "./meeting-notes"; import { useMeetingRecorder, type MeetingRecorder } from "./recorder-context"; import { MeetingsOverlayScope } from "./overlay-scope"; import { StickyBarEdge, useStuckToTop } from "./sticky-bar-edge"; const defaultText = createOpenGeniText(); function errorText(error: unknown): string | undefined { return error instanceof Error ? userErrorText(error) : undefined; } function isNotFound(error: Error | null): boolean { return Boolean(error && /not found|404/iu.test(error.message)); } /** * Fresh playback links for every prepared track. Links expire, so a failed one refetches. * While the meeting is processed, the player waits until every recorded track can * play: the first track alone sounds as if the rest (the call's side) was never recorded. */ function useTrackSources( recording: Recording | null, getAudio: (trackNumber: number) => Promise<{ url: string }>, ): { sources: MeetingPlayerSource[]; reload: () => void } { const [sources, setSources] = useState([]); const [generation, setGeneration] = useState(0); const state = recording?.state; const playable = useMemo(() => { const tracks = recording?.tracks ?? []; const partial = state === "processing" && tracks.some((track) => track.chunkCount > 0 && !track.playable); return partial ? [] : tracks.filter((track) => track.playable).map((track) => track.trackNumber); }, [recording?.tracks, state]); const key = playable.join(","); const getAudioRef = useRef(getAudio); getAudioRef.current = getAudio; useEffect(() => { if (!key) { setSources([]); return; } let cancelled = false; void Promise.all( key.split(",").map(async (value) => { const trackNumber = Number(value); try { const audio = await getAudioRef.current(trackNumber); return { trackNumber, url: audio.url }; } catch { return null; } }), ).then((loaded) => { if (!cancelled) { setSources(loaded.filter((source): source is MeetingPlayerSource => source !== null)); } }); return () => { cancelled = true; }; }, [key, generation]); const reload = useCallback(() => setGeneration((value) => value + 1), []); return { sources, reload }; } function RenameDialog({ open, title, onClose, onRename, }: { open: boolean; title: string; onClose: () => void; onRename: (title: string) => Promise; }) { const msg = useOpenGeniText(); const [value, setValue] = useState(title); const [error, setError] = useState(null); useEffect(() => { if (open) { setValue(title); setError(null); } }, [open, title]); return ( { if (!next) onClose(); }} title={msg("meetings.detailPage.renameMeeting")} submitLabel={msg("meetings.detailPage.save")} pendingLabel={msg("meetings.detailPage.saving")} submitDisabled={!value.trim() || value.trim() === title} error={error} onSubmit={async () => { try { await onRename(value.trim()); } catch (cause) { setError(errorText(cause) ?? msg("meetings.detailPage.couldnTRenameThisMeeting")); return false; } }} onSubmitted={onClose} > setValue(event.target.value)} /> ); } /** * Where the owner's own Only me meeting works: the workspace that stores it * and their Personal workspace always, plus the ones they pick, or all of * their workspaces in the organization. Only they, and agent turns they * start, see it in any of them. */ function MeetingReachDialog({ open, recording, hereId, workspaces, organizationName, onClose, onSave, }: { open: boolean; recording: Recording; /** The workspace the page was opened from. */ hereId: string; workspaces: readonly ReachWorkspace[]; organizationName: string; onClose: () => void; /** Saves the other workspaces it works in (null for all), and says whether it still works here. */ onSave: (reachWorkspaceIds: string[] | null, leavesHere: boolean) => Promise; }) { const msg = useOpenGeniText(); const saved = recording.reachWorkspaceIds ?? null; const savedKey = saved === null ? null : saved.join(","); const [value, setValue] = useState({ workspaceIds: saved, personalWorkspaces: true, }); const [error, setError] = useState(null); useEffect(() => { if (open) { setValue({ workspaceIds: savedKey === null ? null : savedKey.split(",").filter(Boolean), personalWorkspaces: true, }); setError(null); } }, [open, savedKey]); const home = recording.workspaceId; const here = workspaces.find((workspace) => workspace.id === hereId); const chosen = value.workspaceIds === null ? null : value.workspaceIds.filter((id) => id !== home).sort(); // Opened from another workspace it was turned on in, which it would leave. const leavesHere = hereId !== home && here?.personal !== true && chosen !== null && !chosen.includes(hereId); const unchanged = chosen === null ? saved === null : saved !== null && [...saved].sort().join(",") === chosen.join(","); return ( { if (!next) onClose(); }} title={msg("meetings.detailPage.availableIn")} description={msg("meetings.detailPage.onlyYouSeeItInThese")} submitLabel={msg("meetings.detailPage.save")} pendingLabel={msg("meetings.detailPage.saving")} submitDisabled={unchanged} error={error} onSubmit={async () => { try { await onSave(chosen, leavesHere); } catch (cause) { setError(errorText(cause) ?? msg("meetings.detailPage.couldnTChangeWhereItWorks")); return false; } }} onSubmitted={onClose} >
(hereId !== home && here?.personal !== true ? [hereId] : [])} personalWorkspaces="always" /> {leavesHere ? ( {msg("meetings.detailPage.itWillNoLongerShowHere")} ) : null}
); } /** * The models "Transcribe again" offers. One that can't be used says why: * "Not supported in EU" when EU-only switched it off, otherwise what to connect. */ export function transcribeAgainModelOptions( models: readonly Pick< RecordingTranscriptionModel, | "providerId" | "providerName" | "model" | "name" | "available" | "unavailableReason" | "usdPerHour" >[], msg: OpenGeniText = defaultText, ): SelectOption[] { return models.map((entry) => ({ value: `${entry.providerId}/${entry.model}`, label: entry.name, meta: entry.usdPerHour !== null ? msg("meetings.detailPage.valuePerHour", { value: entry.usdPerHour.toFixed(2) }) : entry.providerName, disabled: !entry.available, disabledReason: entry.available ? undefined : (regionRestrictedText(msg, entry.unavailableReason) ?? msg("meetings.detailPage.connectProvidernameFirst", { providerName: entry.providerName })), })); } /** * What transcribing a meeting again costs at a model's hourly price. Each * recorded track (a microphone beside computer audio, say) is transcribed and * billed on its own, so a two-track hour costs two hours. */ export function transcribeAgainEstimate( recording: Pick, usdPerHour: number | null | undefined, ): { usd: number; tracks: number } | null { if (usdPerHour == null) return null; const recorded = recording.tracks.filter( (track) => track.chunkCount > 0 && track.durationMilliseconds > 0, ); const milliseconds = recorded.length > 0 ? recorded.reduce((total, track) => total + track.durationMilliseconds, 0) : recording.durationMilliseconds; if (milliseconds <= 0) return null; return { usd: (usdPerHour * milliseconds) / 3_600_000, tracks: Math.max(1, recorded.length) }; } function TranscribeAgainDialog({ open, recording, models, defaultModel, onClose, onRun, }: { open: boolean; recording: Recording; models: ReturnType["models"]; defaultModel: ReturnType["defaultModel"]; onClose: () => void; onRun: (options: { providerId: string; model: string; /** Null detects it, even when the workspace names a meeting language. */ language: string | null; /** How many people speak; speaker detection finds that many. */ speakers?: number; }) => Promise; }) { const msg = useOpenGeniText(); const current = recording.transcript; const initialModel = current ? `${current.providerId}/${current.model}` : defaultModel ? `${defaultModel.providerId}/${defaultModel.model}` : ""; const [model, setModel] = useState(initialModel); const [language, setLanguage] = useState( recording.transcription.language ?? DETECT_LANGUAGE, ); const initialSpeakers = recording.transcription.speakers ?? recording.transcription.maxSpeakers; const [speakers, setSpeakers] = useState(initialSpeakers ? String(initialSpeakers) : ""); const [error, setError] = useState(null); useEffect(() => { if (open) { setModel(initialModel); setError(null); } }, [open, initialModel]); const modelOptions = transcribeAgainModelOptions(models, msg); const selected = models.find((entry) => `${entry.providerId}/${entry.model}` === model); const estimate = transcribeAgainEstimate(recording, selected?.usdPerHour); const duration = formatDuration(recording.durationMilliseconds, msg); const languageOptions = meetingLanguageOptions(language, undefined, msg); const speakerCount = speakers.trim() ? Number(speakers) : undefined; const speakersInvalid = speakerCount !== undefined && (!Number.isInteger(speakerCount) || speakerCount < 1 || speakerCount > 32); // Speakers come from the model, or from Opengeni's own speaker detection // when this deployment has it (it made the current transcript's). const tellsSpeakersApart = selected?.capabilities.diarization === true || current?.diarization === "ours"; return ( { if (!next) onClose(); }} title={msg("meetings.detailPage.transcribeAgain")} description={msg("meetings.detailPage.makesANewTranscriptNotesToo")} submitLabel={msg("meetings.detailPage.transcribe")} pendingLabel={msg("meetings.detailPage.starting")} submitDisabled={!selected || !selected.available || speakersInvalid} error={error} onSubmit={async () => { if (!selected) return false; try { await onRun({ providerId: selected.providerId, model: selected.model, language: language === DETECT_LANGUAGE ? null : language, ...(speakerCount !== undefined && tellsSpeakersApart ? { speakers: speakerCount } : {}), }); } catch (cause) { setError(errorText(cause) ?? msg("meetings.detailPage.couldnTStartTranscribing")); return false; } }} onSubmitted={onClose} > 1 ? msg("meetings.detailPage.aboutEstimateForTracks", { estimate: estimate.usd.toFixed(2), duration, count: estimate.tracks, }) : msg("meetings.detailPage.aboutEstimateForThisDuration", { estimate: estimate.usd.toFixed(2), duration, }) : undefined } > {tellsSpeakersApart ? ( setSpeakers(event.target.value.replace(/[^0-9]/gu, ""))} className="max-w-24" /> ) : null} ); } function VisibilityMenu({ visibility, onChange, }: { visibility: RecordingVisibility; onChange: (visibility: RecordingVisibility) => void; }) { const msg = useOpenGeniText(); const options: Array<{ value: RecordingVisibility; label: string; description: string }> = [ { value: "private", label: msg("meetings.detailPage.onlyMe"), description: msg("meetings.detailPage.onlyYouCanOpenIt"), }, { value: "workspace", label: msg("meetings.detailPage.workspace"), description: msg("meetings.detailPage.everyoneInThisWorkspaceCan"), }, ]; return ( {options.map((option) => ( { if (option.value !== visibility) onChange(option.value); }} className="items-start" > {option.label} {option.description} {option.value === visibility ? ( ))} ); } /** A transcript version's model and the provider it runs on, by name. */ type ModelAbout = { modelName: string; providerName: string; funding: string; /** The deployment offers no other model. */ pinned: boolean; }; const SPINNER = (