Álvaro Valenzuela Valdes commited on
Commit ·
aaf6916
1
Parent(s): d1d31de
feat: Detailed agent thought process logs in analysis history
Browse files
frontend/components/AnalysisHistory.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
import type { AnalysisHistoryItem } from "../lib/types";
|
| 4 |
|
| 5 |
type Props = {
|
|
@@ -7,6 +6,14 @@ type Props = {
|
|
| 7 |
};
|
| 8 |
|
| 9 |
export default function AnalysisHistory({ history }: Props) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
if (!history.length) {
|
| 11 |
return (
|
| 12 |
<div className="flex flex-col items-center justify-center min-h-[40vh] glass-card rounded-3xl border border-white/5 p-12 text-center animate-in fade-in duration-700">
|
|
@@ -20,60 +27,85 @@ export default function AnalysisHistory({ history }: Props) {
|
|
| 20 |
return (
|
| 21 |
<div className="space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700">
|
| 22 |
<div className="space-y-6">
|
| 23 |
-
{history.map((item) =>
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
</div>
|
| 31 |
-
|
| 32 |
-
<
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
<
|
| 38 |
-
<
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
<
|
| 44 |
-
{item.analysis.decision}
|
| 45 |
-
</p>
|
| 46 |
</div>
|
| 47 |
</div>
|
| 48 |
-
</div>
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
</div>
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
</div>
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
<button className="text-xs font-bold text-purple-400 hover:text-white transition-colors flex items-center gap-2">
|
| 71 |
-
<span>View Full Analysis Details</span>
|
| 72 |
-
<span>→</span>
|
| 73 |
-
</button>
|
| 74 |
-
</div>
|
| 75 |
-
</div>
|
| 76 |
-
))}
|
| 77 |
</div>
|
| 78 |
</div>
|
| 79 |
);
|
|
|
|
| 1 |
+
import { useState } from "react";
|
|
|
|
| 2 |
import type { AnalysisHistoryItem } from "../lib/types";
|
| 3 |
|
| 4 |
type Props = {
|
|
|
|
| 6 |
};
|
| 7 |
|
| 8 |
export default function AnalysisHistory({ history }: Props) {
|
| 9 |
+
const [expandedItems, setExpandedItems] = useState<string[]>([]);
|
| 10 |
+
|
| 11 |
+
const toggleExpand = (id: string) => {
|
| 12 |
+
setExpandedItems(prev =>
|
| 13 |
+
prev.includes(id) ? prev.filter(i => i !== id) : [...prev, id]
|
| 14 |
+
);
|
| 15 |
+
};
|
| 16 |
+
|
| 17 |
if (!history.length) {
|
| 18 |
return (
|
| 19 |
<div className="flex flex-col items-center justify-center min-h-[40vh] glass-card rounded-3xl border border-white/5 p-12 text-center animate-in fade-in duration-700">
|
|
|
|
| 27 |
return (
|
| 28 |
<div className="space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700">
|
| 29 |
<div className="space-y-6">
|
| 30 |
+
{history.map((item) => {
|
| 31 |
+
const itemId = `${item.tender_code}-${item.analyzed_at}`;
|
| 32 |
+
const isExpanded = expandedItems.includes(itemId);
|
| 33 |
+
|
| 34 |
+
return (
|
| 35 |
+
<div key={itemId} className="glass-card rounded-3xl p-8 border border-white/5 hover:border-purple-500/30 transition-all duration-300">
|
| 36 |
+
<div className="flex flex-col gap-6 lg:flex-row lg:items-center lg:justify-between">
|
| 37 |
+
<div className="space-y-1">
|
| 38 |
+
<div className="flex items-center gap-3 mb-2">
|
| 39 |
+
<span className="text-[10px] font-black uppercase tracking-widest text-purple-400 bg-purple-500/10 px-2 py-0.5 rounded border border-purple-500/20">Audit Record</span>
|
| 40 |
+
<span className="text-xs text-slate-500 font-mono">{item.tender_code}</span>
|
| 41 |
+
</div>
|
| 42 |
+
<h3 className="text-2xl font-bold text-white tracking-tight">{item.tender_name}</h3>
|
| 43 |
+
<p className="text-xs text-slate-500">{new Date(item.analyzed_at).toLocaleString()}</p>
|
| 44 |
</div>
|
| 45 |
+
|
| 46 |
+
<div className="flex items-center gap-8 bg-white/5 rounded-2xl p-6 border border-white/5">
|
| 47 |
+
<div className="text-center">
|
| 48 |
+
<p className="text-[9px] uppercase tracking-widest text-slate-500 font-bold mb-1">Fit Score</p>
|
| 49 |
+
<p className="text-3xl font-black text-white">{item.analysis.fit_score}%</p>
|
| 50 |
+
</div>
|
| 51 |
+
<div className="h-10 w-px bg-white/10" />
|
| 52 |
+
<div className="text-center">
|
| 53 |
+
<p className="text-[9px] uppercase tracking-widest text-slate-500 font-bold mb-1">Decision</p>
|
| 54 |
+
<p className={`text-xs font-black uppercase tracking-widest px-3 py-1 rounded-full ${item.analysis.decision === 'Recommended' ? 'bg-green-500/20 text-green-400' : 'bg-amber-500/20 text-amber-400'}`}>
|
| 55 |
+
{item.analysis.decision}
|
| 56 |
+
</p>
|
| 57 |
+
</div>
|
|
|
|
|
|
|
| 58 |
</div>
|
| 59 |
</div>
|
|
|
|
| 60 |
|
| 61 |
+
<div className="mt-8 grid gap-4 grid-cols-2 md:grid-cols-4">
|
| 62 |
+
<div className="p-4 rounded-2xl bg-black/20 border border-white/5">
|
| 63 |
+
<p className="text-[9px] uppercase text-slate-500 font-bold mb-1">Risks Detected</p>
|
| 64 |
+
<p className="text-sm font-bold text-white">{item.analysis.risks.length}</p>
|
| 65 |
+
</div>
|
| 66 |
+
<div className="p-4 rounded-2xl bg-black/20 border border-white/5">
|
| 67 |
+
<p className="text-[9px] uppercase text-slate-500 font-bold mb-1">Key Requirements</p>
|
| 68 |
+
<p className="text-sm font-bold text-white">{item.analysis.key_requirements.length}</p>
|
| 69 |
+
</div>
|
| 70 |
+
<div className="p-4 rounded-2xl bg-black/20 border border-white/5">
|
| 71 |
+
<p className="text-[9px] uppercase text-slate-500 font-bold mb-1">Legal Gaps</p>
|
| 72 |
+
<p className="text-sm font-bold text-white">{item.analysis.compliance_gaps.length}</p>
|
| 73 |
+
</div>
|
| 74 |
+
<div className="p-4 rounded-2xl bg-black/20 border border-white/5">
|
| 75 |
+
<p className="text-[9px] uppercase text-slate-500 font-bold mb-1">Audit Logs</p>
|
| 76 |
+
<p className="text-sm font-bold text-white">{item.analysis.audit_log?.length ?? 0}</p>
|
| 77 |
+
</div>
|
| 78 |
</div>
|
| 79 |
+
|
| 80 |
+
<div className="mt-6">
|
| 81 |
+
<button
|
| 82 |
+
onClick={() => toggleExpand(itemId)}
|
| 83 |
+
className="text-xs font-bold text-purple-400 hover:text-white transition-colors flex items-center gap-2"
|
| 84 |
+
>
|
| 85 |
+
<span>{isExpanded ? "Hide Thought Process" : "View Agent Thought Process"}</span>
|
| 86 |
+
<span className={`transition-transform ${isExpanded ? "rotate-90" : ""}`}>→</span>
|
| 87 |
+
</button>
|
| 88 |
</div>
|
| 89 |
+
|
| 90 |
+
{isExpanded && (
|
| 91 |
+
<div className="mt-8 p-6 rounded-3xl bg-black/40 border border-white/5 animate-in slide-in-from-top-4 duration-500">
|
| 92 |
+
<h4 className="text-[10px] font-black uppercase tracking-widest text-slate-500 mb-4">Agent Intelligence Log (Full Audit)</h4>
|
| 93 |
+
<div className="space-y-3">
|
| 94 |
+
{item.analysis.audit_log?.map((log, idx) => (
|
| 95 |
+
<div key={idx} className="flex gap-4 p-3 rounded-xl bg-white/[0.02] border border-white/[0.02]">
|
| 96 |
+
<span className="text-xs opacity-30 mt-0.5">[{idx + 1}]</span>
|
| 97 |
+
<p className="text-xs text-slate-400 font-mono leading-relaxed">{log}</p>
|
| 98 |
+
</div>
|
| 99 |
+
))}
|
| 100 |
+
{(!item.analysis.audit_log || item.analysis.audit_log.length === 0) && (
|
| 101 |
+
<p className="text-xs text-slate-600 italic">No logs available for this session.</p>
|
| 102 |
+
)}
|
| 103 |
+
</div>
|
| 104 |
+
</div>
|
| 105 |
+
)}
|
| 106 |
</div>
|
| 107 |
+
);
|
| 108 |
+
})}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
</div>
|
| 110 |
</div>
|
| 111 |
);
|