diff --git a/frontend/apps/editor2d/src/components/PromptBox.tsx b/frontend/apps/editor2d/src/components/PromptBox.tsx index c8d0cff643..10a1f8f74b 100644 --- a/frontend/apps/editor2d/src/components/PromptBox.tsx +++ b/frontend/apps/editor2d/src/components/PromptBox.tsx @@ -320,7 +320,7 @@ export const PromptBox = () => { if (!prompt.trim()) return; try { console.log( - "Enqueuing with prompt:", + "(3) Enqueuing with prompt:", prompt, "and reference images:", referenceImages, diff --git a/frontend/apps/editor3d/app/src/pages/PageEnigma/comps/PromptBox/PromptBox.tsx b/frontend/apps/editor3d/app/src/pages/PageEnigma/comps/PromptBox/PromptBox.tsx index 3f6665ccad..5b8f6067ab 100644 --- a/frontend/apps/editor3d/app/src/pages/PageEnigma/comps/PromptBox/PromptBox.tsx +++ b/frontend/apps/editor3d/app/src/pages/PageEnigma/comps/PromptBox/PromptBox.tsx @@ -446,8 +446,10 @@ export const PromptBox = () => { r.playSound("test"); if (isDesktop) { + console.log("Desktop enqueueing...") await handleTauriEnqueue(); } else { + console.log("Web enqueueing...") await handleWebEnqueue(); } }; @@ -492,7 +494,7 @@ export const PromptBox = () => { try { // Here we would pass both the prompt and reference images to the generation console.log( - "Enqueuing with prompt:", + "(2) Enqueuing with prompt:", prompt, "and reference images:", referenceImages, @@ -592,7 +594,7 @@ export const PromptBox = () => { try { // Here we would pass both the prompt and reference images to the generation console.log( - "Enqueuing with prompt:", + "(1) Enqueuing with prompt:", prompt, "and reference images:", referenceImages, diff --git a/frontend/libs/components/promptbox/src/lib/PromptBox2D.tsx b/frontend/libs/components/promptbox/src/lib/PromptBox2D.tsx index d14d6f1565..b2d5584840 100644 --- a/frontend/libs/components/promptbox/src/lib/PromptBox2D.tsx +++ b/frontend/libs/components/promptbox/src/lib/PromptBox2D.tsx @@ -357,7 +357,7 @@ export const PromptBox2D = ({ if (!prompt.trim()) return; try { console.log( - "Enqueuing with prompt:", + "(4) Enqueuing with prompt:", prompt, "and reference images:", referenceImages diff --git a/frontend/libs/components/promptbox/src/lib/PromptBox3D.tsx b/frontend/libs/components/promptbox/src/lib/PromptBox3D.tsx index 4d6b0e87b7..2f4b85ca3d 100644 --- a/frontend/libs/components/promptbox/src/lib/PromptBox3D.tsx +++ b/frontend/libs/components/promptbox/src/lib/PromptBox3D.tsx @@ -42,19 +42,20 @@ import { PromptsApi } from "@storyteller/api"; import { SoundRegistry } from "@storyteller/soundboard"; import { toast } from "@storyteller/ui-toaster"; -interface ReferenceImage { - id: string; - url: string; - file: File; - mediaToken: string; -} - import { EngineApi } from "@storyteller/api"; import { CameraSettingsModal } from "@storyteller/ui-camera-settings-modal"; import { twMerge } from "tailwind-merge"; import { GalleryModal, GalleryItem } from "@storyteller/ui-gallery-modal"; import { Modal } from "@storyteller/ui-modal"; import { Signal } from "@preact/signals-react"; +import { CommandSuccessStatus, GetAppPreferences, SoraImageRemix } from "@storyteller/tauri-api"; + +interface ReferenceImage { + id: string; + url: string; + file: File; + mediaToken: string; +} interface PromptBox3DProps { cameras: Signal; @@ -317,14 +318,11 @@ export const PromptBox3D = ({ const handleEnqueue = async () => { const isDesktop = IsDesktopApp(); - console.log("Is this a desktop app?", isDesktop); - - const r = SoundRegistry.getInstance(); - r.playSound("test"); - if (isDesktop) { + console.log("Desktop app - tauri enqueue"); await handleTauriEnqueue(); } else { + console.log("Web app - web enqueue"); await handleWebEnqueue(); } }; @@ -369,7 +367,7 @@ export const PromptBox3D = ({ try { // Here we would pass both the prompt and reference images to the generation console.log( - "Enqueuing with prompt:", + "(3D.2) Enqueuing with prompt:", prompt, "and reference images:", referenceImages @@ -388,6 +386,15 @@ export const PromptBox3D = ({ setisEnqueueing(true); + setTimeout(() => { + // TODO(bt,2025-05-08): This is a hack so we don't accidentally wind up with a permanently disabled prompt box if + // the backend hangs on a given request. (Sometimes Sora doesn't respond.) Ideally what we would do instead is only + // force the prompt box to be enabled again as long as another request isn't running, ie. if we just fired off two + // requests in succession, we wouldn't want to turn it off as the first one gets submitted. + console.debug('Turn off blocking of prompt box...'); + setisEnqueueing(false); + }, 10000); + setPrompt(prompt); const promptsApi = new PromptsApi(); @@ -401,19 +408,54 @@ export const PromptBox3D = ({ //sceneMediaToken: "", }); - const generateResponse = await invoke("sora_image_remix_command", { - request: { - snapshot_media_token: snapshotResult.data!, - disable_system_prompt: !useSystemPrompt, - prompt: prompt, - maybe_additional_images: referenceImages.map( - (image) => image.mediaToken - ), - maybe_number_of_samples: 1, - }, + console.log("snapshotResult", snapshotResult); + + // const generateResponse = await invoke("sora_image_remix_command", { + // request: { + // snapshot_media_token: snapshotResult.data!, + // disable_system_prompt: !useSystemPrompt, + // prompt: prompt, + // maybe_additional_images: referenceImages.map( + // (image) => image.mediaToken + // ), + // maybe_number_of_samples: 1, + // }, + // }); + + const generateResponse = await SoraImageRemix({ + snapshot_media_token: snapshotResult.data!, + disable_system_prompt: !useSystemPrompt, + prompt: prompt, + maybe_additional_images: referenceImages.map( + (image) => image.mediaToken, + ), + maybe_number_of_samples: 1, }); - console.log("response", generateResponse); + console.log("generateResponse", generateResponse); + + if (generateResponse.status === CommandSuccessStatus.Success) { + const prefs = await GetAppPreferences(); + const soundName = prefs.preferences?.enqueue_success_sound; + if (soundName !== undefined) { + const registry = SoundRegistry.getInstance(); + registry.playSound(soundName); + } + toast.success("Image added to queue"); + setisEnqueueing(false); + return; + + } else { + const prefs = await GetAppPreferences(); + const soundName = prefs.preferences?.enqueue_failure_sound; + if (soundName !== undefined) { + const registry = SoundRegistry.getInstance(); + registry.playSound(soundName); + } + toast.error("Failed to enqueue image"); + setisEnqueueing(false); + return; + } //if (generateResponse.errorMessage) { // handleError(response.errorMessage); @@ -425,7 +467,7 @@ export const PromptBox3D = ({ try { // Here we would pass both the prompt and reference images to the generation console.log( - "Enqueuing with prompt:", + "(3D.1) Enqueuing with prompt:", prompt, "and reference images:", referenceImages