feat: 完善会商产物提交匹配与流式写文件预览
席位流程图按已提交 Markdown 对齐;流式未命名产物不再误请求 artifacts API,并兼容临时文件名路径。同时补强会话流中断识别与 8BF/岗位会商展示。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
acf538ac01
commit
3afa76894f
19 files changed
+2459
-1881
No files matched your search
@@ -0,0 +1,92 @@
|
||||
import type { RoundtableArtifactSubmissionRecord } from "@/roundtable-planning/api/artifact-submissions";
|
||||
import type { ThreadIdMap } from "@/roundtable-planning/api/multi-agent";
|
||||
import type { ChainSeat } from "@/roundtable-planning/lib/business-chain";
|
||||
import { getDisplayNameFor, type SelectedAgent } from "@/roundtable-planning/lib/roundtable-constants";
|
||||
|
||||
function norm(value: string | null | undefined): string {
|
||||
return (value ?? "").trim().toLowerCase();
|
||||
}
|
||||
|
||||
function sourceKeyOf(record: RoundtableArtifactSubmissionRecord): string {
|
||||
const raw = (record.artifact.sourceKey ?? "").trim();
|
||||
if (!raw || raw.toLowerCase().startsWith("thread:")) return "";
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Match a chain seat to a submitted Markdown artifact.
|
||||
*
|
||||
* Submissions are keyed by the graph agent name (`threadIds` key) or UUID;
|
||||
* chain seats expose both `agent_id` and display `name`.
|
||||
*/
|
||||
export function findSeatSubmission(
|
||||
seat: ChainSeat,
|
||||
records: RoundtableArtifactSubmissionRecord[],
|
||||
selectedAgents: SelectedAgent[],
|
||||
threadIds: ThreadIdMap | null,
|
||||
): RoundtableArtifactSubmissionRecord | null {
|
||||
const selected = selectedAgents.find((agent) => agent.agent_id === seat.agent_id);
|
||||
const aliases = new Set(
|
||||
[
|
||||
seat.agent_id,
|
||||
seat.name,
|
||||
selected?.agent_id,
|
||||
selected?.name,
|
||||
selected ? getDisplayNameFor(selected) : "",
|
||||
]
|
||||
.map(norm)
|
||||
.filter(Boolean),
|
||||
);
|
||||
|
||||
const hits = records.filter((record) => {
|
||||
if (!record.submitted) return false;
|
||||
const sourceKey = norm(sourceKeyOf(record));
|
||||
if (sourceKey && aliases.has(sourceKey)) return true;
|
||||
if (!threadIds) return false;
|
||||
const owner = Object.entries(threadIds).find(([, id]) => id === record.artifact.threadId)?.[0];
|
||||
if (owner && aliases.has(norm(owner))) return true;
|
||||
for (const alias of aliases) {
|
||||
const mapped = threadIds[alias];
|
||||
if (mapped && mapped === record.artifact.threadId) return true;
|
||||
}
|
||||
const byName = threadIds[seat.name] ?? (selected ? threadIds[selected.name] : undefined);
|
||||
return Boolean(byName && byName === record.artifact.threadId);
|
||||
});
|
||||
|
||||
if (hits.length === 0) return null;
|
||||
return hits
|
||||
.slice()
|
||||
.sort((a, b) => (b.submittedAt ?? "").localeCompare(a.submittedAt ?? ""))[0] ?? null;
|
||||
}
|
||||
|
||||
/** Identity keys the flowchart can match against `seat.agent_id` / `seat.name`. */
|
||||
export function submittedSeatKeysFor(
|
||||
seats: ChainSeat[],
|
||||
records: RoundtableArtifactSubmissionRecord[],
|
||||
selectedAgents: SelectedAgent[],
|
||||
threadIds: ThreadIdMap | null,
|
||||
): string[] {
|
||||
const keys = new Set<string>();
|
||||
for (const record of records) {
|
||||
if (!record.submitted) continue;
|
||||
const sourceKey = sourceKeyOf(record);
|
||||
if (sourceKey) keys.add(norm(sourceKey));
|
||||
if (threadIds) {
|
||||
const owner = Object.entries(threadIds).find(([, id]) => id === record.artifact.threadId)?.[0];
|
||||
if (owner) keys.add(norm(owner));
|
||||
}
|
||||
}
|
||||
for (const seat of seats) {
|
||||
if (!findSeatSubmission(seat, records, selectedAgents, threadIds)) continue;
|
||||
keys.add(norm(seat.agent_id));
|
||||
if (seat.name) keys.add(norm(seat.name));
|
||||
}
|
||||
for (const agent of selectedAgents) {
|
||||
const seat = { agent_id: agent.agent_id, name: agent.name };
|
||||
if (!findSeatSubmission(seat, records, selectedAgents, threadIds)) continue;
|
||||
keys.add(norm(agent.agent_id));
|
||||
keys.add(norm(agent.name));
|
||||
keys.add(norm(getDisplayNameFor(agent)));
|
||||
}
|
||||
return [...keys];
|
||||
}
|
||||
@@ -37,4 +37,6 @@ export interface TaskArtifactSubmissionController {
|
||||
stateFor: (target: TaskArtifactTarget) => TaskArtifactSubmissionState;
|
||||
errorFor: (target: TaskArtifactTarget) => string | null;
|
||||
submit: (target: TaskArtifactTarget) => Promise<RoundtableArtifactSubmissionRecord | null>;
|
||||
/** Task-scoped ledger rows that have been formally submitted. */
|
||||
submittedRecords: RoundtableArtifactSubmissionRecord[];
|
||||
}
|
||||
Reference in new issue
Block a user