feat(dashboard): extract inline script to standalone dashboard.ts/js, add UI build/check recipes, and add route unit tests
This commit is contained in:
1 parent
4b307b55b9
commit
19f9c7ace7
24 files changed
+2343
-1819
No files matched your search
@@ -51,6 +51,10 @@ pub struct TelemetryStores {
|
||||
pub struct MemoryState {
|
||||
pub base_dir: PathBuf,
|
||||
pub clipboard_watch_mode: tokio::sync::RwLock<bool>,
|
||||
pub clipboard_notify: Arc<tokio::sync::Notify>,
|
||||
pub index_commit_notify: Arc<tokio::sync::Notify>,
|
||||
pub ttl_notify: Arc<tokio::sync::Notify>,
|
||||
pub condense_notify: Arc<tokio::sync::Notify>,
|
||||
pub graph: Store<KnowledgeGraph>,
|
||||
pub search_index: RwLock<MemoryIndex>,
|
||||
pub vector_db: tokio::sync::RwLock<Option<VectorDB>>,
|
||||
@@ -75,6 +79,10 @@ impl MemoryState {
|
||||
let state = Self {
|
||||
ollama: Arc::new(crate::ollama::OllamaClient::new_from_env()),
|
||||
clipboard_watch_mode: tokio::sync::RwLock::new(false),
|
||||
clipboard_notify: Arc::new(tokio::sync::Notify::new()),
|
||||
index_commit_notify: Arc::new(tokio::sync::Notify::new()),
|
||||
ttl_notify: Arc::new(tokio::sync::Notify::new()),
|
||||
condense_notify: Arc::new(tokio::sync::Notify::new()),
|
||||
graph: Store::new("knowledge_graph_master", db.clone()),
|
||||
base_dir: base.clone(),
|
||||
search_index: RwLock::new(match crate::search::MemoryIndex::new(&base) {
|
||||
@@ -207,6 +215,7 @@ impl MemoryState {
|
||||
if let Ok(mut w) = self.search_index.write() {
|
||||
*w = idx;
|
||||
}
|
||||
self.index_commit_notify.notify_waiters();
|
||||
}
|
||||
|
||||
pub fn record_activity(&self, category: &str, summary: &str, details: Option<&str>) {
|
||||
@@ -243,6 +252,49 @@ impl MemoryState {
|
||||
let _ = self.activity_tx.send(payload);
|
||||
}
|
||||
|
||||
pub fn broadcast_task_event(&self, event: TaskEvent) {
|
||||
let payload_val = serde_json::to_value(&event).unwrap_or_default();
|
||||
|
||||
let summary_str = format!("Task {} -> {}", event.task_id, event.status);
|
||||
self.telemetry.recent_activities.modify(|activities| {
|
||||
let activity = ActivityRecord {
|
||||
timestamp: event.timestamp,
|
||||
category: "TASK_EVENT".to_string(),
|
||||
summary: summary_str,
|
||||
details: Some(payload_val.to_string()),
|
||||
};
|
||||
activities.push_front(serde_json::to_value(&activity).unwrap_or_default());
|
||||
if activities.len() > 100 {
|
||||
activities.pop_back();
|
||||
}
|
||||
});
|
||||
|
||||
let generic_ev = GenericEvent {
|
||||
topic: "task:event".to_string(),
|
||||
session_id: event.session_id.clone(),
|
||||
payload: payload_val,
|
||||
};
|
||||
let _ = self.event_bus_tx.send(generic_ev);
|
||||
|
||||
let ws_notification = serde_json::json!({
|
||||
"jsonrpc": "2.0",
|
||||
"method": "notifications/task/completed",
|
||||
"params": event
|
||||
})
|
||||
.to_string();
|
||||
let _ = self.activity_tx.send(ws_notification);
|
||||
|
||||
let ws_resource_notification = serde_json::json!({
|
||||
"jsonrpc": "2.0",
|
||||
"method": "notifications/resources/updated",
|
||||
"params": {
|
||||
"uri": "memory://tasks/active"
|
||||
}
|
||||
})
|
||||
.to_string();
|
||||
let _ = self.activity_tx.send(ws_resource_notification);
|
||||
}
|
||||
|
||||
pub fn record_terminal_history(&self, payload: TerminalHistory) {
|
||||
self.telemetry.terminal_history.modify(|history| {
|
||||
history.push_front(payload);
|
||||
|
||||
Reference in new issue
Block a user