()
| 592 | |
| 593 | // ── 8. History flush + drain helpers ──────────────────────────────────── |
| 594 | function drainFlushGate(): void { |
| 595 | const msgs = flushGate.end() |
| 596 | if (msgs.length === 0) return |
| 597 | for (const msg of msgs) recentPostedUUIDs.add(msg.uuid) |
| 598 | const events = toSDKMessages(msgs).map(m => ({ |
| 599 | ...m, |
| 600 | session_id: sessionId, |
| 601 | })) |
| 602 | if (msgs.some(m => m.type === 'user')) { |
| 603 | transport.reportState('running') |
| 604 | } |
| 605 | logForDebugging( |
| 606 | `[remote-bridge] Drained ${msgs.length} queued message(s) after flush`, |
| 607 | ) |
| 608 | void transport.writeBatch(events) |
| 609 | } |
| 610 | |
| 611 | async function flushHistory(msgs: Message[]): Promise<void> { |
| 612 | // v2 always creates a fresh server session (unconditional createCodeSession |
no test coverage detected