fix code queue trace message fragments

This commit is contained in:
Codex
2026-05-16 15:58:30 +00:00
parent 9fad202b96
commit 6263f83926
5 changed files with 180 additions and 7 deletions
+59 -1
View File
@@ -921,6 +921,64 @@ function coalesceFileChangeTraceSteps(steps: any[]): any[] {
return merged;
}
function traceStepMessageMergeKey(step: any): string {
if (String(step?.kind || "") !== "message") return "";
const title = String(step?.title || "").trim().toLowerCase();
if (title !== "assistant message" && title !== "reasoning") return "";
return `${title}:${String(step?.status || "")}`;
}
function mergeMessageTraceStepGroup(group: any[]): any {
if (group.length <= 1) return group[0];
const first = group[0];
const last = group.at(-1) || first;
const rawSeqs = group.flatMap((step) => Array.isArray(step?.rawSeqs) ? step.rawSeqs : [step?.seq]).filter((seq) => seq !== undefined);
const seenRawSeqs: any[] = [];
for (const seq of rawSeqs) if (!seenRawSeqs.includes(seq)) seenRawSeqs.push(seq);
const summaryLines = group
.flatMap(traceStepSummaryLines)
.filter((line) => line.trim().length > 0);
return {
...first,
seq: traceStepSeqValue(last) || traceStepSeqValue(first),
at: last?.at || first?.at,
summaryLines: summaryLines.length > 0 ? [summaryLines.at(-1) || summaryLines[0]] : [],
rawSeqs: seenRawSeqs,
};
}
function coalesceMessageTraceSteps(steps: any[]): any[] {
const rows = Array.isArray(steps) ? steps : [];
const merged: any[] = [];
let group: any[] = [];
let groupKey = "";
const flush = () => {
if (group.length > 0) merged.push(mergeMessageTraceStepGroup(group));
group = [];
groupKey = "";
};
for (const step of rows) {
const key = traceStepMessageMergeKey(step);
if (key.length > 0 && key === groupKey) {
group.push(step);
continue;
}
flush();
if (key.length > 0) {
group = [step];
groupKey = key;
} else {
merged.push(step);
}
}
flush();
return merged;
}
function coalesceTraceSteps(steps: any[]): any[] {
return coalesceMessageTraceSteps(coalesceFileChangeTraceSteps(steps));
}
function canonicalExecutionSummary(execution: AnyRecord): AnyRecord {
return { ...execution };
}
@@ -1638,7 +1696,7 @@ function ProgressivePromptBlock({ task, loading, onLoadPromptPart, testId = "cod
}
function ProgressiveExecutionSummary({ task, attempt, attemptIndex, loading, onLoadSteps, onLoadStep, testId = "codex-execution-summary" }: AnyRecord) {
const steps = coalesceFileChangeTraceSteps(taskTraceSteps(task, attemptIndex));
const steps = coalesceTraceSteps(taskTraceSteps(task, attemptIndex));
const execution = canonicalExecutionSummary(attemptExecutionSummary(task, attempt));
const stats = attempt ? attemptOaTraceStats(task, attempt) : taskOaTraceStats(task);
const stepDetails = taskTraceStepDetails(task);