feat: 新增8BF多智能体会商页面
This commit is contained in:
1 parent
f1e53ef5c0
commit
e70bb4aa6f
10 files changed
+552
-13
No files matched your search
@@ -22,7 +22,7 @@
|
||||
* 5) Persona 抽屉改的 model 不会立即重启编排,下一轮才生效
|
||||
* 6) 模型选择全局默认 `availableModels[0].name`,Persona 覆盖更高优先级
|
||||
*/
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
||||
import { useNavigate, useLocation } from "react-router-dom";
|
||||
import { getStoredAuth } from "@/core/auth";
|
||||
import { setRoundtableErrorContext } from "@/roundtable-planning/api/diagnostics-report";
|
||||
@@ -288,8 +288,23 @@ function readEmbedHashQueryPrefill(): RoundtablePrefill | null {
|
||||
|
||||
export default function RoundtablePlanningPage({
|
||||
compactChrome = false,
|
||||
/** 独立业务页锁定的公共业务链;不影响原多智能体会商入口。 */
|
||||
lockedChainId = null,
|
||||
/** 即使尚未配置业务链,也禁止用户改为推荐/手选链路。 */
|
||||
lockBusinessChain = false,
|
||||
/** 独立业务页的草稿/后台作业存储键。 */
|
||||
storageTaskId,
|
||||
/** 供独立业务页在原页头部插入自己的操作入口。 */
|
||||
toolbarSlot,
|
||||
/** 独立业务页的根节点样式类,避免修改原会商样式。 */
|
||||
rootClassName,
|
||||
}: {
|
||||
compactChrome?: boolean;
|
||||
lockedChainId?: string | null;
|
||||
lockBusinessChain?: boolean;
|
||||
storageTaskId?: string | null;
|
||||
toolbarSlot?: ReactNode;
|
||||
rootClassName?: string;
|
||||
}) {
|
||||
const { theme } = useTheme();
|
||||
// 全工作区跨页的后台作业完成通知器(Provider 挂在 PageLayout 常驻层)。
|
||||
@@ -309,6 +324,8 @@ export default function RoundtablePlanningPage({
|
||||
readWujiePrefill() ??
|
||||
readPersistedDeeplinkPrefill(location.pathname),
|
||||
);
|
||||
// 8BF 等独立页面可提供专属存储键;原会商仍沿用深链 taskId / 个人草稿语义。
|
||||
const draftStorageTaskId = storageTaskId ?? recordTaskIdOf(prefillRef.current);
|
||||
// 由 prefill.businessCode 解析出的「自动选用业务链」结果;有值时「进入研讨」跳过选链弹窗直接进 Step 2。
|
||||
const [autoChainResult, setAutoChainResult] = useState<SeatSelectionResult | null>(null);
|
||||
/** 无界直传 chainId 时,链条解析完成前禁止弹选链窗(避免 modal 布局抖动)。 */
|
||||
@@ -317,6 +334,31 @@ export default function RoundtablePlanningPage({
|
||||
inWujieEmbed &&
|
||||
!!(prefillRef.current?.chainId || prefillRef.current?.businessCode),
|
||||
);
|
||||
|
||||
// 独立业务页使用管理员配置的固定业务链。它只负责预选,不触发深链的自动开跑逻辑。
|
||||
useEffect(() => {
|
||||
if (!lockedChainId) {
|
||||
setAutoChainResult(null);
|
||||
return;
|
||||
}
|
||||
let cancelled = false;
|
||||
setAutoChainLoading(true);
|
||||
void Promise.all([getChain(lockedChainId), listAgents().catch(() => [])])
|
||||
.then(([chain, agents]) => {
|
||||
if (cancelled || !chain) return;
|
||||
const result = buildChainSeatSelection(chain, filterRecommendCandidates(agents));
|
||||
if (!cancelled) setAutoChainResult(result);
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled) setAutoChainResult(null);
|
||||
})
|
||||
.finally(() => {
|
||||
if (!cancelled) setAutoChainLoading(false);
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [lockedChainId]);
|
||||
const autoStartedRef = useRef(false);
|
||||
const prefillClearedRef = useRef(false);
|
||||
// 共识达成后只向父页面(无界)回传一次交付结果。
|
||||
@@ -756,7 +798,7 @@ export default function RoundtablePlanningPage({
|
||||
setCurrentStep,
|
||||
triggerToast,
|
||||
// 聊天记录存储键:xdfx-A 按行动id 隔离,其它业务按真实 taskId(见 recordTaskIdOf)。
|
||||
taskId: recordTaskIdOf(prefillRef.current),
|
||||
taskId: draftStorageTaskId,
|
||||
intentSending: step1.isIntentSending,
|
||||
step2FinalizedCount,
|
||||
step3SavedTick,
|
||||
@@ -1042,6 +1084,10 @@ export default function RoundtablePlanningPage({
|
||||
// 再次点击同一条链 = 取消勾选。
|
||||
const handleSelectChainFromSidebar = useCallback(
|
||||
async (chain: BusinessChain) => {
|
||||
if (lockBusinessChain) {
|
||||
triggerToast("当前页面的业务链由管理员统一配置");
|
||||
return;
|
||||
}
|
||||
if (autoChainResult?.chain?.id === chain.id) {
|
||||
setAutoChainResult(null);
|
||||
triggerToast(`已取消业务链「${chain.title}」`);
|
||||
@@ -1061,7 +1107,7 @@ export default function RoundtablePlanningPage({
|
||||
triggerToast("选择业务链失败,请重试");
|
||||
}
|
||||
},
|
||||
[autoChainResult, triggerToast],
|
||||
[autoChainResult, lockBusinessChain, triggerToast],
|
||||
);
|
||||
|
||||
// ─── 会商自动化串联(模块 C) ──────────────────────────────────
|
||||
@@ -1524,7 +1570,7 @@ export default function RoundtablePlanningPage({
|
||||
step2.stopOrchestration();
|
||||
// 1. 取消后端作业:避免前后端双跑/抢同一线程(409),线程随后由前端接管续跑。
|
||||
// executor.cancel 会 task.cancel() 中断在跑的 run,DB 同步置 cancelled。
|
||||
await cancelJob(jobId, recordTaskIdOf(prefillRef.current)).catch(() => null);
|
||||
await cancelJob(jobId, draftStorageTaskId).catch(() => null);
|
||||
// 2. 加载作业最近写回草稿的快照:恢复 threadIds(作业真实线程)+ 协调名 + 完整对话。
|
||||
// hydrateFromDraft 已同步写好 threadIds/coordinatorName 的 ref,供下一步接管即时读取。
|
||||
await drafts.handleLoadDraft(draftId);
|
||||
@@ -1629,7 +1675,7 @@ export default function RoundtablePlanningPage({
|
||||
// 后台挂起发起前**立刻强制存一次**当前聊天(保住发起时刻的本地研讨记录,防丢)。
|
||||
const draftId = await drafts.saveDraftNow(2);
|
||||
// 后台作业按聊天记录存储键归属(xdfx-A=行动id):报告写回对应 task-draft 存储、去重一致。
|
||||
const tid = recordTaskIdOf(prefillRef.current);
|
||||
const tid = draftStorageTaskId;
|
||||
// 防重复:该草稿已有在跑作业就不再新建(避免重复作业 / 前后端双跑)。
|
||||
const existing = draftId ? await getJobByDraft(draftId, tid).catch(() => null) : null;
|
||||
const alreadyRunning =
|
||||
@@ -1701,7 +1747,7 @@ export default function RoundtablePlanningPage({
|
||||
const planSnap = mode === "dag" ? orchestrationPlan : null;
|
||||
const draftId = drafts.currentDraftId;
|
||||
// 后台作业按聊天记录存储键归属(xdfx-A=行动id),与草稿存储一致。
|
||||
const tid = recordTaskIdOf(prefillRef.current);
|
||||
const tid = draftStorageTaskId;
|
||||
|
||||
// 立刻:标记「挂起中」+ 跳回第一步 + 提示(不等接口)。
|
||||
if (draftId) markPendingSuspend(draftId);
|
||||
@@ -1796,7 +1842,7 @@ export default function RoundtablePlanningPage({
|
||||
if (agents.length === 0) return;
|
||||
startJobKeepalive({
|
||||
draftId: drafts.currentDraftId ?? undefined,
|
||||
taskId: recordTaskIdOf(prefillRef.current) ?? undefined,
|
||||
taskId: draftStorageTaskId ?? undefined,
|
||||
intent: buildInitialIntent(),
|
||||
agents,
|
||||
model: selectedModel || undefined,
|
||||
@@ -1866,6 +1912,7 @@ export default function RoundtablePlanningPage({
|
||||
className={cn(
|
||||
"roundtable-planning theme-transition relative flex h-full min-h-0 flex-col bg-[#fef6f6] font-sans text-slate-800 selection:bg-red-200",
|
||||
isDark && "roundtable-planning--dark",
|
||||
rootClassName,
|
||||
)}
|
||||
>
|
||||
{/* 启动加载遮罩:深链/预填自动会话从进入页面到问答真正开始(建意图线程 / 回显历史草稿)
|
||||
@@ -1936,7 +1983,7 @@ export default function RoundtablePlanningPage({
|
||||
{/* 派活链路流程图弹窗(订阅进行中作业的真实 SSE 进度) */}
|
||||
<DispatchChainJobModal
|
||||
jobId={chainModalJobId}
|
||||
taskId={prefillRef.current?.taskId ?? null}
|
||||
taskId={draftStorageTaskId ?? null}
|
||||
open={chainModalJobId !== null}
|
||||
onOpenChange={(o) => {
|
||||
if (!o) setChainModalJobId(null);
|
||||
@@ -1973,6 +2020,7 @@ export default function RoundtablePlanningPage({
|
||||
/>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{toolbarSlot}
|
||||
{/* 深链 taskId 模式:查看线上当前策划进度(目的树)。与单智能体闸门同一条接口。 */}
|
||||
{prefillRef.current?.taskId && (
|
||||
<button
|
||||
@@ -1987,7 +2035,7 @@ export default function RoundtablePlanningPage({
|
||||
)}
|
||||
|
||||
{/* 深链接(taskId)模式:业务链由 businessCode 自动决定,隐藏手动「业务链条」入口。 */}
|
||||
{!inWujieEmbed && !prefillRef.current?.taskId && (
|
||||
{!lockBusinessChain && !inWujieEmbed && !prefillRef.current?.taskId && (
|
||||
<button
|
||||
id="business-chain-btn"
|
||||
onClick={() => setIsChainListOpen(true)}
|
||||
@@ -2118,7 +2166,10 @@ export default function RoundtablePlanningPage({
|
||||
onOpenDraft={drafts.handleLoadDraft}
|
||||
activeDraftId={drafts.currentDraftId}
|
||||
entryRailTaskId={recordTaskIdOf(prefillRef.current)}
|
||||
historyTaskId={draftStorageTaskId}
|
||||
entryRailBusinessCode={prefillRef.current?.businessCode ?? null}
|
||||
lockedChainId={lockedChainId}
|
||||
lockBusinessChain={lockBusinessChain}
|
||||
/>
|
||||
|
||||
{/* MIDDLE VIEWPORT */}
|
||||
@@ -2163,6 +2214,14 @@ export default function RoundtablePlanningPage({
|
||||
void drafts.ensureDraft(1).finally(() => handleConfirmAgents(result));
|
||||
return;
|
||||
}
|
||||
if (lockBusinessChain) {
|
||||
triggerToast(
|
||||
autoChainLoading
|
||||
? "正在加载管理员配置的业务链,请稍候…"
|
||||
: "管理员尚未配置可用的业务链,请联系管理员处理",
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
inWujieEmbed &&
|
||||
autoChainLoading &&
|
||||
@@ -2662,8 +2721,14 @@ interface LeftSidebarProps {
|
||||
activeDraftId: string | null;
|
||||
/** 深链 taskId 模式:Step1 落地左栏「分析记录」只列该任务的草稿。 */
|
||||
entryRailTaskId?: string | null;
|
||||
/** 独立页面的历史草稿存储键。 */
|
||||
historyTaskId?: string | null;
|
||||
/** 深链业务码:左上角卡片据此决定显示「当前任务」(rwfx/3qfx) 还是「当前行动」(xdfx)。 */
|
||||
entryRailBusinessCode?: string | null;
|
||||
/** 独立页面禁止在左栏改选业务链。 */
|
||||
lockBusinessChain?: boolean;
|
||||
/** 独立页面锁定显示的业务链。 */
|
||||
lockedChainId?: string | null;
|
||||
}
|
||||
|
||||
function Step2SandboxSidebarSync({
|
||||
@@ -2710,7 +2775,10 @@ function LeftSidebar({
|
||||
onOpenDraft,
|
||||
activeDraftId,
|
||||
entryRailTaskId,
|
||||
historyTaskId,
|
||||
entryRailBusinessCode,
|
||||
lockBusinessChain,
|
||||
lockedChainId,
|
||||
}: LeftSidebarProps) {
|
||||
// 整片脱敏:左侧面板(任务概览/参与角色/人工参与等)的所有文本——标题、动态内容、
|
||||
// 嵌套子组件文本一并脱敏。消息列表与沙箱是另外的容器,不挂此 Hook,保持原文。
|
||||
@@ -2849,7 +2917,10 @@ function LeftSidebar({
|
||||
onOpenDraft={onOpenDraft}
|
||||
activeDraftId={activeDraftId}
|
||||
taskId={entryRailTaskId ?? null}
|
||||
historyTaskId={historyTaskId ?? null}
|
||||
businessCode={entryRailBusinessCode ?? null}
|
||||
lockBusinessChain={lockBusinessChain}
|
||||
lockedChainId={lockedChainId ?? null}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
@@ -2900,7 +2971,10 @@ function RoundtableEntryRail({
|
||||
onOpenDraft,
|
||||
activeDraftId,
|
||||
taskId,
|
||||
historyTaskId,
|
||||
businessCode,
|
||||
lockedChainId,
|
||||
lockBusinessChain = false,
|
||||
}: {
|
||||
selectedChainId: string | null;
|
||||
onSelectChain: (chain: BusinessChain) => void;
|
||||
@@ -2908,13 +2982,18 @@ function RoundtableEntryRail({
|
||||
activeDraftId: string | null;
|
||||
/** 深链 taskId 模式:分析记录只列该任务的草稿。 */
|
||||
taskId?: string | null;
|
||||
/** 独立页面的草稿存储键;不改变当前任务卡片/业务链区域的展示语义。 */
|
||||
historyTaskId?: string | null;
|
||||
/** 深链业务码:xdfx(7BF) 左上角显示「当前行动」,其余显示「当前任务」。 */
|
||||
businessCode?: string | null;
|
||||
/** 固定业务链时,左侧只展示这条链的流程图及放大入口。 */
|
||||
lockedChainId?: string | null;
|
||||
lockBusinessChain?: boolean;
|
||||
}) {
|
||||
const [chains, setChains] = useState<BusinessChain[]>([]);
|
||||
const [chainSectionExpanded, setChainSectionExpanded] = useState(true);
|
||||
const [expandedChainId, setExpandedChainId] = useState<string | null>(null);
|
||||
const { drafts: records, refresh } = useRoundtableDrafts(taskId);
|
||||
const { drafts: records, refresh } = useRoundtableDrafts(historyTaskId ?? taskId);
|
||||
// 分析记录「按业务链筛选」—— 选项从已加载草稿的 chainTitle 去重得到,
|
||||
// 无业务链的草稿(自由 / recommend 模式)归入「自由模式」。
|
||||
const [chainFilter, setChainFilter] = useState<string>(RECORD_FILTER_ALL);
|
||||
@@ -2963,7 +3042,9 @@ function RoundtableEntryRail({
|
||||
let cancelled = false;
|
||||
void listChains("public")
|
||||
.then((all) => {
|
||||
if (!cancelled) setChains(all);
|
||||
if (!cancelled) {
|
||||
setChains(lockBusinessChain ? all.filter((chain) => chain.id === lockedChainId) : all);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
/* 业务链非关键,静默忽略 */
|
||||
@@ -2972,7 +3053,7 @@ function RoundtableEntryRail({
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [refresh, deeplink]);
|
||||
}, [refresh, deeplink, lockedChainId, lockBusinessChain]);
|
||||
|
||||
const formatTime = (value: string) => {
|
||||
const date = new Date(value);
|
||||
|
||||
Reference in new issue
Block a user