Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Set new recording picker to default
Richie McIlroy833dce08d2a8
diff --git a/apps/desktop/src-tauri/src/general_settings.rs b/apps/desktop/src-tauri/src/general_settings.rsindex fbd618985..ae8800e43 100644--- a/apps/desktop/src-tauri/src/general_settings.rs+++ b/apps/desktop/src-tauri/src/general_settings.rs@@ -113,6 +113,8 @@ pub struct GeneralSettingsStore {)]pub enable_new_recording_flow: bool,#[serde(default)]+ pub recording_picker_preference_set: bool,+ #[serde(default)]pub post_deletion_behaviour: PostDeletionBehaviour,#[serde(default = "default_excluded_windows")]pub excluded_windows: Vec<WindowExclusion>,@@ -128,7 +130,7 @@ fn default_enable_native_camera_preview() -> bool {}fn default_enable_new_recording_flow() -> bool {- cfg!(debug_assertions)+ true}fn no(_: &bool) -> bool {@@ -180,6 +182,7 @@ impl Default for GeneralSettingsStore {enable_native_camera_preview: default_enable_native_camera_preview(),auto_zoom_on_clicks: false,enable_new_recording_flow: default_enable_new_recording_flow(),+ recording_picker_preference_set: false,post_deletion_behaviour: PostDeletionBehaviour::DoNothing,excluded_windows: default_excluded_windows(),delete_instant_recordings_after_upload: false,@@ -240,7 +243,7 @@ impl GeneralSettingsStore {pub fn init(app: &AppHandle) {println!("Initializing GeneralSettingsStore");- let store = match GeneralSettingsStore::get(app) {+ let mut store = match GeneralSettingsStore::get(app) {Ok(Some(store)) => store,Ok(None) => GeneralSettingsStore::default(),Err(e) => {@@ -249,6 +252,11 @@ pub fn init(app: &AppHandle) {}};+ if !store.recording_picker_preference_set {+ store.enable_new_recording_flow = true;+ store.recording_picker_preference_set = true;+ }+store.save(app).unwrap();println!("GeneralSettingsState managed");diff --git a/apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx b/apps/desktop/src/routes/(window-chrome)/settings/experimental.tsxindex 2e3573523..5c8e47264 100644--- a/apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx@@ -23,7 +23,7 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {autoCreateShareableLink: false,enableNotifications: true,enableNativeCameraPreview: false,- enableNewRecordingFlow: false,+ enableNewRecordingFlow: true,autoZoomOnClicks: false,custom_cursor_capture2: true,},@@ -83,19 +83,6 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {);}}/>- <ToggleSettingItem- label="New recording flow"- description="New and improved flow for starting a recording! You may need to restart the app for this to take effect."- value={!!settings.enableNewRecordingFlow}- onChange={(value) => {- handleChange("enableNewRecordingFlow", value);- // This is bad code, but I just want the UI to not jank and can't seem to find the issue.- setTimeout(- () => window.scrollTo({ top: 0, behavior: "instant" }),- 5,- );- }}- /></div></div></div>diff --git a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx b/apps/desktop/src/routes/(window-chrome)/settings/general.tsxindex 52cd6384b..08b484640 100644--- a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings/general.tsx@@ -69,7 +69,8 @@ const createDefaultGeneralSettings = (): ExtendedGeneralSettingsStore => ({autoCreateShareableLink: false,enableNotifications: true,enableNativeCameraPreview: false,- enableNewRecordingFlow: false,+ enableNewRecordingFlow: true,+ recordingPickerPreferenceSet: false,autoZoomOnClicks: false,custom_cursor_capture2: true,excludedWindows: [],@@ -202,15 +203,26 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {const handleChange = async <K extends keyof typeof settings>(key: K,value: (typeof settings)[K],+ extra?: Partial<GeneralSettingsStore>,) => {console.log(`Handling settings change for ${key}: ${value}`);setSettings(key as keyof GeneralSettingsStore, value);- generalSettingsStore.set({ [key]: value });+ generalSettingsStore.set({ [key]: value, ...(extra ?? {}) });};const ostype: OsType = type();const excludedWindows = createMemo(() => settings.excludedWindows ?? []);+ const recordingWindowVariant = () =>+ settings.enableNewRecordingFlow === false ? "old" : "new";++ const updateRecordingWindowVariant = (variant: "new" | "old") => {+ const shouldUseNew = variant === "new";+ if (settings.enableNewRecordingFlow === shouldUseNew) return;+ handleChange("enableNewRecordingFlow", shouldUseNew, {+ recordingPickerPreferenceSet: true,+ });+ };const matchesExclusion = (exclusion: WindowExclusion,@@ -424,6 +436,33 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {)}<SettingGroup title="Recording">+ <SettingItem+ label="Recording window"+ description="Choose which recording picker experience Cap should open."+ >+ <div class="flex gap-1 bg-gray-3 rounded-lg p-1 text-xs font-medium">+ {(+ [+ { id: "new", label: "New" },+ { id: "old", label: "Old" },+ ] as const+ ).map((option) => (+ <button+ type="button"+ class={cx("flex-1 rounded-md px-3 py-1.5 transition-colors", {+ "bg-gray-12 text-gray-1":+ recordingWindowVariant() === option.id,+ "text-gray-11 hover:text-gray-12":+ recordingWindowVariant() !== option.id,+ })}+ aria-pressed={recordingWindowVariant() === option.id}+ onClick={() => updateRecordingWindowVariant(option.id)}+ >+ {option.label}+ </button>+ ))}+ </div>+ </SettingItem><SelectSettingItemlabel="Instant mode max resolution"description="Choose the maximum resolution for Instant Mode recordings."diff --git a/apps/desktop/src/routes/target-select-overlay.tsx b/apps/desktop/src/routes/target-select-overlay.tsxindex 55b9cec22..a193a1691 100644--- a/apps/desktop/src/routes/target-select-overlay.tsx+++ b/apps/desktop/src/routes/target-select-overlay.tsx@@ -3,7 +3,7 @@ import { createEventListener } from "@solid-primitives/event-listener";import { createElementSize } from "@solid-primitives/resize-observer";import { createScheduled, debounce } from "@solid-primitives/scheduled";import { useSearchParams } from "@solidjs/router";-import { useQuery } from "@tanstack/solid-query";+import { createMutation, useQuery } from "@tanstack/solid-query";import { LogicalPosition } from "@tauri-apps/api/dpi";import { emit } from "@tauri-apps/api/event";import {@@ -34,14 +34,24 @@ import {} from "~/components/Cropper";import ModeSelect from "~/components/ModeSelect";import { authStore, generalSettingsStore } from "~/store";-import { createOptionsQuery, createOrganizationsQuery } from "~/utils/queries";import {+ createCameraMutation,+ createOptionsQuery,+ createOrganizationsQuery,+ listAudioDevices,+ listVideoDevices,+} from "~/utils/queries";+import {+ type CameraInfo,commands,+ type DeviceOrModelID,type DisplayId,events,type ScreenCaptureTarget,type TargetUnderCursor,} from "~/utils/tauri";+import CameraSelect from "./(window-chrome)/new-main/CameraSelect";+import MicrophoneSelect from "./(window-chrome)/new-main/MicrophoneSelect";import {RecordingOptionsProvider,useRecordingOptions,@@ -53,6 +63,15 @@ const capitalize = (str: string) => {return str.charAt(0).toUpperCase() + str.slice(1);};+const findCamera = (cameras: CameraInfo[], id?: DeviceOrModelID | null) => {+ if (!id) return undefined;+ return cameras.find((camera) =>+ "DeviceID" in id+ ? camera.device_id === id.DeviceID+ : camera.model_id === id.ModelID,+ );+};+export default function () {return (<RecordingOptionsProvider>@@ -153,22 +172,23 @@ function Inner() {data-over={targetUnderCursor.display_id === displayId()}class="relative w-screen h-screen flex flex-col items-center justify-center data-[over='true']:bg-blue-600/40 transition-colors">- <div class="absolute inset-0 bg-black/50 -z-10" />+ <div class="absolute inset-0 bg-black/70 -z-10" /><Show when={displayInformation.data} keyed>{(display) => (- <>- <span class="mb-2 text-3xl font-semibold text-white">+ <div class="flex flex-col items-center text-white">+ <IconCapMonitor class="size-20 mb-3" />+ <span class="mb-2 text-3xl font-semibold">{display.name || "Monitor"}</span><Show when={display.physical_size}>{(size) => (- <span class="mb-2 text-xs text-white">+ <span class="mb-2 text-xs">{`${size().width}x${size().height} · ${display.refresh_rate}FPS`}</span>)}</Show>- </>+ </div>)}</Show>@@ -202,7 +222,7 @@ function Inner() {{(windowUnderCursor) => (<divdata-over={targetUnderCursor.display_id === params.displayId}- class="relative w-screen h-screen bg-black/50"+ class="relative w-screen h-screen bg-black/70"><divclass="flex absolute flex-col justify-center items-center bg-blue-600/40"@@ -214,7 +234,7 @@ function Inner() {}}><div class="flex flex-col justify-center items-center text-white">- <div class="w-32 h-32">+ <div class="w-24 h-24"><Suspense><Show when={windowIcon.data}>{(icon) => (@@ -379,7 +399,7 @@ function Inner() {});return (- <div class="fixed w-screen h-screen">+ <div class="fixed w-screen h-screen bg-black/70"><divref={controlsEl}class="fixed z-50 transition-opacity"@@ -444,6 +464,27 @@ function RecordingControls(props: {const { setOptions, rawOptions } = useRecordingOptions();const generalSetings = generalSettingsStore.createQuery();+ const cameras = useQuery(() => listVideoDevices);+ const mics = useQuery(() => listAudioDevices);+ const setMicInput = createMutation(() => ({+ mutationFn: async (name: string | null) => {+ await commands.setMicInput(name);+ setOptions("micName", name);+ },+ }));+ const setCamera = createCameraMutation();++ const selectedCamera = createMemo(() => {+ if (!rawOptions.cameraID) return null;+ return findCamera(cameras.data ?? [], rawOptions.cameraID) ?? null;+ });++ const selectedMicName = createMemo(() => {+ if (!rawOptions.micName) return null;+ return (+ (mics.data ?? []).find((name) => name === rawOptions.micName) ?? null+ );+ });const menuModes = async () =>await Menu.new({@@ -510,63 +551,92 @@ function RecordingControls(props: {return (<>- <div class="flex gap-2.5 items-center p-2.5 my-2.5 rounded-xl border min-w-fit w-fit bg-gray-2 shadow-sm border-gray-4">- <div- onClick={() => {- setOptions("targetMode", null);- commands.closeTargetSelectOverlays();- }}- class="flex justify-center items-center rounded-full transition-opacity bg-gray-12 size-9 hover:opacity-80"- >- <IconCapX class="invert will-change-transform size-3 dark:invert-0" />- </div>- <div- data-inactive={rawOptions.mode === "instant" && !auth.data}- class="flex overflow-hidden flex-row h-11 rounded-full bg-blue-9 group"- onClick={() => {- if (rawOptions.mode === "instant" && !auth.data) {- emit("start-sign-in");- return;- }-- commands.startRecording({- capture_target: props.target,- mode: rawOptions.mode,- capture_system_audio: rawOptions.captureSystemAudio,- });- }}- >- <div class="flex items-center py-1 pl-4 transition-colors hover:bg-blue-10">- {rawOptions.mode === "studio" ? (- <IconCapFilmCut class="size-4" />- ) : (- <IconCapInstant class="size-4" />- )}- <div class="flex flex-col mr-2 ml-3">- <span class="text-sm font-medium text-white text-nowrap">- {rawOptions.mode === "instant" && !auth.data- ? "Sign In To Use"- : "Start Recording"}- </span>- <span class="text-xs flex items-center text-nowrap gap-1 transition-opacity duration-200 text-white font-light -mt-0.5 opacity-90">- {`${capitalize(rawOptions.mode)} Mode`}- </span>+ <div class="flex flex-col gap-2.5 items-stretch my-2.5 w-[22rem] max-w-[90vw]">+ <div class="p-3 rounded-2xl border border-white/30 dark:border-white/10 bg-white/70 dark:bg-gray-2/70 shadow-lg backdrop-blur-xl">+ <div class="flex gap-2.5 items-center">+ <div+ onClick={() => {+ setOptions("targetMode", null);+ commands.closeTargetSelectOverlays();+ }}+ class="flex justify-center items-center rounded-full transition-opacity bg-gray-12 size-9 hover:opacity-80"+ >+ <IconCapX class="invert will-change-transform size-3 dark:invert-0" />+ </div>+ <div+ data-inactive={rawOptions.mode === "instant" && !auth.data}+ class="flex flex-1 min-w-0 max-w-[15rem] overflow-hidden flex-row h-11 rounded-full text-white shadow-[0_8px_20px_rgba(32,85,255,0.35)] bg-gradient-to-r from-blue-10 via-blue-10 to-blue-11 group"+ onClick={() => {+ if (rawOptions.mode === "instant" && !auth.data) {+ emit("start-sign-in");+ return;+ }++ commands.startRecording({+ capture_target: props.target,+ mode: rawOptions.mode,+ capture_system_audio: rawOptions.captureSystemAudio,+ });+ }}+ >+ <div class="flex flex-1 items-center py-1 pl-4 transition-colors hover:bg-white/10 min-w-0">+ {rawOptions.mode === "studio" ? (+ <IconCapFilmCut class="size-4 flex-shrink-0" />+ ) : (+ <IconCapInstant class="size-4 flex-shrink-0" />+ )}+ <div class="flex flex-col mr-2 ml-3 min-w-0">+ <span class="text-[0.95rem] font-medium text-white text-nowrap">+ {rawOptions.mode === "instant" && !auth.data+ ? "Sign In To Use"+ : "Start Recording"}+ </span>+ <span class="text-[11px] flex items-center text-nowrap gap-1 transition-opacity duration-200 text-white/90 font-light -mt-0.5">+ {`${capitalize(rawOptions.mode)} Mode`}+ </span>+ </div>+ </div>+ <div+ class="pl-2.5 pr-3 py-1.5 flex items-center border-l border-white/20 bg-white/5 transition-colors group-hover:bg-white/10"+ onMouseDown={(e) => showMenu(menuModes(), e)}+ onClick={(e) => showMenu(menuModes(), e)}+ >+ <IconCapCaretDown class="pointer-events-none" />+ </div>+ </div>+ <div+ class="flex justify-center items-center rounded-full border transition-opacity bg-gray-6 text-gray-12 size-9 hover:opacity-80"+ onMouseDown={(e) => showMenu(preRecordingMenu(), e)}+ onClick={(e) => showMenu(preRecordingMenu(), e)}+ >+ <IconCapGear class="pointer-events-none will-change-transform size-5" /></div>- </div>- <div- class="pl-2.5 group-hover:bg-blue-10 transition-colors pr-3 py-1.5 flex items-center"- onMouseDown={(e) => showMenu(menuModes(), e)}- onClick={(e) => showMenu(menuModes(), e)}- >- <IconCapCaretDown class="pointer-events-none focus:rotate-90" /></div></div>- <div- class="flex justify-center items-center rounded-full border transition-opacity bg-gray-6 text-gray-12 size-9 hover:opacity-80"- onMouseDown={(e) => showMenu(preRecordingMenu(), e)}- onClick={(e) => showMenu(preRecordingMenu(), e)}- >- <IconCapGear class="pointer-events-none will-change-transform size-5" />+ <div class="p-3 rounded-2xl border border-white/30 dark:border-white/10 bg-white/70 dark:bg-gray-2/70 shadow-lg backdrop-blur-xl">+ <div class="grid grid-cols-2 gap-2 w-full">+ <CameraSelect+ disabled={cameras.isPending}+ options={cameras.data ?? []}+ value={selectedCamera() ?? null}+ onChange={(camera) => {+ if (!camera) setCamera.mutate(null);+ else if (camera.model_id)+ setCamera.mutate({ ModelID: camera.model_id });+ else setCamera.mutate({ DeviceID: camera.device_id });+ }}+ />+ <MicrophoneSelect+ disabled={mics.isPending}+ options={mics.isPending ? [] : (mics.data ?? [])}+ value={+ mics.isPending+ ? (rawOptions.micName ?? null)+ : selectedMicName()+ }+ onChange={(value) => setMicInput.mutate(value)}+ />+ </div></div></div><div class="flex justify-center items-center w-full">diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex 55e2434a1..57ce4676f 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -402,7 +402,7 @@ export type ExportSettings = ({ format: "Mp4" } & Mp4ExportSettings) | ({ formatexport type FileType = "recording" | "screenshot"export type Flags = { captions: boolean }export type FramesRendered = { renderedCount: number; totalFrames: number; type: "FramesRendered" }-export type GeneralSettingsStore = { instanceId?: string; uploadIndividualFiles?: boolean; hideDockIcon?: boolean; autoCreateShareableLink?: boolean; enableNotifications?: boolean; disableAutoOpenLinks?: boolean; hasCompletedStartup?: boolean; theme?: AppTheme; commercialLicense?: CommercialLicense | null; lastVersion?: string | null; windowTransparency?: boolean; postStudioRecordingBehaviour?: PostStudioRecordingBehaviour; mainWindowRecordingStartBehaviour?: MainWindowRecordingStartBehaviour; custom_cursor_capture2?: boolean; serverUrl?: string; recordingCountdown?: number | null; enableNativeCameraPreview: boolean; autoZoomOnClicks?: boolean; enableNewRecordingFlow: boolean; postDeletionBehaviour?: PostDeletionBehaviour; excludedWindows?: WindowExclusion[]; deleteInstantRecordingsAfterUpload?: boolean; instantModeMaxResolution?: number }+export type GeneralSettingsStore = { instanceId?: string; uploadIndividualFiles?: boolean; hideDockIcon?: boolean; autoCreateShareableLink?: boolean; enableNotifications?: boolean; disableAutoOpenLinks?: boolean; hasCompletedStartup?: boolean; theme?: AppTheme; commercialLicense?: CommercialLicense | null; lastVersion?: string | null; windowTransparency?: boolean; postStudioRecordingBehaviour?: PostStudioRecordingBehaviour; mainWindowRecordingStartBehaviour?: MainWindowRecordingStartBehaviour; custom_cursor_capture2?: boolean; serverUrl?: string; recordingCountdown?: number | null; enableNativeCameraPreview: boolean; autoZoomOnClicks?: boolean; enableNewRecordingFlow: boolean; recordingPickerPreferenceSet?: boolean; postDeletionBehaviour?: PostDeletionBehaviour; excludedWindows?: WindowExclusion[]; deleteInstantRecordingsAfterUpload?: boolean; instantModeMaxResolution?: number }export type GifExportSettings = { fps: number; resolution_base: XY<number>; quality: GifQuality | null }export type GifQuality = {/**diff --git a/packages/ui-solid/icons/monitor.svg b/packages/ui-solid/icons/monitor.svgnew file mode 100644index 000000000..3687f88b1--- /dev/null+++ b/packages/ui-solid/icons/monitor.svg@@ -0,0 +1,45 @@+<svg width="125" height="84" viewBox="0 0 125 84" fill="none" xmlns="http://www.w3.org/2000/svg">+<rect width="125" height="84" rx="20" fill="url(#paint0_linear_735_1927)"/>+<g filter="url(#filter0_iii_735_1927)">+<rect x="3.7207" y="3.6842" width="117.56" height="76.6316" rx="20" fill="#242424"/>+</g>+<rect x="4.7207" y="4.6842" width="115.56" height="74.6316" rx="19" stroke="url(#paint1_linear_735_1927)" stroke-width="2"/>+<defs>+<filter id="filter0_iii_735_1927" x="3.7207" y="-4.3158" width="117.56" height="84.6316" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">+<feFlood flood-opacity="0" result="BackgroundImageFix"/>+<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>+<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>+<feOffset dy="-8"/>+<feGaussianBlur stdDeviation="6"/>+<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>+<feColorMatrix type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.15 0"/>+<feBlend mode="normal" in2="shape" result="effect1_innerShadow_735_1927"/>+<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>+<feMorphology radius="3" operator="erode" in="SourceAlpha" result="effect2_innerShadow_735_1927"/>+<feOffset/>+<feGaussianBlur stdDeviation="2.8"/>+<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>+<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>+<feBlend mode="normal" in2="effect1_innerShadow_735_1927" result="effect2_innerShadow_735_1927"/>+<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>+<feOffset dy="-6"/>+<feGaussianBlur stdDeviation="2.95"/>+<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>+<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>+<feBlend mode="normal" in2="effect2_innerShadow_735_1927" result="effect3_innerShadow_735_1927"/>+</filter>+<linearGradient id="paint0_linear_735_1927" x1="15.5" y1="6.5" x2="119.5" y2="77.5" gradientUnits="userSpaceOnUse">+<stop stop-color="#5F5F5F"/>+<stop offset="0.287795" stop-color="#BFBFBF"/>+<stop offset="0.42905" stop-color="white"/>+<stop offset="1" stop-color="#4A4A4A"/>+</linearGradient>+<linearGradient id="paint1_linear_735_1927" x1="10.5" y1="9.5" x2="110.5" y2="72.5" gradientUnits="userSpaceOnUse">+<stop stop-color="#4B4B4B"/>+<stop offset="0.226088" stop-color="#818181"/>+<stop offset="0.406072" stop-color="white"/>+<stop offset="0.708835" stop-color="#585858"/>+<stop offset="1" stop-color="#666666"/>+</linearGradient>+</defs>+</svg>\ No newline at end of filediff --git a/packages/ui-solid/src/auto-imports.d.ts b/packages/ui-solid/src/auto-imports.d.tsindex 9770d9c34..a1d920379 100644--- a/packages/ui-solid/src/auto-imports.d.ts+++ b/packages/ui-solid/src/auto-imports.d.ts@@ -46,6 +46,7 @@ declare global {const IconCapLogoFullDark: typeof import('~icons/cap/logo-full-dark.jsx')['default']const IconCapMessageBubble: typeof import('~icons/cap/message-bubble.jsx')['default']const IconCapMicrophone: typeof import('~icons/cap/microphone.jsx')['default']+ const IconCapMonitor: typeof import('~icons/cap/monitor.jsx')['default']const IconCapMoreVertical: typeof import('~icons/cap/more-vertical.jsx')['default']const IconCapMoveLeft: typeof import("~icons/cap/move-left.jsx")["default"]const IconCapMoveRight: typeof import("~icons/cap/move-right.jsx")["default"]