(force = false)
| 601 | }; |
| 602 | |
| 603 | const streamAssistantDraft = (force = false) => { |
| 604 | const combined = buildAssistantPayload(); |
| 605 | if (!combined) { |
| 606 | return; |
| 607 | } |
| 608 | if (!force && combined === lastStreamedAssistantPayload) { |
| 609 | return; |
| 610 | } |
| 611 | const id = assistantMessageId ?? (assistantMessageId = randomUUID()); |
| 612 | |
| 613 | // Enhanced duplicate prevention |
| 614 | if (streamedMessageIds.has(id) && !force) { |
| 615 | console.debug(`[CodexService] Assistant message ${id} already streamed, skipping`); |
| 616 | return; |
| 617 | } |
| 618 | |
| 619 | const realtime = createRealtimeMessage({ |
| 620 | id, |
| 621 | projectId, |
| 622 | role: 'assistant', |
| 623 | messageType: 'chat', |
| 624 | content: combined, |
| 625 | metadata: { cli_type: 'codex' }, |
| 626 | cliSource: 'codex', |
| 627 | requestId, |
| 628 | isStreaming: true, |
| 629 | isFinal: false, |
| 630 | }); |
| 631 | streamManager.publish(projectId, { type: 'message', data: realtime }); |
| 632 | streamedMessageIds.add(id); |
| 633 | lastStreamedAssistantPayload = combined; |
| 634 | console.debug(`[CodexService] Streamed assistant message: ${id} (length: ${combined.length})`); |
| 635 | }; |
| 636 | |
| 637 | const resetAssistantBuffers = () => { |
| 638 | agentBuffer = ''; |
no test coverage detected