From d842066f5176ec56345f6536fb7d02b518556f82 Mon Sep 17 00:00:00 2001 From: kaj <40004347+KAJdev@users.noreply.github.com> Date: Mon, 24 Jul 2023 19:41:16 -0800 Subject: [PATCH] inline comfy output display --- .../src/App/Sidebar/Section.tsx | 2 +- .../src/App/Sidebar/Tab/index.tsx | 4 +- packages/stablestudio-ui/src/Comfy/index.tsx | 37 ++++++++++++++++--- .../src/Editor/Sidebar/index.tsx | 26 +++++++------ .../src/Generation/Image/Sidebar/index.tsx | 35 +++++++++--------- 5 files changed, 67 insertions(+), 37 deletions(-) diff --git a/packages/stablestudio-ui/src/App/Sidebar/Section.tsx b/packages/stablestudio-ui/src/App/Sidebar/Section.tsx index 2613494..4508cb2 100644 --- a/packages/stablestudio-ui/src/App/Sidebar/Section.tsx +++ b/packages/stablestudio-ui/src/App/Sidebar/Section.tsx @@ -47,7 +47,7 @@ export function Section(props: Section.Props) { )} > {title && ( -
+
{ + useEffect(() => { setTab(props.name, { enabled: true, ...props }); return () => setTab(props.name); }, [props, setTab]); - useLayoutEffect(() => { + useEffect(() => { (window.location.pathname === props.route || (window.location.pathname === "/" && props.defaultActive)) && setSidebar((sidebar) => ({ ...sidebar, tab: props.name })); diff --git a/packages/stablestudio-ui/src/Comfy/index.tsx b/packages/stablestudio-ui/src/Comfy/index.tsx index 1907f90..6dcdb66 100644 --- a/packages/stablestudio-ui/src/Comfy/index.tsx +++ b/packages/stablestudio-ui/src/Comfy/index.tsx @@ -1,6 +1,5 @@ import { useLocation } from "react-router-dom"; import { create } from "zustand"; -import { shallow } from "zustand/shallow"; import { Generation } from "~/Generation"; export type ComfyApp = { @@ -122,6 +121,9 @@ type State = { lastOuput: ComfyOutput | null; setLastOutput: (output: ComfyOutput | null) => void; + + inlineExpanded: boolean; + setInlineExpanded: (expanded: boolean) => void; }; export namespace Comfy { @@ -154,6 +156,9 @@ export namespace Comfy { lastOuput: null, setLastOutput: (lastOuput) => set({ lastOuput }), + + inlineExpanded: false, + setInlineExpanded: (inlineExpanded) => set({ inlineExpanded }), })); export const registerListeners = async () => { @@ -274,12 +279,34 @@ export namespace Comfy { use.getState().setRunning(true); }; - export const Output = () => { - const output = Comfy.use(({ output }) => output, shallow); + export const Output = ({ + className, + small, + }: Styleable & { + small?: boolean; + }) => { + const { output, inlineExpanded, setInlineExpanded } = Comfy.use( + (state) => ({ + output: state.output, + inlineExpanded: state.inlineExpanded, + setInlineExpanded: state.setInlineExpanded, + }) + ); return ( -
- {[...output].reverse().map((line, index) => ( +
setInlineExpanded(!inlineExpanded)} + > + {(small && !inlineExpanded + ? output.slice(-1) + : [...output].reverse() + ).map((line, index) => (

- createDream()} - fullWidth - disabled={ - !inputID || - generating || - !(dreams.filter((d) => d.id === selectedID).length > 0) - } - loading={generating} - /> +

+ + createDream()} + fullWidth + disabled={ + !inputID || + generating || + !(dreams.filter((d) => d.id === selectedID).length > 0) + } + loading={generating} + /> +
); diff --git a/packages/stablestudio-ui/src/Generation/Image/Sidebar/index.tsx b/packages/stablestudio-ui/src/Generation/Image/Sidebar/index.tsx index 5cabc27..ebeb60a 100644 --- a/packages/stablestudio-ui/src/Generation/Image/Sidebar/index.tsx +++ b/packages/stablestudio-ui/src/Generation/Image/Sidebar/index.tsx @@ -1,5 +1,6 @@ import { useLocation } from "react-router-dom"; import { App } from "~/App"; +import { Comfy } from "~/Comfy"; import { Generation } from "~/Generation"; import { Theme } from "~/Theme"; @@ -11,6 +12,20 @@ export function Sidebar() { const location = useLocation(); if (!input?.id) return null; + + const bottom = ( + +
+ + createDream()} + fullWidth + /> +
+
+ ); + return ( <> - createDream()} - fullWidth - /> - - } + bottom={bottom} > @@ -49,15 +56,7 @@ export function Sidebar() { location.pathname.startsWith("/edit") || location.pathname.startsWith("/nodes") } - bottom={ - - createDream()} - fullWidth - /> - - } + bottom={bottom} >