diff --git a/frontend/src/components/message/TodoItem.tsx b/frontend/src/components/message/TodoItem.tsx
new file mode 100644
index 00000000..7a8c4592
--- /dev/null
+++ b/frontend/src/components/message/TodoItem.tsx
@@ -0,0 +1,46 @@
+import type { components } from '@/api/opencode-types'
+import { CheckCircle2, Circle } from 'lucide-react'
+
+export type Todo = components['schemas']['Todo']
+
+interface TodoItemProps {
+ todo: Todo
+ compact?: boolean
+}
+
+export function TodoItem({ todo, compact = false }: TodoItemProps) {
+ const isCompleted = todo.status === 'completed'
+ const isInProgress = todo.status === 'in_progress'
+
+ const priorityColor = todo.priority === 'high'
+ ? 'bg-red-500'
+ : todo.priority === 'medium'
+ ? 'bg-yellow-500'
+ : 'bg-blue-400'
+
+ return (
+
+ {isCompleted ? (
+
+ ) : isInProgress ? (
+
+ ) : (
+
+ )}
+ {todo.priority && (
+
+ )}
+
+ {todo.content}
+
+
+ )
+}
diff --git a/frontend/src/components/message/TodoListDisplay.tsx b/frontend/src/components/message/TodoListDisplay.tsx
new file mode 100644
index 00000000..539f64f5
--- /dev/null
+++ b/frontend/src/components/message/TodoListDisplay.tsx
@@ -0,0 +1,134 @@
+import type { components } from '@/api/opencode-types'
+import { TodoItem } from './TodoItem'
+import { useEffect, useRef } from 'react'
+
+export type Todo = components['schemas']['Todo']
+
+interface TodoListDisplayProps {
+ todos: Todo[]
+ title?: string
+ showCompleted?: boolean
+ scrollCurrentOnly?: boolean
+ isLoading?: boolean
+}
+
+export function TodoListDisplay({
+ todos,
+ title = 'Todo List',
+ showCompleted = true,
+ scrollCurrentOnly = false,
+ isLoading = false,
+}: TodoListDisplayProps) {
+ const scrollRef = useRef(null)
+
+ // Filter completed tasks if not showing them
+ const filteredTodos = showCompleted
+ ? todos
+ : todos.filter((t) => t.status !== 'completed')
+
+ // Group by status for better organization
+ const inProgress = filteredTodos.filter((t) => t.status === 'in_progress')
+ const pending = filteredTodos.filter((t) => t.status === 'pending')
+ const completed = showCompleted
+ ? filteredTodos.filter((t) => t.status === 'completed')
+ : []
+
+ const hasMultipleGroups =
+ (inProgress.length > 0 ? 1 : 0) +
+ (pending.length > 0 ? 1 : 0) +
+ (completed.length > 0 ? 1 : 0) >
+ 1
+
+ // Auto-scroll to current task (in_progress or first pending) within container only
+ useEffect(() => {
+ if (scrollRef.current && scrollCurrentOnly && filteredTodos.length > 0) {
+ const container = scrollRef.current
+ const currentElement = container.querySelector('[data-status="in_progress"], [data-status="pending"]') as HTMLElement | null
+ if (currentElement) {
+ const containerTop = container.scrollTop
+ const containerHeight = container.clientHeight
+ const elementTop = currentElement.offsetTop - container.offsetTop
+ const elementHeight = currentElement.offsetHeight
+
+ if (elementTop < containerTop) {
+ container.scrollTop = elementTop
+ } else if (elementTop + elementHeight > containerTop + containerHeight) {
+ container.scrollTop = elementTop + elementHeight - containerHeight
+ }
+ }
+ }
+ }, [todos, scrollCurrentOnly, filteredTodos.length])
+
+ // Empty states
+ if (!todos || todos.length === 0) {
+ return (
+
+ No tasks in the todo list.
+
+ )
+ }
+
+ if (filteredTodos.length === 0) {
+ return (
+
+ ✓
+ All tasks completed!
+
+ )
+ }
+
+ const renderGroup = (label: string, items: Todo[], isCollapsible = false) => {
+ if (items.length === 0) return null
+ return (
+
+ {hasMultipleGroups && (
+
+ {label} ({items.length})
+
+ )}
+
3 ? 'max-h-[60px] overflow-hidden relative after:absolute after:bottom-0 after:left-0 after:right-0 after:h-4 after:bg-gradient-to-t after:from-card after:to-transparent' : ''}>
+ {items.map((todo) => (
+
+
+
+ ))}
+
+
+ )
+ }
+
+ const progress = filteredTodos.length > 0
+ ? Math.round((filteredTodos.filter(t => t.status === 'completed').length / filteredTodos.length) * 100)
+ : 0
+
+ return (
+
+ {/* Compact header with progress bar */}
+
+
{title}
+ {isLoading && (
+
+ )}
+
+
+ {filteredTodos.filter(t => t.status === 'completed').length}/{filteredTodos.length}
+
+
+
+ {/* Scrollable content area - optimized height for visibility */}
+
+ {renderGroup('In Progress', inProgress)}
+ {renderGroup('Pending', pending)}
+ {renderGroup('Completed', completed, true)}
+
+
+ )
+}
diff --git a/frontend/src/components/message/ToolCallPart.tsx b/frontend/src/components/message/ToolCallPart.tsx
index 10faca17..6b9e8149 100644
--- a/frontend/src/components/message/ToolCallPart.tsx
+++ b/frontend/src/components/message/ToolCallPart.tsx
@@ -5,8 +5,10 @@ import { useUserBash } from '@/stores/userBashStore'
import { detectFileReferences } from '@/lib/fileReferences'
import { ExternalLink, Loader2 } from 'lucide-react'
import { CopyButton } from '@/components/ui/copy-button'
+import { TodoListDisplay } from './TodoListDisplay'
type ToolPart = components['schemas']['ToolPart']
+type Todo = components['schemas']['Todo']
interface ToolCallPartProps {
part: ToolPart
@@ -54,6 +56,17 @@ function ClickableJson({ json, onFileClick }: { json: unknown; onFileClick?: (fi
return {parts}
}
+function parseTodoOutput(output: string): Todo[] | null {
+ try {
+ const parsed = JSON.parse(output)
+ if (Array.isArray(parsed)) return parsed
+ if (parsed && Array.isArray(parsed.todos)) return parsed.todos
+ return null
+ } catch {
+ return null
+ }
+}
+
export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCallPartProps) {
const { preferences } = useSettings()
const { userBashCommands } = useUserBash()
@@ -62,7 +75,10 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
part.state.status === 'completed' &&
typeof part.state.input?.command === 'string' &&
userBashCommands.has(part.state.input.command)
- const defaultExpanded = isUserBashCommand || (preferences?.expandToolCalls ?? false)
+ const isTodoTool = part.tool === 'todowrite' || part.tool === 'todoread'
+
+ // Todo tools show expanded content by default, other tools use preference
+ const defaultExpanded = isUserBashCommand || isTodoTool || (preferences?.expandToolCalls ?? false)
const [expanded, setExpanded] = useState(defaultExpanded)
useEffect(() => {
@@ -120,14 +136,98 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
return (input.path as string) || '.'
case 'task':
return (input.description as string) || null
+ case 'todowrite':
+ case 'todoread':
+ return null
default:
return null
}
}
+ const getTodoData = () => {
+ if (part.tool !== 'todowrite' && part.tool !== 'todoread') {
+ return null
+ }
+
+ const state = part.state
+
+ // For completed state - has output and metadata
+ if (state.status === 'completed') {
+ if (state.metadata?.todos && Array.isArray(state.metadata.todos)) {
+ return state.metadata.todos as Todo[]
+ }
+ if (state.output) {
+ const parsed = parseTodoOutput(state.output)
+ if (parsed) return parsed
+ }
+ }
+
+ // For running state - might have metadata
+ if (state.status === 'running' && state.metadata?.todos && Array.isArray(state.metadata.todos)) {
+ return state.metadata.todos as Todo[]
+ }
+
+ // For any state - try input (used by todowrite)
+ if (state.input?.todos && Array.isArray(state.input.todos)) {
+ return state.input.todos as Todo[]
+ }
+
+ return null
+ }
+
const previewText = getPreviewText()
+ const todoData = getTodoData()
const isFileTool = ['read', 'write', 'edit'].includes(part.tool)
+ // For todo tools, render the TodoListDisplay directly without wrapper
+ if (isTodoTool) {
+ if (part.state.status === 'pending') {
+ return (
+
+
+ Preparing task list...
+
+ )
+ }
+
+ if (part.state.status === 'running') {
+ return (
+
+
+
+ )
+ }
+
+ if (part.state.status === 'completed') {
+ return (
+
+
+
+ )
+ }
+
+ if (part.state.status === 'error') {
+ return (
+
+ Error updating tasks: {part.state.error}
+
+ )
+ }
+
+ return null
+ }
+
if (isUserBashCommand) {
const command = part.state.input.command as string
const output = part.state.status === 'completed' ? part.state.output : ''
@@ -175,11 +275,13 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
>
{getStatusIcon()}
{part.tool}
+
+ {/* Header preview text */}
{previewText && isFileTool ? (
{
e.stopPropagation()
- if (onFileClick) {
+ if (onFileClick && previewText) {
onFileClick(previewText)
}
}}
@@ -191,8 +293,12 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
) : previewText ? (
{previewText}
) : null}
+
{part.tool === 'task' && (() => {
- const sessionId = (part.metadata?.sessionId ?? (part.state.status !== 'pending' && part.state.metadata?.sessionId)) as string | undefined
+ let sessionId: string | undefined = part.metadata?.sessionId as string | undefined
+ if (!sessionId && part.state.status !== 'pending' && 'metadata' in part.state) {
+ sessionId = part.state.metadata?.sessionId as string | undefined
+ }
return sessionId ? (
{
@@ -210,6 +316,7 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
({part.state.status})
+ {/* Expanded content for non-todo tools */}
{expanded && (
{part.state.status === 'pending' && (
@@ -222,7 +329,7 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
Preparing tool call...
)}
-
+
{part.state.status === 'running' && (
<>
{part.tool === 'bash' ? (