feat(ui): add new gallery/canvas session buttons to queue actions menu

A new "session" just means to reset most settings to default values, excluding model.

There are a few things that need to be reset:
- Parameters state, except for models and things dependent on model selection (like VAE precision)
- Canvas state, except for the `modelBase`, which is dependent on the model selection
- Canvas staging area state
- LoRAs state
- HRF state
- Style presets state

We also select the canvas tab.

For new gallery sessions, we:
- Open the image viewer
- Set the right panel tab to `gallery`

And for new canvas sessions, we:
- Close the image viewer
- Set the right panel tab to `layers`
This commit is contained in:
psychedelicious
2024-10-03 17:15:54 +10:00
committed by Kent Keirsey
parent b793328edd
commit 2d1e745594
12 changed files with 84 additions and 6 deletions

View File

@@ -1,5 +1,11 @@
import { IconButton, Menu, MenuButton, MenuGroup, MenuItem, MenuList } from '@invoke-ai/ui-library';
import { useAppDispatch } from 'app/store/storeHooks';
import { newCanvasSessionRequested, newGallerySessionRequested } from 'features/controlLayers/store/actions';
import {
selectCanvasRightPanelGalleryTab,
selectCanvasRightPanelLayersTab,
} from 'features/controlLayers/store/ephemeral';
import { useImageViewer } from 'features/gallery/components/ImageViewer/useImageViewer';
import { useClearQueue } from 'features/queue/components/ClearQueueConfirmationAlertDialog';
import { QueueCountBadge } from 'features/queue/components/QueueCountBadge';
import { usePauseProcessor } from 'features/queue/hooks/usePauseProcessor';
@@ -25,6 +31,7 @@ export const QueueActionsMenuButton = memo(() => {
const { t } = useTranslation();
const isPauseEnabled = useFeatureStatus('pauseQueue');
const isResumeEnabled = useFeatureStatus('resumeQueue');
const imageViewer = useImageViewer();
const clearQueue = useClearQueue();
const {
resumeProcessor,
@@ -39,6 +46,16 @@ export const QueueActionsMenuButton = memo(() => {
const openQueue = useCallback(() => {
dispatch(setActiveTab('queue'));
}, [dispatch]);
const onClickNewGallerySession = useCallback(() => {
dispatch(newGallerySessionRequested());
imageViewer.open();
selectCanvasRightPanelGalleryTab();
}, [dispatch, imageViewer]);
const onClickNewCanvasSession = useCallback(() => {
dispatch(newCanvasSessionRequested());
imageViewer.close();
selectCanvasRightPanelLayersTab();
}, [dispatch, imageViewer]);
return (
<>
@@ -46,10 +63,10 @@ export const QueueActionsMenuButton = memo(() => {
<MenuButton ref={ref} as={IconButton} size="lg" aria-label="Queue Actions Menu" icon={<PiListBold />} />
<MenuList>
<MenuGroup title={t('common.new')}>
<MenuItem icon={<PiImageBold />} onClick={resumeProcessor} isLoading={isLoadingResumeProcessor}>
<MenuItem icon={<PiImageBold />} onClick={onClickNewGallerySession}>
{t('controlLayers.newGallerySession')}
</MenuItem>
<MenuItem icon={<PiPaintBrushBold />} onClick={resumeProcessor} isLoading={isLoadingResumeProcessor}>
<MenuItem icon={<PiPaintBrushBold />} onClick={onClickNewCanvasSession}>
{t('controlLayers.newCanvasSession')}
</MenuItem>
</MenuGroup>