Files
Jonathan Cardoso 5c73ee4af6 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.
2026-11-02 00:38:13 -05:00
..