-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: implement cap deep links and raycast extension #1564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| } | ||
|
|
||
| if url.scheme() == "cap" { | ||
| return match url.domain() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Url::domain() is meant for hostnames; for a custom scheme like cap://record host_str() is a better fit and avoids odd edge-cases. Also fixes the current indentation.
| return match url.domain() { | |
| if url.scheme() == "cap" { | |
| return match url.host_str() { | |
| Some("record") => Ok(Self::StartDefaultRecording), | |
| Some("stop") => Ok(Self::StopRecording), | |
| Some("pause") => Ok(Self::PauseRecording), | |
| Some("resume") => Ok(Self::ResumeRecording), | |
| _ => Err(ActionParseFromUrlError::Invalid), | |
| }; | |
| } |
| let displays = cap_recording::screen_capture::list_displays(); | ||
|
|
||
| if let Some((display, _)) = displays.into_iter().next() { | ||
| let capture_target = ScreenCaptureTarget::Display { id: display.id }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaulting to the first display + capture_system_audio: true + RecordingMode::Studio feels a bit opinionated for a deep link. If this is meant for Raycast “quick record”, might be worth pulling defaults from settings (or prompting) to avoid surprising behavior on multi-monitor setups.
| if let Some(recording) = state_read.current_recording() { | ||
| recording.pause().await.map_err(|e| e.to_string())?; | ||
| crate::recording::RecordingEvent::Paused.emit(app).ok(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emit(app).ok() will trip unused_must_use = deny (since .ok() returns a #[must_use] Option). Also note this awaits while holding state.read(); if that lock is contended, consider exposing a cloneable handle to avoid awaiting under the lock.
| } | |
| recording.pause().await.map_err(|e| e.to_string())?; | |
| let _ = crate::recording::RecordingEvent::Paused.emit(app); |
| if let Some(recording) = state_read.current_recording() { | ||
| recording.resume().await.map_err(|e| e.to_string())?; | ||
| crate::recording::RecordingEvent::Resumed.emit(app).ok(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same emit(app).ok() issue here (unused #[must_use]).
| } | |
| recording.resume().await.map_err(|e| e.to_string())?; | |
| let _ = crate::recording::RecordingEvent::Resumed.emit(app); |
| await showHUD("Starting Cap recording..."); | ||
| } catch (error) { | ||
| await showHUD("Failed to open Cap"); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swallowing the actual open() failure makes debugging harder; showing the error string (or at least “is Cap installed?”) would help. Also these 4 command files are identical aside from the URL/message—might be worth a shared helper.
| } | |
| } catch (error) { | |
| await showHUD(`Failed to open Cap: ${String(error)}`); | |
| } |
Greptile Overview
Greptile Summary
This PR implements Cap deep link support and a Raycast extension for controlling recordings via keyboard shortcuts. The implementation adds a new
cap://URL scheme that enables external applications to control Cap's recording functionality.Key changes:
StartDefaultRecording,PauseRecording,ResumeRecording, andStopRecordingtodeeplink_actions.rscap://URL scheme in Tauri configuration alongside the existingcap-desktop://schemecap://scheme first before falling back to the existing action-based parsingRecordingEvent::PausedandRecordingEvent::Resumedevents to update the UIImplementation quality:
The Rust implementation follows repository conventions with proper error handling and async patterns. The pause/resume handlers correctly access the current recording state and emit the appropriate events. The
StartDefaultRecordingaction provides a sensible default (first display, Studio mode, system audio enabled) for quick recording starts.Confidence Score: 5/5
Important Files Changed
cap://URL scheme alongside existingcap-desktop://scheme for deep linkscap://recorddeep link to trigger default recording startcap://stopdeep link to stop active recordingcap://pausedeep link to pause active recordingcap://resumedeep link to resume paused recordingSequence Diagram
sequenceDiagram participant Raycast as Raycast Extension participant OS as Operating System participant Tauri as Tauri Deep Link Handler participant Parser as DeepLinkAction Parser participant App as Cap Desktop App participant Recording as Recording Module participant Frontend as Desktop Frontend Raycast->>OS: open("cap://record") OS->>Tauri: Route cap:// URL Tauri->>Parser: Parse URL to DeepLinkAction Parser->>Parser: Match domain (record/stop/pause/resume) Parser-->>Tauri: Return DeepLinkAction variant Tauri->>App: execute(StartDefaultRecording) App->>Recording: list_displays() Recording-->>App: Display list App->>App: Select first display App->>Recording: start_recording(inputs) Recording-->>App: Recording started Note over Raycast,Frontend: Pause Flow Raycast->>OS: open("cap://pause") OS->>Tauri: Route cap:// URL Tauri->>Parser: Parse URL Parser-->>Tauri: DeepLinkAction::PauseRecording Tauri->>App: execute(PauseRecording) App->>Recording: recording.pause() Recording-->>App: Ok() App->>Frontend: RecordingEvent::Paused.emit() Note over Raycast,Frontend: Resume Flow Raycast->>OS: open("cap://resume") OS->>Tauri: Route cap:// URL Tauri->>Parser: Parse URL Parser-->>Tauri: DeepLinkAction::ResumeRecording Tauri->>App: execute(ResumeRecording) App->>Recording: recording.resume() Recording-->>App: Ok() App->>Frontend: RecordingEvent::Resumed.emit() Note over Raycast,Frontend: Stop Flow Raycast->>OS: open("cap://stop") OS->>Tauri: Route cap:// URL Tauri->>Parser: Parse URL Parser-->>Tauri: DeepLinkAction::StopRecording Tauri->>App: execute(StopRecording) App->>Recording: stop_recording() Recording-->>App: Recording stopped(2/5) Greptile learns from your feedback when you react with thumbs up/down!
Bounty Claim
/claim #1540
Walkthrough
I have implemented the deep link support and Raycast extension as requested.