Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ scap-screencapturekit = { path = "../../../crates/scap-screencapturekit" }
scap-direct3d = { path = "../../../crates/scap-direct3d" }

flume.workspace = true
zip = { version = "4", default-features = false, features = ["deflate"] }
walkdir = "2"
tracing-subscriber = "0.3.19"
tracing-appender = "0.2.3"
dirs = "6.0.0"
Expand Down
4 changes: 4 additions & 0 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ mod recording_settings;
mod recording_telemetry;
mod recovery;
mod screenshot_editor;
mod session_profile;
mod target_select_overlay;
mod thumbnails;
mod tray;
Expand Down Expand Up @@ -4278,6 +4279,8 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
set_native_camera_preview_enabled,
recording_settings::set_recording_mode,
upload_logs,
session_profile::get_session_profile_status,
session_profile::upload_session_profile,
get_system_diagnostics,
cli::get_cli_install_status,
cli::install_cli,
Expand Down Expand Up @@ -4443,6 +4446,7 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
import::VideoImportProgress,
SetCaptureAreaPending,
DevicesUpdated,
session_profile::SessionProfileProgress,
])
.error_handling(tauri_specta::ErrorHandlingMode::Throw)
.typ::<ProjectConfiguration>()
Expand Down
145 changes: 142 additions & 3 deletions apps/desktop/src-tauri/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde::Serialize;
use std::{fs, path::PathBuf};
use tauri::{AppHandle, Manager};

async fn get_latest_log_file(app: &AppHandle) -> Option<PathBuf> {
pub async fn get_latest_log_file(app: &AppHandle) -> Option<PathBuf> {
let logs_dir = app
.state::<ArcLock<crate::App>>()
.read()
Expand Down Expand Up @@ -36,7 +36,7 @@ async fn get_latest_log_file(app: &AppHandle) -> Option<PathBuf> {

#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct LogUploadDiagnostics {
pub struct LogUploadDiagnostics {
hardware: HardwareInfo,
system: cap_recording::diagnostics::SystemDiagnostics,
displays: Vec<DisplayDiagnostics>,
Expand Down Expand Up @@ -130,7 +130,7 @@ fn collect_storage_info(recordings_path: &std::path::Path) -> Option<StorageInfo
})
}

fn collect_diagnostics_for_upload(
pub fn collect_diagnostics_for_upload(
recordings_dir: &std::path::Path,
app_data_dir: &std::path::Path,
is_recording: bool,
Expand Down Expand Up @@ -171,6 +171,145 @@ fn collect_diagnostics_for_upload(
}
}

/// Builds a concise, human-readable Markdown summary of the collected
/// diagnostics suitable for posting to chat (e.g. Discord). The full
/// machine-readable diagnostics should still be shipped alongside this.
pub fn summarize_diagnostics(diagnostics: &LogUploadDiagnostics) -> String {
let value = serde_json::to_value(diagnostics).unwrap_or(serde_json::Value::Null);
let mut lines: Vec<String> = Vec::new();

if let Some(hardware) = value.get("hardware") {
let cpu = hardware
.get("cpuBrand")
.and_then(|v| v.as_str())
.unwrap_or("Unknown");
let cores = hardware
.get("cpuCores")
.and_then(|v| v.as_u64())
.unwrap_or(0);
let arch = hardware
.get("architecture")
.and_then(|v| v.as_str())
.unwrap_or("");
lines.push(format!("**CPU:** {cpu} ({cores} cores, {arch})"));

let total = hardware
.get("totalMemoryMb")
.and_then(|v| v.as_u64())
.unwrap_or(0);
let available = hardware
.get("availableMemoryMb")
.and_then(|v| v.as_u64())
.unwrap_or(0);
lines.push(format!("**Memory:** {available} MB free / {total} MB"));
}

let system = value.get("system");

let os_line = system
.and_then(|s| s.get("macosVersion"))
.and_then(|v| v.get("displayName"))
.and_then(|v| v.as_str())
.or_else(|| {
system
.and_then(|s| s.get("windowsVersion"))
.and_then(|v| v.get("displayName"))
.and_then(|v| v.as_str())
});
if let Some(os) = os_line {
lines.push(format!("**OS:** {os}"));
} else if let Some(kernel) = system
.and_then(|s| s.get("kernelVersion"))
.and_then(|v| v.as_str())
{
lines.push(format!("**Kernel:** {kernel}"));
}

let gpu = system
.and_then(|s| s.get("gpuName"))
.and_then(|v| v.as_str())
.or_else(|| {
system
.and_then(|s| s.get("gpuInfo"))
.and_then(|v| v.get("description"))
.and_then(|v| v.as_str())
});
if let Some(gpu) = gpu {
lines.push(format!("**GPU:** {gpu}"));
}

if let Some(encoders) = system
.and_then(|s| s.get("availableEncoders"))
.and_then(|v| v.as_array())
{
let list: Vec<&str> = encoders.iter().filter_map(|e| e.as_str()).collect();
if !list.is_empty() {
lines.push(format!("**Encoders:** {}", list.join(", ")));
}
}

let capture_supported = system
.and_then(|s| s.get("screenCaptureSupported"))
.and_then(|v| v.as_bool())
.or_else(|| {
system
.and_then(|s| s.get("graphicsCaptureSupported"))
.and_then(|v| v.as_bool())
});
if let Some(supported) = capture_supported {
lines.push(format!(
"**Screen Capture:** {}",
if supported {
"✅ Supported"
} else {
"❌ Not Supported"
}
));
}

if let Some(displays) = value.get("displays").and_then(|v| v.as_array()) {
lines.push(format!("**Displays:** {}", displays.len()));
}
if let Some(cameras) = value.get("cameras").and_then(|v| v.as_array()) {
lines.push(format!("**Cameras:** {}", cameras.len()));
}
if let Some(microphones) = value.get("microphones").and_then(|v| v.as_array()) {
lines.push(format!("**Mics:** {}", microphones.len()));
}

if let Some(permissions) = value.get("permissions") {
let screen = permissions
.get("screenRecording")
.and_then(|v| v.as_str())
.unwrap_or("?");
let camera = permissions
.get("camera")
.and_then(|v| v.as_str())
.unwrap_or("?");
let microphone = permissions
.get("microphone")
.and_then(|v| v.as_str())
.unwrap_or("?");
lines.push(format!(
"**Permissions:** Screen: {screen}, Camera: {camera}, Mic: {microphone}"
));
}

if let Some(storage) = value.get("storage").filter(|v| !v.is_null()) {
let available = storage
.get("availableSpaceMb")
.and_then(|v| v.as_u64())
.unwrap_or(0);
let total = storage
.get("totalSpaceMb")
.and_then(|v| v.as_u64())
.unwrap_or(0);
lines.push(format!("**Disk:** {available} MB free / {total} MB"));
}

lines.join("\n")
}

pub async fn upload_log_file(app: &AppHandle) -> Result<(), String> {
let log_file = get_latest_log_file(app).await.ok_or("No log file found")?;

Expand Down
Loading
Loading