{"record":{"id":"13b68670fd6951b8","repo":"Hmbown/CodeWhale","slug":"automationeditorconflict","errorCode":null,"errorMessage":"AutomationEditorConflict","messagePattern":"AutomationEditorConflict","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/views/automations/editor.rs","lineNumber":684,"sourceCode":"                cwds: workspace_changed.then_some(cwds),\n                model: (choice != ModelChoice::from_record(original))\n                    .then(|| choice.model.clone().unwrap_or_default()),\n                model_provider: (choice != ModelChoice::from_record(original))\n                    .then(|| choice.provider.clone().unwrap_or_default()),\n                model_provider_id: (choice != ModelChoice::from_record(original))\n                    .then(|| choice.provider_id.clone().unwrap_or_default()),\n                status: (status != original.status).then_some(status),\n                ..Default::default()\n            };\n            if (request.name.is_some() && latest.name != original.name)\n                || (request.prompt.is_some() && latest.prompt != original.prompt)\n                || (request.rrule.is_some() && latest.rrule != original.rrule)\n                || (request.cwds.is_some() && latest.cwds != original.cwds)\n                || (request.model.is_some()\n                    && ModelChoice::from_record(&latest) != ModelChoice::from_record(original))\n                || (request.status.is_some() && latest.status != original.status)\n            {\n                anyhow::bail!(\"{}\", tr(self.locale, MessageId::AutomationEditorConflict));\n            }\n            manager.update_automation(&original.id, request)\n        } else {\n            manager.create_automation(CreateAutomationRequest {\n                name: self.name.value.clone(),\n                prompt: self.prompt.value.clone(),\n                rrule,\n                cwds,\n                model: choice.model,\n                model_provider: choice.provider,\n                model_provider_id: choice.provider_id,\n                status: Some(status),\n                mode: None,\n                allow_shell: None,\n                trust_mode: None,\n                auto_approve: None,\n                delivery_mode: None,\n            })","sourceCodeStart":666,"sourceCodeEnd":702,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/views/automations/editor.rs#L666-L702","documentation":"AutomationEditor::save performs optimistic-concurrency detection: it re-reads the latest stored automation record and compares every field the save request touches (schedule/rrule, cwds, model, status) against the original record the editor loaded. If any differ, someone else modified the automation and it bails with the AutomationEditorConflict message instead of clobbering their changes.","triggerScenarios":"Calling save with request fields Some(...) where latest.rrule != original.rrule, latest.cwds != original.cwds, ModelChoice::from_record(&latest) != ModelChoice::from_record(original), or latest.status != original.status — i.e. the stored record changed under the editor.","commonSituations":"Another window/agent edited or paused the same automation while the editor was open; an automated job status transition happened between open and save; a schedule sync tool updated the record.","solutions":["Reload the automation in the editor (discard or merge your edits with the latest record) and re-apply changes, then save again.","If the concurrent change is unwanted, revert the record to the original state first, then save.","Retry the save immediately after reload if contention is rare and changes are trivial."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match editor.save() {\n    Err(e) if e.to_string().contains(\"conflict\") => { editor.reload_latest(); prompt_user_to_reapply(); }\n    other => other?,\n}","preventionTips":["Reload the record immediately before saving when possible to shrink the race window.","Avoid leaving the editor open long; edit and save promptly.","Coordinate edits to the same automation across windows/agents.","Expect conflicts on automations whose status changes automatically (pauses, runs)."],"tags":["automation-editor","conflict","optimistic-concurrency","ui"],"backgroundTag":"invalid-state-transition","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T10:30:35.592Z"}