refactor(frontend): deduplicate CSS keyframes, unify types, extract format utils, add UI states, trim mock data
- Remove duplicate @keyframes pulse-* from 3 component files (already in nexus-tokens.css) - Rename AgentDetail → AgentDetailData in dashboard types to avoid collision with types/agent.ts - Extract shared formatNumber/initials/formatTime to utils/format.ts - Simplify FlowBoard: use agentStore modal/selection getters instead of duplicating local state - Add error banner + empty state to IrisChat; add loading skeleton + error/empty states to TaskStrip - Remove 105-line unused mockAgents array from useFlowLayout - Reduce operations store fallbacks from hardcoded preview data to minimal safe defaults - Update operations store tests to match lean fallback structure - Net: -73 lines, cleaner imports, fewer magic strings
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { apiFetch } from '../services/api'
|
||||
import type { AgentNodeData } from '../composables/useFlowLayout'
|
||||
import type { AgentDetail, ThinkingItem } from '../components/dashboard/v2/types'
|
||||
import type { AgentDetailData, ThinkingItem } from '../components/dashboard/v2/types'
|
||||
|
||||
/* ── API Response Shapes ──────────────────────────── */
|
||||
|
||||
@@ -127,7 +127,7 @@ function buildThinkingItems(data: AgentNodeData): ThinkingItem[] {
|
||||
return items
|
||||
}
|
||||
|
||||
export function buildAgentDetail(data: AgentNodeData, models: { id: string; alias: string }[]): AgentDetail {
|
||||
export function buildAgentDetail(data: AgentNodeData, models: { id: string; alias: string }[]): AgentDetailData {
|
||||
const tokenNum = parseFloat(data.tokens?.replace(/[^0-9.]/g, '') || '0')
|
||||
const tokenMultiplier = data.tokens?.includes('M') ? 1_000_000 : data.tokens?.includes('k') ? 1_000 : 1
|
||||
const tokensToday = Math.round(tokenNum * tokenMultiplier)
|
||||
@@ -177,7 +177,7 @@ export const useAgentStore = defineStore('agents', {
|
||||
},
|
||||
|
||||
/** Selected agent detail for modal */
|
||||
selectedAgent(state): AgentDetail | null {
|
||||
selectedAgent(state): AgentDetailData | null {
|
||||
if (!state.selectedAgentId) return null
|
||||
const data = state.agents.find(a => a.id === state.selectedAgentId)
|
||||
if (!data) return null
|
||||
|
||||
@@ -4,36 +4,15 @@ import { apiFetch } from '../services/api'
|
||||
|
||||
const fallback: OperationsSnapshot = {
|
||||
generatedAt: new Date().toISOString(),
|
||||
runtime: { runtime: 'OpenClaw', status: 'Online', detail: 'Gateway responding' },
|
||||
models: [
|
||||
{ provider: 'OpenClaw', model: 'deepseek/deepseek-v4-flash', status: 'Online', isLocal: false, detail: 'Programmer agent' },
|
||||
{ provider: 'OpenClaw', model: 'deepseek/deepseek-v4-pro', status: 'Online', isLocal: false, detail: 'Reviewer agent' },
|
||||
{ provider: 'OpenClaw', model: 'openai/gpt-5.3-chat-latest', status: 'Online', isLocal: false, detail: 'Iris orchestrator' },
|
||||
],
|
||||
metrics: { activeAgents: 3, queuedTasks: 7, successRate: 98.4, incidents: 0 },
|
||||
projects: [
|
||||
{ id: 'nexus', name: 'Nexus', status: 'Active', progress: 18 },
|
||||
{ id: 'openclaw', name: 'OpenClaw Runtime', status: 'Online', progress: 100 },
|
||||
{ id: 'infra', name: 'Noveria Infrastructure', status: 'Stable', progress: 74 },
|
||||
],
|
||||
tasks: [
|
||||
{ id: 'preview-foundation', title: 'Nexus foundation', state: 'In progress', priority: 'Critical', updatedAt: new Date().toISOString() },
|
||||
{ id: 'preview-runtime', title: 'Connect OpenClaw adapter', state: 'In progress', priority: 'High', updatedAt: new Date().toISOString() },
|
||||
{ id: 'preview-routing', title: 'Configure model routing', state: 'In progress', priority: 'High', updatedAt: new Date().toISOString() },
|
||||
{ id: 'preview-auth', title: 'Owner authentication', state: 'Done', priority: 'Critical', updatedAt: new Date().toISOString() },
|
||||
],
|
||||
activity: [
|
||||
{ type: 'runtime', message: 'OpenClaw runtime health checked', at: new Date().toISOString() },
|
||||
{ type: 'deploy', message: 'Nexus foundation initialized', at: new Date(Date.now() - 720000).toISOString() },
|
||||
{ type: 'deploy', message: 'Model routing configured for DeepSeek agents', at: new Date(Date.now() - 1140000).toISOString() },
|
||||
],
|
||||
runtime: { runtime: 'OpenClaw', status: 'Unknown', detail: 'Awaiting connection…' },
|
||||
models: [],
|
||||
metrics: { activeAgents: 0, queuedTasks: 0, successRate: 0, incidents: 0 },
|
||||
projects: [],
|
||||
tasks: [],
|
||||
activity: [],
|
||||
}
|
||||
|
||||
const fallbackRouting: RoutingTarget[] = [
|
||||
{ priority: 1, provider: 'OpenClaw', model: 'deepseek/deepseek-v4-flash', purpose: 'Programmer agent', status: 'Online', detail: 'Routed through OpenClaw' },
|
||||
{ priority: 2, provider: 'OpenClaw', model: 'deepseek/deepseek-v4-pro', purpose: 'Reviewer agent', status: 'Online', detail: 'Routed through OpenClaw' },
|
||||
{ priority: 3, provider: 'OpenClaw', model: 'openai/gpt-5.3-chat-latest', purpose: 'Iris orchestrator', status: 'Online', detail: 'Routed through OpenClaw' },
|
||||
]
|
||||
const fallbackRouting: RoutingTarget[] = []
|
||||
|
||||
export const useOperationsStore = defineStore('operations', {
|
||||
state: () => ({
|
||||
|
||||
Reference in New Issue
Block a user