`undo` is unreliable after CapCut saves: the app rewrites `.capcut-cli-history/*.snap`
Summary
On CapCut 9.5.0.4050 (Windows 10.0.19045, app_source = "cc"), saving a project in the app rewrote a history snapshot the CLI had just written. .capcut-cli-history/draft_content.json.000001.snap changed from the genuine pre-write content to a copy of the app's own draft_content.json.bak — content that already includes the CLI's edit. undo therefore has nothing correct to restore.
Reproduction
- Fresh empty project created by the app; app fully closed.
capcut add-text <project> 2s 3s "…"— creates.capcut-cli-history/{draft_content.json,template-2.tmp}.000001.snap, both holding the pre-write file (4281B, 0 segments).- Open the project in CapCut, save (Ctrl+S), close.
- Compare the snapshots:
.capcut-cli-history/draft_content.json.000001.snap
before save: cd0a3701… 4281B 0 segments <- correct pre-write state
after save : 7c8af639… 9551B 1 segment
^ byte-identical to the app's own draft_content.json.bak
.capcut-cli-history/template-2.tmp.000001.snap
before save: cd0a3701… 4281B 0 segments
after save : cd0a3701… 4281B 0 segments <- untouched
Note the asymmetry: the template-2.tmp snapshot is left alone while the draft_content.json one is replaced — and the replacement is byte-identical to the app's draft_content.json.bak (9551B), which is not the pre-write file either.
Impact
capcut undoafter an app save restores the wrong content — the state at save time rather than before the CLI write.- It fails silently. The journal still records
before_sha256/after_sha256for the CLI write, so history looks intact while one snapshot no longer matches its own journal entry.
Possible mitigations
- Keep snapshots somewhere the app does not enumerate (it appears to touch files matching the primary draft's name inside the project tree).
- Before restoring, verify
sha256(snap) == journal.before_sha256and refuse with a clear message when it does not match, rather than restoring silently.
Environment
CapCut 9.5.0.4050, Windows 10.0.19045, capcut-cli 0.29.0.
Before/after fixtures were captured with capcut fixture (media excluded, home paths redacted) and can be attached if useful.
Thanks for catching this and comparing the hashes! The snapshot is currently hard-linked to .bak, so an in-place app rewrite could explain both changing together. Could you attach the redacted before/after captures? Independent snapshots and hash checks before restore look like the right fix.
This is addressed in v0.30.0 (npm i -g [email protected]):
- History snapshots are now their own files, no longer hard links to
.bak, so the app rewriting.bakon save leaves them untouched. restorechecks the.bakor snapshot against the hash recorded before the write. If the file changed, it refuses (refused [backup-changed]/[snapshot-changed]) and points at an intact step;--force-writeoverrides.restore --listshowsintact,changedorunverifiedfor each snapshot.
Snapshots written by older versions are still hard links, so they will show as changed once CapCut has saved. New edits get independent snapshots.
Closing as fixed in 0.30.0. If undo still breaks after CapCut 9.5.0.4050 saves on this version, comment here and I'll reopen.