fix: separate target health from replay playback

This commit is contained in:
lda
2026-07-12 15:06:25 +07:00 Verified
parent 35ee86bf9d
commit 8926cb9aef
6 changed files with 54 additions and 25 deletions
@@ -282,10 +282,11 @@ describe("PresentationRoute", () => {
it("uses stored target for live presentation mode", async () => {
window.sessionStorage.setItem("lda.workflowConsole.target", "http://127.0.0.1:8765/rpc");
window.location.hash = "#scene/run-from-deployment/operation";
const { PresentationRoute } = await import("./PresentationRoute.js");
render(<PresentationRoute />);
expect(await screen.findByRole("button", { name: /run prepared workflow/i })).toBeInTheDocument();
expect(await screen.findAllByRole("button", { name: /run prepared workflow/i })).toHaveLength(2);
});
it("exposes an explicit live launch on the Scene 10 operation beat", async () => {
@@ -294,7 +295,9 @@ describe("PresentationRoute", () => {
const { PresentationRoute } = await import("./PresentationRoute.js");
render(<PresentationRoute />);
const launch = await screen.findByRole("button", { name: "Run prepared workflow" });
const launches = await screen.findAllByRole("button", { name: "Run prepared workflow" });
const launch = launches.at(-1);
if (!launch) throw new Error("Expected a live workflow launch control");
await userEvent.click(launch);
await waitFor(() => {
@@ -309,7 +312,7 @@ describe("PresentationRoute", () => {
const { PresentationRoute } = await import("./PresentationRoute.js");
render(<PresentationRoute />);
expect(await screen.findByText(/Replay evidence is active/i)).toBeInTheDocument();
expect(await screen.findByText(/Live target is ready/i)).toBeInTheDocument();
expect(await screen.findByText("Workflow input")).toBeInTheDocument();
expect(await screen.findByRole("button", { name: "Submit" })).toBeInTheDocument();
});
@@ -331,6 +334,7 @@ describe("PresentationRoute", () => {
it("updates the chat intro after the live health probe succeeds", async () => {
window.sessionStorage.setItem("lda.workflowConsole.target", "http://127.0.0.1:8765/rpc");
window.location.hash = "#scene/run-from-deployment/operation";
const { PresentationRoute } = await import("./PresentationRoute.js");
render(<PresentationRoute />);
@@ -347,10 +351,20 @@ describe("PresentationRoute", () => {
const { PresentationRoute } = await import("./PresentationRoute.js");
render(<PresentationRoute />);
expect(await screen.findByText(/Replay evidence is active/i)).toBeInTheDocument();
expect(await screen.findByText(/Live target is ready/i)).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Send" })).toBeEnabled();
expect(screen.queryByRole("button", { name: "Run prepared workflow" })).not.toBeInTheDocument();
expect(mockedCallOperation).not.toHaveBeenCalled();
expect(mockedCallOperation).toHaveBeenCalledWith("workflow.health", "http://127.0.0.1:8765/rpc", {});
});
it("does not probe a configured target on the title route", async () => {
window.sessionStorage.setItem("lda.workflowConsole.target", "http://127.0.0.1:8765/rpc");
mockedCallOperation.mockClear();
const { PresentationRoute } = await import("./PresentationRoute.js");
render(<PresentationRoute />);
expect(screen.getByRole("heading", { name: /Design and Implementation of lda\.chat/i })).toBeInTheDocument();
expect(mockedCallOperation).not.toHaveBeenCalledWith("workflow.health", expect.anything(), expect.anything());
});
it("opens Scene 10 approval from the canonical hash", async () => {
@@ -8,6 +8,7 @@ import { useDemoTimeline } from "../demo/useDemoTimeline.js";
import { PresentationCanvas } from "./PresentationCanvas.js";
import { PresentationStage } from "./PresentationStage.js";
import { requirementForDemoBeat } from "./demo-beat-requirements.js";
import { isDemoChromeScene } from "./presentation-demo-chrome.js";
import {
createInitialPresentationState,
presentationReducer,
@@ -53,8 +54,13 @@ export const PresentationRoute = () => {
const presentationTarget = useMemo(() => resolvePresentationTarget(), []);
const demo = useDemoTimeline(presentationTarget.target, recordEvidence, recording);
const isScene8 = state.location.kind === "main" && state.location.sceneId === "agent-handoff";
const targetStatusController = usePresentationTargetStatus(presentationTarget, demo.state, !isScene8);
const probeEnabled = state.location.kind === "main"
&& isDemoChromeScene(state.location.sceneId);
const targetStatusController = usePresentationTargetStatus(
presentationTarget,
demo.state,
probeEnabled,
);
const targetStatus = targetStatusController.status;
const timelineAgent = useTimelineAgent(demo, {
mode: presentationTarget.mode === "live" ? "live" : "replay",
@@ -18,22 +18,34 @@ describe("presentationTargetHealth", () => {
target: "http://127.0.0.1:8765/rpc",
probe: "ready",
liveActive: false,
replayActive: false,
})).toMatchObject({
kind: "ready",
label: "Live target ready",
detail: "127.0.0.1:8765",
});
});
it("labels a reviewed replay selected alongside a healthy target", () => {
it("keeps a healthy target ready while replay is active", () => {
expect(presentationTargetHealth({
target: "http://127.0.0.1:8765/rpc",
probe: "ready",
liveActive: false,
replayActive: true,
})).toMatchObject({
kind: "ready",
label: "Live target ready",
detail: "127.0.0.1:8765",
});
});
it("uses reviewed recording fallback when no target is configured", () => {
expect(presentationTargetHealth({
target: null,
probe: "none",
liveActive: false,
})).toMatchObject({
kind: "replay",
label: "Replay evidence",
detail: "reviewed recording",
});
});
@@ -20,13 +20,11 @@ export const presentationTargetHealth = ({
target,
probe,
liveActive,
replayActive = false,
failureReason,
}: {
readonly target: string | null;
readonly probe: TargetProbeState;
readonly liveActive: boolean;
readonly replayActive?: boolean;
readonly failureReason?: string | undefined;
}): PresentationTargetHealth => {
if (!target) {
@@ -37,14 +35,6 @@ export const presentationTargetHealth = ({
};
}
if (replayActive && probe === "ready") {
return {
kind: "replay",
label: "Replay evidence",
detail: "reviewed recording",
};
}
if (liveActive && probe === "ready") {
return {
kind: "active",
@@ -95,7 +95,17 @@ describe("usePresentationTargetStatus", () => {
);
await waitFor(() => expect(result.current.liveTargetReady).toBe(true));
expect(result.current.status.kind).toBe("replay");
expect(result.current.status.kind).toBe("ready");
expect(result.current.status.label).toBe("Live target ready");
});
it("does not probe when health probing is disabled", async () => {
const { result } = renderHook(() =>
usePresentationTargetStatus(target, replayState, false),
);
await waitFor(() => expect(result.current.status.kind).toBe("replay"));
expect(mockedCallOperation).not.toHaveBeenCalled();
});
it("retries health without changing replay playback", async () => {
@@ -37,7 +37,7 @@ export const usePresentationTargetStatus = (
}
if (!probeEnabled) {
setProbe("none");
setFailureReason("deterministic Scene 8 replay");
setFailureReason(undefined);
return;
}
@@ -70,14 +70,11 @@ export const usePresentationTargetStatus = (
target: null,
probe: "none",
liveActive: false,
replayActive: true,
failureReason: "deterministic Scene 8 replay",
})
: presentationTargetHealth({
target: targetState.mode === "live" ? targetState.target : null,
probe,
liveActive: liveActive(demoState),
replayActive: demoState.mode === "replay",
failureReason,
});