Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(recording): resolve race conditions in recording/transcription notifications (#17309)
Hristo Terezov2fa9178aee11
diff --git a/lang/main-fr-CA.json b/lang/main-fr-CA.jsonindex 552185037c..48809568d7 100644--- a/lang/main-fr-CA.json+++ b/lang/main-fr-CA.json@@ -1120,6 +1120,8 @@"noStreams": "Aucun flux audio ou vidéo détectés.","off": "L'enregistrement est arrêté","offBy": "{{name}} a arrêté l'enregistrement",+ "offByWithTranscription": "{{name}} a arrêté l'enregistrement et la transcription",+ "offWithTranscription": "L'enregistrement et la transcription sont arrêtés","on": "Enregistrement","onBy": "{{name}} a démarré l'enregistrement","onlyRecordSelf": "Enregistrer seulement mon audio et ma vidéo.",diff --git a/lang/main-fr.json b/lang/main-fr.jsonindex 0785420d5c..636262ae83 100644--- a/lang/main-fr.json+++ b/lang/main-fr.json@@ -1139,6 +1139,8 @@"noStreams": "Aucun flux audio ou vidéo détectés.","off": "Enregistrement arrêté","offBy": "{{name}} a arrêté l'enregistrement",+ "offByWithTranscription": "{{name}} a arrêté l'enregistrement et la transcription",+ "offWithTranscription": "L'enregistrement et la transcription sont arrêtés","on": "Enregistrement","onBy": "{{name}} a démarré l'enregistrement","onlyRecordSelf": "Enregistrer seulement mon audio et ma vidéo.",diff --git a/lang/main.json b/lang/main.jsonindex d697beb2ea..7c38786c80 100644--- a/lang/main.json+++ b/lang/main.json@@ -1147,6 +1147,8 @@"noStreams": "No audio or video stream detected.","off": "Recording stopped","offBy": "{{name}} stopped the recording",+ "offByWithTranscription": "{{name}} stopped the recording and transcription",+ "offWithTranscription": "Recording and transcription stopped","on": "Recording started","onBy": "{{name}} started the recording","onByWithTranscription": "{{name}} started the recording. A transcript will also be available after the meeting.",diff --git a/react/features/base/conference/reducer.ts b/react/features/base/conference/reducer.tsindex 44e62fa9a2..f62abfa809 100644--- a/react/features/base/conference/reducer.ts+++ b/react/features/base/conference/reducer.ts@@ -66,6 +66,7 @@ export interface IConferenceMetadata {};};recording?: {+ isRecordingRequested?: boolean;isTranscribingEnabled: boolean;};visitors?: {diff --git a/react/features/recording/actionTypes.ts b/react/features/recording/actionTypes.tsindex 1ab1b91d34..ffbbfdfd8b 100644--- a/react/features/recording/actionTypes.ts+++ b/react/features/recording/actionTypes.ts@@ -102,3 +102,26 @@ export const STOP_LOCAL_RECORDING = 'STOP_LOCAL_RECORDING';* }*/export const SET_START_RECORDING_NOTIFICATION_SHOWN = 'SET_START_RECORDING_NOTIFICATION_SHOWN';++/**+ * Stores the user's intent when starting recording (with or without transcription).+ * Set synchronously before any async operations begin.+ *+ * {+ * type: SET_START_RECORDING_INTENT,+ * intent: Object | null+ * }+ */+export const SET_START_RECORDING_INTENT = 'SET_START_RECORDING_INTENT';++/**+ * Stores what the user is stopping (recording and/or transcription). Mirrors+ * SET_START_RECORDING_INTENT. Seeded from the stop dialog on the local side and+ * from metadata true→false transitions on remote observers.+ *+ * {+ * type: SET_STOP_RECORDING_INTENT,+ * intent: Object | null+ * }+ */+export const SET_STOP_RECORDING_INTENT = 'SET_STOP_RECORDING_INTENT';diff --git a/react/features/recording/actions.any.ts b/react/features/recording/actions.any.tsindex 1dc42983e4..8556965517 100644--- a/react/features/recording/actions.any.ts+++ b/react/features/recording/actions.any.ts@@ -25,12 +25,14 @@ import {SET_MEETING_HIGHLIGHT_BUTTON_STATE,SET_PENDING_RECORDING_NOTIFICATION_UID,SET_SELECTED_RECORDING_SERVICE,+ SET_START_RECORDING_INTENT,SET_START_RECORDING_NOTIFICATION_SHOWN,+ SET_STOP_RECORDING_INTENT,SET_STREAM_KEY,START_LOCAL_RECORDING,STOP_LOCAL_RECORDING} from './actionTypes';-import { START_RECORDING_NOTIFICATION_ID } from './constants';+import { RECORDING_METADATA_ID, START_RECORDING_NOTIFICATION_ID } from './constants';import {getRecordButtonProps,getRecordingLink,@@ -42,6 +44,7 @@ import {shouldAutoTranscribeOnRecord} from './functions';import logger from './logger';+import { IStartRecordingIntent, IStopRecordingIntent } from './reducer';/**@@ -204,21 +207,36 @@ export function showRecordingWarning(props: Object) {* @param {string} streamType - The type of the stream ({@code file} or* {@code stream}).* @param {string?} participantName - The participant name stopping the recording.+ * @param {boolean} wasWithTranscription - Whether transcription was active alongside+ * recording when it was started.* @returns {showNotification}*/-export function showStoppedRecordingNotification(streamType: string, participantName?: string) {+export function showStoppedRecordingNotification(+ streamType: string, participantName?: string, wasWithTranscription?: boolean) {const isLiveStreaming= streamType === JitsiMeetJS.constants.recording.mode.STREAM;const descriptionArguments = { name: participantName };- const dialogProps = isLiveStreaming ? {- descriptionKey: participantName ? 'liveStreaming.offBy' : 'liveStreaming.off',- descriptionArguments,- titleKey: 'dialog.liveStreaming'- } : {- descriptionKey: participantName ? 'recording.offBy' : 'recording.off',- descriptionArguments,- titleKey: 'dialog.recording'- };+ let dialogProps;++ if (isLiveStreaming) {+ dialogProps = {+ descriptionKey: participantName ? 'liveStreaming.offBy' : 'liveStreaming.off',+ descriptionArguments,+ titleKey: 'dialog.liveStreaming'+ };+ } else if (wasWithTranscription) {+ dialogProps = {+ descriptionKey: participantName ? 'recording.offByWithTranscription' : 'recording.offWithTranscription',+ descriptionArguments,+ titleKey: 'dialog.recording'+ };+ } else {+ dialogProps = {+ descriptionKey: participantName ? 'recording.offBy' : 'recording.off',+ descriptionArguments,+ titleKey: 'dialog.recording'+ };+ }return showNotification(dialogProps, NOTIFICATION_TIMEOUT_TYPE.SHORT);}@@ -230,12 +248,16 @@ export function showStoppedRecordingNotification(streamType: string, participant* @param {string} mode - The type of the recording: Stream of File.* @param {string | Object } initiator - The participant who started recording.* @param {string} sessionId - The recording session id.+ * @param {boolean} willTranscribe - Whether transcription is/will be active alongside recording,+ * as determined by the middleware when the sound was played. Ensures the notification text matches+ * the audio cue.* @returns {Function}*/export function showStartedRecordingNotification(mode: string,initiator: { getId: Function; } | string,- sessionId: string) {+ sessionId: string,+ willTranscribe?: boolean) {return async (dispatch: IStore['dispatch'], getState: IStore['getState']) => {const state = getState();const initiatorId = getResourceId(initiator);@@ -256,7 +278,11 @@ export function showStartedRecordingNotification(const recordingSharingUrl = getRecordingSharingUrl(state);const iAmRecordingInitiator = getLocalParticipant(state)?.id === initiatorId;const { showRecordingLink } = state['features/base/config'].recordings || {};- const isTranscribing = isRecorderTranscriptionsRunning(state);++ // Use the willTranscribe value passed from the middleware for consistency+ // with the sound that was already played. Fall back to live state check+ // if not provided.+ const isTranscribing = willTranscribe ?? isRecorderTranscriptionsRunning(state);const isRecording = isRecordingRunning(state);// Case 1: Transcription only (no recording)@@ -476,13 +502,23 @@ export function showStartRecordingNotificationWithCallback(openRecordingDialog:const { conference } = state['features/base/conference'];const autoTranscribeOnRecord = shouldAutoTranscribeOnRecord(state);+ dispatch(setStartRecordingIntent({+ recording: true,+ transcription: autoTranscribeOnRecord+ }));+conference?.startRecording({mode: JitsiRecordingConstants.mode.FILE,appData: JSON.stringify(options)});if (autoTranscribeOnRecord) {- dispatch(setRequestingSubtitles(true, false, null));+ dispatch(setRequestingSubtitles(true, false, null, false, true));+ } else {+ conference?.getMetadataHandler().setMetadata(RECORDING_METADATA_ID, {+ isRecordingRequested: true,+ isTranscribingEnabled: false+ });}} else {openRecordingDialog();@@ -508,3 +544,32 @@ export function markConsentRequested(sessionId: string) {sessionId};}++/**+ * Sets the user's recording + transcription intent from the dialog.+ * Used to coordinate sound/notification timing when both services are requested.+ *+ * @param {Object|null} intent - The intent, or null to clear.+ * @returns {Object}+ */+export function setStartRecordingIntent(intent: IStartRecordingIntent | null) {+ return {+ type: SET_START_RECORDING_INTENT,+ intent+ };+}++/**+ * Sets what the user is stopping (recording and/or transcription). Mirrors+ * {@link setStartRecordingIntent}. Consumed by {@code maybeNotifyRecordingStop}+ * to coordinate the off-sound/notification across stop events.+ *+ * @param {Object|null} intent - The intent, or null to clear.+ * @returns {Object}+ */+export function setStopRecordingIntent(intent: IStopRecordingIntent | null) {+ return {+ type: SET_STOP_RECORDING_INTENT,+ intent+ };+}diff --git a/react/features/recording/components/Recording/AbstractStartRecordingDialog.ts b/react/features/recording/components/Recording/AbstractStartRecordingDialog.tsindex b66cd69e93..1923c6050e 100644--- a/react/features/recording/components/Recording/AbstractStartRecordingDialog.ts+++ b/react/features/recording/components/Recording/AbstractStartRecordingDialog.ts@@ -12,7 +12,7 @@ import { updateDropboxToken } from '../../../dropbox/actions';import { getDropboxData, getNewAccessToken, isEnabled as isDropboxEnabled } from '../../../dropbox/functions.any';import { showErrorNotification } from '../../../notifications/actions';import { setRequestingSubtitles } from '../../../subtitles/actions.any';-import { setSelectedRecordingService, startLocalVideoRecording } from '../../actions';+import { setSelectedRecordingService, setStartRecordingIntent, startLocalVideoRecording } from '../../actions';import { RECORDING_METADATA_ID, RECORDING_TYPES } from '../../constants';import { isRecordingSharingEnabled, shouldAutoTranscribeOnRecord, supportsLocalRecording } from '../../functions';@@ -367,6 +367,13 @@ class AbstractStartRecordingDialog extends Component<IProps, IState> {type?: string;} = {};+ // Dispatch intent synchronously before any async operations.+ // This coordinates sound/notification timing between recording and transcription.+ dispatch(setStartRecordingIntent({+ recording: this.state.shouldRecordAudioAndVideo,+ transcription: this.state.shouldRecordTranscription+ }));+if (this.state.shouldRecordAudioAndVideo) {switch (this.state.selectedRecordingService) {case RECORDING_TYPES.DROPBOX: {@@ -423,9 +430,12 @@ class AbstractStartRecordingDialog extends Component<IProps, IState> {if (this.state.selectedRecordingService === RECORDING_TYPES.JITSI_REC_SERVICE&& this.state.shouldRecordTranscription) {- dispatch(setRequestingSubtitles(true, _displaySubtitles, _subtitlesLanguage, true));+ dispatch(setRequestingSubtitles(+ true, _displaySubtitles, _subtitlesLanguage, true,+ this.state.shouldRecordAudioAndVideo));} else {_conference?.getMetadataHandler().setMetadata(RECORDING_METADATA_ID, {+ isRecordingRequested: this.state.shouldRecordAudioAndVideo,isTranscribingEnabled: this.state.shouldRecordTranscription});}diff --git a/react/features/recording/components/Recording/AbstractStopRecordingDialog.ts b/react/features/recording/components/Recording/AbstractStopRecordingDialog.tsindex a49a69e0d9..159598df93 100644--- a/react/features/recording/components/Recording/AbstractStopRecordingDialog.ts+++ b/react/features/recording/components/Recording/AbstractStopRecordingDialog.ts@@ -8,7 +8,8 @@ import { IJitsiConference } from '../../../base/conference/reducer';import { JitsiRecordingConstants } from '../../../base/lib-jitsi-meet';import { setVideoMuted } from '../../../base/media/actions';import { setRequestingSubtitles } from '../../../subtitles/actions.any';-import { stopLocalVideoRecording } from '../../actions';+import { isRecorderTranscriptionsRunning } from '../../../transcribing/functions';+import { setStopRecordingIntent, stopLocalVideoRecording } from '../../actions';import { RECORDING_METADATA_ID } from '../../constants';import { getActiveSession } from '../../functions';import { ISessionData } from '../../reducer';@@ -46,6 +47,11 @@ export interface IProps extends WithTranslation {*/_subtitlesLanguage: string | null;+ /**+ * Whether a transcription session is running.+ */+ _transcriptionRunning: boolean;+/*** The redux dispatch function.*/@@ -93,10 +99,26 @@ export default class AbstractStopRecordingDialog<P extends IProps>_fileRecordingSession,_localRecording,_subtitlesLanguage,+ _transcriptionRunning,dispatch,localRecordingVideoStop} = this.props;+ // Pre-seed stopRecordingIntent from current running state so the+ // off-sound/notification coordinator (maybeNotifyRecordingStop) knows+ // what to wait for. Local recording has its own inline sound path and+ // does not flow through this coordinator.+ if (!_localRecording) {+ const recordingRunning = Boolean(_fileRecordingSession);++ if (recordingRunning || _transcriptionRunning) {+ dispatch(setStopRecordingIntent({+ recording: recordingRunning,+ transcription: _transcriptionRunning+ }));+ }+ }+if (_localRecording) {dispatch(stopLocalVideoRecording());if (localRecordingVideoStop) {@@ -112,6 +134,7 @@ export default class AbstractStopRecordingDialog<P extends IProps>setRequestingSubtitles(Boolean(_displaySubtitles), _displaySubtitles, _subtitlesLanguage, true));this.props._conference?.getMetadataHandler().setMetadata(RECORDING_METADATA_ID, {+ isRecordingRequested: false,isTranscribingEnabled: false});@@ -148,6 +171,7 @@ export function _mapStateToProps(state: IReduxState) {_fileRecordingSession:getActiveSession(state, JitsiRecordingConstants.mode.FILE),_localRecording: LocalRecordingManager.isRecordingLocally(),- _subtitlesLanguage+ _subtitlesLanguage,+ _transcriptionRunning: isRecorderTranscriptionsRunning(state)};}diff --git a/react/features/recording/middleware.ts b/react/features/recording/middleware.tsindex 060bde76e7..76c83d110d 100644--- a/react/features/recording/middleware.ts+++ b/react/features/recording/middleware.ts@@ -31,13 +31,15 @@ import {import { TRACK_ADDED } from '../base/tracks/actionTypes';import { hideNotification, showErrorNotification, showNotification } from '../notifications/actions';import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';-import { isRecorderTranscriptionsRunning } from '../transcribing/functions';+import { isRecorderTranscriptionsRunning, isTranscribing } from '../transcribing/functions';import { RECORDING_SESSION_UPDATED, START_LOCAL_RECORDING, STOP_LOCAL_RECORDING } from './actionTypes';import {clearRecordingSessions,hidePendingRecordingNotification,markConsentRequested,+ setStartRecordingIntent,+ setStopRecordingIntent,showPendingRecordingNotification,showRecordingError,showRecordingWarning,@@ -55,7 +57,9 @@ import {RECORDING_AND_TRANSCRIPTION_ON_SOUND_ID,RECORDING_OFF_SOUND_ID,RECORDING_ON_SOUND_ID,- START_RECORDING_NOTIFICATION_ID+ START_RECORDING_NOTIFICATION_ID,+ TRANSCRIPTION_OFF_SOUND_ID,+ TRANSCRIPTION_ON_SOUND_ID} from './constants';import {getResourceId,@@ -65,11 +69,211 @@ import {unregisterRecordingAudioFiles} from './functions';import logger from './logger';+import { ISessionData } from './reducer';/**- * Map to track which recording sessions have transcription enabled.+ * Evaluates whether all intended services (recording and/or transcription) have+ * resolved (succeeded or failed) and plays the appropriate start sound and notification.+ *+ * Intent source: {@code startRecordingIntent} — populated on the local side by the+ * start dialog / auto-start callback, and on remote observers by the metadata listener+ * when a false→true transition of isRecordingRequested / isTranscribingEnabled is seen.+ *+ * Resolution is derived from existing Redux state — no separate tracking needed.+ * The recording notification's "started by …" name is read directly from the active+ * FILE session in {@code sessionDatas}. When recording is on but the initiator has not+ * yet been delivered by jicofo, the function waits — keeping the intent alive.+ *+ * Called from:+ * - Recording middleware when RECORDING_SESSION_UPDATED arrives with the initiator+ * (jicofo update) or with an error.+ * - Transcription subscriber when isRecorderTranscriptionsRunning becomes true.+ * - Subtitles middleware when conference.dial() fails.+ * - Transcribing middleware when TRANSCRIBER_LEFT abruptly.+ * - Metadata change listener when room metadata updates.+ *+ * @param {Function} dispatch - Redux dispatch.+ * @param {Function} getState - Redux getState.+ * @returns {void}*/-const sessionsWithTranscription = new Map<string, boolean>();+export function maybeNotifyRecordingStart(dispatch: IStore['dispatch'], getState: IStore['getState']) {+ const state = getState();++ const intent = state['features/recording'].startRecordingIntent;++ const wantsRecording = Boolean(intent?.recording);+ const wantsTranscription = Boolean(intent?.transcription);++ // No intent — nothing to coordinate.+ if (!wantsRecording && !wantsTranscription) {+ return;+ }++ const { sessionDatas } = state['features/recording'];+ const { mode: modeConstants, status: statusConstants } = JitsiRecordingConstants;++ // Locate the active FILE recording session (if any) and derive its state.+ const fileSession = sessionDatas.find(sd => sd.mode === modeConstants.FILE+ && (sd.status === statusConstants.ON || sd.error));+ const recordingOn = fileSession?.status === statusConstants.ON;+ const recordingFailed = Boolean(fileSession?.error);+ const recordingResolved = !wantsRecording || recordingOn || recordingFailed;++ // Derive transcription resolution from existing state.+ const transcriptionOn = isRecorderTranscriptionsRunning(state) || isTranscribing(state);+ const transcriptionFailed = state['features/subtitles']._hasError;+ const transcriptionResolved = !wantsTranscription || transcriptionOn || transcriptionFailed;++ // Wait until all intended services have resolved.+ // Note: In theory (it should never happen here) wantsTranscription/wantsRecording might be false and in the same+ // time the transcriptionOn/recordingOn might be true. In this case we would play a notification no matter that+ // wantsTranscription/wantsRecording is false. This is better because the recording/transcription are on and the+ // user has to be informed. Also if this ever happens it will be noticeable and we will be able to debug/fix.+ if (!recordingResolved || !transcriptionResolved) {+ return;+ }++ // Recording is on but jicofo hasn't yet delivered the initiator. Wait for it+ // so the notification text reflects who started the recording.+ if (recordingOn && (!fileSession?.initiator || !fileSession.id)) {+ return;+ }++ // Clear the intent BEFORE dispatching below to avoid a re-entrancy double+ // fire — see the matching comment in maybeNotifyRecordingStop.+ if (intent) {+ dispatch(setStartRecordingIntent(null));+ }++ // Determine sound to play now that all intended services have resolved.+ let soundID: string | undefined;++ if (recordingOn && transcriptionOn) {+ soundID = RECORDING_AND_TRANSCRIPTION_ON_SOUND_ID;+ } else if (recordingOn) {+ soundID = RECORDING_ON_SOUND_ID;+ } else if (transcriptionOn) {+ soundID = TRANSCRIPTION_ON_SOUND_ID;+ }+ // If both failed — no start sound (error notifications handle it).++ if (soundID) {+ dispatch(playSound(soundID));+ }++ if (recordingOn && fileSession?.initiator && fileSession.id) {+ dispatch(showStartedRecordingNotification(+ modeConstants.FILE,+ fileSession.initiator,+ fileSession.id,+ recordingOn && transcriptionOn));+ } else if (transcriptionOn && !recordingOn) {+ // Transcription-only case (recording failed or wasn't requested).+ dispatch(showNotification({+ descriptionKey: 'transcribing.on',+ titleKey: 'dialog.recording'+ }, NOTIFICATION_TIMEOUT_TYPE.SHORT));+ }+}++/**+ * Evaluates whether all intended services (recording and/or transcription) that+ * are being stopped have resolved, and plays the appropriate off sound and+ * notification. Mirror of {@link maybeNotifyRecordingStart}.+ *+ * Intent source: {@code stopRecordingIntent} — populated on the local side by the+ * stop dialog, and on remote observers by the metadata listener when a true→false+ * transition of isRecordingRequested / isTranscribingEnabled is seen.+ *+ * Called from:+ * - Metadata change listener on true→false transitions.+ * - Recording middleware when RECORDING_SESSION_UPDATED arrives with OFF.+ * - Transcription subscriber when isRecorderTranscriptionsRunning becomes false.+ * - Transcribing middleware when TRANSCRIBER_LEFT abruptly.+ *+ * @param {Function} dispatch - Redux dispatch.+ * @param {Function} getState - Redux getState.+ * @returns {void}+ */+export function maybeNotifyRecordingStop(dispatch: IStore['dispatch'], getState: IStore['getState']) {+ const state = getState();+ const intent = state['features/recording'].stopRecordingIntent;++ if (!intent) {+ return;+ }++ const { sessionDatas } = state['features/recording'];+ const { mode: modeConstants, status: statusConstants } = JitsiRecordingConstants;++ // Recording resolves when there's no active/pending FILE session.+ const activeFileSession = sessionDatas.find(sd =>+ sd.mode === modeConstants.FILE+ && (sd.status === statusConstants.ON || sd.status === statusConstants.PENDING));+ const recordingResolved = !intent.recording || !activeFileSession;++ // Transcription resolves when the selector flips false.+ const transcriptionResolved = !intent.transcription || !isRecorderTranscriptionsRunning(state);++ if (!recordingResolved || !transcriptionResolved) {+ return;+ }++ // Determine sounds + notification.+ let onSoundID: string | undefined;+ let offSoundID: string | undefined;++ if (intent.recording && intent.transcription) {+ onSoundID = RECORDING_AND_TRANSCRIPTION_ON_SOUND_ID;+ offSoundID = RECORDING_AND_TRANSCRIPTION_OFF_SOUND_ID;+ } else if (intent.recording) {+ onSoundID = RECORDING_ON_SOUND_ID;+ offSoundID = RECORDING_OFF_SOUND_ID;+ } else if (intent.transcription) {+ onSoundID = TRANSCRIPTION_ON_SOUND_ID;+ offSoundID = TRANSCRIPTION_OFF_SOUND_ID;+ }++ // Clear the intent BEFORE dispatching below. Otherwise the first dispatch+ // re-enters StateListenerRegistry synchronously; the isRecorderTranscriptionsRunning+ // subscriber (in ../transcribing/subscriber) can fire in that nested walk+ // with an unresolved prevSel and call back into this function while intent+ // is still set — producing a duplicate notification. Reading intent into a+ // local const above keeps the branches below correct.+ dispatch(setStopRecordingIntent(null));++ if (offSoundID) {+ if (onSoundID) {+ dispatch(stopSound(onSoundID));+ }+ dispatch(playSound(offSoundID));+ }++ if (intent.recording) {+ // Pick the most recent FILE OFF session so the "stopped by …" name+ // reflects the current stop, not a stale earlier cycle left in+ // sessionDatas. sessionDatas is append-order, so the last match wins.+ let offSession: ISessionData | undefined;++ sessionDatas.forEach(sd => {+ if (sd.mode === modeConstants.FILE && sd.status === statusConstants.OFF) {+ offSession = sd;+ }+ });++ const participantName = offSession?.terminator+ ? getParticipantDisplayName(state, getResourceId(offSession.terminator))+ : undefined;++ dispatch(showStoppedRecordingNotification(+ modeConstants.FILE, participantName, intent.transcription));+ } else if (intent.transcription) {+ dispatch(showNotification({+ descriptionKey: 'transcribing.off',+ titleKey: 'dialog.recording'+ }, NOTIFICATION_TIMEOUT_TYPE.SHORT));+ }+}/*** StateListenerRegistry provides a reliable way to detect the leaving of a@@ -84,6 +288,52 @@ StateListenerRegistry.register(});+/**+ * Listen for metadata changes to coordinate start/stop sound on the remote side.+ * Detects false↔true transitions for {@code isRecordingRequested} and+ * {@code isTranscribingEnabled} and seeds the corresponding intent for remote+ * observers. Local initiators already have the intent set synchronously from+ * their dialog — the {@code if (!existing)} guard prevents clobbering.+ */+StateListenerRegistry.register(+ /* selector */ state => state['features/base/conference'].metadata?.recording,+ /* listener */ (recordingMetadata, { dispatch, getState }, previousValue) => {+ const prevRec = Boolean(previousValue?.isRecordingRequested);+ const prevTrans = Boolean(previousValue?.isTranscribingEnabled);+ const curRec = Boolean(recordingMetadata?.isRecordingRequested);+ const curTrans = Boolean(recordingMetadata?.isTranscribingEnabled);++ const recordingStarting = !prevRec && curRec;+ const transcriptionStarting = !prevTrans && curTrans;+ const recordingStopping = prevRec && !curRec;+ const transcriptionStopping = prevTrans && !curTrans;++ if (recordingStarting || transcriptionStarting) {+ const existing = getState()['features/recording'].startRecordingIntent;++ if (!existing) {+ dispatch(setStartRecordingIntent({+ recording: recordingStarting,+ transcription: transcriptionStarting+ }));+ }+ maybeNotifyRecordingStart(dispatch, getState);+ }++ if (recordingStopping || transcriptionStopping) {+ const existing = getState()['features/recording'].stopRecordingIntent;++ if (!existing) {+ dispatch(setStopRecordingIntent({+ recording: recordingStopping,+ transcription: transcriptionStopping+ }));+ }+ maybeNotifyRecordingStop(dispatch, getState);+ }+ }+);+/*** The redux middleware to handle the recorder updates in a React way.*@@ -239,7 +489,6 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {dispatch(hidePendingRecordingNotification(mode));if (updatedSessionData?.status === ON) {-// We receive 2 updates of the session status ON. The first one is from jibri when it joins.// The second one is from jicofo which will deliver the initiator value. Since the start// recording notification uses the initiator value we skip the jibri update and show the@@ -247,37 +496,19 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {// FIXME: simplify checks when the backend start sending only one status ON update containing// the initiator.if (initiator && !oldSessionData?.initiator) {- dispatch(showStartedRecordingNotification(mode, initiator, action.sessionData.id));+ // Initiator just became known — let maybeNotifyRecordingStart+ // decide whether to emit the notification now. It reads the+ // initiator directly from sessionDatas and gates on its presence.+ maybeNotifyRecordingStart(dispatch, getState);}if (oldSessionData?.status !== ON) {sendAnalytics(createRecordingEvent('start', mode));- let soundID;- const isTranscribing = isRecorderTranscriptionsRunning(state);- const isRequestingTranscription = state['features/subtitles']._requestingSubtitles;- const willTranscribe = isTranscribing || isRequestingTranscription;-- // Store whether transcription was enabled when recording started- if (mode === JitsiRecordingConstants.mode.FILE) {- const sessionId = action.sessionData.id;-- if (sessionId) {- sessionsWithTranscription.set(sessionId, willTranscribe);- }-- if (willTranscribe) {- soundID = RECORDING_AND_TRANSCRIPTION_ON_SOUND_ID;- } else {- soundID = RECORDING_ON_SOUND_ID;- }- } else if (mode === JitsiRecordingConstants.mode.STREAM) {- soundID = LIVE_STREAMING_ON_SOUND_ID;- }-- if (soundID) {- dispatch(playSound(soundID));+ if (mode === JitsiRecordingConstants.mode.STREAM) {+ dispatch(playSound(LIVE_STREAMING_ON_SOUND_ID));}+ // FILE: no call here — handled by the initiator branch above with maybeNotifyRecordingStart.if (typeof APP !== 'undefined') {APP.API.notifyRecordingStatusChanged(@@ -285,13 +516,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {}}} else if (updatedSessionData?.status === OFF && oldSessionData?.status !== OFF) {- const participantName = terminator- ? getParticipantDisplayName(state, getResourceId(terminator))- : undefined;-- dispatch(showStoppedRecordingNotification(mode, participantName));-- let duration = 0, soundOff, soundOn;+ let duration = 0;if (oldSessionData?.timestamp) {duration@@ -299,31 +524,19 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {}sendAnalytics(createRecordingEvent('stop', mode, duration));- // Check if transcription was enabled when the recording started- const sessionId = action.sessionData.id;- const wasWithTranscription = sessionId ? sessionsWithTranscription.get(sessionId) ?? false : false;-if (mode === JitsiRecordingConstants.mode.FILE) {- if (wasWithTranscription) {- soundOff = RECORDING_AND_TRANSCRIPTION_OFF_SOUND_ID;- soundOn = RECORDING_AND_TRANSCRIPTION_ON_SOUND_ID;- } else {- soundOff = RECORDING_OFF_SOUND_ID;- soundOn = RECORDING_ON_SOUND_ID;- }-- // Clean up the entry when recording stops- if (sessionId) {- sessionsWithTranscription.delete(sessionId);- }+ // Recording OFF is one of the resolution points — let the stop+ // coordinator decide which sound/notification to play based on+ // stopRecordingIntent (combined vs recording-only).+ maybeNotifyRecordingStop(dispatch, getState);} else if (mode === JitsiRecordingConstants.mode.STREAM) {- soundOff = LIVE_STREAMING_OFF_SOUND_ID;- soundOn = LIVE_STREAMING_ON_SOUND_ID;- }+ const participantName = terminator+ ? getParticipantDisplayName(state, getResourceId(terminator))+ : undefined;- if (soundOff && soundOn) {- dispatch(stopSound(soundOn));- dispatch(playSound(soundOff));+ dispatch(showStoppedRecordingNotification(mode, participantName, false));+ dispatch(stopSound(LIVE_STREAMING_ON_SOUND_ID));+ dispatch(playSound(LIVE_STREAMING_OFF_SOUND_ID));}if (typeof APP !== 'undefined') {@@ -435,6 +648,15 @@ function _showRecordingErrorNotification(session: any, dispatch: IStore['dispatcif (typeof APP !== 'undefined') {APP.API.notifyRecordingStatusChanged(false, mode, error, isRecorderTranscriptionsRunning(getState()));}++ // Recording failed — re-evaluate. maybeNotifyRecordingStart derives state from+ // sessionDatas (which now has the error) and will play transcription-only sound+ // if transcription succeeded.+ const intent = getState()['features/recording'].startRecordingIntent;++ if (intent) {+ maybeNotifyRecordingStart(dispatch, getState);+ }}/**diff --git a/react/features/recording/reducer.ts b/react/features/recording/reducer.tsindex 0e8244fd0b..8f24c6eb33 100644--- a/react/features/recording/reducer.ts+++ b/react/features/recording/reducer.ts@@ -7,7 +7,9 @@ import {SET_MEETING_HIGHLIGHT_BUTTON_STATE,SET_PENDING_RECORDING_NOTIFICATION_UID,SET_SELECTED_RECORDING_SERVICE,+ SET_START_RECORDING_INTENT,SET_START_RECORDING_NOTIFICATION_SHOWN,+ SET_STOP_RECORDING_INTENT,SET_STREAM_KEY} from './actionTypes';@@ -30,6 +32,25 @@ export interface ISessionData {timestamp?: number;}+/**+ * Tracks the user's intent when starting recording with or without transcription.+ * Set synchronously before any async operations begin to coordinate sound/notification timing.+ */+export interface IStartRecordingIntent {+ recording: boolean;+ transcription: boolean;+}++/**+ * Tracks what is being stopped (recording and/or transcription). Mirrors+ * IStartRecordingIntent. Used by maybeNotifyRecordingStop to coordinate the+ * off-sound/notification across the recording and transcription stop events.+ */+export interface IStopRecordingIntent {+ recording: boolean;+ transcription: boolean;+}+export interface IRecordingState {consentRequested: Set<any>;disableHighlightMeetingMoment: boolean;@@ -38,6 +59,8 @@ export interface IRecordingState {};selectedRecordingService: string;sessionDatas: Array<ISessionData>;+ startRecordingIntent?: IStartRecordingIntent | null;+ stopRecordingIntent?: IStopRecordingIntent | null;streamKey?: string;wasStartRecordingSuggested?: boolean;}@@ -65,7 +88,9 @@ ReducerRegistry.register<IRecordingState>(STORE_NAME,case CLEAR_RECORDING_SESSIONS:return {...state,- sessionDatas: []+ sessionDatas: [],+ startRecordingIntent: null,+ stopRecordingIntent: null};case MARK_CONSENT_REQUESTED:@@ -116,6 +141,18 @@ ReducerRegistry.register<IRecordingState>(STORE_NAME,disableHighlightMeetingMoment: action.disabled};+ case SET_START_RECORDING_INTENT:+ return {+ ...state,+ startRecordingIntent: action.intent+ };++ case SET_STOP_RECORDING_INTENT:+ return {+ ...state,+ stopRecordingIntent: action.intent+ };+case SET_START_RECORDING_NOTIFICATION_SHOWN:return {...state,diff --git a/react/features/subtitles/actions.any.ts b/react/features/subtitles/actions.any.tsindex 4f14d921e7..3d98a36632 100644--- a/react/features/subtitles/actions.any.ts+++ b/react/features/subtitles/actions.any.ts@@ -84,25 +84,36 @@ export function toggleRequestingSubtitles() {* @param {boolean} displaySubtitles - Whether to display subtitles or not.* @param {string} language - The language of the subtitles.* @param {boolean} forceBackendRecordingOn - Whether to force that backend recording is on.+ * @param {boolean} isRecordingRequested - Whether recording was also requested alongside transcription.+ * Passed through to metadata so remote clients receive both intent fields in a single atomic update.+ * @param {boolean} skipMetadataUpdate - When true, skips setting room metadata. Used when reacting+ * to a transcriber started by someone else (e.g. autoCaptionOnTranscribe) to avoid overwriting+ * the initiator's metadata.* @returns {{* type: SET_REQUESTING_SUBTITLES,* backendRecordingOn: boolean,* enabled: boolean,* displaySubtitles: boolean,- * language: string+ * isRecordingRequested: boolean,+ * language: string,+ * skipMetadataUpdate: boolean* }}*/export function setRequestingSubtitles(enabled: boolean,displaySubtitles = true,language: string | null = `translation-languages:${DEFAULT_LANGUAGE}`,- forceBackendRecordingOn: boolean = false) {+ forceBackendRecordingOn: boolean = false,+ isRecordingRequested: boolean = false,+ skipMetadataUpdate: boolean = false) {return {type: SET_REQUESTING_SUBTITLES,displaySubtitles,enabled,forceBackendRecordingOn,- language+ isRecordingRequested,+ language,+ skipMetadataUpdate};}diff --git a/react/features/subtitles/middleware.ts b/react/features/subtitles/middleware.tsindex 8235b88df7..58738a9e56 100644--- a/react/features/subtitles/middleware.ts+++ b/react/features/subtitles/middleware.ts@@ -9,6 +9,7 @@ import { TRANSCRIBER_ID } from '../base/participants/constants';import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';import { showErrorNotification } from '../notifications/actions';import { RECORDING_METADATA_ID } from '../recording/constants';+import { maybeNotifyRecordingStart } from '../recording/middleware';import { TRANSCRIBER_JOINED } from '../transcribing/actionTypes';import {@@ -92,13 +93,19 @@ MiddlewareRegistry.register(store => next => action => {const { transcription } = store.getState()['features/base/config'];if (transcription?.autoCaptionOnTranscribe) {- store.dispatch(setRequestingSubtitles(true));+ // The transcriber was started by someone else — skip metadata update+ // to avoid overwriting the initiator's isRecordingRequested flag.+ store.dispatch(setRequestingSubtitles(+ true, undefined, undefined, undefined, undefined, true));}break;}case SET_REQUESTING_SUBTITLES:- _requestingSubtitlesChange(store, action.enabled, action.language, action.forceBackendRecordingOn);+ _requestingSubtitlesChange(+ store, action.enabled, action.language,+ action.forceBackendRecordingOn, action.isRecordingRequested,+ action.skipMetadataUpdate);break;}@@ -346,6 +353,11 @@ function _getPrimaryLanguageCode(language: string) {* @param {string} language - The language to use for translation.* @param {boolean} forceBackendRecordingOn - Whether to force backend recording is on or not. This is used only when* we start recording, stopping is based on whether isTranscribingEnabled is already set.+ * @param {boolean} isRecordingRequested - Whether recording was also requested alongside transcription.+ * Passed through to metadata so remote clients receive both intent fields in a single atomic update.+ * @param {boolean} skipMetadataUpdate - When true, skips setting room metadata. Used when reacting+ * to a transcriber started by someone else (e.g. autoCaptionOnTranscribe) to avoid overwriting+ * the initiator's metadata.* @private* @returns {void}*/@@ -353,7 +365,9 @@ function _requestingSubtitlesChange({ dispatch, getState }: IStore,enabled: boolean,language?: string | null,- forceBackendRecordingOn: boolean = false) {+ forceBackendRecordingOn: boolean = false,+ isRecordingRequested: boolean = false,+ skipMetadataUpdate: boolean = false) {const state = getState();const { conference } = state['features/base/conference'];const backendRecordingOn = conference?.getMetadataHandler()?.getMetadata()?.asyncTranscription;@@ -377,12 +391,22 @@ function _requestingSubtitlesChange(titleKey: 'transcribing.failed'}));dispatch(setSubtitlesError(true));++ // Transcription failed — re-evaluate. _hasError is now true,+ // so maybeNotifyRecordingStart will see transcription as resolved-failed+ // and play recording-only sound if recording succeeded.+ const intent = getState()['features/recording'].startRecordingIntent;++ if (intent) {+ maybeNotifyRecordingStart(dispatch, getState);+ }});}- if (backendRecordingOn || forceBackendRecordingOn) {+ if (!skipMetadataUpdate && (backendRecordingOn || forceBackendRecordingOn)) {conference?.getMetadataHandler()?.setMetadata(RECORDING_METADATA_ID, {- isTranscribingEnabled: true+ isTranscribingEnabled: true,+ ...(isRecordingRequested && { isRecordingRequested: true })});}}@@ -396,6 +420,7 @@ function _requestingSubtitlesChange(if (!enabled && (backendRecordingOn || forceBackendRecordingOn)&& conference?.getMetadataHandler()?.getMetadata()[RECORDING_METADATA_ID]?.isTranscribingEnabled) {conference?.getMetadataHandler()?.setMetadata(RECORDING_METADATA_ID, {+ isRecordingRequested: false,isTranscribingEnabled: false});}diff --git a/react/features/transcribing/middleware.ts b/react/features/transcribing/middleware.tsindex a0ffe284b0..60cf3e5987 100644--- a/react/features/transcribing/middleware.ts+++ b/react/features/transcribing/middleware.ts@@ -1,5 +1,7 @@import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';import { showErrorNotification } from '../notifications/actions';+import { maybeNotifyRecordingStart, maybeNotifyRecordingStop } from '../recording/middleware';+import { setSubtitlesError } from '../subtitles/actions.any';import { TRANSCRIBER_LEFT } from './actionTypes';import './subscriber';@@ -10,16 +12,35 @@ import './subscriber';* @param {Store} store - The redux store.* @returns {Function}*/-MiddlewareRegistry.register(({ dispatch }) => next => action => {+MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {switch (action.type) {- case TRANSCRIBER_LEFT:+ case TRANSCRIBER_LEFT: {if (action.abruptly) {dispatch(showErrorNotification({titleKey: 'transcribing.failed'}));++ // TRANSCRIBER_LEFT resets subtitles state to default (_hasError: false).+ // If we're in the coordinated start flow, we need _hasError = true+ // so maybeNotifyRecordingStart sees transcription as resolved-failed.+ const startIntent = getState()['features/recording'].startRecordingIntent;++ if (startIntent) {+ dispatch(setSubtitlesError(true));+ maybeNotifyRecordingStart(dispatch, getState);+ }++ // If we're in the coordinated stop flow, the transcriber leaving is+ // the transcription resolution — re-evaluate.+ const stopIntent = getState()['features/recording'].stopRecordingIntent;++ if (stopIntent) {+ maybeNotifyRecordingStop(dispatch, getState);+ }}break;}+ }return next(action);});diff --git a/react/features/transcribing/subscriber.ts b/react/features/transcribing/subscriber.tsindex a1438ef490..d4b48809fe 100644--- a/react/features/transcribing/subscriber.ts+++ b/react/features/transcribing/subscriber.ts@@ -1,17 +1,8 @@-import { batch } from 'react-redux';-import { IStore } from '../app/types';import { JitsiRecordingConstants } from '../base/lib-jitsi-meet';import StateListenerRegistry from '../base/redux/StateListenerRegistry';-import { playSound } from '../base/sounds/actions';-import { showNotification } from '../notifications/actions';-import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';-import { INotificationProps } from '../notifications/types';-import {- TRANSCRIPTION_OFF_SOUND_ID,- TRANSCRIPTION_ON_SOUND_ID-} from '../recording/constants';import { isLiveStreamingRunning, isRecordingRunning } from '../recording/functions';+import { maybeNotifyRecordingStart, maybeNotifyRecordingStop } from '../recording/middleware';import { isRecorderTranscriptionsRunning, isTranscribing } from './functions';@@ -27,9 +18,11 @@ StateListenerRegistry.register(}if (isRecorderTranscriptionsRunningValue) {- maybeEmitRecordingNotification(dispatch, getState, true);+ // Coordinate the start sound/notification with any concurrent recording start.+ maybeNotifyRecordingStart(dispatch, getState);} else {- maybeEmitRecordingNotification(dispatch, getState, false);+ // Coordinate the stop sound/notification with any concurrent recording stop.+ maybeNotifyRecordingStop(dispatch, getState);}});@@ -49,38 +42,6 @@ StateListenerRegistry.register(});-/**- * Emit a recording started / stopped notification if the transcription started / stopped. Only- * if there is no recording in progress.- *- * @param {Dispatch} dispatch - The Redux dispatch function.- * @param {Function} getState - The Redux state.- * @param {boolean} on - Whether the transcription is on or not.- *- * @returns {void}- */-function maybeEmitRecordingNotification(dispatch: IStore['dispatch'], getState: IStore['getState'], on: boolean) {- const state = getState();- const { sessionDatas } = state['features/recording'];- const { mode: modeConstants, status: statusConstants } = JitsiRecordingConstants;-- if (sessionDatas.some(sd => sd.mode === modeConstants.FILE && sd.status === statusConstants.ON)) {- // If a recording is still ongoing, don't send any notification.- return;- }-- // Show transcription-specific notification when there's no recording- const notifyProps: INotificationProps = {- descriptionKey: on ? 'transcribing.on' : 'transcribing.off',- titleKey: 'dialog.recording'- };-- batch(() => {- dispatch(showNotification(notifyProps, NOTIFICATION_TIMEOUT_TYPE.SHORT));- dispatch(playSound(on ? TRANSCRIPTION_ON_SOUND_ID : TRANSCRIPTION_OFF_SOUND_ID));- });-}-/*** Notify external application (if API is enabled) that transcribing has started or stopped.*@@ -91,11 +52,24 @@ function maybeEmitRecordingNotification(dispatch: IStore['dispatch'], getState:function notifyTranscribingStatusChanged(getState: IStore['getState'], on: boolean) {if (typeof APP !== 'undefined') {const state = getState();+ const { sessionDatas } = state['features/recording'];+ const { mode: modeConstants, status: statusConstants } = JitsiRecordingConstants;const isRecording = isRecordingRunning(state);const isStreaming = isLiveStreamingRunning(state);- const mode = isRecording ? JitsiRecordingConstants.mode.FILE : JitsiRecordingConstants.mode.STREAM;- APP.API.notifyRecordingStatusChanged(isRecording || isStreaming, mode, undefined, on);+ // Only call notifyRecordingStatusChanged when there is no active FILE recording+ // session. During recording session transitions (ON/PENDING), the recording+ // middleware already reports the recording + transcription state accurately.+ // This avoids duplicate or contradictory API calls.+ const hasActiveFileSession = sessionDatas.some(sd => sd.mode === modeConstants.FILE+ && (sd.status === statusConstants.ON || sd.status === statusConstants.PENDING));++ if (!hasActiveFileSession) {+ const mode = isRecording ? modeConstants.FILE : modeConstants.STREAM;++ APP.API.notifyRecordingStatusChanged(isRecording || isStreaming, mode, undefined, on);+ }+APP.API.notifyTranscribingStatusChanged(on);}}diff --git a/resources/prosody-plugins/mod_filter_iq_rayo.lua b/resources/prosody-plugins/mod_filter_iq_rayo.luaindex 47318314d8..7b886cec73 100644--- a/resources/prosody-plugins/mod_filter_iq_rayo.lua+++ b/resources/prosody-plugins/mod_filter_iq_rayo.lua@@ -260,6 +260,7 @@ module:hook('jitsi-metadata-allow-moderation', function (event)and is_feature_allowed('transcription', session.jitsi_meet_context_features) thenlocal res = {};res.isTranscribingEnabled = data.isTranscribingEnabled;+ res.isRecordingRequested = data.isRecordingRequested;return res;elseif not session.jitsi_meet_context_features and occupant.role == 'moderator' thenreturn data;