AP2.3c: Slice-bewusstes Laden und hoisted InitiativeOperationsProvider.
Test Suite / pytest-backend (push) Waiting to run
Test Suite / lint-backend (push) Waiting to run
Test Suite / compose-smoke (push) Waiting to run
Test Suite / k6 /api/health Baseline (push) Blocked by required conditions
Test Suite / playwright-smoke (push) Blocked by required conditions
Deploy Development / deploy (push) Has been cancelled

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-07-25 10:26:56 +02:00
1 parent 90934453e6
commit 1b55d8558c
6 files changed
+308 -140

No files matched your search

+36 -73
View File
@@ -1,10 +1,9 @@
import { NavLink, useLocation } from 'react-router-dom'
import { useEffect, useMemo, useState } from 'react'
import { listInitiativeProjects } from '../api/projects.js'
import { listInitiativeActions } from '../api/initiatives.js'
import { listInitiativeBacklog } from '../api/backlog.js'
import { getInitiativeExecutionGraphState } from '../api/executionPlan.js'
import { useProgramScope } from '../context/ProgramScopeContext.jsx'
import { useOptionalInitiativeOperations } from '../context/InitiativeOperationsContext.jsx'
import { useMethodUiContext } from '../hooks/useMethodUiContext.js'
import { buildProjectsByParent } from '../utils/projectTree.js'
import { projectPath } from '../utils/routes.js'
import {
@@ -12,9 +11,7 @@ import {
resolvePlanOutlineProjectId,
resolvePlanOutlineActionId,
} from '../plan/planOutlineNodes.js'
import { resolvePlanOutlineNodes } from '../config/methodUiDefaults.js'
import { getInitiative } from '../api/initiatives.js'
import { getActiveWorkCycle } from '../api/workCycles.js'
import { resolvePlanOutlineNodesFromProfile } from '../registry/resolveOperatingProfile.js'
import { PlanOutlineWorkTree } from './PlanOutlineWorkTree.jsx'
function PlanOutlineProjectTree({ projects, parentId, activeProjectId, depth = 0 }) {
@@ -55,15 +52,12 @@ function PlanOutlineProjectTree({ projects, parentId, activeProjectId, depth = 0
export function PlanOutlineNav() {
const location = useLocation()
const { initiativeId, initiativeTitle, hrefWithScope } = useProgramScope()
const { operatingContext, hasActiveSprint } = useMethodUiContext()
const ops = useOptionalInitiativeOperations()
const activeKey = resolvePlanOutlineActiveKey(location.pathname)
const activeProjectId = resolvePlanOutlineProjectId(location.pathname)
const activeActionId = resolvePlanOutlineActionId(location.pathname)
const [counts, setCounts] = useState({ inbox: null, work: null })
const [projects, setProjects] = useState([])
const [openActions, setOpenActions] = useState([])
const [executionGraph, setExecutionGraph] = useState(null)
const [archetypeKey, setArchetypeKey] = useState(null)
const [hasActiveSprint, setHasActiveSprint] = useState(false)
const [structureOpen, setStructureOpen] = useState(
activeKey === 'structure' || Boolean(activeProjectId),
)
@@ -71,6 +65,29 @@ export function PlanOutlineNav() {
activeKey === 'work' || Boolean(activeActionId),
)
const contextReady = Boolean(initiativeId && ops?.initiativeId === initiativeId)
const projects = contextReady ? ops.projects : []
const backlogItems = contextReady ? ops.backlogItems : []
const actions = contextReady ? ops.actions : []
const openActions = useMemo(
() =>
actions.filter(
(action) => action.status !== 'done' && action.status !== 'discarded',
),
[actions],
)
const counts = useMemo(
() => ({
inbox: contextReady
? backlogItems.filter((item) => item.status !== 'converted').length
: null,
work: contextReady ? openActions.length : null,
}),
[contextReady, backlogItems, openActions],
)
useEffect(() => {
setStructureOpen(activeKey === 'structure' || Boolean(activeProjectId))
}, [activeKey, activeProjectId])
@@ -79,85 +96,31 @@ export function PlanOutlineNav() {
setWorkOpen(activeKey === 'work' || Boolean(activeActionId))
}, [activeKey, activeActionId])
useEffect(() => {
if (!initiativeId) {
setArchetypeKey(null)
setHasActiveSprint(false)
return undefined
}
let cancelled = false
Promise.all([
getInitiative(initiativeId),
getActiveWorkCycle(initiativeId).catch(() => null),
])
.then(([initiative, activeCycle]) => {
if (cancelled) return
setArchetypeKey(initiative?.archetype_key || null)
setHasActiveSprint(Boolean(activeCycle?.id))
})
.catch(() => {
if (!cancelled) {
setArchetypeKey(null)
setHasActiveSprint(false)
}
})
return () => {
cancelled = true
}
}, [initiativeId])
const outlineNodes = useMemo(
() =>
resolvePlanOutlineNodes({
archetypeKey,
resolvePlanOutlineNodesFromProfile({
operatingContext,
hasActiveSprint,
}),
[archetypeKey, hasActiveSprint],
[operatingContext, hasActiveSprint],
)
useEffect(() => {
if (!initiativeId) {
setProjects([])
setExecutionGraph(null)
return undefined
}
let cancelled = false
listInitiativeProjects(initiativeId)
.then((items) => {
if (!cancelled) setProjects(Array.isArray(items) ? items : [])
getInitiativeExecutionGraphState(initiativeId)
.then((graphState) => {
if (!cancelled) setExecutionGraph(graphState)
})
.catch(() => {
if (!cancelled) setProjects([])
if (!cancelled) setExecutionGraph(null)
})
return () => {
cancelled = true
}
}, [initiativeId])
useEffect(() => {
if (!initiativeId) {
setCounts({ inbox: null, work: null })
return undefined
}
let cancelled = false
Promise.all([
listInitiativeBacklog(initiativeId).catch(() => []),
listInitiativeActions(initiativeId).catch(() => []),
getInitiativeExecutionGraphState(initiativeId).catch(() => null),
]).then(([backlog, actions, graphState]) => {
if (cancelled) return
const open = actions.filter(
(action) => action.status !== 'done' && action.status !== 'discarded',
)
setOpenActions(open)
setExecutionGraph(graphState)
setCounts({
inbox: backlog.filter((item) => item.status !== 'converted').length,
work: open.length,
})
})
return () => {
cancelled = true
}
}, [initiativeId, location.pathname])
function nodeLabel(node) {