Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 70 additions & 3 deletions apps/desktop/src-tauri/src/deeplink_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ pub enum DeepLinkAction {
mode: RecordingMode,
},
StopRecording,
PauseRecording,
ResumeRecording,
TogglePauseRecording,
SetMicrophone {
mic_label: Option<String>,
},
SetCamera {
camera: Option<DeviceOrModelID>,
},
OpenEditor {
project_path: PathBuf,
},
Expand Down Expand Up @@ -88,9 +97,10 @@ impl TryFrom<&Url> for DeepLinkAction {
.map_err(|_| ActionParseFromUrlError::Invalid);
}

match url.domain() {
Some(v) if v != "action" => Err(ActionParseFromUrlError::NotAction),
_ => Err(ActionParseFromUrlError::Invalid),
match url.host_str() {
Some("action") => Ok(()),
Some(_) => Err(ActionParseFromUrlError::NotAction),
None => Err(ActionParseFromUrlError::Invalid),
}?;

let params = url
Expand Down Expand Up @@ -147,6 +157,21 @@ impl DeepLinkAction {
DeepLinkAction::StopRecording => {
crate::recording::stop_recording(app.clone(), app.state()).await
}
DeepLinkAction::PauseRecording => {
crate::recording::pause_recording(app.clone(), app.state()).await
}
DeepLinkAction::ResumeRecording => {
crate::recording::resume_recording(app.clone(), app.state()).await
}
DeepLinkAction::TogglePauseRecording => {
crate::recording::toggle_pause_recording(app.clone(), app.state()).await
}
DeepLinkAction::SetMicrophone { mic_label } => {
crate::set_mic_input(app.state(), mic_label).await
}
DeepLinkAction::SetCamera { camera } => {
crate::set_camera_input(app.clone(), app.state(), camera, Some(true)).await
}
DeepLinkAction::OpenEditor { project_path } => {
crate::open_project_from_path(Path::new(&project_path), app.clone())
}
Expand All @@ -156,3 +181,45 @@ impl DeepLinkAction {
}
}
}

#[cfg(test)]
mod tests {
use super::{ActionParseFromUrlError, DeepLinkAction};
use tauri::Url;

#[test]
fn parses_action_host_from_custom_scheme() {
let url = Url::parse("cap-desktop://action?value=%7B%22stop_recording%22%3Anull%7D")
.expect("valid action deeplink");

let action = DeepLinkAction::try_from(&url).expect("action should parse");

assert!(matches!(action, DeepLinkAction::StopRecording));
}

#[test]
fn ignores_non_action_hosts() {
let url = Url::parse("cap-desktop://signin?token=test").expect("valid sign-in deeplink");

let result = DeepLinkAction::try_from(&url);

assert!(matches!(result, Err(ActionParseFromUrlError::NotAction)));
}

#[test]
fn parses_camera_switch_action() {
let url = Url::parse(
"cap-desktop://action?value=%7B%22set_camera%22%3A%7B%22camera%22%3A%7B%22DeviceID%22%3A%22camera-123%22%7D%7D%7D",
)
.expect("valid set camera deeplink");

let action = DeepLinkAction::try_from(&url).expect("camera action should parse");

assert!(matches!(
action,
DeepLinkAction::SetCamera {
camera: Some(_)
}
));
}
}
19 changes: 19 additions & 0 deletions apps/raycast/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Cap Raycast Extension

This extension drives the Cap desktop app through Cap deeplinks.

## Commands

- Start Recording: starts an instant or studio recording for a screen or window name.
- Stop Recording: stops the active recording.
- Pause Recording: pauses the active recording.
- Resume Recording: resumes the active recording.
- Toggle Recording Pause: toggles pause state for the active recording.
- Switch Microphone: switches Cap to an exact microphone label.
- Switch Camera: switches Cap using either a camera device id or model id.

## Notes

- Screen and window names must exactly match the names Cap sees from the OS.
- Camera switching expects the raw device id or model id already used by Cap.
- The extension sends `cap-desktop://action?...` deeplinks, so the Cap desktop app must already be installed.
Binary file added apps/raycast/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading