feat: 完善会商产物提交匹配与流式写文件预览

席位流程图按已提交 Markdown 对齐;流式未命名产物不再误请求 artifacts API,并兼容临时文件名路径。同时补强会话流中断识别与 8BF/岗位会商展示。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
董宏凯andCursor committed 2026-08-19 17:08:52 +08:00
1 parent acf538ac01
commit 3afa76894f
19 files changed
+2459 -1881

No files matched your search

@@ -5,7 +5,7 @@
* 不会读取或写入岗位会商的会话、岗位节点状态。
*/
import { useRef, useState } from "react";
import { CheckCircle2, Circle, Search } from "lucide-react";
import { Check, Search } from "lucide-react";
import {
Dialog,
@@ -34,6 +34,14 @@ export interface PositionBusinessChainFlowProps {
* border and background; this flow keeps only its title row and canvas.
*/
embedded?: boolean;
/**
* Identity keys of seats whose Markdown artifact has been submitted.
* Matched against `seat.agent_id` and `seat.name` (case-insensitive).
* Green filled check = submitted only, same as 岗位会商 `is-delivered`.
*/
submittedSeatKeys?: readonly string[];
/** Click a seat node. Host opens the deliverable dialog when a submission exists. */
onSeatClick?: (seat: ChainSeat) => void;
}
function getFlowStages(chain: BusinessChain): FlowStage[] {
@@ -51,13 +59,27 @@ function getFlowStages(chain: BusinessChain): FlowStage[] {
return chain.seats.map((seat) => ({ goal: null, seats: [seat] }));
}
function isSeatSubmitted(seat: ChainSeat, submittedSeatKeys: ReadonlySet<string>): boolean {
return submittedSeatKeys.has(seat.agent_id.trim().toLowerCase())
|| submittedSeatKeys.has((seat.name ?? "").trim().toLowerCase());
}
export function PositionBusinessChainFlow({
chain,
loading = false,
className,
embedded = false,
submittedSeatKeys,
onSeatClick,
}: PositionBusinessChainFlowProps) {
const [dialogOpen, setDialogOpen] = useState(false);
const submittedKeys = new Set(
(submittedSeatKeys ?? []).map((key) => key.trim().toLowerCase()).filter(Boolean),
);
const handleSeatClick = (seat: ChainSeat) => {
onSeatClick?.(seat);
setDialogOpen(false);
};
return (
<section
@@ -112,14 +134,26 @@ export function PositionBusinessChainFlow({
</div>
) : (
<>
<BusinessChainCanvas chain={chain} embedded={embedded} className="min-h-0 flex-1" />
<BusinessChainCanvas
chain={chain}
embedded={embedded}
submittedKeys={submittedKeys}
onSeatClick={onSeatClick ? handleSeatClick : undefined}
className="min-h-0 flex-1"
/>
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
<DialogContent className="flex h-[86vh] w-[96vw] max-w-[1180px] flex-col gap-0 overflow-hidden p-0">
<DialogHeader className="shrink-0 border-b px-5 py-4 dark:border-[#2b8ffe]/25">
<DialogTitle className="text-base font-semibold">{chain.title} · 业务链条流程图</DialogTitle>
</DialogHeader>
<div className="min-h-0 flex-1 p-4">
<BusinessChainCanvas chain={chain} expanded className="h-full" />
<BusinessChainCanvas
chain={chain}
expanded
submittedKeys={submittedKeys}
onSeatClick={onSeatClick ? handleSeatClick : undefined}
className="h-full"
/>
</div>
</DialogContent>
</Dialog>
@@ -133,11 +167,15 @@ function BusinessChainCanvas({
chain,
expanded = false,
embedded = false,
submittedKeys,
onSeatClick,
className,
}: {
chain: BusinessChain;
expanded?: boolean;
embedded?: boolean;
submittedKeys: ReadonlySet<string>;
onSeatClick?: (seat: ChainSeat) => void;
className?: string;
}) {
const [view, setView] = useState({ tx: 0, ty: 0 });
@@ -175,6 +213,7 @@ function BusinessChainCanvas({
onDoubleClick={() => setView({ tx: 0, ty: 0 })}
onPointerDown={(event) => {
if (event.button !== 0) return;
if ((event.target as HTMLElement | null)?.closest?.(".pr-flow-card")) return;
dragRef.current = { x: event.clientX, y: event.clientY, tx: view.tx, ty: view.ty };
setPanning(true);
event.currentTarget.setPointerCapture(event.pointerId);
@@ -217,6 +256,8 @@ function BusinessChainCanvas({
accent={accent}
width={nodeWidth}
compact={embedded}
completed={isSeatSubmitted(seat, submittedKeys)}
onClick={onSeatClick ? () => onSeatClick(seat) : undefined}
/>
);
})}
@@ -277,6 +318,7 @@ function FlowNode({
completed = false,
width,
compact = false,
onClick,
}: {
title: string;
description: string;
@@ -284,25 +326,27 @@ function FlowNode({
completed?: boolean;
width: number;
compact?: boolean;
onClick?: () => void;
}) {
const StatusIcon = completed ? CheckCircle2 : Circle;
return (
<article
className={cn(
"relative overflow-hidden rounded-xl border border-slate-200 bg-white p-3 pr-10 shadow-sm dark:border-[#2b8ffe]/40 dark:bg-[#0a2d58]",
compact && "rounded-lg",
)}
style={{ width, borderLeftWidth: 5, borderLeftColor: accent }}
>
const className = cn(
"pr-flow-card relative overflow-hidden rounded-xl border border-slate-200 bg-white p-3 pr-10 text-left font-[inherit] shadow-sm dark:border-[#2b8ffe]/40 dark:bg-[#0a2d58]",
compact && "rounded-lg",
completed && "border-[#36b987]/60",
onClick && "cursor-pointer transition hover:-translate-y-0.5 hover:shadow-md",
);
const style = { width, borderLeftWidth: 5, borderLeftColor: accent };
const body = (
<>
<span
className={cn(
"absolute right-2 top-2 flex size-6 items-center justify-center rounded-full border bg-white shadow-sm dark:bg-[#0d3768]",
"absolute right-2 top-2 grid size-5 place-items-center rounded-full",
completed
? "border-emerald-500 text-emerald-500"
: "border-slate-300 text-slate-400 dark:border-[#8aa0c4] dark:text-[#8aa0c4]",
? "border-0 bg-[#36b987] text-white"
: "border-2 border-[#78a7e8] bg-transparent text-white",
)}
title={completed ? "已完成" : "待提交"}
>
<StatusIcon className="size-3.5" strokeWidth={2.5} />
{completed ? <Check className="size-3" strokeWidth={3} /> : null}
</span>
<p className="truncate text-sm font-extrabold leading-5 text-slate-900 dark:text-[#e8edf5]" title={title}>
{title}
@@ -310,6 +354,25 @@ function FlowNode({
<p className="mt-0.5 truncate text-xs font-semibold leading-4" style={{ color: accent }} title={description}>
{description}
</p>
</>
);
if (onClick) {
return (
<button
type="button"
className={className}
style={style}
title={completed ? "已完成 · 点击查看产物" : "点击查看产物"}
onClick={onClick}
onPointerDown={(event) => event.stopPropagation()}
>
{body}
</button>
);
}
return (
<article className={className} style={style}>
{body}
</article>
);
}