fix: keep live cancellation terminal

This commit is contained in:
lda
2026-07-09 18:33:29 +07:00 Verified
parent 2606d38f70
commit aecbf21735
4 changed files with 98 additions and 7 deletions
@@ -168,6 +168,22 @@ describe("useTimelineAgent", () => {
);
});
it("live cancel does not call next", async () => {
const cancelReview = vi.fn(async () => {});
const next = vi.fn(async () => {});
const demo = demoController({
state: { ...initialDemoTimelineState, mode: "live", phase: "review" },
cancelReview,
next,
});
const { result } = renderHook(() => useTimelineAgent(demo, { mode: "live", status: readyStatus }));
await act(async () => result.current.cancelReview());
expect(cancelReview).toHaveBeenCalledWith("Cancelled by operator.");
expect(next).not.toHaveBeenCalled();
});
it("uses replay label when live target failed", () => {
const demo = demoController();
const { result } = renderHook(() =>
@@ -122,11 +122,8 @@ export const useTimelineAgent = (
const cancelReview = useCallback(async () => {
await demo.cancelReview("Cancelled by operator.");
// In replay the canonical recording only contains the submitted branch.
// Do not call next() or the UI would falsely advance into submitted evidence.
if (demo.state.mode === "live") {
await demo.next();
}
// Cancellation is terminal in presentation mode. Do not call next() or the UI
// would falsely advance into submitted/resume evidence.
setMessages((current) => appendToolMessage(
current,
"timeline-agent-cancel",