Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

@ammar-agent ammar-agent commented Oct 14, 2025

Adds TodoWrite and TodoRead tools to enable the AI to manage task lists during complex operations, following Claude Code's pattern with a simplified schema.

Changes

Tool Implementation:

  • TodoWrite: Full-replacement semantics (replaces entire list on each call)
  • TodoRead: Returns current todo list
  • Stream-scoped filesystem storage in tmpdir (automatic cleanup when stream ends)
  • Schema: content, status (pending/in_progress/completed), activeForm fields

UI Component:

  • Visual indicators: ✓ (completed), ⏳ (in_progress), ○ (pending)
  • Shows activeForm text for in-progress items
  • Color-coded borders and backgrounds by status

Testing:

  • Unit tests for storage layer (7 tests)
  • All existing tests pass (477 total)

Design Decisions

Simplified schema: Removed id, priority, timestamps, and metadata fields (unnecessary complexity). Added activeForm for better UX ("Adding tests" vs "Add tests").

Stream-scoped storage: TODOs stored in stream's tmpdir as todos.json. Automatically cleaned up when stream ends. Each stream has isolated storage (no cross-stream pollution).

Full-replacement semantics: AI replaces entire list on each call. Simpler than incremental updates and matches Claude Code's pattern.

Benefits

Automatic cleanup: tmpdir removed when stream ends, preventing memory leaks
Stream isolation: Concurrent streams in same workspace don't share TODOs
Inspectable: Can view todos.json during debugging
Crash resilient: TODOs persisted to disk during stream

Generated with cmux

- Add TodoWrite and TodoRead tools for managing task lists during operations
- Schema includes content, status (pending/in_progress/completed), and activeForm fields
- In-memory storage with workspace isolation (ephemeral, conversation-scoped)
- UI component displays checklist with visual indicators (✓/⏳/○)
- Full-replacement semantics (replaces entire list on each call)
- Unit tests for storage layer

Generated with `cmux`
Changes:
- Replace in-memory Map storage with filesystem storage in stream's tmpdir
- TODOs are now automatically cleaned up when stream ends
- Each stream has isolated TODO storage (no cross-stream pollution)
- Test helper functions updated to use tempDir instead of workspaceId

Benefits:
- Fixes memory leaks (TODOs no longer survive across conversations)
- Proper stream isolation (concurrent streams don't share TODOs)
- Automatic lifecycle management via streamManager cleanup
- TODOs are inspectable during debugging (stored as todos.json)

_Generated with `cmux`_
Enforce ordering rules for todo_write tool:
- TODOs must be ordered: pending → in_progress → completed
- Only one task can be in_progress at a time
- Empty lists are allowed (all completed or nothing to do)

Changes:
- Added validateTodos() function with state machine validation
- writeTodos() now validates before persisting to disk
- Updated all tests to use valid todo ordering
- Added 4 new test cases for validation rules

Benefits:
- Prevents model from creating invalid TODO states
- Clear error messages guide model to fix ordering
- Validation happens before filesystem write (atomic)

_Generated with `cmux`_
@ammar-agent ammar-agent force-pushed the todo branch 2 times, most recently from b3405b9 to fb640f8 Compare October 14, 2025 17:53
Remove invalid type parameters from jest.fn() mock - Jest's Mock type
only accepts 0-1 type arguments in TypeScript, not the tuple syntax
used previously.

_Generated with `cmux`_
- Reduced vertical spacing: gap 8px→3px, padding 8px→4px
- Tighter line-height: 1.5→1.35
- Smaller font size: 12px→11px (activeForm 10px)
- Thinner border-left: 3px→2px
- Subtler backgrounds (92%/96% transparency vs 90%/95%)
- Added opacity to completed items for visual hierarchy
- Refined icon and text sizes for density
- In-progress tasks now display activeForm instead of content
- Added CSS animation for ellipsis (...) on activeForm
- Animation cycles through '', '.', '..', '...' every 1.5s
- Increased activeForm font size to 11px (matches other text)
- Removed margin-top since activeForm is now the primary text
- Changed animation from content change to width animation
- Uses overflow: hidden with steps(4, end) for smooth dots reveal
- Fixed width prevents layout shifts and line breaks
- Ellipsis animates from 0 width to 1em, showing dots progressively
Changes:
- Validation now enforces completed first, in_progress middle, pending last
- Updated all test fixtures to match new order
- Updated tool description to emphasize using TODOs for all complex multi-step operations
- Fixed ellipsis animation to prevent line breaks (width animation with overflow:hidden)
- In-progress tasks now show only activeForm (not content) with animated ellipsis

This creates a more natural progress view: what's done → what's happening → what's next
- Use TooltipWrapper pattern for emoji display (matches other tools)
- Removed ToolName component in favor of tooltip
- Added instruction to mark all todos completed before finishing stream
- Ensures consistency with bash, file_read, etc. tool displays
@ammario ammario marked this pull request as ready for review October 14, 2025 19:58
@ammario ammario merged commit 81d1568 into main Oct 14, 2025
7 checks passed
@ammario ammario deleted the todo branch October 14, 2025 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants