Open source CapCut alternative.
TypeScript
fix(chatgpt): stable widget entry names survive ChatGPT's template cache
David Leb5b86ed1e76e
diff --git a/docs/guides/chatgpt-app.md b/docs/guides/chatgpt-app.mdindex d2eaeef6..2d356205 100644--- a/docs/guides/chatgpt-app.md+++ b/docs/guides/chatgpt-app.md@@ -45,9 +45,11 @@ economics before it acts.The standalone widget imports `@donkeycut/artifact-player/ArtifactVideo`, thesame player used by website previews and shared videos. The package owns video-buffers, visibility handling, and teardown. HLS loads on demand. The widget's-hashed assets are built by `npm run chatgpt:build`, which also runs before the-site's development and production builds. Rebuild it after editing widget code.+buffers, visibility handling, and teardown. HLS loads on demand. The widget is+built by `npm run chatgpt:build`, which also runs before the site's development+and production builds. Rebuild it after editing widget code. ChatGPT caches the+widget HTML it reads over MCP, so the entry script and stylesheet keep stable+names that revalidate on every load; only the chunks they import are hashed.The MCP adapter exposes project listing, creation and opening, the commandcatalog and guides, editing, importing, undo and redo, previews, exports and jobdiff --git a/site/next.config.ts b/site/next.config.tsindex 6e087bba..f9f197e3 100644--- a/site/next.config.ts+++ b/site/next.config.ts@@ -44,6 +44,12 @@ const nextConfig: NextConfig = {{ key: "X-Content-Type-Options", value: "nosniff" },],},+ {+ // ChatGPT caches the widget HTML, so the entry it names revalidates+ // on every load while the hashed chunks stay immutable.+ source: "/clients/chatgpt/main.:ext(js|css)",+ headers: [{ key: "Cache-Control", value: "public, max-age=0, must-revalidate" }],+ },{source: "/_next/static/:path*",headers: [{ key: "X-Robots-Tag", value: "noindex" }],diff --git a/site/scripts/build-chatgpt-widget.ts b/site/scripts/build-chatgpt-widget.tsindex 721ed60a..f4f9a7b4 100644--- a/site/scripts/build-chatgpt-widget.ts+++ b/site/scripts/build-chatgpt-widget.ts@@ -1,7 +1,9 @@import { mkdir, rm, writeFile } from "node:fs/promises";import path from "node:path";-// Hashed chunks let the widget load MP4 playback without downloading the HLS decoder.+// ChatGPT caches the widget HTML it reads over MCP, so the entry script and+// stylesheet keep stable names and revalidate on every load; the chunks the+// entry imports stay hashed, so MP4 playback never downloads the HLS decoder.const root = path.resolve(import.meta.dir, "..");const outdir = path.join(root, "public/clients/chatgpt");await rm(outdir, { recursive: true, force: true });@@ -9,7 +11,7 @@ await mkdir(outdir, { recursive: true });const result = await Bun.build({entrypoints: [path.join(root, "src/clients/chatgpt/ui/main.tsx")],target: "browser", format: "esm", splitting: true, minify: true, outdir,- naming: { entry: "[name]-[hash].[ext]", chunk: "[name]-[hash].[ext]", asset: "[name]-[hash].[ext]" },+ naming: { entry: "[name].[ext]", chunk: "[name]-[hash].[ext]", asset: "[name]-[hash].[ext]" },define: { "process.env.NODE_ENV": JSON.stringify("production") },});if (!result.success) throw new AggregateError(result.logs, "ChatGPT widget build failed");