frontend components, remove profiling, open login modal

This commit is contained in:
Brandon Thomas committed 2025-12-18 18:36:21 -05:00
1 parent 1fc8f7b537
commit e1fe7a0b84
8 files changed
+132 -4

No files matched your search

@@ -18,6 +18,7 @@ use crate::services::midjourney::threads::midjourney_long_polling_thread::midjou
use crate::services::sora::state::sora_credential_manager::SoraCredentialManager;
use crate::services::sora::state::sora_task_queue::SoraTaskQueue;
use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager;
use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager;
use errors::AnyhowResult;
use tauri::{AppHandle, Manager};
@@ -32,6 +33,7 @@ pub async fn handle_tauri_startup(
mj_creds_manager: MidjourneyCredentialManager,
grok_creds_manager: GrokCredentialManager,
grok_image_prompt_queue: GrokImagePromptQueue,
worldlabs_creds_manager: WorldlabsCredentialManager,
) -> AnyhowResult<()> {
set_app_log_level(
+7 -1
View File
@@ -38,6 +38,7 @@ use crate::services::midjourney::commands::midjourney_clear_credentials_command:
use crate::services::midjourney::commands::midjourney_get_credential_info_command::midjourney_get_credential_info_command;
use crate::services::midjourney::commands::midjourney_open_login_command::midjourney_open_login_command;
use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager;
use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager;
use crate::services::sora::commands::check_sora_session_command::check_sora_session_command;
use crate::services::sora::commands::open_sora_login_command::open_sora_login_command;
use crate::services::sora::commands::sora_get_credential_info_command::sora_get_credential_info_command;
@@ -111,6 +112,9 @@ pub fn run() {
let grok_prompt_queue = GrokImagePromptQueue::new();
let grok_prompt_queue_2 = grok_prompt_queue.clone();
let worldlabs_creds_manager = WorldlabsCredentialManager::initialize_from_disk_infallible(&app_data_root);
let worldlabs_creds_manager_2 = worldlabs_creds_manager.clone();
println!("Initializing backend runtime...");
let builder = tauri::Builder::default()
@@ -150,6 +154,7 @@ pub fn run() {
midjourney_creds_manager_2,
grok_creds_manager_2,
grok_prompt_queue_2,
worldlabs_creds_manager_2,
).await;
if let Err(err) = result {
@@ -169,7 +174,8 @@ pub fn run() {
.manage(midjourney_creds_manager)
.manage(sora_creds_manager)
.manage(sora_task_queue)
.manage(storyteller_creds_manager_3);
.manage(storyteller_creds_manager_3)
.manage(worldlabs_creds_manager);
// TODO: Break this out into another module, because RustRover/IntelliJ lags with these macros.
// My first attempt at naively doing this didn't work because the macros can't find their codegen'd targets.
@@ -35,6 +35,7 @@ fn get_info(
let mut can_clear_state = true;
let maybe_cookies = creds.maybe_copy_cookie_store()?;
//let maybe_full_credentials = creds.user()?;
//
//if maybe_cookies.is_none() && maybe_full_credentials.is_none() {
@@ -45,6 +46,10 @@ fn get_info(
// .map(|full_creds| full_creds.client_secrets.user_email)
// .map(|maybe_email| maybe_email.map(|email| email.to_string()))
// .flatten();
if maybe_cookies.is_none() {
can_clear_state = false;
}
Ok(WorldlabsGetCredentialInfoResponse {
maybe_email: None,
+3 -1
View File
@@ -14,7 +14,9 @@
gtag('js', new Date());
gtag('config', 'G-Y4Y8KMLPQ7');
</script>
<script crossOrigin="anonymous" src="//unpkg.com/react-scan/dist/auto.global.js"></script>
<!---->
<!-- <script crossOrigin="anonymous" src="//unpkg.com/react-scan/dist/auto.global.js"></script> -->
<!-- Microsoft Clarity -->
<script type="text/javascript">
@@ -3,6 +3,7 @@ import { ArtcraftAccountBlock } from "./ArtcraftAccountBlock";
import { FalApiKeyBlock } from "./FalApiKeyBlock";
import { MidjourneyAccountBlock } from "./MidjourneyAccountBlock";
import { GrokAccountBlock } from "./GrokAccountBlock";
import { WorldLabsAccountBlock } from "./WorldLabsAccountBlock";
interface AccountSettingsPaneProps {
globalAccountLogoutCallback: () => void;
@@ -44,6 +45,7 @@ export const AccountSettingsPane = ({
/>
<MidjourneyAccountBlock />
<GrokAccountBlock />
<WorldLabsAccountBlock />
<SoraAccountBlock />
<FalApiKeyBlock />
{/*
@@ -0,0 +1,91 @@
import { Button } from "@storyteller/ui-button";
import { invoke } from "@tauri-apps/api/core";
import { useEffect, useState } from "react";
import { faSpinnerThird } from "@fortawesome/pro-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useRefreshAccountStateEvent } from "@storyteller/tauri-events";
import { RefreshAccountStateEvent } from "@storyteller/tauri-events";
import { WorldLabsGetCredentialInfo, WorldLabsGetCredentialInfoSuccess } from "@storyteller/tauri-api";
export const WorldLabsAccountBlock = () => {
const [worldlabsSession, setWorldlabsSession] = useState<WorldLabsGetCredentialInfoSuccess| undefined>(undefined);
const [isCheckingWorldlabsSession, setIsCheckingWorldlabsSession] = useState(false);
const fetchSession = async () => {
setIsCheckingWorldlabsSession(true);
try {
const result = await WorldLabsGetCredentialInfo();
setWorldlabsSession(result);
} catch (e) {
console.error("Error fetching WorldLabs session", e);
setWorldlabsSession(undefined);
} finally {
setIsCheckingWorldlabsSession(false);
}
};
useEffect(() => {
fetchSession();
}, []);
useRefreshAccountStateEvent(async (event: RefreshAccountStateEvent) => {
fetchSession();
});
const clearState = async() => {
try {
await invoke("worldlabs_clear_credentials_command");
} catch (e) {
console.error("Error clearing WorldLabs credentials", e);
}
}
const openLogin = async() => {
try {
await invoke("worldlabs_open_login_command");
} catch (e) {
console.error("Error opening WorldLabs login", e);
}
}
const handleWorldlabsButton = async () => {
if (worldlabsSession?.payload?.can_clear_state) {
await clearState();
setWorldlabsSession(undefined);
} else {
await openLogin();
}
};
console.log("worldlabs session", worldlabsSession);
return(
<div className="flex justify-between items-center">
<span>WorldLabs Account:</span>
<pre>{worldlabsSession?.payload?.maybe_email || "Not logged in"}</pre>
<Button
variant={
worldlabsSession?.payload?.can_clear_state && !isCheckingWorldlabsSession
? "destructive"
: worldlabsSession?.payload?.can_clear_state
? "primary"
: "secondary"
}
className="h-[30px]"
onClick={handleWorldlabsButton}
disabled={isCheckingWorldlabsSession}
>
{isCheckingWorldlabsSession ? (
<FontAwesomeIcon
icon={faSpinnerThird}
className="animate-spin text-sm"
/>
) : worldlabsSession?.payload?.can_clear_state ? (
"Disconnect"
) : (
"Connect"
)}
</Button>
</div>
)
}
+6 -2
View File
@@ -1,6 +1,8 @@
export * from "./lib/artcraft/ArtcraftGetCredits.js";
export * from "./lib/artcraft/ArtcraftGetSubscription.js";
export * from "./lib/artcraft/media_files/MediaFileDelete.js";
export * from "./lib/artcraft/task_queue/GetTaskQueue.js";
export * from "./lib/artcraft/task_queue/MarkTaskAsDismissed.js";
export * from "./lib/common/CommandStatus.js";
export * from "./lib/enqueue/EnqueueEditImage.js";
export * from "./lib/enqueue/EnqueueImageBgRemovalCommand.js";
@@ -22,8 +24,6 @@ export * from "./lib/openai/GetOpenAIApiKey.js";
export * from "./lib/openai/SetOpenAIApiKey.js";
export * from "./lib/providers/GetProviderOrder.js";
export * from "./lib/providers/Provider.js";
export * from "./lib/artcraft/task_queue/GetTaskQueue.js";
export * from "./lib/artcraft/task_queue/MarkTaskAsDismissed.js";
export * from "./lib/providers/SetProviderOrder.js";
export * from "./lib/settings/GetAppPreferences.js";
export * from "./lib/settings/UpdateAppPreference.js";
@@ -35,3 +35,7 @@ export * from "./lib/sora/useSoraLoginListener.js";
export * from "./lib/sora/waitForSoraLogin.js";
export * from "./lib/system/GetAppInfo.js";
export * from "./lib/util/LoadWithoutCors.js";
<<<<<<< HEAD
=======
export * from "./lib/worldlabs/WorldLabsGetCredentialInfo.js";
>>>>>>> e213d3349 (frontend components, remove profiling, open login modal)
@@ -0,0 +1,16 @@
import { invoke } from "@tauri-apps/api/core";
import { CommandResult } from "../common/CommandStatus";
export interface WorldLabsGetCredentialInfoPayload {
maybe_email?: string;
can_clear_state: boolean;
}
export interface WorldLabsGetCredentialInfoSuccess extends CommandResult {
payload: WorldLabsGetCredentialInfoPayload;
}
export const WorldLabsGetCredentialInfo = async (): Promise<WorldLabsGetCredentialInfoSuccess> => {
const result = await invoke("worldlabs_get_credential_info_command");
return result as WorldLabsGetCredentialInfoSuccess;
};