commit f6056c03c88e6b517a599bd0560140a1ea7fb179
parent c9bfba728e760fe8a1f0da8371a2f1f8d7c88c1c
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 19 Oct 2026 17:33:16 -0400
umtool: the cited clip plays the project's own cached window before a (wider) corpus one
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/umtool/lib/clips/cited.ts b/umtool/lib/clips/cited.ts
@@ -1,3 +1,4 @@
+import path from "node:path";
import {
fetchClip,
validateFetchClipArgs,
@@ -59,8 +60,14 @@ async function projectPlay(t: CitedTarget): Promise<CitedPlay | null> {
const r = await resolveClip(t.project, t.clip).catch(() => null);
if (!r || "error" in r) return null;
const cache = await projectCache(r.project, r.manifest);
- const windows = (await windowsFor(r.project, { ...r.clip, start: t.from, end: t.to }, cache)) as { name: string; from: number; to: number }[];
- const win = windows.find((w) => w.from <= t.from + WIN_EPS && w.to >= t.to - WIN_EPS);
+ const windows = (await windowsFor(r.project, { ...r.clip, start: t.from, end: t.to }, cache)) as { name: string; path?: string; from: number; to: number }[];
+ // The project's OWN window first: a corpus window is shared by every project and
+ // another one's fetch can be wider (clip-bench's after-only fetch leaves vid1's
+ // 0-14), which would play instead of the cache this project counts on.
+ const own = (w: { path?: string }) => (w.path && path.resolve(w.path).startsWith(path.resolve(r.project.dir) + path.sep) ? 0 : 1);
+ const win = windows
+ .filter((w) => w.from <= t.from + WIN_EPS && w.to >= t.to - WIN_EPS)
+ .sort((a, b) => own(a) - own(b))[0];
if (!win) return null;
return {
kind: "window",