{"record":{"id":"b577f7f8993ce340","repo":"Zackriya-Solutions/meetily","slug":"app-state-not-available-b577f7","errorCode":null,"errorMessage":"App state not available","messagePattern":"App state not available","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/audio/retranscription.rs","lineNumber":427,"sourceCode":"    info!(\n        \"Transcription complete: {} segments transcribed out of {}, avg confidence: {:.2}\",\n        transcribed_count, processable_count, avg_confidence\n    );\n\n    // Check for cancellation\n    if RETRANSCRIPTION_CANCELLED.load(Ordering::SeqCst) {\n        return Err(anyhow!(\"Retranscription cancelled\"));\n    }\n\n    emit_progress(&app, &meeting_id, \"saving\", 80, \"Saving transcripts...\");\n\n    // Create transcript segments with proper timestamps from VAD\n    let segments = create_transcript_segments(&all_transcripts);\n\n    // Save to database\n    let app_state = app\n        .try_state::<AppState>()\n        .ok_or_else(|| anyhow!(\"App state not available\"))?;\n\n    // Wrap delete+insert+update in a transaction to prevent data loss\n    let pool = app_state.db_manager.pool();\n    let mut conn = pool.acquire().await.map_err(|e| anyhow!(\"DB error: {}\", e))?;\n    let mut tx = sqlx::Connection::begin(&mut *conn)\n        .await\n        .map_err(|e| anyhow!(\"Failed to start transaction: {}\", e))?;\n\n    sqlx::query(\"DELETE FROM transcripts WHERE meeting_id = ?\")\n        .bind(&meeting_id)\n        .execute(&mut *tx)\n        .await\n        .map_err(|e| anyhow!(\"Failed to delete existing transcripts: {}\", e))?;\n\n    for segment in &segments {\n        sqlx::query(\n            \"INSERT INTO transcripts (id, meeting_id, transcript, timestamp, audio_start_time, audio_end_time, duration)\n             VALUES (?, ?, ?, ?, ?, ?, ?)\"","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/audio/retranscription.rs#L409-L445","documentation":"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.","triggerScenarios":"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.","commonSituations":"DB file locked by another app instance so setup bailed; corrupted database on first run; a dev build that bypasses the normal setup sequence.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Gate the command on state availability before doing any work\nif app.try_state::<AppState>().is_none() {\n    return Err(\"Database not initialized - restart the app\".into());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["tauri","managed-state","database","initialization"],"backgroundTag":"tauri-managed-state-missing","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}