(clineMessages: ClineMessage[])
| 1 | import { ClineMessage } from "@roo-code/types" |
| 2 | |
| 3 | export function getLatestTodo(clineMessages: ClineMessage[]) { |
| 4 | const todos = clineMessages |
| 5 | .filter( |
| 6 | (msg) => |
| 7 | (msg.type === "ask" && msg.ask === "tool") || (msg.type === "say" && msg.say === "user_edit_todos"), |
| 8 | ) |
| 9 | .map((msg) => { |
| 10 | try { |
| 11 | return JSON.parse(msg.text ?? "{}") |
| 12 | } catch { |
| 13 | return null |
| 14 | } |
| 15 | }) |
| 16 | .filter((item) => item && item.tool === "updateTodoList" && Array.isArray(item.todos)) |
| 17 | .map((item) => item.todos) |
| 18 | .pop() |
| 19 | |
| 20 | if (todos) { |
| 21 | return todos |
| 22 | } else { |
| 23 | return [] |
| 24 | } |
| 25 | } |
no test coverage detected