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(git): stop stale conflict batches after hide or cleanup (#35682)
OrcaWin8d4e61912c0a
diff --git a/src/renderer/src/components/right-sidebar/stale-conflict-operation-poll.test.tsx b/src/renderer/src/components/right-sidebar/stale-conflict-operation-poll.test.tsxnew file mode 100644index 00000000000..45ab3abfa63--- /dev/null+++ b/src/renderer/src/components/right-sidebar/stale-conflict-operation-poll.test.tsx@@ -0,0 +1,79 @@+// @vitest-environment happy-dom++import { act, createElement } from 'react'+import { createRoot, type Root } from 'react-dom/client'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import type { GitConflictOperation } from '../../../../shared/git-status-types'+import { useStaleConflictOperationPolling } from './stale-conflict-operation-poll'++globalThis.IS_REACT_ACT_ENVIRONMENT = true++const request = vi.hoisted(() => vi.fn<() => Promise<GitConflictOperation>>())+vi.mock('@/runtime/runtime-git-status-client', () => ({+ getRuntimeGitConflictOperation: request+}))+vi.mock('./worktree-git-owner-target', () => ({+ getWorktreeGitOwnerTarget: () => ({ kind: 'local' })+}))+vi.mock('@/lib/connection-context', () => ({ getConnectionId: () => undefined }))++const worktrees = ['one', 'two'].map((name) => ({+ id: `repo::/repo/${name}`,+ path: `/repo/${name}`,+ repoId: 'repo'+}))+const conflictOperationByWorktree: Record<string, GitConflictOperation> = Object.fromEntries(+ worktrees.map(({ id }) => [id, 'merge'])+)+const repoMap = new Map([['repo', { kind: 'git' as const }]])+const slowTaskBackoff = { idleMultiplier: 1, changeSignalMultiplier: 1, maxIntervalMs: 300_000 }+const setConflictOperation = (): void => {}+const isConnectionReady = (): boolean => true++function HookProbe({ enabled }: { enabled: boolean }): null {+ useStaleConflictOperationPolling({+ enabled,+ activeWorktreeId: null,+ allWorktrees: worktrees,+ repoMap,+ conflictOperationByWorktree,+ setConflictOperation,+ isConnectionReady,+ slowTaskBackoff+ })+ return null+}++describe('useStaleConflictOperationPolling', () => {+ let root: Root+ let container: HTMLDivElement++ beforeEach(() => {+ vi.useFakeTimers()+ vi.spyOn(document, 'visibilityState', 'get').mockReturnValue('visible')+ request.mockReset()+ container = document.createElement('div')+ document.body.appendChild(container)+ root = createRoot(container)+ })++ afterEach(async () => {+ await act(async () => root.unmount())+ container.remove()+ vi.restoreAllMocks()+ vi.useRealTimers()+ })++ it('stops probing remaining worktrees once the effect is retired and the probe rejects', async () => {+ const pending = Promise.withResolvers<GitConflictOperation>()+ request.mockReturnValueOnce(pending.promise)+ await act(async () => root.render(createElement(HookProbe, { enabled: true })))+ expect(request).toHaveBeenCalledTimes(1)++ await act(async () => root.render(createElement(HookProbe, { enabled: false })))+ await act(async () => pending.reject(new Error('Disconnected during probe')))+ await act(async () => vi.advanceTimersByTimeAsync(10_000))++ expect(request).toHaveBeenCalledTimes(1)+ })+})diff --git a/src/renderer/src/components/right-sidebar/stale-conflict-operation-poll.ts b/src/renderer/src/components/right-sidebar/stale-conflict-operation-poll.tsindex 381130e1076..41e9aca0a1f 100644--- a/src/renderer/src/components/right-sidebar/stale-conflict-operation-poll.ts+++ b/src/renderer/src/components/right-sidebar/stale-conflict-operation-poll.ts@@ -66,6 +66,9 @@ export function useStaleConflictOperationPolling(args: {return}for (const { id, path } of staleConflictWorktrees) {+ if (!active || !isWindowVisible()) {+ return+ }try {const connectionId = getConnectionId(id) ?? undefined// Explicit SSH disconnect removes the provider; wait for reconnection before probing.