'use client';
import React from 'react';
import { useGraphStore } from '@/store/graph';
import { entityColor } from '@/lib/constants';
import {
GitBranch, ChevronRight, FileText, Zap, Copy, Check, Info
} from 'lucide-react';
export interface Hop {
from: string;
rel: string;
to: string;
doc?: string;
chunk_text?: string;
}
interface AlternativePath {
hops: Hop[];
explanation: string;
}
interface PathViewProps {
hops: Hop[];
alternativePaths: AlternativePath[];
activeTab: number;
onTabChange: (index: number) => void;
explanation: string;
entityA: string;
entityB: string;
copied: boolean;
onCopy: () => void;
onExplainPath?: (index: number) => void;
explainingLoading?: boolean;
}
function NodeBadge({ name, isStart, isEnd }: { name: string; isStart?: boolean; isEnd?: boolean }) {
const nodes = useGraphStore((s) => s.data.nodes);
const foundNode = nodes.find(n => n.name === name || n.id === name);
const type = foundNode ? foundNode.type : 'ENTITY';
const color = entityColor(type);
const bg = `${color}14`; // ~8% opacity
const border = `${color}4D`; // ~30% opacity
return (
{/* ── PATH TITLE BANNER ── */}
Reasoning Path Found
{currentPath.length} hop{currentPath.length !== 1 ? 's' : ''}
{alternativePaths.length > 0 && (
+{alternativePaths.length} alternative path{alternativePaths.length > 1 ? 's' : ''}
)}
{/* ── STICKY PATH CONTROLLER ── */}
{/* ── PATH TABS (IF MULTIPLE PATHS EXIST) ── */}
{pathsList.length > 1 && (
{pathsList.map((_, i) => {
const isActive = activeTab === i;
return (
);
})}
)}
{/* ── ACTIVE PATH SUMMARY BREADCRUMB ── */}
Active Graph Pathway: {activeTab === 0 ? 'Primary Route' : `Alternative Route ${activeTab}`}
Highlighted on Graph
{(() => {
const nodesList: string[] = [];
if (currentPath.length > 0) {
nodesList.push(currentPath[0].from);
for (const h of currentPath) {
nodesList.push(h.to);
}
}
return nodesList.map((n, idx) => (
{idx > 0 && }
{n}
));
})()}
{/* ── VISUAL CHAIN DIAGRAM ── */}
Interactive Visual Chain Flow
{currentPath.map((hop, i) => (
{i === currentPath.length - 1 && (
)}
))}
{/* ── STEP-BY-STEP DESCRIPTIVE ANNOTATION ── */}
Path Step Details
{currentPath.map((hop, i) => (
))}
{/* ── AI CONCLUSION CARD ── */}
{currentExplanation ? (
AI Reasoning Explanation ({activeTab === 0 ? 'Primary Path' : `Alt Path ${activeTab}`})
{currentExplanation}
Pathway loaded & visualized on graph
Active
) : (
Generate Path-Specific Explanation
Generate a custom LLM summary explaining the connection path between {entityA} and {entityB} using this path's specific document chunks.
)}
);
}