feat: recompose lifecycle scene

This commit is contained in:
lda
2026-07-08 16:38:09 +07:00 Verified
parent 826f9ea33f
commit 33f34c4f96
3 changed files with 174 additions and 56 deletions
@@ -168,6 +168,63 @@ describe("SceneBody", () => {
expect(withinBoundary.getByText(/JSON-RPC/)).toBeInTheDocument(); expect(withinBoundary.getByText(/JSON-RPC/)).toBeInTheDocument();
}); });
it("renders Scene 5 as a full workflow lifecycle rail", () => {
const location: PresentationLocation = { kind: "main", sceneId: "lifecycle", beatId: "deployment", focusPath: [] };
render(
<SceneBody
location={location}
demo={demo}
selectedNodeId={null}
selectNode={noop}
openEvidence={noop}
openDiscussion={noop}
onFocusPathChange={noop}
motionDisabled={false}
/>,
);
const rail = screen.getByLabelText("workflow lifecycle rail");
expect(rail).toHaveAttribute("data-lifecycle-active-stage", "deployment");
const withinRail = within(rail);
expect(withinRail.getByText("Draft")).toBeInTheDocument();
expect(withinRail.getByText("Artifact")).toBeInTheDocument();
expect(withinRail.getByText("Deployment")).toBeInTheDocument();
expect(withinRail.getByText("Run")).toBeInTheDocument();
expect(withinRail.getByText("Source binding")).toBeInTheDocument();
});
it("updates the lifecycle explanation with the active beat", () => {
const { rerender } = render(
<SceneBody
location={{ kind: "main", sceneId: "lifecycle", beatId: "draft", focusPath: [] }}
demo={demo}
selectedNodeId={null}
selectNode={noop}
openEvidence={noop}
openDiscussion={noop}
onFocusPathChange={noop}
motionDisabled={false}
/>,
);
expect(screen.getByLabelText("current lifecycle state")).toHaveTextContent("Mutable authoring state");
rerender(
<SceneBody
location={{ kind: "main", sceneId: "lifecycle", beatId: "run", focusPath: [] }}
demo={demo}
selectedNodeId={null}
selectNode={noop}
openEvidence={noop}
openDiscussion={noop}
onFocusPathChange={noop}
motionDisabled={false}
/>,
);
expect(screen.getByLabelText("current lifecycle state")).toHaveTextContent("Execution record and trace");
});
it("marks the planner side active on the planner beat", () => { it("marks the planner side active on the planner beat", () => {
const location: PresentationLocation = { kind: "main", sceneId: "planner-runtime", beatId: "planner", focusPath: [] }; const location: PresentationLocation = { kind: "main", sceneId: "planner-runtime", beatId: "planner", focusPath: [] };
render( render(
+37 -25
View File
@@ -166,32 +166,44 @@ const BoundaryScene = ({ scene, beat }: { scene: SceneDefinition; beat: SceneBea
}; };
const lifecycleStages = [ const lifecycleStages = [
{ id: "draft", label: "Draft" }, { id: "draft", label: "Draft", role: "Mutable authoring state", detail: "Iterate before freezing a workflow definition." },
{ id: "artifact", label: "Artifact" }, { id: "artifact", label: "Artifact", role: "Immutable workflow definition", detail: "Save a versioned plan that can be deployed." },
{ id: "deployment", label: "Deployment" }, { id: "deployment", label: "Deployment", role: "Source binding", detail: "Bind workflow requirements to configured runtime sources." },
{ id: "run", label: "Run" }, { id: "run", label: "Run", role: "Execution record and trace", detail: "Persist status, outputs, interrupts, and trace evidence." },
]; ] as const;
const LifecycleScene = ({ scene, beat }: { scene: SceneDefinition; beat: SceneBeatDefinition }) => ( const LifecycleScene = ({ scene, beat }: { scene: SceneDefinition; beat: SceneBeatDefinition }) => {
<> const activeIndex = Math.max(0, lifecycleStages.findIndex((stage) => stage.id === beat.id));
<StageCaption eyebrow="Act II · implemented" title={scene.title}> const activeStage = lifecycleStages[activeIndex] ?? lifecycleStages[0];
<p>{beat.caption}</p> return (
</StageCaption> <>
<div className="scene-body__lifecycle"> <StageCaption eyebrow="Act II · implemented" title={scene.title}>
{lifecycleStages.map((stage, i) => ( <p>{beat.caption}</p>
<div </StageCaption>
key={stage.id} <div className="scene-body__lifecycle" aria-label="workflow lifecycle rail" data-lifecycle-active-stage={activeStage.id}>
className={`scene-body__lifecycle-stage${beat.id === stage.id ? " scene-body__lifecycle-stage--active" : ""}`} {lifecycleStages.map((stage, i) => (
> <article
<span className="scene-body__lifecycle-number">{i + 1}</span> key={stage.id}
<strong>{stage.label}</strong> className="scene-body__lifecycle-stage"
{i < lifecycleStages.length - 1 && <span className="scene-body__lifecycle-arrow"></span>} data-lifecycle-active={i === activeIndex ? "true" : "false"}
</div> data-lifecycle-complete={i < activeIndex ? "true" : "false"}
))} >
</div> <span className="scene-body__lifecycle-number">{i + 1}</span>
<p className="scene-body__evidence">{scene.evidencePointer}</p> <strong>{stage.label}</strong>
</> <small>{stage.role}</small>
); {i < lifecycleStages.length - 1 && <span className="scene-body__lifecycle-arrow"></span>}
</article>
))}
</div>
<aside className="scene-body__lifecycle-current" aria-label="current lifecycle state">
<span>{activeStage.label}</span>
<strong>{activeStage.role}</strong>
<p>{activeStage.detail}</p>
</aside>
<p className="scene-body__evidence">{scene.evidencePointer}</p>
</>
);
};
const authoringSteps = [ const authoringSteps = [
{ id: "discover", label: "Discover capability", detail: "wf schema / cap inspect" }, { id: "discover", label: "Discover capability", detail: "wf schema / cap inspect" },
@@ -827,22 +827,45 @@
} }
.scene-body__lifecycle { .scene-body__lifecycle {
display: flex; display: grid;
align-items: center; grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 0.35rem; gap: 0.65rem;
margin-top: 0.75rem; align-items: stretch;
flex-wrap: wrap; margin-top: 1.2rem;
} }
.scene-body__lifecycle-stage { .scene-body__lifecycle-stage {
display: flex; position: relative;
align-items: center; display: grid;
gap: 0.35rem; align-content: start;
padding: 0.5rem 0.75rem; gap: 0.5rem;
border: 1px solid oklch(0.36 0.04 250); min-height: 9rem;
background: oklch(0.16 0.025 250); border: 1px solid color-mix(in oklch, var(--color-editorial-muted, oklch(0.48 0.025 65)) 32%, transparent);
border-radius: 0.5rem; border-radius: 0.9rem;
font-size: 0.85rem; padding: 0.9rem;
background: color-mix(in oklch, var(--color-editorial-paper, oklch(0.975 0.012 82)) 82%, white);
color: var(--color-editorial-ink, oklch(0.19 0.015 65));
}
.scene-body__lifecycle-stage[data-lifecycle-active="false"] {
opacity: 0.68;
}
.scene-body__lifecycle-stage[data-lifecycle-active="true"] {
opacity: 1;
transform: translateY(-0.25rem);
border-color: color-mix(in oklch, var(--accent-cyan, oklch(0.7 0.16 195)) 58%, transparent);
background: color-mix(in oklch, var(--accent-cyan, oklch(0.7 0.16 195)) 8%, var(--color-editorial-paper, oklch(0.975 0.012 82)));
}
.scene-body__lifecycle-stage strong {
color: var(--color-editorial-ink, oklch(0.19 0.015 65));
font-size: 1.2rem;
}
.scene-body__lifecycle-stage small {
color: color-mix(in oklch, var(--color-editorial-ink, oklch(0.19 0.015 65)) 72%, var(--color-editorial-muted, oklch(0.48 0.025 65)));
line-height: 1.3;
} }
.scene-body__authoring-loop { .scene-body__authoring-loop {
@@ -908,7 +931,18 @@
} }
} }
.scene-body__lifecycle-number, .scene-body__lifecycle-number {
display: inline-flex;
align-items: center;
justify-content: center;
width: 1.5rem;
height: 1.5rem;
border-radius: 50%;
background: color-mix(in oklch, var(--accent-cyan, oklch(0.7 0.16 195)) 74%, white);
color: var(--color-editorial-ink, oklch(0.19 0.015 65));
font: 800 0.72rem/1 var(--font-mono, monospace);
}
.scene-body__authoring-number { .scene-body__authoring-number {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@@ -923,8 +957,38 @@
} }
.scene-body__lifecycle-arrow { .scene-body__lifecycle-arrow {
color: oklch(0.5 0.06 250); position: absolute;
font-size: 1.1rem; right: -0.55rem;
top: 50%;
color: var(--color-editorial-muted, oklch(0.48 0.025 65));
transform: translateY(-50%);
}
.scene-body__lifecycle-current {
display: grid;
gap: 0.3rem;
margin-top: 0.9rem;
border: 1px solid color-mix(in oklch, var(--color-editorial-muted, oklch(0.48 0.025 65)) 28%, transparent);
border-radius: 0.85rem;
padding: 0.8rem 0.9rem;
background: color-mix(in oklch, var(--color-editorial-paper, oklch(0.975 0.012 82)) 86%, white);
color: var(--color-editorial-ink, oklch(0.19 0.015 65));
}
.scene-body__lifecycle-current span {
color: var(--color-editorial-muted, oklch(0.48 0.025 65));
font: 700 0.66rem/1 var(--font-mono, monospace);
letter-spacing: 0.08em;
text-transform: uppercase;
}
.scene-body__lifecycle-current strong,
.scene-body__lifecycle-current p {
margin: 0;
}
.scene-body__lifecycle-current p {
color: color-mix(in oklch, var(--color-editorial-ink, oklch(0.19 0.015 65)) 76%, var(--color-editorial-muted, oklch(0.48 0.025 65)));
} }
.scene-body__architecture { .scene-body__architecture {
@@ -985,21 +1049,6 @@
} }
/* Beat-driven active states */ /* Beat-driven active states */
.scene-body__lifecycle-stage {
transition: opacity 0.3s ease, transform 0.25s ease, border-color 0.2s ease, background 0.2s ease;
}
.scene-body__lifecycle-stage:not(.scene-body__lifecycle-stage--active) {
opacity: 0.4;
transform: scale(0.96);
}
.scene-body__lifecycle-stage--active {
border-color: oklch(0.7 0.16 195);
background: oklch(0.2 0.06 195);
transform: scale(1.03);
}
.scene-body__architecture-layer { .scene-body__architecture-layer {
transition: opacity 0.3s ease, transform 0.25s ease, border-color 0.2s ease, background 0.2s ease; transition: opacity 0.3s ease, transform 0.25s ease, border-color 0.2s ease, background 0.2s ease;
} }