Dashboard-Performance: API-Endpoints konsolidieren

Backend:
- GET /api/sessions: Git-Status inline integriert (parallel pro Session)
  - Neue Hilfsmethoden GetGitStatusSummaryAsync (Counts) und
    GetGitStatusDetailedAsync (Dateinamen, für Einzel-Endpoint)
  - GetSessionsWithStats gibt typisierte SessionWithStats zurück
  - Neue Models: SessionWithStats, GitStatusSummary
- GET /api/agents: Skills inline pro Agent integriert
  - SkillService als Parameter in HandleList
  - Skills als Array mit slug/name/description

Frontend:
- Dashboard: 1 paralleler Promise.all statt sequentieller Requests
  - Vorher: agents → sessions → N×git-status → M×agent-skills → cronjobs → shares
  - Nachher: Promise.all([agents, sessions, cronjobs, shares]) (4 Requests)
  - Git-Status direkt aus Session-Response, Skills aus Agent-Response
- Session-Page: Agent-Skills aus inline-Daten statt N×apiGetAgentSkills

Reduziert Dashboard-Requests von ~4+N+M auf 4 (fix).
This commit is contained in:
Meleki committed 2026-03-07 19:40:26 +01:00
1 parent 0dcc05ebf9
commit 11acfde081
7 files changed
+265 -119

No files matched your search

+44 -2
View File
@@ -1,3 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using Gott.Extensions;
@@ -20,11 +22,51 @@ public static class AgentEndpoint
app.MapDelete("/api/agents/{agentId}", HandleDelete);
}
private static async Task HandleList(HttpContext ctx, DatabaseService db)
private static async Task HandleList(HttpContext ctx, DatabaseService db, SkillService skillService)
{
var userId = ctx.GetUserId();
var agents = await db.GetAgents(userId);
await ctx.Response.WriteAsJsonAsync(agents);
var allSkills = skillService.GetAllSkills();
var skillMap = allSkills.ToDictionary(s => s.Slug);
var results = new List<object>();
foreach (var a in agents)
{
var agentSkillSlugs = await db.GetAgentSkills(a.AgentId);
var skills = agentSkillSlugs
.Where(slug => skillMap.ContainsKey(slug))
.Select(slug => new { slug, name = skillMap[slug].Name, description = skillMap[slug].Description })
.ToList();
results.Add(new
{
a.AgentId,
a.Name,
a.Avatar,
a.Description,
a.Model,
a.ToolChoice,
a.CustomCommands,
a.AutoCommit,
a.UseSoul,
a.UseIdentity,
a.UseUserInfo,
a.UseMemory,
a.UseWebSearch,
a.WebSearchVersion,
a.AllowUserChoice,
a.TaskInstruction,
a.AvatarScale,
a.AvatarOffsetX,
a.AvatarOffsetY,
a.IsDeleted,
a.CreatedAt,
a.UpdatedAt,
Skills = skills
});
}
await ctx.Response.WriteAsJsonAsync(results);
}
private static async Task HandleGet(HttpContext ctx, DatabaseService db)