Skip to content

feat: add deep-link support and Raycast extension#1708

Open
Angelebeats wants to merge 1 commit intoCapSoftware:mainfrom
Angelebeats:main
Open

feat: add deep-link support and Raycast extension#1708
Angelebeats wants to merge 1 commit intoCapSoftware:mainfrom
Angelebeats:main

Conversation

@Angelebeats
Copy link
Copy Markdown

@Angelebeats Angelebeats commented Apr 2, 2026

This PR adds deep-link support to Cap (cap://record, cap://stop, cap://pause) and includes a dedicated Raycast extension for remote control.

Greptile Summary

This PR adds three new deep-link actions (StartDefaultRecording, PauseRecording, ResumeRecording) and a new cap:// URL scheme to complement the existing cap-desktop:// scheme, enabling Raycast and other external tools to remotely control Cap's recording lifecycle via cap://record, cap://stop, cap://pause, and cap://resume.

Key issues found:

  • P0 – Wrong event payload in StartDefaultRecording: app.emit("request-open-recording-picker", ()) emits a JSON null payload, but the RequestOpenRecordingPicker tauri_specta struct expects { "target_mode": null }. Every other call site in hotkeys.rs correctly uses RequestOpenRecordingPicker { target_mode: None }.emit(&app). This mismatch will cause the frontend event listener to receive an unexpected payload, likely causing cap://record to silently do nothing.
  • P2 – Generic cap:// scheme expands the attack surface: Registering the short, guessable cap scheme system-wide means any local application or browser link (e.g., a <a href="cap://record"> on a web page) can invisibly trigger screen recording. The existing cap-desktop://action?value=... format was harder to exploit accidentally; the new URLs remove that friction.

Confidence Score: 2/5

  • Not safe to merge — the cap://record action will silently fail due to a payload type mismatch in the emitted event.
  • The StartDefaultRecording handler emits the request-open-recording-picker event with a () (unit/null) payload instead of the typed RequestOpenRecordingPicker { target_mode: None } struct used everywhere else in the codebase. This payload mismatch means the primary advertised feature (cap://record opening the recording picker) will not function correctly. The fix is straightforward but the bug must be resolved before merging.
  • apps/desktop/src-tauri/src/deeplink_actions.rs — specifically the StartDefaultRecording arm in the execute match.

Important Files Changed

Filename Overview
apps/desktop/src-tauri/src/deeplink_actions.rs Adds StartDefaultRecording, PauseRecording, and ResumeRecording variants and a cap:// URL parsing branch; contains a P0 event payload bug — app.emit("request-open-recording-picker", ()) emits null instead of the expected { target_mode: null }, causing frontend deserialization failure. Also bypasses the typed tauri_specta event system used everywhere else in the codebase.
apps/desktop/src-tauri/tauri.conf.json Adds "cap" alongside "cap-desktop" in the deep-link scheme registration; mechanically correct but introduces a short, guessable system-wide scheme.

Sequence Diagram

sequenceDiagram
    participant Raycast as Raycast or Browser
    participant OS as OS Deep-Link Router
    participant Tauri as Tauri Plugin
    participant Handler as deeplink_actions
    participant Recording as recording module
    participant Frontend as Frontend Webview

    Raycast->>OS: "open cap://record"
    OS->>Tauri: "cap scheme triggered"
    Tauri->>Handler: "urls: [cap://record]"
    Handler->>Handler: "parse: scheme==cap, host==record"
    Handler->>Handler: "Ok(StartDefaultRecording)"
    Handler->>Frontend: "app.emit(request-open-recording-picker, null) ⚠️"
    Note over Frontend: "Expected payload: {target_mode:null}, got: null"

    Raycast->>OS: "open cap://stop"
    OS->>Tauri: "cap scheme triggered"
    Tauri->>Handler: "urls: [cap://stop]"
    Handler->>Handler: "Ok(StopRecording)"
    Handler->>Recording: "stop_recording(app, state)"

    Raycast->>OS: "open cap://pause"
    OS->>Tauri: "cap scheme triggered"
    Tauri->>Handler: "urls: [cap://pause]"
    Handler->>Handler: "Ok(PauseRecording)"
    Handler->>Recording: "pause_recording(app, state)"

    Raycast->>OS: "open cap://resume"
    OS->>Tauri: "cap scheme triggered"
    Tauri->>Handler: "urls: [cap://resume]"
    Handler->>Handler: "Ok(ResumeRecording)"
    Handler->>Recording: "resume_recording(app, state)"
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: apps/desktop/src-tauri/src/deeplink_actions.rs
Line: 169-171

Comment:
**Wrong event payload causes frontend deserialization failure**

`app.emit("request-open-recording-picker", ())` sends a JSON `null` payload, but the `RequestOpenRecordingPicker` struct has a `target_mode: Option<RecordingTargetMode>` field. The auto-generated frontend type expects `{ target_mode: null }`, not `null`. This payload mismatch will likely cause the event to silently fail or be ignored by the frontend listener.

All other call sites in `hotkeys.rs` correctly use the typed `tauri_specta` event. Use the same pattern here:

```suggestion
            DeepLinkAction::StartDefaultRecording => {
                RequestOpenRecordingPicker { target_mode: None }.emit(app).map_err(|e| e.to_string())
            }
```

You'll also need to import `RequestOpenRecordingPicker` at the top of the file (or reference it as `crate::RequestOpenRecordingPicker`).

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: apps/desktop/src-tauri/src/deeplink_actions.rs
Line: 94-102

Comment:
**Security: generic `cap://` scheme is accessible by any app or web page**

Registering `cap` as a system-wide URL scheme means any application — including browsers that silently follow `cap://` links in web pages — can trigger `cap://record`, `cap://stop`, `cap://pause`, and `cap://resume` without user confirmation. A malicious web page could embed `<a href="cap://record">` or automatically redirect to it, invisibly starting a screen capture session.

The existing `cap-desktop://action?value=...` scheme has the same surface area, but its JSON-in-query-string format is significantly harder to invoke accidentally or from a web page. The new `cap://` URLs reduce the exploit complexity to a single, guessable link.

Consider requiring explicit user-facing confirmation (e.g., showing a toast/alert before acting), or at minimum documenting this behavior so users are aware that any local app can control their recording session via these URLs.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "feat: implement cap:// deep-link protoco..." | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.

.map_err(|_| ActionParseFromUrlError::Invalid);
}

if url.scheme() == "cap" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Host matching is currently case-sensitive, so cap://Stop etc would be rejected. Might be worth using eq_ignore_ascii_case here for resilience.

Suggested change
if url.scheme() == "cap" {
if url.scheme() == "cap" {
return match url.host_str() {
Some(host) if host.eq_ignore_ascii_case("record") => Ok(Self::StartDefaultRecording),
Some(host) if host.eq_ignore_ascii_case("stop") => Ok(Self::StopRecording),
Some(host) if host.eq_ignore_ascii_case("pause") => Ok(Self::PauseRecording),
Some(host) if host.eq_ignore_ascii_case("resume") => Ok(Self::ResumeRecording),
_ => Err(ActionParseFromUrlError::Invalid),
};
}

crate::show_window(app.clone(), ShowCapWindow::Settings { page }).await
}
DeepLinkAction::StartDefaultRecording => {
app.emit("request-open-recording-picker", ()).map_err(|e| e.to_string())
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StartDefaultRecording currently emits a stringly-typed event and (from the name) reads like it should start immediately. If the intent is to open the picker, using the existing typed event keeps emit patterns consistent.

Suggested change
app.emit("request-open-recording-picker", ()).map_err(|e| e.to_string())
DeepLinkAction::StartDefaultRecording => {
crate::RequestOpenRecordingPicker { target_mode: None }
.emit(app)
.map_err(|e| e.to_string())
}

Comment on lines +169 to +171
DeepLinkAction::StartDefaultRecording => {
app.emit("request-open-recording-picker", ()).map_err(|e| e.to_string())
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Wrong event payload causes frontend deserialization failure

app.emit("request-open-recording-picker", ()) sends a JSON null payload, but the RequestOpenRecordingPicker struct has a target_mode: Option<RecordingTargetMode> field. The auto-generated frontend type expects { target_mode: null }, not null. This payload mismatch will likely cause the event to silently fail or be ignored by the frontend listener.

All other call sites in hotkeys.rs correctly use the typed tauri_specta event. Use the same pattern here:

Suggested change
DeepLinkAction::StartDefaultRecording => {
app.emit("request-open-recording-picker", ()).map_err(|e| e.to_string())
}
DeepLinkAction::StartDefaultRecording => {
RequestOpenRecordingPicker { target_mode: None }.emit(app).map_err(|e| e.to_string())
}

You'll also need to import RequestOpenRecordingPicker at the top of the file (or reference it as crate::RequestOpenRecordingPicker).

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src-tauri/src/deeplink_actions.rs
Line: 169-171

Comment:
**Wrong event payload causes frontend deserialization failure**

`app.emit("request-open-recording-picker", ())` sends a JSON `null` payload, but the `RequestOpenRecordingPicker` struct has a `target_mode: Option<RecordingTargetMode>` field. The auto-generated frontend type expects `{ target_mode: null }`, not `null`. This payload mismatch will likely cause the event to silently fail or be ignored by the frontend listener.

All other call sites in `hotkeys.rs` correctly use the typed `tauri_specta` event. Use the same pattern here:

```suggestion
            DeepLinkAction::StartDefaultRecording => {
                RequestOpenRecordingPicker { target_mode: None }.emit(app).map_err(|e| e.to_string())
            }
```

You'll also need to import `RequestOpenRecordingPicker` at the top of the file (or reference it as `crate::RequestOpenRecordingPicker`).

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +94 to +102
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),
};
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Security: generic cap:// scheme is accessible by any app or web page

Registering cap as a system-wide URL scheme means any application — including browsers that silently follow cap:// links in web pages — can trigger cap://record, cap://stop, cap://pause, and cap://resume without user confirmation. A malicious web page could embed <a href="cap://record"> or automatically redirect to it, invisibly starting a screen capture session.

The existing cap-desktop://action?value=... scheme has the same surface area, but its JSON-in-query-string format is significantly harder to invoke accidentally or from a web page. The new cap:// URLs reduce the exploit complexity to a single, guessable link.

Consider requiring explicit user-facing confirmation (e.g., showing a toast/alert before acting), or at minimum documenting this behavior so users are aware that any local app can control their recording session via these URLs.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src-tauri/src/deeplink_actions.rs
Line: 94-102

Comment:
**Security: generic `cap://` scheme is accessible by any app or web page**

Registering `cap` as a system-wide URL scheme means any application — including browsers that silently follow `cap://` links in web pages — can trigger `cap://record`, `cap://stop`, `cap://pause`, and `cap://resume` without user confirmation. A malicious web page could embed `<a href="cap://record">` or automatically redirect to it, invisibly starting a screen capture session.

The existing `cap-desktop://action?value=...` scheme has the same surface area, but its JSON-in-query-string format is significantly harder to invoke accidentally or from a web page. The new `cap://` URLs reduce the exploit complexity to a single, guessable link.

Consider requiring explicit user-facing confirmation (e.g., showing a toast/alert before acting), or at minimum documenting this behavior so users are aware that any local app can control their recording session via these URLs.

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant