Skip to content

Open source CapCut alternative.

TypeScript

fix(chatgpt): allow queued undo and redo commands

David Le22ec676e5af8
diff --git a/site/src/clients/chatgpt/server/catalog.test.ts b/site/src/clients/chatgpt/server/catalog.test.ts
index 941ac30a..ba4a3ee5 100644
--- a/site/src/clients/chatgpt/server/catalog.test.ts
+++ b/site/src/clients/chatgpt/server/catalog.test.ts
@@ -1,6 +1,13 @@
import { expect, test } from "bun:test";
import { AI_TOOLS, PROJECT_TOOLS } from "@/cut/server/ai/catalog";
-import { COMMANDS, READ_COMMANDS, SKILL_INDEX, readSkill } from "./catalog";
+import { COMMANDS, READ_COMMANDS, SKILL_INDEX, readSkill, unknownCommandNames } from "./catalog";
+
+test("first-class history tools can queue their editor commands", () => {
+ expect(COMMANDS.some((tool) => tool.name === "undo" || tool.name === "redo")).toBe(false);
+ expect(unknownCommandNames(["undo", "redo", "not_a_command"])).toEqual(["not_a_command"]);
+ expect(READ_COMMANDS.has("undo")).toBe(false);
+ expect(READ_COMMANDS.has("redo")).toBe(false);
+});
test("ChatGPT exposes file metadata as a read command", () => {
expect(READ_COMMANDS.has("get_asset_info")).toBe(true);
diff --git a/site/src/clients/chatgpt/server/catalog.ts b/site/src/clients/chatgpt/server/catalog.ts
index a4ec2f6e..28af5038 100644
--- a/site/src/clients/chatgpt/server/catalog.ts
+++ b/site/src/clients/chatgpt/server/catalog.ts
@@ -42,9 +42,8 @@ export const COMMANDS: AiToolDef[] = PROJECT_TOOLS.filter((tool) => !HIDDEN.has(
}));
export const COMMAND_NAMES = COMMANDS.map((tool) => tool.name);
-/** What a batch may name: the catalog, the state read inspect_project runs
- * by default, and the adoption an import queues after its download. */
-const KNOWN_COMMANDS = new Set([...COMMAND_NAMES, "get_state", ADOPT_COMMAND]);
+/** Batches include the catalog and commands queued by first-class tools. */
+const KNOWN_COMMANDS = new Set([...COMMAND_NAMES, "get_state", "undo", "redo", ADOPT_COMMAND]);
export const unknownCommandNames = (names: string[]): string[] => names.filter((name) => !KNOWN_COMMANDS.has(name));
/** Commands whose output matters and whose effect is on the caller's eyes: