feat #14740: call model and sqlite store

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-05 13:57:54 +01:00
co-authored by Claude Opus 5.5
parent 5a381b8f56
commit 7cfe2963c0
5 changed files with 901 additions and 0 deletions
+132
View File
@@ -0,0 +1,132 @@
//! Domain types shared by the recording pipeline, the SQLite store and the
//! Tauri command layer.
use std::path::PathBuf;
use chrono::{DateTime, Local, NaiveDate};
use serde::{Deserialize, Serialize};
/// Primary key of a `calls` row (SQLite `rowid`).
pub type CallId = i64;
/// Lifecycle state of a recorded call.
///
/// Serializes (and is persisted) as its lowercase snake_case name, e.g.
/// `CallStatus::AwaitingDecision` -> `"awaiting_decision"`.
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum CallStatus {
Recording,
AwaitingDecision,
Processing,
Done,
Failed,
}
/// A single recorded call and everything tracked about its lifecycle.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct Call {
pub id: CallId,
pub app: String,
pub started_at: DateTime<Local>,
pub ended_at: Option<DateTime<Local>>,
pub status: CallStatus,
pub interrupted: bool,
pub error: Option<String>,
pub mic_path: PathBuf,
pub out_path: PathBuf,
pub transcribed_at: Option<DateTime<Local>>,
pub audio_deleted: bool,
pub account_id: Option<String>,
}
/// A single transcribed word with its timing and speaker attribution.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct Word {
pub text: String,
pub start: f64,
pub end: f64,
pub speaker: Option<String>,
}
/// Who is speaking in a segment: the local user, or one of the remote
/// participants detected via diarization.
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
pub enum Speaker {
Me,
Remote(u32),
}
impl Speaker {
/// Stable identifier used as a storage/lookup key, e.g. for
/// `Store::set_speaker_name` / `Store::speaker_names`.
pub fn key(&self) -> String {
match self {
Speaker::Me => "me".to_string(),
Speaker::Remote(n) => format!("remote:{n}"),
}
}
/// Default German display label before the user renames a speaker.
pub fn default_label(&self) -> String {
match self {
Speaker::Me => "Ich".to_string(),
Speaker::Remote(n) => format!("Sprecher {n}"),
}
}
/// Parses a key produced by [`Speaker::key`] back into a `Speaker`.
pub fn from_key(key: &str) -> Option<Self> {
if key == "me" {
Some(Speaker::Me)
} else {
key.strip_prefix("remote:")
.and_then(|n| n.parse::<u32>().ok())
.map(Speaker::Remote)
}
}
}
/// A merged, diarized stretch of transcript attributed to one speaker.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct Segment {
pub speaker: Speaker,
pub start: f64,
pub end: f64,
pub text: String,
}
/// Who owns a to-do coming out of the call summary.
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum Owner {
Ich,
Kunde,
Sonstige,
}
/// A single action item extracted from the call summary.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct Todo {
pub text: String,
pub owner: Owner,
pub faellig: Option<NaiveDate>,
#[serde(default)]
pub erledigt: bool,
}
/// The next agreed point of contact, if any.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default)]
pub struct NaechsterKontakt {
pub datum: Option<NaiveDate>,
pub notiz: Option<String>,
}
/// Structured summary produced by Claude for a finished call.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct Summary {
pub kernpunkte: Vec<String>,
pub vereinbarungen: Vec<String>,
pub todos: Vec<Todo>,
pub naechster_kontakt: NaechsterKontakt,
}