Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (agy): reject a NaN renderMs and cover the derived-record strips

[._.]/ Adam Eivybc864f5cf8f0
diff --git a/client/src/components/media/normalize.js b/client/src/components/media/normalize.js
index e0dc1ad547..e830c110fa 100644
--- a/client/src/components/media/normalize.js
+++ b/client/src/components/media/normalize.js
@@ -64,7 +64,9 @@ export function normalizeImage(i) {
// so it excludes queue wait. Absent on records from a path that never
// observed a start instant (uploads, downloads, extracted frames, older
// renders), which the cards render as "no render time" rather than 0.
- renderMs: typeof i.renderMs === 'number' ? i.renderMs : null,
+ // `Number.isFinite`, not `typeof === 'number'` — the latter admits NaN, and
+ // `formatDurationMs(NaN)` renders the literal string "NaNd NaNh".
+ renderMs: Number.isFinite(i.renderMs) ? i.renderMs : null,
hidden: !!i.hidden,
extractedFromVideoId: i.extractedFromVideoId || null,
extractedFromVideoFilename: i.extractedFromVideoFilename || null,
@@ -123,7 +125,7 @@ export function normalizeVideo(v) {
loraNames,
createdAt: v.createdAt,
// Same contract as normalizeImage's renderMs above.
- renderMs: typeof v.renderMs === 'number' ? v.renderMs : null,
+ renderMs: Number.isFinite(v.renderMs) ? v.renderMs : null,
hidden: !!v.hidden,
raw: v,
};
diff --git a/client/src/components/media/normalize.test.js b/client/src/components/media/normalize.test.js
index e71fd03e4a..bef37cca85 100644
--- a/client/src/components/media/normalize.test.js
+++ b/client/src/components/media/normalize.test.js
@@ -319,7 +319,9 @@ describe('render duration normalization', () => {
});
it('reports null — not 0, not the raw value — when the record was never timed', () => {
- for (const raw of [{}, { renderMs: null }, { renderMs: '42000' }]) {
+ // NaN is in this list deliberately: `typeof NaN === 'number'`, so a
+ // typeof-based guard admits it and formatDurationMs renders "NaNd NaNh".
+ for (const raw of [{}, { renderMs: null }, { renderMs: '42000' }, { renderMs: NaN }, { renderMs: Infinity }]) {
expect(normalizeImage({ filename: 'a.png', ...raw }).renderMs).toBeNull();
expect(normalizeVideo({ id: 'v1', filename: 'a.mp4', ...raw }).renderMs).toBeNull();
}
diff --git a/server/services/videoGen/local.test.js b/server/services/videoGen/local.test.js
index 592161b0b4..0632d92522 100644
--- a/server/services/videoGen/local.test.js
+++ b/server/services/videoGen/local.test.js
@@ -460,6 +460,45 @@ afterEach(() => {
vi.clearAllMocks();
});
+// Render duration (#5878). The upscaled row is built by spreading the SOURCE
+// history row, so the source's `renderMs` is one careless spread away from being
+// displayed on a card whose only work was a 2x ffmpeg pass — and, before the
+// estimator learned to skip derived rows, from training the render-time cost
+// model at 4x the work units against seconds of duration.
+describe('upscaleHistoryItem — render duration', () => {
+ const SOURCE_ID = '11111111-1111-4111-8111-111111111111';
+
+ const upscaleFrom = async (sourceFields) => {
+ const { readJSONFile } = await import('../../lib/fileUtils.js');
+ vi.mocked(readJSONFile).mockResolvedValue([{
+ id: SOURCE_ID, filename: `${SOURCE_ID}.mp4`, prompt: 'a lighthouse',
+ modelId: 'ltx2_unified', width: 768, height: 512, numFrames: 49, fps: 24,
+ ...sourceFields,
+ }]);
+ const { upscaleHistoryItem } = await import('./local.js');
+ return upscaleHistoryItem(SOURCE_ID);
+ };
+
+ it('times its own ffmpeg pass instead of inheriting the source render', async () => {
+ const upscaled = await upscaleFrom({
+ renderMs: 900_000,
+ renderStartedAt: '2026-09-02T00:00:00.000Z',
+ renderCompletedAt: '2026-09-02T00:15:00.000Z',
+ });
+
+ expect(upscaled.renderMs).not.toBe(900_000);
+ expect(upscaled.renderMs).toBeLessThan(900_000);
+ expect(Date.parse(upscaled.renderStartedAt)).toBeGreaterThan(Date.parse('2026-09-02T00:15:00.000Z'));
+ });
+
+ it('still times the pass when the source carried no timing of its own', async () => {
+ const upscaled = await upscaleFrom({});
+
+ expect(upscaled.renderMs).toBeGreaterThanOrEqual(0);
+ expect(upscaled.upscaledFrom).toBe(SOURCE_ID);
+ });
+});
+
describe('stitchVideos — history provenance', () => {
const renderFields = [
'steps',
@@ -474,7 +513,7 @@ describe('stitchVideos — history provenance', () => {
'renderInputsVersion',
];
- const stitchHistory = async (firstChunkFields = {}, secondChunkFields = {}) => {
+ const stitchHistory = async (firstChunkFields = {}, secondChunkFields = {}, historyKey = 'chainedFrom') => {
const { readJSONFile } = await import('../../lib/fileUtils.js');
const chunkIds = ['chunk-a', 'chunk-b'];
vi.mocked(readJSONFile).mockResolvedValue([
@@ -492,7 +531,7 @@ describe('stitchVideos — history provenance', () => {
return stitchVideos(chunkIds, {
id: randomUUID(),
filenamePrefix: 'chained',
- historyKey: 'chainedFrom',
+ historyKey,
});
};
@@ -521,6 +560,44 @@ describe('stitchVideos — history provenance', () => {
for (const field of renderFields) expect(stitched).not.toHaveProperty(field);
});
+ // Render duration (#5878). A chain writes its chunk rows `hidden: true`, so the
+ // stitched row is the only one the user ever sees — without timing here a chained
+ // render would be the one kind that never reports how long it took.
+ describe('render duration', () => {
+ const timed = (startedAt) => ({ renderStartedAt: startedAt, renderMs: 60_000 });
+
+ it('spans from the earliest chunk start through the concat', async () => {
+ const first = '2026-09-02T00:00:00.000Z';
+ const stitched = await stitchHistory(timed('2026-09-02T00:05:00.000Z'), timed(first));
+
+ // The EARLIEST start, not chunk 0's: chunks render sequentially but the
+ // history rows are not ordered by start time.
+ expect(stitched.renderStartedAt).toBe(first);
+ expect(Date.parse(stitched.renderCompletedAt) - Date.parse(first)).toBe(stitched.renderMs);
+ // The whole span, not the sum of the chunks' own renderMs — the concat and
+ // the inter-chunk trimming are time the user waited too.
+ expect(stitched.renderMs).toBeGreaterThan(0);
+ });
+
+ it('reports nothing when a chunk never observed a start instant', async () => {
+ const stitched = await stitchHistory(timed('2026-09-02T00:00:00.000Z'), {});
+
+ // Absent, not a span measured from the one chunk that did report — that
+ // would read as a suspiciously fast render.
+ expect(stitched).not.toHaveProperty('renderMs');
+ expect(stitched).not.toHaveProperty('renderStartedAt');
+ expect(stitched).not.toHaveProperty('renderCompletedAt');
+ });
+
+ it('reports nothing for a hand-stitched clip, which ran no render of its own', async () => {
+ const t = timed('2026-09-02T00:00:00.000Z');
+ const stitched = await stitchHistory(t, t, 'stitchedFrom');
+
+ expect(stitched).not.toHaveProperty('renderMs');
+ expect(stitched).not.toHaveProperty('renderStartedAt');
+ });
+ });
+
// Draft decode (#5423). The REQUEST is chain-wide — every chunk is submitted
// with the same value — but the OUTCOME is decided per child process, because
// the runner falls back to the full decoder on any load failure. Claiming