Skip to content

Feature/Hunk mode - add to stage & revert block actions#15

Closed
fcmiranda wants to merge 19 commits into
Blankeos:feature/revert-block-cleanfrom
fcmiranda:feature/revert-block-clean
Closed

Feature/Hunk mode - add to stage & revert block actions#15
fcmiranda wants to merge 19 commits into
Blankeos:feature/revert-block-cleanfrom
fcmiranda:feature/revert-block-clean

Conversation

@fcmiranda
Copy link
Copy Markdown
Contributor

@fcmiranda fcmiranda commented May 16, 2026

Summary

@Blankeos I have implemented several improvements on top of feature/revert-block-clean:

New Features

  • Hunk mode: Added a dedicated hunk navigation mode with help hints and status bar integration (7f31007)
  • Enhanced hunk mode entry: Improved hunk mode entry flow and updated status bar hints (bb2f672)

Refactoring

  • Renamed and refactored hunk marker handling structures for clarity (cf69f2b)
  • Bound revert action to r key for consistency (0db65e2)

Fixes

  • Updated revert icon to new design in help entries and config (352a834)

H : enter into hunk mode
esc: exit hunk mode

Hunk mode:
j: next hunk
k: previous hunk
a: add to stage
r: revert
u: undo (undo previous action)

image

Let me know what do you think!

Changed Files

  • src/config/keybindings.rs — keybinding updates
  • src/config/mod.rs / src/config/user_config.rs — config adjustments
  • src/git/staging.rs — staging logic improvements
  • src/gui/mod.rs — hunk mode implementation
  • src/gui/controller/diff_mode.rs — diff mode controller updates
  • src/gui/presentation/diff_mode.rs — presentation layer updates
  • src/gui/views.rs — view updates
  • src/pager/side_by_side.rs — side-by-side pager refactor

fcmiranda and others added 19 commits April 30, 2026 18:57
Adds a per-hunk revert affordance on unstaged file diffs. In the Files
panel, <c-j>/<c-k> cycle through hunks, <enter> reverts the selected
hunk, and clicking the marker glyph in the divider column reverts that
hunk directly. Hunks are reverted via `git apply --reverse` against
the worktree, scoped to one hunk at a time.
Show "enter Revert hunk" tooltip beside the marker glyph when the mouse
hovers over it, mirroring the AI-generate button's tooltip pattern. The
tooltip overlays the right diff panel on the marker's row only while
the cursor is on the divider column at a hunk start.
Replace the Enter handler with a dedicated `<c-r>` keybinding for
reverting the currently selected (or hovered) hunk. Also update the
hover tooltip to show `c-r Revert hunk`. Enter no longer triggers
revert — `<c-r>` is the single source of truth for the action key.

feat(diff): hover color + diff-focused status bar hints

- Revert-hunk marker now uses accent_secondary on mouse hover (matching
  the AI sparkle's hover pattern), distinct from accent (selected via
  c-j/c-k cycle) and separator (default).
- Status bar shows a tighter, diff-focused hint set when the diff panel
  has focus: {/} prev/next hunk, [/] side view, and on Files context
  c-j/c-k cycle + c-r revert. The c-r key is highlighted when a hunk
  is selected so the action is more discoverable.

feat(diff): only surface c-r when a hunk is selected

c-r is now hidden from the status bar unless `selected_revert_hunk` is
set, and is prepended as the first hint when present. Pressing c-r
without a selection is a no-op so showing it always was noise — it
appears only when the action will actually do something.

fix(diff): don't scroll on c-j/c-k if hunk already visible

center_selected_revert_block was unconditionally re-centering the diff
on every cycle, which is jarring when the target hunk is already in
the viewport. Only scroll when the hunk's start row is outside the
visible range.

feat(diff): group c-r and c-j/c-k revert hints together

Move the cycle keys (c-j/c-k) next to c-r at the front of the status
bar so the revert action and its cycle keys read as one cluster
instead of being split across the line.

fix(diff): show hover feedback even when revert hunk is already selected

Previously the selected color (accent) overrode hover styling, so
hovering a hunk that was already selected via c-j/c-k showed no visual
change. Add an UNDERLINED modifier on hover that stacks with whichever
fg color is in effect, so the marker reacts to the cursor in every
state.

fix(diff): use bg fill for hover so it shows even when hunk is selected

UNDERLINED didn't render reliably on the Nerd Font marker glyph in
many terminals. Switch to a selected_bg background fill on hover —
visible regardless of fg color and terminal capabilities, including
when a hunk is already selected (accent fg + selected_bg fill).

fix(diff): make hover unambiguously visible via REVERSED

The selected_bg fill blended too subtly with the selected accent fg —
hovering a focused hunk looked nearly identical to just being focused.
Use REVERSED to invert fg/bg on hover; the marker reads as a high-
contrast highlight regardless of which fg color is currently active.

fix(diff): solid bg fill on hover + drop c-r tooltip when not selected

Hover now paints the marker as a solid colored cell (fg ↔ bg with
panel background). Visually unmistakable in any terminal — including
when the hunk is already selected, where the previous REVERSED/bg
tweaks were too subtle.

Tooltip text drops the c-r keybind when the hovered hunk isn't the
selected one, since pressing c-r in that state is misleading. Falls
back to a plain "Revert hunk" label.

fix(diff): paint full divider gap with hover bg

Single-cell bg fill was easy to miss against the surrounding panel
background — fill both columns of the divider gap with the hover bg
so the marker reads as a clearly-coloured pill against the diff.
Also fixes the second render path which was still on UNDERLINED.

fix(diff): hover changes only the icon color, no bg fill

Drop the colored bg pill — hover now switches the marker fg to
text_strong, which wins over both the selected accent and default
separator colors. Selected stays accent when not hovered, default is
separator. Hover is visible in every state because the icon color
itself changes; nothing else in the divider gap is touched.

fix(diff): use accent_secondary for hover so it matches tooltip key color

Hover color was text_strong (off-white). Switch to accent_secondary so
the hovered marker reads in the same yellow as the c-r shortcut key
text inside the tooltip — visually links the two.
- Change revert_block keybinding from <c-r> to <enter> - Update Escape handler to clear hunk selection before search - Update status bar hints and tooltips accordingly
…igation

- Removed non-functional Ctrl+J/K hunk navigation in favor of configurable { and }
- Updated { and } navigation to automatically select the target hunk, enabling keyboard-only revert without mouse hover
- Removed fixed KeyCode::Char('{')/('}') handlers in favor of keybinding config
Keep keyboard-only revert flow intact after applying a hunk by auto-selecting the nearest remaining hunk on refresh. Also let users override the revert marker icon, weight, and colors from config without changing the active theme.
When a revert refresh selects the nearest remaining hunk, recenter it if it lands outside the current viewport so keyboard-only revert keeps the active target visible.
Use a dedicated revert key in hunk mode so Enter is no longer overloaded in the diff view. Update the files help and status hints to advertise r as the single keyboard action for reverting the selected hunk.
- Renamed `RevertHunkMarkerConfig` to `HunkMarkerConfig` and updated all references.
- Updated `GuiConfig` to use the new `HunkMarkerConfig`.
- Refactored `GitCommands` to use `build_hunk_patch` instead of `build_patch`.
- Changed GUI logic to handle hunk actions instead of revert actions, including renaming variables and methods for clarity.
- Updated rendering logic to display hunk markers instead of revert markers.
- Adjusted undo functionality to track hunk actions instead of revert actions.
- Modified tooltip rendering to reflect hunk actions for staging and reverting.
feat(gui): add hunk mode with navigation, refactor markers and improve UX
@fcmiranda fcmiranda changed the title Feature/Hunk mode with add to stage and revert block actions Feature/Hunk mode - add to stage & revert block actions May 16, 2026
@Blankeos Blankeos force-pushed the feature/revert-block-clean branch from 22d0113 to f918338 Compare May 16, 2026 16:25
@fcmiranda fcmiranda closed this May 16, 2026
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.

2 participants