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): accept a numeric-string context window on resume

[._.]/ Adam Eivy929800c5ac2d
diff --git a/client/src/hooks/useVideoGenForm.js b/client/src/hooks/useVideoGenForm.js
index 7f2de34198..6b0c780d0d 100644
--- a/client/src/hooks/useVideoGenForm.js
+++ b/client/src/hooks/useVideoGenForm.js
@@ -905,7 +905,15 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled })
// 0 is a real restored value ("last frame only"), so this can't gate on
// truthiness the way `chunks` does — that would silently upgrade a render
// the user deliberately put on last-frame chaining back to a window.
- if (Number.isFinite(p.contextFrames)) setContextFrames(p.contextFrames);
+ // Absence is tested separately from the numeric check rather than folded
+ // into one `Number.isFinite(...)`: the route persists a number today, but a
+ // share link or hand-rolled client sends `'0'`, and a bare isFinite on the
+ // raw value rejects that string while `Number(null)`/`Number('')` are both
+ // a finite 0 that would wrongly clear the default. Same shape the
+ // `guidanceScale` restore above uses, for the same round-tripping reason.
+ if (p.contextFrames != null && p.contextFrames !== '' && Number.isFinite(Number(p.contextFrames))) {
+ setContextFrames(Number(p.contextFrames));
+ }
// Per-chunk beats (#3695). The server normalizes an absent beat to null;
// the editor's shape is '' for the same thing, so map back on restore.
if (Array.isArray(p.chunkPrompts) && p.chunkPrompts.length) {
diff --git a/client/src/hooks/useVideoGenForm.test.jsx b/client/src/hooks/useVideoGenForm.test.jsx
index fbbf34d22f..d7fac4c1ef 100644
--- a/client/src/hooks/useVideoGenForm.test.jsx
+++ b/client/src/hooks/useVideoGenForm.test.jsx
@@ -393,6 +393,30 @@ describe('useVideoGenForm', () => {
expect(result.current.contextFrames).toBe(0);
});
+ it('restores a numeric-string context window without losing an explicit 0', async () => {
+ // The route persists a number, but a share link or hand-rolled client
+ // sends '0'. Rejecting the string would silently put the render back on
+ // a 22-frame window after the user chose last-frame chaining.
+ const { result } = render();
+ await waitFor(() => expect(result.current.modelId).toBe(MLX.id));
+ act(() => result.current.applyResumedParams({ prompt: 'p', chunks: 2, contextFrames: '0' }));
+ expect(result.current.contextFrames).toBe(0);
+
+ act(() => result.current.applyResumedParams({ prompt: 'p', chunks: 2, contextFrames: '45' }));
+ expect(result.current.contextFrames).toBe(45);
+ });
+
+ it('leaves the context window alone when the resumed job carries none', async () => {
+ // Number(null) and Number('') are both a finite 0 — folding the absence
+ // test into the numeric check would clear the default to 0 here.
+ const { result } = render();
+ await waitFor(() => expect(result.current.modelId).toBe(MLX.id));
+ act(() => result.current.applyResumedParams({ prompt: 'p', chunks: 2 }));
+ expect(result.current.contextFrames).toBe(22);
+ act(() => result.current.applyResumedParams({ prompt: 'p', chunks: 2, contextFrames: '' }));
+ expect(result.current.contextFrames).toBe(22);
+ });
+
it('restores beats from a resumed job, mapping the server null back to blank', async () => {
const { result } = render();
await waitFor(() => expect(result.current.modelId).toBe(MLX.id));