()
| 632 | |
| 633 | // ── 8. History flush + drain helpers ──────────────────────────────────── |
| 634 | function drainFlushGate(): void { |
| 635 | const msgs = flushGate.end() |
| 636 | if (msgs.length === 0) return |
| 637 | for (const msg of msgs) recentPostedUUIDs.add(msg.uuid) |
| 638 | const events: TransportMessage[] = toSDKMessages(msgs).map(m => ({ |
| 639 | ...m, |
| 640 | session_id: sessionId, |
| 641 | })) as TransportMessage[] |
| 642 | if (shouldReportRunningForMessages(msgs)) { |
| 643 | transport.reportState('running') |
| 644 | } |
| 645 | logForDebugging( |
| 646 | `[remote-bridge] Drained ${msgs.length} queued message(s) after flush`, |
| 647 | ) |
| 648 | void transport.writeBatch(events as StdoutMessage[]) |
| 649 | } |
| 650 | |
| 651 | async function flushHistory(msgs: Message[]): Promise<void> { |
| 652 | // v2 always creates a fresh server session (unconditional createCodeSession |
no test coverage detected