Skip to content

Commit bc9686a

Browse files
committed
fix: handle object format for narrative highlights in UnifiedInsightSection
- Updated UnifiedInsightSection to accept highlights as either strings or objects with {label, value, interpretation} - Fixed type definitions in page.tsx to match the actual LLM output format - Added renderHighlight helper function to format object highlights nicely
1 parent f987526 commit bc9686a

2 files changed

Lines changed: 26 additions & 6 deletions

File tree

apps/web/src/app/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ type AuthStats = {
106106
narrative?: {
107107
headline?: string;
108108
paragraphs?: string[];
109-
highlights?: string[];
109+
highlights?: Array<{ label: string; value: string; interpretation?: string }>;
110110
} | null;
111111
llmModel?: string | null;
112112
llmKeySource?: string | null;
@@ -518,7 +518,7 @@ export default async function Home({
518518
narrative_json: {
519519
headline?: string;
520520
paragraphs?: string[];
521-
highlights?: string[];
521+
highlights?: Array<{ label: string; value: string; interpretation?: string }>;
522522
} | null;
523523
llm_model: string | null;
524524
llm_key_source: string | null;
@@ -611,7 +611,7 @@ export default async function Home({
611611
narrative_json: {
612612
headline?: string;
613613
paragraphs?: string[];
614-
highlights?: string[];
614+
highlights?: Array<{ label: string; value: string; interpretation?: string }>;
615615
} | null;
616616
llm_model: string | null;
617617
llm_key_source: string | null;

apps/web/src/components/vcp/unified/UnifiedInsightSection.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
import { cn } from "@/lib/utils";
44

5+
// Highlight can be a simple string or a rich object
6+
type HighlightItem =
7+
| string
8+
| { label: string; value: string | number; interpretation?: string };
9+
510
interface UnifiedInsightSectionProps {
611
/** Main headline/insight */
712
headline: string;
813
/** Additional narrative paragraphs (LLM-generated) */
914
paragraphs?: string[];
10-
/** Highlight bullet points (LLM-generated) */
11-
highlights?: string[];
15+
/** Highlight bullet points (LLM-generated) - can be strings or objects */
16+
highlights?: HighlightItem[];
1217
/** Whether the narrative is LLM-generated */
1318
isLLMGenerated?: boolean;
1419
/** LLM model used */
@@ -17,6 +22,21 @@ interface UnifiedInsightSectionProps {
1722
className?: string;
1823
}
1924

25+
/**
26+
* Render a highlight item - handles both string and object formats
27+
*/
28+
function renderHighlight(item: HighlightItem): string {
29+
if (typeof item === "string") {
30+
return item;
31+
}
32+
// Object format: { label, value, interpretation }
33+
const parts = [`${item.label}: ${item.value}`];
34+
if (item.interpretation) {
35+
parts.push(`— ${item.interpretation}`);
36+
}
37+
return parts.join(" ");
38+
}
39+
2040
/**
2141
* UnifiedInsightSection - Displays the main insight and LLM narrative
2242
*
@@ -60,7 +80,7 @@ export function UnifiedInsightSection({
6080
{highlights.map((highlight, idx) => (
6181
<li key={idx} className="flex items-start gap-2 text-sm text-slate-600">
6282
<span className="mt-1 text-violet-400"></span>
63-
<span>{highlight}</span>
83+
<span>{renderHighlight(highlight)}</span>
6484
</li>
6585
))}
6686
</ul>

0 commit comments

Comments
 (0)