Two editors, one file: how an AI agent edits a project the user has open
Part 6 of a series on Movie Engine, where an AI agent edits Kdenlive video projects while the editor stays open. Earlier parts: 1, overview , 2, UI Automation without stealing focus , 3, menu names from translation files , 4, rendering what Kdenlive can't , 5, captions timed to the spoken word . Here is the situation Movie Engine is built for. Kdenlive is open with a project. I am trimming clips…
Kdenlive, a video editing software, currently lacks an automation API. This limitation presented a challenge for AI agents that wished to edit projects open in the software. To overcome this, developers created Movie Engine, a system allowing an AI agent to edit a project while the user remains in control. The key to success lay in ensuring the user's edits were never lost and the AI's edits were always reflected in the open editor.
Movie Engine achieves this through a two-step process: a lock and a check. The lock is a mutex, a unique identifier tied to the project file. When the AI agent or the user attempt to edit the project, they must first obtain the lock. The lock ensures both entities edit the project sequentially, preventing interleaving. This is crucial because the user's edits must not be overwritten by the AI's edits.
After obtaining the lock, the system checks for unsaved edits. If Kdenlive has unsaved edits, the system saves them using UI Automation, a method that doesn't steal focus from the user. The system waits until the Save button is disabled again, indicating Kdenlive has finished saving. The system then checks the file's hash, a unique string derived from the file's content.
This hash is used to verify that the file's content hasn't changed while the edit command was running. If the hash has changed, the system throws an error and asks the user to re-run the command, ensuring the user's edits are not lost.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to