diff --git a/Cargo.lock b/Cargo.lock index 0126ee50..5e1266ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -1303,7 +1303,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" dependencies = [ - "libloading 0.8.5", + "libloading 0.7.4", ] [[package]] @@ -1517,7 +1517,7 @@ dependencies = [ [[package]] name = "eyre" version = "1.0.0" -source = "git+https://github.com/thewh1teagle/eyre?branch=feat/report-serialize-backtrace#8a0b71c8de62efcab7408fff8e6dc29ba7e5b59a" +source = "git+https://github.com/thewh1teagle/eyre?branch=feat%2Freport-serialize-backtrace#8a0b71c8de62efcab7408fff8e6dc29ba7e5b59a" dependencies = [ "indenter", "once_cell", @@ -6590,6 +6590,7 @@ dependencies = [ "crash-handler", "eyre 1.0.0", "futures", + "glob", "hound", "libc", "libc-stdhandle", @@ -6634,6 +6635,7 @@ dependencies = [ name = "vibe_core" version = "0.0.6" dependencies = [ + "chrono", "eyre 1.0.0", "futures-util", "glob", @@ -6976,8 +6978,8 @@ dependencies = [ [[package]] name = "whisper-rs" -version = "0.13.0" -source = "git+https://github.com/thewh1teagle/whisper-rs.git?rev=4585bb#4585bb82420c97ec0b5a39f7d94fd2bc0fd73138" +version = "0.13.1" +source = "git+https://github.com/thewh1teagle/whisper-rs.git?branch=dev#a957d6ae6ef64c4b9c956f2423907c157deb3335" dependencies = [ "tracing", "whisper-rs-sys", @@ -6985,8 +6987,8 @@ dependencies = [ [[package]] name = "whisper-rs-sys" -version = "0.11.0" -source = "git+https://github.com/thewh1teagle/whisper-rs.git?rev=4585bb#4585bb82420c97ec0b5a39f7d94fd2bc0fd73138" +version = "0.11.1" +source = "git+https://github.com/thewh1teagle/whisper-rs.git?branch=dev#a957d6ae6ef64c4b9c956f2423907c157deb3335" dependencies = [ "bindgen 0.69.5", "cfg-if", diff --git a/core/Cargo.toml b/core/Cargo.toml index 1088353c..710b2898 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -11,7 +11,7 @@ path = "src/lib.rs" # Fixed incorrect timestamps, better logs whisper-rs = { git = "https://github.com/thewh1teagle/whisper-rs.git", features = [ "whisper-cpp-tracing", -], default-features = false, rev = "4585bb" } +], default-features = false, branch = "dev" } serde = { version = "1.0.195", features = ["derive"] } num = "0.4.1" once_cell = "1.19.0" @@ -21,6 +21,7 @@ eyre = { workspace = true } hound = "3.5.1" reqwest = { version = "0.11.23", features = ["stream"] } tempfile = "3.9.0" +chrono = "0.4.38" tokio = { version = "1.35.1", features = [ "tokio-macros", "macros", diff --git a/core/src/lib.rs b/core/src/lib.rs index f4d06555..7b34f151 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -6,3 +6,14 @@ pub mod transcript; #[cfg(test)] mod test; + +pub fn get_vibe_temp_folder() -> std::path::PathBuf { + use chrono::Local; + let current_datetime = Local::now(); + let formatted_datetime = current_datetime.format("%Y-%m-%d").to_string(); + let dir = std::env::temp_dir().join(format!("vibe_temp_{}", formatted_datetime)); + if let Ok(_) = std::fs::create_dir_all(&dir) { + return dir; + } + std::env::temp_dir() +} diff --git a/core/src/transcribe.rs b/core/src/transcribe.rs index a99ae804..260f550b 100644 --- a/core/src/transcribe.rs +++ b/core/src/transcribe.rs @@ -1,6 +1,6 @@ -use crate::audio; use crate::config::TranscribeOptions; use crate::transcript::{Segment, Transcript}; +use crate::{audio, get_vibe_temp_folder}; use eyre::{bail, eyre, Context, OptionExt, Result}; use hound::WavReader; use std::collections::hash_map::DefaultHasher; @@ -81,7 +81,7 @@ pub fn create_normalized_audio(source: PathBuf, additional_ffmpeg_args: Option result.collect(), Err(error) => { tracing::error!("error: {:?}", error); - tracing::debug!( + tracing::trace!( "start = {:.2}, end = {:.2}, speaker = ?", diarize_segment.start, diarize_segment.end @@ -247,9 +247,9 @@ pub fn transcribe( new_segment_callback(segment); } if let Some(ref progress_callback) = progress_callback { - tracing::debug!("progress: {} * {} / 100", i, diarize_segments.len()); + tracing::trace!("progress: {} * {} / 100", i, diarize_segments.len()); let progress = ((i + 1) as f64 / diarize_segments.len() as f64 * 100.0) as i32; - tracing::debug!("progress diarize: {}", progress); + tracing::trace!("progress diarize: {}", progress); progress_callback(progress); } } @@ -283,7 +283,7 @@ pub fn transcribe( if PROGRESS_CALLBACK.lock().map_err(|e| eyre!("{:?}", e))?.as_ref().is_some() { params.set_progress_callback_safe(|progress| { // using move here lead to crash - tracing::debug!("progress callback {}", progress); + tracing::trace!("progress callback {}", progress); match PROGRESS_CALLBACK.lock() { Ok(callback_guard) => { if let Some(progress_callback) = callback_guard.as_ref() { @@ -330,10 +330,5 @@ pub fn transcribe( processing_time_sec: Instant::now().duration_since(st).as_secs(), }; - // cleanup - if out_path.starts_with(std::env::temp_dir()) { - std::fs::remove_file(out_path)?; - } - Ok(transcript) } diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml index 33ecd6ef..81283b00 100644 --- a/desktop/src-tauri/Cargo.toml +++ b/desktop/src-tauri/Cargo.toml @@ -52,6 +52,7 @@ utoipa-swagger-ui = { version = "7.1.0", features = ["axum"], optional = true } tracing = { version = "0.1.40", features = ["log"] } tracing-log = "0.2.0" tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] } +glob = "0.3.1" chrono = "0.4.38" crash-handler = "0.6.2" diff --git a/desktop/src-tauri/src/cleaner.rs b/desktop/src-tauri/src/cleaner.rs new file mode 100644 index 00000000..322d4c82 --- /dev/null +++ b/desktop/src-tauri/src/cleaner.rs @@ -0,0 +1,57 @@ +use crate::utils::LogError; +use crate::{cmd::get_logs_folder, config, logging::get_log_path}; +use eyre::{eyre, ContextCompat, Result}; +use vibe_core::get_vibe_temp_folder; + +pub fn clean_old_logs(app: &tauri::AppHandle) -> Result<()> { + tracing::debug!("clean old logs"); + let current_log_path = get_log_path(&app.clone())?; + + // Get logs folder + let logs_folder = get_logs_folder(app.to_owned())?; + let logs_folder = logs_folder.to_str().context("tostr")?; + + // Remove suffix + let logs_folder = logs_folder.strip_suffix('/').unwrap_or(logs_folder); + let logs_folder = logs_folder.strip_suffix('\\').unwrap_or(logs_folder); + let pattern = format!( + "{}/{}*{}", + logs_folder, + config::LOG_FILENAME_PREFIX, + config::LOG_FILENAME_SUFFIX + ); + tracing::debug!("searching old logs in {}", pattern); + for path in glob::glob(&pattern)? { + let path = path?; + if path == current_log_path { + tracing::debug!("Skip clean of current log path {}", path.display()); + continue; + } + tracing::debug!("clean old log {}", path.display()); + std::fs::remove_file(path)?; + } + Ok(()) +} + +pub fn clean_old_files() -> Result<()> { + let current_temp_dir = get_vibe_temp_folder(); + let temp_dir = std::env::temp_dir(); + let temp_dir = temp_dir.to_str().unwrap_or_default(); + // Remove suffix + let temp_dir = temp_dir.strip_suffix('/').unwrap_or(temp_dir); + let temp_dir = temp_dir.strip_suffix('\\').unwrap_or(temp_dir); + let pattern = format!("{}/vibe_temp*", temp_dir); + tracing::debug!("searching old files in {}", pattern); + for path in glob::glob(&pattern)? { + let path = path?; + if path == current_temp_dir { + tracing::debug!("Skip deletion of {}", current_temp_dir.display()); + continue; + } + tracing::debug!("Clean old folder {}", path.clone().display()); + std::fs::remove_dir_all(path.clone()) + .map_err(|e| eyre!("failed to delete {}: {:?}", path.display(), e)) + .log_error(); + } + Ok(()) +} diff --git a/desktop/src-tauri/src/cmd/audio.rs b/desktop/src-tauri/src/cmd/audio.rs index 70f72e1b..42402ecd 100644 --- a/desktop/src-tauri/src/cmd/audio.rs +++ b/desktop/src-tauri/src/cmd/audio.rs @@ -8,6 +8,7 @@ use std::io::BufWriter; use std::path::PathBuf; use std::sync::{Arc, Mutex}; use tauri::{AppHandle, Emitter, Listener, Manager}; +use vibe_core::get_vibe_temp_folder; #[cfg(target_os = "macos")] use crate::screen_capture_kit; @@ -108,7 +109,7 @@ pub async fn start_record(app_handle: AppHandle, devices: Vec, stor }; let spec = wav_spec_from_config(&config); - let path = std::env::temp_dir().join(format!("{}.wav", random_string(10))); + let path = get_vibe_temp_folder().join(format!("{}.wav", random_string(10))); tracing::debug!("WAV file path: {:?}", path); wav_paths.push((path.clone(), 0)); @@ -125,7 +126,7 @@ pub async fn start_record(app_handle: AppHandle, devices: Vec, stor cpal::SampleFormat::I8 => device.build_input_stream( &config.into(), move |data, _: &_| { - tracing::debug!("Writing input data (I8)"); + tracing::trace!("Writing input data (I8)"); write_input_data::(data, &writer_2) }, err_fn, @@ -134,7 +135,7 @@ pub async fn start_record(app_handle: AppHandle, devices: Vec, stor cpal::SampleFormat::I16 => device.build_input_stream( &config.into(), move |data, _: &_| { - tracing::debug!("Writing input data (I16)"); + tracing::trace!("Writing input data (I16)"); write_input_data::(data, &writer_2) }, err_fn, @@ -143,7 +144,7 @@ pub async fn start_record(app_handle: AppHandle, devices: Vec, stor cpal::SampleFormat::I32 => device.build_input_stream( &config.into(), move |data, _: &_| { - tracing::debug!("Writing input data (I32)"); + tracing::trace!("Writing input data (I32)"); write_input_data::(data, &writer_2) }, err_fn, @@ -152,7 +153,7 @@ pub async fn start_record(app_handle: AppHandle, devices: Vec, stor cpal::SampleFormat::F32 => device.build_input_stream( &config.into(), move |data, _: &_| { - tracing::debug!("Writing input data (F32)"); + tracing::trace!("Writing input data (F32)"); write_input_data::(data, &writer_2) }, err_fn, @@ -194,7 +195,7 @@ pub async fn start_record(app_handle: AppHandle, devices: Vec, stor { if let Some(stream) = screencapture_stream { screen_capture_kit::stop_capture(&stream).map_err(|e| eyre!("{:?}", e)).log_error(); - let output_path = std::env::temp_dir().join(format!("{}.wav", random_string(5))); + let output_path = get_vibe_temp_folder().join(format!("{}.wav", random_string(5))); screen_capture_kit::screencapturekit_to_wav(output_path.clone()).map_err(|e| eyre!("{e:?}")).log_error(); tracing::debug!("output path is {}", output_path.display()); wav_paths.push((output_path, 1)); @@ -204,7 +205,7 @@ pub async fn start_record(app_handle: AppHandle, devices: Vec, stor let dst = if wav_paths.len() == 1 { wav_paths[0].0.clone() } else if wav_paths[0].1 > 0 && wav_paths[1].1 > 0 { - let dst = std::env::temp_dir().join(format!("{}.wav", random_string(10))); + let dst = get_vibe_temp_folder().join(format!("{}.wav", random_string(10))); tracing::debug!("Merging WAV files"); vibe_core::audio::merge_wav_files(wav_paths[0].0.clone(), wav_paths[1].0.clone(), dst.clone()).map_err(|e| eyre!("{e:?}")).log_error(); dst @@ -218,7 +219,7 @@ pub async fn start_record(app_handle: AppHandle, devices: Vec, stor }; tracing::debug!("Emitting record_finish event"); - let mut normalized = std::env::temp_dir().join(format!("{}.wav", get_local_time())); + let mut normalized = get_vibe_temp_folder().join(format!("{}.wav", get_local_time())); vibe_core::audio::normalize(dst.clone(), normalized.clone(), None).map_err(|e| eyre!("{e:?}")).log_error(); if store_in_documents { diff --git a/desktop/src-tauri/src/cmd/mod.rs b/desktop/src-tauri/src/cmd/mod.rs index 7c25ee0c..293ce0b3 100644 --- a/desktop/src-tauri/src/cmd/mod.rs +++ b/desktop/src-tauri/src/cmd/mod.rs @@ -117,7 +117,7 @@ pub async fn download_model(app_handle: tauri::AppHandle, url: Option) - // Update progress in background tauri::async_runtime::spawn(async move { let percentage = (current as f64 / total as f64) * 100.0; - tracing::debug!("percentage: {}", percentage); + tracing::trace!("percentage: {}", percentage); if let Err(e) = set_progress_bar(&app_handle, Some(percentage)) { tracing::error!("Failed to set progress bar: {}", e); } @@ -179,7 +179,7 @@ pub async fn download_file(app_handle: tauri::AppHandle, url: String, path: Stri // Update progress in background tauri::async_runtime::spawn(async move { let percentage = (current as f64 / total as f64) * 100.0; - tracing::debug!("percentage: {}", percentage); + tracing::trace!("percentage: {}", percentage); if let Some(window) = app_handle.get_webview_window("main") { if let Err(e) = window.emit("download_progress", (current, total)) { tracing::error!("Failed to emit download progress: {}", e); @@ -276,7 +276,6 @@ pub async fn transcribe( let app_handle_c = app_handle.clone(); let app_handle_c1 = app_handle.clone(); let progress_callback = move |progress: i32| { - // tracing::debug!("desktop progress is {}", progress); let _ = set_progress_bar(&app_handle, Some(progress.into())); }; @@ -489,6 +488,19 @@ pub fn get_logs_folder(app_handle: tauri::AppHandle) -> Result { Ok(config_path) } +#[tauri::command] +pub async fn show_log_path(app_handle: tauri::AppHandle) -> Result<()> { + let log_path = crate::logging::get_log_path(&app_handle)?; + if log_path.exists() { + showfile::show_path_in_file_manager(log_path); + } else { + if let Some(parent) = log_path.parent() { + showfile::show_path_in_file_manager(parent); + } + } + Ok(()) +} + #[tauri::command] pub fn get_models_folder(app_handle: tauri::AppHandle) -> Result { let store = app_handle.store(STORE_FILENAME)?; diff --git a/desktop/src-tauri/src/cmd/ytdlp.rs b/desktop/src-tauri/src/cmd/ytdlp.rs index 1f85e7a5..63a1439b 100644 --- a/desktop/src-tauri/src/cmd/ytdlp.rs +++ b/desktop/src-tauri/src/cmd/ytdlp.rs @@ -1,5 +1,6 @@ use eyre::{bail, Context, Result}; use tauri::{AppHandle, Manager}; +use vibe_core::get_vibe_temp_folder; use super::get_ffmpeg_path; @@ -22,9 +23,9 @@ fn get_binary_name() -> &'static str { #[tauri::command] pub fn get_temp_path(app_handle: AppHandle, ext: String, in_documents: Option) -> String { let mut base_path = if in_documents.unwrap_or_default() { - app_handle.path().document_dir().unwrap_or(std::env::temp_dir()) + app_handle.path().document_dir().unwrap_or(get_vibe_temp_folder()) } else { - std::env::temp_dir() + get_vibe_temp_folder() }; base_path.push(format!("{}.{}", crate::utils::get_local_time(), ext)); diff --git a/desktop/src-tauri/src/config.rs b/desktop/src-tauri/src/config.rs index cfa55bc4..e5b00dd7 100644 --- a/desktop/src-tauri/src/config.rs +++ b/desktop/src-tauri/src/config.rs @@ -1,5 +1,6 @@ -pub const CRASH_LOG_FILENAME_PREFIX: &str = "crash"; pub const LOG_FILENAME_PREFIX: &str = "log"; +pub const LOG_FILENAME_SUFFIX: &str = ".txt"; +pub const DEFAULT_LOG_DIRECTIVE: &str = "vibe=DEBUG,vibe_core=DEBUG,whisper_rs=INFO"; pub const STORE_FILENAME: &str = "app_config.json"; pub const DEAFULT_MODEL_URL: &str = "https://github.com/thewh1teagle/vibe/releases/download/v0.0.1/ggml-medium.bin"; pub const DEAFULT_MODEL_FILENAME: &str = "ggml-medium.bin"; diff --git a/desktop/src-tauri/src/logging.rs b/desktop/src-tauri/src/logging.rs index 34d01b54..d29177e0 100644 --- a/desktop/src-tauri/src/logging.rs +++ b/desktop/src-tauri/src/logging.rs @@ -1,6 +1,6 @@ use chrono::Local; use eyre::{Context, Result}; -use serde_json::Value; +use std::env; use std::sync::Arc; use std::{fs::OpenOptions, path::PathBuf}; use tauri::{AppHandle, Manager, Wry}; @@ -17,14 +17,19 @@ pub fn get_log_path(app: &AppHandle) -> Result { }; let current_datetime = Local::now(); - let formatted_datetime = current_datetime.format("%Y-%m").to_string(); - let log_filename = format!("{}_{}.txt", config::LOG_FILENAME_PREFIX, formatted_datetime); + let formatted_datetime = current_datetime.format("%Y-%m-%d").to_string(); + let log_filename = format!( + "{}_{}{}", + config::LOG_FILENAME_PREFIX, + formatted_datetime, + config::LOG_FILENAME_SUFFIX + ); let log_path = config_path.join(log_filename); Ok(log_path) } -pub fn setup_logging(app: &AppHandle, store: Arc>) -> Result<()> { +pub fn setup_logging(app: &AppHandle, _store: Arc>) -> Result<()> { let sub = Registry::default().with( tracing_subscriber::fmt::layer() .with_file(true) @@ -33,26 +38,32 @@ pub fn setup_logging(app: &AppHandle, store: Arc>) -> Result<()> { .with_filter(EnvFilter::from_default_env()), ); - if store - .get("prefs_log_to_file") - .unwrap_or(Value::Bool(false)) - .as_bool() - .unwrap_or_default() - { - // with log to file - let path = get_log_path(app)?; - let file = OpenOptions::new() - .create(true) - .append(true) - .open(path.clone()) - .context(format!("failed to open file at {}", path.display()))?; - - let current_datetime = Local::now(); - let formatted_datetime = current_datetime.format("%Y-%m-%d-%H-%M-%S").to_string(); - tracing::debug!("Setup logging to file at {}", formatted_datetime); - tracing::subscriber::set_global_default(sub.with(tracing_subscriber::fmt::layer().json().with_writer(file)))?; - } else { - tracing::subscriber::set_global_default(sub)?; - } + // if store + // .get("prefs_log_to_file") + // .unwrap_or(Value::Bool(false)) + // .as_bool() + // .unwrap_or_default() + + // Enable logs by default. TODO: remove? + let rust_log = env::var("RUST_LOG").unwrap_or_else(|_| config::DEFAULT_LOG_DIRECTIVE.to_owned()); + + let path = get_log_path(app)?; + let file = OpenOptions::new() + .create(true) + .append(true) + .open(path.clone()) + .context(format!("failed to open file at {}", path.display()))?; + tracing::subscriber::set_global_default( + sub.with( + tracing_subscriber::fmt::layer() + .json() + .with_writer(file) + .with_filter(EnvFilter::new(rust_log.clone())), + ), + )?; + + tracing::debug!("LEVEL {}", rust_log); + tracing::debug!("Setup logging to file at {}", path.display()); + // tracing::subscriber::set_global_default(sub)?; Ok(()) } diff --git a/desktop/src-tauri/src/main.rs b/desktop/src-tauri/src/main.rs index 82b6deae..cd0e9ee6 100644 --- a/desktop/src-tauri/src/main.rs +++ b/desktop/src-tauri/src/main.rs @@ -1,6 +1,7 @@ // Prevents additional console window on Windows in release, DO NOT REMOVE!! #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] +mod cleaner; mod cli; mod cmd; mod config; @@ -86,6 +87,7 @@ fn main() -> Result<()> { cmd::is_portable, cmd::check_vulkan, cmd::get_logs_folder, + cmd::show_log_path, cmd::get_ffmpeg_path, cmd::ytdlp::download_audio, cmd::ytdlp::get_temp_path, diff --git a/desktop/src-tauri/src/panic_hook.rs b/desktop/src-tauri/src/panic_hook.rs index 6a0c51e4..97e58b3f 100644 --- a/desktop/src-tauri/src/panic_hook.rs +++ b/desktop/src-tauri/src/panic_hook.rs @@ -1,34 +1,12 @@ -use crate::{ - cmd::is_portable, - config, - utils::{get_current_dir, LogError}, -}; -use chrono::Local; -use eyre::{eyre, Context, Result}; -use std::{panic, path::PathBuf, sync::Arc}; -use tauri::{AppHandle, Manager}; - -fn get_log_path(app: &AppHandle) -> Result { - let config_path = if is_portable() { - get_current_dir()? - } else { - app.path().app_config_dir()? - }; - - let current_datetime = Local::now(); - let formatted_datetime = current_datetime.format("%Y-%m-%d-%H-%M-%S").to_string(); - let log_filename = format!("{}_{}.txt", config::CRASH_LOG_FILENAME_PREFIX, formatted_datetime); - let log_path = config_path.join(log_filename); - - Ok(log_path) -} +use eyre::Result; +use std::{panic, sync::Arc}; +use tauri::AppHandle; pub fn set_panic_hook(app: &AppHandle) -> Result<()> { - let log_path = get_log_path(app)?; + let log_path = crate::logging::get_log_path(app)?; let log_path = Arc::new(log_path); panic::set_hook(Box::new(move |info| { - let log_path = log_path.clone(); let mut message = String::new(); message.push_str(&format!("thread '{}' ", std::thread::current().name().unwrap_or("unknown"))); message.push_str(&format!("{}", info)); @@ -38,13 +16,10 @@ pub fn set_panic_hook(app: &AppHandle) -> Result<()> { message.push_str(&format!("{}", backtrace)); } } + message.push_str(&format!("\nCOMMIT: {}", env!("COMMIT_HASH"))); eprintln!("{}", message); // do whatever with the message - std::fs::write(log_path.as_path(), format!("{}\nCOMMIT: {}", message, env!("COMMIT_HASH"))) - .context("write") - .context("write") - .map_err(|e| eyre!("{:?}", e)) - .log_error(); + tracing::error!(message); // Open the log path in release mode if !cfg!(debug_assertions) && !crate::cli::is_cli_detected() { showfile::show_path_in_file_manager(log_path.as_path()); diff --git a/desktop/src-tauri/src/screen_capture_kit.rs b/desktop/src-tauri/src/screen_capture_kit.rs index a4f0aa0d..a994546d 100644 --- a/desktop/src-tauri/src/screen_capture_kit.rs +++ b/desktop/src-tauri/src/screen_capture_kit.rs @@ -13,6 +13,7 @@ use std::ops::Deref; use std::path::PathBuf; use std::process::{Command, Stdio}; use vibe_core::audio::find_ffmpeg_path; +use vibe_core::get_vibe_temp_folder; use crate::utils::LogError; @@ -31,7 +32,7 @@ impl UnsafeSCStreamOutput for StoreAudioHandler { fn did_output_sample_buffer(&self, sample: Id, _of_type: u8) { let audio_buffers = sample.get_av_audio_buffer_list(); - let base_path = std::env::temp_dir(); + let base_path = get_vibe_temp_folder(); for (i, buffer) in audio_buffers.into_iter().enumerate() { if i > MAX_CHANNELS { @@ -97,7 +98,7 @@ pub fn init() -> Result> { } pub fn start_capture(stream: &Id) -> Result<()> { - let base_path = std::env::temp_dir(); + let base_path = get_vibe_temp_folder(); for i in 0..MAX_CHANNELS { let output_path = base_path.join(format!("output{}.raw", i)); if output_path.exists() { @@ -128,7 +129,7 @@ pub fn resume_capture(stream: &Id) -> Result<()> { pub fn screencapturekit_to_wav(output_path: PathBuf) -> Result<()> { // TODO: convert to wav // ffmpeg -f f32le -ar 48000 -ac 1 -i output0.raw -f f32le -ar 48000 -ac 1 -i output1.raw -filter_complex "[0:a][1:a]amerge=inputs=2" -ac 2 output.wav - let base_path = std::env::temp_dir(); + let base_path = get_vibe_temp_folder(); let output_0 = base_path.join(format!("output{}.raw", 0)); let output_1 = base_path.join(format!("output{}.raw", 1)); let mut pid = Command::new(find_ffmpeg_path().context("no ffmpeg")?) diff --git a/desktop/src-tauri/src/setup.rs b/desktop/src-tauri/src/setup.rs index 70e8d0cf..dd693814 100644 --- a/desktop/src-tauri/src/setup.rs +++ b/desktop/src-tauri/src/setup.rs @@ -40,6 +40,8 @@ pub fn setup(app: &App) -> Result<(), Box> { *app_handle = Some(app.handle().clone()); } crate::logging::setup_logging(app.handle(), store).unwrap(); + crate::cleaner::clean_old_logs(app.handle()).log_error(); + crate::cleaner::clean_old_files().log_error(); tracing::debug!("Vibe App Running"); // Crash handler diff --git a/desktop/src/pages/settings/Page.tsx b/desktop/src/pages/settings/Page.tsx index 56726da2..a96768b7 100644 --- a/desktop/src/pages/settings/Page.tsx +++ b/desktop/src/pages/settings/Page.tsx @@ -219,7 +219,9 @@ export default function SettingsPage({ setVisible }: SettingsPageProps) { )} -
+ + {/* Logs enabled by default currently */} + {/*
-
+
*/}
- diff --git a/desktop/src/pages/settings/viewModel.ts b/desktop/src/pages/settings/viewModel.ts index 27e32530..45e7113c 100644 --- a/desktop/src/pages/settings/viewModel.ts +++ b/desktop/src/pages/settings/viewModel.ts @@ -31,9 +31,8 @@ async function reportIssue() { } } -async function openLogsFolder() { - const dst = await invoke('get_logs_folder') - invoke('open_path', { path: dst }) +async function revealLogs() { + await invoke('show_log_path') } async function copyLogs() { @@ -141,7 +140,7 @@ export function viewModel() { askAndReset, openModelPath, openModelsUrl, - openLogsFolder, + revealLogs, models, appVersion, reportIssue, diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 41879463..6f764dd0 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -110,6 +110,11 @@ bunx tauri build ## Gotchas +### On Linux cmake not find Vulkan + +Then install it from [here](https://vulkan.lunarg.com/sdk/home) + + On Windows when run `pre_build` with `--vulkan` you may need to run it with admin rights first time thanks to vulkan recent changes... On Ubuntu you may need to copy some libraries for `ffmpeg_next` library @@ -215,7 +220,8 @@ git push ## Update packages ```console -bunx ncu -u -t newest +bun i -D +bunx ncu -u cd src-tauri cargo install cargo-edit rm -rf ../Cargo.lock diff --git a/scripts/pre_build.js b/scripts/pre_build.js index eeb7c266..8a3d8fe1 100755 --- a/scripts/pre_build.js +++ b/scripts/pre_build.js @@ -274,7 +274,6 @@ if (!process.env.GITHUB_ENV) { } if (platform == 'macos') { console.log(`export FFMPEG_DIR="${exports.ffmpeg}"`) - console.log(`export WHISPER_METAL_EMBED_LIBRARY=ON`) } if (!process.env.GITHUB_ENV) { const features = ['openblas', 'vulkan', 'cuda'].filter((f) => hasFeature(f)).join(',') @@ -294,10 +293,6 @@ if (process.env.GITHUB_ENV) { console.log('Adding ENV', ffmpeg) await fs.appendFile(process.env.GITHUB_ENV, ffmpeg) } - if (platform == 'macos') { - const embed_metal = 'WHISPER_METAL_EMBED_LIBRARY=ON' - await fs.appendFile(process.env.GITHUB_ENV, embed_metal) - } if (platform == 'windows') { const openblas = `OPENBLAS_PATH=${exports.openBlas}\n` console.log('Adding ENV', openblas) @@ -332,9 +327,6 @@ if (action?.includes('--build' || action.includes('--dev'))) { process.env['LIBCLANG_PATH'] = process.env['LIBCLANG_PATH'] || exports.libClang process.env['PATH'] = `${process.env['PATH']};${exports.cmake}` } - if (platform == 'macos') { - process.env['WHISPER_METAL_EMBED_LIBRARY'] = 'ON' - } await $`bun install` await $`bunx tauri ${action.includes('--dev') ? 'dev' : 'build'}` }