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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: cancel fal renders cancelled mid-submit, price and key-check fal image routes, and tidy fal image form edge cases
[._.]/ Adam Eivy7a2894be2912
diff --git a/client/src/components/settings/ImageGenTab.jsx b/client/src/components/settings/ImageGenTab.jsxindex b996cd57c0..d2c540c2bd 100644--- a/client/src/components/settings/ImageGenTab.jsx+++ b/client/src/components/settings/ImageGenTab.jsx@@ -591,7 +591,7 @@ export function ImageGenTab() {cleanC2PA: cleanC2PAByMode.agy, denoise: denoiseByMode.agy,},fal: {- enabled: falEnabled, model: falModel || undefined,+ enabled: falEnabled, model: falImageFamily(falModel) ? falModel : undefined,cleanC2PA: cleanC2PAByMode.fal, denoise: denoiseByMode.fal,},expose: { a1111: exposeA1111 },diff --git a/client/src/hooks/useImageGenForm.js b/client/src/hooks/useImageGenForm.jsindex 64665bd8be..f2fc464c54 100644--- a/client/src/hooks/useImageGenForm.js+++ b/client/src/hooks/useImageGenForm.js@@ -5,6 +5,7 @@ import { composeStyledPrompt } from '../lib/composeStyledPrompt';import { universeStylePreset } from '../lib/universeStylePreset';import { RUNNER_FAMILIES, loraCompatKey, loraCompatKeysMatch, loraFamilyOf, usesDiffusersRunner } from '../lib/runnerFamilies';import {+ FAL_IMAGE_DEFAULT_MODEL,IMAGE_GEN_MODE,LOCAL_IMAGEGEN_DEFAULT_MODEL,cloudPromptRequired,@@ -480,7 +481,7 @@ export function useImageGenForm({ searchParams, setSearchParams, backend }) {maxSlots: (isLocalMode && isQwen21Model) || isFalMode ? REFERENCE_SLOT_COUNT : 4,localSupportsReferences: isFlux2Model || isQwen21Model,localInputCap: isQwen21Model ? 10 : null,- cloudModelId: isFalMode ? (falModel || savedFalModel || null) : null,+ cloudModelId: isFalMode ? (falModel || savedFalModel || FAL_IMAGE_DEFAULT_MODEL) : null,});const activeStylePresets = useMemo(() => [selectedUniverse ? universeStylePreset(selectedUniverse) : null,diff --git a/server/services/falQueue.js b/server/services/falQueue.jsindex 06f15828bd..df0f0cdab0 100644--- a/server/services/falQueue.js+++ b/server/services/falQueue.js@@ -135,7 +135,12 @@ export async function awaitFalCompletion({}) {let statusFailures = 0;while (Date.now() < deadline) {- if (entry.aborted) return { outcome: 'canceled' };+ if (entry.aborted) {+ // The cancel may have landed while submit was in flight, before the+ // receipt's cancel_url existed — send it now rather than leave a paid render running.+ await cancelFalRequest(entry);+ return { outcome: 'canceled' };+ }onPoll();let status;try {diff --git a/server/services/falQueue.test.js b/server/services/falQueue.test.jsnew file mode 100644index 0000000000..8f45c6caab--- /dev/null+++ b/server/services/falQueue.test.js@@ -0,0 +1,27 @@+import { describe, it, expect, vi, afterEach } from 'vitest';+import { awaitFalCompletion, createFalRequestEntry } from './falQueue.js';++afterEach(() => vi.unstubAllGlobals());++describe('awaitFalCompletion', () => {+ // A cancel that lands while submit is in flight finds no cancel_url, so the+ // remote cancel is a no-op; the receipt arrives afterwards. The paid render+ // must still be cancelled remotely instead of left queued at fal.ai.+ it('sends the remote cancel when the job was cancelled before the receipt arrived', async () => {+ const fetchMock = vi.fn(async () => ({ ok: true, status: 200 }));+ vi.stubGlobal('fetch', fetchMock);+ const entry = createFalRequestEntry('test-key');+ entry.aborted = true;+ entry.cancelUrl = 'https://queue.fal.run/example/requests/abc/cancel';++ const result = await awaitFalCompletion({+ entry, statusUrl: 'https://queue.fal.run/example/requests/abc/status',+ apiKey: 'test-key', deadline: Date.now() + 60_000, timeoutMs: 60_000,+ });++ expect(result).toEqual({ outcome: 'canceled' });+ expect(fetchMock).toHaveBeenCalledTimes(1);+ expect(fetchMock.mock.calls[0][0]).toBe(entry.cancelUrl);+ expect(fetchMock.mock.calls[0][1].method).toBe('PUT');+ });+});diff --git a/server/services/musicVideo/productionPool.js b/server/services/musicVideo/productionPool.jsindex cdf00ead1f..120a507f0a 100644--- a/server/services/musicVideo/productionPool.js+++ b/server/services/musicVideo/productionPool.js@@ -25,6 +25,8 @@*/import { ServerError } from '../../lib/errorHandler.js';+import { FAL_IMAGE_FAMILIES, buildFalImageRequest, falImageFamily } from '../../lib/falImageModels.js';+import { resolveFalApiKey } from '../falQueue.js';import { QUEUEABLE_IMAGE_MODES, VIDEO_GEN_MODES } from '../../lib/generationModes.js';import { musicVideoConditioningReferences } from '../../lib/musicVideoConditioning.js';import { MUSIC_VIDEO_AUTOMATION_TOOLS } from '../../lib/musicVideoAutomation.js';@@ -51,11 +53,21 @@ export const falRouteVideoSettings = (project, route) => ({* catalog estimate of a default-length cutaway take for a fal video route* (null when its model is uncurated), null (unknown) for other metered routes.*/+// A fal image route renders on the configured (or per-route) catalog model; when+// the route names none the configured one is unknown here, so price at the+// dearest catalog model — a dollar cap then bounds the worst case.+function falImageRoutePriceUsd(modelId) {+ const estimate = (id) => buildFalImageRequest({ modelId: id, prompt: 'x' }).estimatedCostUsd;+ if (falImageFamily(modelId)) return estimate(modelId);+ return Math.max(...FAL_IMAGE_FAMILIES.map((f) => estimate(f.textEndpoint)));+}+function routePriceUsd(route, project = null) {if (!isMetered(route)) return 0;if (route.kind === 'video' && route.mode === 'fal') {return falSceneTake({ scene: null, videoSettings: falRouteVideoSettings(project, route) }).costUsd;}+ if (route.kind === 'image' && route.mode === 'fal') return falImageRoutePriceUsd(route.model);return null;}@@ -130,6 +142,9 @@ async function routeEligibility(route, env) {if (settings?.imageGen?.[route.mode]?.enabled !== true) {return { ok: false, reason: `${describe(route)} is not enabled in Settings → Image Gen` };}+ if (route.mode === 'fal' && !resolveFalApiKey(settings)) {+ return { ok: false, reason: 'fal.ai has no API key — add one in Settings → Image Gen or set FAL_KEY' };+ }const configured = settings.imageGen[route.mode].model || null;if (route.model && route.model !== configured && !supportsCloudModelOverride(route.mode)) {return { ok: false, reason: `${route.mode} image gen cannot select model "${route.model}"; it renders with its configured model only` };diff --git a/server/services/voice/tools/media.js b/server/services/voice/tools/media.jsindex 861b1d5584..8faf00a1df 100644--- a/server/services/voice/tools/media.js+++ b/server/services/voice/tools/media.js@@ -61,7 +61,8 @@ export const MEDIA_TOOLS = [if (!s?.imageGen?.[requestedMode]?.enabled) {const label = requestedMode === imageGen.IMAGE_GEN_MODE.CODEX? 'Codex'- : requestedMode === imageGen.IMAGE_GEN_MODE.GROK ? 'Grok' : 'Agy';+ : requestedMode === imageGen.IMAGE_GEN_MODE.GROK ? 'Grok'+ : requestedMode === imageGen.IMAGE_GEN_MODE.FAL ? 'fal.ai' : 'Agy';return { ok: false, summary: `${label} Imagegen is disabled — enable it in Settings → Image Gen first.` };}}