feat: add GitHub-style diff stats display to task header #4823
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.
Summary
Adds a GitHub-style diff stats display to the task header showing the number of lines added and removed by the current task. The UI updates in real-time as the user accepts file changes.
Changes
New Files
webview-ui/src/components/ui/hooks/kilocode/useTaskDiffStats.ts: Custom React hook that aggregates diff stats from all accepted file operations in the task's message historywebview-ui/src/components/kilocode/DiffStatsDisplay.tsx: GitHub-style component displaying "+X −Y" with proportional colored boxes (green for additions, red for deletions)webview-ui/src/components/ui/hooks/__tests__/useTaskDiffStats.spec.ts: Comprehensive tests for the hookwebview-ui/src/components/kilocode/__tests__/DiffStatsDisplay.spec.tsx: Tests for the display componentModified Files
webview-ui/src/components/kilocode/KiloTaskHeader.tsx: Integrated the diff stats display in both collapsed and expanded stateswebview-ui/src/i18n/locales/en/chat.json: Added "Changes" translation keyHow It Works
useTaskDiffStatshook iterates throughclineMessagesand filters for answered tool requests that have diff statsaddedandremovedcounts from both single file operations and batch operations (batchDiffs)DiffStatsDisplaycomponent renders the stats with:Visual Example
The display looks like:
+8 −4 ■■■■□where:Testing