From dd8b03692ac4caadaa32e6386148da3c8a0aa7f0 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 21 Apr 2025 15:45:14 -0400 Subject: [PATCH] refactor sora module naming --- crates/desktop/tauri-artcraft/src/commands/mod.rs | 3 +-- .../desktop/tauri-artcraft/src/commands/sora/mod.rs | 2 ++ .../open_sora_login_command.rs} | 4 ++-- .../sora_image_generation_command.rs} | 2 +- crates/desktop/tauri-artcraft/src/lib.rs | 12 ++++++------ crates/desktop/tauri-artcraft/src/threads/mod.rs | 2 +- ...{login_thread.rs => sora_session_login_thread.rs} | 2 +- frontend/apps/editor2d/src/app/pages/main/index.tsx | 2 +- script/desktop/launch_desktop_2d.sh | 3 ++- 9 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 crates/desktop/tauri-artcraft/src/commands/sora/mod.rs rename crates/desktop/tauri-artcraft/src/commands/{open_login_command.rs => sora/open_sora_login_command.rs} (93%) rename crates/desktop/tauri-artcraft/src/commands/{image_generation_command.rs => sora/sora_image_generation_command.rs} (98%) rename crates/desktop/tauri-artcraft/src/threads/{login_thread.rs => sora_session_login_thread.rs} (96%) diff --git a/crates/desktop/tauri-artcraft/src/commands/mod.rs b/crates/desktop/tauri-artcraft/src/commands/mod.rs index 1aa7df3cd2..7afb07f6fa 100644 --- a/crates/desktop/tauri-artcraft/src/commands/mod.rs +++ b/crates/desktop/tauri-artcraft/src/commands/mod.rs @@ -1,3 +1,2 @@ pub mod flip_image; -pub mod image_generation_command; -pub mod open_login_command; +pub mod sora; diff --git a/crates/desktop/tauri-artcraft/src/commands/sora/mod.rs b/crates/desktop/tauri-artcraft/src/commands/sora/mod.rs new file mode 100644 index 0000000000..9054cfe591 --- /dev/null +++ b/crates/desktop/tauri-artcraft/src/commands/sora/mod.rs @@ -0,0 +1,2 @@ +pub mod sora_image_generation_command; +pub mod open_sora_login_command; diff --git a/crates/desktop/tauri-artcraft/src/commands/open_login_command.rs b/crates/desktop/tauri-artcraft/src/commands/sora/open_sora_login_command.rs similarity index 93% rename from crates/desktop/tauri-artcraft/src/commands/open_login_command.rs rename to crates/desktop/tauri-artcraft/src/commands/sora/open_sora_login_command.rs index be136ebb2d..2c25c41221 100644 --- a/crates/desktop/tauri-artcraft/src/commands/open_login_command.rs +++ b/crates/desktop/tauri-artcraft/src/commands/sora/open_sora_login_command.rs @@ -4,7 +4,7 @@ use once_cell::sync::Lazy; use tauri::{AppHandle, Manager, Url, WebviewUrl, WebviewWindowBuilder, WindowBuilder}; use tokio::time::sleep_until; use errors::AnyhowResult; -use crate::threads::login_thread::{LOGIN_WINDOW_NAME, SORA_LOGIN_URL}; +use crate::threads::sora_session_login_thread::{LOGIN_WINDOW_NAME, SORA_LOGIN_URL}; use crate::utils::clear_all_webview_cookies::clear_all_webview_cookies; pub const START_URL_STR: &str = "https://storyteller.ai/"; @@ -20,7 +20,7 @@ pub static SORA_HOMEPAGE_URL : Lazy = Lazy::new(|| { }); #[tauri::command] -pub async fn open_login_command( +pub async fn open_sora_login_command( app: AppHandle, ) -> Result { info!("open_login_command called"); diff --git a/crates/desktop/tauri-artcraft/src/commands/image_generation_command.rs b/crates/desktop/tauri-artcraft/src/commands/sora/sora_image_generation_command.rs similarity index 98% rename from crates/desktop/tauri-artcraft/src/commands/image_generation_command.rs rename to crates/desktop/tauri-artcraft/src/commands/sora/sora_image_generation_command.rs index 7b33eb414a..dfee9749bb 100644 --- a/crates/desktop/tauri-artcraft/src/commands/image_generation_command.rs +++ b/crates/desktop/tauri-artcraft/src/commands/sora/sora_image_generation_command.rs @@ -15,7 +15,7 @@ use openai_sora_client::upload::upload_media_from_file::SoraMediaUploadRequest; use crate::state::app_dir::AppDataRoot; #[tauri::command] -pub async fn image_generation_command( +pub async fn sora_image_generation_command( image: &str, prompt: &str, app: AppHandle, diff --git a/crates/desktop/tauri-artcraft/src/lib.rs b/crates/desktop/tauri-artcraft/src/lib.rs index c5ff9c8fe6..e9cfceedc6 100644 --- a/crates/desktop/tauri-artcraft/src/lib.rs +++ b/crates/desktop/tauri-artcraft/src/lib.rs @@ -6,10 +6,10 @@ pub mod transfer; pub mod utils; use crate::commands::flip_image::flip_image; -use crate::commands::image_generation_command::image_generation_command; -use crate::commands::open_login_command::open_login_command; +use crate::commands::sora::open_sora_login_command::open_sora_login_command; +use crate::commands::sora::sora_image_generation_command::sora_image_generation_command; use crate::state::app_config::AppConfig; -use crate::threads::login_thread::login_thread; +use crate::threads::sora_session_login_thread::sora_session_login_thread; use tauri_plugin_log::Target; use tauri_plugin_log::TargetKind; @@ -49,7 +49,7 @@ pub fn run() { //} let app = app.handle().clone(); - tauri::async_runtime::spawn(login_thread(app, app_data_root2)); + tauri::async_runtime::spawn(sora_session_login_thread(app, app_data_root2)); Ok(()) }) @@ -57,8 +57,8 @@ pub fn run() { .manage(app_data_root) .invoke_handler(tauri::generate_handler![ flip_image, - image_generation_command, - open_login_command, + sora_image_generation_command, + open_sora_login_command, ]) .run(tauri::generate_context!("tauri.conf.json")) .expect("error while running tauri application"); diff --git a/crates/desktop/tauri-artcraft/src/threads/mod.rs b/crates/desktop/tauri-artcraft/src/threads/mod.rs index 4f68c93e04..f336543a59 100644 --- a/crates/desktop/tauri-artcraft/src/threads/mod.rs +++ b/crates/desktop/tauri-artcraft/src/threads/mod.rs @@ -1 +1 @@ -pub mod login_thread; \ No newline at end of file +pub mod sora_session_login_thread; \ No newline at end of file diff --git a/crates/desktop/tauri-artcraft/src/threads/login_thread.rs b/crates/desktop/tauri-artcraft/src/threads/sora_session_login_thread.rs similarity index 96% rename from crates/desktop/tauri-artcraft/src/threads/login_thread.rs rename to crates/desktop/tauri-artcraft/src/threads/sora_session_login_thread.rs index e9368bcfd6..4053c22e1e 100644 --- a/crates/desktop/tauri-artcraft/src/threads/login_thread.rs +++ b/crates/desktop/tauri-artcraft/src/threads/sora_session_login_thread.rs @@ -23,7 +23,7 @@ pub static SORA_ROOT_URL: Lazy = Lazy::new(|| { Url::parse(SORA_ROOT_URL_STR).expect("URL should parse") }); -pub async fn login_thread(app: AppHandle, app_data_root: AppDataRoot) -> ! { +pub async fn sora_session_login_thread(app: AppHandle, app_data_root: AppDataRoot) -> ! { loop { for (window_name, webview) in app.webviews() { if window_name == LOGIN_WINDOW_NAME { diff --git a/frontend/apps/editor2d/src/app/pages/main/index.tsx b/frontend/apps/editor2d/src/app/pages/main/index.tsx index c9cf0c0738..43125e9ce7 100644 --- a/frontend/apps/editor2d/src/app/pages/main/index.tsx +++ b/frontend/apps/editor2d/src/app/pages/main/index.tsx @@ -134,7 +134,7 @@ export const Main = withProtectionRoute(() => { iconFlip={true} onClick={async () => { if (isTauri()) { - await invoke('open_login_command'); + await invoke('open_sora_login_command'); setFirstTimeDialogOpen(false); } else { console.error('Tauri is not available in this environment'); diff --git a/script/desktop/launch_desktop_2d.sh b/script/desktop/launch_desktop_2d.sh index 3800f40160..c6e1f09ac5 100755 --- a/script/desktop/launch_desktop_2d.sh +++ b/script/desktop/launch_desktop_2d.sh @@ -12,8 +12,8 @@ if lsof -i tcp:5741 &>/dev/null; then else echo "No process running on port 5741" fi + # TODO(bt,2025-02-13): This is not the correct way to get the root dir -brew install pkg-config pixman cairo pango libpng jpeg giflib librsvg root_dir=$(pwd) frontend_path="${root_dir}/frontend" @@ -30,3 +30,4 @@ export CONFIG_PATH="${TAURI_APP_PATH}/tauri.artcraft_2d.conf.toml" # TODO: --no-watch cargo tauri dev --config "${CONFIG_PATH}" +