Files
boss/src/lib/dispatch-plan-ui.ts
2026-03-30 17:11:07 +08:00

36 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export type DispatchPlanUiTarget = {
projectId: string;
threadDisplayName: string;
};
export type DispatchPlanUiPayload = {
planId: string;
status?: string;
summary?: string;
targets?: DispatchPlanUiTarget[];
};
export function latestPendingDispatchPlan(plans: DispatchPlanUiPayload[] | null | undefined) {
return (plans ?? []).find((plan) => plan.status === "pending_user_confirmation") ?? null;
}
export function summarizeDispatchPlan(plan: DispatchPlanUiPayload | null | undefined) {
if (!plan) {
return "主 Agent 暂未生成推荐线程。";
}
const summary = plan.summary?.trim() || "主 Agent 已生成推荐线程。";
const titles = (plan.targets ?? [])
.map((target) => target.threadDisplayName?.trim() || "")
.filter(Boolean);
if (!titles.length) {
return summary;
}
return `${summary}\n推荐线程${titles.join("、")}`;
}
export function extractApprovedTargetProjectIds(plan: DispatchPlanUiPayload | null | undefined) {
return (plan?.targets ?? [])
.map((target) => target.projectId?.trim() || "")
.filter(Boolean);
}