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: add artifact deployment business extension slots (#15670)

Innei5097c0e8b8ec
diff --git a/apps/server/src/routers/lambda/market/index.ts b/apps/server/src/routers/lambda/market/index.ts
index 5f5f9b68e3c..856f066c9cb 100644
--- a/apps/server/src/routers/lambda/market/index.ts
+++ b/apps/server/src/routers/lambda/market/index.ts
@@ -4,6 +4,7 @@ import { serialize } from 'cookie';
import debug from 'debug';
import { z } from 'zod';
+import { marketDeploymentsRouter } from '@/business/server/lambda-routers/marketDeployments';
import { publicProcedure, router } from '@/libs/trpc/lambda';
import { marketUserInfo, serverDatabase } from '@/libs/trpc/lambda/middleware';
import { DiscoverService } from '@/server/services/discover';
@@ -59,6 +60,9 @@ export const marketRouter = router({
// ============================== Credential Management ==============================
creds: credsRouter,
+ // ============================== Artifact Deployments (business) ==============================
+ deployments: marketDeploymentsRouter,
+
// ============================== Skill Management ==============================
skill: skillRouter,
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 8d0bc9f851a..91c418da3b8 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -645,6 +645,17 @@
"rag.userQuery.actions.delete": "Delete Query Rewrite",
"rag.userQuery.actions.regenerate": "Regenerate Query",
"regenerate": "Regenerate",
+ "resource.artifacts.buildLog.copy": "Copy logs",
+ "resource.artifacts.buildLog.copySuccess": "Build logs copied",
+ "resource.artifacts.buildLog.empty": "No build logs have been received yet. Refresh after the builder callback returns.",
+ "resource.artifacts.buildLog.endedAt": "Ended at",
+ "resource.artifacts.buildLog.errorCode": "Error code",
+ "resource.artifacts.buildLog.errorMessage": "Error message",
+ "resource.artifacts.buildLog.job": "Job",
+ "resource.artifacts.buildLog.open": "View build logs",
+ "resource.artifacts.buildLog.startedAt": "Started at",
+ "resource.artifacts.buildLog.status": "Status",
+ "resource.artifacts.buildLog.title": "Build logs",
"resources.knowledgePicker.publicAgentHint": "Public agents can only reference workspace resources. Publish a private resource to the workspace first if you want to attach it.",
"resources.mode.privateHint": "Your own drawer — only you can see these files",
"resources.mode.workspaceHint": "Shared with everyone in this workspace",
@@ -1317,6 +1328,38 @@
"workingPanel.browser.tool.screenshot": "Captured screenshot",
"workingPanel.browser.tool.scroll": "Scrolled page",
"workingPanel.browser.tool.snapshot": "Read page elements",
+ "workingPanel.deployments.buildFailedFallback": "Last build failed; the previous release is still serving.",
+ "workingPanel.deployments.buildLog.open": "View build logs",
+ "workingPanel.deployments.buildStatus.canceled": "Canceled",
+ "workingPanel.deployments.buildStatus.failed": "Failed",
+ "workingPanel.deployments.buildStatus.finalizing": "Finalizing",
+ "workingPanel.deployments.buildStatus.pending": "Pending",
+ "workingPanel.deployments.buildStatus.quota_exceeded": "Quota exceeded",
+ "workingPanel.deployments.buildStatus.running": "Running",
+ "workingPanel.deployments.buildStatus.success": "Succeeded",
+ "workingPanel.deployments.buildStatus.timeout": "Timed out",
+ "workingPanel.deployments.copy": "Copy URL",
+ "workingPanel.deployments.copyDebugId": "Copy debug ID",
+ "workingPanel.deployments.copyDebugIdSuccess": "Debug ID copied",
+ "workingPanel.deployments.copySuccess": "Deployment URL copied",
+ "workingPanel.deployments.empty": "No deployments in this topic",
+ "workingPanel.deployments.noRelease": "No published release",
+ "workingPanel.deployments.noTopic": "Open a topic to view deployments",
+ "workingPanel.deployments.open": "Open deployment",
+ "workingPanel.deployments.refresh": "Refresh deployments",
+ "workingPanel.deployments.retry.failed": "Retry failed",
+ "workingPanel.deployments.retry.noSource": "Source message not found in this topic — re-publish from the artifact card in chat instead.",
+ "workingPanel.deployments.retry.success": "Build re-triggered",
+ "workingPanel.deployments.retry.title": "Retry build",
+ "workingPanel.deployments.size": "{{size}} bytes",
+ "workingPanel.deployments.status.active": "Active",
+ "workingPanel.deployments.status.building": "Building",
+ "workingPanel.deployments.status.failed": "Build failed",
+ "workingPanel.deployments.status.unpublished": "Unpublished",
+ "workingPanel.deployments.tab": "Deployments",
+ "workingPanel.deployments.title": "Deployments",
+ "workingPanel.deployments.unpublish": "Unpublish",
+ "workingPanel.deployments.unpublishSuccess": "Deployment unpublished",
"workingPanel.documents.close": "Close",
"workingPanel.documents.discard": "Discard",
"workingPanel.documents.edit": "Edit",
diff --git a/locales/en-US/labs.json b/locales/en-US/labs.json
index 40203369aed..faf45c97450 100644
--- a/locales/en-US/labs.json
+++ b/locales/en-US/labs.json
@@ -3,6 +3,8 @@
"features.agentGraphConfig.title": "Agent Graph Runtime Configuration",
"features.agentSelfIteration.desc": "Allow the agent to reflect, build self-awareness, and continuously iterate through ongoing attempts and interactions.",
"features.agentSelfIteration.title": "Agent Self-iteration",
+ "features.artifactDeployment.desc": "Publish artifacts to a hosted URL and manage releases from the conversation sidebar",
+ "features.artifactDeployment.title": "Artifact Deployments",
"features.assistantMessageGroup.desc": "Group agent messages and their tool call results together for display",
"features.assistantMessageGroup.title": "Agent Message Grouping",
"features.claudeCodeSdk.desc": "Run Claude Code sessions through the Claude Agent SDK instead of spawning the CLI. Enables richer streaming and session control.",
diff --git a/locales/en-US/portal.json b/locales/en-US/portal.json
index 14f2a042570..403ef9727bb 100644
--- a/locales/en-US/portal.json
+++ b/locales/en-US/portal.json
@@ -2,6 +2,12 @@
"FilePreview.tabs.chunk": "Chunk",
"FilePreview.tabs.file": "File",
"Plugins": "Skills",
+ "artifacts.deploy.copy": "Copy URL",
+ "artifacts.deploy.copySuccess": "Deployment URL copied",
+ "artifacts.deploy.failed": "Deployment failed",
+ "artifacts.deploy.open": "Open deployment",
+ "artifacts.deploy.publish": "Publish",
+ "artifacts.deploy.success": "Published",
"artifacts.display.code": "Code",
"artifacts.display.preview": "Preview",
"artifacts.svg.copyAsImage": "Copy as Image",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index b70d2997046..25cae4b3abd 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -645,6 +645,50 @@
"rag.userQuery.actions.delete": "删除 Query 重写",
"rag.userQuery.actions.regenerate": "重新生成 Query",
"regenerate": "重新生成",
+ "resource.artifacts.buildLog.copy": "复制日志",
+ "resource.artifacts.buildLog.copySuccess": "构建日志已复制",
+ "resource.artifacts.buildLog.empty": "暂未收到构建日志。请在 builder 回调返回后刷新查看。",
+ "resource.artifacts.buildLog.endedAt": "结束时间",
+ "resource.artifacts.buildLog.errorCode": "错误码",
+ "resource.artifacts.buildLog.errorMessage": "错误信息",
+ "resource.artifacts.buildLog.job": "任务",
+ "resource.artifacts.buildLog.open": "查看构建日志",
+ "resource.artifacts.buildLog.startedAt": "开始时间",
+ "resource.artifacts.buildLog.status": "状态",
+ "resource.artifacts.buildLog.title": "构建日志",
+ "resource.artifacts.copy": "复制链接",
+ "resource.artifacts.copyDebugId": "复制排障 ID",
+ "resource.artifacts.copyDebugIdSuccess": "排障 ID 已复制",
+ "resource.artifacts.copySuccess": "已复制",
+ "resource.artifacts.empty": "尚无已发布的 Artifact。在对话中发布 Artifact 后将显示在此处。",
+ "resource.artifacts.error": "加载内容部署失败。",
+ "resource.artifacts.fromTopic": "源自 {{topic}}",
+ "resource.artifacts.history.copySuccess": "版本链接已复制",
+ "resource.artifacts.history.copyUrl": "复制版本链接",
+ "resource.artifacts.history.currentRevision": "当前版本",
+ "resource.artifacts.history.dayLabel.today": "今日",
+ "resource.artifacts.history.dayLabel.yesterday": "昨日",
+ "resource.artifacts.history.empty": "暂无已发布版本。",
+ "resource.artifacts.history.error": "加载版本失败。",
+ "resource.artifacts.history.fromMessage": "来源消息: {{id}}",
+ "resource.artifacts.history.openUrl": "打开此版本",
+ "resource.artifacts.history.preview": "预览",
+ "resource.artifacts.history.previewHint": "选择一个版本以预览。",
+ "resource.artifacts.history.restore": "恢复",
+ "resource.artifacts.history.restoreError": "恢复版本失败",
+ "resource.artifacts.history.restoreSuccess": "已切换至 v{{from}}",
+ "resource.artifacts.history.restoreTo": "恢复至 v{{revision}}",
+ "resource.artifacts.history.revisionCount": "共 {{count}} 版",
+ "resource.artifacts.history.revoked": "已废弃",
+ "resource.artifacts.history.sizeBytes": "{{size}} 字节",
+ "resource.artifacts.history.title": "版本历史",
+ "resource.artifacts.open": "打开",
+ "resource.artifacts.refresh": "刷新",
+ "resource.artifacts.size": "{{size}} 字节",
+ "resource.artifacts.title": "内容部署",
+ "resource.artifacts.unpublish": "取消发布",
+ "resource.artifacts.unpublishConfirm": "确认取消发布?公开链接将失效。",
+ "resource.artifacts.unpublishSuccess": "已取消发布",
"resources.knowledgePicker.publicAgentHint": "公共 Agent 仅可关联工作区资源。要挂载私人内容,请先在资源库中「发布到工作区」。",
"resources.mode.privateHint": "只有您自己能看到的抽屉",
"resources.mode.workspaceHint": "与工作区成员共享",
@@ -1317,6 +1361,39 @@
"workingPanel.browser.tool.screenshot": "截取了页面截图",
"workingPanel.browser.tool.scroll": "滚动了页面",
"workingPanel.browser.tool.snapshot": "读取了页面元素",
+ "workingPanel.deployments.buildFailedFallback": "上次构建失败,上一版本仍在线",
+ "workingPanel.deployments.buildLog.open": "查看构建日志",
+ "workingPanel.deployments.buildStatus.canceled": "已取消",
+ "workingPanel.deployments.buildStatus.failed": "失败",
+ "workingPanel.deployments.buildStatus.finalizing": "收尾中",
+ "workingPanel.deployments.buildStatus.pending": "排队中",
+ "workingPanel.deployments.buildStatus.quota_exceeded": "额度已超限",
+ "workingPanel.deployments.buildStatus.running": "运行中",
+ "workingPanel.deployments.buildStatus.success": "成功",
+ "workingPanel.deployments.buildStatus.timeout": "已超时",
+ "workingPanel.deployments.copy": "复制链接",
+ "workingPanel.deployments.copyDebugId": "复制排障 ID",
+ "workingPanel.deployments.copyDebugIdSuccess": "排障 ID 已复制",
+ "workingPanel.deployments.copySuccess": "部署链接已复制",
+ "workingPanel.deployments.empty": "当前话题暂无部署",
+ "workingPanel.deployments.history": "版本历史",
+ "workingPanel.deployments.noRelease": "暂无已发布版本",
+ "workingPanel.deployments.noTopic": "打开话题以查看部署",
+ "workingPanel.deployments.open": "打开部署",
+ "workingPanel.deployments.refresh": "刷新部署列表",
+ "workingPanel.deployments.retry.failed": "重新发布失败",
+ "workingPanel.deployments.retry.noSource": "本话题中未找到源消息,请回到 chat 中重新发布",
+ "workingPanel.deployments.retry.success": "已重新触发构建",
+ "workingPanel.deployments.retry.title": "重新发布",
+ "workingPanel.deployments.size": "{{size}} 字节",
+ "workingPanel.deployments.status.active": "已上线",
+ "workingPanel.deployments.status.building": "构建中",
+ "workingPanel.deployments.status.failed": "构建失败",
+ "workingPanel.deployments.status.unpublished": "已下线",
+ "workingPanel.deployments.tab": "部署",
+ "workingPanel.deployments.title": "部署",
+ "workingPanel.deployments.unpublish": "取消发布",
+ "workingPanel.deployments.unpublishSuccess": "已取消发布",
"workingPanel.documents.close": "关闭",
"workingPanel.documents.discard": "放弃",
"workingPanel.documents.edit": "编辑",
diff --git a/locales/zh-CN/file.json b/locales/zh-CN/file.json
index 79d331ffce3..f10b33396c2 100644
--- a/locales/zh-CN/file.json
+++ b/locales/zh-CN/file.json
@@ -225,6 +225,7 @@
"searchFilePlaceholder": "搜索文件",
"searchPagePlaceholder": "搜索文稿",
"tab.all": "全部",
+ "tab.artifacts": "内容部署",
"tab.audios": "语音",
"tab.documents": "文档",
"tab.home": "首页",
diff --git a/locales/zh-CN/labs.json b/locales/zh-CN/labs.json
index dc747d98358..ea27807ee7f 100644
--- a/locales/zh-CN/labs.json
+++ b/locales/zh-CN/labs.json
@@ -3,6 +3,8 @@
"features.agentGraphConfig.title": "Agent Graph 运行时配置",
"features.agentSelfIteration.desc": "允许助理自我反思、自我感知,并在持续的尝试与交互中不断自我迭代。",
"features.agentSelfIteration.title": "Agent 自我迭代",
+ "features.artifactDeployment.desc": "将 Artifact 发布为可访问的托管链接,并在会话侧边栏管理发布版本",
+ "features.artifactDeployment.title": "Artifact 部署",
"features.assistantMessageGroup.desc": "将代理消息及其工具调用结果组合在一起显示",
"features.assistantMessageGroup.title": "代理消息分组",
"features.claudeCodeSdk.desc": "通过 Claude Agent SDK 运行 Claude Code 会话,替代 CLI 进程方式,提供更丰富的流式输出与会话控制。",
diff --git a/locales/zh-CN/portal.json b/locales/zh-CN/portal.json
index 16e641906bf..c5ee265e5c4 100644
--- a/locales/zh-CN/portal.json
+++ b/locales/zh-CN/portal.json
@@ -2,6 +2,15 @@
"FilePreview.tabs.chunk": "分块",
"FilePreview.tabs.file": "文件",
"Plugins": "技能",
+ "artifacts.deploy.copy": "复制链接",
+ "artifacts.deploy.copySuccess": "部署链接已复制",
+ "artifacts.deploy.failed": "发布失败",
+ "artifacts.deploy.history": "版本历史",
+ "artifacts.deploy.open": "打开部署",
+ "artifacts.deploy.outdated": "线上为旧版",
+ "artifacts.deploy.publish": "发布",
+ "artifacts.deploy.publishNewVersion": "发布此版本",
+ "artifacts.deploy.success": "已发布",
"artifacts.display.code": "代码",
"artifacts.display.preview": "预览",
"artifacts.svg.copyAsImage": "复制为图片",
diff --git a/package.json b/package.json
index f37284f8b41..ec1b852b863 100644
--- a/package.json
+++ b/package.json
@@ -216,6 +216,7 @@
"@lobechat/agent-runtime": "workspace:*",
"@lobechat/agent-signal": "workspace:*",
"@lobechat/agent-templates": "workspace:*",
+ "@lobechat/artifact-template": "workspace:*",
"@lobechat/builtin-agents": "workspace:*",
"@lobechat/builtin-skills": "workspace:*",
"@lobechat/builtin-tool-activator": "workspace:*",
diff --git a/packages/artifact-template/package.json b/packages/artifact-template/package.json
new file mode 100644
index 00000000000..2c5d20fb8e5
--- /dev/null
+++ b/packages/artifact-template/package.json
@@ -0,0 +1,11 @@
+{
+ "name": "@lobechat/artifact-template",
+ "version": "1.0.0",
+ "private": true,
+ "type": "module",
+ "exports": {
+ ".": "./src/index.ts"
+ },
+ "main": "./src/index.ts",
+ "dependencies": {}
+}
diff --git a/packages/artifact-template/src/index.ts b/packages/artifact-template/src/index.ts
new file mode 100644
index 00000000000..cb4003fb3ad
--- /dev/null
+++ b/packages/artifact-template/src/index.ts
@@ -0,0 +1,215 @@
+// Shared between the Sandpack preview and the publishable-site builder. This
+// package is the single source of truth for React artifact boilerplate,
+// dependencies, and runtime aliases.
+
+export interface ReactArtifactPackageJsonOverride {
+ dependencies?: Record<string, string>;
+ devDependencies?: Record<string, string>;
+}
+
+export interface ReactArtifactTemplateOverrides {
+ appCode?: string;
+ entry?: string;
+ indexHtml?: string;
+ packageJson?: ReactArtifactPackageJsonOverride;
+ viteConfig?: string;
+}
+
+export interface ReactArtifactTemplateOptions {
+ appCode: string;
+ extraFiles?: Record<string, string>;
+ overrides?: ReactArtifactTemplateOverrides;
+ title?: string;
+}
+
+export interface ReactArtifactProject {
+ dependencies: Record<string, string>;
+ devDependencies: Record<string, string>;
+ entry: string;
+ externalResources: readonly string[];
+ files: Record<string, string>;
+}
+
+// The HTML shell loaded by the browser when visiting the deployed site.
+export const REACT_ARTIFACT_ENTRY_PATH = '/index.html';
+// The JS bootstrap module the HTML shell references via <script type="module">.
+export const REACT_ARTIFACT_BOOTSTRAP_PATH = '/index.tsx';
+export const REACT_ARTIFACT_APP_PATH = '/App.tsx';
+export const REACT_ARTIFACT_INDEX_HTML_PATH = '/index.html';
+export const REACT_ARTIFACT_VITE_CONFIG_PATH = '/vite.config.ts';
+export const REACT_ARTIFACT_PACKAGE_JSON_PATH = '/package.json';
+
+export const REACT_ARTIFACT_DEFAULT_DEPENDENCIES: Record<string, string> = {
+ '@ant-design/icons': 'latest',
+ '@lshay/ui': 'latest',
+ '@radix-ui/react-accordion': 'latest',
+ '@radix-ui/react-alert-dialog': 'latest',
+ '@radix-ui/react-avatar': 'latest',
+ '@radix-ui/react-checkbox': 'latest',
+ '@radix-ui/react-collapsible': 'latest',
+ '@radix-ui/react-dialog': 'latest',
+ '@radix-ui/react-dropdown-menu': 'latest',
+ '@radix-ui/react-icons': 'latest',
+ '@radix-ui/react-label': 'latest',
+ '@radix-ui/react-navigation-menu': 'latest',
+ '@radix-ui/react-popover': 'latest',
+ '@radix-ui/react-progress': 'latest',
+ '@radix-ui/react-scroll-area': 'latest',
+ '@radix-ui/react-select': 'latest',
+ '@radix-ui/react-separator': 'latest',
+ '@radix-ui/react-slider': 'latest',
+ '@radix-ui/react-slot': 'latest',
+ '@radix-ui/react-switch': 'latest',
+ '@radix-ui/react-tabs': 'latest',
+ '@radix-ui/react-toast': 'latest',
+ '@radix-ui/react-tooltip': 'latest',
+ 'antd': 'latest',
+ 'class-variance-authority': 'latest',
+ 'cmdk': 'latest',
+ 'clsx': 'latest',
+ 'date-fns': 'latest',
+ 'embla-carousel-react': 'latest',
+ 'input-otp': 'latest',
+ 'lodash-es': 'latest',
+ // Pin to 0.x. lucide-react 1.x renamed/dropped several icons (notably
+ // `Github` and `Twitter`), but most LLM training data still emits the 0.x
+ // names. Until model knowledge catches up, prefer the stable 0.x line.
+ 'lucide-react': '^0.544.0',
+ 'motion': 'latest',
+ 'react': '19.2.7',
+ 'react-day-picker': 'latest',
+ 'react-dom': '19.2.7',
+ 'react-router': 'latest',
+ 'recharts': 'latest',
+ 'sonner': 'latest',
+ 'tailwind-merge': 'latest',
+ 'vaul': 'latest',
+ 'zustand': 'latest',
+};
+
+export const REACT_ARTIFACT_DEFAULT_DEV_DEPENDENCIES: Record<string, string> = {
+ '@types/react': 'latest',
+ '@types/react-dom': 'latest',
+ '@vitejs/plugin-react': 'latest',
+ 'typescript': 'latest',
+ 'vite': 'latest',
+};
+
+export const REACT_ARTIFACT_TAILWIND_CDN = 'https://cdn.tailwindcss.com';
+export const REACT_ARTIFACT_EXTERNAL_RESOURCES: readonly string[] = [REACT_ARTIFACT_TAILWIND_CDN];
+
+export const REACT_ARTIFACT_VITE_ALIASES: Record<string, string> = {
+ '@/components/ui': '@lshay/ui/components/default',
+};
+
+const escapeHtml = (value: string) =>
+ value.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
+
+const defaultIndexHtml = (title: string) => `<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>${escapeHtml(title)}</title>
+ <script src="${REACT_ARTIFACT_TAILWIND_CDN}"></script>
+ </head>
+ <body>
+ <div id="root"></div>
+ <script type="module" src="/index.tsx"></script>
+ </body>
+</html>
+`;
+
+const defaultEntry = `import { StrictMode } from 'react';
+import { createRoot } from 'react-dom/client';
+
+import App from './App';
+
+const container = document.getElementById('root');
+if (!container) throw new Error('Root container #root not found');
+
+createRoot(container).render(
+ <StrictMode>
+ <App />
+ </StrictMode>,
+);
+`;
+
+const defaultViteConfig = `import react from '@vitejs/plugin-react';
+import { defineConfig } from 'vite';
+
+export default defineConfig({
+ base: './',
+ plugins: [react()],
+ resolve: {
+ alias: ${JSON.stringify(REACT_ARTIFACT_VITE_ALIASES, null, 6)},
+ },
+});
+`;
+
+const defaultPackageJson = (
+ title: string,
+ dependencies: Record<string, string>,
+ devDependencies: Record<string, string>,
+) =>
+ `${JSON.stringify(
+ {
+ name: 'lobe-artifact-react-app',
+ private: true,
+ version: '0.0.0',
+ type: 'module',
+ scripts: {
+ build: 'vite build',
+ dev: 'vite',
+ preview: 'vite preview',
+ },
+ description: title,
+ dependencies,
+ devDependencies,
+ },
+ null,
+ 2,
+ )}\n`;
+
+export const buildReactArtifactProject = (
+ options: ReactArtifactTemplateOptions,
+): ReactArtifactProject => {
+ const { appCode, extraFiles, overrides, title } = options;
+ const resolvedTitle = title ?? 'Artifacts App';
+
+ const dependencies = {
+ ...REACT_ARTIFACT_DEFAULT_DEPENDENCIES,
+ ...overrides?.packageJson?.dependencies,
+ };
+ const devDependencies = {
+ ...REACT_ARTIFACT_DEFAULT_DEV_DEPENDENCIES,
+ ...overrides?.packageJson?.devDependencies,
+ };
+
+ const files: Record<string, string> = {
+ [REACT_ARTIFACT_APP_PATH]: overrides?.appCode ?? appCode,
+ [REACT_ARTIFACT_BOOTSTRAP_PATH]: overrides?.entry ?? defaultEntry,
+ [REACT_ARTIFACT_INDEX_HTML_PATH]: overrides?.indexHtml ?? defaultIndexHtml(resolvedTitle),
+ [REACT_ARTIFACT_PACKAGE_JSON_PATH]: defaultPackageJson(
+ resolvedTitle,
+ dependencies,
+ devDependencies,
+ ),
+ [REACT_ARTIFACT_VITE_CONFIG_PATH]: overrides?.viteConfig ?? defaultViteConfig,
+ };
+
+ if (extraFiles) {
+ for (const [path, content] of Object.entries(extraFiles)) {
+ const normalized = path.startsWith('/') ? path : `/${path}`;
+ files[normalized] = content;
+ }
+ }
+
+ return {
+ dependencies,
+ devDependencies,
+ entry: REACT_ARTIFACT_ENTRY_PATH,
+ externalResources: REACT_ARTIFACT_EXTERNAL_RESOURCES,
+ files,
+ };
+};
diff --git a/packages/builtin-skills/package.json b/packages/builtin-skills/package.json
index 1c379d20168..e67e298efe4 100644
--- a/packages/builtin-skills/package.json
+++ b/packages/builtin-skills/package.json
@@ -7,7 +7,9 @@
".": "./src/index.ts"
},
"main": "./src/index.ts",
- "dependencies": {},
+ "dependencies": {
+ "@lobechat/artifact-template": "workspace:*"
+ },
"devDependencies": {
"@lobechat/types": "workspace:*"
}
diff --git a/packages/builtin-skills/src/index.ts b/packages/builtin-skills/src/index.ts
index 6931098f1dd..3feb085ea18 100644
--- a/packages/builtin-skills/src/index.ts
+++ b/packages/builtin-skills/src/index.ts
@@ -7,6 +7,23 @@ import { TaskSkill } from './task';
export { AgentBrowserIdentifier } from './agent-browser';
export { ArtifactsIdentifier } from './artifacts';
+export {
+ buildReactArtifactProject,
+ REACT_ARTIFACT_APP_PATH,
+ REACT_ARTIFACT_BOOTSTRAP_PATH,
+ REACT_ARTIFACT_DEFAULT_DEPENDENCIES,
+ REACT_ARTIFACT_DEFAULT_DEV_DEPENDENCIES,
+ REACT_ARTIFACT_ENTRY_PATH,
+ REACT_ARTIFACT_EXTERNAL_RESOURCES,
+ REACT_ARTIFACT_INDEX_HTML_PATH,
+ REACT_ARTIFACT_PACKAGE_JSON_PATH,
+ REACT_ARTIFACT_TAILWIND_CDN,
+ REACT_ARTIFACT_VITE_ALIASES,
+ REACT_ARTIFACT_VITE_CONFIG_PATH,
+ type ReactArtifactProject,
+ type ReactArtifactTemplateOptions,
+ type ReactArtifactTemplateOverrides,
+} from '@lobechat/artifact-template';
export { LobeHubIdentifier } from './lobehub';
export { TaskIdentifier } from './task';
diff --git a/packages/business-server/src/lambda-routers/marketDeployments.ts b/packages/business-server/src/lambda-routers/marketDeployments.ts
new file mode 100644
index 00000000000..01befb448b2
--- /dev/null
+++ b/packages/business-server/src/lambda-routers/marketDeployments.ts
@@ -0,0 +1,3 @@
+import { router } from '@/libs/trpc/lambda';
+
+export const marketDeploymentsRouter = router({});
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index a47e195a9c7..e21cd566665 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -103,6 +103,88 @@ export default {
'desktopNotification.aiReplyCompleted.title': 'Reply completed',
'desktopNotification.humanApprovalRequired.body': 'An Agent needs your approval to continue',
'desktopNotification.humanApprovalRequired.title': 'Approval required',
+ 'workingPanel.deployments.copy': 'Copy URL',
+ 'workingPanel.deployments.copyDebugId': 'Copy debug ID',
+ 'workingPanel.deployments.copyDebugIdSuccess': 'Debug ID copied',
+ 'workingPanel.deployments.copySuccess': 'Deployment URL copied',
+ 'workingPanel.deployments.empty': 'No deployments in this topic',
+ 'workingPanel.deployments.history': 'Revision history',
+ 'workingPanel.deployments.noRelease': 'No published release',
+ 'workingPanel.deployments.noTopic': 'Open a topic to view deployments',
+ 'workingPanel.deployments.open': 'Open deployment',
+ 'workingPanel.deployments.refresh': 'Refresh deployments',
+ 'workingPanel.deployments.size': '{{size}} bytes',
+ 'workingPanel.deployments.buildLog.open': 'View build logs',
+ 'workingPanel.deployments.buildFailedFallback':
+ 'Last build failed; the previous release is still serving.',
+ 'workingPanel.deployments.buildStatus.canceled': 'Canceled',
+ 'workingPanel.deployments.buildStatus.failed': 'Failed',
+ 'workingPanel.deployments.buildStatus.finalizing': 'Finalizing',
+ 'workingPanel.deployments.buildStatus.pending': 'Pending',
+ 'workingPanel.deployments.buildStatus.quota_exceeded': 'Quota exceeded',
+ 'workingPanel.deployments.buildStatus.running': 'Running',
+ 'workingPanel.deployments.buildStatus.success': 'Succeeded',
+ 'workingPanel.deployments.buildStatus.timeout': 'Timed out',
+ 'workingPanel.deployments.retry.failed': 'Retry failed',
+ 'workingPanel.deployments.retry.noSource':
+ 'Source message not found in this topic — re-publish from the artifact card in chat instead.',
+ 'workingPanel.deployments.retry.success': 'Build re-triggered',
+ 'workingPanel.deployments.retry.title': 'Retry build',
+ 'workingPanel.deployments.status.active': 'Active',
+ 'workingPanel.deployments.status.building': 'Building',
+ 'workingPanel.deployments.status.failed': 'Build failed',
+ 'workingPanel.deployments.status.unpublished': 'Unpublished',
+ 'workingPanel.deployments.tab': 'Deployments',
+ 'workingPanel.deployments.title': 'Deployments',
+ 'workingPanel.deployments.unpublish': 'Unpublish',
+ 'workingPanel.deployments.unpublishSuccess': 'Deployment unpublished',
+ 'resource.artifacts.copy': 'Copy URL',
+ 'resource.artifacts.copyDebugId': 'Copy debug ID',
+ 'resource.artifacts.copyDebugIdSuccess': 'Debug ID copied',
+ 'resource.artifacts.copySuccess': 'URL copied',
+ 'resource.artifacts.buildLog.copy': 'Copy logs',
+ 'resource.artifacts.buildLog.copySuccess': 'Build logs copied',
+ 'resource.artifacts.buildLog.empty':
+ 'No build logs have been received yet. Refresh after the builder callback returns.',
+ 'resource.artifacts.buildLog.endedAt': 'Ended at',
+ 'resource.artifacts.buildLog.errorCode': 'Error code',
+ 'resource.artifacts.buildLog.errorMessage': 'Error message',
+ 'resource.artifacts.buildLog.job': 'Job',
+ 'resource.artifacts.buildLog.open': 'View build logs',
+ 'resource.artifacts.buildLog.startedAt': 'Started at',
+ 'resource.artifacts.buildLog.status': 'Status',
+ 'resource.artifacts.buildLog.title': 'Build logs',
+ 'resource.artifacts.empty':
+ 'No published artifacts yet. Publish an Artifact from the chat to see it here.',
+ 'resource.artifacts.error': 'Failed to load artifacts.',
+ 'resource.artifacts.fromTopic': 'from {{topic}}',
+ 'resource.artifacts.open': 'Open',
+ 'resource.artifacts.refresh': 'Refresh',
+ 'resource.artifacts.size': '{{size}} bytes',
+ 'resource.artifacts.title': 'Artifacts',
+ 'resource.artifacts.unpublish': 'Unpublish',
+ 'resource.artifacts.unpublishConfirm':
+ 'Unpublish this artifact? The public URL will stop working.',
+ 'resource.artifacts.unpublishSuccess': 'Artifact unpublished',
+ 'resource.artifacts.history.title': 'Revision history',
+ 'resource.artifacts.history.empty': 'No published revisions yet.',
+ 'resource.artifacts.history.error': 'Failed to load revisions.',
+ 'resource.artifacts.history.currentRevision': 'Current',
+ 'resource.artifacts.history.restore': 'Restore',
+ 'resource.artifacts.history.copySuccess': 'Revision URL copied',
+ 'resource.artifacts.history.copyUrl': 'Copy revision URL',
+ 'resource.artifacts.history.openUrl': 'Open revision',
+ 'resource.artifacts.history.restoreSuccess': 'Switched to v{{from}}',
+ 'resource.artifacts.history.restoreError': 'Failed to restore revision',
+ 'resource.artifacts.history.revoked': 'Revoked',
+ 'resource.artifacts.history.preview': 'Preview',
+ 'resource.artifacts.history.previewHint': 'Select a revision to preview.',
+ 'resource.artifacts.history.fromMessage': 'From message: {{id}}',
+ 'resource.artifacts.history.sizeBytes': '{{size}} bytes',
+ 'resource.artifacts.history.revisionCount': '{{count}} revisions',
+ 'resource.artifacts.history.restoreTo': 'Restore to v{{revision}}',
+ 'resource.artifacts.history.dayLabel.today': 'Today',
+ 'resource.artifacts.history.dayLabel.yesterday': 'Yesterday',
'dm.placeholder': 'Your private messages with {{agentTitle}} will appear here.',
'dm.tooltip': 'Send a private message',
'dm.visibleTo': 'Visible to {{target}} only',
diff --git a/packages/locales/src/default/file.ts b/packages/locales/src/default/file.ts
index f742a15e4bb..e03b2d9926d 100644
--- a/packages/locales/src/default/file.ts
+++ b/packages/locales/src/default/file.ts
@@ -258,6 +258,7 @@ export default {
'searchFilePlaceholder': 'Search Files',
'searchPagePlaceholder': 'Search Pages',
'tab.all': 'All',
+ 'tab.artifacts': 'Artifacts',
'tab.audios': 'Audio',
'tab.documents': 'Documents',
'tab.home': 'Home',
diff --git a/packages/locales/src/default/labs.ts b/packages/locales/src/default/labs.ts
index 98c69b83d58..b431298eb1a 100644
--- a/packages/locales/src/default/labs.ts
+++ b/packages/locales/src/default/labs.ts
@@ -5,6 +5,9 @@ export default {
'features.agentSelfIteration.desc':
'Allow the agent to reflect, build self-awareness, and continuously iterate through ongoing attempts and interactions.',
'features.agentSelfIteration.title': 'Agent Self-iteration',
+ 'features.artifactDeployment.desc':
+ 'Publish artifacts to a hosted URL and manage releases from the conversation sidebar',
+ 'features.artifactDeployment.title': 'Artifact Deployments',
'features.assistantMessageGroup.desc':
'Group agent messages and their tool call results together for display',
'features.assistantMessageGroup.title': 'Agent Message Grouping',
diff --git a/packages/locales/src/default/portal.ts b/packages/locales/src/default/portal.ts
index 5d15db1c641..77c5a4408a6 100644
--- a/packages/locales/src/default/portal.ts
+++ b/packages/locales/src/default/portal.ts
@@ -4,6 +4,15 @@ export default {
'Plugins': 'Skills',
'artifacts.display.code': 'Code',
'artifacts.display.preview': 'Preview',
+ 'artifacts.deploy.copy': 'Copy URL',
+ 'artifacts.deploy.copySuccess': 'Deployment URL copied',
+ 'artifacts.deploy.failed': 'Deployment failed',
+ 'artifacts.deploy.history': 'Revision history',
+ 'artifacts.deploy.open': 'Open deployment',
+ 'artifacts.deploy.outdated': 'Older version live',
+ 'artifacts.deploy.publish': 'Publish',
+ 'artifacts.deploy.publishNewVersion': 'Publish this version',
+ 'artifacts.deploy.success': 'Published',
'artifacts.svg.copyAsImage': 'Copy as Image',
'artifacts.svg.copyFail': 'Copy failed: {{error}}. Try again.',
'artifacts.svg.copySuccess': 'Image copied successfully',
diff --git a/packages/types/src/user/preference.ts b/packages/types/src/user/preference.ts
index bbd0a60dbdf..343b00de313 100644
--- a/packages/types/src/user/preference.ts
+++ b/packages/types/src/user/preference.ts
@@ -87,6 +87,10 @@ export const UserLabSchema = z.object({
* enable agent self-iteration feedback capture and policy execution
*/
enableAgentSelfIteration: z.boolean().optional(),
+ /**
+ * enable artifact deployment features (publish artifacts to a hosted URL)
+ */
+ enableArtifactDeployment: z.boolean().optional(),
/**
* run Claude Code hetero sessions through the Claude Agent SDK instead of CLI spawn
*/
diff --git a/src/business/client/BusinessDesktopRoutes.tsx b/src/business/client/BusinessDesktopRoutes.tsx
index 763c0214c2f..1db3cdecdfd 100644
--- a/src/business/client/BusinessDesktopRoutes.tsx
+++ b/src/business/client/BusinessDesktopRoutes.tsx
@@ -3,3 +3,4 @@ import { type RouteObject } from 'react-router';
export const BusinessDesktopRoutesWithMainLayout: RouteObject[] = [];
export const BusinessDesktopRoutesWithSettingsLayout: RouteObject[] = [];
export const BusinessDesktopRoutesWithoutMainLayout: RouteObject[] = [];
+export const BusinessResourceRoutes: RouteObject[] = [];
diff --git a/src/business/client/features/ArtifactDeploymentActions.tsx b/src/business/client/features/ArtifactDeploymentActions.tsx
new file mode 100644
index 00000000000..d382ef42def
--- /dev/null
+++ b/src/business/client/features/ArtifactDeploymentActions.tsx
@@ -0,0 +1,13 @@
+export interface ArtifactDeploymentActionsProps {
+ artifactIdentifier?: string;
+ artifactTitle?: string;
+ artifactType?: string;
+ displayMode?: string;
+ isArtifactTagClosed: boolean;
+ messageId?: string;
+ topicId?: string;
+}
+
+export default function ArtifactDeploymentActions(_props: ArtifactDeploymentActionsProps) {
+ return null;
+}
diff --git a/src/business/client/features/ResourceCategories.tsx b/src/business/client/features/ResourceCategories.tsx
new file mode 100644
index 00000000000..c9eb6577532
--- /dev/null
+++ b/src/business/client/features/ResourceCategories.tsx
@@ -0,0 +1,12 @@
+import type { LucideIcon } from 'lucide-react';
+
+export interface BusinessResourceCategory {
+ icon: LucideIcon;
+ key: string;
+ titleKey: string;
+ url: string;
+}
+
+export function useBusinessResourceCategories(): BusinessResourceCategory[] {
+ return [];
+}
diff --git a/src/business/client/features/WorkingSidebarTabs.tsx b/src/business/client/features/WorkingSidebarTabs.tsx
new file mode 100644
index 00000000000..12f4de26fde
--- /dev/null
+++ b/src/business/client/features/WorkingSidebarTabs.tsx
@@ -0,0 +1,18 @@
+import type { ReactNode } from 'react';
+
+export interface BusinessWorkingSidebarTab {
+ key: string;
+ label: ReactNode;
+ pane: ReactNode;
+}
+
+export interface BusinessWorkingSidebarTabsContext {
+ activeAgentId?: string;
+ topicId?: string;
+}
+
+export function useBusinessWorkingSidebarTabs(
+ _context: BusinessWorkingSidebarTabsContext,
+): BusinessWorkingSidebarTab[] {
+ return [];
+}
diff --git a/src/business/client/features/__tests__/ResourceCategories.test.tsx b/src/business/client/features/__tests__/ResourceCategories.test.tsx
new file mode 100644
index 00000000000..d29f66d6f68
--- /dev/null
+++ b/src/business/client/features/__tests__/ResourceCategories.test.tsx
@@ -0,0 +1,11 @@
+import { renderHook } from '@testing-library/react';
+import { describe, expect, it } from 'vitest';
+
+import { useBusinessResourceCategories } from '../ResourceCategories';
+
+describe('useBusinessResourceCategories (OSS stub)', () => {
+ it('returns an empty array', () => {
+ const { result } = renderHook(() => useBusinessResourceCategories());
+ expect(result.current).toEqual([]);
+ });
+});
diff --git a/src/features/Conversation/Markdown/plugins/LobeArtifact/Render/index.tsx b/src/features/Conversation/Markdown/plugins/LobeArtifact/Render/index.tsx
index ed16f16c05e..00903054da3 100644
--- a/src/features/Conversation/Markdown/plugins/LobeArtifact/Render/index.tsx
+++ b/src/features/Conversation/Markdown/plugins/LobeArtifact/Render/index.tsx
@@ -112,7 +112,7 @@ const Render = memo<ArtifactProps>(({ identifier, title, type, language, childre
)}
{hasChildren && (
<Flexbox horizontal className={styles.desc}>
- {identifier} ·{' '}
+ {identifier} ·&nbsp;
<Flexbox horizontal gap={2}>
{!isArtifactTagClosed && (
<div>
diff --git a/src/features/Portal/Artifacts/Body/Renderer/React/index.tsx b/src/features/Portal/Artifacts/Body/Renderer/React/index.tsx
index 029547ae311..b6a99a6c032 100644
--- a/src/features/Portal/Artifacts/Body/Renderer/React/index.tsx
+++ b/src/features/Portal/Artifacts/Body/Renderer/React/index.tsx
@@ -1,11 +1,10 @@
import { SandpackLayout, SandpackPreview, SandpackProvider } from '@codesandbox/sandpack-react';
+import { buildReactArtifactProject } from '@lobechat/artifact-template';
import { memo } from 'react';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
-import { createTemplateFiles } from './template';
-
interface ReactRendererProps {
code: string;
}
@@ -13,33 +12,18 @@ interface ReactRendererProps {
const ReactRenderer = memo<ReactRendererProps>(({ code }) => {
const title = useChatStore(chatPortalSelectors.artifactTitle);
+ const project = buildReactArtifactProject({ appCode: code, title });
+
return (
<SandpackProvider
+ customSetup={{ dependencies: project.dependencies }}
+ files={project.files}
style={{ height: '100%' }}
template="vite-react-ts"
theme="auto"
- customSetup={{
- dependencies: {
- '@ant-design/icons': 'latest',
- '@lshay/ui': 'latest',
- '@radix-ui/react-alert-dialog': 'latest',
- '@radix-ui/react-dialog': 'latest',
- '@radix-ui/react-icons': 'latest',
- 'antd': 'latest',
- 'class-variance-authority': 'latest',
- 'clsx': 'latest',
- 'lucide-react': 'latest',
- 'recharts': 'latest',
- 'tailwind-merge': 'latest',
- },
- }}
- files={{
- 'App.tsx': code,
- ...createTemplateFiles({ title }),
- }}
options={{
- externalResources: ['https://cdn.tailwindcss.com'],
- visibleFiles: ['App.tsx'],
+ externalResources: [...project.externalResources],
+ visibleFiles: ['/App.tsx'],
}}
>
<SandpackLayout style={{ height: '100%' }}>
diff --git a/src/features/Portal/Artifacts/Body/Renderer/React/template.ts b/src/features/Portal/Artifacts/Body/Renderer/React/template.ts
deleted file mode 100644
index 6aef8c74dbc..00000000000
--- a/src/features/Portal/Artifacts/Body/Renderer/React/template.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-interface TemplateFilesParams {
- title?: string;
-}
-export const createTemplateFiles = ({ title }: TemplateFilesParams = {}) => ({
- 'index.html': `<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>${title || 'Artifacts App'}</title>
- <script src="https://cdn.tailwindcss.com"></script>
-</head>
- <body>
- <div id="root"></div>
- <script type="module" src="/index.tsx"></script>
- </body>
-</html>
-`,
- 'vite.config.ts': {
- code: `import { defineConfig } from 'vite';
-import react from '@vitejs/plugin-react';
-
-export default defineConfig({
- plugins: [react()],
- resolve: {
- alias: {
- '@/components/ui': '@lshay/ui/components/default',
- },
- },
-});`,
- },
-});
diff --git a/src/features/Portal/Artifacts/Title.tsx b/src/features/Portal/Artifacts/Title.tsx
index 2456f84e3bf..f99e4583f07 100644
--- a/src/features/Portal/Artifacts/Title.tsx
+++ b/src/features/Portal/Artifacts/Title.tsx
@@ -6,6 +6,7 @@ import { cx } from 'antd-style';
import { ArrowLeft, CodeIcon, EyeIcon } from 'lucide-react';
import { useTranslation } from 'react-i18next';
+import ArtifactDeploymentActions from '@/business/client/features/ArtifactDeploymentActions';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
import { ArtifactDisplayMode } from '@/store/chat/slices/portal/initialState';
@@ -14,19 +15,30 @@ import { oneLineEllipsis } from '@/styles';
const Title = () => {
const { t } = useTranslation('portal');
- const [displayMode, artifactType, artifactTitle, isArtifactTagClosed, closeArtifact] =
- useChatStore((s) => {
- const messageId = chatPortalSelectors.artifactMessageId(s) || '';
- const identifier = chatPortalSelectors.artifactIdentifier(s);
+ const [
+ messageId,
+ artifactIdentifier,
+ topicId,
+ displayMode,
+ artifactType,
+ artifactTitle,
+ isArtifactTagClosed,
+ closeArtifact,
+ ] = useChatStore((s) => {
+ const messageId = chatPortalSelectors.artifactMessageId(s) || '';
+ const identifier = chatPortalSelectors.artifactIdentifier(s);
- return [
- s.portalArtifactDisplayMode,
- chatPortalSelectors.artifactType(s),
- chatPortalSelectors.artifactTitle(s),
- chatPortalSelectors.isArtifactTagClosed(messageId, identifier)(s),
- s.closeArtifact,
- ];
- });
+ return [
+ messageId,
+ identifier,
+ s.activeTopicId,
+ s.portalArtifactDisplayMode,
+ chatPortalSelectors.artifactType(s),
+ chatPortalSelectors.artifactTitle(s),
+ chatPortalSelectors.isArtifactTagClosed(messageId, identifier)(s),
+ s.closeArtifact,
+ ];
+ });
// show switch only when artifact is closed and the type is not code
const showSwitch = isArtifactTagClosed && artifactType !== ArtifactType.Code;
@@ -48,27 +60,38 @@ const Title = () => {
},
}}
>
- {showSwitch && (
- <Tabs
- activeKey={displayMode}
- size={'small'}
- items={[
- {
- icon: <Icon icon={EyeIcon} />,
- key: ArtifactDisplayMode.Preview,
- label: t('artifacts.display.preview'),
- },
- {
- icon: <Icon icon={CodeIcon} />,
- key: ArtifactDisplayMode.Code,
- label: t('artifacts.display.code'),
- },
- ]}
- onChange={(key) => {
- useChatStore.setState({ portalArtifactDisplayMode: key as ArtifactDisplayMode });
- }}
+ <Flexbox horizontal align={'center'} gap={4}>
+ <ArtifactDeploymentActions
+ artifactIdentifier={artifactIdentifier}
+ artifactTitle={artifactTitle}
+ artifactType={artifactType}
+ displayMode={displayMode}
+ isArtifactTagClosed={isArtifactTagClosed}
+ messageId={messageId}
+ topicId={topicId}
/>
- )}
+ {showSwitch && (
+ <Tabs
+ activeKey={displayMode}
+ size={'small'}
+ items={[
+ {
+ icon: <Icon icon={EyeIcon} />,
+ key: ArtifactDisplayMode.Preview,
+ label: t('artifacts.display.preview'),
+ },
+ {
+ icon: <Icon icon={CodeIcon} />,
+ key: ArtifactDisplayMode.Code,
+ label: t('artifacts.display.code'),
+ },
+ ]}
+ onChange={(key) => {
+ useChatStore.setState({ portalArtifactDisplayMode: key as ArtifactDisplayMode });
+ }}
+ />
+ )}
+ </Flexbox>
</ConfigProvider>
</Flexbox>
);
diff --git a/src/features/Portal/components/Header.tsx b/src/features/Portal/components/Header.tsx
index c421fe5aca7..ce7d13c9471 100644
--- a/src/features/Portal/components/Header.tsx
+++ b/src/features/Portal/components/Header.tsx
@@ -33,9 +33,9 @@ const Header = memo<{ rightExtra?: ReactNode; title: ReactNode }>(({ title, righ
return (
<NavHeader
showTogglePanelButton={false}
- style={{ paddingBlock: 8, paddingInline: 8 }}
+ style={{ paddingBlock: 8, paddingInline: 8, width: '100%' }}
left={
- <Flexbox horizontal align="center" gap={4}>
+ <Flexbox horizontal align="center" flex={1} gap={4} style={{ minWidth: 0 }}>
{canGoBack && (
<ActionIcon icon={ArrowLeft} size={DESKTOP_HEADER_ICON_SMALL_SIZE} onClick={goBack} />
)}
@@ -61,7 +61,12 @@ const Header = memo<{ rightExtra?: ReactNode; title: ReactNode }>(({ title, righ
}
styles={{
left: {
+ flex: 1,
marginLeft: canGoBack ? 0 : 6,
+ minWidth: 0,
+ },
+ right: {
+ flex: 'none',
},
}}
/>
diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/__tests__/index.test.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/__tests__/index.test.tsx
index 451023c4aa2..b334e98205a 100644
--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/__tests__/index.test.tsx
+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/__tests__/index.test.tsx
@@ -83,6 +83,11 @@ vi.mock('@/store/global/selectors', () => ({
},
}));
vi.mock('@/store/electron', () => ({ useElectronStore: () => undefined }));
+vi.mock('@/store/chat', () => ({ useChatStore: () => undefined }));
+
+vi.mock('@/business/client/features/WorkingSidebarTabs', () => ({
+ useBusinessWorkingSidebarTabs: () => [],
+}));
vi.mock('@/features/ChatInput/ControlBar/useRepoType', () => ({
useRepoType: () => reviewState.repoType,
diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.tsx
index 532a8bbf935..5b19a46e263 100644
--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.tsx
+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.tsx
@@ -4,6 +4,7 @@ import { PanelRightCloseIcon } from 'lucide-react';
import { lazy, memo, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { useBusinessWorkingSidebarTabs } from '@/business/client/features/WorkingSidebarTabs';
import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import { isDesktop } from '@/const/version';
import { useRepoType } from '@/features/ChatInput/ControlBar/useRepoType';
@@ -19,6 +20,7 @@ import {
agentSelectors,
chatConfigByIdSelectors,
} from '@/store/agent/selectors';
+import { useChatStore } from '@/store/chat';
import { useElectronStore } from '@/store/electron';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
@@ -82,8 +84,6 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
`,
}));
-type Tab = 'browser' | 'files' | 'params' | 'review' | 'resources';
-
const REVIEW_TREE_STORAGE_KEY = 'lobechat-review-tree';
const MAX_PANEL_WIDTH = 1200;
// Two-pane Review (diff list + file-tree rail) is cramped below this.
@@ -104,6 +104,7 @@ const AgentWorkingSidebar = memo(() => {
s.status.workingSidebarTab,
]);
const activeAgentId = useAgentStore((s) => s.activeAgentId);
+ const topicId = useChatStore((s) => s.activeTopicId);
const isLocalSystemEnabled = useAgentStore((s) =>
activeAgentId ? chatConfigByIdSelectors.isLocalSystemEnabledById(activeAgentId)(s) : false,
);
@@ -156,18 +157,33 @@ const AgentWorkingSidebar = memo(() => {
const enableInAppBrowser = useUserStore(labPreferSelectors.enableInAppBrowser);
const browserAvailable = isDesktop && enableInAppBrowser;
const browserSessionId = `agent:${activeAgentId ?? 'default'}`;
- const resolveActiveTab = (): Tab => {
- if (storedTab === 'params' && paramsAvailable) return 'params';
- if (storedTab === 'review' && reviewAvailable) return 'review';
- if (storedTab === 'files' && filesAvailable) return 'files';
- if (storedTab === 'browser' && browserAvailable) return 'browser';
- if (storedTab === 'resources') return 'resources';
+
+ const businessTabs = useBusinessWorkingSidebarTabs({ activeAgentId, topicId });
+
+ const availableTabs = new Set<string>([
+ 'resources',
+ ...(reviewAvailable ? ['review'] : []),
+ ...(filesAvailable ? ['files'] : []),
+ ...(browserAvailable ? ['browser'] : []),
+ ...(paramsAvailable ? ['params'] : []),
+ ...businessTabs.map((tab) => tab.key),
+ ]);
+
+ const resolveActiveTab = (): string => {
+ if (storedTab && availableTabs.has(storedTab)) return storedTab;
+ // a persisted tab may reference a business tab that is absent in this build
+ if (storedTab) {
+ if (paramsAvailable) return 'params';
+ if (reviewAvailable) return 'review';
+ if (filesAvailable) return 'files';
+ return 'resources';
+ }
if (isHetero) return 'resources';
if (reviewAvailable) return 'review';
if (filesAvailable) return 'files';
return 'resources';
};
- const activeTab: Tab = resolveActiveTab();
+ const activeTab = resolveActiveTab();
// Review's tree-nav rail lives here (not inside Review) so the panel can widen
// when the two-pane layout is on. Hidden by default — the panel shows only the
@@ -212,6 +228,16 @@ const AgentWorkingSidebar = memo(() => {
paddingInline={4}
>
<div className={styles.tabs}>
+ {businessTabs.map((tab) => (
+ <button
+ className={`${styles.tab} ${activeTab === tab.key ? styles.tabActive : ''}`}
+ key={tab.key}
+ type="button"
+ onClick={() => setWorkingSidebarTab(tab.key)}
+ >
+ {tab.label}
+ </button>
+ ))}
<button
className={`${styles.tab} ${activeTab === 'resources' ? styles.tabActive : ''}`}
type="button"
@@ -292,6 +318,14 @@ const AgentWorkingSidebar = memo(() => {
<BrowserPane key={browserSessionId} sessionId={browserSessionId} />
</Flexbox>
)}
+ {businessTabs.map((tab) => (
+ <Flexbox
+ className={activeTab === tab.key ? styles.pane : styles.paneHidden}
+ key={tab.key}
+ >
+ {tab.pane}
+ </Flexbox>
+ ))}
<Flexbox
className={activeTab === 'resources' ? styles.pane : styles.paneHidden}
gap={8}
diff --git a/src/routes/(main)/resource/(home)/_layout/Header/CategoryMenu.tsx b/src/routes/(main)/resource/(home)/_layout/Header/CategoryMenu.tsx
index 50038ccd4bc..283d7e90225 100644
--- a/src/routes/(main)/resource/(home)/_layout/Header/CategoryMenu.tsx
+++ b/src/routes/(main)/resource/(home)/_layout/Header/CategoryMenu.tsx
@@ -4,8 +4,9 @@ import { Flexbox } from '@lobehub/ui';
import { FileText, ImageIcon, LayoutPanelTopIcon, Mic2, SquarePlay } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
-import { Link } from 'react-router';
+import { Link, useLocation } from 'react-router';
+import { useBusinessResourceCategories } from '@/business/client/features/ResourceCategories';
import NavItem from '@/features/NavPanel/components/NavItem';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { FilesTabs } from '@/types/files';
@@ -16,6 +17,8 @@ const CategoryMenu = memo(() => {
const { t } = useTranslation('file');
const [activeKey, setMode] = useResourceManagerStore((s) => [s.category, s.setMode]);
const navigate = useWorkspaceAwareNavigate();
+ const businessCategories = useBusinessResourceCategories();
+ const location = useLocation();
const items = useMemo(
() => [
@@ -49,25 +52,37 @@ const CategoryMenu = memo(() => {
title: t('tab.videos'),
url: '/resource?category=videos',
},
+ ...businessCategories.map((category) => ({
+ icon: category.icon,
+ key: category.key,
+ // Business categories carry a chat-namespace key but the type narrows to a
+ // string at this seam; cast so t() accepts the dynamic key.
+ title: t(category.titleKey as never) as string,
+ url: category.url,
+ })),
],
- [t],
+ [t, businessCategories],
);
return (
<Flexbox gap={1} paddingInline={4}>
- {items.map((item) => (
- <Link
- key={item.key}
- to={item.url}
- onClick={(e) => {
- e.preventDefault();
- setMode('explorer');
- navigate(item.url, { replace: true });
- }}
- >
- <NavItem active={activeKey === item.key} icon={item.icon} title={item.title} />
- </Link>
- ))}
+ {items.map((item) => {
+ const isBusinessRoute = item.url.startsWith('/resource/');
+ const isActive = isBusinessRoute ? location.pathname === item.url : activeKey === item.key;
+ return (
+ <Link
+ key={item.key}
+ to={item.url}
+ onClick={(e) => {
+ e.preventDefault();
+ setMode('explorer');
+ navigate(item.url, { replace: true });
+ }}
+ >
+ <NavItem active={isActive} icon={item.icon} title={item.title} />
+ </Link>
+ );
+ })}
</Flexbox>
);
});
diff --git a/src/routes/(main)/settings/advanced/index.tsx b/src/routes/(main)/settings/advanced/index.tsx
index 694bb75798b..df4598fd428 100644
--- a/src/routes/(main)/settings/advanced/index.tsx
+++ b/src/routes/(main)/settings/advanced/index.tsx
@@ -58,6 +58,7 @@ const Page = memo(() => {
enableFoldFinishedTurn,
enableMessageTextSelectionActions,
enableInAppBrowser,
+ enableArtifactDeployment,
updateLab,
] = useUserStore((s) => [
preferenceSelectors.isPreferenceInit(s),
@@ -70,6 +71,7 @@ const Page = memo(() => {
labPreferSelectors.enableFoldFinishedTurn(s),
labPreferSelectors.enableMessageTextSelectionActions(s),
labPreferSelectors.enableInAppBrowser(s),
+ labPreferSelectors.enableArtifactDeployment(s),
s.updateLab,
]);
@@ -306,6 +308,19 @@ const Page = memo(() => {
} satisfies FormItemProps,
]
: []),
+ {
+ children: (
+ <Switch
+ checked={enableArtifactDeployment}
+ loading={!isPreferenceInit}
+ onChange={(checked: boolean) => updateLab({ enableArtifactDeployment: checked })}
+ />
+ ),
+ className: styles.labItem,
+ desc: tLabs('features.artifactDeployment.desc'),
+ label: tLabs('features.artifactDeployment.title'),
+ minWidth: undefined,
+ } satisfies FormItemProps,
];
const labsGroup: FormGroupItemType = {
diff --git a/src/spa/router/desktopRouter.config.desktop.tsx b/src/spa/router/desktopRouter.config.desktop.tsx
index f02e0ab1e0b..43a0167f48a 100644
--- a/src/spa/router/desktopRouter.config.desktop.tsx
+++ b/src/spa/router/desktopRouter.config.desktop.tsx
@@ -15,6 +15,7 @@ import type { RouteObject } from 'react-router';
import {
BusinessDesktopRoutesWithMainLayout,
BusinessDesktopRoutesWithoutMainLayout,
+ BusinessResourceRoutes,
} from '@/business/client/BusinessDesktopRoutes';
import { agentDocumentRouteMeta } from '@/features/AgentDocumentPage/routeMeta';
import { taskRouteMeta, tasksRouteMeta } from '@/features/AgentTasks/routeMeta';
@@ -403,6 +404,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
},
index: true,
},
+ ...BusinessResourceRoutes,
],
element: <ResourceHomeLayout />,
},
diff --git a/src/spa/router/desktopRouter.config.tsx b/src/spa/router/desktopRouter.config.tsx
index 0c72f59c929..c3dd54e2fae 100644
--- a/src/spa/router/desktopRouter.config.tsx
+++ b/src/spa/router/desktopRouter.config.tsx
@@ -15,6 +15,7 @@ import { type RouteObject } from 'react-router';
import {
BusinessDesktopRoutesWithMainLayout,
BusinessDesktopRoutesWithoutMainLayout,
+ BusinessResourceRoutes,
} from '@/business/client/BusinessDesktopRoutes';
import { agentDocumentRouteMeta } from '@/features/AgentDocumentPage/routeMeta';
import { taskRouteMeta, tasksRouteMeta } from '@/features/AgentTasks/routeMeta';
@@ -423,6 +424,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
},
index: true,
},
+ ...BusinessResourceRoutes,
],
element: dynamicElement(
() => import('@/routes/(main)/resource/(home)/_layout'),
diff --git a/src/spa/router/desktopRouter.sync.test.tsx b/src/spa/router/desktopRouter.sync.test.tsx
index 23ba9477993..a3e4acf9281 100644
--- a/src/spa/router/desktopRouter.sync.test.tsx
+++ b/src/spa/router/desktopRouter.sync.test.tsx
@@ -186,6 +186,15 @@ describe('desktopRouter config sync', () => {
).toEqual([]);
});
+ it('both configs import and spread BusinessResourceRoutes into /resource children', async () => {
+ const [asyncSource, syncSource] = await readDesktopRouterSources();
+
+ expect(asyncSource).toContain('BusinessResourceRoutes');
+ expect(syncSource).toContain('BusinessResourceRoutes');
+ expect(asyncSource).toContain('...BusinessResourceRoutes');
+ expect(syncSource).toContain('...BusinessResourceRoutes');
+ });
+
it('task list and detail desktop routes share one workspace layout', async () => {
const [asyncSource, syncSource] = await readDesktopRouterSources();
diff --git a/src/store/global/initialState.ts b/src/store/global/initialState.ts
index 86830192c00..d52ef98064c 100644
--- a/src/store/global/initialState.ts
+++ b/src/store/global/initialState.ts
@@ -37,7 +37,9 @@ export enum GroupSettingsTabs {
Settings = 'settings',
}
-export type WorkingSidebarTab = 'browser' | 'files' | 'params' | 'resources' | 'review';
+// business builds may register extra sidebar tabs, so any string key is accepted
+export type WorkingSidebarTab =
+ 'browser' | 'files' | 'params' | 'resources' | 'review' | (string & {});
export const DEFAULT_RESOURCE_MANAGER_COLUMN_WIDTHS = {
date: 160,
diff --git a/src/store/user/slices/preference/selectors/labPrefer.ts b/src/store/user/slices/preference/selectors/labPrefer.ts
index 7f03eea6cac..701e0443dc7 100644
--- a/src/store/user/slices/preference/selectors/labPrefer.ts
+++ b/src/store/user/slices/preference/selectors/labPrefer.ts
@@ -9,6 +9,8 @@ export const labPreferSelectors = {
false,
enableAgentSelfIteration: (s: UserState): boolean =>
s.preference.lab?.enableAgentSelfIteration ?? false,
+ enableArtifactDeployment: (s: UserState): boolean =>
+ s.preference.lab?.enableArtifactDeployment ?? false,
enableClaudeCodeSdk: (s: UserState): boolean => s.preference.lab?.enableClaudeCodeSdk ?? false,
enableFleet: (s: UserState): boolean => s.preference.lab?.enableFleet ?? false,
enableFoldFinishedTurn: (s: UserState): boolean =>