diff --git a/apps/staged/src-tauri/src/session_commands.rs b/apps/staged/src-tauri/src/session_commands.rs index 064e3505..674fa3ee 100644 --- a/apps/staged/src-tauri/src/session_commands.rs +++ b/apps/staged/src-tauri/src/session_commands.rs @@ -213,24 +213,22 @@ pub fn resume_session( .map(|note| note.project_id); // If this session is linked to a commit, capture the current HEAD so we - // can detect amended commits when the session completes. + // can detect new or amended commits when the session completes. + // This applies both when the commit already has a SHA (amend case) and + // when it's still pending (no SHA — the previous run didn't produce a + // commit, so we need to detect if this resumed run does). let (pre_head_sha, workspace_name) = if let Ok(Some(commit)) = store.get_commit_by_session(&session_id) { - // Only bother if the commit already has a SHA (i.e. was previously completed). - if commit.sha.is_some() { - let branch = store.get_branch(&commit.branch_id).ok().flatten(); - let ws_name = branch.as_ref().and_then(|b| b.workspace_name.clone()); - let head = if let Some(ref ws) = ws_name { - crate::blox::ws_exec(ws, &["git", "rev-parse", "HEAD"]) - .map(|s| s.trim().to_string()) - .ok() - } else { - crate::git::get_head_sha(&working_dir).ok() - }; - (head, ws_name) + let branch = store.get_branch(&commit.branch_id).ok().flatten(); + let ws_name = branch.as_ref().and_then(|b| b.workspace_name.clone()); + let head = if let Some(ref ws) = ws_name { + crate::blox::ws_exec(ws, &["git", "rev-parse", "HEAD"]) + .map(|s| s.trim().to_string()) + .ok() } else { - (None, None) - } + crate::git::get_head_sha(&working_dir).ok() + }; + (head, ws_name) } else { (None, None) };