From 3dab42c324f93985f03c82ef5327844f553aa357 Mon Sep 17 00:00:00 2001 From: felixpy <2902215+felixpy@users.noreply.github.com> Date: Mon, 30 Nov 2026 00:21:27 +0000 Subject: [PATCH 1/3] fix(stories): keep a WebVTT cue whose identifier starts with WEBVTT captionBlocks rejected every block whose first line started with WEBVTT before it checked the next line. A cue identifier may be that word when the next line is a timestamp. The file header and NOTE blocks stay out. Co-authored-by: Felix Yang --- electron/src/shared/utils/importStory.js | 7 ++++-- electron/src/shared/utils/importStory.test.js | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/electron/src/shared/utils/importStory.js b/electron/src/shared/utils/importStory.js index 13b4899b92..def704bb75 100644 --- a/electron/src/shared/utils/importStory.js +++ b/electron/src/shared/utils/importStory.js @@ -124,11 +124,14 @@ function captionBlocks(text, webvtt) { .filter(Boolean); if (!lines.length) return false; const first = lines[0]; - if (/^WEBVTT(?:[ \t]|$)/.test(first)) return false; + const nextIsTiming = lines.length > 1 && isTimingLine(lines[1]); + // The file header starts with WEBVTT and has no timing line next. A cue + // identifier may start with the same word when the next line is the timing line. + if (/^WEBVTT(?:[ \t]|$)/.test(first) && !nextIsTiming) return false; if (/^NOTE(?:[ \t]|$)/.test(first)) return false; // A cue starts with a timing line or an identifier immediately followed // by one. This also permits STYLE and REGION as cue identifiers. - return isTimingLine(first) || (lines.length > 1 && isTimingLine(lines[1])); + return isTimingLine(first) || nextIsTiming; }); } diff --git a/electron/src/shared/utils/importStory.test.js b/electron/src/shared/utils/importStory.test.js index eaf2a8f368..cb490e5414 100644 --- a/electron/src/shared/utils/importStory.test.js +++ b/electron/src/shared/utils/importStory.test.js @@ -141,6 +141,24 @@ describe('parseSrt', () => { expect(parseSrt(vtt)).toBe('Hello world.\nStill here.'); } }); + it('keeps a cue whose identifier starts with WEBVTT', () => { + for (const identifier of ['WEBVTT', 'WEBVTT intro', 'WEBVTT\tname']) { + const vtt = + `WEBVTT\n\n${identifier}\n00:00:01.000 --> 00:00:02.000\nFirst cue\n\n` + + 'second\n00:00:02.000 --> 00:00:03.000\nSecond cue\n'; + expect(parseSrt(vtt)).toBe('First cue\nSecond cue'); + } + expect(parseSrt('WEBVTT\n00:00:01.000 --> 00:00:02.000\nHello\n')).toBe('Hello'); + }); + it('still drops a WebVTT header that carries metadata and no cue timing', () => { + for (const header of ['WEBVTT', 'WEBVTT Kind: captions', 'WEBVTT\tKind: captions']) { + const vtt = `${header}\nLanguage: en\n\n00:00:01.000 --> 00:00:02.000\nHello\n`; + expect(parseSrt(vtt)).toBe('Hello'); + } + expect(parseSrt('WEBVTT Kind: captions\n\n00:00:01.000 --> 00:00:02.000\nHello\n')).toBe( + 'Hello', + ); + }); it('keeps NOTE when it is the spoken dialogue', () => { expect( parseSrt('WEBVTT\n\n00:01.000 --> 00:02.000\nNOTE this is spoken\nSTYLE\nREGION\n'), @@ -184,4 +202,11 @@ describe('importToText', () => { expect(importToText('captions.vtt', vtt)).toBe('hey everyone'); expect(importToText('captions.VTT', vtt)).toBe('hey everyone'); }); + it('keeps a WEBVTT cue identifier for .vtt and .srt filenames', () => { + const vtt = + 'WEBVTT\n\nWEBVTT intro\n00:00:01.000 --> 00:00:02.000\nFirst cue\n\n' + + 'second\n00:00:02.000 --> 00:00:03.000\nSecond cue\n'; + expect(importToText('captions.vtt', vtt)).toBe('First cue\nSecond cue'); + expect(importToText('captions.srt', vtt)).toBe('First cue\nSecond cue'); + }); }); From c73c35bd335913759964867b9b95d405a0707f44 Mon Sep 17 00:00:00 2001 From: felixpy <2902215+felixpy@users.noreply.github.com> Date: Mon, 30 Nov 2026 00:26:13 +0000 Subject: [PATCH 2/3] docs(changelog): add the fragment for the WebVTT cue identifier fix Co-authored-by: Felix Yang --- changelog.d/4554.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/4554.fixed.md diff --git a/changelog.d/4554.fixed.md b/changelog.d/4554.fixed.md new file mode 100644 index 0000000000..a97778591f --- /dev/null +++ b/changelog.d/4554.fixed.md @@ -0,0 +1 @@ +Stories import keeps a WebVTT cue whose identifier starts with WEBVTT (#4554) From 09c5dda48eadfcaa75c787c18e8b829fb03664f2 Mon Sep 17 00:00:00 2001 From: felixpy <2902215+felixpy@users.noreply.github.com> Date: Mon, 30 Nov 2026 00:27:57 +0000 Subject: [PATCH 3/3] docs(changelog): use the official WebVTT cue identifier line Co-authored-by: Felix Yang --- changelog.d/4554.fixed.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/4554.fixed.md b/changelog.d/4554.fixed.md index a97778591f..f113f2905a 100644 --- a/changelog.d/4554.fixed.md +++ b/changelog.d/4554.fixed.md @@ -1 +1 @@ -Stories import keeps a WebVTT cue whose identifier starts with WEBVTT (#4554) +Stories import no longer drops a caption cue whose identifier starts with WEBVTT (#4554) — thanks @felixpy!