[Update] Add VRCT Availability Status that if the status set to false, that is when ai models has not been detected by backend, can't use VRCT.

This commit is contained in:
Sakamoto Shiina
2025-02-08 21:58:29 +09:00
parent a36dc93522
commit 9daa50294e
8 changed files with 45 additions and 16 deletions

View File

@@ -1,9 +1,5 @@
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import {
useWindow,
} from "@logics_common";
import { import {
KeyEventController, KeyEventController,
StartPythonController, StartPythonController,
@@ -23,9 +19,10 @@ import { UpdatingComponent } from "./updating_component/UpdatingComponent";
import { ModalController } from "./modal_controller/ModalController"; import { ModalController } from "./modal_controller/ModalController";
import { SnackbarController } from "./snackbar_controller/SnackbarController"; import { SnackbarController } from "./snackbar_controller/SnackbarController";
import styles from "./App.module.scss"; import styles from "./App.module.scss";
import { useIsBackendReady, useIsSoftwareUpdating } from "@logics_common"; import { useIsBackendReady, useIsSoftwareUpdating, useIsVrctAvailable, useWindow } from "@logics_common";
export const App = () => { export const App = () => {
const { currentIsVrctAvailable } = useIsVrctAvailable();
const { currentIsBackendReady } = useIsBackendReady(); const { currentIsBackendReady } = useIsBackendReady();
const { WindowGeometryController } = useWindow(); const { WindowGeometryController } = useWindow();
const { i18n } = useTranslation(); const { i18n } = useTranslation();
@@ -42,10 +39,12 @@ export const App = () => {
<TransparencyController /> <TransparencyController />
<WindowGeometryController /> <WindowGeometryController />
{currentIsBackendReady.data === false {(currentIsBackendReady.data === false || currentIsVrctAvailable.data === false)
? <SplashComponent /> ? <SplashComponent />
: <Contents key={i18n.language}/> : <Contents key={i18n.language}/>
} }
<SnackbarController />
</div> </div>
); );
}; };
@@ -61,7 +60,6 @@ const Contents = () => {
<ConfigPage /> <ConfigPage />
<MainPage /> <MainPage />
<ModalController /> <ModalController />
<SnackbarController />
</div> </div>
: :
<UpdatingComponent /> <UpdatingComponent />

View File

@@ -17,17 +17,23 @@ export const SnackbarController = () => {
[styles.is_error]: currentNotificationStatus.data.status === "error", [styles.is_error]: currentNotificationStatus.data.status === "error",
}); });
const settings = currentNotificationStatus.data;
let hide_duration = 5000;
if (settings.options?.hide_duration === null) hide_duration = null;
if (Number(settings.options?.hide_duration)) hide_duration = settings.options.hide_duration;
return ( return (
<div> <div>
<Snackbar <Snackbar
open={currentNotificationStatus.data.is_open} open={settings.is_open}
onClose={handleClose} onClose={handleClose}
TransitionComponent={SlideTransition} TransitionComponent={SlideTransition}
key={currentNotificationStatus.data.key} key={settings.key}
autoHideDuration={5000} autoHideDuration={hide_duration}
> >
<div className={snackbar_classname}> <div className={snackbar_classname}>
<p className={styles.snackbar_message}>{currentNotificationStatus.data.message}</p> <p className={styles.snackbar_message}>{settings.message}</p>
</div> </div>
</Snackbar> </Snackbar>
</div> </div>

View File

@@ -11,3 +11,4 @@ export { useMessage } from "./useMessage";
export { useUpdateSoftware } from "./useUpdateSoftware"; export { useUpdateSoftware } from "./useUpdateSoftware";
export { useVolume } from "./useVolume"; export { useVolume } from "./useVolume";
export { useHandleNetworkConnection } from "./useHandleNetworkConnection"; export { useHandleNetworkConnection } from "./useHandleNetworkConnection";
export { useIsVrctAvailable } from "./useIsVrctAvailable";

View File

@@ -6,7 +6,9 @@ export const useHandleNetworkConnection = () => {
const handleNetworkConnection = (is_network_connected) => { const handleNetworkConnection = (is_network_connected) => {
if (!is_network_connected) { if (!is_network_connected) {
showNotification_Error("Network is not connected. Some of the function will not work."); showNotification_Error("Network is not connected. Some of the function will not work.", {
hide_duration: 8000,
});
} }
}; };

View File

@@ -0,0 +1,10 @@
import { useStore_IsVrctAvailable } from "@store";
export const useIsVrctAvailable = () => {
const { currentIsVrctAvailable, updateIsVrctAvailable } = useStore_IsVrctAvailable();
return {
currentIsVrctAvailable,
updateIsVrctAvailable,
};
};

View File

@@ -5,12 +5,13 @@ export const useNotificationStatus = () => {
const generateRandomKey = () => Math.random(); const generateRandomKey = () => Math.random();
const showNotification_Error = (message) => { const showNotification_Error = (message, options = {}) => {
updateNotificationStatus({ updateNotificationStatus({
status: "error", status: "error",
is_open: true, is_open: true,
key: generateRandomKey(), key: generateRandomKey(),
message: message, message: message,
options: options,
}); });
}; };
@@ -20,6 +21,7 @@ export const useNotificationStatus = () => {
is_open: true, is_open: true,
key: generateRandomKey(), key: generateRandomKey(),
message: message, message: message,
options: options,
}); });
}; };

View File

@@ -2,6 +2,7 @@ import { translator_status } from "@ui_configs";
import { arrayToObject } from "@utils"; import { arrayToObject } from "@utils";
import { import {
useIsVrctAvailable,
useNotificationStatus, useNotificationStatus,
useHandleNetworkConnection, useHandleNetworkConnection,
@@ -74,6 +75,7 @@ import {
} from "@logics_configs"; } from "@logics_configs";
export const useReceiveRoutes = () => { export const useReceiveRoutes = () => {
const { updateIsVrctAvailable } = useIsVrctAvailable();
const { updateComputeMode } = useComputeMode(); const { updateComputeMode } = useComputeMode();
const { updateInitProgress } = useInitProgress(); const { updateInitProgress } = useInitProgress();
const { updateIsBackendReady } = useIsBackendReady(); const { updateIsBackendReady } = useIsBackendReady();
@@ -184,6 +186,12 @@ export const useReceiveRoutes = () => {
// Common // Common
"/run/feed_watchdog": () => {}, "/run/feed_watchdog": () => {},
"/run/initialization_progress": updateInitProgress, "/run/initialization_progress": updateInitProgress,
"/run/enable_ai_models": (is_ai_models_available) => {
if (is_ai_models_available === false) {
updateIsVrctAvailable(false);
showNotification_Error("AI models have not been detected. Check the network connection and restart VRCT (it will download automatically, normally).", { hide_duration: null });
}
},
"/get/data/compute_mode": updateComputeMode, "/get/data/compute_mode": updateComputeMode,
"/get/data/main_window_geometry": restoreWindowGeometry, "/get/data/main_window_geometry": restoreWindowGeometry,
"/set/data/main_window_geometry": () => {}, "/set/data/main_window_geometry": () => {},
@@ -481,6 +489,7 @@ export const useReceiveRoutes = () => {
"/get/data/speaker_no_speech_prob": ()=>{}, // Not implemented on UI yet "/get/data/speaker_no_speech_prob": ()=>{}, // Not implemented on UI yet
"/get/data/convert_message_to_romaji": ()=>{}, // Not implemented on UI yet "/get/data/convert_message_to_romaji": ()=>{}, // Not implemented on UI yet
"/get/data/convert_message_to_hiragana": ()=>{}, // Not implemented on UI yet "/get/data/convert_message_to_hiragana": ()=>{}, // Not implemented on UI yet
"/get/data/transcription_engines": ()=>{}, // Not implemented on UI yet. (if ai_models has not been detected, this will be blank array[]. if the ai_models are ok but just network has not connected, it'l be only ["Whisper"])
}; };
const error_routes = { const error_routes = {

View File

@@ -106,6 +106,7 @@ const createAtomWithHook = (initialValue, base_name, options) => {
// Common // Common
export const { atomInstance: Atom_IsBackendReady, useHook: useStore_IsBackendReady } = createAtomWithHook(false, "IsBackendReady"); export const { atomInstance: Atom_IsBackendReady, useHook: useStore_IsBackendReady } = createAtomWithHook(false, "IsBackendReady");
export const { atomInstance: Atom_IsVrctAvailable, useHook: useStore_IsVrctAvailable } = createAtomWithHook(true, "IsVrctAvailable");
export const { atomInstance: Atom_ComputeMode, useHook: useStore_ComputeMode } = createAtomWithHook("", "ComputeMode"); export const { atomInstance: Atom_ComputeMode, useHook: useStore_ComputeMode } = createAtomWithHook("", "ComputeMode");
export const { atomInstance: Atom_IsOpenedConfigPage, useHook: useStore_IsOpenedConfigPage } = createAtomWithHook(false, "IsOpenedConfigPage"); export const { atomInstance: Atom_IsOpenedConfigPage, useHook: useStore_IsOpenedConfigPage } = createAtomWithHook(false, "IsOpenedConfigPage");
export const { atomInstance: Atom_MainFunctionsStateMemory, useHook: useStore_MainFunctionsStateMemory } = createAtomWithHook({ export const { atomInstance: Atom_MainFunctionsStateMemory, useHook: useStore_MainFunctionsStateMemory } = createAtomWithHook({