-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Chat - more working set cleanup and refactoring #288362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the chat working set rendering code to simplify parameter passing and improve code maintainability by consolidating data transformations upstream.
Changes:
- Removed unused
IChatSessionFileChangeimport - Simplified
renderChatEditingSessionWithEntriesmethod signature by removing intermediate observables and relying on pre-transformedIChatCollapsibleListItemobservables - Refactored statistics calculation to use unified
IChatCollapsibleListItemstructure instead of raw data sources, improving consistency and reducing duplication
| if (entries.length > 0) { | ||
| for (const entry of entries) { | ||
| if (entry.kind === 'reference' && entry.options?.diffMeta) { | ||
| added += entry.options.diffMeta.added; | ||
| removed += entry.options.diffMeta.removed; | ||
| } | ||
| } | ||
| } else { | ||
| for (const entry of sessionEntries) { | ||
| if (entry.kind === 'reference' && entry.options?.diffMeta) { | ||
| added += entry.options.diffMeta.added; | ||
| removed += entry.options.diffMeta.removed; | ||
| } |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff stats calculation logic is duplicated between the two branches. The code should accumulate stats from both entries and sessionEntries arrays instead of using an if-else. Based on line 2588 where both arrays are combined, both arrays can contain relevant data simultaneously. Change the logic to iterate over both arrays unconditionally to avoid missing diff stats when both arrays have data.
| if (entries.length > 0) { | |
| for (const entry of entries) { | |
| if (entry.kind === 'reference' && entry.options?.diffMeta) { | |
| added += entry.options.diffMeta.added; | |
| removed += entry.options.diffMeta.removed; | |
| } | |
| } | |
| } else { | |
| for (const entry of sessionEntries) { | |
| if (entry.kind === 'reference' && entry.options?.diffMeta) { | |
| added += entry.options.diffMeta.added; | |
| removed += entry.options.diffMeta.removed; | |
| } | |
| for (const entry of entries) { | |
| if (entry.kind === 'reference' && entry.options?.diffMeta) { | |
| added += entry.options.diffMeta.added; | |
| removed += entry.options.diffMeta.removed; | |
| } | |
| } | |
| for (const entry of sessionEntries) { | |
| if (entry.kind === 'reference' && entry.options?.diffMeta) { | |
| added += entry.options.diffMeta.added; | |
| removed += entry.options.diffMeta.removed; |
No description provided.