Zackriya-Solutions/meetily · error · anyhow::Error
App state not available
Error message
App state not available
What it means
app.try_state::<AppState>() returned None at the save stage: the Tauri app never managed an AppState, so no database pool exists. AppState is registered only by app.manage(AppState { db_manager }) during database setup (database/setup.rs:33, database/commands.rs:164/188); if that setup failed or was skipped, every try_state call returns None.
Source
Thrown at frontend/src-tauri/src/audio/retranscription.rs:427
info!(
"Transcription complete: {} segments transcribed out of {}, avg confidence: {:.2}",
transcribed_count, processable_count, avg_confidence
);
// Check for cancellation
if RETRANSCRIPTION_CANCELLED.load(Ordering::SeqCst) {
return Err(anyhow!("Retranscription cancelled"));
}
emit_progress(&app, &meeting_id, "saving", 80, "Saving transcripts...");
// Create transcript segments with proper timestamps from VAD
let segments = create_transcript_segments(&all_transcripts);
// Save to database
let app_state = app
.try_state::<AppState>()
.ok_or_else(|| anyhow!("App state not available"))?;
// Wrap delete+insert+update in a transaction to prevent data loss
let pool = app_state.db_manager.pool();
let mut conn = pool.acquire().await.map_err(|e| anyhow!("DB error: {}", e))?;
let mut tx = sqlx::Connection::begin(&mut *conn)
.await
.map_err(|e| anyhow!("Failed to start transaction: {}", e))?;
sqlx::query("DELETE FROM transcripts WHERE meeting_id = ?")
.bind(&meeting_id)
.execute(&mut *tx)
.await
.map_err(|e| anyhow!("Failed to delete existing transcripts: {}", e))?;
for segment in &segments {
sqlx::query(
"INSERT INTO transcripts (id, meeting_id, transcript, timestamp, audio_start_time, audio_end_time, duration)
VALUES (?, ?, ?, ?, ?, ?, ?)"View on GitHub (pinned to 0281737d87)
Solutions
- Check startup logs for database initialization errors before this point.
- Ensure the database setup that calls app.manage(AppState { db_manager }) runs and succeeds before any retranscription command is invoked.
- Close other app instances holding the database file, then restart.
- If the database is corrupt, back up and recreate the data directory.
Defensive patterns
Strategy: validation
Validate before calling
// Gate the command on state availability before doing any work
if app.try_state::<AppState>().is_none() {
return Err("Database not initialized - restart the app".into());
} Prevention
- Verify database setup completes during app bootstrap before enabling retranscription in the UI.
- Fail loudly at startup when app.manage cannot register AppState instead of continuing degraded.
- In tests, always build the AppHandle with .manage(AppState { db_manager }) or skip DB-touching paths.
When it happens
Trigger: Database initialization errored at startup and the failure was swallowed; the retranscription code path runs in a test harness or headless AppHandle that never called manage; state was managed under a different type.
Common situations: DB file locked by another app instance so setup bailed; corrupted database on first run; a dev build that bypasses the normal setup sequence.
Related errors
- Whisper engine not initialized
- Parakeet engine not initialized
- Whisper engine not initialized
- Parakeet engine not initialized
- Failed to initialize database
AI-assisted analysis of Zackriya-Solutions/meetily@0281737d87 (2026-08-16).
Data as JSON: /api/errors/b577f7f8993ce340.
Report an issue: GitHub.