Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

test: add desktop benchmark lifecycle controls

Richie McIlroy542df22e8987
diff --git a/apps/desktop/src-tauri/src/deeplink_actions.rs b/apps/desktop/src-tauri/src/deeplink_actions.rs
index 7be4674e3..5372d5878 100644
--- a/apps/desktop/src-tauri/src/deeplink_actions.rs
+++ b/apps/desktop/src-tauri/src/deeplink_actions.rs
@@ -58,6 +58,20 @@ pub enum DeepLinkAction {
SetCameraPreviewState {
state: CameraPreviewState,
},
+ #[cfg(debug_assertions)]
+ SetRecordingInputs {
+ camera: Option<DeviceOrModelID>,
+ mic_label: Option<String>,
+ },
+ #[cfg(debug_assertions)]
+ SetEditorPlayback {
+ project_path: PathBuf,
+ playing: bool,
+ },
+ #[cfg(debug_assertions)]
+ CloseEditor {
+ project_path: PathBuf,
+ },
OpenEditor {
project_path: PathBuf,
},
@@ -77,17 +91,19 @@ impl DeepLinkActionExecutor {
let runtime = tokio::runtime::Handle::current();
trace!("Starting deep link action executor");
- let thread_result = std::thread::Builder::new()
- .name("deep-link-action-executor".to_string())
- .spawn(move || {
- trace!("Deep link action executor started");
- for action in rx {
- trace!(?action, "Executing deep link action");
- if let Err(err) = runtime.block_on(action.execute(&app_handle)) {
- eprintln!("Failed to handle deep link action: {err}");
- }
+ let thread = std::thread::Builder::new().name("deep-link-action-executor".to_string());
+ // Debug recording futures overflow the default thread stack; match Tauri's worker stack.
+ #[cfg(debug_assertions)]
+ let thread = thread.stack_size(16 * 1024 * 1024);
+ let thread_result = thread.spawn(move || {
+ trace!("Deep link action executor started");
+ for action in rx {
+ trace!(?action, "Executing deep link action");
+ if let Err(err) = runtime.block_on(action.execute(&app_handle)) {
+ eprintln!("Failed to handle deep link action: {err}");
}
- });
+ }
+ });
if let Err(err) = thread_result {
eprintln!("Failed to start deep link action executor: {err}");
@@ -286,6 +302,34 @@ impl DeepLinkAction {
DeepLinkAction::SetCameraPreviewState { state } => {
crate::set_camera_preview_state(app.state(), state).await
}
+ #[cfg(debug_assertions)]
+ DeepLinkAction::SetRecordingInputs { camera, mic_label } => {
+ crate::set_camera_input(app.clone(), app.state(), camera, None).await?;
+ crate::set_mic_input(app.clone(), app.state(), mic_label).await
+ }
+ #[cfg(debug_assertions)]
+ DeepLinkAction::SetEditorPlayback {
+ project_path,
+ playing,
+ } => {
+ let window = crate::windows::editor_window_for_path(app, &project_path)
+ .ok_or("Editor window is not open")?;
+ window
+ .emit_to(
+ tauri::EventTarget::WebviewWindow {
+ label: window.label().to_string(),
+ },
+ "cap-dev-set-editor-playback",
+ playing,
+ )
+ .map_err(|error| error.to_string())
+ }
+ #[cfg(debug_assertions)]
+ DeepLinkAction::CloseEditor { project_path } => {
+ let window = crate::windows::editor_window_for_path(app, &project_path)
+ .ok_or("Editor window is not open")?;
+ window.close().map_err(|error| error.to_string())
+ }
DeepLinkAction::OpenEditor { project_path } => {
crate::open_project_from_path(Path::new(&project_path), app.clone())
}
diff --git a/apps/desktop/src/routes/editor/Player.tsx b/apps/desktop/src/routes/editor/Player.tsx
index a6551c123..3ef4105cf 100644
--- a/apps/desktop/src/routes/editor/Player.tsx
+++ b/apps/desktop/src/routes/editor/Player.tsx
@@ -3,6 +3,7 @@ import { createElementBounds } from "@solid-primitives/bounds";
import { createEventListener } from "@solid-primitives/event-listener";
import { debounce } from "@solid-primitives/scheduled";
import { Menu } from "@tauri-apps/api/menu";
+import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
import { type as ostype } from "@tauri-apps/plugin-os";
import { cx } from "cva";
import {
@@ -16,6 +17,7 @@ import {
} from "solid-js";
import Tooltip from "~/components/Tooltip";
import { captionsStore } from "~/store/captions";
+import { createTauriEventListener } from "~/utils/createEventListener";
import { commands } from "~/utils/tauri";
import AspectRatioSelect from "./AspectRatioSelect";
import {
@@ -292,6 +294,21 @@ export function PlayerContent(props: { compactness?: number }) {
}
};
+ if (import.meta.env.DEV) {
+ createTauriEventListener<boolean>(
+ {
+ listen: (callback) =>
+ getCurrentWebviewWindow().listen(
+ "cap-dev-set-editor-playback",
+ callback,
+ ),
+ },
+ (playing) => {
+ if (playbackIntent() !== playing) void handlePlayPauseClick();
+ },
+ );
+ }
+
// Register keyboard shortcuts in one place
useEditorShortcuts(() => {
const el = document.activeElement;