MCPcopy
hub / github.com/openai/codex-plugin-cc / completeTurn

Function completeTurn

plugins/codex/scripts/lib/codex.mjs:346–371  ·  view source on GitHub ↗
(state, turn = null, options = {})

Source from the content-addressed store, hash-verified

344}
345
346function completeTurn(state, turn = null, options = {}) {
347 if (state.completed) {
348 return;
349 }
350
351 clearCompletionTimer(state);
352 state.completed = true;
353
354 if (turn) {
355 state.finalTurn = turn;
356 if (!state.turnId) {
357 state.turnId = turn.id;
358 }
359 } else if (!state.finalTurn) {
360 state.finalTurn = {
361 id: state.turnId ?? "inferred-turn",
362 status: "completed"
363 };
364 }
365
366 if (options.inferred) {
367 emitProgress(state.onProgress, "Turn completion inferred after the main thread finished and subagent work drained.", "finalizing");
368 }
369
370 state.resolveCompletion(state);
371}
372
373function scheduleInferredCompletion(state) {
374 if (state.completed || state.finalTurn || !state.finalAnswerSeen) {

Callers 3

applyTurnNotificationFunction · 0.85
captureTurnFunction · 0.85

Calls 2

clearCompletionTimerFunction · 0.85
emitProgressFunction · 0.85

Tested by

no test coverage detected