Skip to content

fix: don't scale or crop timelines when opening a saved file (#453)#555

Merged
azfoo merged 3 commits into
TimeLineAnnotator:devfrom
FelipeDefensor:fix/453-keep-timelines-on-open
Jul 24, 2026
Merged

fix: don't scale or crop timelines when opening a saved file (#453)#555
azfoo merged 3 commits into
TimeLineAnnotator:devfrom
FelipeDefensor:fix/453-keep-timelines-on-open

Conversation

@FelipeDefensor

Copy link
Copy Markdown
Collaborator

Closes #453.

Problem

Opening a .tla sets the media duration twice: first from the file's stored media length, then again when the player reports the actual duration. For YouTube sources these two values usually differ by a fraction of a second, so TiLiA prompted the user to scale timelines that already matched the saved media.

Fix

Route the file-open media load through a new scale_timelines="keep" mode. On open, the timelines were saved to match this media, so the duration the player reports must not scale, crop, or prompt — it should only update the stored duration.

"keep" rather than "no": "no" still crops when the reported duration comes back shorter than the stored value (App.on_media_duration_changed), which silently deletes any components past the new end. YouTube's asynchronous duration can be a few milliseconds shorter than the stored value, so "no" risked data loss. Explicit Load Media actions keep the default "prompt", and the media-not-found → replacement-media path on open also keeps "prompt".

Test

test_async_duration_after_open_does_not_prompt_or_change_timelines — parametrized over a shorter and a longer async duration reported after open; asserts no scale prompt fires and no component is scaled or cropped. Built with save_and_reopen (a real temporary .tla). Verified it fails under "no" (the end marker is cropped: assert 0 == 1) and passes under "keep".

Test plan

  • pytest tests/test_app.py::TestFileLoad tests/test_app.py::TestScaleCropTimeline tests/test_app.py::TestMediaLoad (22 passed)
  • pre-commit (black, ruff)

🤖 Generated with Claude Code

@FelipeDefensor

Copy link
Copy Markdown
Collaborator Author

@azfoo, sorry for the dealy on opening, but this one is important. The bug is very annoying. Ideally to be landed on the next minor version.

I didn't test the AI fix.

@FelipeDefensor FelipeDefensor added this to the 0.6.4 milestone Jul 21, 2026
@azfoo

azfoo commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

@FelipeDefensor will do, no worries. do also see the last email I sent you.

FelipeDefensor and others added 2 commits July 24, 2026 15:47
…eAnnotator#453)

Opening a .tla sets the media duration twice: first from the file's stored media length, then again when the player reports the actual duration. For YouTube these two values often differ by a fraction of a second, so TiLiA prompted to scale timelines that already matched the saved media.

Route the file-open media load through a new scale_timelines="keep" mode that updates the duration without scaling, cropping, or prompting. "no" is not enough: it still crops when the reported duration comes back shorter, which silently deletes end components. "keep" leaves the timelines untouched -- correct on open, since they were saved to match this media. Explicit "Load Media" actions keep the default "prompt".

Add a regression test covering both a shorter and a longer async duration reported after open, asserting no scale prompt and no component loss.
It is possible to edit the same video with the same id and cut it significantly shorter. This can cause problems further down if the new media duration is saved with elements that are now well beyond the end time. Rather than assuming that the time difference is always due to a small error, limit the potential for major differences.
@azfoo
azfoo force-pushed the fix/453-keep-timelines-on-open branch from e1da2e4 to 05cd95a Compare July 24, 2026 13:53
also adds a --scale-timelines option in the cli
@azfoo
azfoo merged commit 3b60d49 into TimeLineAnnotator:dev Jul 24, 2026
11 checks passed
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.

2 participants