fix: expose live run action in agent handoff scene

This commit is contained in:
lda
2026-07-11 22:18:47 +07:00 Verified
parent 4e81950bec
commit 31fb170dba
6 changed files with 53 additions and 8 deletions
@@ -1,5 +1,6 @@
import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it } from "vitest";
import { afterEach, describe, expect, it, vi } from "vitest";
import type { TimelineAgentController } from "../../demo/agent/timelineAgent.js";
import { findBeat, findScene } from "../storyboard.js";
import { AgentHandoffScene } from "./AgentHandoffScene.js";
@@ -68,4 +69,29 @@ describe("AgentHandoffScene", () => {
renderBeat("handoff");
expect(screen.queryByText("prepared workflow lifecycle")).not.toBeInTheDocument();
});
it("exposes the live prepared-workflow action inside the visible conversation", () => {
const runPreparedWorkflow = vi.fn();
const timelineAgent = {
messages: [],
canRun: true,
runLabel: "Run prepared workflow",
runPreparedWorkflow,
submitSelectedIssues: vi.fn(async () => {}),
cancelReview: vi.fn(async () => {}),
} as unknown as TimelineAgentController;
render(
<AgentHandoffScene
scene={findScene("agent-handoff")!}
beat={findBeat("agent-handoff", "request")!}
timelineAgent={timelineAgent}
/>,
);
const action = screen.getByRole("button", { name: "Run prepared workflow" });
expect(action).toBeEnabled();
action.click();
expect(runPreparedWorkflow).toHaveBeenCalledOnce();
});
});
@@ -1,10 +1,12 @@
import { AuthoringConversation } from "./AuthoringConversation.js";
import type { AuthoringPhaseId } from "./authoring-recording.js";
import type { TimelineAgentController } from "../../demo/agent/timelineAgent.js";
import type { SceneBeatDefinition, SceneDefinition } from "../storyboard.js";
type AgentHandoffSceneProps = {
readonly scene: SceneDefinition;
readonly beat: SceneBeatDefinition;
readonly timelineAgent?: TimelineAgentController | undefined;
};
/**
@@ -12,10 +14,10 @@ type AgentHandoffSceneProps = {
*
* The request beat shows the operator asking the agent to prepare a report;
* the handoff beat reveals the full completed conversation with all phases.
* Neither run actions nor approval actions are passed because this is a
* prepared recording, not a live agent interaction.
* The conversation is a prepared recording, but the shared run action can
* start the configured live workflow when a target is available.
*/
export const AgentHandoffScene = ({ beat }: AgentHandoffSceneProps) => {
export const AgentHandoffScene = ({ beat, timelineAgent }: AgentHandoffSceneProps) => {
const phase: AuthoringPhaseId = beat.id === "handoff" ? "deployment" : "discover";
const phases: readonly { readonly id: AuthoringPhaseId; readonly label: string }[] = [
{ id: "discover", label: "Discover" },
@@ -46,6 +48,11 @@ export const AgentHandoffScene = ({ beat }: AgentHandoffSceneProps) => {
throughPhase={phase}
activePhase={phase}
surface="stage"
runAction={timelineAgent ? {
label: timelineAgent.runLabel,
disabled: !timelineAgent.canRun,
run: () => { void timelineAgent.runPreparedWorkflow(); },
} : undefined}
/>
</div>
</section>
@@ -9,6 +9,7 @@ type AuthoringConversationProps = {
readonly throughPhase: AuthoringPhaseId;
readonly activePhase: AuthoringPhaseId;
readonly surface: "stage" | "dock";
readonly runAction?: { readonly label: string; readonly disabled: boolean; readonly run: () => void } | undefined;
};
/** Renders the same prepared conversation at full-stage or compact-dock scale. */
@@ -16,6 +17,7 @@ export const AuthoringConversation = ({
throughPhase,
activePhase,
surface,
runAction,
}: AuthoringConversationProps) => (
<AssistantOperatorThread
mode={surface === "stage" ? "full" : "dock"}
@@ -23,5 +25,6 @@ export const AuthoringConversation = ({
messages={projectPreparedAuthoringThread(throughPhase)}
activeToolGroupId={authoringToolGroupId(activePhase)}
ariaLabel="prepared authoring conversation"
runAction={runAction}
/>
);