The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
fix(project): one process at a time on a project folder - the window, concat --mcp and the CLI lock what they open (#337)
Jareer68ceffe259f8
diff --git a/docs/MCP.md b/docs/MCP.mdindex ebd52d0a..6c0ffd5a 100644--- a/docs/MCP.md+++ b/docs/MCP.md@@ -40,7 +40,7 @@ On Windows, write the path with doubled backslashes in JSON: `"C:\\Program Files`concat --mcp` works one of two ways, and the `concat_version` tool says which (`mcp.mode`):- **Through the window** (`window`). When Concat is open with **Settings > Automation > Scripts and apps** on, the window writes where its server is, and its token, to `automation.json` in Concat's config folder (readable only by you). The MCP server finds it and goes through the window's server. This is the safer way while you are editing: the agent cannot open the project you have on screen and save over it, and exports take turns with yours.-- **On its own** (`headless`). Otherwise the MCP server runs Concat's engine itself, with no window. Nothing has to be open. It does not know what the window is doing, so do not let it edit a project you have open in the window at the same time.+- **On its own** (`headless`). Otherwise the MCP server runs Concat's engine itself, with no window. Nothing has to be open. Every Concat process locks the project folders it has open (`concat.lock`, let go on close or when the process dies), so a project open in the window is refused here with a note to turn on Automation and use `--mcp window`, and the window refuses a project an agent has open.Choose explicitly with `--mcp window` (fail rather than run on its own) or `--mcp headless`; the default is `--mcp auto`. To reach a server elsewhere, set `CONCAT_API_ADDRESS` (e.g. `127.0.0.1:7420`) and `CONCAT_API_TOKEN` in the client's `env` for the server.diff --git a/src/Cargo.lock b/src/Cargo.lockindex 9ca2a2b6..3375aeb1 100644--- a/src/Cargo.lock+++ b/src/Cargo.lock@@ -1260,6 +1260,7 @@ dependencies = ["serde","serde_json","sha2",+ "tempfile","ureq 2.12.1","windows-sys 0.61.2",]diff --git a/src/crates/concat-api/src/lib.rs b/src/crates/concat-api/src/lib.rsindex e4b463e5..d623b3f7 100644--- a/src/crates/concat-api/src/lib.rs+++ b/src/crates/concat-api/src/lib.rs@@ -48,7 +48,7 @@ use concat_host::preview::{FrameSpec, Monitor};use concat_host::session::EditorView;use concat_host::stabilize::{StabilizeRequest, Stabilizers};use concat_host::templates::{self, SlotFill};-use concat_host::{ProjectInfo, Session, Titles, media, projects};+use concat_host::{ProjectInfo, Session, Titles, lock, media, projects};use concat_project::Command;use concat_project::model::VideoSettings;@@ -111,26 +111,83 @@ impl std::fmt::Display for Holder {}}+/// Why a project folder could not be claimed.+#[derive(Clone, Debug, PartialEq, Eq)]+pub enum Refusal {+ /// The other side of this process has it: the window, or the API it+ /// serves.+ Here(Holder),+ /// Another process has it - a second window, `concat --mcp`, the CLI -+ /// as its lock file says.+ Elsewhere(lock::Owner),+}++impl std::fmt::Display for Refusal {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ match self {+ Refusal::Here(holder) => write!(f, "open in {holder}"),+ Refusal::Elsewhere(owner) => {+ let what = if owner.role == "window" {+ "a Concat window"+ } else {+ "another Concat process"+ };+ match owner.pid {+ Some(pid) => write!(f, "open in {what} (process {pid})"),+ None => write!(f, "open in {what}"),+ }+ }+ }+ }+}++/// One claimed folder: who has it in this process, and the lock that+/// keeps every other process off it.+struct Claim {+ holder: Holder,+ /// `None` where the folder would not take a lock file - one that+ /// cannot be written - which costs the guard, not the open.+ _lock: Option<lock::ProjectLock>,+}+/// The project folders open on this machine and who has each, shared/// between a window and the API it embeds, so neither opens a folder the/// other is editing and saves over its work (audit 2026-09-23, #5). Cheap/// to clone; every clone is the same register.+///+/// Each claimed folder is also locked against every other process+/// ([`lock::ProjectLock`]): a second window, `concat --mcp` working on its+/// own, the CLI. The lock goes with the claim, and with the process if it+/// dies, so a crash leaves a folder the next opener takes over.#[derive(Clone, Default)]-pub struct OpenProjects(Arc<Mutex<BTreeMap<String, Holder>>>);+pub struct OpenProjects(Arc<Mutex<BTreeMap<String, Claim>>>);impl OpenProjects {/// Claims `path` for `holder`. Refused, naming who has it, when the- /// other side does; claiming again what one already holds is fine.- pub fn claim(&self, path: &str, holder: Holder) -> Result<(), Holder> {+ /// other side of this process does or another process does; claiming+ /// again what one already holds is fine.+ pub fn claim(&self, path: &str, holder: Holder) -> Result<(), Refusal> {let key = key_of(path);let mut open = self.0.lock().unwrap_or_else(|poisoned| poisoned.into_inner());match open.get(&key) {- Some(&other) if other != holder => Err(other),- _ => {- open.insert(key, holder);+ Some(claim) if claim.holder != holder => Err(Refusal::Here(claim.holder)),+ Some(_) => Ok(()),+ None => {+ let role = match holder {+ Holder::Window => "window",+ Holder::Api => "api",+ };+ let lock = match lock::ProjectLock::acquire(Path::new(path), role) {+ Ok(lock) => Some(lock),+ Err(lock::LockError::Held(owner)) => return Err(Refusal::Elsewhere(owner)),+ // A folder that will not take the file: a read-only+ // one, which nobody can save over anyway.+ Err(lock::LockError::Io(_)) => None,+ };+ open.insert(key, Claim { holder, _lock: lock });Ok(())}}@@ -152,7 +209,7 @@ impl OpenProjects {.lock().unwrap_or_else(|poisoned| poisoned.into_inner()).get(&key)- .copied()+ .map(|claim| claim.holder)}}@@ -482,10 +539,19 @@ impl Api {/// Opens a session on a project the host just described and puts it at/// the front of the recents list.fn adopt(&mut self, info: ProjectInfo) -> Result<EditorView, ApiError> {- if let Err(holder) = self.open.claim(&info.path, Holder::Api) {+ if let Err(refusal) = self.open.claim(&info.path, Holder::Api) {+ // A window holding it is the case an agent meets: say how to+ // go through that window instead of around it.+ let how = match &refusal {+ Refusal::Elsewhere(owner) if owner.role == "window" => {+ ". To work on it from an agent, turn on Settings > Automation in that window and run the agent with `concat --mcp window`; the project on screen stays the window's until live mode lands"+ }+ Refusal::Elsewhere(_) => ". Close it there first",+ Refusal::Here(_) => "",+ };return Err(ApiError::new(ErrorCode::Refused,- format!("{} is open in {holder}", info.path),+ format!("{} is {refusal}{how}", info.path),));}let session = match Session::open_info(&info) {@@ -1654,13 +1720,42 @@ mod tests {assert_eq!(open.holder(&path), Some(Holder::Api));assert_eq!(open.claim(&path, Holder::Window),- Err(Holder::Api),+ Err(Refusal::Here(Holder::Api)),"and the window is refused in turn");+ assert!(+ Path::new(&path).join(lock::FILE).exists(),+ "and every other process by the lock"+ );ok(api.dispatch(Request::ProjectClose {path: path.clone(),save: false,}));assert_eq!(open.holder(&path), None, "closing gives it back");+ assert!(!Path::new(&path).join(lock::FILE).exists(), "lock and all");+ }++ /// Two registers are two processes as far as the lock goes: an API+ /// that does not share the window's register - `concat --mcp` on its+ /// own - is kept off a folder the window has, and told the way in.+ #[test]+ fn a_project_another_process_holds_is_refused_with_the_way_in() {+ let (mut other, _other_scratch, _other_events) = api();+ let (mut api, scratch, _events) = api();+ let path = project(&mut api, &scratch, "Held");+ ok(api.dispatch(Request::ProjectClose {+ path: path.clone(),+ save: false,+ }));+ let window = lock::ProjectLock::acquire(Path::new(&path), "window").expect("the window");+ let refused = err(api.dispatch(Request::ProjectOpen { path: path.clone() }));+ assert_eq!(refused.code, ErrorCode::Refused);+ assert!(refused.message.contains("a Concat window (process"), "{}", refused.message);+ assert!(refused.message.contains("concat --mcp window"), "{}", refused.message);+ drop(window);+ ok(api.dispatch(Request::ProjectOpen { path: path.clone() }));++ let refused = err(other.dispatch(Request::ProjectOpen { path: path.clone() }));+ assert!(refused.message.contains("another Concat process"), "{}", refused.message);}}diff --git a/src/crates/concat-host/Cargo.toml b/src/crates/concat-host/Cargo.tomlindex 2fa88ed5..e9db5a02 100644--- a/src/crates/concat-host/Cargo.toml+++ b/src/crates/concat-host/Cargo.toml@@ -67,5 +67,8 @@ windows-sys = { version = "0.61", features = ["Win32_System_Threading",] }+[dev-dependencies]+tempfile = "3"+[lints]workspace = truediff --git a/src/crates/concat-host/src/lib.rs b/src/crates/concat-host/src/lib.rsindex 64dc3f5f..f7571854 100644--- a/src/crates/concat-host/src/lib.rs+++ b/src/crates/concat-host/src/lib.rs@@ -28,6 +28,7 @@ pub mod dirs;pub mod enhance;pub mod export;pub mod jobs;+pub mod lock;pub mod logs;pub mod machine;pub mod media;diff --git a/src/crates/concat-host/src/lock.rs b/src/crates/concat-host/src/lock.rsnew file mode 100644index 00000000..f35f1563--- /dev/null+++ b/src/crates/concat-host/src/lock.rs@@ -0,0 +1,273 @@+// SPDX-License-Identifier: AGPL-3.0-or-later+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors++//! One process at a time on a project folder: the window, `concat --mcp`,+//! `concat-cli`, a second window.+//!+//! Two processes editing one folder each save their own document over the+//! other's, and the last save wins whatever it lost. So a process that+//! opens a project takes `concat.lock` in its folder: a file it holds an+//! exclusive operating-system lock on (`flock` on Unix, `LockFileEx` on+//! Windows, through [`std::fs::File::try_lock`]), with its process id, its+//! role and when it started written inside for whoever is refused.+//!+//! The lock is the operating system's, not the file's: it lives exactly+//! as long as the process's handle, so a process that crashes or is killed+//! lets go with it, and the file it leaves behind is taken over by the+//! next opener without anybody deciding whether its pid is still running -+//! a question a reused pid answers wrongly. The words in the file are only+//! what a refusal says.+//!+//! Within one process the window and the API it serves share+//! `concat_api::OpenProjects`, which holds one of these per folder; this+//! is the line between processes.++use std::fs::{File, OpenOptions, TryLockError};+use std::io::{Read, Seek, SeekFrom, Write};+use std::path::{Path, PathBuf};+use std::time::{SystemTime, UNIX_EPOCH};++/// The lock file's name in a project folder.+pub const FILE: &str = "concat.lock";++/// How many times an open races a holder that is letting go - the file+/// removed between this process opening it and locking it - before it+/// gives up.+const ATTEMPTS: usize = 4;++/// A project folder held by this process; let go when dropped.+#[derive(Debug)]+pub struct ProjectLock {+ file: Option<File>,+ path: PathBuf,+}++/// Who holds a folder, as the lock file says.+#[derive(Clone, Debug, PartialEq, Eq)]+pub struct Owner {+ /// The holding process, when the file names one.+ pub pid: Option<u32>,+ /// What it is: "window", "api", or empty when the file does not say.+ pub role: String,+}++/// Why a folder could not be taken.+#[derive(Clone, Debug, PartialEq, Eq)]+pub enum LockError {+ /// Another process holds it.+ Held(Owner),+ /// The lock file could not be made or locked: a folder that cannot be+ /// written, a file system without locks.+ Io(String),+}++impl std::fmt::Display for LockError {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ match self {+ LockError::Held(owner) => match owner.pid {+ Some(pid) => write!(f, "open in another Concat (process {pid})"),+ None => f.write_str("open in another Concat"),+ },+ LockError::Io(why) => f.write_str(why),+ }+ }+}++impl ProjectLock {+ /// Takes `folder` for this process, as `role`. Refused with the owner+ /// when another live process holds it; a lock file left by a process+ /// that is gone is taken over.+ pub fn acquire(folder: &Path, role: &str) -> Result<ProjectLock, LockError> {+ let path = folder.join(FILE);+ let could_not =+ |error: &dyn std::fmt::Display| LockError::Io(format!("{}: {error}", path.display()));+ for attempt in 1..=ATTEMPTS {+ let opened = OpenOptions::new()+ .read(true)+ .write(true)+ .create(true)+ .truncate(false)+ .open(&path);+ let mut file = match opened {+ Ok(file) => file,+ // On Windows a file being removed cannot be opened until+ // its last handle closes, which is a moment away.+ Err(error)+ if error.kind() == std::io::ErrorKind::PermissionDenied+ && attempt < ATTEMPTS =>+ {+ std::thread::sleep(std::time::Duration::from_millis(50));+ continue;+ }+ Err(error) => return Err(could_not(&error)),+ };+ match file.try_lock() {+ Ok(()) => {}+ Err(TryLockError::WouldBlock) => return Err(LockError::Held(owner_in(&mut file))),+ Err(TryLockError::Error(error)) => return Err(could_not(&error)),+ }+ // A holder letting go removes the file after its last write; a+ // lock taken on the file it removed guards nothing. Locked, the+ // path must still be this file, or the open starts over.+ if !same_file(&file, &path) {+ continue;+ }+ let started = SystemTime::now()+ .duration_since(UNIX_EPOCH)+ .map(|since| since.as_millis())+ .unwrap_or(0);+ let text = format!("{}\n{role}\n{started}\n", std::process::id());+ file.set_len(0)+ .and_then(|()| file.seek(SeekFrom::Start(0)).map(|_| ()))+ .and_then(|()| file.write_all(text.as_bytes()))+ .and_then(|()| file.flush())+ .map_err(|error| could_not(&error))?;+ return Ok(ProjectLock {+ file: Some(file),+ path,+ });+ }+ Err(could_not(&"another process kept taking and letting go of it"))+ }++ /// The lock file.+ pub fn path(&self) -> &Path {+ &self.path+ }++ /// Who holds `folder`, if a live process does: the owner its lock file+ /// names. `None` when nobody does, or when this process does.+ pub fn holder(folder: &Path) -> Option<Owner> {+ let path = folder.join(FILE);+ let mut file = File::open(&path).ok()?;+ match file.try_lock_shared() {+ Ok(()) => None,+ Err(TryLockError::WouldBlock) => {+ let owner = owner_in(&mut file);+ (owner.pid != Some(std::process::id())).then_some(owner)+ }+ Err(TryLockError::Error(_)) => None,+ }+ }+}++impl Drop for ProjectLock {+ /// The file goes first, then the lock with the handle: a process that+ /// opened the file in between finds it gone once it has the lock, and+ /// starts over on a new one.+ fn drop(&mut self) {+ let _ = std::fs::remove_file(&self.path);+ if let Some(file) = self.file.take() {+ let _ = file.unlock();+ }+ }+}++/// The owner a lock file names.+fn owner_in(file: &mut File) -> Owner {+ let mut text = String::new();+ let _ = file.seek(SeekFrom::Start(0));+ let _ = file.read_to_string(&mut text);+ let mut lines = text.lines();+ Owner {+ pid: lines.next().and_then(|line| line.trim().parse().ok()),+ role: lines.next().unwrap_or_default().trim().to_owned(),+ }+}++/// Whether `path` is still the file `file` has open.+#[cfg(unix)]+fn same_file(file: &File, path: &Path) -> bool {+ use std::os::unix::fs::MetadataExt;+ match (file.metadata(), std::fs::metadata(path)) {+ (Ok(held), Ok(named)) => held.dev() == named.dev() && held.ino() == named.ino(),+ _ => false,+ }+}++/// Whether `path` is still the file `file` has open. On Windows a file+/// another process is removing cannot be opened at all until it is gone,+/// so a file that opened and locked is the one at the path.+#[cfg(not(unix))]+fn same_file(_file: &File, path: &Path) -> bool {+ path.exists()+}++#[cfg(test)]+mod tests {+ use super::*;+ use std::process::{Command, Stdio};++ #[test]+ fn a_lock_is_taken_named_and_given_back() {+ let scratch = tempfile::tempdir().expect("scratch");+ let lock = ProjectLock::acquire(scratch.path(), "window").expect("taken");+ let text = std::fs::read_to_string(lock.path()).expect("written");+ assert!(text.starts_with(&format!("{}\nwindow\n", std::process::id())));+ assert_eq!(ProjectLock::holder(scratch.path()), None, "ours is not another's");+ drop(lock);+ assert!(!scratch.path().join(FILE).exists(), "the file goes with it");+ let again = ProjectLock::acquire(scratch.path(), "api").expect("free again");+ drop(again);+ }++ #[test]+ fn a_file_left_by_a_process_that_died_is_taken_over() {+ let scratch = tempfile::tempdir().expect("scratch");+ // A crash leaves the file and its words, and no lock.+ std::fs::write(scratch.path().join(FILE), "999999\nwindow\n0\n").expect("written");+ assert_eq!(ProjectLock::holder(scratch.path()), None);+ let lock = ProjectLock::acquire(scratch.path(), "api").expect("taken over");+ let text = std::fs::read_to_string(lock.path()).expect("rewritten");+ assert!(text.contains("\napi\n"), "{text}");+ }++ /// Another process holds the folder: this test's own binary, run as a+ /// child that takes the lock and waits for its input to close.+ #[test]+ fn a_second_process_is_refused_and_told_who_holds_it() {+ if let Ok(folder) = std::env::var("CONCAT_LOCK_CHILD") {+ let _lock = ProjectLock::acquire(Path::new(&folder), "window").expect("child takes it");+ println!("held");+ let mut line = String::new();+ let _ = std::io::stdin().read_line(&mut line);+ return;+ }+ let scratch = tempfile::tempdir().expect("scratch");+ let mut child = Command::new(std::env::current_exe().expect("this test"))+ .args([+ "--exact",+ "lock::tests::a_second_process_is_refused_and_told_who_holds_it",+ "--nocapture",+ "--test-threads=1",+ ])+ .env("CONCAT_LOCK_CHILD", scratch.path())+ .stdin(Stdio::piped())+ .stdout(Stdio::piped())+ .spawn()+ .expect("a child");+ let mut out = std::io::BufReader::new(child.stdout.take().expect("stdout"));+ let mut line = String::new();+ loop {+ line.clear();+ let read = std::io::BufRead::read_line(&mut out, &mut line).expect("reads");+ assert!(read > 0, "the child never held it");+ // The harness prints the test's name on the same line first.+ if line.trim_end().ends_with("held") {+ break;+ }+ }+ let refused = ProjectLock::acquire(scratch.path(), "api").expect_err("held elsewhere");+ let owner = Owner {+ pid: Some(child.id()),+ role: "window".to_owned(),+ };+ assert_eq!(refused, LockError::Held(owner.clone()));+ assert_eq!(ProjectLock::holder(scratch.path()), Some(owner));+ // The child goes - as a crash would - and the folder is free.+ let _ = child.kill();+ let _ = child.wait();+ let lock = ProjectLock::acquire(scratch.path(), "api").expect("free once it is gone");+ drop(lock);+ }+}diff --git a/src/crates/concat/locales/ar.json b/src/crates/concat/locales/ar.jsonindex fa846d62..202dea77 100644--- a/src/crates/concat/locales/ar.json+++ b/src/crates/concat/locales/ar.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "ضع مؤشر التشغيل داخل المقطع لقصّه هناك","studio.paste": "لصق","studio.projectOpenThroughRemote": "هذا المشروع مفتوح عبر واجهة Remote API",+ "studio.projectOpenElsewhere": "هذا المشروع مفتوح في نسخة أخرى من Concat (العملية {0}). أغلقه هناك، ثم افتحه هنا.","studio.projectSaved": "تم حفظ المشروع","studio.quit": "إنهاء","studio.reattachAudio": "إعادة إرفاق الصوت",diff --git a/src/crates/concat/locales/bn.json b/src/crates/concat/locales/bn.jsonindex 3fdde275..c951c796 100644--- a/src/crates/concat/locales/bn.json+++ b/src/crates/concat/locales/bn.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "সেখানে কাটতে প্লেহেডটি ক্লিপের ভেতরে রাখুন","studio.paste": "পেস্ট","studio.projectOpenThroughRemote": "এই প্রজেক্টটি রিমোট API-এর মাধ্যমে খোলা",+ "studio.projectOpenElsewhere": "এই প্রজেক্টটি আরেকটি Concat-এ খোলা আছে (প্রসেস {0})। সেখানে বন্ধ করুন, তারপর এখানে খুলুন।","studio.projectSaved": "প্রজেক্ট সংরক্ষিত","studio.quit": "বন্ধ করুন","studio.reattachAudio": "অডিও পুনরায় যুক্ত করুন",diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.jsonindex 8b52f0b6..2802eb31 100644--- a/src/crates/concat/locales/de.json+++ b/src/crates/concat/locales/de.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Setze den Abspielkopf in den Clip, um ihn dort zu schneiden","studio.paste": "Einfügen","studio.projectOpenThroughRemote": "Dieses Projekt ist über die Remote-API geöffnet",+ "studio.projectOpenElsewhere": "Dieses Projekt ist in einem anderen Concat geöffnet (Prozess {0}). Schließen Sie es dort und öffnen Sie es dann hier.","studio.projectSaved": "Projekt gespeichert","studio.quit": "Beenden","studio.reattachAudio": "Audio wieder anhängen",diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.jsonindex 3510d3b6..28429469 100644--- a/src/crates/concat/locales/en.json+++ b/src/crates/concat/locales/en.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Put the playhead inside the clip to cut it there","studio.paste": "Paste","studio.projectOpenThroughRemote": "This project is open through the Remote API",+ "studio.projectOpenElsewhere": "This project is open in another Concat (process {0}). Close it there, then open it here.","studio.projectSaved": "Project saved","studio.quit": "Quit","studio.reattachAudio": "Reattach audio",diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.jsonindex 52dbf45e..3c0829c6 100644--- a/src/crates/concat/locales/es.json+++ b/src/crates/concat/locales/es.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Coloca el cabezal dentro del clip para cortarlo ahí","studio.paste": "Pegar","studio.projectOpenThroughRemote": "Este proyecto está abierto a través de la API remota",+ "studio.projectOpenElsewhere": "Este proyecto está abierto en otro Concat (proceso {0}). Ciérralo allí y luego ábrelo aquí.","studio.projectSaved": "Proyecto guardado","studio.quit": "Salir","studio.reattachAudio": "Volver a unir el audio",diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.jsonindex bdf6b7fd..90654acc 100644--- a/src/crates/concat/locales/fa.json+++ b/src/crates/concat/locales/fa.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "نشانگر پخش را داخل کلیپ بگذارید تا همانجا بریده شود","studio.paste": "چسباندن","studio.projectOpenThroughRemote": "این پروژه از طریق API راه دور باز است",+ "studio.projectOpenElsewhere": "این پروژه در Concat دیگری باز است (فرایند {0}). آن را آنجا ببندید، سپس اینجا باز کنید.","studio.projectSaved": "پروژه ذخیره شد","studio.quit": "خروج","studio.reattachAudio": "اتصال دوباره صدا",diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.jsonindex 61d2591f..cd92b0af 100644--- a/src/crates/concat/locales/fr.json+++ b/src/crates/concat/locales/fr.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Placez la tête de lecture dans le clip pour le couper à cet endroit","studio.paste": "Coller","studio.projectOpenThroughRemote": "Ce projet est ouvert via l’API distante",+ "studio.projectOpenElsewhere": "Ce projet est ouvert dans un autre Concat (processus {0}). Fermez-le là-bas, puis ouvrez-le ici.","studio.projectSaved": "Projet enregistré","studio.quit": "Quitter","studio.reattachAudio": "Rattacher l'audio",diff --git a/src/crates/concat/locales/he.json b/src/crates/concat/locales/he.jsonindex 050a8dc7..6931a11c 100644--- a/src/crates/concat/locales/he.json+++ b/src/crates/concat/locales/he.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "יש למקם את סמן ההפעלה בתוך הקליפ כדי לחתוך אותו שם","studio.paste": "הדבקה","studio.projectOpenThroughRemote": "הפרויקט הזה פתוח דרך ה-Remote API",+ "studio.projectOpenElsewhere": "הפרויקט הזה פתוח ב-Concat אחר (תהליך {0}). סגרו אותו שם ואז פתחו אותו כאן.","studio.projectSaved": "הפרויקט נשמר","studio.quit": "יציאה","studio.reattachAudio": "חיבור השמע מחדש",diff --git a/src/crates/concat/locales/hi.json b/src/crates/concat/locales/hi.jsonindex 5c4cbef7..723f4a98 100644--- a/src/crates/concat/locales/hi.json+++ b/src/crates/concat/locales/hi.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "क्लिप को वहीं काटने के लिए प्लेहेड को उसके अंदर रखें","studio.paste": "चिपकाएं","studio.projectOpenThroughRemote": "यह प्रोजेक्ट रिमोट API के ज़रिए खुला है",+ "studio.projectOpenElsewhere": "यह प्रोजेक्ट किसी दूसरे Concat में खुला है (प्रोसेस {0})। उसे वहाँ बंद करें, फिर यहाँ खोलें।","studio.projectSaved": "प्रोजेक्ट सेव हो गया","studio.quit": "बंद करें","studio.reattachAudio": "ऑडियो फिर से जोड़ें",diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.jsonindex 5675d35d..6b189adc 100644--- a/src/crates/concat/locales/hr.json+++ b/src/crates/concat/locales/hr.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Postavi playhead unutar klipa da bi ga ondje izrezao","studio.paste": "Zalijepi","studio.projectOpenThroughRemote": "Ovaj je projekt otvoren putem udaljenog API-ja",+ "studio.projectOpenElsewhere": "Ovaj je projekt otvoren u drugom Concatu (proces {0}). Zatvorite ga ondje, a zatim ga otvorite ovdje.","studio.projectSaved": "Projekt spremljen","studio.quit": "Izađi","studio.reattachAudio": "Ponovno spoji zvuk",diff --git a/src/crates/concat/locales/id.json b/src/crates/concat/locales/id.jsonindex 566ef76e..52cca980 100644--- a/src/crates/concat/locales/id.json+++ b/src/crates/concat/locales/id.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Letakkan penanda putar di dalam klip untuk memotongnya di titik itu","studio.paste": "Tempel","studio.projectOpenThroughRemote": "Proyek ini terbuka melalui API Jarak Jauh",+ "studio.projectOpenElsewhere": "Proyek ini terbuka di Concat lain (proses {0}). Tutup di sana, lalu buka di sini.","studio.projectSaved": "Proyek disimpan","studio.quit": "Keluar","studio.reattachAudio": "Pasang kembali audio",diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.jsonindex 2dbdeb31..7c818887 100644--- a/src/crates/concat/locales/it.json+++ b/src/crates/concat/locales/it.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Porta la testina dentro la clip per tagliarla lì","studio.paste": "Incolla","studio.projectOpenThroughRemote": "Questo progetto è aperto tramite l’API remota",+ "studio.projectOpenElsewhere": "Questo progetto è aperto in un altro Concat (processo {0}). Chiudilo lì, poi aprilo qui.","studio.projectSaved": "Progetto salvato","studio.quit": "Esci","studio.reattachAudio": "Ricollega l'audio",diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.jsonindex c37e7151..8192166b 100644--- a/src/crates/concat/locales/ja.json+++ b/src/crates/concat/locales/ja.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "その位置で切るには、再生ヘッドをクリップ内に置いてください","studio.paste": "ペースト","studio.projectOpenThroughRemote": "このプロジェクトはリモート API で開かれています",+ "studio.projectOpenElsewhere": "このプロジェクトは別の Concat で開かれています(プロセス {0})。そちらで閉じてから、ここで開いてください。","studio.projectSaved": "プロジェクトを保存しました","studio.quit": "終了","studio.reattachAudio": "音声を再結合",diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.jsonindex 5e60f686..4255d2ff 100644--- a/src/crates/concat/locales/ko.json+++ b/src/crates/concat/locales/ko.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "그 위치에서 자르려면 재생 헤드를 클립 안에 두세요","studio.paste": "붙여넣기","studio.projectOpenThroughRemote": "이 프로젝트는 원격 API를 통해 열려 있습니다",+ "studio.projectOpenElsewhere": "이 프로젝트는 다른 Concat에서 열려 있습니다(프로세스 {0}). 그곳에서 닫은 뒤 여기서 여세요.","studio.projectSaved": "프로젝트를 저장했습니다","studio.quit": "끝내기","studio.reattachAudio": "오디오 다시 연결",diff --git a/src/crates/concat/locales/nl.json b/src/crates/concat/locales/nl.jsonindex 42c46fb6..d5fa7479 100644--- a/src/crates/concat/locales/nl.json+++ b/src/crates/concat/locales/nl.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Zet de afspeelkop in de clip om hem daar te knippen","studio.paste": "Plakken","studio.projectOpenThroughRemote": "Dit project is geopend via de Remote API",+ "studio.projectOpenElsewhere": "Dit project is geopend in een andere Concat (proces {0}). Sluit het daar en open het dan hier.","studio.projectSaved": "Project opgeslagen","studio.quit": "Stoppen","studio.reattachAudio": "Audio opnieuw koppelen",diff --git a/src/crates/concat/locales/pl.json b/src/crates/concat/locales/pl.jsonindex d8e7b3f3..d33c34da 100644--- a/src/crates/concat/locales/pl.json+++ b/src/crates/concat/locales/pl.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Ustaw głowicę wewnątrz klipu, aby go tam przeciąć","studio.paste": "Wklej","studio.projectOpenThroughRemote": "Ten projekt jest otwarty przez Remote API",+ "studio.projectOpenElsewhere": "Ten projekt jest otwarty w innym Concat (proces {0}). Zamknij go tam, a potem otwórz tutaj.","studio.projectSaved": "Projekt zapisany","studio.quit": "Zakończ","studio.reattachAudio": "Dołącz dźwięk ponownie",diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.jsonindex 287d61f5..77c67d99 100644--- a/src/crates/concat/locales/pt-BR.json+++ b/src/crates/concat/locales/pt-BR.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Coloque o cursor dentro do clipe para cortá-lo ali","studio.paste": "Colar","studio.projectOpenThroughRemote": "Este projeto está aberto pela API remota",+ "studio.projectOpenElsewhere": "Este projeto está aberto em outro Concat (processo {0}). Feche-o lá e depois abra-o aqui.","studio.projectSaved": "Projeto salvo","studio.quit": "Sair","studio.reattachAudio": "Reanexar áudio",diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.jsonindex b1dbaa65..29073c6c 100644--- a/src/crates/concat/locales/ru.json+++ b/src/crates/concat/locales/ru.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Поставьте курсор внутрь клипа, чтобы разрезать его там","studio.paste": "Вставить","studio.projectOpenThroughRemote": "Этот проект открыт через удалённый API",+ "studio.projectOpenElsewhere": "Этот проект открыт в другом Concat (процесс {0}). Закройте его там, а затем откройте здесь.","studio.projectSaved": "Проект сохранён","studio.quit": "Выйти","studio.reattachAudio": "Присоединить звук обратно",diff --git a/src/crates/concat/locales/th.json b/src/crates/concat/locales/th.jsonindex 517f0f79..edb11bd3 100644--- a/src/crates/concat/locales/th.json+++ b/src/crates/concat/locales/th.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "วางหัวเล่นไว้ภายในคลิปเพื่อตัดตรงนั้น","studio.paste": "วาง","studio.projectOpenThroughRemote": "โปรเจกต์นี้เปิดผ่าน API ระยะไกล",+ "studio.projectOpenElsewhere": "โปรเจกต์นี้เปิดอยู่ใน Concat อีกตัวหนึ่ง (โพรเซส {0}) ปิดที่นั่นก่อน แล้วค่อยเปิดที่นี่","studio.projectSaved": "บันทึกโปรเจกต์แล้ว","studio.quit": "ออกจากโปรแกรม","studio.reattachAudio": "รวมเสียงกลับ",diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.jsonindex 891d349f..0ebf4abf 100644--- a/src/crates/concat/locales/tr.json+++ b/src/crates/concat/locales/tr.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Klibi orada kesmek için oynatma imlecini klibin içine getirin","studio.paste": "Yapıştır","studio.projectOpenThroughRemote": "Bu proje Uzak API üzerinden açık",+ "studio.projectOpenElsewhere": "Bu proje başka bir Concat'te açık (işlem {0}). Önce orada kapatın, sonra burada açın.","studio.projectSaved": "Proje kaydedildi","studio.quit": "Çık","studio.reattachAudio": "Sesi yeniden bağla",diff --git a/src/crates/concat/locales/uk.json b/src/crates/concat/locales/uk.jsonindex 07c31742..ab888eb1 100644--- a/src/crates/concat/locales/uk.json+++ b/src/crates/concat/locales/uk.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Поставте курсор відтворення всередину кліпу, щоб розрізати його там","studio.paste": "Вставити","studio.projectOpenThroughRemote": "Цей проєкт відкрито через Remote API",+ "studio.projectOpenElsewhere": "Цей проєкт відкрито в іншому Concat (процес {0}). Закрийте його там, а потім відкрийте тут.","studio.projectSaved": "Проєкт збережено","studio.quit": "Вийти","studio.reattachAudio": "Повернути аудіо",diff --git a/src/crates/concat/locales/ur.json b/src/crates/concat/locales/ur.jsonindex fe53d617..a03ca5f6 100644--- a/src/crates/concat/locales/ur.json+++ b/src/crates/concat/locales/ur.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "کلپ کو وہاں سے کاٹنے کے لیے پلے ہیڈ کو اس کے اندر رکھیں","studio.paste": "پیسٹ کریں","studio.projectOpenThroughRemote": "یہ پروجیکٹ Remote API کے ذریعے کھلا ہے",+ "studio.projectOpenElsewhere": "یہ پروجیکٹ کسی دوسرے Concat میں کھلا ہے (پروسیس {0})۔ اسے وہاں بند کریں، پھر یہاں کھولیں۔","studio.projectSaved": "پروجیکٹ محفوظ ہو گیا","studio.quit": "بند کریں","studio.reattachAudio": "آڈیو دوبارہ جوڑیں",diff --git a/src/crates/concat/locales/vi.json b/src/crates/concat/locales/vi.jsonindex fd14bfbc..7b16f20f 100644--- a/src/crates/concat/locales/vi.json+++ b/src/crates/concat/locales/vi.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "Đặt đầu phát vào trong clip để cắt tại vị trí đó","studio.paste": "Dán","studio.projectOpenThroughRemote": "Dự án này đang được mở thông qua API từ xa",+ "studio.projectOpenElsewhere": "Dự án này đang mở trong một Concat khác (tiến trình {0}). Hãy đóng nó ở đó, rồi mở ở đây.","studio.projectSaved": "Đã lưu dự án","studio.quit": "Thoát","studio.reattachAudio": "Gắn lại âm thanh",diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.jsonindex ed3ae24b..89670199 100644--- a/src/crates/concat/locales/zh-Hans.json+++ b/src/crates/concat/locales/zh-Hans.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "请将播放头放在片段内,才能在该处切开","studio.paste": "粘贴","studio.projectOpenThroughRemote": "此项目正通过远程 API 打开",+ "studio.projectOpenElsewhere": "此项目已在另一个 Concat 中打开(进程 {0})。请先在那里关闭,再在这里打开。","studio.projectSaved": "项目已保存","studio.quit": "退出","studio.reattachAudio": "重新附加音频",diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.jsonindex 56a163ce..19fa5f12 100644--- a/src/crates/concat/locales/zh-TW.json+++ b/src/crates/concat/locales/zh-TW.json@@ -655,6 +655,7 @@"studio.parkPlayheadInsideClip": "請將播放磁頭放在片段內,才能在該處切開","studio.paste": "貼上","studio.projectOpenThroughRemote": "此專案正透過遠端 API 打開",+ "studio.projectOpenElsewhere": "此專案已在另一個 Concat 中開啟(程序 {0})。請先在那裡關閉,再在這裡開啟。","studio.projectSaved": "專案已儲存","studio.quit": "結束","studio.reattachAudio": "重新附加音訊",diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rsindex 426ab28e..c9c9313b 100644--- a/src/crates/concat/src/studio.rs+++ b/src/crates/concat/src/studio.rs@@ -8062,13 +8062,26 @@ impl Studio {/// says why it could not.pub fn open_project(&mut self, info: ProjectInfo) -> Result<(), String> {log::info!("project: opening {}", info.path);- if self+ match self.host.open_projects.claim(&info.path, concat_api::Holder::Window)- .is_err(){- return Err(t("studio.projectOpenThroughRemote"));+ Ok(()) => {}+ Err(concat_api::Refusal::Here(_)) => {+ return Err(t("studio.projectOpenThroughRemote"));+ }+ // Another process has it - a second window, an agent's+ // `concat --mcp`, the CLI - and two saving one folder lose+ // each other's work.+ Err(concat_api::Refusal::Elsewhere(owner)) => {+ let pid = owner+ .pid+ .map(|pid| pid.to_string())+ .unwrap_or_else(|| "?".to_owned());+ log::warn!("project: {} is held by process {pid}", info.path);+ return Err(tf("studio.projectOpenElsewhere", &[&pid]));+ }}match Session::open_info(&info) {Ok(session) => {