feat: polish web master-agent controls and dispatch recovery

This commit is contained in:
kris
2026-04-01 07:50:20 +08:00
parent 87093677b8
commit e52932e8ef
8 changed files with 153 additions and 29 deletions

View File

@@ -18,6 +18,45 @@ export function latestRejectedDispatchPlan(plans: DispatchPlanUiPayload[] | null
return (plans ?? []).find((plan) => plan.status === "rejected") ?? null;
}
export type DispatchPlanComposerState = {
pendingDispatchPlan: DispatchPlanUiPayload | null;
rejectedDispatchPlan: DispatchPlanUiPayload | null;
recoveryHint: string | null;
recoveryActionLabel: string | null;
};
export function resolveDispatchPlanComposerState(
plans: DispatchPlanUiPayload[] | null | undefined,
): DispatchPlanComposerState {
const pendingDispatchPlan = latestPendingDispatchPlan(plans);
const rejectedDispatchPlan = pendingDispatchPlan ? null : latestRejectedDispatchPlan(plans);
if (rejectedDispatchPlan) {
return {
pendingDispatchPlan,
rejectedDispatchPlan,
recoveryHint: "上次推荐已拒绝。直接点击“重新生成新的推荐”即可继续协作,不用重新发送整条消息。",
recoveryActionLabel: "重新生成新的推荐",
};
}
if (pendingDispatchPlan) {
return {
pendingDispatchPlan,
rejectedDispatchPlan: null,
recoveryHint: "当前有待确认推荐,已折叠旧的拒绝状态。",
recoveryActionLabel: null,
};
}
return {
pendingDispatchPlan: null,
rejectedDispatchPlan: null,
recoveryHint: null,
recoveryActionLabel: null,
};
}
export function summarizeDispatchPlan(plan: DispatchPlanUiPayload | null | undefined) {
if (!plan) {
return "主 Agent 暂未生成推荐线程。";

View File

@@ -1,5 +1,14 @@
export const MASTER_AGENT_CHAT_PAGE_ANCHORS = {
prompt: "/me/master-agent#prompt-section",
model: "/me/master-agent#model-section",
reasoningEffort: "/me/master-agent#reasoning-effort-section",
memory: "/me/master-agent#memory-section",
} as const;
export type MasterAgentChatPageAnchors = typeof MASTER_AGENT_CHAT_PAGE_ANCHORS;
export type MasterAgentChatMenuItem = {
key: "prompt" | "memory" | "refresh";
key: "prompt" | "model" | "reasoning_effort" | "memory" | "refresh";
label: string;
href?: string;
action?: "refresh";
@@ -14,12 +23,22 @@ export function getMasterAgentChatMenuItems(projectId: string): MasterAgentChatM
{
key: "prompt",
label: "提示词",
href: "/me/master-agent#prompt-section",
href: MASTER_AGENT_CHAT_PAGE_ANCHORS.prompt,
},
{
key: "model",
label: "模型",
href: MASTER_AGENT_CHAT_PAGE_ANCHORS.model,
},
{
key: "reasoning_effort",
label: "推理强度",
href: MASTER_AGENT_CHAT_PAGE_ANCHORS.reasoningEffort,
},
{
key: "memory",
label: "记忆",
href: "/me/master-agent#memory-section",
href: MASTER_AGENT_CHAT_PAGE_ANCHORS.memory,
},
{
key: "refresh",