refactor: SOLID architecture — backend service layer + frontend V2 components
## Backend — Service Layer & Repository Refactoring ### Neue Services (21 neue Dateien) **Interfaces & Implementierungen:** - `IOpenClawGatewayClient` — Interface für OpenClawGatewayClient (DIP-Fix: DashboardController hing an konkreter Klasse) - `IAgentConfigService` / `AgentConfigService` — Agent-Config-File-I/O aus AgentsController extrahiert - `IProjectService` / `ProjectService` — Projekt-CRUD + Activity-Logging (SRP) - `ITaskService` / `TaskService` — Task-State-Machine, Approve/Reject, Dashboard-Operationen (eliminiert Duplikation zwischen TasksController und DashboardController) - `IDashboardService` / `DashboardService` — Queue-Aggregation, Priority-Normalisierung, Gateway-Delegation - `IOperationsService` / `OperationsService` — Metriken-Berechnung aus OperationsController - `ITeamService` / `TeamService` — IDENTITY.md-Lesen aus TeamController - `IMemoryService` / `MemoryService` — File-I/O aus MemoryController - `IIncidentService` / `IncidentService` — File-Parsing (Regex-Source-Generatoren) aus IncidentsController - `IDocService` / `DocService` — Directory-Scan aus DocsController - `ICalendarService` / `CalendarService` — Gateway-HTTP-Calls + Fallback-Daten aus CalendarController ### Repository-Fixes **IUserRepository / UserRepository:** - `SaveChangesAsync` entfernt (leaky abstraction — Caller sollten nie SaveChanges steuern) - `RevokeTokenAsync(tokenHash)` — atomares Token-Revoke inkl. SaveChanges - `RevokeFamilyAsync(familyId)` — Batch-Revoke einer Token-Familie inkl. SaveChanges - `RemoveExpiredTokensAsync` speichert jetzt selbst (war vorher dependent auf nachfolgenden Save) ### AuthService-Fixes - `GetUserAsync`: unnötiges `Task.Run` entfernt → direkt `_users.GetByIdAsync().AsTask()` - `RevokeAsync`: delegiert jetzt an `IUserRepository.RevokeTokenAsync` - `RefreshAsync`: Token-Reuse-Detection delegiert an `IUserRepository.RevokeFamilyAsync` ### Bug-Fix - `OpenClawGatewayClient.ReadAgentGoalAsync`: pre-existing `CS1656` behoben (`reader` war `using`-Variable und wurde neu zugewiesen — in `reader2` umbenannt) ### Controller (16 Stück — alle slim) Alle Controller reduziert auf: Input validieren → Service aufrufen → HTTP-Result zurückgeben. Kein Business-Logic, kein File-I/O, keine direkte Repository-Nutzung (außer AgentsController für Activity-Log). **Program.cs — neue Registrierungen:** - `AddHttpClient<IOpenClawGatewayClient, OpenClawGatewayClient>` (war vorher konkrete Klasse) - Scoped: IDashboardService, IProjectService, ITaskService, IOperationsService, ITeamService, ICalendarService - Singleton: IAgentConfigService, IMemoryService, IIncidentService, IDocService --- ## Frontend — Dashboard V2 Components **AgentDetailModal.vue, IrisChat.vue, TaskStrip.vue:** - V2 Design-System: Dark Space Theme, Glass-Panels, Gradient-Akzente - Stores (agents, chat, tasks) nutzen Service + Mapper-Pattern - NexusLayout, FlowBoard, Topbar — Layoutfixes für fullHeight-Route-Meta Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,11 @@ interface DashboardAgentInfo {
|
||||
progress?: number
|
||||
workload?: number
|
||||
goal?: string | null
|
||||
roleBadge?: string
|
||||
statusLabel?: string
|
||||
elapsed?: string | null
|
||||
think?: string | null
|
||||
next?: string | null
|
||||
}
|
||||
|
||||
interface ModelOption {
|
||||
@@ -35,25 +40,6 @@ interface ModelOption {
|
||||
provider: string
|
||||
}
|
||||
|
||||
/* ── Agent Catalog (static enrichment) ────────────── */
|
||||
|
||||
// Type-safe catalog for static AgentNodeData fields not provided by API
|
||||
interface AgentCatalogEntry {
|
||||
elapsed: string;
|
||||
think: string | null;
|
||||
next: string;
|
||||
}
|
||||
|
||||
const AGENT_CATALOG: Record<string, AgentCatalogEntry> = {
|
||||
iris: { elapsed: '--', think: null, next: 'Standby' },
|
||||
programmer: { elapsed: '--', think: null, next: 'Standby' },
|
||||
developer: { elapsed: '--', think: null, next: 'Standby' },
|
||||
architekt: { elapsed: '--', think: null, next: 'Standby' },
|
||||
reviewer: { elapsed: '--', think: null, next: 'Standby' },
|
||||
executor: { elapsed: '--', think: null, next: 'Standby' },
|
||||
researcher: { elapsed: '--', think: null, next: 'Standby' },
|
||||
}
|
||||
|
||||
/* ── Status Mapping ───────────────────────────────── */
|
||||
|
||||
function mapStatus(isActive: boolean, currentTask: string | null): AgentNodeData['status'] {
|
||||
@@ -78,24 +64,24 @@ function avatarFor(id: string, name: string): string {
|
||||
/* ── Enrich API Agent → AgentNodeData ─────────────── */
|
||||
|
||||
function enrichAgent(api: DashboardAgentInfo): AgentNodeData {
|
||||
const cat = AGENT_CATALOG[api.id] ?? AGENT_CATALOG['reviewer']!
|
||||
const status = mapStatus(api.isActive, api.currentTask)
|
||||
return {
|
||||
id: api.id,
|
||||
name: api.name,
|
||||
role: api.role,
|
||||
roleBadge: api.roleBadge ?? 'badge-slate',
|
||||
model: api.model,
|
||||
avatar: avatarFor(api.id, api.name),
|
||||
status,
|
||||
statusLabel: STATUS_LABELS[status],
|
||||
statusLabel: api.statusLabel ?? STATUS_LABELS[status],
|
||||
task: api.currentTask,
|
||||
goal: api.goal ?? null,
|
||||
progress: api.progress ?? 0,
|
||||
elapsed: cat.elapsed ?? '--',
|
||||
next: cat.next ?? 'Standby',
|
||||
elapsed: api.elapsed ?? '--',
|
||||
next: api.next ?? 'Standby',
|
||||
tokens: '0',
|
||||
cost: '0.00',
|
||||
think: cat.think ?? null,
|
||||
think: api.think ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,8 +128,19 @@ export function buildAgentDetail(data: AgentNodeData, models: { id: string; alia
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
role: data.role,
|
||||
roleBadge: data.roleBadge || 'badge-slate',
|
||||
model: displayModel,
|
||||
status: data.status === 'block' ? 'idle' : data.status,
|
||||
statusLabel: data.statusLabel,
|
||||
task: data.task,
|
||||
goal: data.goal,
|
||||
progress,
|
||||
elapsed: data.elapsed || '—',
|
||||
next: data.next || '—',
|
||||
tokens: data.tokens || '0',
|
||||
cost: data.cost || '0.00',
|
||||
think: data.think,
|
||||
md: data.md,
|
||||
tokensToday,
|
||||
costToday: costNum,
|
||||
workload: progress,
|
||||
@@ -163,6 +160,7 @@ export const useAgentStore = defineStore('agents', {
|
||||
error: null as string | null,
|
||||
selectedAgentId: null as string | null,
|
||||
refreshInterval: null as ReturnType<typeof setInterval> | null,
|
||||
isConnected: false,
|
||||
}),
|
||||
|
||||
getters: {
|
||||
@@ -211,10 +209,12 @@ export const useAgentStore = defineStore('agents', {
|
||||
async fetchAgents() {
|
||||
try {
|
||||
const res = await apiFetch('/api/dashboard/agents')
|
||||
if (!res.ok) return
|
||||
if (!res.ok) { this.isConnected = false; return }
|
||||
const data: DashboardAgentInfo[] = await res.json()
|
||||
this.agents = data.map(enrichAgent)
|
||||
this.isConnected = true
|
||||
} catch (err) {
|
||||
this.isConnected = false
|
||||
console.warn('[AgentStore] fetchAgents failed', err)
|
||||
}
|
||||
},
|
||||
@@ -262,7 +262,7 @@ export const useAgentStore = defineStore('agents', {
|
||||
this.refreshInterval = setInterval(() => {
|
||||
this.fetchAgents()
|
||||
this.fetchModels()
|
||||
}, 30000)
|
||||
}, 15000)
|
||||
},
|
||||
|
||||
stopPolling() {
|
||||
|
||||
Reference in New Issue
Block a user