Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
5f57775
1
Parent(s): 62bed67
backend stabilization
Browse filesFiles changed (2)
566 unmodified lines567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765566 unmodified lines color: #1E293B; font-weight: 500; font-style: italic;}
/* 6. AI Growth Center Enhancements */.headerTabs { display: flex; gap: 4px; background: rgba(255, 255, 255, 0.1); padding: 4px; border-radius: 12px; margin-bottom: 24px; width: fit-content; border: 1px solid rgba(255, 255, 255, 0.1);}
.tab { padding: 8px 20px; border-radius: 8px; border: none; background: none; color: rgba(255, 255, 255, 0.6); font-size: 11px; font-weight: 800; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 8px;}
.tab.activeTab { background: white; color: var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,0.1);}
.growthGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(450px, 1fr)); gap: 32px;}
.insightCard { background: white; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 32px; display: flex; flex-direction: column; gap: 24px; position: relative; overflow: hidden; transition: all 0.3s;}
.insightCard::after { content: ''; position: absolute; top: 0; right: 0; width: 100px; height: 100px; background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.05) 0%, transparent 70%); pointer-events: none;}
.insightContent h3 { font-size: 20px; font-weight: 800; color: var(--text-main); margin-bottom: 8px;}
.insightType { font-size: 10px; font-weight: 900; color: var(--primary); text-transform: uppercase; letter-spacing: 0.1em; display: block; margin-bottom: 16px;}
.reasoningBox { background: #F8FAFC; padding: 16px; border-radius: 12px; border-left: 3px solid var(--primary);}
.reasoningLabel { display: block; font-size: 10px; font-weight: 900; color: var(--text-muted); margin-bottom: 6px;}
.reasoningText { font-size: 13px; color: var(--text-main); line-height: 1.5; font-style: italic;}
.confidenceSection { display: flex; flex-direction: column; gap: 8px;}
.confHeader { display: flex; justify-content: space-between; align-items: center;}
.confHeader label { font-size: 10px; font-weight: 900; color: var(--text-muted);}
.confValue { font-size: 12px; font-weight: 800; color: var(--primary);}
.confMeter { height: 6px; background: #E2E8F0; border-radius: 3px; overflow: hidden;}
.confFill { height: 100%; background: linear-gradient(to right, #818CF8, #6366F1); border-radius: 3px;}
.insightActions { display: flex; gap: 12px; margin-top: auto;}
.applyBtn { flex: 2; background: var(--primary); color: white; border: none; padding: 12px; border-radius: 10px; font-weight: 800; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.2s;}
.applyBtn:hover { background: #4F46E5; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);}
.dismissBtn { flex: 1; background: #F1F5F9; color: #64748B; border: none; padding: 12px; border-radius: 10px; font-weight: 800; font-size: 11px; cursor: pointer; transition: all 0.2s;}
.dismissBtn:hover { background: #E2E8F0; color: #475569;}
.sourceTag { font-size: 9px; font-weight: 700; color: var(--text-muted); background: #F1F5F9; padding: 2px 6px; border-radius: 4px;}81 unmodified lines828384858687888990919231 unmodified lines12412512612712812913013113213313413513613713813914014114214314414514614714814915015115215369 unmodified lines2232242252262272282292302312322332342352362372382392402412422432442452462472482493 unmodified lines25325425521121225625725825926026126226326426526626726826927027127227327427527627727827928055 unmodified lines33633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940027440140240340481 unmodified lines const [suggestions, setSuggestions] = useState<string[]>([]); const [aiSuggestion, setAiSuggestion] = useState<string | null>(null);
// AI Growth Center State const [activeTab, setActiveTab] = useState<'library' | 'growth'>('library'); const [insights, setInsights] = useState<any[]>([]); const [insightsLoading, setInsightsLoading] = useState(false);
// 1. Fetch Categories const fetchCategories = useCallback(async () => { try {31 unmodified lines } }, []);
// 3. Fetch Insights const fetchInsights = useCallback(async () => { setInsightsLoading(true); try { const resp = await api.get('kb_insights/'); setInsights(resp.data); } catch (err) { console.error('Failed to fetch insights:', err); } finally { setInsightsLoading(false); } }, []);
useEffect(() => { fetchCategories(); fetchArticles('', 'All'); }, [fetchCategories, fetchArticles]);
useEffect(() => { if (activeTab === 'growth') { fetchInsights(); } }, [activeTab, fetchInsights]);
const handleSearchTrigger = (e?: React.FormEvent) => { if (e) e.preventDefault(); setActiveQuery(searchInput);69 unmodified lines } };
// Insight Actions const handleApplyInsight = async (insight: any) => { try { await api.post(`kb_insights/${insight.id}/apply/`); setInsights(prev => prev.filter(i => i.id !== insight.id)); setActiveTab('library'); fetchArticles('', selectedCategory); } catch (err) { console.error('Failed to apply insight:', err); } };
const handleDismissInsight = async (id: string) => { try { await api.post(`kb_insights/${id}/dismiss/`); setInsights(prev => prev.filter(i => i.id !== id)); } catch (err) { console.error('Failed to dismiss insight:', err); } };
// Pagination Logic const totalPages = Math.ceil(articles.length / itemsPerPage); const paginatedArticles = articles.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage);3 unmodified lines <header className={styles.missionBanner}> <div className={styles.bannerContent}> <div className={styles.headerBadge}>MISSION CORE</div> <h1>Knowledge Library</h1> <p className={styles.description}>Strategic intelligence gathering and architectural documentation.</p> <div className={styles.headerTabs}> <button className={`${styles.tab} ${activeTab === 'library' ? styles.activeTab : ''}`} onClick={() => setActiveTab('library')} > <Globe size={14} /> LIBRARY </button> <button className={`${styles.tab} ${activeTab === 'growth' ? styles.activeTab : ''}`} onClick={() => setActiveTab('growth')} > <Sparkles size={14} /> AI GROWTH CENTER </button> </div>
<h1>{activeTab === 'library' ? 'Knowledge Library' : 'Knowledge Growth'}</h1> <p className={styles.description}> {activeTab === 'library' ? 'Strategic intelligence gathering and architectural documentation.' : 'AI-detected blindspots and performance-driven documentation suggestions.'} </p> <form className={styles.searchControls} onSubmit={handleSearchTrigger}> <div className={styles.searchWrapper}>55 unmodified lines
<div className={styles.contentArea}> <AnimatePresence mode="wait"> {activeTab === 'growth' ? ( <motion.div key="growth" className={styles.growthGrid} initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0, y: -20 }} > {insightsLoading ? ( <div className={styles.emptyState}> <div className={styles.loadingPulse} /> <p>Scanning knowledge topology for gaps...</p> </div> ) : insights.length === 0 ? ( <div className={styles.emptyState}> <ShieldCheck size={48} color="var(--primary)" /> <h3>Knowledge Equilibrium Reached</h3> <p>AI has not detected any significant blindspots in current ticket resolutions.</p> </div> ) : ( insights.map((insight) => ( <motion.div key={insight.id} className={styles.insightCard}> <span className={styles.insightType}>{insight.insight_type.replace('_', ' ')}</span> <div className={styles.insightContent}> <h3>{insight.suggested_title}</h3> <div className={styles.reasoningBox}> <span className={styles.reasoningLabel}>AI REASONING</span> <p className={styles.reasoningText}>{insight.reasoning}</p> </div> </div>
<div className={styles.confidenceSection}> <div className={styles.confHeader}> <label>CONFIDENCE LEVEL</label> <span className={styles.confValue}>{Math.round(insight.confidence_score * 100)}%</span> </div> <div className={styles.confMeter}> <div className={styles.confFill} style={{ width: `${insight.confidence_score * 100}%` }} /> </div> </div>
<div className={styles.insightActions}> <button className={styles.applyBtn} onClick={() => handleApplyInsight(insight)} > <Send size={14} /> DEPLOY DRAFT </button> <button className={styles.dismissBtn} onClick={() => handleDismissInsight(insight.id)} > DISMISS </button> </div> </motion.div> )) )} </motion.div> {loading && articles.length === 0 ? ( ) : loading && articles.length === 0 ? ( <motion.div key="loading" initial={{ opacity: 0 }} animate={{ opacity: 1 }} className={styles.emptyState}> <div className={styles.loadingPulse} /> <p>Syncing Library Telemetry...</p>frontend/apps/internal/src/components/KnowledgeBase.module.css+195
frontend/apps/internal/src/components/KnowledgeBase.tsx+130-3