Phase 6: Llama-server manager, settings UI, packaging, and polish
- Implement LlamaManager in Rust for llama-server lifecycle: spawn with
port allocation, health check, clean shutdown on Drop, model listing
- Add llama_start/stop/status/list_models Tauri commands
- Add load_settings/save_settings commands with JSON persistence
- Build SettingsModal with tabs for Transcription, AI Provider, Local AI
settings (model size, device, language, API keys, provider selection)
- Wire settings into pipeline calls (model, device, language, skip diarization)
- Configure Tauri packaging: asset protocol for local audio files,
CSP policy, bundle metadata, Linux .deb/.AppImage and Windows .msi config
- Add keyboard shortcuts: Space (play/pause), Ctrl+O (import),
Ctrl+, (settings), Escape (close menus/modals)
- Close export dropdown on outside click
- Tests: 30 Python, 6 Rust, 0 Svelte errors
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 16:38:23 -08:00
|
|
|
use serde_json::{json, Value};
|
|
|
|
|
use std::fs;
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
|
|
use crate::llama::LlamaManager;
|
|
|
|
|
|
|
|
|
|
fn settings_path() -> PathBuf {
|
|
|
|
|
LlamaManager::data_dir().join("settings.json")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Load app settings from disk.
|
|
|
|
|
#[tauri::command]
|
|
|
|
|
pub fn load_settings() -> Value {
|
|
|
|
|
let path = settings_path();
|
|
|
|
|
if !path.exists() {
|
|
|
|
|
return json!({});
|
|
|
|
|
}
|
|
|
|
|
match fs::read_to_string(&path) {
|
|
|
|
|
Ok(content) => serde_json::from_str(&content).unwrap_or(json!({})),
|
|
|
|
|
Err(_) => json!({}),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Save app settings to disk.
|
|
|
|
|
#[tauri::command]
|
|
|
|
|
pub fn save_settings(settings: Value) -> Result<(), String> {
|
|
|
|
|
let path = settings_path();
|
|
|
|
|
if let Some(parent) = path.parent() {
|
|
|
|
|
fs::create_dir_all(parent).map_err(|e| format!("Cannot create settings dir: {e}"))?;
|
|
|
|
|
}
|
|
|
|
|
let json = serde_json::to_string_pretty(&settings).map_err(|e| e.to_string())?;
|
|
|
|
|
fs::write(&path, json).map_err(|e| format!("Cannot write settings: {e}"))?;
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
2026-03-22 10:55:48 -07:00
|
|
|
|
|
|
|
|
/// Toggle devtools on the main window.
|
|
|
|
|
#[tauri::command]
|
|
|
|
|
pub fn toggle_devtools(app: tauri::AppHandle, open: bool) {
|
|
|
|
|
use tauri::Manager;
|
|
|
|
|
if let Some(window) = app.get_webview_window("main") {
|
|
|
|
|
if open {
|
|
|
|
|
window.open_devtools();
|
|
|
|
|
} else {
|
|
|
|
|
window.close_devtools();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|