Skip to content

Commit 80807bf

Browse files
committed
Update SignalCard.tsx
1 parent 06770be commit 80807bf

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

apps/code/src/renderer/features/inbox/components/detail/SignalCard.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ interface SessionProblemExtra {
108108
distinct_id?: string;
109109
session_start_time?: string;
110110
session_end_time?: string;
111+
session_duration?: number;
112+
session_active_seconds?: number;
111113
exported_asset_id?: number;
112114
}
113115

@@ -515,6 +517,16 @@ const PROBLEM_TYPE_LABELS: Record<
515517
failure: { label: "Failure", color: "red" },
516518
};
517519

520+
function formatSessionDuration(seconds: number): string {
521+
if (seconds < 60) return `${Math.round(seconds)}s`;
522+
const mins = Math.floor(seconds / 60);
523+
const secs = Math.round(seconds % 60);
524+
if (mins < 60) return secs > 0 ? `${mins}m ${secs}s` : `${mins}m`;
525+
const hrs = Math.floor(mins / 60);
526+
const remainMins = mins % 60;
527+
return remainMins > 0 ? `${hrs}h ${remainMins}m` : `${hrs}h`;
528+
}
529+
518530
function SessionProblemSignalCard({
519531
signal,
520532
extra,
@@ -538,6 +550,11 @@ function SessionProblemSignalCard({
538550
return (
539551
<Box className="min-w-0 overflow-hidden rounded-lg border border-gray-6 bg-gray-1 p-3">
540552
<SignalCardHeader signal={signal} verified={verified} />
553+
{extra.segment_title && (
554+
<Text size="1" weight="medium" mt="1" className="text-gray-11" as="p">
555+
{extra.segment_title}
556+
</Text>
557+
)}
541558
<CollapsibleBody body={signal.content} />
542559

543560
{extra.session_id && (
@@ -578,6 +595,25 @@ function SessionProblemSignalCard({
578595
</span>
579596
</>
580597
)}
598+
{extra.session_duration != null && (
599+
<>
600+
<span>·</span>
601+
<span>{formatSessionDuration(extra.session_duration)} session</span>
602+
</>
603+
)}
604+
{extra.session_active_seconds != null &&
605+
extra.session_duration != null &&
606+
extra.session_duration > 0 && (
607+
<>
608+
<span>·</span>
609+
<span>
610+
{Math.round(
611+
(extra.session_active_seconds / extra.session_duration) * 100,
612+
)}
613+
% active
614+
</span>
615+
</>
616+
)}
581617
</Flex>
582618
<CodePathsCollapsible paths={codePaths ?? []} />
583619
<DataQueriedCollapsible text={dataQueried ?? ""} />

0 commit comments

Comments
 (0)