Skip to content

Fix CapCut 7.x active timeline writes - #51

Closed
jaecho1001 wants to merge 1 commit into
renezander030:masterfrom
jaecho1001:fix/capcut-7-timelines
Closed

jaecho1001 wants to merge 1 commit into
renezander030:masterfrom
jaecho1001:fix/capcut-7-timelines

Conversation

@jaecho1001

Copy link
Copy Markdown

Summary

  • follow Timelines/project.json to the active nested draft for verified CapCut 7.x projects
  • keep the active timeline and readable root mirrors synchronized through the existing transactional write path
  • make sync-timelines repair in the structurally safe active-timeline → root-mirror direction
  • preserve the established CapCut 8.7+ template-2.tmp priority and treat legacy nested files as diagnostic-only there
  • isolate explicitly addressed root/archived files and reject traversal or symlink escapes
  • document the layout-selected canonical behavior in both READMEs, help, changelog, and generated command references

Root cause

CapCut 7.7 can store the document it actually opens at Timelines/<main_timeline_id>/draft_info.json. The project-root draft_info.json is a derived mirror. Root-only discovery therefore let commands return success while editing a file that CapCut replaced from the untouched nested timeline on reopen.

Compatibility and safety

The nested pointer is authoritative only for pre-8.7 CapCut storage. Modern projects retain their existing canonical selection and never write discovered legacy nested files. Explicit non-active file paths remain isolated, unreadable explicit mirrors fall back without dropping the canonical write target, and the active path must remain within the real Timelines directory.

Validation

  • Full Node test suite: 531 passed, 0 failed
  • New Timelines regression suite: 12 passed, 0 failed
  • npm run build
  • npm run lint
  • npm run docs:commands
  • git diff --check

Closes #50

@renezander030 renezander030 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jaecho1001, thanks for this. The implementation is careful in the places that matter: containment on the main_timeline_id value before it is joined, realpathSync checks so a symlinked timeline cannot escape Timelines/, the 8.7+ template-2.tmp priority left intact, explicit non-active paths kept isolated, and docs, help, changelog and the generated command reference all updated in the same pass. That is more diligence than most first PRs to this repo bring.

Two things before I can merge.

1. Evidence for the premise. I have asked in #50 for the artifacts that separate an active timeline from an archived one. Everything below assumes the pointer turns out to be authoritative.

2. The canonical flip is too broad. In discoverDraftStore, canonical ??= activeTimeline fires for any project below 8.7 where Timelines/project.json resolves to a directory holding draft_info.json or draft_content.json. Pre-8.7 is the bulk of the existing user base, and those projects are served correctly today from the root file. If a given project keeps Timelines/ as an archive rather than as the live document, this makes the nested snapshot canonical, reads come from stale data, and the sync path then pushes that stale timeline out to the root mirrors. That converts a silent no-op into overwritten work, which is the worse failure.

What I would like instead:

  • Add the nested active file as a write target unconditionally. That part is safe and captures most of the value.
  • Promote it to canonical only under a narrower condition: the root mirror is missing or unparseable, or the nested timeline hash differs from the root's and the nested file's mtime is newer. Otherwise keep the root file canonical.
  • Surface the decision. doctor and info should name which file was selected and why, so a user seeing an unexpected edit can diagnose it without reading source. The existing layout field is the right place to hang it.

Also worth adding to test/timelines-directory.test.mjs: a pre-8.7 project with a Timelines/ directory whose nested draft is older than the root, asserting the root stays canonical and nothing gets rolled back.

I am approving the workflow run so CI executes on Node 18, 20 and 22. Once that is green and the tests above are in, this is close.

Rene

@renezander030

Copy link
Copy Markdown
Owner

Hi @jaecho1001, closing this for now to keep the queue moving, since the repro artifact requested in #50 (the nested draft_info.json still holding the old text right after a set-text that reported success) has not come through. Code quality was never the concern. If the artifact lands and confirms the nested file is the live document on a real pre-8.7 project, happy to reopen and take this with the narrowed canonical gate discussed in the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CapCut 7.x edits are discarded when the active draft lives under Timelines/

2 participants