* Count plan_mode attachments since the last plan_mode_exit (or from start if no exit). * This ensures the full/sparse cycle resets when re-entering plan mode.
(messages: Message[])
| 1167 | * This ensures the full/sparse cycle resets when re-entering plan mode. |
| 1168 | */ |
| 1169 | function countPlanModeAttachmentsSinceLastExit(messages: Message[]): number { |
| 1170 | let count = 0 |
| 1171 | // Iterate backwards - if we hit a plan_mode_exit, stop counting |
| 1172 | for (let i = messages.length - 1; i >= 0; i--) { |
| 1173 | const message = messages[i] |
| 1174 | if (message?.type === 'attachment') { |
| 1175 | if (message.attachment.type === 'plan_mode_exit') { |
| 1176 | break // Stop counting at the last exit |
| 1177 | } |
| 1178 | if (message.attachment.type === 'plan_mode') { |
| 1179 | count++ |
| 1180 | } |
| 1181 | } |
| 1182 | } |
| 1183 | return count |
| 1184 | } |
| 1185 | |
| 1186 | async function getPlanModeAttachments( |
| 1187 | messages: Message[] | undefined, |
no outgoing calls
no test coverage detected