cli: --save runs on one project take turns, so no edit is lost (#3926)

* cli: --save runs on one project take turns, so no edit is lost (#3924)

A run reads the project, edits it and writes the whole file back, so two
at once silently dropped the edits of whichever saved first. A run that
saves over the file it opened now holds an OS lock on `.<name>.lock` next
to the project from before its read until it exits. The next run says so
on stderr, waits, then edits what the first one saved.

The OS drops the lock however the process ends, so a crash leaves nothing
stale. If the lock can't be taken the run warns and saves as it did before.
The desktop app and `mcp` sessions don't take this lock.

* cli: the save lock goes by the path being saved over (#3924)

A save through a symlink replaces the link with a plain file. Resolving
the path therefore gave the runs before and after that save different
locks, and a run still waiting on the old lock could overwrite a later
run's save. The lock now uses the path as written, so replacing the link
can't change which lock a run takes.
This commit is contained in:
Jonathan Cardoso
2026-11-02 02:38:13 -03:00
committed by GitHub
parent d57a29b776
commit 5c73ee4af6
5 changed files with 252 additions and 1 deletions
+4
View File
@@ -102,6 +102,10 @@ Every write of a project file, auto-save, recovery snapshot or preferences file
A crash, `kill -9` or power cut at any point leaves either the complete old file or the complete new
one. If a step fails, the temp file is removed and the old file is untouched.
Atomic writes keep the file whole, but they don't merge: of two sessions that opened the same project,
the one that saves last replaces what the other saved. `filmcraft-cli --save` runs take turns on a lock
to avoid that ([agents.md](agents.md)); the desktop app and `mcp` sessions don't.
## Commands
| Id | Menu | |