@@ -18,6 +18,7 @@ import { formatPathTooltip } from "@src/utils/formatPathTooltip"
1818
1919import { ToolUseBlock , ToolUseBlockHeader } from "../common/ToolUseBlock"
2020import UpdateTodoListToolBlock from "./UpdateTodoListToolBlock"
21+ import { TodoChangeDisplay } from "./TodoChangeDisplay"
2122import CodeAccordian from "../common/CodeAccordian"
2223import MarkdownBlock from "../common/MarkdownBlock"
2324import { ReasoningBlock } from "./ReasoningBlock"
@@ -62,6 +63,39 @@ import {
6263import { cn } from "@/lib/utils"
6364import { PathTooltip } from "../ui/PathTooltip"
6465
66+ // Helper function to get previous todos before a specific message
67+ function getPreviousTodos ( messages : ClineMessage [ ] , currentMessageTs : number ) : any [ ] {
68+ // Find the previous updateTodoList message before the current one
69+ const previousUpdateIndex = messages
70+ . slice ( )
71+ . reverse ( )
72+ . findIndex ( ( msg ) => {
73+ if ( msg . ts >= currentMessageTs ) return false
74+ if ( msg . type === "ask" && msg . ask === "tool" ) {
75+ try {
76+ const tool = JSON . parse ( msg . text || "{}" )
77+ return tool . tool === "updateTodoList"
78+ } catch {
79+ return false
80+ }
81+ }
82+ return false
83+ } )
84+
85+ if ( previousUpdateIndex !== - 1 ) {
86+ const previousMessage = messages . slice ( ) . reverse ( ) [ previousUpdateIndex ]
87+ try {
88+ const tool = JSON . parse ( previousMessage . text || "{}" )
89+ return tool . todos || [ ]
90+ } catch {
91+ return [ ]
92+ }
93+ }
94+
95+ // If no previous updateTodoList message, return empty array
96+ return [ ]
97+ }
98+
6599interface ChatRowProps {
66100 message : ClineMessage
67101 lastModifiedMessage ?: ClineMessage
@@ -127,11 +161,10 @@ export const ChatRowContent = ({
127161 onFollowUpUnmount,
128162 onBatchFileResponse,
129163 isFollowUpAnswered,
130- editable,
131164} : ChatRowContentProps ) => {
132165 const { t } = useTranslation ( )
133166
134- const { mcpServers, alwaysAllowMcp, currentCheckpoint, mode, apiConfiguration } = useExtensionState ( )
167+ const { mcpServers, alwaysAllowMcp, currentCheckpoint, mode, apiConfiguration, clineMessages } = useExtensionState ( )
135168 const { info : model } = useSelectedModel ( apiConfiguration )
136169 const [ isEditing , setIsEditing ] = useState ( false )
137170 const [ editedContent , setEditedContent ] = useState ( "" )
@@ -503,18 +536,11 @@ export const ChatRowContent = ({
503536 }
504537 case "updateTodoList" as any : {
505538 const todos = ( tool as any ) . todos || [ ]
506- return (
507- < UpdateTodoListToolBlock
508- todos = { todos }
509- content = { tool . content }
510- onChange = { ( updatedTodos ) => {
511- if ( typeof vscode !== "undefined" && vscode ?. postMessage ) {
512- vscode . postMessage ( { type : "updateTodoList" , payload : { todos : updatedTodos } } )
513- }
514- } }
515- editable = { editable && isLast }
516- />
517- )
539+
540+ // Get previous todos from the latest todos in the task context
541+ const previousTodos = getPreviousTodos ( clineMessages , message . ts )
542+
543+ return < TodoChangeDisplay previousTodos = { previousTodos } newTodos = { todos } />
518544 }
519545 case "newFileCreated" :
520546 return (
0 commit comments