fix(desktop): add missing PATCH /api/sessions/{id} so rename works (#36249)

The desktop rename dialog sent PATCH /api/sessions/{id}, but the backend
only defined GET and DELETE for that path — FastAPI returned 405 Method
Not Allowed, surfaced to the user as "Rename failed". Add the PATCH route
backed by SessionDB.set_session_title (handles sanitization, uniqueness,
and clearing the title when empty).

Also fix a misleading notification: any 405 was summarized as an unrelated
"does not support that audio endpoint" message. Make it a generic 405 hint.
This commit is contained in:
brooklyn!
2026-06-01 00:01:28 -05:00
committed by GitHub
parent bdceedf784
commit 7fbe9b79ab
3 changed files with 72 additions and 1 deletions
+25
View File
@@ -3657,6 +3657,31 @@ async def delete_session_endpoint(session_id: str):
db.close()
class SessionRename(BaseModel):
title: Optional[str] = None
@app.patch("/api/sessions/{session_id}")
async def rename_session_endpoint(session_id: str, body: SessionRename):
"""Rename a session (or clear its title when ``title`` is empty/null)."""
from hermes_state import SessionDB
db = SessionDB()
try:
sid = db.resolve_session_id(session_id)
if not sid:
raise HTTPException(status_code=404, detail="Session not found")
try:
updated = db.set_session_title(sid, body.title or "")
except ValueError as e:
# Title too long, invalid characters, or already in use.
raise HTTPException(status_code=400, detail=str(e))
if not updated:
raise HTTPException(status_code=404, detail="Session not found")
return {"ok": True, "title": db.get_session_title(sid) or ""}
finally:
db.close()
# ---------------------------------------------------------------------------
# Log viewer endpoint
# ---------------------------------------------------------------------------