fix: normalize codex app plan completion status

This commit is contained in:
shiyue
2026-06-26 12:06:24 +08:00
parent 756b9651f9
commit 911dd84c35
2 changed files with 17 additions and 3 deletions

View File

@@ -235,6 +235,19 @@ function createCodexAppRuntime(deps = {}) {
};
}
function isTodoListPlanDone(item, todoList) {
const status = normalizeIdentifier(item?.status || item?.state);
if (['completed', 'complete', 'done', 'success', 'succeeded', 'failed', 'error', 'cancelled', 'canceled'].includes(status)) {
return true;
}
return Array.isArray(todoList?.items) && todoList.items.length > 0 && todoList.items.every((planItem) => planItem.completed);
}
function todoListPlanStatus(item, todoList) {
if (isTodoListPlanDone(item, todoList)) return 'completed';
return item?.status || 'inProgress';
}
function planUpdateItemFromParams(params = {}) {
const item = params.item && typeof params.item === 'object' ? { ...params.item } : {};
return {
@@ -415,12 +428,13 @@ function createCodexAppRuntime(deps = {}) {
function itemMeta(item) {
if (!item) return null;
if (normalizeTodoListFromPlanItem(item)) {
const todoList = normalizeTodoListFromPlanItem(item);
if (todoList) {
return {
kind: 'todo_list',
title: 'Plan List',
subtitle: item.explanation || item.title || item.tool || '',
status: item.status || null,
status: todoListPlanStatus(item, todoList),
};
}
switch (item.type) {
@@ -748,7 +762,7 @@ function createCodexAppRuntime(deps = {}) {
const item = planUpdateItemFromParams(params);
const todoList = normalizeTodoListFromPlanItem(item);
if (!todoList) return { done: false };
updateToolResult(entry, sessionId, todoList.id, JSON.stringify(todoList, null, 2), false, {
updateToolResult(entry, sessionId, todoList.id, JSON.stringify(todoList, null, 2), isTodoListPlanDone(item, todoList), {
name: 'PlanList',
kind: 'todo_list',
input: todoList,