Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(generate): restyle section shell

Josh Corbettb617060c6ea5
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/shared/GenerateCollapsibleSection.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/shared/GenerateCollapsibleSection.browser.test.tsx
new file mode 100644
index 0000000000..e77e09bfe7
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/generation/ui/shared/GenerateCollapsibleSection.browser.test.tsx
@@ -0,0 +1,127 @@
+/* oxlint-disable react-perf/jsx-no-new-object-as-prop */
+import { ChakraProvider, Stack } from '@chakra-ui/react';
+import { system } from '@theme/system';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { GenerateCollapsibleSection } from './GenerateCollapsibleSection';
+
+vi.mock('@features/generation/ui/GenerationUiContext', () => ({
+ useGenerationUi: () => ({
+ sectionPreferences: { sectionsOpen: { 'open-section': true, 'shut-section': false }, setSectionOpen: vi.fn() },
+ }),
+}));
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+let host: HTMLDivElement | null = null;
+let root: Root | null = null;
+
+afterEach(async () => {
+ await act(() => root?.unmount());
+ host?.remove();
+ host = null;
+ root = null;
+});
+
+const render = async (children: React.ReactNode) => {
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+
+ await act(() => {
+ root?.render(<ChakraProvider value={system}>{children}</ChakraProvider>);
+ });
+};
+
+const getSections = () => [...document.querySelectorAll<HTMLElement>('.generate-section')];
+
+describe('GenerateCollapsibleSection list styling', () => {
+ it('styles by DOM state so uncontrolled sections (no sectionId) still read as cards', async () => {
+ // Upscale's sections pass only defaultOpen — openness never reaches the
+ // component as a prop, so any prop-driven styling is blind to them.
+ await render(
+ <GenerateCollapsibleSection defaultOpen label="Uncontrolled">
+ <div>body</div>
+ </GenerateCollapsibleSection>
+ );
+
+ const [section] = getSections();
+
+ expect(section?.dataset.state).toBe('open');
+ expect(getComputedStyle(section!).backgroundColor).not.toBe('rgba(0, 0, 0, 0)');
+ // A lone row has no neighboring section, so no separator shows.
+ expect(getComputedStyle(section!, '::before').opacity).toBe('0');
+ expect(getComputedStyle(section!, '::after').content).toBe('none');
+ });
+
+ it('draws one overlay hairline per section|section boundary and fades the ones touching an open card', async () => {
+ await render(
+ <Stack gap={1}>
+ <GenerateCollapsibleSection label="A" sectionId="open-section">
+ <div>a</div>
+ </GenerateCollapsibleSection>
+ <GenerateCollapsibleSection label="B" sectionId="shut-section">
+ <div>b</div>
+ </GenerateCollapsibleSection>
+ <GenerateCollapsibleSection label="C" sectionId="shut-section">
+ <div>c</div>
+ </GenerateCollapsibleSection>
+ </Stack>
+ );
+
+ const [open, afterOpen, afterClosed] = getSections();
+
+ expect(open?.dataset.state).toBe('open');
+ expect(afterOpen?.dataset.state).toBe('closed');
+
+ // The separators are pseudo-element overlays centered in the gap — real
+ // borders or margins would move content on open/close. Each boundary gets
+ // exactly ONE 1px line (the lower row's ::before): a second overlapping
+ // half would stack the translucent border color into a heavier line.
+ for (const section of [open, afterOpen, afterClosed]) {
+ expect(getComputedStyle(section!).borderTopWidth).toBe('0px');
+ expect(getComputedStyle(section!).marginTop).toBe('0px');
+ expect(getComputedStyle(section!, '::before').position).toBe('absolute');
+ expect(getComputedStyle(section!, '::before').top).toBe('-2px');
+ expect(getComputedStyle(section!, '::before').borderTopWidth).toBe('1px');
+ // Separators live only between rows: nothing ever closes the list.
+ expect(getComputedStyle(section!, '::after').content).toBe('none');
+ }
+
+ // The lines touching the open card are faded: its own, and the one under
+ // it (owned by the next row); the closed|closed boundary stays visible.
+ expect(getComputedStyle(open!, '::before').opacity).toBe('0');
+ expect(getComputedStyle(afterOpen!, '::before').opacity).toBe('0');
+ expect(getComputedStyle(afterClosed!, '::before').opacity).toBe('1');
+ // Closed rows never carry the card treatment.
+ expect(getComputedStyle(afterOpen!).backgroundColor).toBe('rgba(0, 0, 0, 0)');
+ });
+
+ it('shows separators only between sections — none above the first row, even after a non-section', async () => {
+ await render(
+ <Stack gap={1}>
+ <div>model card stand-in</div>
+ <GenerateCollapsibleSection label="A" sectionId="shut-section">
+ <div>a</div>
+ </GenerateCollapsibleSection>
+ <GenerateCollapsibleSection label="B" sectionId="shut-section">
+ <div>b</div>
+ </GenerateCollapsibleSection>
+ <GenerateCollapsibleSection label="C" sectionId="open-section">
+ <div>c</div>
+ </GenerateCollapsibleSection>
+ </Stack>
+ );
+
+ const [first, second, open] = getSections();
+
+ // A closed first row draws nothing above itself: the element before it is
+ // not a section, so that boundary is not section|section.
+ expect(getComputedStyle(first!, '::before').opacity).toBe('0');
+ expect(getComputedStyle(second!, '::before').opacity).toBe('1');
+ // The boundary above the open card is the card's own ::before — faded.
+ expect(getComputedStyle(open!, '::before').opacity).toBe('0');
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/shared/GenerateCollapsibleSection.tsx b/invokeai/frontend/webv2/src/features/generation/ui/shared/GenerateCollapsibleSection.tsx
index 6942b723dc..9f1af98b1d 100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/shared/GenerateCollapsibleSection.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/shared/GenerateCollapsibleSection.tsx
@@ -15,6 +15,49 @@ type Props = {
const COLLAPSIBLE_INDICATOR_OPEN_STYLES = { transform: 'rotate(90deg)' };
+/**
+ * Closed: a quiet hairline row in the list. Open: a card — background, radius,
+ * breathing room — with no separators of its own.
+ *
+ * Three invariants make it feel right:
+ *
+ * - Everything keys off the DOM's `data-state`, not React state: sections
+ * without a `sectionId` (Upscale passes only `defaultOpen`) run uncontrolled,
+ * so their openness never reaches this component as a prop — the browser
+ * always has it.
+ * - The geometry is constant. The hosting Stack keeps a fixed `gap="1"`
+ * between rows in every state, so opening a section never adds a margin or a
+ * border — nothing below shifts by even a pixel.
+ * - The separators are pseudo-element overlays, not borders on the box, and
+ * exactly ONE line is painted per boundary, only BETWEEN rows: a section's
+ * `::before` (a 1px border-top centered in the gap) shows only when the
+ * element above it is another section — so nothing renders above the first
+ * row (even mid-stack, after non-section siblings) or below the last, and
+ * two overlapping halves never stack the translucent border color into a
+ * heavier line. Around an open card the touching lines fade out — the
+ * card's own via `data-state`, the one below it via `A + B`, since no
+ * section can see its neighbor's state on its own. Only opacity and
+ * background ever animate.
+ */
+const SECTION_OPEN_STYLES = { bg: 'bg.muted', rounded: 'sm' };
+const SECTION_STYLES = {
+ '&::before': {
+ content: '""',
+ position: 'absolute',
+ insetInline: 0,
+ top: 'calc(var(--chakra-spacing-1) / -2)',
+ borderTopWidth: '1px',
+ pointerEvents: 'none',
+ opacity: 0,
+ transition: 'opacity var(--wb-motion-duration-slow) ease',
+ },
+ '.generate-section + &::before': { opacity: 1 },
+ // Order matters against the rule above: at equal specificity, an open
+ // section's own state must win over its predecessor's presence.
+ '&[data-state="open"]::before': { opacity: 0 },
+ '.generate-section[data-state="open"] + &::before': { opacity: 0 },
+} as const;
+
export const GenerateCollapsibleSection = ({ badges, children, defaultOpen, isOpen, label, sectionId }: Props) => {
const { sectionPreferences } = useGenerationUi();
const persistedOpen = sectionId === undefined ? undefined : sectionPreferences.sectionsOpen[sectionId];
@@ -30,14 +73,16 @@ export const GenerateCollapsibleSection = ({ badges, children, defaultOpen, isOp
return (
<Collapsible.Root
- bg="bg.muted/50"
+ className="generate-section"
+ css={SECTION_STYLES}
+ _open={SECTION_OPEN_STYLES}
defaultOpen={sectionId === undefined ? defaultOpen : undefined}
open={resolvedOpen}
- overflow="hidden"
- rounded="md"
+ position="relative"
+ transition="background var(--wb-motion-duration-slow) ease, border-radius var(--wb-motion-duration-slow) ease"
onOpenChange={sectionId === undefined ? undefined : handleOpenChange}
>
- <Collapsible.Trigger display="flex" gap={2} w="full" px={2} h="8" alignItems="center">
+ <Collapsible.Trigger display="flex" gap={2} w="full" px={1.5} h="8" alignItems="center">
<Collapsible.Indicator
_open={COLLAPSIBLE_INDICATOR_OPEN_STYLES}
transition="transform var(--wb-motion-duration-slow)"
@@ -61,7 +106,8 @@ export const GenerateCollapsibleSection = ({ badges, children, defaultOpen, isOp
{badges}
</Flex>
</Collapsible.Trigger>
- <Collapsible.Content bg="bg.muted">
+
+ <Collapsible.Content>
<Box borderTopWidth={1} borderColor="bg.subtle">
{children}
</Box>
diff --git a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx
index 2c50fc8c1f..f53f959cc2 100644
--- a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx
@@ -436,7 +436,7 @@ export const UpscaleWidgetView = () => {
);
return (
- <Stack gap="1" minW="0" p="1">
+ <Stack gap={1} minW={0} p="1">
<UpscaleModelReconciler
key={`${projectId}:${modelsStatus}:${modelsFingerprint}`}
rawValues={rawValues}