{"record":{"id":"f2621c9b35460644","repo":"Hmbown/CodeWhale","slug":"editor","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"exception","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/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/tui/views/automations/editor.rs#L666-L702","documentation":"Thrown in `AutomationEditor::save` when a concurrent modification is detected: the automation record was changed by someone else since the editor loaded it, and the pending update request touches those fields (name/prompt, schedule, rrule, cwds, model, or status). The message is the localized `AutomationEditorConflict` string. `save` compares `latest` against `original` field-by-field only for fields the request will overwrite, then aborts rather than silently clobbering.","triggerScenarios":"Calling `save` on an existing automation when any overwritten field differs between the DB's `latest` record and the editor's `original` snapshot: a rename/edit elsewhere, a schedule change, cwd list change, model switch, or status toggle (e.g. pause from another session) happened between open and save.","commonSituations":"Two TUI sessions editing the same automation; a scheduler or CLI pausing/renaming the automation while the editor dialog is open; long-lived editor left open while automation state changed underneath.","solutions":["Reload the editor with the latest record, re-apply your edits, and save again","Save promptly after opening the editor to shrink the conflict window","Coordinate edits: check whether another session/tool is managing this automation","If the conflict is only in fields you did not intend to change, narrow the update request to the fields you actually edited"],"exampleFix":"null","handlingStrategy":"retry","validationCode":"let latest = manager.get_automation(&original.id)?;\nlet conflicted = (request.name.is_some() && latest.name != original.name)\n    || (request.status.is_some() && latest.status != original.status);\nif conflicted { /* reload before saving */ }","typeGuard":null,"tryCatchPattern":"match save_result {\n    Err(e) if e.to_string().contains(\"conflict\") || e.to_string().contains(\"changed\") => {\n        // reload latest record, merge/re-apply edits, retry save once\n    }\n    other => other?,\n}","preventionTips":["Save soon after opening the editor","Reload the record before saving after long edit sessions","Coordinate with other sessions/tools editing the same automation","Narrow update requests to only the fields actually edited"],"tags":["automation","concurrency","optimistic-locking","rust"],"backgroundTag":"invalid-state-transition","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}