MCPcopy Create free account
hub / github.com/tiann/hapi / interruptActiveTurns

Method interruptActiveTurns

cli/src/codex/codexRemoteLauncher.ts:199–237  ·  view source on GitHub ↗
(reason: string)

Source from the content-addressed store, hash-verified

197 }
198
199 private async interruptActiveTurns(reason: string): Promise<void> {
200 const turnsToInterrupt = [
201 ...(this.currentThreadId && this.currentTurnId
202 ? [{ threadId: this.currentThreadId, turnId: this.currentTurnId, role: 'parent' as const }]
203 : []),
204 ...Array.from(this.activeChildTurns, ([threadId, turnId]) => ({
205 threadId,
206 turnId,
207 role: 'child' as const
208 }))
209 ];
210
211 if (turnsToInterrupt.length === 0) {
212 return;
213 }
214
215 const results = await Promise.allSettled(
216 turnsToInterrupt.map((target) => this.appServerClient.interruptTurn({
217 threadId: target.threadId,
218 turnId: target.turnId
219 }))
220 );
221
222 results.forEach((result, index) => {
223 const target = turnsToInterrupt[index];
224 if (result.status === 'fulfilled') {
225 if (target.role === 'child') {
226 this.activeChildTurns.delete(target.threadId);
227 }
228 return;
229 }
230
231 logger.debug(
232 `[Codex] Error interrupting ${target.role} app-server turn ` +
233 `for ${reason}; threadId=${target.threadId} turnId=${target.turnId}:`,
234 result.reason
235 );
236 });
237 }
238
239 private async handleAbort(): Promise<void> {
240 logger.debug('[Codex] Abort requested - stopping current task');

Callers 2

handleAbortMethod · 0.95
interruptActiveTurnMethod · 0.95

Calls 2

debugMethod · 0.80
interruptTurnMethod · 0.45

Tested by

no test coverage detected