Skip to content

armgit / orca

Public Imported from GitHub
0

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.

1.5 KB
Raw Blame
import type {
  SourceControlPrimaryActionDecision,
  SourceControlPrimaryActionDecisionInputs
} from './source-control-primary-action-decision-types'

export function resolveSourceControlPrimaryActionDuringRemoteOp(
  inputs: SourceControlPrimaryActionDecisionInputs,
  resolveWithoutRemoteOp: (
    inputs: SourceControlPrimaryActionDecisionInputs
  ) => SourceControlPrimaryActionDecision
): SourceControlPrimaryActionDecision {
  const { inFlightRemoteOpKind, hasUnresolvedConflicts } = inputs
  const candidate = resolveWithoutRemoteOp({ ...inputs, isRemoteOperationActive: false })
  const inFlightIsPrimaryKind =
    inFlightRemoteOpKind === 'push' ||
    inFlightRemoteOpKind === 'pull' ||
    inFlightRemoteOpKind === 'sync' ||
    inFlightRemoteOpKind === 'publish'

  if (inFlightRemoteOpKind === 'force_push') {
    return {
      kind: 'push',
      labelIntent: 'force_push',
      titleIntent: 'force_push_in_progress',
      disabled: true,
      requiresForceWithLease: true
    }
  }

  if (inFlightIsPrimaryKind && candidate.kind !== inFlightRemoteOpKind) {
    return {
      kind: inFlightRemoteOpKind,
      labelIntent: inFlightRemoteOpKind,
      titleIntent: 'action_in_progress',
      disabled: true
    }
  }

  const titleIntent = hasUnresolvedConflicts
    ? 'resolve_conflicts_before_commit'
    : candidate.kind === 'commit'
      ? 'remote_operation_blocks_commit'
      : 'remote_operation_in_progress'

  return {
    ...candidate,
    titleIntent,
    disabled: true
  }
}