fix: reduce codex submit success noise
This commit is contained in:
@@ -2773,6 +2773,101 @@ function compactTaskMutationResponse(task: unknown, options: CompactTaskMutation
|
||||
};
|
||||
}
|
||||
|
||||
function compactSubmitTaskConfirmation(task: unknown): Record<string, unknown> {
|
||||
const record = asRecord(task) ?? {};
|
||||
const taskId = asString(record.id);
|
||||
const prompt = asString(record.displayPrompt ?? record.basePrompt ?? record.prompt);
|
||||
return {
|
||||
id: taskId || null,
|
||||
queueId: record.queueId ?? null,
|
||||
status: record.status ?? null,
|
||||
queuedReason: record.queuedReason ?? null,
|
||||
providerId: record.providerId ?? null,
|
||||
model: record.model ?? null,
|
||||
reasoningEffort: record.reasoningEffort ?? null,
|
||||
cwd: record.cwd ?? null,
|
||||
executionMode: record.executionMode ?? null,
|
||||
maxAttempts: record.maxAttempts ?? null,
|
||||
createdAt: record.createdAt ?? null,
|
||||
updatedAt: record.updatedAt ?? null,
|
||||
promptChars: prompt.length,
|
||||
promptOmitted: true,
|
||||
commands: taskId.length === 0 ? null : {
|
||||
show: `bun scripts/cli.ts codex task ${taskId}`,
|
||||
detail: `bun scripts/cli.ts codex task ${taskId} --detail`,
|
||||
trace: `bun scripts/cli.ts codex task ${taskId} --trace --tail --limit ${defaultTraceLimit}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function compactSubmitQueueConfirmation(value: unknown): Record<string, unknown> | null {
|
||||
const record = asRecord(value);
|
||||
if (record === null) return null;
|
||||
return {
|
||||
total: record.total ?? null,
|
||||
queueCount: record.queueCount ?? null,
|
||||
counts: record.counts ?? null,
|
||||
activeQueueIds: boundedUniqueStringList(record.activeQueueIds, 8),
|
||||
activeTaskIds: boundedUniqueStringList(record.activeTaskIds ?? record.databaseActiveTaskIds, 8),
|
||||
queuedTaskIds: boundedUniqueStringList(record.queuedTaskIds, 8),
|
||||
executionDiagnostics: compactQueueExecutionDiagnostics(record.executionDiagnostics),
|
||||
};
|
||||
}
|
||||
|
||||
function compactSubmitConcurrencyGuard(value: Record<string, unknown>): Record<string, unknown> {
|
||||
return {
|
||||
mode: value.mode ?? null,
|
||||
acquiredAfterMs: value.acquiredAfterMs ?? null,
|
||||
heldMs: value.heldMs ?? null,
|
||||
throttleMs: value.throttleMs ?? null,
|
||||
staleMs: value.staleMs ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
function compactSubmitSuccessResponse(body: Record<string, unknown>, upstream: Record<string, unknown>, lock: Record<string, unknown>): Record<string, unknown> {
|
||||
const allTasks = asArray(body.tasks).map(compactSubmitTaskConfirmation);
|
||||
const tasks = allTasks.slice(0, defaultTasksLimit);
|
||||
const allTaskIds = allTasks.map((task) => asString(task.id)).filter(Boolean);
|
||||
const taskIds = allTaskIds.slice(0, defaultTasksLimit);
|
||||
const queueIds = Array.from(new Set(tasks.map((task) => asString(task.queueId)).filter(Boolean))).sort();
|
||||
const firstTaskId = taskIds[0] ?? null;
|
||||
const firstQueueId = queueIds[0] ?? null;
|
||||
return {
|
||||
ok: true,
|
||||
upstream,
|
||||
submitted: {
|
||||
accepted: true,
|
||||
taskCount: allTasks.length,
|
||||
returnedTaskCount: tasks.length,
|
||||
taskIds,
|
||||
taskIdsCount: allTaskIds.length,
|
||||
taskIdsTruncated: allTaskIds.length > taskIds.length,
|
||||
queueIds,
|
||||
tasks,
|
||||
tasksTruncated: allTasks.length > tasks.length,
|
||||
promptOmitted: true,
|
||||
outputPolicy: {
|
||||
default: "write-confirmation",
|
||||
promptEchoed: false,
|
||||
reason: "codex submit is a write operation; default output confirms persistence and provides drill-down commands without echoing prompt text.",
|
||||
},
|
||||
},
|
||||
queue: compactSubmitQueueConfirmation(body.queue),
|
||||
submitConcurrencyGuard: compactSubmitConcurrencyGuard(lock),
|
||||
commands: {
|
||||
firstTask: firstTaskId === null ? null : `bun scripts/cli.ts codex task ${firstTaskId}`,
|
||||
firstTaskDetail: firstTaskId === null ? null : `bun scripts/cli.ts codex task ${firstTaskId} --detail`,
|
||||
queue: firstQueueId === null ? null : `bun scripts/cli.ts codex tasks --queue ${firstQueueId} --limit ${defaultTasksLimit}`,
|
||||
supervisor: `bun scripts/cli.ts codex tasks --view supervisor --limit ${defaultTasksLimit}`,
|
||||
queues: "bun scripts/cli.ts codex queues",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function compactSubmitSuccessResponseForTest(body: Record<string, unknown>, upstream: Record<string, unknown> = { ok: true, status: 200 }, lock: Record<string, unknown> = {}): Record<string, unknown> {
|
||||
return compactSubmitSuccessResponse(body, upstream, lock);
|
||||
}
|
||||
|
||||
function codexReadTask(taskId: string): unknown {
|
||||
const response = unwrapCodexResponse(coreInternalFetch(codeQueueProxyPath(`/api/tasks/${encodeURIComponent(taskId)}/read`), { method: "POST", body: {} }));
|
||||
return {
|
||||
@@ -3728,12 +3823,7 @@ function codexSubmitTask(args: string[]): unknown {
|
||||
}
|
||||
const locked = runWithSubmitLock(() => unwrapCodexResponse(coreInternalFetch(codeQueueProxyPath("/api/tasks"), { method: "POST", body: payload })));
|
||||
const response = locked.result;
|
||||
return {
|
||||
upstream: response.upstream,
|
||||
tasks: asArray(response.body.tasks).map((task) => compactTaskMutationResponse(task, { fullPrompt: true })),
|
||||
queue: compactQueueMutationSummary(response.body.queue),
|
||||
submitConcurrencyGuard: locked.lock,
|
||||
};
|
||||
return compactSubmitSuccessResponse(response.body, response.upstream, locked.lock);
|
||||
}
|
||||
|
||||
function codexInterruptTask(taskId: string): unknown {
|
||||
|
||||
Reference in New Issue
Block a user