mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
ModelsModals: extract auto-open
This commit is contained in:
@@ -2,6 +2,11 @@ import * as React from 'react';
|
||||
|
||||
import { optimaActions, optimaOpenPreferences, useOptimaModals } from './useOptima';
|
||||
|
||||
// auto-open models trigger
|
||||
import { optimaOpenModels } from '~/common/layout/optima/useOptima';
|
||||
import { runWhenIdle } from '~/common/util/pwaUtils';
|
||||
import { useModelsZeroState } from '~/common/stores/llms/hooks/useModelsZeroState';
|
||||
|
||||
// Modals
|
||||
import { AixDebuggerDialog } from '~/modules/aix/client/debugger/AixDebuggerDialog';
|
||||
import { LogViewerDialog } from '~/common/logger/viewer/LoggerViewerDialog';
|
||||
@@ -20,6 +25,16 @@ export function Modals(props: { suspendAutoModelsSetup?: boolean }) {
|
||||
// derived state
|
||||
const { closeAIXDebugger, closeKeyboardShortcuts, closeLogger, closePreferences, openKeyboardShortcuts } = optimaActions();
|
||||
|
||||
|
||||
// [effect] Auto-open the configurator - anytime no service is selected
|
||||
const hasNoServices = useModelsZeroState();
|
||||
const autoOpenTrigger = hasNoServices && !props.suspendAutoModelsSetup;
|
||||
React.useEffect(() => {
|
||||
if (autoOpenTrigger)
|
||||
return runWhenIdle(() => optimaOpenModels(), 2000);
|
||||
}, [autoOpenTrigger]);
|
||||
|
||||
|
||||
return <>
|
||||
|
||||
{/* Overlay - Preferences Modal */}
|
||||
|
||||
Reference in New Issue
Block a user