diff --git a/crates/desktop/artcraft/src/commands/command_response_wrapper.rs b/crates/desktop/artcraft/src/commands/command_response_wrapper.rs index a3207900f4..aefe2a330b 100644 --- a/crates/desktop/artcraft/src/commands/command_response_wrapper.rs +++ b/crates/desktop/artcraft/src/commands/command_response_wrapper.rs @@ -26,6 +26,9 @@ pub struct CommandSuccessResponseWrapper { /// Both "success" and "error" types have a `status` field for the frontend. pub status: CommandSuccessStatus, + #[serde(skip_serializing_if = "Option::is_none")] + pub success_message: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub payload: Option, } @@ -36,7 +39,10 @@ pub struct CommandErrorResponseWrapper { pub status: CommandErrorStatus, #[serde(skip_serializing_if = "Option::is_none")] - pub error: Option, + pub error_message: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + pub error_details: Option, } @@ -44,6 +50,7 @@ impl CommandSuccessResponseWrapper<()> { pub fn empty() -> Self { CommandSuccessResponseWrapper { status: CommandSuccessStatus::Success, + success_message: None, payload: None, } } @@ -61,6 +68,7 @@ impl From<()> for CommandSuccessResponseWrapper<()> { fn from(_: ()) -> Self { CommandSuccessResponseWrapper { status: CommandSuccessStatus::Success, + success_message: None, payload: None, } } @@ -72,16 +80,28 @@ impl From for CommandSuccessResponseWrapper where T: Serialize + Seria fn from(val: T) -> Self { CommandSuccessResponseWrapper { status: CommandSuccessStatus::Success, + success_message: None, payload: Some(val), } } } +impl From<&str> for CommandSuccessResponseWrapper { + fn from(msg: &str) -> Self { + CommandSuccessResponseWrapper { + status: CommandSuccessStatus::Success, + success_message: Some(msg.to_string()), + payload: None, + } + } +} + impl From<&str> for CommandErrorResponseWrapper { fn from(value: &str) -> Self { CommandErrorResponseWrapper { status: CommandErrorStatus::BadRequest, // NB: Default to 500 error. - error: Some(value.to_string()), + error_message: Some(value.to_string()), + error_details: None, } } } diff --git a/crates/desktop/artcraft/src/commands/sora/sora_image_remix_command.rs b/crates/desktop/artcraft/src/commands/sora/sora_image_remix_command.rs index f5163345e7..26b84e2667 100644 --- a/crates/desktop/artcraft/src/commands/sora/sora_image_remix_command.rs +++ b/crates/desktop/artcraft/src/commands/sora/sora_image_remix_command.rs @@ -1,3 +1,4 @@ +use crate::commands::command_response_wrapper::CommandResult; use crate::events::sendable_event_trait::SendableEvent; use crate::events::sora::sora_image_enqueue_failure_event::SoraImageEnqueueFailureEvent; use crate::events::sora::sora_image_enqueue_success_event::SoraImageEnqueueSuccessEvent; @@ -56,7 +57,7 @@ pub async fn sora_image_remix_command( app_data_root: State<'_, AppDataRoot>, sora_creds_manager: State<'_, SoraCredentialManager>, sora_task_queue: State<'_, SoraTaskQueue>, -) -> Result { +) -> CommandResult<(), String> { info!("image_generation_command called; scene media token: {:?}, additional images: {:?}", request.snapshot_media_token, request.maybe_additional_images); @@ -75,7 +76,7 @@ pub async fn sora_image_remix_command( error!("Failed to emit event: {:?}", err); } - return Err("there was an error".to_string()); + return Err("there was an error".into()); } let event = SoraImageEnqueueSuccessEvent {}; @@ -85,7 +86,7 @@ pub async fn sora_image_remix_command( error!("Failed to emit event: {:?}", err); } - Ok("success".to_string()) + Ok(().into()) } pub async fn generate_image(