* ST-1243: F1 schema + propagateStatusUpwards-helper voor sprint-flow Schema-uitbreidingen voor de sprint-niveau jobflow (PBI-46): - TaskStatus, StoryStatus, PbiStatus, SprintStatus krijgen FAILED - Nieuwe enums: SprintRunStatus, PrStrategy - Nieuw SprintRun-model dat per-task ClaudeJobs groepeert - ClaudeJob.sprint_run_id koppeling + index - Product.pr_strategy (default SPRINT) - Bijhorende Prisma-migratie propagateStatusUpwards vervangt updateTaskStatusWithStoryPromotion en herevalueert de keten Task → Story → PBI → Sprint → SprintRun bij elke task-statuswijziging. Bij FAILED cancelt het sibling-jobs in dezelfde SprintRun. PBI-status BLOCKED blijft handmatig en wordt niet overschreven. Status-mappers + theme krijgen failed-token + label-uitbreidingen. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ST-1244: F2 sprint-runs actions + deprecate per-task enqueues actions/sprint-runs.ts (nieuw): - startSprintRunAction met pre-flight (impl_plan / open ClaudeQuestion / PBI BLOCKED|FAILED) - Maakt SprintRun + ClaudeJobs in PBI→Story→Task volgorde - resumeSprintAction zet FAILED tasks/stories/PBIs terug en start nieuwe SprintRun - cancelSprintRunAction breekt lopende SprintRun af zonder cascade actions/claude-jobs.ts: - enqueueClaudeJobAction, enqueueAllTodoJobsAction, previewEnqueueAllAction, enqueueClaudeJobsBatchAction nu deprecation-stubs (UI-cleanup volgt in F4) - cancelClaudeJobAction blijft beschikbaar voor losse jobs Tests bijgewerkt: 11 nieuwe sprint-runs tests, claude-jobs(-batch) tests herzien naar deprecation-asserties. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ST-1246: F4 UI Start/Resume/Cancel sprint + pr_strategy dropdown - components/sprint/sprint-run-controls.tsx: knoppen Start Sprint (sprintStatus=ACTIVE), Hervat sprint (sprintStatus=FAILED) en Annuleer sprint-run (lopende run). Pre-flight blocker-modal toont blockers met directe links naar de relevante pagina's. - components/products/pr-strategy-select.tsx: dropdown SPRINT|STORY in product-settings, met optimistic update + sonner-toast op fail. - actions/products.ts: updatePrStrategyAction (eigenaar-only, demo-block). - Sprint-page: query op actieve SprintRun + tonen van controls-balk. Live cascade-visualisatie (T-634) staat als follow-up genoteerd — huidige sprint-board statusbadges volstaan voor MVP. De Solo-board "Voer uit"-knoppen zijn niet expliciet verwijderd; ze tonen nu de deprecation-error van de gestubde actions tot de Solo-flow opnieuw ontworpen wordt. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
113 lines
3.3 KiB
TypeScript
113 lines
3.3 KiB
TypeScript
'use server'
|
|
|
|
import { revalidatePath } from 'next/cache'
|
|
import { prisma } from '@/lib/prisma'
|
|
import { getSession } from '@/lib/auth'
|
|
import { productAccessFilter } from '@/lib/product-access'
|
|
import { ACTIVE_JOB_STATUSES, jobStatusToApi } from '@/lib/job-status'
|
|
import { enforceUserRateLimit } from '@/lib/rate-limit'
|
|
|
|
type EnqueueResult =
|
|
| { success: true; jobId: string }
|
|
| { error: string; jobId?: string }
|
|
|
|
type EnqueueAllResult =
|
|
| { success: true; count: number }
|
|
| { error: string }
|
|
|
|
type CancelResult = { success: true } | { error: string }
|
|
|
|
export type PreviewTask = {
|
|
id: string
|
|
title: string
|
|
status: string
|
|
story_title: string
|
|
pbi_id: string
|
|
pbi_status: string
|
|
}
|
|
|
|
type PreflightResult =
|
|
| { error: string }
|
|
| { tasks: PreviewTask[]; blockerIndex: number | null; blockerReason: 'task-review' | 'pbi-blocked' | null }
|
|
|
|
/**
|
|
* @deprecated Vervangen door startSprintRunAction in actions/sprint-runs.ts.
|
|
* Per-task starts zijn niet meer toegestaan — een sprint draait nu als geheel.
|
|
* Wordt verwijderd zodra de UI is omgebouwd (F4).
|
|
*/
|
|
export async function enqueueClaudeJobAction(_taskId: string): Promise<EnqueueResult> {
|
|
return {
|
|
error:
|
|
'Per-task starten is niet meer mogelijk. Gebruik "Start Sprint" voor de hele actieve sprint.',
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @deprecated Vervangen door startSprintRunAction in actions/sprint-runs.ts.
|
|
*/
|
|
export async function enqueueAllTodoJobsAction(_productId: string): Promise<EnqueueAllResult> {
|
|
return {
|
|
error:
|
|
'"Alle TO_DO als jobs queueen" is vervangen door "Start Sprint". Gebruik startSprintRunAction.',
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @deprecated Vervangen door pre-flight in startSprintRunAction (actions/sprint-runs.ts).
|
|
*/
|
|
export async function previewEnqueueAllAction(_productId: string): Promise<PreflightResult> {
|
|
return {
|
|
error:
|
|
'Per-product preview is vervangen door de pre-flight check in startSprintRunAction.',
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @deprecated Vervangen door startSprintRunAction in actions/sprint-runs.ts.
|
|
*/
|
|
export async function enqueueClaudeJobsBatchAction(
|
|
_productId: string,
|
|
_taskIds: string[]
|
|
): Promise<EnqueueAllResult> {
|
|
return {
|
|
error:
|
|
'Batch-queue per task is vervangen door "Start Sprint". Gebruik startSprintRunAction.',
|
|
}
|
|
}
|
|
|
|
export async function cancelClaudeJobAction(jobId: string): Promise<CancelResult> {
|
|
const session = await getSession()
|
|
if (!session.userId) return { error: 'Niet ingelogd' }
|
|
if (session.isDemo) return { error: 'Niet beschikbaar in demo-modus' }
|
|
|
|
if (!jobId) return { error: 'job_id is verplicht' }
|
|
|
|
const job = await prisma.claudeJob.findFirst({
|
|
where: { id: jobId, user_id: session.userId },
|
|
select: { id: true, status: true, task_id: true, product_id: true },
|
|
})
|
|
if (!job) return { error: 'Job niet gevonden' }
|
|
|
|
if (!ACTIVE_JOB_STATUSES.includes(job.status)) {
|
|
return { error: 'Alleen actieve jobs kunnen geannuleerd worden' }
|
|
}
|
|
|
|
await prisma.claudeJob.update({
|
|
where: { id: jobId },
|
|
data: { status: 'CANCELLED', finished_at: new Date() },
|
|
})
|
|
|
|
await prisma.$executeRaw`
|
|
SELECT pg_notify('scrum4me_changes', ${JSON.stringify({
|
|
type: 'claude_job_status',
|
|
job_id: jobId,
|
|
task_id: job.task_id,
|
|
user_id: session.userId,
|
|
product_id: job.product_id,
|
|
status: jobStatusToApi('CANCELLED'),
|
|
})}::text)
|
|
`
|
|
|
|
revalidatePath(`/products/${job.product_id}/solo`)
|
|
return { success: true }
|
|
}
|