Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
fix(web): defer setup and plugin assets to restore release budgets
Leggett03eb81ae60bf
diff --git a/apps/web/e2e/web-desktop-parity.spec.ts b/apps/web/e2e/web-desktop-parity.spec.tsindex a5c4b96a..d14b5586 100644--- a/apps/web/e2e/web-desktop-parity.spec.ts+++ b/apps/web/e2e/web-desktop-parity.spec.ts@@ -1,7 +1,7 @@import { createDefaultCreatorServicesConfig, type CreatorRuntimeComponentsResponse, type CreatorServicesCapabilitiesResponse, type CreatorYtDlpStatusResponse } from '@opencreator/protocol';import { test, expect } from './fixtures/runtime.js';-test('项目管理资源不随通用项目页面提前加载且 Browser/Desktop 布局一致', async ({ browser, runtime }, testInfo) => {+test('首页和项目页按需加载管理、登录与插件资源且 Browser/Desktop 布局一致', async ({ browser, runtime }, testInfo) => {test.skip(testInfo.project.name !== 'chromium-desktop');const results: unknown[] = [];for (const platform of ['browser', 'desktop']) {@@ -9,11 +9,17 @@ test('项目管理资源不随通用项目页面提前加载且 Browser/Desktopconst page = await context.newPage();const resources: string[] = [];page.on('request', request => {- if (/ProjectManagementDialog|project-management\.css/.test(request.url())) resources.push(request.url());+ if (/ProjectManagementDialog|project-management\.css|StartupAgentSetup|startup-agent-setup\.css|gateway-account-settings\.css|skill-market-catalog|\/packages\/skill-market\//.test(request.url())) resources.push(request.url());});if (platform === 'desktop') await installDesktopBridge(page);try {await runtime.openApp(page);+ expect(resources.some(url => /StartupAgentSetup/.test(url))).toBe(true);+ expect(resources.some(url => /ProjectManagementDialog|\/packages\/skill-market\//.test(url))).toBe(false);+ resources.length = 0;+ await page.reload();+ await expect(page.getByRole('status', { name: '本地运行内核正常' })).toBeVisible();+ await expect(page.locator('.startup-agent-setup')).toHaveCount(0);expect(resources).toHaveLength(0);await page.getByRole('button', { name: '我的项目', exact: true }).click();const workspace = page.getByRole('region', { name: 'OpenCreator 工作区' });diff --git a/apps/web/src/app/App.test.tsx b/apps/web/src/app/App.test.tsxindex 87f2d7df..f7f88026 100644--- a/apps/web/src/app/App.test.tsx+++ b/apps/web/src/app/App.test.tsx@@ -33,7 +33,7 @@ import {} from './AppController.js';import { PROJECTS_STORAGE_KEY } from '../features/projects/project-model.js';import type { OpenCreatorProject } from '../features/projects/project-model.js';-import { confirmAgentSetup } from '../features/settings/StartupAgentSetup.js';+import { confirmAgentSetup } from '../features/settings/agent-setup-state.js';import type { HostBridge } from '../host/bridge.js';import type { SubscribeRunEventsInput } from '../runtime/sse.js';import type { FileTreeNode, WorkspaceFile } from '../services/file-service.js';@@ -133,6 +133,10 @@ describe('App', () => {if (projectResponse !== undefined) return projectResponse;if (url.endsWith('/healthz')) return jsonResponse({ ok: true });if (url.endsWith('/codex/status')) return jsonResponse(createCodexStatusResponse());+ if (url.endsWith('/gateway/account')) return jsonResponse({+ source: 'manual', authState: 'signed_out', activationState: 'inactive',+ account: null, bindingVersion: null, models: [], activationError: null+ });if (url.endsWith('/codex/readiness')) return jsonResponse({state: authenticated ? 'ready' : 'degraded',account: { status: authenticated ? 'ready' : 'not_authenticated', accountStatus: authenticated ? 'signed_in' : 'signed_out' },@@ -159,7 +163,7 @@ describe('App', () => {await user.click(screen.getByRole('button', { name: '稍后配置,进入本地模式' }));await user.click(screen.getByRole('button', { name: '设置' }));await user.click(await screen.findByRole('button', { name: /AI 服务/ }));- await user.click(screen.getByRole('button', { name: '配置 Agent' }));+ await user.click(await screen.findByRole('button', { name: '配置 Agent' }));await user.click(screen.getByRole('button', { name: '本地模式' }));await user.selectOptions(await screen.findByRole('combobox', { name: '供应商' }), 'openai');expect(screen.getByLabelText('模型名称')).toHaveValue('gpt-5.6-sol');diff --git a/apps/web/src/app/AppController.tsx b/apps/web/src/app/AppController.tsxindex a7754d05..54f3953d 100644--- a/apps/web/src/app/AppController.tsx+++ b/apps/web/src/app/AppController.tsx@@ -22,7 +22,6 @@ import type {ThreadHistoryItem,ThreadResponse} from '@opencreator/protocol';-import { skillMarketCatalog } from '@opencreator/skill-market';import type {CSSProperties,DragEvent as ReactDragEvent,@@ -48,7 +47,6 @@ import {import { ConversationHeader } from '../features/conversation/ConversationHeader.js';import { ApprovalPanel } from '../features/approvals/ApprovalPanel.js';import { useThreadHistory } from '../features/conversation/use-thread-history.js';-import { getSkillMarketDisplayTitle } from '../features/plugins/skill-market-model.js';import {collectTaskTransitions,createTaskNotification,@@ -81,7 +79,6 @@ import {type ComposerSlashCommand} from '../features/runs/Composer.js';import { IssueList, PageIssueRoutingProvider } from '../features/issues/IssuePresenter.js';-import AgentDiagnosticsPanel from '../features/issues/AgentDiagnosticsPanel.js';import { buildIssueAgentPrompt } from '../features/issues/issue-catalog.js';import { usePageIssueState } from '../features/issues/page-issue-state.js';import { createScheduleTaskSummaries } from '../features/schedules/schedule-task-model.js';@@ -108,9 +105,9 @@ import type {import {confirmAgentSetup,isAgentSetupConfirmed,- StartupAgentSetup,type AgentSetupSnapshot-} from '../features/settings/StartupAgentSetup.js';+} from '../features/settings/agent-setup-state.js';+import '../features/settings/startup-agent-shell.css';import { useLocalizedCopy } from '../i18n/useLocalizedCopy.js';import type { McpCapabilities } from '../features/settings/McpSettingsView.js';import { OpenCreatorSidebar } from '../features/shell/OpenCreatorSidebar.js';@@ -270,6 +267,11 @@ const ScheduleThreadHeader = lazy(async () => {const SchedulesPage = lazy(() => import('../features/schedules/SchedulesPage.js'));const SearchPage = lazy(() => import('../features/search/SearchPage.js'));const SettingsPage = lazy(() => import('../features/settings/SettingsPage.js'));+const AgentDiagnosticsPanel = lazy(() => import('../features/issues/AgentDiagnosticsPanel.js'));+const StartupAgentSetup = lazy(async () => {+ const module = await import('../features/settings/StartupAgentSetup.js');+ return { default: module.StartupAgentSetup };+});const PersonalCenterPage = lazy(() => import('../features/account/PersonalCenterPage.js'));const TaskCenterPage = lazy(() => import('../features/tasks/TaskCenterPage.js'));const DetailPanel = lazy(async () => {@@ -3259,14 +3261,27 @@ export function AppController(props: AppControllerProps) {async function useMarketSkill(skillId: string, projectId: string) {setSkillMarketUseError(undefined);const isSkillCreator = skillId === 'skill-creator';- const entry = isSkillCreator ? undefined : getSkillMarketEntry(skillId);- if (!isSkillCreator && entry === undefined) {- setSkillMarketUseError({ skillId, error: '未找到这个技能' });- return;+ let title = '创建技能';+ if (!isSkillCreator) {+ try {+ const [{ skillMarketCatalog }, { getSkillMarketDisplayTitle }] = await Promise.all([+ import('@opencreator/skill-market'),+ import('../features/plugins/skill-market-model.js')+ ]);+ const entry = skillMarketCatalog.find(candidate => candidate.id === skillId);+ if (entry === undefined) {+ setSkillMarketUseError({ skillId, error: '未找到这个技能' });+ return;+ }+ title = getSkillMarketDisplayTitle(entry);+ } catch {+ setSkillMarketUseError({ skillId, error: '技能列表加载失败,请重试' });+ return;+ }}await useSkillByName({skillName: skillId,- title: isSkillCreator ? '创建技能' : getSkillMarketDisplayTitle(entry!),+ title,projectId,onError: error => setSkillMarketUseError(error === undefined ? undefined : { skillId, error }@@ -4966,22 +4981,24 @@ export function AppController(props: AppControllerProps) {</main>) : null}{agentSetup === 'needed' && connectionService !== null && !configurationPageActive ? (- <StartupAgentSetup- service={connectionService}- gatewayService={gatewayAccountService}- gatewayState={gatewayAccountState}- onGatewayStateChange={onGatewayStateChange}- openExternal={url => hostBridge.openExternal(url)}- initialSnapshot={agentSetupSnapshot}- onReady={snapshot => {- setAgentSetupRequested(false);- confirmAgentSetup(snapshot);- setAgentSetupSnapshot(snapshot);- setAgentSetup('ready');- startNewConversation({ destination: 'home' });- }}- onSkip={() => { setAgentSetupRequested(false); setAgentSetup('skipped'); }}- />+ <Suspense fallback={<main className="startup-agent-setup" role="status">{l('正在加载 Agent 配置…', 'Loading Agent setup…')}</main>}>+ <StartupAgentSetup+ service={connectionService}+ gatewayService={gatewayAccountService}+ gatewayState={gatewayAccountState}+ onGatewayStateChange={onGatewayStateChange}+ openExternal={url => hostBridge.openExternal(url)}+ initialSnapshot={agentSetupSnapshot}+ onReady={snapshot => {+ setAgentSetupRequested(false);+ confirmAgentSetup(snapshot);+ setAgentSetupSnapshot(snapshot);+ setAgentSetup('ready');+ startNewConversation({ destination: 'home' });+ }}+ onSkip={() => { setAgentSetupRequested(false); setAgentSetup('skipped'); }}+ />+ </Suspense>) : null}{projectDropActive ? (<div className="project-drop-overlay" role="status" aria-live="polite">@@ -5030,11 +5047,13 @@ export function AppController(props: AppControllerProps) {/></Suspense>) : null}- <AgentDiagnosticsPanel- hiddenCreatorIssues={immersiveWorkspace && props.route.view === 'workbench' && props.route.jobId === undefined}- hiddenBackgroundRuntimeIssues={immersiveWorkspace && props.route.view === 'workbench'}- onAskIssue={askAgentAboutIssue}- />+ <Suspense fallback={null}>+ <AgentDiagnosticsPanel+ hiddenCreatorIssues={immersiveWorkspace && props.route.view === 'workbench' && props.route.jobId === undefined}+ hiddenBackgroundRuntimeIssues={immersiveWorkspace && props.route.view === 'workbench'}+ onAskIssue={askAgentAboutIssue}+ />+ </Suspense></div></PageIssueRoutingProvider></RuntimeRecoveryContext.Provider>);@@ -5415,10 +5434,6 @@ function useMediaQuery(query: string): boolean {return matches;}-function getSkillMarketEntry(skillId: string): (typeof skillMarketCatalog)[number] | undefined {- return skillMarketCatalog.find(entry => entry.id === skillId);-}-function shouldShowThreadInSidebar(thread: ThreadResponse): boolean {if (thread.purpose === 'schedule_draft') return true;if (thread.workspaceMode === 'managed') return false;diff --git a/apps/web/src/features/settings/StartupAgentSetup.test.tsx b/apps/web/src/features/settings/StartupAgentSetup.test.tsxindex 8238cade..f72d7c4e 100644--- a/apps/web/src/features/settings/StartupAgentSetup.test.tsx+++ b/apps/web/src/features/settings/StartupAgentSetup.test.tsx@@ -5,9 +5,9 @@ import { afterEach, describe, expect, it, vi } from 'vitest';import { LanguageProvider } from '../../i18n/LanguageProvider.js';import type { GatewayAccountSettingsService } from '../../services/gateway-account-service.js';import {- availableAgentMode, confirmAgentSetup, isAgentSetupConfirmed,- StartupAgentSetup, type AgentSetupService, type AgentSetupSnapshot+ StartupAgentSetup, type AgentSetupService} from './StartupAgentSetup.js';+import { availableAgentMode, confirmAgentSetup, isAgentSetupConfirmed, type AgentSetupSnapshot } from './agent-setup-state.js';function readiness(accountStatus: 'signed_out' | 'signed_in' | 'expired', state: 'ready' | 'degraded' | 'blocked' = 'ready'): CodexRuntimeReadiness {return {diff --git a/apps/web/src/features/settings/StartupAgentSetup.tsx b/apps/web/src/features/settings/StartupAgentSetup.tsxindex e60fe037..8dac7c3e 100644--- a/apps/web/src/features/settings/StartupAgentSetup.tsx+++ b/apps/web/src/features/settings/StartupAgentSetup.tsx@@ -1,62 +1,24 @@-import { creatorProviderCatalogById, type CodexProviderConfig, type CodexRuntimeReadiness } from '@opencreator/protocol';+import { creatorProviderCatalogById } from '@opencreator/protocol';import { useEffect, useRef, useState } from 'react';import { ArrowLeft, LogIn, Monitor } from 'lucide-react';import OpenCreatorMark from '../../components/brand/OpenCreatorMark.js';import { useLocalizedCopy } from '../../i18n/useLocalizedCopy.js';import type { ConnectionService } from '../../services/connection-service.js';-import { readJsonFromStorage, writeJsonToStorage } from '../../storage/browser-storage.js';import { inferLlmProviderId, llmProviderOptions } from './llm-provider-selection.js';+import { availableAgentMode, type AgentSetupSnapshot } from './agent-setup-state.js';+import './startup-agent-shell.css';import './startup-agent-setup.css';import { GatewayAccountSettingsView } from './GatewayAccountSettingsView.js';import type { GatewayAccountSettingsService } from '../../services/gateway-account-service.js';import type { GatewayAccountState } from '@opencreator/protocol';-export type AgentSetupSnapshot = { readiness: CodexRuntimeReadiness; provider: CodexProviderConfig };type AgentSetupMode = 'codex' | 'custom';-const confirmationKey = 'opencreator.agent-setup-confirmed.v1';export type AgentSetupService = Pick<ConnectionService,| 'getCodexReadiness'| 'getCodexProvider'| 'updateCodexProvider'>;-export function needsAgentSetup(readiness: CodexRuntimeReadiness): boolean {- return readiness.account.accountStatus === 'signed_out'- || readiness.account.accountStatus === 'expired'- || readiness.account.status === 'not_authenticated';-}--export function availableAgentMode({ readiness, provider }: AgentSetupSnapshot): 'chatgpt' | 'api_key' | null {- if (readiness.binary.status !== 'ready' || readiness.protocol.status !== 'ready'- || readiness.models.status !== 'ready' || readiness.state === 'blocked') return null;- if (provider.authentication === 'chatgpt' && provider.baseUrl.length === 0- && !needsAgentSetup(readiness) && readiness.account.status === 'ready') return 'chatgpt';- if (provider.authentication === 'api_key' && provider.apiKeyConfigured && provider.model.trim().length > 0- && (readiness.account.status === 'ready' && readiness.account.accountStatus === 'signed_in'- || readiness.account.status === 'not_authenticated' && readiness.account.accountStatus === 'signed_out'- && provider.baseUrl.trim().length > 0)) return 'api_key';- return null;-}--function confirmationValue(snapshot: AgentSetupSnapshot): string {- const { readiness, provider } = snapshot;- return JSON.stringify([- readiness.codexHome, availableAgentMode(snapshot), provider.authentication,- provider.baseUrl, provider.model, provider.apiKeyConfigured- ]);-}--export function isAgentSetupConfirmed(snapshot: AgentSetupSnapshot): boolean {- return availableAgentMode(snapshot) !== null- && readJsonFromStorage<string>(confirmationKey) === confirmationValue(snapshot);-}--export function confirmAgentSetup(snapshot: AgentSetupSnapshot): void {- try {- writeJsonToStorage(confirmationKey, confirmationValue(snapshot));- } catch {}-}-export function StartupAgentSetup(props: {service: AgentSetupService;initialSnapshot?: AgentSetupSnapshot;diff --git a/apps/web/src/features/settings/agent-setup-state.ts b/apps/web/src/features/settings/agent-setup-state.tsnew file mode 100644index 00000000..6de9d1ba--- /dev/null+++ b/apps/web/src/features/settings/agent-setup-state.ts@@ -0,0 +1,42 @@+import type { CodexProviderConfig, CodexRuntimeReadiness } from '@opencreator/protocol';+import { readJsonFromStorage, writeJsonToStorage } from '../../storage/browser-storage.js';++export type AgentSetupSnapshot = { readiness: CodexRuntimeReadiness; provider: CodexProviderConfig };+const confirmationKey = 'opencreator.agent-setup-confirmed.v1';++export function needsAgentSetup(readiness: CodexRuntimeReadiness): boolean {+ return readiness.account.accountStatus === 'signed_out'+ || readiness.account.accountStatus === 'expired'+ || readiness.account.status === 'not_authenticated';+}++export function availableAgentMode({ readiness, provider }: AgentSetupSnapshot): 'chatgpt' | 'api_key' | null {+ if (readiness.binary.status !== 'ready' || readiness.protocol.status !== 'ready'+ || readiness.models.status !== 'ready' || readiness.state === 'blocked') return null;+ if (provider.authentication === 'chatgpt' && provider.baseUrl.length === 0+ && !needsAgentSetup(readiness) && readiness.account.status === 'ready') return 'chatgpt';+ if (provider.authentication === 'api_key' && provider.apiKeyConfigured && provider.model.trim().length > 0+ && (readiness.account.status === 'ready' && readiness.account.accountStatus === 'signed_in'+ || readiness.account.status === 'not_authenticated' && readiness.account.accountStatus === 'signed_out'+ && provider.baseUrl.trim().length > 0)) return 'api_key';+ return null;+}++function confirmationValue(snapshot: AgentSetupSnapshot): string {+ const { readiness, provider } = snapshot;+ return JSON.stringify([+ readiness.codexHome, availableAgentMode(snapshot), provider.authentication,+ provider.baseUrl, provider.model, provider.apiKeyConfigured+ ]);+}++export function isAgentSetupConfirmed(snapshot: AgentSetupSnapshot): boolean {+ return availableAgentMode(snapshot) !== null+ && readJsonFromStorage<string>(confirmationKey) === confirmationValue(snapshot);+}++export function confirmAgentSetup(snapshot: AgentSetupSnapshot): void {+ try {+ writeJsonToStorage(confirmationKey, confirmationValue(snapshot));+ } catch {}+}diff --git a/apps/web/src/features/settings/startup-agent-setup.css b/apps/web/src/features/settings/startup-agent-setup.cssindex f443ae50..e8289c14 100644--- a/apps/web/src/features/settings/startup-agent-setup.css+++ b/apps/web/src/features/settings/startup-agent-setup.css@@ -1,14 +1,3 @@-.startup-agent-setup {- position: fixed;- z-index: 70;- inset: 0;- display: grid;- place-items: center;- overflow: auto;- padding: max(32px, var(--opencreator-titlebar-height, 0px)) 20px 32px;- background: var(--bg);-}-.startup-agent-setup__card {width: min(100%, 480px);display: grid;@@ -55,13 +44,3 @@.startup-agent-setup__card .startup-agent-setup__primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }.startup-agent-setup__card .startup-agent-setup__skip { justify-self: center; border: 0; background: transparent; color: var(--muted); }.startup-agent-setup__card .startup-agent-setup__error { color: var(--danger); }--.startup-agent-banner {- width: min(760px, 100%);- margin: 0 auto 10px;- padding: 14px;- border: 1px solid var(--border);- border-radius: 10px;- background: var(--surface);-}-.startup-agent-banner button { margin-left: 12px; color: var(--accent-strong); background: transparent; border: 0; cursor: pointer; }diff --git a/apps/web/src/features/settings/startup-agent-shell.css b/apps/web/src/features/settings/startup-agent-shell.cssnew file mode 100644index 00000000..ddf10c4d--- /dev/null+++ b/apps/web/src/features/settings/startup-agent-shell.css@@ -0,0 +1,20 @@+.startup-agent-setup {+ position: fixed;+ z-index: 70;+ inset: 0;+ display: grid;+ place-items: center;+ overflow: auto;+ padding: max(32px, var(--opencreator-titlebar-height, 0px)) 20px 32px;+ background: var(--bg);+}++.startup-agent-banner {+ width: min(760px, 100%);+ margin: 0 auto 10px;+ padding: 14px;+ border: 1px solid var(--border);+ border-radius: 10px;+ background: var(--surface);+}+.startup-agent-banner button { margin-left: 12px; color: var(--accent-strong); background: transparent; border: 0; cursor: pointer; }diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.tsindex c664a7ca..87a0f2d4 100644--- a/apps/web/vite.config.ts+++ b/apps/web/vite.config.ts@@ -49,6 +49,15 @@ export default defineConfig({opencreatorStaticResourcesPlugin(),opencreatorRuntimeDevPlugin()],+ build: {+ rollupOptions: {+ output: {+ manualChunks(id) {+ if (id.includes('/packages/skill-market/')) return 'skill-market-catalog';+ }+ }+ }+ },server: {host: '127.0.0.1',port: 19861,