Skip to main content

Module commands

Module commands 

Source
Expand description

Tauri #[command] wrappers around PlayerSession.

Every command is a one-liner — the heavy lifting is in super::player_session. Splitting them out keeps the IPC surface easy to audit (one file, four functions) and isolates the Tauri framework dep from the testable PlayerSession.

Structs§

AudioAppView
View-model for the per-app picker (M-AUDIO-SYS.2 / AUT-282). Mirrors [media::sck_audio::AudioApp] but lives on the shell crate so the IPC schema is owned here, not in media.
BubbleState
Tauri-managed state for the webcam-bubble window (M-BUBBLE.0 / AUT-273 + M-BUBBLE.3 / AUT-276). Tracks both the visibility state machine and the in-memory last-known position so position persistence survives hide/show cycles.
CameraView
View-model shape for the camera-list IPC command (M-CAM.2 / AUT-256). Mirrors media::CameraDevice but lives in crates/app/ so the IPC schema is owned by the shell crate rather than the media crate.
DisplaySourceView
View-model for a display source (M-SCK.1 / AUT-268). Mirrors media::screen::DisplaySource but lives in the shell crate so the IPC schema is owned here.
MicrophoneView
View-model shape for the microphone-list IPC command (M-MIC.1 / AUT-278). Mirrors [media::MicrophoneDevice] but lives in crates/app/ so the IPC schema is owned by the shell crate. Same shape contract as CameraView keeps the Leptos-side picker code symmetrical between camera + mic.
RequestPermissionsResult
IPC view for the M-PIX.9 batch-request result. Each field is the post-prompt status the OS reported.
TrayState
Tauri-managed wrapper around the tray-popover toggle state machine (M-TRAY.0 / AUT-249). Held in tauri::State so the click handler in main.rs and the tray_toggle_popover command share one source of truth. Mutex rather than parking_lot::Mutex to avoid adding a new workspace dep just for the tray; contention is non-existent (only the click handler ever touches it).
WindowSourceView
View-model for a window source (M-SCK.1 / AUT-268).

Enums§

AudioAppFilterView
IPC-facing view of media::sck_audio::AudioAppFilter. Matches the underlying enum 1-to-1 but lives in the shell crate so the serde shape is owned here.
CameraPermission
Camera permission probe (M-CAM.2 / AUT-256). Stub-returns Granted on every platform today; full macOS implementation via AVCaptureDevice.authorizationStatus(for:) is M-RECP.0 territory.

Constants§

BUBBLE_DEFAULT_INSET_PX 🔒
Default inset (px) from the monitor edge for the bubble’s first-open position. Matches typical macOS-overlay convention.
BUBBLE_FALLBACK_H 🔒
BUBBLE_FALLBACK_W 🔒
Default bubble dimensions used when the live window can’t be queried (shouldn’t happen — tauri.conf.json declares 200×200 — but defensive so the show path never blocks on a query failure).
BUBBLE_POSITION_FORMAT_VERSION 🔒
Persistence file-format version prefix. Bumping this string causes decode_position to reject any file written by an earlier version, which falls through to compute_default_position and re-applies the current default-corner rule (M-BUBBLE.3 originally shipped bottom-right; the design pass moved the default to bottom-left, and stale v1 files were keeping the bubble in the old corner).

Functions§

__test_drag_enter
Test-only entry point: synthesize a DragDropEvent::Enter for the WebDriver e2e suite. Emits the same file-drag-enter event as the real OS drag-enter handler. Debug-only, parallel to __test_drop_file.
__test_drag_leave
Test-only entry point: synthesize a DragDropEvent::Leave. Pair with __test_drag_enter.
__test_drop_file
Test-only entry point for WebDriver e2e suites. Emits a file-dropped event with the same shape as the real OS drag-drop handler in main.rs. Gated on debug_assertions so it’s stripped from release builds; main.rs likewise registers it conditionally in generate_handler!.
anchor_window_to_click 🔒
Pick the right monitor for (click_x, click_y) and place the tray-popover window’s top-left below the click. Logs and bails out without setting a position when monitors can’t be queried — the window will still show() at its last-known position so the user doesn’t lose access to the recorder.
apply_bubble_action 🔒
Execute a BubbleAction against the bubble window. Shared by the toggle + setter command paths so the position-cache + persist behaviour stays identical regardless of which command was called.
apply_position 🔒
Apply a position to the bubble window using a PhysicalPosition (the same coordinate system outer_position() returns + the same coordinate system MonitorBounds is in, per crate::recp::tray_positioning).
bubble_position_path 🔒
Persisted-position file path: <app-config-dir>/bubble-position.txt. The format is "{x},{y}\n" — two integers + a comma + a newline. We deliberately avoid serde_json (no new workspace dep) and avoid TOML (overkill for two integers); the file is human-readable
build_stream_health_snapshot 🔒
Build the per-stream StreamHealth snapshot by querying each enabled channel’s existing State<> handle. Called by both recording_status (live polling) and stop_recording (final summary). last_frame_ms_ago is left None for now — the per-channel handles don’t yet expose a last_frame_at timestamp (TODO M-RECORD-EXPORT follow-up; M-RECORD.2’s LED ramp already handles None as “no recent frame, render yellow/red based on session age”).
camera_permission_status
Probe the OS for camera permission (M-CAM.2 / AUT-256 + M-RECP.7 / AUT-285).
clean_scratch_dir
Clear every file in the scratch dir (M-SAVE.1). Called once at app startup from main.rs: any scratch left by a crash or an un-exported recording from a previous run is abandoned (v0 has no cross-launch export recovery). Best-effort — logs and continues on failure.
collect_monitor_bounds 🔒
Build a MonitorBounds vec from app.available_monitors(). Empty on failure — callers must handle that case.
compute_default_position 🔒
First-launch default: bottom-right of the primary monitor with a 16 px inset. Returns None only when the OS reports zero monitors — defensive; in practice available_monitors() always yields ≥1 when a webview is up.
compute_popover_anchor 🔒
Pure compute step shared by anchor_window_to_click (runtime) and the unit tests (no Tauri). Returns the popover’s target top-left position (anchored top-right of the picked monitor) in screen coordinates, or None if the monitor list is empty.
decode_position 🔒
Parse helper extracted for unit testing. Requires the BUBBLE_POSITION_FORMAT_VERSION prefix so old-format files get rejected (returns None), letting the caller fall through to compute_default_position with the current default-corner rule.
default_recording_output_path
Resolve the default output path for a recording starting now with the given format slug. Returns the absolute path as a string (the JS side feeds it back into start_recording’s output_path if the user doesn’t override).
discard_recording
Discard the pending recording — delete its scratch file and clear the awaiting-export state (M-SAVE.1). No-op when nothing is pending; a missing / unremovable scratch is logged, not surfaced. Returns Result (always Ok today) to keep the IPC signature stable.
encode_position 🔒
Format helper extracted for unit testing.
export_recording
Export the pending recording to output_dir in format, then return the final absolute path (M-SAVE.1 / .2).
get_output_dir
Return the currently-configured output directory — the persisted override if the user set one, otherwise the per-OS default. Always returns an absolute path string (never empty).
latest_camera_frame_bgra
Return the latest BGRA frame from the camera capture slot (M-PIX.8). Used by <CameraPreview />’s 15fps poll to paint the live webcam into the canvas. Returns raw bytes via tauri::ipc::Response so the JS side receives an ArrayBuffer directly (no JSON-array serialization overhead).
latest_screen_frame_bgra
Non-macOS stub for latest_screen_frame_bgra. Always empty.
list_audio_apps
Enumerate every running app SCK can see (M-AUDIO-SYS.2 / AUT-282).
list_cameras
Enumerate attached cameras (M-CAM.2 / AUT-256).
list_microphones
Enumerate attached microphones (M-MIC.1 / AUT-278).
list_screen_displays
Enumerate every display SCK can see (M-SCK.1 / AUT-268). Returns empty Vec on non-macOS targets.
list_screen_windows
Enumerate every visible window SCK can see (M-SCK.1 / AUT-268).
load_bubble_position 🔒
Load BubblePosition from disk; returns None on missing file, I/O error, or malformed contents.
mic_status
Snapshot the current mic-capture lifecycle (M-MIC.1 / AUT-278).
microphone_permission_status
Probe the OS for microphone permission (M-MIC.2 / AUT-279 + M-RECP.7 / AUT-285).
open_settings_camera
Shell out to open System Settings → Privacy & Security → Camera. Falls back to a no-op on Linux (no universal Settings deep-link).
open_settings_microphone
Shell out to open System Settings → Privacy & Security → Microphone. Linux no-op.
open_settings_pane 🔒
Shared shell-out helper. Resolves the OS-specific argv from open_command and spawns it. Returns Ok(()) even when no deep-link is known for the pane on this OS (Linux, or Screen Recording on Windows) — the caller treats “no error” as “instruction displayed.”
open_settings_screen_recording
Shell out to open System Settings → Privacy & Security → Screen Recording. macOS only — Windows + Linux return a no-op Ok(()) because neither has a system-level Screen Recording pane the recorder can deep-link to.
pick_output_dir
Open a native folder picker and return the chosen absolute path, or None if the user cancelled. Does not persist the choice — the caller (set_output_dir) does. Opens at the current configured directory when it exists.
player_open
Open a video file and start it paused at frame 0.
player_pause
Pause playback. No-op when nothing is loaded.
player_play
Resume playback. No-op when nothing is loaded.
player_status
Snapshot the current status. The shell normally subscribes to the pushed player-status events instead of polling, but this command is useful on initial mount to seed the UI before the first event.
preview_diagnostics
Snapshot the camera-pipeline diagnostics (M-CAM.3 / AUT-257 diagnostic addition).
preview_status
Snapshot the current preview lifecycle (M-CAM.2 / AUT-256).
recording_pending_export
The recording currently sitting in scratch awaiting export, if any (M-SAVE.1). The Save panel polls this on mount (and after stop_recording) to decide whether to appear. None when nothing is awaiting export.
recording_status
Live snapshot of the recording session for the picker LED ramp
request_all_permissions
Proactively request macOS TCC permissions for all four protected resources (M-PIX.9 of M-RECORD-EXPORT-REAL-PIXELS). Fires the OS-level prompts that register com.screen.app in the TCC database — without this, pickers enumerate empty on first launch because no entry exists yet.
request_screen_recording_permission
Proactively trigger the Screen Recording TCC request.
restore_bubble_position 🔒
Look up the bubble window’s last-known position (in-memory first; then disk; then default_position on the primary monitor) and apply it via set_position BEFORE show() so the window doesn’t flicker through a stale OS-default location.
reveal_recording_in_file_manager
Open the OS file manager focused on the given recording file (M-EXPORT.4). macOS: open -R. Windows: explorer /select,. Linux: xdg-open <parent-dir> (no portable “select” verb).
rollback_started 🔒
Roll back partially-started channels after a per-channel start failure mid-session. Best-effort — each stop swallows its own errors since we’re already on the error path.
save_bubble_position 🔒
Persist pos to disk. Creates the app-config dir if it doesn’t exist yet (first-ever app launch).
scratch_dir 🔒
Directory for in-progress / awaiting-export scratch recordings (M-SAVE.1). Under the app cache dir so it’s app-scoped and on the home volume (so the export rename into ~/Movies/Screen etc. is atomic rather than a cross-device copy). None only if the platform path resolver fails.
scratch_file_path 🔒
Scratch file path for session_idscratch-<id>.mp4. The scratch is always MP4/H.264 (the canonical intermediate the Save panel moves or transcodes).
screen_capture_frame_count
Non-macOS stub. Always 0.
screen_capture_status
Non-macOS stub for screen_capture_status. Always false.
screen_recording_permission_status
Query the platform Screen Recording grant without touching SCK.
set_bubble_clickthrough
Toggle whether the webcam-bubble window passes mouse events through to whatever’s underneath (M-BUBBLE.1 v0 / AUT-274).
set_output_dir
Persist dir as the default output directory for future recordings. An empty / whitespace-only string clears the override, reverting to the per-OS default.
set_system_audio_filter
Non-macOS stub for set_system_audio_filter. Returns the same “not supported” error as the start command so the Leptos picker can surface a consistent message on every platform.
set_webcam_bubble_visibility
Explicit setter for the webcam bubble visibility. ISS-05 — the recorder’s camera_enabled RwSignal defaults to true while BubbleVisibility::default() is Hidden, so the always-flip toggle_webcam_bubble path was one click out of phase from every page mount. The setter aligns the bubble to the caller’s source of truth instead, and no-ops when already in the requested state — safe to spam from a reactive subscription.
snapshot_and_persist_bubble_position 🔒
Read the window’s current outer position, store it in the in-memory state, and persist to disk. Called on Hide so a subsequent show (this session OR a later launch) restores the user’s chosen position.
spawn_status_emitter 🔒
Spawn the 500 ms event-push thread. Loops emitting recording-status until the session is gone from RecordingState. Self-terminates on session end so callers don’t need to track the JoinHandle. Plain std::thread rather than a tokio task — Tauri’s Emitter is sync-friendly and avoids adding a direct tokio dep (Tauri uses tokio internally but doesn’t re-export tokio::time::interval).
start_camera_for_session 🔒
Direct-call equivalent of start_preview — bypasses the #[tauri::command] layer so the session orchestrator can coordinate with the existing PreviewState lifecycle.
start_mic_capture
Start the microphone capture worker (M-MIC.1 / AUT-278).
start_mic_for_session 🔒
start_preview
Start the camera preview pipeline (M-CAM.2 / AUT-256).
start_recording
Start a coordinated recording session (M-RECORD.1 of M-RECORD-EXPORT).
start_screen_capture
Non-macOS stub for start_screen_capture. Returns the requires-macOS-13.0 error so the Leptos picker surfaces a consistent message across platforms. Signature matches the macOS variant so the IPC schema stays uniform.
start_system_audio_capture
Non-macOS stub for start_system_audio_capture. Returns a “not supported” error so the Leptos picker can show the user they’re on the wrong platform.
stop_camera_for_session 🔒
stop_mic_capture
Stop the microphone capture worker (M-MIC.1 / AUT-278).
stop_mic_for_session 🔒
stop_preview
Stop the camera preview pipeline (M-CAM.2 / AUT-256 + M-CAM.3 / AUT-257).
stop_recording
Stop the active recording session (M-RECORD.1).
stop_screen_capture
Non-macOS stub for stop_screen_capture. No-op.
stop_system_audio_capture
Non-macOS stub for stop_system_audio_capture. No-op since no session can have been started on this platform.
system_audio_status
Non-macOS stub for system_audio_status. Always returns false since no session can have been started on this platform.
toggle_tray_popover
Pure function variant of tray_toggle_popover — not a Tauri command. Calls toggle_tray_popover_at with no click position so the window opens at its previous position (or the OS-default position on first show). Used by the IPC bus and the no-position fallback for synthetic clicks in tests.
toggle_tray_popover_at
Like toggle_tray_popover but anchors the popover under click_position (M-RECP.1 / AUT-262 wiring). When the state machine resolves to Action::Show AND click_position is set, we look up the monitor the click happened on, compute the below-click anchor, and set_position BEFORE showing the window. Without the explicit set_position Tauri restores the last-known position (or the OS default), which is the source of the “popover doesn’t follow the tray icon” bug.
toggle_webcam_bubble
Webcam-bubble toggle command (M-BUBBLE.0 / AUT-273).
tray_toggle_popover
Tray-popover toggle command (M-TRAY.0 / AUT-249).
update_bubble_position_from_event
Update the bubble window’s in-memory position cache. Called from main.rs’s on_window_event handler whenever the user drags the bubble. Persistence happens on Hide (not on every Moved) to avoid hammering the disk during a drag — per-frame Moved events on macOS would otherwise cause thousands of writes per drag.
window_dims 🔒
Resolve the window’s physical inner-size into integer width/height, falling back to the tauri.conf.json declared 200×200 if the live query fails.