Skip to content

Fix: Prevent premature state update and export corruption in TrimControl#957

Merged
magic-peach merged 3 commits into
magic-peach:mainfrom
Sandeep6135:fix-trim-state-bug
May 23, 2026
Merged

Fix: Prevent premature state update and export corruption in TrimControl#957
magic-peach merged 3 commits into
magic-peach:mainfrom
Sandeep6135:fix-trim-state-bug

Conversation

@Sandeep6135
Copy link
Copy Markdown
Contributor

Description

This pull request fixes a critical state corruption bug in the video trimming workflow.
The Problem:
Previously, the handleEnd function in TrimControl updated the global recipe.trimEnd state before validating the user's input. If a user entered an invalid value (resulting in NaN) or an out-of-bounds value, the NaN value was committed to the state despite the UI showing an error. This bypassed the pre-export validation (NaN > duration evaluates to false), passing corrupted state to FFmpeg and causing the video export to fail/crash.
The Solution:
Moved the onChange({ trimEnd: n }) state dispatch to the very end of the handleEnd function. The global recipe state is now only updated after all input validation checks (like isNaN, positive integer bounds, and duration checks) pass successfully.
Testing:

  • Verified that entering invalid characters correctly shows an inline error without persisting to the global recipe.
  • Verified that valid inputs successfully update the state.
  • Verified that corrupted values no longer bypass the export validations.

Closes #954

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

@Sandeep6135 is attempting to deploy a commit to the magic-peach1's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

✅ PR Format Check Passed — @Sandeep6135

Basic format checks passed. A maintainer will review your code changes.

This does not mean the PR is approved — it just means the format is correct.

@github-actions
Copy link
Copy Markdown
Contributor

👋 Thanks for your PR, @Sandeep6135!

Welcome to Reframe — a browser-based video editor built for everyone 🎬

What happens next

  1. 🤖 Automated checks — build & TypeScript typecheck will run automatically
  2. Vercel preview — a preview deployment will be created (requires maintainer authorization for fork PRs)
  3. 👀 Code review — a maintainer will review your changes
  4. 🚀 Merge — once approved, your PR will be merged!

Quick checklist

  • PR title follows Conventional Commits (e.g. feat: add dark mode)
  • Linked the issue this PR closes (e.g. Closes #123)
  • Tested the changes locally (bun run dev)
  • Build passes (bun run build)

Useful links

Happy coding! 🎉

@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
reframe Ready Ready Preview, Comment May 23, 2026 11:07am

@magic-peach magic-peach added gssoc:approved Approved for GSSoC'26 quality:clean Well-implemented, clean code labels May 23, 2026
@magic-peach
Copy link
Copy Markdown
Owner

@Sandeep6135 please star the repo

@magic-peach magic-peach merged commit 4873deb into magic-peach:main May 23, 2026
11 checks passed
chavanGaneshDatta pushed a commit to chavanGaneshDatta/reframe that referenced this pull request May 23, 2026
…rol (magic-peach#957)

* Fix premature state update in TrimControl

* Trigger CI recheck

* Fix unexportable video bug for unknown durations
Ram-sah19 pushed a commit to Ram-sah19/reframe that referenced this pull request May 24, 2026
…rol (magic-peach#957)

* Fix premature state update in TrimControl

* Trigger CI recheck

* Fix unexportable video bug for unknown durations
sahilsultane pushed a commit to sahilsultane/reframe that referenced this pull request May 24, 2026
…rol (magic-peach#957)

* Fix premature state update in TrimControl

* Trigger CI recheck

* Fix unexportable video bug for unknown durations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Approved for GSSoC'26 level:beginner Beginner level - 20 pts quality:clean Well-implemented, clean code type:bug Bug fix type:design UI/UX design type:testing Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] State corruption and export failure due to premature state update in 'TrimControl'

2 participants