import { useReducer } from "react"; import type { ReactNode } from "react"; import { projectPreparedLifecycleStep, type PreparedLifecycleStepId, } from "./authoring-projection.js"; import { AuthoringPhaseVisual } from "./AuthoringPhaseVisual.js"; import { PresentationAssistantPane } from "./PresentationAssistantPane.js"; import { initialPreparedLifecycleMessageState, projectPreparedLifecycleMessage, projectPreparedLifecycleSubmittedOverrides, preparedLifecycleMessageReducer, } from "./prepared-lifecycle-message-state.js"; import type { SceneBeatDefinition, SceneDefinition } from "../storyboard.js"; type PreparedAuthoringLifecycleSceneProps = { readonly scene: SceneDefinition; readonly beat: SceneBeatDefinition; readonly onAdvance?: (() => void) | undefined; readonly onRunPreparedWorkflow?: (() => Promise) | undefined; readonly discussionRail?: ReactNode; }; const steps = [ { id: "discover", label: "Discover", detail: "Sources, capabilities, schemas" }, { id: "draft", label: "Author", detail: "Create and edit mutable Draft" }, { id: "diagnose", label: "Diagnose", detail: "Structured validation result" }, { id: "repair", label: "Repair", detail: "Focused route edit" }, { id: "artifact", label: "Artifact", detail: "Immutable versioned definition" }, { id: "deployment", label: "Deployment", detail: "Bind and validate sources" }, ] as const satisfies readonly { readonly id: PreparedLifecycleStepId; readonly label: string; readonly detail: string; }[]; /** * Prepared workflow authoring lifecycle. * * Each beat shows a persistent prepared assistant beside one dominant phase * projection sourced from the prepared authoring recording. */ export const PreparedAuthoringLifecycleScene = ({ scene, beat, onAdvance, onRunPreparedWorkflow, discussionRail }: PreparedAuthoringLifecycleSceneProps) => { const [messageState, dispatch] = useReducer( preparedLifecycleMessageReducer, initialPreparedLifecycleMessageState, ); // Storyboard beats normally match these IDs. Discovery is a safe projection // if a future beat reaches this scene before its authoring mapping is added. const activeStep = steps.find((candidate) => candidate.id === beat.id) ?? steps[0]!; const step = activeStep.id; const projection = projectPreparedLifecycleStep(step); const activeStepIndex = steps.findIndex((candidate) => candidate.id === step); return (
dispatch({ type: "draft_edited", draft })} onSubmit={(submittedText) => { dispatch({ type: "draft_edited", draft: submittedText }); if (step === "discover") { dispatch({ type: "discover_submitted" }); } if (step === "draft") { dispatch({ type: "draft_submitted" }); onAdvance?.(); } if (step === "artifact") { dispatch({ type: "artifact_submitted" }); onAdvance?.(); } if (step === "deployment") { dispatch({ type: "run_requested" }); // This is the same mode-aware action as the footer control; the // presentation remains on this beat so the presenter advances it. void onRunPreparedWorkflow?.(); } }} />
    {steps.map((candidate, index) => (
  1. {candidate.label} {candidate.detail}
  2. ))}
{scene.title} {activeStep.label}

{beat.title}

{beat.caption}

Method
{projection.primaryCommand.title}
Equivalent CLI
{projection.primaryCommand.command}
{projection.evidence.kind === "diagnostic" && ( )}
{discussionRail && (
{discussionRail}
)}
); };