(retries: number)
| 327 | } |
| 328 | |
| 329 | async function flushPromptHistory(retries: number): Promise<void> { |
| 330 | if (isWriting || pendingEntries.length === 0) { |
| 331 | return |
| 332 | } |
| 333 | |
| 334 | // Stop trying to flush history until the next user prompt |
| 335 | if (retries > 5) { |
| 336 | return |
| 337 | } |
| 338 | |
| 339 | isWriting = true |
| 340 | |
| 341 | try { |
| 342 | await immediateFlushHistory() |
| 343 | } finally { |
| 344 | isWriting = false |
| 345 | |
| 346 | if (pendingEntries.length > 0) { |
| 347 | // Avoid trying again in a hot loop |
| 348 | await sleep(500) |
| 349 | |
| 350 | void flushPromptHistory(retries + 1) |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | async function addToPromptHistory( |
| 356 | command: HistoryEntry | string, |
no test coverage detected