-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Add Raycast Extension with Enhanced Deeplink Support (#1540) #1566
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
Open
1234-ad
wants to merge
17
commits into
CapSoftware:main
Choose a base branch
from
1234-ad:feat/raycast-extension-1540
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7271a47
feat: add Raycast extension package.json
1234-ad 82b49b8
feat: add start recording command
1234-ad cfc0570
feat: add stop recording command
1234-ad 8a40117
feat: add start recording window command
1234-ad c50cd09
feat: add toggle pause command
1234-ad ff68127
feat: add switch camera command
1234-ad 990705b
feat: add switch microphone command
1234-ad 88041e2
feat: add open settings command
1234-ad 14c474c
feat: add Raycast extension README
1234-ad 8384bd9
feat: add TypeScript configuration
1234-ad 3f45b13
feat: add gitignore for Raycast extension
1234-ad fa6d941
feat: add ESLint configuration
1234-ad 3933fe3
feat: add pause/resume, switch camera/mic deeplink actions
1234-ad 175d726
feat: implement pause/resume toggle with deeplink
1234-ad a5aa3e3
feat: implement camera switching with deeplink
1234-ad c572a5b
feat: implement microphone switching with deeplink
1234-ad b9f475e
docs: add implementation details for Raycast extension
1234-ad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "extends": "@raycast" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| node_modules/ | ||
| dist/ | ||
| .DS_Store | ||
| *.log | ||
| .raycast/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,237 @@ | ||
| # Raycast Extension Implementation Details | ||
|
|
||
| This document describes the implementation of the Cap Raycast extension for issue #1540. | ||
|
|
||
| ## Overview | ||
|
|
||
| This implementation adds a complete Raycast extension for Cap that enables users to control screen recording directly from Raycast. The extension communicates with the Cap desktop app using deeplinks. | ||
|
|
||
| ## Changes Made | ||
|
|
||
| ### 1. Raycast Extension (`raycast-extension/`) | ||
|
|
||
| Created a complete Raycast extension with the following structure: | ||
|
|
||
| ``` | ||
| raycast-extension/ | ||
| ├── package.json # Extension manifest and dependencies | ||
| ├── tsconfig.json # TypeScript configuration | ||
| ├── .eslintrc.json # ESLint configuration | ||
| ├── .gitignore # Git ignore rules | ||
| ├── README.md # User documentation | ||
| ├── IMPLEMENTATION.md # This file | ||
| └── src/ | ||
| ├── start-recording.tsx # Quick start recording command | ||
| ├── start-recording-window.tsx # Select window to record | ||
| ├── stop-recording.tsx # Stop current recording | ||
| ├── toggle-pause.tsx # Pause/resume recording | ||
| ├── switch-camera.tsx # Switch camera input | ||
| ├── switch-microphone.tsx # Switch microphone input | ||
| └── open-settings.tsx # Open Cap settings | ||
| ``` | ||
|
|
||
| ### 2. Enhanced Deeplink Actions (`apps/desktop/src-tauri/src/deeplink_actions.rs`) | ||
|
|
||
| Extended the existing deeplink implementation with new actions: | ||
|
|
||
| - **PauseRecording**: Pause the current recording | ||
| - **ResumeRecording**: Resume a paused recording | ||
| - **SwitchCamera**: Change camera input during recording | ||
| - **SwitchMicrophone**: Change microphone input during recording | ||
|
|
||
| These additions complement the existing actions: | ||
| - StartRecording | ||
| - StopRecording | ||
| - OpenEditor | ||
| - OpenSettings | ||
|
|
||
| ## Deeplink Protocol | ||
|
|
||
| The extension uses the `cap://action?value=<encoded_json>` protocol to communicate with Cap. | ||
|
|
||
| ### Action Format | ||
|
|
||
| Actions are JSON objects that are URL-encoded and passed as the `value` parameter: | ||
|
|
||
| ```typescript | ||
| // Start Recording | ||
| { | ||
| "start_recording": { | ||
| "capture_mode": { "screen": "Built-in Display" }, | ||
| "camera": null, | ||
| "mic_label": null, | ||
| "capture_system_audio": true, | ||
| "mode": "desktop" | ||
| } | ||
| } | ||
|
|
||
| // Stop Recording | ||
| "stop_recording" | ||
|
|
||
| // Pause Recording | ||
| "pause_recording" | ||
|
|
||
| // Resume Recording | ||
| "resume_recording" | ||
|
|
||
| // Switch Camera | ||
| { | ||
| "switch_camera": { | ||
| "camera": "camera_id" | ||
| } | ||
| } | ||
|
|
||
| // Switch Microphone | ||
| { | ||
| "switch_microphone": { | ||
| "mic_label": "microphone_name" | ||
| } | ||
| } | ||
|
|
||
| // Open Settings | ||
| { | ||
| "open_settings": { | ||
| "page": null | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Commands | ||
|
|
||
| ### 1. Start Recording (`start-recording.tsx`) | ||
| - **Mode**: no-view (executes immediately) | ||
| - **Action**: Starts recording the primary display with system audio | ||
| - **Deeplink**: Uses `start_recording` action with screen capture mode | ||
|
|
||
| ### 2. Start Recording Window (`start-recording-window.tsx`) | ||
| - **Mode**: view (shows window selection list) | ||
| - **Action**: Lists all open windows and starts recording the selected one | ||
| - **Features**: | ||
| - Uses AppleScript to enumerate windows | ||
| - Searchable list interface | ||
| - Shows app name for each window | ||
|
|
||
| ### 3. Stop Recording (`stop-recording.tsx`) | ||
| - **Mode**: no-view (executes immediately) | ||
| - **Action**: Stops the current recording | ||
| - **Deeplink**: Uses `stop_recording` action | ||
|
|
||
| ### 4. Toggle Pause (`toggle-pause.tsx`) | ||
| - **Mode**: no-view (executes immediately) | ||
| - **Action**: Pauses or resumes the current recording | ||
| - **Deeplink**: Uses `pause_recording` action | ||
| - **Note**: State management is handled by the Cap app | ||
|
|
||
| ### 5. Switch Camera (`switch-camera.tsx`) | ||
| - **Mode**: view (shows camera selection list) | ||
| - **Action**: Lists available cameras and switches to the selected one | ||
| - **Features**: | ||
| - Uses `system_profiler` to enumerate cameras | ||
| - Searchable list interface | ||
| - Fallback to built-in camera | ||
|
|
||
| ### 6. Switch Microphone (`switch-microphone.tsx`) | ||
| - **Mode**: view (shows microphone selection list) | ||
| - **Action**: Lists available microphones and switches to the selected one | ||
| - **Features**: | ||
| - Uses `system_profiler` to enumerate audio inputs | ||
| - Searchable list interface | ||
| - Fallback to built-in microphone | ||
|
|
||
| ### 7. Open Settings (`open-settings.tsx`) | ||
| - **Mode**: no-view (executes immediately) | ||
| - **Action**: Opens the Cap settings window | ||
| - **Deeplink**: Uses `open_settings` action | ||
|
|
||
| ## Technical Implementation | ||
|
|
||
| ### Deeplink Execution Flow | ||
|
|
||
| 1. User triggers command in Raycast | ||
| 2. Extension constructs action JSON object | ||
| 3. JSON is serialized and URL-encoded | ||
| 4. Deeplink URL is constructed: `cap://action?value=<encoded_json>` | ||
| 5. URL is opened using Raycast's `open()` API | ||
| 6. Cap app receives and parses the deeplink | ||
| 7. Action is executed in the Cap app | ||
| 8. User receives HUD notification in Raycast | ||
|
|
||
| ### Device Enumeration | ||
|
|
||
| The extension uses macOS system utilities to enumerate devices: | ||
|
|
||
| - **Cameras**: `system_profiler SPCameraDataType` | ||
| - **Microphones**: `system_profiler SPAudioDataType` | ||
| - **Windows**: AppleScript via `osascript` | ||
|
|
||
| ### Error Handling | ||
|
|
||
| All commands include try-catch blocks and show appropriate HUD messages: | ||
| - ✅ Success messages with action details | ||
| - ❌ Error messages when operations fail | ||
| - Console logging for debugging | ||
|
|
||
| ## Dependencies | ||
|
|
||
| ### Runtime Dependencies | ||
| - `@raycast/api`: ^1.65.0 - Core Raycast API | ||
| - `@raycast/utils`: ^1.12.0 - Utility hooks and helpers | ||
|
|
||
| ### Development Dependencies | ||
| - `@raycast/eslint-config`: ^1.0.8 - ESLint configuration | ||
| - `@types/node`: 20.8.10 - Node.js type definitions | ||
| - `@types/react`: 18.2.27 - React type definitions | ||
| - `eslint`: ^8.51.0 - Linting | ||
| - `prettier`: ^3.0.3 - Code formatting | ||
| - `typescript`: ^5.2.2 - TypeScript compiler | ||
|
|
||
| ## Testing | ||
|
|
||
| To test the extension: | ||
|
|
||
| 1. Install dependencies: `npm install` | ||
| 2. Run in development mode: `npm run dev` | ||
| 3. Open Raycast and search for Cap commands | ||
| 4. Test each command with Cap running | ||
|
|
||
| ## Future Enhancements | ||
|
|
||
| Potential improvements for future iterations: | ||
|
|
||
| 1. **Recording Status**: Show current recording status in Raycast | ||
| 2. **Recent Recordings**: Quick access to recent recordings | ||
| 3. **Recording Presets**: Save and load recording configurations | ||
| 4. **Keyboard Shortcuts**: Add default keyboard shortcuts for common actions | ||
| 5. **Recording Timer**: Display recording duration | ||
| 6. **Quick Share**: Share recordings directly from Raycast | ||
|
|
||
| ## Notes | ||
|
|
||
| - The extension requires Cap to be installed and running | ||
| - Deeplink actions require Cap version with the enhanced deeplink support | ||
| - Some features (pause/resume, switch camera/mic) require the Rust backend changes to be merged | ||
| - The extension is designed for macOS (uses system_profiler and AppleScript) | ||
|
|
||
| ## Bounty Requirements | ||
|
|
||
| This implementation fulfills the bounty requirements: | ||
|
|
||
| ✅ Deeplinks support for: | ||
| - Recording (start/stop) | ||
| - Pause/Resume | ||
| - Camera switching | ||
| - Microphone switching | ||
| - Settings access | ||
|
|
||
| ✅ Raycast Extension with: | ||
| - Complete command set | ||
| - User-friendly interface | ||
| - Proper error handling | ||
| - Documentation | ||
|
|
||
| ## Related Files | ||
|
|
||
| - Issue: #1540 | ||
| - Deeplink Implementation: `apps/desktop/src-tauri/src/deeplink_actions.rs` | ||
| - Extension Source: `raycast-extension/src/` | ||
| - Documentation: `raycast-extension/README.md` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Cap Raycast Extension | ||
|
|
||
| Control Cap screen recording directly from Raycast. | ||
|
|
||
| ## Features | ||
|
|
||
| - **Start Recording**: Quickly start recording your screen | ||
| - **Start Recording Window**: Select and record a specific window | ||
| - **Stop Recording**: Stop the current recording | ||
| - **Toggle Pause**: Pause or resume recording (coming soon) | ||
| - **Switch Camera**: Change camera input during recording | ||
| - **Switch Microphone**: Change microphone input during recording | ||
| - **Open Settings**: Open Cap settings | ||
|
|
||
| ## Installation | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - [Cap](https://cap.so) must be installed on your system | ||
| - [Raycast](https://raycast.com) must be installed | ||
|
|
||
| ### Setup | ||
|
|
||
| 1. Clone this repository or download the extension | ||
| 2. Navigate to the `raycast-extension` directory | ||
| 3. Run `npm install` to install dependencies | ||
| 4. Run `npm run dev` to load the extension in Raycast | ||
|
|
||
| ## Usage | ||
|
|
||
| Open Raycast and search for any of the Cap commands: | ||
|
|
||
| - `Start Recording` - Immediately start recording your primary screen | ||
| - `Start Recording Window` - Choose a window to record | ||
| - `Stop Recording` - Stop the current recording | ||
| - `Toggle Pause Recording` - Pause/resume (coming soon) | ||
| - `Switch Camera` - Change camera input | ||
| - `Switch Microphone` - Change microphone input | ||
| - `Open Settings` - Open Cap settings | ||
|
|
||
| ## Deeplink Protocol | ||
|
|
||
| This extension uses Cap's deeplink protocol (`cap://action`) to communicate with the Cap app. The deeplink actions are defined in the Cap desktop app at `apps/desktop/src-tauri/src/deeplink_actions.rs`. | ||
|
|
||
| ### Supported Actions | ||
|
|
||
| - `StartRecording`: Start a new recording with specified capture mode, camera, microphone, and audio settings | ||
| - `StopRecording`: Stop the current recording | ||
| - `OpenSettings`: Open Cap settings with optional page parameter | ||
|
|
||
| ### Future Actions (To Be Implemented) | ||
|
|
||
| - `PauseRecording`: Pause the current recording | ||
| - `ResumeRecording`: Resume a paused recording | ||
| - `SwitchCamera`: Change camera input during recording | ||
| - `SwitchMicrophone`: Change microphone input during recording | ||
|
|
||
| ## Development | ||
|
|
||
| ### Building | ||
|
|
||
| ```bash | ||
| npm run build | ||
| ``` | ||
|
|
||
| ### Linting | ||
|
|
||
| ```bash | ||
| npm run lint | ||
| npm run fix-lint | ||
| ``` | ||
|
|
||
| ### Publishing | ||
|
|
||
| ```bash | ||
| npm run publish | ||
| ``` | ||
|
|
||
| ## Contributing | ||
|
|
||
| Contributions are welcome! Please feel free to submit a Pull Request. | ||
|
|
||
| ## License | ||
|
|
||
| MIT |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.