|
4 | 4 | buildAssistantStreamData, |
5 | 5 | consumePendingToolMediaIntoReply, |
6 | 6 | consumePendingToolMediaReply, |
| 7 | + discardAlreadySentPendingToolMedia, |
7 | 8 | handleMessageEnd, |
8 | 9 | handleMessageUpdate, |
9 | 10 | hasAssistantVisibleReply, |
@@ -229,6 +230,34 @@ describe("consumePendingToolMediaIntoReply", () => { |
229 | 230 | }); |
230 | 231 | }); |
231 | 232 |
|
| 233 | +describe("discardAlreadySentPendingToolMedia", () => { |
| 234 | + it("removes pending media that was already delivered via a messaging tool", () => { |
| 235 | + const state = { |
| 236 | + pendingToolMediaUrls: ["/tmp/a.mp3", "/tmp/b.mp3"], |
| 237 | + pendingToolAudioAsVoice: true, |
| 238 | + messagingToolSentMediaUrls: ["/tmp/a.mp3"], |
| 239 | + }; |
| 240 | + |
| 241 | + discardAlreadySentPendingToolMedia(state); |
| 242 | + |
| 243 | + expect(state.pendingToolMediaUrls).toEqual(["/tmp/b.mp3"]); |
| 244 | + expect(state.pendingToolAudioAsVoice).toBe(true); |
| 245 | + }); |
| 246 | + |
| 247 | + it("clears the voice flag when all pending media was already delivered", () => { |
| 248 | + const state = { |
| 249 | + pendingToolMediaUrls: ["/tmp/a.mp3"], |
| 250 | + pendingToolAudioAsVoice: true, |
| 251 | + messagingToolSentMediaUrls: ["/tmp/a.mp3"], |
| 252 | + }; |
| 253 | + |
| 254 | + discardAlreadySentPendingToolMedia(state); |
| 255 | + |
| 256 | + expect(state.pendingToolMediaUrls).toEqual([]); |
| 257 | + expect(state.pendingToolAudioAsVoice).toBe(false); |
| 258 | + }); |
| 259 | +}); |
| 260 | + |
232 | 261 | describe("consumePendingToolMediaReply", () => { |
233 | 262 | it("builds a media-only reply for orphaned tool media", () => { |
234 | 263 | const state = { |
|
0 commit comments