fix: address presentation review findings

This commit is contained in:
lda
2026-07-13 07:12:45 +07:00 Verified
parent a16e0933e2
commit ab943deed5
25 changed files with 339 additions and 92 deletions
@@ -128,6 +128,34 @@ describe("useTimelineAgent", () => {
expect(start).toHaveBeenCalledWith("live");
});
it("does not advertise live launch when the timeline cannot start", () => {
const demo = demoController({ canStart: false });
const { result } = renderHook(() => useTimelineAgent(demo, {
mode: "live",
status: readyStatus,
}));
expect(result.current.canRunLive).toBe(false);
});
it("uses target health for an explicit live launch regardless of selected mode", async () => {
const start = vi.fn();
const demo = demoController({
state: { ...initialDemoTimelineState, mode: "replay" },
start,
});
const { result } = renderHook(() => useTimelineAgent(demo, {
mode: "replay",
status: readyStatus,
}));
expect(result.current.canRunLive).toBe(true);
await act(async () => result.current.runPreparedWorkflow("live"));
expect(start).toHaveBeenCalledWith("live");
});
it("does not offer an explicit live launch when health has failed", () => {
const start = vi.fn();
const demo = demoController({ start });
@@ -91,9 +91,15 @@ export const useTimelineAgent = (
const runLabel = modeLabel === "live" ? "Run prepared workflow" : "Run replay walkthrough";
const canRun = demo.canStart && !demo.inFlight && demo.state.phase !== "running";
const canRunLive = (options.liveTargetReady ?? (options.mode === "live" && (
// Live capability is about the target and timeline, not the selected display
// mode; callers can request a live run from a replay-backed slide explicitly.
const liveTargetReady = options.liveTargetReady ?? (
options.status.kind === "ready" || options.status.kind === "active"
))) && !demo.inFlight && demo.state.phase !== "running";
);
const canRunLive = liveTargetReady
&& demo.canStart
&& !demo.inFlight
&& demo.state.phase !== "running";
const runPreparedWorkflow = useCallback(async (requestedMode?: TimelineAgentMode) => {
const mode = requestedMode ?? modeLabel;