Skip to content

Commit 778bf8f

Browse files
committed
Enable restart on error and improve file extension handling
1 parent 20c2c78 commit 778bf8f

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

apps/web/app/(org)/dashboard/caps/components/web-recorder-dialog/InProgressRecordingBar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,11 @@ export const InProgressRecordingBar = ({
290290
</span>
291291
)}
292292
</div>
293-
{Boolean(onRestart) && canRestart && (
293+
{Boolean(onRestart) && (canRestart || phase === "error") && (
294294
<ActionButton
295295
data-no-drag
296296
onClick={handleRestart}
297-
disabled={!canRestart}
297+
disabled={!(canRestart || phase === "error")}
298298
aria-label="Restart recording"
299299
aria-busy={isRestarting}
300300
>

apps/web/app/(org)/dashboard/caps/components/web-recorder-dialog/useWebRecorder.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ const unwrapExitOrThrow = <T, E>(exit: Exit.Exit<T, E>) => {
7676
return exit.value;
7777
};
7878

79+
const getFileExtensionFromMime = (mime?: string | null) => {
80+
if (!mime) return "mp4";
81+
const [, subtypeWithParams] = mime.split("/");
82+
if (!subtypeWithParams) return "mp4";
83+
const [subtypeWithSuffix] = subtypeWithParams.split(";");
84+
if (!subtypeWithSuffix) return "mp4";
85+
const [subtype] = subtypeWithSuffix.split("+");
86+
const normalized = subtype.trim().toLowerCase();
87+
return normalized || "mp4";
88+
};
89+
7990
export const useWebRecorder = ({
8091
organisationId,
8192
selectedMicId,
@@ -218,11 +229,12 @@ export const useWebRecorder = ({
218229
}
219230

220231
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
232+
const extension = getFileExtensionFromMime(blob.type);
221233
const url = URL.createObjectURL(blob);
222234
errorDownloadUrlRef.current = url;
223235
setErrorDownload({
224236
url,
225-
fileName: `cap-recording-${timestamp}.mp4`,
237+
fileName: `cap-recording-${timestamp}.${extension}`,
226238
});
227239
}, []);
228240

0 commit comments

Comments
 (0)