Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
fix(studio): an edit the history could not record says why in the log (#5489)
Miguel Ángel86521b94f592
diff --git a/packages/studio/src/hooks/usePersistentEditHistory.test.ts b/packages/studio/src/hooks/usePersistentEditHistory.test.tsindex 549418ce4f..5f9706998e 100644--- a/packages/studio/src/hooks/usePersistentEditHistory.test.ts+++ b/packages/studio/src/hooks/usePersistentEditHistory.test.ts@@ -561,7 +561,9 @@ it("a claim the server refused is logged, and the write stays undoable as a chanfiles: { "index.html": { before: "A", after: "B" } },}),);- expect(logged).toHaveBeenCalledWith('"Moved Title" was not recorded as your edit: disk full');+ expect(logged).toHaveBeenCalledWith(+ '[history] 500: "Moved Title" was not recorded as your edit: disk full',+ );restoreFetch();expect(await act(() => hook().undo({ readFile }))).toMatchObject({ok: true,@@ -570,6 +572,46 @@ it("a claim the server refused is logged, and the write stays undoable as a chanexpect(file()).toBe("A");});+it.each([+ [+ "the server refused",+ 409,+ () => answer("/history/claim", 409, { error: "newer edit" }),+ "newer edit",+ ],+ [+ "could not reach the server",+ 0,+ () => {+ const real = globalThis.fetch;+ vi.stubGlobal("fetch", (url: string, init?: RequestInit) =>+ url.endsWith("/history/claim")+ ? Promise.reject(new TypeError("fetch failed"))+ : real(url, init),+ );+ },+ "Studio could not reach its server.",+ ],+] as const)(+ "a claim that %s logs under [history] with its status",+ async (_, status, stub, reason) => {+ const { hook, save } = await studio();+ const logged = vi.spyOn(console, "error").mockImplementation(() => {});+ cleanup.push(() => logged.mockRestore());+ stub();+ save("B");+ await act(() =>+ hook().recordEdit({+ label: "Moved Title",+ files: { "index.html": { before: "A", after: "B" } },+ }),+ );+ expect(logged).toHaveBeenCalledWith(+ `[history] ${status}: "Moved Title" was not recorded as your edit: ${reason}`,+ );+ },+);+it("a step whose reply cannot be read says so, instead of throwing", async () => {const { hook, readFile } = await studio();answer("/history/step", 200, "<html>");diff --git a/packages/studio/src/hooks/usePersistentEditHistory.ts b/packages/studio/src/hooks/usePersistentEditHistory.tsindex 6e0e8f18d2..154e9b7a9d 100644--- a/packages/studio/src/hooks/usePersistentEditHistory.ts+++ b/packages/studio/src/hooks/usePersistentEditHistory.ts@@ -154,7 +154,9 @@ function claimHeld(reply: Awaited<ReturnType<typeof post>>, label: string): striif (reply.ok)return (reply.body as { claimed: { id: string } | null } | null)?.claimed?.id ?? null;if (reply.status !== 404)- console.error(`"${label}" was not recorded as your edit: ${reply.error}`);+ console.error(+ `[history] ${reply.status}: "${label}" was not recorded as your edit: ${reply.error}`,+ );return null;}