Repository navigation
feat(source-control): branch switcher in the Source Control panel - #5416
Devin345458 wants to merge 15 commits into
Conversation
… SSH + smart-checkout
- cap the radix scroll viewport (not the root) so the branch list scrolls instead of overflowing and painting over the create-branch footer, which had hidden the Remote section - match the popover to the trigger width so the picker fills the panel
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds an in-app Git branch switcher (desktop + web runtime) with support for stashing local changes during checkout, plus shared typings and runtime/IPC plumbing.
Changes:
- Introduces branch switching UX (BranchSwitcher component + hook) and candidate annotation for local/remote refs + worktree awareness.
- Implements
git switchorchestration (plain/stash/create) in main process with runtime RPC + preload IPC entry points. - Adds i18n strings and tests covering switching behavior, candidate annotation, and main/IPC routing.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/shared/git-branch-switch.ts | Adds shared types/results/options and a standardized stash label for branch switching. |
| src/renderer/src/web/web-preload-api.ts | Exposes git.switchBranch for web runtime via runtime dispatch. |
| src/renderer/src/runtime/runtime-git-client.ts | Adds switchRuntimeGitBranch to route branch switching via local IPC or runtime RPC. |
| src/renderer/src/i18n/locales/zh.json | Adds branchSwitch i18n keys (currently English text). |
| src/renderer/src/i18n/locales/ko.json | Adds branchSwitch i18n keys (currently English text). |
| src/renderer/src/i18n/locales/ja.json | Adds branchSwitch i18n keys (currently English text). |
| src/renderer/src/i18n/locales/es.json | Adds branchSwitch i18n keys (currently English text). |
| src/renderer/src/i18n/locales/en.json | Adds English branchSwitch i18n keys. |
| src/renderer/src/components/right-sidebar/useBranchSwitch.ts | Implements branch search + switch orchestration with confirm/toast flows and overlap guard. |
| src/renderer/src/components/right-sidebar/useBranchSwitch.test.ts | Adds hook tests for dirty-conflict confirm flow, pop-conflict warning, failure surfacing, and overlap guard. |
| src/renderer/src/components/right-sidebar/branch-switch-candidates.ts | Adds candidate annotation/deduping and “checked out elsewhere” detection. |
| src/renderer/src/components/right-sidebar/branch-switch-candidates.test.ts | Tests candidate annotation rules and remote/local dedupe. |
| src/renderer/src/components/right-sidebar/SourceControl.tsx | Integrates the BranchSwitcher into the SourceControl sidebar and triggers refreshes on switch. |
| src/renderer/src/components/right-sidebar/BranchSwitcher.tsx | Adds BranchSwitcher UI (popover + searchable list + create branch flow). |
| src/renderer/src/components/right-sidebar/BranchSwitcher.test.tsx | Adds basic UI tests for selection and “checked out elsewhere” hint rendering. |
| src/preload/index.ts | Adds preload IPC method git.switchBranch returning SwitchBranchResult. |
| src/preload/api-types.ts | Extends PreloadApi.git with switchBranch signature. |
| src/main/runtime/runtime-rpc.ts | Allowlists git.switchBranch for mobile/runtime RPC. |
| src/main/runtime/rpc/methods/git.ts | Adds runtime RPC method handler for git.switchBranch. |
| src/main/runtime/rpc/methods/git-params.ts | Adds zod validation for git.switchBranch params. |
| src/main/runtime/orca-runtime.ts | Exposes switchRuntimeGitBranch on runtime service. |
| src/main/runtime/orca-runtime-git.ts | Adds runtime command implementation delegating to runSwitchBranch. |
| src/main/runtime/orca-runtime-git.test.ts | Tests delegation of switchRuntimeGitBranch to runSwitchBranch. |
| src/main/ipc/filesystem.ts | Adds git:switchBranch IPC handler with validation and local/SSH routing to runSwitchBranch. |
| src/main/ipc/filesystem.test.ts | Tests IPC routing and validation for git:switchBranch. |
| src/main/git/switch-branch.ts | Implements switch orchestration (plain/stash/create), error normalization, and local/SSH exec wiring. |
| src/main/git/switch-branch.test.ts | Adds unit tests for orchestration, normalization, and local/SSH execution paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!repoId) { | ||
| setRefs([]) | ||
| return | ||
| } |
| const stashed = await exec([ | ||
| 'stash', | ||
| 'push', | ||
| '--include-untracked', | ||
| '-m', | ||
| SWITCH_BRANCH_STASH_LABEL | ||
| ]) | ||
| if (stashed.exitCode !== 0) { | ||
| return { ok: false, reason: 'failed', message: stashed.stderr.trim() } | ||
| } | ||
| const createdStash = !isNothingToStash(stashed) | ||
| const switched = await exec(['switch', options.branch]) | ||
| if (switched.exitCode !== 0) { | ||
| // Why: only restore if we actually stashed — otherwise `pop` would apply an | ||
| // unrelated pre-existing stash and strand foreign changes here. | ||
| if (createdStash) { | ||
| await exec(['stash', 'pop']) | ||
| } | ||
| return { ok: false, reason: 'failed', message: switched.stderr.trim() } | ||
| } |
| const popped = await exec(['stash', 'pop']) | ||
| if (popped.exitCode !== 0) { | ||
| return { ok: false, reason: 'stash_pop_conflict' } | ||
| } |
| switchBranch: (args: { | ||
| worktreePath: string | ||
| branch: string | ||
| mode: 'plain' | 'stash' | 'create' | ||
| connectionId?: string | ||
| }) => Promise<SwitchBranchResult> |
| "branchSwitch": { | ||
| "search": "Search branches…", | ||
| "searching": "Searching…", | ||
| "none": "No matching branches.", | ||
| "local": "Local", | ||
| "remote": "Remote", | ||
| "newName": "New branch name", | ||
| "create": "Create", | ||
| "createNew": "Create new branch…", | ||
| "inWorkspace": "in {{value0}}", | ||
| "current": "current", | ||
| "noBranch": "No branch", | ||
| "stashTitle": "Stash changes and switch?", | ||
| "stashBody": "Your local changes would be overwritten. Stash them, switch, and re-apply?", | ||
| "stashConfirm": "Stash & switch", | ||
| "popConflict": "Switched, but re-applying your changes conflicted — they are saved in git stash.", | ||
| "failed": "Could not switch branch." | ||
| } |
📝 WalkthroughWalkthroughThis PR adds a complete git branch-switching feature. A new shared module defines 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 13
🧹 Nitpick comments (3)
src/renderer/src/components/right-sidebar/branch-switch-candidates.test.ts (1)
32-44: ⚡ Quick winAdd a remote-first dedupe regression case.
Current coverage only checks local-then-remote ordering. Add the inverse ordering (
origin/xbeforex) to lock dedupe behavior regardless of ref order.src/main/ipc/filesystem.test.ts (1)
1909-1937: ⚡ Quick winAdd a dedicated invalid-
modetest for the new IPC guard.The handler validates
modeat runtime, but these tests only cover branch validation. Add one case with an invalid mode to lock this boundary behavior.src/preload/api-types.ts (1)
2216-2221: ⚡ Quick winUse the shared
SwitchBranchModetype to prevent contract drift.This API surface already depends on shared branch-switch types; reusing
SwitchBranchModehere avoids literal-union drift across IPC/runtime/preload boundaries.Suggested patch
-import type { SwitchBranchResult } from '../shared/git-branch-switch' +import type { SwitchBranchMode, SwitchBranchResult } from '../shared/git-branch-switch' ... switchBranch: (args: { worktreePath: string branch: string - mode: 'plain' | 'stash' | 'create' + mode: SwitchBranchMode connectionId?: string }) => Promise<SwitchBranchResult>
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 336cb2fc-3238-42b2-b6d2-e2f2cce6e615
📒 Files selected for processing (27)
src/main/git/switch-branch.test.tssrc/main/git/switch-branch.tssrc/main/ipc/filesystem.test.tssrc/main/ipc/filesystem.tssrc/main/runtime/orca-runtime-git.test.tssrc/main/runtime/orca-runtime-git.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/git-params.tssrc/main/runtime/rpc/methods/git.tssrc/main/runtime/runtime-rpc.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/right-sidebar/BranchSwitcher.test.tsxsrc/renderer/src/components/right-sidebar/BranchSwitcher.tsxsrc/renderer/src/components/right-sidebar/SourceControl.tsxsrc/renderer/src/components/right-sidebar/branch-switch-candidates.test.tssrc/renderer/src/components/right-sidebar/branch-switch-candidates.tssrc/renderer/src/components/right-sidebar/useBranchSwitch.test.tssrc/renderer/src/components/right-sidebar/useBranchSwitch.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/runtime/runtime-git-client.tssrc/renderer/src/web/web-preload-api.tssrc/shared/git-branch-switch.ts
| if (switched.exitCode !== 0) { | ||
| // Why: only restore if we actually stashed — otherwise `pop` would apply an | ||
| // unrelated pre-existing stash and strand foreign changes here. | ||
| if (createdStash) { | ||
| await exec(['stash', 'pop']) | ||
| } | ||
| return { ok: false, reason: 'failed', message: switched.stderr.trim() } |
There was a problem hiding this comment.
Handle restore-pop failure after a failed switch.
On Line 83-Line 89, the recovery stash pop result is ignored. If restoration conflicts, the function still returns only reason: 'failed', so pop-conflict handling is skipped even though the worktree may now be in conflict state.
Proposed fix
if (switched.exitCode !== 0) {
// Why: only restore if we actually stashed — otherwise `pop` would apply an
// unrelated pre-existing stash and strand foreign changes here.
if (createdStash) {
- await exec(['stash', 'pop'])
+ const restored = await exec(['stash', 'pop'])
+ if (restored.exitCode !== 0) {
+ return { ok: false, reason: 'stash_pop_conflict' }
+ }
}
return { ok: false, reason: 'failed', message: switched.stderr.trim() }
}| // Why: reject ref names that could be parsed as `git switch` flags (e.g. | ||
| // "--orphan") before they reach the shell-free exec. | ||
| if (!args.branch || args.branch.startsWith('-')) { | ||
| throw new Error('Invalid branch name') | ||
| } | ||
| if (args.mode !== 'plain' && args.mode !== 'stash' && args.mode !== 'create') { | ||
| throw new Error('Invalid switch mode') |
There was a problem hiding this comment.
Tighten IPC branch validation to reject whitespace-only names.
Line 1556 allows values like ' ' through; they fail later in git with a less actionable error. Validate a trimmed branch string at the boundary.
Suggested patch
- if (!args.branch || args.branch.startsWith('-')) {
+ const branch = typeof args.branch === 'string' ? args.branch.trim() : ''
+ if (!branch || branch.startsWith('-')) {
throw new Error('Invalid branch name')
}
@@
return runSwitchBranch({
cwd: worktreePath,
connectionId: args.connectionId,
- options: { branch: args.branch, mode: args.mode }
+ options: { branch, mode: args.mode }
})| runSwitchBranch: vi.fn() | ||
| })) |
There was a problem hiding this comment.
Reset runSwitchBranch between tests to avoid state leakage.
mocks.runSwitchBranch is added but not reset in beforeEach (Line 77 onward), so call history/stubs can bleed between tests.
Suggested patch
beforeEach(() => {
mocks.abortMerge.mockReset()
mocks.abortRebase.mockReset()
mocks.getStagedCommitContext.mockReset()
mocks.getPullRequestDraftContext.mockReset()
mocks.generateCommitMessageFromContext.mockReset()
mocks.generatePullRequestFieldsFromContext.mockReset()
mocks.resolveCommitMessageSettings.mockReset()
mocks.getSshGitProvider.mockReset()
+ mocks.runSwitchBranch.mockReset()
})| const seenLocal = new Set<string>() | ||
| const candidates: BranchSwitchCandidate[] = [] | ||
| for (const ref of input.refs) { | ||
| // Why: the ref search strips the remote prefix into localBranchName, so a | ||
| // remote ref differs from its local name while a local ref matches it. | ||
| const kind = ref.refName === ref.localBranchName ? 'local' : 'remote' | ||
| // Why: a remote ref and an already-tracked local branch resolve to the same | ||
| // switch target; collapse to the local entry to avoid a duplicate row. | ||
| if (kind === 'remote' && seenLocal.has(ref.localBranchName)) { | ||
| continue | ||
| } | ||
| if (kind === 'local') { | ||
| seenLocal.add(ref.localBranchName) | ||
| } |
There was a problem hiding this comment.
Order-dependent dedupe can emit duplicate entries for the same switch target.
A remote ref is only skipped after its local branch has already been seen. If the remote appears first, both remote and local candidates are emitted, which breaks the one-row-per-target behavior.
Proposed fix
- const seenLocal = new Set<string>()
+ const localBranchNames = new Set(
+ input.refs
+ .filter((ref) => ref.refName === ref.localBranchName)
+ .map((ref) => ref.localBranchName)
+ )
const candidates: BranchSwitchCandidate[] = []
for (const ref of input.refs) {
// Why: the ref search strips the remote prefix into localBranchName, so a
// remote ref differs from its local name while a local ref matches it.
const kind = ref.refName === ref.localBranchName ? 'local' : 'remote'
// Why: a remote ref and an already-tracked local branch resolve to the same
// switch target; collapse to the local entry to avoid a duplicate row.
- if (kind === 'remote' && seenLocal.has(ref.localBranchName)) {
+ if (kind === 'remote' && localBranchNames.has(ref.localBranchName)) {
continue
}
- if (kind === 'local') {
- seenLocal.add(ref.localBranchName)
- }| <button | ||
| type="button" | ||
| onClick={() => setCreating(true)} | ||
| disabled={disabled} | ||
| className={cn( | ||
| 'flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm hover:bg-accent', | ||
| disabled && 'pointer-events-none opacity-50' | ||
| )} | ||
| > | ||
| <Plus className="size-3.5 shrink-0" aria-hidden="true" /> | ||
| {translate('auto.branchSwitch.createNew', 'Create new branch…')} | ||
| </button> | ||
| )} |
There was a problem hiding this comment.
Use the shared Button primitive for interactive controls.
Line 111, Line 159, and Line 225 render raw <button> elements in UI flows where this layer is expected to use shadcn primitives. Please migrate these to @/components/ui/button variants to keep interaction styling and states consistent.
As per coding guidelines, “All UI work … must follow docs/STYLEGUIDE.md and use tokens defined in src/renderer/src/assets/main.css and shadcn primitives in src/renderer/src/components/ui/.”
Also applies to: 159-190, 225-233
Source: Coding guidelines
| }, | ||
| "branchSwitch": { |
There was a problem hiding this comment.
branchSwitch appears attached to the wrong namespace.
branchSwitch is added as a sibling of i18n at Line 10915, while this PR’s stated i18n contract places it under i18n.hostedReview.copy. If lookup code expects the nested path, these keys won’t resolve.
| "search": "Search branches…", | ||
| "searching": "Searching…", | ||
| "none": "No matching branches.", | ||
| "local": "Local", | ||
| "remote": "Remote", | ||
| "newName": "New branch name", | ||
| "create": "Create", | ||
| "createNew": "Create new branch…", | ||
| "inWorkspace": "in {{value0}}", | ||
| "current": "current", | ||
| "noBranch": "No branch", | ||
| "stashTitle": "Stash changes and switch?", | ||
| "stashBody": "Your local changes would be overwritten. Stash them, switch, and re-apply?", | ||
| "stashConfirm": "Stash & switch", | ||
| "popConflict": "Switched, but re-applying your changes conflicted — they are saved in git stash.", | ||
| "failed": "Could not switch branch." |
There was a problem hiding this comment.
Spanish locale strings are still in English.
The new branchSwitch entries are English text in es.json (for example Line 10916 "Search branches…" and Line 10929 "Stash & switch"), which will surface untranslated UI in Spanish.
| "branchSwitch": { | ||
| "search": "Search branches…", | ||
| "searching": "Searching…", | ||
| "none": "No matching branches.", | ||
| "local": "Local", | ||
| "remote": "Remote", | ||
| "newName": "New branch name", | ||
| "create": "Create", | ||
| "createNew": "Create new branch…", | ||
| "inWorkspace": "in {{value0}}", | ||
| "current": "current", | ||
| "noBranch": "No branch", | ||
| "stashTitle": "Stash changes and switch?", | ||
| "stashBody": "Your local changes would be overwritten. Stash them, switch, and re-apply?", | ||
| "stashConfirm": "Stash & switch", | ||
| "popConflict": "Switched, but re-applying your changes conflicted — they are saved in git stash.", | ||
| "failed": "Could not switch branch." | ||
| } |
There was a problem hiding this comment.
Localize the new branchSwitch copy.
Several labels in this Japanese locale are still English, so the branch picker will show mixed-language UI. Please translate the whole block.
Suggested translations
- "search": "Search branches…",
- "searching": "Searching…",
- "none": "No matching branches.",
- "local": "Local",
- "remote": "Remote",
- "newName": "New branch name",
- "create": "Create",
- "createNew": "Create new branch…",
- "inWorkspace": "in {{value0}}",
- "current": "current",
- "noBranch": "No branch",
- "stashTitle": "Stash changes and switch?",
- "stashBody": "Your local changes would be overwritten. Stash them, switch, and re-apply?",
- "stashConfirm": "Stash & switch",
- "popConflict": "Switched, but re-applying your changes conflicted — they are saved in git stash.",
- "failed": "Could not switch branch."
+ "search": "ブランチを検索…",
+ "searching": "検索中…",
+ "none": "一致するブランチがありません。",
+ "local": "ローカル",
+ "remote": "リモート",
+ "newName": "新しいブランチ名",
+ "create": "作成",
+ "createNew": "新規ブランチを作成…",
+ "inWorkspace": "({{value0}} で使用中)",
+ "current": "現在",
+ "noBranch": "ブランチなし",
+ "stashTitle": "変更をスタッシュして切り替えますか?",
+ "stashBody": "ローカル変更が上書きされます。スタッシュして切り替え、再適用しますか?",
+ "stashConfirm": "スタッシュして切り替え",
+ "popConflict": "切り替え後の再適用で競合しました。変更は git stash に保存されています。",
+ "failed": "ブランチを切り替えられませんでした。"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "branchSwitch": { | |
| "search": "Search branches…", | |
| "searching": "Searching…", | |
| "none": "No matching branches.", | |
| "local": "Local", | |
| "remote": "Remote", | |
| "newName": "New branch name", | |
| "create": "Create", | |
| "createNew": "Create new branch…", | |
| "inWorkspace": "in {{value0}}", | |
| "current": "current", | |
| "noBranch": "No branch", | |
| "stashTitle": "Stash changes and switch?", | |
| "stashBody": "Your local changes would be overwritten. Stash them, switch, and re-apply?", | |
| "stashConfirm": "Stash & switch", | |
| "popConflict": "Switched, but re-applying your changes conflicted — they are saved in git stash.", | |
| "failed": "Could not switch branch." | |
| } | |
| "branchSwitch": { | |
| "search": "ブランチを検索…", | |
| "searching": "検索中…", | |
| "none": "一致するブランチがありません。", | |
| "local": "ローカル", | |
| "remote": "リモート", | |
| "newName": "新しいブランチ名", | |
| "create": "作成", | |
| "createNew": "新規ブランチを作成…", | |
| "inWorkspace": "({{value0}} で使用中)", | |
| "current": "現在", | |
| "noBranch": "ブランチなし", | |
| "stashTitle": "変更をスタッシュして切り替えますか?", | |
| "stashBody": "ローカル変更が上書きされます。スタッシュして切り替え、再適用しますか?", | |
| "stashConfirm": "スタッシュして切り替え", | |
| "popConflict": "切り替え後の再適用で競合しました。変更は git stash に保存されています。", | |
| "failed": "ブランチを切り替えられませんでした。" | |
| } |
| "branchSwitch": { | ||
| "search": "Search branches…", | ||
| "searching": "Searching…", | ||
| "none": "No matching branches.", | ||
| "local": "Local", | ||
| "remote": "Remote", | ||
| "newName": "New branch name", | ||
| "create": "Create", | ||
| "createNew": "Create new branch…", | ||
| "inWorkspace": "in {{value0}}", | ||
| "current": "current", | ||
| "noBranch": "No branch", | ||
| "stashTitle": "Stash changes and switch?", | ||
| "stashBody": "Your local changes would be overwritten. Stash them, switch, and re-apply?", | ||
| "stashConfirm": "Stash & switch", | ||
| "popConflict": "Switched, but re-applying your changes conflicted — they are saved in git stash.", | ||
| "failed": "Could not switch branch." |
There was a problem hiding this comment.
Translate branchSwitch strings to Korean in the Korean locale file.
The new branchSwitch entries are still English, so Korean users will see mixed-language UI.
Suggested localization patch
"branchSwitch": {
- "search": "Search branches…",
- "searching": "Searching…",
- "none": "No matching branches.",
- "local": "Local",
- "remote": "Remote",
- "newName": "New branch name",
- "create": "Create",
- "createNew": "Create new branch…",
- "inWorkspace": "in {{value0}}",
- "current": "current",
- "noBranch": "No branch",
- "stashTitle": "Stash changes and switch?",
- "stashBody": "Your local changes would be overwritten. Stash them, switch, and re-apply?",
- "stashConfirm": "Stash & switch",
- "popConflict": "Switched, but re-applying your changes conflicted — they are saved in git stash.",
- "failed": "Could not switch branch."
+ "search": "브랜치 검색…",
+ "searching": "검색 중…",
+ "none": "일치하는 브랜치가 없습니다.",
+ "local": "로컬",
+ "remote": "원격",
+ "newName": "새 브랜치 이름",
+ "create": "생성",
+ "createNew": "새 브랜치 생성…",
+ "inWorkspace": "{{value0}}에서",
+ "current": "현재",
+ "noBranch": "브랜치 없음",
+ "stashTitle": "변경 사항을 스태시하고 전환할까요?",
+ "stashBody": "로컬 변경 사항이 덮어써집니다. 스태시한 뒤 전환하고 다시 적용할까요?",
+ "stashConfirm": "스태시 후 전환",
+ "popConflict": "브랜치를 전환했지만 변경 사항 재적용 중 충돌이 발생했습니다 — 변경 사항은 git stash에 저장되었습니다.",
+ "failed": "브랜치를 전환할 수 없습니다."
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "branchSwitch": { | |
| "search": "Search branches…", | |
| "searching": "Searching…", | |
| "none": "No matching branches.", | |
| "local": "Local", | |
| "remote": "Remote", | |
| "newName": "New branch name", | |
| "create": "Create", | |
| "createNew": "Create new branch…", | |
| "inWorkspace": "in {{value0}}", | |
| "current": "current", | |
| "noBranch": "No branch", | |
| "stashTitle": "Stash changes and switch?", | |
| "stashBody": "Your local changes would be overwritten. Stash them, switch, and re-apply?", | |
| "stashConfirm": "Stash & switch", | |
| "popConflict": "Switched, but re-applying your changes conflicted — they are saved in git stash.", | |
| "failed": "Could not switch branch." | |
| "branchSwitch": { | |
| "search": "브랜치 검색…", | |
| "searching": "검색 중…", | |
| "none": "일치하는 브랜치가 없습니다.", | |
| "local": "로컬", | |
| "remote": "원격", | |
| "newName": "새 브랜치 이름", | |
| "create": "생성", | |
| "createNew": "새 브랜치 생성…", | |
| "inWorkspace": "{{value0}}에서", | |
| "current": "현재", | |
| "noBranch": "브랜치 없음", | |
| "stashTitle": "변경 사항을 스태시하고 전환할까요?", | |
| "stashBody": "로컬 변경 사항이 덮어써집니다. 스태시한 뒤 전환하고 다시 적용할까요?", | |
| "stashConfirm": "스태시 후 전환", | |
| "popConflict": "브랜치를 전환했지만 변경 사항 재적용 중 충돌이 발생했습니다 — 변경 사항은 git stash에 저장되었습니다.", | |
| "failed": "브랜치를 전환할 수 없습니다." | |
| } |
| "branchSwitch": { | ||
| "search": "Search branches…", | ||
| "searching": "Searching…", | ||
| "none": "No matching branches.", | ||
| "local": "Local", | ||
| "remote": "Remote", | ||
| "newName": "New branch name", | ||
| "create": "Create", | ||
| "createNew": "Create new branch…", | ||
| "inWorkspace": "in {{value0}}", | ||
| "current": "current", | ||
| "noBranch": "No branch", | ||
| "stashTitle": "Stash changes and switch?", | ||
| "stashBody": "Your local changes would be overwritten. Stash them, switch, and re-apply?", | ||
| "stashConfirm": "Stash & switch", | ||
| "popConflict": "Switched, but re-applying your changes conflicted — they are saved in git stash.", | ||
| "failed": "Could not switch branch." |
There was a problem hiding this comment.
Localize branchSwitch strings for zh.json instead of shipping English text.
All newly added branchSwitch values are English, so Chinese users will see untranslated UI in this flow. Please provide Chinese translations for this block to match the locale file and PR i18n goal.
Summary
Adds a PhpStorm-style branch picker to the right-sidebar Source Control panel that switches the active worktree's branch in place via
git switch.git stash.Architecture
switchGitBranch) drives all three modes (plain / stash / create) through an injectedexecfunction, so it's unit-testable and shared by both entry points — the local preload IPC handler and the runtime RPC — preventing the local and SSH paths from drifting.useBranchSwitchorchestration hook.Test plan
pnpm typecheck— cleanpnpm lint— clean (oxlint, switch-exhaustiveness, styled-scrollbars, localization catalog + coverage)useBranchSwitchhook (dirty-conflict→stash recursion, pop-conflict toast, double-submit guard), and theBranchSwitchercomponentELI5
Source Control gains a branch picker: click the branch chip, search local/remote branches, and switch the active worktree in place. If local changes would be overwritten, it can stash, switch, and re-apply.