feat: 多智能体会商草稿分享(import 复制 / view 公开结果页)
支持会商草稿生成分享码、导入副本与公开只读结果页,并在侧边栏展示最近会商记录。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
cca3d8eb41
commit
0fd314632a
20 files changed
+1584
No files matched your search
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 侧边栏「多智能体会商」记录用的轻量草稿列表 hook。
|
||||
*
|
||||
* 与页面内的 {@link useDraftPersistence} 不同 —— 那个负责完整的「存 / 加载 / 重命名 /
|
||||
* 删除」编排,依赖 Step1/Step2 快照。侧边栏只需要只读地展示最近草稿 + 重命名 / 删除,
|
||||
* 所以这里单独包一层,结构对齐 `useAIWritingSessions`(`{ drafts, loading, refresh,
|
||||
* rename, remove }`)。
|
||||
*/
|
||||
import { useCallback, useState } from "react";
|
||||
|
||||
import {
|
||||
deleteDraft,
|
||||
listDrafts,
|
||||
updateDraft,
|
||||
type DraftMeta,
|
||||
} from "@/roundtable-planning/api/drafts";
|
||||
|
||||
export function useRoundtableDrafts() {
|
||||
const [drafts, setDrafts] = useState<DraftMeta[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const data = await listDrafts();
|
||||
setDrafts(data);
|
||||
} catch {
|
||||
// 历史记录非关键,静默忽略
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const rename = useCallback(async (id: string, title: string) => {
|
||||
// 只发 title —— 与页面自动保存的「不带 title」互补,是改标题的唯一入口。
|
||||
const updated = await updateDraft(id, { title });
|
||||
if (updated) {
|
||||
setDrafts((prev) =>
|
||||
prev.map((d) => (d.id === id ? { ...d, title: updated.title } : d)),
|
||||
);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const remove = useCallback(async (id: string) => {
|
||||
await deleteDraft(id);
|
||||
setDrafts((prev) => prev.filter((d) => d.id !== id));
|
||||
}, []);
|
||||
|
||||
return { drafts, loading, refresh, rename, remove };
|
||||
}
|
||||
@@ -36,6 +36,7 @@ import {
|
||||
Clipboard,
|
||||
Clock,
|
||||
Cpu,
|
||||
Download,
|
||||
History,
|
||||
ListOrdered,
|
||||
Loader2,
|
||||
@@ -54,6 +55,7 @@ import { cn } from "@/lib/utils";
|
||||
import { useModels } from "@/core/models/hooks";
|
||||
|
||||
import { getAvatar, Man1Avatar, RobotAvatar } from "@/roundtable-planning/components/Avatars";
|
||||
import { ImportRoundtableDraftDialog } from "@/components/workspace/roundtable-draft-share-dialogs";
|
||||
import { RecommendAgentsDialog } from "@/roundtable-planning/components/RecommendAgentsDialog";
|
||||
import { BusinessChainListDialog } from "@/roundtable-planning/components/BusinessChainListDialog";
|
||||
import { DispatchChainJobModal } from "@/roundtable-planning/components/DispatchChainJobModal";
|
||||
@@ -99,6 +101,8 @@ export default function RoundtablePlanningPage() {
|
||||
const [isChainListOpen, setIsChainListOpen] = useState<boolean>(false);
|
||||
// 历史下拉点击「进行中」任务 → 打开派活链路流程图弹窗(订阅该作业 SSE)。
|
||||
const [chainModalJobId, setChainModalJobId] = useState<string | null>(null);
|
||||
// 「导入会商」弹窗(输入分享码把别人分享的会商复制到本账号)。
|
||||
const [isImportOpen, setIsImportOpen] = useState<boolean>(false);
|
||||
const [selectedModel, setSelectedModel] = useState<string>("");
|
||||
// Step 2 编排模式:recommend = 总控自由派活;chain = 总控按业务链条顺序派活。
|
||||
// 由推荐弹窗确认时的 SeatSelectionResult.mode 决定(见 handleConfirmAgents)。
|
||||
@@ -442,6 +446,30 @@ export default function RoundtablePlanningPage() {
|
||||
loadedFromDraftRefHolder.current = drafts.loadedFromDraftRef.current;
|
||||
});
|
||||
|
||||
// ─── 从侧边栏「多智能体会商」记录进入 ───────────────────────
|
||||
// 侧边栏点击某条草稿时:不在本页 → 把 id 存进 sessionStorage 再跳转,挂载时消费;
|
||||
// 已在本页 → 直接派 `roundtable:open-draft` 事件。两条路径都走 handleLoadDraft。
|
||||
// 用 ref 持有最新 handleLoadDraft,让下面的 effect 保持「挂载只跑一次」,避免
|
||||
// handleLoadDraft 身份变化导致重复消费 / 重复加载。
|
||||
const handleLoadDraftRef = useRef(drafts.handleLoadDraft);
|
||||
useEffect(() => {
|
||||
handleLoadDraftRef.current = drafts.handleLoadDraft;
|
||||
}, [drafts.handleLoadDraft]);
|
||||
|
||||
useEffect(() => {
|
||||
const pending = sessionStorage.getItem("roundtable:pending-draft");
|
||||
if (pending) {
|
||||
sessionStorage.removeItem("roundtable:pending-draft");
|
||||
handleLoadDraftRef.current(pending);
|
||||
}
|
||||
const onOpenDraft = (e: Event) => {
|
||||
const id = (e as CustomEvent<string>).detail;
|
||||
if (id) handleLoadDraftRef.current(id);
|
||||
};
|
||||
window.addEventListener("roundtable:open-draft", onOpenDraft);
|
||||
return () => window.removeEventListener("roundtable:open-draft", onOpenDraft);
|
||||
}, []);
|
||||
|
||||
// ─── 角色面板转场 ────────────────────────────────────────
|
||||
// Step 1: 仅指挥员 + 任务理解智能体两行(状态跟随 intent init)。
|
||||
// Step 2: 完整席位(loadedFromDraft 时直接 "在线",否则 "正在上线")。
|
||||
@@ -660,6 +688,16 @@ export default function RoundtablePlanningPage() {
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* 导入会商弹窗:输入分享码 → 复制副本 → 加载到当前页面继续研讨 */}
|
||||
<ImportRoundtableDraftDialog
|
||||
open={isImportOpen}
|
||||
onOpenChange={setIsImportOpen}
|
||||
onImported={(draftId) => {
|
||||
void drafts.refresh();
|
||||
if (draftId) drafts.handleLoadDraft(draftId);
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* 派活链路流程图弹窗(订阅进行中作业的真实 SSE 进度) */}
|
||||
<DispatchChainJobModal
|
||||
jobId={chainModalJobId}
|
||||
@@ -763,6 +801,16 @@ export default function RoundtablePlanningPage() {
|
||||
保存草稿
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="import-roundtable-btn"
|
||||
onClick={() => setIsImportOpen(true)}
|
||||
title="输入分享码,把别人分享的会商复制到我的账号"
|
||||
className="bg-white hover:bg-slate-50 border border-[#e2e8f0] text-[#334155] text-xs font-bold px-3 py-2 rounded-xl flex items-center gap-1.5 transition dark:border-border dark:bg-secondary dark:text-foreground dark:hover:bg-accent"
|
||||
>
|
||||
<Download className="w-3.5 h-3.5 text-slate-500" />
|
||||
导入会商
|
||||
</button>
|
||||
|
||||
<HistoryDropdown
|
||||
innerRef={drafts.historyDropdownRef}
|
||||
isOpen={drafts.isHistoryOpen}
|
||||
|
||||
Reference in new issue
Block a user