fix: stop resetting missing-terminal timeout on notifications (#238)
This commit is contained in:
@@ -572,6 +572,7 @@ async function runCodexStdioTurnWithSession(options: CodexStdioTurnOptions, sess
|
||||
let idleTimeout: NodeJS.Timeout | null = null;
|
||||
let idleWarningTimeout: NodeJS.Timeout | null = null;
|
||||
let missingTerminalAfterToolTimeout: NodeJS.Timeout | null = null;
|
||||
let lastToolCallAt: number | null = null;
|
||||
const turnHardTimeoutAttrs = (): JsonRecord => ({
|
||||
waitingFor,
|
||||
elapsedMs: Math.max(0, Date.now() - turnStartedAt),
|
||||
@@ -586,6 +587,7 @@ async function runCodexStdioTurnWithSession(options: CodexStdioTurnOptions, sess
|
||||
retryMaxAttempts: 0,
|
||||
retryExhausted: true,
|
||||
lastToolCall,
|
||||
toolIdleMs: lastToolCallAt === null ? null : Math.max(0, Date.now() - lastToolCallAt),
|
||||
});
|
||||
const failTurnHardTimeout = (): void => {
|
||||
if (terminal) return;
|
||||
@@ -637,6 +639,7 @@ async function runCodexStdioTurnWithSession(options: CodexStdioTurnOptions, sess
|
||||
resolveTerminalNow();
|
||||
};
|
||||
const scheduleMissingTerminalAfterToolTimeout = (): void => {
|
||||
if (!lastToolCall) return;
|
||||
clearMissingTerminalAfterToolTimeout();
|
||||
missingTerminalAfterToolTimeout = setTimeout(failMissingTerminalAfterTool, missingTerminalAfterToolTimeoutMs);
|
||||
missingTerminalAfterToolTimeout.unref?.();
|
||||
@@ -656,7 +659,6 @@ async function runCodexStdioTurnWithSession(options: CodexStdioTurnOptions, sess
|
||||
if (terminal) return;
|
||||
lastActivityAt = Date.now();
|
||||
scheduleIdleWarning();
|
||||
if (lastToolCall) scheduleMissingTerminalAfterToolTimeout();
|
||||
if (idleTimeout) clearTimeout(idleTimeout);
|
||||
idleTimeout = setTimeout(() => {
|
||||
if (terminal) return;
|
||||
@@ -691,6 +693,7 @@ async function runCodexStdioTurnWithSession(options: CodexStdioTurnOptions, sess
|
||||
const toolSummary = toolCallSummaryFromNotification(message);
|
||||
if (toolSummary?.status === "completed" || toolSummary?.status === "failed") {
|
||||
lastToolCall = toolSummary;
|
||||
lastToolCallAt = Date.now();
|
||||
missingTerminalAfterToolReported = false;
|
||||
scheduleMissingTerminalAfterToolTimeout();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user