MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / getPreviousTodos

Function getPreviousTodos

webview-ui/src/components/chat/ChatRow.tsx:82–112  ·  view source on GitHub ↗
(messages: ClineMessage[], currentMessageTs: number)

Source from the content-addressed store, hash-verified

80
81// Helper function to get previous todos before a specific message
82function getPreviousTodos(messages: ClineMessage[], currentMessageTs: number): any[] {
83 // Find the previous updateTodoList message before the current one
84 const previousUpdateIndex = messages
85 .slice()
86 .reverse()
87 .findIndex((msg) => {
88 if (msg.ts >= currentMessageTs) return false
89 if (msg.type === "ask" && msg.ask === "tool") {
90 try {
91 const tool = JSON.parse(msg.text || "{}")
92 return tool.tool === "updateTodoList"
93 } catch {
94 return false
95 }
96 }
97 return false
98 })
99
100 if (previousUpdateIndex !== -1) {
101 const previousMessage = messages.slice().reverse()[previousUpdateIndex]
102 try {
103 const tool = JSON.parse(previousMessage.text || "{}")
104 return tool.todos || []
105 } catch {
106 return []
107 }
108 }
109
110 // If no previous updateTodoList message, return empty array
111 return []
112}
113
114interface ChatRowProps {
115 message: ClineMessage

Callers 1

ChatRowContentFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected