Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Description

Notebook entries in the chat editing view always displayed +0/-0 diff stats regardless of actual changes. The UI code in chatInputPart.ts checks for linesAdded and linesRemoved properties before accumulating stats, but ChatEditingModifiedNotebookEntry did not implement these optional properties from the IModifiedFileEntry interface.

Changes

Added linesAdded and linesRemoved getters to ChatEditingModifiedNotebookEntry:

  • linesAdded: Counts inserted and modified cells (skips cells with identical diffs)
  • linesRemoved: Counts deleted cells (skips cells with identical diffs)
  • countCellChanges: Helper method to reduce duplication, properly typed using ICellDiffInfo['type']

Returns IObservable<number> using the same .map() pattern as the text file implementation. Treats cells as the unit of change, analogous to lines in text files.

Example: A notebook with 3 modified cells and 1 deleted cell now shows +3/-1 instead of +0/-0.

Original prompt

This section details on the original issue you should resolve

<issue_title>+0/-0 diff displayed for all notebook changes in chat view</issue_title>
<issue_description>In working in edit sessions, I was getting notebooks working (though most diffing doesn't work right now.) I want to at least get parity. I had a simple change that updated three of the four cells in a notebook. No moves/deletions, and the changes were pretty minor.

The notebookDiff here looked somewhat broken:

const notebookDiff = await this.notebookEditorWorkerService.computeDiff(this.originalURI, this.modifiedURI);

{
  metadataChanged: false,
  cellsDiff: {
    changes: [
      {
        originalStart: 0,
        originalLength: 1,
        modifiedStart: 0,
        modifiedLength: 1,
      },
      {
        originalStart: 1,
        originalLength: 1,
        modifiedStart: 1,
        modifiedLength: 1,
      },
      {
        originalStart: 2,
        originalLength: 1,
        modifiedStart: 2,
        modifiedLength: 1,
      },
      {
        originalStart: 0,
        originalLength: 2,
        modifiedStart: 0,
        modifiedLength: 2,
      },
      {
        originalStart: 0,
        originalLength: 1,
        modifiedStart: 0,
        modifiedLength: 1,
      },
      {
        originalStart: 1,
        originalLength: 1,
        modifiedStart: 1,
        modifiedLength: 1,
      },
      {
        originalStart: 2,
        originalLength: 1,
        modifiedStart: 2,
        modifiedLength: 1,
      },
      {
        originalStart: 3,
        originalLength: 1,
        modifiedStart: 3,
        modifiedLength: 1,
      },
      {
        originalStart: 0,
        originalLength: 1,
        modifiedStart: 0,
        modifiedLength: 1,
      },
      {
        originalStart: 1,
        originalLength: 1,
        modifiedStart: 1,
        modifiedLength: 1,
      },
      {
        originalStart: 2,
        originalLength: 1,
        modifiedStart: 2,
        modifiedLength: 1,
      },
    ],
    quitEarly: false,
  },
}

I wonder if this is why for any notebook edits, the working set always shows +0 / -0</issue_description>

Comments on the Issue (you are @copilot in this section)

@DonJayamanne @connor4312 I'm sorry I missed this. In this case we are getting changes indicated at cell level. From what I can tell cells 1,2,3 changed.

The reason its 0/0 is because of the following code in chatInputPar.ts

				if (entry.linesAdded && entry.linesRemoved) {
					added += entry.linesAdded.read(reader);
					removed += entry.linesRemoved.read(reader);
				}

The notebook entry does not have line level diff information.
Its not really possible to get this as the underlying file format may be text and may not be text.
We offer diff information at cell level (how many cells were modified/inserted/deleted and the changes per cell).

I think linesAdded?: IObservable and linesRemoved?:IObservable is the problem here.
These are optional & Notebook does not have these properties (hence the above if (entry.linesAdded && entry.linesRemoved)
We might want to remove the notion of added/removed lines and have added/removed changes as simple counters.

This way notebook can just give added = number of cells added/updated/moved and removed = number of cells removed
& regular files and give added = number of lines added & removed = number of lines removed

@justschen /cc as I believe you may have added this change for text files.

I can try to clean this up in debt week & unify the change diff and change the terminology as mentioned above (i.e. added/removed as opposed to linesAdded/linesRemoved)</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix +0/-0 diff displayed for notebook changes in chat view Fix notebook diff stats showing +0/-0 in chat editing view Dec 10, 2025
Copilot AI requested a review from DonJayamanne December 10, 2025 12:17
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.

+0/-0 diff displayed for all notebook changes in chat view

2 participants