Repository navigation
Add support for videoRecordingStartMode - #193
zachm-vapi wants to merge 1 commit into
Conversation
mhar-vapi
left a comment
There was a problem hiding this comment.
looks good to me overall. please address the p2 timing gap below so a recording failure during join reaches the caller. ci is green, including all 86 tests and the sdk and example builds. the backend rollout and generated-type cleanup listed in the draft still need to happen before release.
| const parsedMessage = JSON.parse(e.data); | ||
| // Not a Vapi client message: re-emitted as recording-error, and kept | ||
| // out of 'message' because its consumers switch on `type`. | ||
| if (parsedMessage?.type === VIDEO_RECORDING_START_FAILED_MESSAGE_TYPE) { |
There was a problem hiding this comment.
[p2] please register the app-message listener before awaiting join in start(), as reconnect() already does. the server starts recording when it sees the user join, so its failure message can arrive while a slow client is still joining. start() currently attaches the listener afterward, dropping that message and never emitting recording-error. i reproduced this by delivering the failure during join: start() missed it, while reconnect() received it. please add that timing case to the tests.
Summary
Adds a
videoRecordingStartModeoption tovapi.start()so callers can choose who starts the video recording whenartifactPlan.videoRecordingEnabledis on:client(the server's default): the Daily meeting token starts the cloud recording from the client when the user joins. This is today's behavior.server: Vapi starts the recording from its servers once the user has joined, so a weak client connection can't stop it from starting.Tracks VAPICS-1747.
Changes
New
StartCallOptions.videoRecordingStartMode('client'|'server'), sent in the create-web-call body. When it isn't set it staysundefined, so older backends use the old client behavior instead of returning 400.Reads
transport.videoRecordingStartModefrom the web call in bothstart()andreconnect(). In server mode thevideo-recording-setupprogress event reportsaction: 'started-by-server'instead of'auto-started-via-meeting-token'.Server-side start failures are reported as
recording-error. Avideo-recording.start-failedDaily app message is turned into arecording-errorevent (Vapi couldn't start the recording (<outcome>): <error>) so clients can continue to watch the existing event.The SDK no longer starts recordings itself.⚠️ Before this change, if recording was enabled but the server sent no callToken, the SDK called
startRecording()from the client. Now it starts nothing:video-recording-setupreportsstatus: 'failed'withaction: 'no-meeting-token'.recording-erroris emitted afterstart()/reconnect()resolves. It fires in a later task, so listeners added right after the await still get it, and it is skipped if the call was stopped or replaced in the meantime.type: 'video-recording-setup-error'is no longer emitted.startRecording()themselves if desired.In practice, the manual start is equivalent to the token start since they are both initiated by the client immediately after joining. The token has always been present in production, so the manual start provides no value.
README: the Recording section now explains the two modes.
Example app: adds a "Recording Start Mode" selector (default / client / server), logs
recording-startedandrecording-error, and shows thecall-start-progressaction.Before merging (why this is a draft)
There are two
TODO(VAPICS-1747)comments invapi.tsto resolve once the backend change is deployed andapi.tsis regenerated from the prod spec:VideoRecordingStartModetype alias withCreateWebCallDTO['videoRecordingStartMode']CreateWebCallDTO & { videoRecordingStartMode?: ... }intersection oncreateWebCallBodyand use plainCreateWebCallDTO