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§
- Audio
AppView - 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 inmedia. - Bubble
State - 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.
- Camera
View - View-model shape for the camera-list IPC command (M-CAM.2 /
AUT-256). Mirrors
media::CameraDevicebut lives incrates/app/so the IPC schema is owned by the shell crate rather than the media crate. - Display
Source View - View-model for a display source (M-SCK.1 / AUT-268). Mirrors
media::screen::DisplaySourcebut lives in the shell crate so the IPC schema is owned here. - Microphone
View - View-model shape for the microphone-list IPC command (M-MIC.1 /
AUT-278). Mirrors [
media::MicrophoneDevice] but lives incrates/app/so the IPC schema is owned by the shell crate. Same shape contract asCameraViewkeeps the Leptos-side picker code symmetrical between camera + mic. - Request
Permissions Result - IPC view for the M-PIX.9 batch-request result. Each field is the post-prompt status the OS reported.
- Tray
State - Tauri-managed wrapper around the tray-popover toggle state machine
(M-TRAY.0 / AUT-249). Held in
tauri::Stateso the click handler inmain.rsand thetray_toggle_popovercommand share one source of truth.Mutexrather thanparking_lot::Mutexto avoid adding a new workspace dep just for the tray; contention is non-existent (only the click handler ever touches it). - Window
Source View - View-model for a window source (M-SCK.1 / AUT-268).
Enums§
- Audio
AppFilter View - 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. - Camera
Permission - Camera permission probe (M-CAM.2 / AUT-256). Stub-returns
Grantedon every platform today; full macOS implementation viaAVCaptureDevice.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.jsondeclares 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_positionto reject any file written by an earlier version, which falls through tocompute_default_positionand re-applies the current default-corner rule (M-BUBBLE.3 originally shipped bottom-right; the design pass moved the default to bottom-left, and stalev1files were keeping the bubble in the old corner).
Functions§
- __
test_ drag_ enter - Test-only entry point: synthesize a
DragDropEvent::Enterfor theWebDrivere2e suite. Emits the samefile-drag-enterevent 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
WebDrivere2e suites. Emits afile-droppedevent with the same shape as the real OS drag-drop handler inmain.rs. Gated ondebug_assertionsso it’s stripped from release builds;main.rslikewise registers it conditionally ingenerate_handler!. - anchor_
window_ 🔒to_ click - Pick the right monitor for
(click_x, click_y)and place thetray-popoverwindow’s top-left below the click. Logs and bails out without setting a position when monitors can’t be queried — the window will stillshow()at its last-known position so the user doesn’t lose access to the recorder. - apply_
bubble_ 🔒action - Execute a
BubbleActionagainst 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 systemouter_position()returns + the same coordinate systemMonitorBoundsis in, percrate::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 avoidserde_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
StreamHealthsnapshot by querying each enabled channel’s existing State<> handle. Called by bothrecording_status(live polling) andstop_recording(final summary).last_frame_ms_agois leftNonefor now — the per-channel handles don’t yet expose alast_frame_attimestamp (TODO M-RECORD-EXPORT follow-up; M-RECORD.2’s LED ramp already handlesNoneas “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
MonitorBoundsvec fromapp.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
Noneonly when the OS reports zero monitors — defensive; in practiceavailable_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, orNoneif the monitor list is empty. - decode_
position 🔒 - Parse helper extracted for unit testing. Requires the
BUBBLE_POSITION_FORMAT_VERSIONprefix so old-format files get rejected (returnsNone), letting the caller fall through tocompute_default_positionwith 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’soutput_pathif 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(alwaysOktoday) to keep the IPC signature stable. - encode_
position 🔒 - Format helper extracted for unit testing.
- export_
recording - Export the pending recording to
output_dirinformat, 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 viatauri::ipc::Responseso the JS side receives anArrayBufferdirectly (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
BubblePositionfrom disk; returnsNoneon 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_commandand spawns it. ReturnsOk(())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
Noneif 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-statusevents 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.Nonewhen 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.appin 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_positionon the primary monitor) and apply it viaset_positionBEFOREshow()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
posto 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
renameinto~/Movies/Screenetc. is atomic rather than a cross-device copy).Noneonly if the platform path resolver fails. - scratch_
file_ 🔒path - Scratch file path for
session_id—scratch-<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. Alwaysfalse. - 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
diras 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_enabledRwSignaldefaults totruewhileBubbleVisibility::default()isHidden, so the always-fliptoggle_webcam_bubblepath 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-statusuntil the session is gone fromRecordingState. Self-terminates on session end so callers don’t need to track theJoinHandle. Plainstd::threadrather than a tokio task — Tauri’sEmitteris sync-friendly and avoids adding a direct tokio dep (Tauri uses tokio internally but doesn’t re-exporttokio::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 existingPreviewStatelifecycle. - 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 returnsfalsesince no session can have been started on this platform. - toggle_
tray_ popover - Pure function variant of
tray_toggle_popover— not a Tauri command. Callstoggle_tray_popover_atwith 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_popoverbut anchors the popover underclick_position(M-RECP.1 / AUT-262 wiring). When the state machine resolves toAction::ShowANDclick_positionis set, we look up the monitor the click happened on, compute the below-click anchor, andset_positionBEFORE showing the window. Without the explicitset_positionTauri 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’son_window_eventhandler whenever the user drags the bubble. Persistence happens on Hide (not on every Moved) to avoid hammering the disk during a drag — per-frameMovedevents 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.jsondeclared 200×200 if the live query fails.