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
feat(webv2): duplicate any system prompt, and let admins edit shared ones
Lincoln Stein0c76a735d03f
diff --git a/invokeai/frontend/webv2/performance/architecture-baseline.json b/invokeai/frontend/webv2/performance/architecture-baseline.jsonindex 2d74dd9d6c..e4d0a47829 100644--- a/invokeai/frontend/webv2/performance/architecture-baseline.json+++ b/invokeai/frontend/webv2/performance/architecture-baseline.json@@ -337,7 +337,7 @@"initialRawBytes": 2972354,"largestAssetRawBytes": 747209,"otherAssetRawBytes": 0,- "ownedRawBytes": 131277,+ "ownedRawBytes": 131330,"requestCount": 106,"scriptRequestCount": 90,"sourceOwners": [@@ -1031,7 +1031,7 @@"initialRawBytes": 3002078,"largestAssetRawBytes": 754682,"otherAssetRawBytes": 0,- "ownedRawBytes": 131277,+ "ownedRawBytes": 131330,"requestCount": 106,"scriptRequestCount": 90},diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex fe19f18336..cfd433209e 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -2227,6 +2227,8 @@"maxTokensInvalid": "Enter a whole number between {{min}} and {{max}}, or leave it empty.","none": "No system prompts","shared": "Shared",+ "duplicate": "Duplicate",+ "sharedEditWarning": "Shared with everyone. Changes apply to all users.","deleteTitle": "Delete system prompt","deleteBody": "“{{name}}” will be deleted. This cannot be undone.","couldNotSave": "Could not save this system prompt.",diff --git a/invokeai/frontend/webv2/src/app/GenerationUiAdapter.tsx b/invokeai/frontend/webv2/src/app/GenerationUiAdapter.tsxindex c252f88b26..9bbe2a8525 100644--- a/invokeai/frontend/webv2/src/app/GenerationUiAdapter.tsx+++ b/invokeai/frontend/webv2/src/app/GenerationUiAdapter.tsx@@ -200,10 +200,10 @@ export const GenerationUiAdapterProvider = ({ children }: { children: ReactNode() => ({ patchGenerateSettings: generation.patchSettings }),[generation]);- const { canManagePromptTemplates } = useCapabilities();+ const { canManagePromptTemplates, canManageSharedSystemPrompts } = useCapabilities();const capabilitiesGroup = useMemo<GenerationUiAdapter['capabilities']>(- () => ({ canManagePromptTemplates }),- [canManagePromptTemplates]+ () => ({ canManagePromptTemplates, canManageSharedSystemPrompts }),+ [canManagePromptTemplates, canManageSharedSystemPrompts]);const accountGroup = useMemo<GenerationUiAdapter['account']>(() => ({diff --git a/invokeai/frontend/webv2/src/features/generation/core/systemPrompts.test.ts b/invokeai/frontend/webv2/src/features/generation/core/systemPrompts.test.tsindex 87916acc0b..09c8d44c8b 100644--- a/invokeai/frontend/webv2/src/features/generation/core/systemPrompts.test.ts+++ b/invokeai/frontend/webv2/src/features/generation/core/systemPrompts.test.ts@@ -4,7 +4,9 @@ import {classifySystemPrompts,isOwnedSystemPrompt,parseMaxTokensInput,- requireOwnedSystemPrompt,+ buildDuplicateName,+ canEditSystemPrompt,+ requireEditableSystemPrompt,resolveSelectedSystemPromptId,SYSTEM_PROMPT_MAX_TOKENS_MAX,SYSTEM_PROMPT_MAX_TOKENS_MIN,@@ -50,13 +52,17 @@ describe('classifySystemPrompts', () => {});});-describe('isOwnedSystemPrompt / requireOwnedSystemPrompt', () => {+describe('isOwnedSystemPrompt / requireEditableSystemPrompt', () => {it('allows the owner and refuses another user’s shared prompt', () => {expect(isOwnedSystemPrompt(record('a', 'me', false), MULTIUSER)).toBe(true);expect(isOwnedSystemPrompt(record('b', 'someone', true), MULTIUSER)).toBe(false);- expect(() => requireOwnedSystemPrompt(record('b', 'someone', true), MULTIUSER)).toThrow(SystemPromptOwnershipError);- expect(() => requireOwnedSystemPrompt(record('a', 'me', false), MULTIUSER)).not.toThrow();+ const noAuthority = { ...MULTIUSER, canManageSharedPrompts: false };++ expect(() => requireEditableSystemPrompt(record('b', 'someone', true), noAuthority)).toThrow(+ SystemPromptOwnershipError+ );+ expect(() => requireEditableSystemPrompt(record('a', 'me', false), noAuthority)).not.toThrow();});it('treats an anonymous multiuser session as owning nothing', () => {@@ -113,3 +119,53 @@ describe('parseMaxTokensInput', () => {}});});++describe('canEditSystemPrompt', () => {+ const MANAGER = { ...MULTIUSER, canManageSharedPrompts: true };+ const MEMBER = { ...MULTIUSER, canManageSharedPrompts: false };++ it('lets a manager edit a prompt shared by someone else', () => {+ const sharedByOther = record('b', 'someone', true);++ expect(canEditSystemPrompt(sharedByOther, MEMBER)).toBe(false);+ expect(canEditSystemPrompt(sharedByOther, MANAGER)).toBe(true);+ });++ it('never lets a manager edit another user’s private prompt', () => {+ // The REST layer does allow an admin to write this one. Offering it in the UI would turn a+ // moderation capability into an everyday button, so the client refuses regardless of rights.+ const privateOfOther = record('c', 'someone', false);++ expect(canEditSystemPrompt(privateOfOther, MANAGER)).toBe(false);+ expect(() => requireEditableSystemPrompt(privateOfOther, MANAGER)).toThrow(SystemPromptOwnershipError);+ });++ it('leaves own prompts editable without any management rights', () => {+ expect(canEditSystemPrompt(record('a', 'me', false), MEMBER)).toBe(true);+ });++ it('keeps everything editable in single-user mode', () => {+ const singleUser = { ...SINGLE_USER, canManageSharedPrompts: false };++ expect(canEditSystemPrompt(record('a', 'system', true), singleUser)).toBe(true);+ });+});++describe('buildDuplicateName', () => {+ it('suffixes the source name', () => {+ expect(buildDuplicateName('Ref2VA', [])).toBe('Ref2VA (copy)');+ });++ it('numbers past names already taken, so repeated copies stay distinguishable', () => {+ expect(buildDuplicateName('Ref2VA', ['Ref2VA (copy)'])).toBe('Ref2VA (copy 2)');+ expect(buildDuplicateName('Ref2VA', ['Ref2VA (copy)', 'Ref2VA (copy 2)'])).toBe('Ref2VA (copy 3)');+ });++ it('skips a gap rather than reusing a name in the list', () => {+ expect(buildDuplicateName('Ref2VA', ['Ref2VA (copy)', 'Ref2VA (copy 3)'])).toBe('Ref2VA (copy 2)');+ });++ it('copies a copy without parsing the suffix apart', () => {+ expect(buildDuplicateName('Ref2VA (copy)', ['Ref2VA (copy)'])).toBe('Ref2VA (copy) (copy)');+ });+});diff --git a/invokeai/frontend/webv2/src/features/generation/core/systemPrompts.ts b/invokeai/frontend/webv2/src/features/generation/core/systemPrompts.tsindex a0db8deebd..5196842f15 100644--- a/invokeai/frontend/webv2/src/features/generation/core/systemPrompts.ts+++ b/invokeai/frontend/webv2/src/features/generation/core/systemPrompts.ts@@ -47,19 +47,64 @@ export const classifySystemPrompts = <T extends SystemPromptOwnershipRecord>(export const isOwnedSystemPrompt = (record: SystemPromptOwnershipRecord, account: SystemPromptAccount): boolean =>!account.multiuserEnabled || (account.currentUserId !== null && record.userId === account.currentUserId);+/** What the viewer is allowed to change, beyond what they own. */+export interface SystemPromptEditAuthority extends SystemPromptAccount {+ /** Admin-derived. Grants edit rights over shared prompts only -- see `canEditSystemPrompt`. */+ canManageSharedPrompts: boolean;+}++/**+ * Own prompts always; shared ones when the viewer may manage them.+ *+ * Deliberately never true for another user's private prompt: the REST layer does let an admin+ * write one, but offering it here would turn a moderation capability into an everyday button.+ * `classifySystemPrompts` already keeps those records out of the list, and this is the second+ * guard so that a change to the first cannot silently expose them.+ */+export const canEditSystemPrompt = (+ record: SystemPromptOwnershipRecord,+ authority: SystemPromptEditAuthority+): boolean => isOwnedSystemPrompt(record, authority) || (authority.canManageSharedPrompts && record.isPublic);+export class SystemPromptOwnershipError extends Error {constructor() {- super('Only personal system prompts can be changed.');+ super('Only your own system prompts, or shared ones you manage, can be changed.');this.name = 'SystemPromptOwnershipError';}}-export const requireOwnedSystemPrompt = (record: SystemPromptOwnershipRecord, account: SystemPromptAccount): void => {- if (!isOwnedSystemPrompt(record, account)) {+export const requireEditableSystemPrompt = (+ record: SystemPromptOwnershipRecord,+ authority: SystemPromptEditAuthority+): void => {+ if (!canEditSystemPrompt(record, authority)) {throw new SystemPromptOwnershipError();}};+/**+ * A name for a copy that does not collide with one already in the list.+ *+ * Duplicating twice gives "... (copy)" then "... (copy 2)". A source that is itself a copy keeps+ * its suffix rather than being parsed apart, so the chain stays readable and the rule stays one+ * anyone can predict from the name they are looking at.+ */+export const buildDuplicateName = (sourceName: string, existingNames: Iterable<string>): string => {+ const taken = new Set(existingNames);+ const base = `${sourceName} (copy)`;++ if (!taken.has(base)) {+ return base;+ }+ for (let suffix = 2; ; suffix++) {+ const candidate = `${sourceName} (copy ${String(suffix)})`;++ if (!taken.has(candidate)) {+ return candidate;+ }+ }+};+/*** The selection that should actually be in effect.*diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerationUiContext.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerationUiContext.tsxindex 726f9bb912..a381bb6aa2 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerationUiContext.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerationUiContext.tsx@@ -54,6 +54,8 @@ export interface GenerationUiAdapter {capabilities: {/** Bulk import/export of prompt templates; the backend routes are admin-only. */canManagePromptTemplates: boolean;+ /** Edit prompts shared with everyone; never another user's private prompt. */+ canManageSharedSystemPrompts: boolean;};gallery: {selectedImage: GenerationSelectedImage | null;diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PositivePromptField.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PositivePromptField.browser.test.tsxindex 3b27a84a48..c9c1f29e9a 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PositivePromptField.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PositivePromptField.browser.test.tsx@@ -17,6 +17,7 @@ await i18n.use(initReactI18next).init({ fallbackLng: 'en', lng: 'en', resources:vi.mock('@features/generation/ui/GenerationUiContext', async (importOriginal) => ({...(await importOriginal<object>()),useGenerationUi: () => ({+ capabilities: { canManagePromptTemplates: false, canManageSharedSystemPrompts: false },gallery: { selectedImage: null },models: { catalog: [], ensureLoaded: vi.fn() },notifications: { reportError: vi.fn() },diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/SystemPromptsField.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/SystemPromptsField.tsxindex bd8cf7579e..71f9176c34 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/SystemPromptsField.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/SystemPromptsField.tsx@@ -21,7 +21,7 @@ import { MiddleTruncate } from '@platform/ui/MiddleTruncate';import { Scrollable } from '@platform/ui/Scrollable';import { Select } from '@platform/ui/Select';import { Tooltip } from '@platform/ui/Tooltip';-import { PencilIcon, PlusIcon, SettingsIcon, TrashIcon } from 'lucide-react';+import { CopyIcon, PencilIcon, PlusIcon, SettingsIcon, TrashIcon } from 'lucide-react';import { useCallback, useId, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -46,40 +46,57 @@ const EMPTY_DRAFT: Draft = { content: '', maxTokens: '', name: '' };const SystemPromptRow = ({canEdit,onDelete,+ onDuplicate,onEdit,prompt,}: {canEdit: boolean;prompt: SystemPromptRecord;onDelete: (prompt: SystemPromptRecord) => void;+ onDuplicate: (prompt: SystemPromptRecord) => void;onEdit: (prompt: SystemPromptRecord) => void;}) => {const { t } = useTranslation();const handleEdit = useCallback(() => onEdit(prompt), [onEdit, prompt]);const handleDelete = useCallback(() => onDelete(prompt), [onDelete, prompt]);+ const handleDuplicate = useCallback(() => onDuplicate(prompt), [onDuplicate, prompt]);return (<HStack justify="space-between" px="1" py="0.5"><MiddleTruncate fontSize="xs" minW="0" text={prompt.name} />- {canEdit ? (- <HStack gap="0.5">- <Tooltip content={t('common.edit')}>- <IconButton aria-label={t('common.edit')} size="2xs" variant="ghost" onClick={handleEdit}>- <PencilIcon />- </IconButton>- </Tooltip>- <Tooltip content={t('common.delete')}>- <IconButton aria-label={t('common.delete')} size="2xs" variant="ghost" onClick={handleDelete}>- <TrashIcon />- </IconButton>- </Tooltip>- </HStack>- ) : (- // Shared by someone else. Says why it has no controls without adding colour.- <Text color="fg.subtle" fontSize="2xs">- {t('widgets.generate.systemPrompts.shared')}- </Text>- )}+ <HStack gap="0.5">+ {/* Copying needs no rights over the source, so it is the one control every row has --+ it is how someone adapts a prompt they cannot edit. */}+ <Tooltip content={t('widgets.generate.systemPrompts.duplicate')}>+ <IconButton+ aria-label={t('widgets.generate.systemPrompts.duplicate')}+ size="2xs"+ variant="ghost"+ onClick={handleDuplicate}+ >+ <CopyIcon />+ </IconButton>+ </Tooltip>+ {canEdit ? (+ <>+ <Tooltip content={t('common.edit')}>+ <IconButton aria-label={t('common.edit')} size="2xs" variant="ghost" onClick={handleEdit}>+ <PencilIcon />+ </IconButton>+ </Tooltip>+ <Tooltip content={t('common.delete')}>+ <IconButton aria-label={t('common.delete')} size="2xs" variant="ghost" onClick={handleDelete}>+ <TrashIcon />+ </IconButton>+ </Tooltip>+ </>+ ) : (+ // Shared by someone else. Says why it has no edit controls without adding colour.+ <Text color="fg.subtle" fontSize="2xs">+ {t('widgets.generate.systemPrompts.shared')}+ </Text>+ )}+ </HStack></HStack>);};@@ -174,6 +191,26 @@ export const SystemPromptsField = ({ catalog, onSelect, selectedId }: SystemPromsetEditorTarget(null);}, [catalog, draft, editorTarget, onSelect, t]);+ const duplicatePrompt = useCallback(+ async (prompt: SystemPromptRecord) => {+ setError(null);++ let copy: SystemPromptRecord;++ try {+ copy = await catalog.duplicate(prompt);+ } catch (caught) {+ setError(getApiErrorMessage(caught, t('widgets.generate.systemPrompts.couldNotSave')));+ return;+ }++ // A copy is made to be used or edited, so hand the user straight to it.+ onSelect(copy.id);+ startEdit(copy);+ },+ [catalog, onSelect, startEdit, t]+ );+const confirmDelete = useCallback(async () => {if (!pendingDelete) {return;@@ -199,6 +236,7 @@ export const SystemPromptsField = ({ catalog, onSelect, selectedId }: SystemPromconst cancelDelete = useCallback(() => setPendingDelete(null), []);const handleSave = useCallback(() => void saveDraft(), [saveDraft]);+ const handleDuplicate = useCallback((prompt: SystemPromptRecord) => void duplicatePrompt(prompt), [duplicatePrompt]);const handleConfirmDelete = useCallback(() => void confirmDelete(), [confirmDelete]);const handleNameChange = useCallback((event: ChangeEvent<HTMLInputElement>) => setDraft((current) => ({ ...current, name: event.target.value })),@@ -241,6 +279,11 @@ export const SystemPromptsField = ({ catalog, onSelect, selectedId }: SystemPromeditorTarget.record ? t('widgets.generate.systemPrompts.edit') : t('widgets.generate.systemPrompts.new')}/>+ {editorTarget.record?.isPublic ? (+ <Text color="fg.muted" fontSize="2xs">+ {t('widgets.generate.systemPrompts.sharedEditWarning')}+ </Text>+ ) : null}<Field id={nameFieldId} label={t('widgets.generate.systemPrompts.name')}><Inputid={nameFieldId}@@ -319,6 +362,7 @@ export const SystemPromptsField = ({ catalog, onSelect, selectedId }: SystemPromcanEdit={canEdit(prompt)}prompt={prompt}onDelete={setPendingDelete}+ onDuplicate={handleDuplicate}onEdit={startEdit}/>))}diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/promptImageDrop.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/promptImageDrop.browser.test.tsxindex 0cff0f9fa6..a18d95be83 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/promptImageDrop.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/promptImageDrop.browser.test.tsx@@ -27,6 +27,7 @@ vi.mock('@features/generation/ui/GenerationUiContext', async (importOriginal) =>// unmocked module instance, which no provider in this harness fills.GenerationModelSelect: stubs.ModelSelect,useGenerationUi: () => ({+ capabilities: { canManagePromptTemplates: false, canManageSharedSystemPrompts: false },gallery: { selectedImage: stubs.selectedImage },models: {catalog: [{ base: 'any', key: 'llava-1', name: 'LLaVA', type: 'llava_onevision' }],diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/useSystemPrompts.ts b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/useSystemPrompts.tsindex 3837e442d1..a85faeb04c 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/useSystemPrompts.ts+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/useSystemPrompts.ts@@ -1,9 +1,11 @@import type { SystemPromptDraft, SystemPromptRecord } from '@features/generation/data/systemPrompts';import {+ buildDuplicateName,+ canEditSystemPrompt,classifySystemPrompts,- isOwnedSystemPrompt,- requireOwnedSystemPrompt,+ requireEditableSystemPrompt,+ type SystemPromptEditAuthority,} from '@features/generation/core/systemPrompts';import {createSystemPrompt,@@ -25,15 +27,21 @@ export interface SystemPromptCatalog {isLoaded: boolean;canEdit: (prompt: SystemPromptRecord) => boolean;create: (draft: SystemPromptDraft) => Promise<SystemPromptRecord>;+ /** Copies any visible prompt into one this account owns. Needs no management rights. */+ duplicate: (prompt: SystemPromptRecord) => Promise<SystemPromptRecord>;update: (prompt: SystemPromptRecord, draft: SystemPromptDraft) => Promise<SystemPromptRecord>;remove: (prompt: SystemPromptRecord) => Promise<void>;}export const useSystemPrompts = ({ isEnabled = true }: { isEnabled?: boolean } = {}): SystemPromptCatalog => {const queryClient = useQueryClient();- const { account } = useGenerationUi();+ const { account, capabilities } = useGenerationUi();const query = useQuery({ ...systemPromptsQueryOptions(), enabled: isEnabled });const classified = useMemo(() => classifySystemPrompts(query.data ?? [], account), [account, query.data]);+ const authority = useMemo<SystemPromptEditAuthority>(+ () => ({ ...account, canManageSharedPrompts: capabilities.canManageSharedSystemPrompts }),+ [account, capabilities.canManageSharedSystemPrompts]+ );const runAndInvalidate = useCallback(async <T>(run: () => Promise<T>): Promise<T> => {@@ -54,27 +62,46 @@ export const useSystemPrompts = ({ isEnabled = true }: { isEnabled?: boolean } =const update = useCallback((prompt: SystemPromptRecord, draft: SystemPromptDraft) => {- // The backend rejects this too; failing here keeps a shared prompt's disabled edit- // affordance from turning into a round-trip 403 if it is ever mis-rendered.- requireOwnedSystemPrompt(prompt, account);+ // Mirrors the affordance so a mis-rendered edit control fails here rather than as a 403 --+ // and so the one case the API would allow but this UI does not, another user's private+ // prompt, cannot be reached from the client at all.+ requireEditableSystemPrompt(prompt, authority);return runAndInvalidate(() => updateSystemPrompt(prompt.id, draft));},- [account, runAndInvalidate]+ [authority, runAndInvalidate]+ );++ const duplicate = useCallback(+ (prompt: SystemPromptRecord) =>+ runAndInvalidate(() =>+ createSystemPrompt({+ content: prompt.content,+ maxTokens: prompt.maxTokens,+ // Taken from the list the viewer can see, which is the same list the new name has to+ // be distinguishable in.+ name: buildDuplicateName(+ prompt.name,+ classified.prompts.map((visible) => visible.name)+ ),+ })+ ),+ [classified.prompts, runAndInvalidate]);const remove = useCallback((prompt: SystemPromptRecord) => {- requireOwnedSystemPrompt(prompt, account);+ requireEditableSystemPrompt(prompt, authority);return runAndInvalidate(() => deleteSystemPrompt(prompt.id));},- [account, runAndInvalidate]+ [authority, runAndInvalidate]);- const canEdit = useCallback((prompt: SystemPromptRecord) => isOwnedSystemPrompt(prompt, account), [account]);+ const canEdit = useCallback((prompt: SystemPromptRecord) => canEditSystemPrompt(prompt, authority), [authority]);return {canEdit,create,+ duplicate,isLoaded: query.isSuccess,isLoading: query.isPending,personalPrompts: classified.personalPrompts,diff --git a/invokeai/frontend/webv2/src/features/identity/capabilities.test.ts b/invokeai/frontend/webv2/src/features/identity/capabilities.test.tsindex 048569e9c5..ceb3443924 100644--- a/invokeai/frontend/webv2/src/features/identity/capabilities.test.ts+++ b/invokeai/frontend/webv2/src/features/identity/capabilities.test.ts@@ -24,6 +24,7 @@ describe('Identity route capabilities', () => {canManageNodes: false,canManageSharedFonts: false,canManagePromptTemplates: false,+ canManageSharedSystemPrompts: false,canManageUsers: false,});});@@ -36,6 +37,7 @@ describe('Identity route capabilities', () => {canManageNodes: true,canManageSharedFonts: true,canManagePromptTemplates: true,+ canManageSharedSystemPrompts: true,canManageUsers: false,});});@@ -58,6 +60,7 @@ describe('Identity route capabilities', () => {canManageNodes: false,canManageSharedFonts: false,canManagePromptTemplates: false,+ canManageSharedSystemPrompts: false,canManageUsers: false,});expect(getCapabilities(session({ user: { ...baseUser, is_admin: true } }))).toEqual({@@ -67,6 +70,7 @@ describe('Identity route capabilities', () => {canManageNodes: true,canManageSharedFonts: true,canManagePromptTemplates: true,+ canManageSharedSystemPrompts: true,canManageUsers: true,});});diff --git a/invokeai/frontend/webv2/src/features/identity/capabilities.ts b/invokeai/frontend/webv2/src/features/identity/capabilities.tsindex 8cab47012a..0e9302c8f0 100644--- a/invokeai/frontend/webv2/src/features/identity/capabilities.ts+++ b/invokeai/frontend/webv2/src/features/identity/capabilities.ts@@ -11,6 +11,8 @@ export interface Capabilities {canManageSharedFonts: boolean;/** Bulk import/export of prompt templates; the routes are admin-only. */canManagePromptTemplates: boolean;+ /** Edit prompts shared with everyone. Never covers another user's private prompt. */+ canManageSharedSystemPrompts: boolean;canManageUsers: boolean;}@@ -23,6 +25,7 @@ export const getCapabilities = (session: AuthSession): Capabilities => {canManageNodes: false,canManageSharedFonts: false,canManagePromptTemplates: false,+ canManageSharedSystemPrompts: false,canManageUsers: false,};}@@ -39,6 +42,9 @@ export const getCapabilities = (session: AuthSession): Capabilities => {// Matches the routers' `AdminUserOrDefault`: everyone qualifies in// single-user mode, only admins once multiuser is on.canManagePromptTemplates: isAdmin,+ // The router lets an admin write any prompt; the UI offers it only for shared ones, so an+ // admin never edits another user's private prompt by accident.+ canManageSharedSystemPrompts: isAdmin,canManageUsers: session.multiuserEnabled && session.user?.is_admin === true,};};