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

Let code animation generation run without a time limit (#12776)

[._.]/be44b2d9e6ab
diff --git a/server/services/codeAnimation/generationTimeout.test.js b/server/services/codeAnimation/generationTimeout.test.js
new file mode 100644
index 0000000000..097dde229d
--- /dev/null
+++ b/server/services/codeAnimation/generationTimeout.test.js
@@ -0,0 +1,49 @@
+/**
+ * Generating an animation may take hours. A wall-clock cap on the authoring
+ * run timed out a working Claude Code TUI run at 15 minutes, failed it over,
+ * and benched the provider for every other caller.
+ */
+import { afterAll, describe, expect, it, vi } from 'vitest';
+import { lazyTempDataRoot, makePathsProxy, cleanupTempDataRoots } from '../../lib/mockPathsDataRoot.js';
+
+vi.mock('../../lib/paths.js', async importOriginal =>
+ makePathsProxy(await importOriginal(), { dataRoot: () => lazyTempDataRoot('code-animation-timeout-') }));
+vi.mock('../../lib/databaseMaintenanceJournal.js', async importOriginal => ({
+ ...(await importOriginal()),
+ assertDatabaseAdmission: () => {},
+}));
+vi.mock('../socket.js', () => ({ emitCodeAnimationChanged: vi.fn() }));
+const jobs = vi.hoisted(() => ({ saveCodeAnimationJobRecord: vi.fn(async job => job), saveCodeAnimationHtml: vi.fn() }));
+vi.mock('./jobStore.js', async importOriginal => ({ ...(await importOriginal()), ...jobs }));
+vi.mock('../providers.js', () => ({
+ getProviderById: vi.fn(async () => ({ id: 'example-tui', type: 'tui', enabled: true, timeout: 300000 })),
+}));
+const runner = vi.hoisted(() => ({
+ runPromptThroughProvider: vi.fn(async () => ({ text: '```html\n<!doctype html><html><canvas></canvas></html>\n```' })),
+}));
+vi.mock('../promptRunner.js', () => runner);
+vi.mock('../creativeStyleSources.js', () => ({
+ resolveUniverseStyleSource: vi.fn(async () => null),
+ resolveMoodBoardStyleSource: vi.fn(async () => ({ board: null, images: [] })),
+}));
+
+const { startCodeAnimationGeneration } = await import('./index.js');
+
+afterAll(() => cleanupTempDataRoots('code-animation-timeout-'));
+
+describe('code animation generation run budget', () => {
+ it('runs the authoring prompt with no total-runtime cap on any provider type', async () => {
+ await startCodeAnimationGeneration({
+ providerId: 'example-tui', concept: 'A cube hops over a cone.',
+ format: { aspectRatio: '16:9', resolution: '720p', fps: 24, durationSeconds: 4 },
+ });
+ await vi.waitFor(() => expect(jobs.saveCodeAnimationJobRecord).toHaveBeenLastCalledWith(expect.objectContaining({ status: 'completed' })));
+ const [{ source, timeout, absoluteTimeoutMs }] = runner.runPromptThroughProvider.mock.calls.at(-1);
+ expect({ source, absoluteTimeoutMs }).toEqual({ source: 'code-animation-generation', absoluteTimeoutMs: 0 });
+ // CLI/TUI read `timeout` as a total cap; API runs keep their no-progress bound.
+ expect(timeout({ type: 'tui', timeout: 300000 })).toBe(0);
+ expect(timeout({ type: 'cli', timeout: 300000 })).toBe(0);
+ expect(timeout({ type: 'api', timeout: 300000 })).toBe(15 * 60 * 1000);
+ expect(timeout({ type: 'api', timeout: 30 * 60 * 1000 })).toBe(30 * 60 * 1000);
+ });
+});
diff --git a/server/services/codeAnimation/index.js b/server/services/codeAnimation/index.js
index f27c5e529c..2bc2ed9ff9 100644
--- a/server/services/codeAnimation/index.js
+++ b/server/services/codeAnimation/index.js
@@ -411,6 +411,12 @@ export async function pageCodeAnimationJobs({ limit = JOB_PAGE_SIZE, cursor } =
const canAttachImages = (provider) => provider.type === 'api'
|| isVisionCapableCliProvider(provider) || isVisionCapableCodexTuiProvider(provider);
+// Resolved per attempt, so a fallback of another type gets its own bound.
+const CODE_ANIMATION_API_STALL_MS = 15 * 60 * 1000;
+const codeAnimationRunTimeout = (provider) => (provider?.type === 'api'
+ ? Math.max(provider.timeout || 0, CODE_ANIMATION_API_STALL_MS)
+ : 0);
+
async function runGeneration({ provider, model, effort, prompt, referencePaths }) {
const promptRunner = await import('../promptRunner.js');
const { runPromptThroughProvider } = promptRunner;
@@ -426,7 +432,12 @@ async function runGeneration({ provider, model, effort, prompt, referencePaths }
// Every provider that can read images gets them as attachments; a
// non-vision CLI keeps only the on-disk paths written into the prompt.
screenshots: canAttachImages(provider) ? referencePaths : [],
- timeout: Math.max(provider.timeout || 0, 15 * 60 * 1000),
+ // Authoring a whole animation can legitimately run for hours, so no
+ // total-runtime cap: a cap here failed long runs over and benched a
+ // healthy provider for everyone. CLI/TUI read `timeout` as that cap
+ // (0 = unbounded); API runs read it as a no-progress bound, which stays.
+ timeout: codeAnimationRunTimeout,
+ absoluteTimeoutMs: 0,
});
// A fallback to a non-vision provider must not silently drop the references.
if (referencePaths.length && canAttachImages(provider)) promptRunner.assertVisionRunUsedImages(result, provider);
diff --git a/server/services/promptRunner.js b/server/services/promptRunner.js
index d4b4d1ba95..f35adf0c79 100644
--- a/server/services/promptRunner.js
+++ b/server/services/promptRunner.js
@@ -673,9 +673,12 @@ function createRecoveryInvestigationScope({ failed, failedModel, firstError }) {
* base64-encode each into `image_url` blocks. Codex and Claude Code CLI
* providers receive staged file attachments through executeCliRun. Other CLI
* and all TUI providers are rejected before a run record is created.
- * @param {number} [args.timeout] — per-call timeout in ms; falls back to
- * `provider.timeout`, then DEFAULT_TIMEOUT_MS. Callers like the loop
- * runner expose a user-configurable timeout that isn't a provider attr.
+ * @param {number|((provider: object) => number)} [args.timeout] — per-call
+ * timeout in ms; falls back to `provider.timeout`, then DEFAULT_TIMEOUT_MS.
+ * Callers like the loop runner expose a user-configurable timeout that isn't
+ * a provider attr. A function is resolved against the provider that actually
+ * runs (fallbacks included), for callers whose bound depends on its type:
+ * CLI/TUI treat it as a total cap, API runs as a no-progress (stall) bound.
* @param {number} [args.outputReserveTokens=8000] — expected completion budget
* included in fallback context admission. Callers with a tighter known
* output budget may lower it.
@@ -1592,7 +1595,8 @@ async function executeProviderRunOnce({
// original provider's timeout against a fallback would either time out
// a still-working run early or let a stuck one hang past its
// intended cap.
- const effectiveTimeout = timeoutOverride ?? effectiveProvider?.timeout ?? DEFAULT_TIMEOUT_MS;
+ const resolvedTimeoutOverride = typeof timeoutOverride === 'function' ? timeoutOverride(effectiveProvider) : timeoutOverride;
+ const effectiveTimeout = resolvedTimeoutOverride ?? effectiveProvider?.timeout ?? DEFAULT_TIMEOUT_MS;
// Gate concurrent in-flight calls to a LOCAL endpoint on the EFFECTIVE
// provider — the one that ACTUALLY runs after createRun's proactive swap
diff --git a/server/services/promptRunner.test.js b/server/services/promptRunner.test.js
index 6b636f27f9..05237ab94e 100644
--- a/server/services/promptRunner.test.js
+++ b/server/services/promptRunner.test.js
@@ -1332,6 +1332,25 @@ describe('promptRunner — retry-with-fallback', () => {
expect(autoFixer.noteFallbackFailed).not.toHaveBeenCalled();
});
+ it('resolves a function timeout against each provider that runs, fallback included', async () => {
+ mockToolkitWithFallback();
+ runner.executeCliRun.mockImplementation(async ({ onComplete }) => {
+ onComplete({ success: false, error: 'Process exited with code 1' });
+ });
+ runner.executeApiRun.mockImplementation(async ({ onData, onComplete }) => {
+ onData('fallback content');
+ onComplete({ success: true });
+ });
+
+ await runPromptThroughProvider({
+ provider: primaryCli, prompt: 'p', source: 'test',
+ timeout: (provider) => (provider.type === 'api' ? 900000 : 0),
+ });
+
+ expect(runner.executeCliRun).toHaveBeenCalledWith(expect.objectContaining({ timeout: 0 }));
+ expect(runner.executeApiRun).toHaveBeenCalledWith(expect.objectContaining({ timeout: 900000 }));
+ });
+
it('threads screenshot capability into retry selection and the fallback run', async () => {
const status = mockToolkitWithFallback();
runner.executeApiRun