[Fix] Add deeplinks for pause/resume recording and hardware switching#1810
[Fix] Add deeplinks for pause/resume recording and hardware switching#1810adminlip wants to merge 1 commit into
Conversation
|
|
||
| assert!(matches!( | ||
| parse_action( | ||
| "cap://action?value=%7B%22set_camera%22%3A%7B%22camera%22%3A%7B%22id%22%3A%22123%22%7D%7D" |
There was a problem hiding this comment.
This URL decodes to {"set_camera":{"camera":{"id":"123"}} (missing the final }), so the test should currently fail. Might just need one more %7D.
| "cap://action?value=%7B%22set_camera%22%3A%7B%22camera%22%3A%7B%22id%22%3A%22123%22%7D%7D" | |
| "cap://action?value=%7B%22set_camera%22%3A%7B%22camera%22%3A%7B%22id%22%3A%22123%22%7D%7D%7D" |
| assert!(matches!( | ||
| parse_action( | ||
| "cap://action?value=%7B%22set_camera%22%3A%7B%22camera%22%3A%7B%22id%22%3A%22123%22%7D%7D" | ||
| ), | ||
| Ok(DeepLinkAction::SetCamera { camera: Some(DeviceOrModelID::Id(id)) }) if id == "123" | ||
| )); |
There was a problem hiding this comment.
Non-existent enum variant
DeviceOrModelID::Id used in test
The test pattern-matches on DeviceOrModelID::Id(id), but the actual enum (in crates/recording/src/feeds/camera.rs) only has DeviceID(String) and ModelID(...) variants — there is no Id variant. This causes a compile-time error when running cargo test. Additionally, the JSON embedded in the test URL decodes to {"set_camera":{"camera":{"id":"123"}} (note: only two closing braces at the end), which is malformed JSON (missing the final }), and even if braces were balanced, {"id":"123"} is not the serde representation of DeviceOrModelID::DeviceID — that serialises as {"DeviceID":"123"}. These three issues together mean the test was never actually compiled or run.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src-tauri/src/deeplink_actions.rs
Line: 220-225
Comment:
**Non-existent enum variant `DeviceOrModelID::Id` used in test**
The test pattern-matches on `DeviceOrModelID::Id(id)`, but the actual enum (in `crates/recording/src/feeds/camera.rs`) only has `DeviceID(String)` and `ModelID(...)` variants — there is no `Id` variant. This causes a compile-time error when running `cargo test`. Additionally, the JSON embedded in the test URL decodes to `{"set_camera":{"camera":{"id":"123"}}` (note: only two closing braces at the end), which is malformed JSON (missing the final `}`), and even if braces were balanced, `{"id":"123"}` is not the serde representation of `DeviceOrModelID::DeviceID` — that serialises as `{"DeviceID":"123"}`. These three issues together mean the test was never actually compiled or run.
How can I resolve this? If you propose a fix, please make it concise.- Adds DeepLinkAction variants: PauseRecording, ResumeRecording, TogglePauseRecording - Adds SetMicrophone and SetCamera deeplink actions for hardware switching - Implements execute() methods for all new actions - Adds unit tests for parsing and execution This enables the Raycast extension to control: - Recording controls via deeplinks (pause/resume/toggle) - Hardware selection (mic/camera) via deeplinks See: CapSoftware#1540
| assert!(matches!( | ||
| parse_action( | ||
| "cap://action?value=%7B%22set_camera%22%3A%7B%22camera%22%3A%7B%22id%22%3A%22123%22%7D%7D" | ||
| ), | ||
| Ok(DeepLinkAction::SetCamera { camera: Some(DeviceOrModelID::Id(id)) }) if id == "123" | ||
| )); |
There was a problem hiding this comment.
The DeviceOrModelID serde shape here is an externally-tagged enum ({"DeviceID":"123"}), and the URL-encoded JSON is also missing a closing }.
| assert!(matches!( | |
| parse_action( | |
| "cap://action?value=%7B%22set_camera%22%3A%7B%22camera%22%3A%7B%22id%22%3A%22123%22%7D%7D" | |
| ), | |
| Ok(DeepLinkAction::SetCamera { camera: Some(DeviceOrModelID::Id(id)) }) if id == "123" | |
| )); | |
| assert!(matches!( | |
| parse_action( | |
| "cap://action?value=%7B%22set_camera%22%3A%7B%22camera%22%3A%7B%22DeviceID%22%3A%22123%22%7D%7D%7D" | |
| ), | |
| Ok(DeepLinkAction::SetCamera { camera: Some(DeviceOrModelID::DeviceID(id)) }) if id == "123" | |
| )); |
Fixes issue #1540: Bounty: Deeplinks support + Raycast Extension
Summary
Validation
Greptile Summary
This PR extends the deeplink system with pause, resume, toggle-pause, set-microphone, and set-camera actions, and refactors the
executemethod to hoist the sharedAppstate rather than declaring it per-branch. The production code paths (delegating to the existingrecording::pause_recording,resume_recording,toggle_pause_recording,set_mic_input, andset_camera_inputfunctions) are correct.PauseRecording,ResumeRecording,TogglePauseRecording,SetMicrophone, andSetCameraare added toDeepLinkActionand wired to existing recording helpers.app.state::<ArcLock<App>>()is now declared once at the top ofexecute()and reused across all match arms.parses_hardware_switch_actionstest forSetCamerareferencesDeviceOrModelID::Id(non-existent), uses a malformed JSON URL (missing closing}), and uses the wrong serde key.cargo testwill fail to compile.Confidence Score: 3/5
The production logic is sound, but the added SetCamera test will not compile due to a non-existent enum variant reference and malformed JSON in the test URL.
The functional deeplink wiring is correct, but the parses_hardware_switch_actions test introduces a compile-time error: DeviceOrModelID::Id does not exist (real variants are DeviceID and ModelID), the encoded JSON is missing a closing brace, and the serde key name is wrong. cargo build skips cfg(test) code so this was not caught.
apps/desktop/src-tauri/src/deeplink_actions.rs — specifically the parses_hardware_switch_actions test block needs the enum variant name, JSON key, and URL brace count corrected.
Important Files Changed
cargo test.Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "[Fix] Add deeplinks for pause/resume rec..." | Re-trigger Greptile