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.

chore(webv2): trim explanatory comments

joshistoastdf8150c0cfcc
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetChrome.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetChrome.tsx
index 0bbcb7df73..a7351a92b8 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetChrome.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetChrome.tsx
@@ -23,15 +23,8 @@ type GalleryChromeProps = { region: GalleryWidgetProps['region'] };
const ACCEPTED_UPLOAD_EXTENSIONS = 'image/png,image/jpeg,image/webp,video/mp4,.png,.jpg,.jpeg,.webp,.mp4';
const UPLOAD_INPUT_STYLE = { display: 'none' } as const;
-// Ghost buttons fill when expanded, and the boards start expanded — which left
-// the label looking pressed at rest. The chevron carries the state instead.
const LABEL_EXPANDED_PROPS = { bg: 'transparent' } as const;
-/**
- * Frame chrome mounts outside `GalleryWidgetView` and so outside its context;
- * it reads the App-owned UI port directly. The boards query is the one the view
- * already caches.
- */
const useGalleryChromeBoards = () => {
const { gallery, galleryValues } = useGalleryUi();
const settings = getGallerySettings(galleryValues);
@@ -54,7 +47,6 @@ const useGalleryChromeBoards = () => {
};
};
-/** Separate from the read-only hook so the label skips assembling upload actions. */
const useGalleryChromeActions = () => {
const { boards, galleryValues, selectedBoardId, ...rest } = useGalleryChromeBoards();
const galleryView = getGalleryView(galleryValues);
@@ -68,10 +60,6 @@ const useGalleryChromeActions = () => {
return { ...rest, boards, galleryValues, selectedBoardId, uploadFiles };
};
-/**
- * `Gallery / [Board]`, where the board name expands and collapses the panel —
- * the shape the workflow widget uses for its library trigger.
- */
export const GalleryWidgetLabel = ({ region }: GalleryChromeProps) => {
const { t } = useTranslation();
const { boards, gallery, selectedBoardId, settings } = useGalleryChromeBoards();
@@ -85,10 +73,7 @@ export const GalleryWidgetLabel = ({ region }: GalleryChromeProps) => {
);
return (
- // End padding keeps the name off the frame's actions; the center floats
- // this in its own island and is exempt.
<HStack flex="1" gap="1" minW="0" pe={region === 'center' ? undefined : '2'}>
- {/* The center's view selector already names the widget. */}
{region === 'center' ? null : (
<Text flexShrink={0} fontSize="xs" fontWeight="700">
{t('widgets.labels.gallery')}
@@ -117,10 +102,6 @@ export const GalleryWidgetLabel = ({ region }: GalleryChromeProps) => {
);
};
-/**
- * Upload and grid settings, in every region. The frame owns these because the
- * center hoists header chrome into an island that would otherwise sit empty.
- */
export const GalleryWidgetHeaderActions = (_props: GalleryChromeProps) => {
const { boards, gallery, selectedBoardId, settings, uploadFiles } = useGalleryChromeActions();
diff --git a/invokeai/frontend/webv2/src/features/models/ui/components/ModelSelect.tsx b/invokeai/frontend/webv2/src/features/models/ui/components/ModelSelect.tsx
index e26e02af6f..f1809d1748 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/components/ModelSelect.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/components/ModelSelect.tsx
@@ -32,15 +32,6 @@ const EMPTY_KEYS: ReadonlySet<string> = new Set();
const getOptionId = (model: ModelConfig): string => model.key;
-/**
- * Universal single-model picker: a button-triggered searchable list over the
- * installed library, built on the generic {@link Picker}.
- *
- * Scope it with `modelTypes` — one type for dedicated pickers (a LoRA picker, a
- * main-model picker) or several for cross-type pickers. Results group by BASE
- * only; a cross-type picker marks each row with its type rather than repeating
- * a type header above every base section.
- */
export const ModelSelect = ({
className,
disabled,
@@ -58,21 +49,16 @@ export const ModelSelect = ({
}: {
className?: string;
disabled?: boolean;
- /** Hide specific models (e.g. the current model and already-linked ones). */
excludeKeys?: ReadonlySet<string>;
- /** Extra predicate, e.g. base-architecture compatibility. */
filter?: (model: ModelConfig) => boolean;
id?: string;
invalid?: boolean;
isClearable?: boolean;
- /** The model types this instance searches. */
modelTypes: ModelTaxonomyType[];
onChange: (model: ModelConfig | null) => void;
placeholder?: string;
- /** Show the shortcut to the model manager. Hide it inside the manager itself. */
showManagerButton?: boolean;
size?: 'xs' | 'sm' | 'md';
- /** Selected model key, or null. */
value: string | null;
}) => {
const { enableModelDescriptions } = useModelsUi();
@@ -83,7 +69,6 @@ export const ModelSelect = ({
const [selectedBases, setSelectedBases] = useState<ReadonlySet<string>>(EMPTY_BASES);
const [lastDisabled, setLastDisabled] = useState(disabled);
- // Sibling pickers of the same kind share one density preference.
const pickerId = id ?? `models:${modelTypes.join('+')}`;
const isCompact = useModelsUiSelector((snapshot) => snapshot.pickerCompactViews[pickerId] ?? false);
const relatedKeys = useRelatedModelKeys(isOpen ? value : null);
@@ -110,7 +95,6 @@ export const ModelSelect = ({
filter,
modelTypes,
relatedKeys,
- // The generic Picker owns text search; this pass only scopes and groups.
searchTerm: '',
})
: { availableBases: [], candidates: [], groups: [] },
@@ -118,9 +102,6 @@ export const ModelSelect = ({
);
const selectedModel = useMemo(() => models.find((model) => model.key === value) ?? null, [models, value]);
- // Keyed off what is actually installed, not the declared scope: a picker
- // scoped to main + external API models still lists only main models on most
- // installs, and badging every row "Main Model" says nothing.
const hasMixedTypes = useMemo(() => new Set(candidates.map((model) => model.type)).size > 1, [candidates]);
const scopeLabel =
modelTypes.length === 1 ? getModelTypePluralLabel(modelTypes[0] ?? 'main').toLowerCase() : 'models';
@@ -341,7 +322,6 @@ export const ModelSelect = ({
);
};
-/** Search over the facts a user actually types: name, base, type, description. */
const matchesModel = (model: ModelConfig, searchTerm: string): boolean => {
const terms = searchTerm.toLowerCase().split(/\s+/).filter(Boolean);
const haystack = `${model.name} ${model.base} ${model.type} ${model.description ?? ''}`.toLowerCase();
@@ -349,11 +329,6 @@ const matchesModel = (model: ModelConfig, searchTerm: string): boolean => {
return terms.every((term) => haystack.includes(term));
};
-/**
- * Models linked to the current selection, so they can lead their group. The
- * backend exposes only a single-key lookup, so this is scoped to "related to
- * what is selected here" rather than to everything selected app-wide.
- */
const useRelatedModelKeys = (modelKey: string | null): ReadonlySet<string> => {
const [relatedKeys, setRelatedKeys] = useState<ReadonlySet<string>>(EMPTY_KEYS);
@@ -470,10 +445,6 @@ const ModelButtonContent = ({ model }: { model: ModelConfig }) => (
</HStack>
);
-/**
- * No base badge: the group header already carries it. The type badge appears
- * only in cross-type pickers, where two rows could otherwise look identical.
- */
const ModelOptionContent = ({
enableDescription,
isRelated,
diff --git a/invokeai/frontend/webv2/src/platform/ui/ColorPicker.tsx b/invokeai/frontend/webv2/src/platform/ui/ColorPicker.tsx
index b63d165513..58a294fd21 100644
--- a/invokeai/frontend/webv2/src/platform/ui/ColorPicker.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/ColorPicker.tsx
@@ -34,10 +34,6 @@ export type ColorPickerSize = NonNullable<ComponentProps<typeof ChakraColorPicke
export type { ColorPickerFormat };
-/**
- * Machine formats behind each presented format. `hex` and `rgb` share `rgba`,
- * so switching between them changes only which inputs render — never the value.
- */
const MACHINE_FORMAT: Record<ColorPickerFormat, 'rgba' | 'hsla' | 'hsba'> = {
hex: 'rgba',
hsb: 'hsba',
@@ -53,15 +49,6 @@ const MACHINE_FORMAT: Record<ColorPickerFormat, 'rgba' | 'hsla' | 'hsba'> = {
*/
const TRANSPARENCY_CHECK_SIZE = '0.5rem';
-/**
- * Swatches wrap into as many even columns as the popover actually fits.
- *
- * `auto-fill` rather than a fixed `repeat(10, …)`: the swatch holds a fixed
- * `--swatch-size` from the size variant, so a fixed column count overflows the
- * popover the moment the swatch, the gap, or the content width changes — which
- * is exactly what happened at ten columns in a 224px popover. Deriving the
- * count from the available width instead makes that arithmetic unrepresentable.
- */
const SWATCH_GROUP_CSS = {
display: 'grid',
gap: '1',
@@ -72,65 +59,22 @@ const CHANNEL_ROW_CSS = { '& input': { minW: '0' } };
const SLIDER_STACK_CSS = { minW: '0' };
export interface ColorPickerProps {
- /** Accessible label for the swatch trigger button. */
'aria-label': string;
disabled?: boolean;
size?: ColorPickerSize;
- /**
- * The swatch row: `true` (default) shows the workbench palette followed by
- * recently committed colors, `false` hides it, and an array supplies an
- * explicit palette instead.
- */
swatches?: boolean | readonly string[];
- /** The current color, as a `#rrggbb` (or `#rrggbbaa` under `withAlpha`) string. */
value: string;
- /**
- * Accept and emit `#rrggbbaa`, and show the alpha slider, alpha channel
- * input, and a transparency checkerboard behind the trigger swatch.
- */
withAlpha?: boolean;
- /**
- * Offer the browser's screen eyedropper. Chromium-only — the trigger is
- * omitted entirely where `EyeDropper` is unavailable rather than rendering a
- * button that does nothing. Ignored when `onSampleColor` is supplied.
- */
withEyeDropper?: boolean;
- /** Show the current value as text beside the trigger swatch. */
withValueText?: boolean;
- /** Called as the user drags the area/sliders or edits a channel input. */
onValueChange: (value: string) => void;
- /**
- * Called with the final value when an interaction ends (pointer up on the
- * area/slider, a channel input committing, or a swatch being picked).
- * Consumers that record undo history use this to collapse a whole drag into
- * one entry, mirroring the `Slider` `onValueChangeEnd` pattern.
- */
onValueChangeEnd?: (value: string) => void;
- /**
- * Sample a color from somewhere the picker cannot reach itself — the canvas
- * passes a sampler backed by its own eyedropper tool, which reads the
- * composited document rather than the screen. Replaces the browser
- * eyedropper when present. Resolves `null` when the user cancels.
- */
onSampleColor?: () => Promise<string | null>;
}
-/**
- * The colour channels a format exposes. Alpha is always dropped — it gets its
- * own percentage field ({@link AlphaInput}) rather than Zag's unit-float one,
- * and it belongs at the end of the row regardless of which format is showing.
- */
const useChannels = (format: ColorPickerFormat) =>
useMemo(() => getColorChannels(MACHINE_FORMAT[format]).filter((channel) => channel !== 'alpha'), [format]);
-/**
- * Cycles HEX → RGB → HSL → HSB.
- *
- * A dropdown would name all four up front, but it has to portal out of the
- * picker's own popover, and opening it reads as an outside interaction that
- * dismisses the picker. Ark's built-in `FormatTrigger` cycles for the same
- * reason; this keeps that behavior on workbench chrome.
- */
const FormatTrigger = ({
format,
onFormatChange,
@@ -145,8 +89,6 @@ const FormatTrigger = ({
}, [format, onFormatChange]);
return (
- // `subtle` rather than `ghost`: a bare label beside two filled inputs reads
- // as a caption, not something you can click to change the units.
<IconButton
aria-label={t('common.colorPicker.format')}
flexShrink="0"
@@ -162,16 +104,7 @@ const FormatTrigger = ({
);
};
-/**
- * A swatch that also reports a commit. Zag's `SwatchTrigger` sets the value and
- * fires `onValueChange`, but never `onValueChangeEnd` — without this, every
- * consumer that records undo history on commit (mask fills, shapes, gradients)
- * would silently drop swatch picks from their history.
- *
- * The commit is *armed* here rather than emitted: Zag's own value change runs
- * after this handler, so emitting directly would put the commit before the
- * change and leave undo entries recording the pre-swatch color.
- */
+// Zag does not emit onValueChangeEnd for swatches, and its value change runs after the click handler.
const CommittingSwatch = ({ value, onArmCommit }: { value: string; onArmCommit: () => void }) => (
<ChakraColorPicker.SwatchTrigger value={value} onClick={onArmCommit}>
<ChakraColorPicker.Swatch value={value}>
@@ -180,14 +113,6 @@ const CommittingSwatch = ({ value, onArmCommit }: { value: string; onArmCommit:
</ChakraColorPicker.SwatchTrigger>
);
-/**
- * Opacity as a whole percentage.
- *
- * Zag's own alpha `ChannelInput` renders the raw unit float — a field reading
- * `0.501` next to a hex triplet is noise, and nobody types opacity that way.
- * This edits the same channel in the units the rest of the app uses (layer
- * opacity, brush opacity) and commits on blur so a drag-free edit is one entry.
- */
const AlphaInput = ({
alpha,
onAlphaChange,
@@ -230,19 +155,6 @@ const AlphaInput = ({
);
};
-/**
- * Workbench color picker: a compact swatch trigger that opens a popover with a
- * saturation/value area, hue and alpha sliders, an eyedropper, switchable
- * HEX/RGB/HSL/HSB channel inputs, and a swatch row of the workbench palette
- * plus recently committed colors. Composed from Chakra v3's `ColorPicker.*`
- * parts; chrome comes from the `colorPicker` slot-recipe override in
- * `theme/recipes.ts`.
- *
- * Internally, the picker's controlled value is kept as a full Chakra/Zag
- * `Color` (which preserves hue/saturation independent of RGB), not a hex
- * string — see `shouldSyncExternalColor` for why. The external API stays
- * string based; hex is only produced at the emit boundary.
- */
export const ColorPicker = ({
'aria-label': ariaLabel,
disabled,
@@ -261,7 +173,6 @@ export const ColorPicker = ({
const recents = useRecentColors();
const channels = useChannels(format);
- // Zag emits uppercase hex; the workbench stores and compares lowercase.
const toEmitted = useCallback(
(color: Color) => color.toString(withAlpha ? 'hexa' : 'hex').toLowerCase(),
[withAlpha]
@@ -340,7 +251,6 @@ export const ColorPicker = ({
if (!onSampleColor) {
return;
}
- // Get out of the way so the user can see (and click) what they're sampling.
setIsOpen(false);
const sampled = await onSampleColor();
if (sampled) {
@@ -361,8 +271,6 @@ export const ColorPicker = ({
return [...DEFAULT_COLOR_SWATCHES, ...recents.filter((entry) => !seen.has(normalizeHex(entry)))];
}, [recents, swatches]);
- // The browser eyedropper is Chromium-only; omit the trigger where it would
- // do nothing. A canvas-backed sampler always wins when one is supplied.
const canUseScreenEyeDropper = withEyeDropper && typeof window !== 'undefined' && 'EyeDropper' in window;
return (
diff --git a/invokeai/frontend/webv2/src/platform/ui/Picker.tsx b/invokeai/frontend/webv2/src/platform/ui/Picker.tsx
index 9324254009..7c3ef2a795 100644
--- a/invokeai/frontend/webv2/src/platform/ui/Picker.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/Picker.tsx
@@ -5,22 +5,10 @@ import { dropdownGroupLabel } from '@theme/recipes';
import { SearchIcon } from 'lucide-react';
import { useCallback, useDeferredValue, useMemo, useRef, useState } from 'react';
-/**
- * A searchable, grouped option list. Owns search, group filter chips, group
- * chrome (colour rail, sticky header, count), and keyboard navigation; callers
- * own what a row looks like and what matching means.
- *
- * Navigation is roving rather than focus-moving: DOM focus stays in the search
- * field and an `activeId` marks the highlighted row, so arrows cross group
- * boundaries and typing never has to reclaim focus. Rows are not tab stops.
- */
-
export interface PickerGroup<T> {
id: string;
- /** Header text, e.g. "Stable Diffusion XL". */
name: string;
options: T[];
- /** Chip text; falls back to `name`. */
shortName?: string;
colorPalette?: string;
getCountLabel?: (count: number) => string;
@@ -53,7 +41,6 @@ export const Picker = <T,>({
toolbarSlot,
onSelect,
}: {
- /** Shown when there is nothing to pick from at all. */
emptyMessage: ReactNode;
getIsOptionDisabled?: (option: T) => boolean;
getOptionId: (option: T) => string;
@@ -61,16 +48,12 @@ export const Picker = <T,>({
isCompact?: boolean;
isMatch: (option: T, searchTerm: string) => boolean;
listLabel: string;
- /** Shown when a search or filter excluded everything. */
noMatchesMessage: ReactNode;
renderOption: (option: T, state: PickerOptionState) => ReactNode;
searchPlaceholder: string;
- /** Controls beside the search field, e.g. a manager link or view toggle. */
searchSlot?: ReactNode;
selectedId: string | null;
- /** Replaces the list entirely, e.g. while loading or after a load failure. */
statusSlot?: ReactNode;
- /** Extra row under the search field, e.g. filter chips. */
toolbarSlot?: ReactNode;
onSelect: (option: T) => void;
}) => {
diff --git a/invokeai/frontend/webv2/src/platform/ui/color.ts b/invokeai/frontend/webv2/src/platform/ui/color.ts
index cffe7718fd..cb8c63f8c0 100644
--- a/invokeai/frontend/webv2/src/platform/ui/color.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/color.ts
@@ -1,20 +1,3 @@
-/**
- * Hex-string ↔ object color conversion for the workbench.
- *
- * The canonical object form is {@link RgbaColor}: `r`/`g`/`b` are integers in
- * `[0, 255]` and `a` is a unit float in `[0, 1]`. That matches the generation
- * settings' `infillColorValue` and the legacy app's `zRgbaColor`, so those
- * consumers adapt with no extra arithmetic. The one consumer that differs —
- * workflow `ColorField`, whose alpha is `[0, 255]` — scales at its own call
- * site rather than forcing a second alpha convention through here.
- *
- * Parsing is deliberately tolerant: these values come from persisted documents,
- * node fields, and hand-typed input, so anything unparseable falls back rather
- * than throwing. Formatting always emits lowercase with a leading `#`.
- *
- * Pure module — no React, no Chakra, no DOM.
- */
-
/** An RGBA color. `r`/`g`/`b` are `[0, 255]` integers; `a` is a `[0, 1]` float. */
export interface RgbaColor {
r: number;
@@ -24,14 +7,11 @@ export interface RgbaColor {
}
export interface FormatHexColorOptions {
- /** Emit `#rrggbbaa` instead of `#rrggbb`. */
alpha?: boolean;
}
-/** Opaque black — the fallback for anything unparseable. */
export const BLACK: RgbaColor = { a: 1, b: 0, g: 0, r: 0 };
-/** `#rgb`, `#rgba`, `#rrggbb`, or `#rrggbbaa`, with an optional leading `#`. */
const HEX_PATTERN = /^#?([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
const clampChannel = (value: number): number => {
@@ -52,10 +32,8 @@ const clampAlpha = (value: number): number => {
const toHexByte = (value: number): string => clampChannel(value).toString(16).padStart(2, '0');
-/** Expands a shorthand nibble (`f`) into a byte (`ff`). */
const expandNibble = (nibble: string): number => parseInt(`${nibble}${nibble}`, 16);
-/** Parses any supported hex form, or `null` when the input is not one. */
const tryParseHexColor = (value: string): RgbaColor | null => {
const match = HEX_PATTERN.exec(value.trim());
@@ -82,40 +60,24 @@ const tryParseHexColor = (value: string): RgbaColor | null => {
};
};
-/**
- * Parses any supported hex form into an {@link RgbaColor}. Returns `fallback`
- * (opaque black by default) for input that is not a 3/4/6/8-digit hex string.
- */
export const parseHexColor = (value: string, fallback: RgbaColor = BLACK): RgbaColor =>
tryParseHexColor(value) ?? fallback;
-/** Formats an {@link RgbaColor} as `#rrggbb`, or `#rrggbbaa` when `alpha` is set. */
export const formatHexColor = (color: RgbaColor, options?: FormatHexColorOptions): string => {
const rgb = `#${toHexByte(color.r)}${toHexByte(color.g)}${toHexByte(color.b)}`;
return options?.alpha ? `${rgb}${toHexByte(clampAlpha(color.a) * 255)}` : rgb;
};
-/**
- * Splits a color into its `#rrggbb` part and a `[0, 1]` alpha, for consumers
- * that store the two separately (gradient stops used to do this inline).
- */
export const splitHexAlpha = (value: string): { hex: string; alpha: number } => {
const color = parseHexColor(value);
return { alpha: color.a, hex: formatHexColor(color) };
};
-/** Recombines a `#rrggbb` and a `[0, 1]` alpha into `#rrggbbaa`. */
export const joinHexAlpha = (hex: string, alpha: number): string =>
formatHexColor({ ...parseHexColor(hex), a: clampAlpha(alpha) }, { alpha: true });
-/**
- * Normalizes any supported hex form to lowercase `#rrggbb`, or `#rrggbbaa` when
- * the input carries a non-opaque alpha. Used to compare values that may differ
- * only in case or shorthand. Unparseable input returns `fallback` verbatim, so
- * callers can pass through non-hex CSS colors untouched.
- */
export const normalizeHex = (value: string, fallback: string = '#000000'): string => {
const color = tryParseHexColor(value);
diff --git a/invokeai/frontend/webv2/src/platform/ui/colorPickerStore.ts b/invokeai/frontend/webv2/src/platform/ui/colorPickerStore.ts
index d25d4058bf..a3d03d10f2 100644
--- a/invokeai/frontend/webv2/src/platform/ui/colorPickerStore.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/colorPickerStore.ts
@@ -1,17 +1,5 @@
-/**
- * Shared state behind every {@link ColorPicker}: the default swatch palette, a
- * most-recently-used list of committed colors, and the preferred channel
- * format.
- *
- * Both persisted values are per browser rather than per account or project —
- * like the command palette's frecency record, a picker's muscle memory should
- * not reset when the user switches projects. Storage failures (quota, private
- * mode, blocked cookies) are non-fatal: the picker still works, it just forgets.
- */
-
import { createExternalStore } from '@platform/state/externalStore';
-/** The channel layouts the picker can present. */
export type ColorPickerFormat = 'hex' | 'rgb' | 'hsl' | 'hsb';
export const COLOR_PICKER_FORMATS: readonly ColorPickerFormat[] = ['hex', 'rgb', 'hsl', 'hsb'];
@@ -108,11 +96,6 @@ const store = createExternalStore<ColorPickerSnapshot>({
recents: parseRecents(readStored(RECENTS_STORAGE_KEY)),
});
-/**
- * Promotes `color` to the front of the recents list. Callers record on commit
- * (`onValueChangeEnd`) only — recording every drag frame would fill the list
- * with the colors swept through on the way to the chosen one.
- */
export const recordRecentColor = (color: string): void => {
const normalized = color.toLowerCase();
const { recents } = store.getSnapshot();
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
index bbdc3ca5ae..1f70119d2d 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
@@ -1,29 +1,6 @@
import { defineRecipe, defineSlotRecipe } from '@chakra-ui/react';
import { recipes as chakraRecipes, slotRecipes as chakraSlotRecipes } from '@chakra-ui/react/theme';
-/**
- * Reusable, theme-aware recipes for the workbench design system.
- *
- * Recipes reference semantic tokens only, so every variant automatically tracks
- * the active theme. Two kinds live here:
- *
- * 1. Overrides for Chakra's built-in component recipes (`tooltip`, `menu`,
- * `select`, `combobox`, `dialog`) — registered in `system.ts` so every
- * instance app-wide gets the workbench chrome with zero props at the call
- * site.
- * 2. Workbench-specific recipes (`panel`, `row`, `chip`, `fieldLabel`,
- * `themeCard`) — consumed via the wrappers in `platform/ui`
- * with `useRecipe({ recipe })` / `useSlotRecipe({ recipe })`, which keeps
- * them fully typed without the Chakra typegen step.
- *
- * Either way, this file is the single place where shared component styling is
- * edited.
- */
-
-/* -------------------------------------------------------------------------- *
- * Built-in component overrides (registered in system.ts)
- * -------------------------------------------------------------------------- */
-
/**
* Tooltip chrome: raised surface with a hairline stroke instead of inverted
* fill. Extends Chakra's default recipe — replacing it wholesale would drop
@@ -50,15 +27,6 @@ export const tooltipSlotRecipe = defineSlotRecipe({
},
});
-/**
- * Tabs: quick neutral hover feedback, with accent reserved for selection.
- * Restricting hover styles to unselected triggers keeps active tabs visually
- * stable without relying on condition ordering in the generated CSS.
- *
- * Trigger text follows the same rule as {@link buttonRecipe}: the label stops
- * scaling below `lg`, so `sm` and `md` both sit at 12px with the rest of the
- * workbench chrome. Only the row height still scales with the size.
- */
export const tabsSlotRecipe = defineSlotRecipe({
...chakraSlotRecipes.tabs,
base: {
@@ -136,12 +104,6 @@ export const tabsSlotRecipe = defineSlotRecipe({
} as unknown as typeof chakraSlotRecipes.tabs.variants,
});
-/**
- * Buttons: the text size stops scaling below `lg`. The workbench is dense, and
- * a 14px label on a 40px `md` button reads as a marketing button next to the
- * 12px chrome around it. `sm` moves with `md` — otherwise the smaller button
- * would carry the larger label.
- */
export const buttonRecipe = defineRecipe({
...chakraRecipes.button,
variants: {
@@ -154,30 +116,6 @@ export const buttonRecipe = defineRecipe({
} as unknown as typeof chakraRecipes.button.variants,
});
-/**
- * Segment control: a flat strip, not a recessed pill.
- *
- * Chakra's stock look — inset-shadowed `bg.muted` track, elevated white
- * indicator, hairline dividers between every segment — is a light-UI form
- * control, and it read as a foreign object among the workbench's flat toolbars.
- * This version drops the track and the dividers entirely: selection is a filled
- * `bg.emphasized` segment, exactly the fill the icon-button strips in the canvas
- * and preview toolbars already use, so a segment control now reads as one of
- * them rather than as a form field.
- *
- * Unselected segments sit at `fg.muted` and step to `fg` on hover, which is the
- * only feedback they need — a hover fill on top of a selection fill would give
- * the strip two competing highlights.
- *
- * A hairline stroke bounds the strip so it still reads as one control when
- * nothing around it provides an edge. It is a real border rather than the
- * `inset` box-shadow used elsewhere in this file: the indicator is a negative
- * z-index child, so it paints over the root's own background and shadow layer
- * and would punch a gap in an inset hairline wherever the active segment meets
- * the edge. A border sits outside the padding box, so the indicator can never
- * reach it. Root radius is one step above `--segment-radius` to absorb the
- * border width, keeping the corners concentric.
- */
export const segmentGroupSlotRecipe = defineSlotRecipe({
...chakraSlotRecipes.segmentGroup,
base: {
@@ -199,16 +137,11 @@ export const segmentGroupSlotRecipe = defineSlotRecipe({
fontWeight: '500',
transitionDuration: 'faster',
transitionProperty: 'background, color',
- // Stock draws a hairline between neighbouring segments. With a filled
- // selection they only add noise, and they never line up with the
- // indicator's rounded corners.
_before: { display: 'none' },
_checked: { color: 'fg' },
_hover: {
'&:not([data-state=checked])': { color: 'fg' },
},
- // Pre-hydration fallback: without the measured indicator, the checked
- // segment has to paint its own fill.
'&[data-state=checked][data-ssr]': {
bg: 'bg.emphasized',
shadow: 'none',
@@ -233,19 +166,10 @@ export const segmentGroupSlotRecipe = defineSlotRecipe({
} as unknown as typeof chakraSlotRecipes.segmentGroup.variants,
defaultVariants: {
...chakraSlotRecipes.segmentGroup.defaultVariants,
- // Workbench density — stock defaults to `md`.
size: 'xs',
},
});
-/**
- * Shared interactive states for every bordered form control — text inputs,
- * textareas, number inputs, select/combobox triggers, and hand-rolled trigger
- * buttons (ModelSelect). Idle border is `border`; hover steps to
- * `border.emphasized`; an open dropdown commits to `accent.solid` so hover and
- * open remain distinguishable. Focus uses the accent border without adding a
- * second ring around the control.
- */
const formControlFocused = {
'--focus-ring-color': 'var(--focus-color) !important',
borderColor: 'accent.solid',
@@ -278,7 +202,6 @@ export const formControlInteraction = {
const formControlOpen = { borderColor: 'accent.solid' };
-/** Text input: Chakra default plus the shared hover/transition treatment. */
export const inputRecipe = defineRecipe({
...chakraRecipes.input,
variants: {
@@ -295,7 +218,6 @@ export const inputRecipe = defineRecipe({
},
});
-/** Textarea: Chakra default plus the shared hover/transition treatment. */
export const textareaRecipe = defineRecipe({
...chakraRecipes.textarea,
variants: {
@@ -312,7 +234,6 @@ export const textareaRecipe = defineRecipe({
},
});
-/** Number input: the input slot gets the shared hover/transition treatment. */
export const numberInputSlotRecipe = defineSlotRecipe({
...chakraSlotRecipes.numberInput,
variants: {
@@ -344,7 +265,6 @@ export const numberInputSlotRecipe = defineSlotRecipe({
},
});
-/** Shared dropdown surface: one look for menu, select, combobox, and hand-rolled poppers (ModelSelect). */
export const dropdownContent = {
bg: 'bg.muted',
borderColor: 'border.emphasized',
@@ -354,13 +274,6 @@ export const dropdownContent = {
color: 'fg',
};
-/**
- * Shared dropdown item treatment. The highlight sits on `bg.emphasized`: the
- * content surface is `bg.muted`, and on the dark ramps `bg.subtle` is darker
- * than the surface, which made the old highlight nearly invisible (classic
- * theme especially). `bg.emphasized` is one step away from the surface in
- * every theme, so the highlight reads everywhere.
- */
export const dropdownItem = {
_highlighted: { bg: 'bg.emphasized' },
_hover: { bg: 'bg.emphasized' },
@@ -379,7 +292,6 @@ export const dropdownGroupLabel = {
textTransform: 'uppercase',
};
-/** Menu / context-menu chrome: popover surface with an emphasized stroke. */
export const menuSlotRecipe = defineSlotRecipe({
...chakraSlotRecipes.menu,
base: {
@@ -407,7 +319,6 @@ export const menuSlotRecipe = defineSlotRecipe({
},
});
-/** Select dropdown chrome: same surface and item treatment as menus. */
export const selectSlotRecipe = defineSlotRecipe({
...chakraSlotRecipes.select,
// The outline variant carries its own `_expanded` (border.emphasized) which
@@ -457,7 +368,6 @@ export const selectSlotRecipe = defineSlotRecipe({
},
});
-/** Combobox chrome: kept aligned with Select for future searchable fields. */
export const comboboxSlotRecipe = defineSlotRecipe({
...chakraSlotRecipes.combobox,
variants: {
@@ -502,7 +412,6 @@ export const comboboxSlotRecipe = defineSlotRecipe({
},
});
-/** Dialog chrome: panel surface with a hairline stroke. */
export const dialogSlotRecipe = defineSlotRecipe({
...chakraSlotRecipes.dialog,
base: {
@@ -515,7 +424,6 @@ export const dialogSlotRecipe = defineSlotRecipe({
},
});
-/** Slider marks: compact auxiliary labels for dense widget controls. */
export const sliderSlotRecipe = defineSlotRecipe({
...chakraSlotRecipes.slider,
base: {
@@ -529,7 +437,6 @@ export const sliderSlotRecipe = defineSlotRecipe({
},
});
-/** Progress circle: add a compact icon-sized variant for dense chrome like tabs. */
export const progressCircleSlotRecipe = defineSlotRecipe({
...chakraSlotRecipes.progressCircle,
variants: {
@@ -549,19 +456,7 @@ export const progressCircleSlotRecipe = defineSlotRecipe({
},
});
-/**
- * Color picker chrome: the popover surface, area, sliders, swatches, and
- * channel inputs, aligned with the rest of the workbench controls. This was the
- * last built-in still rendering Chakra's stock chrome, so it was the only
- * control that did not track the active theme.
- *
- * Extends the default rather than replacing it: the stock recipe folds
- * `colorSwatchRecipe.base` into `swatch` and `inputRecipe.base` into
- * `channelInput`, and its `size` variants are what define `--swatch-size`,
- * `--slider-height`, and `--thumb-size`. Replacing wholesale renders every
- * thumb and swatch at zero size — the same failure the tooltip recipe above
- * documents for `--arrow-size`.
- */
+// Extending the stock recipe preserves the CSS variables that size thumbs and swatches.
export const colorPickerSlotRecipe = defineSlotRecipe({
...chakraSlotRecipes.colorPicker,
base: {
@@ -569,23 +464,17 @@ export const colorPickerSlotRecipe = defineSlotRecipe({
content: {
...chakraSlotRecipes.colorPicker.base?.content,
...dropdownContent,
- // Wide enough for a full ten-swatch row at its natural size; narrower and
- // the swatches, the format button, and the channel inputs all crowd.
gap: '2',
p: '2',
width: '64',
},
area: {
...chakraSlotRecipes.colorPicker.base?.area,
- // Denser than the stock 180px, which dwarfs the workbench tool bars.
height: '140px',
- // Hairline ring so the area does not float on the light theme's surface.
boxShadow: 'inset 0 0 0 1px {colors.border.subtle}',
},
areaThumb: {
...chakraSlotRecipes.colorPicker.base?.areaThumb,
- // The white ring alone disappears on light colors; the outer hairline
- // keeps the thumb legible across the whole area.
boxShadow: '0 0 0 1px {colors.border.image}',
},
channelSliderThumb: {
@@ -594,13 +483,11 @@ export const colorPickerSlotRecipe = defineSlotRecipe({
},
channelSliderTrack: {
...chakraSlotRecipes.colorPicker.base?.channelSliderTrack,
- // Stock hardcodes rgba(0,0,0,0.1), which vanishes on the dark ramps.
boxShadow: 'inset 0 0 0 1px {colors.border.subtle}',
},
swatch: {
...chakraSlotRecipes.colorPicker.base?.swatch,
borderRadius: 'l1',
- // Without a hairline, white and fully transparent swatches are invisible.
boxShadow: 'inset 0 0 0 1px {colors.border.image}',
},
swatchTrigger: {
@@ -636,16 +523,10 @@ export const colorPickerSlotRecipe = defineSlotRecipe({
},
defaultVariants: {
...chakraSlotRecipes.colorPicker.defaultVariants,
- // Workbench density — stock defaults to `md`.
size: 'xs',
},
});
-/* -------------------------------------------------------------------------- *
- * Reusable UI recipes (consumed through Platform UI wrappers)
- * -------------------------------------------------------------------------- */
-
-/** Bordered surface container — panels, cards, wells. */
export const panelRecipe = defineRecipe({
base: {
bg: 'bg.subtle',
@@ -673,7 +554,6 @@ export const panelRecipe = defineRecipe({
defaultVariants: { tone: 'surface', density: 'none' },
});
-/** Interactive list / table row with hover, focus, and active fills. */
export const rowRecipe = defineRecipe({
base: {
alignItems: 'center',
@@ -711,7 +591,6 @@ export const rowRecipe = defineRecipe({
defaultVariants: { active: 'none' },
});
-/** Compact status chip with intent tones — queue counts, server state, versions. */
export const chipRecipe = defineRecipe({
base: {
alignItems: 'center',
@@ -738,7 +617,6 @@ export const chipRecipe = defineRecipe({
defaultVariants: { tone: 'neutral' },
});
-/** Compact uppercase field label shared across widget forms and the settings modal. */
export const fieldLabelRecipe = defineRecipe({
base: {
color: 'fg.muted',
@@ -748,7 +626,6 @@ export const fieldLabelRecipe = defineRecipe({
},
});
-/** Selectable theme swatch card used by the Settings appearance picker. */
export const themeCardRecipe = defineSlotRecipe({
slots: ['root', 'preview', 'swatch', 'body', 'name', 'description', 'indicator'],
base: {
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts
index 84186d5f1e..04e2a38361 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts
@@ -1,30 +1,3 @@
-/**
- * `CanvasEngine`: the per-project imperative heart of the canvas.
- *
- * One engine instance exists per project (managed by `engineRegistry.ts`) and
- * shared by the canvas and layers widgets. It owns interaction, pixels, and
- * rendering; the reducer owns the document. The document flows in one way
- * through the {@link createDocumentMirror | document mirror}; the engine never
- * dispatches from pointer input except for the single gesture-start
- * `addCanvasLayer` a paint tool emits when auto-creating a layer.
- *
- * Responsibilities:
- * - Hold the {@link Viewport} (pan/zoom) and the transient {@link EngineStores}
- * React subscribes to.
- * - `attach`/`detach` bind two stacked canvases (composited document + overlay)
- * as render targets, wire pointer/wheel/key listeners, and drive the
- * scheduler; `resize` sizes the backing stores to `css × min(dpr, 2)`.
- * - Route normalized pointer/wheel input to the active {@link Tool} via the
- * pointer pipeline and wheel handler (middle-mouse pan, space/alt temp tools,
- * plain-wheel zoom, ctrl+wheel brush-size step), and relay committed strokes
- * to `onStrokeCommitted` subscribers.
- * - Orchestrate rasterization: ensure a raster cache per visible layer, compose
- * the document, and draw the overlay each scheduled frame.
- *
- * DOM APIs are confined to `attach`/`detach`/`resize` and the DOM raster
- * backend, so importing this module stays node-safe. Zero React imports.
- */
-
import type {
CanvasHistoryCapability,
CanvasDiagnosticsCapability,
diff --git a/invokeai/frontend/webv2/src/workbench/graphWidgets.ts b/invokeai/frontend/webv2/src/workbench/graphWidgets.ts
index c6af8f5c0f..50e1b52ea2 100644
--- a/invokeai/frontend/webv2/src/workbench/graphWidgets.ts
+++ b/invokeai/frontend/webv2/src/workbench/graphWidgets.ts
@@ -5,25 +5,10 @@ import type { WidgetTypeId } from '@workbench/widgetContracts';
import { autoSwitchDestinations } from './autoRoutePolicy';
import { getDestinationLabel, getSourceLabel, isInvocationSourceAvailable } from './invocation';
-/**
- * The invocation source model behind the topbar's routing control.
- *
- * A *graph widget* is a widget that can expose a generation graph and can
- * therefore act as a source. Which ones are open is a property of the live
- * layout, not of the layout preset — a preset routinely places two or three of
- * them at once, which is exactly why a preset can never determine the source.
- */
-
-/** Widget type ids that carry a graph, in the order the routing menu lists them. */
const graphWidgetTypeIds = ['generate', 'canvas', 'upscale', 'workflow'] as const;
export type GraphWidgetTypeId = (typeof graphWidgetTypeIds)[number];
-/**
- * Source id and widget type id are the same string for every graph widget today.
- * They are still distinct concepts — one names a route, the other names a
- * dockable surface — so the mapping is written out rather than assumed.
- */
const sourceIdsByWidgetTypeId: Record<GraphWidgetTypeId, InvocationSourceId> = {
canvas: 'canvas',
generate: 'generate',
@@ -47,7 +32,6 @@ export const getSourceIdForWidgetTypeId = (typeId: WidgetTypeId): InvocationSour
export const getWidgetTypeIdForSourceId = (sourceId: InvocationSourceId): GraphWidgetTypeId =>
widgetTypeIdsBySourceId[sourceId];
-/** Where a source's output naturally lands when the destination is not locked. */
export const getNaturalDestination = (sourceId: InvocationSourceId): ResultDestination =>
autoSwitchDestinations[sourceId];
@@ -57,7 +41,6 @@ export interface GraphWidgetSource {
label: string;
}
-/** Every graph widget, in the order the routing menu lists them. */
export const graphWidgetSources: GraphWidgetSource[] = graphWidgetTypeIds
.map((typeId) => ({
label: getSourceLabel(sourceIdsByWidgetTypeId[typeId]),
@@ -66,17 +49,7 @@ export const graphWidgetSources: GraphWidgetSource[] = graphWidgetTypeIds
}))
.filter((source) => isInvocationSourceAvailable(source.sourceId));
-/**
- * The widget type each region is currently showing.
- *
- * This is what "visible" means in the routing menu — a surface the current
- * layout is showing. It is deliberately *not* what the menu lists:
- * every source stays selectable, because being unable to pick Workflow just
- * because the centre happens to show Canvas is a dead end, not a safeguard.
- *
- * A collapsed region still counts. Collapsing a panel is a viewing choice, not
- * a statement about what should run.
- */
+// Collapsed regions still count as visible because disclosure does not change routing.
export const getVisibleWidgetTypeIds = (project: Project): Set<WidgetTypeId> => {
const typeIds = new Set<WidgetTypeId>();
@@ -91,7 +64,6 @@ export const getVisibleWidgetTypeIds = (project: Project): Set<WidgetTypeId> =>
return typeIds;
};
-/** Widget types placed anywhere in the project, whether or not they are showing. */
export const getPlacedWidgetTypeIds = (project: Project): Set<WidgetTypeId> => {
const typeIds = new Set<WidgetTypeId>();
@@ -108,10 +80,6 @@ export const getPlacedWidgetTypeIds = (project: Project): Set<WidgetTypeId> => {
return typeIds;
};
-/**
- * The routing indicator is icon-only, so it carries the whole route in its
- * accessible name — including whether the route is pinned or follows edits.
- */
export const describeRoute = ({
destination,
destinationLocked,
diff --git a/invokeai/frontend/webv2/src/workbench/shell/CenterArea.tsx b/invokeai/frontend/webv2/src/workbench/shell/CenterArea.tsx
index 4bbb3e6503..780f7e067d 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/CenterArea.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/CenterArea.tsx
@@ -38,19 +38,8 @@ type CenterWidgetItem = PlacedWidgetRegionItem<WidgetPlacementInstanceMeta>;
const CENTER_MENU_POSITIONING = { placement: 'bottom-start' } as const;
const CENTER_PREFERRED_REGIONS = ['center'] as const;
-/**
- * The chrome floats over the work surface, so widgets whose own content is
- * top-anchored (the gallery toolbar) clear it with this inset instead of the
- * region reserving a row. Full-bleed surfaces — canvas, workflow, preview —
- * ignore it and run their content edge to edge beneath the islands.
- */
const CENTER_CHROME_INSET_STYLE = { '--wb-center-chrome-inset': '3rem' } as React.CSSProperties;
-/**
- * Center work area: a full-bleed registered center view with two floating
- * chrome islands over it — the view selector (plus the active widget's own
- * label slot) at the start, the active widget's actions at the end.
- */
export const CenterArea = () => {
const { t } = useTranslation();
const placementProject = useActiveProjectSelector(getWidgetPlacementProject, areWidgetPlacementProjectsEqual);
@@ -137,8 +126,6 @@ export const CenterArea = () => {
? isRequiredCenterView(activeItem as WidgetRegionItem, centerViewItems.length)
: true;
- // Widgets that can be added: every center-capable type that has no instance
- // placed here yet (`availableItems` already accounts for `allowMultiple`).
const availableCenterItems = useMemo(
() => centerWidgetMenuItems.filter((item) => !item.isEnabled && item.status !== 'disabled'),
[centerWidgetMenuItems]
@@ -233,12 +220,6 @@ export const CenterArea = () => {
);
};
-/**
- * One floating chrome group. Islands carry the same `bg.subtle` surface as the
- * top bar, the widget rails, and the side panels, so the chrome reads as one
- * material wherever it appears. Pointer events are re-enabled per island so the
- * gap between them stays click-through.
- */
const ChromeIsland = ({ children }: { children: ReactNode }) => (
<HStack
bg="bg.subtle"
@@ -364,11 +345,6 @@ const CenterViewMenu = ({
);
};
-/**
- * One row of the selector. Open views are radio items so the active one is
- * announced as checked; rows that would open a new view stay plain menu items,
- * since they are an action rather than a choice within the current set.
- */
const CenterViewMenuRow = ({
isActive,
item,
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/AppMenu.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/AppMenu.tsx
index 6781e72340..10963c74b2 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/AppMenu.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/AppMenu.tsx
@@ -33,14 +33,6 @@ const MENU_POSITIONING = { placement: 'bottom-start' } as const;
const DOCS_URL = 'https://invoke-ai.github.io/InvokeAI/';
const DISCORD_URL = 'https://discord.gg/ZmtBAhwWhy';
-/**
- * The application menu. The bar carries no wordmark any more, so the menu header
- * is the only place the product name and version now appear.
- *
- * It deliberately holds no widget navigation. Generate, Canvas, Upscale, and
- * Workflow are widgets, and every dock area already has its own widget picker —
- * listing them here would be a second, worse copy of a control that exists.
- */
export const AppMenu = () => {
const { t } = useTranslation();
const { canManageModels, canManageNodes } = useCapabilities();
@@ -129,14 +121,6 @@ export const AppMenu = () => {
);
};
-/**
- * The mark at rest, a hamburger once you reach for it.
- *
- * The bar carries no other branding, so this slot does double duty: it is the
- * app's identity when idle, and admits to being a menu the moment a pointer or
- * keyboard focus arrives. Both glyphs occupy the same box, so nothing shifts on
- * the swap — only the crossfade reads as a change.
- */
const MARK_SWAP_PROPS = { opacity: 0 } as const;
const GLYPH_SWAP_PROPS = { opacity: 1 } as const;
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/QueueCluster.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/QueueCluster.tsx
index 55fec9a625..7ff9e4ffae 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/QueueCluster.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/QueueCluster.tsx
@@ -33,14 +33,6 @@ const tonePalettes: Record<QueueTone, string | undefined> = {
running: 'accent',
};
-/**
- * Everything about work already dispatched: the counter, a cancel control that
- * only exists when there is something to cancel, and the processor menu.
- *
- * This is where generation progress lives — deliberately not on the Invoke
- * button, which stays static so that queueing onto a running batch never looks
- * unavailable.
- */
export const QueueCluster = () => {
const { t } = useTranslation();
const queueItems = useActiveProjectSelector((project) => project.queue.items);
@@ -69,8 +61,6 @@ export const QueueCluster = () => {
return (
<Menu.Root>
- {/* The cancel button is simply absent when idle. Reserving its width left
- a hole in the middle of the group that read as a broken control. */}
<Group attached colorPalette={tonePalettes[tone]} flexShrink={0}>
<QueueButtonTooltip
current={current}
@@ -88,8 +78,6 @@ export const QueueCluster = () => {
variant={tone === 'idle' ? 'outline' : 'subtle'}
onClick={handleOpenQueue}
>
- {/* Progress fills behind the label rather than replacing it: the
- counter is the thing people read, and it must stay readable. */}
{tone === 'running' && progressValue !== null ? (
<Box
aria-hidden="true"
@@ -104,9 +92,6 @@ export const QueueCluster = () => {
/>
) : null}
<Icon as={isPaused ? PauseIcon : ListOrderedIcon} position="relative" zIndex="1" />
- {/* Tabular figures and a reserved minimum: the counter is watched
- continuously, and digits that change width would nudge the
- controls beside it on every step of a run. */}
<chakra.span fontVariantNumeric="tabular-nums" position="relative" textAlign="center" zIndex="1">
{remaining}
</chakra.span>
@@ -181,13 +166,7 @@ const QueueButtonTooltip = ({
);
};
-/**
- * Progress for screen readers, quantised to ten percent.
- *
- * A 30-step run emits progress continuously; announcing every event would make
- * the whole page unusable while generating, so the live region only changes
- * when the rounded decile does.
- */
+// Quantize screen-reader announcements so progress events do not flood the live region.
const QueueProgressAnnouncement = ({
current,
progress,
@@ -310,8 +289,6 @@ const QueueTooltip = ({
{t('topbar.queue.backendBatch', { id: item.backendBatchId })}
</Text>
) : null}
- {/* Queue items snapshot their route at enqueue time (contract §9.2), so
- this reads the item's own snapshot, never the live route. */}
<Text truncate>
{t('topbar.queue.route', {
destination: getDestinationLabel(item.snapshot.destination),
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/topbarBreakpoints.ts b/invokeai/frontend/webv2/src/workbench/shell/topbar/topbarBreakpoints.ts
index e3b8d62b47..a13c6b8f90 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/topbarBreakpoints.ts
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/topbarBreakpoints.ts
@@ -1,23 +1,7 @@
-/**
- * The top bar's own widths, as raw media queries.
- *
- * The theme's breakpoint scale (992 / 1280 / 1536) is about page layout; this
- * bar degrades at the points where its *own* content stops fitting, which are
- * not the same numbers. Rather than bend the shared scale for one component, the
- * three thresholds live here as conditions.
- *
- * Order of sacrifice: the ⌘↵ hint, then the preset labels, then the project
- * name. The routing indicator and the queue readout never collapse at any width
- * — the first is the only thing telling a user what ⌘↵ is about to run, and the
- * second is the only thing telling them whether it started.
- */
const hideBelow = (px: number) => ({ [`@media (max-width: ${px - 1}px)`]: { display: 'none' } }) as const;
-/** The `⌘↵` hint on the Invoke button face; the tooltip keeps it below this. */
export const HIDE_BELOW_HINT_WIDTH = hideBelow(1440);
-/** Preset labels; the names move to their tooltips below this. */
export const HIDE_BELOW_PRESET_LABEL_WIDTH = hideBelow(1280);
-/** The project name; the count badge and selector glyph always stay. */
export const HIDE_BELOW_PROJECT_NAME_WIDTH = hideBelow(1024);
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/useInvocationState.ts b/invokeai/frontend/webv2/src/workbench/shell/topbar/useInvocationState.ts
index 634b58ada5..8d48095903 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/useInvocationState.ts
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/useInvocationState.ts
@@ -33,7 +33,6 @@ const selectInvocationRouteInput = createInvocationRouteInputSelector();
const areTypeIdSetsEqual = (left: ReadonlySet<WidgetTypeId>, right: ReadonlySet<WidgetTypeId>): boolean =>
left.size === right.size && [...left].every((typeId) => right.has(typeId));
-/** Reads the persisted dynamic prompt fields off untyped widget values. */
const readDynamicPromptsConfig = (values: Record<string, unknown>) => ({
combinatorial: values.dynamicPromptsCombinatorial,
maxPrompts: values.dynamicPromptsMaxPrompts,
@@ -41,11 +40,6 @@ const readDynamicPromptsConfig = (values: Record<string, unknown>) => ({
seedBehaviour: values.dynamicPromptsSeedBehaviour,
});
-/**
- * The prompt that will actually be expanded and submitted — the authored text
- * wrapped by the active template, since a template can introduce `{a|b}` the
- * authored prompt never had.
- */
const readEffectivePositivePrompt = (values: Record<string, unknown>): string => {
const settings = normalizeGenerateSettings(values);
@@ -59,27 +53,14 @@ export interface InvocationState {
blockingReasons: string[];
invocation: InvocationRoute;
isValid: boolean;
- /** Every graph widget — all of them stay selectable in the routing menu. */
sources: GraphWidgetSource[];
- /** Widget types the layout is showing right now. */
visibleTypeIds: ReadonlySet<WidgetTypeId>;
- /** Widget types placed in some rail; picking one of these needs no new placement. */
placedTypeIds: ReadonlySet<WidgetTypeId>;
promptExpansion: DynamicPromptsExpansion;
- /** The values the batch count and prompt summary belong to (generate or upscale). */
sourceValues: Record<string, unknown>;
- /** Submits the current route. Pass a destination to override it for this run only. */
invoke: (destinationOverride?: ResultDestination) => Promise<void>;
}
-/**
- * Everything the invocation cluster needs to render and to fire, in one place.
- *
- * The Invoke button, the routing indicator, and the iterations stepper all
- * depend on the same resolved route; splitting the resolution across three
- * components would let them disagree about whether the route is runnable, which
- * is exactly the failure the redesign exists to prevent.
- */
export const useInvocationState = (): InvocationState => {
const { t } = useTranslation();
const routeInput = useActiveProjectSelector(selectInvocationRouteInput);
@@ -104,8 +85,6 @@ export const useInvocationState = (): InvocationState => {
const isConnected = backendConnectionStatus === 'connected';
const sourceValues = invocation.sourceId === 'upscale' ? routeInput.upscaleValues : routeInput.generateValues;
- // Observing the shared expansion cache here keeps the count honest and costs
- // nothing extra: the Generate preview and the submit path use the same key.
const promptExpansion = useDynamicPrompts(
readEffectivePositivePrompt(routeInput.generateValues),
invocation.sourceId === 'generate' || invocation.sourceId === 'canvas'
@@ -119,9 +98,6 @@ export const useInvocationState = (): InvocationState => {
? 'The prompt could not be expanded.'
: (promptExpansion.error ?? null);
- // Whether the source widget is *placed* is already part of route validation
- // ("The X widget is not mounted in this project"), so there is no separate
- // openness gate here — a source that is merely not on screen still runs.
const blockingReasons = useMemo(
() => [
...(isConnected ? [] : ['The backend is disconnected.']),
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentsPopover.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentsPopover.tsx
index 3f07642677..398b648907 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentsPopover.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentsPopover.tsx
@@ -22,17 +22,6 @@ import { applyStructural, applyStructuralPreview } from './layerOps';
const SELECT_POSITIONING = { placement: 'bottom-end', sameWidth: false } as const;
-/**
- * The curve editor's SVG goes through the Chakra factory so `fill`/`stroke` take
- * semantic tokens.
- *
- * Hand-written `var(--chakra-colors-bg-inset)` silently produced a solid black
- * box: Chakra emits these custom properties with the token path intact
- * (`--chakra-colors-bg.inset`, dot and all), so the hyphenated guess resolved to
- * nothing — and an unresolvable `fill` falls back to its initial value, black,
- * while `stroke` falls back to `none`. That took the grid, the border, the
- * diagonal, the curve, and the handle outlines with it.
- */
const CurveSvg = chakra('svg');
const CurveRect = chakra('rect');
const CurveLine = chakra('line');
@@ -40,15 +29,6 @@ const CurveGroup = chakra('g');
const CurvePath = chakra('path');
const CurveHandle = chakra('circle');
-/**
- * Square, so the `0 0 180 180` viewBox maps 1:1 onto the element box.
- *
- * With a full-width box and a fixed height the default `preserveAspectRatio`
- * letterboxed the drawing — it rendered centred with dead space either side,
- * while `svgPointFromEvent` still mapped pointer x across the *whole* element.
- * Every horizontal hit test was therefore offset, so grabbing an interior point
- * missed it and dropping one landed at the wrong input level.
- */
const CURVE_SVG_CSS = {
aspectRatio: '1',
borderRadius: 'l2',
@@ -58,14 +38,6 @@ const CURVE_SVG_CSS = {
width: 'full',
};
-/**
- * Nothing in the editor is selectable text.
- *
- * Double-clicking to add a point is a word-select gesture as far as the browser
- * is concerned, so it would latch onto the nearest text — the channel select's
- * label. The next press on a handle then dragged *that* selection instead,
- * trailing a floating "Red" across the screen and abandoning the point drag.
- */
const CURVE_EDITOR_CSS = { userSelect: 'none' };
const CURVE_HANDLE_CSS = { cursor: 'grab', _active: { cursor: 'grabbing' } };
@@ -74,7 +46,6 @@ const preventDefault = (event: { preventDefault: () => void }): void => event.pr
type CurveChannel = 'r' | 'g' | 'b';
const CURVE_CHANNELS: readonly CurveChannel[] = ['r', 'g', 'b'];
-/** The identity curve control points (diagonal). */
const IDENTITY_CURVE: [number, number][] = [
[0, 0],
[255, 255],
@@ -101,19 +72,6 @@ interface AdjustmentsPopoverProps {
layer: CanvasRasterLayerContractV2;
}
-/**
- * Non-destructive raster-adjustment editor (plan §1.3): brightness / contrast /
- * saturation sliders plus a minimal per-channel curves editor and a reset. All
- * edits patch the layer's `adjustments` through the canvas undo stack
- * (`applyStructural` → `updateCanvasLayerConfig`); sliders use the same
- * draft/commit pattern as opacity (one history entry per drag). The curve math
- * lives in the pure `render/adjustments` module — this component only manages
- * control points and previews the LUT.
- *
- * Rendered inline inside the per-layer properties popover (round 3): a nested
- * popover would be an "outside interaction" for its parent and close it, so this
- * renders as a plain section rather than its own popover.
- */
export const AdjustmentsPopover = ({ engine, layer }: AdjustmentsPopoverProps) => {
const adjustments = layer.adjustments ?? DEFAULT_ADJUSTMENTS;
return <AdjustmentsControls adjustments={adjustments} engine={engine} layer={layer} />;
@@ -171,7 +129,6 @@ const AdjustmentsControls = ({ adjustments, engine, layer }: AdjustmentsControls
commit(t('widgets.layers.adjustments.reset'), { ...DEFAULT_ADJUSTMENTS }, adjustments);
}, [adjustments, commit, t]);
- // Live (render-only) during a curve-point drag: preview without pushing history.
const handleCurveLive = useCallback(
(channel: CurveChannel, points: [number, number][]) => {
patchLive(withCurve(adjustments, channel, points));
@@ -181,10 +138,6 @@ const AdjustmentsControls = ({ adjustments, engine, layer }: AdjustmentsControls
const handleCurveCancel = useCallback((before: CanvasAdjustmentsContract) => patchLive(before), [patchLive]);
- // Single history entry per gesture (drag end, click-add, dbl-click-remove). The
- // `before` snapshot is captured at gesture start by the editor (during a drag
- // `adjustments` has already advanced via the live previews), so it undoes the
- // WHOLE gesture rather than the last frame.
const handleCurveCommit = useCallback(
(current: CanvasAdjustmentsContract, before: CanvasAdjustmentsContract) => {
commit(t('widgets.layers.adjustments.curves'), current, before);
@@ -236,7 +189,6 @@ interface AdjustmentSliderProps {
onCommit: (label: string, key: ScalarKey, next: number, before: CanvasAdjustmentsContract) => void;
}
-/** A single -1..1 adjustment slider owning its own draft/before (one history entry per drag). */
const AdjustmentSlider = ({ adjustmentKey, adjustments, label, onCommit, onLive }: AdjustmentSliderProps) => {
const beforeRef = useRef<CanvasAdjustmentsContract | null>(null);
const value = adjustments[adjustmentKey] ?? 0;
@@ -290,24 +242,16 @@ const AdjustmentSlider = ({ adjustmentKey, adjustments, label, onCommit, onLive
interface CurvesEditorProps {
adjustments: CanvasAdjustmentsContract;
- /** Render-only preview during a point drag (no history entry). */
onLive: (channel: CurveChannel, points: [number, number][]) => void;
- /** Restores the pre-drag snapshot when the browser cancels a gesture. */
onCancel: (before: CanvasAdjustmentsContract) => void;
- /** Commits one history entry for a completed gesture, undoing to `before`. */
onCommit: (current: CanvasAdjustmentsContract, before: CanvasAdjustmentsContract) => void;
}
-/** A compact per-channel curves editor (SVG): drag points, click to add, double-click to remove. */
const CurvesEditor = ({ adjustments, onCancel, onCommit, onLive }: CurvesEditorProps) => {
const { t } = useTranslation();
const [channel, setChannel] = useState<CurveChannel>('r');
const dragIndexRef = useRef<number | null>(null);
const svgRef = useRef<SVGSVGElement | null>(null);
- // A point drag streams render-only previews; `beforeRef` snapshots the
- // adjustments at drag start and `latestPointsRef` holds the last previewed
- // points, so pointer-up commits the whole drag as ONE history entry (mirrors
- // the scalar sliders' live/commit split — no per-frame undo-stack flooding).
const beforeRef = useRef<CanvasAdjustmentsContract | null>(null);
const latestPointsRef = useRef<[number, number][] | null>(null);
const dragTargetRef = useRef<Element | null>(null);
@@ -325,8 +269,6 @@ const CurvesEditor = ({ adjustments, onCancel, onCommit, onLive }: CurvesEditorP
[t]
);
- // Relies on the SVG being square (see CURVE_SVG_CSS): the viewBox then maps
- // linearly onto the element box, so a plain ratio is the whole conversion.
const svgPointFromEvent = useCallback((event: { clientX: number; clientY: number }): { px: number; py: number } => {
const svg = svgRef.current;
if (!svg) {
@@ -355,19 +297,13 @@ const CurvesEditor = ({ adjustments, onCancel, onCommit, onLive }: CurvesEditorP
[]
);
- // Handlers read their point index off the element rather than closing over it,
- // so each handle gets one stable callback instead of a fresh closure per
- // render (these sit on a `chakra()` component, which re-renders on new props).
const handlePointDown = useCallback(
(event: ReactPointerEvent<SVGCircleElement>) => {
event.stopPropagation();
- // Keeps the press from also starting a native selection/text drag, which
- // would hijack the gesture a few pixels in.
event.preventDefault();
event.currentTarget.setPointerCapture(event.pointerId);
dragIndexRef.current = Number(event.currentTarget.dataset.index);
dragTargetRef.current = event.currentTarget;
- // Snapshot the pre-drag state once, for a single whole-drag history entry.
beforeRef.current = adjustments;
latestPointsRef.current = null;
},
@@ -387,10 +323,8 @@ const CurvesEditor = ({ adjustments, onCancel, onCommit, onLive }: CurvesEditorP
if (i !== index) {
return p;
}
- // Endpoints keep their x anchored (0 / 255); only y moves.
return isEndpoint ? ([p[0], ny] as [number, number]) : ([nx, ny] as [number, number]);
});
- // Keep interior x within its neighbours to preserve monotonic ordering.
if (!isEndpoint) {
const lo = next[index - 1][0] + 1;
const hi = next[index + 1][0] - 1;
@@ -411,8 +345,6 @@ const CurvesEditor = ({ adjustments, onCancel, onCommit, onLive }: CurvesEditorP
}
dragIndexRef.current = null;
dragTargetRef.current = null;
- // Commit the whole drag as one history entry (only if the point actually
- // moved — a click with no move streams no previews and needs no commit).
const before = beforeRef.current;
const finalPoints = latestPointsRef.current;
beforeRef.current = null;
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.tsx
index ea75ee92b3..b3a54a4346 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerListItem.tsx
@@ -69,7 +69,6 @@ const VISIBILITY_DOT_UNCHECKED_HOVER = {
export type LayerListItemEngine = LayerContextMenuEngine & LayerPropertiesEngine & Pick<CanvasEngineHandle, 'previews'>;
-/** i18n key for a layer's short type/source badge. */
const layerBadgeKey = (layer: CanvasLayerContract): string => {
if (layer.type === 'raster') {
return layer.source.type === 'image' ? 'widgets.layers.types.image' : 'widgets.layers.types.paint';
@@ -95,15 +94,6 @@ export const getLayerListItemInteractionState = (editingLocked: boolean) => ({
sortableDisabled: editingLocked,
});
-/**
- * One layer row: thumbnail, name (double-click to rename), type badge,
- * visibility + lock toggles, a properties popover (blend mode + the layer's
- * type-specific settings), and an overflow/context menu. The whole row is the
- * pointer drag target, so reordering costs no visible grip; by keyboard it is
- * the context menu's Move actions. The pointer distance constraint keeps
- * clicks, double-click rename, and row buttons working; selected-layer opacity
- * lives in the panel header.
- */
export const LayerListItem = ({
dispatch,
editingLocked,
@@ -160,12 +150,6 @@ export const LayerListItem = ({
[layer.isEnabled, patchBase, t]
);
- /**
- * Hide is a DISPLAY-only axis, orthogonal to enabled: a hidden control map or
- * mask still conditions generation exactly as it would if visible. Only the
- * three overlay types have it — for a raster layer, visibility and
- * participation are the same fact.
- */
const handleToggleHidden = useCallback(
(event: { stopPropagation: () => void }) => {
event.stopPropagation();
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFrame.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFrame.tsx
index 707dac51b4..9515d20976 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFrame.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFrame.tsx
@@ -25,18 +25,6 @@ import { PreviewCompareDropZone } from './PreviewCompareDropZone';
import { PreviewLiveOverlay } from './PreviewLiveReadout';
import { usePreviewLoupe, type PreviewLoupeControls } from './usePreviewLoupe';
-/**
- * The preview's image surface: a dot-grid backdrop with an aspect-fitted,
- * shadowed frame. Owns everything drawn over the image (live badge, and later
- * the loupe, progress hairline, and drop-to-compare affordance) so the widget
- * shell never grows frame-specific rendering.
- *
- * The backdrop is deliberately unframed — no border, no radius, no outer
- * padding — so the dot grid reads as the widget's own floor and runs edge to
- * edge. The only framed thing is the media itself; the filmstrip and details
- * float above the grid rather than sitting in a second card.
- */
-
export const previewGridCss = {
backgroundImage: 'radial-gradient(circle, currentColor 1px, transparent 1.5px)',
backgroundPosition: 'center',
@@ -76,30 +64,22 @@ export type PreviewMediaSource =
| { itemKey: GalleryItemKey; kind: 'video'; label: string; poster: string; src: string };
interface PreviewFrameProps {
- /** Rendered instead of the fitted frame when there is no image source (inset variant only). */
children?: ReactNode;
- /** Saved gallery image represented by this frame. Live progress frames are never draggable. */
dragItem?: GalleryItemRef;
frameHeight: number;
frameWidth: number;
- /** Live selected-key read used by protected-video retry guards. */
isItemCurrent?: (itemKey: GalleryItemKey) => boolean;
isLive: boolean;
liveBadgeLabel: string;
- /** When set, the static live badge is replaced by the live progress readout for this run. */
liveQueueItemId?: string | null;
- /** Imperative zoom controls, for hotkeys registered by the widget shell. */
loupeControlsRef?: Ref<PreviewLoupeControls>;
onContextMenu?: (x: number, y: number) => void;
onVideoCopyAvailabilityChange?: (itemKey: GalleryItemKey, isAvailable: boolean) => void;
padding?: string;
- /** Extra bottom padding reserving room for the overlaid filmstrip and details. */
paddingBottom?: string;
shouldAntialiasLiveImage: boolean;
source: PreviewMediaSource | null;
- /** Preview-owned controller for the selected video's current frame. */
videoControllerRef?: Ref<PreviewVideoFrameController>;
- /** `framed` = bordered surface for a selected item; `inset` = flush surface for the empty state. */
variant: 'framed' | 'inset';
}