AP1.15a: Zielzustands-Designer mit Pan/Zoom und Kanten im Plan-Tab.
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 2m19s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 12s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-07-11 08:28:15 +02:00
1 parent 2843d8775a
commit 0c2ca4a69d
7 files changed
+770 -8

No files matched your search

+100
View File
@@ -0,0 +1,100 @@
/** Designer-Hilfen für Zielzustands-Graph (AP1.15a) — kein Workflow. */
export const DESIGNER_MIN_ZOOM = 0.5
export const DESIGNER_MAX_ZOOM = 2
export const DESIGNER_ZOOM_STEP = 0.1
/**
* @param {number} zoom
* @returns {number}
*/
export function clampDesignerZoom(zoom) {
return Math.min(DESIGNER_MAX_ZOOM, Math.max(DESIGNER_MIN_ZOOM, zoom))
}
/**
* @param {string} initiativeId
* @returns {Record<string, { x: number, y: number }>}
*/
export function loadManualGatePositions(initiativeId) {
if (typeof window === 'undefined' || !initiativeId) return {}
try {
const raw = window.localStorage.getItem(`kairo.plan.gateLayout:${initiativeId}`)
if (!raw) return {}
const parsed = JSON.parse(raw)
return parsed && typeof parsed === 'object' ? parsed : {}
} catch {
return {}
}
}
/**
* @param {string} initiativeId
* @param {Record<string, { x: number, y: number }>} positions
*/
export function storeManualGatePositions(initiativeId, positions) {
if (typeof window === 'undefined' || !initiativeId) return
window.localStorage.setItem(
`kairo.plan.gateLayout:${initiativeId}`,
JSON.stringify(positions),
)
}
/**
* @param {string} initiativeId
*/
export function clearManualGatePositions(initiativeId) {
if (typeof window === 'undefined' || !initiativeId) return
window.localStorage.removeItem(`kairo.plan.gateLayout:${initiativeId}`)
}
/**
* @param {{ nodes: Array<{ id: string, x: number, y: number, width: number, height: number, item: object }> }} layout
* @param {Record<string, { x: number, y: number }>} manualPositions
*/
export function applyManualGatePositions(layout, manualPositions) {
if (!layout?.nodes?.length || !manualPositions) return layout
const nodes = layout.nodes.map((node) => {
const manual = manualPositions[node.id]
if (!manual) return node
return { ...node, x: manual.x, y: manual.y }
})
const nodeById = new Map(nodes.map((node) => [node.id, node]))
const edges = (layout.edges || []).map((edge) => {
const sourceNode =
edge.dependency_type === 'requires'
? nodeById.get(edge.toId || edge.from_item_id)
: nodeById.get(edge.fromId || edge.from_item_id)
const targetNode =
edge.dependency_type === 'requires'
? nodeById.get(edge.fromId || edge.to_item_id)
: nodeById.get(edge.toId || edge.to_item_id)
if (!sourceNode || !targetNode) return edge
const center = (node) => ({
x: node.x + node.width / 2,
y: node.y + node.height / 2,
})
if (edge.dependency_type === 'related') {
const from = center(sourceNode)
const to = center(targetNode)
return { ...edge, x1: from.x, y1: from.y, x2: to.x, y2: to.y }
}
return {
...edge,
x1: sourceNode.x + sourceNode.width / 2,
y1: sourceNode.y + sourceNode.height,
x2: targetNode.x + targetNode.width / 2,
y2: targetNode.y,
}
})
const width = Math.max(...nodes.map((node) => node.x + node.width), 0) + 32
const height = Math.max(...nodes.map((node) => node.y + node.height), 0) + 32
return { ...layout, nodes, edges, width, height }
}
@@ -0,0 +1,28 @@
import { describe, expect, it } from 'vitest'
import {
applyManualGatePositions,
clampDesignerZoom,
} from './gateGraphDesigner.js'
describe('gateGraphDesigner', () => {
it('clamps zoom range', () => {
expect(clampDesignerZoom(0.1)).toBe(0.5)
expect(clampDesignerZoom(3)).toBe(2)
expect(clampDesignerZoom(1)).toBe(1)
})
it('applies manual node positions', () => {
const layout = {
nodes: [
{ id: 'a', x: 10, y: 20, width: 100, height: 72, item: {} },
{ id: 'b', x: 200, y: 20, width: 100, height: 72, item: {} },
],
edges: [],
width: 400,
height: 200,
}
const merged = applyManualGatePositions(layout, { a: { x: 50, y: 80 } })
expect(merged.nodes.find((n) => n.id === 'a').x).toBe(50)
expect(merged.nodes.find((n) => n.id === 'b').x).toBe(200)
})
})
+3 -3
View File
@@ -171,12 +171,12 @@ export function computeGateGraphLayout(items, dependencies) {
/**
* @param {string} initiativeId
* @param {number} itemCount
* @returns {'list' | 'graph'}
* @returns {'list' | 'graph' | 'designer'}
*/
export function resolveGatesViewMode(initiativeId, itemCount) {
if (typeof window !== 'undefined' && initiativeId) {
const stored = window.localStorage.getItem(`kairo.plan.gates.view:${initiativeId}`)
if (stored === 'list' || stored === 'graph') {
if (stored === 'list' || stored === 'graph' || stored === 'designer') {
return stored
}
}
@@ -185,7 +185,7 @@ export function resolveGatesViewMode(initiativeId, itemCount) {
/**
* @param {string} initiativeId
* @param {'list' | 'graph'} mode
* @param {'list' | 'graph' | 'designer'} mode
*/
export function storeGatesViewMode(initiativeId, mode) {
if (typeof window !== 'undefined' && initiativeId) {