From 9599d718b6853c27fcfa448f86e30e04a85f8519 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sun, 1 Nov 2026 14:41:11 -0700 Subject: [PATCH] Clarify Git operation status across workspaces (#37093) * Clarify Git operation status across workspaces * fix translation * Clarify when a Git operation is running in another workspace * Clarify Git operation feedback in Chinese translations * Clarify which Git operations can block another workspace * Show Git operation waiting feedback during PR preparation * rm file * Fix remote operation ownership test setup * Fix remote operation ownership test setup --- .../right-sidebar/CommitArea.test.tsx | 19 +++++ .../source-control-primary-action-types.ts | 2 + ...ol-primary-action.create-pr-intent.test.ts | 51 +++++++++++ .../source-control-primary-action.ts | 33 +++++++ .../ai/use-ai.operation-recovery.test.tsx | 2 +- .../commit/commit-action-menu.tsx | 8 +- .../commit/commit-area.fixture.tsx | 85 +++++++++++++++++++ .../source-control/commit/commit-area.tsx | 8 +- .../listing/use-worktree-context.ts | 9 +- .../source-control/panel/use-panel-model.ts | 2 + .../review/primary-create-pr-intent-action.ts | 32 ++++--- .../source-control/review/use-action-model.ts | 4 + src/renderer/src/i18n/locales/de.json | 2 + src/renderer/src/i18n/locales/en.json | 2 + src/renderer/src/i18n/locales/es.json | 2 + src/renderer/src/i18n/locales/fr.json | 2 + src/renderer/src/i18n/locales/ja.json | 2 + src/renderer/src/i18n/locales/ko.json | 2 + src/renderer/src/i18n/locales/pt.json | 2 + src/renderer/src/i18n/locales/ru.json | 2 + src/renderer/src/i18n/locales/tr.json | 2 + src/renderer/src/i18n/locales/zh-Hant.json | 2 + src/renderer/src/i18n/locales/zh.json | 2 + .../editor-remote-branch-actions.test.ts | 49 ++++++++++- .../editor/actions/git-remote-push-pull.ts | 15 ++-- .../editor/actions/git-remote-status.ts | 34 +++----- .../slices/editor/actions/git-remote-sync.ts | 12 +-- .../slices/editor/types/editor-git-slice.ts | 8 +- .../github-post-operation-owner.test.ts | 8 +- .../source-control-operation-recovery.spec.ts | 2 +- 30 files changed, 336 insertions(+), 69 deletions(-) create mode 100644 src/renderer/src/components/right-sidebar/source-control/commit/commit-area.fixture.tsx diff --git a/src/renderer/src/components/right-sidebar/CommitArea.test.tsx b/src/renderer/src/components/right-sidebar/CommitArea.test.tsx index d12113766be..aac5b507cd8 100644 --- a/src/renderer/src/components/right-sidebar/CommitArea.test.tsx +++ b/src/renderer/src/components/right-sidebar/CommitArea.test.tsx @@ -838,3 +838,22 @@ describe('OperationBanner', () => { } }) }) + +it('shows waiting feedback without a publish spinner when another workspace publishes', () => { + const props = baseProps({ + stagedCount: 0, + hasMessage: false, + upstreamStatus: { hasUpstream: false, ahead: 0, behind: 0 }, + isRemoteOperationActive: true, + inFlightRemoteOpKind: null, + isRemoteOperationInAnotherWorktree: true + }) + const { container, getByRole } = render() + expect( + getByRole('button', { name: 'Git operation running elsewhere' }).hasAttribute('disabled') + ).toBe(true) + expect(container.querySelector('.animate-spin')).toBeNull() + expect(container.textContent).toContain( + 'Another workspace is running a Git operation, such as push, pull, or force push.' + ) +}) diff --git a/src/renderer/src/components/right-sidebar/source-control-primary-action-types.ts b/src/renderer/src/components/right-sidebar/source-control-primary-action-types.ts index 6703bb9d45b..f91b2661223 100644 --- a/src/renderer/src/components/right-sidebar/source-control-primary-action-types.ts +++ b/src/renderer/src/components/right-sidebar/source-control-primary-action-types.ts @@ -17,6 +17,7 @@ export type PrimaryAction = { label: string title: string disabled: boolean + isWaitingForRemoteOperation?: boolean } export type PrimaryActionInputs = { @@ -28,6 +29,7 @@ export type PrimaryActionInputs = { hasUnresolvedConflicts: boolean isCommitting: boolean isRemoteOperationActive: boolean + isRemoteOperationInAnotherWorktree?: boolean upstreamStatus: GitUpstreamStatus | undefined prState?: PRState | null isPRStateLoading?: boolean diff --git a/src/renderer/src/components/right-sidebar/source-control-primary-action.create-pr-intent.test.ts b/src/renderer/src/components/right-sidebar/source-control-primary-action.create-pr-intent.test.ts index 40d0e57652d..06ecf2a0366 100644 --- a/src/renderer/src/components/right-sidebar/source-control-primary-action.create-pr-intent.test.ts +++ b/src/renderer/src/components/right-sidebar/source-control-primary-action.create-pr-intent.test.ts @@ -325,6 +325,57 @@ describe('resolvePrimaryAction Create PR intent', () => { }) }) + it('shows waiting feedback across PR preparation actions when another workspace is busy', () => { + const input = inputs({ + isPrIntentInFlight: true, + isRemoteOperationActive: true, + isRemoteOperationInAnotherWorktree: true, + upstreamStatus: { hasUpstream: false, ahead: 0, behind: 0 } + }) + + for (const resolveAction of [resolvePrimaryAction, resolveCreatePrHeaderAction]) { + expect(resolveAction(input)).toEqual({ + kind: 'create_pr_intent', + label: 'Git operation running elsewhere', + title: + "Another workspace is running a Git operation, such as push, pull, or force push. Wait for it to finish before using this action, so the two operations don't overlap.", + disabled: true, + isWaitingForRemoteOperation: true + }) + } + expect(resolveCommitAreaPrimaryAction(input)).toEqual({ + kind: 'publish', + label: 'Git operation running elsewhere', + title: + "Another workspace is running a Git operation, such as push, pull, or force push. Wait for it to finish before using this action, so the two operations don't overlap.", + disabled: true, + isWaitingForRemoteOperation: true + }) + }) + + it.each([ + { isRemoteOperationActive: false, isRemoteOperationInAnotherWorktree: true }, + { isRemoteOperationActive: true, isRemoteOperationInAnotherWorktree: false }, + { + isRemoteOperationActive: true, + isRemoteOperationInAnotherWorktree: true, + isCommitting: true + } + ])('keeps preparation feedback when the intent is not waiting elsewhere: %j', (busyState) => { + const input = inputs({ isPrIntentInFlight: true, ...busyState }) + const headerAction = resolveCreatePrHeaderAction(input) + expect(headerAction).toMatchObject({ + kind: 'create_pr_intent', + label: 'Create PR', + title: 'Preparing branch for review…', + disabled: true + }) + expect(headerAction?.isWaitingForRemoteOperation).toBeUndefined() + const primaryAction = resolvePrimaryAction(input) + expect(primaryAction.isWaitingForRemoteOperation).toBeUndefined() + expect(primaryAction.title).toBe('Preparing branch for review…') + }) + it.each(['azure-devops', 'gitea'] as const)( 'returns Create PR intent for a %s branch that needs a safe push before review', (provider) => { diff --git a/src/renderer/src/components/right-sidebar/source-control-primary-action.ts b/src/renderer/src/components/right-sidebar/source-control-primary-action.ts index 984bc02b50c..433cb0b516d 100644 --- a/src/renderer/src/components/right-sidebar/source-control-primary-action.ts +++ b/src/renderer/src/components/right-sidebar/source-control-primary-action.ts @@ -41,6 +41,10 @@ function toRendererPrimaryAction( decision: SourceControlPrimaryActionDecision, inputs: PrimaryActionInputs ): PrimaryAction { + const waitingAction = resolveCrossWorktreeWaitingAction(inputs, decision.kind) + if (waitingAction) { + return waitingAction + } return { kind: decision.kind, label: resolvePrimaryActionLabel(decision, inputs), @@ -49,6 +53,35 @@ function toRendererPrimaryAction( } } +export function resolveCrossWorktreeWaitingAction( + inputs: Pick< + PrimaryActionInputs, + 'isCommitting' | 'isRemoteOperationActive' | 'isRemoteOperationInAnotherWorktree' + >, + kind: PrimaryAction['kind'] +): PrimaryAction | null { + if ( + inputs.isRemoteOperationActive && + inputs.isRemoteOperationInAnotherWorktree && + !inputs.isCommitting + ) { + return { + kind, + label: translate( + 'settings.sourceControl.gitOperationInAnotherWorkspace', + 'Git operation running elsewhere' + ), + title: translate( + 'settings.sourceControl.remoteOperationInAnotherWorkspace', + "Another workspace is running a Git operation, such as push, pull, or force push. Wait for it to finish before using this action, so the two operations don't overlap." + ), + disabled: true, + isWaitingForRemoteOperation: true + } + } + return null +} + function resolvePrimaryActionLabel( decision: SourceControlPrimaryActionDecision, inputs: PrimaryActionInputs diff --git a/src/renderer/src/components/right-sidebar/source-control/ai/use-ai.operation-recovery.test.tsx b/src/renderer/src/components/right-sidebar/source-control/ai/use-ai.operation-recovery.test.tsx index 6d8a3d746f8..ae9b7762b11 100644 --- a/src/renderer/src/components/right-sidebar/source-control/ai/use-ai.operation-recovery.test.tsx +++ b/src/renderer/src/components/right-sidebar/source-control/ai/use-ai.operation-recovery.test.tsx @@ -198,7 +198,7 @@ describe('AI operation recovery composer', () => { ) it('opens while an unrelated workspace fetch is pending', async () => { const { result } = renderHook(() => useSourceControlAi(controllerParams())) - useAppStore.getState().beginRemoteOperation('fetch') + useAppStore.getState().beginRemoteOperation('fetch', 'wt-2') await act(() => result.current.handleResolveConflictsWithAI()) expect(result.current.resolveConflictsComposerOpen).toBe(true) expect(mutationInFlight).toHaveBeenCalledWith({ diff --git a/src/renderer/src/components/right-sidebar/source-control/commit/commit-action-menu.tsx b/src/renderer/src/components/right-sidebar/source-control/commit/commit-action-menu.tsx index f474a4e28a1..829640176a6 100644 --- a/src/renderer/src/components/right-sidebar/source-control/commit/commit-action-menu.tsx +++ b/src/renderer/src/components/right-sidebar/source-control/commit/commit-action-menu.tsx @@ -31,10 +31,10 @@ export function CommitActionMenu({ }): React.JSX.Element { return ( // Keep action and chevron together so edit/commit/push stays in one vertical band. -
-
+
+
- + diff --git a/src/renderer/src/components/right-sidebar/source-control/commit/commit-area.fixture.tsx b/src/renderer/src/components/right-sidebar/source-control/commit/commit-area.fixture.tsx new file mode 100644 index 00000000000..ec6181dc5f5 --- /dev/null +++ b/src/renderer/src/components/right-sidebar/source-control/commit/commit-area.fixture.tsx @@ -0,0 +1,85 @@ +import { defineFixture } from '../../../../component-fixtures/component-fixture' +import { CommitArea } from './commit-area' +import { resolveCommitAreaPrimaryAction } from '../../source-control-primary-action' + +function PublishState({ anotherWorkspace }: { anotherWorkspace: boolean }) { + const primaryAction = resolveCommitAreaPrimaryAction({ + stagedCount: 0, + hasUnstagedChanges: false, + hasStageableChanges: false, + hasPartiallyStagedChanges: false, + hasMessage: false, + hasUnresolvedConflicts: false, + isCommitting: false, + isRemoteOperationActive: true, + isRemoteOperationInAnotherWorktree: anotherWorkspace, + inFlightRemoteOpKind: anotherWorkspace ? null : 'publish', + upstreamStatus: { hasUpstream: false, ahead: 0, behind: 0 } + }) + return ( + {}} + onGenerate={() => {}} + onCancelGenerate={() => {}} + onFixCommitFailureWithAI={() => false} + onFixPushFailureWithAI={() => false} + onPrimaryAction={() => {}} + onDropdownAction={() => {}} + /> + ) +} + +export const anotherWorkspacePublishing = defineFixture({ + width: 310, + render: () => +}) + +export const thisWorkspacePublishing = defineFixture({ + width: 310, + render: () => +}) + +export const anotherWorkspacePublishingTooltip = defineFixture({ + width: 310, + render: () => , + interact: (frame) => { + frame.querySelector('span[tabindex="0"]')?.focus() + } +}) + +export const narrowAnotherWorkspacePublishing = defineFixture({ + ...anotherWorkspacePublishing, + width: 220, + interact: (frame) => { + const container = frame.querySelector('.px-3') + if (container && container.scrollWidth > container.clientWidth) { + throw new Error('Commit actions overflow the minimum sidebar width') + } + } +}) + +export const narrowAnotherWorkspacePublishingTooltip = defineFixture({ + ...anotherWorkspacePublishingTooltip, + width: 220 +}) diff --git a/src/renderer/src/components/right-sidebar/source-control/commit/commit-area.tsx b/src/renderer/src/components/right-sidebar/source-control/commit/commit-area.tsx index 017c5afb308..73d04b7e9df 100644 --- a/src/renderer/src/components/right-sidebar/source-control/commit/commit-area.tsx +++ b/src/renderer/src/components/right-sidebar/source-control/commit/commit-area.tsx @@ -88,10 +88,14 @@ export function CommitArea({ ? isCreatingPr : primaryAction.kind === 'commit' ? isCommitting - : isRemoteOperationActive && primaryHostsRemoteOperation + : isRemoteOperationActive && + primaryHostsRemoteOperation && + !primaryAction.isWaitingForRemoteOperation // Spin the chevron for operations absent from the primary; otherwise no-op Fetch has no immediate feedback. const showChevronSpinner = - (isCommitting || isCreatingPr || isRemoteOperationActive) && !showSpinner + (isCommitting || isCreatingPr || isRemoteOperationActive) && + !showSpinner && + !primaryAction.isWaitingForRemoteOperation const commitFailureSummary = useMemo( () => (commitError ? summarizeCommitFailure(commitError) : null), [commitError] diff --git a/src/renderer/src/components/right-sidebar/source-control/listing/use-worktree-context.ts b/src/renderer/src/components/right-sidebar/source-control/listing/use-worktree-context.ts index 1d86364fcd3..1be6a8897ee 100644 --- a/src/renderer/src/components/right-sidebar/source-control/listing/use-worktree-context.ts +++ b/src/renderer/src/components/right-sidebar/source-control/listing/use-worktree-context.ts @@ -71,7 +71,13 @@ export function useSourceControlWorktreeContext() { activeWorktreeId ? s.remoteStatusesByWorktree[activeWorktreeId] : undefined ) const isRemoteOperationActive = useAppStore((s) => s.isRemoteOperationActive) - const inFlightRemoteOpKind = useAppStore((s) => s.inFlightRemoteOpKind) + const inFlightRemoteOpKind = useAppStore( + (s) => + s.remoteOperations.findLast((operation) => operation.worktreeId === activeWorktreeId)?.kind ?? + null + ) + const isRemoteOperationInAnotherWorktree = + isRemoteOperationActive && inFlightRemoteOpKind === null const settings = useAppStore((s) => s.settings) const hostedReviewCacheKey = activeRepo && branchName @@ -164,6 +170,7 @@ export function useSourceControlWorktreeContext() { hostedReviewEntry, hostedReviewEntryData, inFlightRemoteOpKind, + isRemoteOperationInAnotherWorktree, isBranchVisible, isFolder, isRemoteOperationActive, diff --git a/src/renderer/src/components/right-sidebar/source-control/panel/use-panel-model.ts b/src/renderer/src/components/right-sidebar/source-control/panel/use-panel-model.ts index ac62f2dd34e..e17093e0a9d 100644 --- a/src/renderer/src/components/right-sidebar/source-control/panel/use-panel-model.ts +++ b/src/renderer/src/components/right-sidebar/source-control/panel/use-panel-model.ts @@ -44,6 +44,7 @@ export function useSourceControlPanelModel() { hostedReviewCreationForHeader, hostedReviewStateForActions, inFlightRemoteOpKind, + isRemoteOperationInAnotherWorktree, isAbortingOperation, isBranchVisible, isCommitting, @@ -86,6 +87,7 @@ export function useSourceControlPanelModel() { hostedReviewStateForActions, isHostedReviewStateLoading, inFlightRemoteOpKind, + isRemoteOperationInAnotherWorktree, hostedReviewCreation, branchSummary, branchName, diff --git a/src/renderer/src/components/right-sidebar/source-control/review/primary-create-pr-intent-action.ts b/src/renderer/src/components/right-sidebar/source-control/review/primary-create-pr-intent-action.ts index 7ab2746ac7f..b78a9ac267f 100644 --- a/src/renderer/src/components/right-sidebar/source-control/review/primary-create-pr-intent-action.ts +++ b/src/renderer/src/components/right-sidebar/source-control/review/primary-create-pr-intent-action.ts @@ -10,6 +10,7 @@ import type { HostedReviewProvider } from '../../../../../../shared/hosted-review' import type { PrimaryAction, PrimaryActionInputs } from '../../source-control-primary-action-types' +import { resolveCrossWorktreeWaitingAction } from '../../source-control-primary-action' import { resolveCreatePrIntentEligibility } from './create-pr-intent-state' import { canClickBlockedCreateReviewReason, @@ -197,25 +198,28 @@ export function resolveDisabledCreatePrHeaderAction( } export function resolveCreatePrIntentInFlightPrimaryAction( - inputs?: Pick + inputs?: PrimaryActionInputs ): PrimaryAction { + const waitingAction = inputs && resolveCrossWorktreeWaitingAction(inputs, 'create_pr_intent') const copy = localizedHostedReviewCopy( resolveSupportedHostedReviewCopyProvider(inputs?.hostedReviewCreation?.provider) ) - return { - kind: 'create_pr_intent', - label: translate( - 'auto.components.right.sidebar.source.control.primary.action.e7ffa46946', - 'Create {{value0}}', - { value0: copy.shortLabel } - ), - title: translate( - 'auto.components.right.sidebar.source.control.primary.action.d37e68f61d', - 'Preparing branch for review…' - ), - disabled: true - } + return ( + waitingAction ?? { + kind: 'create_pr_intent', + label: translate( + 'auto.components.right.sidebar.source.control.primary.action.e7ffa46946', + 'Create {{value0}}', + { value0: copy.shortLabel } + ), + title: translate( + 'auto.components.right.sidebar.source.control.primary.action.d37e68f61d', + 'Preparing branch for review…' + ), + disabled: true + } + ) } export function resolveCreatePrIntentPrimaryAction( diff --git a/src/renderer/src/components/right-sidebar/source-control/review/use-action-model.ts b/src/renderer/src/components/right-sidebar/source-control/review/use-action-model.ts index d1cfced9f0e..315004a9470 100644 --- a/src/renderer/src/components/right-sidebar/source-control/review/use-action-model.ts +++ b/src/renderer/src/components/right-sidebar/source-control/review/use-action-model.ts @@ -24,6 +24,7 @@ export function useSourceControlActionModel({ hostedReviewStateForActions, isHostedReviewStateLoading, inFlightRemoteOpKind, + isRemoteOperationInAnotherWorktree, hostedReviewCreation, branchSummary, branchName, @@ -49,6 +50,7 @@ export function useSourceControlActionModel({ remoteStatusForActions: PrimaryInput['upstreamStatus'] hostedReviewStateForActions: PrimaryInput['prState'] isHostedReviewStateLoading: boolean + isRemoteOperationInAnotherWorktree: boolean inFlightRemoteOpKind: PrimaryInput['inFlightRemoteOpKind'] hostedReviewCreation: PrimaryInput['hostedReviewCreation'] branchSummary: GitBranchCompareSummary | null @@ -101,6 +103,7 @@ export function useSourceControlActionModel({ prState: hostedReviewStateForActions, isPRStateLoading: isHostedReviewStateLoading, inFlightRemoteOpKind, + isRemoteOperationInAnotherWorktree, hostedReviewCreation: createReviewEligibility, branchCommitsAhead: branchSummary?.status === 'ready' ? (branchSummary.commitsAhead ?? 0) : undefined, @@ -118,6 +121,7 @@ export function useSourceControlActionModel({ isAbortingOperation, isRemoteOperationActive, inFlightRemoteOpKind, + isRemoteOperationInAnotherWorktree, createReviewEligibility, isHostedReviewStateLoading, hostedReviewStateForActions, diff --git a/src/renderer/src/i18n/locales/de.json b/src/renderer/src/i18n/locales/de.json index 961b5b5c784..79754c3664a 100644 --- a/src/renderer/src/i18n/locales/de.json +++ b/src/renderer/src/i18n/locales/de.json @@ -844,6 +844,8 @@ "claudeRemoveFolder": "Orca löscht den Claude-Ordner dieses Kontos und dessen Anmeldung von diesem Computer. Der mit „Systemstandard“ geteilte Chat-Verlauf bleibt erhalten. Falls dieses Konto ausgewählt ist, verwendet der nächste Claude-Start „Systemstandard“." }, "sourceControl": { + "gitOperationInAnotherWorkspace": "Git-Vorgang läuft anderswo", + "remoteOperationInAnotherWorkspace": "In einem anderen Arbeitsbereich läuft ein Git-Vorgang, etwa Push, Pull oder erzwungener Push. Warte, bis er abgeschlossen ist, bevor du diese Aktion verwendest, damit sich die Vorgänge nicht überschneiden.", "actionModel": { "on": "Ein", "off": "Aus", diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 5d3f579b4c6..430875b99ba 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -916,6 +916,8 @@ "claudeRemoveFolder": "Orca deletes this account's Claude folder and its sign-in from this computer. Chat history shared with System default stays. If it is selected, the next Claude you start uses System default." }, "sourceControl": { + "gitOperationInAnotherWorkspace": "Git operation running elsewhere", + "remoteOperationInAnotherWorkspace": "Another workspace is running a Git operation, such as push, pull, or force push. Wait for it to finish before using this action, so the two operations don't overlap.", "actionModel": { "on": "On", "off": "Off", diff --git a/src/renderer/src/i18n/locales/es.json b/src/renderer/src/i18n/locales/es.json index 52a9dda97c4..58d301cc497 100644 --- a/src/renderer/src/i18n/locales/es.json +++ b/src/renderer/src/i18n/locales/es.json @@ -412,6 +412,8 @@ "claudeRemoveFolder": "Orca elimina la carpeta de Claude de esta cuenta y su inicio de sesión de este equipo. El historial de chat compartido con Predeterminado del sistema se conserva. Si está seleccionada, el próximo Claude que inicies usará Predeterminado del sistema." }, "sourceControl": { + "gitOperationInAnotherWorkspace": "Operación de Git en otro lugar", + "remoteOperationInAnotherWorkspace": "Otro espacio de trabajo está ejecutando una operación de Git, como push, pull o force push. Espera a que termine antes de usar esta acción para que las operaciones no se solapen.", "actionModel": { "on": "Activado", "off": "Desactivado", diff --git a/src/renderer/src/i18n/locales/fr.json b/src/renderer/src/i18n/locales/fr.json index b4a9c6cd458..36e3496ee19 100644 --- a/src/renderer/src/i18n/locales/fr.json +++ b/src/renderer/src/i18n/locales/fr.json @@ -632,6 +632,8 @@ "claudeRemoveFolder": "Orca supprime le dossier Claude de ce compte et sa connexion de cet ordinateur. L'historique de chat partagé avec Système par défaut est conservé. S'il est sélectionné, le prochain Claude que vous démarrez utilise Système par défaut." }, "sourceControl": { + "gitOperationInAnotherWorkspace": "Opération Git en cours ailleurs", + "remoteOperationInAnotherWorkspace": "Un autre espace de travail exécute une opération Git, par exemple un push, un pull ou un force push. Attendez qu’elle se termine avant d’utiliser cette action pour éviter des opérations simultanées.", "actionModel": { "on": "Activé", "off": "Désactivé", diff --git a/src/renderer/src/i18n/locales/ja.json b/src/renderer/src/i18n/locales/ja.json index 87103e82f0c..a258fccf34d 100644 --- a/src/renderer/src/i18n/locales/ja.json +++ b/src/renderer/src/i18n/locales/ja.json @@ -407,6 +407,8 @@ "claudeRemoveFolder": "Orca はこのアカウントの Claude フォルダーとサインイン情報をこのコンピュータから削除します。システムのデフォルトと共有しているチャット履歴は残ります。このアカウントが選択されている場合、次に起動する Claude はシステムのデフォルトを使用します。" }, "sourceControl": { + "gitOperationInAnotherWorkspace": "他の場所で Git 操作を実行中", + "remoteOperationInAnotherWorkspace": "別のワークスペースで Git 操作(プッシュ、プル、フォースプッシュなど)を実行中です。操作が重複しないよう、完了してからこのアクションを使用してください。", "actionModel": { "on": "オン", "off": "オフ", diff --git a/src/renderer/src/i18n/locales/ko.json b/src/renderer/src/i18n/locales/ko.json index bbe718cbb5a..17213da97be 100644 --- a/src/renderer/src/i18n/locales/ko.json +++ b/src/renderer/src/i18n/locales/ko.json @@ -407,6 +407,8 @@ "claudeRemoveFolder": "Orca는 이 컴퓨터에서 해당 계정의 Claude 폴더와 로그인 정보를 삭제합니다. 시스템 기본 계정과 공유하는 채팅 기록은 유지됩니다. 삭제한 계정이 선택되어 있었다면, 다음에 시작하는 Claude는 시스템 기본 계정을 사용합니다." }, "sourceControl": { + "gitOperationInAnotherWorkspace": "다른 곳에서 Git 작업 실행 중", + "remoteOperationInAnotherWorkspace": "다른 워크스페이스에서 Git 작업(푸시, 풀, 강제 푸시 등)을 실행 중입니다. 작업이 겹치지 않도록 완료된 후 이 작업을 사용하세요.", "actionModel": { "on": "켜짐", "off": "꺼짐", diff --git a/src/renderer/src/i18n/locales/pt.json b/src/renderer/src/i18n/locales/pt.json index 114563ae077..1c8c1394cac 100644 --- a/src/renderer/src/i18n/locales/pt.json +++ b/src/renderer/src/i18n/locales/pt.json @@ -1596,6 +1596,8 @@ "claudeRemoveFolder": "O Orca exclui deste computador a pasta do Claude desta conta e seu login. O histórico de chat compartilhado com Padrão do sistema é mantido. Se esta conta estiver selecionada, o próximo Claude que você iniciar usará Padrão do sistema." }, "sourceControl": { + "gitOperationInAnotherWorkspace": "Operação do Git em outro lugar", + "remoteOperationInAnotherWorkspace": "Outro espaço de trabalho está executando uma operação do Git, como push, pull ou force push. Aguarde a conclusão antes de usar esta ação para que as operações não se sobreponham.", "actionModel": { "on": "Ativado", "off": "Desativado", diff --git a/src/renderer/src/i18n/locales/ru.json b/src/renderer/src/i18n/locales/ru.json index 7cc72a2e955..616030e7a48 100644 --- a/src/renderer/src/i18n/locales/ru.json +++ b/src/renderer/src/i18n/locales/ru.json @@ -900,6 +900,8 @@ "claudeRemoveFolder": "Orca удалит с этого компьютера папку Claude и данные входа этой учётной записи. История чатов, общая с системной учётной записью по умолчанию, сохранится. Если выбрана эта учётная запись, следующий запуск Claude использует системную учётную запись по умолчанию." }, "sourceControl": { + "gitOperationInAnotherWorkspace": "Операция Git идёт в другом месте", + "remoteOperationInAnotherWorkspace": "В другом рабочем пространстве выполняется операция Git, например отправка, получение или принудительная отправка. Дождитесь её завершения, прежде чем использовать это действие, чтобы операции не пересекались.", "actionModel": { "on": "Включено", "off": "Выключено", diff --git a/src/renderer/src/i18n/locales/tr.json b/src/renderer/src/i18n/locales/tr.json index 1bdcd01c34b..bf1d7a2ef84 100644 --- a/src/renderer/src/i18n/locales/tr.json +++ b/src/renderer/src/i18n/locales/tr.json @@ -836,6 +836,8 @@ "claudeRemoveFolder": "Orca, bu hesabın Claude klasörünü ve oturum açma bilgilerini bu bilgisayardan siler. Sistem varsayılanı ile paylaşılan sohbet geçmişi korunur. Bu hesap seçiliyse bir sonraki Claude başlatılışında Sistem varsayılanı kullanılır." }, "sourceControl": { + "gitOperationInAnotherWorkspace": "Git işlemi başka yerde çalışıyor", + "remoteOperationInAnotherWorkspace": "Başka bir çalışma alanında Git işlemi (push, pull veya force push gibi) çalışıyor. İşlemlerin çakışmaması için bitmesini bekleyip bu eylemi kullanın.", "actionModel": { "on": "Açık", "off": "Kapalı", diff --git a/src/renderer/src/i18n/locales/zh-Hant.json b/src/renderer/src/i18n/locales/zh-Hant.json index 72a29374af0..20480715562 100644 --- a/src/renderer/src/i18n/locales/zh-Hant.json +++ b/src/renderer/src/i18n/locales/zh-Hant.json @@ -809,6 +809,8 @@ "claudeRemoveFolder": "Orca 會從這部電腦刪除此帳戶的 Claude 資料夾及其登入資訊。與系統預設共用的聊天記錄會保留。如果已選取此帳戶,您下次啟動的 Claude 將使用系統預設。" }, "sourceControl": { + "gitOperationInAnotherWorkspace": "其他工作區正在執行 Git 操作", + "remoteOperationInAnotherWorkspace": "其他工作區正在執行 Git 操作(例如推送、拉取或強制推送)。請等待其完成後再使用此動作,以免操作重疊。", "actionModel": { "on": "開啟", "off": "關閉", diff --git a/src/renderer/src/i18n/locales/zh.json b/src/renderer/src/i18n/locales/zh.json index e3450b889d5..ca4ca5e74dc 100644 --- a/src/renderer/src/i18n/locales/zh.json +++ b/src/renderer/src/i18n/locales/zh.json @@ -407,6 +407,8 @@ "claudeRemoveFolder": "Orca 会从此计算机删除此账户的 Claude 文件夹及其登录信息。与系统默认共享的聊天记录会保留。如果此账户被选中,您下次启动的 Claude 将使用系统默认。" }, "sourceControl": { + "gitOperationInAnotherWorkspace": "其他工作区正在运行 Git 操作", + "remoteOperationInAnotherWorkspace": "其他工作区正在运行 Git 操作(例如推、拉或强力推)。请等待其完成后再使用此操作,以免操作重叠。", "actionModel": { "on": "开启", "off": "关闭", diff --git a/src/renderer/src/store/slices/editor-remote-branch-actions.test.ts b/src/renderer/src/store/slices/editor-remote-branch-actions.test.ts index b1f3b37e629..c1ee945debe 100644 --- a/src/renderer/src/store/slices/editor-remote-branch-actions.test.ts +++ b/src/renderer/src/store/slices/editor-remote-branch-actions.test.ts @@ -225,7 +225,7 @@ describe('createEditorSlice remote branch actions', () => { }) ) - const pushA = store.getState().pushBranch('wt-1', '/a') + const pushA = store.getState().pushBranch('wt-1', '/a', true) // Kick microtasks so pushA has begun and flipped the flag on. await Promise.resolve() expect(store.getState().isRemoteOperationActive).toBe(true) @@ -236,16 +236,63 @@ describe('createEditorSlice remote branch actions', () => { await Promise.resolve() expect(store.getState().isRemoteOperationActive).toBe(true) + expect(store.getState().remoteOperations).toEqual([ + { worktreeId: 'wt-1', kind: 'publish' }, + { worktreeId: 'wt-2', kind: 'push' } + ]) resolveA() await pushA.catch(() => {}) + expect(store.getState().remoteOperations).toEqual([{ worktreeId: 'wt-2', kind: 'push' }]) // B is still running, so the busy flag must remain true. expect(store.getState().isRemoteOperationActive).toBe(true) resolveB() await pushB.catch(() => {}) + expect(store.getState().remoteOperations).toEqual([]) expect(store.getState().isRemoteOperationActive).toBe(false) }) + it.each(['publish', 'fetch'] as const)( + 'keeps the remaining operation when %s finishes first in the same workspace', + async (firstToFinish) => { + const store = createEditorStore() + let finishPublish: () => void = () => {} + let finishFetch: () => void = () => {} + gitPushMock.mockImplementationOnce( + () => + new Promise((resolve) => { + finishPublish = resolve + }) + ) + gitFetchMock.mockImplementationOnce( + () => + new Promise((resolve) => { + finishFetch = resolve + }) + ) + const publishing = store.getState().pushBranch('wt-1', '/repo', true) + const fetching = store.getState().fetchBranch('wt-1', '/repo') + + if (firstToFinish === 'publish') { + finishPublish() + await publishing + } else { + finishFetch() + await fetching + } + expect(store.getState().isRemoteOperationActive).toBe(true) + expect(store.getState().remoteOperations).toEqual([ + { worktreeId: 'wt-1', kind: firstToFinish === 'publish' ? 'fetch' : 'publish' } + ]) + + finishPublish() + finishFetch() + await Promise.all([publishing, fetching]) + expect(store.getState().remoteOperations).toEqual([]) + expect(store.getState().isRemoteOperationActive).toBe(false) + } + ) + it('skips the inner push when syncBranch sees ahead=0', async () => { // Require ahead>0 guard to avoid no-op push after pure fast-forward pull. const store = createEditorStore() diff --git a/src/renderer/src/store/slices/editor/actions/git-remote-push-pull.ts b/src/renderer/src/store/slices/editor/actions/git-remote-push-pull.ts index d254f6b6ccb..e995bbb772d 100644 --- a/src/renderer/src/store/slices/editor/actions/git-remote-push-pull.ts +++ b/src/renderer/src/store/slices/editor/actions/git-remote-push-pull.ts @@ -28,8 +28,9 @@ export function createGitRemotePushPull( ) => { const runtimeTarget = resolveGitOperationTarget(get(), worktreeId, options) // Refresh upstream without awaiting so compound flows stay fast while button labels update before the 3s poll. - get().beginRemoteOperation( - publish ? 'publish' : options.forceWithLease === true ? 'force_push' : 'push' + const endRemoteOperation = get().beginRemoteOperation( + publish ? 'publish' : options.forceWithLease === true ? 'force_push' : 'push', + worktreeId ) let shouldRefreshAfterRejectedPush = false try { @@ -48,7 +49,7 @@ export function createGitRemotePushPull( ) throw error } finally { - get().endRemoteOperation() + endRemoteOperation() if (shouldRefreshAfterRejectedPush) { const context = { target: runtimeTarget, worktreeId, worktreePath, connectionId } // Why: the rejected push proved the branch moved; fetch first so legacy base-tracking worktrees discover origin/, then refresh ahead/behind. @@ -74,7 +75,7 @@ export function createGitRemotePushPull( }, pullBranch: async (worktreeId, worktreePath, connectionId, pushTarget, options) => { const runtimeTarget = resolveGitOperationTarget(get(), worktreeId, options) - get().beginRemoteOperation('pull') + const endRemoteOperation = get().beginRemoteOperation('pull', worktreeId) try { await pullRuntimeGit( { target: runtimeTarget, worktreeId, worktreePath, connectionId }, @@ -84,7 +85,7 @@ export function createGitRemotePushPull( toast.error(resolveRemoteOperationErrorMessage(error)) throw error } finally { - get().endRemoteOperation() + endRemoteOperation() } void get().fetchUpstreamStatus(worktreeId, worktreePath, connectionId, pushTarget, { runtimeTarget @@ -99,7 +100,7 @@ export function createGitRemotePushPull( }, fastForwardBranch: async (worktreeId, worktreePath, connectionId, pushTarget, options) => { const runtimeTarget = resolveGitOperationTarget(get(), worktreeId, options) - get().beginRemoteOperation('fast_forward') + const endRemoteOperation = get().beginRemoteOperation('fast_forward', worktreeId) try { await fastForwardRuntimeGit( { target: runtimeTarget, worktreeId, worktreePath, connectionId }, @@ -109,7 +110,7 @@ export function createGitRemotePushPull( toast.error(resolveRemoteOperationErrorMessage(error, { isFastForward: true })) throw error } finally { - get().endRemoteOperation() + endRemoteOperation() } void get().fetchUpstreamStatus(worktreeId, worktreePath, connectionId, pushTarget, { runtimeTarget diff --git a/src/renderer/src/store/slices/editor/actions/git-remote-status.ts b/src/renderer/src/store/slices/editor/actions/git-remote-status.ts index 988aa078248..50051be523f 100644 --- a/src/renderer/src/store/slices/editor/actions/git-remote-status.ts +++ b/src/renderer/src/store/slices/editor/actions/git-remote-status.ts @@ -13,10 +13,8 @@ export function createGitRemoteStatus( | 'remoteStatusesByWorktree' | 'setUpstreamStatus' | 'isRemoteOperationActive' - | 'remoteOperationDepth' - | 'inFlightRemoteOpKind' + | 'remoteOperations' | 'beginRemoteOperation' - | 'endRemoteOperation' | 'fetchUpstreamStatus' > { return { @@ -34,25 +32,19 @@ export function createGitRemoteStatus( } }), isRemoteOperationActive: false, - remoteOperationDepth: 0, - inFlightRemoteOpKind: null, - beginRemoteOperation: (kind) => + remoteOperations: [], + beginRemoteOperation: (kind, worktreeId) => { + const operation = { kind, worktreeId } set((s) => ({ - remoteOperationDepth: s.remoteOperationDepth + 1, - isRemoteOperationActive: true, - // Why: last-write-wins on the kind; the UI blocks a second user-initiated op, so the most recent kind matches what the user is watching. - inFlightRemoteOpKind: kind ?? s.inFlightRemoteOpKind - })), - endRemoteOperation: () => - set((s) => { - const next = Math.max(0, s.remoteOperationDepth - 1) - return { - remoteOperationDepth: next, - isRemoteOperationActive: next > 0, - // Why: keep the in-flight kind (its label/spinner) until depth reaches 0 and no remote op remains. - inFlightRemoteOpKind: next > 0 ? s.inFlightRemoteOpKind : null - } - }), + remoteOperations: [...s.remoteOperations, operation], + isRemoteOperationActive: true + })) + return () => + set((s) => { + const remoteOperations = s.remoteOperations.filter((entry) => entry !== operation) + return { remoteOperations, isRemoteOperationActive: remoteOperations.length > 0 } + }) + }, fetchUpstreamStatus: async (worktreeId, worktreePath, connectionId, pushTarget, options) => { const runtimeTarget = tryResolveGitOperationTarget(get(), worktreeId, options) if (!runtimeTarget) { diff --git a/src/renderer/src/store/slices/editor/actions/git-remote-sync.ts b/src/renderer/src/store/slices/editor/actions/git-remote-sync.ts index cb5ca399218..4c684969495 100644 --- a/src/renderer/src/store/slices/editor/actions/git-remote-sync.ts +++ b/src/renderer/src/store/slices/editor/actions/git-remote-sync.ts @@ -23,7 +23,7 @@ export function createGitRemoteSync( syncBranch: async (worktreeId, worktreePath, connectionId, pushTarget, options) => { const runtimeTarget = resolveGitOperationTarget(get(), worktreeId, options) // Why: like pushBranch — fire-and-forget the post-op upstream refresh so the primary button label rotates immediately. - get().beginRemoteOperation('sync') + const endRemoteOperation = get().beginRemoteOperation('sync', worktreeId) // Why: the inner push stage toasts as Sync and marks the error so the outer catch skips toasting, avoiding a double-toast. let pushStageToastShown = false let pushed = false @@ -73,7 +73,7 @@ export function createGitRemoteSync( } throw error } finally { - get().endRemoteOperation() + endRemoteOperation() } void get().fetchUpstreamStatus(worktreeId, worktreePath, connectionId, pushTarget, { runtimeTarget @@ -97,7 +97,7 @@ export function createGitRemoteSync( options ) => { const runtimeTarget = resolveGitOperationTarget(get(), worktreeId, options) - get().beginRemoteOperation('rebase') + const endRemoteOperation = get().beginRemoteOperation('rebase', worktreeId) try { await rebaseRuntimeGitFromBase( { target: runtimeTarget, worktreeId, worktreePath, connectionId }, @@ -107,7 +107,7 @@ export function createGitRemoteSync( toast.error(resolveRemoteOperationErrorMessage(error, { isRebase: true })) throw error } finally { - get().endRemoteOperation() + endRemoteOperation() } void get().fetchUpstreamStatus(worktreeId, worktreePath, connectionId, pushTarget, { runtimeTarget @@ -123,7 +123,7 @@ export function createGitRemoteSync( fetchBranch: async (worktreeId, worktreePath, connectionId, pushTarget, options) => { const runtimeTarget = resolveGitOperationTarget(get(), worktreeId, options) // Why: like pushBranch — fire-and-forget the upstream refresh after the busy flag clears so new ahead/behind counts surface. - get().beginRemoteOperation('fetch') + const endRemoteOperation = get().beginRemoteOperation('fetch', worktreeId) try { await fetchRuntimeGit( { target: runtimeTarget, worktreeId, worktreePath, connectionId }, @@ -133,7 +133,7 @@ export function createGitRemoteSync( toast.error(resolveRemoteOperationErrorMessage(error, { isFetch: true })) throw error } finally { - get().endRemoteOperation() + endRemoteOperation() } void get().fetchUpstreamStatus(worktreeId, worktreePath, connectionId, pushTarget, { runtimeTarget diff --git a/src/renderer/src/store/slices/editor/types/editor-git-slice.ts b/src/renderer/src/store/slices/editor/types/editor-git-slice.ts index 12c549e2d5f..b2e05f845b4 100644 --- a/src/renderer/src/store/slices/editor/types/editor-git-slice.ts +++ b/src/renderer/src/store/slices/editor/types/editor-git-slice.ts @@ -39,13 +39,9 @@ export type EditorGitSlice = { setConflictOperation: (worktreeId: string, operation: GitConflictOperation) => void remoteStatusesByWorktree: Record setUpstreamStatus: (worktreeId: string, status: GitUpstreamStatus) => void - // Why: refcount-backed busy flag; a bare boolean races across worktrees (A finishing re-enables B mid-flight). begin/end must be paired. isRemoteOperationActive: boolean - remoteOperationDepth: number - // Why: which remote op the user triggered, so the primary button mirrors its label+spinner; cleared at depth 0. - inFlightRemoteOpKind: RemoteOpKind | null - beginRemoteOperation: (kind?: RemoteOpKind) => void - endRemoteOperation: () => void + remoteOperations: { worktreeId: string; kind: RemoteOpKind }[] + beginRemoteOperation: (kind: RemoteOpKind, worktreeId: string) => () => void fetchUpstreamStatus: ( worktreeId: string, worktreePath: string, diff --git a/src/renderer/src/store/slices/github-post-operation-owner.test.ts b/src/renderer/src/store/slices/github-post-operation-owner.test.ts index 305977e99f6..aad24a1f67d 100644 --- a/src/renderer/src/store/slices/github-post-operation-owner.test.ts +++ b/src/renderer/src/store/slices/github-post-operation-owner.test.ts @@ -82,8 +82,7 @@ describe('post-operation review refresh ownership', () => { const twinEntry = { data: makePR({ number: 11 }), fetchedAt: Date.now() } store.setState({ ...createGitRemotePushPull(store.setState, store.getState), - beginRemoteOperation: vi.fn(), - endRemoteOperation: vi.fn(), + beginRemoteOperation: vi.fn(() => vi.fn()), fetchUpstreamStatus: vi.fn().mockResolvedValue(undefined), repos: [direct, paired], worktreesByRepo: { @@ -164,13 +163,12 @@ describe('post-operation review refresh ownership', () => { store.setState({ ...createGitRemotePushPull(store.setState, store.getState), ...createGitRemoteSync(store.setState, store.getState), - beginRemoteOperation: vi.fn(), - endRemoteOperation: vi.fn(), + beginRemoteOperation: vi.fn(() => vi.fn()), fetchUpstreamStatus: vi.fn().mockResolvedValue(undefined), repos: [twin, owner], worktreesByRepo: { [repo.id]: [{ ...worktree, hostId: twinHost }, worktree] }, activeWorktreeId: worktree.id, - activeWorkspaceExecutionHostId: worktree.hostId, + activeWorkspaceExecutionHostId: paired ? 'ssh:builder' : hostId, sshConnectionStates: new Map([ [ 'builder', diff --git a/tests/e2e/source-control-operation-recovery.spec.ts b/tests/e2e/source-control-operation-recovery.spec.ts index c43cf7e2d1f..1e325d21be0 100644 --- a/tests/e2e/source-control-operation-recovery.spec.ts +++ b/tests/e2e/source-control-operation-recovery.spec.ts @@ -86,7 +86,7 @@ test('offers Resolve with AI for a paused rebase with no unmerged files', async }, ensureDetectedAgents: async () => [] }) - state.beginRemoteOperation('fetch') + state.beginRemoteOperation('fetch', 'unrelated-workspace') }) const resolve = orcaPage.getByRole('button', { name: 'Resolve with AI', exact: true })