commit 192139d823557e077dff56c51a5d9805bfdefac6
parent 2ea0d40e544345f33cfc9e19768890482b4f876e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 13 Nov 2026 20:28:08 -0500
tallerFromSaved: "best" only when the box is the limit; a short saved copy is "lower"
A 720 copy against a 1080 ask answered "best" on its first ask and "lower"
on the next (the pointer exit, once probed.height was written). Now "best"
only when the fitted height is below min(cap, the copy's height), as an
ultrawide copy in the 1080 box; otherwise "lower" with the reason, on every
ask. The planner test that was loosened is restored (a 90p copy against a
1080 ask is lower).
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/common/lib/clipWindowTier-server.ts b/common/lib/clipWindowTier-server.ts
@@ -78,9 +78,13 @@ export async function tallerFromSaved(opts: {
// never reaches, so it would be cut again on every ask.
const best = fittedHeight(source.probe.width, source.probe.height, opts.cap) ?? Math.min(opts.cap, savedHeight);
if (best <= have) {
- return have >= best && opts.hitHeight !== null
+ // "best" only when the BOX is the limit (an ultrawide copy fits the 1080
+ // box at 810): the window is all the ask could ever get from this copy.
+ // A copy that is itself short of the ask (a 720 copy, a 1080 ask) is
+ // "lower", with why — the same answer the pointer's early exit gives.
+ return opts.hitHeight !== null && best < Math.min(opts.cap, savedHeight)
? { kind: "best", height: best }
- : { kind: "lower", why: `the saved copy gives ${best}p in the ${opts.cap}p box, no taller than the window` };
+ : { kind: "lower", why: `the saved copy is ${savedHeight}p, no taller than the window` };
}
return { kind: "cut", source, height: best };
}
diff --git a/common/lib/clipWindowTier.test.ts b/common/lib/clipWindowTier.test.ts
@@ -240,6 +240,15 @@ test("taller from the saved copy: only when the copy is taller than the window;
const r3 = await tallerFromSaved({ ...base, hitHeight: null, source: src(covers(1440)) });
assert.equal((r3 as { height: number }).height, 1080);
assert.equal(JSON.parse(await readFile(path.join(videoDir, "saved-video.json"), "utf8")).probed.height, 1440);
+ // A copy short of the ask, probed (no recorded height): "lower" on the first
+ // ask as on the second (the pointer exit), never "best".
+ await pointer(videoDir);
+ const short1 = await tallerFromSaved({ ...base, hitHeight: 720, source: src(covers(720)) });
+ assert.equal(short1.kind, "lower");
+ assert.match((short1 as { why: string }).why, /saved copy is 720p/);
+ const short2 = await tallerFromSaved({ ...base, hitHeight: 720, source: src(covers(720)) });
+ assert.equal(short2.kind, "lower");
+ await pointer(videoDir);
// A copy that does not hold the span, or has no picture: lower, with why.
const r4 = await tallerFromSaved({ ...base, hitHeight: 720, source: async () => ({ kind: "not-covering", container: "/s", durationSec: 5 }) });
assert.match((r4 as { why: string }).why, /does not hold this span/);
diff --git a/editor/app/channels/[slug]/videos/fetchWindowsTier.test.ts b/editor/app/channels/[slug]/videos/fetchWindowsTier.test.ts
@@ -61,7 +61,7 @@ const items = [
{ slug: SLUG, id: "equal1", from: 1, to: 3, clipId: "c#2" },
];
-test("a tall ask plans a taller cut beside a window lower than the saved copy; one as tall as the copy gives is a hit", async () => {
+test("a tall ask plans a taller cut beside a window lower than the saved copy, and lists the one that cannot be taller", async () => {
const r = await fetchWindowsAction({ items, requestedBy: "umtool", maxHeight: 1080, dryRun: true });
assert.ok(r.ok);
if (!r.ok) return;
@@ -69,9 +69,13 @@ test("a tall ask plans a taller cut beside a window lower than the saved copy; o
r.groups.map((g) => [g.platform, g.items.map((i) => i.clipId)]),
[["saved-video", ["c#1"]]],
);
- // 90p is all a 160×90 copy gives in the 1080 box: an ordinary hit, not "lower".
+ // A 90p copy is itself short of the 1080 ask: "lower", with why (not "best").
assert.deepEqual(r.cached.map((i) => i.clipId), ["c#2"]);
- assert.equal(r.lower, undefined);
+ assert.equal(r.lower?.length, 1);
+ assert.equal(r.lower![0].item.clipId, "c#2");
+ assert.equal(r.lower![0].height, 90);
+ assert.equal(r.lower![0].asked, 1080);
+ assert.match(r.lower![0].why, /saved copy is 90p/);
});
test("no ask plans as before: both held windows are cached, nothing listed lower", async () => {
@@ -89,7 +93,7 @@ test("an ask above clips.windowMaxHeight is planned at the ceiling, and says so"
assert.ok(r.ok);
if (!r.ok) return;
assert.equal(r.clampedFrom, 2160);
- assert.deepEqual(r.cached.map((i) => i.clipId), ["c#2"]);
+ assert.equal(r.lower?.[0]?.asked, 1080);
});
test("a tall refetch is not answered by a held window: planned onto the saved copy's cut", async () => {