BTerminal/v2/src-tauri/src/commands/search.rs
Hibryda 944b48ff13 feat: add FTS5 full-text search with Spotlight-style overlay
Upgrade rusqlite to bundled-full for FTS5. SearchDb with 3 virtual tables
(messages, tasks, btmsg). SearchOverlay.svelte: Ctrl+Shift+F, 300ms
debounce, grouped results with highlight snippets.
2026-03-12 04:57:29 +01:00

35 lines
917 B
Rust

use crate::AppState;
use crate::search::SearchResult;
use tauri::State;
#[tauri::command]
pub fn search_init(state: State<'_, AppState>) -> Result<(), String> {
// SearchDb is already initialized during app setup; this is a no-op
// but allows the frontend to confirm readiness.
let _db = &state.search_db;
Ok(())
}
#[tauri::command]
pub fn search_query(
state: State<'_, AppState>,
query: String,
limit: Option<i32>,
) -> Result<Vec<SearchResult>, String> {
state.search_db.search_all(&query, limit.unwrap_or(20))
}
#[tauri::command]
pub fn search_rebuild(state: State<'_, AppState>) -> Result<(), String> {
state.search_db.rebuild_index()
}
#[tauri::command]
pub fn search_index_message(
state: State<'_, AppState>,
session_id: String,
role: String,
content: String,
) -> Result<(), String> {
state.search_db.index_message(&session_id, &role, &content)
}