Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions webview-ui/src/components/chat/TodoChangeDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,38 +55,41 @@ function TodoList({ todos, status, keyPrefix, className }: TodoGroup) {
export function TodoChangeDisplay({ previousTodos, newTodos }: TodoChangeDisplayProps) {
const isInitialState = previousTodos.length === 0

// Reverse the todos array to display in correct order (first to last)
const reversedTodos = [...newTodos].reverse()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix assumes the backend sends todos in reverse order, but reviewing the data flow shows no reversal: parseMarkdownChecklist in UpdateTodoListTool.ts processes lines sequentially (first line = first todo), and the data is passed to the frontend without modification. If the display was actually reversed, the root cause may be elsewhere (e.g., in how messages are stored or retrieved). Without tests or evidence confirming the backend reversal, this blanket .reverse() could introduce incorrect ordering if the assumption is wrong. Consider adding a unit test that verifies the expected input/output behavior, or investigate whether the reversal occurs in message storage/retrieval rather than the todos array itself.

Fix it with Roo Code or mention @roomote and request a fix.


// Determine which todos to display
let todoGroups: TodoGroup[]

if (isInitialState && newTodos.length > 0) {
if (isInitialState && reversedTodos.length > 0) {
// For initial state, show all todos grouped by status
todoGroups = [
{
todos: newTodos.filter((todo) => !todo.status || todo.status === "pending"),
todos: reversedTodos.filter((todo) => !todo.status || todo.status === "pending"),
status: null,
keyPrefix: "pending",
},
{
todos: newTodos.filter((todo) => todo.status === "in_progress"),
todos: reversedTodos.filter((todo) => todo.status === "in_progress"),
status: "in_progress",
keyPrefix: "in-progress",
className: "text-vscode-charts-yellow",
},
{
todos: newTodos.filter((todo) => todo.status === "completed"),
todos: reversedTodos.filter((todo) => todo.status === "completed"),
status: "completed",
keyPrefix: "completed",
},
]
} else {
// For updates, only show changes
const completedTodos = newTodos.filter((newTodo) => {
const completedTodos = reversedTodos.filter((newTodo) => {
if (newTodo.status !== "completed") return false
const previousTodo = previousTodos.find((p) => p.id === newTodo.id || p.content === newTodo.content)
return !previousTodo || previousTodo.status !== "completed"
})

const startedTodos = newTodos.filter((newTodo) => {
const startedTodos = reversedTodos.filter((newTodo) => {
if (newTodo.status !== "in_progress") return false
const previousTodo = previousTodos.find((p) => p.id === newTodo.id || p.content === newTodo.content)
return !previousTodo || previousTodo.status !== "in_progress"
Expand Down
Loading