(role, text)
| 110 | let streamingEntry = null; |
| 111 | |
| 112 | function addTranscript(role, text) { |
| 113 | // Remove the placeholder if present |
| 114 | const placeholder = transcript.querySelector('.italic'); |
| 115 | if (placeholder) placeholder.remove(); |
| 116 | |
| 117 | const entry = document.createElement('div'); |
| 118 | entry.className = 'flex items-start space-x-2'; |
| 119 | |
| 120 | const icon = document.createElement('i'); |
| 121 | const msg = document.createElement('p'); |
| 122 | msg.className = 'text-[var(--color-text-primary)]'; |
| 123 | msg.textContent = text; |
| 124 | |
| 125 | if (role === 'user') { |
| 126 | icon.className = 'fa-solid fa-user text-[var(--color-primary)] mt-1 flex-shrink-0'; |
| 127 | } else { |
| 128 | icon.className = 'fa-solid fa-robot text-[var(--color-accent)] mt-1 flex-shrink-0'; |
| 129 | } |
| 130 | |
| 131 | entry.appendChild(icon); |
| 132 | entry.appendChild(msg); |
| 133 | transcript.appendChild(entry); |
| 134 | transcript.scrollTop = transcript.scrollHeight; |
| 135 | return entry; |
| 136 | } |
| 137 | |
| 138 | function updateStreamingTranscript(role, delta) { |
| 139 | if (!streamingEntry) { |
no test coverage detected