{"record":{"id":"f1681c7a10cc0133","repo":"gitbutlerapp/gitbutler","slug":"you-are-in-conflict-resolution-mode-finish-with-but-resolve-f1681c","errorCode":null,"errorMessage":"You are in conflict resolution mode. Finish with `but resolve finish` or cancel with `but resolve cancel` before using --ai.","messagePattern":"You are in conflict resolution mode\\. Finish with `but resolve finish` or cancel with `but resolve cancel` before using --ai\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/resolve.rs","lineNumber":1081,"sourceCode":"            \"manual\": result.manual,\n        }))?;\n    }\n\n    Ok(())\n}\n\n/// Resolve conflicts with the configured AI model: one commit when\n/// `commit_id_str` is given, otherwise every conflicted commit in the\n/// workspace, oldest first.\nfn resolve_with_ai(\n    ctx: &mut Context,\n    out: &mut OutputChannel,\n    commit_id_str: Option<&str>,\n) -> Result<()> {\n    let t = theme::get();\n    let mode = operating_mode(ctx)?.operating_mode;\n    if matches!(mode, OperatingMode::Edit(_)) {\n        bail!(\n            \"You are in conflict resolution mode. Finish with `but resolve finish` or cancel with `but resolve cancel` before using --ai.\"\n        );\n    }\n\n    let mut results = Vec::new();\n    if let Some(commit_id_str) = commit_id_str {\n        let (commit_oid, _commit_ref) = parse_commit_id(ctx, commit_id_str)?;\n        results.push(resolve_one_with_ai(ctx, out, commit_oid)?);\n    } else {\n        // Resolving a commit rebases its descendants, which changes their ids\n        // and can change (or clear) their conflicts — so re-discover the\n        // oldest conflicted commit after every resolution.\n        loop {\n            let Some(commit_oid) = oldest_conflicted_commit(ctx)? else {\n                break;\n            };\n            results.push(resolve_one_with_ai(ctx, out, commit_oid)?);\n        }","sourceCodeStart":1063,"sourceCodeEnd":1099,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/resolve.rs#L1063-L1099","documentation":"`but resolve --ai` refuses to run while the workspace is in Edit (conflict resolution) mode. AI-assisted resolution operates on commits independently, and being mid-resolution would conflict with the in-progress resolution state, so the user must first finish or cancel it.","triggerScenarios":"Running `but resolve --ai [commit]` (resolve_with_ai via handle) when operating_mode(ctx) reports OperatingMode::Edit(_), i.e. a prior `but resolve`/edit session is still open.","commonSituations":"Starting an interactive resolve, abandoning it, then trying `--ai`; automation scripts that left a resolution session open.","solutions":["Complete the pending session: `but resolve finish`","Or abort it: `but resolve cancel`","Then re-run `but resolve --ai`"],"exampleFix":"// before\nbut resolve --ai\n// error: You are in conflict resolution mode...\n// after\nbut resolve cancel\nbut resolve --ai","handlingStrategy":"validation","validationCode":"// check operating mode before invoking resolve --ai\nconst mode = await getOperatingMode();\nif (mode === 'edit') console.error('Finish with `but resolve finish` or `but resolve cancel` first');","typeGuard":"const canRunAiResolve = (mode) => mode !== 'edit';","tryCatchPattern":"try {\n  await but(['resolve', '--ai']);\n} catch (e) {\n  if (e.message.includes('conflict resolution mode')) {\n    await but(['resolve', 'cancel']);\n    await but(['resolve', '--ai']);\n  } else throw e;\n}","preventionTips":["Always close resolution sessions with `but resolve finish`/`cancel` in scripts","Check operating mode before AI-assisted commands","Wrap interactive sessions in try/finally to guarantee cancellation"],"tags":["cli","conflict-resolution","ai","state"],"backgroundTag":"invalid-state-transition","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}