Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
fix(source-control): resolve delete/modify conflicts and complete merges from the panel (#35347)
Kelvin Amoaba6b937c7e5f5a
diff --git a/src/main/git/source-control/commit-changes.ts b/src/main/git/source-control/commit-changes.tsindex bcac078568d..a52a9d77a2a 100644--- a/src/main/git/source-control/commit-changes.ts+++ b/src/main/git/source-control/commit-changes.ts@@ -1,16 +1,37 @@import type { GitRuntimeOptions } from '../git-runtime-options'import { gitOptionsForWorktree } from '../git-runtime-options'import { gitExecFileAsync } from '../runner'+import { detectConflictOperation } from './git-conflict-operation'import { invalidateGitReadCaches } from './git-read-cache-invalidation'-export async function commitChanges(+export function commitChanges(worktreePath: string,message: string,options: GitRuntimeOptions = {}+): Promise<{ success: boolean; error?: string }> {+ return runCommit(worktreePath, ['commit', '-m', message], options)+}++/** Concludes a paused merge with Git's MERGE_MSG; strip drops its "# Conflicts:" comments like an editor commit would. */+export async function completeMerge(+ worktreePath: string,+ options: GitRuntimeOptions = {}+): Promise<{ success: boolean; error?: string }> {+ // Without MERGE_HEAD, --no-edit would commit staged changes under commit.template text.+ if ((await detectConflictOperation(worktreePath, options)) !== 'merge') {+ return { success: false, error: 'There is no merge in progress.' }+ }+ return runCommit(worktreePath, ['commit', '--no-edit', '--cleanup=strip'], options)+}++async function runCommit(+ worktreePath: string,+ args: string[],+ options: GitRuntimeOptions): Promise<{ success: boolean; error?: string }> {invalidateGitReadCaches()try {- await gitExecFileAsync(['commit', '-m', message], gitOptionsForWorktree(worktreePath, options))+ await gitExecFileAsync(args, gitOptionsForWorktree(worktreePath, options))return { success: true }} catch (error) {// Hook/GPG failures use stderr; nothing-to-commit output can be on stdout.diff --git a/src/main/git/source-control/complete-merge-real-git.test.ts b/src/main/git/source-control/complete-merge-real-git.test.tsnew file mode 100644index 00000000000..01de1ba8eb6--- /dev/null+++ b/src/main/git/source-control/complete-merge-real-git.test.ts@@ -0,0 +1,86 @@+import { execFileSync } from 'node:child_process'+import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+import { afterEach, describe, expect, it } from 'vitest'+import { completeMerge } from './commit-changes'+import { detectConflictOperation } from './git-conflict-operation'+import { stageFile } from './staging'++describe('delete/modify merge resolved through stage and completeMerge', () => {+ const tempPaths: string[] = []++ afterEach(() => {+ for (const path of tempPaths.splice(0)) {+ rmSync(path, { recursive: true, force: true })+ }+ })++ function createDeleteModifyConflict(): {+ repoPath: string+ git: (...args: string[]) => string+ } {+ const repoPath = mkdtempSync(join(tmpdir(), 'orca-complete-merge-'))+ tempPaths.push(repoPath)+ const git = (...args: string[]): string =>+ execFileSync('git', args, { cwd: repoPath, encoding: 'utf8' })+ git('init', '--quiet', '-b', 'main')+ git('config', 'user.name', 'Orca Test')+ git('config', 'user.email', '[email protected]')+ git('config', 'commit.gpgSign', 'false')+ git('config', 'core.hooksPath', '.git/no-hooks')+ writeFileSync(join(repoPath, 'gone.txt'), 'base\n')+ git('add', 'gone.txt')+ git('commit', '--quiet', '-m', 'base')+ git('checkout', '--quiet', '-b', 'feature')+ writeFileSync(join(repoPath, 'gone.txt'), 'changed on feature\n')+ git('commit', '--quiet', '-am', 'modify')+ git('checkout', '--quiet', 'main')+ git('rm', '--quiet', 'gone.txt')+ git('commit', '--quiet', '-m', 'delete')+ expect(() => git('merge', 'feature')).toThrow()+ expect(git('status', '--porcelain')).toBe('DU gone.txt\n')+ return { repoPath, git }+ }++ it('keeps the incoming file and concludes the merge with Git’s message', async () => {+ const { repoPath, git } = createDeleteModifyConflict()++ await stageFile(repoPath, 'gone.txt')+ await expect(completeMerge(repoPath)).resolves.toEqual({ success: true })++ expect(git('log', '-1', '--format=%P').trim().split(' ')).toHaveLength(2)+ expect(git('log', '-1', '--format=%B').trim()).toBe("Merge branch 'feature'")+ expect(git('show', 'HEAD:gone.txt')).toBe('changed on feature\n')+ await expect(detectConflictOperation(repoPath)).resolves.toBe('unknown')+ })++ it('keeps the deletion by staging the removed worktree file', async () => {+ const { repoPath, git } = createDeleteModifyConflict()++ rmSync(join(repoPath, 'gone.txt'))+ await stageFile(repoPath, 'gone.txt')+ await expect(completeMerge(repoPath)).resolves.toEqual({ success: true })++ expect(git('ls-tree', '--name-only', 'HEAD')).toBe('')+ expect(git('log', '-1', '--format=%P').trim().split(' ')).toHaveLength(2)+ await expect(detectConflictOperation(repoPath)).resolves.toBe('unknown')+ })++ it('refuses without a merge in progress instead of committing staged changes', async () => {+ const { repoPath, git } = createDeleteModifyConflict()+ git('merge', '--abort')+ // A commit template gives --no-edit a message, so only the merge check stops a stray commit.+ writeFileSync(join(repoPath, '.git', 'template.txt'), 'template subject\n')+ git('config', 'commit.template', join(repoPath, '.git', 'template.txt'))+ writeFileSync(join(repoPath, 'staged.txt'), 'staged\n')+ git('add', 'staged.txt')+ const head = git('rev-parse', 'HEAD')++ await expect(completeMerge(repoPath)).resolves.toEqual({+ success: false,+ error: 'There is no merge in progress.'+ })+ expect(git('rev-parse', 'HEAD')).toBe(head)+ })+})diff --git a/src/main/git/status.ts b/src/main/git/status.tsindex 20e41804f69..9e30dc31c1d 100644--- a/src/main/git/status.ts+++ b/src/main/git/status.ts@@ -38,7 +38,7 @@ export {unstageFile} from './source-control/staging'export { getStagedCommitContext } from './source-control/staged-commit-context'-export { commitChanges } from './source-control/commit-changes'+export { commitChanges, completeMerge } from './source-control/commit-changes'export {bulkDiscardChanges,discardChanges,diff --git a/src/main/ipc/filesystem/filesystem-git-commit-handlers.ts b/src/main/ipc/filesystem/filesystem-git-commit-handlers.tsindex 57f2571d6a9..79a319c2f1a 100644--- a/src/main/ipc/filesystem/filesystem-git-commit-handlers.ts+++ b/src/main/ipc/filesystem/filesystem-git-commit-handlers.ts@@ -1,5 +1,5 @@import { ipcMain } from 'electron'-import { commitChanges } from '../../git/status'+import { commitChanges, completeMerge } from '../../git/status'import { resolveRegisteredWorktreePath } from '../registered-worktree-roots-cache'import { getLocalGitOptionsForRegisteredWorktree } from '../local-worktree-runtime-options'import type { FilesystemHandlerContext } from './filesystem-handler-context'@@ -31,4 +31,23 @@ export function registerFilesystemGitCommitHandlers(context: FilesystemHandlerCo})})+ ipcMain.handle(+ 'git:completeMerge',+ async (+ _event,+ args: { worktreePath: string; connectionId?: string }+ ): Promise<{ success: boolean; error?: string }> => {+ requireReachableGitRoute(getConnectionExecutionHostId(args.connectionId))+ const worktreePath = await resolveRegisteredWorktreePath(args.worktreePath, store)+ const gitOptions = getLocalGitOptionsForRegisteredWorktree(+ store,+ args.worktreePath,+ worktreePath+ )+ return completeMerge(worktreePath, {+ ...gitOptions,+ admissionTier: 'interactive'+ })+ }+ )}diff --git a/src/main/providers/git-provider-contract.ts b/src/main/providers/git-provider-contract.tsindex 0cdb6b638e9..1950cfab64e 100644--- a/src/main/providers/git-provider-contract.ts+++ b/src/main/providers/git-provider-contract.ts@@ -30,6 +30,7 @@ export type IGitProvider = {checkIgnoredPaths(worktreePath: string, relativePaths: string[]): Promise<string[]>getHistory(worktreePath: string, options?: GitHistoryOptions): Promise<GitHistoryResult>commit(worktreePath: string, message: string): Promise<{ success: boolean; error?: string }>+ completeMerge(worktreePath: string): Promise<{ success: boolean; error?: string }>getStagedCommitContext(worktreePath: string): Promise<CommitMessageDraftContext | null>getDiff(worktreePath: string,diff --git a/src/main/providers/local-git-provider.ts b/src/main/providers/local-git-provider.tsindex 534613452fc..fbe72623faf 100644--- a/src/main/providers/local-git-provider.ts+++ b/src/main/providers/local-git-provider.ts@@ -13,6 +13,7 @@ import {bulkStageFiles,bulkUnstageFiles,commitChanges,+ completeMerge,detectConflictOperation,discardChanges,getBranchCompare,@@ -72,6 +73,7 @@ export function createLocalGitProvider(options: LocalGitProviderOptions = {}): LgetHistory: (worktreePath, historyOptions = {}) =>getHistory(worktreePath, { ...historyOptions, ...interactive }),commit: (worktreePath, message) => commitChanges(worktreePath, message, interactive),+ completeMerge: (worktreePath) => completeMerge(worktreePath, interactive),getStagedCommitContext: (worktreePath) => getStagedCommitContext(worktreePath, interactive),getDiff: (worktreePath, filePath, staged, compareAgainstHead) =>getDiff(worktreePath, filePath, staged, compareAgainstHead, interactive),diff --git a/src/main/runtime/orca-runtime-git.ts b/src/main/runtime/orca-runtime-git.tsindex 669b2b18645..4c12fc77a8b 100644--- a/src/main/runtime/orca-runtime-git.ts+++ b/src/main/runtime/orca-runtime-git.ts@@ -31,6 +31,7 @@ export class RuntimeGitCommands {readonly rebaseRuntimeGitFromBase: RuntimeGitSyncCommands['rebaseRuntimeGitFromBase']readonly pushRuntimeGit: RuntimeGitSyncCommands['pushRuntimeGit']readonly commitRuntimeGit: RuntimeGitSyncCommands['commitRuntimeGit']+ readonly completeRuntimeGitMerge: RuntimeGitSyncCommands['completeRuntimeGitMerge']readonly generateRuntimeCommitMessage: RuntimeGitGenerationCommands['generateRuntimeCommitMessage']readonly cancelRuntimeGenerateCommitMessage: RuntimeGitGenerationCommands['cancelRuntimeGenerateCommitMessage']readonly generateRuntimePullRequestFields: RuntimeGitGenerationCommands['generateRuntimePullRequestFields']@@ -75,6 +76,7 @@ export class RuntimeGitCommands {this.rebaseRuntimeGitFromBase = sync.rebaseRuntimeGitFromBase.bind(sync)this.pushRuntimeGit = sync.pushRuntimeGit.bind(sync)this.commitRuntimeGit = sync.commitRuntimeGit.bind(sync)+ this.completeRuntimeGitMerge = sync.completeRuntimeGitMerge.bind(sync)this.generateRuntimeCommitMessage = generation.generateRuntimeCommitMessage.bind(generation)this.cancelRuntimeGenerateCommitMessage =generation.cancelRuntimeGenerateCommitMessage.bind(generation)diff --git a/src/main/runtime/rpc/methods/git.ts b/src/main/runtime/rpc/methods/git.tsindex 3d063c94b9d..64e73dae0e8 100644--- a/src/main/runtime/rpc/methods/git.ts+++ b/src/main/runtime/rpc/methods/git.ts@@ -101,6 +101,12 @@ export const GIT_METHODS = [params: WorktreeSelector,handler: async (params, { runtime }) => runtime.abortRuntimeGitMerge(params.worktree)}),+ defineMethod({+ name: 'git.completeMerge',+ permission: 'workspace',+ params: WorktreeSelector,+ handler: async (params, { runtime }) => runtime.completeRuntimeGitMerge(params.worktree)+ }),defineMethod({name: 'git.abortRebase',permission: 'workspace',diff --git a/src/main/runtime/runtime-git-command-surface.ts b/src/main/runtime/runtime-git-command-surface.tsindex 4d0e5897a13..79328e7d467 100644--- a/src/main/runtime/runtime-git-command-surface.ts+++ b/src/main/runtime/runtime-git-command-surface.ts@@ -24,6 +24,7 @@ type RuntimeGitCommandName =| 'getRuntimeGitBranchDiff'| 'getRuntimeGitCommitDiff'| 'commitRuntimeGit'+ | 'completeRuntimeGitMerge'| 'generateRuntimeCommitMessage'| 'discoverRuntimeCommitMessageModels'| 'cancelRuntimeGenerateCommitMessage'@@ -68,6 +69,7 @@ export function installRuntimeGitCommandSurface(getRuntimeGitBranchDiff: commands.getRuntimeGitBranchDiff.bind(commands),getRuntimeGitCommitDiff: commands.getRuntimeGitCommitDiff.bind(commands),commitRuntimeGit: commands.commitRuntimeGit.bind(commands),+ completeRuntimeGitMerge: commands.completeRuntimeGitMerge.bind(commands),generateRuntimeCommitMessage: commands.generateRuntimeCommitMessage.bind(commands),discoverRuntimeCommitMessageModels: commands.discoverRuntimeCommitMessageModels.bind(commands),cancelRuntimeGenerateCommitMessage: commands.cancelRuntimeGenerateCommitMessage.bind(commands),diff --git a/src/main/runtime/runtime-git-sync-commands.ts b/src/main/runtime/runtime-git-sync-commands.tsindex 0036d771d1f..c56d16c790b 100644--- a/src/main/runtime/runtime-git-sync-commands.ts+++ b/src/main/runtime/runtime-git-sync-commands.ts@@ -128,4 +128,11 @@ export class RuntimeGitSyncCommands {const target = await this.host.resolveRuntimeGitTarget(worktreeSelector)return requireRuntimeGitProvider(target).commit(target.worktree.path, message)}++ async completeRuntimeGitMerge(+ worktreeSelector: string+ ): Promise<{ success: boolean; error?: string }> {+ const target = await this.host.resolveRuntimeGitTarget(worktreeSelector)+ return requireRuntimeGitProvider(target).completeMerge(target.worktree.path)+ }}diff --git a/src/preload/api/git-bridge.ts b/src/preload/api/git-bridge.tsindex c8352b508dd..f6321855642 100644--- a/src/preload/api/git-bridge.ts+++ b/src/preload/api/git-bridge.ts@@ -132,6 +132,11 @@ export const gitApi = {message: stringconnectionId?: string}): Promise<{ success: boolean; error?: string }> => ipcRenderer.invoke('git:commit', args),+ completeMerge: (args: {+ worktreePath: string+ connectionId?: string+ }): Promise<{ success: boolean; error?: string }> =>+ ipcRenderer.invoke('git:completeMerge', args),generateCommitMessage: (args: {worktreePath: stringworktreeId?: stringdiff --git a/src/preload/api/git-operation-api.ts b/src/preload/api/git-operation-api.tsindex d75841370c8..26c7cac46b9 100644--- a/src/preload/api/git-operation-api.ts+++ b/src/preload/api/git-operation-api.ts@@ -48,6 +48,10 @@ export type GitOperationApi = {message: stringconnectionId?: string}) => Promise<{ success: boolean; error?: string }>+ completeMerge: (args: {+ worktreePath: string+ connectionId?: string+ }) => Promise<{ success: boolean; error?: string }>generateCommitMessage: (args: {worktreePath: string/** Raw (unstripped) worktree meta key; validated against worktreePath in main. */diff --git a/src/renderer/src/components/right-sidebar/source-control-too-many-changes-banner.test.tsx b/src/renderer/src/components/right-sidebar/source-control-too-many-changes-banner.test.tsxindex c5f424b1dda..9d35115d7cb 100644--- a/src/renderer/src/components/right-sidebar/source-control-too-many-changes-banner.test.tsx+++ b/src/renderer/src/components/right-sidebar/source-control-too-many-changes-banner.test.tsx@@ -71,6 +71,8 @@ describe('TooManyChangesBanner', () => {isRecoveryBusy: false,isAbortingOperation: false,onAbortOperation: vi.fn(),+ isCompletingMerge: false,+ onCompleteMerge: vi.fn(),onResolveWithAi: vi.fn(),onReviewConflicts: vi.fn(),worktreeId: 'wt-1',diff --git a/src/renderer/src/components/right-sidebar/source-control/commit/use-commit-action.ts b/src/renderer/src/components/right-sidebar/source-control/commit/use-commit-action.tsindex d5f638f9193..4ee2e230b9f 100644--- a/src/renderer/src/components/right-sidebar/source-control/commit/use-commit-action.ts+++ b/src/renderer/src/components/right-sidebar/source-control/commit/use-commit-action.ts@@ -1,7 +1,9 @@import { useCallback } from 'react'+import { toast } from 'sonner'import { requireGitOwnerTarget } from '../../worktree-git-owner-target'+import { translate } from '@/i18n/i18n'import { getConnectionId } from '@/lib/connection-context'-import { commitRuntimeGit } from '@/runtime/runtime-git-sync-client'+import { commitRuntimeGit, completeRuntimeGitMerge } from '@/runtime/runtime-git-sync-client'import type { SourceControlOperationTarget } from '../listing/operation-target'import type { SourceControlStoreActions } from '../listing/use-store-actions'import type { SourceControlWorktreeContext } from '../listing/use-worktree-context'@@ -156,7 +158,65 @@ export function useSourceControlCommitAction({])- return { handleCommit }+ const handleCompleteMerge = useCallback(async (): Promise<void> => {+ if (!activeWorktreeId || !worktreePath || unresolvedConflictCount > 0) {+ return+ }+ if (commitInFlightRef.current[activeWorktreeId]) {+ return+ }+ commitInFlightRef.current[activeWorktreeId] = true+ setCommitInFlightByWorktree((prev) => ({ ...prev, [activeWorktreeId]: true }))+ let result: { success: boolean; error?: string }+ try {+ result = await completeRuntimeGitMerge({+ target: requireGitOwnerTarget(activeRepoTarget),+ worktreeId: activeWorktreeId,+ worktreePath,+ connectionId: getConnectionId(activeWorktreeId) ?? undefined+ })+ } catch (error) {+ result = { success: false, error: error instanceof Error ? error.message : undefined }+ } finally {+ setCommitInFlightByWorktree((prev) => ({ ...prev, [activeWorktreeId]: false }))+ commitInFlightRef.current[activeWorktreeId] = false+ }+ void refreshActiveGitStatusAfterMutation()+ if (!result.success) {+ // The commit area and its inline error stay hidden while the merge is paused.+ toast.error(+ translate(+ 'auto.components.right.sidebar.source.control.commit.completeMergeFailed',+ 'Complete merge failed'+ ),+ { description: result.error }+ )+ return+ }+ if (compareBaseRef) {+ beginGitBranchCompareRequest(+ activeWorktreeId,+ `${activeWorktreeId}:${compareBaseRef}:${Date.now()}:post-commit`,+ compareBaseRef+ )+ }+ void refreshBranchCompareRef.current()+ void refreshGitHistoryRef.current()+ }, [+ activeRepoTarget,+ activeWorktreeId,+ beginGitBranchCompareRequest,+ commitInFlightRef,+ compareBaseRef,+ refreshActiveGitStatusAfterMutation,+ refreshBranchCompareRef,+ refreshGitHistoryRef,+ setCommitInFlightByWorktree,+ unresolvedConflictCount,+ worktreePath+ ])++ return { handleCommit, handleCompleteMerge }}export type SourceControlCommitAction = ReturnType<typeof useSourceControlCommitAction>diff --git a/src/renderer/src/components/right-sidebar/source-control/commit/use-commit-flows.ts b/src/renderer/src/components/right-sidebar/source-control/commit/use-commit-flows.tsindex 739f25040e1..875c9a0d3a4 100644--- a/src/renderer/src/components/right-sidebar/source-control/commit/use-commit-flows.ts+++ b/src/renderer/src/components/right-sidebar/source-control/commit/use-commit-flows.ts@@ -94,7 +94,7 @@ export function useSourceControlCommitFlows(foundation: SourceControlPanelFoundaupdateCommitMessageGenerationRecord,worktreePath})- const { handleCommit: commitStagedChanges } = commitAction+ const { handleCommit: commitStagedChanges, handleCompleteMerge } = commitActionconst { handleCancelGenerate } = commitMessageGeneration// Cancel box generation when committing its draft so a late reply cannot refill it; Create PR has its own target.const handleCommit = useCallback<typeof commitStagedChanges>(@@ -153,6 +153,7 @@ export function useSourceControlCommitFlows(foundation: SourceControlPanelFoundareturn {handleCommit,+ handleCompleteMerge,...commitMessageGeneration,...createPrIntentCommitMessage,...remoteActionRunner,diff --git a/src/renderer/src/components/right-sidebar/source-control/commit/use-entry-mutations.ts b/src/renderer/src/components/right-sidebar/source-control/commit/use-entry-mutations.tsindex a10eb08d950..a1e059bad21 100644--- a/src/renderer/src/components/right-sidebar/source-control/commit/use-entry-mutations.ts+++ b/src/renderer/src/components/right-sidebar/source-control/commit/use-entry-mutations.ts@@ -1,12 +1,18 @@-import { useCallback } from 'react'+import { useCallback, useRef } from 'react'import { requireGitOwnerTarget } from '../../worktree-git-owner-target'import type { RuntimeClientTarget } from '../../../../../../shared/runtime-client-target'+import type { GitStatusEntry } from '../../../../../../shared/git-status-types'+import type { ConflictResolution } from '../../../../../../shared/source-control-entry-actions'+import { editorFileHoldKey, pathMutationHoldKeys } from '@/components/editor/editor-autosave-holds'import {notifyEditorExternalFileChange,+ requestEditorFileSave,requestEditorSaveQuiesce} from '@/components/editor/editor-autosave'import { getConnectionId } from '@/lib/connection-context'-import { basename } from '@/lib/path'+import { basename, joinPath } from '@/lib/path'+import { useAppStore } from '@/store'+import { deleteRuntimePath } from '@/runtime/runtime-file-mutation-client'import {bulkDiscardRuntimeGitPaths,bulkUnstageRuntimeGitPaths,@@ -92,6 +98,66 @@ export function useSourceControlEntryMutations({[runEntryMutation])+ const resolvingConflictKeysRef = useRef(new Set<string>())+ const handleResolveConflict = useCallback(+ (entry: GitStatusEntry, resolution: ConflictResolution): Promise<void> => {+ // One resolution per file at a time: a second click could stage before an earlier delete lands.+ const resolvingKey = `${activeWorktreeId}\0${entry.path}`+ if (+ !activeWorktreeId ||+ !worktreePath ||+ !entry.conflictKind ||+ resolvingConflictKeysRef.current.has(resolvingKey)+ ) {+ return Promise.resolve()+ }+ // Staging drops Git's u record; tracking keeps the row's Resolved locally continuity.+ useAppStore.getState().trackConflictPath(activeWorktreeId, entry.path, entry.conflictKind)+ const editorTarget = {+ worktreeId: activeWorktreeId,+ worktreePath,+ relativePath: entry.path,+ runtimeEnvironmentId:+ activeRepoTarget?.kind === 'environment' ? activeRepoTarget.environmentId : null+ }+ const resolve: (context: RuntimeGitContext, filePath: string) => Promise<void> =+ resolution !== 'keep_deletion'+ ? async (context, filePath) => {+ // Same view match as autosave holds: every workspace's view of this physical file, not another host's.+ const current = useAppStore.getState()+ const keys = pathMutationHoldKeys(current, editorTarget)+ const dirtyFiles = current.openFiles.filter(+ (file) => file.isDirty && keys.has(editorFileHoldKey(current, file))+ )+ // Stage what the user sees: an unsaved resolution must reach disk before git add reads it.+ await Promise.all(+ dirtyFiles.map((file) => requestEditorFileSave({ fileId: file.id }))+ )+ await stageRuntimeGitPath(context, filePath)+ }+ : async (context, filePath) => {+ // Hold autosave so an open tab cannot recreate the file after it is removed.+ const releaseAutoSave = await requestEditorSaveQuiesce(editorTarget)+ try {+ // Delete even if status said absent so a since-restored file is never staged; Git history keeps it.+ await deleteRuntimePath(context, joinPath(worktreePath, filePath), false, {+ permanent: true+ })+ notifyEditorExternalFileChange(editorTarget)+ // With the worktree file gone, git add stages the removal and resolves the conflict.+ await stageRuntimeGitPath(context, filePath)+ } finally {+ releaseAutoSave()+ }+ }+ resolvingConflictKeysRef.current.add(resolvingKey)+ return runEntryMutation('stage', entry.path, resolve).finally(() => {+ resolvingConflictKeysRef.current.delete(resolvingKey)+ })+ },+ [activeRepoTarget, activeWorktreeId, runEntryMutation, worktreePath]+ )+// Throw for bulk callers to aggregate; per-row callers report their own failures.const discardSingle = useCallback(async (filePath: string) => {@@ -191,5 +257,11 @@ export function useSourceControlEntryMutations({[activeRepoTarget, activeWorktreeId, worktreePath])- return { handleStage, handleUnstage, discardSingle, discardMany }+ return {+ handleStage,+ handleUnstage,+ handleResolveConflict,+ discardSingle,+ discardMany+ }}diff --git a/src/renderer/src/components/right-sidebar/source-control/listing/conflict-label.ts b/src/renderer/src/components/right-sidebar/source-control/listing/conflict-label.tsindex 96db590eeb4..7d08a39ffcd 100644--- a/src/renderer/src/components/right-sidebar/source-control/listing/conflict-label.ts+++ b/src/renderer/src/components/right-sidebar/source-control/listing/conflict-label.ts@@ -1,4 +1,6 @@import type { GitStatusEntry } from '../../../../../../shared/git-status-types'+import { Check, FileCheck, FileX, type LucideIcon } from 'lucide-react'+import type { ConflictResolution } from '../../../../../../shared/source-control-entry-actions'import { translate } from '@/i18n/i18n'/** Localized short label for a merge-conflict kind, e.g. `both_modified` → "both modified". */@@ -22,3 +24,23 @@ export function getLocalizedConflictKindLabel(return translate('auto.components.right.sidebar.SourceControl.5b176fa431', 'both deleted')}}++export const CONFLICT_RESOLUTION_ICONS: Record<ConflictResolution, LucideIcon> = {+ mark_resolved: Check,+ keep_file: FileCheck,+ keep_deletion: FileX+}++export function getLocalizedConflictResolutionLabel(resolution: ConflictResolution): string {+ switch (resolution) {+ case 'mark_resolved':+ return translate(+ 'auto.components.right.sidebar.SourceControl.markResolved',+ 'Mark as resolved'+ )+ case 'keep_file':+ return translate('auto.components.right.sidebar.SourceControl.keepFile', 'Keep file')+ case 'keep_deletion':+ return translate('auto.components.right.sidebar.SourceControl.keepDeletion', 'Keep deletion')+ }+}diff --git a/src/renderer/src/components/right-sidebar/source-control/listing/conflict-status-cards.tsx b/src/renderer/src/components/right-sidebar/source-control/listing/conflict-status-cards.tsxindex d22e1ba8ff9..fded204d048 100644--- a/src/renderer/src/components/right-sidebar/source-control/listing/conflict-status-cards.tsx+++ b/src/renderer/src/components/right-sidebar/source-control/listing/conflict-status-cards.tsx@@ -115,6 +115,8 @@ export function OperationBanner({isRecoveryBusy = false,isAbortingOperation = false,onAbortOperation,+ isCompletingMerge = false,+ onCompleteMerge,sourceControlAiActionsVisible = false,onResolveWithAI}: {@@ -122,6 +124,8 @@ export function OperationBanner({isRecoveryBusy?: booleanisAbortingOperation?: booleanonAbortOperation?: (operation: GitConflictOperation) => void+ isCompletingMerge?: boolean+ onCompleteMerge?: () => voidsourceControlAiActionsVisible?: booleanonResolveWithAI?: () => void}): React.JSX.Element {@@ -147,6 +151,7 @@ export function OperationBanner({)const Icon = conflictOperation === 'rebase' ? GitPullRequestArrow : GitMerge+ const canCompleteMerge = conflictOperation === 'merge' && !!onCompleteMergereturn (<div className="rounded-md border border-amber-500/25 bg-amber-500/5 px-3 py-2">@@ -155,13 +160,33 @@ export function OperationBanner({<span className="text-xs font-medium text-foreground">{label}</span></div><div className="mt-2 space-y-1.5">- {sourceControlAiActionsVisible && onResolveWithAI ? (+ {canCompleteMerge ? (<Buttontype="button"variant="default"size="sm"className="h-7 w-full text-xs"- disabled={isAbortingOperation || isRecoveryBusy}+ disabled={isCompletingMerge || isAbortingOperation || isRecoveryBusy}+ onClick={onCompleteMerge}+ >+ {isCompletingMerge ? (+ <RefreshCw className="size-3.5 animate-spin" />+ ) : (+ <GitMerge className="size-3.5" />+ )}+ {translate(+ 'auto.components.right.sidebar.source.control.conflict.status.cards.completeMerge',+ 'Complete merge'+ )}+ </Button>+ ) : null}+ {sourceControlAiActionsVisible && onResolveWithAI ? (+ <Button+ type="button"+ variant={canCompleteMerge ? 'outline' : 'default'}+ size="sm"+ className="h-7 w-full text-xs"+ disabled={isAbortingOperation || isRecoveryBusy || isCompletingMerge}onClick={onResolveWithAI}><Sparkles className="size-3.5" />@@ -174,7 +199,7 @@ export function OperationBanner({variant="outline"size="sm"className="h-7 w-full text-xs"- disabled={isAbortingOperation}+ disabled={isAbortingOperation || isCompletingMerge}onClick={() => onAbortOperation(conflictOperation)}>{isAbortingOperation ? <RefreshCw className="size-3.5 animate-spin" /> : null}diff --git a/src/renderer/src/components/right-sidebar/source-control/listing/content-status.test.tsx b/src/renderer/src/components/right-sidebar/source-control/listing/content-status.test.tsxindex c4866ff1602..a0019a0c8e4 100644--- a/src/renderer/src/components/right-sidebar/source-control/listing/content-status.test.tsx+++ b/src/renderer/src/components/right-sidebar/source-control/listing/content-status.test.tsx@@ -13,6 +13,8 @@ function statusProps(): React.ComponentProps<typeof SourceControlContentStatus>isRecoveryBusy: false,isAbortingOperation: false,onAbortOperation: vi.fn(),+ isCompletingMerge: false,+ onCompleteMerge: vi.fn(),onResolveWithAi: vi.fn(),onReviewConflicts: vi.fn(),repositoryHuge: null,diff --git a/src/renderer/src/components/right-sidebar/source-control/listing/content-status.tsx b/src/renderer/src/components/right-sidebar/source-control/listing/content-status.tsxindex 37e236c70eb..d3c0b7c023b 100644--- a/src/renderer/src/components/right-sidebar/source-control/listing/content-status.tsx+++ b/src/renderer/src/components/right-sidebar/source-control/listing/content-status.tsx@@ -14,6 +14,8 @@ export function SourceControlContentStatus({isRecoveryBusy,isAbortingOperation,onAbortOperation,+ isCompletingMerge,+ onCompleteMerge,onResolveWithAi,onReviewConflicts,repositoryHuge,@@ -36,6 +38,8 @@ export function SourceControlContentStatus({isRecoveryBusy: booleanisAbortingOperation: booleanonAbortOperation: (operation: GitConflictOperation) => void+ isCompletingMerge: boolean+ onCompleteMerge: () => voidonResolveWithAi: () => voidonReviewConflicts: () => voidrepositoryHuge: { limit: number } | null | undefined@@ -75,6 +79,8 @@ export function SourceControlContentStatus({isRecoveryBusy={isRecoveryBusy}isAbortingOperation={isAbortingOperation}onAbortOperation={onAbortOperation}+ isCompletingMerge={isCompletingMerge}+ onCompleteMerge={onCompleteMerge}sourceControlAiActionsVisible={sourceControlAiActionsVisible}onResolveWithAI={onResolveWithAi}/>diff --git a/src/renderer/src/components/right-sidebar/source-control/listing/entry-context-menu.tsx b/src/renderer/src/components/right-sidebar/source-control/listing/entry-context-menu.tsxindex 22037cd5b75..13e0a0b0746 100644--- a/src/renderer/src/components/right-sidebar/source-control/listing/entry-context-menu.tsx+++ b/src/renderer/src/components/right-sidebar/source-control/listing/entry-context-menu.tsx@@ -27,6 +27,8 @@ import {} from '@/lib/local-path-open-guard'import { runtimeEnvironmentIdOrLocalUnlessTwin } from '@/lib/worktree-runtime-owner'import { formatClipboardFilePath } from '@/lib/clipboard-file-path'+import type { ConflictResolution } from '../../../../../../shared/source-control-entry-actions'+import { CONFLICT_RESOLUTION_ICONS, getLocalizedConflictResolutionLabel } from './conflict-label'import { NO_OPEN_IN_APPLICATIONS } from '@/lib/open-in-application-selection'import {getOpenInEntryAvailability,@@ -42,6 +44,8 @@ type SourceControlEntryContextMenuProps = {hasWorkingTreeFile: booleanconnectionId?: string | nullonView?: () => void+ conflictResolutions?: readonly ConflictResolution[]+ onResolveConflict?: (resolution: ConflictResolution) => voidonRevealInExplorer: (worktreeId: string, absolutePath: string) => voidonOpenChange?: (open: boolean) => voidchildren: React.ReactNode@@ -54,6 +58,8 @@ export function SourceControlEntryContextMenu({hasWorkingTreeFile,connectionId,onView,+ conflictResolutions,+ onResolveConflict,onRevealInExplorer,onOpenChange,children@@ -128,6 +134,20 @@ export function SourceControlEntryContextMenu({'View')}</ContextMenuItem>+ {onResolveConflict && conflictResolutions && conflictResolutions.length > 0 ? (+ <>+ <ContextMenuSeparator />+ {conflictResolutions.map((resolution) => {+ const Icon = CONFLICT_RESOLUTION_ICONS[resolution]+ return (+ <ContextMenuItem key={resolution} onSelect={() => onResolveConflict(resolution)}>+ <Icon className="size-3.5" />+ {getLocalizedConflictResolutionLabel(resolution)}+ </ContextMenuItem>+ )+ })}+ </>+ ) : null}<ContextMenuSeparator /><ContextMenuItem onSelect={handleCopyPath} disabled={!absolutePath}><Copy className="size-3.5" />diff --git a/src/renderer/src/components/right-sidebar/source-control/listing/section-action-buttons.test.tsx b/src/renderer/src/components/right-sidebar/source-control/listing/section-action-buttons.test.tsxindex 3701cd4d9f3..5d28b022f63 100644--- a/src/renderer/src/components/right-sidebar/source-control/listing/section-action-buttons.test.tsx+++ b/src/renderer/src/components/right-sidebar/source-control/listing/section-action-buttons.test.tsx@@ -67,6 +67,7 @@ function renderUncommittedSections({activeConnectionId={null}handleOpenDiff={vi.fn()}handleStage={vi.fn()}+ handleResolveConflict={vi.fn()}handleUnstage={vi.fn()}requestDiscardEntry={vi.fn()}diffCommentCountByPath={new Map()}diff --git a/src/renderer/src/components/right-sidebar/source-control/listing/section-file-list.tsx b/src/renderer/src/components/right-sidebar/source-control/listing/section-file-list.tsxindex 882956ef434..8819392808b 100644--- a/src/renderer/src/components/right-sidebar/source-control/listing/section-file-list.tsx+++ b/src/renderer/src/components/right-sidebar/source-control/listing/section-file-list.tsx@@ -1,5 +1,6 @@import React from 'react'import type { GitStatusEntry } from '../../../../../../shared/git-status-types'+import type { ConflictResolution } from '../../../../../../shared/source-control-entry-actions'import type { SourceControlViewMode } from '../../../../../../shared/ui-chrome-types'import type { DiscardAllArea } from '../../../../../../shared/source-control-discard-all-sequence'import {@@ -39,6 +40,7 @@ export function SourceControlSectionFileList({activeConnectionId,handleOpenDiff,handleStage,+ handleResolveConflict,handleUnstage,requestDiscardEntry,diffCommentCountByPath@@ -66,6 +68,7 @@ export function SourceControlSectionFileList({activeConnectionId: string | nullhandleOpenDiff: (entry: GitStatusEntry, event?: SourceControlRowOpenEvent) => voidhandleStage: (path: string) => Promise<void>+ handleResolveConflict: (entry: GitStatusEntry, resolution: ConflictResolution) => Promise<void>handleUnstage: (path: string, oldPath?: string) => Promise<void>requestDiscardEntry: (entry: GitStatusEntry) => voiddiffCommentCountByPath: Map<string, number>@@ -124,6 +127,7 @@ export function SourceControlSectionFileList({connectionId={activeConnectionId}onOpen={handleOpenDiff}onStage={handleStage}+ onResolveConflict={handleResolveConflict}onUnstage={handleUnstage}onDiscard={requestDiscardEntry}commentCount={diffCommentCountByPath.get(node.entry.path) ?? 0}@@ -175,6 +179,7 @@ export function SourceControlSectionFileList({connectionId={activeConnectionId}onOpen={handleOpenDiff}onStage={handleStage}+ onResolveConflict={handleResolveConflict}onUnstage={handleUnstage}onDiscard={requestDiscardEntry}commentCount={diffCommentCountByPath.get(entry.path) ?? 0}diff --git a/src/renderer/src/components/right-sidebar/source-control/listing/uncommitted-entry-row.tsx b/src/renderer/src/components/right-sidebar/source-control/listing/uncommitted-entry-row.tsxindex 06c09719bfe..70e58e1b76d 100644--- a/src/renderer/src/components/right-sidebar/source-control/listing/uncommitted-entry-row.tsx+++ b/src/renderer/src/components/right-sidebar/source-control/listing/uncommitted-entry-row.tsx@@ -10,14 +10,20 @@ import { useUiLanguageRevision } from '@/i18n/use-ui-language-revision'import type { GitStatusEntry } from '../../../../../../shared/git-status-types'import { ActionButton } from './action-button'import { ConflictBadge } from './conflict-badge'-import { getLocalizedConflictKindLabel } from './conflict-label'+import {+ CONFLICT_RESOLUTION_ICONS,+ getLocalizedConflictKindLabel,+ getLocalizedConflictResolutionLabel+} from './conflict-label'import { DiffLineCounts } from './diff-line-counts'import { reviewNoteCountTitle } from './review-note-count-title'import { SourceControlEntryContextMenu } from './entry-context-menu'import {canDiscardStatusEntry,canStageStatusEntry,- canUnstageStatusEntry+ canUnstageStatusEntry,+ getConflictResolutions,+ type ConflictResolution} from '../../../../../../shared/source-control-entry-actions'import { isSubmoduleWorktreeOnlyChange } from '../../../../../../shared/source-control-discard-all-sequence'import { toPermanentSourceControlRowOpenEvent, type SourceControlRowOpenEvent } from './split-open'@@ -44,6 +50,7 @@ export const UncommittedEntryRow = React.memo(function UncommittedEntryRow({connectionId,onOpen,onStage,+ onResolveConflict,onUnstage,onDiscard,commentCount,@@ -63,6 +70,7 @@ export const UncommittedEntryRow = React.memo(function UncommittedEntryRow({connectionId?: string | nullonOpen: (entry: GitStatusEntry, event?: SourceControlRowOpenEvent) => voidonStage: (filePath: string) => Promise<void>+ onResolveConflict: (entry: GitStatusEntry, resolution: ConflictResolution) => Promise<void>onUnstage: (filePath: string, oldPath?: string) => Promise<void>onDiscard: (entry: GitStatusEntry) => voidcommentCount: number@@ -84,6 +92,7 @@ export const UncommittedEntryRow = React.memo(function UncommittedEntryRow({const canStage = canStageStatusEntry(entry)// Parent Git cannot unstage submodule-internal files; match bulk gating.const canUnstage = canUnstageStatusEntry(entry)+ const conflictResolutions = getConflictResolutions(entry)return (<SourceControlEntryContextMenu@@ -93,6 +102,8 @@ export const UncommittedEntryRow = React.memo(function UncommittedEntryRow({hasWorkingTreeFile={entry.status !== 'deleted'}connectionId={connectionId}onView={() => onOpen(entry)}+ conflictResolutions={conflictResolutions}+ onResolveConflict={(resolution) => void onResolveConflict(entry, resolution)}onRevealInExplorer={onRevealInExplorer}onOpenChange={(open) => {if (open && onContextMenu) {@@ -203,6 +214,17 @@ export const UncommittedEntryRow = React.memo(function UncommittedEntryRow({</>)}<div className={SOURCE_CONTROL_ROW_ACTION_OVERLAY_CLASS}>+ {conflictResolutions.map((resolution) => (+ <ActionButton+ key={resolution}+ icon={CONFLICT_RESOLUTION_ICONS[resolution]}+ title={getLocalizedConflictResolutionLabel(resolution)}+ onClick={(event) => {+ event.stopPropagation()+ void onResolveConflict(entry, resolution)+ }}+ />+ ))}{canDiscard && (<ActionButtonicon={entry.area === 'untracked' ? Trash : Undo2}diff --git a/src/renderer/src/components/right-sidebar/source-control/listing/uncommitted-sections.tsx b/src/renderer/src/components/right-sidebar/source-control/listing/uncommitted-sections.tsxindex de80ab68fb6..6cc307b8300 100644--- a/src/renderer/src/components/right-sidebar/source-control/listing/uncommitted-sections.tsx+++ b/src/renderer/src/components/right-sidebar/source-control/listing/uncommitted-sections.tsx@@ -3,6 +3,7 @@ import { Minus, Plus, Undo2 } from 'lucide-react'import { Button } from '@/components/ui/button'import { translate } from '@/i18n/i18n'import type { GitStatusEntry } from '../../../../../../shared/git-status-types'+import type { ConflictResolution } from '../../../../../../shared/source-control-entry-actions'import type { SourceControlViewMode } from '../../../../../../shared/ui-chrome-types'import {getDiscardAllPaths,@@ -83,6 +84,7 @@ export function SourceControlUncommittedSections(props: {activeConnectionId: string | nullhandleOpenDiff: (entry: GitStatusEntry, event?: SourceControlRowOpenEvent) => voidhandleStage: (path: string) => Promise<void>+ handleResolveConflict: (entry: GitStatusEntry, resolution: ConflictResolution) => Promise<void>handleUnstage: (path: string, oldPath?: string) => Promise<void>requestDiscardEntry: (entry: GitStatusEntry) => voiddiffCommentCountByPath: Map<string, number>@@ -200,6 +202,7 @@ export function SourceControlUncommittedSections(props: {activeConnectionId={props.activeConnectionId}handleOpenDiff={props.handleOpenDiff}handleStage={props.handleStage}+ handleResolveConflict={props.handleResolveConflict}handleUnstage={props.handleUnstage}requestDiscardEntry={props.requestDiscardEntry}diffCommentCountByPath={props.diffCommentCountByPath}diff --git a/src/renderer/src/components/right-sidebar/source-control/panel/panel-content.tsx b/src/renderer/src/components/right-sidebar/source-control/panel/panel-content.tsxindex f1f9a424c16..1a65a1834f0 100644--- a/src/renderer/src/components/right-sidebar/source-control/panel/panel-content.tsx+++ b/src/renderer/src/components/right-sidebar/source-control/panel/panel-content.tsx@@ -29,10 +29,12 @@ export function SourceControlPanelContent(props: SourceControlPanelReadyProps) {gitHistoryState,handleAbortOperationForConflict,handleCommitAction,+ handleCompleteMerge,handleContextMenu,handleOpenDiff,handleResolveConflictsWithAI,handleSelect,+ handleResolveConflict,handleStage,handleStageAllPaths,handleStageSectionPaths,@@ -43,6 +45,7 @@ export function SourceControlPanelContent(props: SourceControlPanelReadyProps) {isResolvingConflictsWithAI,isAbortingOperation,isCheckingRecoveryAdmission,+ isCommitting,isExecutingBulk,isGitHistoryVisible,loadCommitFiles,@@ -94,6 +97,8 @@ export function SourceControlPanelContent(props: SourceControlPanelReadyProps) {isRecoveryBusy={isCheckingRecoveryAdmission || isResolvingConflictsWithAI}isAbortingOperation={isAbortingOperation}onAbortOperation={handleAbortOperationForConflict}+ isCompletingMerge={isCommitting}+ onCompleteMerge={() => void handleCompleteMerge()}onResolveWithAi={() => void handleResolveConflictsWithAI()}onReviewConflicts={() => {openConflictReview(@@ -174,6 +179,7 @@ export function SourceControlPanelContent(props: SourceControlPanelReadyProps) {activeConnectionId={activeConnectionId}handleOpenDiff={handleOpenDiff}handleStage={handleStage}+ handleResolveConflict={handleResolveConflict}handleUnstage={handleUnstage}requestDiscardEntry={requestDiscardEntry}diffCommentCountByPath={diffCommentCountByPath}diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.jsonindex 0d6347e81b4..8c56ac9529d 100644--- a/src/renderer/src/i18n/locales/en.json+++ b/src/renderer/src/i18n/locales/en.json@@ -13866,7 +13866,10 @@"clearNotesFromWorkspace_one": "Clear {{count}} note from this workspace?","clearNotesFromWorkspace_other": "Clear {{count}} notes from this workspace?","clearNotesFromFile_one": "Clear {{count}} note from {{path}}?",- "clearNotesFromFile_other": "Clear {{count}} notes from {{path}}?"+ "clearNotesFromFile_other": "Clear {{count}} notes from {{path}}?",+ "markResolved": "Mark as resolved",+ "keepFile": "Keep file",+ "keepDeletion": "Keep deletion"},"SourceControlAgentActionDialog": {"8e856842d1": "Could not start the selected agent.",@@ -14448,7 +14451,8 @@"edc2d82a2b": "Merge in progress","5c3707aa44": "Rebase in progress","ffe53a1da6": "Cherry-pick in progress",- "35eb76d323": "Operation in progress"+ "35eb76d323": "Operation in progress",+ "completeMerge": "Complete merge"}}},@@ -14477,7 +14481,8 @@"e7876a2bde": "Stage at least one file to generate a message.","0904be2505": "Clear the message to regenerate.","1ea9ba37aa": "Pick an agent in Settings -> Git -> Source Control AI."- }+ },+ "completeMergeFailed": "Complete merge failed"}}},@@ -18957,6 +18962,9 @@"forgeCredentialTarget": {"unknownHost": "The machine that owns this repository is not known yet. Reconnect it and try again.","thisComputer": "this computer"+ },+ "runtimeGitSyncClient": {+ "completeMergeNeedsNewerHost": "Completing a merge needs a newer Orca on this host. Update Orca on that host."}},"ssh": {diff --git a/src/renderer/src/runtime/runtime-git-sync-client.ts b/src/renderer/src/runtime/runtime-git-sync-client.tsindex aa2692be023..729a1bb9170 100644--- a/src/renderer/src/runtime/runtime-git-sync-client.ts+++ b/src/renderer/src/runtime/runtime-git-sync-client.ts@@ -3,7 +3,9 @@ import type { GitUpstreamStatus } from '../../../shared/git-status-types'import { REBASE_FROM_BASE_RPC_TIMEOUT_MS } from '../../../shared/git-rebase-source'import type { GitPushTarget } from '../../../shared/worktree/types'import { resolveLocalWorktreePath, type RuntimeGitContext } from './runtime-git-client-context'+import { translate } from '@/i18n/i18n'import { callRuntimeRpc } from './runtime-rpc-client'+import { RuntimeRpcCallError } from './runtime-rpc-result'import { toRuntimeWorktreeSelector } from './runtime-worktree-selector'export async function abortRuntimeGitMerge(context: RuntimeGitContext): Promise<void> {@@ -227,3 +229,34 @@ export async function commitRuntimeGit({ timeoutMs: 30_000 })}++export async function completeRuntimeGitMerge(+ context: RuntimeGitContext+): Promise<{ success: boolean; error?: string }> {+ const target = context.target+ if (target.kind === 'local' || !context.worktreeId) {+ return window.api.git.completeMerge({+ worktreePath: resolveLocalWorktreePath(context),+ connectionId: context.connectionId+ })+ }+ try {+ return await callRuntimeRpc<{ success: boolean; error?: string }>(+ target,+ 'git.completeMerge',+ { worktree: toRuntimeWorktreeSelector(context.worktreeId) },+ { timeoutMs: 30_000 }+ )+ } catch (error) {+ if (error instanceof RuntimeRpcCallError && error.code === 'method_not_found') {+ return {+ success: false,+ error: translate(+ 'auto.runtime.runtimeGitSyncClient.completeMergeNeedsNewerHost',+ 'Completing a merge needs a newer Orca on this host. Update Orca on that host.'+ )+ }+ }+ throw error+ }+}diff --git a/src/renderer/src/web/preload-api/web-git-api.ts b/src/renderer/src/web/preload-api/web-git-api.tsindex df1559c76c3..c7a3a7c87b2 100644--- a/src/renderer/src/web/preload-api/web-git-api.ts+++ b/src/renderer/src/web/preload-api/web-git-api.ts@@ -225,6 +225,12 @@ export function createGitApi(): NonNullable<Partial<PreloadApi>['git']> {message})},+ completeMerge: async ({ worktreePath }) => {+ const worktree = await resolveRuntimeWorktreeByPath(worktreePath)+ return callRuntimeResult('git.completeMerge', {+ worktree: toRuntimeWorktreeSelector(worktree.id)+ })+ },generateCommitMessage: async () => ({success: false,error: translate(diff --git a/src/shared/rpc-contract/rpc-params-catalog.generated.ts b/src/shared/rpc-contract/rpc-params-catalog.generated.tsindex 981b5dd8b52..3f1666ed73b 100644--- a/src/shared/rpc-contract/rpc-params-catalog.generated.ts+++ b/src/shared/rpc-contract/rpc-params-catalog.generated.ts@@ -1019,6 +1019,7 @@ export const RPC_PARAMS_BY_METHOD = {'git.commit': GitCommit,'git.commitCompare': GitCommitCompare,'git.commitDiff': GitCommitDiff,+ 'git.completeMerge': WorktreeSelectorOfGitParams,'git.conflictOperation': WorktreeSelectorOfGitParams,'git.diff': GitDiff,'git.discard': GitFilePath,diff --git a/src/shared/source-control-entry-actions.test.ts b/src/shared/source-control-entry-actions.test.tsnew file mode 100644index 00000000000..e5a58129f09--- /dev/null+++ b/src/shared/source-control-entry-actions.test.ts@@ -0,0 +1,41 @@+import { describe, expect, it } from 'vitest'+import type { GitStatusEntry } from './git-status-types'+import { getConflictResolutions } from './source-control-entry-actions'++function conflict(overrides: Partial<GitStatusEntry>): GitStatusEntry {+ return {+ path: 'a.txt',+ area: 'unstaged',+ status: 'modified',+ conflictKind: 'both_modified',+ conflictStatus: 'unresolved',+ ...overrides+ }+}++describe('getConflictResolutions', () => {+ it('offers both sides of a delete/modify conflict while the surviving file is present', () => {+ expect(getConflictResolutions(conflict({ conflictKind: 'deleted_by_us' }))).toEqual([+ 'keep_file',+ 'keep_deletion'+ ])+ })++ it('offers only the deletion once the worktree file is gone', () => {+ expect(+ getConflictResolutions(conflict({ conflictKind: 'deleted_by_them', status: 'deleted' }))+ ).toEqual(['keep_deletion'])+ expect(+ getConflictResolutions(conflict({ conflictKind: 'both_modified', status: 'deleted' }))+ ).toEqual(['keep_deletion'])+ })++ it('marks content conflicts resolved as edited', () => {+ expect(getConflictResolutions(conflict({}))).toEqual(['mark_resolved'])+ })++ it('offers nothing for resolved rows or rows inside a submodule the parent cannot stage', () => {+ expect(getConflictResolutions(conflict({ conflictStatus: 'resolved_locally' }))).toEqual([])+ expect(getConflictResolutions(conflict({ submoduleRoot: 'sub' }))).toEqual([])+ })+})diff --git a/src/shared/source-control-entry-actions.ts b/src/shared/source-control-entry-actions.tsindex 0fb878a3553..180cdf65ec3 100644--- a/src/shared/source-control-entry-actions.ts+++ b/src/shared/source-control-entry-actions.ts@@ -19,3 +19,19 @@ export function canDiscardStatusEntry(entry: GitStatusEntry): boolean {(entry.area === 'unstaged' || entry.area === 'untracked'))}++export type ConflictResolution = 'mark_resolved' | 'keep_file' | 'keep_deletion'++/** Staging the worktree is Git's resolution; a missing worktree file can only resolve as a deletion. */+export function getConflictResolutions(entry: GitStatusEntry): ConflictResolution[] {+ if (entry.conflictStatus !== 'unresolved' || !entry.conflictKind || entry.submoduleRoot) {+ return []+ }+ if (entry.status === 'deleted') {+ return ['keep_deletion']+ }+ if (entry.conflictKind === 'deleted_by_us' || entry.conflictKind === 'deleted_by_them') {+ return ['keep_file', 'keep_deletion']+ }+ return ['mark_resolved']+}