feat: Add Brain Monitor dashboard and live API stats
This commit is contained in:
1 parent
3239e32866
commit
18fd05bb11
10 files changed
+672
-80
No files matched your search
@@ -1,5 +1,6 @@
|
||||
use crate::models::*;
|
||||
use crate::store::{Store, read_json_file, write_json_atomic};
|
||||
use crate::search::MemoryIndex;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
@@ -11,6 +12,7 @@ pub struct MemoryState {
|
||||
pub master_path: PathBuf,
|
||||
pub session_graph: RwLock<KnowledgeGraph>,
|
||||
pub master_cache: RwLock<(KnowledgeGraph, SystemTime)>,
|
||||
pub search_index: RwLock<MemoryIndex>,
|
||||
pub ledger: Store<Vec<CodeChange>>,
|
||||
pub sticky: Store<Vec<StickyNote>>,
|
||||
pub tasks: Store<Vec<Task>>,
|
||||
@@ -136,5 +138,27 @@ impl MemoryState {
|
||||
|
||||
let _ = fs::remove_file(&lock_path);
|
||||
}
|
||||
|
||||
pub fn rebuild_index(&self) {
|
||||
if let Ok(new_idx) = MemoryIndex::new() {
|
||||
let full = self.get_full_graph();
|
||||
for (_, e) in &full.entities {
|
||||
let _ = new_idx.index_entity(e);
|
||||
}
|
||||
for t in self.tasks.read() {
|
||||
let _ = new_idx.index_task(&t);
|
||||
}
|
||||
for s in self.snippets.read() {
|
||||
let _ = new_idx.index_snippet(&s);
|
||||
}
|
||||
for a in self.adrs.read() {
|
||||
let _ = new_idx.index_adr(&a);
|
||||
}
|
||||
if let Ok(mut w) = self.search_index.write() {
|
||||
*w = new_idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user