feat: persist model selection
This commit is contained in:
@@ -8,6 +8,7 @@ use tauri_plugin_store::StoreExt;
|
||||
|
||||
const STORE_PATH: &str = "store.json";
|
||||
const KEY_LAST_PROJECT: &str = "last_project_path";
|
||||
const KEY_SELECTED_MODEL: &str = "selected_model";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Helper Functions
|
||||
@@ -125,6 +126,31 @@ pub async fn get_current_project(
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_model_preference(app: AppHandle) -> Result<Option<String>, String> {
|
||||
let store = app
|
||||
.store(STORE_PATH)
|
||||
.map_err(|e| format!("Failed to access store: {}", e))?;
|
||||
|
||||
if let Some(val) = store.get(KEY_SELECTED_MODEL) {
|
||||
if let Some(model) = val.as_str() {
|
||||
return Ok(Some(model.to_string()));
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn set_model_preference(app: AppHandle, model: String) -> Result<(), String> {
|
||||
let store = app
|
||||
.store(STORE_PATH)
|
||||
.map_err(|e| format!("Failed to access store: {}", e))?;
|
||||
|
||||
store.set(KEY_SELECTED_MODEL, json!(model));
|
||||
let _ = store.save();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn read_file(path: String, state: State<'_, SessionState>) -> Result<String, String> {
|
||||
let full_path = resolve_path(&state, &path)?;
|
||||
|
||||
Reference in New Issue
Block a user