From 7fd15845b862232223e08d5f9af3ddeb820f7fef Mon Sep 17 00:00:00 2001 From: kev1n77 Date: Wed, 18 Nov 2026 17:07:01 +0800 Subject: [PATCH] feat(settings): add visual skin design entry --- .../AppearanceSettingsPage.test.tsx | 188 ++++++++++++++++-- .../application/AppearanceSettingsPage.tsx | 106 +++++++++- .../src/flow_chat/hooks/useMessageSender.ts | 5 +- .../flow-chat-manager/SessionModule.test.ts | 27 +++ .../flow-chat-manager/SessionModule.ts | 1 + .../flow_chat/store/sessionComposerStore.ts | 24 +++ .../components/VisualSkinConfigSection.tsx | 8 +- .../locales/en-US/settings/appearance.json | 5 +- .../locales/zh-CN/settings/appearance.json | 5 +- .../locales/zh-TW/settings/appearance.json | 5 +- 10 files changed, 341 insertions(+), 33 deletions(-) diff --git a/src/web-ui/src/app/scenes/settings/pages/application/AppearanceSettingsPage.test.tsx b/src/web-ui/src/app/scenes/settings/pages/application/AppearanceSettingsPage.test.tsx index 5c0382fbc5..5115c5e881 100644 --- a/src/web-ui/src/app/scenes/settings/pages/application/AppearanceSettingsPage.test.tsx +++ b/src/web-ui/src/app/scenes/settings/pages/application/AppearanceSettingsPage.test.tsx @@ -1,30 +1,36 @@ // @vitest-environment jsdom -import React from 'react'; +import React, { act } from 'react'; +import { createRoot } from 'react-dom/client'; import { renderToStaticMarkup } from 'react-dom/server'; -import { describe, expect, it, vi } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import AppearanceSettingsPage from '@/app/scenes/settings/pages/application/AppearanceSettingsPage'; +import { beginComposerSubmission, sessionComposerStore } from '@/flow_chat/store/sessionComposerStore'; +import type { Session } from '@/flow_chat/types/flow-chat'; +import { activateSurface, LOCAL_SURFACE_ID } from '@/infrastructure/peer-device/deviceSurface'; +import appearanceStrings from '@/locales/en-US/settings/appearance.json'; -vi.mock('react-i18next', () => ({ +const mocks = vi.hoisted(() => ({ + createChatDraft: vi.fn(), + getFlowChatState: vi.fn(), + openMainSession: vi.fn(), + getWorkspaceState: vi.fn(), + notifyError: vi.fn(), +})); + +vi.mock('@/flow_chat/services/FlowChatManager', () => ({ + flowChatManager: { createChatDraft: mocks.createChatDraft, getFlowChatState: mocks.getFlowChatState }, +})); +vi.mock('@/flow_chat/services/sessionActivation', () => ({ openMainSession: mocks.openMainSession })); +vi.mock('@/infrastructure/services/business/workspaceManager', () => ({ workspaceManager: { getState: mocks.getWorkspaceState } })); + +vi.mock('react-i18next', async (importOriginal) => ({ + ...await importOriginal(), useTranslation: (namespace: string) => ({ t: (key: string) => `${namespace}:${key}`, }), })); -vi.mock('@openbitfun/ui', async (importOriginal) => ({ - ...await importOriginal(), - ScrollArea: ({ children, ...props }: React.HTMLAttributes) =>
{children}
, - FormSection: ({ children, ...props }: React.HTMLAttributes) =>
{children}
, - FieldGroup: ({ children, ...props }: React.HTMLAttributes) =>
{children}
, - Select: ({ options, ...props }: any) => ( - - ), -})); - vi.mock('@/infrastructure/appearance', () => ({ SYSTEM_APPEARANCE_ID: 'system', useAppearance: () => ({ @@ -38,7 +44,11 @@ vi.mock('@/infrastructure/appearance', () => ({ vi.mock('@/infrastructure/i18n', () => ({ useI18n: () => ({ - t: (key: string) => key, + t: (key: string, values?: { skill?: string }) => { + if (key === 'skin.create') return appearanceStrings.skin.create; + if (key === 'skin.createPrompt') return appearanceStrings.skin.createPrompt.replace('{{skill}}', values?.skill ?? ''); + return key; + }, }), useLanguageSelector: () => ({ currentLanguage: 'zh-CN', @@ -49,7 +59,7 @@ vi.mock('@/infrastructure/i18n', () => ({ })); vi.mock('@/shared/notification-system', () => ({ - notificationService: { error: vi.fn() }, + notificationService: { error: mocks.notifyError }, })); vi.mock('@/infrastructure/font-preference', () => ({ @@ -60,7 +70,54 @@ vi.mock('../../../../../infrastructure/config/components/AppearancePackageConfig AppearancePackageConfigSection: () =>
, })); +const primary = { id: 'design-assistant', rootPath: '/assistants/design', workspaceKind: 'assistant', assistantId: 'design' }; +const skinPrompt = appearanceStrings.skin.createPrompt.replace('{{skill}}', 'openbitfun-skin-designer'); + +function assistantSession(sessionId: string, overrides: Partial = {}): Session { + return { + sessionId, workspaceId: primary.id, sessionKind: 'normal', mode: 'Claw', historyState: 'new', + status: 'idle', config: {}, dialogTurns: [], createdAt: 1, lastActiveAt: 1, error: null, ...overrides, + }; +} + +function showSessions(sessions: Session[], activeSessionId: string | null = null) { + mocks.getFlowChatState.mockReturnValue({ + sessions: new Map(sessions.map(session => [session.sessionId, session])), activeSessionId, + }); +} + +async function mountPage() { + const container = document.body.appendChild(document.createElement('div')); + const root = createRoot(container); + await act(async () => root.render()); + return { + createButton: container.querySelector('[data-testid="visual-skin-import"] + button')!, + close: async () => { + await act(async () => root.unmount()); + container.remove(); + }, + }; +} + describe('AppearanceSettingsPage', () => { + beforeEach(() => { + globalThis.IS_REACT_ACT_ENVIRONMENT = true; + mocks.getWorkspaceState.mockReturnValue({ + assistantWorkspaces: [{ id: 'default-assistant', workspaceKind: 'assistant' }, primary], + openedWorkspaces: new Map(), + primaryAssistantWorkspaceId: primary.id, + }); + showSessions([]); + mocks.createChatDraft.mockResolvedValue('skin-session'); + }); + + afterEach(() => { + document.body.replaceChildren(); + sessionComposerStore.setState({ drafts: {} }); + activateSurface(LOCAL_SURFACE_ID); + vi.resetAllMocks(); + }); + it('keeps themes and fonts together while language belongs to General', () => { document.body.innerHTML = renderToStaticMarkup(); expect(document.querySelector('[data-testid="appearance-package-config"]')).not.toBeNull(); @@ -69,5 +126,98 @@ describe('AppearanceSettingsPage', () => { expect(document.querySelector('[data-testid="appearance-language-select"]')).toBeNull(); expect(document.querySelector('[data-testid="appearance-palette-select"]')).toBeNull(); expect(document.querySelector('[data-testid="appearance-package-select"]')).toBeNull(); + expect(document.querySelector('.visual-skin-config .openbitfun-config-page-section__description')).toBeNull(); + }); + + it.each(['local', 'peer'])('prefills a fresh primary assistant session on the %s surface', async surfaceId => { + activateSurface(surfaceId); + mocks.openMainSession.mockImplementation(async (sessionId: string) => { + expect(sessionComposerStore.getState().getDraft(sessionId, surfaceId).value).toBe(skinPrompt); + }); + + const page = await mountPage(); + try { + expect(page.createButton.textContent).toBe(appearanceStrings.skin.create); + await act(async () => { + page.createButton.click(); + page.createButton.click(); + }); + expect(mocks.createChatDraft).toHaveBeenCalledExactlyOnceWith({ + workspaceId: primary.id, workspacePath: primary.rootPath, + }, 'Claw'); + expect(mocks.openMainSession).toHaveBeenCalledExactlyOnceWith('skin-session', { + workspaceId: primary.id, isCurrent: expect.any(Function), + }); + expect(mocks.notifyError).not.toHaveBeenCalled(); + if (surfaceId === 'peer') { + expect(sessionComposerStore.getState().getDraft('skin-session', LOCAL_SURFACE_ID).value).toBe(''); + } + } finally { + await page.close(); + } + }); + + it('reuses a blank assistant session while preserving other composer drafts', async () => { + const composer = sessionComposerStore.getState(); + composer.setValue('unrelated-text', 'My draft'); + composer.setContexts('attached-file', [{ id: 'file', type: 'file', fileName: 'ref.png', filePath: '/ref.png' }]); + composer.setPendingLargePastes('large-paste', { paste: 'My notes' }); + const finishSubmission = beginComposerSubmission('sending', LOCAL_SURFACE_ID); + showSessions([ + assistantSession('unrelated-text', { createdAt: 10 }), + assistantSession('attached-file', { createdAt: 9 }), + assistantSession('large-paste', { createdAt: 8 }), + assistantSession('sending', { createdAt: 7 }), + assistantSession('metadata-only', { createdAt: 6, historyState: 'metadata-only' }), + assistantSession('different-assistant', { createdAt: 5, workspaceId: 'other' }), + assistantSession('blank'), + ], 'unrelated-text'); + + const page = await mountPage(); + try { + await act(async () => page.createButton.click()); + expect(mocks.createChatDraft).not.toHaveBeenCalled(); + expect(mocks.openMainSession).toHaveBeenCalledExactlyOnceWith('blank', expect.objectContaining({ workspaceId: primary.id })); + expect(composer.getDraft('blank').value).toBe(skinPrompt); + expect(composer.getDraft('unrelated-text').value).toBe('My draft'); + expect(composer.getDraft('attached-file').contexts).toHaveLength(1); + expect(composer.getDraft('large-paste').pendingLargePastes).toEqual({ paste: 'My notes' }); + } finally { + finishSubmission(); + await page.close(); + } + }); + + it('returns to the same edited skin draft after reopening settings until it is sent', async () => { + const skinSession = assistantSession('skin-session'); + const anotherBlankSession = assistantSession('newer-blank', { createdAt: 2 }); + const composer = sessionComposerStore.getState(); + const firstPage = await mountPage(); + try { + await act(async () => firstPage.createButton.click()); + } finally { + await firstPage.close(); + } + composer.setValue(skinSession.sessionId, 'Design a forest skin'); + composer.setContexts(skinSession.sessionId, [{ id: 'file', type: 'file', fileName: 'forest.png', filePath: '/forest.png' }]); + showSessions([skinSession, anotherBlankSession], anotherBlankSession.sessionId); + + const page = await mountPage(); + try { + await act(async () => page.createButton.click()); + expect(mocks.createChatDraft).toHaveBeenCalledTimes(1); + expect(mocks.openMainSession.mock.calls.map(([id]) => id)).toEqual(['skin-session', 'skin-session']); + expect(composer.getDraft(skinSession.sessionId)).toMatchObject({ + value: 'Design a forest skin', contexts: [{ id: 'file', fileName: 'forest.png' }], + }); + + showSessions([{ ...skinSession, lastSubmittedMode: 'Claw' }, anotherBlankSession]); + await act(async () => page.createButton.click()); + expect(mocks.openMainSession).toHaveBeenLastCalledWith('newer-blank', expect.anything()); + expect(mocks.createChatDraft).toHaveBeenCalledTimes(1); + expect(composer.getDraft(anotherBlankSession.sessionId).value).toBe(skinPrompt); + } finally { + await page.close(); + } }); }); diff --git a/src/web-ui/src/app/scenes/settings/pages/application/AppearanceSettingsPage.tsx b/src/web-ui/src/app/scenes/settings/pages/application/AppearanceSettingsPage.tsx index b1ada91397..692e046fa2 100644 --- a/src/web-ui/src/app/scenes/settings/pages/application/AppearanceSettingsPage.tsx +++ b/src/web-ui/src/app/scenes/settings/pages/application/AppearanceSettingsPage.tsx @@ -1,4 +1,16 @@ import '@/app/scenes/settings/pages/application/AppearanceSettingsPage.scss'; +import { Button } from '@openbitfun/ui'; +import { Paintbrush } from 'lucide-react'; +import { useRef, useState } from 'react'; +import { flowChatSessionConfigForWorkspace, pickPrimaryAssistantWorkspace } from '@/app/utils/projectSessionWorkspace'; +import { flowChatManager } from '@/flow_chat/services/FlowChatManager'; +import { pendingQueueManager } from '@/flow_chat/services/flow-chat-manager/PendingQueueModule'; +import { openMainSession } from '@/flow_chat/services/sessionActivation'; +import { SessionExecutionState, stateMachineManager } from '@/flow_chat/state-machine'; +import { isComposerSubmissionPending, sessionComposerStore } from '@/flow_chat/store/sessionComposerStore'; +import { canRestoreQueuedMessageToComposer } from '@/flow_chat/utils/pendingQueueDraft'; +import { isSessionBindingLocked } from '@/flow_chat/utils/sessionLifecycle'; +import { compareSessionsForNavStable, sessionBelongsToWorkspaceNavRow } from '@/flow_chat/utils/sessionOrdering'; import { AppearancePackageConfigSection } from '@/infrastructure/config/components/AppearancePackageConfigSection'; import { VisualSkinConfigSection } from '@/infrastructure/config/components/VisualSkinConfigSection'; import { @@ -8,14 +20,85 @@ import { ConfigPageSectionStack } from '@/infrastructure/config/components/common'; import { FontPreferencePanel } from '@/infrastructure/font-preference'; +import { useI18n } from '@/infrastructure/i18n'; +import { getActiveSurfaceScope, isSurfaceChangedError, type DeviceSurfaceId } from '@/infrastructure/peer-device/deviceSurface'; +import { workspaceManager } from '@/infrastructure/services/business/workspaceManager'; +import { notificationService } from '@/shared/notification-system'; import SessionPanelSettingsSection from './SessionPanelSettingsSection'; import FlowChatWidthSettingsSection from './FlowChatWidthSettingsSection'; import SidebarSettingsSection from './SidebarSettingsSection'; -import React from 'react'; -import { useTranslation } from 'react-i18next'; -const AppearanceSettingsPage: React.FC = () => { - const { t } = useTranslation('settings/appearance'); +function findSkinDesignSession(workspaceId: string, surfaceId: DeviceSurfaceId) { + const { activeSessionId, sessions } = flowChatManager.getFlowChatState(); + const composer = sessionComposerStore.getState(); + const candidates = Array.from(sessions.values()).filter(session => ( + sessionBelongsToWorkspaceNavRow(session, workspaceId) + && session.mode?.toLowerCase() === 'claw' + && session.sessionKind === 'normal' && !session.parentSessionId && !session.isTransient + && !session.externalHistory && !session.config.dispatchTarget && !session.config.dispatchJobId + && session.status !== 'error' && session.persistedStatus !== 'archived' && session.persistedStatus !== 'completed' + && !session.isPartial && !session.persistedTurnCount && !isSessionBindingLocked(session) + && (!session.draft || session.draft.phase === 'editing') + )).sort(compareSessionsForNavStable); + + let emptySessionId: string | undefined; + for (const { sessionId } of candidates) { + const machine = stateMachineManager.getSnapshot(sessionId); + if (isComposerSubmissionPending(sessionId, surfaceId) + || (machine && machine.currentState !== SessionExecutionState.IDLE) + || machine?.context.queuedInput || pendingQueueManager.listForSurface(surfaceId, sessionId).length) continue; + const draft = composer.getDraft(sessionId, surfaceId); + if (draft.prefillSource === 'skin-design') return { sessionId, needsPrefill: false }; + if (canRestoreQueuedMessageToComposer(draft) && (!emptySessionId || sessionId === activeSessionId)) { + emptySessionId = sessionId; + } + } + return emptySessionId ? { sessionId: emptySessionId, needsPrefill: true } : undefined; +} + +function AppearanceSettingsPage() { + const { t } = useI18n('settings/appearance'); + const creationPending = useRef(false); + const [creatingSkin, setCreatingSkin] = useState(false); + + async function handleCreateSkin() { + if (creationPending.current) return; + const scope = getActiveSurfaceScope(); + const { assistantWorkspaces, openedWorkspaces, primaryAssistantWorkspaceId } = workspaceManager.getState(); + const workspace = pickPrimaryAssistantWorkspace( + assistantWorkspaces ?? Array.from(openedWorkspaces.values()), + primaryAssistantWorkspaceId, + ); + if (!workspace) { + notificationService.error(t('skin.assistantUnavailable')); + return; + } + + creationPending.current = true; + setCreatingSkin(true); + try { + const existing = findSkinDesignSession(workspace.id, scope.surfaceId); + const sessionId = existing?.sessionId + ?? await flowChatManager.createChatDraft(flowChatSessionConfigForWorkspace(workspace), 'Claw'); + if (!scope.isCurrent()) return; + if (existing?.needsPrefill !== false) { + sessionComposerStore.getState().setPrefill( + sessionId, + t('skin.createPrompt', { skill: 'openbitfun-skin-designer' }), + 'skin-design', + scope.surfaceId, + ); + } + await openMainSession(sessionId, { workspaceId: workspace.id, isCurrent: scope.isCurrent }); + } catch (error) { + if (scope.isCurrent() && !isSurfaceChangedError(error)) { + notificationService.error(error instanceof Error ? error.message : t('skin.createFailed')); + } + } finally { + creationPending.current = false; + setCreatingSkin(false); + } + } return ( { > - + ); -}; +} export default AppearanceSettingsPage; diff --git a/src/web-ui/src/flow_chat/hooks/useMessageSender.ts b/src/web-ui/src/flow_chat/hooks/useMessageSender.ts index 491b538e6a..763baceea8 100644 --- a/src/web-ui/src/flow_chat/hooks/useMessageSender.ts +++ b/src/web-ui/src/flow_chat/hooks/useMessageSender.ts @@ -42,7 +42,7 @@ import type { AgentDialogTurnExecution, SessionPermissionMode, } from '@/infrastructure/api/service-api/AgentAPI'; -import type { PendingLargePasteMap } from '../store/sessionComposerStore'; +import { beginComposerSubmission, type PendingLargePasteMap } from '../store/sessionComposerStore'; import { LARGE_PASTES_METADATA_KEY, pickReferencedLargePastes } from '../utils/largePasteMetadata'; const log = createLogger('FlowChat'); @@ -160,6 +160,7 @@ export function useMessageSender(props: UseMessageSenderProps): UseMessageSender agentType: currentAgentType || 'Standard', }); + const finishComposerSubmission = sessionId ? beginComposerSubmission(sessionId, surfaceScope.surfaceId) : undefined; try { const sendImmediately = options?.sendImmediately ?? (await getChatInputSendDuringTurn() === 'immediate'); @@ -353,6 +354,8 @@ export function useMessageSender(props: UseMessageSenderProps): UseMessageSender error: (error as Error)?.message ?? 'unknown', }); throw error; + } finally { + finishComposerSubmission?.(); } }, [ canSetInitialBtwModel, diff --git a/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.test.ts b/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.test.ts index 514088c4b6..e17c6d657d 100644 --- a/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.test.ts +++ b/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.test.ts @@ -28,6 +28,7 @@ import { } from '../sessionOpenIntent'; import type { Session } from '../../types/flow-chat'; import type { ReviewTeamRunManifest } from '@/shared/services/reviewTeamService'; +import { WorkspaceKind, WorkspaceType, type WorkspaceInfo } from '@/shared/types'; import { workspaceManager } from '@/infrastructure/services/business/workspaceManager'; import { notificationService } from '../../../shared/notification-system'; @@ -404,6 +405,32 @@ describe('createChatSession', () => { expect(agentApiMocks.createSession).not.toHaveBeenCalled(); }); + it('creates a Claw session for a closed assistant by its catalog ID', async () => { + const assistant: WorkspaceInfo = { + id: 'closed-assistant', + name: 'Design assistant', + rootPath: '/assistants/design', + workspaceKind: WorkspaceKind.Assistant, + workspaceType: WorkspaceType.Other, + languages: [], + openedAt: '', + lastAccessed: '', + tags: [], + }; + const workspaceState = vi.spyOn(workspaceManager, 'getState').mockReturnValueOnce({ + ...workspaceManager.getState(), assistantWorkspaces: [assistant], + }); + const { context } = createContext(createSession()); + try { + await expect(createChatSession(context, { workspaceId: assistant.id }, 'Claw', true)).resolves.toBe('created-1'); + expect(agentApiMocks.createSession).toHaveBeenCalledWith(expect.objectContaining({ + workspaceId: assistant.id, workspacePath: assistant.rootPath, agentType: 'Claw', + })); + } finally { + workspaceState.mockRestore(); + } + }); + it('dedupes concurrent creates before model config loading resolves', async () => { // This keeps the first create suspended in the model config path while the // second create enters with the same creation key. diff --git a/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.ts b/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.ts index fdd86d02f5..16c88b7695 100644 --- a/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.ts +++ b/src/web-ui/src/flow_chat/services/flow-chat-manager/SessionModule.ts @@ -419,6 +419,7 @@ const resolveSessionWorkspace = (config: SessionConfig): WorkspaceInfo => { if (!id) throw new Error('Workspace ID is required to create a session'); const workspace = state.openedWorkspaces.get(id) ?? (state.currentWorkspace?.id === id ? state.currentWorkspace : undefined) + ?? state.assistantWorkspaces?.find(record => record.id === id) ?? state.recentWorkspaces?.find(record => record.id === id); if (!workspace) throw new Error(`Workspace ID is unavailable: ${id}`); return workspace; diff --git a/src/web-ui/src/flow_chat/store/sessionComposerStore.ts b/src/web-ui/src/flow_chat/store/sessionComposerStore.ts index 5ae86f3ade..874232676d 100644 --- a/src/web-ui/src/flow_chat/store/sessionComposerStore.ts +++ b/src/web-ui/src/flow_chat/store/sessionComposerStore.ts @@ -8,11 +8,13 @@ import { } from '@/infrastructure/peer-device/deviceSurface'; export type PendingLargePasteMap = Record; +type ComposerPrefillSource = 'skin-design'; export interface SessionComposerDraft { value: string; contexts: ContextItem[]; pendingLargePastes: PendingLargePasteMap; + prefillSource?: ComposerPrefillSource; updatedAt: number; } @@ -26,6 +28,7 @@ interface SessionComposerState { persistPreviousContexts?: boolean, ) => SessionComposerDraft; setValue: (sessionId: string, value: string, surfaceId?: DeviceSurfaceId) => void; + setPrefill: (sessionId: string, value: string, source: ComposerPrefillSource, surfaceId: DeviceSurfaceId) => void; setContexts: (sessionId: string, contexts: ContextItem[], surfaceId?: DeviceSurfaceId) => void; setPendingLargePastes: (sessionId: string, pendingLargePastes: PendingLargePasteMap, surfaceId?: DeviceSurfaceId) => void; clearDraft: (sessionId: string) => void; @@ -35,6 +38,7 @@ interface SessionComposerState { const EMPTY_CONTEXTS: ContextItem[] = []; const EMPTY_PENDING_LARGE_PASTES: PendingLargePasteMap = {}; +const pendingSubmissions = new Map(); function createEmptyDraft(): SessionComposerDraft { return { @@ -49,6 +53,21 @@ function draftKey(sessionId: string, surfaceId = getActiveSurfaceId()): string { return surfaceScopedKey(surfaceId, sessionId); } +export function isComposerSubmissionPending(sessionId: string, surfaceId: DeviceSurfaceId): boolean { + return pendingSubmissions.has(draftKey(sessionId, surfaceId)); +} + +/** Protect the cleared composer while a send prepares attachments and awaits admission. */ +export function beginComposerSubmission(sessionId: string, surfaceId: DeviceSurfaceId): () => void { + const key = draftKey(sessionId, surfaceId); + pendingSubmissions.set(key, (pendingSubmissions.get(key) ?? 0) + 1); + return () => { + const remaining = (pendingSubmissions.get(key) ?? 1) - 1; + if (remaining) pendingSubmissions.set(key, remaining); + else pendingSubmissions.delete(key); + }; +} + function updateDraft( state: SessionComposerState, sessionId: string, @@ -94,6 +113,10 @@ export const useSessionComposerStore = create((set, get) = set(state => updateDraft(state, sessionId, { value }, surfaceId)); }, + setPrefill: (sessionId, value, prefillSource, surfaceId) => { + set(state => updateDraft(state, sessionId, { value, prefillSource }, surfaceId)); + }, + setContexts: (sessionId, contexts, surfaceId) => { set(state => updateDraft(state, sessionId, { contexts: [...contexts] }, surfaceId)); }, @@ -114,6 +137,7 @@ export const useSessionComposerStore = create((set, get) = value: '', contexts: [], pendingLargePastes: {}, + prefillSource: undefined, }); }); }, diff --git a/src/web-ui/src/infrastructure/config/components/VisualSkinConfigSection.tsx b/src/web-ui/src/infrastructure/config/components/VisualSkinConfigSection.tsx index ea66f5feaf..0be17a3634 100644 --- a/src/web-ui/src/infrastructure/config/components/VisualSkinConfigSection.tsx +++ b/src/web-ui/src/infrastructure/config/components/VisualSkinConfigSection.tsx @@ -1,11 +1,11 @@ import { Button, IconButton } from '@openbitfun/ui'; import { Check, Image, Palette, Trash2, Upload } from 'lucide-react'; -import { useEffect, useRef, useState } from 'react'; +import { useEffect, useRef, useState, type ReactNode } from 'react'; import { useTranslation } from 'react-i18next'; import { useVisualSkin, type VisualSkinCatalogEntry } from '@/infrastructure/visual-skin'; import { decodeSkinDataUrl } from '@/infrastructure/visual-skin/archive'; -import { ConfigPageSection, formatStandaloneUiText } from './common'; +import { ConfigPageSection } from './common'; function previewSource(entry: VisualSkinCatalogEntry): string | undefined { return typeof entry.previewAsset === 'string' && entry.previewAsset.trim() @@ -60,7 +60,7 @@ function VideoPreview({ source }: { source: string }) { * image. The runtime owns validation and persistence; this component only * exposes the safe, user-facing workflow. */ -export function VisualSkinConfigSection() { +export function VisualSkinConfigSection({ createAction }: { createAction?: ReactNode }) { const { t } = useTranslation('settings/appearance'); const fileInputRef = useRef(null); const [busy, setBusy] = useState(false); @@ -109,7 +109,6 @@ export function VisualSkinConfigSection() { {busy ? t('skin.importing') : t('skin.import')} + {createAction} )} > diff --git a/src/web-ui/src/locales/en-US/settings/appearance.json b/src/web-ui/src/locales/en-US/settings/appearance.json index c84cceef92..411bc77c13 100644 --- a/src/web-ui/src/locales/en-US/settings/appearance.json +++ b/src/web-ui/src/locales/en-US/settings/appearance.json @@ -39,9 +39,12 @@ }, "skin": { "title": "Visual skin packs", - "description": "Import a skin pack generated from a reference image. It changes the visual language across the workspace while keeping the product structure intact.", "import": "Import skin pack", "importing": "Importing…", + "create": "Create skin", + "createPrompt": "Use the built-in {{skill}} skill to create an importable OpenBitFun visual skin pack based on [your reference materials or attached image].", + "assistantUnavailable": "No primary assistant workspace is available on this device.", + "createFailed": "Couldn't open a skin design conversation.", "empty": "No imported skin packs yet.", "generated": "Generated visual theme", "previewAlt": "Preview of {{name}}", diff --git a/src/web-ui/src/locales/zh-CN/settings/appearance.json b/src/web-ui/src/locales/zh-CN/settings/appearance.json index 6e4d30e612..3e369df1e9 100644 --- a/src/web-ui/src/locales/zh-CN/settings/appearance.json +++ b/src/web-ui/src/locales/zh-CN/settings/appearance.json @@ -39,9 +39,12 @@ }, "skin": { "title": "视觉皮肤包", - "description": "导入由参考图生成的皮肤包,在保留产品结构的同时,将视觉语言应用到整个工作区。", "import": "导入皮肤包", "importing": "正在导入…", + "create": "制作皮肤", + "createPrompt": "请使用内置的 {{skill}} Skill,参考【在此填写素材,或上传参考图】,制作一个可导入 OpenBitFun 的视觉皮肤包。", + "assistantUnavailable": "当前设备没有可用的主助理工作区。", + "createFailed": "无法打开皮肤制作会话。", "empty": "还没有导入皮肤包。", "generated": "生成的视觉主题", "previewAlt": "{{name}} 的预览", diff --git a/src/web-ui/src/locales/zh-TW/settings/appearance.json b/src/web-ui/src/locales/zh-TW/settings/appearance.json index f1d20d1b05..5f9ed9e43d 100644 --- a/src/web-ui/src/locales/zh-TW/settings/appearance.json +++ b/src/web-ui/src/locales/zh-TW/settings/appearance.json @@ -39,9 +39,12 @@ }, "skin": { "title": "視覺皮膚包", - "description": "匯入由參考圖產生的皮膚包,在保留產品結構的同時,將視覺語言套用到整個工作區。", "import": "匯入皮膚包", "importing": "正在匯入…", + "create": "製作皮膚", + "createPrompt": "請使用內建的 {{skill}} Skill,參考【在此填寫素材,或上傳參考圖】,製作一個可匯入 OpenBitFun 的視覺皮膚包。", + "assistantUnavailable": "目前裝置沒有可用的主要助理工作區。", + "createFailed": "無法開啟皮膚製作會話。", "empty": "尚未匯入皮膚包。", "generated": "產生的視覺主題", "previewAlt": "{{name}} 的預覽",