Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"tauri:ios:prepare-onnxruntime": "node scripts/install-onnxruntime-ios.mjs ios-arm64 && node scripts/install-onnxruntime-ios.mjs ios-arm64_x86_64-simulator",
"tauri:ios:dev:ready": "node scripts/install-onnxruntime-ios.mjs ios-arm64 && node scripts/install-onnxruntime-ios.mjs ios-arm64_x86_64-simulator && tauri ios dev",
"tauri:ios:build:ready": "node scripts/install-onnxruntime-ios.mjs ios-arm64 && node scripts/install-onnxruntime-ios.mjs ios-arm64_x86_64-simulator && tauri ios build",
"check": "tsc --noEmit && cd src-tauri && cargo check && echo 'All checks successful.'"
"check": "tsc --noEmit && cd src-tauri && cargo check && echo 'All checks successful.'",
"test": "vitest run"
},
"dependencies": {
"@tailwindcss/vite": "^4.2.2",
Expand Down Expand Up @@ -65,7 +66,8 @@
"prettier": "^3.8.1",
"tailwindcss": "^4.2.2",
"typescript": "~6.0.2",
"vite": "^8.0.3"
"vite": "^8.0.3",
"vitest": "^4.1.10"
},
"lint-staged": {
"src/**/*.{ts,tsx,js,jsx,json,css,md}": [
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/chat_manager/lorebook_generator/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ pub async fn lorebook_gen_commit(app: AppHandle, args: CommitArgs) -> Result<Com
keyword_detection_mode: LorebookKeywordDetectionMode::default(),
created_at: now,
updated_at: now,
tags: Vec::new(),
};
let saved = upsert_lorebook(&conn, &new_lb)?;
saved.id
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/discovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,7 @@ pub async fn discovery_import_character(app: AppHandle, path: String) -> Result<
crate::storage_manager::lorebook::LorebookKeywordDetectionMode::RecentMessageWindow,
created_at: now,
updated_at: now,
tags: Vec::new(),
};

if let Err(err) = upsert_lorebook(&conn, &lorebook_record) {
Expand Down
43 changes: 42 additions & 1 deletion src-tauri/src/migrations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::storage_manager::settings::{read_settings_typed, write_settings_typed
use crate::utils::{log_info, log_warn};

/// Current migration version
pub const CURRENT_MIGRATION_VERSION: u32 = 95;
pub const CURRENT_MIGRATION_VERSION: u32 = 96;

pub fn run_migrations(app: &AppHandle) -> Result<(), String> {
log_info(app, "migrations", "Starting migration check");
Expand Down Expand Up @@ -979,6 +979,16 @@ pub fn run_migrations(app: &AppHandle) -> Result<(), String> {
version = 95;
}

if version < 96 {
log_info(
app,
"migrations",
"Running migration v95 -> v96: Add tags column to personas and lorebooks",
);
migrate_v95_to_v96(app)?;
version = 96;
}

if version != CURRENT_MIGRATION_VERSION {
log_warn(
app,
Expand Down Expand Up @@ -4270,6 +4280,37 @@ fn migrate_v74_to_v75(app: &AppHandle) -> Result<(), String> {
Ok(())
}

/// Add a column only if missing; returns Err on a genuine ALTER failure so the
/// migration aborts (version not advanced) and retries next launch instead of wedging.
fn add_column_if_missing(
conn: &rusqlite::Connection,
table: &str,
column: &str,
decl: &str,
) -> Result<(), String> {
let mut stmt = conn
.prepare(&format!("PRAGMA table_info({table})"))
.map_err(|e| crate::utils::err_to_string(module_path!(), line!(), e))?;
let existing = stmt
.query_map([], |row| row.get::<_, String>(1))
.map_err(|e| crate::utils::err_to_string(module_path!(), line!(), e))?
.collect::<Result<Vec<String>, _>>()
.map_err(|e| crate::utils::err_to_string(module_path!(), line!(), e))?;
if existing.iter().any(|name| name == column) {
return Ok(());
}
conn.execute(&format!("ALTER TABLE {table} ADD COLUMN {column} {decl}"), [])
.map_err(|e| crate::utils::err_to_string(module_path!(), line!(), e))?;
Ok(())
}

fn migrate_v95_to_v96(app: &AppHandle) -> Result<(), String> {
let conn = crate::storage_manager::db::open_db(app)?;
add_column_if_missing(&conn, "personas", "tags", "TEXT")?;
add_column_if_missing(&conn, "lorebooks", "tags", "TEXT")?;
Ok(())
}

fn migrate_v75_to_v76(app: &AppHandle) -> Result<(), String> {
let conn = crate::storage_manager::db::open_db(app)?;

Expand Down
Loading
Loading