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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
refactor: apply final review fixes to palette and image listing
joshistoast5d1b3e4e60e3
diff --git a/invokeai/app/services/image_records/image_records_sqlite.py b/invokeai/app/services/image_records/image_records_sqlite.pyindex 949971bdda..6b99068309 100644--- a/invokeai/app/services/image_records/image_records_sqlite.py+++ b/invokeai/app/services/image_records/image_records_sqlite.py@@ -36,6 +36,19 @@ class _ImageQueryFilters:is_admin: bool = False+# Every uncategorized image plus every image on an active (non-archived) board:+# the board_id="all" visibility scope for admins and single-user installs.+_ALL_ACTIVE_BOARDS_CONDITION = """(+ board_images.board_id IS NULL+ OR EXISTS (+ SELECT 1+ FROM boards+ WHERE boards.board_id = board_images.board_id+ AND boards.archived = 0+ )+ )"""++def _build_image_query_conditions(filters: _ImageQueryFilters) -> tuple[str, list[Union[int, str, bool]]]:"""Build the shared filters for image-list and image-name queries."""conditions: list[str] = []@@ -62,17 +75,7 @@ def _build_image_query_conditions(filters: _ImageQueryFilters) -> tuple[str, lisparams.append(filters.user_id)elif filters.board_id == "all":if filters.is_admin:- conditions.append(- """(- board_images.board_id IS NULL- OR EXISTS (- SELECT 1- FROM boards- WHERE boards.board_id = board_images.board_id- AND boards.archived = 0- )- )"""- )+ conditions.append(_ALL_ACTIVE_BOARDS_CONDITION)elif filters.user_id is not None:conditions.append("""(@@ -97,19 +100,8 @@ def _build_image_query_conditions(filters: _ImageQueryFilters) -> tuple[str, lis)params.extend([filters.user_id, filters.user_id, filters.user_id])else:- # Single-user mode has no current user. It can read every active board- # and every uncategorized image, matching the administrative scope.- conditions.append(- """(- board_images.board_id IS NULL- OR EXISTS (- SELECT 1- FROM boards- WHERE boards.board_id = board_images.board_id- AND boards.archived = 0- )- )"""- )+ # Single-user mode has no current user; it reads the administrative scope.+ conditions.append(_ALL_ACTIVE_BOARDS_CONDITION)elif filters.board_id is not None:conditions.append("board_images.board_id = ?")params.append(filters.board_id)diff --git a/invokeai/frontend/webv2/public/locales/en-GB.json b/invokeai/frontend/webv2/public/locales/en-GB.jsonindex 2aaa0cdc42..481f298fee 100644--- a/invokeai/frontend/webv2/public/locales/en-GB.json+++ b/invokeai/frontend/webv2/public/locales/en-GB.json@@ -38,6 +38,7 @@"date": {"aWeekAgo": "A week ago","date": "Date",+ "day": "{{date}}","formatHint": "Or type a date — YYYY-MM-DD, 7d, 2w, 1m","from": "From {{date}}","pastWeek": "Past week",@@ -81,8 +82,7 @@"goToNodes": "Go to Nodes","goToProjects": "Go to Projects","goToUsers": "Go to Users",- "openEditor": "Open Editor",- "openSettings": "Open Settings"+ "openEditor": "Open Editor"},"appEntries": {"keyboardShortcuts": "Keyboard Shortcuts",diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex a183f2f5b5..b6c1148964 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -38,6 +38,7 @@"date": {"aWeekAgo": "A week ago","date": "Date",+ "day": "{{date}}","formatHint": "Or type a date — YYYY-MM-DD, 7d, 2w, 1m","from": "From {{date}}","pastWeek": "Past week",@@ -81,8 +82,7 @@"goToNodes": "Go to Nodes","goToProjects": "Go to Projects","goToUsers": "Go to Users",- "openEditor": "Open Editor",- "openSettings": "Open Settings"+ "openEditor": "Open Editor"},"appEntries": {"keyboardShortcuts": "Keyboard Shortcuts",diff --git a/invokeai/frontend/webv2/src/architecture/dependencyPolicy.test.ts b/invokeai/frontend/webv2/src/architecture/dependencyPolicy.test.tsindex d3d8f5e643..cd79c25071 100644--- a/invokeai/frontend/webv2/src/architecture/dependencyPolicy.test.ts+++ b/invokeai/frontend/webv2/src/architecture/dependencyPolicy.test.ts@@ -166,6 +166,10 @@ describe('feature public-interface registry', () => {expect(checkDependency('workbench/palette/paletteProviders.ts', '@features/workflow/paletteSearch')).toEqual([]);expect(checkDependency('workbench/palette/paletteProviders.ts', '@features/gallery/paletteSearch')).toEqual([]);expect(checkDependency('workbench/palette/paletteProviders.ts', '@features/queue/queries')).toEqual([]);+ expect(checkDependency('workbench/palette/WorkbenchCommandPalette.tsx', '@features/queue/paletteSearch')).toEqual(+ []+ );+ expect(checkDependency('workbench/palette/WorkbenchCommandPalette.tsx', '@features/queue/reveal')).toEqual([]);expect(checkDependency('features/gallery/ui/View.tsx', '@features/queue/publicApi')).toMatchObject([{ rule: 'feature-public-interface' },]);diff --git a/invokeai/frontend/webv2/src/features/gallery/data/backend.ts b/invokeai/frontend/webv2/src/features/gallery/data/backend.tsindex 788e7e3a23..9c4a2c752e 100644--- a/invokeai/frontend/webv2/src/features/gallery/data/backend.ts+++ b/invokeai/frontend/webv2/src/features/gallery/data/backend.ts@@ -290,7 +290,7 @@ export const listGalleryImages = async ({signal?: AbortSignal;starredFirst?: boolean;}): Promise<GalleryImagesPage> => {- if (boardId !== undefined && isDateBoardId(boardId)) {+ if (isDateBoardId(boardId)) {return listGalleryDateBoardImages({boardId,createdFrom,diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryToolbar.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryToolbar.tsxindex 71d25bb04c..546ce70977 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryToolbar.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryToolbar.tsx@@ -15,12 +15,7 @@ import {Text,} from '@chakra-ui/react';import { isDateBoardId } from '@features/gallery/data/backend';-import {- formatIsoDate,- isPossibleDatePrefix,- matchTrailingDateToken,- parseDateTokens,-} from '@platform/search/dateTokens';+import { describeDateRange, findInvalidDateToken, formatIsoDate, parseDateTokens } from '@platform/search/dateTokens';import { Button, CloseButton, IconButton, Tabs } from '@platform/ui';import { SearchIcon, SettingsIcon, UploadIcon } from 'lucide-react';import { useCallback, useMemo, useRef } from 'react';@@ -91,53 +86,48 @@ export const GalleryToolbar = ({ layout }: { layout: 'stacked' | 'wide' }) => {);// Derived from the raw search term: an applied-range summary, or invalid-- // token feedback. A trailing token that could still become valid (`from:`,- // `from:2026-`) is normal typing, not an error.+ // token feedback.const dateHint = useMemo(() => {const parse = parseDateTokens(gallery.searchTerm);- const trailing = matchTrailingDateToken(gallery.searchTerm);- const invalid = parse.invalidTokens.find(- (token) =>- !(- trailing &&- token.key === trailing.key &&- token.raw === trailing.partialValue &&- isPossibleDatePrefix(token.raw)- )- );+ const invalid = findInvalidDateToken(gallery.searchTerm, parse);if (invalid) {return { isInvalid: true, label: t('widgets.gallery.dateFilterInvalid', { value: invalid.raw }) };}- if (!parse.range) {+ const shape = parse.range ? describeDateRange(parse.range) : null;++ if (!shape) {return null;}const locale = i18n.language;- const { from, to } = parse.range;- if (from !== undefined && to !== undefined) {- return {- isInvalid: false,- label:- from === to- ? t('widgets.gallery.dateFilterDay', { date: formatIsoDate(from, locale) })- : t('widgets.gallery.dateFilterRange', {- from: formatIsoDate(from, locale),- to: formatIsoDate(to, locale),- }),- };+ switch (shape.kind) {+ case 'day':+ return {+ isInvalid: false,+ label: t('widgets.gallery.dateFilterDay', { date: formatIsoDate(shape.date, locale) }),+ };+ case 'range':+ return {+ isInvalid: false,+ label: t('widgets.gallery.dateFilterRange', {+ from: formatIsoDate(shape.from, locale),+ to: formatIsoDate(shape.to, locale),+ }),+ };+ case 'from':+ return {+ isInvalid: false,+ label: t('widgets.gallery.dateFilterFrom', { date: formatIsoDate(shape.date, locale) }),+ };+ case 'through':+ return {+ isInvalid: false,+ label: t('widgets.gallery.dateFilterThrough', { date: formatIsoDate(shape.date, locale) }),+ };}-- if (from !== undefined) {- return { isInvalid: false, label: t('widgets.gallery.dateFilterFrom', { date: formatIsoDate(from, locale) }) };- }-- return {- isInvalid: false,- label: t('widgets.gallery.dateFilterThrough', { date: formatIsoDate(to ?? '', locale) }),- };}, [gallery.searchTerm, i18n.language, t]);const searchInput = useMemo(diff --git a/invokeai/frontend/webv2/src/features/workflow/paletteSearch.ts b/invokeai/frontend/webv2/src/features/workflow/paletteSearch.tsindex 99d5f4d7fc..ac1de62574 100644--- a/invokeai/frontend/webv2/src/features/workflow/paletteSearch.ts+++ b/invokeai/frontend/webv2/src/features/workflow/paletteSearch.ts@@ -1,6 +1,6 @@import { apiFetchJson } from '@platform/transport/http';-interface WorkflowLibraryListItem {+interface WorkflowLibraryListItemDTO {workflow_id: string;name: string;description: string;@@ -8,15 +8,38 @@ interface WorkflowLibraryListItem {tags?: string | null;}-interface WorkflowLibraryPage {- items: WorkflowLibraryListItem[];+interface WorkflowLibraryPageDTO {+ items: WorkflowLibraryListItemDTO[];page: number;pages: number;total: number;}+export interface WorkflowLibraryItem {+ workflowId: string;+ name: string;+ description: string;+ category: 'user' | 'default';+ tags?: string;+}++export interface WorkflowLibraryPage {+ items: WorkflowLibraryItem[];+ page: number;+ pages: number;+ total: number;+}++const mapItem = (item: WorkflowLibraryListItemDTO): WorkflowLibraryItem => ({+ category: item.category,+ description: item.description,+ name: item.name,+ tags: item.tags ?? undefined,+ workflowId: item.workflow_id,+});+/** Cancellable workflow-library read used by deferred cross-feature search surfaces. */-export const listLibraryWorkflows = ({+export const listLibraryWorkflows = async ({category,page,perPage = 20,@@ -41,5 +64,7 @@ export const listLibraryWorkflows = ({params.set('query', query.trim());}- return apiFetchJson<WorkflowLibraryPage>(`/api/v1/workflows/?${params.toString()}`, { signal });+ const body = await apiFetchJson<WorkflowLibraryPageDTO>(`/api/v1/workflows/?${params.toString()}`, { signal });++ return { items: body.items.map(mapItem), page: body.page, pages: body.pages, total: body.total };};diff --git a/invokeai/frontend/webv2/src/platform/search/dateTokens.ts b/invokeai/frontend/webv2/src/platform/search/dateTokens.tsindex a0d155d639..71ce1f8d6b 100644--- a/invokeai/frontend/webv2/src/platform/search/dateTokens.ts+++ b/invokeai/frontend/webv2/src/platform/search/dateTokens.ts@@ -205,6 +205,54 @@ export const isPossibleDatePrefix = (partialValue: string): boolean => {return /^\d{1,4}(-(\d{0,2}(-\d{0,2})?)?)?$/.test(lower) && lower.length <= 10;};+/**+ * The first invalid token worth surfacing as feedback. A trailing token whose+ * value could still become valid with more typing (`from:`, `from:2026-`) is+ * normal entry, not an error, and is exempted.+ */+export const findInvalidDateToken = (query: string, parse: DateTokenParse): InvalidDateToken | undefined => {+ const trailing = matchTrailingDateToken(query);++ return parse.invalidTokens.find(+ (token) =>+ !(+ trailing &&+ token.key === trailing.key &&+ token.raw === trailing.partialValue &&+ isPossibleDatePrefix(token.raw)+ )+ );+};++/**+ * The label shape an applied range should render as: a single day (both bounds+ * equal), a closed range, or an open-ended bound. Surfaces map each kind to+ * their own i18n copy.+ */+export type DateRangeShape =+ | { kind: 'day'; date: string }+ | { kind: 'range'; from: string; to: string }+ | { kind: 'from'; date: string }+ | { kind: 'through'; date: string };++export const describeDateRange = (range: DateRange): DateRangeShape | null => {+ if (range.from !== undefined && range.to !== undefined) {+ return range.from === range.to+ ? { date: range.from, kind: 'day' }+ : { from: range.from, kind: 'range', to: range.to };+ }++ if (range.from !== undefined) {+ return { date: range.from, kind: 'from' };+ }++ if (range.to !== undefined) {+ return { date: range.to, kind: 'through' };+ }++ return null;+};+/*** Formats a YYYY-MM-DD string as a short local date ("Jul 14"). Builds the* Date from parts in local time — never via `new Date(isoString)`, whichdiff --git a/invokeai/frontend/webv2/src/workbench/palette/LaunchpadCommandPaletteDialog.tsx b/invokeai/frontend/webv2/src/workbench/palette/LaunchpadCommandPaletteDialog.tsxindex 153170ac60..ba8682a4a4 100644--- a/invokeai/frontend/webv2/src/workbench/palette/LaunchpadCommandPaletteDialog.tsx+++ b/invokeai/frontend/webv2/src/workbench/palette/LaunchpadCommandPaletteDialog.tsx@@ -27,65 +27,26 @@ const LaunchpadCommandPaletteDialog = ({const { canManageModels, canManageNodes, canManageUsers } = useCapabilities();const entries = useMemo<PaletteEntry[]>(() => {+ const navEntry = ({ id, keywords, run }: { id: string; keywords?: string; run: () => void }): PaletteEntry => ({+ group: 'Navigation',+ groupLabel: t('commandPalette.groups.navigation'),+ id: `launchpad.${id}`,+ isPersistentRecent: true,+ keywords,+ run,+ showInEmptyState: true,+ title: t(`commandPalette.launchpad.${id}`),+ });const navigation: PaletteEntry[] = [- {- group: 'Navigation',- groupLabel: t('commandPalette.groups.navigation'),- id: 'launchpad.openEditor',- isPersistentRecent: true,+ navEntry({+ id: 'openEditor',keywords: 'workbench app project',run: () => void navigate({ search: search.project ? { project: search.project } : {}, to: '/app' }),- showInEmptyState: true,- title: t('commandPalette.launchpad.openEditor'),- },- {- group: 'Navigation',- groupLabel: t('commandPalette.groups.navigation'),- id: 'launchpad.goToProjects',- isPersistentRecent: true,- run: () => void navigate({ to: '/projects' }),- showInEmptyState: true,- title: t('commandPalette.launchpad.goToProjects'),- },- ...(canManageModels- ? [- {- group: 'Navigation',- groupLabel: t('commandPalette.groups.navigation'),- id: 'launchpad.goToModels',- isPersistentRecent: true,- run: () => void navigate({ to: '/models' }),- showInEmptyState: true,- title: t('commandPalette.launchpad.goToModels'),- },- ]- : []),- ...(canManageNodes- ? [- {- group: 'Navigation',- groupLabel: t('commandPalette.groups.navigation'),- id: 'launchpad.goToNodes',- isPersistentRecent: true,- run: () => void navigate({ to: '/nodes' }),- showInEmptyState: true,- title: t('commandPalette.launchpad.goToNodes'),- },- ]- : []),- ...(canManageUsers- ? [- {- group: 'Navigation',- groupLabel: t('commandPalette.groups.navigation'),- id: 'launchpad.goToUsers',- isPersistentRecent: true,- run: () => void navigate({ to: '/users' }),- showInEmptyState: true,- title: t('commandPalette.launchpad.goToUsers'),- },- ]- : []),+ }),+ navEntry({ id: 'goToProjects', run: () => void navigate({ to: '/projects' }) }),+ ...(canManageModels ? [navEntry({ id: 'goToModels', run: () => void navigate({ to: '/models' }) })] : []),+ ...(canManageNodes ? [navEntry({ id: 'goToNodes', run: () => void navigate({ to: '/nodes' }) })] : []),+ ...(canManageUsers ? [navEntry({ id: 'goToUsers', run: () => void navigate({ to: '/users' }) })] : []),{group: 'App',groupLabel: t('commandPalette.groups.app'),@@ -94,7 +55,7 @@ const LaunchpadCommandPaletteDialog = ({keywords: 'preferences options',run: () => openWorkbenchSettings(),showInEmptyState: true,- title: t('commandPalette.launchpad.openSettings'),+ title: t('commandPalette.appEntries.openSettings'),},];diff --git a/invokeai/frontend/webv2/src/workbench/palette/paletteProviders.ts b/invokeai/frontend/webv2/src/workbench/palette/paletteProviders.tsindex 38656d6b46..aa03039229 100644--- a/invokeai/frontend/webv2/src/workbench/palette/paletteProviders.ts+++ b/invokeai/frontend/webv2/src/workbench/palette/paletteProviders.ts@@ -4,12 +4,14 @@ import type { QueueReadModel } from '@features/queue/contracts';import type { PromptHistoryItem } from '@workbench/projectContracts';import type { TFunction } from 'i18next';-import { ALL_READABLE_BOARDS_ID, listGalleryBoards, listGalleryImages } from '@features/gallery/paletteSearch';+import { ALL_READABLE_BOARDS_ID, listGalleryImages } from '@features/gallery/paletteSearch';+import { galleryBoardsOptions } from '@features/gallery/queries';import { focusPositivePrompt } from '@features/generation/react';import { ensureModelsLoaded, getModelBaseLabel, getModelsSnapshot } from '@features/models';import { extractGenerationMeta, getResultImageName } from '@features/queue/contracts';import { listLibraryWorkflows } from '@features/workflow/paletteSearch';import { requestLibraryWorkflowLoad } from '@features/workflow/react';+import { queryClient } from '@platform/query/client';import { formatIsoDate, isTimestampInRange } from '@platform/search/dateTokens';import { absolutizeApiUrl } from '@platform/transport/http';@@ -27,6 +29,13 @@ import { getObjectIdentity } from './objectIdentity';const PROVIDER_PAGE_SIZE = 8;+/**+ * Boards back two providers on every debounced keystroke; read them through the+ * query cache (60s staleTime) instead of refetching per search.+ */+const loadActiveBoards = (): Promise<GalleryBoard[]> =>+ queryClient.fetchQuery(galleryBoardsOptions({ includeArchived: false }));+const matchesTerms = (haystack: string, query: string): boolean => {const terms = query.trim().toLowerCase().split(/\s+/).filter(Boolean);const lower = haystack.toLowerCase();@@ -53,12 +62,12 @@ export const createWorkflowsProvider = ({return [...user.items, ...defaults.items].map<PaletteEntry>((item) => ({group: 'Workflows',groupLabel: t('commandPalette.groups.workflows'),- id: `workflow:${item.workflow_id}`,+ id: `workflow:${item.workflowId}`,isPersistentRecent: false,- keywords: item.tags ?? undefined,+ keywords: item.tags,run: () => {openWorkflowWidget();- requestLibraryWorkflowLoad(item.workflow_id);+ requestLibraryWorkflowLoad(item.workflowId);},subtitle:item.category === 'default'@@ -83,7 +92,9 @@ export const createBoardsProvider = ({providerKey: getPaletteContributionKey('provider', 'boards'),supportsCreatedAtRange: true,search: async (query, { signal }) => {- const boards = await listGalleryBoards({ includeArchived: false, signal });+ const boards = await loadActiveBoards();++ signal.throwIfAborted();return boards.filter(@@ -294,7 +305,7 @@ export const createImagesProvider = ({searchTerm: query.text,signal,}),- listGalleryBoards({ includeArchived: false, signal }),+ loadActiveBoards(),]);const boardNames = new Map(boards.map((board: GalleryBoard) => [board.id, board.name]));diff --git a/invokeai/frontend/webv2/src/workbench/palette/useCommandPaletteController.ts b/invokeai/frontend/webv2/src/workbench/palette/useCommandPaletteController.tsindex 712e14e26d..ae59a76fb1 100644--- a/invokeai/frontend/webv2/src/workbench/palette/useCommandPaletteController.ts+++ b/invokeai/frontend/webv2/src/workbench/palette/useCommandPaletteController.ts@@ -4,8 +4,9 @@ import type { ChangeEvent, KeyboardEvent } from 'react';import { useMountEffect } from '@platform/react/useMountEffect';import {completeTrailingDateToken,+ describeDateRange,+ findInvalidDateToken,formatIsoDate,- isPossibleDatePrefix,matchTrailingDateToken,parseDateTokens,} from '@platform/search/dateTokens';@@ -565,40 +566,26 @@ export const useCommandPaletteController = ({}, [focusInput, scopedQueryResult]);// Quiet acknowledgment of the applied range, and inline feedback for values- // that cannot parse. A trailing token that could still become valid- // (`from:`, `from:2026-`) is normal typing, not an error. Feedback beats- // acknowledgment when both apply.+ // that cannot parse. Feedback beats acknowledgment when both apply.const dateInvalidHint = useMemo(() => {- if (dateParse === null) {- return null;- }-- const trailing = matchTrailingDateToken(localQuery);- const invalid = dateParse.invalidTokens.find(- (token) =>- !(- trailing &&- token.key === trailing.key &&- token.raw === trailing.partialValue &&- isPossibleDatePrefix(token.raw)- )- );+ const invalid = dateParse === null ? undefined : findInvalidDateToken(localQuery, dateParse);return invalid ? t('commandPalette.states.invalidDate', { value: invalid.raw }) : null;}, [dateParse, localQuery, t]);+ const dateShape = dateParse?.range && dateInvalidHint === null ? describeDateRange(dateParse.range) : null;const dateSummary =- dateParse?.range && dateInvalidHint === null- ? dateParse.range.from && dateParse.range.to- ? t('commandPalette.date.range', {- from: formatIsoDate(dateParse.range.from, i18n.resolvedLanguage),- to: formatIsoDate(dateParse.range.to, i18n.resolvedLanguage),- })- : dateParse.range.from- ? t('commandPalette.date.from', { date: formatIsoDate(dateParse.range.from, i18n.resolvedLanguage) })- : dateParse.range.to- ? t('commandPalette.date.through', { date: formatIsoDate(dateParse.range.to, i18n.resolvedLanguage) })- : null- : null;+ dateShape === null+ ? null+ : dateShape.kind === 'day'+ ? t('commandPalette.date.day', { date: formatIsoDate(dateShape.date, i18n.resolvedLanguage) })+ : dateShape.kind === 'range'+ ? t('commandPalette.date.range', {+ from: formatIsoDate(dateShape.from, i18n.resolvedLanguage),+ to: formatIsoDate(dateShape.to, i18n.resolvedLanguage),+ })+ : dateShape.kind === 'from'+ ? t('commandPalette.date.from', { date: formatIsoDate(dateShape.date, i18n.resolvedLanguage) })+ : t('commandPalette.date.through', { date: formatIsoDate(dateShape.date, i18n.resolvedLanguage) });const isBusy = providerSections.some((section) => section.isFetching || section.isWaitingForDebounce);const failedProviderCount = providerSections.filter((section) => section.isError).length;