fix(web): show live agent work progress and fail truncated rectification answers
Rectification dropped tool.activity started events and treated length finishes as completed. Share generation settings with consultation, keep the activity line through streaming, and name multi-domain chart calculation. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -290,6 +290,7 @@ export async function POST(request: Request) {
|
||||
emit: (event) => send(event),
|
||||
signal: request.signal,
|
||||
timeContext,
|
||||
generationModel: selectedModel.model,
|
||||
buildAgent: (turnId, skillPackage, attemptId) => Promise.resolve(
|
||||
getRectificationV9Agent(selectedModel, {
|
||||
userId,
|
||||
|
||||
@@ -241,8 +241,29 @@ button:disabled { cursor: default; opacity: .45; }
|
||||
}
|
||||
.markdown-table tr:last-child th,
|
||||
.markdown-table tr:last-child td { border-bottom: 0; }
|
||||
.agent-activity-status { min-height: 24px; display: flex; align-items: center; gap: var(--space-2); color: var(--color-ink-tertiary); font-size: var(--type-body-sm); line-height: 1.5; }
|
||||
.agent-activity-status {
|
||||
min-height: 24px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 2px;
|
||||
color: var(--color-ink-tertiary);
|
||||
font-size: var(--type-body-sm);
|
||||
line-height: 1.5;
|
||||
}
|
||||
.agent-activity-status__row { min-height: 24px; display: flex; align-items: center; gap: var(--space-2); min-width: 0; width: 100%; }
|
||||
.agent-activity-status__live { min-height: 24px; display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
|
||||
.agent-activity-status canvas { flex: 0 0 auto; }
|
||||
.agent-activity-status__elapsed {
|
||||
flex: 0 0 auto;
|
||||
color: var(--color-ink-tertiary);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.agent-activity-status__trail {
|
||||
margin: 0;
|
||||
padding-left: 28px;
|
||||
color: var(--color-ink-tertiary);
|
||||
}
|
||||
.agent-activity-status__text {
|
||||
color: var(--color-ink-tertiary);
|
||||
background: linear-gradient(
|
||||
|
||||
@@ -92,12 +92,20 @@ import {
|
||||
BALANCE_CHANGED_EVENT,
|
||||
membershipHref,
|
||||
} from "@/lib/membership";
|
||||
import { chatMessageViews, type AgentActivityView, type ChatMessage } from "@/lib/chat-message-view";
|
||||
import { chatMessageViews, nextActivityView, activityCompletedTrail, type AgentActivityView, type ChatMessage } from "@/lib/chat-message-view";
|
||||
import {
|
||||
createNdjsonParser,
|
||||
type AgentExecutionReceipt,
|
||||
type ConsultationAgentPublicEvent,
|
||||
} from "@/lib/consultation-agent-events";
|
||||
import {
|
||||
CONSULTATION_CHART_CALCULATION_LABEL,
|
||||
CONSULTATION_COMPOSING_LABEL,
|
||||
CONSULTATION_DONE_CHART_LABEL,
|
||||
CONSULTATION_DONE_SKILL_LABEL,
|
||||
CONSULTATION_EVIDENCE_VALIDATION_LABEL,
|
||||
CONSULTATION_LOADING_METHOD_LABEL,
|
||||
} from "@/lib/consultation-activity-labels";
|
||||
import { writeChatSession } from "@/lib/chat-session-write-contract";
|
||||
import { consultationReportMarkdown } from "@/lib/consultation-report-export";
|
||||
import {
|
||||
@@ -3200,7 +3208,13 @@ export default function Home() {
|
||||
const updateStreamingAnswer = (activity?: AgentActivityView) => {
|
||||
const partialReply = parseAgentReply(answer).text;
|
||||
latestPartialReply = partialReply;
|
||||
setStreamingReply({ sessionId, text: partialReply, activity });
|
||||
setStreamingReply((current) => ({
|
||||
sessionId,
|
||||
text: partialReply,
|
||||
activity: activity
|
||||
? nextActivityView(current?.sessionId === sessionId ? current.activity : undefined, activity)
|
||||
: current?.sessionId === sessionId ? current.activity : undefined,
|
||||
}));
|
||||
if (partialReply && pendingConsultation.current?.requestId === requestId) {
|
||||
pendingConsultation.current = { ...pendingConsultation.current, partialReply };
|
||||
}
|
||||
@@ -3208,15 +3222,29 @@ export default function Home() {
|
||||
const updateActivity = (event: ConsultationAgentPublicEvent) => {
|
||||
let activity: AgentActivityView | undefined;
|
||||
if (event.type === "skill.started") {
|
||||
activity = { phase: "loading-method", label: "正在读取印度占星分析规则…" };
|
||||
} else if (event.type === "tool.started") {
|
||||
activity = { phase: "chart-calculation", label: "正在计算本命盘…" };
|
||||
activity = { phase: "loading-method", label: CONSULTATION_LOADING_METHOD_LABEL };
|
||||
} else if (event.type === "skill.completed" || event.type === "tool.started") {
|
||||
activity = {
|
||||
phase: "chart-calculation",
|
||||
label: CONSULTATION_CHART_CALCULATION_LABEL,
|
||||
completedTrail: activityCompletedTrail([CONSULTATION_DONE_SKILL_LABEL]),
|
||||
};
|
||||
} else if (event.type === "activity") {
|
||||
activity = { phase: event.phase, label: event.label };
|
||||
activity = {
|
||||
phase: event.phase,
|
||||
label: event.label,
|
||||
completedTrail: event.phase === "evidence-validation"
|
||||
? activityCompletedTrail([CONSULTATION_DONE_SKILL_LABEL, CONSULTATION_DONE_CHART_LABEL])
|
||||
: activityCompletedTrail([CONSULTATION_DONE_SKILL_LABEL]),
|
||||
};
|
||||
} else if (event.type === "tool.completed") {
|
||||
activity = { phase: "evidence-validation", label: "正在核对可用证据…" };
|
||||
activity = {
|
||||
phase: "evidence-validation",
|
||||
label: CONSULTATION_EVIDENCE_VALIDATION_LABEL,
|
||||
completedTrail: activityCompletedTrail([CONSULTATION_DONE_SKILL_LABEL, CONSULTATION_DONE_CHART_LABEL]),
|
||||
};
|
||||
} else if (event.type === "answer.delta") {
|
||||
activity = { phase: "answer-composition", label: "正在组织回答…" };
|
||||
activity = { phase: "answer-composition", label: CONSULTATION_COMPOSING_LABEL };
|
||||
}
|
||||
if (activity) updateStreamingAnswer(activity);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user