{"record":{"id":"a4321503fcb46f13","repo":"BigPizzaV3/CodexPlusPlus","slug":"session-index-cleanup-preview-task-failed-error","errorCode":null,"errorMessage":"session index cleanup preview task failed: {error}","messagePattern":"session index cleanup preview task failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/codex-plus-manager/src-tauri/src/commands.rs","lineNumber":3235,"sourceCode":"                    unavailable_reason,\n                });\n        }\n    }\n    targets.targets.sort_by(|left, right| {\n        right\n            .is_current_provider\n            .cmp(&left.is_current_provider)\n            .then_with(|| left.id.cmp(&right.id))\n    });\n}\n\n#[tauri::command]\npub async fn preview_session_index_cleanup() -> CommandResult<Value> {\n    let result = tauri::async_runtime::spawn_blocking(|| {\n        codex_plus_data::preview_session_index_cleanup(None)\n    })\n    .await\n    .map_err(|error| anyhow::anyhow!(\"session index cleanup preview task failed: {error}\"))\n    .and_then(|result| result);\n    match result {\n        Ok(preview) => ok(\n            &format!(\n                \"发现 {} 条仅存在于任务索引中的候选记录。\",\n                preview.candidates.len()\n            ),\n            json!({\n                \"snapshotSha256\": preview.snapshot_sha256,\n                \"candidates\": preview.candidates,\n            }),\n        ),\n        Err(error) => failed(&format!(\"预览失效任务索引失败：{error}\"), json!({})),\n    }\n}\n\n#[tauri::command]\npub async fn apply_session_index_cleanup(","sourceCodeStart":3217,"sourceCodeEnd":3253,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/apps/codex-plus-manager/src-tauri/src/commands.rs#L3217-L3253","documentation":"preview_session_index_cleanup dispatches codex_plus_data::preview_session_index_cleanup to a blocking thread with tauri::async_runtime::spawn_blocking and awaits it. A JoinError on .await (blocking task panicked or cancelled) is mapped into this error before the inner Result is checked with and_then.","triggerScenarios":"The spawn_blocking closure running codex_plus_data::preview_session_index_cleanup(None) panicked or its JoinHandle resolved to Err(JoinError) — e.g. a panic while scanning/parsing session index files, or runtime cancellation.","commonSituations":"Corrupt or malformed session index entries causing unwrap/index panics in the preview scan, locked or unreadable session files hit by a panic path, or app shutdown cancelling the blocking task.","solutions":["Inspect the wrapped JoinError text — a panic report points at the exact scan/parse line to fix","Harden preview_session_index_cleanup to return Err on malformed index entries instead of panicking","Back up or repair the corrupted session index file the preview reads","Retry if cancellation during app shutdown caused the join failure"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match tauri::async_runtime::spawn_blocking(|| codex_plus_data::preview_session_index_cleanup(None)).await {\n    Ok(Ok(preview)) => { /* 展示预览 */ }\n    Ok(Err(data_err)) => eprintln!(\"preview failed: {data_err}\"),\n    Err(join_err) => eprintln!(\"preview task panicked or was cancelled: {join_err}\"),\n}","preventionTips":["Harden the preview scan to skip or report malformed session index entries instead of panicking","Repair or back up corrupted session index files before running cleanup previews","Keep blocking closures returning Result for all IO and parse failures","Don't run previews during app shutdown when cancellation is likely"],"tags":["rust","tauri","spawn-blocking","join-error","session-index"],"backgroundTag":"thread-interrupted","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}