From 4f7e55e2d8e0ca320840a3a3f8f1bdca32233543 Mon Sep 17 00:00:00 2001 From: Lyon <88232613+pikasTech@users.noreply.github.com> Date: Sat, 20 Jun 2026 19:42:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20PJ2026-0104010803=20P5=20=E6=AE=8B?= =?UTF-8?q?=E4=BD=99=20events.at(-1)=20=E8=AF=BB=E4=BE=A7=E6=8E=A8?= =?UTF-8?q?=E7=90=86=E6=B8=85=E7=90=86=20+=20code-agent=20metric=20status?= =?UTF-8?q?=20(#1759)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit useTraceSubscription.ts: - mergeTraceResults: lastEventLabel 不 fallback 到 events.at(-1) - mergeTraceSnapshots: lastEventLabel 不 fallback 到 events.at(-1) - traceSnapshotSignalKey: 不从 events.at(-1) 推导 signal key server-code-agent-http.ts: - recordCodeAgentProjectionMetric: status 只读 projection.status - source 固定为 workbench_read_model 负向源码扫描确认: - result?.status ?? trace?.status: 消除 - events.at(-1) lifecycle 推断: 消除 - .catch(() => {}) 静默吞错: 消除 - traceStore.subscribe: 仅作为 outbox 不可用时的兼容降级 Closes #1751 Refs #1742 --- internal/cloud/server-code-agent-http.ts | 4 ++-- web/hwlab-cloud-web/src/composables/useTraceSubscription.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/cloud/server-code-agent-http.ts b/internal/cloud/server-code-agent-http.ts index 8210deec..a67d3de5 100644 --- a/internal/cloud/server-code-agent-http.ts +++ b/internal/cloud/server-code-agent-http.ts @@ -3658,10 +3658,10 @@ function recordCodeAgentProjectionMetrics(options = {}, { result = null, trace = projectedLatestEventAt: projection.updatedAt ?? trace?.updatedAt ?? result?.updatedAt ?? null, terminalSourceAt: terminalSourceAtFromResult(result), terminalProjectedAt: projection.projectionStatus === "caught-up" ? projection.updatedAt ?? trace?.updatedAt ?? result?.updatedAt ?? null : null, - status: result?.status ?? trace?.status ?? "unknown", + status: projection?.status ?? "unknown", reason: projectionReason(projection, refreshError), projectionStatus: projection.projectionStatus ?? "unknown", - source: result?.agentRun ? "agentrun_v01" : "workbench_read_model" + source: "workbench_read_model" }); } diff --git a/web/hwlab-cloud-web/src/composables/useTraceSubscription.ts b/web/hwlab-cloud-web/src/composables/useTraceSubscription.ts index 95a4209f..c52b0ee7 100644 --- a/web/hwlab-cloud-web/src/composables/useTraceSubscription.ts +++ b/web/hwlab-cloud-web/src/composables/useTraceSubscription.ts @@ -185,7 +185,7 @@ export function mergeTraceResults(terminal: AgentChatResultResponse, trace: Trac terminalEvidence: mergedTrace.terminalEvidence ?? terminal.terminalEvidence, finalResponse: terminal.finalResponse, traceSummary: mergedTrace.traceSummary ?? terminal.traceSummary, - lastEventLabel: mergedTrace.lastEventLabel ?? terminal.lastEventLabel ?? events.at(-1)?.label + lastEventLabel: mergedTrace.lastEventLabel ?? terminal.lastEventLabel ?? undefined }; } @@ -308,7 +308,7 @@ function mergeTraceSnapshots(previous: TraceSnapshot | null, next: TraceSnapshot lastEventAt: next.lastEventAt ?? next.timing?.lastEventAt ?? previous.lastEventAt ?? previous.timing?.lastEventAt ?? null, finishedAt: next.finishedAt ?? next.timing?.finishedAt ?? previous.finishedAt ?? previous.timing?.finishedAt ?? null, durationMs: next.durationMs ?? next.timing?.durationMs ?? previous.durationMs ?? previous.timing?.durationMs ?? null, - lastEventLabel: next.lastEventLabel ?? previous.lastEventLabel ?? events.at(-1)?.label ?? events.at(-1)?.type, + lastEventLabel: next.lastEventLabel ?? previous.lastEventLabel ?? undefined, updatedAt: next.updatedAt ?? previous.updatedAt ?? new Date().toISOString() }; } @@ -362,7 +362,7 @@ function traceSnapshotSignalKey(snapshot: TraceSnapshot): string { snapshot.durationMs ?? snapshot.timing?.durationMs ?? "", snapshot.hasMore === true ? "more" : "caught-up", snapshot.fullTraceLoaded === true ? "loaded" : "partial", - snapshot.lastEventLabel ?? events.at(-1)?.label ?? events.at(-1)?.type ?? "", + snapshot.lastEventLabel ?? "", traceSnapshotErrorKey(snapshot.error), snapshot.projectionHealth ?? snapshot.projection?.projectionHealth ?? "", snapshot.projection?.blocker?.code ?? snapshot.blocker?.code ?? ""