Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

clippy

Richie McIlroyd03c38b52a3e
diff --git a/apps/cli/src/doctor.rs b/apps/cli/src/doctor.rs
index 6faa07de5..f821265ea 100644
--- a/apps/cli/src/doctor.rs
+++ b/apps/cli/src/doctor.rs
@@ -236,8 +236,11 @@ pub struct Check {
#[derive(Serialize, Clone, Copy)]
#[serde(rename_all = "camelCase")]
pub enum PermissionStatus {
+ #[cfg(target_os = "macos")]
Granted,
+ #[cfg(target_os = "macos")]
Denied,
+ #[cfg(target_os = "macos")]
NotDetermined,
Unknown,
}
@@ -317,6 +320,7 @@ fn avformat_version() -> String {
fn permission_check(permissions: &Permissions) -> Check {
match permissions.screen_recording {
+ #[cfg(target_os = "macos")]
PermissionStatus::Granted => Check {
id: CheckId::ScreenRecordingPermission,
status: CheckStatus::Ok,
@@ -330,6 +334,7 @@ fn permission_check(permissions: &Permissions) -> Check {
.clone()
.unwrap_or_else(|| "Screen recording permission status unknown".to_string()),
},
+ #[cfg(target_os = "macos")]
PermissionStatus::Denied | PermissionStatus::NotDetermined => Check {
id: CheckId::ScreenRecordingPermission,
status: CheckStatus::Warn,
@@ -371,6 +376,16 @@ fn install_check(install: &Result<cap_cli_install::CliInstallStatus, String>) ->
}
}
+fn capture_ready(permissions: &Permissions) -> bool {
+ match permissions.screen_recording {
+ #[cfg(target_os = "macos")]
+ PermissionStatus::Granted => true,
+ PermissionStatus::Unknown => true,
+ #[cfg(target_os = "macos")]
+ PermissionStatus::Denied | PermissionStatus::NotDetermined => false,
+ }
+}
+
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Doctor {
@@ -434,12 +449,7 @@ pub fn run_doctor(format: OutputFormat) -> Result<(), String> {
let ok = !checks
.iter()
.any(|check| matches!(check.status, CheckStatus::Fail));
- // On platforms with no runtime screen-capture permission gate (Windows) the status is
- // Unknown rather than Granted, yet capture can still start — treat that as ready.
- let capture_ready = matches!(
- permissions.screen_recording,
- PermissionStatus::Granted | PermissionStatus::Unknown
- );
+ let capture_ready = capture_ready(&permissions);
let doctor = Doctor {
schema_version: SCHEMA_VERSION,
diff --git a/apps/desktop/src-tauri/src/export.rs b/apps/desktop/src-tauri/src/export.rs
index 04db5cf1d..63cbeb1bf 100644
--- a/apps/desktop/src-tauri/src/export.rs
+++ b/apps/desktop/src-tauri/src/export.rs
@@ -178,6 +178,12 @@ impl ExportWorkerMode {
#[derive(Clone)]
struct ExportProgress(tauri::ipc::Channel<FramesRendered>);
+struct ExportSaveDialogRequest {
+ app: tauri::AppHandle,
+ file_name: String,
+ file_type: String,
+}
+
impl ExportProgress {
fn send(&self, progress: FramesRendered) -> bool {
self.0.send(progress).is_ok()
@@ -1028,9 +1034,8 @@ pub async fn export_video_with_id(
#[tauri::command]
#[specta::specta]
-#[instrument(skip(app, window, progress, editor))]
+#[instrument(skip(window, progress, editor))]
pub async fn export_video_to_file(
- app: tauri::AppHandle,
window: tauri::Window,
project_path: PathBuf,
progress: tauri::ipc::Channel<FramesRendered>,
@@ -1039,6 +1044,7 @@ pub async fn export_video_to_file(
file_type: String,
editor: OptionalWindowEditorInstance,
) -> Result<PathBuf, String> {
+ let app = window.app_handle().clone();
let window_label = window.label().to_string();
Box::pin(run_export_command(move || async move {
let cancellation_guard = ExportCancellationGuard::new(
@@ -1046,13 +1052,15 @@ pub async fn export_video_to_file(
Some(window_label),
);
export_video_to_file_inner(
- app,
project_path,
- progress,
settings,
- file_name,
- file_type,
editor,
+ ExportProgress(progress),
+ ExportSaveDialogRequest {
+ app,
+ file_name,
+ file_type,
+ },
cancellation_guard.token(),
)
.await
@@ -1061,30 +1069,27 @@ pub async fn export_video_to_file(
}
async fn export_video_to_file_inner(
- app: tauri::AppHandle,
project_path: PathBuf,
- progress: tauri::ipc::Channel<FramesRendered>,
settings: ExportSettings,
- file_name: String,
- file_type: String,
editor: OptionalWindowEditorInstance,
+ progress: ExportProgress,
+ save_dialog: ExportSaveDialogRequest,
cancel_token: CancellationToken,
) -> Result<PathBuf, String> {
let _session_guard = ExportSessionGuard::new();
+ let ExportSaveDialogRequest {
+ app,
+ file_name,
+ file_type,
+ } = save_dialog;
let Some(save_path) = show_export_save_dialog(&app, file_name, file_type).await? else {
return Err("Save dialog cancelled".to_string());
};
info!(path = %save_path.display(), "Export save path selected");
- let output_path = export_video_inner(
- project_path,
- settings,
- editor,
- ExportProgress(progress),
- cancel_token,
- )
- .await?;
+ let output_path =
+ export_video_inner(project_path, settings, editor, progress, cancel_token).await?;
copy_export_to_path(&output_path, &save_path).await?;
Ok(save_path)
}