Skip to content
Closed
Prev Previous commit
Next Next commit
small fixes
  • Loading branch information
raydeStar committed Dec 10, 2025
commit fba96562bfa8fcf4c9b79cabc83f53dda048659f
17 changes: 2 additions & 15 deletions src/components/TriangulatedNews/ClaimClusterSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,15 @@ const ClaimCard = ({
))}
</div>

{/* Source count and agreement level */}
<div className="flex items-center gap-2 text-[10px] text-black/50 dark:text-white/50">
{/* Source count */}
<div className="text-[10px] text-black/50 dark:text-white/50">
<button
onClick={() => setDetailsExpanded(!detailsExpanded)}
className="hover:text-black dark:hover:text-white transition underline"
>
{cluster.supportingClaims.length} source
{cluster.supportingClaims.length !== 1 ? 's' : ''}
</button>
<span
className={cn(
'px-1.5 py-0.5 rounded font-medium uppercase tracking-wide',
cluster.agreementLevel === 'high' &&
'bg-green-500/10 text-green-600 dark:text-green-400',
cluster.agreementLevel === 'medium' &&
'bg-amber-500/10 text-amber-600 dark:text-amber-400',
cluster.agreementLevel === 'low' &&
'bg-gray-500/10 text-gray-600 dark:text-gray-400',
)}
>
{cluster.agreementLevel}
</span>
</div>
</div>

Expand Down
26 changes: 11 additions & 15 deletions src/lib/search/newsTriangulate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,9 @@ const generateNeutralSummary = async (

let spectrumNote = '';
if (dominantLane) {
spectrumNote = `\n*⚠ Limited diversity: ${Math.round((dominantLane[1] / totalSources) * 100)}% of sources are ${dominantLane[0].toLowerCase()}-leaning*`;
spectrumNote = `*⚠ Limited diversity: ${Math.round((dominantLane[1] / totalSources) * 100)}% of sources are ${dominantLane[0].toLowerCase()}-leaning*`;
} else if (!hasFullSpectrum) {
spectrumNote = `\n*⚠ Limited spectrum: No ${laneCounts.LEFT === 0 ? 'left' : 'right'}-leaning sources available*`;
spectrumNote = `*⚠ Limited spectrum: No ${laneCounts.LEFT === 0 ? 'left' : 'right'}-leaning sources available*`;
}

// Detect polarized conflicts (conflicts that include both LEFT and RIGHT lanes)
Expand Down Expand Up @@ -549,7 +549,8 @@ Write a news briefing in this structure:

# [Compelling, specific headline]

*${laneBreakdown.replace(/:/g, ':').replace(/,/g, ' |')} sources | Credibility: ${credibilityLabel}*${spectrumNote}
*${laneBreakdown.replace(/:/g, ':').replace(/,/g, ' |')} sources | Credibility: ${credibilityLabel}*
${spectrumNote ? `\n${spectrumNote}` : ''}

[OPENING: 2-3 sentence lead covering the core story. Hook the reader with the most newsworthy element.]

Expand Down Expand Up @@ -707,8 +708,8 @@ export class NewsTriangulationAgent implements MetaSearchAgentType {
const tagged = withLaneAndCredibility(sources);
const balanced = selectBalancedNewsSources(tagged);

// Minimum sources needed for meaningful triangulation (ideal: 5-10)
const MIN_SOURCES_FOR_TRIANGULATION = 5;
// Absolute minimum: need at least 3 sources for any meaningful comparison
const MIN_SOURCES_ABSOLUTE = 3;

// Check for political diversity - need at least 1 LEFT and 1 RIGHT for true triangulation
const hasLeft = balanced.some(s => s.lane === 'LEFT');
Expand All @@ -727,16 +728,11 @@ export class NewsTriangulationAgent implements MetaSearchAgentType {

console.log(`[Triangulate] Query: "${searchQuery.substring(0, 50)}..." | Sources: ${balanced.length} | Lanes: L=${laneCounts.LEFT} R=${laneCounts.RIGHT} C=${laneCounts.CENTER} U=${laneCounts.UNKNOWN} | FullSpectrum: ${hasFullSpectrum}`);

// Handle low-source case: still show sources but skip claim extraction
if (balanced.length < MIN_SOURCES_FOR_TRIANGULATION) {
let summary: string;
if (balanced.length === 0) {
summary = 'No news sources found for this query. Try a more specific or recent news topic.';
} else if (balanced.length < 3) {
summary = `Only ${balanced.length} source${balanced.length === 1 ? '' : 's'} found. At least ${MIN_SOURCES_FOR_TRIANGULATION} diverse sources are needed for proper triangulation. Try a broader news topic.`;
} else {
summary = `Found ${balanced.length} sources, but ${MIN_SOURCES_FOR_TRIANGULATION}+ are recommended for reliable triangulation. Results may be limited.`;
}
// Handle zero or near-zero sources: can't triangulate at all
if (balanced.length < MIN_SOURCES_ABSOLUTE) {
const summary = balanced.length === 0
? 'No news sources found for this query. Try a more specific or recent news topic.'
: `Only ${balanced.length} source${balanced.length === 1 ? '' : 's'} found. At least ${MIN_SOURCES_ABSOLUTE} sources are needed for triangulation. Try a broader news topic.`;

const fallbackResult: TriangulatedNewsResult = {
summary,
Expand Down