diff --git a/server/src/dashboard.html b/server/src/dashboard.html index 0e728d2..778501d 100644 --- a/server/src/dashboard.html +++ b/server/src/dashboard.html @@ -137,7 +137,7 @@ tasks.forEach(t => { const card = document.createElement('div'); card.className = `task-card ${t.status === 'completed' ? 'completed' : ''}`; - card.innerHTML = `${t.name}
${t.description}`; + card.innerHTML = `${t.title}
${t.description}`; if (t.status === 'completed') { doneContainer.appendChild(card); @@ -202,3 +202,4 @@ + diff --git a/server/src/fix_routes.py b/server/src/fix_routes.py new file mode 100644 index 0000000..c6ee2d7 --- /dev/null +++ b/server/src/fix_routes.py @@ -0,0 +1,50 @@ +import re + +endpoints = """ + .route("/api/graph", get({ + let state_clone = app_state.handler.state.clone(); + move || async move { + let graph = state_clone.get_full_graph(); + axum::Json(graph) + } + })) + .route("/api/tasks", get({ + let state_clone = app_state.handler.state.clone(); + move || async move { + let tasks = state_clone.tasks.read(); + axum::Json(tasks.clone()) + } + })) + .route("/api/search", get({ + let state_clone = app_state.handler.state.clone(); + move |axum::extract::Query(params): axum::extract::Query>| async move { + if let Some(q) = params.get("q") { + if let Ok(idx) = state_clone.search_index.read() { + if let Ok(results) = idx.search(q, None) { + let mut formatted_results = Vec::new(); + for (type_name, content) in results { + formatted_results.push(serde_json::json!({ + "type_name": type_name, + "content": content, + "score": 1.0 + })); + } + return axum::Json(serde_json::json!({ "results": formatted_results })); + } + } + } + axum::Json(serde_json::json!({ "results": [] })) + } + })) +""" + +filepath = "C:\\Users\\reazul.ashraf\\workspace\\rust\\mcp-memory\\server\\src\\main.rs" +with open(filepath, "r", encoding="utf-8") as f: + content = f.read() + +# Replace the broken routes with the fixed ones +pattern = r'\.route\("/api/graph".*?\.route\("/api/stats"' +content = re.sub(pattern, endpoints.strip() + '\n .route("/api/stats"', content, flags=re.DOTALL) + +with open(filepath, "w", encoding="utf-8") as f: + f.write(content) diff --git a/server/src/main.rs b/server/src/main.rs index 0539efb..9542250 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -268,8 +268,42 @@ fn run_server(state: Arc) -> Result<(), Box> "/", get(|| async move { axum::response::Html(include_str!("dashboard.html")) }), ) - .route( - "/api/stats", + .route("/api/graph", get({ + let state_clone = app_state.handler.state.clone(); + move || async move { + let graph = state_clone.get_full_graph(); + axum::Json(graph) + } + })) + .route("/api/tasks", get({ + let state_clone = app_state.handler.state.clone(); + move || async move { + let tasks = state_clone.tasks.read(); + axum::Json(tasks.clone()) + } + })) + .route("/api/search", get({ + let state_clone = app_state.handler.state.clone(); + move |axum::extract::Query(params): axum::extract::Query>| async move { + if let Some(q) = params.get("q") { + if let Ok(idx) = state_clone.search_index.read() { + if let Ok(results) = idx.search(q, None) { + let mut formatted_results = Vec::new(); + for (type_name, content) in results { + formatted_results.push(serde_json::json!({ + "type_name": type_name, + "content": content, + "score": 1.0 + })); + } + return axum::Json(serde_json::json!({ "results": formatted_results })); + } + } + } + axum::Json(serde_json::json!({ "results": [] })) + } + })) + .route("/api/stats", get({ let state_clone = app_state.handler.state.clone(); move || async move { @@ -716,3 +750,5 @@ fn main() -> Result<(), Box> { run_server(state) } + +