fix(studio): a refused timeline delete keeps the server's status in its message (#8171)

This commit is contained in:
Miguel Ángel
2026-11-18 19:28:04 +00:00
committed by GitHub
parent f6c9d09de8
commit 11cc1a519e
2 changed files with 9 additions and 7 deletions
@@ -156,7 +156,8 @@ describe("useTimelineDeleteOps: ripple undo label", () => {
expect(body.targets).toHaveLength(elements.length);
});
it("a refused delete names its count: 1 clip, 2 clips", async () => {
// fails without the fix: the refused delete dropped the server's status, so telemetry could not say why it failed.
it("a refused delete names its count and the server's status: 1 clip, 2 clips", async () => {
vi.stubGlobal(
"fetch",
vi.fn(async (input: RequestInfo | URL) =>
@@ -179,8 +180,8 @@ describe("useTimelineDeleteOps: ripple undo label", () => {
});
expect(showToast.mock.calls.map(([message]) => message)).toEqual([
"Failed to delete 1 clip from index.html",
"Failed to delete 2 clips from index.html",
"Failed to delete 1 clip from index.html (500): {}",
"Failed to delete 2 clips from index.html (500): {}",
]);
});
@@ -26,7 +26,7 @@ import type {
} from "./useTimelineGroupEditing";
import { studioApiFetch } from "../utils/studioApiFetch";
import { countOf } from "../utils/countOf";
import { heldFileWordsOf } from "../utils/studioSaveDiagnostics";
import { createStudioSaveHttpError } from "../utils/studioSaveDiagnostics";
/** Apply already-resolved ripple changes to the surviving elements for the
* optimistic store update after a delete. Pure — no IO. */
@@ -141,9 +141,10 @@ export function useTimelineDeleteOps({
},
);
if (!removeResponse.ok) {
throw new Error(
(await heldFileWordsOf(removeResponse, targetPath)) ??
`Failed to delete ${countOf(sameFile.length, "clip")} from ${targetPath}`,
throw await createStudioSaveHttpError(
removeResponse,
`Failed to delete ${countOf(sameFile.length, "clip")} from ${targetPath}`,
{ path: targetPath },
);
}
const removeData = (await removeResponse.json()) as { content?: string };