building out the components, updating the UI in overview and adding a little sqlite viewer

This commit is contained in:
itsamejms
2026-07-17 09:31:51 +01:00
parent 82f2dcf3df
commit b89a39ec9d
30 changed files with 2664 additions and 635 deletions
+36 -5
View File
@@ -2,10 +2,37 @@ mod llm;
mod rag;
mod generations;
mod commands;
mod sql_viewer;
use llm::AppState;
use std::sync::Mutex;
use tauri::Manager;
use tauri_plugin_store::StoreExt;
// ponytail: the data-dir preference lives in a tiny store at the OS default
// app_data_dir so it's always discoverable at startup, even before we know the
// custom location. Key: `dataDir` (absolute path). Empty/missing → default.
const PREFS_STORE: &str = "dm-pal-prefs.json";
const DATA_DIR_KEY: &str = "dataDir";
/// Resolve the data dir: the configured one if set and usable, else the
/// default `$APPDATA/dm-toolkit`.
fn resolve_data_dir(app: &tauri::AppHandle) -> std::path::PathBuf {
let default = app
.path()
.app_data_dir()
.expect("app data dir")
.join("dm-toolkit");
if let Ok(store) = app.store(PREFS_STORE) {
if let Some(Some(v)) = store.get(DATA_DIR_KEY).map(|v| v.as_str().map(|s| s.to_string())) {
let p = std::path::PathBuf::from(v);
// ponytail: fall back to default if the configured path is gone —
// a DM who unmounts the external drive shouldn't lose the app.
if p.is_absolute() { return p; }
}
}
default
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
@@ -13,12 +40,9 @@ pub fn run() {
.plugin(tauri_plugin_log::Builder::default().build())
.plugin(tauri_plugin_store::Builder::default().build())
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_dialog::init())
.setup(|app| {
let data_dir = app
.path()
.app_data_dir()
.expect("app data dir")
.join("dm-toolkit");
let data_dir = resolve_data_dir(&app.handle());
let rag = rag::RagStore::open(&data_dir.join("lore"))
.expect("open lore db");
let gen = generations::GenerationStore::open(&data_dir)
@@ -27,6 +51,7 @@ pub fn run() {
config: Mutex::new(llm::LlmConfig::default()),
rag,
gen,
data_dir,
});
Ok(())
})
@@ -38,15 +63,21 @@ pub fn run() {
commands::llm_commands::set_llm_config,
commands::llm_commands::test_connection,
commands::image_commands::generate_image,
commands::image_commands::generate_image_stream,
commands::rag_commands::rag_add,
commands::rag_commands::rag_search,
commands::rag_commands::rag_list,
commands::rag_commands::rag_clear,
commands::rag_commands::rag_chunks,
commands::generation_commands::generation_add,
commands::generation_commands::generation_list,
commands::generation_commands::generation_get,
commands::generation_commands::generation_delete,
commands::generation_commands::generation_counts,
commands::data_commands::get_data_dir,
commands::data_commands::set_data_dir,
commands::data_commands::reset_data_dir,
commands::data_commands::sql_query,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");