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
23 changes: 22 additions & 1 deletion apps/desktop/src-tauri/src/deeplink_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ pub enum DeepLinkAction {
mode: RecordingMode,
},
StopRecording,
PauseRecording,
ResumeRecording,
SwitchMicrophone {
mic_label: String,
},
SwitchCamera {
camera: DeviceOrModelID,
},
OpenEditor {
project_path: PathBuf,
},
Expand All @@ -49,7 +57,6 @@ pub fn handle(app_handle: &AppHandle, urls: Vec<Url>) {
ActionParseFromUrlError::Invalid => {
eprintln!("Invalid deep link format \"{}\"", &url)
}
// Likely login action, not handled here.
ActionParseFromUrlError::NotAction => {}
})
.ok()
Expand Down Expand Up @@ -147,6 +154,20 @@ 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::SwitchMicrophone { mic_label } => {
let state = app.state::<ArcLock<App>>();
crate::set_mic_input(state.clone(), Some(mic_label)).await
}
DeepLinkAction::SwitchCamera { camera } => {
let state = app.state::<ArcLock<App>>();
crate::set_camera_input(app.clone(), state.clone(), Some(camera), None).await
}
DeepLinkAction::OpenEditor { project_path } => {
crate::open_project_from_path(Path::new(&project_path), app.clone())
}
Expand Down
7 changes: 7 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
"rules": { "a11y": "off" }
}
},
{
"includes": ["extensions/raycast/**/*"],
"formatter": {
"indentStyle": "space",
"indentWidth": 2
}
},
{
"includes": ["**/*.css"],
"linter": {
Expand Down
5 changes: 5 additions & 0 deletions extensions/raycast/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
out
dist
*.log
.DS_Store
Binary file added extensions/raycast/assets/command-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions extensions/raycast/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"$schema": "https://www.raycast.com/schemas/extension.json",
"name": "cap",
"title": "Cap",
"description": "Control Cap recording via deeplinks",
"icon": "command-icon.png",
"author": "cap",
"categories": [
"Productivity"
],
"license": "MIT",
"commands": [
{
"name": "start-recording",
"title": "Start Recording",
"description": "Start a Cap recording",
"mode": "no-view"
},
{
"name": "stop-recording",
"title": "Stop Recording",
"description": "Stop the current Cap recording",
"mode": "no-view"
},
{
"name": "pause-recording",
"title": "Pause Recording",
"description": "Pause the current Cap recording",
"mode": "no-view"
},
{
"name": "resume-recording",
"title": "Resume Recording",
"description": "Resume the current Cap recording",
"mode": "no-view"
},
{
"name": "switch-microphone",
"title": "Switch Microphone",
"description": "Switch the active microphone in Cap",
"mode": "no-view",
"arguments": [
{
"name": "mic",
"placeholder": "Microphone Name",
"type": "text",
"required": true
}
]
},
{
"name": "switch-camera",
"title": "Switch Camera",
"description": "Switch the active camera in Cap",
"mode": "no-view",
"arguments": [
{
"name": "camera",
"placeholder": "Camera Name",
"type": "text",
"required": true
}
]
}
],
"dependencies": {
"@raycast/api": "^1.83.1"
},
"devDependencies": {
"@types/node": "20.8.10",
"@types/react": "18.2.27",
"typescript": "^5.2.2"
},
"scripts": {
"build": "ray build -e dist",
"dev": "ray develop",
"lint": "ray lint",
"fix-lint": "ray fix-lint"
}
}
6 changes: 6 additions & 0 deletions extensions/raycast/src/pause-recording.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { open } from "@raycast/api";

export default async function Command() {
const value = JSON.stringify({ PauseRecording: {} });
await open(`cap://action?value=${encodeURIComponent(value)}`);
}
6 changes: 6 additions & 0 deletions extensions/raycast/src/resume-recording.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { open } from "@raycast/api";

export default async function Command() {
const value = JSON.stringify({ ResumeRecording: {} });
await open(`cap://action?value=${encodeURIComponent(value)}`);
}
14 changes: 14 additions & 0 deletions extensions/raycast/src/start-recording.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { open } from "@raycast/api";

export default async function Command() {
const value = JSON.stringify({
StartRecording: {
capture_mode: { Screen: "" },
camera: null,
mic_label: null,
Comment on lines +5 to +8
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.

P1 Hardcoded screen/mode with no user control

capture_mode is hard-coded to Screen with an empty display name (""), and mode is hard-coded to "Studio". An empty display name causes the Rust handler to search list_displays() for a display whose name == "", which will not match any real display and returns an error. The start-recording command should either accept arguments for these fields or use a sensible default like the primary display name.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/raycast/src/start-recording.tsx
Line: 5-8

Comment:
**Hardcoded screen/mode with no user control**

`capture_mode` is hard-coded to `Screen` with an empty display name (`""`), and `mode` is hard-coded to `"Studio"`. An empty display name causes the Rust handler to search `list_displays()` for a display whose `name == ""`, which will not match any real display and returns an error. The `start-recording` command should either accept arguments for these fields or use a sensible default like the primary display name.

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

capture_system_audio: false,
mode: "Studio",
},
});
await open(`cap://action?value=${encodeURIComponent(value)}`);
Comment on lines +3 to +13
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.

P1 Nested serde renames also use the wrong case

Beyond the outer variant name (StartRecordingstart_recording), two inner types have their own rename_all rules:

  • CaptureMode has rename_all = "snake_case"Screen must be screen
  • RecordingMode has rename_all = "camelCase"Studio must be studio

All three mismatches together mean this command will always fail to parse.

Suggested change
export default async function Command() {
const value = JSON.stringify({
StartRecording: {
capture_mode: { Screen: "" },
camera: null,
mic_label: null,
capture_system_audio: false,
mode: "Studio",
},
});
await open(`cap://action?value=${encodeURIComponent(value)}`);
export default async function Command() {
const value = JSON.stringify({
start_recording: {
capture_mode: { screen: "" },
camera: null,
mic_label: null,
capture_system_audio: false,
mode: "studio",
},
});
await open(`cap://action?value=${encodeURIComponent(value)}`);
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/raycast/src/start-recording.tsx
Line: 3-13

Comment:
**Nested serde renames also use the wrong case**

Beyond the outer variant name (`StartRecording``start_recording`), two inner types have their own `rename_all` rules:

- `CaptureMode` has `rename_all = "snake_case"``Screen` must be `screen`
- `RecordingMode` has `rename_all = "camelCase"``Studio` must be `studio`

All three mismatches together mean this command will always fail to parse.

```suggestion
export default async function Command() {
  const value = JSON.stringify({
    start_recording: {
      capture_mode: { screen: "" },
      camera: null,
      mic_label: null,
      capture_system_audio: false,
      mode: "studio",
    },
  });
  await open(`cap://action?value=${encodeURIComponent(value)}`);
}
```

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

}
6 changes: 6 additions & 0 deletions extensions/raycast/src/stop-recording.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { open } from "@raycast/api";

export default async function Command() {
const value = JSON.stringify({ StopRecording: {} });
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.

P1 Wrong serde variant names across all Raycast commands

DeepLinkAction is declared with #[serde(rename_all = "snake_case")], so every variant name is serialised as snake_case in JSON. All six Raycast commands use the original PascalCase names, which serde will never match, so every deeplink invocation silently fails with a parse error.

Same problem in pause-recording.tsx (PauseRecording), resume-recording.tsx (ResumeRecording), switch-microphone.tsx (SwitchMicrophone), switch-camera.tsx (SwitchCamera), and start-recording.tsx (StartRecording).

Suggested change
const value = JSON.stringify({ StopRecording: {} });
const value = JSON.stringify({ stop_recording: {} });
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/raycast/src/stop-recording.tsx
Line: 4

Comment:
**Wrong serde variant names across all Raycast commands**

`DeepLinkAction` is declared with `#[serde(rename_all = "snake_case")]`, so every variant name is serialised as `snake_case` in JSON. All six Raycast commands use the original `PascalCase` names, which serde will never match, so every deeplink invocation silently fails with a parse error.

Same problem in `pause-recording.tsx` (`PauseRecording`), `resume-recording.tsx` (`ResumeRecording`), `switch-microphone.tsx` (`SwitchMicrophone`), `switch-camera.tsx` (`SwitchCamera`), and `start-recording.tsx` (`StartRecording`).

```suggestion
  const value = JSON.stringify({ stop_recording: {} });
```

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

await open(`cap://action?value=${encodeURIComponent(value)}`);
}
16 changes: 16 additions & 0 deletions extensions/raycast/src/switch-camera.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { open } from "@raycast/api";

interface Props {
arguments: {
camera: string;
};
}

export default async function Command(props: Props) {
const value = JSON.stringify({
SwitchCamera: {
camera: props.arguments.camera,
},
});
await open(`cap://action?value=${encodeURIComponent(value)}`);
Comment on lines +10 to +15
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.

P1 camera must be a DeviceOrModelID tagged object, not a bare string

The Rust field type is DeviceOrModelID, an enum serialised with serde's default external-tag format. Passing a plain string like "My Camera" will fail to deserialise. The correct payload for a device ID is { DeviceID: "..." } (or { ModelID: "..." } for model IDs).

Suggested change
const value = JSON.stringify({
SwitchCamera: {
camera: props.arguments.camera,
},
});
await open(`cap://action?value=${encodeURIComponent(value)}`);
const value = JSON.stringify({
switch_camera: {
camera: { DeviceID: props.arguments.camera },
},
});
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/raycast/src/switch-camera.tsx
Line: 10-15

Comment:
**`camera` must be a `DeviceOrModelID` tagged object, not a bare string**

The Rust field type is `DeviceOrModelID`, an enum serialised with serde's default external-tag format. Passing a plain string like `"My Camera"` will fail to deserialise. The correct payload for a device ID is `{ DeviceID: "..." }` (or `{ ModelID: "..." }` for model IDs).

```suggestion
  const value = JSON.stringify({
    switch_camera: {
      camera: { DeviceID: props.arguments.camera },
    },
  });
```

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

}
16 changes: 16 additions & 0 deletions extensions/raycast/src/switch-microphone.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { open } from "@raycast/api";

interface Props {
arguments: {
mic: string;
};
}

export default async function Command(props: Props) {
const value = JSON.stringify({
SwitchMicrophone: {
mic_label: props.arguments.mic,
},
});
await open(`cap://action?value=${encodeURIComponent(value)}`);
}
19 changes: 19 additions & 0 deletions extensions/raycast/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Node 20",
"include": ["src/**/*"],
"compilerOptions": {
"lib": ["ES2023"],
"module": "commonjs",
"target": "ES2022",
"strict": true,
"isolatedModules": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react-jsx",
"resolveJsonModule": true,
"declaration": true,
"outDir": "out"
}
}