11import React , { useState , useMemo } from 'react' ;
2- import { History , TrendingUp , X , Trash2 , Fingerprint , Map } from 'lucide-react' ;
3- import { ConversationEntry , ConsciousnessArchetype } from '../types' ;
2+ import { History , TrendingUp , X , Trash2 , Brain , Map } from 'lucide-react' ;
3+ import { ConversationEntry } from '../types' ;
44import { dbService } from '../services/db' ;
55
66interface Props {
@@ -18,43 +18,43 @@ export const HistoryPanel: React.FC<Props> = ({ history, onClear }) => {
1818 // Use history prop directly
1919 const displayData = history ;
2020
21- // Helper for safe access
22- const safeMetric = ( entry : ConversationEntry , key : 'coherence ' | 'presence ' | 'entanglement ' ) => {
23- return entry . quantum_metrics ? entry . quantum_metrics [ key ] : 0 ;
21+ // Helper for safe access to mindfulness metrics
22+ const safeMetric = ( entry : ConversationEntry , key : 'attention_stability ' | 'present_moment_awareness ' | 'emotional_regulation ' ) => {
23+ return entry . mindfulness_metrics ? entry . mindfulness_metrics [ key ] : 0 ;
2424 } ;
2525
26- const avgCoherence = displayData . reduce ( ( sum , e ) => sum + safeMetric ( e , 'coherence ' ) , 0 ) / ( displayData . length || 1 ) ;
27- const avgPresence = displayData . reduce ( ( sum , e ) => sum + safeMetric ( e , 'presence ' ) , 0 ) / ( displayData . length || 1 ) ;
28- const avgEntanglement = displayData . reduce ( ( sum , e ) => sum + safeMetric ( e , 'entanglement ' ) , 0 ) / ( displayData . length || 1 ) ;
29-
30- // DETERMINE CONSCIOUSNESS DNA ARCHETYPE
31- let archetype : ConsciousnessArchetype = 'The Seeker' ;
32- let description = "Bạn đang trên hành trình tìm kiếm sự bình an ." ;
33-
34- if ( avgPresence > 0.7 && avgCoherence > 0.7 ) {
35- archetype = 'The Warrior' ; // High discipline
36- description = "Bạn có khả năng định tâm vững chãi như núi ." ;
37- } else if ( avgEntanglement > 0.7 ) {
38- archetype = 'The Healer' ; // High connection
39- description = "Trái tim bạn rộng mở và kết nối sâu sắc với vạn vật ." ;
40- } else if ( avgCoherence > 0.8 ) {
41- archetype = 'The Observer' ; // High coherence
42- description = "Bạn nhìn thấu bản chất vấn đề với sự tĩnh lặng ." ;
26+ const avgAttentionStability = displayData . reduce ( ( sum , e ) => sum + safeMetric ( e , 'attention_stability ' ) , 0 ) / ( displayData . length || 1 ) ;
27+ const avgPresentMomentAwareness = displayData . reduce ( ( sum , e ) => sum + safeMetric ( e , 'present_moment_awareness ' ) , 0 ) / ( displayData . length || 1 ) ;
28+ const avgEmotionalRegulation = displayData . reduce ( ( sum , e ) => sum + safeMetric ( e , 'emotional_regulation ' ) , 0 ) / ( displayData . length || 1 ) ;
29+
30+ // DETERMINE MINDFULNESS PROFILE (clinically based)
31+ let profileTitle = "Developing Awareness" ;
32+ let description = "Bạn đang xây dựng nền tảng chánh niệm ." ;
33+
34+ if ( avgPresentMomentAwareness > 0.7 && avgAttentionStability > 0.7 ) {
35+ profileTitle = "Strong Practice" ; // High discipline
36+ description = "Bạn đã phát triển khả năng định tâm vững chãi." ;
37+ } else if ( avgEmotionalRegulation > 0.7 ) {
38+ profileTitle = "Emotional Balance" ; // High regulation
39+ description = "Bạn điều tiết cảm xúc một cách khéo léo ." ;
40+ } else if ( avgAttentionStability > 0.8 ) {
41+ profileTitle = "Focused Attention" ; // High attention
42+ description = "Bạn có khả năng tập trung ổn định tốt ." ;
4343 }
4444
4545 return {
4646 displayData,
47- avgCoherence ,
48- avgPresence ,
49- avgEntanglement ,
50- archetype ,
47+ avgAttentionStability ,
48+ avgPresentMomentAwareness ,
49+ avgEmotionalRegulation ,
50+ profileTitle ,
5151 description
5252 } ;
5353 } , [ history ] ) ;
5454
5555 if ( ! analysis ) return null ;
5656
57- const { displayData, avgCoherence , avgPresence , avgEntanglement , archetype , description } = analysis ;
57+ const { displayData, avgAttentionStability , avgPresentMomentAwareness , avgEmotionalRegulation , profileTitle , description } = analysis ;
5858
5959 const emotionColor = {
6060 anxious : 'border-orange-400 bg-orange-50' ,
@@ -87,27 +87,27 @@ export const HistoryPanel: React.FC<Props> = ({ history, onClear }) => {
8787 { /* Header */ }
8888 < div className = "bg-gradient-to-r from-stone-800 to-stone-900 text-amber-50 p-4 rounded-t-2xl flex items-center justify-between shadow-sm" >
8989 < div className = "flex items-center gap-2" >
90- < Fingerprint size = { 18 } className = "text-amber-400" />
91- < h3 className = "font-bold text-sm tracking-wide uppercase" > Consciousness DNA </ h3 >
90+ < Brain size = { 18 } className = "text-amber-400" />
91+ < h3 className = "font-bold text-sm tracking-wide uppercase" > Mindfulness Profile </ h3 >
9292 </ div >
9393 < button onClick = { ( ) => setIsOpen ( false ) } className = "hover:bg-white/10 rounded-full p-1 transition-colors" >
9494 < X size = { 18 } />
9595 </ button >
9696 </ div >
9797
98- { /* DNA Profile (New Feature ) */ }
98+ { /* Mindfulness Profile (Clinical Metrics ) */ }
9999 < div className = "bg-stone-50 p-5 border-b border-stone-200" >
100100 < div className = "text-center mb-3" >
101- < span className = "text-[10px] uppercase tracking-[0.2em] text-stone-400" > Your Archetype </ span >
102- < h4 className = "text-xl font-serif font-bold text-stone-800 mt-1" > { archetype } </ h4 >
101+ < span className = "text-[10px] uppercase tracking-[0.2em] text-stone-400" > Practice Level </ span >
102+ < h4 className = "text-xl font-serif font-bold text-stone-800 mt-1" > { profileTitle } </ h4 >
103103 < p className = "text-xs text-stone-500 italic mt-1" > { description } </ p >
104104 </ div >
105-
106- { /* Mini DNA Bar Chart */ }
105+
106+ { /* Mindfulness Metrics Bar Chart */ }
107107 < div className = "space-y-2 mt-4" >
108- < DnaBar label = "Presence " value = { avgPresence } color = "bg-emerald-500" />
109- < DnaBar label = "Connection " value = { avgEntanglement } color = "bg-purple-500" />
110- < DnaBar label = "Clarity " value = { avgCoherence } color = "bg-blue-500" />
108+ < DnaBar label = "Present Moment " value = { avgPresentMomentAwareness } color = "bg-emerald-500" />
109+ < DnaBar label = "Emotion Regulation " value = { avgEmotionalRegulation } color = "bg-purple-500" />
110+ < DnaBar label = "Attention " value = { avgAttentionStability } color = "bg-blue-500" />
111111 </ div >
112112 </ div >
113113
@@ -132,8 +132,8 @@ export const HistoryPanel: React.FC<Props> = ({ history, onClear }) => {
132132 < span className = "text-[10px] text-stone-400 font-mono" > { timeStr } </ span >
133133 </ div >
134134 < div className = "flex gap-3 text-[10px] font-medium opacity-80" >
135- < span className = "text-blue-600" > C : { Math . round ( ( entry . quantum_metrics ?. coherence || 0 ) * 100 ) } </ span >
136- < span className = "text-purple-600" > E : { Math . round ( ( entry . quantum_metrics ?. entanglement || 0 ) * 100 ) } </ span >
135+ < span className = "text-blue-600" > Attn : { Math . round ( ( entry . mindfulness_metrics ?. attention_stability || 0 ) * 100 ) } </ span >
136+ < span className = "text-purple-600" > Reg : { Math . round ( ( entry . mindfulness_metrics ?. emotional_regulation || 0 ) * 100 ) } </ span >
137137 </ div >
138138 </ div >
139139 ) ;
0 commit comments