fix: normalize codex app plan completion status
This commit is contained in:
Binary file not shown.
@@ -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 = {}) {
|
function planUpdateItemFromParams(params = {}) {
|
||||||
const item = params.item && typeof params.item === 'object' ? { ...params.item } : {};
|
const item = params.item && typeof params.item === 'object' ? { ...params.item } : {};
|
||||||
return {
|
return {
|
||||||
@@ -415,12 +428,13 @@ function createCodexAppRuntime(deps = {}) {
|
|||||||
|
|
||||||
function itemMeta(item) {
|
function itemMeta(item) {
|
||||||
if (!item) return null;
|
if (!item) return null;
|
||||||
if (normalizeTodoListFromPlanItem(item)) {
|
const todoList = normalizeTodoListFromPlanItem(item);
|
||||||
|
if (todoList) {
|
||||||
return {
|
return {
|
||||||
kind: 'todo_list',
|
kind: 'todo_list',
|
||||||
title: 'Plan List',
|
title: 'Plan List',
|
||||||
subtitle: item.explanation || item.title || item.tool || '',
|
subtitle: item.explanation || item.title || item.tool || '',
|
||||||
status: item.status || null,
|
status: todoListPlanStatus(item, todoList),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
@@ -748,7 +762,7 @@ function createCodexAppRuntime(deps = {}) {
|
|||||||
const item = planUpdateItemFromParams(params);
|
const item = planUpdateItemFromParams(params);
|
||||||
const todoList = normalizeTodoListFromPlanItem(item);
|
const todoList = normalizeTodoListFromPlanItem(item);
|
||||||
if (!todoList) return { done: false };
|
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',
|
name: 'PlanList',
|
||||||
kind: 'todo_list',
|
kind: 'todo_list',
|
||||||
input: todoList,
|
input: todoList,
|
||||||
|
|||||||
Reference in New Issue
Block a user