Skip to content

fix(todo): render todo diffs in strict id order with status-aware removed states#2512

Merged
tusharmath merged 6 commits intomainfrom
fix-todo-status-display
Mar 11, 2026
Merged

fix(todo): render todo diffs in strict id order with status-aware removed states#2512
tusharmath merged 6 commits intomainfrom
fix-todo-status-display

Conversation

@amitksingh1490
Copy link
Copy Markdown
Contributor

@amitksingh1490 amitksingh1490 commented Mar 9, 2026

Summary

Fix todo diff rendering so entries are consistently ordered by todo id, while preserving status-specific visual semantics for completed and removed items.

Context

The todo UI diff flow was showing removed completed tasks at the end of the list instead of their id position, which made timeline updates visually confusing. We also needed to preserve the intended status semantics: completed items in the current list should remain green, while completed items removed in later updates should still be shown as historical done items in gray.

Changes

  • Sorted rendered todo output by id in both standard todo rendering and diff rendering.
  • Reworked todo diff rendering to merge current and removed entries into a single sorted stream before rendering.
  • Preserved green styling for currently completed todos.
  • Added gray dimmed rendering for removed completed todos.
  • Kept red rendering for removed non-completed todos.
  • Updated snapshot and added focused tests for dump-flow ordering and removed-completed behavior.

Key Implementation Details

  • Introduced an internal merged diff-line representation in format_todos_diff to combine:
    • current todos (after) with bold/dim emphasis logic
    • removed todos (before - after) with status-aware removed styling
  • Applied a single sort by todo.id across both groups to guarantee stable ordering in UI diff output.
  • Added regression coverage mirroring the real dump sequence (4-step flow) to ensure ordering and status rendering remain correct.

Use Cases

  • Multi-step todo updates where completed tasks are removed later now render in correct id position instead of being appended.
  • Operators can distinguish:
    • current completed (green)
    • historical removed completed (gray)
    • canceled/removed pending or in-progress (red)

Testing

cargo test -p forge_app todo_fmt
cargo build
./target/debug/forge -p "Reproduce this exact todo flow using todo_write only and no other tools unless required: Step1 ids 1..6 with statuses [1 in_progress,2 pending,3 pending,4 pending,5 pending,6 pending] and matching contents from the dump; Step2 mark id1 completed and id2 in_progress; Step3 remove id1 and mark id2 completed and id3 in_progress; Step4 remove id2 and mark id3 completed id4 completed id5 in_progress id6 pending. After each step, continue to next step."

Links

  • Conversation dump reproduced during validation: 2026-03-09_17-33-41-dump (1).html

@github-actions github-actions Bot added the type: fix Iterations on existing features or infrastructure. label Mar 9, 2026
@amitksingh1490 amitksingh1490 changed the title fix(todo): sort todo output by id and preserve removed completed status fix(todo): render todo diffs in strict id order with status-aware removed states Mar 9, 2026
@amitksingh1490
Copy link
Copy Markdown
Contributor Author

Before:
Screenshot 2026-03-09 at 5 32 41 PM

After
image

@amitksingh1490
Copy link
Copy Markdown
Contributor Author

image maintaining whole state

Comment thread crates/forge_domain/src/session_metrics.rs
@tusharmath tusharmath merged commit 970a75f into main Mar 11, 2026
9 checks passed
@tusharmath tusharmath deleted the fix-todo-status-display branch March 11, 2026 08:14
tusharmath pushed a commit that referenced this pull request Mar 13, 2026
…oved states (#2512)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants