* 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[])
| 1317 | * This ensures the full/sparse cycle resets when re-entering auto mode. |
| 1318 | */ |
| 1319 | function countAutoModeAttachmentsSinceLastExit(messages: Message[]): number { |
| 1320 | let count = 0 |
| 1321 | for (let i = messages.length - 1; i >= 0; i--) { |
| 1322 | const message = messages[i] |
| 1323 | if (message?.type === 'attachment') { |
| 1324 | if (message.attachment.type === 'auto_mode_exit') { |
| 1325 | break |
| 1326 | } |
| 1327 | if (message.attachment.type === 'auto_mode') { |
| 1328 | count++ |
| 1329 | } |
| 1330 | } |
| 1331 | } |
| 1332 | return count |
| 1333 | } |
| 1334 | |
| 1335 | async function getAutoModeAttachments( |
| 1336 | messages: Message[] | undefined, |
no outgoing calls
no test coverage detected