Skip to content

Fix importing your own transcript dropping the picked file - #112

Open
chiragjangiir wants to merge 1 commit into
wassgha:mainfrom
chiragjangiir:fix/import-transcript-file-input
Open

chiragjangiir wants to merge 1 commit into
wassgha:mainfrom
chiragjangiir:fix/import-transcript-file-input

Conversation

@chiragjangiir

Copy link
Copy Markdown

Summary

Importing an SRT, VTT or JSON caption file did nothing: the app silently fell
back to transcribing with Whisper. Both transcript file inputs dropped the file
the user picked, so the "skip Whisper" path was never taken.

Fixes #105.

Root cause

Both inputs did this:

const files = e.target.files;   // keep a reference to the live FileList
e.target.value = "";            // ...then clear the input to allow a re-pick
const file = files?.[0];        // undefined — the list was just emptied

input.files is a live [SameObject] FileList, so clearing the input empties
the very object the handler is still holding. file came back undefined, the
handler treated the pick as a cancel, pendingTranscript was never set, and
loadVideo ran without words — so skipTranscription stayed false and Whisper
transcribed a video the user had already captioned.

Measured in Chromium 130, and then in the app itself with a temporary probe in
the old handler:

[probe-old] captured.length after clear = 0 | files[0] = undefined

Clearing the input is only there to allow re-picking the same file, so the fix is
to read the file first and clear after. The media input in Editor.tsx already
did it in that order, which is why uploading video still worked.

Implementation

  • lib/parseTranscript.ts — new takeSelectedTranscriptFile(input): reads
    input.files[0], then resets the input, with the ordering documented.
  • components/ImportTranscriptOption.tsx — the upload-screen "import your own
    transcript" input uses it. The rest of the handler (progress, error, menu and
    cancel-timer bookkeeping) is unchanged.
  • components/TranscriptPanel.tsx — the in-editor "replace captions" input uses
    it, and handleImportTranscript now takes the File instead of a FileList,
    so no cast is needed to keep the async handler working.
  • tests/transcript-file-input-test.ts — new regression tests.
  • package.json + .github/workflows/ci.yml — a test:transcript script and a
    CI step. This also wires up tests/parse-transcript-test.ts, which existed but
    was run by no script or workflow.

Nothing changes for users who do not import a transcript: loadVideo still sets
skipTranscription: false when it is called without words.

Testing

Each command below was run; results are the actual output.

$ npm run lint                          # exit 0
$ npx next typegen && npx tsc --noEmit  # exit 0
$ npm run typecheck:electron            # exit 0
$ npm run test:i18n                     # ALL I18N TESTS PASSED
$ npm run test:timeline                 # ALL SERIALIZE TIMELINE TESTS PASSED
$ npm run test:transcript               # ALL TRANSCRIPT FILE INPUT TESTS PASSED
$ npm run test:ffmpeg                   # PASSED (native render tests skipped: no fetched ffmpeg)
$ npm run build                         # exit 0
$ npm run build:electron                # exit 0

The new test file covers: the harness reproducing the clear-then-read bug (a
control block, so the suite fails loudly if the browser behaviour it models ever
changes), SRT/VTT/JSON parsing through the helper, an empty transcript throwing
instead of importing nothing, cancel yielding null, re-picking the same file,
an unsupported file still being handed to the UI so it can report it, and the
end-to-end consequence — loadVideo with words sets skipTranscription: true
while loadVideo without words leaves it false.

Verified by hand in the running app (npm run dev, Chromium), same injection
against old and new code:

after picking mycaptions.srt result
old code file dropped; upload area still reads "MP4, WebM, MOV, MP3, WAV, …" (Whisper path)
with this change selector reads mycaptions.srt; "Will use mycaptions.srt"

With the fix, picking an SRT and then a 20s WAV opened the editor with the
imported words in the transcript panel — no transcription ran — and the
in-editor "Import" (replace captions) control replaced the transcript with a
different file.

Limitations

  • There is no automated test of the React handlers themselves; this repo has no
    DOM/component test setup and the tests are standalone tsx scripts. The
    regression test exercises the shared helper and a file-input double whose
    behaviour was measured in Chromium 130; the component wiring was confirmed by
    hand in the running app, as described above.
  • The in-editor replacement flow was verified manually, not automatically.
  • Only SRT was driven through the UI end to end; VTT and JSON go through the same
    handler and are covered by the parser and helper tests.
  • npm run test:ffmpeg report: the native render tests skip unless
    npm run fetch:ffmpeg has run, and they were skipped here.

Both "import your own transcript" inputs captured `e.target.files` and then
cleared `e.target.value` before reading it. `input.files` is a live
[SameObject] FileList, so clearing the input emptied the very list the handler
was still holding: `files[0]` came back undefined, the handler treated the pick
as a cancel, `pendingTranscript` was never set, and `loadVideo` ran without
words — so Whisper transcribed a video the user had already captioned. That is
what wassgha#105 reports, and clearing the input is only meant to allow re-picking the
same file.

Read the chosen file before resetting the input, in one helper both inputs now
share. The in-editor "replace captions" handler takes the File rather than a
FileList. Verified in Chromium 130 that clearing `value` does empty an
already-captured FileList, and regression-tested against a file input that
reproduces that behaviour.

Also wires tests/parse-transcript-test.ts into CI: it existed but no script or
workflow step ran it.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@vercel

vercel Bot commented Oct 10, 2026

Copy link
Copy Markdown

@chiragjangiir is attempting to deploy a commit to the wassgha's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Myoh01

Myoh01 commented Oct 29, 2026

Copy link
Copy Markdown

Sorry, something wrong must've happened, I did not review this, so ignore that.

This branch has not been deployed

No deployments
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.

“Import your own transcript — skip Whisper and edit with an SRT, VTT, or JSON caption file” doesn‘t work

2 participants