diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 21229e4..4b9e0c2 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -14,7 +14,7 @@ crate-type = ["staticlib", "cdylib", "rlib"] tauri-build = { version = "2", features = [] } [dependencies] -tauri = { version = "2", features = ["protocol-asset"] } +tauri = { version = "2", features = ["protocol-asset", "devtools"] } tauri-plugin-opener = "2" serde = { version = "1", features = ["derive"] } serde_json = "1" diff --git a/src-tauri/src/commands/system.rs b/src-tauri/src/commands/system.rs index 985b465..1071fcc 100644 --- a/src-tauri/src/commands/system.rs +++ b/src-tauri/src/commands/system.rs @@ -60,3 +60,18 @@ pub fn llama_list_models() -> Value { pub fn get_data_dir() -> String { LlamaManager::data_dir().to_string_lossy().to_string() } + +/// Log a message from the frontend to a file for debugging. +#[tauri::command] +pub fn log_frontend(level: String, message: String) { + use std::io::Write; + let log_path = LlamaManager::data_dir().join("frontend.log"); + if let Ok(mut file) = std::fs::OpenOptions::new() + .create(true) + .append(true) + .open(&log_path) + { + let timestamp = chrono::Local::now().format("%Y-%m-%d %H:%M:%S"); + let _ = writeln!(file, "[{timestamp}] [{level}] {message}"); + } +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 380e57c..05eed99 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -15,7 +15,9 @@ use commands::project::{ }; use commands::settings::{load_settings, save_settings}; use commands::sidecar::{check_sidecar, check_sidecar_update, download_sidecar}; -use commands::system::{get_data_dir, llama_list_models, llama_start, llama_status, llama_stop}; +use commands::system::{ + get_data_dir, llama_list_models, llama_start, llama_status, llama_stop, log_frontend, +}; use commands::transcribe::{download_diarize_model, run_pipeline, transcribe_file}; use state::AppState; @@ -39,6 +41,8 @@ pub fn run() { // Set the webview background to match the app's dark theme if let Some(window) = app.get_webview_window("main") { let _ = window.set_background_color(Some(Color(10, 10, 35, 255))); + // Enable right-click → Inspect (requires "devtools" feature in Cargo.toml) + window.open_devtools(); } Ok(()) }) @@ -69,6 +73,7 @@ pub fn run() { check_sidecar, download_sidecar, check_sidecar_update, + log_frontend, ]) .run(tauri::generate_context!()) .expect("error while running tauri application");