feat(review): add working-tree staging, hunk actions, and focused files-pane UX - #1021
Open
yusing wants to merge 12 commits into
Open
feat(review): add working-tree staging, hunk actions, and focused files-pane UX#1021yusing wants to merge 12 commits into
yusing wants to merge 12 commits into
Conversation
Expose both Git status sides through the public VCS and sidebar contracts. Stage or unstage exact files with Space and consecutive mouse double-clicks, preserve unrelated changes, and reconcile writes through reload and graceful shutdown. Add provider, command, component, and PTY coverage plus extension and keybinding documentation.
Apply byte-preserving canonical Git hunks with status and HEAD attestation. Keep unrelated hunks and worktree content intact, refuse text-converted patches, and integrate scoped Space and release-confirmed double-click actions through the provider contract.
Add exact-file confirmation and stash-message prompts with contextual keys and mouse parity. Preserve unrelated live changes and stash trees, partial staging, tracked modes, and recoverable published stashes when cleanup fails.
Track deliberate line selection separately from viewport seeding, fall back to the active hunk's first change, and map staged source addresses through later worktree edits. Guard asynchronous lookups by review generation and refuse unsupported editor line syntax.
Render index and worktree status columns with semantic colors, highlight selected rows across the full sidebar width, and color fully staged filenames. Add optional `statusCode` to the v21 extension API, expose Git status codes, and document and test the new sidebar behavior and theme contrast.
Hide shadowed key hints from help and menus, keep file quick actions scoped to the focused sidebar, and fall back to file staging when hunk staging is unavailable. Add coverage for pointer focus, shortcut precedence, and working-tree behavior.
Track focus ownership between the files pane and the review stream so pointer and command toggles move cursor ownership cleanly: `↑`/`↓`/`j`/`k` now step files when the files pane is focused, review focus stays in the diff stream, and `Space` stages the file when a selected hunk is not stageable. Review-stream clicks now drop files-pane quick-action scope, and focused panes are visually emphasized with brighter frame and divider styling. Centralize shortcut labeling for help and menus through first-match command ownership so a command only advertises keys that are actually reachable, preventing shadowed aliases from appearing while preserving visible alternatives on the real owner. Updated command descriptions, docs, and focused-pane/interaction tests to match the new focus model and selection behavior.
Add a files-pane selection model that tracks folder rows alongside files, and thread folder-aware entry IDs through sidebar rendering and extension working-tree props. Folder and file rows are now selectable/clickable with updated focus and highlighting, and the focused entry is kept coherent across tree and compact sidebar modes. Wire the new model into working-tree actions so `Space`, discard, and stash now operate on the focused files-pane row, including folders. Folder actions apply to all nested files in tree view or all files under a compact group row, with updated prompts/messages and selection behavior. Bump extension VCS API version and expose `selectedEntryId`/`selectEntry`/`toggleEntry`, plus a new provider operation `stashFiles` so folder actions can stash multiple attested files in one operation. The Git adapter now performs multi-file stashes while preserving per-file staged-untracked semantics, with docs and tests updated for the new behavior.
Add optional `stats` (`additions`/`deletions`) to working-tree file inventory in API v23 and enrich git status rows from `git diff --numstat` across both staged and unstaged sides, including rename/copy-safe parsing and untracked/symlink/large-file count handling, so sidebar +/- stays visible even when a file is off the active review stream. Preserve folder selection semantics by choosing a nested path on the current tab when available so folder-stage/discard/stash actions do not unexpectedly jump sides, and update sidebar rendering helpers, selection tests, and docs/keybinding wording to reflect file-or-folder actions and stable stats visibility across tabs.
Add `hunk.review.focusDiffPane` and `hunk.review.focusFilesPane` command entries and App bindings so Enter focuses the selected file’s review and Escape returns focus to the files pane, with enablement tied to active pane state and selection kind. Normalize Escape key matching for `escape`, `esc`, and raw `\u001b`, expose both actions in file menu/help/keyboard docs, and extend command, menu, and interaction tests (including mode handoff coverage with overrideable bindings) for the new focus behavior.
Contributor
|
PR author is not in the allowed authors list. |
|
@yusing is attempting to deploy a commit to the Modem Team on Vercel. A member of the Team first needs to authorize it. |
Member
|
@yusing This feels like a large UX change, with no screenshots/video etc. Did you consider building this as an extension instead? (It's unlikely I'm going to merge this because it's not aligned with the project goals. The core is not trying to rebuild lazygit. But if you need more extension points to make that happen, that's worth discussing.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Working-tree review in Hunk could show a diff, but it could not act like a Git working-tree tool. Staging, unstaging, discarding, and stashing still required leaving the TUI. File-list navigation also fought the review stream for the same keys, so it was easy to page, stage, or discard the wrong thing.
User impact
In a Git working-tree review, Hunk now lets you inspect and mutate staged vs unstaged work in place:
[/], Space stages or unstages only that hunk.$EDITORat the selected changed line, mapping staged index lines through later unstaged edits.↑/↓/j/kmove in the files pane when it owns focus; Enter focuses the selected file’s review; Escape returns to the files pane.Keyboard and mouse stay paired for the new actions. Built-in review shortcuts keep their meaning outside an actionable working-tree files pane.
Approach
Keep Pierre as the renderer and the shared review document as the semantic model. Add working-tree mutation as optional VCS provider operations, then drive them from one host-side action layer (
useWorkingTreeActions) and a files-pane focus/selection model.The bundled Git provider implements:
stashFiles)The public extension API is bumped so other adapters can opt in without a parallel protocol:
stageHunk/unstageHunkdiscardFile/stashFileresolveWorkingTreeLinestatusCodestashFilesstats(additions/deletions)Sidebar extensions receive
selectedEntryId,selectEntry, andtoggleEntryso folder rows are first-class.Why this belongs in core
Staging, discard, stash, stream tabs, and pane-focus behavior are the default working-tree review, not an opt-in workflow. The host has to own shortcut precedence, confirmation prompts, reload/shutdown serialization, and review-stream geometry. Provider-specific Git writes stay in
packages/hunk-gitbehind the existinghunkdiff/extensioncontract.Non-goals
Tests
This branch adds provider, command, component, AppHost, and PTY coverage for the new behavior, including:
packages/hunk-git/src/{workingTree,hunkStaging,fileActions,editorLine,commands}.test.tspackages/hunk/src/ui/AppHost.working-tree.test.tsxpackages/hunk/src/ui/AppHost.interactions.test.tsxtest/pty/working-tree-integration.test.tstest/pty/editor-integration.test.tsThis PR submission did not re-run the suite against
modem-dev/hunkmain.Suggested checks:
bun run typecheck bun run test bun run test:integrationPlatforms
Visual evidence
None attached yet. The changes are terminal-native (focus chrome, status colors, stream tabs, folder rows, confirm/stash dialogs). Screenshots or a short PTY video can follow if useful for review.
Limitations / follow-up
d/sonly take over discard/stash while the files pane is visible and focused; otherwise they keep half-page scroll and files-pane toggle.Commits
feat(review): add status-aware file staging and stream tabsfeat(review): stage and unstage the active diff hunkfeat(review): discard and stash only the selected filefeat(review): open the editor at the selected changed linefeat(ui): show Git-style file status colorsfix(ui): scope file quick actions to the focused sidebarfix(ui): resolve shortcut ownership across review focus and menusfeat(ui): indicate focused pane and scope keyboard actions to itfeat(ui): make files-pane folders actionablefeat(ui): keep working-tree folder actions and line stats on both tabsfeat(ui): add Enter/escape pane focus commandsfix: reconcile rebased staging and sidebar integrations