Skip to content

feat: show total lines added/removed in task header#11244

Draft
roomote[bot] wants to merge 1 commit intomainfrom
feature/task-diff-stats-display
Draft

feat: show total lines added/removed in task header#11244
roomote[bot] wants to merge 1 commit intomainfrom
feature/task-diff-stats-display

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Feb 6, 2026

Related GitHub Issue

Closes: #11213

Description

This PR attempts to address Issue #11213 by adding aggregated line change stats (+added / -removed) to the TaskHeader component.

How it works:

  • A new useDiffStats hook (webview-ui/src/components/chat/hooks/useDiffStats.ts) iterates through clineMessages, parses tool messages (ask="tool" and say="tool"), and extracts diffStats from file-editing tools (editedExistingFile, appliedDiff, newFileCreated). It also handles batchDiffs per-file stats. The result is memoized.

  • Compact view (collapsed header): Shows +N / -N with green/red coloring next to the cost display, separated by a dot divider. Only shown when there are actual file changes.

  • Expanded view (expanded header): Adds a "Lines Changed" row in the details table showing the same +N / -N stats, matching the existing visual pattern of the Tokens, Cache, and API Cost rows.

  • Uses the existing text-vscode-charts-green and text-vscode-charts-red Tailwind classes, matching the CodeAccordian per-file diff display pattern already in use.

Test Procedure

  • Unit tests for aggregateDiffStats (14 tests): Covers undefined/empty messages, ask/say tool messages, all file-edit tool types, batch diffs, malformed JSON, null text, and mixed message types.

    • Run: cd webview-ui && npx vitest run src/components/chat/hooks/__tests__/useDiffStats.spec.ts
  • Integration tests for TaskHeader (6 new tests added to existing spec): Covers no diff stats shown when no edits, compact view display, expanded view display, aggregation across multiple messages, and zero-stat edge case.

    • Run: cd webview-ui && npx vitest run src/components/chat/__tests__/TaskHeader.spec.tsx

All 40 tests pass (14 hook + 26 TaskHeader including 6 new).

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue.
  • Scope: Changes are focused on the linked issue.
  • Self-Review: Self-reviewed.
  • Testing: New tests added (14 unit + 6 integration).
  • Documentation Impact: No documentation updates required.
  • Contribution Guidelines: Read and agreed.

Documentation Updates

  • No documentation updates are required.

Additional Notes

Feedback and guidance are welcome. This is an initial implementation covering the core feature. Future enhancements could include per-file breakdown in expanded view and an opt-out toggle setting.


Important

Adds line change stats to TaskHeader with new useDiffStats hook and updates UI for compact and expanded views.

  • Behavior:
    • Adds useDiffStats hook in useDiffStats.ts to calculate total lines added/removed from clineMessages.
    • Updates TaskHeader.tsx to display +N / -N in compact view and "Lines Changed" in expanded view.
    • Uses text-vscode-charts-green and text-vscode-charts-red for styling.
  • Tests:
    • Adds 14 unit tests for aggregateDiffStats in useDiffStats.spec.ts.
    • Adds 6 integration tests for TaskHeader in TaskHeader.spec.tsx to cover various display scenarios.
  • Localization:
    • Adds "Lines Changed" label to chat.json for i18n support.

This description was created by Ellipsis for 524c8d5. You can customize this summary. It will automatically update as commits are pushed.

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.

[ENHANCEMENT] Show Total and Net lines of code added/removed per task and/or iteration

1 participant