Skip to content

Commit 08b1fee

Browse files
authored
add base prop for destination to direct users to different tabs on initial load (#6706)
## Summary - we want a way to load the studio while being directed to a specific tab, introduced a destination prop to achieve that <!--A description of the changes in this PR. Include the kind of change (fix, feature, docs, etc), the "why" and the "how". Screenshots or videos are useful for frontend changes.--> ## Related Issues / Discussions <!--WHEN APPLICABLE: List any related issues or discussions on github or discord. If this PR closes an issue, please use the "Closes #1234" format, so that the issue will be automatically closed when the PR merges.--> ## QA Instructions <!--WHEN APPLICABLE: Describe how you have tested the changes in this PR. Provide enough detail that a reviewer can reproduce your tests.--> ## Merge Plan <!--WHEN APPLICABLE: Large PRs, or PRs that touch sensitive things like DB schemas, may need some care when merging. For example, a careful rebase by the change author, timing to not interfere with a pending release, or a message to contributors on discord after merging.--> ## Checklist - [ ] _The PR has a short but descriptive title, suitable for a changelog_ - [ ] _Tests added / updated (if applicable)_ - [ ] _Documentation added / updated (if applicable)_
2 parents 4ce64b6 + e78fb42 commit 08b1fee

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

invokeai/frontend/web/src/app/components/App.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { useStarterModelsToast } from 'features/modelManagerV2/hooks/useStarterM
1616
import { configChanged } from 'features/system/store/configSlice';
1717
import { languageSelector } from 'features/system/store/systemSelectors';
1818
import InvokeTabs from 'features/ui/components/InvokeTabs';
19+
import type { InvokeTabName } from 'features/ui/store/tabMap';
20+
import { setActiveTab } from 'features/ui/store/uiSlice';
1921
import { AnimatePresence } from 'framer-motion';
2022
import i18n from 'i18n';
2123
import { size } from 'lodash-es';
@@ -34,9 +36,10 @@ interface Props {
3436
imageName: string;
3537
action: 'sendToImg2Img' | 'sendToCanvas' | 'useAllParameters';
3638
};
39+
destination?: InvokeTabName | undefined;
3740
}
3841

39-
const App = ({ config = DEFAULT_CONFIG, selectedImage }: Props) => {
42+
const App = ({ config = DEFAULT_CONFIG, selectedImage, destination }: Props) => {
4043
const language = useAppSelector(languageSelector);
4144
const logger = useLogger('system');
4245
const dispatch = useAppDispatch();
@@ -67,6 +70,12 @@ const App = ({ config = DEFAULT_CONFIG, selectedImage }: Props) => {
6770
}
6871
}, [dispatch, config, logger]);
6972

73+
useEffect(() => {
74+
if (destination) {
75+
dispatch(setActiveTab(destination));
76+
}
77+
}, [dispatch, destination]);
78+
7079
useEffect(() => {
7180
dispatch(appStarted());
7281
}, [dispatch]);

invokeai/frontend/web/src/app/components/InvokeAIUI.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type { PartialAppConfig } from 'app/types/invokeai';
1919
import Loading from 'common/components/Loading/Loading';
2020
import AppDndContext from 'features/dnd/components/AppDndContext';
2121
import type { WorkflowCategory } from 'features/nodes/types/workflow';
22+
import type { InvokeTabName } from 'features/ui/store/tabMap';
2223
import type { PropsWithChildren, ReactNode } from 'react';
2324
import React, { lazy, memo, useEffect, useMemo } from 'react';
2425
import { Provider } from 'react-redux';
@@ -43,6 +44,7 @@ interface Props extends PropsWithChildren {
4344
imageName: string;
4445
action: 'sendToImg2Img' | 'sendToCanvas' | 'useAllParameters';
4546
};
47+
destination?: InvokeTabName;
4648
customStarUi?: CustomStarUi;
4749
socketOptions?: Partial<ManagerOptions & SocketOptions>;
4850
isDebugging?: boolean;
@@ -62,6 +64,7 @@ const InvokeAIUI = ({
6264
projectUrl,
6365
queueId,
6466
selectedImage,
67+
destination,
6568
customStarUi,
6669
socketOptions,
6770
isDebugging = false,
@@ -218,7 +221,7 @@ const InvokeAIUI = ({
218221
<React.Suspense fallback={<Loading />}>
219222
<ThemeLocaleProvider>
220223
<AppDndContext>
221-
<App config={config} selectedImage={selectedImage} />
224+
<App config={config} selectedImage={selectedImage} destination={destination} />
222225
</AppDndContext>
223226
</ThemeLocaleProvider>
224227
</React.Suspense>

0 commit comments

Comments
 (0)