feat(position-roundtable): add standalone position collaboration

This commit is contained in:
fengxiangdebaozi committed 2026-07-21 17:50:24 +08:00
1 parent b93b82fcaf
commit 85e119db08
22 files changed
+3494 -201

No files matched your search

@@ -87,6 +87,8 @@ export interface Step1PanelProps {
onSkipQuestion: () => void;
onFollowUp: () => void;
onEnterRoundtable: () => void;
/** 保持旧文案默认不变;嵌入式新工作流可覆写确认动作名称。 */
enterButtonLabel?: string;
onManualSave: () => void;
onTriggerToast: (msg: string) => void;
submitIntentClarifications: (
@@ -111,6 +113,7 @@ export function Step1Panel(props: Step1PanelProps) {
onSkipQuestion,
onFollowUp,
onEnterRoundtable,
enterButtonLabel = "进入多智能体研讨 >",
onManualSave,
onTriggerToast,
submitIntentClarifications,
@@ -334,7 +337,7 @@ export function Step1Panel(props: Step1PanelProps) {
}`}
>
<Sparkles className="w-3.5 h-3.5 text-emerald-100" />
进入多智能体研讨 &gt;
{enterButtonLabel}
</button>
</div>
@@ -113,6 +113,8 @@ export interface UseStep1IntentReturn {
// ─── Handlers ────────────────────────────────────────────────────────
/** 清空当前 Step 1 状态并重新拉取 intent thread。 */
runStep1Init: () => void;
/** 清空当前状态但不创建线程,供宿主切换任务后重新进入 Step 1。 */
resetIntent: () => void;
/**
* 把 `userText` 作为用户气泡发给 intent agent,流式渲染回复。
* `files`:可选的本地文件,发送前先上传到 intent thread,再把引用随消息提交(后端
@@ -256,6 +258,20 @@ export function useStep1Intent(options: UseStep1IntentOptions): UseStep1IntentRe
})();
}, []);
const resetIntent = useCallback(() => {
stopIntentStream();
step1InitRef.current = false;
step1InitGenRef.current += 1;
setIntentThreadId(null);
setIntentReady(null);
setIntentInitError(null);
setIntentInitErrorDetail(null);
setPendingIntentClarificationMsgId(null);
setIntentClarificationSelections(new Map());
setInteractiveMessages([]);
setTimelineEntries([]);
}, [stopIntentStream]);
// 离开 Step 1 自动中断流;`currentStep === 1` 但还没初始化 → runStep1Init。
useEffect(() => {
if (currentStep !== 1) {
@@ -648,6 +664,7 @@ export function useStep1Intent(options: UseStep1IntentOptions): UseStep1IntentRe
timelineEntries,
setIntentClarificationSelections,
runStep1Init,
resetIntent,
sendIntentMessage,
submitIntentClarifications,
updateIntentReady,
@@ -45,6 +45,11 @@ export interface ChainSeat {
* 数组在 `api/chains.ts` 不做 camel↔snake 转换,键名须与后端 schema 逐字匹配)。
*/
seat_mode?: SeatMode | null;
/**
* 岗位协同专用的席位归属。普通圆桌会商不读取该字段;它跟随 `seats` JSON 保存,
* 使同一条业务链既能继续用于原会商,也能在岗位协同中按岗位筛选可问答的智能体。
*/
position_id?: string | null;
}
/** 一条可复用的业务链条(与后端 `/api/roundtable-chains` 记录对应)。 */
@@ -77,8 +77,13 @@ import { Switch } from "@/components/ui/switch";
import { useDesensitizeSubtree } from "@/roundtable-planning/lib/use-desensitize-subtree";
import { TagSearchBar } from "@/components/workspace/tags/tag-search-bar";
import { ModelNameSelect } from "@/components/workspace/model-name-select";
import { Select as TSelect } from "tdesign-react";
import { listAgents } from "@/core/agents";
import { getStoredAuth } from "@/core/auth";
import {
POSITION_OPTIONS,
type PositionId,
} from "@/position-roundtable/lib/positions";
import {
filterRecommendCandidates,
@@ -152,6 +157,14 @@ type ActiveDrag =
export default function BusinessChainEditorPage() {
const navigate = useNavigate();
const [searchParams] = useSearchParams();
// 岗位配置只由岗位协同页入口开启,普通圆桌编辑器完全不显示也不依赖该控件。
// `returnTo` 只接受站内绝对路径,避免把导航带往外部地址。
const positionConfigMode = searchParams.get("mode") === "position";
const requestedReturnTo = searchParams.get("returnTo");
const returnPath =
positionConfigMode && requestedReturnTo?.startsWith("/")
? requestedReturnTo
: "/page/workspace/roundtable/planning";
// 整片脱敏:链条配置页展示文本(链条名/描述/席位名/标题)。可编辑的 input/textarea 不脱敏(Hook 跳过),保证编辑用原文。
const dzRef = useDesensitizeSubtree<HTMLDivElement>();
@@ -415,6 +428,18 @@ export default function BusinessChainEditorPage() {
setStageGroups((prev) => setSeatModeOnGroups(prev, agentId, mode));
}, []);
// 岗位协同专用席位归属。保留在同一个 ChainSeat JSON 内,普通会商不会读取它。
const setSeatPositionCb = useCallback((agentId: string, positionId: PositionId | null) => {
setStageGroups((prev) =>
prev.map((group) => ({
...group,
seats: group.seats.map((seat) =>
seat.agent_id === agentId ? { ...seat, position_id: positionId } : seat,
),
})),
);
}, []);
// ── 提示词 AI 优化(总控提示词 / 各 Stage 阶段目标)────────────────────────
const [optimizingCoordinator, setOptimizingCoordinator] = useState(false);
const [goalOptimizingIdx, setGoalOptimizingIdx] = useState<number | null>(null);
@@ -617,6 +642,8 @@ export default function BusinessChainEditorPage() {
seat_skill_directive: s.seat_skill_directive ?? false,
// 席位「推理深度覆盖」:随席位一起落库(null = 跟随链条级 seatMode)。
seat_mode: s.seat_mode ?? null,
// 岗位协同专用岗位归属:普通圆桌忽略,但保存时必须原样保留。
position_id: s.position_id ?? null,
};
});
// 总控编排提示:trim 后空串落 null(清空),与后端「空=不注入」一致。
@@ -893,14 +920,14 @@ export default function BusinessChainEditorPage() {
<header className="flex shrink-0 flex-wrap items-center gap-3 border-b border-border bg-card px-6 py-3">
<button
type="button"
onClick={() => navigate("/page/workspace/roundtable/planning")}
onClick={() => navigate(returnPath)}
className={cn(
"flex items-center gap-1.5 border border-border bg-card px-3 py-1.5 text-sm font-medium text-muted-foreground transition hover:bg-muted hover:text-foreground active:scale-[0.98]",
R_CTRL,
)}
>
<ArrowLeft className="size-4" />
返回圆桌
{positionConfigMode ? "返回岗位协同" : "返回圆桌"}
</button>
{/* 品牌标识 */}
@@ -921,6 +948,17 @@ export default function BusinessChainEditorPage() {
</div>
</div>
{positionConfigMode && (
<span
className={cn(
"border border-primary/30 bg-primary/10 px-2 py-1 text-[11px] font-semibold text-primary",
R_CTRL,
)}
>
岗位协同配置
</span>
)}
{/* 链条选择下拉 */}
<div className="relative ml-2">
<button
@@ -1205,6 +1243,8 @@ export default function BusinessChainEditorPage() {
onSeatModelChange={setSeatModelCb}
onSeatSkillDirectiveChange={setSeatSkillDirectiveCb}
onSeatModeChange={setSeatModeCb}
positionConfigMode={positionConfigMode}
onSeatPositionChange={setSeatPositionCb}
onStageGoalChange={setGoal}
goalOptimizingIdx={goalOptimizingIdx}
onOptimizeGoal={handleOptimizeStageGoal}
@@ -1385,6 +1425,8 @@ function StagesColumn({
onSeatModelChange,
onSeatSkillDirectiveChange,
onSeatModeChange,
positionConfigMode,
onSeatPositionChange,
onStageGoalChange,
goalOptimizingIdx,
onOptimizeGoal,
@@ -1403,6 +1445,9 @@ function StagesColumn({
onSeatModelChange: (agentId: string, model: string | null) => void;
onSeatSkillDirectiveChange: (agentId: string, enabled: boolean) => void;
onSeatModeChange: (agentId: string, mode: SeatMode | null) => void;
/** 仅岗位协同入口启用;普通圆桌编辑器不显示岗位控件。 */
positionConfigMode: boolean;
onSeatPositionChange: (agentId: string, positionId: PositionId | null) => void;
onStageGoalChange: (stageIdx: number, goal: string) => void;
/** 正在 AI 优化阶段目标的 stage 下标(null = 没有进行中的优化)。 */
goalOptimizingIdx: number | null;
@@ -1439,6 +1484,11 @@ function StagesColumn({
<span className={cn("border border-border bg-muted px-2 py-0.5 text-[10px] font-bold text-muted-foreground", R_CTRL)}>
同层并行 · 层间串行
</span>
{positionConfigMode && (
<span className={cn("border border-primary/25 bg-primary/5 px-2 py-0.5 text-[10px] font-semibold text-primary", R_CTRL)}>
为每个席位指定岗位
</span>
)}
</div>
<div className="flex select-none items-center gap-2 text-xs">
@@ -1503,6 +1553,8 @@ function StagesColumn({
onSeatModelChange={onSeatModelChange}
onSeatSkillDirectiveChange={onSeatSkillDirectiveChange}
onSeatModeChange={onSeatModeChange}
positionConfigMode={positionConfigMode}
onSeatPositionChange={onSeatPositionChange}
onGoalChange={(goal) => onStageGoalChange(stageIdx, goal)}
goalOptimizing={goalOptimizingIdx === stageIdx}
anyGoalOptimizing={goalOptimizingIdx !== null}
@@ -1534,6 +1586,8 @@ function StageSection({
onSeatModelChange,
onSeatSkillDirectiveChange,
onSeatModeChange,
positionConfigMode,
onSeatPositionChange,
onGoalChange,
goalOptimizing,
anyGoalOptimizing,
@@ -1554,6 +1608,8 @@ function StageSection({
onSeatModelChange: (agentId: string, model: string | null) => void;
onSeatSkillDirectiveChange: (agentId: string, enabled: boolean) => void;
onSeatModeChange: (agentId: string, mode: SeatMode | null) => void;
positionConfigMode: boolean;
onSeatPositionChange: (agentId: string, positionId: PositionId | null) => void;
onGoalChange: (goal: string) => void;
/** 本 Stage 的阶段目标正在 AI 优化中。 */
goalOptimizing: boolean;
@@ -1717,6 +1773,8 @@ function StageSection({
onModelChange={(model) => onSeatModelChange(seat.agent_id, model)}
onSkillDirectiveChange={(enabled) => onSeatSkillDirectiveChange(seat.agent_id, enabled)}
onSeatModeChange={(mode) => onSeatModeChange(seat.agent_id, mode)}
showPositionConfig={positionConfigMode}
onPositionChange={(positionId) => onSeatPositionChange(seat.agent_id, positionId)}
onDetail={() => onSeatDetail(seat.agent_id, seat.name)}
/>
))}
@@ -1742,6 +1800,8 @@ function SeatStrip({
onModelChange,
onSkillDirectiveChange,
onSeatModeChange,
showPositionConfig,
onPositionChange,
onDetail,
}: {
seat: ChainSeat;
@@ -1760,6 +1820,9 @@ function SeatStrip({
onSkillDirectiveChange: (enabled: boolean) => void;
/** 席位「推理深度覆盖」变更(null = 跟随链条级 seatMode)。 */
onSeatModeChange: (mode: SeatMode | null) => void;
/** 仅岗位协同入口展示的岗位配置。 */
showPositionConfig: boolean;
onPositionChange: (positionId: PositionId | null) => void;
onDetail: () => void;
}) {
const { attributes, listeners, setNodeRef, transform, transition, isDragging } =
@@ -1810,6 +1873,29 @@ function SeatStrip({
)}
</div>
{/* 岗位协同从专用入口进来时才展示。使用 TDesign Select,未分配不会阻塞普通圆桌使用。 */}
{showPositionConfig && (
<div className="flex shrink-0 items-center gap-1.5 border-l border-border px-2.5">
<span className="shrink-0 text-[10px] font-medium text-muted-foreground">岗位</span>
<TSelect
size="small"
value={seat.position_id ?? ""}
options={[
{ label: "未分配", value: "" },
...POSITION_OPTIONS.map((position) => ({
label: position.name,
value: position.id,
})),
]}
onChange={(value) =>
onPositionChange(value ? (String(value) as PositionId) : null)
}
className="w-[132px]"
popupProps={{ overlayClassName: "z-[80]" }}
/>
</div>
)}
{/* 席位模型覆盖(右侧操作区):空 = 跟随全局所选模型;选了则该席位作为子智能体
执行时用此模型。技能重的席位配强模型、边角席位配快模型,配合技能白名单实现
「强弱搭配」。放到右侧操作区,与名称/描述解耦,卡片更整洁。 */}