Open source CapCut alternative.
TypeScript
fix(site): send a stock sound's id from library_add to stock_add and its area
David Le5d3ac619c59e
diff --git a/site/src/cut/lib/aiTools.ts b/site/src/cut/lib/aiTools.tsindex 92a43719..10c35a17 100644--- a/site/src/cut/lib/aiTools.ts+++ b/site/src/cut/lib/aiTools.ts@@ -4474,8 +4474,12 @@ const toolRuns: Record<BrowserToolName, ToolRun> = {...(place ? { addedToTimeline: true, clip: placeAssetOnTimeline(asset, input) } : { addedToTimeline: false }) };}const found = findLibraryAsset((await fetchLibrary()).assets, String(input.id ?? ""));+ // A turn routed away from the stock area doesn't see stock_add, so the+ // miss names the area to request as well as the tool.+ if (!found && STOCK_SFX.some((x) => x.id === input.id))+ throw new ToolError(`"${String(input.id)}" is a stock sound effect, not a Library asset: add it with stock_add (the stock area; call request_tools with ["stock"] if stock_add isn't declared to you).`);if (!found)- throw new ToolError(`No library asset with id or name "${String(input.id)}". Call library_list with a query for ids; stock sound effects come from stock_search and stock_add.`);+ throw new ToolError(`No library asset with id or name "${String(input.id)}". Call library_list with a query for ids; stock sound effects come from stock_search and stock_add in the stock area (request_tools ["stock"] if you don't see them).`);if ("candidates" in found)throw new ToolError(`Several Library assets are named "${String(input.id)}": ${JSON.stringify(found.candidates)}. Pass one id.`);const lib = found.asset;diff --git a/site/src/cut/lib/folderReference.test.ts b/site/src/cut/lib/folderReference.test.tsindex 082cf2a5..02c72ff5 100644--- a/site/src/cut/lib/folderReference.test.ts+++ b/site/src/cut/lib/folderReference.test.ts@@ -151,4 +151,14 @@ describe("folder references", () => {} finally { listing.mockRestore(); sync.mockRestore(); resolve.mockRestore(); }});+ test("a stock sound effect's id names stock_add and the area that declares it", async () => {+ useEditor.setState({ projectId: "p1", loaded: true });+ const listing = spyOn(library, "fetchLibrary").mockResolvedValue({ assets: [], folders: [], templates: [] });+ try {+ await expect(runAiTool("library_add", { id: "keyboard-laptop-key" })).rejects.toThrow(+ /"keyboard-laptop-key" is a stock sound effect.*stock_add.*request_tools.*stock/+ );+ } finally { listing.mockRestore(); }+ });+});