Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(agent): add an avatar studio with brand-style one-click generation (#18113)

Arvin Xu74dcf0f3cd21
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index 7c9721b7515..04ffea597d1 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -689,10 +689,8 @@
"settingAgent.agentTools.tabAgent": "Agent Tools",
"settingAgent.agentTools.tabUser": "User Tools",
"settingAgent.agentTools.tabWorkspace": "Workspace Tools",
- "settingAgent.artwork.avatar.generate": "Generate avatar",
- "settingAgent.artwork.avatar.generateAction": "Generate from Agent Profile",
"settingAgent.artwork.avatar.generating": "Creating an avatar that matches this Agent…",
- "settingAgent.artwork.avatar.image": "Image avatar",
+ "settingAgent.artwork.avatar.image": "AI avatar",
"settingAgent.artwork.background.empty": "Add a background to give this Agent a visual identity",
"settingAgent.artwork.background.emptyHint": "Add a cover image",
"settingAgent.artwork.background.generate": "Generate background",
@@ -704,11 +702,25 @@
"settingAgent.artwork.generatingHint": "This usually takes about 60 seconds. You can keep editing while it finishes.",
"settingAgent.artwork.retry": "Try again",
"settingAgent.artwork.sizeExceeded": "Image must be smaller than 1 MB",
+ "settingAgent.artwork.studio.diyHint": "Upload your own image (under 1 MB), or click the avatar on the profile to pick an emoji.",
+ "settingAgent.artwork.studio.diyTitle": "Make your own",
+ "settingAgent.artwork.studio.enableModel": "Enable a model",
+ "settingAgent.artwork.studio.generate": "Generate avatar",
+ "settingAgent.artwork.studio.generateHint": "Pick a style and we'll create an avatar from this Agent's profile.",
+ "settingAgent.artwork.studio.generateTitle": "Generate with AI",
+ "settingAgent.artwork.studio.lobeStyle": "Lobe official style",
+ "settingAgent.artwork.studio.moreStyles": "More styles",
+ "settingAgent.artwork.studio.noModel": "Enable an image generation model to use one-click generation.",
+ "settingAgent.artwork.studio.open": "Customize appearance",
+ "settingAgent.artwork.studio.openAction": "Open the avatar studio",
+ "settingAgent.artwork.studio.recommended": "Recommended",
+ "settingAgent.artwork.studio.title": "Agent Appearance",
+ "settingAgent.artwork.studio.upload": "Upload image",
"settingAgent.artwork.style.clay": "3D Clay",
- "settingAgent.artwork.style.editorial": "Editorial Illustration",
"settingAgent.artwork.style.geometric": "Flat Geometric",
- "settingAgent.artwork.style.photographic": "Minimal Photography",
- "settingAgent.artwork.style.riso": "Retro Print",
+ "settingAgent.artwork.style.lobe": "Soft 3D mascot with a bold color backdrop",
+ "settingAgent.artwork.style.pixel": "Pixel Art",
+ "settingAgent.artwork.style.sticker": "Sticker",
"settingAgent.artwork.style.watercolor": "Watercolor",
"settingAgent.artwork.styleMenu": "Generation style",
"settingAgent.artwork.uploadFailed": "Could not upload the image. Try again.",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index f46b1a84aaf..81b32762366 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -689,10 +689,8 @@
"settingAgent.agentTools.tabAgent": "Agent 工具",
"settingAgent.agentTools.tabUser": "用户工具",
"settingAgent.agentTools.tabWorkspace": "Workspace 工具",
- "settingAgent.artwork.avatar.generate": "生成头像",
- "settingAgent.artwork.avatar.generateAction": "根据助理档案生成",
"settingAgent.artwork.avatar.generating": "正在生成符合助理形象的头像…",
- "settingAgent.artwork.avatar.image": "图片头像",
+ "settingAgent.artwork.avatar.image": "AI 形象",
"settingAgent.artwork.background.empty": "添加背景,让助理拥有更鲜明的视觉形象",
"settingAgent.artwork.background.emptyHint": "添加封面图片",
"settingAgent.artwork.background.generate": "生成背景",
@@ -704,11 +702,25 @@
"settingAgent.artwork.generatingHint": "通常需要约 60 秒,生成期间可以继续编辑其他内容",
"settingAgent.artwork.retry": "重试",
"settingAgent.artwork.sizeExceeded": "图片大小不能超过 1 MB",
+ "settingAgent.artwork.studio.diyHint": "上传一张自己的图片(1MB 以内),或在资料页头像中选择 Emoji",
+ "settingAgent.artwork.studio.diyTitle": "自行制作",
+ "settingAgent.artwork.studio.enableModel": "去启用",
+ "settingAgent.artwork.studio.generate": "一键生成",
+ "settingAgent.artwork.studio.generateHint": "选择风格,我们会根据 Agent 的资料生成专属形象",
+ "settingAgent.artwork.studio.generateTitle": "AI 一键生成",
+ "settingAgent.artwork.studio.lobeStyle": "Lobe 官方风格",
+ "settingAgent.artwork.studio.moreStyles": "更多风格",
+ "settingAgent.artwork.studio.noModel": "启用图像生成模型后即可一键生成",
+ "settingAgent.artwork.studio.open": "自定义形象",
+ "settingAgent.artwork.studio.openAction": "打开形象工作室",
+ "settingAgent.artwork.studio.recommended": "推荐",
+ "settingAgent.artwork.studio.title": "Agent 形象",
+ "settingAgent.artwork.studio.upload": "上传图片",
"settingAgent.artwork.style.clay": "3D 黏土",
- "settingAgent.artwork.style.editorial": "编辑插画",
"settingAgent.artwork.style.geometric": "扁平几何",
- "settingAgent.artwork.style.photographic": "极简摄影",
- "settingAgent.artwork.style.riso": "复古版画",
+ "settingAgent.artwork.style.lobe": "软 3D 吉祥物 · 大色块背景",
+ "settingAgent.artwork.style.pixel": "像素风",
+ "settingAgent.artwork.style.sticker": "贴纸插画",
"settingAgent.artwork.style.watercolor": "水彩手绘",
"settingAgent.artwork.styleMenu": "生成风格",
"settingAgent.artwork.uploadFailed": "暂时无法上传图片,请重试",
diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.ts
index 7f3450d5e82..be12401b7af 100644
--- a/packages/locales/src/default/setting.ts
+++ b/packages/locales/src/default/setting.ts
@@ -752,10 +752,8 @@ export default {
'plugin.store': 'Skill Store',
'settingAgent.avatar.sizeExceeded': 'Image size exceeds 1MB limit, please choose a smaller image',
'settingAgent.avatar.title': 'Avatar',
- 'settingAgent.artwork.avatar.generate': 'Generate avatar',
- 'settingAgent.artwork.avatar.generateAction': 'Generate from Agent Profile',
'settingAgent.artwork.avatar.generating': 'Creating an avatar that matches this Agent…',
- 'settingAgent.artwork.avatar.image': 'Image avatar',
+ 'settingAgent.artwork.avatar.image': 'AI avatar',
'settingAgent.artwork.background.empty': 'Add a background to give this Agent a visual identity',
'settingAgent.artwork.background.emptyHint': 'Add a cover image',
'settingAgent.artwork.background.generate': 'Generate background',
@@ -768,11 +766,28 @@ export default {
'This usually takes about 60 seconds. You can keep editing while it finishes.',
'settingAgent.artwork.retry': 'Try again',
'settingAgent.artwork.sizeExceeded': 'Image must be smaller than 1 MB',
+ 'settingAgent.artwork.studio.diyHint':
+ 'Upload your own image (under 1 MB), or click the avatar on the profile to pick an emoji.',
+ 'settingAgent.artwork.studio.diyTitle': 'Make your own',
+ 'settingAgent.artwork.studio.enableModel': 'Enable a model',
+ 'settingAgent.artwork.studio.generate': 'Generate avatar',
+ 'settingAgent.artwork.studio.generateHint':
+ "Pick a style and we'll create an avatar from this Agent's profile.",
+ 'settingAgent.artwork.studio.generateTitle': 'Generate with AI',
+ 'settingAgent.artwork.studio.lobeStyle': 'Lobe official style',
+ 'settingAgent.artwork.studio.moreStyles': 'More styles',
+ 'settingAgent.artwork.studio.noModel':
+ 'Enable an image generation model to use one-click generation.',
+ 'settingAgent.artwork.studio.open': 'Customize appearance',
+ 'settingAgent.artwork.studio.openAction': 'Open the avatar studio',
+ 'settingAgent.artwork.studio.recommended': 'Recommended',
+ 'settingAgent.artwork.studio.title': 'Agent Appearance',
+ 'settingAgent.artwork.studio.upload': 'Upload image',
'settingAgent.artwork.style.clay': '3D Clay',
- 'settingAgent.artwork.style.editorial': 'Editorial Illustration',
'settingAgent.artwork.style.geometric': 'Flat Geometric',
- 'settingAgent.artwork.style.photographic': 'Minimal Photography',
- 'settingAgent.artwork.style.riso': 'Retro Print',
+ 'settingAgent.artwork.style.lobe': 'Soft 3D mascot with a bold color backdrop',
+ 'settingAgent.artwork.style.pixel': 'Pixel Art',
+ 'settingAgent.artwork.style.sticker': 'Sticker',
'settingAgent.artwork.style.watercolor': 'Watercolor',
'settingAgent.artwork.styleMenu': 'Generation style',
'settingAgent.artwork.uploadFailed': 'Could not upload the image. Try again.',
diff --git a/packages/model-bank/src/aiModels/aihubmix.ts b/packages/model-bank/src/aiModels/aihubmix.ts
index 74089030bc3..ebdbe2db209 100644
--- a/packages/model-bank/src/aiModels/aihubmix.ts
+++ b/packages/model-bank/src/aiModels/aihubmix.ts
@@ -1,4 +1,4 @@
-import { gptImage2Schema } from '../const/imageParameters';
+import { gptImage2Schema, nanoBanana2LiteParameters } from '../const/imageParameters';
import type { AIChatModelCard, AIImageModelCard } from '../types/aiModel';
const aihubmixChatModels: AIChatModelCard[] = [
@@ -1843,6 +1843,25 @@ const aihubmixChatModels: AIChatModelCard[] = [
];
const aihubmixImageModels: AIImageModelCard[] = [
+ {
+ description:
+ "Gemini 3.1 Flash Lite Image (Nano Banana 2 Lite) is Google's fastest and most cost-efficient image generation model, built for high-volume generation and editing.",
+ displayName: 'Nano Banana 2 Lite',
+ enabled: true,
+ id: 'gemini-3.1-flash-lite-image:image',
+ parameters: nanoBanana2LiteParameters,
+ pricing: {
+ approximatePricePerImage: 0.034,
+ units: [
+ { name: 'imageOutput', rate: 30, strategy: 'fixed', unit: 'millionTokens' },
+ { name: 'textInput', rate: 0.25, strategy: 'fixed', unit: 'millionTokens' },
+ { name: 'imageInput', rate: 0.25, strategy: 'fixed', unit: 'millionTokens' },
+ { name: 'textOutput', rate: 1.5, strategy: 'fixed', unit: 'millionTokens' },
+ ],
+ },
+ releasedAt: '2026-06-30',
+ type: 'image',
+ },
{
description:
"OpenAI's next-generation multimodal image model with native reasoning, up to 4K resolution, near-perfect text rendering, and high-fidelity multilingual support.",
diff --git a/packages/prompts/src/prompts/agentArtwork/index.test.ts b/packages/prompts/src/prompts/agentArtwork/index.test.ts
index 65d14e94999..e595e797c93 100644
--- a/packages/prompts/src/prompts/agentArtwork/index.test.ts
+++ b/packages/prompts/src/prompts/agentArtwork/index.test.ts
@@ -54,10 +54,54 @@ describe('buildAgentArtworkPrompt', () => {
expect(prompt).toContain('same identity system');
});
- it('defaults to the editorial style direction', () => {
+ it('defaults to the lobe mascot style direction', () => {
const prompt = buildAgentArtworkPrompt({ id: 'agent-1', kind: 'avatar' });
- expect(prompt).toContain('polished editorial illustration');
+ expect(prompt).toContain('one vivid contrasting solid background color');
+ expect(prompt).toContain('mascot-style 3D emoji character');
+ expect(prompt).toContain('never blank or babyish');
+ expect(prompt).toContain('friendly likeable color');
+ expect(prompt).not.toContain('smirk');
+ });
+
+ it('swaps the character-shaped lobe direction for a style-only one on covers', () => {
+ const prompt = buildAgentArtworkPrompt({ id: 'agent-1', kind: 'background', style: 'lobe' });
+
+ expect(prompt).toContain('soft 3D cartoon world');
+ expect(prompt).not.toContain('big lively glossy eyes');
+ });
+
+ it('describes attached style references and fences off subjects and proportions', () => {
+ const prompt = buildAgentArtworkPrompt({
+ id: 'agent-1',
+ kind: 'avatar',
+ styleReferenceImageUrls: ['https://example.com/ref-a.webp', 'https://example.com/ref-b.webp'],
+ });
+
+ expect(prompt).toContain('as the target character style');
+ expect(prompt).toContain('Do not copy their exact faces, hats, or subjects');
+ });
+
+ it('uses singular wording for a single style reference', () => {
+ const prompt = buildAgentArtworkPrompt({
+ id: 'agent-1',
+ kind: 'background',
+ styleReferenceImageUrls: ['https://example.com/ref-a.webp'],
+ });
+
+ expect(prompt).toContain('only as a rendering-style reference');
+ });
+
+ it('lets style references suppress the counterpart artwork reference', () => {
+ const prompt = buildAgentArtworkPrompt({
+ id: 'agent-1',
+ kind: 'avatar',
+ referenceImageUrl: 'https://example.com/background.png',
+ styleReferenceImageUrls: ['https://example.com/ref-a.webp'],
+ });
+
+ expect(prompt).toContain('as the target character style');
+ expect(prompt).not.toContain('attached existing profile background');
});
it('renders a distinct direction for every style preset', () => {
@@ -67,7 +111,8 @@ describe('buildAgentArtworkPrompt', () => {
expect(new Set(prompts).size).toBe(AGENT_ARTWORK_STYLES.length);
expect(prompts.find((p) => p.includes('watercolor'))).toBeTruthy();
- expect(prompts.find((p) => p.includes('risograph'))).toBeTruthy();
+ expect(prompts.find((p) => p.includes('pixel art'))).toBeTruthy();
+ expect(prompts.find((p) => p.includes('die-cut sticker'))).toBeTruthy();
});
it('applies the chosen style to both avatar and background prompts', () => {
@@ -78,8 +123,8 @@ describe('buildAgentArtworkPrompt', () => {
style: 'clay',
});
- expect(avatar).toContain('clay-style scene');
- expect(background).toContain('clay-style scene');
+ expect(avatar).toContain('clay-style figure');
+ expect(background).toContain('clay-style figure');
});
it('steers the motif away from generic technology clichés in every prompt', () => {
diff --git a/packages/prompts/src/prompts/agentArtwork/index.ts b/packages/prompts/src/prompts/agentArtwork/index.ts
index 8706c3ab90a..2bdfc0dc573 100644
--- a/packages/prompts/src/prompts/agentArtwork/index.ts
+++ b/packages/prompts/src/prompts/agentArtwork/index.ts
@@ -3,31 +3,48 @@ import { escapeXmlAttr, escapeXmlContent } from '../search/xmlEscape';
export type AgentArtworkKind = 'avatar' | 'background';
export const AGENT_ARTWORK_STYLES = [
- 'editorial',
- 'geometric',
+ 'lobe',
'clay',
'watercolor',
- 'riso',
- 'photographic',
+ 'geometric',
+ 'pixel',
+ 'sticker',
] as const;
export type AgentArtworkStyle = (typeof AGENT_ARTWORK_STYLES)[number];
-export const DEFAULT_AGENT_ARTWORK_STYLE: AgentArtworkStyle = 'editorial';
+export const DEFAULT_AGENT_ARTWORK_STYLE: AgentArtworkStyle = 'lobe';
+/**
+ * Wording here is A/B-tested against real Nano Banana output. Two phrasings
+ * that measurably ruin the lobe style: "inflated" (produces a puffy relief
+ * carving instead of a character) and letting the domain motif land ON the
+ * character (maps / diagrams embossed on the body) — identity must flow
+ * through outfit and accessories instead.
+ */
const STYLE_DIRECTIONS: Record<AgentArtworkStyle, string> = {
- clay: 'Render it as a soft 3D clay-style scene with rounded forms, matte materials, gentle studio lighting, and warm pastel colors.',
- editorial:
- 'Render it as polished editorial illustration with a calm premium color palette and high contrast.',
+ clay: 'Render it as a soft 3D clay-style figure with rounded forms, matte materials, subtle hand-made charm, gentle studio lighting, and warm pastel colors.',
geometric:
'Render it as flat geometric illustration built from bold simple shapes, crisp edges, and a confident limited palette in the spirit of mid-century poster design.',
- photographic:
- 'Render it as a minimalist still-life photograph of tangible objects and materials with soft natural light and a restrained color palette.',
- riso: 'Render it as a retro risograph print with two or three flat ink colors, visible grain, slight misregistration, and bold graphic shapes.',
+ lobe: "Render it as a bold mascot-style 3D emoji character: a single oversized head filling most of the frame, skin in one friendly likeable color that people love — warm yellow, orange, peach, coral, or soft brown (not realistic human skin, and never odd tones like green, teal, or gray), graphic simplified facial features with an expression that matches the agent's personality (a knowing wink, a curious smile, a warm grin — lively, never blank or babyish), glossy candy-like materials with soft studio lighting, and one vivid contrasting solid background color. Show at most a hint of shoulders. Express the identity through a hat and one or two small floating accessory props beside the head — do not draw scenes, maps, or diagrams on the character.",
+ pixel:
+ 'Render it as crisp retro pixel art with chunky readable pixels, a limited bright palette, and clean shading in the spirit of classic 16-bit games.',
+ sticker:
+ 'Render it as a glossy die-cut sticker illustration with bold clean outlines, flat vivid colors, a thick white sticker border, and a simple bright solid background.',
watercolor:
'Render it as a hand-painted watercolor piece with visible paper texture, soft pigment washes, and loose organic edges.',
};
+/**
+ * The avatar directions above are subject-shaped (the lobe one literally asks
+ * for a character), which contradicts the cover prompt's "abstract environment,
+ * no person portrait" frame. Cover generation swaps in these style-only
+ * variants where the avatar wording would fight the cover composition.
+ */
+const BACKGROUND_STYLE_OVERRIDES: Partial<Record<AgentArtworkStyle, string>> = {
+ lobe: 'Render it as a soft 3D cartoon world with smooth rounded matte forms, playful proportions, and one vivid saturated dominant color filling the frame.',
+};
+
/**
* Image models collapse "AI agent" semantics into the same starry-space /
* particle / circuit imagery by default, so every profile ends up looking
@@ -43,6 +60,13 @@ export interface AgentArtworkPromptInput {
name?: string | null;
referenceImageUrl?: string | null;
style?: AgentArtworkStyle | null;
+ /**
+ * Attached images that define the target rendering style (not the subject).
+ * When present they win over `referenceImageUrl`: mixing "copy this style"
+ * and "continue this identity system" wording in one prompt makes the model
+ * blend the two references unpredictably.
+ */
+ styleReferenceImageUrls?: string[] | null;
systemRole?: string | null;
title?: string | null;
}
@@ -75,13 +99,32 @@ export const buildAgentArtworkPrompt = (input: AgentArtworkPromptInput): string
systemRole: input.systemRole?.slice(0, 1200),
title: input.title,
});
- const styleDirection = STYLE_DIRECTIONS[input.style ?? DEFAULT_AGENT_ARTWORK_STYLE];
+ const style = input.style ?? DEFAULT_AGENT_ARTWORK_STYLE;
+ const styleDirection =
+ input.kind === 'background'
+ ? (BACKGROUND_STYLE_OVERRIDES[style] ?? STYLE_DIRECTIONS[style])
+ : STYLE_DIRECTIONS[style];
+
+ const styleReferenceCount =
+ input.styleReferenceImageUrls?.filter((url) => url.trim()).length ?? 0;
+ // For avatars the references define the TARGET character feel (the official
+ // mascot look), so the wording asks for that same energy while fencing off
+ // the literal faces / hats / subjects — copying those would make every agent
+ // look like the same mascot. Covers must not inherit the character wording
+ // (they forbid portraits), so they only borrow surface qualities.
+ const styleReferenceDirection =
+ styleReferenceCount > 0
+ ? input.kind === 'avatar'
+ ? `\n\nUse the attached ${styleReferenceCount === 1 ? 'image' : 'images'} as the target character style — the same mascot-like head-dominant look, single-color skin, material, lighting, and color energy. Do not copy ${styleReferenceCount === 1 ? 'its' : 'their'} exact faces, hats, or subjects — invent a new character for the agent described above.`
+ : `\n\nUse the attached ${styleReferenceCount === 1 ? 'image' : 'images'} only as a rendering-style reference — match ${styleReferenceCount === 1 ? 'its' : 'their'} materials, lighting, color saturation, and level of finish. Do not copy ${styleReferenceCount === 1 ? 'its' : 'their'} subjects or compositions.`
+ : '';
+ const counterpartReferenceUrl = styleReferenceCount > 0 ? undefined : input.referenceImageUrl;
if (input.kind === 'avatar') {
// The reference paragraph preserves palette / materials / motifs but not the
// rendering style itself — the user may regenerate with a different preset,
// and the style direction above must stay authoritative.
- const referenceDirection = input.referenceImageUrl?.trim()
+ const referenceDirection = counterpartReferenceUrl?.trim()
? `\n\nUse the attached existing profile background as the visual source of truth. Preserve its dominant color palette, materials, lighting, atmosphere, and recurring motifs while distilling them into a single avatar subject. The avatar must feel designed as part of the same identity system, not merely depict a related topic.`
: '';
@@ -89,10 +132,10 @@ export const buildAgentArtworkPrompt = (input: AgentArtworkPromptInput): string
${agentContext}
-Translate the agent's identity, purpose, and personality into one coherent visual concept. Use a single centered subject with a simple silhouette. ${styleDirection} ${MOTIF_DIRECTION} Fill the entire square canvas edge to edge with the artwork: use a full-bleed composition with no white background, no white matte, no empty margin, no padding, no frame, and no border. No words, no letters, and no logo. The result must remain clear as a small app avatar.${referenceDirection}`;
+Translate the agent's identity, purpose, and personality into one coherent visual concept. Use a single centered subject with a simple silhouette. ${styleDirection} ${MOTIF_DIRECTION} Fill the entire square canvas edge to edge with the artwork: use a full-bleed composition with no white background, no white matte, no empty margin, no padding, no frame, and no border. No words, no letters, and no logo. The result must remain clear as a small app avatar.${styleReferenceDirection}${referenceDirection}`;
}
- const referenceDirection = input.referenceImageUrl?.trim()
+ const referenceDirection = counterpartReferenceUrl?.trim()
? `\n\nUse the attached existing avatar as the visual source of truth. Preserve its dominant color palette, materials, lighting, atmosphere, and recurring motifs, then expand that visual world into a wide environment. Do not enlarge, repeat, or place the avatar itself in the cover. The cover and avatar must feel designed as one identity system.`
: '';
@@ -100,5 +143,5 @@ Translate the agent's identity, purpose, and personality into one coherent visua
${agentContext}
-Translate the agent's identity, purpose, and personality into an abstract environment. ${styleDirection} ${MOTIF_DIRECTION} Use generous negative space and a balanced composition. Do not use a person portrait, words, letters, a logo, or a border.${referenceDirection}`;
+Translate the agent's identity, purpose, and personality into an abstract environment. ${styleDirection} ${MOTIF_DIRECTION} Use generous negative space and a balanced composition. Do not use a person portrait, words, letters, a logo, or a border.${styleReferenceDirection}${referenceDirection}`;
};
diff --git a/public/images/agent-artwork-styles/style-clay.jpg b/public/images/agent-artwork-styles/style-clay.jpg
new file mode 100644
index 00000000000..25751d7628b
Binary files /dev/null and b/public/images/agent-artwork-styles/style-clay.jpg differ
diff --git a/public/images/agent-artwork-styles/style-geometric.jpg b/public/images/agent-artwork-styles/style-geometric.jpg
new file mode 100644
index 00000000000..8f7ca2e1c11
Binary files /dev/null and b/public/images/agent-artwork-styles/style-geometric.jpg differ
diff --git a/public/images/agent-artwork-styles/style-pixel.jpg b/public/images/agent-artwork-styles/style-pixel.jpg
new file mode 100644
index 00000000000..df97bb47532
Binary files /dev/null and b/public/images/agent-artwork-styles/style-pixel.jpg differ
diff --git a/public/images/agent-artwork-styles/style-sticker.jpg b/public/images/agent-artwork-styles/style-sticker.jpg
new file mode 100644
index 00000000000..c04ed7af6b6
Binary files /dev/null and b/public/images/agent-artwork-styles/style-sticker.jpg differ
diff --git a/public/images/agent-artwork-styles/style-watercolor.jpg b/public/images/agent-artwork-styles/style-watercolor.jpg
new file mode 100644
index 00000000000..ede05bb0820
Binary files /dev/null and b/public/images/agent-artwork-styles/style-watercolor.jpg differ
diff --git a/src/features/AgentArtworkStudio/Content.tsx b/src/features/AgentArtworkStudio/Content.tsx
new file mode 100644
index 00000000000..b4284ce0fe7
--- /dev/null
+++ b/src/features/AgentArtworkStudio/Content.tsx
@@ -0,0 +1,423 @@
+'use client';
+
+import { imageUrl } from '@lobechat/const';
+import {
+ AGENT_ARTWORK_STYLES,
+ type AgentArtworkStyle,
+ DEFAULT_AGENT_ARTWORK_STYLE,
+} from '@lobechat/prompts';
+import { Alert, Avatar, Center, Flexbox, Icon, Tag, Text } from '@lobehub/ui';
+import { Button, toast, useModalContext } from '@lobehub/ui/base-ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { Check, SettingsIcon, UploadIcon, WandSparkles } from 'lucide-react';
+import { memo, useCallback, useRef, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import NeuralNetworkLoading from '@/components/NeuralNetworkLoading';
+import {
+ avatarRemountKey,
+ openFilePicker,
+ resolveAgentBackground,
+} from '@/features/AgentProfileArtwork/utils';
+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+import { useAgentStore } from '@/store/agent';
+import { agentArtworkSelectors, agentSelectors } from '@/store/agent/selectors';
+import { useAiInfraStore } from '@/store/aiInfra';
+import { aiProviderSelectors } from '@/store/aiInfra/selectors';
+import { useFileStore } from '@/store/file';
+
+import {
+ LOBE_STYLE_REFERENCE_IMAGE_URLS,
+ styleReferencesForArtworkStyle,
+} from './lobeStyleReferences';
+
+const MAX_AVATAR_SIZE = 1024 * 1024;
+
+const GALLERY_STYLES = AGENT_ARTWORK_STYLES.filter((item) => item !== 'lobe');
+
+const styles = createStaticStyles(({ css }) => ({
+ galleryCheck: css`
+ position: absolute;
+ z-index: 1;
+ inset-block-start: 6px;
+ inset-inline-end: 6px;
+
+ width: 20px;
+ height: 20px;
+ border-radius: 50%;
+
+ color: ${cssVar.colorTextLightSolid};
+
+ background: ${cssVar.colorPrimary};
+ `,
+ galleryGrid: css`
+ display: grid;
+
+ /* One row of five, per review: the set is curated to exactly five styles. */
+ grid-template-columns: repeat(5, 1fr);
+ gap: 8px;
+ `,
+ galleryItem: css`
+ cursor: pointer;
+ border-radius: ${cssVar.borderRadiusLG};
+
+ &:hover img {
+ filter: brightness(1.06);
+ }
+ `,
+ galleryLabel: css`
+ font-size: 12px;
+ color: ${cssVar.colorTextSecondary};
+ text-align: center;
+ `,
+ galleryThumb: css`
+ aspect-ratio: 1;
+ width: 100%;
+ border-radius: ${cssVar.borderRadiusLG};
+
+ object-fit: cover;
+
+ transition: filter ${cssVar.motionDurationFast};
+ `,
+ galleryThumbWrap: css`
+ position: relative;
+ `,
+ generationOverlay: css`
+ position: absolute;
+ z-index: 2;
+ inset: 0;
+
+ border-radius: calc(${cssVar.borderRadiusLG} - 1px);
+
+ background: color-mix(in srgb, ${cssVar.colorBgContainer} 88%, transparent);
+ backdrop-filter: blur(12px);
+ `,
+ hint: css`
+ font-size: 13px;
+ color: ${cssVar.colorTextSecondary};
+ `,
+ lobeCard: css`
+ cursor: pointer;
+ border-radius: ${cssVar.borderRadiusLG};
+ background: ${cssVar.colorFillQuaternary};
+ transition: background ${cssVar.motionDurationFast};
+
+ &:hover {
+ background: ${cssVar.colorFillTertiary};
+ }
+ `,
+ lobeCardActive: css`
+ background: ${cssVar.colorFillSecondary};
+
+ &:hover {
+ background: ${cssVar.colorFillSecondary};
+ }
+ `,
+ noModelBlock: css`
+ border-radius: ${cssVar.borderRadiusLG};
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ preview: css`
+ position: relative;
+
+ overflow: hidden;
+ flex: none;
+
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ sectionTitle: css`
+ font-weight: 500;
+ `,
+ visuallyHiddenInput: css`
+ pointer-events: none;
+
+ position: fixed;
+
+ overflow: hidden;
+
+ width: 1px;
+ height: 1px;
+
+ opacity: 0;
+ `,
+}));
+
+interface AgentArtworkStudioContentProps {
+ agentId: string;
+}
+
+const AgentArtworkStudioContent = memo<AgentArtworkStudioContentProps>(({ agentId }) => {
+ const { t } = useTranslation('setting');
+ const { close } = useModalContext();
+ const navigate = useWorkspaceAwareNavigate();
+ const meta = useAgentStore(agentSelectors.getAgentMetaById(agentId));
+ const systemRole = useAgentStore(
+ (s) => agentSelectors.getAgentConfigById(agentId)(s)?.systemRole,
+ );
+ const generation = useAgentStore(agentArtworkSelectors.generationByAgentId(agentId));
+ const generateAgentArtwork = useAgentStore((s) => s.generateAgentArtwork);
+ const cancelAgentArtworkGeneration = useAgentStore((s) => s.cancelAgentArtworkGeneration);
+ const updateAgentMetaById = useAgentStore((s) => s.updateAgentMetaById);
+ const uploadWithProgress = useFileStore((s) => s.uploadWithProgress);
+ const canGenerate = useAiInfraStore(
+ (state) => aiProviderSelectors.enabledImageModelList(state).length > 0,
+ );
+
+ const uploadInputRef = useRef<HTMLInputElement>(null);
+ const [uploading, setUploading] = useState(false);
+ const [style, setStyle] = useState<AgentArtworkStyle>(DEFAULT_AGENT_ARTWORK_STYLE);
+
+ const generating = generation?.status === 'generating' && generation.kind === 'avatar';
+ const generationError = generation?.status === 'error' && generation.kind === 'avatar';
+
+ const generate = useCallback(
+ (nextStyle: AgentArtworkStyle) => {
+ generateAgentArtwork({
+ description: meta.description,
+ id: agentId,
+ kind: 'avatar',
+ name: meta.name,
+ referenceImageUrl: resolveAgentBackground(meta.backgroundColor),
+ style: nextStyle,
+ styleReferenceImageUrls: styleReferencesForArtworkStyle(nextStyle),
+ systemRole,
+ title: meta.title,
+ }).catch(() => {
+ // The Agent store owns the persistent error state rendered below.
+ });
+ },
+ [
+ agentId,
+ generateAgentArtwork,
+ meta.backgroundColor,
+ meta.description,
+ meta.name,
+ meta.title,
+ systemRole,
+ ],
+ );
+
+ const upload = useCallback(
+ async (file: File) => {
+ if (file.size > MAX_AVATAR_SIZE) {
+ toast.error(t('settingAgent.artwork.sizeExceeded'));
+ return;
+ }
+
+ setUploading(true);
+ try {
+ const result = await uploadWithProgress({ file });
+ if (!result?.url) throw new Error('Upload returned no URL');
+ await updateAgentMetaById(agentId, { avatar: result.url });
+ } catch (error) {
+ console.error('Failed to upload agent avatar:', error);
+ toast.error(t('settingAgent.artwork.uploadFailed'));
+ } finally {
+ setUploading(false);
+ }
+ },
+ [agentId, t, updateAgentMetaById, uploadWithProgress],
+ );
+
+ const selectStyle = useCallback((next: AgentArtworkStyle) => setStyle(next), []);
+
+ const keySelect = useCallback(
+ (next: AgentArtworkStyle) => (event: { key: string; preventDefault: () => void }) => {
+ if (event.key === 'Enter' || event.key === ' ') {
+ event.preventDefault();
+ setStyle(next);
+ }
+ },
+ [],
+ );
+
+ return (
+ <Flexbox horizontal gap={32} padding={24} wrap={'wrap'}>
+ {/* DIY path: the live avatar plus upload. The preview doubles as the
+ generation stage so both paths land on the same picture. */}
+ <Flexbox gap={16} style={{ flex: 'none', width: 232 }}>
+ <Center className={styles.preview} height={232} width={232}>
+ {/* Keyed by the url: Avatar latches an internal `isImgError` on the
+ first failed load and never clears it when `avatar` changes, so a
+ previously broken avatar would keep the freshly generated one
+ invisible until a reload. */}
+ <Avatar
+ avatar={meta.avatar || undefined}
+ key={avatarRemountKey(meta.avatar)}
+ shape={'square'}
+ size={180}
+ />
+ {generating ? (
+ <Center className={styles.generationOverlay}>
+ <Flexbox align={'center'} gap={10}>
+ <NeuralNetworkLoading size={32} />
+ <Flexbox align={'center'} gap={4}>
+ <Text className={styles.sectionTitle}>
+ {t('settingAgent.artwork.avatar.generating')}
+ </Text>
+ <Text className={styles.hint} style={{ textAlign: 'center' }}>
+ {t('settingAgent.artwork.generatingHint')}
+ </Text>
+ <Button
+ size={'small'}
+ style={{ marginBlockStart: 4 }}
+ type={'fill'}
+ onClick={() => void cancelAgentArtworkGeneration(agentId)}
+ >
+ {t('settingAgent.artwork.cancel')}
+ </Button>
+ </Flexbox>
+ </Flexbox>
+ </Center>
+ ) : null}
+ </Center>
+ <Flexbox gap={8}>
+ <Text className={styles.sectionTitle}>{t('settingAgent.artwork.studio.diyTitle')}</Text>
+ <Text className={styles.hint}>{t('settingAgent.artwork.studio.diyHint')}</Text>
+ <Button
+ icon={UploadIcon}
+ loading={uploading}
+ onClick={() => {
+ const input = uploadInputRef.current;
+ if (input) openFilePicker(input);
+ }}
+ >
+ {t('settingAgent.artwork.studio.upload')}
+ </Button>
+ </Flexbox>
+ </Flexbox>
+
+ {/* One-click path: brand style first, then the generated style gallery. */}
+ <Flexbox gap={16} style={{ flex: 1, minWidth: 280 }}>
+ <Flexbox gap={4}>
+ <Text className={styles.sectionTitle}>
+ {t('settingAgent.artwork.studio.generateTitle')}
+ </Text>
+ <Text className={styles.hint}>{t('settingAgent.artwork.studio.generateHint')}</Text>
+ </Flexbox>
+
+ {canGenerate ? (
+ <>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={`${styles.lobeCard} ${style === 'lobe' ? styles.lobeCardActive : ''}`}
+ gap={12}
+ padding={12}
+ role={'button'}
+ tabIndex={0}
+ onClick={() => selectStyle('lobe')}
+ onKeyDown={keySelect('lobe')}
+ >
+ <Flexbox horizontal flex={'none'} gap={4}>
+ {LOBE_STYLE_REFERENCE_IMAGE_URLS.map((url) => (
+ <Avatar avatar={url} key={url} shape={'square'} size={40} />
+ ))}
+ </Flexbox>
+ <Flexbox flex={1} gap={2} style={{ minWidth: 0 }}>
+ <Flexbox horizontal align={'center'} gap={8}>
+ <Text className={styles.sectionTitle}>
+ {t('settingAgent.artwork.studio.lobeStyle')}
+ </Text>
+ <Tag color={'processing'} size={'small'}>
+ {t('settingAgent.artwork.studio.recommended')}
+ </Tag>
+ </Flexbox>
+ <Text ellipsis className={styles.hint}>
+ {t('settingAgent.artwork.style.lobe')}
+ </Text>
+ </Flexbox>
+ {style === 'lobe' ? (
+ <Icon color={cssVar.colorPrimary} icon={Check} size={18} style={{ flex: 'none' }} />
+ ) : null}
+ </Flexbox>
+
+ <Flexbox gap={8}>
+ <Text className={styles.hint}>{t('settingAgent.artwork.studio.moreStyles')}</Text>
+ <div className={styles.galleryGrid}>
+ {GALLERY_STYLES.map((item) => (
+ <Flexbox
+ className={styles.galleryItem}
+ gap={6}
+ key={item}
+ role={'button'}
+ tabIndex={0}
+ onClick={() => selectStyle(item)}
+ onKeyDown={keySelect(item)}
+ >
+ <div className={styles.galleryThumbWrap}>
+ <img
+ alt={t(`settingAgent.artwork.style.${item}`)}
+ className={styles.galleryThumb}
+ src={imageUrl(`agent-artwork-styles/style-${item}.jpg`)}
+ />
+ {style === item ? (
+ <Center className={styles.galleryCheck}>
+ <Icon icon={Check} size={13} />
+ </Center>
+ ) : null}
+ </div>
+ <Text ellipsis className={styles.galleryLabel}>
+ {t(`settingAgent.artwork.style.${item}`)}
+ </Text>
+ </Flexbox>
+ ))}
+ </div>
+ </Flexbox>
+
+ <Flexbox gap={8} style={{ marginBlockStart: 'auto' }}>
+ <Button
+ disabled={generating}
+ icon={WandSparkles}
+ type={'primary'}
+ onClick={() => generate(style)}
+ >
+ {t('settingAgent.artwork.studio.generate')}
+ </Button>
+ {generationError ? (
+ <Alert showIcon title={t('settingAgent.artwork.generateFailed')} type={'error'} />
+ ) : null}
+ </Flexbox>
+ </>
+ ) : (
+ <Center className={styles.noModelBlock} flex={1} gap={12} padding={24}>
+ <Text className={styles.hint} style={{ textAlign: 'center' }}>
+ {t('settingAgent.artwork.studio.noModel')}
+ </Text>
+ <Button
+ icon={SettingsIcon}
+ type={'primary'}
+ onClick={() => {
+ close();
+ navigate('/settings/provider/all');
+ }}
+ >
+ {t('settingAgent.artwork.studio.enableModel')}
+ </Button>
+ </Center>
+ )}
+ </Flexbox>
+
+ <input
+ accept="image/*"
+ aria-label={t('settingAgent.artwork.studio.upload')}
+ className={styles.visuallyHiddenInput}
+ ref={uploadInputRef}
+ tabIndex={-1}
+ type="file"
+ onChange={(event) => {
+ const file = event.target.files?.[0];
+ event.target.value = '';
+ if (file) void upload(file);
+ }}
+ />
+ </Flexbox>
+ );
+});
+
+AgentArtworkStudioContent.displayName = 'AgentArtworkStudioContent';
+
+export default AgentArtworkStudioContent;
diff --git a/src/features/AgentArtworkStudio/index.tsx b/src/features/AgentArtworkStudio/index.tsx
new file mode 100644
index 00000000000..0a05fd5c711
--- /dev/null
+++ b/src/features/AgentArtworkStudio/index.tsx
@@ -0,0 +1,22 @@
+'use client';
+
+import { createModal, type ModalInstance } from '@lobehub/ui/base-ui';
+import { t } from 'i18next';
+
+import AgentArtworkStudioContent from './Content';
+
+export { styleReferencesForArtworkStyle } from './lobeStyleReferences';
+
+/**
+ * Large avatar workshop for one agent: make your own (upload) or one-click
+ * generate in the official style. Reads everything from the agent store, so
+ * any surface that knows an agent id can open it.
+ */
+export const openAgentArtworkStudio = (agentId: string): ModalInstance =>
+ createModal({
+ content: <AgentArtworkStudioContent agentId={agentId} />,
+ footer: null,
+ maskClosable: true,
+ title: t('settingAgent.artwork.studio.title', { ns: 'setting' }),
+ width: 'min(92vw, 820px)',
+ });
diff --git a/src/features/AgentArtworkStudio/lobeStyleReferences.ts b/src/features/AgentArtworkStudio/lobeStyleReferences.ts
new file mode 100644
index 00000000000..c2825925212
--- /dev/null
+++ b/src/features/AgentArtworkStudio/lobeStyleReferences.ts
@@ -0,0 +1,17 @@
+import type { AgentArtworkStyle } from '@lobechat/prompts';
+
+import { CHIEF_AGENT_ARTWORKS } from '@/features/ChiefAgent/artwork';
+
+/**
+ * Three hue-diverse official mascots. Enough images to pin the rendering
+ * style, while the variety keeps the model from copying one character
+ * instead of inventing a subject for the agent.
+ */
+const REFERENCE_IDS = new Set(['lobe', 'byte', 'buttercup']);
+
+export const LOBE_STYLE_REFERENCE_IMAGE_URLS = CHIEF_AGENT_ARTWORKS.filter((item) =>
+ REFERENCE_IDS.has(item.id),
+).map((item) => item.avatar);
+
+export const styleReferencesForArtworkStyle = (style: AgentArtworkStyle): string[] | undefined =>
+ style === 'lobe' ? LOBE_STYLE_REFERENCE_IMAGE_URLS : undefined;
diff --git a/src/features/AgentProfileArtwork/index.tsx b/src/features/AgentProfileArtwork/index.tsx
index 23ed272df5c..35add8f4920 100644
--- a/src/features/AgentProfileArtwork/index.tsx
+++ b/src/features/AgentProfileArtwork/index.tsx
@@ -5,7 +5,7 @@ import {
type AgentArtworkStyle,
DEFAULT_AGENT_ARTWORK_STYLE,
} from '@lobechat/prompts';
-import { ActionIcon, Alert, Avatar, Center, Flexbox, Icon, Text, Tooltip } from '@lobehub/ui';
+import { ActionIcon, Avatar, Center, Flexbox, Icon, Text, Tooltip } from '@lobehub/ui';
import { Button, type DropdownItem, DropdownMenu, toast } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar } from 'antd-style';
import { Check, ImageIcon, MoreHorizontal, Trash2, UploadIcon, WandSparkles } from 'lucide-react';
@@ -14,13 +14,17 @@ import { useTranslation } from 'react-i18next';
import EmojiPicker from '@/components/EmojiPicker';
import NeuralNetworkLoading from '@/components/NeuralNetworkLoading';
+import {
+ openAgentArtworkStudio,
+ styleReferencesForArtworkStyle,
+} from '@/features/AgentArtworkStudio';
import { useAgentStore } from '@/store/agent';
import { agentArtworkSelectors } from '@/store/agent/selectors';
import { useAiInfraStore } from '@/store/aiInfra';
import { aiProviderSelectors } from '@/store/aiInfra/selectors';
import { useFileStore } from '@/store/file';
-import { openFilePicker, resolveAgentBackground } from './utils';
+import { avatarRemountKey, openFilePicker, resolveAgentBackground } from './utils';
const MAX_ARTWORK_SIZE = 1024 * 1024;
@@ -106,16 +110,6 @@ const styles = createStaticStyles(({ css }) => ({
emptyBackgroundHint: css`
color: ${cssVar.colorTextSecondary};
`,
- generatedPreview: css`
- position: relative;
-
- overflow: hidden;
-
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadiusLG};
-
- background: ${cssVar.colorFillQuaternary};
- `,
generationFeedback: css`
position: absolute;
z-index: 3;
@@ -139,9 +133,35 @@ const styles = createStaticStyles(({ css }) => ({
generationTitle: css`
font-weight: 500;
`,
- previewGenerationFeedback: css`
- inset: 1px;
- border-radius: calc(${cssVar.borderRadiusLG} - 1px);
+ generatedPreview: css`
+ position: relative;
+
+ overflow: hidden;
+
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ studioBadge: css`
+ position: absolute;
+ z-index: 5;
+ inset-block-end: -6px;
+ inset-inline-end: -6px;
+
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadius};
+
+ opacity: 0;
+ background: ${cssVar.colorBgElevated};
+ box-shadow: ${cssVar.boxShadowTertiary};
+
+ transition: opacity ${cssVar.motionDurationFast};
+
+ .agent-avatar-entry:hover &,
+ .agent-avatar-entry:focus-within & {
+ opacity: 1;
+ }
`,
visuallyHiddenInput: css`
pointer-events: none;
@@ -200,7 +220,6 @@ export const AgentProfileArtwork = memo<AgentProfileArtworkProps>(
const generation = useAgentStore(agentArtworkSelectors.generationByAgentId(agentId));
const backgroundInputRef = useRef<HTMLInputElement>(null);
const backgroundInputId = useId();
- const [avatarUploading, setAvatarUploading] = useState(false);
const [backgroundUploading, setBackgroundUploading] = useState(false);
const [artworkStyle, setArtworkStyle] = useState<AgentArtworkStyle>(
DEFAULT_AGENT_ARTWORK_STYLE,
@@ -217,29 +236,29 @@ export const AgentProfileArtwork = memo<AgentProfileArtworkProps>(
openFilePicker(input);
}, []);
+ // Avatar uploads moved into the studio; only the cover keeps an inline
+ // upload path here.
const upload = useCallback(
- async (kind: 'avatar' | 'background', file: File) => {
+ async (file: File) => {
if (!canEdit) return;
if (file.size > MAX_ARTWORK_SIZE) {
toast.error(t('settingAgent.artwork.sizeExceeded'));
return;
}
- const setUploading = kind === 'avatar' ? setAvatarUploading : setBackgroundUploading;
- setUploading(true);
+ setBackgroundUploading(true);
try {
const result = await uploadWithProgress({ file });
if (!result?.url) throw new Error('Upload returned no URL');
- if (kind === 'avatar') onAvatarChange(result.url);
- else onBackgroundChange(result.url);
+ onBackgroundChange(result.url);
} catch (error) {
console.error('Failed to upload agent artwork:', error);
toast.error(t('settingAgent.artwork.uploadFailed'));
} finally {
- setUploading(false);
+ setBackgroundUploading(false);
}
},
- [canEdit, onAvatarChange, onBackgroundChange, t, uploadWithProgress],
+ [canEdit, onBackgroundChange, t, uploadWithProgress],
);
const generateArtwork = useCallback(
@@ -254,6 +273,7 @@ export const AgentProfileArtwork = memo<AgentProfileArtworkProps>(
name,
referenceImageUrl: kind === 'background' ? avatar : backgroundUrl,
style,
+ styleReferenceImageUrls: styleReferencesForArtworkStyle(style),
systemRole,
title,
});
@@ -441,12 +461,19 @@ export const AgentProfileArtwork = memo<AgentProfileArtworkProps>(
</Flexbox>
) : null}
</div>
- <div className={styles.avatar}>
+ <div className={`${styles.avatar} agent-avatar-entry`}>
+ {/* Uploading an image lives in the studio, so the picker keeps only
+ emoji plus the studio launcher tab; the launcher tab is ordered
+ first and auto-selected on open, preserving the old generate-tab
+ position. */}
+ {/* Keyed by the url for the same reason as the studio preview: the
+ underlying Avatar latches its image-error state, so without a
+ remount a newly generated avatar stays invisible whenever the
+ previous one failed to load. */}
<EmojiPicker
allowModelAvatar
allowDelete={canEdit && !!avatar}
- allowUpload={canEdit}
- loading={avatarUploading}
+ key={avatarRemountKey(avatar)}
locale={locale}
open={canEdit ? undefined : false}
popupClassName={`${styles.avatarPicker} agent-avatar-artwork-picker`}
@@ -454,81 +481,39 @@ export const AgentProfileArtwork = memo<AgentProfileArtworkProps>(
shape={'square'}
size={72}
value={avatar || undefined}
- customTabs={
- canGenerate
- ? [
- {
- label: (
- <Tooltip title={t('settingAgent.artwork.avatar.image')}>
- <Icon icon={ImageIcon} size={{ size: 20, strokeWidth: 2.5 }} />
- </Tooltip>
- ),
- render: () => (
- <Flexbox gap={16} padding={20} width={348}>
- <Center className={styles.generatedPreview} height={156}>
- <Avatar avatar={avatar || undefined} shape={'square'} size={112} />
- {generating === 'avatar' ? (
- <Center
- className={`${styles.generationFeedback} ${styles.previewGenerationFeedback}`}
- >
- <Flexbox align={'center'} gap={10}>
- <NeuralNetworkLoading size={32} />
- <Flexbox align={'center'} gap={4}>
- <Text className={styles.generationTitle}>
- {t('settingAgent.artwork.avatar.generating')}
- </Text>
- <Text className={styles.generationHint}>
- {t('settingAgent.artwork.generatingHint')}
- </Text>
- <Button
- className={styles.generationActions}
- size={'small'}
- type={'fill'}
- onClick={() => void cancelAgentArtworkGeneration(agentId)}
- >
- {t('settingAgent.artwork.cancel')}
- </Button>
- </Flexbox>
- </Flexbox>
- </Center>
- ) : null}
- </Center>
- {generating !== 'avatar' ? (
- <Flexbox horizontal gap={8}>
- <Button
- icon={WandSparkles}
- style={{ flex: 1 }}
- onClick={() => void generateArtwork('avatar', artworkStyle)}
- >
- {t('settingAgent.artwork.avatar.generateAction')}
- </Button>
- <DropdownMenu items={() => buildStyleItems('avatar')}>
- <Button
- aria-label={t('settingAgent.artwork.styleMenu')}
- icon={MoreHorizontal}
- />
- </DropdownMenu>
- </Flexbox>
- ) : null}
- {generationError === 'avatar' ? (
- <Alert
- showIcon
- title={t('settingAgent.artwork.generateFailed')}
- type={'error'}
- />
- ) : null}
- </Flexbox>
- ),
- value: 'generate',
- },
- ]
- : undefined
- }
+ customTabs={[
+ {
+ label: (
+ <Tooltip title={t('settingAgent.artwork.avatar.image')}>
+ <Icon icon={ImageIcon} size={{ size: 20, strokeWidth: 2.5 }} />
+ </Tooltip>
+ ),
+ render: () => (
+ <Flexbox gap={16} padding={20} width={348}>
+ <Center className={styles.generatedPreview} height={156}>
+ <Avatar
+ avatar={avatar || undefined}
+ key={avatarRemountKey(avatar)}
+ shape={'square'}
+ size={112}
+ />
+ </Center>
+ <Button
+ icon={WandSparkles}
+ type={'primary'}
+ onClick={() => openAgentArtworkStudio(agentId)}
+ >
+ {t('settingAgent.artwork.studio.openAction')}
+ </Button>
+ </Flexbox>
+ ),
+ value: 'generate',
+ },
+ ]}
onChange={(value) => onAvatarChange(value)}
onDelete={() => onAvatarChange(null)}
- onUpload={(file) => upload('avatar', file)}
onOpenChange={(open) => {
- if (!open || !canGenerate) return;
+ if (!open) return;
requestAnimationFrame(() => {
const tabs = document.querySelectorAll('.agent-avatar-artwork-picker [role="tab"]');
@@ -541,6 +526,17 @@ export const AgentProfileArtwork = memo<AgentProfileArtworkProps>(
<NeuralNetworkLoading size={28} />
</Center>
) : null}
+ {/* Hover-revealed corner badge as the direct studio entry. */}
+ {canEdit ? (
+ <Tooltip title={t('settingAgent.artwork.studio.open')}>
+ <ActionIcon
+ className={styles.studioBadge}
+ icon={WandSparkles}
+ size={'small'}
+ onClick={() => openAgentArtworkStudio(agentId)}
+ />
+ </Tooltip>
+ ) : null}
</div>
<input
accept="image/*"
@@ -553,7 +549,7 @@ export const AgentProfileArtwork = memo<AgentProfileArtworkProps>(
onChange={(event) => {
const file = event.target.files?.[0];
event.target.value = '';
- if (file) void upload('background', file);
+ if (file) void upload(file);
}}
/>
</div>
diff --git a/src/features/AgentProfileArtwork/utils.test.ts b/src/features/AgentProfileArtwork/utils.test.ts
index d10af8ba9b0..6b33538eed7 100644
--- a/src/features/AgentProfileArtwork/utils.test.ts
+++ b/src/features/AgentProfileArtwork/utils.test.ts
@@ -3,7 +3,7 @@ import { describe, expect, it, vi } from 'vitest';
import { selectAgentArtworkModel } from '@/store/agent/slices/artwork/utils';
import type { EnabledProviderWithModels } from '@/types/aiProvider';
-import { openFilePicker, resolveAgentBackground } from './utils';
+import { avatarRemountKey, openFilePicker, resolveAgentBackground } from './utils';
describe('openFilePicker', () => {
it('uses the native picker while preserving click as a compatibility fallback', () => {
@@ -66,3 +66,29 @@ describe('selectAgentArtworkModel', () => {
expect(selectAgentArtworkModel([createProvider('fal', ['flux'])])?.model.id).toBe('flux');
});
});
+
+/**
+ * `@lobehub/ui`'s `Avatar` latches an internal image-error flag and never
+ * clears it when `avatar` changes, so a broken avatar url would keep every
+ * later one — including a freshly generated one — invisible until a reload.
+ * Every avatar render site keys off this helper to force a clean remount, so
+ * the key MUST change with the url and MUST NOT change for anything else.
+ */
+describe('avatarRemountKey', () => {
+ it('changes when the avatar url changes', () => {
+ expect(avatarRemountKey('http://example.com/a.png')).not.toBe(
+ avatarRemountKey('http://example.com/b.png'),
+ );
+ });
+
+ it('stays stable for the same avatar so unrelated re-renders do not remount', () => {
+ expect(avatarRemountKey('http://example.com/a.png')).toBe(
+ avatarRemountKey('http://example.com/a.png'),
+ );
+ });
+
+ it('collapses every empty value onto one placeholder key', () => {
+ expect(avatarRemountKey(undefined)).toBe(avatarRemountKey(null));
+ expect(avatarRemountKey('')).toBe(avatarRemountKey(undefined));
+ });
+});
diff --git a/src/features/AgentProfileArtwork/utils.ts b/src/features/AgentProfileArtwork/utils.ts
index 6cf0dc98941..bac381804b9 100644
--- a/src/features/AgentProfileArtwork/utils.ts
+++ b/src/features/AgentProfileArtwork/utils.ts
@@ -18,3 +18,15 @@ export const resolveAgentBackground = (value?: string | null): string | undefine
return source && IMAGE_SOURCE_PATTERN.test(source) ? source : undefined;
};
+
+/**
+ * Remount key for any avatar rendered through `@lobehub/ui`'s `Avatar`.
+ *
+ * That component latches an internal `isImgError` on the first failed image
+ * load and never clears it when `avatar` changes, so once an avatar url breaks
+ * (deleted object, expired signature, a transient 5xx) every later avatar in
+ * that mount stays invisible until a reload. Keying by the url remounts with a
+ * clean error state exactly when the source changes, and keeps the identity
+ * stable across unrelated re-renders so nothing flickers.
+ */
+export const avatarRemountKey = (avatar?: string | null): string => avatar || 'empty';
diff --git a/src/store/agent/slices/artwork/action.test.ts b/src/store/agent/slices/artwork/action.test.ts
index a86d1dd1d81..9f9db6dcd93 100644
--- a/src/store/agent/slices/artwork/action.test.ts
+++ b/src/store/agent/slices/artwork/action.test.ts
@@ -131,6 +131,100 @@ describe('AgentArtworkAction', () => {
);
});
+ it('attaches every style reference when the model has no image input cap', async () => {
+ vi.mocked(getAiInfraStoreState).mockReturnValue({
+ enabledImageModelList: [
+ {
+ children: [
+ {
+ abilities: {},
+ id: 'gemini-3.1-flash-lite-image:image',
+ parameters: {
+ aspectRatio: { default: 'auto', enum: ['auto', '1:1', '16:9'] },
+ imageUrls: { default: [] },
+ prompt: { default: '' },
+ },
+ },
+ ],
+ id: 'google',
+ name: 'Google',
+ source: 'builtin',
+ },
+ ],
+ } as unknown as ReturnType<typeof getAiInfraStoreState>);
+ vi.mocked(generationTopicService.createTopic).mockResolvedValue('topic-1');
+ vi.mocked(imageService.createImage).mockResolvedValue({
+ data: { generations: [{ asyncTaskId: 'task-1', id: 'generation-1' }] },
+ success: true,
+ } as never);
+ vi.mocked(generationService.getGenerationStatus).mockResolvedValue({
+ generation: { asset: { url: 'https://example.com/avatar.webp' } },
+ status: AsyncTaskStatus.Success,
+ } as never);
+ useAgentStore.setState({ updateAgentMetaById: vi.fn().mockResolvedValue(undefined) });
+
+ await useAgentStore.getState().generateAgentArtwork({
+ ...input,
+ referenceImageUrl: 'https://example.com/background.webp',
+ styleReferenceImageUrls: ['https://example.com/ref-a.webp', 'https://example.com/ref-b.webp'],
+ });
+
+ expect(imageService.createImage).toHaveBeenCalledWith(
+ expect.objectContaining({
+ params: expect.objectContaining({
+ aspectRatio: '1:1',
+ imageUrls: ['https://example.com/ref-a.webp', 'https://example.com/ref-b.webp'],
+ prompt: expect.stringContaining('as the target character style'),
+ }),
+ }),
+ );
+ const { prompt } = vi.mocked(imageService.createImage).mock.calls[0][0].params;
+ expect(prompt).not.toContain('attached existing profile background');
+ });
+
+ it('truncates style references to the model image input cap', async () => {
+ vi.mocked(getAiInfraStoreState).mockReturnValue({
+ enabledImageModelList: [
+ {
+ children: [
+ {
+ abilities: {},
+ id: 'gpt-image-2',
+ parameters: { imageUrls: { default: [], maxCount: 1 }, prompt: { default: '' } },
+ },
+ ],
+ id: 'openai',
+ name: 'OpenAI',
+ source: 'builtin',
+ },
+ ],
+ } as unknown as ReturnType<typeof getAiInfraStoreState>);
+ vi.mocked(generationTopicService.createTopic).mockResolvedValue('topic-1');
+ vi.mocked(imageService.createImage).mockResolvedValue({
+ data: { generations: [{ asyncTaskId: 'task-1', id: 'generation-1' }] },
+ success: true,
+ } as never);
+ vi.mocked(generationService.getGenerationStatus).mockResolvedValue({
+ generation: { asset: { url: 'https://example.com/avatar.webp' } },
+ status: AsyncTaskStatus.Success,
+ } as never);
+ useAgentStore.setState({ updateAgentMetaById: vi.fn().mockResolvedValue(undefined) });
+
+ await useAgentStore.getState().generateAgentArtwork({
+ ...input,
+ styleReferenceImageUrls: ['https://example.com/ref-a.webp', 'https://example.com/ref-b.webp'],
+ });
+
+ expect(imageService.createImage).toHaveBeenCalledWith(
+ expect.objectContaining({
+ params: expect.objectContaining({
+ imageUrls: ['https://example.com/ref-a.webp'],
+ prompt: expect.stringContaining('as the target character style'),
+ }),
+ }),
+ );
+ });
+
it('keeps a retryable error state when generation cannot start', async () => {
vi.mocked(generationTopicService.createTopic).mockResolvedValue('topic-1');
vi.mocked(imageService.createImage).mockResolvedValue({ success: false } as never);
diff --git a/src/store/agent/slices/artwork/action.ts b/src/store/agent/slices/artwork/action.ts
index 265f639f626..cc569183b65 100644
--- a/src/store/agent/slices/artwork/action.ts
+++ b/src/store/agent/slices/artwork/action.ts
@@ -120,9 +120,25 @@ export class AgentArtworkActionImpl {
if (!selection) throw new Error('No image generation model is available');
const { model, provider } = selection;
- const referenceImageUrl = input.referenceImageUrl?.trim();
- const supportsReferenceImage =
- !!referenceImageUrl && !!model.parameters && 'imageUrls' in model.parameters;
+ const supportsImageInput = !!model.parameters && 'imageUrls' in model.parameters;
+ const imageInputLimit = supportsImageInput
+ ? (model.parameters?.imageUrls?.maxCount ?? Number.POSITIVE_INFINITY)
+ : 0;
+ // Style references win over the counterpart-artwork reference; the prompt
+ // builder applies the same precedence so wording matches attachments.
+ const styleReferenceImageUrls = (input.styleReferenceImageUrls ?? [])
+ .map((url) => url.trim())
+ .filter(Boolean)
+ .slice(0, imageInputLimit);
+ const referenceImageUrl =
+ styleReferenceImageUrls.length > 0 ? undefined : input.referenceImageUrl?.trim();
+ const supportsReferenceImage = !!referenceImageUrl && supportsImageInput;
+ const imageUrls =
+ styleReferenceImageUrls.length > 0
+ ? styleReferenceImageUrls
+ : supportsReferenceImage
+ ? [referenceImageUrl]
+ : undefined;
const supportedSizes =
model.parameters && 'size' in model.parameters ? model.parameters.size?.enum : undefined;
const preferredSizes =
@@ -138,11 +154,12 @@ export class AgentArtworkActionImpl {
const aspectRatio = input.kind === 'avatar' ? '1:1' : '16:9';
const params = {
...(model.parameters && 'aspectRatio' in model.parameters ? { aspectRatio } : {}),
- ...(supportsReferenceImage ? { imageUrls: [referenceImageUrl] } : {}),
+ ...(imageUrls ? { imageUrls } : {}),
...(size ? { size } : {}),
prompt: buildAgentArtworkPrompt({
...input,
referenceImageUrl: supportsReferenceImage ? referenceImageUrl : undefined,
+ styleReferenceImageUrls,
}),
};
const result = await imageService.createImage({
diff --git a/src/store/agent/slices/artwork/utils.test.ts b/src/store/agent/slices/artwork/utils.test.ts
new file mode 100644
index 00000000000..74a479f96ee
--- /dev/null
+++ b/src/store/agent/slices/artwork/utils.test.ts
@@ -0,0 +1,50 @@
+import { describe, expect, it } from 'vitest';
+
+import type { EnabledProviderWithModels } from '@/types/aiProvider';
+
+import { selectAgentArtworkModel } from './utils';
+
+const provider = (id: string, modelIds: string[]) =>
+ ({
+ children: modelIds.map((modelId) => ({ abilities: {}, id: modelId })),
+ id,
+ name: id,
+ source: 'builtin',
+ }) as unknown as EnabledProviderWithModels;
+
+describe('selectAgentArtworkModel', () => {
+ it('prefers Nano Banana 2 Lite over gpt-image-2 across providers', () => {
+ const selection = selectAgentArtworkModel([
+ provider('openai', ['gpt-image-2']),
+ provider('google', ['gemini-3.1-flash-lite-image:image']),
+ ]);
+
+ expect(selection?.model.id).toBe('gemini-3.1-flash-lite-image:image');
+ expect(selection?.provider.id).toBe('google');
+ });
+
+ it('matches the preferred model without an :image suffix too', () => {
+ const selection = selectAgentArtworkModel([
+ provider('custom', ['gemini-3.1-flash-lite-image']),
+ ]);
+
+ expect(selection?.model.id).toBe('gemini-3.1-flash-lite-image');
+ });
+
+ it('falls back to gpt-image-2, then to the first available model', () => {
+ expect(
+ selectAgentArtworkModel([
+ provider('fal', ['fal-ai/nano-banana']),
+ provider('openai', ['gpt-image-2']),
+ ])?.model.id,
+ ).toBe('gpt-image-2');
+
+ expect(selectAgentArtworkModel([provider('fal', ['fal-ai/nano-banana'])])?.model.id).toBe(
+ 'fal-ai/nano-banana',
+ );
+ });
+
+ it('returns undefined when no image model is available', () => {
+ expect(selectAgentArtworkModel([])).toBeUndefined();
+ });
+});
diff --git a/src/store/agent/slices/artwork/utils.ts b/src/store/agent/slices/artwork/utils.ts
index f307eef9519..a69fbbec301 100644
--- a/src/store/agent/slices/artwork/utils.ts
+++ b/src/store/agent/slices/artwork/utils.ts
@@ -1,11 +1,22 @@
import type { EnabledProviderWithModels } from '@/types/aiProvider';
-const PREFERRED_ARTWORK_MODEL = 'gpt-image-2';
+/**
+ * Nano Banana 2 Lite leads: it accepts multiple style-reference images
+ * (gpt-image-2 caps `imageUrls` at one) and is the cheapest per image, which
+ * is what the one-click brand-style avatar path relies on.
+ */
+const PREFERRED_ARTWORK_MODELS = ['gemini-3.1-flash-lite-image', 'gpt-image-2'];
+
+// Image variants of chat models carry an `:image` suffix (e.g.
+// `gemini-3.1-flash-lite-image:image`), standalone image models do not.
+const baseModelId = (id: string) => id.split(':')[0];
export const selectAgentArtworkModel = (providers: EnabledProviderWithModels[]) => {
- for (const provider of providers) {
- const model = provider.children.find(({ id }) => id === PREFERRED_ARTWORK_MODEL);
- if (model) return { model, provider };
+ for (const preferred of PREFERRED_ARTWORK_MODELS) {
+ for (const provider of providers) {
+ const model = provider.children.find(({ id }) => baseModelId(id) === preferred);
+ if (model) return { model, provider };
+ }
}
const provider = providers[0];