From dce10e3e3bbfdad84645926064f5b431fd5268cb Mon Sep 17 00:00:00 2001 From: Vance Ingalls Date: Wed, 25 Mar 2026 17:30:55 -0700 Subject: [PATCH] fix(cli): format warm-grain captions and fix TS nullability errors - Format warm-grain/compositions/captions.html - Add optional chaining on token.offsets (may be undefined) - Use intermediate variable for lastWord to satisfy TS strict checks Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/cli/src/commands/init.ts | 11 ++++++----- .../templates/warm-grain/compositions/captions.html | 7 ++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts index c0b945a1c7..90344add7e 100644 --- a/packages/cli/src/commands/init.ts +++ b/packages/cli/src/commands/init.ts @@ -244,16 +244,17 @@ function patchTranscript(dir: string, transcriptPath: string): void { // Merge punctuation with the previous word const isPunctuation = /^[.,!?;:'")\]}>…–—-]+$/.test(text); - if (isPunctuation && words.length > 0) { - words[words.length - 1].text += text; - words[words.length - 1].end = Math.round((token.offsets.to / 1000) * 1000) / 1000; + const lastWord = words[words.length - 1]; + if (isPunctuation && lastWord) { + lastWord.text += text; + lastWord.end = Math.round(((token.offsets?.to ?? 0) / 1000) * 1000) / 1000; continue; } words.push({ text, - start: Math.round((token.offsets.from / 1000) * 1000) / 1000, - end: Math.round((token.offsets.to / 1000) * 1000) / 1000, + start: Math.round(((token.offsets?.from ?? 0) / 1000) * 1000) / 1000, + end: Math.round(((token.offsets?.to ?? 0) / 1000) * 1000) / 1000, }); } } diff --git a/packages/cli/src/templates/warm-grain/compositions/captions.html b/packages/cli/src/templates/warm-grain/compositions/captions.html index a9d060f340..566c49b328 100644 --- a/packages/cli/src/templates/warm-grain/compositions/captions.html +++ b/packages/cli/src/templates/warm-grain/compositions/captions.html @@ -1,5 +1,10 @@