MCP: create the automation folder before claiming the startup lock

On a profile that never ran the editor the folder did not exist, the lock
write failed, and ocs_sessions(launch_if_none) took that as another caller
starting the GUI: it never spawned one and kept answering "still starting".

Closes #1846

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-16 22:40:02 +03:00
1 parent ecdcc5d2b6
commit 519d6605f9
1 file changed
+2
+2
View File
@@ -854,6 +854,8 @@ fn now_unix_secs() -> u64 {
fn write_startup_lock_at(directory: &Path, pid: u64, started: u64) -> Result<(), String> {
let text = serde_json::to_string(&json!({"pid": pid, "started": started}))
.map_err(|error| error.to_string())?;
// On a profile that never ran the editor nothing has made the folder yet.
std::fs::create_dir_all(directory).map_err(|error| error.to_string())?;
std::fs::write(startup_lock_path_for(directory), text).map_err(|error| error.to_string())
}