* fix(ST-1272): allow PLAN_READY → GRILLING re-grill transition
actions/ideas.ts already lists PLAN_READY in GRILL_TRIGGERABLE_FROM,
but lib/idea-status.ts ALLOWED_TRANSITIONS was missing the
PLAN_READY → GRILLING edge. As a result, clicking Grill on a PLAN_READY
idea returned 422 "Status-transitie ongeldig" while the UI button was
enabled. Mirrors the existing PLANNED → GRILLING re-grill behaviour.
- lib/idea-status.ts: PLAN_READY allows GRILLING in addition to
PLANNING/PLANNED
- __tests__/lib/idea-status.test.ts: explicit assert for
PLAN_READY → GRILLING and PLAN_READY added to the regrill loop
covering every GRILL_TRIGGERABLE_FROM status
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(ST-1275): render SKIPPED job status in chart-colors and insights
Closing the gap left when ClaudeJobStatus.SKIPPED was added to the schema:
the badge map and case-mapper already covered it, but the chart palette,
the per-day insights aggregator and the stacked-bar chart did not. SKIPPED
jobs (e.g. cmovkur8 manually flipped during the no-op-exit hotfix) now
render with a muted style consistent with cancelled.
- lib/chart-colors.ts: JOB_STATUS_COLORS gains a 'skipped' entry
(var(--muted-foreground), same intensity as cancelled — neither rood/orange)
- lib/insights/agent-throughput.ts: DayCount + STATUSES + perDay zero-fill
now include 'skipped'; the SQL terminal_7d filter already counted SKIPPED
- app/(app)/insights/components/agent-throughput.tsx: STACKED_STATUSES and
the empty-state guard include 'skipped'
- __tests__: chart-colors keys list, job-status round-trip ('all 7 statuses')
and the insights non-zero filter all account for SKIPPED
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
85 lines
2.8 KiB
TypeScript
85 lines
2.8 KiB
TypeScript
// Bidirectionele case-mapper voor IdeaStatus + transitie-guard helper.
|
|
// DB houdt UPPER_SNAKE; API exposeert lowercase.
|
|
// Patroon volgt lib/task-status.ts.
|
|
|
|
import type { IdeaStatus } from '@prisma/client'
|
|
|
|
const IDEA_DB_TO_API = {
|
|
DRAFT: 'draft',
|
|
GRILLING: 'grilling',
|
|
GRILL_FAILED: 'grill_failed',
|
|
GRILLED: 'grilled',
|
|
PLANNING: 'planning',
|
|
PLAN_FAILED: 'plan_failed',
|
|
PLAN_READY: 'plan_ready',
|
|
PLANNED: 'planned',
|
|
} as const satisfies Record<IdeaStatus, string>
|
|
|
|
const IDEA_API_TO_DB: Record<string, IdeaStatus> = {
|
|
draft: 'DRAFT',
|
|
grilling: 'GRILLING',
|
|
grill_failed: 'GRILL_FAILED',
|
|
grilled: 'GRILLED',
|
|
planning: 'PLANNING',
|
|
plan_failed: 'PLAN_FAILED',
|
|
plan_ready: 'PLAN_READY',
|
|
planned: 'PLANNED',
|
|
}
|
|
|
|
export type IdeaStatusApi = (typeof IDEA_DB_TO_API)[IdeaStatus]
|
|
|
|
export function ideaStatusToApi(s: IdeaStatus): IdeaStatusApi {
|
|
return IDEA_DB_TO_API[s]
|
|
}
|
|
|
|
export function ideaStatusFromApi(s: string): IdeaStatus | null {
|
|
return IDEA_API_TO_DB[s.toLowerCase()] ?? null
|
|
}
|
|
|
|
export const IDEA_STATUS_API_VALUES = Object.values(IDEA_DB_TO_API)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// State-machine transition table (zie docs/plans/M12-ideas.md state-machine).
|
|
// Server-actions gebruiken canTransition(from, to) als guard vóór mutatie.
|
|
//
|
|
// Asymmetrisch: trek vanuit DRAFT alleen naar GRILLING; vanuit GRILLED kan
|
|
// re-grill (→ GRILLING) of make-plan (→ PLANNING) gebeuren. PLANNED is een
|
|
// terminal state; verlaat alleen via expliciete relink (PBI verwijderd → PLAN_READY).
|
|
|
|
const ALLOWED_TRANSITIONS: Record<IdeaStatus, ReadonlyArray<IdeaStatus>> = {
|
|
DRAFT: ['GRILLING'],
|
|
GRILLING: ['GRILLED', 'GRILL_FAILED'],
|
|
GRILL_FAILED: ['GRILLING', 'DRAFT'],
|
|
GRILLED: ['GRILLING', 'PLANNING'],
|
|
PLANNING: ['PLAN_READY', 'PLAN_FAILED'],
|
|
PLAN_FAILED: ['PLANNING', 'GRILLED'],
|
|
PLAN_READY: ['PLANNING', 'PLANNED', 'GRILLING'], // GRILLING via startGrillJobAction (re-grill)
|
|
PLANNED: ['PLAN_READY', 'GRILLING'], // PLAN_READY via relinkIdeaPlanAction; GRILLING via startGrillJobAction
|
|
}
|
|
|
|
export function canTransition(from: IdeaStatus, to: IdeaStatus): boolean {
|
|
return ALLOWED_TRANSITIONS[from].includes(to)
|
|
}
|
|
|
|
// Statussen waarin een idee bewerkbaar is (form-input, niet md-velden).
|
|
const EDITABLE_STATUSES: ReadonlyArray<IdeaStatus> = [
|
|
'DRAFT',
|
|
'GRILL_FAILED',
|
|
'GRILLED',
|
|
'PLAN_FAILED',
|
|
'PLAN_READY',
|
|
]
|
|
|
|
export function isIdeaEditable(s: IdeaStatus): boolean {
|
|
return EDITABLE_STATUSES.includes(s)
|
|
}
|
|
|
|
// Statussen waarin grill_md bewerkbaar is (handmatige finetuning).
|
|
export function isGrillMdEditable(s: IdeaStatus): boolean {
|
|
return s === 'GRILLED' || s === 'PLAN_READY'
|
|
}
|
|
|
|
// Statussen waarin plan_md bewerkbaar is.
|
|
export function isPlanMdEditable(s: IdeaStatus): boolean {
|
|
return s === 'PLAN_READY'
|
|
}
|