Add selective line restoration, file-history annotation, and sidebar section menu #52
Loading…
Reference in a new issue
No description provided.
Delete branch "refs/pull/52/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This change implements three user-facing and internal updates: selective restoration of lines from a historical commit into the working file, an annotation on file history entries that marks when the latest history entry matches the working tree, and a small left-sidebar section menu to toggle visibility of non-branch panels. It also includes a couple of UI polish and styling tweaks (repository select cursor and per-group accents in the branch panel).
What changed (behavioral summary)
Selective line restoration from historical commits
get_file_restore_patch(path, commit, file)that produces the reverse diff (historical -> working) for a single file. The patch text is filtered to remove mode lines and returned as UTF-8 text.apply_file_patchnow supports an additional action string"restore-lines". Applying this action validates the patch (validate_restore_patch) and then checks/applies it via the existing patch application helpers.git apply --numstat -z).App.svelteimports and usesgetFileRestorePatch, opens a line-restore flow from the compare dialog (onRestoreLines), exposes aRestore lines…button inCompareDialog.sveltewhen applicable, and providesrestoreSelectedLineswhich invokesapplyFilePatch(..., "restore-lines"), refreshes diffs/history/views, and surfaces any errors.File history annotation
FileHistoryCommit { commit: GitCommit, matches_working_tree: bool }.list_file_historynow returns the annotated commits;annotate_file_historycomputesmatches_working_treeby running agit diff --quietof the first returned commit against the working tree for regular files only. The implementation only marks the first entry (index 0) as matching the working tree when appropriate.Sidebar section menu and visibility toggles
SidebarSectionMenucomponent is imported and opened on contextmenu over the left sidebar (right-click). It allows toggling visibility for non-branch panels: Worktrees, Tags, Stashes, Files (Explorer).gitlite.sidebarVisibility.v1. The layout and handle visibility logic (panel ordering and sizing) were updated to respect thesidebarVisibilitymap.UI and styling tweaks
RepoTabs.svelte: change repository-select cursor fromgrabtopointerfor clickable select elements.BranchPanel.svelte: per-group accent styling for branch group headers (local vs remote) via CSS variables and color-mix, with a subtle left inset shadow and hover color changes.Implementation notes (helpful to review)
Rust backend
src-tauri/src/git.rs:get_file_restore_patch,validate_restore_patch, andannotate_file_history.apply_file_patchwas extended to handle therestore-linesaction by validating and then applying the patch.list_file_historysignature in the Rust tauri back-end now returnsVec<FileHistoryCommit>(annotated commits) instead ofVec<GitCommit>.main.rsexportsget_file_restore_patchto the Tauri command list so the frontend can call it.Frontend
App.svelteadditions: state and functions to open the historical-line restore flow (openHistoricalLineRestore), to fetch the historical patch (getFileRestorePatch), to apply selected lines (restoreSelectedLines), and to managesidebarVisibility(load/save, toggle). TheLinePatchcomponent is passed a newrestoreCommitprop in its invocation.CompareDialog.sveltegained an optionalonRestoreLinescallback prop and shows aRestore lines…button when the comparison represents a historical comparison (noto_hash) and the selected file is a modified file (noold_path). When clicked it triggers theopenHistoricalLineRestoreflow.buildLeftSidebarRows,sidebarHandleVisible,expandedSidebarPanels). Right-click on the left sidebar opens the section menu.Tests
src-tauri/src/git.rstests module:restore_lines_preserves_unselected_changes_and_indexrestore_lines_rejects_stale_or_wrong_file_patchesfile_history_marks_only_an_identical_current_fileNo test execution results were provided. The commits and tests are present in the diff but the PR does not include CI output.
Recommended checks for reviewers:
cargo testfor thesrc-tauricrate to verify the new tests and ensure no regressions.from_hashand noto_hash), select a modified file in the comparison, click the newRestore lines…button, select/apply a subset of hunks in the line-patch dialog and confirm that:list_file_historytauri command should now expect objects withcommitandmatches_working_treekeys; ensure frontendFileHistoryDialoguses the new shape (the diff shows corresponding UI changes, but please confirm no external consumers rely on the old plainGitCommitarray).gitlite.sidebarVisibility.v1.Compatibility / reviewer actions
list_file_historychanged to includematches_working_tree. If any external code or plugin expected a plainGitCommitlist from that command, it must be updated to handleFileHistoryCommitobjects.get_file_restore_patchcommand is exported; review callers for correct usage and error handling.restore-linesaction path inapply_file_patchperforms stricter validation than generic patch application — this is intentional and enforced invalidate_restore_patch.If you want, I can list the specific files that changed for each of the bullet items above or produce a short checklist of smoke tests to run in the UI (open compare, right-click sidebar, etc.).