diagnostics: panic hook + frontend error capture + Settings → About diagnostic report
THE BRIEF: For the friends beta we need verbal feedback AND technical feedback — some bugs the user cannot describe but a stack trace can. Built it in two layers, with Layer 3 deferred until there is real volume. PRIVACY POSTURE (matches Kon's local-first positioning): - All capture is to disk only. Nothing is transmitted. - The manual report bundler shows the user exactly what would be shared and lets them choose to copy / save it. - No remote endpoint, no Sentry, no opt-out telemetry. LAYER 1 — Always-on local capture: - Rust panic hook (commands/diagnostics.rs::install_panic_hook) writes each panic to ~/.kon/crashes/<unix-ts>-<short-id>.crash. Captures thread name, OS/arch, RUST_BACKTRACE state, and the panic info. Installed before tauri::Builder so it catches setup-time panics too. - Frontend window.onerror + window.unhandledrejection in src/routes/+layout.svelte forward to the new log_frontend_error Tauri command, which inserts into the existing error_log SQLite table. Best-effort: errors in the error handler itself are swallowed so logging can never crash the app. - Existing error_log table (migration v1) is now actually used — closes the TODO from crates/storage/src/database.rs:409. LAYER 2 — Manual diagnostic report: - Settings → About → Diagnostics section: Generate report → Preview → Copy / Save. - Report is plain markdown so it pastes cleanly into email, Discord, GitHub issues. Sections: app version + OS, sanitised settings JSON, recent error_log rows, last 5 crash dumps with previews, log file tail (8KB). - Preview is shown in a <details> with the full text the user can inspect before deciding to share. - Save writes to ~/.kon/diagnostic-reports/kon-diagnostic-<ts>.md. NEW FILES: - src-tauri/src/commands/diagnostics.rs (panic hook + 5 Tauri commands) CHANGES: - crates/storage/src/file_storage.rs: crashes_dir() + logs_dir() helpers - crates/storage/src/database.rs: ErrorLogRow + list_recent_errors() - crates/storage/src/lib.rs: re-exports - src-tauri/src/commands/mod.rs: + diagnostics module - src-tauri/src/lib.rs: install_panic_hook() before Builder; 5 new Tauri commands registered (log_frontend_error, list_recent_errors_command, list_crash_files, generate_diagnostic_report, save_diagnostic_report) - src/routes/+layout.svelte: installGlobalErrorCapture() at mount - src/lib/pages/SettingsPage.svelte: diagnostic state + buttons + preview block at the end of the About section cargo check -p kon-storage clean. Settings.svelte if/each balanced. LAYER 3 (deferred): - Optional opt-in remote reporting (self-hosted Sentry on Tartarus or similar). Not for friends beta. Open up after volume justifies it.
This commit is contained in:
@@ -3,13 +3,26 @@
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use tauri::Emitter;
|
||||
|
||||
use crate::commands::models::{default_model_id_for_engine, ensure_model_loaded};
|
||||
use crate::AppState;
|
||||
use kon_ai_formatting::{post_process_segments, FormatMode, PostProcessOptions};
|
||||
use kon_core::types::{Segment, TranscriptionOptions};
|
||||
|
||||
fn pick_engine(
|
||||
state: &AppState,
|
||||
engine: &str,
|
||||
) -> Result<Arc<kon_transcription::LocalEngine>, String> {
|
||||
match engine {
|
||||
"whisper" => Ok(state.whisper_engine.clone()),
|
||||
"parakeet" => Ok(state.parakeet_engine.clone()),
|
||||
other => Err(format!("Unknown engine: {other}")),
|
||||
}
|
||||
}
|
||||
|
||||
/// Transcribe raw PCM f32 samples (Whisper). Emits "transcription-result" event.
|
||||
#[tauri::command]
|
||||
pub async fn transcribe_pcm(
|
||||
@@ -69,6 +82,8 @@ pub async fn transcribe_pcm(
|
||||
pub async fn transcribe_file(
|
||||
state: tauri::State<'_, AppState>,
|
||||
path: String,
|
||||
engine: Option<String>,
|
||||
model_id: Option<String>,
|
||||
language: String,
|
||||
initial_prompt: String,
|
||||
remove_fillers: bool,
|
||||
@@ -76,7 +91,12 @@ pub async fn transcribe_file(
|
||||
anti_hallucination: bool,
|
||||
format_mode: String,
|
||||
) -> Result<serde_json::Value, String> {
|
||||
let engine = state.whisper_engine.clone();
|
||||
let engine_name = engine.unwrap_or_else(|| "whisper".to_string());
|
||||
let model_id = model_id
|
||||
.unwrap_or_else(|| default_model_id_for_engine(&engine_name).to_string());
|
||||
ensure_model_loaded(&state, &engine_name, &model_id).await?;
|
||||
|
||||
let engine = pick_engine(&state, &engine_name)?;
|
||||
let options = TranscriptionOptions {
|
||||
language: Some(language),
|
||||
initial_prompt: Some(initial_prompt),
|
||||
@@ -106,6 +126,8 @@ pub async fn transcribe_file(
|
||||
);
|
||||
|
||||
Ok(serde_json::json!({
|
||||
"engine": engine_name,
|
||||
"modelId": model_id,
|
||||
"segments": segments,
|
||||
"language": timed.transcript.language(),
|
||||
"duration": timed.transcript.duration(),
|
||||
|
||||
Reference in New Issue
Block a user