( eventsPath: string, wsId: string, wsName: string, customInstructionsBytes?: number, onProgress?: (bytesRead: number, totalBytes: number) => void, )
| 427 | * longer blocks the worker for minutes or freezes the host progress bar (issue #106). |
| 428 | */ |
| 429 | export async function parseCLIEventsFileAsync( |
| 430 | eventsPath: string, |
| 431 | wsId: string, |
| 432 | wsName: string, |
| 433 | customInstructionsBytes?: number, |
| 434 | onProgress?: (bytesRead: number, totalBytes: number) => void, |
| 435 | ): Promise<Session | null> { |
| 436 | const state = createInitialCliState(wsId); |
| 437 | |
| 438 | let sawAnyEvent = false; |
| 439 | try { |
| 440 | await forEachJsonlLineAsync(eventsPath, (line) => { |
| 441 | if (!line.trim()) return; |
| 442 | const event = parseCLIEventLine(line); |
| 443 | if (event) { |
| 444 | handleCliEvent(event, state, wsId); |
| 445 | sawAnyEvent = true; |
| 446 | } |
| 447 | }, onProgress); |
| 448 | } catch (e) { |
| 449 | recordFailedFile('parser-vscode-cli', eventsPath, e); |
| 450 | return null; |
| 451 | } |
| 452 | |
| 453 | if (!sawAnyEvent) return null; |
| 454 | |
| 455 | return finalizeCliSession(state, wsId, wsName, customInstructionsBytes); |
| 456 | } |
| 457 |
no test coverage detected