From c2c13ef92c13ef8df9833717bf14176970e14bab Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 17 Dec 2025 14:06:20 -0500 Subject: [PATCH] login window tweaks --- .../worldlabs_clear_credentials_command.rs | 2 +- ...worldlabs_login_webview_extract_cookies.rs | 1 - .../worldlabs_login_window_open.rs | 21 +++++++++++++------ .../worldlabs_login_window_thread.rs | 6 +++--- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_clear_credentials_command.rs b/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_clear_credentials_command.rs index e4b6fc18a1..f829c45249 100644 --- a/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_clear_credentials_command.rs +++ b/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_clear_credentials_command.rs @@ -1,10 +1,10 @@ use crate::core::commands::response::shorthand::{Response, SimpleResponse}; use crate::core::state::data_dir::app_data_root::AppDataRoot; +use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; use errors::AnyhowResult; use log::{error, info}; use serde_derive::Deserialize; use tauri::State; -use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; #[tauri::command] pub async fn worldlabs_clear_credentials_command( diff --git a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_webview_extract_cookies.rs b/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_webview_extract_cookies.rs index e687f31b89..49f19ed11e 100644 --- a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_webview_extract_cookies.rs +++ b/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_webview_extract_cookies.rs @@ -2,7 +2,6 @@ use cookie_store::cookie_store::CookieStore; use errors::AnyhowResult; use once_cell::sync::Lazy; use reqwest::Url; -use std::collections::HashSet; use tauri::webview::Cookie; use tauri::WebviewWindow; diff --git a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_open.rs b/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_open.rs index 2813c651b2..b90111b557 100644 --- a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_open.rs +++ b/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_open.rs @@ -7,6 +7,7 @@ use errors::AnyhowResult; use once_cell::sync::Lazy; use reqwest::Url; use std::time::Duration; +use log::info; use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder}; /// Name of the window @@ -17,11 +18,11 @@ pub (super) static START_URL: Lazy = Lazy::new(|| { }); pub (super) static WORLDLABS_HOMEPAGE_URL: Lazy = Lazy::new(|| { - Url::parse("https://grok.com/").expect("URL should parse") + Url::parse("https://marble.worldlabs.ai/").expect("URL should parse") }); pub (super) static WORLDLABS_LOGIN_URL: Lazy = Lazy::new(|| { - Url::parse("https://accounts.x.ai/sign-in?redirect=grok-com").expect("URL should parse") + Url::parse("https://marble.worldlabs.ai/").expect("URL should parse") }); pub async fn worldlabs_login_window_open( @@ -43,7 +44,7 @@ pub async fn worldlabs_login_window_open( .resizable(true) .visible(true) .closable(true) - .min_inner_size(200.0, 800.0) + .min_inner_size(800.0, 800.0) .focused(true) .devtools(true) .build()?; @@ -55,10 +56,18 @@ pub async fn worldlabs_login_window_open( webview.navigate(WORLDLABS_HOMEPAGE_URL.clone())?; - // NB: We're starting to get Cloudflare protection screens. Let's try to avoid. - tokio::time::sleep(Duration::from_millis(100)).await; + tokio::time::sleep(Duration::from_millis(200)).await; - webview.navigate(WORLDLABS_LOGIN_URL.clone())?; + for _ in 0 .. 100 { + tokio::time::sleep(Duration::from_millis(100)).await; + info!("Running script..."); + + // Close "welcome" + webview.eval(r#"document.querySelectorAll("div:has(h2) ~ button[data-slot=dialog-close]")"#)?; + + // Open "login" + webview.eval(r#"document.querySelectorAll("button:has(span[data-slot=avatar])").forEach((el) => el.click())"#)?; + } let app_handle = app.clone(); let app_data_root = app_data_root.clone(); diff --git a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_thread.rs b/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_thread.rs index 1a8f6e9171..852ff7cc8f 100644 --- a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_thread.rs +++ b/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_thread.rs @@ -9,6 +9,9 @@ use crate::services::grok::state::grok_credential_manager::GrokCredentialManager use crate::services::sora::events::sora_login_success_event::SoraLoginSuccessEvent; use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; use crate::services::sora::windows::sora_login_window::extract_sora_webview_cookies::extract_sora_webview_cookies; +use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; +use crate::services::worldlabs::windows::worldlabs_login_window::worldlabs_login_webview_extract_cookies::worldlabs_login_webview_extract_cookies; +use crate::services::worldlabs::windows::worldlabs_login_window::worldlabs_login_window_open::WORLDLABS_LOGIN_WINDOW_NAME; use anyhow::anyhow; use cookie_store::cookie_store::CookieStore; use enums::common::generation_provider::GenerationProvider; @@ -18,9 +21,6 @@ use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; use openai_sora_client::utils::has_session_cookie::{has_session_cookie, SessionCookiePresence}; use tauri::{AppHandle, Manager, WebviewWindow}; -use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; -use crate::services::worldlabs::windows::worldlabs_login_window::worldlabs_login_webview_extract_cookies::worldlabs_login_webview_extract_cookies; -use crate::services::worldlabs::windows::worldlabs_login_window::worldlabs_login_window_open::WORLDLABS_LOGIN_WINDOW_NAME; pub async fn worldlabs_login_window_thread( app: AppHandle,