fix: keep presentation deep links replay backed
This commit is contained in:
@@ -40,7 +40,7 @@ export const DemoTimelineControls = ({
|
||||
</div>
|
||||
<div className="demo-playback-controls">
|
||||
{state.phase === "ready" && (
|
||||
<button onClick={start} disabled={!canStart || inFlight}>Start presentation</button>
|
||||
<button onClick={() => start()} disabled={!canStart || inFlight}>Start presentation</button>
|
||||
)}
|
||||
{inRunning && (
|
||||
<button onClick={pause} disabled={inFlight}>Pause</button>
|
||||
|
||||
@@ -34,7 +34,7 @@ describe("useTimelineAgent", () => {
|
||||
const { result } = renderHook(() => useTimelineAgent(demo, "live"));
|
||||
await act(async () => result.current.runPreparedWorkflow());
|
||||
|
||||
expect(start).toHaveBeenCalledTimes(1);
|
||||
expect(start).toHaveBeenCalledWith("live");
|
||||
expect(result.current.messages.at(-1)?.parts).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ type: "tool-result" }),
|
||||
@@ -42,6 +42,16 @@ describe("useTimelineAgent", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("starts the replay walkthrough explicitly when replay is active", async () => {
|
||||
const start = vi.fn();
|
||||
const demo = demoController({ start });
|
||||
|
||||
const { result } = renderHook(() => useTimelineAgent(demo, "replay"));
|
||||
await act(async () => result.current.runPreparedWorkflow());
|
||||
|
||||
expect(start).toHaveBeenCalledWith("replay");
|
||||
});
|
||||
|
||||
it("submits selected issues from the current interrupt payload", async () => {
|
||||
const submitSelectedIssues = vi.fn(async () => {});
|
||||
const demo = demoController({
|
||||
@@ -79,4 +89,4 @@ describe("useTimelineAgent", () => {
|
||||
const { result } = renderHook(() => useTimelineAgent(demo, "live"));
|
||||
expect(result.current.canRun).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -48,7 +48,7 @@ export const useTimelineAgent = (
|
||||
"timeline-agent-intro",
|
||||
"assistant",
|
||||
modeLabel === "live"
|
||||
? "Live workflow server is available. I can run the prepared workflow now."
|
||||
? "Live workflow target is configured. I can run the prepared workflow now."
|
||||
: "Replay fallback is active. I can still walk through the prepared workflow evidence.",
|
||||
),
|
||||
]);
|
||||
@@ -58,8 +58,7 @@ export const useTimelineAgent = (
|
||||
|
||||
const runPreparedWorkflow = useCallback(async () => {
|
||||
if (!demo.canStart || demo.inFlight) return;
|
||||
demo.restart();
|
||||
demo.start();
|
||||
demo.start(modeLabel);
|
||||
setMessages((current) => appendToolMessage(
|
||||
current,
|
||||
"timeline-agent-start",
|
||||
@@ -107,4 +106,4 @@ export const useTimelineAgent = (
|
||||
submitSelectedIssues,
|
||||
cancelReview,
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -35,6 +35,29 @@ describe("useDemoTimeline", () => {
|
||||
expect(result.current.state.appliedCount).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("can force replay start without first switching timeline mode", async () => {
|
||||
vi.useFakeTimers();
|
||||
const { result } = renderHook(() => useDemoTimeline("http://127.0.0.1:8765/rpc", vi.fn()));
|
||||
|
||||
act(() => result.current.start("replay"));
|
||||
await act(async () => vi.advanceTimersByTimeAsync(900));
|
||||
|
||||
expect(result.current.state.mode).toBe("replay");
|
||||
expect(mockedCallOperation).not.toHaveBeenCalled();
|
||||
expect(result.current.state.appliedCount).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("can force live start from replay mode without stale state", () => {
|
||||
const { result } = renderHook(() => useDemoTimeline("http://127.0.0.1:8765/rpc", vi.fn()));
|
||||
|
||||
act(() => result.current.setMode("replay"));
|
||||
act(() => result.current.start("live"));
|
||||
|
||||
expect(result.current.state.mode).toBe("live");
|
||||
expect(result.current.state.events).toEqual([]);
|
||||
expect(result.current.state.phase).toBe("running");
|
||||
});
|
||||
|
||||
it("live Next executes exactly one operation", async () => {
|
||||
mockedCallOperation.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
|
||||
@@ -35,7 +35,7 @@ export type DemoTimelineController = {
|
||||
readonly recordingId: string | null;
|
||||
readonly canStart: boolean;
|
||||
readonly setMode: (mode: DemoMode) => void;
|
||||
readonly start: () => void;
|
||||
readonly start: (mode?: DemoMode) => void;
|
||||
readonly pause: () => void;
|
||||
readonly play: () => void;
|
||||
readonly next: () => Promise<void>;
|
||||
@@ -206,9 +206,10 @@ export const useDemoTimeline = (
|
||||
dispatch({ type: "set_mode", mode });
|
||||
}, [resetRuntime]);
|
||||
|
||||
const start = useCallback(() => {
|
||||
const start = useCallback((modeOverride?: DemoMode) => {
|
||||
resetRuntime();
|
||||
if (state.mode === "replay") {
|
||||
const mode = modeOverride ?? state.mode;
|
||||
if (mode === "replay") {
|
||||
const recording = activeRecording.current;
|
||||
if (!recording) return;
|
||||
dispatch({ type: "start", mode: "replay", events: recording.events });
|
||||
|
||||
Reference in New Issue
Block a user