feat: show total lines added/removed in task header#11244
Draft
roomote[bot] wants to merge 1 commit intomainfrom
Draft
feat: show total lines added/removed in task header#11244roomote[bot] wants to merge 1 commit intomainfrom
roomote[bot] wants to merge 1 commit intomainfrom
Conversation
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
useDiffStatshook (webview-ui/src/components/chat/hooks/useDiffStats.ts) iterates throughclineMessages, parses tool messages (ask="tool"andsay="tool"), and extractsdiffStatsfrom file-editing tools (editedExistingFile,appliedDiff,newFileCreated). It also handlesbatchDiffsper-file stats. The result is memoized.Compact view (collapsed header): Shows
+N / -Nwith 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 / -Nstats, matching the existing visual pattern of the Tokens, Cache, and API Cost rows.Uses the existing
text-vscode-charts-greenandtext-vscode-charts-redTailwind 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.cd webview-ui && npx vitest run src/components/chat/hooks/__tests__/useDiffStats.spec.tsIntegration 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.
cd webview-ui && npx vitest run src/components/chat/__tests__/TaskHeader.spec.tsxAll 40 tests pass (14 hook + 26 TaskHeader including 6 new).
Pre-Submission Checklist
Documentation Updates
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
useDiffStatshook and updates UI for compact and expanded views.useDiffStatshook inuseDiffStats.tsto calculate total lines added/removed fromclineMessages.TaskHeader.tsxto display+N / -Nin compact view and "Lines Changed" in expanded view.text-vscode-charts-greenandtext-vscode-charts-redfor styling.aggregateDiffStatsinuseDiffStats.spec.ts.TaskHeaderinTaskHeader.spec.tsxto cover various display scenarios.chat.jsonfor i18n support.This description was created by
for 524c8d5. You can customize this summary. It will automatically update as commits are pushed.