Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(web): preserve hours in transcript timestamps
Akshar Patelf6ea97b48f11
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 926bdcd44..f4d179dc9 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -144,6 +144,7 @@ jobs:__tests__/unit/speed-controller.test.ts__tests__/unit/summary-editor.test.ts__tests__/unit/sso-login-pages.test.ts+ __tests__/unit/transcript-hours.test.ts__tests__/unit/transcript-numbers.test.ts__tests__/unit/video-analytics-access.test.tsdiff --git a/apps/web/__tests__/unit/transcript-hours.test.ts b/apps/web/__tests__/unit/transcript-hours.test.tsnew file mode 100644index 000000000..7938f6672--- /dev/null+++ b/apps/web/__tests__/unit/transcript-hours.test.ts@@ -0,0 +1,23 @@+import { describe, expect, it } from "vitest";+import { parseTranscriptVTT } from "@/app/s/[videoId]/_components/utils/parse-transcript-vtt";+import { formatToWebVTT } from "@/lib/transcribe-utils";++describe("transcript timestamp labels", () => {+ it.each([+ [12_250, "00:12", 12.25, 12.75],+ [3_599_250, "59:59", 3599.25, 3599.75],+ [3_600_000, "01:00:00", 3600, 3600.5],+ [3_612_250, "01:00:12", 3612.25, 3612.75],+ [7_212_250, "02:00:12", 7212.25, 7212.75],+ ] as const)(+ "keeps the complete position at %i ms",+ (start, timestamp, startTime, endTime) => {+ const vtt = formatToWebVTT({+ words: [{ text: "Reference.", start, end: start + 500 }],+ });+ expect(parseTranscriptVTT(vtt)).toEqual([+ { id: 1, text: "Reference.", timestamp, startTime, endTime },+ ]);+ },+ );+});diff --git a/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx b/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsxindex de9a8b253..2915c4dd2 100644--- a/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx+++ b/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx@@ -454,7 +454,7 @@ export const Transcript: React.FC<TranscriptProps> = ({ data, onSeek }) => {onClick={() => handleTranscriptClick(entry)}type="button">- <span className="w-9 shrink-0 font-mono text-[10px] leading-[22px] tabular-nums text-gray-8">+ <span className="min-w-9 shrink-0 font-mono text-[10px] leading-[22px] tabular-nums text-gray-8">{entry.timestamp}</span><span className="min-w-0 flex-1 text-[13px] leading-[22px] text-gray-11">@@ -852,7 +852,7 @@ export const Transcript: React.FC<TranscriptProps> = ({ data, onSeek }) => {onClick={() => handleTranscriptClick(entry)}type="button">- <span className="w-9 shrink-0 font-mono text-[10px] leading-[22px] tabular-nums text-gray-8">+ <span className="min-w-9 shrink-0 font-mono text-[10px] leading-[22px] tabular-nums text-gray-8">{entry.timestamp}</span><span className="min-w-0 flex-1 text-[13px] leading-[22px] text-gray-11">diff --git a/apps/web/app/s/[videoId]/_components/utils/parse-transcript-vtt.ts b/apps/web/app/s/[videoId]/_components/utils/parse-transcript-vtt.tsindex d62fccfb4..c7cb07a77 100644--- a/apps/web/app/s/[videoId]/_components/utils/parse-transcript-vtt.ts+++ b/apps/web/app/s/[videoId]/_components/utils/parse-transcript-vtt.ts@@ -50,7 +50,10 @@ export const parseTranscriptVTT = (vttContent: string): TranscriptEntry[] => {const fraction = fractionPart ? Number(`0.${fractionPart}`) : 0;return {- mm_ss: `${minutesStr}:${secondsPart}`,+ mm_ss:+ Number(hoursStr) > 0+ ? `${hoursStr}:${minutesStr}:${secondsPart}`+ : `${minutesStr}:${secondsPart}`,totalSeconds: totalSeconds + (Number.isFinite(fraction) ? fraction : 0),};};