diff --git a/server/src/chat/commands/unblock.rs b/server/src/chat/commands/unblock.rs index e3aa338f..40fd3054 100644 --- a/server/src/chat/commands/unblock.rs +++ b/server/src/chat/commands/unblock.rs @@ -98,15 +98,27 @@ pub(crate) fn unblock_by_path(path: &Path, story_id: &str) -> String { let story_name = meta.name.as_deref().unwrap_or(story_id).to_string(); - if meta.blocked != Some(true) { + let has_blocked = meta.blocked == Some(true); + let has_merge_failure = meta.merge_failure.is_some(); + + if !has_blocked && !has_merge_failure { return format!( "**{story_name}** ({story_id}) is not blocked. Nothing to unblock." ); } - // Clear the blocked flag (reads + writes the file). - if let Err(e) = clear_front_matter_field(path, "blocked") { - return format!("Failed to clear blocked flag on **{story_id}**: {e}"); + // Clear the blocked flag if present. + if has_blocked { + if let Err(e) = clear_front_matter_field(path, "blocked") { + return format!("Failed to clear blocked flag on **{story_id}**: {e}"); + } + } + + // Clear merge_failure if present. + if has_merge_failure { + if let Err(e) = clear_front_matter_field(path, "merge_failure") { + return format!("Failed to clear merge_failure on **{story_id}**: {e}"); + } } // Reset retry_count to 0 (re-read the updated file, modify, write). @@ -119,7 +131,10 @@ pub(crate) fn unblock_by_path(path: &Path, story_id: &str) -> String { return format!("Failed to reset retry_count on **{story_id}**: {e}"); } - format!("Unblocked **{story_name}** ({story_id}). Retry count reset to 0.") + let mut cleared = Vec::new(); + if has_blocked { cleared.push("blocked"); } + if has_merge_failure { cleared.push("merge_failure"); } + format!("Unblocked **{story_name}** ({story_id}). Cleared: {}. Retry count reset to 0.", cleared.join(", ")) } // ---------------------------------------------------------------------------