Skip to content

Conversation

@jtpio
Copy link
Contributor

@jtpio jtpio commented Oct 21, 2025

Fixes #3
Fixes #10

The demos below were made with the agent from https://github.com/jupyterlite/ai, which uses the commands defined in jupyterlab-cell-diff to show the diffs:

Unified cell diffs

jupyterlab-cell-diff-unified-cell-diff.mp4

Unified file diffs

jupyterlab-cell-diff-file-diffs.mp4

@jtpio jtpio added the enhancement New feature or request label Oct 21, 2025
This was referenced Oct 21, 2025

commands.addCommand('jupyterlab-cell-diff:show-codemirror', {
label: trans.__('Show Cell Diff (CodeMirror)'),
commands.addCommand('jupyterlab-cell-diff:split-cell-diff', {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the id of the existing command, so it's aligned with the names of the new commands.

@jtpio jtpio mentioned this pull request Oct 21, 2025
4 tasks
@Zsailer
Copy link
Collaborator

Zsailer commented Oct 22, 2025

Love this PR! The unified diff view is a great addition. 🎉

I have some minor UX suggestions that are totally up for discussion - these are pretty nitpicky and
shouldn't block merging. We can always iterate on the polish later.

Icon Choices

Accept All: checkIcon (✓) - universally understood, looks great ✅

Reject All: undoIcon (↶) - worth discussing! This is an interesting choice that differs from
some common patterns:

  • VS Code: Uses X icon or trash can for rejecting/discarding changes
  • GitHub: Uses X in a circle for "Request Changes"
  • GitKraken/IntelliJ: Use trash can or X icons

The undo icon is actually quite nice here because it's:

  • Less destructive-feeling than an X
  • Semantically correct - you're reverting/undoing the proposed changes
  • Clearer intent than a trash can (not deleting, but undoing)

That said, it's worth considering if users might expect a more traditional "discard" icon. Curious
what others think!

Button UX and styling

The button spacing could use some minor tweaks:

  1. Icon-to-label spacing: A bit more breathing room between icon and text
  2. Button-to-button spacing: Slightly more space between "Reject All" and "Accept All"

Here are some values to try and see if the spacing feels better:

.jp-UnifiedDiff-acceptAll,
.jp-UnifiedDiff-rejectAll,
.jp-UnifiedFileDiff-acceptAll,
.jp-UnifiedFileDiff-rejectAll {
  gap: 6px;
}

.jp-UnifiedDiff-rejectAll,
.jp-UnifiedFileDiff-rejectAll {
  margin-right: 8px;
}

It might be helpful to add subtle color cues to differentiate Accept vs Reject actions (while keeping it accessible)

Auto-dismiss the cell footer instead of "X" icon

The unified diff has a different UX pattern than the dropdown split-cell diff:

  • Dropdown split-cell diff: Changes are implicitly accepted when shown. The diff is a "review before
    commit" tool, which is why it has an X button in the cell footer to finalize and dismiss.
  • Unified diff: Changes aren't applied until explicitly accepted. The diff is an "approve changes"
    tool.

Because of this difference, the X button in the cell footer isn't needed here - the buttons should
just automatically disappear when all chunks are handled. Once you've reviewed everything, the UI
gets out of your way.


Again, these are just suggestions for future polish. The PR is great as-is! 🚀

@Zsailer
Copy link
Collaborator

Zsailer commented Oct 22, 2025

Also, a question: what happens if the user runs the cell while the diff is still showing? Does it run the old source or new source?

@jtpio
Copy link
Contributor Author

jtpio commented Oct 22, 2025

These icons are currently the same as the existing split (side by side) cell diff. We could choose different icons for sure (no strong opinion).

Otherwise yes there are likely a couple of UX improvements to be done. Maybe we can look into that in a follow-up PR?

VS Code: Uses X icon or trash can for rejecting/discarding changes

Does it? This is what is displayed when a change is made by Copilot (using the "Keep" / "Undo" terminology that we could also follow here)

image

Also, a question: what happens if the user runs the cell while the diff is still showing? Does it run the old source or new source?

It uses the new content, which seems to be the case in other IDEs too. But we could make that configurable with a new command argument.

@Zsailer
Copy link
Collaborator

Zsailer commented Oct 22, 2025

It uses the new content, which seems to be the case in other IDEs too. But we could make that configurable with a new command argument.

Using the new content makes the most sense to me.

@Zsailer
Copy link
Collaborator

Zsailer commented Oct 22, 2025

Otherwise yes there are likely a couple of UX improvements to be done. Maybe we can look into that in a follow-up PR?

Sure, totally fine.

@jtpio
Copy link
Contributor Author

jtpio commented Oct 22, 2025

This PR adds a couple of basic UI tests to cover the three commands. There are all quite similar for now, with one test file per command.

We should likely add more, for example to:

  • show a diff for a specific cell in a notebook that does not have the focus
  • accepting individual chunks
  • cover a few more of the available command arguments

But happy to stop here for now in case folks are already interested in using the new commands. But at least we have the basic structure to add more tests now.

@Zsailer
Copy link
Collaborator

Zsailer commented Oct 22, 2025

I'm comfortable merging without further tests and doing this work in follow up PRs. I'd love to start using this work right away. 😎

@jtpio jtpio marked this pull request as ready for review October 22, 2025 20:02
@jtpio jtpio requested a review from Zsailer October 22, 2025 20:03
Copy link
Collaborator

@Zsailer Zsailer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, @jtpio! Thank you for your amazing work here.

@Zsailer Zsailer merged commit bbf793a into jupyter-ai-contrib:main Oct 22, 2025
6 checks passed
@jtpio jtpio deleted the filediffs branch October 23, 2025 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inline diffs Expand to file diffs

2 participants