* Count auto_mode attachments since the last auto_mode_exit (or from start if no exit). * This ensures the full/sparse cycle resets when re-entering auto mode.
(messages: Message[])
| 1323 | * This ensures the full/sparse cycle resets when re-entering auto mode. |
| 1324 | */ |
| 1325 | function countAutoModeAttachmentsSinceLastExit(messages: Message[]): number { |
| 1326 | let count = 0 |
| 1327 | for (let i = messages.length - 1; i >= 0; i--) { |
| 1328 | const message = messages[i] |
| 1329 | if (message?.type === 'attachment') { |
| 1330 | if (message.attachment.type === 'auto_mode_exit') { |
| 1331 | break |
| 1332 | } |
| 1333 | if (message.attachment.type === 'auto_mode') { |
| 1334 | count++ |
| 1335 | } |
| 1336 | } |
| 1337 | } |
| 1338 | return count |
| 1339 | } |
| 1340 | |
| 1341 | async function getAutoModeAttachments( |
| 1342 | messages: Message[] | undefined, |
no outgoing calls
no test coverage detected