Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion dist/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,48 @@
"type": "panel",
"id": "contextmanager",
"label": {
"default": "Context Manager"
"default": "AI Manager"
},
"minimumSize": {
"width": 400,
"height": 150
},
"maximumSize": {
"width": 1340,
"height": 1516
},
"preferredDockedSize": {
"width": 340,
"height": 516
},
"preferredFloatingSize": {
"width": 340,
"height": 315
},
"icons": [
{
"width": 23,
"height": 23,
"path": "icons/bashful_23.png",
"scale": [1, 2],
"theme": ["dark", "darkest"],
"species": ["chrome"]
},
{
"width": 23,
"height": 23,
"path": "icons/bashful_23.png",
"scale": [1, 2],
"theme": ["lightest", "light"],
"species": ["chrome"]
}
]
},
{
"type": "panel",
"id": "contextpalette",
"label": {
"default": "AI Brush"
},
"minimumSize": {
"width": 400,
Expand Down
43 changes: 42 additions & 1 deletion plugin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,48 @@
"type": "panel",
"id": "contextmanager",
"label": {
"default": "Context Manager"
"default": "AI Manager"
},
"minimumSize": {
"width": 400,
"height": 150
},
"maximumSize": {
"width": 1340,
"height": 1516
},
"preferredDockedSize": {
"width": 340,
"height": 516
},
"preferredFloatingSize": {
"width": 340,
"height": 315
},
"icons": [
{
"width": 23,
"height": 23,
"path": "icons/bashful_23.png",
"scale": [1, 2],
"theme": ["dark", "darkest"],
"species": ["chrome"]
},
{
"width": 23,
"height": 23,
"path": "icons/bashful_23.png",
"scale": [1, 2],
"theme": ["lightest", "light"],
"species": ["chrome"]
}
]
},
{
"type": "panel",
"id": "contextpalette",
"label": {
"default": "AI Brush"
},
"minimumSize": {
"width": 400,
Expand Down
1 change: 1 addition & 0 deletions src/common/types/htmlTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export interface ExtendedHTMLDialogElement extends HTMLDialogElement {
uxpShowModal(options: any): Promise<void>;
uxpShow(options: any): Promise<void>;
}
23 changes: 12 additions & 11 deletions src/components/Context/ContextInfoColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import ContextLabel from './ContextLabel';

export type ContextInfoColumnProps = {
contextID: string;
contextType: ContextType;
};

function DefaultContextInfoColumn() {
Expand All @@ -26,8 +27,8 @@ function DefaultContextInfoColumn() {
}

export default function ContextInfoColumn(props: ContextInfoColumnProps) {
let layerContext = useContextStore((state: ContextStoreState) =>
state.getContextFromStore(props.contextID, ContextType.LAYER)
let genAISettings = useContextStore((state: ContextStoreState) =>
state.getContextFromStore(props.contextID, props.contextType)
);

let getContextFromStore = useContextStore(
Expand All @@ -39,7 +40,7 @@ export default function ContextInfoColumn(props: ContextInfoColumnProps) {
);

let { loading, value } = useAsyncEffect(async () => {
if (layerContext.is_cloud_run == false) {
if (!(genAISettings?.is_cloud_run)) {
// While this does work, this is for the future where we batch run the models, currently
// we would have to make sure each local user swaps out the models when they want to use
// a different model on a specific layer. We will collect the selection of models for them
Expand All @@ -50,13 +51,13 @@ export default function ContextInfoColumn(props: ContextInfoColumnProps) {
} else {
return getAvailableModelConfigs();
}
}, [layerContext.is_cloud_run]);
}, [genAISettings?.is_cloud_run]);

function getDropDownOptions() {
if (loading) {
return ['loading models...'];
} else {
if (layerContext.is_cloud_run == false) {
if (genAISettings.is_cloud_run == false) {
return value
.map((modelObj: ModelResponse) => {
return modelObj.title;
Expand All @@ -75,7 +76,7 @@ export default function ContextInfoColumn(props: ContextInfoColumnProps) {
function saveSelectedModelConfig(selectedConfigObj: ModelConfigResponse) {
let copyOfContext = getContextFromStore(
props.contextID,
ContextType.LAYER
props.contextType
).copy();
copyOfContext.model_config = selectedConfigObj.name;
saveContextToStore(copyOfContext);
Expand All @@ -88,7 +89,7 @@ export default function ContextInfoColumn(props: ContextInfoColumnProps) {
}

function getCorrectContextKey() {
if (!layerContext.is_cloud_run) {
if (!genAISettings.is_cloud_run) {
return 'generationModelName' as keyof typeof LayerAIContext;
}

Expand All @@ -99,27 +100,27 @@ export default function ContextInfoColumn(props: ContextInfoColumnProps) {
return (
<div className="flex flex-col min-w-fit justify-center">
<ContextLabel
value={layerContext.currentLayer?.name}
value={genAISettings.currentLayer?.name}
labelText={'Layer Name:'}
/>
{loading ? (
<ContextDropdown
label="Model:"
contextID={props.contextID}
contextType={ContextType.LAYER}
contextType={props.contextType}
options={['loading models...']}
/>
) : (
getDropDownOptions().length > 0 && (
<ContextDropdown
// Not sure why, but is_cloud_run is backwards
label={
!layerContext.is_cloud_run
!genAISettings.is_cloud_run
? 'Model:'
: 'Art Type:'
}
contextID={props.contextID}
contextType={ContextType.LAYER}
contextType={props.contextType}
contextKey={getCorrectContextKey()}
options={getDropDownOptions()}
onChange={(event: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,53 @@ import React from 'react';

import ContextInfoColumn from './ContextInfoColumn';
import ContextToolColumn from './ContextToolColumn';
import ContextToolBar from './ContextToolBar';
import LayerContextToolBar from './LayerContextToolBar';
import ContextSlider from './ContextSlider';

import _ from 'lodash';
import LayerAIContext from 'models/LayerAIContext';
import ContextTextarea from './ContextTextarea';
import { ContextType } from 'bashConstants';
import ContextTagArea from './ContextTagArea';
import ContextObject from 'models/ContextObject';
export type ContextItemProps = {
contextID: string;
contextType: ContextType;
};

export default function ContextItem(props: ContextItemProps) {
export default function LayerContextItem(props: ContextItemProps) {
return (
<div className="flex flex-col p-1 bg-[color:var(--uxp-host-widget-hover-background-color)] border border-[color:var(--uxp-host-border-color)] rounded">
<ContextToolBar contextID={props.contextID} />
<LayerContextToolBar contextID={props.contextID} />
<div className="flex">
<ContextInfoColumn contextID={props.contextID} />
<ContextInfoColumn contextID={props.contextID} contextType={ContextType.LAYER}/>
<ContextToolColumn contextID={props.contextID} />
</div>
<div>
<ContextSlider
animate={true}
contextID={props.contextID}
contextType={ContextType.LAYER}
contextType={props.contextType}
contextKey={
'consistencyStrength' as keyof typeof LayerAIContext
'consistencyStrength' as keyof typeof ContextObject
}
>
Consistency Strength
</ContextSlider>
<ContextSlider
animate={true}
contextID={props.contextID}
contextType={ContextType.LAYER}
contextType={props.contextType}
contextKey={
'stylingStrength' as keyof typeof LayerAIContext
'stylingStrength' as keyof typeof ContextObject
}
>
Styling Strength
</ContextSlider>
<ContextTextarea
contextID={props.contextID}
contextType={ContextType.LAYER}
contextKey={'currentPrompt' as keyof typeof LayerAIContext}
contextType={props.contextType}
contextKey={'currentPrompt' as keyof typeof ContextObject}
className="w-full select-none"
inputDelayTime={1000}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ import {
toggleOffContextHidingTool,
toggleOnContextHidingTool,
} from 'services/tools_service';
import { popUpModal } from 'utils/general_utils';
import { popUp, popUpModal } from 'utils/general_utils';
import { ExtendedHTMLDialogElement } from 'common/types/htmlTypes';
import photoshop from 'photoshop';
import Spectrum, { Checkbox, Label } from 'react-uxp-spectrum';
import Tool from 'components/Tool';
import RegenerationTool from 'components/RegenerationTool';
import ContextPainterModal from 'components/modals/ContextPainterModal';
import ContextPainterModal from 'components/modals/ContextPaletteModal';
import { ContextType } from 'bashConstants';
import { Layer } from 'photoshop/dom/Layer';
import { entrypoints } from 'uxp';

const events = [
'make',
Expand Down Expand Up @@ -56,7 +57,7 @@ export type ContexToolBarColumnProps = {
contextID: string;
};

export default function ContextToolBar(props: ContexToolBarColumnProps) {
export default function LayerContextToolBar(props: ContexToolBarColumnProps) {
const getContextFromStore = useContextStore(
(state: ContextStoreState) => state.getContextFromStore
);
Expand Down Expand Up @@ -190,30 +191,35 @@ export default function ContextToolBar(props: ContexToolBarColumnProps) {
}
/>
</ToolSection>
<ToolbarDivider />
{/* <ToolbarDivider />
<ToolSection>
<Tool
icon={GridViewIcon}
label="Context Painter"
onClick={() =>
popUpModal(
{

console.log(popupRef.current);
popUpModal(
popupRef,
<ContextPainterModal
handle={popupRef.current}
contextID={props.contextID}
/>,
'Context Painter'
)
}
}
/>
</ToolSection>
</ToolSection> */}
<ToolbarDivider />
<ToolSection>
<RegenerationTool
icon={RefreshIcon}
label="Regenerate Layer"
contextId={props.contextID}
newLayerDTOSelectionFunc={setSelectedLayerDTO}
contextType={ContextType.LAYER}
/>
</ToolSection>
<ToolbarDivider />
Expand Down
62 changes: 62 additions & 0 deletions src/components/Context/PromptContextItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React from 'react';

import ContextInfoColumn from './ContextInfoColumn';
import ContextToolColumn from './ContextToolColumn';
import LayerContextToolBar from './LayerContextToolBar';
import ContextSlider from './ContextSlider';

import _ from 'lodash';
import LayerAIContext from 'models/LayerAIContext';
import ContextTextarea from './ContextTextarea';
import { ContextType } from 'bashConstants';
import ContextTagArea from './ContextTagArea';
import ContextObject from 'models/ContextObject';
import RegenerationTool from 'components/RegenerationTool';
import { RefreshIcon } from 'components/Icons/index';
import PromptContextToolBar from './PromptContextToolBar';
export type ContextItemProps = {
contextID: string;
contextType: ContextType;
};

export default function PromptContextItem(props: ContextItemProps) {
return (
<div className="flex flex-col p-1 bg-[color:var(--uxp-host-widget-hover-background-color)] border border-[color:var(--uxp-host-border-color)] rounded">
<PromptContextToolBar contextID={props.contextID} />

{/* <div className="flex">
<ContextInfoColumn contextID={props.contextID} />
<ContextToolColumn contextID={props.contextID} />
</div> */}
<div>
<ContextSlider
animate={true}
contextID={props.contextID}
contextType={props.contextType}
contextKey={
'consistencyStrength' as keyof typeof ContextObject
}
>
Consistency Strength
</ContextSlider>
<ContextSlider
animate={true}
contextID={props.contextID}
contextType={props.contextType}
contextKey={
'stylingStrength' as keyof typeof ContextObject
}
>
Styling Strength
</ContextSlider>
<ContextTextarea
contextID={props.contextID}
contextType={props.contextType}
contextKey={'currentPrompt' as keyof typeof ContextObject}
className="w-full select-none"
inputDelayTime={1000}
/>
</div>
</div>
);
}
Loading