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>
This commit is contained in:
@@ -1,2 +1,34 @@
|
||||
// Settings commands — app preferences, model selection, AI provider config
|
||||
// TODO: Implement when settings UI is built
|
||||
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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user