Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(uploads): anchor upload transcript timestamps to the meeting path's epoch-ms base

Gabriel Steindf826f064297
diff --git a/src/services/uploadNotes.ts b/src/services/uploadNotes.ts
index cfa55c576..ac68bd4ff 100644
--- a/src/services/uploadNotes.ts
+++ b/src/services/uploadNotes.ts
@@ -20,17 +20,25 @@ export interface UploadSegment {
// Serializes provider timing segments into the note.transcript JSON the
// meeting path already stores, unlocking the Transcript tab and the
-// SRT/TXT/JSON/MD export for upload notes. Timestamps stay in relative
-// seconds — normalizeSegmentTimestamps only rebases epoch-ms values.
+// SRT/TXT/JSON/MD export for upload notes. Timestamps are stored on the same
+// epoch-ms base the meeting path writes (anchorMs + offset), NOT in relative
+// seconds: the record button on any note seeds a meeting recording from
+// note.transcript and appends Date.now()-stamped live segments, and a
+// mixed-base transcript defeats the export rebase (normalizeSegmentTimestamps
+// keys off min timestamp > 1e9), rendering garbage cue times. The rebase
+// subtracts the minimum on export, so pure-upload output is unchanged.
// Undefined when there is nothing usable, so plain-text uploads stay exactly
// as they were.
-export function buildUploadTranscript(segments?: UploadSegment[] | null): string | undefined {
+export function buildUploadTranscript(
+ segments?: UploadSegment[] | null,
+ anchorMs: number = Date.now()
+): string | undefined {
if (!segments?.length) return undefined;
const stored = segments
.filter((seg) => seg.text?.trim() && Number.isFinite(seg.start))
.map((seg) => ({
text: seg.text.trim(),
- timestamp: seg.start,
+ timestamp: anchorMs + seg.start * 1000,
...(seg.speaker ? { speakerName: seg.speaker } : {}),
}));
return stored.length ? JSON.stringify(stored) : undefined;
@@ -48,9 +56,10 @@ export function buildUploadTranscript(segments?: UploadSegment[] | null): string
export function buildUploadNoteMetadata(
diarization: DiarizationSettings,
durationSeconds?: number | null,
- segments?: UploadSegment[] | null
+ segments?: UploadSegment[] | null,
+ anchorMs?: number
) {
- const transcript = buildUploadTranscript(segments);
+ const transcript = buildUploadTranscript(segments, anchorMs);
const noteUpdates: Record<string, unknown> | null =
diarization.enabled || transcript
? {
diff --git a/test/services/uploadNotes.test.js b/test/services/uploadNotes.test.js
index c6b0435a8..39f1faeef 100644
--- a/test/services/uploadNotes.test.js
+++ b/test/services/uploadNotes.test.js
@@ -78,19 +78,65 @@ test("unusable durations degrade to null", async () => {
test("provider segments serialize into the meeting-path transcript shape", async () => {
const { buildUploadTranscript } = await load();
- const transcript = buildUploadTranscript([
- { text: " Hello world. ", start: 0, end: 4.2 },
- { text: "Named part.", start: 4.2, end: 7.5, speaker: "Speaker 1" },
- ]);
+ const anchorMs = 1_700_000_000_000;
+ const transcript = buildUploadTranscript(
+ [
+ { text: " Hello world. ", start: 0, end: 4.2 },
+ { text: "Named part.", start: 4.2, end: 7.5, speaker: "Speaker 1" },
+ ],
+ anchorMs
+ );
- // Relative seconds are stored as-is: normalizeSegmentTimestamps only
- // rebases epoch-millisecond values, so export math stays correct.
+ // Timestamps are epoch-anchored ms, the meeting path's base: exports rebase
+ // off the minimum (guarded by min > 1e9), and live segments appended by a
+ // later meeting recording on the same note share the base instead of mixing
+ // relative seconds with Date.now() values.
assert.deepEqual(JSON.parse(transcript), [
- { text: "Hello world.", timestamp: 0 },
- { text: "Named part.", timestamp: 4.2, speakerName: "Speaker 1" },
+ { text: "Hello world.", timestamp: anchorMs },
+ { text: "Named part.", timestamp: anchorMs + 4200, speakerName: "Speaker 1" },
]);
});
+test("the default anchor is the current epoch so later meeting appends share one base", async () => {
+ const { buildUploadTranscript } = await load();
+
+ const before = Date.now();
+ const stored = JSON.parse(buildUploadTranscript([{ text: "Hi.", start: 1.5 }]));
+ const after = Date.now();
+
+ assert.ok(
+ stored[0].timestamp >= before + 1500 && stored[0].timestamp <= after + 1500,
+ `expected ${stored[0].timestamp} to sit 1.5s after an epoch-ms anchor in [${before}, ${after}]`
+ );
+});
+
+// The record button on any editable note seeds a meeting recording from
+// note.transcript and appends Date.now()-stamped live segments. Pin that an
+// upload transcript mixed with those appends exports sane cue times — a
+// relative-seconds base would keep resolveRecordingStartMs at ~0, skip the
+// epoch rebase, and render the appended segments as ~481,000,000-hour cues.
+test("upload transcripts mixed with later live meeting segments export sane SRT times", async () => {
+ const { buildUploadTranscript } = await load();
+ const { formatSrt } = require("../../src/helpers/transcriptFormatter");
+
+ const anchorMs = 1_700_000_000_000;
+ const seeded = JSON.parse(
+ buildUploadTranscript(
+ [
+ { text: "Uploaded intro.", start: 0, end: 3 },
+ { text: "Uploaded detail.", start: 30, end: 33 },
+ ],
+ anchorMs
+ )
+ );
+ const appended = [{ text: "Live follow-up.", source: "mic", timestamp: anchorMs + 60_000 }];
+
+ const output = formatSrt([...seeded, ...appended], {});
+ assert.match(output, /^1\n00:00:00,000 --> 00:00:30,000\nUnknown Speaker: Uploaded intro\./);
+ assert.match(output, /\n2\n00:00:30,000 --> 00:01:00,000\nUnknown Speaker: Uploaded detail\./);
+ assert.match(output, /\n3\n00:01:00,000 --> 00:01:03,000\nYou: Live follow-up\./);
+});
+
test("unusable segments produce no transcript at all", async () => {
const { buildUploadTranscript } = await load();
@@ -109,30 +155,38 @@ test("unusable segments produce no transcript at all", async () => {
test("segments persist the transcript even when diarization is off", async () => {
const { buildUploadNoteMetadata } = await load();
+ const anchorMs = 1_700_000_000_000;
const { noteUpdates } = buildUploadNoteMetadata(
{ enabled: false, localModelsReady: false, numSpeakers: null },
60,
- [{ text: "Hello.", start: 0, end: 2 }]
+ [{ text: "Hello.", start: 0, end: 2 }],
+ anchorMs
);
// The transcript must not drag the diarization columns along: a null
// diarization_enabled still defers to the global speaker setting.
- assert.deepEqual(noteUpdates, { transcript: JSON.stringify([{ text: "Hello.", timestamp: 0 }]) });
+ assert.deepEqual(noteUpdates, {
+ transcript: JSON.stringify([{ text: "Hello.", timestamp: anchorMs }]),
+ });
});
test("segments and diarization metadata share one noteUpdates write", async () => {
const { buildUploadNoteMetadata } = await load();
+ const anchorMs = 1_700_000_000_000;
const { noteUpdates } = buildUploadNoteMetadata(
{ enabled: true, localModelsReady: true, numSpeakers: 2 },
60,
- [{ text: "Hi.", start: 1, speaker: "Speaker 1" }]
+ [{ text: "Hi.", start: 1, speaker: "Speaker 1" }],
+ anchorMs
);
assert.deepEqual(noteUpdates, {
diarization_enabled: 1,
expected_speaker_count: 2,
- transcript: JSON.stringify([{ text: "Hi.", timestamp: 1, speakerName: "Speaker 1" }]),
+ transcript: JSON.stringify([
+ { text: "Hi.", timestamp: anchorMs + 1000, speakerName: "Speaker 1" },
+ ]),
});
});