diff --git a/frontend-web/.env.development b/frontend-web/.env.development index 1d8b3666..0e89436f 100644 --- a/frontend-web/.env.development +++ b/frontend-web/.env.development @@ -26,7 +26,7 @@ VITE_AIPI_KNOWLEDGE_IFRAME_SKIN=red VITE_AIPI_MOPECHAT_URL=https://ch1.b.uat.4.cn/likun_b1_mope VITE_AIPI_BACKENP_URL=https://knowledgetoolserver.b.uat.4.cn # 我的笔记前端 -VITE_AIPI_FRONTEND_URL= xxx +VITE_AIPI_FRONTEND_URL=https://knowledgetoolserver.b.uat.4.cn VITE_AIPI_CONSUMER_URL=https://ch1.b.uat.4.cn/consumer # MaxKey 鉴权(getTokenByOnlineTicket) VITE_AUTH_BASE_URL=https://auth.y.sit.4.cn diff --git a/frontend-web/.env.network b/frontend-web/.env.network index 4bcd8f15..be82f968 100644 --- a/frontend-web/.env.network +++ b/frontend-web/.env.network @@ -2,8 +2,8 @@ # 打包前请将 192.168.1.100 改为实际服务器 IP;变量会写入 dist,运行时不可再改 # Gateway / DeerFlow API(与 offline-backend DEPLOY 文档一致) -VITE_BACKEND_BASE_URL=http://47.88.25.99 -VITE_LANGGRAPH_BASE_URL=http://47.88.25.99/api +VITE_BACKEND_BASE_URL=http://47.88.25.99:7001 +VITE_LANGGRAPH_BASE_URL=http://47.88.25.99:7001/api # 轻应用「新建笔记」系列接口 VITE_NOTE_API_BASE_URL=http://192.168.1.100:8000 diff --git a/frontend-web/.env.production b/frontend-web/.env.production index 67dabce1..6aa2d33d 100644 --- a/frontend-web/.env.production +++ b/frontend-web/.env.production @@ -25,6 +25,7 @@ VITE_AIPI_CONSUMER_URL=https://ch1.b.uat.4.cn/consumer VITE_AUTH_BASE_URL=https://auth.y.uat.4.cn VITE_AIPI_PGLINKTO_URL=https://pg.b.uat.4.cn VITE_AIPI_XKLINKTO_URL=https://kz.b.uat.4.cn +VITE_AIPI_FRONTEND_URL=https://knowledgetoolserver.b.uat.4.cn # 可选:Canvas 独立 LangGraph 地址 # VITE_CANVAS_LANGGRAPH_BASE_URL= diff --git a/frontend-web/package.json b/frontend-web/package.json index a5921463..bc5cbd2e 100644 --- a/frontend-web/package.json +++ b/frontend-web/package.json @@ -64,6 +64,7 @@ "codemirror": "^6.0.2", "date-fns": "^4.1.0", "dayjs": "^1.11.21", + "dnd-kit": "^0.0.2", "docx": "^9.5.1", "dotenv": "^17.2.3", "embla-carousel-react": "^8.6.0", diff --git a/frontend-web/src/components/workspace/artifacts/artifact-file-detail.tsx b/frontend-web/src/components/workspace/artifacts/artifact-file-detail.tsx index 32a16a17..ef9416f2 100644 --- a/frontend-web/src/components/workspace/artifacts/artifact-file-detail.tsx +++ b/frontend-web/src/components/workspace/artifacts/artifact-file-detail.tsx @@ -767,7 +767,10 @@ export function ArtifactFilePreview({ return; } - const blob = new Blob([content ?? ""], { type: "text/html" }); + // 必须带 charset=utf-8:blob: URL 的 Content-Type 不含 charset 时,iframe 会按 + // 系统默认编码(中文 Windows 常为 GBK/Latin-1)解码,模型生成的 HTML 若没写 + // 就会中文乱码。与下方下载/新窗口打开的 blobType 保持一致。 + const blob = new Blob([content ?? ""], { type: "text/html;charset=utf-8" }); const url = URL.createObjectURL(blob); setHtmlPreviewUrl(url); diff --git a/frontend-web/src/components/workspace/settings/memory-settings-page.tsx b/frontend-web/src/components/workspace/settings/memory-settings-page.tsx index 8bf7ef04..477f039e 100644 --- a/frontend-web/src/components/workspace/settings/memory-settings-page.tsx +++ b/frontend-web/src/components/workspace/settings/memory-settings-page.tsx @@ -1,6 +1,6 @@ "use client"; -import { PenLineIcon, PlusIcon, SearchIcon, Trash2Icon } from "lucide-react"; +import { PenLineIcon, PlusIcon, SearchIcon, Trash2Icon, Heart, BookOpen, Map, Zap, Target, ShieldAlert } from "lucide-react"; import { useMemo, useState } from "react"; import { toast } from "sonner"; @@ -464,23 +464,41 @@ const HISTORY_LABELS: Record = { longTermBackground: "长期背景", }; -const CATEGORY_COLORS: Record = { - preference: "bg-blue-100 text-blue-700", - knowledge: "bg-green-100 text-green-700", - context: "bg-yellow-100 text-yellow-700", - behavior: "bg-purple-100 text-purple-700", - goal: "bg-orange-100 text-orange-700", - correction: "bg-red-100 text-red-700", +const CATEGORY_LABELS: Record> = { + zh: { + preference: "偏好", + knowledge: "知识", + context: "背景", + behavior: "行为", + goal: "目标", + correction: "纠偏", + }, + en: { + preference: "Preference", + knowledge: "Knowledge", + context: "Context", + behavior: "Behavior", + goal: "Goal", + correction: "Correction", + }, }; -/** 事实分类的中文标签。 */ -const CATEGORY_LABELS: Record = { - preference: "偏好", - knowledge: "知识", - context: "背景", - behavior: "行为", - goal: "目标", - correction: "纠正", +const CATEGORY_COLORS: Record = { + preference: "bg-blue-50 text-blue-700 border border-blue-200/50 dark:bg-blue-950/30 dark:text-blue-400 dark:border-blue-900/30", + knowledge: "bg-green-50 text-green-700 border border-green-200/50 dark:bg-green-950/30 dark:text-green-400 dark:border-green-900/30", + context: "bg-amber-50 text-amber-700 border border-amber-200/50 dark:bg-amber-950/30 dark:text-amber-400 dark:border-amber-900/30", + behavior: "bg-purple-50 text-purple-700 border border-purple-200/50 dark:bg-purple-950/30 dark:text-purple-400 dark:border-purple-900/30", + goal: "bg-orange-50 text-orange-700 border border-orange-200/50 dark:bg-orange-950/30 dark:text-orange-400 dark:border-orange-900/30", + correction: "bg-red-50 text-red-700 border border-red-200/50 dark:bg-red-950/30 dark:text-red-400 dark:border-red-900/30", +}; + +const CATEGORY_ICONS: Record = { + preference: Heart, + knowledge: BookOpen, + context: Map, + behavior: Zap, + goal: Target, + correction: ShieldAlert, }; /** V1 记忆只读视图:展示 memory.json 的全部字段,Tab 布局。 */ @@ -494,6 +512,9 @@ function MemoryV1View({ memory_usage: string; }; }) { + const { locale } = useI18n(); + const isZh = locale.startsWith("zh"); + const labelMap = isZh ? CATEGORY_LABELS.zh : CATEGORY_LABELS.en; const ctxEntries = Object.entries(memory.user_context ?? {}).filter(([, v]) => v); const historyEntries = Object.entries(memory.history ?? {}).filter(([, v]) => v); @@ -504,9 +525,8 @@ function MemoryV1View({ V1 模式:记忆由系统在对话结束后自动提取,无需手动管理。 - + - 用户画像 & 历史 事实记录 {memory.facts.length > 0 && ( @@ -515,8 +535,81 @@ function MemoryV1View({ )} + 用户画像 & 历史 + {/* 事实记录 Tab */} + +
+
+

事实记录

+ {memory.memory_usage} +
+ {memory.facts.length === 0 ? ( +
+ 暂无事实记录,对话后系统会自动提取。 +
+ ) : ( +
+ {memory.facts.map((fact) => { + const categoryLabel = labelMap[fact.category] ?? fact.category; + const Icon = CATEGORY_ICONS[fact.category] ?? PlusIcon; + return ( +
+ {/* Subtle top highlight */} +
+ +
+
+ + + {categoryLabel} + +
+ + {Math.round(fact.confidence * 100)}% + + {/* Confidence Progress Bar */} +
+
+
+
+
+ +

+ {desensitize(fact.content)} +

+
+ + {fact.sourceError && ( +
+
+
+ + 避免 +
+

{desensitize(fact.sourceError)}

+
+
+ )} +
+ ); + })} +
+ )} +
+ + {/* 用户画像 & 历史摘要 Tab */} {/* 用户画像 (userContext) */} @@ -557,49 +650,6 @@ function MemoryV1View({ )}
- - {/* 事实记录 Tab */} - -
-
-

事实记录

- {memory.memory_usage} -
- {memory.facts.length === 0 ? ( -
- 暂无事实记录,对话后系统会自动提取。 -
- ) : ( -
- {memory.facts.map((fact) => ( -
-
- - {CATEGORY_LABELS[fact.category] ?? fact.category} - - - 置信度 {Math.round(fact.confidence * 100)}% - -
-

{desensitize(fact.content)}

- {fact.sourceError && ( -

- 避免:{desensitize(fact.sourceError)} -

- )} -
- ))} -
- )} -
-
); diff --git a/frontend-web/src/components/workspace/settings/skill-settings-page.tsx b/frontend-web/src/components/workspace/settings/skill-settings-page.tsx index 260f0095..5f114792 100644 --- a/frontend-web/src/components/workspace/settings/skill-settings-page.tsx +++ b/frontend-web/src/components/workspace/settings/skill-settings-page.tsx @@ -29,6 +29,13 @@ import { toast } from "sonner"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; +import { + Card, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from "@/components/ui/card"; import { Dialog, DialogContent, @@ -45,6 +52,7 @@ import { EmptyMedia, EmptyTitle, } from "@/components/ui/empty"; + import { Item, ItemActions, @@ -358,6 +366,8 @@ function SkillSettingsList({ onClose }: { onClose?: () => void }) { {!isLoading && !error && filteredSkills.length === 0 && ( )} + + {/* —— 原纵向列表布局(保留备查)—— {!isLoading && !error && filteredSkills.length > 0 && pagedSkills.map((skill) => ( @@ -367,7 +377,21 @@ function SkillSettingsList({ onClose }: { onClose?: () => void }) { currentUserId={currentUserId} isAdmin={isAdmin} /> - ))} + ))} */} + {/* card */} + {!isLoading && !error && filteredSkills.length > 0 && ( +
+ {pagedSkills.map((skill) => ( + + ))} +
+ )} {!isLoading && !error && totalPages > 1 && (
+ )} + {canManage && ( + + )} + {canTogglePublish && ( + + )} + + {canManage && ( + + )} +
+ + diff --git a/frontend-web/src/components/workspace/tags/tag-chip.tsx b/frontend-web/src/components/workspace/tags/tag-chip.tsx index 17edf948..635e46a6 100644 --- a/frontend-web/src/components/workspace/tags/tag-chip.tsx +++ b/frontend-web/src/components/workspace/tags/tag-chip.tsx @@ -17,20 +17,22 @@ export function TagChip({ className?: string; }) { const color = resolveTagColor(tag.color); + const label = desensitize(tag.name); return ( - {desensitize(tag.name)} + {label} {onRemove && ( + + + + ); +} + +// ── 单张链条行卡片 ───────────────────────────────────────────────────────── + +function ChainRow({ + chain, + onSettings, +}: { + chain: BusinessChain; + onSettings: () => void; +}) { + return ( +
+ {/* 标题行 + 设置按钮 */} +
+
{chain.title || "未命名链条"}
+ + {chain.seats.length} 席 + + +
+ + {chain.description && ( +
{chain.description}
+ )} + + {/* 席位名 tag(按顺序,→ 箭头连接发言次序) */} +
+ {chain.seats.map((seat, i) => ( + + {i > 0 && } + + {seat.name || seat.agent_id} + + + ))} +
+
+ ); +} diff --git a/frontend-web/src/roundtable-planning/components/HighFidelityReport.tsx b/frontend-web/src/roundtable-planning/components/HighFidelityReport.tsx index 8cb7a0d0..cd5e88ea 100644 --- a/frontend-web/src/roundtable-planning/components/HighFidelityReport.tsx +++ b/frontend-web/src/roundtable-planning/components/HighFidelityReport.tsx @@ -14,6 +14,7 @@ import { Sparkles, } from "lucide-react"; +import { useArtifacts } from "@/components/workspace/artifacts"; import { buildArtifactDownloadUrl, listSessionArtifacts, @@ -118,6 +119,13 @@ export const HighFidelityReport: React.FC = ({ }) => { // 「结果绘制」模式:把现有报告内容收起到左栏,右侧由方案可视化智能体绘制图表 HTML。 const [drawMode, setDrawMode] = useState(false); + + // 进入第三步即关闭并清空第二步遗留的沙箱(artifacts 面板全局共享,第二步打开后 + // 不会自动关)。点「结果绘制」后 Step3ReportMode 会按需开自己的沙箱,互不串扰。 + const { deselect: deselectArtifact } = useArtifacts(); + useEffect(() => { + deselectArtifact(); + }, [deselectArtifact]); // Build the per-seat list (excludes the coordinator). useMemo so the file // fetch effect doesn't re-fire on every parent render. const seatThreadEntries = useMemo(() => { diff --git a/frontend-web/src/roundtable-planning/components/Step2Panel.tsx b/frontend-web/src/roundtable-planning/components/Step2Panel.tsx index c3cc6206..fc077524 100644 --- a/frontend-web/src/roundtable-planning/components/Step2Panel.tsx +++ b/frontend-web/src/roundtable-planning/components/Step2Panel.tsx @@ -521,7 +521,7 @@ function PresentFilesRow({ disabled: boolean; }) { return ( -
+
{files.map((path) => ( -
+
{filename}
-
+
{typeLabel} diff --git a/frontend-web/src/roundtable-planning/hooks/useStep3Report.ts b/frontend-web/src/roundtable-planning/hooks/useStep3Report.ts index 6d2bf725..72f05b81 100644 --- a/frontend-web/src/roundtable-planning/hooks/useStep3Report.ts +++ b/frontend-web/src/roundtable-planning/hooks/useStep3Report.ts @@ -17,8 +17,10 @@ import { useCallback, useEffect, useRef, useState } from "react"; import { useArtifacts } from "@/components/workspace/artifacts"; +import { apiFetch } from "@/core/api"; import type { DraftStep3Snapshot } from "@/roundtable-planning/api/drafts"; import { + buildArtifactDownloadUrl, initReportThread, listSessionArtifacts, streamMultiAgent, @@ -139,6 +141,11 @@ function buildReportPrompt(opts: { "文字为主图表点睛(全篇穿插 3–5 个有信息量的图、每图配一两句解读)、浅红主题(主色 #c25555);" + "写完文件后只用一两句话总结,不要把 HTML 源码贴进对话。", ); + // 语言 + 编码硬约束:偶发整篇输出英文 / 中文乱码的两个根因都在这里堵住。 + parts.push( + "硬性要求:① 全程使用简体中文输出——HTML 正文、标题、图表标签与图例、按钮、结论摘要等一切文字都必须是中文,禁止输出英文(专有名词可中英并列);" + + '② HTML 必须是完整文档,并在 最前面声明 ,确保中文不乱码。', + ); return parts.join("\n"); } @@ -543,6 +550,51 @@ export function useStep3Report( [setArtifacts, selectArtifact, setArtifactsOpen], ); + // 收尾对账:以沙箱真实文件为准回灌 stub,拿到完整 HTML。 + // 智能体可能分多次写文件 —— 尤其是 write_file 带 `append=true` 续写后半段(截图里 + // 「Append remaining HTML content…」那一步)。后端 append 会把后半段拼到磁盘文件已有 + // 内容后面,磁盘文件是完整的;但前端 stub 按 (name,path) 去重,第二次 write_file 会用 + // 「只含后半段」的 content 覆盖掉前半段(防抹空守卫只挡空内容、挡不住非空的后半段)。 + // 这里流式结束后从 outputs 读真实文件回灌 stub,让预览与存档都拿到完整 HTML。 + // 返回最终用于存草稿的 HTML(拉取失败 / 真实文件更短时退回 stub 内容,不打断收尾)。 + const reconcileStubFromRealFile = useCallback( + async (threadId: string, signal?: AbortSignal): Promise => { + const writeTc = stubRef.current[threadId]?.[0]?.tool_calls.find( + (tc) => tc.name === "write_file", + ); + const stubPath = + typeof (writeTc?.args as { path?: unknown })?.path === "string" + ? ((writeTc!.args as { path?: string }).path as string) + : ""; + const stubContent = + typeof (writeTc?.args as { content?: unknown })?.content === "string" + ? ((writeTc!.args as { content?: string }).content as string) + : ""; + if (!stubPath) return stubContent; + try { + const list = await listSessionArtifacts(threadId, { signal }); + const htmlFile = + list.files.find((f) => /\.html?$/i.test(f.name)) ?? null; + if (!htmlFile) return stubContent; + const res = await apiFetch( + buildArtifactDownloadUrl(threadId, htmlFile.path), + { signal }, + ); + if (!res.ok) return stubContent; + const real = await res.text(); + // 只在真实文件更长(说明 stub 被后半段截短了)时替换,避免偶发空/短响应回退。 + if (real.trim() && real.length > stubContent.length) { + upsertStub(threadId, "write_file", { path: stubPath, content: real }); + return real; + } + } catch { + /* 拉取真实文件失败就退回 stub 内容,不打断主流程 */ + } + return stubContent; + }, + [upsertStub], + ); + const abort = useCallback(() => { aborterRef.current?.abort(); aborterRef.current = null; @@ -604,17 +656,16 @@ export function useStep3Report( const hasStubFile = (stubRef.current[threadId]?.[0]?.tool_calls.length ?? 0) > 0; if (!hasStubFile) await openRealArtifactFallback(threadId); + // 以沙箱真实文件回灌 stub(修复 append 续写只剩后半段的问题),并拿到完整 HTML。 + const html = hasStubFile + ? await reconcileStubFromRealFile(threadId, aborter.signal) + : ""; + if (aborter.signal.aborted) return; + finalizeDialogue(bubbleId, res.content, "绘制完成"); setPhase("done"); - // 绘制成功 → 把完整 HTML 等抛给上层存进草稿(step3)。从 stub 取最新 write_file 内容。 - const writeTc = stubRef.current[threadId]?.[0]?.tool_calls.find( - (tc) => tc.name === "write_file", - ); - const html = - typeof (writeTc?.args as { content?: unknown })?.content === "string" - ? ((writeTc!.args as { content?: string }).content as string) - : ""; + // 绘制成功 → 把完整 HTML 等抛给上层存进草稿(step3)。 if (html.trim()) { onReportSavedRef.current?.({ html, @@ -645,6 +696,7 @@ export function useStep3Report( handleArtifactToolPhase, handleUpstreamFrame, openRealArtifactFallback, + reconcileStubFromRealFile, ]); const start = useCallback(() => { diff --git a/frontend-web/src/roundtable-planning/pages/BusinessChainEditorPage.tsx b/frontend-web/src/roundtable-planning/pages/BusinessChainEditorPage.tsx index 94354ac9..2ed3f44f 100644 --- a/frontend-web/src/roundtable-planning/pages/BusinessChainEditorPage.tsx +++ b/frontend-web/src/roundtable-planning/pages/BusinessChainEditorPage.tsx @@ -21,8 +21,8 @@ * * 详见 `docs/multi-agent-business-chain-dev.md` §7 阶段 1。 */ -import { useCallback, useEffect, useMemo, useState } from "react"; -import { useNavigate } from "react-router-dom"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { useNavigate, useSearchParams } from "react-router-dom"; import { toast } from "sonner"; import { nanoid } from "nanoid"; import { @@ -101,6 +101,7 @@ type ActiveDrag = export default function BusinessChainEditorPage() { const navigate = useNavigate(); + const [searchParams] = useSearchParams(); // ─── 数据 ──────────────────────────────────────────────────────────── const [pool, setPool] = useState([]); @@ -184,6 +185,19 @@ export default function BusinessChainEditorPage() { setSeats([]); }, []); + // ─── URL 参数 chainId:从「业务链条」弹窗点「设置」进来时自动切到该链条 ────── + // 只在链条列表加载完后应用一次(用 ref 闸门避免覆盖用户后续的手动切换)。 + const appliedChainParamRef = useRef(false); + useEffect(() => { + if (appliedChainParamRef.current) return; + const chainId = searchParams.get("chainId"); + if (!chainId) return; + if (chains.length === 0) return; // 等 refreshChains 拉回列表 + const chain = chains.find((c) => c.id === chainId); + if (chain) loadChain(chain); + appliedChainParamRef.current = true; // 命中或链条已不存在,都不再重试 + }, [chains, searchParams, loadChain]); + // ─── 席位增删改 ─────────────────────────────────────────────────────── const addAgentToSeats = useCallback( (agentId: string, atIndex?: number) => { diff --git a/frontend-web/src/roundtable-planning/pages/RoundtablePlanningPage.tsx b/frontend-web/src/roundtable-planning/pages/RoundtablePlanningPage.tsx index ac457087..2910c69e 100644 --- a/frontend-web/src/roundtable-planning/pages/RoundtablePlanningPage.tsx +++ b/frontend-web/src/roundtable-planning/pages/RoundtablePlanningPage.tsx @@ -55,6 +55,7 @@ import { useModels } from "@/core/models/hooks"; import { getAvatar, Man1Avatar, RobotAvatar } from "@/roundtable-planning/components/Avatars"; import { RecommendAgentsDialog } from "@/roundtable-planning/components/RecommendAgentsDialog"; +import { BusinessChainListDialog } from "@/roundtable-planning/components/BusinessChainListDialog"; import { Step1Panel } from "@/roundtable-planning/components/Step1Panel"; import { Step2Panel } from "@/roundtable-planning/components/Step2Panel"; import { Step3Panel } from "@/roundtable-planning/components/Step3Panel"; @@ -85,6 +86,8 @@ export default function RoundtablePlanningPage() { const [currentStep, setCurrentStep] = useState(1); const [showToast, setShowToast] = useState(null); const [isRecommendDialogOpen, setIsRecommendDialogOpen] = useState(false); + // 「业务链条」按钮 → 打开链条列表弹窗(弹窗里再决定进配置页 / 切到某条链条)。 + const [isChainListOpen, setIsChainListOpen] = useState(false); const [selectedModel, setSelectedModel] = useState(""); // Step 2 编排模式:recommend = 总控自由派活;chain = 总控按业务链条顺序派活。 // 由推荐弹窗确认时的 SeatSelectionResult.mode 决定(见 handleConfirmAgents)。 @@ -374,6 +377,19 @@ export default function RoundtablePlanningPage() { onConfirm={handleConfirmAgents} /> + { + setIsChainListOpen(false); + navigate( + chainId + ? `/page/workspace/roundtable/chains?chainId=${encodeURIComponent(chainId)}` + : "/page/workspace/roundtable/chains", + ); + }} + /> + {showToast && (
@@ -394,8 +410,8 @@ export default function RoundtablePlanningPage() {