Sessions: edit form, soft-delete, lazy creation, chat as separate page

- Session click opens edit form (name, description, image, agent) instead of chat
- Chat is now a separate route (#chat/{id}), opened via button
- Sessions created on save, not on click
- Soft-delete for sessions (is_deleted flag)
- Delete button in session form
- Removed title double-click editing from chat
- Card images now square (aspect-ratio: 1)
- New Session as placeholder card
This commit is contained in:
Meleki committed 2026-02-26 21:25:35 +01:00
1 parent 449c872296
commit a90b9427a5
10 files changed
+340 -188

No files matched your search

+19 -9
View File
@@ -16,6 +16,7 @@ public static class SessionEndpoint
app.MapGet("/api/sessions/{sessionId}", HandleGet);
app.MapPost("/api/sessions", HandleCreate);
app.MapPut("/api/sessions/{sessionId}", HandleUpdate);
app.MapDelete("/api/sessions/{sessionId}", HandleDelete);
}
private static async Task HandleList(HttpContext ctx, DatabaseService db)
@@ -43,7 +44,14 @@ public static class SessionEndpoint
private static async Task HandleCreate(HttpContext ctx, DatabaseService db)
{
var session = await db.CreateSession("Neue Session");
var body = await JsonSerializer.DeserializeAsync<JsonElement>(ctx.Request.Body);
var name = body.TryGetProperty("name", out var n) ? n.GetString() : "Neue Session";
var description = body.TryGetProperty("description", out var d) ? d.GetString() : null;
var image = body.TryGetProperty("image", out var img) ? img.GetString() : null;
var agentId = body.TryGetProperty("agentId", out var a) ? a.GetString() : null;
var session = await db.CreateSession(name, description, image, agentId);
await ctx.Response.WriteAsJsonAsync(session);
}
@@ -57,16 +65,18 @@ public static class SessionEndpoint
}
var body = await JsonSerializer.DeserializeAsync<JsonElement>(ctx.Request.Body);
if (body.TryGetProperty("name", out var nameEl))
{
await db.UpdateSessionName(sessionId, nameEl.GetString());
}
if (body.TryGetProperty("agentId", out var agentEl))
{
await db.UpdateSessionAgent(sessionId, agentEl.GetString());
}
await db.UpdateSession(sessionId, body);
var session = await db.GetSession(sessionId);
await ctx.Response.WriteAsJsonAsync(session);
}
private static async Task HandleDelete(HttpContext ctx, DatabaseService db)
{
var sessionId = ctx.Request.RouteValues["sessionId"]?.ToString();
if (string.IsNullOrEmpty(sessionId)) { ctx.Response.StatusCode = 400; return; }
await db.DeleteSession(sessionId);
ctx.Response.StatusCode = 204;
}
}