feat: brain-engine + brain-ui + docs — template full stack standalone
- brain-engine: server, embed, search, RAG, MCP, start.sh (standalone) - brain-ui: source React complète, build.sh, DocsView avec tier colors - docs: 14 pages guides humains (getting-started, architecture, sessions, workflows, agents, vues tier) - brain-compose.yml v0.9.0: tier featured ajouté, sessions/agents par tier, coach_level, API key schema - DISTRIBUTION_CHECKLIST v1.2: brain-engine + brain-ui + docs dans la checklist
This commit is contained in:
33
brain-ui/src/hooks/useWorkspaceData.ts
Normal file
33
brain-ui/src/hooks/useWorkspaceData.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { useMemo } from 'react'
|
||||
import { useBrainStore } from '../store/brain.store'
|
||||
import type { WorkspaceWorkflow } from '../types'
|
||||
|
||||
const WORKFLOW_COLORS = ['#6366f1', '#f59e0b', '#22c55e', '#ef4444', '#8b5cf6', '#06b6d4']
|
||||
|
||||
function computeLayout(workflows: ReturnType<typeof useBrainStore.getState>['workflows']): WorkspaceWorkflow[] {
|
||||
return workflows.map((wf, wfIdx) => {
|
||||
const baseX = (wfIdx - workflows.length / 2) * 4
|
||||
const color = WORKFLOW_COLORS[wfIdx % WORKFLOW_COLORS.length]
|
||||
|
||||
const steps = (wf.steps ?? []).map((step, stepIdx) => {
|
||||
const z = step.status === 'done' ? -stepIdx * 0.5 : stepIdx === 0 ? 1 : 0
|
||||
return {
|
||||
id: step.id,
|
||||
label: step.label,
|
||||
status: step.status as WorkspaceWorkflow['steps'][number]['status'],
|
||||
isGate: step.isGate ?? false,
|
||||
x: baseX + Math.sin(stepIdx * 0.8) * 0.5,
|
||||
y: (workflows.length / 2 - stepIdx) * 1.5,
|
||||
z,
|
||||
}
|
||||
})
|
||||
|
||||
return { id: wf.id, name: wf.name, steps, teamId: undefined, color }
|
||||
})
|
||||
}
|
||||
|
||||
export function useWorkspaceData() {
|
||||
const workflows = useBrainStore((s) => s.workflows)
|
||||
const workspaceWorkflows = useMemo(() => computeLayout(workflows), [workflows])
|
||||
return { workflows: workspaceWorkflows }
|
||||
}
|
||||
Reference in New Issue
Block a user