Repository navigation
fix: manual repo root discovery for staging; fix stale tabs.length - #11
Merged
Merged
Conversation
- Rust backend: blame_side() runs git blame <ref> -- <file> directly on the tracked file path (no temp file), supporting both HEAD and MERGE_HEAD - parser: add SideBlame type wrapping local + remote BlameMap - frontend: load SideBlame on file open, render blame tooltips on both side panes (Yours + Theirs) with dotted underline hover indicator - CSS: conflict-side-line--blamed style for hover cue - clippy clean, 117+20 Rust tests, 126 frontend tests all passing
- Cmd+Shift+O or welcome button opens a Git repo directory - Auto-starts the conflict watcher and adds the repo - WatchedRepoPanel auto-expands with the repo's conflicted files - Single-conflict-file repos auto-open the file - ShortcutsOverlay updated with new shortcut - ADR 001 documents the design decision
The save command created .splice.bak backup files but never cleaned them up, leaving clutter in the user's repo directory after resolving conflicts. Now the backup is removed after the file is written successfully. The session's undo/redo stack in memory still provides crash protection during the editing session.
In directory (non-mergetool) mode, saving resolved content only updated the file on disk but did not stage it in git's index. Git continued to show the file as 'both modified' in On branch dev Your branch is ahead of 'origin/dev' by 9 commits. (use "git push" to publish your local commits) Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: src-tauri/src/commands/save.rs. Now after a successful save in non-mergetool mode, we run to stage the file, properly marking the conflict as resolved.
- stage_in_git now tries git2 first, falls back to git add via CLI - Added test_stage_multiple_files_in_repo to verify multi-file staging - Both stage files show as correctly resolved after sequential staging
… App.tsx - Add find_repo_root() helper that walks up from file path to find .git directory, replacing reliance on git2::Repository::open auto-discovery which failed on deep package paths (e.g. Java/maven projects) - Use git -C <parent> add <file> in CLI fallback to avoid CWD issues in bundled Tauri apps - Fix three handlers in App.tsx (handleOpenFile, handleOpenConflictedFile, handleOpenDirectory) to use tabsRef.current.length instead of stale tabs.length from closure capture
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.
修复内容
Bug: 保存第二个冲突文件后 staging 失败
在 watcher 模式下,如果有 2+ 冲突文件,保存第二个文件时 staging 失败,文件仍然保持 UU (both modified) 状态。
Root Cause 1 — git2 自动发现 .git 失败
stage_in_git调用git2::Repository::open(parent)从文件所在目录向上搜索 .git,但在深层 Java 包路径下搜索失败(如com/infloww/creator/controller),返回 NotFound。Root Cause 2 — CLI fallback CWD 错误
CLI 回退
git add <file>依赖进程 CWD 来定位 .git 目录,而 Tauri 打包应用的 CWD 不可控,导致 CLI 也失败。Root Cause 3 — 静默吞错误
原代码中 staging 失败仅
eprintln!,不返回前端,用户完全不知情。Root Cause 4 — 闭包陈旧
handleOpenConflictedFile中await后使用闭包捕获的旧tabs.length计算新 tab 索引,导致切换到错误的 tab。改动
save.rs
find_repo_root()辅助函数,手动向上遍历查找 .git 目录/文件stage_in_git改用两步法:先找 repo root,再从 root 打开仓库stage_in_git_cli添加-C <parent>参数,指定 git 从文件所在目录开始搜索return Err到前端,不再静默App.tsx
tabs.length改为tabsRef.current.length,避免闭包捕获旧值