fix(routes): remove duplicate GET /api/sessions that shadowed session_list()
Neuron Soul CI / build (pull_request) Failing after 9m52s
Neuron Soul CI / build (pull_request) Failing after 9m52s
The first registration called route_sessions() which searched for a 'session-start' label that no longer exists, returning an empty array on every list request and making the sidebar appear empty after restart. The second registration (dead code) called the correct session_list(). Removes route_sessions() entirely and the stale first route block. Also wires up session_delete() and session_update_patch() — both existed in sessions.el but had no HTTP routes — via new DELETE and PATCH blocks.
This commit is contained in:
@@ -201,13 +201,6 @@ fn handle_dharma_recv(body: String) -> String {
|
||||
return "{\"error\":\"unknown event_type\",\"event_type\":\"" + eff_event + "\"}"
|
||||
}
|
||||
|
||||
fn route_sessions() -> String {
|
||||
let results: String = engram_search_json("session-start", 20)
|
||||
if str_eq(results, "") { return "[]" }
|
||||
if str_eq(results, "[]") { return "[]" }
|
||||
return results
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// MCP Connectors proxy — thin pass-through to neuron-connectd on :7771.
|
||||
// The UI talks to ONE origin (the soul); all MCP/config complexity lives in
|
||||
@@ -272,9 +265,6 @@ fn handle_request(method: String, path: String, body: String) -> String {
|
||||
if str_eq(clean, "/health") {
|
||||
return route_health()
|
||||
}
|
||||
if str_eq(clean, "/api/sessions") {
|
||||
return route_sessions()
|
||||
}
|
||||
if str_eq(clean, "/lineage") {
|
||||
return route_lineage()
|
||||
}
|
||||
@@ -548,5 +538,31 @@ fn handle_request(method: String, path: String, body: String) -> String {
|
||||
return err_404(clean)
|
||||
}
|
||||
|
||||
if str_eq(method, "DELETE") {
|
||||
// DELETE /api/sessions/:id — delete a session and its history
|
||||
if str_starts_with(clean, "/api/sessions/") {
|
||||
let del_after: String = str_slice(clean, 14, str_len(clean))
|
||||
let del_slash: Int = str_index_of(del_after, "/")
|
||||
let del_id: String = if del_slash < 0 { del_after } else { str_slice(del_after, 0, del_slash) }
|
||||
if !str_eq(del_id, "") {
|
||||
return session_delete(del_id)
|
||||
}
|
||||
}
|
||||
return err_404(clean)
|
||||
}
|
||||
|
||||
if str_eq(method, "PATCH") {
|
||||
// PATCH /api/sessions/:id — update session title and/or folder
|
||||
if str_starts_with(clean, "/api/sessions/") {
|
||||
let patch_after: String = str_slice(clean, 14, str_len(clean))
|
||||
let patch_slash: Int = str_index_of(patch_after, "/")
|
||||
let patch_id: String = if patch_slash < 0 { patch_after } else { str_slice(patch_after, 0, patch_slash) }
|
||||
if !str_eq(patch_id, "") {
|
||||
return session_update_patch(patch_id, body)
|
||||
}
|
||||
}
|
||||
return err_404(clean)
|
||||
}
|
||||
|
||||
return err_405(method, clean)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user