Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ beforeEach(() => {
});

describe("SegmentHeader", () => {
it("keeps the speaker label and timestamp visible", () => {
it("keeps the speaker label visible without exposing timestamps", () => {
render(
<SegmentHeader
transcriptId="transcript-1"
Expand Down Expand Up @@ -68,6 +68,6 @@ describe("SegmentHeader", () => {
);

expect(screen.getByRole("button", { name: "Speaker 3" })).toBeTruthy();
expect(screen.getByText("00:12 - 00:18")).toBeTruthy();
expect(screen.queryByText("00:12 - 00:18")).toBeNull();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useMemo } from "react";
import { cn } from "@hypr/utils";

import { SpeakerAssignPopover } from "./speaker-assign";
import { getTimestampRange, useSegmentColorVars } from "./utils";
import { useSegmentColorVars } from "./utils";

import * as main from "~/store/tinybase/store/main";
import type { Segment } from "~/stt/live-segment";
Expand All @@ -21,7 +21,6 @@ export function SegmentHeader({
}) {
const colorVars = useSegmentColorVars(segment.key);
const label = useSpeakerLabel(segment.key, speakerLabelManager);
const timestamp = getTimestampRange(segment);
const headerClassName = cn([
"bg-card sticky top-0 z-20",
"-mx-3 px-3 py-1",
Expand All @@ -39,9 +38,6 @@ export function SegmentHeader({
color="var(--segment-color)"
label={label}
/>
<span className="text-muted-foreground ml-auto shrink-0 tabular-nums">
{timestamp}
</span>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chroma from "chroma-js";
import { type CSSProperties, useMemo } from "react";

import type { Segment, SegmentKey, SegmentWord } from "~/stt/live-segment";
import type { SegmentKey, SegmentWord } from "~/stt/live-segment";

export type HighlightSegment = { text: string; isMatch: boolean };

Expand Down Expand Up @@ -82,29 +82,6 @@ export function getActiveLineIndex(
return null;
}

export function formatTimestamp(ms: number): string {
const totalSeconds = Math.floor(ms / 1000);
const hours = Math.floor(totalSeconds / 3600);
const minutes = Math.floor((totalSeconds % 3600) / 60);
const seconds = totalSeconds % 60;

if (hours > 0) {
return `${hours}:${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
}

return `${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
}

export function getTimestampRange(segment: Segment): string {
if (segment.words.length === 0) {
return "00:00 - 00:00";
}

const firstWord = segment.words[0]!;
const lastWord = segment.words[segment.words.length - 1]!;
return `${formatTimestamp(firstWord.start_ms)} - ${formatTimestamp(lastWord.end_ms)}`;
}

export function getSegmentColor(
key: SegmentKey,
mode: "light" | "dark" = "light",
Expand Down
Loading