File-based project save/load, AI chat formatting, text edit fix
Project files (.vtn): - Save Project: serializes transcript, speakers, audio path to JSON file - Open Project: loads .vtn file, restores audio/transcript/speakers - User chooses filename and location via save dialog - Replaces SQLite-based project persistence (DB commands remain for future use) - Text edits update in-memory store immediately, persist on explicit save - Fix Windows path separator in project name extraction AI chat: - Markdown rendering in assistant messages (headers, lists, bold, code) - Better visual distinction with border-left accents - Styled markdown elements for dark theme Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,48 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fs;
|
||||
use tauri::State;
|
||||
|
||||
use crate::db::models::Project;
|
||||
use crate::db::queries;
|
||||
use crate::state::AppState;
|
||||
|
||||
// ── File-based project types ────────────────────────────────────
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ProjectFile {
|
||||
pub version: u32,
|
||||
pub name: String,
|
||||
pub audio_file: String,
|
||||
pub created_at: String,
|
||||
pub segments: Vec<ProjectFileSegment>,
|
||||
pub speakers: Vec<ProjectFileSpeaker>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ProjectFileSegment {
|
||||
pub text: String,
|
||||
pub start_ms: i64,
|
||||
pub end_ms: i64,
|
||||
pub speaker: Option<String>,
|
||||
pub is_edited: bool,
|
||||
pub words: Vec<ProjectFileWord>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ProjectFileWord {
|
||||
pub word: String,
|
||||
pub start_ms: i64,
|
||||
pub end_ms: i64,
|
||||
pub confidence: f64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ProjectFileSpeaker {
|
||||
pub label: String,
|
||||
pub display_name: Option<String>,
|
||||
pub color: String,
|
||||
}
|
||||
|
||||
// ── Input types for save_project_transcript ──────────────────────
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -243,3 +281,17 @@ pub fn load_project_transcript(
|
||||
speakers: speaker_outputs,
|
||||
}))
|
||||
}
|
||||
|
||||
// ── File-based project commands ─────────────────────────────────
|
||||
|
||||
#[tauri::command]
|
||||
pub fn save_project_file(path: String, project: ProjectFile) -> Result<(), String> {
|
||||
let json = serde_json::to_string_pretty(&project).map_err(|e| e.to_string())?;
|
||||
fs::write(&path, json).map_err(|e| format!("Failed to save project: {e}"))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn load_project_file(path: String) -> Result<ProjectFile, String> {
|
||||
let json = fs::read_to_string(&path).map_err(|e| format!("Failed to read project: {e}"))?;
|
||||
serde_json::from_str(&json).map_err(|e| format!("Failed to parse project: {e}"))
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ use tauri::Manager;
|
||||
use commands::ai::{ai_chat, ai_configure, ai_list_providers};
|
||||
use commands::export::export_transcript;
|
||||
use commands::project::{
|
||||
create_project, delete_project, get_project, list_projects, load_project_transcript,
|
||||
save_project_transcript, update_segment,
|
||||
create_project, delete_project, get_project, list_projects, load_project_file,
|
||||
load_project_transcript, save_project_file, save_project_transcript, update_segment,
|
||||
};
|
||||
use commands::settings::{load_settings, save_settings};
|
||||
use commands::system::{get_data_dir, llama_list_models, llama_start, llama_status, llama_stop};
|
||||
@@ -41,6 +41,8 @@ pub fn run() {
|
||||
save_project_transcript,
|
||||
load_project_transcript,
|
||||
update_segment,
|
||||
save_project_file,
|
||||
load_project_file,
|
||||
transcribe_file,
|
||||
run_pipeline,
|
||||
download_diarize_model,
|
||||
|
||||
Reference in New Issue
Block a user