Repository navigation
fix(web): stop TrimmingTool effect from clearing the selected video - #2651
Merged
richiemcilroy merged 4 commits intoOct 19, 2026
Merged
richiemcilroy merged 4 commits into
richiemcilroy merged 4 commits into
Conversation
The mount effect listed the per-render cleanupResources function as a dependency, so it re-ran after every commit. Each cleanup reset videoSrc to null and wrote new state, which re-rendered and repeated the cycle, so a selected file never loaded. Register the Safari detection and window drag listeners once on mount. Revoke superseded output URLs through an effect keyed on outputUrl, and revoke the latest video URL on unmount through a ref.
Contributor
|
@MinitJain is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
MinitJain
marked this pull request as ready for review
October 16, 2026 16:31
Cleans up the React root even when an assertion fails before the test's own unmount.
Contributor
Author
|
@greptileai please re-review the PR |
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The TrimmingTool effect lists a per-render
cleanupResourcesas a dependency, so it re-runs after every commit. Its cleanup clearsvideoSrc, so the selected video never loads and the UI stays on "Loading video...".Root cause
cleanupResources(TrimmingTool.tsx:76) is a plain function, so it is a new reference on every render. The effect at 700-725 has deps[cleanupResources, processingState.outputUrl]. After each commit the previous effect's cleanup callscleanupResources(), which setsfileState.videoSrc = nulland writes new state objects. The effect body also callssetVideoState, which writes another new object. Both writes trigger a re-render, which creates a newcleanupResources, and the cycle repeats. Commit 10ae2a2 changed the deps from[]to this list.Fix
The Safari detection and the window dragover/drop listeners now run in a mount-only effect that no longer calls
cleanupResources. Blob URLs are still cleaned up:cleanupResourcesrevokes the old video URL when a new file is chosen; a mount-only effect revokes the current video URL on unmount (read through a ref); and an effect keyed onprocessingState.outputUrlrevokes each trimmed output URL when it is replaced or the component unmounts.How to reproduce
/tools/trim(reproduced on cap.so on 2026-10-16).The regression test
apps/web/__tests__/unit/trimming-tool-effect.test.tsreproduces it: it fails on the current code.Tests
Regression test:
apps/web/__tests__/unit/trimming-tool-effect.test.ts. It fails without the fix and passes with it.Checks run locally:
Note: the production build (
next build) was not run locally, because it needs the app's environment and services. Only the tests, lint and typecheck above were run.

Confidence Score: 5/5
The PR appears safe to merge.Summary
The PR separates window-listener cleanup from blob URL cleanup so the selected video stays loaded.
Reviews (2) · Last reviewed commit: "test(web): unmount TrimmingTool root in ..." · Reviewed by Greptile