feat(tui): diff viewer - #13047
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
Pull request overview
Adds an in-TUI “details” pane that renders commit metadata and a syntax-highlighted unified diff for the selected commit.
Changes:
- Introduces a
Detailscomponent and wires it into the status TUI update/render loop. - Implements diff rendering with syntect-based syntax highlighting and adds a bundled Monokai theme asset (+ license).
- Updates workspace/crate dependencies (ratatui feature flag, adds syntect + textwrap).
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/but/src/command/legacy/status/tui/mod.rs | Integrates a details pane into the status screen layout and update loop. |
| crates/but/src/command/legacy/status/tui/details.rs | Implements commit-details fetching and diff rendering with syntax highlighting. |
| crates/but/assets/syntax-highlighting-themes/Monokai Extended.tmTheme | Adds a bundled theme consumed by syntect. |
| crates/but/assets/syntax-highlighting-themes/Monokai Extended License | Adds license notice for the bundled theme. |
| crates/but/Cargo.toml | Adds dependencies needed for diff rendering/wrapping/highlighting. |
| Cargo.toml | Enables a ratatui unstable feature at the workspace level. |
34f9c0b to
2d9c7ea
Compare
|
There is syntax highlighting! I didnt know this was possible! awesome |
13fc3f2 to
dae900a
Compare
Yeah its very useful! I found https://docs.rs/syntect which does all the heavy lifting. |
dae900a to
5c4772a
Compare
|
Looks great! Regarding the diff layout (unified / side-by-side) and wrapping, I spent some time recently making this work nicely in jjui with difftastic, and I learnt a few things a long the way. For the future, it would be nice to support custom external diff tools, like lazygit. Difftastic is my daily driver. I believe it's possible to pass I also wrote a small wrapper for difftastic that automatically switches the display/layout between unified and side-by-side based on available width: https://github.com/OliverJAsh/dotfiles/blob/5341c9c28d13128b3134e3a909cabc2e0e875369/pkgs/difft-auto-layout.nix. Maybe we could do something similar. |
|
Demo of difftastic using unified for preview and side-by-side for fullscreen diff: Screen.Recording.2026-03-27.at.09.56.48.mov |
Yes I agree that would be good to support.
That's nice! I think I'm gonna steal that for our diff rendering. |
8adb2c6 to
1e67452
Compare
d4b5790 to
541ace8
Compare
8bef897 to
614dff2
Compare
for red/green color blind aid
614dff2 to
08d6968
Compare
Features:
dtoggles a detail+diff viewctrl+nandctrl+pfor individual lines andctrl+dandctrl+ufor bigger jumpsDon't let the size of this PR scare you. The bulk of it is the syntax highlighting theme.
Prior art includes the
but diffandbut diff --tuicommands. I took some inspiration from those implementations but ultimately decided to write something new for the TUI. In part to get more familiarity with the data structures but also because I'm hoping this new implementation can become more full featured and have better performance. When this has matured we should be able to replace the other implementations.Future improvements
These are things that I have intentionally not focused on yet but will in the future.
I have filled Linear tickets for these.
This is part 3 of 3 in a stack made with GitButler:
Modeand related types into their own module #13063DebugAsTypeinto its own module #13062