* feat(PBI-33): chat-kanaal UI — IdeaTimeline merge + UserChatInput
Voltooit de UI-laag van PLAN_CHAT (gebruikersvragen over plan, Claude
antwoordt async). Backend (UserQuestion model, createUserQuestionAction,
SSE-handling, server-side prop-passing) was al aanwezig — alleen de
UI-koppeling ontbrak waardoor userQuestions ongebruikt bleven.
- IdeaDetailLayout geeft userQuestions/planMd/ideaId/isDemo door aan
IdeaTimeline en telt user-questions mee in de tab-count
- IdeaTimeline mergt user-questions chronologisch met logs+questions,
rendert ze met MessageCircle-icoon en pending/answered status, en
toont onderaan UserChatInput wanneer plan_md aanwezig is
- UserChatInput nieuw component met textarea + verzend-knop dat
createUserQuestionAction aanroept en op success router.refresh()
triggert zodat SSE de pending-state oppikt
- useNotificationsRealtime: router toegevoegd aan useEffect-deps zodat
router.refresh() op user_question/idea-job events werkt zonder
stale-closure waarschuwing
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(lint): unused vars/imports + react-hook-form watch incompatibility
Resolves de overige lint-warnings van de gefaalde sprint-build die los
staan van PBI-33. Eslint-config staat unused vars/args toe als ze met
'_' prefixen, dus required interface-params krijgen een prefix terwijl
losse dode constantes/imports verwijderd worden.
- sprint-header: productId is required prop maar nog niet gebruikt
→ prefix _productId i.p.v. verwijderen (caller passeert het door)
- agent-throughput: STATUSES-constante was dood — verwijderd, queries
gebruiken hardcoded status-velden in de perDay-loop
- claude-jobs: productAccessFilter en enforceUserRateLimit waren
dode imports — verwijderd
- story-log.test: ongebruikte 'data' binding vervangen door bare
await res.json() zodat de stream nog wel geconsumeerd wordt
- product-dialog: form.watch('auto_pr') vervangen door useWatch met
control-prop — useWatch is veilig voor React Compiler memoization
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
111 lines
3.2 KiB
TypeScript
111 lines
3.2 KiB
TypeScript
'use server'
|
|
|
|
import { revalidatePath } from 'next/cache'
|
|
import { prisma } from '@/lib/prisma'
|
|
import { getSession } from '@/lib/auth'
|
|
import { ACTIVE_JOB_STATUSES, jobStatusToApi } from '@/lib/job-status'
|
|
|
|
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 }
|
|
}
|