Repository navigation
feat(git): add recoverable branch switching - #1836
Merged
Merged
Conversation
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
Switching branches only asked about uncommitted work after checkout failed, so compatible edits could move without a choice. The native stash/discard modal offered no Bring option, and optimistic branch updates could show the wrong branch after a partial failure. Positional stash indices and fire-and-forget editor saves also made recovery unreliable.
Solution
vertical,showRadio, and visible title/description rows for Leave and Bring.Potential risks
fs2is added as an explicit dependency for OS locking at a version already present in Cargo.lock. App rollback leaves Git stashes andrefs/orgii/branch-switch/<UUID>recovery refs usable; do not delete them during rollback.Verification
Checks ran in an isolated worktree based on
develop; unrelated staged work was excluded. The latest target branch was fetched and the PR remains mergeable.pnpm exec tsgo --noEmit --pretty false— passed the full project check. The earlier shared-checkout type errors are absent in this isolated branch.cd src-tauri && cargo test -p git_api --lib commands::branch_switch— 25 passed using real temporary Git repositories, including Leave/Bring, index preservation, conflicts, collisions, detached/remote targets, worktree locking, stale preparation, journal recovery, pagination and symlinks.cd src-tauri && cargo test -p git --lib util::— 3 passed, including timeout kill/reap and draining output larger than pipe capacity.cargo clippy --lib --message-format=short -p git -p git_api.git diff --checkand scoped source/diff review — passed. Confirmed the PR contains only branch-switch code, localization, tests and audit notes; no new raw action controls, sensitive content or unrelated generated changes.pnpm exec vitest run --config config/vitest.config.ts \ src/api/http/git/branchSwitch.test.ts \ src/components/GitDialogs/CheckoutConflictDialog/index.test.ts \ src/components/GitDialogs/SavedChangesDialog/SavedChangesBanner.test.ts \ src/services/git/operations/__tests__/guardedCheckout.test.ts \ src/services/git/operations/__tests__/guardedCheckoutRecoveryFallbacks.test.ts \ src/services/git/operations/__tests__/branchSwitchEditors.test.ts \ src/services/git/operations/__tests__/branchSwitchWorkspace.test.ts \ src/store/workstation/codeEditor/gitDiffEditDrafts.branchSwitch.test.ts \ src/modules/WorkStation/CodeEditor/hooks/fileContent/__tests__/cache.test.tsCI correction verification
pnpm check:i18n-keys— passed: no missing keys, locale gaps, or placeholder mismatches; no new unused keys.NODE_OPTIONS=--max-old-space-size=6144 pnpm check:typed-lint— passed: 1,099 existing findings, zero new or increased findings. Baselines unchanged.node scripts/ci/run-unit-tests.mjs < /tmp/orgii-pr1836-unit-paths— passed using the NUL-delimited PR diff plus the correction paths: 653 test files, 4,766 tests passed, one skipped.pnpm test:typed-lintandpnpm test:i18n-keys— passed: 6 and 27 tooling tests respectively.pnpm exec eslint --max-warnings 0 src/components/GitDialogs/SavedChangesDialog/index.tsx src/components/GitDialogs/SavedChangesDialog/SavedChangesBanner.tsx— passed.Audit
UI audit: 0 fix, 8 keep with reason, 0 abstract. All ten architecture layers reviewed. Automated lifecycle checks pass; the performance verdict remains blocked for unrun native measurements.