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
+45
View File
@@ -205,6 +205,51 @@ class TestWebServerEndpoints:
assert captured["list"] == 3
assert captured["count"] == 3
def test_rename_session_updates_title(self):
"""PATCH /api/sessions/{id} renames a session (regression: the route
was missing entirely, so the desktop rename dialog got a 405)."""
from hermes_state import SessionDB
db = SessionDB()
try:
db.create_session(session_id="rename-me", source="cli")
finally:
db.close()
resp = self.client.patch("/api/sessions/rename-me", json={"title": "My Chat"})
assert resp.status_code == 200
assert resp.json() == {"ok": True, "title": "My Chat"}
db = SessionDB()
try:
assert db.get_session_title("rename-me") == "My Chat"
finally:
db.close()
def test_rename_session_clears_title_when_empty(self):
from hermes_state import SessionDB
db = SessionDB()
try:
db.create_session(session_id="clear-me", source="cli")
db.set_session_title("clear-me", "Has A Title")
finally:
db.close()
resp = self.client.patch("/api/sessions/clear-me", json={"title": ""})
assert resp.status_code == 200
assert resp.json() == {"ok": True, "title": ""}
db = SessionDB()
try:
assert db.get_session_title("clear-me") is None
finally:
db.close()
def test_rename_session_not_found(self):
resp = self.client.patch("/api/sessions/does-not-exist", json={"title": "x"})
assert resp.status_code == 404
def test_audio_transcription_endpoint(self, monkeypatch):
import tools.transcription_tools as transcription_tools