fix(studio): exclude generated caches from project metadata

This commit is contained in:
Miguel Ángel
2026-08-02 17:37:51 +00:00
parent 3eb7b1ffd5
commit 1d01b9f2cf
4 changed files with 58 additions and 2 deletions
@@ -20,7 +20,10 @@ const SIGNATURE_EXCLUDED_DIRS = new Set([
".git",
".hyperframes",
".next",
".thumbnails",
".transcode-cache",
".vite",
".waveform-cache",
"build",
"coverage",
"dist",
@@ -6,7 +6,13 @@ import { readdirSync } from "node:fs";
// Re-exported here for back-compat with existing `../helpers/safePath.js` imports.
export { isSafePath, resolveWithinProject } from "@hyperframes/core";
const IGNORE_DIRS = new Set([".thumbnails", "node_modules", ".git"]);
const IGNORE_DIRS = new Set([
".thumbnails",
".transcode-cache",
".waveform-cache",
"node_modules",
".git",
]);
function shouldIgnoreDir(rel: string): boolean {
return rel === ".hyperframes/backup";
@@ -91,6 +91,37 @@ describe("GET /projects/:id/signature", () => {
expect(second.signature).not.toBe(first.signature);
});
it("ignores generated cache writes while detecting source edits", async () => {
const projectDir = createProjectDir();
const app = new Hono();
registerProjectRoutes(app, createAdapter(projectDir));
const getSignature = async () =>
(
(await (await app.request("http://localhost/projects/demo/signature")).json()) as {
signature: string;
}
).signature;
const initial = await getSignature();
const generatedFiles = [
[".transcode-cache", "proxy.mp4"],
[".thumbnails", "frame.jpg"],
[".waveform-cache", "peaks.json"],
] as const;
const generatedSignatures: string[] = [];
for (const [dir, file] of generatedFiles) {
mkdirSync(join(projectDir, dir));
writeFileSync(join(projectDir, dir, file), `generated ${dir}`);
generatedSignatures.push(await getSignature());
}
expect(generatedSignatures).toEqual([initial, initial, initial]);
mkdirSync(join(projectDir, "src"));
writeFileSync(join(projectDir, "src", "scene.ts"), "export const scene = true;");
expect(await getSignature()).not.toBe(initial);
});
it("404s for an unknown project", async () => {
const app = new Hono();
registerProjectRoutes(app, {
@@ -132,4 +163,20 @@ describe("registerProjectRoutes — composition discovery (#1384)", () => {
// Only Studio's own backup snapshots are hidden from the tree (#1366).
expect(payload.files).not.toContain(".hyperframes/backup/snapshot.html");
});
it("omits generated cache files from the project file tree", async () => {
const projectDir = createProjectDir();
mkdirSync(join(projectDir, ".transcode-cache"));
writeFileSync(join(projectDir, ".transcode-cache", "proxy.mp4"), "proxy");
mkdirSync(join(projectDir, ".waveform-cache"));
writeFileSync(join(projectDir, ".waveform-cache", "peaks.json"), "[]");
const app = new Hono();
registerProjectRoutes(app, createAdapter(projectDir));
const response = await app.request("http://localhost/projects/demo");
const payload = (await response.json()) as { files?: string[] };
expect(payload.files).not.toContain(".transcode-cache/proxy.mp4");
expect(payload.files).not.toContain(".waveform-cache/peaks.json");
});
});